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@
24 * osKeyTemplate.h - ASN1 templates for openssl asymmetric keys
27 #ifndef _OS_KEY_TEMPLATES_H_
28 #define _OS_KEY_TEMPLATES_H_
30 #include <Security/keyTemplates.h>
33 * Arrays of SecAsn1Template are always associated with a specific
34 * C struct. We attempt to use C structs which are defined in CDSA
35 * if at all possible; these always start with the CSSM_ prefix.
36 * Otherwise we define the struct here, with an NSS_ prefix.
37 * In either case, the name of the C struct is listed in comments
38 * along with the extern declaration of the SecAsn1Template array.
46 *** Note: RSA and Diffie-Hellman keys and structs are in
47 *** security_asn1/keyTemplates.h.
53 * Note that most of the DSA structs are hand rolled and are not
54 * expressed in ASN1 in any doc that I'm aware of.
62 * DSA algorithm parameters. Used in CDSA key generation context as
63 * well as the parameters in an X509-formatted DSA public key.
71 extern const SecAsn1Template kSecAsn1DSAAlgParamsTemplate
[];
74 * DSA algorithm parameters, BSAFE style. Only used in FIPS186 format
75 * public and private keys.
78 SecAsn1Item keySizeInBits
;
82 } NSS_DSAAlgParamsBSAFE
;
84 extern const SecAsn1Template kSecAsn1DSAAlgParamsBSAFETemplate
[];
87 * DSA X509-style AlgorithmID. Avoids ASN_ANY processing via direct
88 * insertion of the appropriate parameters.
92 NSS_DSAAlgParams
*params
; // optional
93 } NSS_DSAAlgorithmIdX509
;
95 extern const SecAsn1Template kSecAsn1DSAAlgorithmIdX509Template
[];
98 * DSA AlgorithmID, BSAFE style. Avoids ASN_ANY
99 * processing via direct insertion of the appropriate parameters.
102 SecAsn1Oid algorithm
;
103 NSS_DSAAlgParamsBSAFE params
;
104 } NSS_DSAAlgorithmIdBSAFE
;
106 extern const SecAsn1Template kSecAsn1DSAAlgorithmIdBSAFETemplate
[];
113 * DSA public key, openssl/X509 format.
115 * The publicKey is actually the DER encoding of an ASN
116 * integer, wrapped in a BIT STRING.
119 NSS_DSAAlgorithmIdX509 dsaAlg
;
120 SecAsn1Item publicKey
; // BIT string - Length in bits
121 } NSS_DSAPublicKeyX509
;
123 extern const SecAsn1Template kSecAsn1DSAPublicKeyX509Template
[];
126 * DSA public key, BSAFE/FIPS186 format.
127 * The public key is the DER encoding of an ASN integer, wrapped
131 NSS_DSAAlgorithmIdBSAFE dsaAlg
;
132 SecAsn1Item publicKey
; // BIT string - Length in bits
133 } NSS_DSAPublicKeyBSAFE
;
135 extern const SecAsn1Template kSecAsn1DSAPublicKeyBSAFETemplate
[];
138 **** DSA private keys
142 * DSA Private key, openssl custom format.
151 } NSS_DSAPrivateKeyOpenssl
;
153 extern const SecAsn1Template kSecAsn1DSAPrivateKeyOpensslTemplate
[];
156 * DSA private key, BSAFE/FIPS186 style.
157 * This is basically a DSA-specific NSS_PrivateKeyInfo.
159 * NSS_DSAPrivateKeyBSAFE.privateKey is an octet string containing
160 * the DER encoding of this.
163 SecAsn1Item privateKey
;
164 } NSS_DSAPrivateKeyOcts
;
166 extern const SecAsn1Template kSecAsn1DSAPrivateKeyOctsTemplate
[];
170 NSS_DSAAlgorithmIdBSAFE dsaAlg
;
171 /* octet string containing a DER-encoded NSS_DSAPrivateKeyOcts */
172 SecAsn1Item privateKey
;
173 } NSS_DSAPrivateKeyBSAFE
;
175 extern const SecAsn1Template kSecAsn1DSAPrivateKeyBSAFETemplate
[];
178 * DSA Private Key, PKCS8/SMIME style. Doesn't have keySizeInBits
179 * in the alg params; has version in the top-level struct; the
180 * private key itself is a DER-encoded integer wrapped in an
185 NSS_DSAAlgorithmIdX509 dsaAlg
;
186 /* octet string containing DER-encoded integer */
187 SecAsn1Item privateKey
;
188 NSS_Attribute
**attributes
; // optional
189 } NSS_DSAPrivateKeyPKCS8
;
191 extern const SecAsn1Template kSecAsn1DSAPrivateKeyPKCS8Template
[];
201 extern const SecAsn1Template kSecAsn1DSASignatureTemplate
[];
208 #endif /* _OS_KEY_TEMPLATES_H_ */