]>
Commit | Line | Data |
---|---|---|
df0e469f A |
1 | /* |
2 | * osKeyTemplate.h - ASN1 templates for openssl asymmetric keys | |
3 | */ | |
4 | ||
5 | #ifndef _OS_KEY_TEMPLATES_H_ | |
6 | #define _OS_KEY_TEMPLATES_H_ | |
7 | ||
8 | #include <SecurityNssAsn1/secasn1.h> | |
9 | #include <SecurityNssAsn1/keyTemplates.h> | |
10 | ||
11 | /* | |
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. | |
18 | */ | |
19 | ||
20 | #ifdef __cplusplus | |
21 | extern "C" { | |
22 | #endif | |
23 | ||
24 | /*** | |
25 | *** Note: RSA and Diffie-Hellman keys and structs are in | |
26 | *** SecurityNssAsn1/keyTemplates.h. | |
27 | ***/ | |
28 | ||
29 | #pragma mark *** DSA *** | |
30 | ||
31 | /* | |
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. | |
34 | */ | |
35 | ||
36 | /**** | |
37 | **** DSA support | |
38 | ****/ | |
39 | ||
40 | /* | |
41 | * DSA algorithm parameters. Used in CDSA key generation context as | |
42 | * well as the parameters in an X509-formatted DSA public key. | |
43 | */ | |
44 | typedef struct { | |
45 | CSSM_DATA p; | |
46 | CSSM_DATA q; | |
47 | CSSM_DATA g; | |
48 | } NSS_DSAAlgParams; | |
49 | ||
50 | extern const SEC_ASN1Template NSS_DSAAlgParamsTemplate[]; | |
51 | ||
52 | /* | |
53 | * DSA algorithm parameters, BSAFE style. Only used in FIPS186 format | |
54 | * public and private keys. | |
55 | */ | |
56 | typedef struct { | |
57 | CSSM_DATA keySizeInBits; | |
58 | CSSM_DATA p; | |
59 | CSSM_DATA q; | |
60 | CSSM_DATA g; | |
61 | } NSS_DSAAlgParamsBSAFE; | |
62 | ||
63 | extern const SEC_ASN1Template NSS_DSAAlgParamsBSAFETemplate[]; | |
64 | ||
65 | /* | |
66 | * DSA X509-style AlgorithmID. Avoids ASN_ANY processing via direct | |
67 | * insertion of the appropriate parameters. | |
68 | */ | |
69 | typedef struct { | |
70 | CSSM_OID algorithm; | |
71 | NSS_DSAAlgParams *params; // optional | |
72 | } NSS_DSAAlgorithmIdX509; | |
73 | ||
74 | extern const SEC_ASN1Template NSS_DSAAlgorithmIdX509Template[]; | |
75 | ||
76 | /* | |
77 | * DSA AlgorithmID, BSAFE style. Avoids ASN_ANY | |
78 | * processing via direct insertion of the appropriate parameters. | |
79 | */ | |
80 | typedef struct { | |
81 | CSSM_OID algorithm; | |
82 | NSS_DSAAlgParamsBSAFE params; | |
83 | } NSS_DSAAlgorithmIdBSAFE; | |
84 | ||
85 | extern const SEC_ASN1Template NSS_DSAAlgorithmIdBSAFETemplate[]; | |
86 | ||
87 | /**** | |
88 | **** DSA public keys | |
89 | ****/ | |
90 | ||
91 | /* | |
92 | * DSA public key, openssl/X509 format. | |
93 | * | |
94 | * The publicKey is actually the DER encoding of an ASN | |
95 | * integer, wrapped in a BIT STRING. | |
96 | */ | |
97 | typedef struct { | |
98 | NSS_DSAAlgorithmIdX509 dsaAlg; | |
99 | CSSM_DATA publicKey; // BIT string - Length in bits | |
100 | } NSS_DSAPublicKeyX509; | |
101 | ||
102 | extern const SEC_ASN1Template NSS_DSAPublicKeyX509Template[]; | |
103 | ||
104 | /* | |
105 | * DSA public key, BSAFE/FIPS186 format. | |
106 | * The public key is the DER encoding of an ASN integer, wrapped | |
107 | * in a bit string. | |
108 | */ | |
109 | typedef struct { | |
110 | NSS_DSAAlgorithmIdBSAFE dsaAlg; | |
111 | CSSM_DATA publicKey; // BIT string - Length in bits | |
112 | } NSS_DSAPublicKeyBSAFE; | |
113 | ||
114 | extern const SEC_ASN1Template NSS_DSAPublicKeyBSAFETemplate[]; | |
115 | ||
116 | /**** | |
117 | **** DSA private keys | |
118 | ****/ | |
119 | ||
120 | /* | |
121 | * DSA Private key, openssl custom format. | |
122 | */ | |
123 | typedef struct { | |
124 | CSSM_DATA version; | |
125 | CSSM_DATA p; | |
126 | CSSM_DATA q; | |
127 | CSSM_DATA g; | |
128 | CSSM_DATA pub; | |
129 | CSSM_DATA priv; | |
130 | } NSS_DSAPrivateKeyOpenssl; | |
131 | ||
132 | extern const SEC_ASN1Template NSS_DSAPrivateKeyOpensslTemplate[]; | |
133 | ||
134 | /* | |
135 | * DSA private key, BSAFE/FIPS186 style. | |
136 | * This is basically a DSA-specific NSS_PrivateKeyInfo. | |
137 | * | |
138 | * NSS_DSAPrivateKeyBSAFE.privateKey is an octet string containing | |
139 | * the DER encoding of this. | |
140 | */ | |
141 | typedef struct { | |
142 | CSSM_DATA privateKey; | |
143 | } NSS_DSAPrivateKeyOcts; | |
144 | ||
145 | extern const SEC_ASN1Template NSS_DSAPrivateKeyOctsTemplate[]; | |
146 | ||
147 | typedef struct { | |
148 | CSSM_DATA version; | |
149 | NSS_DSAAlgorithmIdBSAFE dsaAlg; | |
150 | /* octet string containing a DER-encoded NSS_DSAPrivateKeyOcts */ | |
151 | CSSM_DATA privateKey; | |
152 | } NSS_DSAPrivateKeyBSAFE; | |
153 | ||
154 | extern const SEC_ASN1Template NSS_DSAPrivateKeyBSAFETemplate[]; | |
155 | ||
156 | /* | |
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 | |
160 | * octet string. | |
161 | */ | |
162 | typedef struct { | |
163 | CSSM_DATA version; | |
164 | NSS_DSAAlgorithmIdX509 dsaAlg; | |
165 | /* octet string containing DER-encoded integer */ | |
166 | CSSM_DATA privateKey; | |
167 | NSS_Attribute **attributes; // optional | |
168 | } NSS_DSAPrivateKeyPKCS8; | |
169 | ||
170 | extern const SEC_ASN1Template NSS_DSAPrivateKeyPKCS8Template[]; | |
171 | ||
172 | /* | |
173 | * DSA Signature. | |
174 | */ | |
175 | typedef struct { | |
176 | CSSM_DATA r; | |
177 | CSSM_DATA s; | |
178 | } NSS_DSASignature; | |
179 | ||
180 | extern const SEC_ASN1Template NSS_DSASignatureTemplate[]; | |
181 | ||
182 | #ifdef __cplusplus | |
183 | } | |
184 | #endif | |
185 | ||
186 | ||
187 | #endif /* _OS_KEY_TEMPLATES_H_ */ |