]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 | 1 | /* |
d8f41ccd | 2 | * Copyright (c) 2003-2006,2008,2010-2012 Apple Inc. All Rights Reserved. |
b1ab9ed8 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
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 | |
11 | * file. | |
12 | * | |
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. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* | |
24 | * osKeyTemplate.h - ASN1 templates for openssl asymmetric keys | |
25 | */ | |
26 | ||
27 | #include "osKeyTemplates.h" | |
28 | #include <stddef.h> | |
29 | ||
30 | /**** | |
31 | **** DSA support | |
32 | ****/ | |
33 | ||
34 | /* X509 style DSA algorithm parameters */ | |
35 | const SecAsn1Template kSecAsn1DSAAlgParamsTemplate[] = { | |
36 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgParams) }, | |
37 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParams,p) }, | |
38 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParams,q) }, | |
39 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParams,g) }, | |
40 | { 0, } | |
41 | }; | |
42 | ||
43 | /* BSAFE style DSA algorithm parameters */ | |
44 | const SecAsn1Template kSecAsn1DSAAlgParamsBSAFETemplate[] = { | |
45 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgParamsBSAFE) }, | |
46 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,keySizeInBits) }, | |
47 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,p) }, | |
48 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,q) }, | |
49 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAAlgParamsBSAFE,g) }, | |
50 | { 0, } | |
51 | }; | |
52 | ||
53 | /* DSA X509-style AlgorithmID */ | |
54 | const SecAsn1Template kSecAsn1DSAAlgorithmIdX509Template[] = { | |
55 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgorithmIdX509) }, | |
56 | { SEC_ASN1_OBJECT_ID, offsetof(NSS_DSAAlgorithmIdX509, algorithm) }, | |
57 | /* per CMS, this is optional */ | |
58 | { SEC_ASN1_POINTER | SEC_ASN1_OPTIONAL, | |
59 | offsetof(NSS_DSAAlgorithmIdX509,params), | |
60 | kSecAsn1DSAAlgParamsTemplate }, | |
61 | { 0, } | |
62 | }; | |
63 | ||
64 | /* DSA BSAFE-style AlgorithmID */ | |
65 | const SecAsn1Template kSecAsn1DSAAlgorithmIdBSAFETemplate[] = { | |
66 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAAlgorithmIdBSAFE) }, | |
67 | { SEC_ASN1_OBJECT_ID, offsetof(NSS_DSAAlgorithmIdBSAFE, algorithm) }, | |
68 | { SEC_ASN1_INLINE, | |
69 | offsetof(NSS_DSAAlgorithmIdBSAFE,params), | |
70 | kSecAsn1DSAAlgParamsBSAFETemplate }, | |
71 | { 0, } | |
72 | }; | |
73 | ||
74 | /**** | |
75 | **** DSA public keys | |
76 | ****/ | |
77 | ||
78 | /* DSA public key, openssl/X509 format */ | |
79 | const SecAsn1Template kSecAsn1DSAPublicKeyX509Template[] = { | |
80 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPublicKeyX509) }, | |
81 | { SEC_ASN1_INLINE, | |
82 | offsetof(NSS_DSAPublicKeyX509, dsaAlg), | |
83 | kSecAsn1DSAAlgorithmIdX509Template }, | |
84 | { SEC_ASN1_BIT_STRING, | |
85 | offsetof(NSS_DSAPublicKeyX509, publicKey), }, | |
86 | { 0, } | |
87 | }; | |
88 | ||
89 | /* DSA public key, BSAFE/FIPS186 format */ | |
90 | const SecAsn1Template kSecAsn1DSAPublicKeyBSAFETemplate[] = { | |
91 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPublicKeyBSAFE) }, | |
92 | { SEC_ASN1_INLINE, | |
93 | offsetof(NSS_DSAPublicKeyBSAFE, dsaAlg), | |
94 | kSecAsn1DSAAlgorithmIdBSAFETemplate }, | |
95 | { SEC_ASN1_BIT_STRING, | |
96 | offsetof(NSS_DSAPublicKeyBSAFE, publicKey), }, | |
97 | { 0, } | |
98 | }; | |
99 | ||
100 | /**** | |
101 | **** DSA private keys | |
102 | ****/ | |
103 | ||
104 | /* DSA Private key, openssl custom format */ | |
105 | const SecAsn1Template kSecAsn1DSAPrivateKeyOpensslTemplate[] = { | |
106 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyOpenssl) }, | |
107 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,version) }, | |
108 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,p) }, | |
109 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,q) }, | |
110 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,g) }, | |
111 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,pub) }, | |
112 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOpenssl,priv) }, | |
113 | { 0, } | |
114 | }; | |
115 | ||
116 | /* | |
117 | * DSA private key, BSAFE/FIPS186 style. | |
118 | * This is basically a DSA-specific NSS_PrivateKeyInfo. | |
119 | * | |
120 | * NSS_DSAPrivateKeyBSAFE.privateKey is an octet string containing | |
121 | * the DER encoding of this. | |
122 | */ | |
123 | const SecAsn1Template kSecAsn1DSAPrivateKeyOctsTemplate[] = { | |
124 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyOcts) }, | |
125 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyOcts,privateKey) }, | |
126 | { 0, } | |
127 | }; | |
128 | ||
129 | const SecAsn1Template kSecAsn1DSAPrivateKeyBSAFETemplate[] = { | |
130 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyBSAFE) }, | |
131 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyBSAFE,version) }, | |
132 | { SEC_ASN1_INLINE, | |
133 | offsetof(NSS_DSAPrivateKeyBSAFE, dsaAlg), | |
134 | kSecAsn1DSAAlgorithmIdBSAFETemplate }, | |
135 | { SEC_ASN1_OCTET_STRING, offsetof(NSS_DSAPrivateKeyBSAFE,privateKey) }, | |
136 | { 0, } | |
137 | }; | |
138 | ||
139 | /* | |
140 | * DSA Private Key, PKCS8/SMIME style. | |
141 | */ | |
142 | const SecAsn1Template kSecAsn1DSAPrivateKeyPKCS8Template[] = { | |
143 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSAPrivateKeyPKCS8) }, | |
144 | { SEC_ASN1_INTEGER, offsetof(NSS_DSAPrivateKeyPKCS8,version) }, | |
145 | { SEC_ASN1_INLINE, | |
146 | offsetof(NSS_DSAPrivateKeyPKCS8, dsaAlg), | |
147 | kSecAsn1DSAAlgorithmIdX509Template }, | |
148 | { SEC_ASN1_OCTET_STRING, offsetof(NSS_DSAPrivateKeyPKCS8,privateKey) }, | |
149 | { SEC_ASN1_OPTIONAL | SEC_ASN1_CONSTRUCTED | | |
150 | SEC_ASN1_CONTEXT_SPECIFIC | 0, | |
151 | offsetof(NSS_DSAPrivateKeyPKCS8,attributes), | |
152 | kSecAsn1SetOfAttributeTemplate }, | |
153 | { 0, } | |
154 | }; | |
155 | ||
156 | const SecAsn1Template kSecAsn1DSASignatureTemplate[] = { | |
157 | { SEC_ASN1_SEQUENCE, 0, NULL, sizeof(NSS_DSASignature) }, | |
158 | { SEC_ASN1_INTEGER, offsetof(NSS_DSASignature,r) }, | |
159 | { SEC_ASN1_INTEGER, offsetof(NSS_DSASignature,s) }, | |
160 | { 0, } | |
161 | }; | |
162 | ||
163 |