diff --git a/src/ssl.c b/src/ssl.c index cbd79414e..5077a21f8 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -150,9 +150,6 @@ int wolfssl_bn_get_value(WOLFSSL_BIGNUM* bn, mp_int* mpi); int wolfssl_bn_set_value(WOLFSSL_BIGNUM** bn, mp_int* mpi); #endif -#if defined(OPENSSL_EXTRA) && !defined(NO_ASN) - static int wolfssl_bn_set_neg(WOLFSSL_BIGNUM* bn, int n); -#endif #if defined(WOLFSSL_QT) #include @@ -211,11 +208,6 @@ #define WOLFSSL_EVP_INCLUDED #include "wolfcrypt/src/evp.c" -#ifndef OPENSSL_EXTRA_NO_ASN1 -#define WOLFSSL_SSL_ASN1_INCLUDED -#include "src/ssl_asn1.c" -#endif /* OPENSSL_EXTRA_NO_ASN1 */ - #if (defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)) && \ !defined(WOLFCRYPT_ONLY) /* Convert shortname to NID. @@ -416,6 +408,11 @@ WC_RNG* wolfssl_make_rng(WC_RNG* rng, int* local) #define WOLFSSL_SSL_BN_INCLUDED #include "src/ssl_bn.c" +#ifndef OPENSSL_EXTRA_NO_ASN1 +#define WOLFSSL_SSL_ASN1_INCLUDED +#include "src/ssl_asn1.c" +#endif /* OPENSSL_EXTRA_NO_ASN1 */ + #define WOLFSSL_PK_INCLUDED #include "src/pk.c" diff --git a/src/ssl_asn1.c b/src/ssl_asn1.c index 27ccd13c8..213ccebe0 100644 --- a/src/ssl_asn1.c +++ b/src/ssl_asn1.c @@ -40,6 +40,8 @@ * ASN1_item APIs ******************************************************************************/ +#ifndef NO_ASN + #ifdef OPENSSL_EXTRA #ifdef OPENSSL_ALL @@ -2362,7 +2364,7 @@ char* wolfSSL_i2s_ASN1_STRING(WOLFSSL_v3_ext_method *method, } /* Handle 0 length data separately. */ else if (s->length == 0) { - ret = XMALLOC(1, NULL, DYNAMIC_TYPE_TMP_BUFFER); + ret = (char *)XMALLOC(1, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (ret != NULL) { ret[0] = '\0'; } @@ -4022,5 +4024,7 @@ void wolfSSL_ASN1_TYPE_set(WOLFSSL_ASN1_TYPE *a, int type, void *value) #endif /* OPENSSL_ALL || WOLFSSL_WPAS */ +#endif /* !NO_ASN */ + #endif /* !WOLFSSL_SSL_ASN1_INCLUDED */ diff --git a/tests/api.c b/tests/api.c index 2fddc90de..70c61b06e 100644 --- a/tests/api.c +++ b/tests/api.c @@ -31228,8 +31228,6 @@ static int test_wolfSSL_a2i_ASN1_INTEGER(void) BIO_free(out); AssertNotNull(fixed = BIO_new(wolfSSL_BIO_s_fixed_mem())); - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(i2a_ASN1_INTEGER(fixed, ai), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(i2a_ASN1_INTEGER(fixed, ai), 0); BIO_free(fixed); @@ -31440,6 +31438,7 @@ static int test_wolfSSL_ASN1_OBJECT(void) AssertNotNull(a = wolfSSL_ASN1_OBJECT_dup(&s)); ASN1_OBJECT_free(a); s.obj = der; + s.objSz = sizeof(der); AssertNotNull(a = wolfSSL_ASN1_OBJECT_dup(&s)); ASN1_OBJECT_free(a); ASN1_OBJECT_free(&s); @@ -32016,8 +32015,6 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) AssertIntEQ(p_len, 15); BIO_read(bio, (void*)rbuf, 15); AssertStrEQ((char*)rbuf, "Hello wolfSSL!"); - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 14), 1); @@ -32030,8 +32027,6 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) AssertIntEQ(p_len, 9); BIO_read(bio, (void*)rbuf, 9); AssertStrEQ((char*)rbuf, "a\\+\\;\\<\\>"); - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, esc_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, esc_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 8), 1); @@ -32044,8 +32039,6 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) AssertIntEQ(p_len, 28); BIO_read(bio, (void*)rbuf, 28); AssertStrEQ((char*)rbuf, "OCTET STRING:Hello wolfSSL!"); - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 12), 1); @@ -32060,8 +32053,6 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) AssertIntEQ(p_len, 31); BIO_read(bio, (void*)rbuf, 31); AssertStrEQ((char*)rbuf, "#48656C6C6F20776F6C6653534C2100"); - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 30), 1); @@ -32074,8 +32065,6 @@ static int test_wolfSSL_ASN1_STRING_print_ex(void) AssertIntEQ(p_len, 35); BIO_read(bio, (void*)rbuf, 35); AssertStrEQ((char*)rbuf, "#040F48656C6C6F20776F6C6653534C2100"); - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(wolfSSL_ASN1_STRING_print_ex(fixed, asn_str, flags), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 2), 1); @@ -32235,7 +32224,7 @@ static int test_wolfSSL_ASN1_GENERALIZEDTIME_print(void) BIO_free(bio); AssertNotNull(bio = BIO_new(wolfSSL_BIO_s_fixed_mem())); - for (i = 0; i < 20; i++) { + for (i = 1; i < 20; i++) { AssertIntEQ(BIO_set_write_buf_size(bio, i), 1); AssertIntEQ(wolfSSL_ASN1_GENERALIZEDTIME_print(bio, >ime), 0); } @@ -32677,8 +32666,6 @@ static int test_wolfSSL_ASN1_TIME_print(void) AssertIntEQ(XMEMCMP(buf, "Dec 16 21:17:49 2022 GMT", sizeof(buf) - 1), 0); /* Test BIO_write fails. */ - AssertIntEQ(BIO_set_write_buf_size(fixed, 0), 1); - AssertIntEQ(ASN1_TIME_print(fixed, notBefore), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 1), 1); AssertIntEQ(ASN1_TIME_print(fixed, notBefore), 0); AssertIntEQ(BIO_set_write_buf_size(fixed, 23), 1);