Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/cryptohi/keyhi.h @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
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 _KEYHI_H_ | |
6 #define _KEYHI_H_ | |
7 | |
8 #include "plarena.h" | |
9 | |
10 #include "seccomon.h" | |
11 #include "secoidt.h" | |
12 #include "secdert.h" | |
13 #include "keythi.h" | |
14 #include "certt.h" | |
15 /*#include "secpkcs5.h" */ | |
16 | |
17 SEC_BEGIN_PROTOS | |
18 | |
19 | |
20 /* | |
21 ** Destroy a subject-public-key-info object. | |
22 */ | |
23 extern void SECKEY_DestroySubjectPublicKeyInfo(CERTSubjectPublicKeyInfo *spki); | |
24 | |
25 /* | |
26 ** Copy subject-public-key-info "src" to "dst". "dst" is filled in | |
27 ** appropriately (memory is allocated for each of the sub objects). | |
28 */ | |
29 extern SECStatus SECKEY_CopySubjectPublicKeyInfo(PLArenaPool *arena, | |
30 CERTSubjectPublicKeyInfo *dst, | |
31 CERTSubjectPublicKeyInfo *src); | |
32 | |
33 /* | |
34 ** Update the PQG parameters for a cert's public key. | |
35 ** Only done for DSA certs | |
36 */ | |
37 extern SECStatus | |
38 SECKEY_UpdateCertPQG(CERTCertificate * subjectCert); | |
39 | |
40 | |
41 /* | |
42 ** Return the strength of the public key in bytes | |
43 */ | |
44 extern unsigned SECKEY_PublicKeyStrength(const SECKEYPublicKey *pubk); | |
45 | |
46 /* | |
47 ** Return the strength of the public key in bits | |
48 */ | |
49 extern unsigned SECKEY_PublicKeyStrengthInBits(const SECKEYPublicKey *pubk); | |
50 | |
51 /* | |
52 ** Return the length of the signature in bytes | |
53 */ | |
54 extern unsigned SECKEY_SignatureLen(const SECKEYPublicKey *pubk); | |
55 | |
56 /* | |
57 ** Make a copy of the private key "privKey" | |
58 */ | |
59 extern SECKEYPrivateKey *SECKEY_CopyPrivateKey(const SECKEYPrivateKey *privKey); | |
60 | |
61 /* | |
62 ** Make a copy of the public key "pubKey" | |
63 */ | |
64 extern SECKEYPublicKey *SECKEY_CopyPublicKey(const SECKEYPublicKey *pubKey); | |
65 | |
66 /* | |
67 ** Convert a private key "privateKey" into a public key | |
68 */ | |
69 extern SECKEYPublicKey *SECKEY_ConvertToPublicKey(SECKEYPrivateKey *privateKey); | |
70 | |
71 /* | |
72 * create a new RSA key pair. The private Key is returned... | |
73 */ | |
74 SECKEYPrivateKey *SECKEY_CreateRSAPrivateKey(int keySizeInBits, | |
75 SECKEYPublicKey **pubk, void *cx); | |
76 | |
77 /* | |
78 * create a new DH key pair. The private Key is returned... | |
79 */ | |
80 SECKEYPrivateKey *SECKEY_CreateDHPrivateKey(SECKEYDHParams *param, | |
81 SECKEYPublicKey **pubk, void *cx); | |
82 | |
83 /* | |
84 * create a new EC key pair. The private Key is returned... | |
85 */ | |
86 SECKEYPrivateKey *SECKEY_CreateECPrivateKey(SECKEYECParams *param, | |
87 SECKEYPublicKey **pubk, void *cx); | |
88 | |
89 /* | |
90 ** Create a subject-public-key-info based on a public key. | |
91 */ | |
92 extern CERTSubjectPublicKeyInfo * | |
93 SECKEY_CreateSubjectPublicKeyInfo(const SECKEYPublicKey *k); | |
94 | |
95 /* | |
96 ** Convert a base64 ascii encoded DER public key and challenge to spki, | |
97 ** and verify the signature and challenge data are correct | |
98 */ | |
99 extern CERTSubjectPublicKeyInfo * | |
100 SECKEY_ConvertAndDecodePublicKeyAndChallenge(char *pkacstr, char *challenge, | |
101 void *cx); | |
102 | |
103 /* | |
104 ** Encode a CERTSubjectPublicKeyInfo structure. into a | |
105 ** DER encoded subject public key info. | |
106 */ | |
107 SECItem * | |
108 SECKEY_EncodeDERSubjectPublicKeyInfo(const SECKEYPublicKey *pubk); | |
109 | |
110 /* | |
111 ** Decode a DER encoded subject public key info into a | |
112 ** CERTSubjectPublicKeyInfo structure. | |
113 */ | |
114 extern CERTSubjectPublicKeyInfo * | |
115 SECKEY_DecodeDERSubjectPublicKeyInfo(const SECItem *spkider); | |
116 | |
117 /* | |
118 ** Convert a base64 ascii encoded DER subject public key info to our | |
119 ** internal format. | |
120 */ | |
121 extern CERTSubjectPublicKeyInfo * | |
122 SECKEY_ConvertAndDecodeSubjectPublicKeyInfo(const char *spkistr); | |
123 | |
124 /* | |
125 * extract the public key from a subject Public Key info structure. | |
126 * (used by JSS). | |
127 */ | |
128 extern SECKEYPublicKey * | |
129 SECKEY_ExtractPublicKey(const CERTSubjectPublicKeyInfo *); | |
130 | |
131 /* | |
132 ** Destroy a private key object. | |
133 ** "key" the object | |
134 */ | |
135 extern void SECKEY_DestroyPrivateKey(SECKEYPrivateKey *key); | |
136 | |
137 | |
138 /* | |
139 ** Destroy a public key object. | |
140 ** "key" the object | |
141 */ | |
142 extern void SECKEY_DestroyPublicKey(SECKEYPublicKey *key); | |
143 | |
144 /* Destroy and zero out a private key info structure. for now this | |
145 * function zero's out memory allocated in an arena for the key | |
146 * since PORT_FreeArena does not currently do this. | |
147 * | |
148 * NOTE -- If a private key info is allocated in an arena, one should | |
149 * not call this function with freeit = PR_FALSE. The function should | |
150 * destroy the arena. | |
151 */ | |
152 extern void | |
153 SECKEY_DestroyPrivateKeyInfo(SECKEYPrivateKeyInfo *pvk, PRBool freeit); | |
154 | |
155 /* Destroy and zero out an encrypted private key info. | |
156 * | |
157 * NOTE -- If a encrypted private key info is allocated in an arena, one should | |
158 * not call this function with freeit = PR_FALSE. The function should | |
159 * destroy the arena. | |
160 */ | |
161 extern void | |
162 SECKEY_DestroyEncryptedPrivateKeyInfo(SECKEYEncryptedPrivateKeyInfo *epki, | |
163 PRBool freeit); | |
164 | |
165 /* Copy private key info structure. | |
166 * poolp is the arena into which the contents of from is to be copied. | |
167 * NULL is a valid entry. | |
168 * to is the destination private key info | |
169 * from is the source private key info | |
170 * if either from or to is NULL or an error occurs, SECFailure is | |
171 * returned. otherwise, SECSuccess is returned. | |
172 */ | |
173 extern SECStatus | |
174 SECKEY_CopyPrivateKeyInfo(PLArenaPool *poolp, | |
175 SECKEYPrivateKeyInfo *to, | |
176 const SECKEYPrivateKeyInfo *from); | |
177 | |
178 extern SECStatus | |
179 SECKEY_CacheStaticFlags(SECKEYPrivateKey* key); | |
180 | |
181 /* Copy encrypted private key info structure. | |
182 * poolp is the arena into which the contents of from is to be copied. | |
183 * NULL is a valid entry. | |
184 * to is the destination encrypted private key info | |
185 * from is the source encrypted private key info | |
186 * if either from or to is NULL or an error occurs, SECFailure is | |
187 * returned. otherwise, SECSuccess is returned. | |
188 */ | |
189 extern SECStatus | |
190 SECKEY_CopyEncryptedPrivateKeyInfo(PLArenaPool *poolp, | |
191 SECKEYEncryptedPrivateKeyInfo *to, | |
192 const SECKEYEncryptedPrivateKeyInfo *from); | |
193 /* | |
194 * Accessor functions for key type of public and private keys. | |
195 */ | |
196 KeyType SECKEY_GetPrivateKeyType(const SECKEYPrivateKey *privKey); | |
197 KeyType SECKEY_GetPublicKeyType(const SECKEYPublicKey *pubKey); | |
198 | |
199 /* | |
200 * Creates a PublicKey from its DER encoding. | |
201 * Currently only supports RSA, DSA, and DH keys. | |
202 */ | |
203 SECKEYPublicKey* | |
204 SECKEY_ImportDERPublicKey(const SECItem *derKey, CK_KEY_TYPE type); | |
205 | |
206 SECKEYPrivateKeyList* | |
207 SECKEY_NewPrivateKeyList(void); | |
208 | |
209 void | |
210 SECKEY_DestroyPrivateKeyList(SECKEYPrivateKeyList *keys); | |
211 | |
212 void | |
213 SECKEY_RemovePrivateKeyListNode(SECKEYPrivateKeyListNode *node); | |
214 | |
215 SECStatus | |
216 SECKEY_AddPrivateKeyToListTail( SECKEYPrivateKeyList *list, | |
217 SECKEYPrivateKey *key); | |
218 | |
219 #define PRIVKEY_LIST_HEAD(l) ((SECKEYPrivateKeyListNode*)PR_LIST_HEAD(&l->list)) | |
220 #define PRIVKEY_LIST_NEXT(n) ((SECKEYPrivateKeyListNode *)n->links.next) | |
221 #define PRIVKEY_LIST_END(n,l) (((void *)n) == ((void *)&l->list)) | |
222 | |
223 SECKEYPublicKeyList* | |
224 SECKEY_NewPublicKeyList(void); | |
225 | |
226 void | |
227 SECKEY_DestroyPublicKeyList(SECKEYPublicKeyList *keys); | |
228 | |
229 void | |
230 SECKEY_RemovePublicKeyListNode(SECKEYPublicKeyListNode *node); | |
231 | |
232 SECStatus | |
233 SECKEY_AddPublicKeyToListTail( SECKEYPublicKeyList *list, | |
234 SECKEYPublicKey *key); | |
235 | |
236 #define PUBKEY_LIST_HEAD(l) ((SECKEYPublicKeyListNode*)PR_LIST_HEAD(&l->list)) | |
237 #define PUBKEY_LIST_NEXT(n) ((SECKEYPublicKeyListNode *)n->links.next) | |
238 #define PUBKEY_LIST_END(n,l) (((void *)n) == ((void *)&l->list)) | |
239 | |
240 /* | |
241 * Length in bits of the EC's field size. This is also the length of | |
242 * the x and y coordinates of EC points, such as EC public keys and | |
243 * base points. | |
244 * | |
245 * Return 0 on failure (unknown EC domain parameters). | |
246 */ | |
247 extern int SECKEY_ECParamsToKeySize(const SECItem *params); | |
248 | |
249 /* | |
250 * Length in bits of the EC base point order, usually denoted n. This | |
251 * is also the length of EC private keys and ECDSA signature components | |
252 * r and s. | |
253 * | |
254 * Return 0 on failure (unknown EC domain parameters). | |
255 */ | |
256 extern int SECKEY_ECParamsToBasePointOrderLen(const SECItem *params); | |
257 | |
258 SEC_END_PROTOS | |
259 | |
260 #endif /* _KEYHI_H_ */ |