mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
More fixes from review
This commit is contained in:
15
src/ssl.c
15
src/ssl.c
@ -40625,8 +40625,6 @@ int wc_DhPubKeyToDer(DhKey* key, byte* out, word32* outSz)
|
|||||||
pubSz = mp_unsigned_bin_size(&key->pub);
|
pubSz = mp_unsigned_bin_size(&key->pub);
|
||||||
if (pubSz < 0)
|
if (pubSz < 0)
|
||||||
return pubSz;
|
return pubSz;
|
||||||
else if (pubSz > 256) /* Key is larger than 2048 */
|
|
||||||
return ASN_VERSION_E;
|
|
||||||
|
|
||||||
if (mp_leading_bit(&key->pub))
|
if (mp_leading_bit(&key->pub))
|
||||||
pubSz++;
|
pubSz++;
|
||||||
@ -40635,7 +40633,7 @@ int wc_DhPubKeyToDer(DhKey* key, byte* out, word32* outSz)
|
|||||||
sz += SetLength(pubSz, scratch);
|
sz += SetLength(pubSz, scratch);
|
||||||
sz += pubSz;
|
sz += pubSz;
|
||||||
|
|
||||||
sz += SetBitString(pubSz + ASN_BIT_STRING, 0, scratch);
|
sz += SetBitString(pubSz, 0, scratch);
|
||||||
|
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
/* Uppermost SEQUENCE */
|
/* Uppermost SEQUENCE */
|
||||||
@ -40662,16 +40660,7 @@ int wc_DhPubKeyToDer(DhKey* key, byte* out, word32* outSz)
|
|||||||
/* BIT STRING
|
/* BIT STRING
|
||||||
* INTEGER
|
* INTEGER
|
||||||
*/
|
*/
|
||||||
if (pubSz == 256) { /* Key Size: 2048 */
|
idx += SetBitString(pubSz, 0, out+idx);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
out[idx++] = ASN_INTEGER;
|
out[idx++] = ASN_INTEGER;
|
||||||
idx += SetLength(pubSz, out + idx);
|
idx += SetLength(pubSz, out + idx);
|
||||||
|
@ -11462,11 +11462,7 @@ static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header)
|
|||||||
idx = wc_ed25519_export_public(key, pub, &pubSz);
|
idx = wc_ed25519_export_public(key, pub, &pubSz);
|
||||||
if (idx != 0) {
|
if (idx != 0) {
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
#ifdef WOLFSSL_QT
|
XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#else
|
|
||||||
XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
@ -11476,11 +11472,7 @@ static int SetEd25519PublicKey(byte* output, ed25519_key* key, int with_header)
|
|||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
algo = (byte*)XMALLOC(MAX_ALGO_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (algo == NULL) {
|
if (algo == NULL) {
|
||||||
#ifdef WOLFSSL_QT
|
XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#else
|
|
||||||
XFREE(pub, key->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
#endif
|
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL)
|
#if defined(WOLFSSL_QT) || defined(OPENSSL_ALL)
|
||||||
#include <wolfssl/openssl/dh.h>
|
#include <wolfssl/openssl/dh.h>
|
||||||
#include <wolfssl/openssl/objects.h>
|
#include <wolfssl/openssl/objects.h>
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* all NID_* values are in asn.h */
|
/* 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;
|
typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
|
||||||
|
|
||||||
#ifdef WOLFSSL_QT
|
#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
|
#else
|
||||||
#define CRYPTO_free XFREE
|
#define CRYPTO_free XFREE
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user