]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_keychain/libDER/libDER/asn1Types.h
db992d79b01a0cd68b745f9c257f814be23d9498
2 * Copyright (c) 2005-2016 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
26 * asn1Types.h - ASN.1/DER #defines - strictly hard coded per the real world
30 #ifndef _ASN1_TYPES_H_
31 #define _ASN1_TYPES_H_
33 #if !defined(__WIN32__)
34 #include <sys/cdefs.h>
37 #include <libDER/libDER_config.h>
41 /* copied from libsecurity_asn1 project */
43 /* Type tag numbers */
44 #define ASN1_BOOLEAN 0x01
45 #define ASN1_INTEGER 0x02
46 #define ASN1_BIT_STRING 0x03
47 #define ASN1_OCTET_STRING 0x04
48 #define ASN1_NULL 0x05
49 #define ASN1_OBJECT_ID 0x06
50 #define ASN1_OBJECT_DESCRIPTOR 0x07
51 /* External type and instance-of type 0x08 */
52 #define ASN1_REAL 0x09
53 #define ASN1_ENUMERATED 0x0a
54 #define ASN1_EMBEDDED_PDV 0x0b
55 #define ASN1_UTF8_STRING 0x0c
59 #define ASN1_SEQUENCE 0x10
61 #define ASN1_NUMERIC_STRING 0x12
62 #define ASN1_PRINTABLE_STRING 0x13
63 #define ASN1_T61_STRING 0x14
64 #define ASN1_VIDEOTEX_STRING 0x15
65 #define ASN1_IA5_STRING 0x16
66 #define ASN1_UTC_TIME 0x17
67 #define ASN1_GENERALIZED_TIME 0x18
68 #define ASN1_GRAPHIC_STRING 0x19
69 #define ASN1_VISIBLE_STRING 0x1a
70 #define ASN1_GENERAL_STRING 0x1b
71 #define ASN1_UNIVERSAL_STRING 0x1c
73 #define ASN1_BMP_STRING 0x1e
74 #define ASN1_HIGH_TAG_NUMBER 0x1f
75 #define ASN1_TELETEX_STRING ASN1_T61_STRING
78 #define ASN1_TAG_MASK ((DERTag)~0)
79 #define ASN1_TAGNUM_MASK ((DERTag)~((DERTag)7 << (sizeof(DERTag) * 8 - 3)))
81 #define ASN1_METHOD_MASK ((DERTag)1 << (sizeof(DERTag) * 8 - 3))
82 #define ASN1_PRIMITIVE ((DERTag)0 << (sizeof(DERTag) * 8 - 3))
83 #define ASN1_CONSTRUCTED ((DERTag)1 << (sizeof(DERTag) * 8 - 3))
85 #define ASN1_CLASS_MASK ((DERTag)3 << (sizeof(DERTag) * 8 - 2))
86 #define ASN1_UNIVERSAL ((DERTag)0 << (sizeof(DERTag) * 8 - 2))
87 #define ASN1_APPLICATION ((DERTag)1 << (sizeof(DERTag) * 8 - 2))
88 #define ASN1_CONTEXT_SPECIFIC ((DERTag)2 << (sizeof(DERTag) * 8 - 2))
89 #define ASN1_PRIVATE ((DERTag)3 << (sizeof(DERTag) * 8 - 2))
91 /* One-byte tag modifiers */
92 #define ONE_BYTE_ASN1_TAG_MASK 0xff
93 #define ONE_BYTE_ASN1_TAGNUM_MASK 0x1f
94 #define ONE_BYTE_ASN1_METHOD_MASK 0x20
95 #define ONE_BYTE_ASN1_PRIMITIVE 0x00
96 #define ONE_BYTE_ASN1_CONSTRUCTED 0x20
98 #define ONE_BYTE_ASN1_CLASS_MASK 0xc0
99 #define ONE_BYTE_ASN1_UNIVERSAL 0x00
100 #define ONE_BYTE_ASN1_APPLICATION 0x40
101 #define ONE_BYTE_ASN1_CONTEXT_SPECIFIC 0x80
102 #define ONE_BYTE_ASN1_PRIVATE 0xc0
104 /* sequence and set appear as the following */
105 #define ASN1_CONSTR_SEQUENCE ((DERTag)(ASN1_CONSTRUCTED | ASN1_SEQUENCE))
106 #define ASN1_CONSTR_SET ((DERTag)(ASN1_CONSTRUCTED | ASN1_SET))
108 #define ONE_BYTE_ASN1_CONSTR_SEQUENCE ((uint8_t)(ONE_BYTE_ASN1_CONSTRUCTED | ASN1_SEQUENCE))
109 #define ONE_BYTE_ASN1_CONSTR_SET ((uint8_t)(ONE_BYTE_ASN1_CONSTRUCTED | ASN1_SET))
113 #endif /* _ASN1_TYPES_H_ */