2 * osKeyTemplate.h - ASN1 templates for openssl asymmetric keys
5 #ifndef _OS_KEY_TEMPLATES_H_
6 #define _OS_KEY_TEMPLATES_H_
8 #include <SecurityNssAsn1/secasn1.h>
9 #include <SecurityNssAsn1/keyTemplates.h>
12 * Arrays of SEC_ASN1Templates are always associated with a specific
13 * C struct. We attempt to use C structs which are defined in CDSA
14 * if at all possible; these always start with the CSSM_ prefix.
15 * Otherwise we define the struct here, with an NSS_ prefix.
16 * In either case, the name of the C struct is listed in comments
17 * along with the extern declaration of the SEC_ASN1Template array.
25 *** Note: RSA and Diffie-Hellman keys and structs are in
26 *** SecurityNssAsn1/keyTemplates.h.
29 #pragma mark *** DSA ***
32 * Note that most of the DSA structs are hand rolled and are not
33 * expressed in ASN1 in any doc that I'm aware of.
41 * DSA algorithm parameters. Used in CDSA key generation context as
42 * well as the parameters in an X509-formatted DSA public key.
50 extern const SEC_ASN1Template NSS_DSAAlgParamsTemplate
[];
53 * DSA algorithm parameters, BSAFE style. Only used in FIPS186 format
54 * public and private keys.
57 CSSM_DATA keySizeInBits
;
61 } NSS_DSAAlgParamsBSAFE
;
63 extern const SEC_ASN1Template NSS_DSAAlgParamsBSAFETemplate
[];
66 * DSA X509-style AlgorithmID. Avoids ASN_ANY processing via direct
67 * insertion of the appropriate parameters.
71 NSS_DSAAlgParams
*params
; // optional
72 } NSS_DSAAlgorithmIdX509
;
74 extern const SEC_ASN1Template NSS_DSAAlgorithmIdX509Template
[];
77 * DSA AlgorithmID, BSAFE style. Avoids ASN_ANY
78 * processing via direct insertion of the appropriate parameters.
82 NSS_DSAAlgParamsBSAFE params
;
83 } NSS_DSAAlgorithmIdBSAFE
;
85 extern const SEC_ASN1Template NSS_DSAAlgorithmIdBSAFETemplate
[];
92 * DSA public key, openssl/X509 format.
94 * The publicKey is actually the DER encoding of an ASN
95 * integer, wrapped in a BIT STRING.
98 NSS_DSAAlgorithmIdX509 dsaAlg
;
99 CSSM_DATA publicKey
; // BIT string - Length in bits
100 } NSS_DSAPublicKeyX509
;
102 extern const SEC_ASN1Template NSS_DSAPublicKeyX509Template
[];
105 * DSA public key, BSAFE/FIPS186 format.
106 * The public key is the DER encoding of an ASN integer, wrapped
110 NSS_DSAAlgorithmIdBSAFE dsaAlg
;
111 CSSM_DATA publicKey
; // BIT string - Length in bits
112 } NSS_DSAPublicKeyBSAFE
;
114 extern const SEC_ASN1Template NSS_DSAPublicKeyBSAFETemplate
[];
117 **** DSA private keys
121 * DSA Private key, openssl custom format.
130 } NSS_DSAPrivateKeyOpenssl
;
132 extern const SEC_ASN1Template NSS_DSAPrivateKeyOpensslTemplate
[];
135 * DSA private key, BSAFE/FIPS186 style.
136 * This is basically a DSA-specific NSS_PrivateKeyInfo.
138 * NSS_DSAPrivateKeyBSAFE.privateKey is an octet string containing
139 * the DER encoding of this.
142 CSSM_DATA privateKey
;
143 } NSS_DSAPrivateKeyOcts
;
145 extern const SEC_ASN1Template NSS_DSAPrivateKeyOctsTemplate
[];
149 NSS_DSAAlgorithmIdBSAFE dsaAlg
;
150 /* octet string containing a DER-encoded NSS_DSAPrivateKeyOcts */
151 CSSM_DATA privateKey
;
152 } NSS_DSAPrivateKeyBSAFE
;
154 extern const SEC_ASN1Template NSS_DSAPrivateKeyBSAFETemplate
[];
157 * DSA Private Key, PKCS8/SMIME style. Doesn't have keySizeInBits
158 * in the alg params; has version in the top-level struct; the
159 * private key itself is a DER-encoded integer wrapped in an
164 NSS_DSAAlgorithmIdX509 dsaAlg
;
165 /* octet string containing DER-encoded integer */
166 CSSM_DATA privateKey
;
167 NSS_Attribute
**attributes
; // optional
168 } NSS_DSAPrivateKeyPKCS8
;
170 extern const SEC_ASN1Template NSS_DSAPrivateKeyPKCS8Template
[];
180 extern const SEC_ASN1Template NSS_DSASignatureTemplate
[];
187 #endif /* _OS_KEY_TEMPLATES_H_ */