comparison nss/lib/freebl/ecdecode.c @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef NSS_DISABLE_ECC
6
7 #ifdef FREEBL_NO_DEPEND
8 #include "stubs.h"
9 #endif
10
11 #include "blapi.h"
12 #include "secoid.h"
13 #include "secitem.h"
14 #include "secerr.h"
15 #include "ec.h"
16 #include "ecl-curve.h"
17
18 #define CHECK_OK(func) if (func == NULL) goto cleanup
19 #define CHECK_SEC_OK(func) if (SECSuccess != (rv = func)) goto cleanup
20
21 /*
22 * Initializes a SECItem from a hexadecimal string
23 *
24 * Warning: This function ignores leading 00's, so any leading 00's
25 * in the hexadecimal string must be optional.
26 */
27 static SECItem *
28 hexString2SECItem(PLArenaPool *arena, SECItem *item, const char *str)
29 {
30 int i = 0;
31 int byteval = 0;
32 int tmp = PORT_Strlen(str);
33
34 if ((tmp % 2) != 0) return NULL;
35
36 /* skip leading 00's unless the hex string is "00" */
37 while ((tmp > 2) && (str[0] == '0') && (str[1] == '0')) {
38 str += 2;
39 tmp -= 2;
40 }
41
42 item->data = (unsigned char *) PORT_ArenaAlloc(arena, tmp/2);
43 if (item->data == NULL) return NULL;
44 item->len = tmp/2;
45
46 while (str[i]) {
47 if ((str[i] >= '0') && (str[i] <= '9'))
48 tmp = str[i] - '0';
49 else if ((str[i] >= 'a') && (str[i] <= 'f'))
50 tmp = str[i] - 'a' + 10;
51 else if ((str[i] >= 'A') && (str[i] <= 'F'))
52 tmp = str[i] - 'A' + 10;
53 else
54 return NULL;
55
56 byteval = byteval * 16 + tmp;
57 if ((i % 2) != 0) {
58 item->data[i/2] = byteval;
59 byteval = 0;
60 }
61 i++;
62 }
63
64 return item;
65 }
66
67 /* Copy all of the fields from srcParams into dstParams
68 */
69 SECStatus
70 EC_CopyParams(PLArenaPool *arena, ECParams *dstParams,
71 const ECParams *srcParams)
72 {
73 SECStatus rv = SECFailure;
74
75 dstParams->arena = arena;
76 dstParams->type = srcParams->type;
77 dstParams->fieldID.size = srcParams->fieldID.size;
78 dstParams->fieldID.type = srcParams->fieldID.type;
79 if (srcParams->fieldID.type == ec_field_GFp) {
80 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->fieldID.u.prime,
81 &srcParams->fieldID.u.prime));
82 } else {
83 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->fieldID.u.poly,
84 &srcParams->fieldID.u.poly));
85 }
86 dstParams->fieldID.k1 = srcParams->fieldID.k1;
87 dstParams->fieldID.k2 = srcParams->fieldID.k2;
88 dstParams->fieldID.k3 = srcParams->fieldID.k3;
89 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->curve.a,
90 &srcParams->curve.a));
91 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->curve.b,
92 &srcParams->curve.b));
93 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->curve.seed,
94 &srcParams->curve.seed));
95 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->base,
96 &srcParams->base));
97 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->order,
98 &srcParams->order));
99 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->DEREncoding,
100 &srcParams->DEREncoding));
101 dstParams->name = srcParams->name;
102 CHECK_SEC_OK(SECITEM_CopyItem(arena, &dstParams->curveOID,
103 &srcParams->curveOID));
104 dstParams->cofactor = srcParams->cofactor;
105
106 return SECSuccess;
107
108 cleanup:
109 return SECFailure;
110 }
111
112 static SECStatus
113 gf_populate_params(ECCurveName name, ECFieldType field_type, ECParams *params)
114 {
115 SECStatus rv = SECFailure;
116 const ECCurveParams *curveParams;
117 /* 2 ['0'+'4'] + MAX_ECKEY_LEN * 2 [x,y] * 2 [hex string] + 1 ['\0'] */
118 char genenc[3 + 2 * 2 * MAX_ECKEY_LEN];
119
120 if ((name < ECCurve_noName) || (name > ECCurve_pastLastCurve)) goto cleanup;
121 params->name = name;
122 curveParams = ecCurve_map[params->name];
123 CHECK_OK(curveParams);
124 params->fieldID.size = curveParams->size;
125 params->fieldID.type = field_type;
126 if (field_type == ec_field_GFp) {
127 CHECK_OK(hexString2SECItem(params->arena, &params->fieldID.u.prime,
128 curveParams->irr));
129 } else {
130 CHECK_OK(hexString2SECItem(params->arena, &params->fieldID.u.poly,
131 curveParams->irr));
132 }
133 CHECK_OK(hexString2SECItem(params->arena, &params->curve.a,
134 curveParams->curvea));
135 CHECK_OK(hexString2SECItem(params->arena, &params->curve.b,
136 curveParams->curveb));
137 genenc[0] = '0';
138 genenc[1] = '4';
139 genenc[2] = '\0';
140 strcat(genenc, curveParams->genx);
141 strcat(genenc, curveParams->geny);
142 CHECK_OK(hexString2SECItem(params->arena, &params->base, genenc));
143 CHECK_OK(hexString2SECItem(params->arena, &params->order,
144 curveParams->order));
145 params->cofactor = curveParams->cofactor;
146
147 rv = SECSuccess;
148
149 cleanup:
150 return rv;
151 }
152
153 SECStatus
154 EC_FillParams(PLArenaPool *arena, const SECItem *encodedParams,
155 ECParams *params)
156 {
157 SECStatus rv = SECFailure;
158 SECOidTag tag;
159 SECItem oid = { siBuffer, NULL, 0};
160
161 #if EC_DEBUG
162 int i;
163
164 printf("Encoded params in EC_DecodeParams: ");
165 for (i = 0; i < encodedParams->len; i++) {
166 printf("%02x:", encodedParams->data[i]);
167 }
168 printf("\n");
169 #endif
170
171 if ((encodedParams->len != ANSI_X962_CURVE_OID_TOTAL_LEN) &&
172 (encodedParams->len != SECG_CURVE_OID_TOTAL_LEN)) {
173 PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE);
174 return SECFailure;
175 };
176
177 oid.len = encodedParams->len - 2;
178 oid.data = encodedParams->data + 2;
179 if ((encodedParams->data[0] != SEC_ASN1_OBJECT_ID) ||
180 ((tag = SECOID_FindOIDTag(&oid)) == SEC_OID_UNKNOWN)) {
181 PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE);
182 return SECFailure;
183 }
184
185 params->arena = arena;
186 params->cofactor = 0;
187 params->type = ec_params_named;
188 params->name = ECCurve_noName;
189
190 /* For named curves, fill out curveOID */
191 params->curveOID.len = oid.len;
192 params->curveOID.data = (unsigned char *) PORT_ArenaAlloc(arena, oid.len);
193 if (params->curveOID.data == NULL) goto cleanup;
194 memcpy(params->curveOID.data, oid.data, oid.len);
195
196 #if EC_DEBUG
197 printf("Curve: %s\n", SECOID_FindOIDTagDescription(tag));
198 #endif
199
200 switch (tag) {
201
202 /* Binary curves */
203
204 case SEC_OID_ANSIX962_EC_C2PNB163V1:
205 /* Populate params for c2pnb163v1 */
206 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB163V1, ec_field_GF2m,
207 params) );
208 break;
209
210 case SEC_OID_ANSIX962_EC_C2PNB163V2:
211 /* Populate params for c2pnb163v2 */
212 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB163V2, ec_field_GF2m,
213 params) );
214 break;
215
216 case SEC_OID_ANSIX962_EC_C2PNB163V3:
217 /* Populate params for c2pnb163v3 */
218 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB163V3, ec_field_GF2m,
219 params) );
220 break;
221
222 case SEC_OID_ANSIX962_EC_C2PNB176V1:
223 /* Populate params for c2pnb176v1 */
224 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB176V1, ec_field_GF2m,
225 params) );
226 break;
227
228 case SEC_OID_ANSIX962_EC_C2TNB191V1:
229 /* Populate params for c2tnb191v1 */
230 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB191V1, ec_field_GF2m,
231 params) );
232 break;
233
234 case SEC_OID_ANSIX962_EC_C2TNB191V2:
235 /* Populate params for c2tnb191v2 */
236 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB191V2, ec_field_GF2m,
237 params) );
238 break;
239
240 case SEC_OID_ANSIX962_EC_C2TNB191V3:
241 /* Populate params for c2tnb191v3 */
242 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB191V3, ec_field_GF2m,
243 params) );
244 break;
245
246 case SEC_OID_ANSIX962_EC_C2PNB208W1:
247 /* Populate params for c2pnb208w1 */
248 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB208W1, ec_field_GF2m,
249 params) );
250 break;
251
252 case SEC_OID_ANSIX962_EC_C2TNB239V1:
253 /* Populate params for c2tnb239v1 */
254 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB239V1, ec_field_GF2m,
255 params) );
256 break;
257
258 case SEC_OID_ANSIX962_EC_C2TNB239V2:
259 /* Populate params for c2tnb239v2 */
260 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB239V2, ec_field_GF2m,
261 params) );
262 break;
263
264 case SEC_OID_ANSIX962_EC_C2TNB239V3:
265 /* Populate params for c2tnb239v3 */
266 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB239V3, ec_field_GF2m,
267 params) );
268 break;
269
270 case SEC_OID_ANSIX962_EC_C2PNB272W1:
271 /* Populate params for c2pnb272w1 */
272 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB272W1, ec_field_GF2m,
273 params) );
274 break;
275
276 case SEC_OID_ANSIX962_EC_C2PNB304W1:
277 /* Populate params for c2pnb304w1 */
278 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB304W1, ec_field_GF2m,
279 params) );
280 break;
281
282 case SEC_OID_ANSIX962_EC_C2TNB359V1:
283 /* Populate params for c2tnb359v1 */
284 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB359V1, ec_field_GF2m,
285 params) );
286 break;
287
288 case SEC_OID_ANSIX962_EC_C2PNB368W1:
289 /* Populate params for c2pnb368w1 */
290 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_PNB368W1, ec_field_GF2m,
291 params) );
292 break;
293
294 case SEC_OID_ANSIX962_EC_C2TNB431R1:
295 /* Populate params for c2tnb431r1 */
296 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_CHAR2_TNB431R1, ec_field_GF2m,
297 params) );
298 break;
299
300 case SEC_OID_SECG_EC_SECT113R1:
301 /* Populate params for sect113r1 */
302 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_113R1, ec_field_GF2m,
303 params) );
304 break;
305
306 case SEC_OID_SECG_EC_SECT113R2:
307 /* Populate params for sect113r2 */
308 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_113R2, ec_field_GF2m,
309 params) );
310 break;
311
312 case SEC_OID_SECG_EC_SECT131R1:
313 /* Populate params for sect131r1 */
314 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_131R1, ec_field_GF2m,
315 params) );
316 break;
317
318 case SEC_OID_SECG_EC_SECT131R2:
319 /* Populate params for sect131r2 */
320 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_131R2, ec_field_GF2m,
321 params) );
322 break;
323
324 case SEC_OID_SECG_EC_SECT163K1:
325 /* Populate params for sect163k1
326 * (the NIST K-163 curve)
327 */
328 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_163K1, ec_field_GF2m,
329 params) );
330 break;
331
332 case SEC_OID_SECG_EC_SECT163R1:
333 /* Populate params for sect163r1 */
334 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_163R1, ec_field_GF2m,
335 params) );
336 break;
337
338 case SEC_OID_SECG_EC_SECT163R2:
339 /* Populate params for sect163r2
340 * (the NIST B-163 curve)
341 */
342 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_163R2, ec_field_GF2m,
343 params) );
344 break;
345
346 case SEC_OID_SECG_EC_SECT193R1:
347 /* Populate params for sect193r1 */
348 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_193R1, ec_field_GF2m,
349 params) );
350 break;
351
352 case SEC_OID_SECG_EC_SECT193R2:
353 /* Populate params for sect193r2 */
354 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_193R2, ec_field_GF2m,
355 params) );
356 break;
357
358 case SEC_OID_SECG_EC_SECT233K1:
359 /* Populate params for sect233k1
360 * (the NIST K-233 curve)
361 */
362 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_233K1, ec_field_GF2m,
363 params) );
364 break;
365
366 case SEC_OID_SECG_EC_SECT233R1:
367 /* Populate params for sect233r1
368 * (the NIST B-233 curve)
369 */
370 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_233R1, ec_field_GF2m,
371 params) );
372 break;
373
374 case SEC_OID_SECG_EC_SECT239K1:
375 /* Populate params for sect239k1 */
376 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_239K1, ec_field_GF2m,
377 params) );
378 break;
379
380 case SEC_OID_SECG_EC_SECT283K1:
381 /* Populate params for sect283k1
382 * (the NIST K-283 curve)
383 */
384 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_283K1, ec_field_GF2m,
385 params) );
386 break;
387
388 case SEC_OID_SECG_EC_SECT283R1:
389 /* Populate params for sect283r1
390 * (the NIST B-283 curve)
391 */
392 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_283R1, ec_field_GF2m,
393 params) );
394 break;
395
396 case SEC_OID_SECG_EC_SECT409K1:
397 /* Populate params for sect409k1
398 * (the NIST K-409 curve)
399 */
400 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_409K1, ec_field_GF2m,
401 params) );
402 break;
403
404 case SEC_OID_SECG_EC_SECT409R1:
405 /* Populate params for sect409r1
406 * (the NIST B-409 curve)
407 */
408 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_409R1, ec_field_GF2m,
409 params) );
410 break;
411
412 case SEC_OID_SECG_EC_SECT571K1:
413 /* Populate params for sect571k1
414 * (the NIST K-571 curve)
415 */
416 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_571K1, ec_field_GF2m,
417 params) );
418 break;
419
420 case SEC_OID_SECG_EC_SECT571R1:
421 /* Populate params for sect571r1
422 * (the NIST B-571 curve)
423 */
424 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_CHAR2_571R1, ec_field_GF2m,
425 params) );
426 break;
427
428 /* Prime curves */
429
430 case SEC_OID_ANSIX962_EC_PRIME192V1:
431 /* Populate params for prime192v1 aka secp192r1
432 * (the NIST P-192 curve)
433 */
434 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_192V1, ec_field_GFp,
435 params) );
436 break;
437
438 case SEC_OID_ANSIX962_EC_PRIME192V2:
439 /* Populate params for prime192v2 */
440 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_192V2, ec_field_GFp,
441 params) );
442 break;
443
444 case SEC_OID_ANSIX962_EC_PRIME192V3:
445 /* Populate params for prime192v3 */
446 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_192V3, ec_field_GFp,
447 params) );
448 break;
449
450 case SEC_OID_ANSIX962_EC_PRIME239V1:
451 /* Populate params for prime239v1 */
452 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_239V1, ec_field_GFp,
453 params) );
454 break;
455
456 case SEC_OID_ANSIX962_EC_PRIME239V2:
457 /* Populate params for prime239v2 */
458 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_239V2, ec_field_GFp,
459 params) );
460 break;
461
462 case SEC_OID_ANSIX962_EC_PRIME239V3:
463 /* Populate params for prime239v3 */
464 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_239V3, ec_field_GFp,
465 params) );
466 break;
467
468 case SEC_OID_ANSIX962_EC_PRIME256V1:
469 /* Populate params for prime256v1 aka secp256r1
470 * (the NIST P-256 curve)
471 */
472 CHECK_SEC_OK( gf_populate_params(ECCurve_X9_62_PRIME_256V1, ec_field_GFp,
473 params) );
474 break;
475
476 case SEC_OID_SECG_EC_SECP112R1:
477 /* Populate params for secp112r1 */
478 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_112R1, ec_field_GFp,
479 params) );
480 break;
481
482 case SEC_OID_SECG_EC_SECP112R2:
483 /* Populate params for secp112r2 */
484 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_112R2, ec_field_GFp,
485 params) );
486 break;
487
488 case SEC_OID_SECG_EC_SECP128R1:
489 /* Populate params for secp128r1 */
490 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_128R1, ec_field_GFp,
491 params) );
492 break;
493
494 case SEC_OID_SECG_EC_SECP128R2:
495 /* Populate params for secp128r2 */
496 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_128R2, ec_field_GFp,
497 params) );
498 break;
499
500 case SEC_OID_SECG_EC_SECP160K1:
501 /* Populate params for secp160k1 */
502 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_160K1, ec_field_GFp,
503 params) );
504 break;
505
506 case SEC_OID_SECG_EC_SECP160R1:
507 /* Populate params for secp160r1 */
508 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_160R1, ec_field_GFp,
509 params) );
510 break;
511
512 case SEC_OID_SECG_EC_SECP160R2:
513 /* Populate params for secp160r1 */
514 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_160R2, ec_field_GFp,
515 params) );
516 break;
517
518 case SEC_OID_SECG_EC_SECP192K1:
519 /* Populate params for secp192k1 */
520 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_192K1, ec_field_GFp,
521 params) );
522 break;
523
524 case SEC_OID_SECG_EC_SECP224K1:
525 /* Populate params for secp224k1 */
526 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_224K1, ec_field_GFp,
527 params) );
528 break;
529
530 case SEC_OID_SECG_EC_SECP224R1:
531 /* Populate params for secp224r1
532 * (the NIST P-224 curve)
533 */
534 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_224R1, ec_field_GFp,
535 params) );
536 break;
537
538 case SEC_OID_SECG_EC_SECP256K1:
539 /* Populate params for secp256k1 */
540 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_256K1, ec_field_GFp,
541 params) );
542 break;
543
544 case SEC_OID_SECG_EC_SECP384R1:
545 /* Populate params for secp384r1
546 * (the NIST P-384 curve)
547 */
548 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_384R1, ec_field_GFp,
549 params) );
550 break;
551
552 case SEC_OID_SECG_EC_SECP521R1:
553 /* Populate params for secp521r1
554 * (the NIST P-521 curve)
555 */
556 CHECK_SEC_OK( gf_populate_params(ECCurve_SECG_PRIME_521R1, ec_field_GFp,
557 params) );
558 break;
559
560 default:
561 break;
562 };
563
564 cleanup:
565 if (!params->cofactor) {
566 PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE);
567 #if EC_DEBUG
568 printf("Unrecognized curve, returning NULL params\n");
569 #endif
570 }
571
572 return rv;
573 }
574
575 SECStatus
576 EC_DecodeParams(const SECItem *encodedParams, ECParams **ecparams)
577 {
578 PLArenaPool *arena;
579 ECParams *params;
580 SECStatus rv = SECFailure;
581
582 /* Initialize an arena for the ECParams structure */
583 if (!(arena = PORT_NewArena(NSS_FREEBL_DEFAULT_CHUNKSIZE)))
584 return SECFailure;
585
586 params = (ECParams *)PORT_ArenaZAlloc(arena, sizeof(ECParams));
587 if (!params) {
588 PORT_FreeArena(arena, PR_TRUE);
589 return SECFailure;
590 }
591
592 /* Copy the encoded params */
593 SECITEM_AllocItem(arena, &(params->DEREncoding),
594 encodedParams->len);
595 memcpy(params->DEREncoding.data, encodedParams->data, encodedParams->len);
596
597 /* Fill out the rest of the ECParams structure based on
598 * the encoded params
599 */
600 rv = EC_FillParams(arena, encodedParams, params);
601 if (rv == SECFailure) {
602 PORT_FreeArena(arena, PR_TRUE);
603 return SECFailure;
604 } else {
605 *ecparams = params;;
606 return SECSuccess;
607 }
608 }
609
610 #endif /* NSS_DISABLE_ECC */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)