1/* 2 * Copyright (c) 2005-2007,2011-2012,2014 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 25/* 26 * libDER_config.h - platform dependent #defines and typedefs for libDER 27 * 28 */ 29 30#ifndef _LIB_DER_CONFIG_H_ 31#define _LIB_DER_CONFIG_H_ 32 33#include <stdint.h> 34#include <string.h> 35 36#ifdef __cplusplus 37extern "C" { 38#endif 39 40/* 41 * Basic data types: unsigned 8-bit integer, unsigned 32-bit integer 42 */ 43typedef uint8_t DERByte; 44typedef uint16_t DERShort; 45typedef size_t DERSize; 46 47/* 48 * Use these #defines of you have memset, memmove, and memcmp; else 49 * write your own equivalents. 50 */ 51 52#define DERMemset(ptr, c, len) memset(ptr, c, len) 53#define DERMemmove(dst, src, len) memmove(dst, src, len) 54#define DERMemcmp(b1, b2, len) memcmp(b1, b2, len) 55 56 57/*** 58 *** Compile time options to trim size of the library. 59 ***/ 60 61/* enable general DER encode */ 62#define DER_ENCODE_ENABLE 1 63 64/* enable general DER decode */ 65#define DER_DECODE_ENABLE 1 66 67#ifndef DER_MULTIBYTE_TAGS 68/* enable multibyte tag support. */ 69#define DER_MULTIBYTE_TAGS 1 70#endif 71 72#ifndef DER_TAG_SIZE 73/* Iff DER_MULTIBYTE_TAGS is 1 this is the sizeof(DERTag) in bytes. Note that 74 tags are still encoded and decoded from a minimally encoded DER 75 represantation. This value determines how big each DERItemSpecs is, we 76 choose 2 since that makes DERItemSpecs 8 bytes wide. */ 77#define DER_TAG_SIZE 2 78#endif 79 80 81/* ---------------------- Do not edit below this line ---------------------- */ 82 83/* 84 * Logical representation of a tag (the encoded representation is always in 85 * the minimal number of bytes). The top 3 bits encode class and method 86 * The remaining bits encode the tag value. To obtain smaller DERItemSpecs 87 * sizes, choose the smallest type that fits your needs. Most standard ASN.1 88 * usage only needs single byte tags, but ocasionally custom applications 89 * require a larger tag namespace. 90 */ 91#if DER_MULTIBYTE_TAGS 92 93#if DER_TAG_SIZE == 1 94typedef uint8_t DERTag; 95#elif DER_TAG_SIZE == 2 96typedef uint16_t DERTag; 97#elif DER_TAG_SIZE == 4 98typedef uint32_t DERTag; 99#elif DER_TAG_SIZE == 8 100typedef uint64_t DERTag; 101#else 102#error DER_TAG_SIZE invalid 103#endif 104 105#else /* DER_MULTIBYTE_TAGS */ 106typedef DERByte DERTag; 107#endif /* !DER_MULTIBYTE_TAGS */ 108 109#ifdef __cplusplus 110} 111#endif 112 113#endif /* _LIB_DER_CONFIG_H_ */ 114