2 * Copyright (c) 2003-2006,2008,2010-2012 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@
23 * nameTemplates.h - ASN1 templates for X509 Name, GeneralName, etc.
26 #ifndef _NSS_NAME_TEMPLATES_H_
27 #define _NSS_NAME_TEMPLATES_H_
29 #include <Security/SecAsn1Types.h>
35 // MARK: ----- Generalized NSS_TaggedItem template chooser support -----
38 * A tagged item for use with simple CHOICE types implemented
39 * via SEC_ASN1_DYNAMIC.
47 * Type/template-specific SecAsn1TemplateChooser passes
48 * an array of these, terminated by a NSS_TagChoice with
49 * a NULL templ field, to SecAsn1TaggedTemplateChooser().
53 const SecAsn1Template
*templ
;
57 * Generalized Template chooser.
59 const SecAsn1Template
* SecAsn1TaggedTemplateChooser(
60 /* Four args passed to specific SecAsn1TemplateChooser */
61 void *arg
, // currently not used
65 /* array of tag/template pairs */
66 const NSS_TagChoice
*chooser
);
68 // MARK: ----- X509 Name, RDN ------
71 * ASN class : AttributeTypeAndValue
73 * Roughly corresponds to a CSSM_X509_TYPE_VALUE_PAIR and used
74 * in DirectoryString elements.
78 * This type and template process, via SEC_ASN1_DYNAMIC. the following
81 * SEC_ASN1_PRINTABLE_STRING
82 * SEC_ASN1_TELETEX_STRING
83 * SEC_ASN1_UNIVERSAL_STRING
84 * SEC_ASN1_UTF8_STRING
88 * Note that SEC_ASN1_IA5_STRING is not a legal part of a
89 * DirectoryString, but some certs (e.g. the Thawte serverbasic cert)
98 * ASN class : RelativeDistinguishedName
101 * Corresponds to CSSM_X509_RDN.
109 * C struct : NSS_Name
111 * Corresponds to CSSM_X509_NAME.
117 extern const SecAsn1Template kSecAsn1ATVTemplate
[];
118 extern const SecAsn1Template kSecAsn1RDNTemplate
[];
119 extern const SecAsn1Template kSecAsn1NameTemplate
[];
121 // MARK: ----- OtherName, GeneralizedName -----
124 * ASN Class : OtherName
125 * C struct : CE_OtherName
127 * CE_OtherName.value expressed as ASN_ANY, not en/decoded.
129 extern const SecAsn1Template kSecAsn1OtherNameTemplate
[];
132 * For decoding an OtherName when it's a context-specific CHOICE
135 extern const SecAsn1Template kSecAsn1GenNameOtherNameTemplate
[];
138 * ASN Class : GeneralName
139 * C struct : NSS_GeneralName, typedefd to an NSS_TaggedItem
141 * This roughly maps to a CE_GeneralName (from certextensions.h).
142 * The NSS_TaggedItem mechanism is used to resolve choices down
143 * to the SecAsn1Item level - i.e., at this level (prior to encoding
144 * or after decoding), NSS_GeneralName.item either contains a simple
145 * atomic type (IA5String, Octet string) or is raw, un{de,en}coded
148 typedef NSS_TaggedItem NSS_GeneralName
;
151 * These context-specific tag definitions, for use in
152 * NSS_GeneralName.tag, are from the ASN definition and map to
153 * CE_GeneralNameType values from certextensions.h. The values
154 * happen to be equivalent but apps should not count on that -
155 * these NSS_GeneralNameTag values are explicitly assigned per
156 * the ASN spec of a GeneralName.
158 * Shown with each tag is the simple type the tag maps to.
161 NGT_OtherName
= 0, // ASN_ANY
162 NGT_RFC822Name
= 1, // IA5String
163 NGT_DNSName
= 2, // IA5String
164 NGT_X400Address
= 3, // ASY_ANY
165 NGT_DirectoryName
= 4, // ASN_ANY
166 NGT_EdiPartyName
= 5, // ASN_ANY
167 NGT_URI
= 6, // IA5String
168 NGT_IPAddress
= 7, // OCTET_STRING
169 NGT_RegisteredID
= 8 // OID
170 } NSS_GeneralNameTag
;
172 extern const SecAsn1Template kSecAsn1GeneralNameTemplate
[];
175 * ASN Class : GeneralNames
176 * C struct : NSS_GeneralNames
178 * Since the SEC_ANY_DYNAMIC mechanism doesn't work with POINTERs
179 * or GROUPs (e.g., a sequence of NSS_GeneralName elements), decoding
180 * an NSS_GeneralNames first requires a decode to an array of
181 * ANY_ANY blobs as shown here. Use SEC_SequenceOfAnyTemplate for
182 * that step. Each of the resulting elements is individually
183 * decoded into an NSS_GeneralName.
186 SecAsn1Item
**names
; /* sequence */
189 #define kSecAsn1GeneralNamesTemplate kSecAsn1SequenceOfAnyTemplate
195 #endif /* _NSS_NAME_TEMPLATES_H_ */