From de3536a067b8bdc820e5a7dd008bc6cd1ca63dd2 Mon Sep 17 00:00:00 2001 From: Carie Pointer Date: Thu, 9 Jan 2020 17:28:20 -0700 Subject: [PATCH] More fixes from review --- src/ssl.c | 15 ++------------- wolfcrypt/src/asn.c | 12 ++---------- wolfssl/openssl/ssl.h | 7 +++++-- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 6e25745dc..e432d9695 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -40625,8 +40625,6 @@ int wc_DhPubKeyToDer(DhKey* key, byte* out, word32* outSz) pubSz = mp_unsigned_bin_size(&key->pub); if (pubSz < 0) return pubSz; - else if (pubSz > 256) /* Key is larger than 2048 */ - return ASN_VERSION_E; if (mp_leading_bit(&key->pub)) pubSz++; @@ -40635,7 +40633,7 @@ int wc_DhPubKeyToDer(DhKey* key, byte* out, word32* outSz) sz += SetLength(pubSz, scratch); sz += pubSz; - sz += SetBitString(pubSz + ASN_BIT_STRING, 0, scratch); + sz += SetBitString(pubSz, 0, scratch); if (out == NULL) { /* Uppermost SEQUENCE */ @@ -40662,16 +40660,7 @@ int wc_DhPubKeyToDer(DhKey* key, byte* out, word32* outSz) /* BIT STRING * INTEGER */ - if (pubSz == 256) { /* Key Size: 2048 */ - idx += SetBitString(pubSz + ASN_BIT_STRING+1, 0, out+idx); - } else if (pubSz == 128) { /* Key Size: 1024 */ - idx += SetBitString(pubSz + ASN_BIT_STRING, 0, out+idx); - } else if (pubSz == 64) { /* Key Size: 512 */ - idx += SetBitString(pubSz + ASN_BIT_STRING-1, 0, out+idx); - } else { - WOLFSSL_MSG("Unsupported Key Size"); - return ASN_PARSE_E; - } + idx += SetBitString(pubSz, 0, out+idx); out[idx++] = ASN_INTEGER; idx += SetLength(pubSz, out + idx); diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 307ad6258..7fbbd6435 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -11462,11 +11462,7 @@ static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header) idx = wc_ed25519_export_public(key, pub, &pubSz); if (idx != 0) { #ifdef WOLFSSL_SMALL_STACK - #ifdef WOLFSSL_QT - XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); - #else - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - #endif + XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); #endif return idx; } @@ -11476,11 +11472,7 @@ static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header) #ifdef WOLFSSL_SMALL_STACK algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (algo == NULL) { - #ifdef WOLFSSL_QT - XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); - #else - XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); - #endif + XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; } #endif diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index b82229980..89b824732 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -45,7 +45,6 @@ #if defined(WOLFSSL_QT) || defined(OPENSSL_ALL) #include #include -#include #endif /* all NID_* values are in asn.h */ @@ -124,7 +123,11 @@ typedef WOLFSSL_X509_VERIFY_PARAM X509_VERIFY_PARAM; typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; #ifdef WOLFSSL_QT - #define CRYPTO_free(xp) {if((xp)) wolfSSL_Free((xp));} + #if defined(NO_WOLFSSL_MEMORY) + #define CRYPTO_free(xp) XFREE(xp, NULL, NULL); + #else + #define CRYPTO_free(xp) { if((xp)) wolfSSL_Free((xp));} + #endif #else #define CRYPTO_free XFREE #endif