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 /* Five args passed to specific SecAsn1TemplateChooser */
61 void *arg
, // currently not used
66 /* array of tag/template pairs */
67 const NSS_TagChoice
*chooser
);
69 // MARK: ----- X509 Name, RDN ------
72 * ASN class : AttributeTypeAndValue
74 * Roughly corresponds to a CSSM_X509_TYPE_VALUE_PAIR and used
75 * in DirectoryString elements.
79 * This type and template process, via SEC_ASN1_DYNAMIC. the following
82 * SEC_ASN1_PRINTABLE_STRING
83 * SEC_ASN1_TELETEX_STRING
84 * SEC_ASN1_UNIVERSAL_STRING
85 * SEC_ASN1_UTF8_STRING
89 * Note that SEC_ASN1_IA5_STRING is not a legal part of a
90 * DirectoryString, but some certs (e.g. the Thawte serverbasic cert)
99 * ASN class : RelativeDistinguishedName
102 * Corresponds to CSSM_X509_RDN.
110 * C struct : NSS_Name
112 * Corresponds to CSSM_X509_NAME.
118 extern const SecAsn1Template kSecAsn1ATVTemplate
[];
119 extern const SecAsn1Template kSecAsn1RDNTemplate
[];
120 extern const SecAsn1Template kSecAsn1NameTemplate
[];
122 // MARK: ----- OtherName, GeneralizedName -----
125 * ASN Class : OtherName
126 * C struct : CE_OtherName
128 * CE_OtherName.value expressed as ASN_ANY, not en/decoded.
130 extern const SecAsn1Template kSecAsn1OtherNameTemplate
[];
133 * For decoding an OtherName when it's a context-specific CHOICE
136 extern const SecAsn1Template kSecAsn1GenNameOtherNameTemplate
[];
139 * ASN Class : GeneralName
140 * C struct : NSS_GeneralName, typedefd to an NSS_TaggedItem
142 * This roughly maps to a CE_GeneralName (from certextensions.h).
143 * The NSS_TaggedItem mechanism is used to resolve choices down
144 * to the SecAsn1Item level - i.e., at this level (prior to encoding
145 * or after decoding), NSS_GeneralName.item either contains a simple
146 * atomic type (IA5String, Octet string) or is raw, un{de,en}coded
149 typedef NSS_TaggedItem NSS_GeneralName
;
152 * These context-specific tag definitions, for use in
153 * NSS_GeneralName.tag, are from the ASN definition and map to
154 * CE_GeneralNameType values from certextensions.h. The values
155 * happen to be equivalent but apps should not count on that -
156 * these NSS_GeneralNameTag values are explicitly assigned per
157 * the ASN spec of a GeneralName.
159 * Shown with each tag is the simple type the tag maps to.
162 NGT_OtherName
= 0, // ASN_ANY
163 NGT_RFC822Name
= 1, // IA5String
164 NGT_DNSName
= 2, // IA5String
165 NGT_X400Address
= 3, // ASY_ANY
166 NGT_DirectoryName
= 4, // ASN_ANY
167 NGT_EdiPartyName
= 5, // ASN_ANY
168 NGT_URI
= 6, // IA5String
169 NGT_IPAddress
= 7, // OCTET_STRING
170 NGT_RegisteredID
= 8 // OID
171 } NSS_GeneralNameTag
;
173 extern const SecAsn1Template kSecAsn1GeneralNameTemplate
[];
176 * ASN Class : GeneralNames
177 * C struct : NSS_GeneralNames
179 * Since the SEC_ANY_DYNAMIC mechanism doesn't work with POINTERs
180 * or GROUPs (e.g., a sequence of NSS_GeneralName elements), decoding
181 * an NSS_GeneralNames first requires a decode to an array of
182 * ANY_ANY blobs as shown here. Use SEC_SequenceOfAnyTemplate for
183 * that step. Each of the resulting elements is individually
184 * decoded into an NSS_GeneralName.
187 SecAsn1Item
**names
; /* sequence */
190 #define kSecAsn1GeneralNamesTemplate kSecAsn1SequenceOfAnyTemplate
196 #endif /* _NSS_NAME_TEMPLATES_H_ */