Implement CRYPTO_memcmp

pull/3028/head
Juliusz Sosinowicz 2020-06-05 16:44:12 +02:00
parent 3529d9a40d
commit a75f83c9f2
4 changed files with 26 additions and 0 deletions

View File

@ -41930,6 +41930,13 @@ void wolfSSL_X509_OBJECT_free(WOLFSSL_X509_OBJECT *a)
#if defined(OPENSSL_EXTRA)
int wolfSSL_CRYPTO_memcmp(const void *a, const void *b, size_t size)
{
if (!a || !b)
return 0;
return ConstantCompare(a, b, size);
}
int wolfSSL_sk_X509_num(const WOLF_STACK_OF(WOLFSSL_X509) *s)
{
WOLFSSL_ENTER("wolfSSL_sk_X509_num");

View File

@ -28759,6 +28759,20 @@ static void test_no_op_functions(void)
#endif
}
static void test_wolfSSL_CRYPTO_memcmp(void)
{
#ifdef OPENSSL_EXTRA
char a[] = "wolfSSL (formerly CyaSSL) is a small, fast, portable "
"implementation of TLS/SSL for embedded devices to the cloud.";
char b[] = "wolfSSL (formerly CyaSSL) is a small, fast, portable "
"implementation of TLS/SSL for embedded devices to the cloud.";
char c[] = "wolfSSL (formerly CyaSSL) is a small, fast, portable "
"implementation of TLS/SSL for embedded devices to the cloud!";
AssertIntEQ(CRYPTO_memcmp(a, b, sizeof(a)), 0);
AssertIntNE(CRYPTO_memcmp(a, c, sizeof(a)), 0);
#endif
}
/*----------------------------------------------------------------------------*
| wolfCrypt ASN
@ -32238,6 +32252,8 @@ void ApiTest(void)
test_wolfSSL_EC_get_builtin_curves();
test_wolfSSL_CRYPTO_memcmp();
/* test the no op functions for compatibility */
test_no_op_functions();

View File

@ -151,6 +151,7 @@ typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
#define CRYPTO_cleanup_all_ex_data wolfSSL_cleanup_all_ex_data
#define set_ex_data wolfSSL_CRYPTO_set_ex_data
#define get_ex_data wolfSSL_CRYPTO_get_ex_data
#define CRYPTO_memcmp wolfSSL_CRYPTO_memcmp
/* this function was used to set the default malloc, free, and realloc */
#define CRYPTO_malloc_init() 0 /* CRYPTO_malloc_init is not needed */

View File

@ -3502,6 +3502,8 @@ WOLFSSL_API int wolfSSL_CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const ch
WOLFSSL_API void wolfSSL_CRYPTO_cleanup_all_ex_data(void);
WOLFSSL_API int wolfSSL_CRYPTO_memcmp(const void *a, const void *b, size_t size);
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_768_prime(WOLFSSL_BIGNUM* bn);
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_1024_prime(WOLFSSL_BIGNUM* bn);
WOLFSSL_API WOLFSSL_BIGNUM* wolfSSL_DH_1536_prime(WOLFSSL_BIGNUM* bn);