diff options
Diffstat (limited to 'security/nss/cmd/fbectest')
-rw-r--r-- | security/nss/cmd/fbectest/fbectest.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/security/nss/cmd/fbectest/fbectest.c b/security/nss/cmd/fbectest/fbectest.c index 2336d3fa8..1c8f4c039 100644 --- a/security/nss/cmd/fbectest/fbectest.c +++ b/security/nss/cmd/fbectest/fbectest.c @@ -9,7 +9,6 @@ #include "basicutil.h" #include "secder.h" #include "secitem.h" -#include "secutil.h" #include "nspr.h" #include <stdio.h> @@ -89,26 +88,19 @@ ectest_ecdh_kat(ECDH_KAT *kat) SECItem answer = { siBuffer, NULL, 0 }; SECItem answer2 = { siBuffer, NULL, 0 }; SECItem derived = { siBuffer, NULL, 0 }; - char genenc[3 + 2 * 2 * MAX_ECKEY_LEN]; + SECItem ecEncodedParams = { siBuffer, NULL, 0 }; int i; - rv = init_params(&ecParams, curve, &arena, kat->fieldType); - if (rv != SECSuccess) { - return rv; + arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); + if (!arena) { + return SECFailure; } - SECU_HexString2SECItem(arena, &ecParams.fieldID.u.prime, ecCurve_map[curve]->irr); - SECU_HexString2SECItem(arena, &ecParams.curve.a, ecCurve_map[curve]->curvea); - SECU_HexString2SECItem(arena, &ecParams.curve.b, ecCurve_map[curve]->curveb); - genenc[0] = '0'; - genenc[1] = '4'; - genenc[2] = '\0'; - PORT_Assert(PR_ARRAY_SIZE(genenc) >= PORT_Strlen(ecCurve_map[curve]->genx)); - PORT_Assert(PR_ARRAY_SIZE(genenc) >= PORT_Strlen(ecCurve_map[curve]->geny)); - strcat(genenc, ecCurve_map[curve]->genx); - strcat(genenc, ecCurve_map[curve]->geny); - SECU_HexString2SECItem(arena, &ecParams.base, genenc); - SECU_HexString2SECItem(arena, &ecParams.order, ecCurve_map[curve]->order); + rv = SECU_ecName2params(curve, &ecEncodedParams); + if (rv != SECSuccess) { + goto cleanup; + } + EC_FillParams(arena, &ecEncodedParams, &ecParams); if (kat->our_pubhex) { SECU_HexString2SECItem(arena, &answer, kat->our_pubhex); @@ -162,6 +154,7 @@ ectest_ecdh_kat(ECDH_KAT *kat) } cleanup: + SECITEM_FreeItem(&ecEncodedParams, PR_FALSE); PORT_FreeArena(arena, PR_FALSE); if (ecPriv) { PORT_FreeArena(ecPriv->ecParams.arena, PR_FALSE); |