api.c and asn.c changes to allow 0 to be passed in and expanded coverage on test cases

(cherry picked from commit 8572f67e60d419ddd74d4a2b7051dcaa7d0ca6b4)
This commit is contained in:
aidan garske
2024-07-24 16:53:15 -07:00
parent 324e714a6a
commit dace3acd4d
2 changed files with 28 additions and 13 deletions

View File

@@ -11994,9 +11994,13 @@ int SetAsymKeyDerPublic(const byte* pubKey, word32 pubKeyLen,
DECL_ASNSETDATA(dataASN, edPubKeyASN_Length);
#endif
if (pubKey == NULL) {
/* validate parameters */
if (pubKey == NULL){
return BAD_FUNC_ARG;
}
if (output != NULL && outLen == 0) {
return BUFFER_E;
}
#ifndef WOLFSSL_ASN_TEMPLATE
/* calculate size */
@@ -35337,8 +35341,11 @@ int SetAsymKeyDer(const byte* privKey, word32 privKeyLen,
int sz;
#endif
/* Validate parameters. */
if (privKey == NULL || outLen == 0) {
/* validate parameters */
if (privKey == NULL) {
return BUFFER_E;
}
if (output != NULL && outLen == 0) {
return BAD_FUNC_ARG;
}
@@ -35498,7 +35505,7 @@ int wc_Curve25519PublicKeyToDer(curve25519_key* key, byte* output, word32 inLen,
byte pubKey[CURVE25519_PUB_KEY_SIZE];
word32 pubKeyLen = (word32)sizeof(pubKey);
if (key == NULL || output == NULL) {
if (key == NULL) {
return BAD_FUNC_ARG;
}