|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 #ifndef _LOWKEYTI_H_ |
|
5 #define _LOWKEYTI_H_ 1 |
|
6 |
|
7 #include "blapit.h" |
|
8 #include "prtypes.h" |
|
9 #include "plarena.h" |
|
10 #include "secitem.h" |
|
11 #include "secasn1t.h" |
|
12 #include "secoidt.h" |
|
13 |
|
14 |
|
15 /* |
|
16 * a key in/for the data base |
|
17 */ |
|
18 struct NSSLOWKEYDBKeyStr { |
|
19 PLArenaPool *arena; |
|
20 int version; |
|
21 char *nickname; |
|
22 SECItem salt; |
|
23 SECItem derPK; |
|
24 }; |
|
25 typedef struct NSSLOWKEYDBKeyStr NSSLOWKEYDBKey; |
|
26 |
|
27 typedef struct NSSLOWKEYDBHandleStr NSSLOWKEYDBHandle; |
|
28 |
|
29 #ifdef NSS_USE_KEY4_DB |
|
30 #define NSSLOWKEY_DB_FILE_VERSION 4 |
|
31 #else |
|
32 #define NSSLOWKEY_DB_FILE_VERSION 3 |
|
33 #endif |
|
34 |
|
35 #define NSSLOWKEY_VERSION 0 /* what we *create* */ |
|
36 |
|
37 /* |
|
38 ** Typedef for callback to get a password "key". |
|
39 */ |
|
40 extern const SEC_ASN1Template lg_nsslowkey_PQGParamsTemplate[]; |
|
41 extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate[]; |
|
42 extern const SEC_ASN1Template lg_nsslowkey_RSAPrivateKeyTemplate2[]; |
|
43 extern const SEC_ASN1Template lg_nsslowkey_DSAPrivateKeyTemplate[]; |
|
44 extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyTemplate[]; |
|
45 extern const SEC_ASN1Template lg_nsslowkey_DHPrivateKeyExportTemplate[]; |
|
46 #ifndef NSS_DISABLE_ECC |
|
47 #define NSSLOWKEY_EC_PRIVATE_KEY_VERSION 1 /* as per SECG 1 C.4 */ |
|
48 extern const SEC_ASN1Template lg_nsslowkey_ECParamsTemplate[]; |
|
49 extern const SEC_ASN1Template lg_nsslowkey_ECPrivateKeyTemplate[]; |
|
50 #endif /* NSS_DISABLE_ECC */ |
|
51 |
|
52 extern const SEC_ASN1Template lg_nsslowkey_PrivateKeyInfoTemplate[]; |
|
53 extern const SEC_ASN1Template nsslowkey_EncryptedPrivateKeyInfoTemplate[]; |
|
54 |
|
55 /* |
|
56 * PKCS #8 attributes |
|
57 */ |
|
58 struct NSSLOWKEYAttributeStr { |
|
59 SECItem attrType; |
|
60 SECItem *attrValue; |
|
61 }; |
|
62 typedef struct NSSLOWKEYAttributeStr NSSLOWKEYAttribute; |
|
63 |
|
64 /* |
|
65 ** A PKCS#8 private key info object |
|
66 */ |
|
67 struct NSSLOWKEYPrivateKeyInfoStr { |
|
68 PLArenaPool *arena; |
|
69 SECItem version; |
|
70 SECAlgorithmID algorithm; |
|
71 SECItem privateKey; |
|
72 NSSLOWKEYAttribute **attributes; |
|
73 }; |
|
74 typedef struct NSSLOWKEYPrivateKeyInfoStr NSSLOWKEYPrivateKeyInfo; |
|
75 #define NSSLOWKEY_PRIVATE_KEY_INFO_VERSION 0 /* what we *create* */ |
|
76 |
|
77 /* |
|
78 ** A PKCS#8 private key info object |
|
79 */ |
|
80 struct NSSLOWKEYEncryptedPrivateKeyInfoStr { |
|
81 PLArenaPool *arena; |
|
82 SECAlgorithmID algorithm; |
|
83 SECItem encryptedData; |
|
84 }; |
|
85 typedef struct NSSLOWKEYEncryptedPrivateKeyInfoStr NSSLOWKEYEncryptedPrivateKeyInfo; |
|
86 |
|
87 |
|
88 typedef enum { |
|
89 NSSLOWKEYNullKey = 0, |
|
90 NSSLOWKEYRSAKey = 1, |
|
91 NSSLOWKEYDSAKey = 2, |
|
92 NSSLOWKEYDHKey = 4, |
|
93 NSSLOWKEYECKey = 5 |
|
94 } NSSLOWKEYType; |
|
95 |
|
96 /* |
|
97 ** An RSA public key object. |
|
98 */ |
|
99 struct NSSLOWKEYPublicKeyStr { |
|
100 PLArenaPool *arena; |
|
101 NSSLOWKEYType keyType ; |
|
102 union { |
|
103 RSAPublicKey rsa; |
|
104 DSAPublicKey dsa; |
|
105 DHPublicKey dh; |
|
106 ECPublicKey ec; |
|
107 } u; |
|
108 }; |
|
109 typedef struct NSSLOWKEYPublicKeyStr NSSLOWKEYPublicKey; |
|
110 |
|
111 /* |
|
112 ** Low Level private key object |
|
113 ** This is only used by the raw Crypto engines (crypto), keydb (keydb), |
|
114 ** and PKCS #11. Everyone else uses the high level key structure. |
|
115 */ |
|
116 struct NSSLOWKEYPrivateKeyStr { |
|
117 PLArenaPool *arena; |
|
118 NSSLOWKEYType keyType; |
|
119 union { |
|
120 RSAPrivateKey rsa; |
|
121 DSAPrivateKey dsa; |
|
122 DHPrivateKey dh; |
|
123 ECPrivateKey ec; |
|
124 } u; |
|
125 }; |
|
126 typedef struct NSSLOWKEYPrivateKeyStr NSSLOWKEYPrivateKey; |
|
127 |
|
128 |
|
129 typedef struct NSSLOWKEYPasswordEntryStr NSSLOWKEYPasswordEntry; |
|
130 struct NSSLOWKEYPasswordEntryStr { |
|
131 SECItem salt; |
|
132 SECItem value; |
|
133 unsigned char data[128]; |
|
134 }; |
|
135 |
|
136 |
|
137 #endif /* _LOWKEYTI_H_ */ |