diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /security/nss/cmd/lib/basicutil.c | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-upstream/125.0.1.tar.xz firefox-upstream/125.0.1.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'security/nss/cmd/lib/basicutil.c')
-rw-r--r-- | security/nss/cmd/lib/basicutil.c | 90 |
1 files changed, 24 insertions, 66 deletions
diff --git a/security/nss/cmd/lib/basicutil.c b/security/nss/cmd/lib/basicutil.c index 3ccacd7356..bc1bb0584d 100644 --- a/security/nss/cmd/lib/basicutil.c +++ b/security/nss/cmd/lib/basicutil.c @@ -777,77 +777,35 @@ SECU_HexString2SECItem(PLArenaPool *arena, SECItem *item, const char *str) return item; } -/* mapping between ECCurveName enum and SECOidTags */ -static SECOidTag ecCurve_oid_map[] = { - SEC_OID_UNKNOWN, /* ECCurve_noName */ - SEC_OID_ANSIX962_EC_PRIME192V1, /* ECCurve_NIST_P192 */ - SEC_OID_SECG_EC_SECP224R1, /* ECCurve_NIST_P224 */ - SEC_OID_ANSIX962_EC_PRIME256V1, /* ECCurve_NIST_P256 */ - SEC_OID_SECG_EC_SECP384R1, /* ECCurve_NIST_P384 */ - SEC_OID_SECG_EC_SECP521R1, /* ECCurve_NIST_P521 */ - SEC_OID_SECG_EC_SECT163K1, /* ECCurve_NIST_K163 */ - SEC_OID_SECG_EC_SECT163R1, /* ECCurve_NIST_B163 */ - SEC_OID_SECG_EC_SECT233K1, /* ECCurve_NIST_K233 */ - SEC_OID_SECG_EC_SECT233R1, /* ECCurve_NIST_B233 */ - SEC_OID_SECG_EC_SECT283K1, /* ECCurve_NIST_K283 */ - SEC_OID_SECG_EC_SECT283R1, /* ECCurve_NIST_B283 */ - SEC_OID_SECG_EC_SECT409K1, /* ECCurve_NIST_K409 */ - SEC_OID_SECG_EC_SECT409R1, /* ECCurve_NIST_B409 */ - SEC_OID_SECG_EC_SECT571K1, /* ECCurve_NIST_K571 */ - SEC_OID_SECG_EC_SECT571R1, /* ECCurve_NIST_B571 */ - SEC_OID_ANSIX962_EC_PRIME192V2, - SEC_OID_ANSIX962_EC_PRIME192V3, - SEC_OID_ANSIX962_EC_PRIME239V1, - SEC_OID_ANSIX962_EC_PRIME239V2, - SEC_OID_ANSIX962_EC_PRIME239V3, - SEC_OID_ANSIX962_EC_C2PNB163V1, - SEC_OID_ANSIX962_EC_C2PNB163V2, - SEC_OID_ANSIX962_EC_C2PNB163V3, - SEC_OID_ANSIX962_EC_C2PNB176V1, - SEC_OID_ANSIX962_EC_C2TNB191V1, - SEC_OID_ANSIX962_EC_C2TNB191V2, - SEC_OID_ANSIX962_EC_C2TNB191V3, - SEC_OID_ANSIX962_EC_C2PNB208W1, - SEC_OID_ANSIX962_EC_C2TNB239V1, - SEC_OID_ANSIX962_EC_C2TNB239V2, - SEC_OID_ANSIX962_EC_C2TNB239V3, - SEC_OID_ANSIX962_EC_C2PNB272W1, - SEC_OID_ANSIX962_EC_C2PNB304W1, - SEC_OID_ANSIX962_EC_C2TNB359V1, - SEC_OID_ANSIX962_EC_C2PNB368W1, - SEC_OID_ANSIX962_EC_C2TNB431R1, - SEC_OID_SECG_EC_SECP112R1, - SEC_OID_SECG_EC_SECP112R2, - SEC_OID_SECG_EC_SECP128R1, - SEC_OID_SECG_EC_SECP128R2, - SEC_OID_SECG_EC_SECP160K1, - SEC_OID_SECG_EC_SECP160R1, - SEC_OID_SECG_EC_SECP160R2, - SEC_OID_SECG_EC_SECP192K1, - SEC_OID_SECG_EC_SECP224K1, - SEC_OID_SECG_EC_SECP256K1, - SEC_OID_SECG_EC_SECT113R1, - SEC_OID_SECG_EC_SECT113R2, - SEC_OID_SECG_EC_SECT131R1, - SEC_OID_SECG_EC_SECT131R2, - SEC_OID_SECG_EC_SECT163R1, - SEC_OID_SECG_EC_SECT193R1, - SEC_OID_SECG_EC_SECT193R2, - SEC_OID_SECG_EC_SECT239K1, - SEC_OID_UNKNOWN, /* ECCurve_WTLS_1 */ - SEC_OID_UNKNOWN, /* ECCurve_WTLS_8 */ - SEC_OID_UNKNOWN, /* ECCurve_WTLS_9 */ - SEC_OID_CURVE25519, - SEC_OID_UNKNOWN /* ECCurve_pastLastCurve */ -}; - SECStatus SECU_ecName2params(ECCurveName curve, SECItem *params) { + SECOidTag oidTag; SECOidData *oidData = NULL; - if ((curve < ECCurve_noName) || (curve > ECCurve_pastLastCurve) || - ((oidData = SECOID_FindOIDByTag(ecCurve_oid_map[curve])) == NULL)) { + switch (curve) { + case ECCurve_NIST_P256: + oidTag = SEC_OID_ANSIX962_EC_PRIME256V1; + break; + case ECCurve_NIST_P384: + oidTag = SEC_OID_SECG_EC_SECP384R1; + break; + case ECCurve_NIST_P521: + oidTag = SEC_OID_SECG_EC_SECP521R1; + break; + case ECCurve25519: + oidTag = SEC_OID_CURVE25519; + break; + case ECCurve_Ed25519: + oidTag = SEC_OID_ED25519_PUBLIC_KEY; + break; + default: + PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE); + return SECFailure; + } + + oidData = SECOID_FindOIDByTag(oidTag); + if (oidData == NULL) { PORT_SetError(SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE); return SECFailure; } |