Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/softoken/legacydb/lowkeyi.h @ 3:150b72113545
Add DBM and legacydb support
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 05 Aug 2014 18:32:02 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:a945361df361 | 3:150b72113545 |
---|---|
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 | |
5 #ifndef _LOWKEYI_H_ | |
6 #define _LOWKEYI_H_ | |
7 | |
8 #include "prtypes.h" | |
9 #include "seccomon.h" | |
10 #include "secoidt.h" | |
11 #include "pcertt.h" | |
12 #include "lowkeyti.h" | |
13 #include "sdb.h" | |
14 | |
15 SEC_BEGIN_PROTOS | |
16 | |
17 /* | |
18 * See bugzilla bug 125359 | |
19 * Since NSS (via PKCS#11) wants to handle big integers as unsigned ints, | |
20 * all of the templates above that en/decode into integers must be converted | |
21 * from ASN.1's signed integer type. This is done by marking either the | |
22 * source or destination (encoding or decoding, respectively) type as | |
23 * siUnsignedInteger. | |
24 */ | |
25 extern void lg_prepare_low_rsa_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); | |
26 extern void lg_prepare_low_pqg_params_for_asn1(PQGParams *params); | |
27 extern void lg_prepare_low_dsa_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); | |
28 extern void lg_prepare_low_dh_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); | |
29 #ifndef NSS_DISABLE_ECC | |
30 extern void lg_prepare_low_ec_priv_key_for_asn1(NSSLOWKEYPrivateKey *key); | |
31 extern void lg_prepare_low_ecparams_for_asn1(ECParams *params); | |
32 #endif /* NSS_DISABLE_ECC */ | |
33 | |
34 typedef char * (* NSSLOWKEYDBNameFunc)(void *arg, int dbVersion); | |
35 | |
36 /* | |
37 ** Open a key database. | |
38 */ | |
39 extern NSSLOWKEYDBHandle *nsslowkey_OpenKeyDB(PRBool readOnly, | |
40 const char *domain, | |
41 const char *prefix, | |
42 NSSLOWKEYDBNameFunc namecb, | |
43 void *cbarg); | |
44 | |
45 /* | |
46 ** Close the specified key database. | |
47 */ | |
48 extern void nsslowkey_CloseKeyDB(NSSLOWKEYDBHandle *handle); | |
49 | |
50 /* | |
51 * Get the version number of the database | |
52 */ | |
53 extern int nsslowkey_GetKeyDBVersion(NSSLOWKEYDBHandle *handle); | |
54 | |
55 /* | |
56 ** Delete a key from the database | |
57 */ | |
58 extern SECStatus nsslowkey_DeleteKey(NSSLOWKEYDBHandle *handle, | |
59 const SECItem *pubkey); | |
60 | |
61 /* | |
62 ** Store a key in the database, indexed by its public key modulus. | |
63 ** "pk" is the private key to store | |
64 ** "f" is the callback function for getting the password | |
65 ** "arg" is the argument for the callback | |
66 */ | |
67 extern SECStatus nsslowkey_StoreKeyByPublicKey(NSSLOWKEYDBHandle *handle, | |
68 NSSLOWKEYPrivateKey *pk, | |
69 SECItem *pubKeyData, | |
70 char *nickname, | |
71 SDB *sdb); | |
72 | |
73 /* does the key for this cert exist in the database filed by modulus */ | |
74 extern PRBool nsslowkey_KeyForCertExists(NSSLOWKEYDBHandle *handle, | |
75 NSSLOWCERTCertificate *cert); | |
76 /* does a key with this ID already exist? */ | |
77 extern PRBool nsslowkey_KeyForIDExists(NSSLOWKEYDBHandle *handle, SECItem *id); | |
78 | |
79 /* | |
80 ** Destroy a private key object. | |
81 ** "key" the object | |
82 ** "freeit" if PR_TRUE then free the object as well as its sub-objects | |
83 */ | |
84 extern void lg_nsslowkey_DestroyPrivateKey(NSSLOWKEYPrivateKey *key); | |
85 | |
86 /* | |
87 ** Destroy a public key object. | |
88 ** "key" the object | |
89 ** "freeit" if PR_TRUE then free the object as well as its sub-objects | |
90 */ | |
91 extern void lg_nsslowkey_DestroyPublicKey(NSSLOWKEYPublicKey *key); | |
92 | |
93 | |
94 /* | |
95 ** Convert a low private key "privateKey" into a public low key | |
96 */ | |
97 extern NSSLOWKEYPublicKey | |
98 *lg_nsslowkey_ConvertToPublicKey(NSSLOWKEYPrivateKey *privateKey); | |
99 | |
100 | |
101 SECStatus | |
102 nsslowkey_UpdateNickname(NSSLOWKEYDBHandle *handle, | |
103 NSSLOWKEYPrivateKey *privkey, | |
104 SECItem *pubKeyData, | |
105 char *nickname, | |
106 SDB *sdb); | |
107 | |
108 /* Store key by modulus and specify an encryption algorithm to use. | |
109 * handle is the pointer to the key database, | |
110 * privkey is the private key to be stored, | |
111 * f and arg are the function and arguments to the callback | |
112 * to get a password, | |
113 * algorithm is the algorithm which the privKey is to be stored. | |
114 * A return of anything but SECSuccess indicates failure. | |
115 */ | |
116 extern SECStatus | |
117 nsslowkey_StoreKeyByPublicKeyAlg(NSSLOWKEYDBHandle *handle, | |
118 NSSLOWKEYPrivateKey *privkey, | |
119 SECItem *pubKeyData, | |
120 char *nickname, | |
121 SDB *sdb, | |
122 PRBool update); | |
123 | |
124 /* Find key by modulus. This function is the inverse of store key | |
125 * by modulus. An attempt to locate the key with "modulus" is | |
126 * performed. If the key is found, the private key is returned, | |
127 * else NULL is returned. | |
128 * modulus is the modulus to locate | |
129 */ | |
130 extern NSSLOWKEYPrivateKey * | |
131 nsslowkey_FindKeyByPublicKey(NSSLOWKEYDBHandle *handle, SECItem *modulus, | |
132 SDB *sdb); | |
133 | |
134 extern char * | |
135 nsslowkey_FindKeyNicknameByPublicKey(NSSLOWKEYDBHandle *handle, | |
136 SECItem *modulus, SDB *sdb); | |
137 | |
138 #ifndef NSS_DISABLE_ECC | |
139 /* | |
140 * smaller version of EC_FillParams. In this code, we only need | |
141 * oid and DER data. | |
142 */ | |
143 SECStatus LGEC_FillParams(PLArenaPool *arena, const SECItem *encodedParams, | |
144 ECParams *params); | |
145 | |
146 /* Copy all of the fields from srcParams into dstParams */ | |
147 SECStatus LGEC_CopyParams(PLArenaPool *arena, ECParams *dstParams, | |
148 const ECParams *srcParams); | |
149 #endif | |
150 SEC_END_PROTOS | |
151 | |
152 #endif /* _LOWKEYI_H_ */ |