From 299b4d85521724e13a6a5a166911c771fe2f3378 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Mon, 10 Jul 2023 11:32:17 -0400 Subject: [PATCH] Make wc_BuildEccKeyDer non-static --- wolfcrypt/src/asn.c | 10 +--------- wolfcrypt/src/port/aria/aria-cryptocb.c | 4 ++-- wolfssl/wolfcrypt/asn_public.h | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 1d84002d9..103be9301 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -32639,7 +32639,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx, #if defined(HAVE_ECC_KEY_EXPORT) && !defined(NO_ASN_CRYPT) /* build DER formatted ECC key, include optional public key if requested, * return length on success, negative on error */ -static int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen, +int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen, int pubIn, int curveIn) { #ifndef WOLFSSL_ASN_TEMPLATE @@ -32955,14 +32955,6 @@ int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, word32 inLen) return wc_BuildEccKeyDer(key, output, &inLen, 0, 1); } -/* Write only private ecc key to DER format, - * length on success else < 0 */ -int wc_EccPrivateKeyToDerNoCurve(ecc_key* key, byte* output, word32 inLen) -{ - return wc_BuildEccKeyDer(key, output, &inLen, 0, 0); -} - - #ifdef HAVE_PKCS8 /* Write only private ecc key or both private and public parts to unencrypted diff --git a/wolfcrypt/src/port/aria/aria-cryptocb.c b/wolfcrypt/src/port/aria/aria-cryptocb.c index 456c2331b..b968d3072 100644 --- a/wolfcrypt/src/port/aria/aria-cryptocb.c +++ b/wolfcrypt/src/port/aria/aria-cryptocb.c @@ -202,7 +202,7 @@ int wc_AriaSign(byte* in, word32 inSz, byte* out, word32* outSz, ecc_key* key) rv = MC_SetApiMode(hSession, gApimode); if (rv == MC_OK) { - int ret = wc_EccPrivateKeyToDerNoCurve(key,keyAsn1,keyAsn1Sz); + int ret = wc_BuildEccKeyDer(key,keyAsn1,&keyAsn1Sz,0,0); if (ret < 0) { rv = ret; } else { keyAsn1Sz = ret; } } @@ -369,7 +369,7 @@ int wc_AriaDerive(ecc_key* private_key, ecc_key* public_key, byte* out, word32* mcAlg.nParam=pubAsn1Sz; if (rv == MC_OK) { - int ret = wc_EccPrivateKeyToDerNoCurve(private_key,privAsn1,privAsn1Sz); + int ret = wc_BuildEccKeyDer(private_key,privAsn1,&privAsn1Sz,0,0); if (ret < 0) { rv = ret; } else { diff --git a/wolfssl/wolfcrypt/asn_public.h b/wolfssl/wolfcrypt/asn_public.h index f63f74c24..b3bbc75d1 100644 --- a/wolfssl/wolfcrypt/asn_public.h +++ b/wolfssl/wolfcrypt/asn_public.h @@ -746,12 +746,12 @@ WOLFSSL_API int wc_DhPrivKeyToDer(DhKey* key, byte* out, word32* outSz); WOLFSSL_ABI WOLFSSL_API int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, word32 inSz); + WOLFSSL_LOCAL int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen, + int pubIn, int curveIn); WOLFSSL_ABI WOLFSSL_API int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen); WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, word32 inLen); - WOLFSSL_API int wc_EccPrivateKeyToDerNoCurve(ecc_key* key, byte* output, - word32 inLen); WOLFSSL_API int wc_EccKeyDerSize(ecc_key* key, int pub); WOLFSSL_API int wc_EccPrivateKeyToPKCS8(ecc_key* key, byte* output, word32* outLen);