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/. */
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
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);
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_ENABLE_ECC */
34
typedef char * (* NSSLOWKEYDBNameFunc)(void *arg, int dbVersion);
37
** Open a key database.
39
extern NSSLOWKEYDBHandle *nsslowkey_OpenKeyDB(PRBool readOnly,
42
NSSLOWKEYDBNameFunc namecb,
46
** Close the specified key database.
48
extern void nsslowkey_CloseKeyDB(NSSLOWKEYDBHandle *handle);
51
* Get the version number of the database
53
extern int nsslowkey_GetKeyDBVersion(NSSLOWKEYDBHandle *handle);
56
** Delete a key from the database
58
extern SECStatus nsslowkey_DeleteKey(NSSLOWKEYDBHandle *handle,
59
const SECItem *pubkey);
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
67
extern SECStatus nsslowkey_StoreKeyByPublicKey(NSSLOWKEYDBHandle *handle,
68
NSSLOWKEYPrivateKey *pk,
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);
80
** Destroy a private key object.
82
** "freeit" if PR_TRUE then free the object as well as its sub-objects
84
extern void lg_nsslowkey_DestroyPrivateKey(NSSLOWKEYPrivateKey *key);
87
** Destroy a public key object.
89
** "freeit" if PR_TRUE then free the object as well as its sub-objects
91
extern void lg_nsslowkey_DestroyPublicKey(NSSLOWKEYPublicKey *key);
95
** Convert a low private key "privateKey" into a public low key
97
extern NSSLOWKEYPublicKey
98
*lg_nsslowkey_ConvertToPublicKey(NSSLOWKEYPrivateKey *privateKey);
102
nsslowkey_UpdateNickname(NSSLOWKEYDBHandle *handle,
103
NSSLOWKEYPrivateKey *privkey,
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
113
* algorithm is the algorithm which the privKey is to be stored.
114
* A return of anything but SECSuccess indicates failure.
117
nsslowkey_StoreKeyByPublicKeyAlg(NSSLOWKEYDBHandle *handle,
118
NSSLOWKEYPrivateKey *privkey,
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
130
extern NSSLOWKEYPrivateKey *
131
nsslowkey_FindKeyByPublicKey(NSSLOWKEYDBHandle *handle, SECItem *modulus,
135
nsslowkey_FindKeyNicknameByPublicKey(NSSLOWKEYDBHandle *handle,
136
SECItem *modulus, SDB *sdb);
138
#ifdef NSS_ENABLE_ECC
140
* smaller version of EC_FillParams. In this code, we only need
143
SECStatus LGEC_FillParams(PLArenaPool *arena, const SECItem *encodedParams,
146
/* Copy all of the fields from srcParams into dstParams */
147
SECStatus LGEC_CopyParams(PLArenaPool *arena, ECParams *dstParams,
148
const ECParams *srcParams);
152
#endif /* _LOWKEYI_H_ */