diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-02-06 12:02:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-06 12:02:47 +0100 |
commit | 389c60da5e01761f4a11ef539ffa26e4c1b17875 (patch) | |
tree | c6033924a0de9be1ab140596e305898c651bf57e /security/nss/cmd/fbectest/fbectest.c | |
parent | 7c9b585349c985df0cf6ace83da5dadba8b5c677 (diff) | |
parent | f017b749ea9f1586d2308504553d40bf4cc5439d (diff) | |
download | UXP-389c60da5e01761f4a11ef539ffa26e4c1b17875.tar UXP-389c60da5e01761f4a11ef539ffa26e4c1b17875.tar.gz UXP-389c60da5e01761f4a11ef539ffa26e4c1b17875.tar.lz UXP-389c60da5e01761f4a11ef539ffa26e4c1b17875.tar.xz UXP-389c60da5e01761f4a11ef539ffa26e4c1b17875.zip |
Merge pull request #13 from MoonchildProductions/ported-upstream
Ported upstream
Diffstat (limited to 'security/nss/cmd/fbectest/fbectest.c')
-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); |