Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: mozilla/security/nss/lib/cryptohi/keyhi.h

Issue 14249009: Change the NSS and NSPR source tree to the new directory structure to be (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mozilla/security/nss/lib/cryptohi/key.h ('k') | mozilla/security/nss/lib/cryptohi/keyi.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 /* $Id: keyhi.h,v 1.21 2012/04/25 14:49:41 gerv%gerv.net Exp $ */
5
6 #ifndef _KEYHI_H_
7 #define _KEYHI_H_
8
9 #include "plarena.h"
10
11 #include "seccomon.h"
12 #include "secoidt.h"
13 #include "secdert.h"
14 #include "keythi.h"
15 #include "certt.h"
16 /*#include "secpkcs5.h" */
17
18 SEC_BEGIN_PROTOS
19
20
21 /*
22 ** Destroy a subject-public-key-info object.
23 */
24 extern void SECKEY_DestroySubjectPublicKeyInfo(CERTSubjectPublicKeyInfo *spki);
25
26 /*
27 ** Copy subject-public-key-info "src" to "dst". "dst" is filled in
28 ** appropriately (memory is allocated for each of the sub objects).
29 */
30 extern SECStatus SECKEY_CopySubjectPublicKeyInfo(PLArenaPool *arena,
31 CERTSubjectPublicKeyInfo *dst,
32 CERTSubjectPublicKeyInfo *src);
33
34 /*
35 ** Update the PQG parameters for a cert's public key.
36 ** Only done for DSA certs
37 */
38 extern SECStatus
39 SECKEY_UpdateCertPQG(CERTCertificate * subjectCert);
40
41
42 /*
43 ** Return the strength of the public key in bytes
44 */
45 extern unsigned SECKEY_PublicKeyStrength(const SECKEYPublicKey *pubk);
46
47 /*
48 ** Return the strength of the public key in bits
49 */
50 extern unsigned SECKEY_PublicKeyStrengthInBits(const SECKEYPublicKey *pubk);
51
52 /*
53 ** Return the length of the signature in bytes
54 */
55 extern unsigned SECKEY_SignatureLen(const SECKEYPublicKey *pubk);
56
57 /*
58 ** Make a copy of the private key "privKey"
59 */
60 extern SECKEYPrivateKey *SECKEY_CopyPrivateKey(const SECKEYPrivateKey *privKey);
61
62 /*
63 ** Make a copy of the public key "pubKey"
64 */
65 extern SECKEYPublicKey *SECKEY_CopyPublicKey(const SECKEYPublicKey *pubKey);
66
67 /*
68 ** Convert a private key "privateKey" into a public key
69 */
70 extern SECKEYPublicKey *SECKEY_ConvertToPublicKey(SECKEYPrivateKey *privateKey);
71
72 /*
73 * create a new RSA key pair. The private Key is returned...
74 */
75 SECKEYPrivateKey *SECKEY_CreateRSAPrivateKey(int keySizeInBits,
76 SECKEYPublicKey **pubk, void *cx);
77
78 /*
79 * create a new DH key pair. The private Key is returned...
80 */
81 SECKEYPrivateKey *SECKEY_CreateDHPrivateKey(SECKEYDHParams *param,
82 SECKEYPublicKey **pubk, void *cx);
83
84 /*
85 * create a new EC key pair. The private Key is returned...
86 */
87 SECKEYPrivateKey *SECKEY_CreateECPrivateKey(SECKEYECParams *param,
88 SECKEYPublicKey **pubk, void *cx);
89
90 /*
91 ** Create a subject-public-key-info based on a public key.
92 */
93 extern CERTSubjectPublicKeyInfo *
94 SECKEY_CreateSubjectPublicKeyInfo(SECKEYPublicKey *k);
95
96 /*
97 ** Decode a DER encoded public key into an SECKEYPublicKey structure.
98 */
99 extern SECKEYPublicKey *SECKEY_DecodeDERPublicKey(SECItem *pubkder);
100
101 /*
102 ** Convert a base64 ascii encoded DER public key to our internal format.
103 */
104 extern SECKEYPublicKey *SECKEY_ConvertAndDecodePublicKey(char *pubkstr);
105
106 /*
107 ** Convert a base64 ascii encoded DER public key and challenge to spki,
108 ** and verify the signature and challenge data are correct
109 */
110 extern CERTSubjectPublicKeyInfo *
111 SECKEY_ConvertAndDecodePublicKeyAndChallenge(char *pkacstr, char *challenge,
112 void *cx);
113
114 /*
115 ** Encode a CERTSubjectPublicKeyInfo structure. into a
116 ** DER encoded subject public key info.
117 */
118 SECItem *
119 SECKEY_EncodeDERSubjectPublicKeyInfo(SECKEYPublicKey *pubk);
120
121 /*
122 ** Decode a DER encoded subject public key info into a
123 ** CERTSubjectPublicKeyInfo structure.
124 */
125 extern CERTSubjectPublicKeyInfo *
126 SECKEY_DecodeDERSubjectPublicKeyInfo(SECItem *spkider);
127
128 /*
129 ** Convert a base64 ascii encoded DER subject public key info to our
130 ** internal format.
131 */
132 extern CERTSubjectPublicKeyInfo *
133 SECKEY_ConvertAndDecodeSubjectPublicKeyInfo(char *spkistr);
134
135 /*
136 * extract the public key from a subject Public Key info structure.
137 * (used by JSS).
138 */
139 extern SECKEYPublicKey *
140 SECKEY_ExtractPublicKey(CERTSubjectPublicKeyInfo *);
141
142 /*
143 ** Destroy a private key object.
144 ** "key" the object
145 */
146 extern void SECKEY_DestroyPrivateKey(SECKEYPrivateKey *key);
147
148
149 /*
150 ** Destroy a public key object.
151 ** "key" the object
152 */
153 extern void SECKEY_DestroyPublicKey(SECKEYPublicKey *key);
154
155 /* Destroy and zero out a private key info structure. for now this
156 * function zero's out memory allocated in an arena for the key
157 * since PORT_FreeArena does not currently do this.
158 *
159 * NOTE -- If a private key info is allocated in an arena, one should
160 * not call this function with freeit = PR_FALSE. The function should
161 * destroy the arena.
162 */
163 extern void
164 SECKEY_DestroyPrivateKeyInfo(SECKEYPrivateKeyInfo *pvk, PRBool freeit);
165
166 /* Destroy and zero out an encrypted private key info.
167 *
168 * NOTE -- If a encrypted private key info is allocated in an arena, one should
169 * not call this function with freeit = PR_FALSE. The function should
170 * destroy the arena.
171 */
172 extern void
173 SECKEY_DestroyEncryptedPrivateKeyInfo(SECKEYEncryptedPrivateKeyInfo *epki,
174 PRBool freeit);
175
176 /* Copy private key info structure.
177 * poolp is the arena into which the contents of from is to be copied.
178 * NULL is a valid entry.
179 * to is the destination private key info
180 * from is the source private key info
181 * if either from or to is NULL or an error occurs, SECFailure is
182 * returned. otherwise, SECSuccess is returned.
183 */
184 extern SECStatus
185 SECKEY_CopyPrivateKeyInfo(PLArenaPool *poolp,
186 SECKEYPrivateKeyInfo *to,
187 SECKEYPrivateKeyInfo *from);
188
189 extern SECStatus
190 SECKEY_CacheStaticFlags(SECKEYPrivateKey* key);
191
192 /* Copy encrypted private key info structure.
193 * poolp is the arena into which the contents of from is to be copied.
194 * NULL is a valid entry.
195 * to is the destination encrypted private key info
196 * from is the source encrypted private key info
197 * if either from or to is NULL or an error occurs, SECFailure is
198 * returned. otherwise, SECSuccess is returned.
199 */
200 extern SECStatus
201 SECKEY_CopyEncryptedPrivateKeyInfo(PLArenaPool *poolp,
202 SECKEYEncryptedPrivateKeyInfo *to,
203 SECKEYEncryptedPrivateKeyInfo *from);
204 /*
205 * Accessor functions for key type of public and private keys.
206 */
207 KeyType SECKEY_GetPrivateKeyType(SECKEYPrivateKey *privKey);
208 KeyType SECKEY_GetPublicKeyType(SECKEYPublicKey *pubKey);
209
210 /*
211 * Creates a PublicKey from its DER encoding.
212 * Currently only supports RSA and DSA keys.
213 */
214 SECKEYPublicKey*
215 SECKEY_ImportDERPublicKey(SECItem *derKey, CK_KEY_TYPE type);
216
217 SECKEYPrivateKeyList*
218 SECKEY_NewPrivateKeyList(void);
219
220 void
221 SECKEY_DestroyPrivateKeyList(SECKEYPrivateKeyList *keys);
222
223 void
224 SECKEY_RemovePrivateKeyListNode(SECKEYPrivateKeyListNode *node);
225
226 SECStatus
227 SECKEY_AddPrivateKeyToListTail( SECKEYPrivateKeyList *list,
228 SECKEYPrivateKey *key);
229
230 #define PRIVKEY_LIST_HEAD(l) ((SECKEYPrivateKeyListNode*)PR_LIST_HEAD(&l->list))
231 #define PRIVKEY_LIST_NEXT(n) ((SECKEYPrivateKeyListNode *)n->links.next)
232 #define PRIVKEY_LIST_END(n,l) (((void *)n) == ((void *)&l->list))
233
234 SECKEYPublicKeyList*
235 SECKEY_NewPublicKeyList(void);
236
237 void
238 SECKEY_DestroyPublicKeyList(SECKEYPublicKeyList *keys);
239
240 void
241 SECKEY_RemovePublicKeyListNode(SECKEYPublicKeyListNode *node);
242
243 SECStatus
244 SECKEY_AddPublicKeyToListTail( SECKEYPublicKeyList *list,
245 SECKEYPublicKey *key);
246
247 #define PUBKEY_LIST_HEAD(l) ((SECKEYPublicKeyListNode*)PR_LIST_HEAD(&l->list))
248 #define PUBKEY_LIST_NEXT(n) ((SECKEYPublicKeyListNode *)n->links.next)
249 #define PUBKEY_LIST_END(n,l) (((void *)n) == ((void *)&l->list))
250
251 /*
252 * Length in bits of the EC's field size. This is also the length of
253 * the x and y coordinates of EC points, such as EC public keys and
254 * base points.
255 *
256 * Return 0 on failure (unknown EC domain parameters).
257 */
258 extern int SECKEY_ECParamsToKeySize(const SECItem *params);
259
260 /*
261 * Length in bits of the EC base point order, usually denoted n. This
262 * is also the length of EC private keys and ECDSA signature components
263 * r and s.
264 *
265 * Return 0 on failure (unknown EC domain parameters).
266 */
267 extern int SECKEY_ECParamsToBasePointOrderLen(const SECItem *params);
268
269 SEC_END_PROTOS
270
271 #endif /* _KEYHI_H_ */
OLDNEW
« no previous file with comments | « mozilla/security/nss/lib/cryptohi/key.h ('k') | mozilla/security/nss/lib/cryptohi/keyi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698