More fixes from review

This commit is contained in:
Carie Pointer
2020-01-09 17:28:20 -07:00
parent 47040f1dae
commit de3536a067
3 changed files with 9 additions and 25 deletions

View File

@ -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);

View File

@ -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

View File

@ -45,7 +45,6 @@
#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL)
#include <wolfssl/openssl/dh.h>
#include <wolfssl/openssl/objects.h>
#include <wolfssl/wolfcrypt/settings.h>
#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