OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * Diffie-Hellman parameter generation, key generation, and secret derivation. | 6 * Diffie-Hellman parameter generation, key generation, and secret derivation. |
7 * KEA secret generation and verification. | 7 * KEA secret generation and verification. |
8 */ | 8 */ |
9 #ifdef FREEBL_NO_DEPEND | 9 #ifdef FREEBL_NO_DEPEND |
10 #include "stubs.h" | 10 #include "stubs.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 if (primeLen >= 256) { /* 2048 bits */ | 38 if (primeLen >= 256) { /* 2048 bits */ |
39 return 28; /* 224 bits */ | 39 return 28; /* 224 bits */ |
40 } | 40 } |
41 return 20; /* 160 bits */ | 41 return 20; /* 160 bits */ |
42 } | 42 } |
43 | 43 |
44 SECStatus | 44 SECStatus |
45 DH_GenParam(int primeLen, DHParams **params) | 45 DH_GenParam(int primeLen, DHParams **params) |
46 { | 46 { |
47 PRArenaPool *arena; | 47 PLArenaPool *arena; |
48 DHParams *dhparams; | 48 DHParams *dhparams; |
49 unsigned char *pb = NULL; | 49 unsigned char *pb = NULL; |
50 unsigned char *ab = NULL; | 50 unsigned char *ab = NULL; |
51 unsigned long counter = 0; | 51 unsigned long counter = 0; |
52 mp_int p, q, a, h, psub1, test; | 52 mp_int p, q, a, h, psub1, test; |
53 mp_err err = MP_OKAY; | 53 mp_err err = MP_OKAY; |
54 SECStatus rv = SECSuccess; | 54 SECStatus rv = SECSuccess; |
55 if (!params || primeLen < 0) { | 55 if (!params || primeLen < 0) { |
56 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 56 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
57 return SECFailure; | 57 return SECFailure; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 rv = SECFailure; | 128 rv = SECFailure; |
129 } | 129 } |
130 if (rv) | 130 if (rv) |
131 PORT_FreeArena(arena, PR_TRUE); | 131 PORT_FreeArena(arena, PR_TRUE); |
132 return rv; | 132 return rv; |
133 } | 133 } |
134 | 134 |
135 SECStatus | 135 SECStatus |
136 DH_NewKey(DHParams *params, DHPrivateKey **privKey) | 136 DH_NewKey(DHParams *params, DHPrivateKey **privKey) |
137 { | 137 { |
138 PRArenaPool *arena; | 138 PLArenaPool *arena; |
139 DHPrivateKey *key; | 139 DHPrivateKey *key; |
140 mp_int g, xa, p, Ya; | 140 mp_int g, xa, p, Ya; |
141 mp_err err = MP_OKAY; | 141 mp_err err = MP_OKAY; |
142 SECStatus rv = SECSuccess; | 142 SECStatus rv = SECSuccess; |
143 if (!params || !privKey) { | 143 if (!params || !privKey) { |
144 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 144 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
145 return SECFailure; | 145 return SECFailure; |
146 } | 146 } |
147 arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE); | 147 arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE); |
148 if (!arena) { | 148 if (!arena) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 mp_clear(&p); | 382 mp_clear(&p); |
383 mp_clear(&q); | 383 mp_clear(&q); |
384 mp_clear(&y); | 384 mp_clear(&y); |
385 mp_clear(&r); | 385 mp_clear(&r); |
386 if (err) { | 386 if (err) { |
387 MP_TO_SEC_ERROR(err); | 387 MP_TO_SEC_ERROR(err); |
388 return PR_FALSE; | 388 return PR_FALSE; |
389 } | 389 } |
390 return (cmp == 0) ? PR_TRUE : PR_FALSE; | 390 return (cmp == 0) ? PR_TRUE : PR_FALSE; |
391 } | 391 } |
OLD | NEW |