Skip to content

Commit 435c998

Browse files
authored
Merge pull request #316 from padelsbach/wp-build-flag-config
Add pre-compiler checks for different config options
2 parents 5c98ccb + cdbeb99 commit 435c998

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

include/wolfprovider/settings.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,19 @@
127127
#ifdef HAVE_ECC
128128
#define WP_HAVE_ECC
129129
#ifndef NO_ECC_SECP
130-
#if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
130+
#if (defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 192
131131
#define WP_HAVE_EC_P192
132132
#endif
133-
#if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
133+
#if (defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 224
134134
#define WP_HAVE_EC_P224
135135
#endif
136-
#if defined(HAVE_ECC256) || defined(HAVE_ALL_CURVES)
136+
#if (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 256
137137
#define WP_HAVE_EC_P256
138138
#endif
139-
#if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
139+
#if (defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 384
140140
#define WP_HAVE_EC_P384
141141
#endif
142-
#if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
142+
#if (defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)) && ECC_MIN_KEY_SZ <= 521
143143
#define WP_HAVE_EC_P521
144144
#endif
145145
#endif

src/wp_aes_stream.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,11 @@ static int wp_aes_stream_init(wp_AesStreamCtx *ctx, const unsigned char *key,
331331
/* TODO: don't reach in under the covers.
332332
* Setting the key will reset this.
333333
*/
334+
#if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) || \
335+
defined(WOLFSSL_AES_OFB) || defined(WOLFSSL_AES_XTS) || \
336+
defined(WOLFSSL_AES_CTS)
334337
ctx->aes.left = 0;
338+
#endif
335339
}
336340

337341
if (ok) {

test/test_dh.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,12 @@ static int test_dh_krb5_keygen_ex(OSSL_LIB_CTX *libCtx)
555555
OSSL_DECODER_CTX *dctx = NULL;
556556
const unsigned char *inptr = dh_2048;
557557
size_t inlen = sizeof(dh_2048);
558+
#ifdef WOLFSSL_DH_EXTRA
558559
unsigned char *spki = NULL;
559560
size_t spki_len = 0;
560561
unsigned char *der = NULL;
561562
size_t der_len;
563+
#endif /* WOLFSSL_DH_EXTRA */
562564

563565
PRINT_MSG("Testing DH key generation with krb5 parameters");
564566

@@ -584,6 +586,7 @@ static int test_dh_krb5_keygen_ex(OSSL_LIB_CTX *libCtx)
584586
err = EVP_PKEY_keygen(ctx, &key) != 1;
585587
}
586588

589+
#ifdef WOLFSSL_DH_EXTRA
587590
if (err == 0) {
588591
/* Get the size of the encoded public key */
589592
err = i2d_PUBKEY(key, NULL) <= 0;
@@ -618,6 +621,7 @@ static int test_dh_krb5_keygen_ex(OSSL_LIB_CTX *libCtx)
618621
if (spki) {
619622
OPENSSL_free(spki);
620623
}
624+
#endif /* WOLFSSL_DH_EXTRA */
621625
EVP_PKEY_free(key);
622626
EVP_PKEY_free(params);
623627
EVP_PKEY_CTX_free(ctx);

test/test_rsa.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "unit.h"
2222
#include <wolfprovider/wp_fips.h>
23+
#include <wolfssl/wolfcrypt/asn.h>
2324

2425
#include <openssl/store.h>
2526
#include <openssl/core_names.h>
@@ -1063,7 +1064,8 @@ int test_rsa_pkey_keygen(void *data)
10631064
BIGNUM *eCmd = NULL;
10641065
BIGNUM *n = NULL;
10651066
BIGNUM *eKey = NULL;
1066-
#if defined(HAVE_FIPS) || defined(HAVE_FIPS_VERSION)
1067+
#if defined(HAVE_FIPS) || defined(HAVE_FIPS_VERSION) || \
1068+
(defined(RSA_MIN_SIZE) && RSA_MIN_SIZE >= 2048)
10671069
/* Generating a 3072-bit key is slow, so only do it if we have to because
10681070
* we're using wolfCrypt FIPS. Can't do 2048 because that's the default. */
10691071
const int newKeySize = 3072;
@@ -1096,7 +1098,7 @@ int test_rsa_pkey_keygen(void *data)
10961098
err = BN_set_word(eCmd, 3) != 1;
10971099
}
10981100
if (err == 0) {
1099-
PRINT_MSG("Change the public exponent w/ ctrl command");
1101+
PRINT_MSG("Change the public exponent w/ ctrl command");
11001102
err = EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN,
11011103
EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, eCmd) <= 0;
11021104
}

0 commit comments

Comments
 (0)