diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index 88908143e..da8abde3f 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -49,6 +49,8 @@ #cmakedefine LWS_HAVE_EVP_aes_256_cfb128 #cmakedefine LWS_HAVE_EVP_aes_128_ofb #cmakedefine LWS_HAVE_EVP_aes_128_xts +#cmakedefine LWS_HAVE_EVP_aes_128_ctr +#cmakedefine LWS_HAVE_EVP_aes_128_ecb #cmakedefine LWS_HAVE_EVP_PKEY_new_raw_private_key #cmakedefine LWS_HAVE_EXECVPE #cmakedefine LWS_HAVE_LOCALTIME_R diff --git a/lib/tls/openssl/openssl-x509.c b/lib/tls/openssl/openssl-x509.c index 6ba59b2b9..06ee45061 100644 --- a/lib/tls/openssl/openssl-x509.c +++ b/lib/tls/openssl/openssl-x509.c @@ -579,7 +579,7 @@ lws_x509_jwk_privkey_pem(struct lws_jwk *jwk, void *pem, size_t len, goto bail; } -#if defined(LWS_HAVE_RSA_SET0_KEY) +#if defined(LWS_HAVE_RSA_SET0_KEY) && !defined(USE_WOLFSSL) RSA_get0_key(rsapriv, (const BIGNUM **)&dummy[0], /* n */ (const BIGNUM **)&dummy[1], /* e */ (const BIGNUM **)&mpi); /* d */ diff --git a/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt b/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt index 6bfe7f216..a3678d561 100644 --- a/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt +++ b/minimal-examples/api-tests/api-test-gencrypto/CMakeLists.txt @@ -11,7 +11,7 @@ set(SRCS main.c lws-genaes.c lws-genec.c) set(requirements 1) require_lws_config(LWS_WITH_GENCRYPTO 1 requirements) require_lws_config(LWS_WITH_JOSE 1 requirements) - +require_lws_config(USE_WOLFSSL 0 requirements) if (requirements) diff --git a/minimal-examples/api-tests/api-test-gencrypto/lws-genaes.c b/minimal-examples/api-tests/api-test-gencrypto/lws-genaes.c index 906364720..41650d26a 100644 --- a/minimal-examples/api-tests/api-test-gencrypto/lws-genaes.c +++ b/minimal-examples/api-tests/api-test-gencrypto/lws-genaes.c @@ -9,6 +9,8 @@ #include +#if defined(LWS_HAVE_EVP_aes_128_cbc) || defined(LWS_WITH_MBEDTLS) + static const uint8_t /* * produced with (plaintext.txt contains "test plaintext\0\0") @@ -33,10 +35,13 @@ static const uint8_t 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, } ; +#endif static int test_genaes_cbc(void) { +#if defined(LWS_HAVE_EVP_aes_128_cbc) || defined(LWS_WITH_MBEDTLS) + struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; uint8_t res[32], res1[32]; @@ -100,6 +105,9 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } static const uint8_t @@ -127,6 +135,8 @@ cfb128_enc[] = { static int test_genaes_cfb128(void) { +#if defined(LWS_HAVE_EVP_aes_128_cfb128) || defined(LWS_WITH_MBEDTLS) + struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; uint8_t res[32], res1[32]; @@ -187,6 +197,9 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } static const uint8_t @@ -214,6 +227,8 @@ cfb8_enc[] = { static int test_genaes_cfb8(void) { +#if defined(LWS_HAVE_EVP_aes_128_cfb8) || defined(LWS_WITH_MBEDTLS) + struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; uint8_t res[32], res1[32]; @@ -271,8 +286,13 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } +#if defined(LWS_HAVE_EVP_aes_128_ctr) || defined(LWS_WITH_MBEDTLS) + static const uint8_t /* * produced with (plaintext.txt contains "test plaintext\0\0") @@ -294,10 +314,13 @@ ctr_enc[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, }; +#endif static int test_genaes_ctr(void) { +#if defined(LWS_HAVE_EVP_aes_128_ctr) || defined(LWS_WITH_MBEDTLS) + uint8_t nonce_counter[16], sb[16]; struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; @@ -364,7 +387,11 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } +#if defined(LWS_HAVE_EVP_aes_128_ecb) || defined(LWS_WITH_MBEDTLS) static const uint8_t /* @@ -385,10 +412,13 @@ ecb_enc[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, }; +#endif static int test_genaes_ecb(void) { +#if defined(LWS_HAVE_EVP_aes_128_ecb) || defined(LWS_WITH_MBEDTLS) + struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; uint8_t res[32], res1[32]; @@ -448,10 +478,14 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } -#if defined(MBEDTLS_CONFIG_H) && !defined(MBEDTLS_CIPHER_MODE_OFB) +#if defined(MBEDTLS_CONFIG_H) && defined(MBEDTLS_CIPHER_MODE_OFB) #else +#if defined(LWS_HAVE_EVP_aes_128_ofb) || defined(LWS_WITH_MBEDTLS) static const uint8_t /* @@ -481,10 +515,12 @@ static const uint8_t 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, } ; - +#endif static int test_genaes_ofb(void) { +#if defined(LWS_HAVE_EVP_aes_128_ofb) || defined(LWS_WITH_MBEDTLS) + struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; uint8_t res[32], res1[32]; @@ -545,12 +581,16 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } #endif #if defined(MBEDTLS_CONFIG_H) && !defined(MBEDTLS_CIPHER_MODE_XTS) #else +#if defined(LWS_HAVE_EVP_aes_128_xts) || defined(LWS_WITH_MBEDTLS) static const uint8_t /* @@ -575,10 +615,12 @@ static const uint8_t 0x5f, 0x31, 0x9e, 0xcd, 0x33, 0x08, 0xa0, 0x44 } ; - +#endif static int test_genaes_xts(void) { +#if defined(LWS_HAVE_EVP_aes_128_xts) || defined(LWS_WITH_MBEDTLS) + struct lws_genaes_ctx ctx; struct lws_gencrypto_keyelem e; uint8_t res[32], res1[32], data_unit[16]; @@ -636,6 +678,9 @@ bail: lws_genaes_destroy(&ctx, NULL, 0); return -1; +#else + return 0; +#endif } #endif