OLD | NEW |
1 /* | 1 /* |
2 * loader.c - load platform dependent DSO containing freebl implementation. | 2 * loader.c - load platform dependent DSO containing freebl implementation. |
3 * | 3 * |
4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 | 7 |
8 #include "loader.h" | 8 #include "loader.h" |
9 #include "prmem.h" | 9 #include "prmem.h" |
10 #include "prerror.h" | 10 #include "prerror.h" |
11 #include "prinit.h" | 11 #include "prinit.h" |
12 #include "prenv.h" | 12 #include "prenv.h" |
13 | 13 |
14 static const char* default_name = | 14 static const char *default_name = |
15 SHLIB_PREFIX"freebl"SHLIB_VERSION"."SHLIB_SUFFIX; | 15 SHLIB_PREFIX "freebl" SHLIB_VERSION "." SHLIB_SUFFIX; |
16 | 16 |
17 /* getLibName() returns the name of the library to load. */ | 17 /* getLibName() returns the name of the library to load. */ |
18 | 18 |
19 #if defined(SOLARIS) && defined(__sparc) | 19 #if defined(SOLARIS) && defined(__sparc) |
20 #include <stddef.h> | 20 #include <stddef.h> |
21 #include <strings.h> | 21 #include <strings.h> |
22 #include <sys/systeminfo.h> | 22 #include <sys/systeminfo.h> |
23 | 23 |
24 | |
25 #if defined(NSS_USE_64) | 24 #if defined(NSS_USE_64) |
26 | 25 |
27 const static char fpu_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; | 26 const static char fpu_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; |
28 const static char int_hybrid_shared_lib[] = "libfreebl_64int_3.so"; | 27 const static char int_hybrid_shared_lib[] = "libfreebl_64int_3.so"; |
29 const static char non_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; | 28 const static char non_hybrid_shared_lib[] = "libfreebl_64fpu_3.so"; |
30 | 29 |
31 const static char int_hybrid_isa[] = "sparcv9"; | 30 const static char int_hybrid_isa[] = "sparcv9"; |
32 const static char fpu_hybrid_isa[] = "sparcv9+vis"; | 31 const static char fpu_hybrid_isa[] = "sparcv9+vis"; |
33 | 32 |
34 #else | 33 #else |
35 | 34 |
36 const static char fpu_hybrid_shared_lib[] = "libfreebl_32fpu_3.so"; | 35 const static char fpu_hybrid_shared_lib[] = "libfreebl_32fpu_3.so"; |
37 const static char int_hybrid_shared_lib[] = "libfreebl_32int64_3.so"; | 36 const static char int_hybrid_shared_lib[] = "libfreebl_32int64_3.so"; |
38 /* This was for SPARC V8, now obsolete. */ | 37 /* This was for SPARC V8, now obsolete. */ |
39 const static char *const non_hybrid_shared_lib = NULL; | 38 const static char *const non_hybrid_shared_lib = NULL; |
40 | 39 |
41 const static char int_hybrid_isa[] = "sparcv8plus"; | 40 const static char int_hybrid_isa[] = "sparcv8plus"; |
42 const static char fpu_hybrid_isa[] = "sparcv8plus+vis"; | 41 const static char fpu_hybrid_isa[] = "sparcv8plus+vis"; |
43 | 42 |
44 #endif | 43 #endif |
45 | 44 |
46 static const char * | 45 static const char *getLibName(void) { |
47 getLibName(void) | 46 char *found_int_hybrid; |
48 { | 47 char *found_fpu_hybrid; |
49 char * found_int_hybrid; | 48 long buflen; |
50 char * found_fpu_hybrid; | 49 char buf[256]; |
51 long buflen; | 50 |
52 char buf[256]; | 51 buflen = sysinfo(SI_ISALIST, buf, sizeof buf); |
53 | 52 if (buflen <= 0) return NULL; |
54 buflen = sysinfo(SI_ISALIST, buf, sizeof buf); | 53 /* sysinfo output is always supposed to be NUL terminated, but ... */ |
55 if (buflen <= 0) | 54 if (buflen < sizeof buf) |
56 » return NULL; | 55 buf[buflen] = '\0'; |
57 /* sysinfo output is always supposed to be NUL terminated, but ... */ | 56 else |
58 if (buflen < sizeof buf)· | 57 buf[(sizeof buf) - 1] = '\0'; |
59 » buf[buflen] = '\0'; | 58 /* The ISA list is a space separated string of names of ISAs and |
60 else | 59 * ISA extensions, in order of decreasing performance. |
61 » buf[(sizeof buf) - 1] = '\0'; | 60 * There are two different ISAs with which NSS's crypto code can be |
62 /* The ISA list is a space separated string of names of ISAs and | 61 * accelerated. If both are in the list, we take the first one. |
63 * ISA extensions, in order of decreasing performance. | 62 * If one is in the list, we use it, and if neither then we use |
64 * There are two different ISAs with which NSS's crypto code can be | 63 * the base unaccelerated code. |
65 * accelerated. If both are in the list, we take the first one. | 64 */ |
66 * If one is in the list, we use it, and if neither then we use | 65 found_int_hybrid = strstr(buf, int_hybrid_isa); |
67 * the base unaccelerated code. | 66 found_fpu_hybrid = strstr(buf, fpu_hybrid_isa); |
68 */ | 67 if (found_fpu_hybrid && |
69 found_int_hybrid = strstr(buf, int_hybrid_isa); | 68 (!found_int_hybrid || (found_int_hybrid - found_fpu_hybrid) >= 0)) { |
70 found_fpu_hybrid = strstr(buf, fpu_hybrid_isa); | 69 return fpu_hybrid_shared_lib; |
71 if (found_fpu_hybrid &&· | 70 } |
72 » (!found_int_hybrid || | 71 if (found_int_hybrid) { |
73 » (found_int_hybrid - found_fpu_hybrid) >= 0)) { | 72 return int_hybrid_shared_lib; |
74 » return fpu_hybrid_shared_lib; | 73 } |
75 } | 74 return non_hybrid_shared_lib; |
76 if (found_int_hybrid) { | |
77 » return int_hybrid_shared_lib; | |
78 } | |
79 return non_hybrid_shared_lib; | |
80 } | 75 } |
81 | 76 |
82 #elif defined(HPUX) && !defined(NSS_USE_64) && !defined(__ia64) | 77 #elif defined(HPUX) && !defined(NSS_USE_64) && !defined(__ia64) |
83 #include <unistd.h> | 78 #include <unistd.h> |
84 | 79 |
85 /* This code tests to see if we're running on a PA2.x CPU. | 80 /* This code tests to see if we're running on a PA2.x CPU. |
86 ** It returns true (1) if so, and false (0) otherwise. | 81 ** It returns true (1) if so, and false (0) otherwise. |
87 */ | 82 */ |
88 static const char * | 83 static const char *getLibName(void) { |
89 getLibName(void) | 84 long cpu = sysconf(_SC_CPU_VERSION); |
90 { | 85 return (cpu == CPU_PA_RISC2_0) ? "libfreebl_32fpu_3.sl" |
91 long cpu = sysconf(_SC_CPU_VERSION); | 86 : "libfreebl_32int_3.sl"; |
92 return (cpu == CPU_PA_RISC2_0) | |
93 » » ? "libfreebl_32fpu_3.sl" | |
94 » : "libfreebl_32int_3.sl" ; | |
95 } | 87 } |
96 #else | 88 #else |
97 /* default case, for platforms/ABIs that have only one freebl shared lib. */ | 89 /* default case, for platforms/ABIs that have only one freebl shared lib. */ |
98 static const char * getLibName(void) { return default_name; } | 90 static const char *getLibName(void) { return default_name; } |
99 #endif | 91 #endif |
100 | 92 |
101 #include "prio.h" | 93 #include "prio.h" |
102 #include "prprf.h" | 94 #include "prprf.h" |
103 #include <stdio.h> | 95 #include <stdio.h> |
104 #include "prsystem.h" | 96 #include "prsystem.h" |
105 | 97 |
106 static const char *NameOfThisSharedLib =· | 98 static const char *NameOfThisSharedLib = |
107 SHLIB_PREFIX"softokn"SOFTOKEN_SHLIB_VERSION"."SHLIB_SUFFIX; | 99 SHLIB_PREFIX "softokn" SOFTOKEN_SHLIB_VERSION "." SHLIB_SUFFIX; |
108 | 100 |
109 static PRLibrary* blLib; | 101 static PRLibrary *blLib; |
110 | 102 |
111 #define LSB(x) ((x)&0xff) | 103 #define LSB(x) ((x) & 0xff) |
112 #define MSB(x) ((x)>>8) | 104 #define MSB(x) ((x) >> 8) |
113 | 105 |
114 static const FREEBLVector *vector; | 106 static const FREEBLVector *vector; |
115 static const char *libraryName = NULL; | 107 static const char *libraryName = NULL; |
116 | 108 |
117 #include "genload.c" | 109 #include "genload.c" |
118 | 110 |
119 /* This function must be run only once. */ | 111 /* This function must be run only once. */ |
120 /* determine if hybrid platform, then actually load the DSO. */ | 112 /* determine if hybrid platform, then actually load the DSO. */ |
121 static PRStatus | 113 static PRStatus freebl_LoadDSO(void) { |
122 freebl_LoadDSO( void ) | 114 PRLibrary *handle; |
123 { | 115 const char *name = getLibName(); |
124 PRLibrary * handle; | |
125 const char * name = getLibName(); | |
126 | 116 |
127 if (!name) { | 117 if (!name) { |
128 PR_SetError(PR_LOAD_LIBRARY_ERROR, 0); | 118 PR_SetError(PR_LOAD_LIBRARY_ERROR, 0); |
129 return PR_FAILURE; | 119 return PR_FAILURE; |
130 } | 120 } |
131 | 121 |
132 handle = loader_LoadLibrary(name); | 122 handle = loader_LoadLibrary(name); |
133 if (handle) { | 123 if (handle) { |
134 PRFuncPtr address = PR_FindFunctionSymbol(handle, "FREEBL_GetVector"); | 124 PRFuncPtr address = PR_FindFunctionSymbol(handle, "FREEBL_GetVector"); |
135 PRStatus status; | 125 PRStatus status; |
136 if (address) { | 126 if (address) { |
137 FREEBLGetVectorFn * getVector = (FREEBLGetVectorFn *)address; | 127 FREEBLGetVectorFn *getVector = (FREEBLGetVectorFn *)address; |
138 const FREEBLVector * dsoVector = getVector(); | 128 const FREEBLVector *dsoVector = getVector(); |
139 if (dsoVector) { | 129 if (dsoVector) { |
140 » unsigned short dsoVersion = dsoVector->version; | 130 unsigned short dsoVersion = dsoVector->version; |
141 » unsigned short myVersion = FREEBL_VERSION; | 131 unsigned short myVersion = FREEBL_VERSION; |
142 » if (MSB(dsoVersion) == MSB(myVersion) &&· | 132 if (MSB(dsoVersion) == MSB(myVersion) && |
143 » LSB(dsoVersion) >= LSB(myVersion) && | 133 LSB(dsoVersion) >= LSB(myVersion) && |
144 » dsoVector->length >= sizeof(FREEBLVector)) { | 134 dsoVector->length >= sizeof(FREEBLVector)) { |
145 vector = dsoVector; | 135 vector = dsoVector; |
146 » libraryName = name; | 136 libraryName = name; |
147 » blLib = handle; | 137 blLib = handle; |
148 » return PR_SUCCESS; | 138 return PR_SUCCESS; |
149 » } | 139 } |
150 } | 140 } |
151 } | 141 } |
152 status = PR_UnloadLibrary(handle); | 142 status = PR_UnloadLibrary(handle); |
153 PORT_Assert(PR_SUCCESS == status); | 143 PORT_Assert(PR_SUCCESS == status); |
154 } | 144 } |
155 return PR_FAILURE; | 145 return PR_FAILURE; |
156 } | 146 } |
157 | 147 |
158 static const PRCallOnceType pristineCallOnce; | 148 static const PRCallOnceType pristineCallOnce; |
159 static PRCallOnceType loadFreeBLOnce; | 149 static PRCallOnceType loadFreeBLOnce; |
160 | 150 |
161 static PRStatus | 151 static PRStatus freebl_RunLoaderOnce(void) { |
162 freebl_RunLoaderOnce( void ) | |
163 { | |
164 PRStatus status; | 152 PRStatus status; |
165 | 153 |
166 status = PR_CallOnce(&loadFreeBLOnce, &freebl_LoadDSO); | 154 status = PR_CallOnce(&loadFreeBLOnce, &freebl_LoadDSO); |
167 return status; | 155 return status; |
168 } | 156 } |
169 | 157 |
170 SECStatus | 158 SECStatus BL_Init(void) { |
171 BL_Init(void) | 159 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
172 { | |
173 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
174 return SECFailure; | |
175 return (vector->p_BL_Init)(); | 160 return (vector->p_BL_Init)(); |
176 } | 161 } |
177 | 162 |
178 RSAPrivateKey *· | 163 RSAPrivateKey *RSA_NewKey(int keySizeInBits, SECItem *publicExponent) { |
179 RSA_NewKey(int keySizeInBits, SECItem * publicExponent) | 164 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
180 { | |
181 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
182 return NULL; | |
183 return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent); | 165 return (vector->p_RSA_NewKey)(keySizeInBits, publicExponent); |
184 } | 166 } |
185 | 167 |
186 SECStatus | 168 SECStatus RSA_PublicKeyOp(RSAPublicKey *key, unsigned char *output, |
187 RSA_PublicKeyOp(RSAPublicKey * key, | 169 const unsigned char *input) { |
188 » » » » unsigned char * output, | 170 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
189 » » » » const unsigned char * input) | |
190 { | |
191 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
192 return SECFailure; | |
193 return (vector->p_RSA_PublicKeyOp)(key, output, input); | 171 return (vector->p_RSA_PublicKeyOp)(key, output, input); |
194 } | 172 } |
195 | 173 |
196 SECStatus | 174 SECStatus RSA_PrivateKeyOp(RSAPrivateKey *key, unsigned char *output, |
197 RSA_PrivateKeyOp(RSAPrivateKey * key, | 175 const unsigned char *input) { |
198 » » » » unsigned char * output, | 176 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
199 » » » » const unsigned char * input) | |
200 { | |
201 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
202 return SECFailure; | |
203 return (vector->p_RSA_PrivateKeyOp)(key, output, input); | 177 return (vector->p_RSA_PrivateKeyOp)(key, output, input); |
204 } | 178 } |
205 | 179 |
206 SECStatus | 180 SECStatus RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, |
207 RSA_PrivateKeyOpDoubleChecked(RSAPrivateKey *key, | 181 unsigned char *output, |
208 unsigned char *output, | 182 const unsigned char *input) { |
209 const unsigned char *input) | 183 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
210 { | |
211 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
212 return SECFailure; | |
213 return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input); | 184 return (vector->p_RSA_PrivateKeyOpDoubleChecked)(key, output, input); |
214 } | 185 } |
215 | 186 |
216 SECStatus | 187 SECStatus RSA_PrivateKeyCheck(const RSAPrivateKey *key) { |
217 RSA_PrivateKeyCheck(const RSAPrivateKey *key) | 188 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
218 { | |
219 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
220 return SECFailure; | |
221 return (vector->p_RSA_PrivateKeyCheck)(key); | 189 return (vector->p_RSA_PrivateKeyCheck)(key); |
222 } | 190 } |
223 | 191 |
224 SECStatus | 192 SECStatus DSA_NewKey(const PQGParams *params, DSAPrivateKey **privKey) { |
225 DSA_NewKey(const PQGParams * params, DSAPrivateKey ** privKey) | 193 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
226 { | |
227 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
228 return SECFailure; | |
229 return (vector->p_DSA_NewKey)(params, privKey); | 194 return (vector->p_DSA_NewKey)(params, privKey); |
230 } | 195 } |
231 | 196 |
232 SECStatus | 197 SECStatus DSA_SignDigest(DSAPrivateKey *key, SECItem *signature, |
233 DSA_SignDigest(DSAPrivateKey * key, SECItem * signature, const SECItem * digest) | 198 const SECItem *digest) { |
234 { | 199 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
235 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 200 return (vector->p_DSA_SignDigest)(key, signature, digest); |
236 return SECFailure; | 201 } |
237 return (vector->p_DSA_SignDigest)( key, signature, digest); | 202 |
238 } | 203 SECStatus DSA_VerifyDigest(DSAPublicKey *key, const SECItem *signature, |
239 | 204 const SECItem *digest) { |
240 SECStatus | 205 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
241 DSA_VerifyDigest(DSAPublicKey * key, const SECItem * signature,· | 206 return (vector->p_DSA_VerifyDigest)(key, signature, digest); |
242 const SECItem * digest) | 207 } |
243 { | 208 |
244 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 209 SECStatus DSA_NewKeyFromSeed(const PQGParams *params, const unsigned char *seed, |
245 return SECFailure; | 210 DSAPrivateKey **privKey) { |
246 return (vector->p_DSA_VerifyDigest)( key, signature, digest); | 211 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
247 } | 212 return (vector->p_DSA_NewKeyFromSeed)(params, seed, privKey); |
248 | 213 } |
249 SECStatus | 214 |
250 DSA_NewKeyFromSeed(const PQGParams *params, const unsigned char * seed, | 215 SECStatus DSA_SignDigestWithSeed(DSAPrivateKey *key, SECItem *signature, |
251 DSAPrivateKey **privKey) | 216 const SECItem *digest, |
252 { | 217 const unsigned char *seed) { |
253 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 218 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
254 return SECFailure; | 219 return (vector->p_DSA_SignDigestWithSeed)(key, signature, digest, seed); |
255 return (vector->p_DSA_NewKeyFromSeed)(params, seed, privKey); | 220 } |
256 } | 221 |
257 | 222 SECStatus DSA_NewRandom(PLArenaPool *arena, const SECItem *q, SECItem *seed) { |
258 SECStatus | 223 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
259 DSA_SignDigestWithSeed(DSAPrivateKey * key, SECItem * signature, | 224 return (vector->p_DSA_NewRandom)(arena, q, seed); |
260 » » const SECItem * digest, const unsigned char * seed) | 225 } |
261 { | 226 |
262 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 227 SECStatus DH_GenParam(int primeLen, DHParams **params) { |
263 return SECFailure; | 228 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
264 return (vector->p_DSA_SignDigestWithSeed)( key, signature, digest, seed); | |
265 } | |
266 | |
267 SECStatus | |
268 DSA_NewRandom(PLArenaPool * arena, const SECItem * q, SECItem * seed) | |
269 { | |
270 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
271 return SECFailure; | |
272 return (vector->p_DSA_NewRandom)(arena, q, seed); | |
273 } | |
274 | |
275 SECStatus | |
276 DH_GenParam(int primeLen, DHParams ** params) | |
277 { | |
278 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
279 return SECFailure; | |
280 return (vector->p_DH_GenParam)(primeLen, params); | 229 return (vector->p_DH_GenParam)(primeLen, params); |
281 } | 230 } |
282 | 231 |
283 SECStatus | 232 SECStatus DH_NewKey(DHParams *params, DHPrivateKey **privKey) { |
284 DH_NewKey(DHParams * params, DHPrivateKey ** privKey) | 233 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
285 { | 234 return (vector->p_DH_NewKey)(params, privKey); |
286 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 235 } |
287 return SECFailure; | 236 |
288 return (vector->p_DH_NewKey)( params, privKey); | 237 SECStatus DH_Derive(SECItem *publicValue, SECItem *prime, SECItem *privateValue, |
289 } | 238 SECItem *derivedSecret, unsigned int maxOutBytes) { |
290 | 239 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
291 SECStatus | 240 return (vector->p_DH_Derive)(publicValue, prime, privateValue, derivedSecret, |
292 DH_Derive(SECItem * publicValue, SECItem * prime, SECItem * privateValue,· | 241 maxOutBytes); |
293 » » » SECItem * derivedSecret, unsigned int maxOutBytes) | 242 } |
294 { | 243 |
295 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 244 SECStatus KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2, |
296 return SECFailure; | 245 SECItem *private1, SECItem *private2, |
297 return (vector->p_DH_Derive)( publicValue, prime, privateValue, | 246 SECItem *derivedSecret) { |
298 » » » » derivedSecret, maxOutBytes); | 247 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
299 } | 248 return (vector->p_KEA_Derive)(prime, public1, public2, private1, private2, |
300 | 249 derivedSecret); |
301 SECStatus | 250 } |
302 KEA_Derive(SECItem *prime, SECItem *public1, SECItem *public2,· | 251 |
303 » SECItem *private1, SECItem *private2, SECItem *derivedSecret) | 252 PRBool KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime) { |
304 { | 253 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return PR_FALSE; |
305 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
306 return SECFailure; | |
307 return (vector->p_KEA_Derive)(prime, public1, public2, | |
308 » private1, private2, derivedSecret); | |
309 } | |
310 | |
311 PRBool | |
312 KEA_Verify(SECItem *Y, SECItem *prime, SECItem *subPrime) | |
313 { | |
314 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
315 return PR_FALSE; | |
316 return (vector->p_KEA_Verify)(Y, prime, subPrime); | 254 return (vector->p_KEA_Verify)(Y, prime, subPrime); |
317 } | 255 } |
318 | 256 |
319 RC4Context * | 257 RC4Context *RC4_CreateContext(const unsigned char *key, int len) { |
320 RC4_CreateContext(const unsigned char *key, int len) | 258 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
321 { | |
322 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
323 return NULL; | |
324 return (vector->p_RC4_CreateContext)(key, len); | 259 return (vector->p_RC4_CreateContext)(key, len); |
325 } | 260 } |
326 | 261 |
327 void | 262 void RC4_DestroyContext(RC4Context *cx, PRBool freeit) { |
328 RC4_DestroyContext(RC4Context *cx, PRBool freeit) | 263 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
329 { | |
330 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
331 return; | |
332 (vector->p_RC4_DestroyContext)(cx, freeit); | 264 (vector->p_RC4_DestroyContext)(cx, freeit); |
333 } | 265 } |
334 | 266 |
335 SECStatus | 267 SECStatus RC4_Encrypt(RC4Context *cx, unsigned char *output, |
336 RC4_Encrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, | 268 unsigned int *outputLen, unsigned int maxOutputLen, |
337 » unsigned int maxOutputLen, const unsigned char *input, | 269 const unsigned char *input, unsigned int inputLen) { |
338 » unsigned int inputLen) | 270 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
339 { | 271 return (vector->p_RC4_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
340 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 272 inputLen); |
341 return SECFailure; | 273 } |
342 return (vector->p_RC4_Encrypt)(cx, output, outputLen, maxOutputLen, input,· | 274 |
343 » inputLen); | 275 SECStatus RC4_Decrypt(RC4Context *cx, unsigned char *output, |
344 } | 276 unsigned int *outputLen, unsigned int maxOutputLen, |
345 | 277 const unsigned char *input, unsigned int inputLen) { |
346 SECStatus | 278 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
347 RC4_Decrypt(RC4Context *cx, unsigned char *output, unsigned int *outputLen, | 279 return (vector->p_RC4_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
348 » unsigned int maxOutputLen, const unsigned char *input, | 280 inputLen); |
349 » unsigned int inputLen) | 281 } |
350 { | 282 |
351 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 283 RC2Context *RC2_CreateContext(const unsigned char *key, unsigned int len, |
352 return SECFailure; | 284 const unsigned char *iv, int mode, |
353 return (vector->p_RC4_Decrypt)(cx, output, outputLen, maxOutputLen, input,· | 285 unsigned effectiveKeyLen) { |
354 » inputLen); | 286 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
355 } | |
356 | |
357 RC2Context * | |
358 RC2_CreateContext(const unsigned char *key, unsigned int len, | |
359 » » const unsigned char *iv, int mode, unsigned effectiveKeyLen) | |
360 { | |
361 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
362 return NULL; | |
363 return (vector->p_RC2_CreateContext)(key, len, iv, mode, effectiveKeyLen); | 287 return (vector->p_RC2_CreateContext)(key, len, iv, mode, effectiveKeyLen); |
364 } | 288 } |
365 | 289 |
366 void | 290 void RC2_DestroyContext(RC2Context *cx, PRBool freeit) { |
367 RC2_DestroyContext(RC2Context *cx, PRBool freeit) | 291 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
368 { | |
369 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
370 return; | |
371 (vector->p_RC2_DestroyContext)(cx, freeit); | 292 (vector->p_RC2_DestroyContext)(cx, freeit); |
372 } | 293 } |
373 | 294 |
374 SECStatus | 295 SECStatus RC2_Encrypt(RC2Context *cx, unsigned char *output, |
375 RC2_Encrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, | 296 unsigned int *outputLen, unsigned int maxOutputLen, |
376 » unsigned int maxOutputLen, const unsigned char *input, | 297 const unsigned char *input, unsigned int inputLen) { |
377 » unsigned int inputLen) | 298 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
378 { | 299 return (vector->p_RC2_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
379 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 300 inputLen); |
380 return SECFailure; | 301 } |
381 return (vector->p_RC2_Encrypt)(cx, output, outputLen, maxOutputLen, input,· | 302 |
382 » inputLen); | 303 SECStatus RC2_Decrypt(RC2Context *cx, unsigned char *output, |
383 } | 304 unsigned int *outputLen, unsigned int maxOutputLen, |
384 | 305 const unsigned char *input, unsigned int inputLen) { |
385 SECStatus | 306 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
386 RC2_Decrypt(RC2Context *cx, unsigned char *output, unsigned int *outputLen, | 307 return (vector->p_RC2_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
387 » unsigned int maxOutputLen, const unsigned char *input, | 308 inputLen); |
388 » unsigned int inputLen) | 309 } |
389 { | 310 |
390 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 311 RC5Context *RC5_CreateContext(const SECItem *key, unsigned int rounds, |
391 return SECFailure; | 312 unsigned int wordSize, const unsigned char *iv, |
392 return (vector->p_RC2_Decrypt)(cx, output, outputLen, maxOutputLen, input,· | 313 int mode) { |
393 » inputLen); | 314 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
394 } | |
395 | |
396 RC5Context * | |
397 RC5_CreateContext(const SECItem *key, unsigned int rounds, | |
398 » » unsigned int wordSize, const unsigned char *iv, int mode) | |
399 { | |
400 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
401 return NULL; | |
402 return (vector->p_RC5_CreateContext)(key, rounds, wordSize, iv, mode); | 315 return (vector->p_RC5_CreateContext)(key, rounds, wordSize, iv, mode); |
403 } | 316 } |
404 | 317 |
405 void | 318 void RC5_DestroyContext(RC5Context *cx, PRBool freeit) { |
406 RC5_DestroyContext(RC5Context *cx, PRBool freeit) | 319 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
407 { | |
408 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
409 return; | |
410 (vector->p_RC5_DestroyContext)(cx, freeit); | 320 (vector->p_RC5_DestroyContext)(cx, freeit); |
411 } | 321 } |
412 | 322 |
413 SECStatus | 323 SECStatus RC5_Encrypt(RC5Context *cx, unsigned char *output, |
414 RC5_Encrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, | 324 unsigned int *outputLen, unsigned int maxOutputLen, |
415 » unsigned int maxOutputLen, const unsigned char *input, | 325 const unsigned char *input, unsigned int inputLen) { |
416 » unsigned int inputLen) | 326 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
417 { | 327 return (vector->p_RC5_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
418 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 328 inputLen); |
419 return SECFailure; | 329 } |
420 return (vector->p_RC5_Encrypt)(cx, output, outputLen, maxOutputLen, input,· | 330 |
421 » » » » inputLen); | 331 SECStatus RC5_Decrypt(RC5Context *cx, unsigned char *output, |
422 } | 332 unsigned int *outputLen, unsigned int maxOutputLen, |
423 | 333 const unsigned char *input, unsigned int inputLen) { |
424 SECStatus | 334 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
425 RC5_Decrypt(RC5Context *cx, unsigned char *output, unsigned int *outputLen, | 335 return (vector->p_RC5_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
426 » unsigned int maxOutputLen, const unsigned char *input, | 336 inputLen); |
427 » unsigned int inputLen) | 337 } |
428 { | 338 |
429 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 339 DESContext *DES_CreateContext(const unsigned char *key, const unsigned char *iv, |
430 return SECFailure; | 340 int mode, PRBool encrypt) { |
431 return (vector->p_RC5_Decrypt)(cx, output, outputLen, maxOutputLen, input,· | 341 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
432 » inputLen); | |
433 } | |
434 | |
435 DESContext * | |
436 DES_CreateContext(const unsigned char *key, const unsigned char *iv, | |
437 » » int mode, PRBool encrypt) | |
438 { | |
439 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
440 return NULL; | |
441 return (vector->p_DES_CreateContext)(key, iv, mode, encrypt); | 342 return (vector->p_DES_CreateContext)(key, iv, mode, encrypt); |
442 } | 343 } |
443 | 344 |
444 void | 345 void DES_DestroyContext(DESContext *cx, PRBool freeit) { |
445 DES_DestroyContext(DESContext *cx, PRBool freeit) | 346 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
446 { | |
447 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
448 return; | |
449 (vector->p_DES_DestroyContext)(cx, freeit); | 347 (vector->p_DES_DestroyContext)(cx, freeit); |
450 } | 348 } |
451 | 349 |
452 SECStatus | 350 SECStatus DES_Encrypt(DESContext *cx, unsigned char *output, |
453 DES_Encrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, | 351 unsigned int *outputLen, unsigned int maxOutputLen, |
454 » unsigned int maxOutputLen, const unsigned char *input, | 352 const unsigned char *input, unsigned int inputLen) { |
455 » unsigned int inputLen) | 353 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
456 { | 354 return (vector->p_DES_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
457 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 355 inputLen); |
458 return SECFailure; | 356 } |
459 return (vector->p_DES_Encrypt)(cx, output, outputLen, maxOutputLen, input,· | 357 |
460 » inputLen); | 358 SECStatus DES_Decrypt(DESContext *cx, unsigned char *output, |
461 } | 359 unsigned int *outputLen, unsigned int maxOutputLen, |
462 | 360 const unsigned char *input, unsigned int inputLen) { |
463 SECStatus | 361 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
464 DES_Decrypt(DESContext *cx, unsigned char *output, unsigned int *outputLen, | 362 return (vector->p_DES_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
465 » unsigned int maxOutputLen, const unsigned char *input, | 363 inputLen); |
466 » unsigned int inputLen) | 364 } |
467 { | 365 SEEDContext *SEED_CreateContext(const unsigned char *key, |
468 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 366 const unsigned char *iv, int mode, |
469 return SECFailure; | 367 PRBool encrypt) { |
470 return (vector->p_DES_Decrypt)(cx, output, outputLen, maxOutputLen, input,· | 368 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
471 » inputLen); | |
472 } | |
473 SEEDContext * | |
474 SEED_CreateContext(const unsigned char *key, const unsigned char *iv, | |
475 » » int mode, PRBool encrypt) | |
476 { | |
477 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
478 return NULL; | |
479 return (vector->p_SEED_CreateContext)(key, iv, mode, encrypt); | 369 return (vector->p_SEED_CreateContext)(key, iv, mode, encrypt); |
480 } | 370 } |
481 | 371 |
482 void | 372 void SEED_DestroyContext(SEEDContext *cx, PRBool freeit) { |
483 SEED_DestroyContext(SEEDContext *cx, PRBool freeit) | 373 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
484 { | |
485 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
486 return; | |
487 (vector->p_SEED_DestroyContext)(cx, freeit); | 374 (vector->p_SEED_DestroyContext)(cx, freeit); |
488 } | 375 } |
489 | 376 |
490 SECStatus | 377 SECStatus SEED_Encrypt(SEEDContext *cx, unsigned char *output, |
491 SEED_Encrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, | 378 unsigned int *outputLen, unsigned int maxOutputLen, |
492 » unsigned int maxOutputLen, const unsigned char *input, | 379 const unsigned char *input, unsigned int inputLen) { |
493 » unsigned int inputLen) | 380 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
494 { | 381 return (vector->p_SEED_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
495 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 382 inputLen); |
496 return SECFailure; | 383 } |
497 return (vector->p_SEED_Encrypt)(cx, output, outputLen, maxOutputLen, input,· | 384 |
498 » inputLen); | 385 SECStatus SEED_Decrypt(SEEDContext *cx, unsigned char *output, |
499 } | 386 unsigned int *outputLen, unsigned int maxOutputLen, |
500 | 387 const unsigned char *input, unsigned int inputLen) { |
501 SECStatus | 388 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
502 SEED_Decrypt(SEEDContext *cx, unsigned char *output, unsigned int *outputLen, | 389 return (vector->p_SEED_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
503 » unsigned int maxOutputLen, const unsigned char *input, | 390 inputLen); |
504 » unsigned int inputLen) | 391 } |
505 { | 392 |
506 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 393 AESContext *AES_CreateContext(const unsigned char *key, const unsigned char *iv, |
507 return SECFailure; | 394 int mode, int encrypt, unsigned int keylen, |
508 return (vector->p_SEED_Decrypt)(cx, output, outputLen, maxOutputLen, input,· | 395 unsigned int blocklen) { |
509 » inputLen); | 396 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
510 } | 397 return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen, |
511 | 398 blocklen); |
512 AESContext * | 399 } |
513 AES_CreateContext(const unsigned char *key, const unsigned char *iv,· | 400 |
514 int mode, int encrypt, | 401 void AES_DestroyContext(AESContext *cx, PRBool freeit) { |
515 unsigned int keylen, unsigned int blocklen) | 402 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
516 { | |
517 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
518 return NULL; | |
519 return (vector->p_AES_CreateContext)(key, iv, mode, encrypt, keylen,· | |
520 » » » » blocklen); | |
521 } | |
522 | |
523 void | |
524 AES_DestroyContext(AESContext *cx, PRBool freeit) | |
525 { | |
526 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
527 return ; | |
528 (vector->p_AES_DestroyContext)(cx, freeit); | 403 (vector->p_AES_DestroyContext)(cx, freeit); |
529 } | 404 } |
530 | 405 |
531 SECStatus | 406 SECStatus AES_Encrypt(AESContext *cx, unsigned char *output, |
532 AES_Encrypt(AESContext *cx, unsigned char *output, | 407 unsigned int *outputLen, unsigned int maxOutputLen, |
533 unsigned int *outputLen, unsigned int maxOutputLen, | 408 const unsigned char *input, unsigned int inputLen) { |
534 const unsigned char *input, unsigned int inputLen) | 409 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
535 { | 410 return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, input, |
536 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 411 inputLen); |
537 return SECFailure; | 412 } |
538 return (vector->p_AES_Encrypt)(cx, output, outputLen, maxOutputLen, | 413 |
539 » » » » input, inputLen); | 414 SECStatus AES_Decrypt(AESContext *cx, unsigned char *output, |
540 } | 415 unsigned int *outputLen, unsigned int maxOutputLen, |
541 | 416 const unsigned char *input, unsigned int inputLen) { |
542 SECStatus | 417 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
543 AES_Decrypt(AESContext *cx, unsigned char *output, | 418 return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, input, |
544 unsigned int *outputLen, unsigned int maxOutputLen, | 419 inputLen); |
545 const unsigned char *input, unsigned int inputLen) | 420 } |
546 { | 421 |
547 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 422 SECStatus MD5_Hash(unsigned char *dest, const char *src) { |
548 return SECFailure; | 423 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
549 return (vector->p_AES_Decrypt)(cx, output, outputLen, maxOutputLen, | |
550 » » » » input, inputLen); | |
551 } | |
552 | |
553 SECStatus | |
554 MD5_Hash(unsigned char *dest, const char *src) | |
555 { | |
556 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
557 return SECFailure; | |
558 return (vector->p_MD5_Hash)(dest, src); | 424 return (vector->p_MD5_Hash)(dest, src); |
559 } | 425 } |
560 | 426 |
561 SECStatus | 427 SECStatus MD5_HashBuf(unsigned char *dest, const unsigned char *src, |
562 MD5_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) | 428 PRUint32 src_length) { |
563 { | 429 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
564 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
565 return SECFailure; | |
566 return (vector->p_MD5_HashBuf)(dest, src, src_length); | 430 return (vector->p_MD5_HashBuf)(dest, src, src_length); |
567 } | 431 } |
568 | 432 |
569 MD5Context * | 433 MD5Context *MD5_NewContext(void) { |
570 MD5_NewContext(void) | 434 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
571 { | |
572 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
573 return NULL; | |
574 return (vector->p_MD5_NewContext)(); | 435 return (vector->p_MD5_NewContext)(); |
575 } | 436 } |
576 | 437 |
577 void | 438 void MD5_DestroyContext(MD5Context *cx, PRBool freeit) { |
578 MD5_DestroyContext(MD5Context *cx, PRBool freeit) | 439 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
579 { | |
580 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
581 return; | |
582 (vector->p_MD5_DestroyContext)(cx, freeit); | 440 (vector->p_MD5_DestroyContext)(cx, freeit); |
583 } | 441 } |
584 | 442 |
585 void | 443 void MD5_Begin(MD5Context *cx) { |
586 MD5_Begin(MD5Context *cx) | 444 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
587 { | |
588 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
589 return; | |
590 (vector->p_MD5_Begin)(cx); | 445 (vector->p_MD5_Begin)(cx); |
591 } | 446 } |
592 | 447 |
593 void | 448 void MD5_Update(MD5Context *cx, const unsigned char *input, |
594 MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen) | 449 unsigned int inputLen) { |
595 { | 450 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
596 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
597 return; | |
598 (vector->p_MD5_Update)(cx, input, inputLen); | 451 (vector->p_MD5_Update)(cx, input, inputLen); |
599 } | 452 } |
600 | 453 |
601 void | 454 void MD5_End(MD5Context *cx, unsigned char *digest, unsigned int *digestLen, |
602 MD5_End(MD5Context *cx, unsigned char *digest, | 455 unsigned int maxDigestLen) { |
603 » » unsigned int *digestLen, unsigned int maxDigestLen) | 456 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
604 { | |
605 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
606 return; | |
607 (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen); | 457 (vector->p_MD5_End)(cx, digest, digestLen, maxDigestLen); |
608 } | 458 } |
609 | 459 |
610 unsigned int | 460 unsigned int MD5_FlattenSize(MD5Context *cx) { |
611 MD5_FlattenSize(MD5Context *cx) | 461 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
612 { | |
613 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
614 return 0; | |
615 return (vector->p_MD5_FlattenSize)(cx); | 462 return (vector->p_MD5_FlattenSize)(cx); |
616 } | 463 } |
617 | 464 |
618 SECStatus | 465 SECStatus MD5_Flatten(MD5Context *cx, unsigned char *space) { |
619 MD5_Flatten(MD5Context *cx,unsigned char *space) | 466 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
620 { | |
621 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
622 return SECFailure; | |
623 return (vector->p_MD5_Flatten)(cx, space); | 467 return (vector->p_MD5_Flatten)(cx, space); |
624 } | 468 } |
625 | 469 |
626 MD5Context *· | 470 MD5Context *MD5_Resurrect(unsigned char *space, void *arg) { |
627 MD5_Resurrect(unsigned char *space, void *arg) | 471 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
628 { | |
629 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
630 return NULL; | |
631 return (vector->p_MD5_Resurrect)(space, arg); | 472 return (vector->p_MD5_Resurrect)(space, arg); |
632 } | 473 } |
633 | 474 |
634 void | 475 void MD5_TraceState(MD5Context *cx) { |
635 MD5_TraceState(MD5Context *cx) | 476 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
636 { | |
637 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
638 return ; | |
639 (vector->p_MD5_TraceState)(cx); | 477 (vector->p_MD5_TraceState)(cx); |
640 } | 478 } |
641 | 479 |
642 SECStatus | 480 SECStatus MD2_Hash(unsigned char *dest, const char *src) { |
643 MD2_Hash(unsigned char *dest, const char *src) | 481 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
644 { | |
645 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
646 return SECFailure; | |
647 return (vector->p_MD2_Hash)(dest, src); | 482 return (vector->p_MD2_Hash)(dest, src); |
648 } | 483 } |
649 | 484 |
650 MD2Context * | 485 MD2Context *MD2_NewContext(void) { |
651 MD2_NewContext(void) | 486 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
652 { | |
653 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
654 return NULL; | |
655 return (vector->p_MD2_NewContext)(); | 487 return (vector->p_MD2_NewContext)(); |
656 } | 488 } |
657 | 489 |
658 void | 490 void MD2_DestroyContext(MD2Context *cx, PRBool freeit) { |
659 MD2_DestroyContext(MD2Context *cx, PRBool freeit) | 491 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
660 { | |
661 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
662 return ; | |
663 (vector->p_MD2_DestroyContext)(cx, freeit); | 492 (vector->p_MD2_DestroyContext)(cx, freeit); |
664 } | 493 } |
665 | 494 |
666 void | 495 void MD2_Begin(MD2Context *cx) { |
667 MD2_Begin(MD2Context *cx) | 496 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
668 { | |
669 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
670 return ; | |
671 (vector->p_MD2_Begin)(cx); | 497 (vector->p_MD2_Begin)(cx); |
672 } | 498 } |
673 | 499 |
674 void | 500 void MD2_Update(MD2Context *cx, const unsigned char *input, |
675 MD2_Update(MD2Context *cx, const unsigned char *input, unsigned int inputLen) | 501 unsigned int inputLen) { |
676 { | 502 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
677 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
678 return ; | |
679 (vector->p_MD2_Update)(cx, input, inputLen); | 503 (vector->p_MD2_Update)(cx, input, inputLen); |
680 } | 504 } |
681 | 505 |
682 void | 506 void MD2_End(MD2Context *cx, unsigned char *digest, unsigned int *digestLen, |
683 MD2_End(MD2Context *cx, unsigned char *digest, | 507 unsigned int maxDigestLen) { |
684 » » unsigned int *digestLen, unsigned int maxDigestLen) | 508 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
685 { | |
686 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
687 return ; | |
688 (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen); | 509 (vector->p_MD2_End)(cx, digest, digestLen, maxDigestLen); |
689 } | 510 } |
690 | 511 |
691 unsigned int | 512 unsigned int MD2_FlattenSize(MD2Context *cx) { |
692 MD2_FlattenSize(MD2Context *cx) | 513 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
693 { | |
694 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
695 return 0; | |
696 return (vector->p_MD2_FlattenSize)(cx); | 514 return (vector->p_MD2_FlattenSize)(cx); |
697 } | 515 } |
698 | 516 |
699 SECStatus | 517 SECStatus MD2_Flatten(MD2Context *cx, unsigned char *space) { |
700 MD2_Flatten(MD2Context *cx,unsigned char *space) | 518 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
701 { | |
702 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
703 return SECFailure; | |
704 return (vector->p_MD2_Flatten)(cx, space); | 519 return (vector->p_MD2_Flatten)(cx, space); |
705 } | 520 } |
706 | 521 |
707 MD2Context *· | 522 MD2Context *MD2_Resurrect(unsigned char *space, void *arg) { |
708 MD2_Resurrect(unsigned char *space, void *arg) | 523 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
709 { | |
710 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
711 return NULL; | |
712 return (vector->p_MD2_Resurrect)(space, arg); | 524 return (vector->p_MD2_Resurrect)(space, arg); |
713 } | 525 } |
714 | 526 |
715 | 527 SECStatus SHA1_Hash(unsigned char *dest, const char *src) { |
716 SECStatus | 528 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
717 SHA1_Hash(unsigned char *dest, const char *src) | |
718 { | |
719 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
720 return SECFailure; | |
721 return (vector->p_SHA1_Hash)(dest, src); | 529 return (vector->p_SHA1_Hash)(dest, src); |
722 } | 530 } |
723 | 531 |
724 SECStatus | 532 SECStatus SHA1_HashBuf(unsigned char *dest, const unsigned char *src, |
725 SHA1_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_length) | 533 PRUint32 src_length) { |
726 { | 534 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
727 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
728 return SECFailure; | |
729 return (vector->p_SHA1_HashBuf)(dest, src, src_length); | 535 return (vector->p_SHA1_HashBuf)(dest, src, src_length); |
730 } | 536 } |
731 | 537 |
732 SHA1Context * | 538 SHA1Context *SHA1_NewContext(void) { |
733 SHA1_NewContext(void) | 539 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
734 { | |
735 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
736 return NULL; | |
737 return (vector->p_SHA1_NewContext)(); | 540 return (vector->p_SHA1_NewContext)(); |
738 } | 541 } |
739 | 542 |
740 void | 543 void SHA1_DestroyContext(SHA1Context *cx, PRBool freeit) { |
741 SHA1_DestroyContext(SHA1Context *cx, PRBool freeit) | 544 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
742 { | |
743 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
744 return ; | |
745 (vector->p_SHA1_DestroyContext)(cx, freeit); | 545 (vector->p_SHA1_DestroyContext)(cx, freeit); |
746 } | 546 } |
747 | 547 |
748 void | 548 void SHA1_Begin(SHA1Context *cx) { |
749 SHA1_Begin(SHA1Context *cx) | 549 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
750 { | |
751 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
752 return ; | |
753 (vector->p_SHA1_Begin)(cx); | 550 (vector->p_SHA1_Begin)(cx); |
754 } | 551 } |
755 | 552 |
756 void | 553 void SHA1_Update(SHA1Context *cx, const unsigned char *input, |
757 SHA1_Update(SHA1Context *cx, const unsigned char *input, | 554 unsigned int inputLen) { |
758 » » » unsigned int inputLen) | 555 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
759 { | |
760 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
761 return ; | |
762 (vector->p_SHA1_Update)(cx, input, inputLen); | 556 (vector->p_SHA1_Update)(cx, input, inputLen); |
763 } | 557 } |
764 | 558 |
765 void | 559 void SHA1_End(SHA1Context *cx, unsigned char *digest, unsigned int *digestLen, |
766 SHA1_End(SHA1Context *cx, unsigned char *digest, | 560 unsigned int maxDigestLen) { |
767 » » unsigned int *digestLen, unsigned int maxDigestLen) | 561 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
768 { | |
769 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
770 return ; | |
771 (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen); | 562 (vector->p_SHA1_End)(cx, digest, digestLen, maxDigestLen); |
772 } | 563 } |
773 | 564 |
774 void | 565 void SHA1_TraceState(SHA1Context *cx) { |
775 SHA1_TraceState(SHA1Context *cx) | 566 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
776 { | |
777 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
778 return ; | |
779 (vector->p_SHA1_TraceState)(cx); | 567 (vector->p_SHA1_TraceState)(cx); |
780 } | 568 } |
781 | 569 |
782 unsigned int | 570 unsigned int SHA1_FlattenSize(SHA1Context *cx) { |
783 SHA1_FlattenSize(SHA1Context *cx) | 571 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
784 { | |
785 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
786 return 0; | |
787 return (vector->p_SHA1_FlattenSize)(cx); | 572 return (vector->p_SHA1_FlattenSize)(cx); |
788 } | 573 } |
789 | 574 |
790 SECStatus | 575 SECStatus SHA1_Flatten(SHA1Context *cx, unsigned char *space) { |
791 SHA1_Flatten(SHA1Context *cx,unsigned char *space) | 576 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
792 { | |
793 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
794 return SECFailure; | |
795 return (vector->p_SHA1_Flatten)(cx, space); | 577 return (vector->p_SHA1_Flatten)(cx, space); |
796 } | 578 } |
797 | 579 |
798 SHA1Context *· | 580 SHA1Context *SHA1_Resurrect(unsigned char *space, void *arg) { |
799 SHA1_Resurrect(unsigned char *space, void *arg) | 581 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
800 { | |
801 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
802 return NULL; | |
803 return (vector->p_SHA1_Resurrect)(space, arg); | 582 return (vector->p_SHA1_Resurrect)(space, arg); |
804 } | 583 } |
805 | 584 |
806 SECStatus | 585 SECStatus RNG_RNGInit(void) { |
807 RNG_RNGInit(void) | 586 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
808 { | |
809 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
810 return SECFailure; | |
811 return (vector->p_RNG_RNGInit)(); | 587 return (vector->p_RNG_RNGInit)(); |
812 } | 588 } |
813 | 589 |
814 SECStatus | 590 SECStatus RNG_RandomUpdate(const void *data, size_t bytes) { |
815 RNG_RandomUpdate(const void *data, size_t bytes) | 591 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
816 { | |
817 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
818 return SECFailure; | |
819 return (vector->p_RNG_RandomUpdate)(data, bytes); | 592 return (vector->p_RNG_RandomUpdate)(data, bytes); |
820 } | 593 } |
821 | 594 |
822 SECStatus | 595 SECStatus RNG_GenerateGlobalRandomBytes(void *dest, size_t len) { |
823 RNG_GenerateGlobalRandomBytes(void *dest, size_t len) | 596 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
824 { | |
825 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
826 return SECFailure; | |
827 return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len); | 597 return (vector->p_RNG_GenerateGlobalRandomBytes)(dest, len); |
828 } | 598 } |
829 | 599 |
830 void · | 600 void RNG_RNGShutdown(void) { |
831 RNG_RNGShutdown(void) | 601 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
832 { | |
833 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
834 return ; | |
835 (vector->p_RNG_RNGShutdown)(); | 602 (vector->p_RNG_RNGShutdown)(); |
836 } | 603 } |
837 | 604 |
838 SECStatus | 605 SECStatus PQG_ParamGen(unsigned int j, PQGParams **pParams, PQGVerify **pVfy) { |
839 PQG_ParamGen(unsigned int j, PQGParams **pParams, PQGVerify **pVfy) | 606 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
840 { | 607 return (vector->p_PQG_ParamGen)(j, pParams, pVfy); |
841 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 608 } |
842 return SECFailure; | 609 |
843 return (vector->p_PQG_ParamGen)(j, pParams, pVfy); | 610 SECStatus PQG_ParamGenSeedLen(unsigned int j, unsigned int seedBytes, |
844 } | 611 PQGParams **pParams, PQGVerify **pVfy) { |
845 | 612 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
846 SECStatus | |
847 PQG_ParamGenSeedLen( unsigned int j, unsigned int seedBytes,· | |
848 PQGParams **pParams, PQGVerify **pVfy) | |
849 { | |
850 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
851 return SECFailure; | |
852 return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy); | 613 return (vector->p_PQG_ParamGenSeedLen)(j, seedBytes, pParams, pVfy); |
853 } | 614 } |
854 | 615 |
855 | 616 SECStatus PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy, |
856 SECStatus ·· | 617 SECStatus *result) { |
857 PQG_VerifyParams(const PQGParams *params, const PQGVerify *vfy,· | 618 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
858 » » SECStatus *result) | |
859 { | |
860 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
861 return SECFailure; | |
862 return (vector->p_PQG_VerifyParams)(params, vfy, result); | 619 return (vector->p_PQG_VerifyParams)(params, vfy, result); |
863 } | 620 } |
864 | 621 |
865 void ·· | 622 void PQG_DestroyParams(PQGParams *params) { |
866 PQG_DestroyParams(PQGParams *params) | 623 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
867 { | |
868 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
869 return; | |
870 (vector->p_PQG_DestroyParams)(params); | 624 (vector->p_PQG_DestroyParams)(params); |
871 } | 625 } |
872 | 626 |
873 void ·· | 627 void PQG_DestroyVerify(PQGVerify *vfy) { |
874 PQG_DestroyVerify(PQGVerify *vfy) | 628 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
875 { | |
876 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
877 return; | |
878 (vector->p_PQG_DestroyVerify)(vfy); | 629 (vector->p_PQG_DestroyVerify)(vfy); |
879 } | 630 } |
880 | 631 |
881 void | 632 void BL_Cleanup(void) { |
882 BL_Cleanup(void) | 633 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
883 { | |
884 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
885 return; | |
886 (vector->p_BL_Cleanup)(); | 634 (vector->p_BL_Cleanup)(); |
887 } | 635 } |
888 | 636 |
889 void | 637 void BL_Unload(void) { |
890 BL_Unload(void) | |
891 { | |
892 /* This function is not thread-safe, but doesn't need to be, because it is | 638 /* This function is not thread-safe, but doesn't need to be, because it is |
893 * only called from functions that are also defined as not thread-safe, | 639 * only called from functions that are also defined as not thread-safe, |
894 * namely C_Finalize in softoken, and the SSL bypass shutdown callback called | 640 * namely C_Finalize in softoken, and the SSL bypass shutdown callback called |
895 * from NSS_Shutdown. */ | 641 * from NSS_Shutdown. */ |
896 char *disableUnload = NULL; | 642 char *disableUnload = NULL; |
897 vector = NULL; | 643 vector = NULL; |
898 /* If an SSL socket is configured with SSL_BYPASS_PKCS11, but the application | 644 /* If an SSL socket is configured with SSL_BYPASS_PKCS11, but the application |
899 * never does a handshake on it, BL_Unload will be called even though freebl | 645 * never does a handshake on it, BL_Unload will be called even though freebl |
900 * was never loaded. So, don't assert blLib. */ | 646 * was never loaded. So, don't assert blLib. */ |
901 if (blLib) { | 647 if (blLib) { |
902 disableUnload = PR_GetEnv("NSS_DISABLE_UNLOAD"); | 648 disableUnload = PR_GetEnv("NSS_DISABLE_UNLOAD"); |
903 if (!disableUnload) { | 649 if (!disableUnload) { |
904 PRStatus status = PR_UnloadLibrary(blLib); | 650 PRStatus status = PR_UnloadLibrary(blLib); |
905 PORT_Assert(PR_SUCCESS == status); | 651 PORT_Assert(PR_SUCCESS == status); |
906 } | 652 } |
907 blLib = NULL; | 653 blLib = NULL; |
908 } | 654 } |
909 loadFreeBLOnce = pristineCallOnce; | 655 loadFreeBLOnce = pristineCallOnce; |
910 } | 656 } |
911 | 657 |
912 /* ============== New for 3.003 =============================== */ | 658 /* ============== New for 3.003 =============================== */ |
913 | 659 |
914 SECStatus | 660 SECStatus SHA256_Hash(unsigned char *dest, const char *src) { |
915 SHA256_Hash(unsigned char *dest, const char *src) | 661 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
916 { | |
917 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
918 return SECFailure; | |
919 return (vector->p_SHA256_Hash)(dest, src); | 662 return (vector->p_SHA256_Hash)(dest, src); |
920 } | 663 } |
921 | 664 |
922 SECStatus | 665 SECStatus SHA256_HashBuf(unsigned char *dest, const unsigned char *src, |
923 SHA256_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_lengt
h) | 666 PRUint32 src_length) { |
924 { | 667 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
925 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
926 return SECFailure; | |
927 return (vector->p_SHA256_HashBuf)(dest, src, src_length); | 668 return (vector->p_SHA256_HashBuf)(dest, src, src_length); |
928 } | 669 } |
929 | 670 |
930 SHA256Context * | 671 SHA256Context *SHA256_NewContext(void) { |
931 SHA256_NewContext(void) | 672 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
932 { | |
933 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
934 return NULL; | |
935 return (vector->p_SHA256_NewContext)(); | 673 return (vector->p_SHA256_NewContext)(); |
936 } | 674 } |
937 | 675 |
938 void | 676 void SHA256_DestroyContext(SHA256Context *cx, PRBool freeit) { |
939 SHA256_DestroyContext(SHA256Context *cx, PRBool freeit) | 677 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
940 { | |
941 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
942 return ; | |
943 (vector->p_SHA256_DestroyContext)(cx, freeit); | 678 (vector->p_SHA256_DestroyContext)(cx, freeit); |
944 } | 679 } |
945 | 680 |
946 void | 681 void SHA256_Begin(SHA256Context *cx) { |
947 SHA256_Begin(SHA256Context *cx) | 682 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
948 { | |
949 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
950 return ; | |
951 (vector->p_SHA256_Begin)(cx); | 683 (vector->p_SHA256_Begin)(cx); |
952 } | 684 } |
953 | 685 |
954 void | 686 void SHA256_Update(SHA256Context *cx, const unsigned char *input, |
955 SHA256_Update(SHA256Context *cx, const unsigned char *input, | 687 unsigned int inputLen) { |
956 » » » unsigned int inputLen) | 688 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
957 { | |
958 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
959 return ; | |
960 (vector->p_SHA256_Update)(cx, input, inputLen); | 689 (vector->p_SHA256_Update)(cx, input, inputLen); |
961 } | 690 } |
962 | 691 |
963 void | 692 void SHA256_End(SHA256Context *cx, unsigned char *digest, |
964 SHA256_End(SHA256Context *cx, unsigned char *digest, | 693 unsigned int *digestLen, unsigned int maxDigestLen) { |
965 » » unsigned int *digestLen, unsigned int maxDigestLen) | 694 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
966 { | |
967 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
968 return ; | |
969 (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen); | 695 (vector->p_SHA256_End)(cx, digest, digestLen, maxDigestLen); |
970 } | 696 } |
971 | 697 |
972 void | 698 void SHA256_TraceState(SHA256Context *cx) { |
973 SHA256_TraceState(SHA256Context *cx) | 699 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
974 { | |
975 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
976 return ; | |
977 (vector->p_SHA256_TraceState)(cx); | 700 (vector->p_SHA256_TraceState)(cx); |
978 } | 701 } |
979 | 702 |
980 unsigned int | 703 unsigned int SHA256_FlattenSize(SHA256Context *cx) { |
981 SHA256_FlattenSize(SHA256Context *cx) | 704 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
982 { | |
983 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
984 return 0; | |
985 return (vector->p_SHA256_FlattenSize)(cx); | 705 return (vector->p_SHA256_FlattenSize)(cx); |
986 } | 706 } |
987 | 707 |
988 SECStatus | 708 SECStatus SHA256_Flatten(SHA256Context *cx, unsigned char *space) { |
989 SHA256_Flatten(SHA256Context *cx,unsigned char *space) | 709 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
990 { | |
991 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
992 return SECFailure; | |
993 return (vector->p_SHA256_Flatten)(cx, space); | 710 return (vector->p_SHA256_Flatten)(cx, space); |
994 } | 711 } |
995 | 712 |
996 SHA256Context *· | 713 SHA256Context *SHA256_Resurrect(unsigned char *space, void *arg) { |
997 SHA256_Resurrect(unsigned char *space, void *arg) | 714 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
998 { | |
999 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1000 return NULL; | |
1001 return (vector->p_SHA256_Resurrect)(space, arg); | 715 return (vector->p_SHA256_Resurrect)(space, arg); |
1002 } | 716 } |
1003 | 717 |
1004 SECStatus | 718 SECStatus SHA512_Hash(unsigned char *dest, const char *src) { |
1005 SHA512_Hash(unsigned char *dest, const char *src) | 719 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1006 { | |
1007 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1008 return SECFailure; | |
1009 return (vector->p_SHA512_Hash)(dest, src); | 720 return (vector->p_SHA512_Hash)(dest, src); |
1010 } | 721 } |
1011 | 722 |
1012 SECStatus | 723 SECStatus SHA512_HashBuf(unsigned char *dest, const unsigned char *src, |
1013 SHA512_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_lengt
h) | 724 PRUint32 src_length) { |
1014 { | 725 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1015 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1016 return SECFailure; | |
1017 return (vector->p_SHA512_HashBuf)(dest, src, src_length); | 726 return (vector->p_SHA512_HashBuf)(dest, src, src_length); |
1018 } | 727 } |
1019 | 728 |
1020 SHA512Context * | 729 SHA512Context *SHA512_NewContext(void) { |
1021 SHA512_NewContext(void) | 730 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1022 { | |
1023 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1024 return NULL; | |
1025 return (vector->p_SHA512_NewContext)(); | 731 return (vector->p_SHA512_NewContext)(); |
1026 } | 732 } |
1027 | 733 |
1028 void | 734 void SHA512_DestroyContext(SHA512Context *cx, PRBool freeit) { |
1029 SHA512_DestroyContext(SHA512Context *cx, PRBool freeit) | 735 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1030 { | |
1031 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1032 return ; | |
1033 (vector->p_SHA512_DestroyContext)(cx, freeit); | 736 (vector->p_SHA512_DestroyContext)(cx, freeit); |
1034 } | 737 } |
1035 | 738 |
1036 void | 739 void SHA512_Begin(SHA512Context *cx) { |
1037 SHA512_Begin(SHA512Context *cx) | 740 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1038 { | |
1039 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1040 return ; | |
1041 (vector->p_SHA512_Begin)(cx); | 741 (vector->p_SHA512_Begin)(cx); |
1042 } | 742 } |
1043 | 743 |
1044 void | 744 void SHA512_Update(SHA512Context *cx, const unsigned char *input, |
1045 SHA512_Update(SHA512Context *cx, const unsigned char *input, | 745 unsigned int inputLen) { |
1046 » » » unsigned int inputLen) | 746 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1047 { | |
1048 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1049 return ; | |
1050 (vector->p_SHA512_Update)(cx, input, inputLen); | 747 (vector->p_SHA512_Update)(cx, input, inputLen); |
1051 } | 748 } |
1052 | 749 |
1053 void | 750 void SHA512_End(SHA512Context *cx, unsigned char *digest, |
1054 SHA512_End(SHA512Context *cx, unsigned char *digest, | 751 unsigned int *digestLen, unsigned int maxDigestLen) { |
1055 » » unsigned int *digestLen, unsigned int maxDigestLen) | 752 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1056 { | |
1057 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1058 return ; | |
1059 (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen); | 753 (vector->p_SHA512_End)(cx, digest, digestLen, maxDigestLen); |
1060 } | 754 } |
1061 | 755 |
1062 void | 756 void SHA512_TraceState(SHA512Context *cx) { |
1063 SHA512_TraceState(SHA512Context *cx) | 757 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1064 { | |
1065 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1066 return ; | |
1067 (vector->p_SHA512_TraceState)(cx); | 758 (vector->p_SHA512_TraceState)(cx); |
1068 } | 759 } |
1069 | 760 |
1070 unsigned int | 761 unsigned int SHA512_FlattenSize(SHA512Context *cx) { |
1071 SHA512_FlattenSize(SHA512Context *cx) | 762 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
1072 { | |
1073 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1074 return 0; | |
1075 return (vector->p_SHA512_FlattenSize)(cx); | 763 return (vector->p_SHA512_FlattenSize)(cx); |
1076 } | 764 } |
1077 | 765 |
1078 SECStatus | 766 SECStatus SHA512_Flatten(SHA512Context *cx, unsigned char *space) { |
1079 SHA512_Flatten(SHA512Context *cx,unsigned char *space) | 767 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1080 { | |
1081 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1082 return SECFailure; | |
1083 return (vector->p_SHA512_Flatten)(cx, space); | 768 return (vector->p_SHA512_Flatten)(cx, space); |
1084 } | 769 } |
1085 | 770 |
1086 SHA512Context *· | 771 SHA512Context *SHA512_Resurrect(unsigned char *space, void *arg) { |
1087 SHA512_Resurrect(unsigned char *space, void *arg) | 772 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1088 { | |
1089 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1090 return NULL; | |
1091 return (vector->p_SHA512_Resurrect)(space, arg); | 773 return (vector->p_SHA512_Resurrect)(space, arg); |
1092 } | 774 } |
1093 | 775 |
1094 | 776 SECStatus SHA384_Hash(unsigned char *dest, const char *src) { |
1095 SECStatus | 777 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1096 SHA384_Hash(unsigned char *dest, const char *src) | |
1097 { | |
1098 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1099 return SECFailure; | |
1100 return (vector->p_SHA384_Hash)(dest, src); | 778 return (vector->p_SHA384_Hash)(dest, src); |
1101 } | 779 } |
1102 | 780 |
1103 SECStatus | 781 SECStatus SHA384_HashBuf(unsigned char *dest, const unsigned char *src, |
1104 SHA384_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_lengt
h) | 782 PRUint32 src_length) { |
1105 { | 783 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1106 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1107 return SECFailure; | |
1108 return (vector->p_SHA384_HashBuf)(dest, src, src_length); | 784 return (vector->p_SHA384_HashBuf)(dest, src, src_length); |
1109 } | 785 } |
1110 | 786 |
1111 SHA384Context * | 787 SHA384Context *SHA384_NewContext(void) { |
1112 SHA384_NewContext(void) | 788 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1113 { | |
1114 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1115 return NULL; | |
1116 return (vector->p_SHA384_NewContext)(); | 789 return (vector->p_SHA384_NewContext)(); |
1117 } | 790 } |
1118 | 791 |
1119 void | 792 void SHA384_DestroyContext(SHA384Context *cx, PRBool freeit) { |
1120 SHA384_DestroyContext(SHA384Context *cx, PRBool freeit) | 793 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1121 { | |
1122 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1123 return ; | |
1124 (vector->p_SHA384_DestroyContext)(cx, freeit); | 794 (vector->p_SHA384_DestroyContext)(cx, freeit); |
1125 } | 795 } |
1126 | 796 |
1127 void | 797 void SHA384_Begin(SHA384Context *cx) { |
1128 SHA384_Begin(SHA384Context *cx) | 798 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1129 { | |
1130 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1131 return ; | |
1132 (vector->p_SHA384_Begin)(cx); | 799 (vector->p_SHA384_Begin)(cx); |
1133 } | 800 } |
1134 | 801 |
1135 void | 802 void SHA384_Update(SHA384Context *cx, const unsigned char *input, |
1136 SHA384_Update(SHA384Context *cx, const unsigned char *input, | 803 unsigned int inputLen) { |
1137 » » » unsigned int inputLen) | 804 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1138 { | |
1139 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1140 return ; | |
1141 (vector->p_SHA384_Update)(cx, input, inputLen); | 805 (vector->p_SHA384_Update)(cx, input, inputLen); |
1142 } | 806 } |
1143 | 807 |
1144 void | 808 void SHA384_End(SHA384Context *cx, unsigned char *digest, |
1145 SHA384_End(SHA384Context *cx, unsigned char *digest, | 809 unsigned int *digestLen, unsigned int maxDigestLen) { |
1146 » » unsigned int *digestLen, unsigned int maxDigestLen) | 810 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1147 { | |
1148 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1149 return ; | |
1150 (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen); | 811 (vector->p_SHA384_End)(cx, digest, digestLen, maxDigestLen); |
1151 } | 812 } |
1152 | 813 |
1153 void | 814 void SHA384_TraceState(SHA384Context *cx) { |
1154 SHA384_TraceState(SHA384Context *cx) | 815 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1155 { | |
1156 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1157 return ; | |
1158 (vector->p_SHA384_TraceState)(cx); | 816 (vector->p_SHA384_TraceState)(cx); |
1159 } | 817 } |
1160 | 818 |
1161 unsigned int | 819 unsigned int SHA384_FlattenSize(SHA384Context *cx) { |
1162 SHA384_FlattenSize(SHA384Context *cx) | 820 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
1163 { | |
1164 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1165 return 0; | |
1166 return (vector->p_SHA384_FlattenSize)(cx); | 821 return (vector->p_SHA384_FlattenSize)(cx); |
1167 } | 822 } |
1168 | 823 |
1169 SECStatus | 824 SECStatus SHA384_Flatten(SHA384Context *cx, unsigned char *space) { |
1170 SHA384_Flatten(SHA384Context *cx,unsigned char *space) | 825 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1171 { | |
1172 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1173 return SECFailure; | |
1174 return (vector->p_SHA384_Flatten)(cx, space); | 826 return (vector->p_SHA384_Flatten)(cx, space); |
1175 } | 827 } |
1176 | 828 |
1177 SHA384Context *· | 829 SHA384Context *SHA384_Resurrect(unsigned char *space, void *arg) { |
1178 SHA384_Resurrect(unsigned char *space, void *arg) | 830 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1179 { | |
1180 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1181 return NULL; | |
1182 return (vector->p_SHA384_Resurrect)(space, arg); | 831 return (vector->p_SHA384_Resurrect)(space, arg); |
1183 } | 832 } |
1184 | 833 |
1185 | 834 AESKeyWrapContext *AESKeyWrap_CreateContext(const unsigned char *key, |
1186 AESKeyWrapContext * | 835 const unsigned char *iv, |
1187 AESKeyWrap_CreateContext(const unsigned char *key, const unsigned char *iv,· | 836 int encrypt, unsigned int keylen) { |
1188 int encrypt, unsigned int keylen) | 837 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1189 { | |
1190 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1191 return NULL; | |
1192 return vector->p_AESKeyWrap_CreateContext(key, iv, encrypt, keylen); | 838 return vector->p_AESKeyWrap_CreateContext(key, iv, encrypt, keylen); |
1193 } | 839 } |
1194 | 840 |
1195 void | 841 void AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) { |
1196 AESKeyWrap_DestroyContext(AESKeyWrapContext *cx, PRBool freeit) | 842 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1197 { | |
1198 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1199 return; | |
1200 vector->p_AESKeyWrap_DestroyContext(cx, freeit); | 843 vector->p_AESKeyWrap_DestroyContext(cx, freeit); |
1201 } | 844 } |
1202 | 845 |
1203 SECStatus | 846 SECStatus AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output, |
1204 AESKeyWrap_Encrypt(AESKeyWrapContext *cx, unsigned char *output, | 847 unsigned int *outputLen, unsigned int maxOutputLen, |
1205 » » unsigned int *outputLen, unsigned int maxOutputLen, | 848 const unsigned char *input, |
1206 » » const unsigned char *input, unsigned int inputLen) | 849 unsigned int inputLen) { |
1207 { | 850 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1208 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1209 return SECFailure; | |
1210 return vector->p_AESKeyWrap_Encrypt(cx, output, outputLen, maxOutputLen, | 851 return vector->p_AESKeyWrap_Encrypt(cx, output, outputLen, maxOutputLen, |
1211 input, inputLen); | 852 input, inputLen); |
1212 } | 853 } |
1213 SECStatus | 854 SECStatus AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output, |
1214 AESKeyWrap_Decrypt(AESKeyWrapContext *cx, unsigned char *output, | 855 unsigned int *outputLen, unsigned int maxOutputLen, |
1215 » » unsigned int *outputLen, unsigned int maxOutputLen, | 856 const unsigned char *input, |
1216 » » const unsigned char *input, unsigned int inputLen) | 857 unsigned int inputLen) { |
1217 { | 858 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1218 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1219 return SECFailure; | |
1220 return vector->p_AESKeyWrap_Decrypt(cx, output, outputLen, maxOutputLen, | 859 return vector->p_AESKeyWrap_Decrypt(cx, output, outputLen, maxOutputLen, |
1221 » » input, inputLen); | 860 input, inputLen); |
1222 } | 861 } |
1223 | 862 |
1224 PRBool | 863 PRBool BLAPI_SHVerify(const char *name, PRFuncPtr addr) { |
1225 BLAPI_SHVerify(const char *name, PRFuncPtr addr) | 864 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return PR_FALSE; |
1226 { | |
1227 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1228 return PR_FALSE; | |
1229 return vector->p_BLAPI_SHVerify(name, addr); | 865 return vector->p_BLAPI_SHVerify(name, addr); |
1230 } | 866 } |
1231 | 867 |
1232 /* | 868 /* |
1233 * The Caller is expected to pass NULL as the name, which will | 869 * The Caller is expected to pass NULL as the name, which will |
1234 * trigger the p_BLAPI_VerifySelf() to return 'TRUE'. Pass the real | 870 * trigger the p_BLAPI_VerifySelf() to return 'TRUE'. Pass the real |
1235 * name of the shared library we loaded (the static libraryName set | 871 * name of the shared library we loaded (the static libraryName set |
1236 * in freebl_LoadDSO) to p_BLAPI_VerifySelf. | 872 * in freebl_LoadDSO) to p_BLAPI_VerifySelf. |
1237 */ | 873 */ |
1238 PRBool | 874 PRBool BLAPI_VerifySelf(const char *name) { |
1239 BLAPI_VerifySelf(const char *name) | |
1240 { | |
1241 PORT_Assert(!name); | 875 PORT_Assert(!name); |
1242 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 876 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return PR_FALSE; |
1243 return PR_FALSE; | |
1244 return vector->p_BLAPI_VerifySelf(libraryName); | 877 return vector->p_BLAPI_VerifySelf(libraryName); |
1245 } | 878 } |
1246 | 879 |
1247 /* ============== New for 3.006 =============================== */ | 880 /* ============== New for 3.006 =============================== */ |
1248 | 881 |
1249 SECStatus | 882 SECStatus EC_NewKey(ECParams *params, ECPrivateKey **privKey) { |
1250 EC_NewKey(ECParams * params, ECPrivateKey ** privKey) | 883 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1251 { | 884 return (vector->p_EC_NewKey)(params, privKey); |
1252 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 885 } |
1253 return SECFailure; | 886 |
1254 return (vector->p_EC_NewKey)( params, privKey ); | 887 SECStatus EC_NewKeyFromSeed(ECParams *params, ECPrivateKey **privKey, |
1255 } | 888 const unsigned char *seed, int seedlen) { |
1256 | 889 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1257 SECStatus | 890 return (vector->p_EC_NewKeyFromSeed)(params, privKey, seed, seedlen); |
1258 EC_NewKeyFromSeed(ECParams * params, ECPrivateKey ** privKey, | 891 } |
1259 const unsigned char *seed, int seedlen) | 892 |
1260 { | 893 SECStatus EC_ValidatePublicKey(ECParams *params, SECItem *publicValue) { |
1261 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 894 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1262 return SECFailure; | 895 return (vector->p_EC_ValidatePublicKey)(params, publicValue); |
1263 return (vector->p_EC_NewKeyFromSeed)( params, privKey, seed, seedlen ); | 896 } |
1264 } | 897 |
1265 | 898 SECStatus ECDH_Derive(SECItem *publicValue, ECParams *params, |
1266 SECStatus | 899 SECItem *privateValue, PRBool withCofactor, |
1267 EC_ValidatePublicKey(ECParams * params, SECItem * publicValue) | 900 SECItem *derivedSecret) { |
1268 { | 901 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1269 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 902 return (vector->p_ECDH_Derive)(publicValue, params, privateValue, |
1270 return SECFailure; | 903 withCofactor, derivedSecret); |
1271 return (vector->p_EC_ValidatePublicKey)( params, publicValue ); | 904 } |
1272 } | 905 |
1273 | 906 SECStatus ECDSA_SignDigest(ECPrivateKey *key, SECItem *signature, |
1274 SECStatus | 907 const SECItem *digest) { |
1275 ECDH_Derive(SECItem * publicValue, ECParams * params, SECItem * privateValue, | 908 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1276 PRBool withCofactor, SECItem * derivedSecret) | 909 return (vector->p_ECDSA_SignDigest)(key, signature, digest); |
1277 { | 910 } |
1278 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 911 |
1279 return SECFailure; | 912 SECStatus ECDSA_VerifyDigest(ECPublicKey *key, const SECItem *signature, |
1280 return (vector->p_ECDH_Derive)( publicValue, params, privateValue, | 913 const SECItem *digest) { |
1281 withCofactor, derivedSecret ); | 914 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1282 } | 915 return (vector->p_ECDSA_VerifyDigest)(key, signature, digest); |
1283 | 916 } |
1284 SECStatus | 917 |
1285 ECDSA_SignDigest(ECPrivateKey * key, SECItem * signature, | 918 SECStatus ECDSA_SignDigestWithSeed(ECPrivateKey *key, SECItem *signature, |
1286 const SECItem * digest) | 919 const SECItem *digest, |
1287 { | 920 const unsigned char *seed, |
1288 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 921 const int seedlen) { |
1289 return SECFailure; | 922 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1290 return (vector->p_ECDSA_SignDigest)( key, signature, digest ); | 923 return (vector->p_ECDSA_SignDigestWithSeed)(key, signature, digest, seed, |
1291 } | 924 seedlen); |
1292 | |
1293 SECStatus | |
1294 ECDSA_VerifyDigest(ECPublicKey * key, const SECItem * signature, | |
1295 const SECItem * digest) | |
1296 { | |
1297 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1298 return SECFailure; | |
1299 return (vector->p_ECDSA_VerifyDigest)( key, signature, digest ); | |
1300 } | |
1301 | |
1302 SECStatus | |
1303 ECDSA_SignDigestWithSeed(ECPrivateKey * key, SECItem * signature, | |
1304 const SECItem * digest, const unsigned char *seed, const int seedlen) | |
1305 { | |
1306 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1307 return SECFailure; | |
1308 return (vector->p_ECDSA_SignDigestWithSeed)( key, signature, digest, | |
1309 seed, seedlen ); | |
1310 } | 925 } |
1311 | 926 |
1312 /* ============== New for 3.008 =============================== */ | 927 /* ============== New for 3.008 =============================== */ |
1313 | 928 |
1314 AESContext * | 929 AESContext *AES_AllocateContext(void) { |
1315 AES_AllocateContext(void) | 930 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1316 { | |
1317 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1318 return NULL; | |
1319 return (vector->p_AES_AllocateContext)(); | 931 return (vector->p_AES_AllocateContext)(); |
1320 } | 932 } |
1321 | 933 |
1322 AESKeyWrapContext * | 934 AESKeyWrapContext *AESKeyWrap_AllocateContext(void) { |
1323 AESKeyWrap_AllocateContext(void) | 935 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1324 { | |
1325 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1326 return NULL; | |
1327 return (vector->p_AESKeyWrap_AllocateContext)(); | 936 return (vector->p_AESKeyWrap_AllocateContext)(); |
1328 } | 937 } |
1329 | 938 |
1330 DESContext * | 939 DESContext *DES_AllocateContext(void) { |
1331 DES_AllocateContext(void) | 940 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1332 { | |
1333 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1334 return NULL; | |
1335 return (vector->p_DES_AllocateContext)(); | 941 return (vector->p_DES_AllocateContext)(); |
1336 } | 942 } |
1337 | 943 |
1338 RC2Context * | 944 RC2Context *RC2_AllocateContext(void) { |
1339 RC2_AllocateContext(void) | 945 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1340 { | |
1341 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1342 return NULL; | |
1343 return (vector->p_RC2_AllocateContext)(); | 946 return (vector->p_RC2_AllocateContext)(); |
1344 } | 947 } |
1345 | 948 |
1346 RC4Context * | 949 RC4Context *RC4_AllocateContext(void) { |
1347 RC4_AllocateContext(void) | 950 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1348 { | |
1349 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1350 return NULL; | |
1351 return (vector->p_RC4_AllocateContext)(); | 951 return (vector->p_RC4_AllocateContext)(); |
1352 } | 952 } |
1353 | 953 |
1354 SECStatus | 954 SECStatus AES_InitContext(AESContext *cx, const unsigned char *key, |
1355 AES_InitContext(AESContext *cx, const unsigned char *key,· | 955 unsigned int keylen, const unsigned char *iv, |
1356 » » unsigned int keylen, const unsigned char *iv, int mode, | 956 int mode, unsigned int encrypt, |
1357 » » unsigned int encrypt, unsigned int blocklen) | 957 unsigned int blocklen) { |
1358 { | 958 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1359 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 959 return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt, |
1360 return SECFailure; | 960 blocklen); |
1361 return (vector->p_AES_InitContext)(cx, key, keylen, iv, mode, encrypt,· | 961 } |
1362 » » » » blocklen); | 962 |
1363 } | 963 SECStatus AESKeyWrap_InitContext(AESKeyWrapContext *cx, |
1364 | 964 const unsigned char *key, unsigned int keylen, |
1365 SECStatus | 965 const unsigned char *iv, int mode, |
1366 AESKeyWrap_InitContext(AESKeyWrapContext *cx, const unsigned char *key, | 966 unsigned int encrypt, unsigned int blocklen) { |
1367 » » unsigned int keylen, const unsigned char *iv, int mode, | 967 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1368 » » unsigned int encrypt, unsigned int blocklen) | 968 return (vector->p_AESKeyWrap_InitContext)(cx, key, keylen, iv, mode, encrypt, |
1369 { | 969 blocklen); |
1370 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 970 } |
1371 return SECFailure; | 971 |
1372 return (vector->p_AESKeyWrap_InitContext)(cx, key, keylen, iv, mode, | 972 SECStatus DES_InitContext(DESContext *cx, const unsigned char *key, |
1373 » » » » » encrypt, blocklen); | 973 unsigned int keylen, const unsigned char *iv, |
1374 } | 974 int mode, unsigned int encrypt, unsigned int xtra) { |
1375 | 975 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1376 SECStatus | |
1377 DES_InitContext(DESContext *cx, const unsigned char *key,· | |
1378 » » unsigned int keylen, const unsigned char *iv, int mode, | |
1379 » » unsigned int encrypt, unsigned int xtra) | |
1380 { | |
1381 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1382 return SECFailure; | |
1383 return (vector->p_DES_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); | 976 return (vector->p_DES_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); |
1384 } | 977 } |
1385 | 978 |
1386 SECStatus | 979 SECStatus SEED_InitContext(SEEDContext *cx, const unsigned char *key, |
1387 SEED_InitContext(SEEDContext *cx, const unsigned char *key,· | 980 unsigned int keylen, const unsigned char *iv, |
1388 » » unsigned int keylen, const unsigned char *iv, int mode, | 981 int mode, unsigned int encrypt, unsigned int xtra) { |
1389 » » unsigned int encrypt, unsigned int xtra) | 982 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1390 { | |
1391 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1392 return SECFailure; | |
1393 return (vector->p_SEED_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); | 983 return (vector->p_SEED_InitContext)(cx, key, keylen, iv, mode, encrypt, xtra); |
1394 } | 984 } |
1395 | 985 |
1396 SECStatus | 986 SECStatus RC2_InitContext(RC2Context *cx, const unsigned char *key, |
1397 RC2_InitContext(RC2Context *cx, const unsigned char *key,· | 987 unsigned int keylen, const unsigned char *iv, |
1398 » » unsigned int keylen, const unsigned char *iv, int mode, | 988 int mode, unsigned int effectiveKeyLen, |
1399 » » unsigned int effectiveKeyLen, unsigned int xtra) | 989 unsigned int xtra) { |
1400 { | 990 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1401 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 991 return (vector->p_RC2_InitContext)(cx, key, keylen, iv, mode, effectiveKeyLen, |
1402 return SECFailure; | 992 xtra); |
1403 return (vector->p_RC2_InitContext)(cx, key, keylen, iv, mode, | 993 } |
1404 » » » » effectiveKeyLen, xtra); | 994 |
1405 } | 995 SECStatus RC4_InitContext(RC4Context *cx, const unsigned char *key, |
1406 | 996 unsigned int keylen, const unsigned char *x1, int x2, |
1407 SECStatus | 997 unsigned int x3, unsigned int x4) { |
1408 RC4_InitContext(RC4Context *cx, const unsigned char *key,· | 998 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1409 » » unsigned int keylen, const unsigned char *x1, int x2, | |
1410 » » unsigned int x3, unsigned int x4) | |
1411 { | |
1412 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1413 return SECFailure; | |
1414 return (vector->p_RC4_InitContext)(cx, key, keylen, x1, x2, x3, x4); | 999 return (vector->p_RC4_InitContext)(cx, key, keylen, x1, x2, x3, x4); |
1415 } | 1000 } |
1416 | 1001 |
1417 void | 1002 void MD2_Clone(MD2Context *dest, MD2Context *src) { |
1418 MD2_Clone(MD2Context *dest, MD2Context *src) | 1003 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1419 { | |
1420 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1421 return; | |
1422 (vector->p_MD2_Clone)(dest, src); | 1004 (vector->p_MD2_Clone)(dest, src); |
1423 } | 1005 } |
1424 | 1006 |
1425 void | 1007 void MD5_Clone(MD5Context *dest, MD5Context *src) { |
1426 MD5_Clone(MD5Context *dest, MD5Context *src) | 1008 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1427 { | |
1428 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1429 return; | |
1430 (vector->p_MD5_Clone)(dest, src); | 1009 (vector->p_MD5_Clone)(dest, src); |
1431 } | 1010 } |
1432 | 1011 |
1433 void | 1012 void SHA1_Clone(SHA1Context *dest, SHA1Context *src) { |
1434 SHA1_Clone(SHA1Context *dest, SHA1Context *src) | 1013 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1435 { | |
1436 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1437 return; | |
1438 (vector->p_SHA1_Clone)(dest, src); | 1014 (vector->p_SHA1_Clone)(dest, src); |
1439 } | 1015 } |
1440 | 1016 |
1441 void | 1017 void SHA256_Clone(SHA256Context *dest, SHA256Context *src) { |
1442 SHA256_Clone(SHA256Context *dest, SHA256Context *src) | 1018 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1443 { | |
1444 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1445 return; | |
1446 (vector->p_SHA256_Clone)(dest, src); | 1019 (vector->p_SHA256_Clone)(dest, src); |
1447 } | 1020 } |
1448 | 1021 |
1449 void | 1022 void SHA384_Clone(SHA384Context *dest, SHA384Context *src) { |
1450 SHA384_Clone(SHA384Context *dest, SHA384Context *src) | 1023 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1451 { | |
1452 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1453 return; | |
1454 (vector->p_SHA384_Clone)(dest, src); | 1024 (vector->p_SHA384_Clone)(dest, src); |
1455 } | 1025 } |
1456 | 1026 |
1457 void | 1027 void SHA512_Clone(SHA512Context *dest, SHA512Context *src) { |
1458 SHA512_Clone(SHA512Context *dest, SHA512Context *src) | 1028 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1459 { | |
1460 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1461 return; | |
1462 (vector->p_SHA512_Clone)(dest, src); | 1029 (vector->p_SHA512_Clone)(dest, src); |
1463 } | 1030 } |
1464 | 1031 |
1465 SECStatus | 1032 SECStatus TLS_PRF(const SECItem *secret, const char *label, SECItem *seed, |
1466 TLS_PRF(const SECItem *secret, const char *label,· | 1033 SECItem *result, PRBool isFIPS) { |
1467 » » SECItem *seed, SECItem *result, PRBool isFIPS) | 1034 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1468 { | |
1469 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1470 return SECFailure; | |
1471 return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS); | 1035 return (vector->p_TLS_PRF)(secret, label, seed, result, isFIPS); |
1472 } | 1036 } |
1473 | 1037 |
1474 const SECHashObject * | 1038 const SECHashObject *HASH_GetRawHashObject(HASH_HashType hashType) { |
1475 HASH_GetRawHashObject(HASH_HashType hashType) | 1039 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1476 { | |
1477 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1478 return NULL; | |
1479 return (vector->p_HASH_GetRawHashObject)(hashType); | 1040 return (vector->p_HASH_GetRawHashObject)(hashType); |
1480 } | 1041 } |
1481 | 1042 |
1482 | 1043 void HMAC_Destroy(HMACContext *cx, PRBool freeit) { |
1483 void | 1044 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1484 HMAC_Destroy(HMACContext *cx, PRBool freeit) | |
1485 { | |
1486 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1487 return; | |
1488 (vector->p_HMAC_Destroy)(cx, freeit); | 1045 (vector->p_HMAC_Destroy)(cx, freeit); |
1489 } | 1046 } |
1490 | 1047 |
1491 HMACContext * | 1048 HMACContext *HMAC_Create(const SECHashObject *hashObj, |
1492 HMAC_Create(const SECHashObject *hashObj, const unsigned char *secret, | 1049 const unsigned char *secret, unsigned int secret_len, |
1493 » unsigned int secret_len, PRBool isFIPS) | 1050 PRBool isFIPS) { |
1494 { | 1051 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1495 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1496 return NULL; | |
1497 return (vector->p_HMAC_Create)(hashObj, secret, secret_len, isFIPS); | 1052 return (vector->p_HMAC_Create)(hashObj, secret, secret_len, isFIPS); |
1498 } | 1053 } |
1499 | 1054 |
1500 SECStatus | 1055 SECStatus HMAC_Init(HMACContext *cx, const SECHashObject *hashObj, |
1501 HMAC_Init(HMACContext *cx, const SECHashObject *hashObj,· | 1056 const unsigned char *secret, unsigned int secret_len, |
1502 » const unsigned char *secret, unsigned int secret_len, PRBool isFIPS) | 1057 PRBool isFIPS) { |
1503 { | 1058 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1504 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1505 return SECFailure; | |
1506 return (vector->p_HMAC_Init)(cx, hashObj, secret, secret_len, isFIPS); | 1059 return (vector->p_HMAC_Init)(cx, hashObj, secret, secret_len, isFIPS); |
1507 } | 1060 } |
1508 | 1061 |
1509 void | 1062 void HMAC_Begin(HMACContext *cx) { |
1510 HMAC_Begin(HMACContext *cx) | 1063 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1511 { | |
1512 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1513 return; | |
1514 (vector->p_HMAC_Begin)(cx); | 1064 (vector->p_HMAC_Begin)(cx); |
1515 } | 1065 } |
1516 | 1066 |
1517 void | 1067 void HMAC_Update(HMACContext *cx, const unsigned char *data, |
1518 HMAC_Update(HMACContext *cx, const unsigned char *data, unsigned int data_len) | 1068 unsigned int data_len) { |
1519 { | 1069 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1520 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1521 return; | |
1522 (vector->p_HMAC_Update)(cx, data, data_len); | 1070 (vector->p_HMAC_Update)(cx, data, data_len); |
1523 } | 1071 } |
1524 | 1072 |
1525 SECStatus | 1073 SECStatus HMAC_Finish(HMACContext *cx, unsigned char *result, |
1526 HMAC_Finish(HMACContext *cx, unsigned char *result, unsigned int *result_len, | 1074 unsigned int *result_len, unsigned int max_result_len) { |
1527 » unsigned int max_result_len) | 1075 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1528 { | |
1529 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1530 return SECFailure; | |
1531 return (vector->p_HMAC_Finish)(cx, result, result_len, max_result_len); | 1076 return (vector->p_HMAC_Finish)(cx, result, result_len, max_result_len); |
1532 } | 1077 } |
1533 | 1078 |
1534 HMACContext * | 1079 HMACContext *HMAC_Clone(HMACContext *cx) { |
1535 HMAC_Clone(HMACContext *cx) | 1080 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1536 { | |
1537 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1538 return NULL; | |
1539 return (vector->p_HMAC_Clone)(cx); | 1081 return (vector->p_HMAC_Clone)(cx); |
1540 } | 1082 } |
1541 | 1083 |
1542 void | 1084 void RNG_SystemInfoForRNG(void) { |
1543 RNG_SystemInfoForRNG(void) | 1085 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1544 { | |
1545 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1546 return ; | |
1547 (vector->p_RNG_SystemInfoForRNG)(); | 1086 (vector->p_RNG_SystemInfoForRNG)(); |
1548 | 1087 } |
1549 } | 1088 |
1550 | 1089 SECStatus FIPS186Change_GenerateX(unsigned char *XKEY, |
1551 SECStatus | 1090 const unsigned char *XSEEDj, |
1552 FIPS186Change_GenerateX(unsigned char *XKEY, const unsigned char *XSEEDj, | 1091 unsigned char *x_j) { |
1553 unsigned char *x_j) | 1092 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1554 { | |
1555 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1556 return SECFailure; | |
1557 return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j); | 1093 return (vector->p_FIPS186Change_GenerateX)(XKEY, XSEEDj, x_j); |
1558 } | 1094 } |
1559 | 1095 |
1560 SECStatus | 1096 SECStatus FIPS186Change_ReduceModQForDSA(const unsigned char *w, |
1561 FIPS186Change_ReduceModQForDSA(const unsigned char *w, | 1097 const unsigned char *q, |
1562 const unsigned char *q, | 1098 unsigned char *xj) { |
1563 unsigned char *xj) | 1099 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1564 { | |
1565 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1566 return SECFailure; | |
1567 return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj); | 1100 return (vector->p_FIPS186Change_ReduceModQForDSA)(w, q, xj); |
1568 } | 1101 } |
1569 | 1102 |
1570 /* === new for Camellia === */ | 1103 /* === new for Camellia === */ |
1571 SECStatus | 1104 SECStatus Camellia_InitContext(CamelliaContext *cx, const unsigned char *key, |
1572 Camellia_InitContext(CamelliaContext *cx, const unsigned char *key,· | 1105 unsigned int keylen, const unsigned char *iv, |
1573 » » unsigned int keylen, const unsigned char *iv, int mode, | 1106 int mode, unsigned int encrypt, |
1574 » » unsigned int encrypt, unsigned int unused) | 1107 unsigned int unused) { |
1575 { | 1108 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1576 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1577 return SECFailure; | |
1578 return (vector->p_Camellia_InitContext)(cx, key, keylen, iv, mode, encrypt, | 1109 return (vector->p_Camellia_InitContext)(cx, key, keylen, iv, mode, encrypt, |
1579 » » » » » unused); | 1110 unused); |
1580 } | 1111 } |
1581 | 1112 |
1582 CamelliaContext * | 1113 CamelliaContext *Camellia_AllocateContext(void) { |
1583 Camellia_AllocateContext(void) | 1114 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1584 { | |
1585 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1586 return NULL; | |
1587 return (vector->p_Camellia_AllocateContext)(); | 1115 return (vector->p_Camellia_AllocateContext)(); |
1588 } | 1116 } |
1589 | 1117 |
1590 | 1118 CamelliaContext *Camellia_CreateContext(const unsigned char *key, |
1591 CamelliaContext * | 1119 const unsigned char *iv, int mode, |
1592 Camellia_CreateContext(const unsigned char *key, const unsigned char *iv, | 1120 int encrypt, unsigned int keylen) { |
1593 » » int mode, int encrypt, | 1121 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1594 » » unsigned int keylen) | 1122 return (vector->p_Camellia_CreateContext)(key, iv, mode, encrypt, keylen); |
1595 { | 1123 } |
1596 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1124 |
1597 » return NULL; | 1125 void Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit) { |
1598 return (vector->p_Camellia_CreateContext)(key, iv, mode, encrypt, keylen); | 1126 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1599 } | 1127 (vector->p_Camellia_DestroyContext)(cx, freeit); |
1600 | 1128 } |
1601 void | 1129 |
1602 Camellia_DestroyContext(CamelliaContext *cx, PRBool freeit) | 1130 SECStatus Camellia_Encrypt(CamelliaContext *cx, unsigned char *output, |
1603 { | 1131 unsigned int *outputLen, unsigned int maxOutputLen, |
1604 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1132 const unsigned char *input, unsigned int inputLen) { |
1605 » return ; | 1133 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1606 (vector->p_Camellia_DestroyContext)(cx, freeit); | 1134 return (vector->p_Camellia_Encrypt)(cx, output, outputLen, maxOutputLen, |
1607 } | 1135 input, inputLen); |
1608 | 1136 } |
1609 SECStatus | 1137 |
1610 Camellia_Encrypt(CamelliaContext *cx, unsigned char *output, | 1138 SECStatus Camellia_Decrypt(CamelliaContext *cx, unsigned char *output, |
1611 » » unsigned int *outputLen, unsigned int maxOutputLen, | 1139 unsigned int *outputLen, unsigned int maxOutputLen, |
1612 » » const unsigned char *input, unsigned int inputLen) | 1140 const unsigned char *input, unsigned int inputLen) { |
1613 { | 1141 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1614 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1142 return (vector->p_Camellia_Decrypt)(cx, output, outputLen, maxOutputLen, |
1615 » return SECFailure; | 1143 input, inputLen); |
1616 return (vector->p_Camellia_Encrypt)(cx, output, outputLen, maxOutputLen,· | 1144 } |
1617 » » » » » input, inputLen); | 1145 |
1618 } | 1146 void BL_SetForkState(PRBool forked) { |
1619 | 1147 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1620 SECStatus | 1148 (vector->p_BL_SetForkState)(forked); |
1621 Camellia_Decrypt(CamelliaContext *cx, unsigned char *output, | 1149 } |
1622 » » unsigned int *outputLen, unsigned int maxOutputLen, | 1150 |
1623 » » const unsigned char *input, unsigned int inputLen) | 1151 SECStatus PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len, |
1624 { | 1152 const PRUint8 *nonce, unsigned int nonce_len, |
1625 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1153 const PRUint8 *personal_string, |
1626 » return SECFailure; | 1154 unsigned int ps_len) { |
1627 return (vector->p_Camellia_Decrypt)(cx, output, outputLen, maxOutputLen,· | 1155 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1628 » » » » » input, inputLen); | 1156 return (vector->p_PRNGTEST_Instantiate)(entropy, entropy_len, nonce, |
1629 } | 1157 nonce_len, personal_string, ps_len); |
1630 | 1158 } |
1631 void BL_SetForkState(PRBool forked) | 1159 |
1632 { | 1160 SECStatus PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len, |
1633 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1161 const PRUint8 *additional, |
1634 » return; | 1162 unsigned int additional_len) { |
1635 (vector->p_BL_SetForkState)(forked); | 1163 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1636 } | 1164 return (vector->p_PRNGTEST_Reseed)(entropy, entropy_len, additional, |
1637 | 1165 additional_len); |
1638 SECStatus | 1166 } |
1639 PRNGTEST_Instantiate(const PRUint8 *entropy, unsigned int entropy_len,· | 1167 |
1640 » » const PRUint8 *nonce, unsigned int nonce_len, | 1168 SECStatus PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len, |
1641 » » const PRUint8 *personal_string, unsigned int ps_len) | 1169 const PRUint8 *additional, |
1642 { | 1170 unsigned int additional_len) { |
1643 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1171 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1644 » return SECFailure; | 1172 return (vector->p_PRNGTEST_Generate)(bytes, bytes_len, additional, |
1645 return (vector->p_PRNGTEST_Instantiate)(entropy, entropy_len, | 1173 additional_len); |
1646 » » » » » nonce, nonce_len, | 1174 } |
1647 » » » » » personal_string, ps_len); | 1175 |
1648 } | 1176 SECStatus PRNGTEST_Uninstantiate() { |
1649 | 1177 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1650 SECStatus | 1178 return (vector->p_PRNGTEST_Uninstantiate)(); |
1651 PRNGTEST_Reseed(const PRUint8 *entropy, unsigned int entropy_len,· | 1179 } |
1652 » » const PRUint8 *additional, unsigned int additional_len) | 1180 |
1653 { | 1181 SECStatus RSA_PopulatePrivateKey(RSAPrivateKey *key) { |
1654 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1182 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1655 » return SECFailure; | 1183 return (vector->p_RSA_PopulatePrivateKey)(key); |
1656 return (vector->p_PRNGTEST_Reseed)(entropy, entropy_len, | 1184 } |
1657 » » » » additional, additional_len); | 1185 |
1658 } | 1186 SECStatus JPAKE_Sign(PLArenaPool *arena, const PQGParams *pqg, |
1659 | 1187 HASH_HashType hashType, const SECItem *signerID, |
1660 SECStatus | 1188 const SECItem *x, const SECItem *testRandom, |
1661 PRNGTEST_Generate(PRUint8 *bytes, unsigned int bytes_len,· | 1189 const SECItem *gxIn, SECItem *gxOut, SECItem *gv, |
1662 » » const PRUint8 *additional, unsigned int additional_len) | 1190 SECItem *r) { |
1663 { | 1191 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1664 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1192 return (vector->p_JPAKE_Sign)(arena, pqg, hashType, signerID, x, testRandom, |
1665 » return SECFailure; | 1193 gxIn, gxOut, gv, r); |
1666 return (vector->p_PRNGTEST_Generate)(bytes, bytes_len, | 1194 } |
1667 » » » » » additional, additional_len); | 1195 |
1668 } | 1196 SECStatus JPAKE_Verify(PLArenaPool *arena, const PQGParams *pqg, |
1669 | 1197 HASH_HashType hashType, const SECItem *signerID, |
1670 SECStatus | 1198 const SECItem *peerID, const SECItem *gx, |
1671 PRNGTEST_Uninstantiate() | 1199 const SECItem *gv, const SECItem *r) { |
1672 { | 1200 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1673 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1201 return (vector->p_JPAKE_Verify)(arena, pqg, hashType, signerID, peerID, gx, |
1674 » return SECFailure; | 1202 gv, r); |
1675 return (vector->p_PRNGTEST_Uninstantiate)(); | 1203 } |
1676 } | 1204 |
1677 | 1205 SECStatus JPAKE_Round2(PLArenaPool *arena, const SECItem *p, const SECItem *q, |
1678 SECStatus | 1206 const SECItem *gx1, const SECItem *gx3, |
1679 RSA_PopulatePrivateKey(RSAPrivateKey *key) | 1207 const SECItem *gx4, SECItem *base, const SECItem *x2, |
1680 { | 1208 const SECItem *s, SECItem *x2s) { |
1681 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1209 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1682 » return SECFailure; | 1210 return (vector->p_JPAKE_Round2)(arena, p, q, gx1, gx3, gx4, base, x2, s, x2s); |
1683 return (vector->p_RSA_PopulatePrivateKey)(key); | 1211 } |
1684 } | 1212 |
1685 | 1213 SECStatus JPAKE_Final(PLArenaPool *arena, const SECItem *p, const SECItem *q, |
1686 | 1214 const SECItem *x2, const SECItem *gx4, const SECItem *x2s, |
1687 SECStatus | 1215 const SECItem *B, SECItem *K) { |
1688 JPAKE_Sign(PLArenaPool * arena, const PQGParams * pqg, HASH_HashType hashType, | 1216 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1689 const SECItem * signerID, const SECItem * x, | 1217 return (vector->p_JPAKE_Final)(arena, p, q, x2, gx4, x2s, B, K); |
1690 const SECItem * testRandom, const SECItem * gxIn, SECItem * gxOut, | 1218 } |
1691 SECItem * gv, SECItem * r) | 1219 |
1692 { | 1220 SECStatus TLS_P_hash(HASH_HashType hashAlg, const SECItem *secret, |
1693 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1221 const char *label, SECItem *seed, SECItem *result, |
1694 return SECFailure; | 1222 PRBool isFIPS) { |
1695 return (vector->p_JPAKE_Sign)(arena, pqg, hashType, signerID, x, | 1223 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1696 testRandom, gxIn, gxOut, gv, r); | |
1697 } | |
1698 | |
1699 SECStatus | |
1700 JPAKE_Verify(PLArenaPool * arena, const PQGParams * pqg, | |
1701 HASH_HashType hashType, const SECItem * signerID, | |
1702 const SECItem * peerID, const SECItem * gx, | |
1703 const SECItem * gv, const SECItem * r) | |
1704 { | |
1705 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1706 return SECFailure; | |
1707 return (vector->p_JPAKE_Verify)(arena, pqg, hashType, signerID, peerID, | |
1708 gx, gv, r); | |
1709 } | |
1710 | |
1711 SECStatus | |
1712 JPAKE_Round2(PLArenaPool * arena, const SECItem * p, const SECItem *q, | |
1713 const SECItem * gx1, const SECItem * gx3, const SECItem * gx4, | |
1714 SECItem * base, const SECItem * x2, const SECItem * s, SECItem * x2
s) | |
1715 { | |
1716 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1717 return SECFailure; | |
1718 return (vector->p_JPAKE_Round2)(arena, p, q, gx1, gx3, gx4, base, x2, s, x2s
); | |
1719 } | |
1720 | |
1721 SECStatus | |
1722 JPAKE_Final(PLArenaPool * arena, const SECItem * p, const SECItem *q, | |
1723 const SECItem * x2, const SECItem * gx4, const SECItem * x2s, | |
1724 const SECItem * B, SECItem * K) | |
1725 { | |
1726 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1727 return SECFailure; | |
1728 return (vector->p_JPAKE_Final)(arena, p, q, x2, gx4, x2s, B, K); | |
1729 } | |
1730 | |
1731 SECStatus | |
1732 TLS_P_hash(HASH_HashType hashAlg, const SECItem *secret, const char *label, | |
1733 SECItem *seed, SECItem *result, PRBool isFIPS) | |
1734 { | |
1735 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1736 return SECFailure; | |
1737 return (vector->p_TLS_P_hash)(hashAlg, secret, label, seed, result, isFIPS); | 1224 return (vector->p_TLS_P_hash)(hashAlg, secret, label, seed, result, isFIPS); |
1738 } | 1225 } |
1739 | 1226 |
1740 SECStatus | 1227 SECStatus SHA224_Hash(unsigned char *dest, const char *src) { |
1741 SHA224_Hash(unsigned char *dest, const char *src) | 1228 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1742 { | |
1743 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1744 return SECFailure; | |
1745 return (vector->p_SHA224_Hash)(dest, src); | 1229 return (vector->p_SHA224_Hash)(dest, src); |
1746 } | 1230 } |
1747 | 1231 |
1748 SECStatus | 1232 SECStatus SHA224_HashBuf(unsigned char *dest, const unsigned char *src, |
1749 SHA224_HashBuf(unsigned char *dest, const unsigned char *src, PRUint32 src_lengt
h) | 1233 PRUint32 src_length) { |
1750 { | 1234 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1751 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1752 return SECFailure; | |
1753 return (vector->p_SHA224_HashBuf)(dest, src, src_length); | 1235 return (vector->p_SHA224_HashBuf)(dest, src, src_length); |
1754 } | 1236 } |
1755 | 1237 |
1756 SHA224Context * | 1238 SHA224Context *SHA224_NewContext(void) { |
1757 SHA224_NewContext(void) | 1239 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1758 { | |
1759 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1760 return NULL; | |
1761 return (vector->p_SHA224_NewContext)(); | 1240 return (vector->p_SHA224_NewContext)(); |
1762 } | 1241 } |
1763 | 1242 |
1764 void | 1243 void SHA224_DestroyContext(SHA224Context *cx, PRBool freeit) { |
1765 SHA224_DestroyContext(SHA224Context *cx, PRBool freeit) | 1244 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1766 { | |
1767 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1768 return; | |
1769 (vector->p_SHA224_DestroyContext)(cx, freeit); | 1245 (vector->p_SHA224_DestroyContext)(cx, freeit); |
1770 } | 1246 } |
1771 | 1247 |
1772 void | 1248 void SHA224_Begin(SHA256Context *cx) { |
1773 SHA224_Begin(SHA256Context *cx) | 1249 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1774 { | |
1775 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1776 return; | |
1777 (vector->p_SHA224_Begin)(cx); | 1250 (vector->p_SHA224_Begin)(cx); |
1778 } | 1251 } |
1779 | 1252 |
1780 void | 1253 void SHA224_Update(SHA224Context *cx, const unsigned char *input, |
1781 SHA224_Update(SHA224Context *cx, const unsigned char *input, | 1254 unsigned int inputLen) { |
1782 » » » unsigned int inputLen) | 1255 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1783 { | |
1784 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1785 return; | |
1786 (vector->p_SHA224_Update)(cx, input, inputLen); | 1256 (vector->p_SHA224_Update)(cx, input, inputLen); |
1787 } | 1257 } |
1788 | 1258 |
1789 void | 1259 void SHA224_End(SHA224Context *cx, unsigned char *digest, |
1790 SHA224_End(SHA224Context *cx, unsigned char *digest, | 1260 unsigned int *digestLen, unsigned int maxDigestLen) { |
1791 » » unsigned int *digestLen, unsigned int maxDigestLen) | 1261 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1792 { | |
1793 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1794 return; | |
1795 (vector->p_SHA224_End)(cx, digest, digestLen, maxDigestLen); | 1262 (vector->p_SHA224_End)(cx, digest, digestLen, maxDigestLen); |
1796 } | 1263 } |
1797 | 1264 |
1798 void | 1265 void SHA224_TraceState(SHA224Context *cx) { |
1799 SHA224_TraceState(SHA224Context *cx) | 1266 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1800 { | |
1801 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1802 return; | |
1803 (vector->p_SHA224_TraceState)(cx); | 1267 (vector->p_SHA224_TraceState)(cx); |
1804 } | 1268 } |
1805 | 1269 |
1806 unsigned int | 1270 unsigned int SHA224_FlattenSize(SHA224Context *cx) { |
1807 SHA224_FlattenSize(SHA224Context *cx) | 1271 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return 0; |
1808 { | |
1809 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1810 return 0; | |
1811 return (vector->p_SHA224_FlattenSize)(cx); | 1272 return (vector->p_SHA224_FlattenSize)(cx); |
1812 } | 1273 } |
1813 | 1274 |
1814 SECStatus | 1275 SECStatus SHA224_Flatten(SHA224Context *cx, unsigned char *space) { |
1815 SHA224_Flatten(SHA224Context *cx,unsigned char *space) | 1276 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1816 { | |
1817 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1818 return SECFailure; | |
1819 return (vector->p_SHA224_Flatten)(cx, space); | 1277 return (vector->p_SHA224_Flatten)(cx, space); |
1820 } | 1278 } |
1821 | 1279 |
1822 SHA224Context * | 1280 SHA224Context *SHA224_Resurrect(unsigned char *space, void *arg) { |
1823 SHA224_Resurrect(unsigned char *space, void *arg) | 1281 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return NULL; |
1824 { | |
1825 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1826 return NULL; | |
1827 return (vector->p_SHA224_Resurrect)(space, arg); | 1282 return (vector->p_SHA224_Resurrect)(space, arg); |
1828 } | 1283 } |
1829 | 1284 |
1830 void | 1285 void SHA224_Clone(SHA224Context *dest, SHA224Context *src) { |
1831 SHA224_Clone(SHA224Context *dest, SHA224Context *src) | 1286 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return; |
1832 { | |
1833 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1834 return; | |
1835 (vector->p_SHA224_Clone)(dest, src); | 1287 (vector->p_SHA224_Clone)(dest, src); |
1836 } | 1288 } |
1837 | 1289 |
1838 PRBool | 1290 PRBool BLAPI_SHVerifyFile(const char *name) { |
1839 BLAPI_SHVerifyFile(const char *name) | 1291 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return PR_FALSE; |
1840 { | |
1841 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1842 return PR_FALSE; | |
1843 return vector->p_BLAPI_SHVerifyFile(name); | 1292 return vector->p_BLAPI_SHVerifyFile(name); |
1844 } | 1293 } |
1845 | 1294 |
1846 /* === new for DSA-2 === */ | 1295 /* === new for DSA-2 === */ |
1847 SECStatus | 1296 SECStatus PQG_ParamGenV2(unsigned int L, unsigned int N, unsigned int seedBytes, |
1848 PQG_ParamGenV2( unsigned int L, unsigned int N, unsigned int seedBytes,· | 1297 PQGParams **pParams, PQGVerify **pVfy) { |
1849 PQGParams **pParams, PQGVerify **pVfy) | 1298 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1850 { | 1299 return (vector->p_PQG_ParamGenV2)(L, N, seedBytes, pParams, pVfy); |
1851 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1300 } |
1852 return SECFailure; | 1301 |
1853 return (vector->p_PQG_ParamGenV2)(L, N, seedBytes, pParams, pVfy); | 1302 SECStatus PRNGTEST_RunHealthTests(void) { |
1854 } | 1303 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1855 | |
1856 SECStatus | |
1857 PRNGTEST_RunHealthTests(void) | |
1858 { | |
1859 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1860 return SECFailure; | |
1861 return vector->p_PRNGTEST_RunHealthTests(); | 1304 return vector->p_PRNGTEST_RunHealthTests(); |
1862 } | 1305 } |
1863 | 1306 |
1864 SECStatus | 1307 SECStatus SSLv3_MAC_ConstantTime( |
1865 SSLv3_MAC_ConstantTime( | 1308 unsigned char *result, unsigned int *resultLen, unsigned int maxResultLen, |
1866 unsigned char *result, | 1309 const SECHashObject *hashObj, const unsigned char *secret, |
1867 unsigned int *resultLen, | 1310 unsigned int secretLen, const unsigned char *header, unsigned int headerLen, |
1868 unsigned int maxResultLen, | 1311 const unsigned char *body, unsigned int bodyLen, |
1869 const SECHashObject *hashObj, | 1312 unsigned int bodyTotalLen) { |
1870 const unsigned char *secret, | 1313 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1871 unsigned int secretLen, | |
1872 const unsigned char *header, | |
1873 unsigned int headerLen, | |
1874 const unsigned char *body, | |
1875 unsigned int bodyLen, | |
1876 unsigned int bodyTotalLen) | |
1877 { | |
1878 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1879 return SECFailure; | |
1880 return (vector->p_SSLv3_MAC_ConstantTime)( | 1314 return (vector->p_SSLv3_MAC_ConstantTime)( |
1881 result, resultLen, maxResultLen, | 1315 result, resultLen, maxResultLen, hashObj, secret, secretLen, header, |
1882 hashObj, | 1316 headerLen, body, bodyLen, bodyTotalLen); |
1883 secret, secretLen, | 1317 } |
1884 header, headerLen, | 1318 |
1885 body, bodyLen, bodyTotalLen); | 1319 SECStatus HMAC_ConstantTime(unsigned char *result, unsigned int *resultLen, |
1886 } | 1320 unsigned int maxResultLen, |
1887 | 1321 const SECHashObject *hashObj, |
1888 SECStatus | 1322 const unsigned char *secret, unsigned int secretLen, |
1889 HMAC_ConstantTime( | 1323 const unsigned char *header, unsigned int headerLen, |
1890 unsigned char *result, | 1324 const unsigned char *body, unsigned int bodyLen, |
1891 unsigned int *resultLen, | 1325 unsigned int bodyTotalLen) { |
1892 unsigned int maxResultLen, | 1326 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1893 const SECHashObject *hashObj, | 1327 return (vector->p_HMAC_ConstantTime)(result, resultLen, maxResultLen, hashObj, |
1894 const unsigned char *secret, | 1328 secret, secretLen, header, headerLen, |
1895 unsigned int secretLen, | 1329 body, bodyLen, bodyTotalLen); |
1896 const unsigned char *header, | 1330 } |
1897 unsigned int headerLen, | 1331 |
1898 const unsigned char *body, | 1332 SECStatus RSA_SignRaw(RSAPrivateKey *key, unsigned char *output, |
1899 unsigned int bodyLen, | 1333 unsigned int *outputLen, unsigned int maxOutputLen, |
1900 unsigned int bodyTotalLen) | 1334 const unsigned char *input, unsigned int inputLen) { |
1901 { | 1335 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1902 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1903 return SECFailure; | |
1904 return (vector->p_HMAC_ConstantTime)( | |
1905 result, resultLen, maxResultLen, | |
1906 hashObj, | |
1907 secret, secretLen, | |
1908 header, headerLen, | |
1909 body, bodyLen, bodyTotalLen); | |
1910 } | |
1911 | |
1912 SECStatus RSA_SignRaw(RSAPrivateKey *key, | |
1913 unsigned char *output, | |
1914 unsigned int *outputLen, | |
1915 unsigned int maxOutputLen, | |
1916 const unsigned char *input, | |
1917 unsigned int inputLen) { | |
1918 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1919 return SECFailure; | |
1920 return (vector->p_RSA_SignRaw)(key, output, outputLen, maxOutputLen, input, | 1336 return (vector->p_RSA_SignRaw)(key, output, outputLen, maxOutputLen, input, |
1921 inputLen); | 1337 inputLen); |
1922 } | 1338 } |
1923 | 1339 |
1924 SECStatus RSA_CheckSignRaw(RSAPublicKey *key, | 1340 SECStatus RSA_CheckSignRaw(RSAPublicKey *key, const unsigned char *sig, |
1925 const unsigned char *sig, | 1341 unsigned int sigLen, const unsigned char *hash, |
1926 unsigned int sigLen, | |
1927 const unsigned char *hash, | |
1928 unsigned int hashLen) { | 1342 unsigned int hashLen) { |
1929 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1343 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1930 return SECFailure; | |
1931 return (vector->p_RSA_CheckSignRaw)(key, sig, sigLen, hash, hashLen); | 1344 return (vector->p_RSA_CheckSignRaw)(key, sig, sigLen, hash, hashLen); |
1932 } | 1345 } |
1933 | 1346 |
1934 SECStatus RSA_CheckSignRecoverRaw(RSAPublicKey *key, | 1347 SECStatus RSA_CheckSignRecoverRaw(RSAPublicKey *key, unsigned char *data, |
1935 unsigned char *data, | |
1936 unsigned int *dataLen, | 1348 unsigned int *dataLen, |
1937 unsigned int maxDataLen, | 1349 unsigned int maxDataLen, |
1938 const unsigned char *sig, | 1350 const unsigned char *sig, |
1939 unsigned int sigLen) { | 1351 unsigned int sigLen) { |
1940 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1352 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1941 return SECFailure; | |
1942 return (vector->p_RSA_CheckSignRecoverRaw)(key, data, dataLen, maxDataLen, | 1353 return (vector->p_RSA_CheckSignRecoverRaw)(key, data, dataLen, maxDataLen, |
1943 sig, sigLen); | 1354 sig, sigLen); |
1944 } | 1355 } |
1945 | 1356 |
1946 SECStatus RSA_EncryptRaw(RSAPublicKey *key, | 1357 SECStatus RSA_EncryptRaw(RSAPublicKey *key, unsigned char *output, |
1947 unsigned char *output, | 1358 unsigned int *outputLen, unsigned int maxOutputLen, |
1948 unsigned int *outputLen, | 1359 const unsigned char *input, unsigned int inputLen) { |
1949 unsigned int maxOutputLen, | 1360 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1950 const unsigned char *input, | 1361 return (vector->p_RSA_EncryptRaw)(key, output, outputLen, maxOutputLen, input, |
1951 unsigned int inputLen) { | 1362 inputLen); |
1952 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1363 } |
1953 return SECFailure; | 1364 |
1954 return (vector->p_RSA_EncryptRaw)(key, output, outputLen, maxOutputLen, | 1365 SECStatus RSA_DecryptRaw(RSAPrivateKey *key, unsigned char *output, |
1955 input, inputLen); | 1366 unsigned int *outputLen, unsigned int maxOutputLen, |
1956 } | 1367 const unsigned char *input, unsigned int inputLen) { |
1957 | 1368 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1958 SECStatus RSA_DecryptRaw(RSAPrivateKey *key, | 1369 return (vector->p_RSA_DecryptRaw)(key, output, outputLen, maxOutputLen, input, |
1959 unsigned char *output, | 1370 inputLen); |
1960 unsigned int *outputLen, | 1371 } |
1961 unsigned int maxOutputLen, | 1372 |
1962 const unsigned char *input, | 1373 SECStatus RSA_EncryptOAEP(RSAPublicKey *key, HASH_HashType hashAlg, |
1963 unsigned int inputLen) { | 1374 HASH_HashType maskHashAlg, const unsigned char *label, |
1964 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1375 unsigned int labelLen, const unsigned char *seed, |
1965 return SECFailure; | 1376 unsigned int seedLen, unsigned char *output, |
1966 return (vector->p_RSA_DecryptRaw)(key, output, outputLen, maxOutputLen, | 1377 unsigned int *outputLen, unsigned int maxOutputLen, |
1967 input, inputLen); | 1378 const unsigned char *input, unsigned int inputLen) { |
1968 | 1379 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
1969 } | 1380 return (vector->p_RSA_EncryptOAEP)(key, hashAlg, maskHashAlg, label, labelLen, |
1970 | 1381 seed, seedLen, output, outputLen, |
1971 SECStatus RSA_EncryptOAEP(RSAPublicKey *key, | |
1972 HASH_HashType hashAlg, | |
1973 HASH_HashType maskHashAlg, | |
1974 const unsigned char *label, | |
1975 unsigned int labelLen, | |
1976 const unsigned char *seed, | |
1977 unsigned int seedLen, | |
1978 unsigned char *output, | |
1979 unsigned int *outputLen, | |
1980 unsigned int maxOutputLen, | |
1981 const unsigned char *input, | |
1982 unsigned int inputLen) { | |
1983 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
1984 return SECFailure; | |
1985 return (vector->p_RSA_EncryptOAEP)(key, hashAlg, maskHashAlg, label, | |
1986 labelLen, seed, seedLen, output, | |
1987 outputLen, maxOutputLen, input, inputLen); | |
1988 } | |
1989 | |
1990 SECStatus RSA_DecryptOAEP(RSAPrivateKey *key, | |
1991 HASH_HashType hashAlg, | |
1992 HASH_HashType maskHashAlg, | |
1993 const unsigned char *label, | |
1994 unsigned int labelLen, | |
1995 unsigned char *output, | |
1996 unsigned int *outputLen, | |
1997 unsigned int maxOutputLen, | |
1998 const unsigned char *input, | |
1999 unsigned int inputLen) { | |
2000 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2001 return SECFailure; | |
2002 return (vector->p_RSA_DecryptOAEP)(key, hashAlg, maskHashAlg, label, | |
2003 labelLen, output, outputLen, | |
2004 maxOutputLen, input, inputLen); | 1382 maxOutputLen, input, inputLen); |
2005 } | 1383 } |
2006 | 1384 |
2007 SECStatus RSA_EncryptBlock(RSAPublicKey *key, | 1385 SECStatus RSA_DecryptOAEP(RSAPrivateKey *key, HASH_HashType hashAlg, |
2008 unsigned char *output, | 1386 HASH_HashType maskHashAlg, const unsigned char *label, |
2009 unsigned int *outputLen, | 1387 unsigned int labelLen, unsigned char *output, |
2010 unsigned int maxOutputLen, | 1388 unsigned int *outputLen, unsigned int maxOutputLen, |
2011 const unsigned char *input, | 1389 const unsigned char *input, unsigned int inputLen) { |
2012 unsigned int inputLen) { | 1390 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2013 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1391 return (vector->p_RSA_DecryptOAEP)(key, hashAlg, maskHashAlg, label, labelLen, |
2014 return SECFailure; | 1392 output, outputLen, maxOutputLen, input, |
| 1393 inputLen); |
| 1394 } |
| 1395 |
| 1396 SECStatus RSA_EncryptBlock(RSAPublicKey *key, unsigned char *output, |
| 1397 unsigned int *outputLen, unsigned int maxOutputLen, |
| 1398 const unsigned char *input, unsigned int inputLen) { |
| 1399 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2015 return (vector->p_RSA_EncryptBlock)(key, output, outputLen, maxOutputLen, | 1400 return (vector->p_RSA_EncryptBlock)(key, output, outputLen, maxOutputLen, |
2016 input, inputLen); | 1401 input, inputLen); |
2017 } | 1402 } |
2018 | 1403 |
2019 SECStatus RSA_DecryptBlock(RSAPrivateKey *key, | 1404 SECStatus RSA_DecryptBlock(RSAPrivateKey *key, unsigned char *output, |
2020 unsigned char *output, | 1405 unsigned int *outputLen, unsigned int maxOutputLen, |
2021 unsigned int *outputLen, | 1406 const unsigned char *input, unsigned int inputLen) { |
2022 unsigned int maxOutputLen, | 1407 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2023 const unsigned char *input, | |
2024 unsigned int inputLen) { | |
2025 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2026 return SECFailure; | |
2027 return (vector->p_RSA_DecryptBlock)(key, output, outputLen, maxOutputLen, | 1408 return (vector->p_RSA_DecryptBlock)(key, output, outputLen, maxOutputLen, |
2028 input, inputLen); | 1409 input, inputLen); |
2029 } | 1410 } |
2030 | 1411 |
2031 SECStatus RSA_SignPSS(RSAPrivateKey *key, | 1412 SECStatus RSA_SignPSS(RSAPrivateKey *key, HASH_HashType hashAlg, |
2032 HASH_HashType hashAlg, | 1413 HASH_HashType maskHashAlg, const unsigned char *salt, |
2033 HASH_HashType maskHashAlg, | 1414 unsigned int saltLen, unsigned char *output, |
2034 const unsigned char *salt, | 1415 unsigned int *outputLen, unsigned int maxOutputLen, |
2035 unsigned int saltLen, | 1416 const unsigned char *input, unsigned int inputLen) { |
2036 unsigned char *output, | 1417 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2037 unsigned int *outputLen, | |
2038 unsigned int maxOutputLen, | |
2039 const unsigned char *input, | |
2040 unsigned int inputLen) { | |
2041 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2042 return SECFailure; | |
2043 return (vector->p_RSA_SignPSS)(key, hashAlg, maskHashAlg, salt, saltLen, | 1418 return (vector->p_RSA_SignPSS)(key, hashAlg, maskHashAlg, salt, saltLen, |
2044 output, outputLen, maxOutputLen, input, | 1419 output, outputLen, maxOutputLen, input, |
2045 inputLen); | 1420 inputLen); |
2046 } | 1421 } |
2047 | 1422 |
2048 SECStatus RSA_CheckSignPSS(RSAPublicKey *key, | 1423 SECStatus RSA_CheckSignPSS(RSAPublicKey *key, HASH_HashType hashAlg, |
2049 HASH_HashType hashAlg, | 1424 HASH_HashType maskHashAlg, unsigned int saltLen, |
2050 HASH_HashType maskHashAlg, | 1425 const unsigned char *sig, unsigned int sigLen, |
2051 unsigned int saltLen, | 1426 const unsigned char *hash, unsigned int hashLen) { |
2052 const unsigned char *sig, | 1427 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2053 unsigned int sigLen, | 1428 return (vector->p_RSA_CheckSignPSS)(key, hashAlg, maskHashAlg, saltLen, sig, |
2054 const unsigned char *hash, | 1429 sigLen, hash, hashLen); |
2055 unsigned int hashLen) { | 1430 } |
2056 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1431 |
2057 return SECFailure; | 1432 SECStatus RSA_Sign(RSAPrivateKey *key, unsigned char *output, |
2058 return (vector->p_RSA_CheckSignPSS)(key, hashAlg, maskHashAlg, saltLen, | 1433 unsigned int *outputLen, unsigned int maxOutputLen, |
2059 sig, sigLen, hash, hashLen); | 1434 const unsigned char *input, unsigned int inputLen) { |
2060 } | 1435 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2061 | |
2062 SECStatus RSA_Sign(RSAPrivateKey *key, | |
2063 unsigned char *output, | |
2064 unsigned int *outputLen, | |
2065 unsigned int maxOutputLen, | |
2066 const unsigned char *input, | |
2067 unsigned int inputLen) { | |
2068 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2069 return SECFailure; | |
2070 return (vector->p_RSA_Sign)(key, output, outputLen, maxOutputLen, input, | 1436 return (vector->p_RSA_Sign)(key, output, outputLen, maxOutputLen, input, |
2071 inputLen); | 1437 inputLen); |
2072 } | 1438 } |
2073 | 1439 |
2074 SECStatus RSA_CheckSign(RSAPublicKey *key, | 1440 SECStatus RSA_CheckSign(RSAPublicKey *key, const unsigned char *sig, |
2075 const unsigned char *sig, | 1441 unsigned int sigLen, const unsigned char *data, |
2076 unsigned int sigLen, | |
2077 const unsigned char *data, | |
2078 unsigned int dataLen) { | 1442 unsigned int dataLen) { |
2079 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1443 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2080 return SECFailure; | |
2081 return (vector->p_RSA_CheckSign)(key, sig, sigLen, data, dataLen); | 1444 return (vector->p_RSA_CheckSign)(key, sig, sigLen, data, dataLen); |
2082 | 1445 } |
2083 } | 1446 |
2084 | 1447 SECStatus RSA_CheckSignRecover(RSAPublicKey *key, unsigned char *output, |
2085 SECStatus RSA_CheckSignRecover(RSAPublicKey *key, | |
2086 unsigned char *output, | |
2087 unsigned int *outputLen, | 1448 unsigned int *outputLen, |
2088 unsigned int maxOutputLen, | 1449 unsigned int maxOutputLen, |
2089 const unsigned char *sig, | 1450 const unsigned char *sig, unsigned int sigLen) { |
2090 unsigned int sigLen) { | 1451 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2091 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2092 return SECFailure; | |
2093 return (vector->p_RSA_CheckSignRecover)(key, output, outputLen, maxOutputLen, | 1452 return (vector->p_RSA_CheckSignRecover)(key, output, outputLen, maxOutputLen, |
2094 sig, sigLen); | 1453 sig, sigLen); |
2095 } | 1454 } |
2096 | 1455 |
2097 SECStatus EC_FillParams(PLArenaPool *arena, | 1456 SECStatus EC_FillParams(PLArenaPool *arena, const SECItem *encodedParams, |
2098 const SECItem *encodedParams, | 1457 ECParams *params) { |
2099 ECParams *params) | 1458 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2100 { | |
2101 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2102 return SECFailure; | |
2103 return (vector->p_EC_FillParams)(arena, encodedParams, params); | 1459 return (vector->p_EC_FillParams)(arena, encodedParams, params); |
2104 } | 1460 } |
2105 | 1461 |
2106 SECStatus EC_DecodeParams(const SECItem *encodedParams, | 1462 SECStatus EC_DecodeParams(const SECItem *encodedParams, ECParams **ecparams) { |
2107 ECParams **ecparams) | 1463 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2108 { | |
2109 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | |
2110 return SECFailure; | |
2111 return (vector->p_EC_DecodeParams)(encodedParams, ecparams); | 1464 return (vector->p_EC_DecodeParams)(encodedParams, ecparams); |
2112 } | 1465 } |
2113 | 1466 |
2114 SECStatus EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, | 1467 SECStatus EC_CopyParams(PLArenaPool *arena, ECParams *dstParams, |
2115 const ECParams *srcParams) | 1468 const ECParams *srcParams) { |
2116 { | 1469 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) return SECFailure; |
2117 if (!vector && PR_SUCCESS != freebl_RunLoaderOnce()) | 1470 return (vector->p_EC_CopyParams)(arena, dstParams, srcParams); |
2118 return SECFailure; | 1471 } |
2119 return (vector->p_EC_CopyParams)(arena, dstParams, srcParams); | |
2120 } | |
2121 | |
OLD | NEW |