Merge pull request #8257 from dgarske/settings_h

Fix issue with wc_lms_impl.c or wc_lms not including settings.h
This commit is contained in:
JacobBarthelmeh
2024-12-05 11:43:43 -07:00
committed by GitHub
11 changed files with 38 additions and 30 deletions

View File

@ -2498,7 +2498,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
} }
else if (XSTRCMP(myoptarg, "verifyInfo") == 0) { else if (XSTRCMP(myoptarg, "verifyInfo") == 0) {
printf("Verify should not override error\n"); printf("Verify should not override error\n");
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
} }
else if (XSTRCMP(myoptarg, "useSupCurve") == 0) { else if (XSTRCMP(myoptarg, "useSupCurve") == 0) {
printf("Attempting to test use supported curve\n"); printf("Attempting to test use supported curve\n");
@ -3571,7 +3571,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#endif #endif
} }
if (useVerifyCb || myVerifyAction == VERIFY_FORCE_FAIL || if (useVerifyCb || myVerifyAction == VERIFY_FORCE_FAIL ||
myVerifyAction == VERIFY_USE_PREVERFIY) { myVerifyAction == VERIFY_USE_PREVERIFY) {
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify);
} }
else if (!usePsk && !useAnon && doPeerCheck == 0) { else if (!usePsk && !useAnon && doPeerCheck == 0) {

View File

@ -1947,7 +1947,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
} }
else if (XSTRCMP(myoptarg, "verifyInfo") == 0) { else if (XSTRCMP(myoptarg, "verifyInfo") == 0) {
printf("Verify should use preverify (just show info)\n"); printf("Verify should use preverify (just show info)\n");
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
} }
else if (XSTRCMP(myoptarg, "loadSSL") == 0) { else if (XSTRCMP(myoptarg, "loadSSL") == 0) {
printf("Also load cert/key into wolfSSL object\n"); printf("Also load cert/key into wolfSSL object\n");

View File

@ -9511,7 +9511,7 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_1_ctx_ready(
WOLFSSL_CTX* ctx) WOLFSSL_CTX* ctx)
{ {
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify);
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
wolfSSL_CTX_set_verify_depth(ctx, 2); wolfSSL_CTX_set_verify_depth(ctx, 2);
return TEST_SUCCESS; return TEST_SUCCESS;
} }
@ -9591,7 +9591,7 @@ static int test_wolfSSL_CTX_verifyDepth_ServerClient_3_ctx_ready(
WOLFSSL_CTX* ctx) WOLFSSL_CTX* ctx)
{ {
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify);
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
wolfSSL_CTX_set_verify_depth(ctx, 0); wolfSSL_CTX_set_verify_depth(ctx, 0);
return TEST_SUCCESS; return TEST_SUCCESS;
} }
@ -97909,7 +97909,7 @@ static int test_revoked_loaded_int_cert_ctx_ready1(WOLFSSL_CTX* ctx)
{ {
EXPECT_DECLS; EXPECT_DECLS;
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify);
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx, ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx,
"./certs/ca-cert.pem", NULL, 0), WOLFSSL_SUCCESS); "./certs/ca-cert.pem", NULL, 0), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx, ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx,
@ -97929,7 +97929,7 @@ static int test_revoked_loaded_int_cert_ctx_ready2(WOLFSSL_CTX* ctx)
{ {
EXPECT_DECLS; EXPECT_DECLS;
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify);
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx, ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx,
"./certs/ca-cert.pem", NULL, 0), WOLFSSL_SUCCESS); "./certs/ca-cert.pem", NULL, 0), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx, ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx,
@ -97966,7 +97966,7 @@ static int test_revoked_loaded_int_cert_ctx_ready3(WOLFSSL_CTX* ctx)
{ {
EXPECT_DECLS; EXPECT_DECLS;
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, myVerify);
myVerifyAction = VERIFY_USE_PREVERFIY; myVerifyAction = VERIFY_USE_PREVERIFY;
ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx, ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx,
"./certs/ca-cert.pem", NULL, 0), WOLFSSL_SUCCESS); "./certs/ca-cert.pem", NULL, 0), WOLFSSL_SUCCESS);
ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx, ExpectIntEQ(wolfSSL_CTX_load_verify_locations_ex(ctx,

View File

@ -2761,8 +2761,8 @@ static int dilithium_vec_expand_mask(wc_Shake* shake256, byte* seed,
word16 n = kappa + r; word16 n = kappa + r;
/* Step 4: Append to seed and squeeze out data. */ /* Step 4: Append to seed and squeeze out data. */
seed[DILITHIUM_PRIV_RAND_SEED_SZ + 0] = n; seed[DILITHIUM_PRIV_RAND_SEED_SZ + 0] = (byte)n;
seed[DILITHIUM_PRIV_RAND_SEED_SZ + 1] = n >> 8; seed[DILITHIUM_PRIV_RAND_SEED_SZ + 1] = (byte)(n >> 8);
ret = dilithium_squeeze256(shake256, seed, DILITHIUM_Y_SEED_SZ, v, ret = dilithium_squeeze256(shake256, seed, DILITHIUM_Y_SEED_SZ, v,
DILITHIUM_MAX_V_BLOCKS); DILITHIUM_MAX_V_BLOCKS);
if (ret == 0) { if (ret == 0) {

View File

@ -24,6 +24,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/wc_port.h> #include <wolfssl/wolfcrypt/wc_port.h>
#include <wolfssl/wolfcrypt/error-crypt.h> #include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h> #include <wolfssl/wolfcrypt/logging.h>

View File

@ -24,6 +24,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/wc_port.h> #include <wolfssl/wolfcrypt/wc_port.h>
#include <wolfssl/wolfcrypt/error-crypt.h> #include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h> #include <wolfssl/wolfcrypt/logging.h>

View File

@ -67,6 +67,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/wc_kyber.h> #include <wolfssl/wolfcrypt/wc_kyber.h>
#include <wolfssl/wolfcrypt/cpuid.h> #include <wolfssl/wolfcrypt/cpuid.h>
#include <wolfssl/wolfcrypt/error-crypt.h> #include <wolfssl/wolfcrypt/error-crypt.h>
@ -1139,7 +1140,7 @@ void kyber_keygen(sword16* priv, sword16* pub, sword16* e, const sword16* a,
} }
} }
/* Encapsuluate message. /* Encapsulate message.
* *
* @param [in] pub Public key vector of polynomials. * @param [in] pub Public key vector of polynomials.
* @param [out] bp Vector of polynomials. * @param [out] bp Vector of polynomials.
@ -1272,7 +1273,7 @@ void kyber_keygen(sword16* priv, sword16* pub, sword16* e, const sword16* a,
} }
} }
/* Encapsuluate message. /* Encapsulate message.
* *
* @param [in] pub Public key vector of polynomials. * @param [in] pub Public key vector of polynomials.
* @param [out] bp Vector of polynomials. * @param [out] bp Vector of polynomials.
@ -2719,7 +2720,7 @@ static void kyber_cbd_eta3(sword16* p, const byte* r)
/* Get noise/error by calculating random bytes and sampling to a binomial /* Get noise/error by calculating random bytes and sampling to a binomial
* distribution. * distribution.
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [out] p Polynomial. * @param [out] p Polynomial.
* @param [in] seed Seed to use when calculating random. * @param [in] seed Seed to use when calculating random.
* @param [in] eta1 Size of noise/error integers. * @param [in] eta1 Size of noise/error integers.
@ -2762,7 +2763,7 @@ static int kyber_get_noise_eta1_c(KYBER_PRF_T* prf, sword16* p,
/* Get noise/error by calculating random bytes and sampling to a binomial /* Get noise/error by calculating random bytes and sampling to a binomial
* distribution. Values -2..2 * distribution. Values -2..2
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [out] p Polynomial. * @param [out] p Polynomial.
* @param [in] seed Seed to use when calculating random. * @param [in] seed Seed to use when calculating random.
* @return 0 on success. * @return 0 on success.
@ -2842,7 +2843,7 @@ static void kyber_get_noise_x4_eta3_avx2(byte* rand, byte* seed)
/* Get noise/error by calculating random bytes and sampling to a binomial /* Get noise/error by calculating random bytes and sampling to a binomial
* distribution. Values -2..2 * distribution. Values -2..2
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [out] p Polynomial. * @param [out] p Polynomial.
* @param [in] seed Seed to use when calculating random. * @param [in] seed Seed to use when calculating random.
* @return 0 on success. * @return 0 on success.
@ -2865,7 +2866,7 @@ static int kyber_get_noise_eta2_avx2(KYBER_PRF_T* prf, sword16* p,
/* Get the noise/error by calculating random bytes and sampling to a binomial /* Get the noise/error by calculating random bytes and sampling to a binomial
* distribution. * distribution.
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [out] vec1 First Vector of polynomials. * @param [out] vec1 First Vector of polynomials.
* @param [out] vec2 Second Vector of polynomials. * @param [out] vec2 Second Vector of polynomials.
* @param [out] poly Polynomial. * @param [out] poly Polynomial.
@ -2932,7 +2933,7 @@ static int kyber_get_noise_k3_avx2(sword16* vec1, sword16* vec2, sword16* poly,
/* Get the noise/error by calculating random bytes and sampling to a binomial /* Get the noise/error by calculating random bytes and sampling to a binomial
* distribution. * distribution.
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [out] vec1 First Vector of polynomials. * @param [out] vec1 First Vector of polynomials.
* @param [out] vec2 Second Vector of polynomials. * @param [out] vec2 Second Vector of polynomials.
* @param [out] poly Polynomial. * @param [out] poly Polynomial.
@ -3170,7 +3171,7 @@ static int kyber_get_noise_k4_aarch64(sword16* vec1, sword16* vec2,
/* Get the noise/error by calculating random bytes and sampling to a binomial /* Get the noise/error by calculating random bytes and sampling to a binomial
* distribution. * distribution.
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [in] kp Number of polynomials in vector. * @param [in] kp Number of polynomials in vector.
* @param [out] vec1 First Vector of polynomials. * @param [out] vec1 First Vector of polynomials.
* @param [in] eta1 Size of noise/error integers with first vector. * @param [in] eta1 Size of noise/error integers with first vector.
@ -3215,7 +3216,7 @@ static int kyber_get_noise_c(KYBER_PRF_T* prf, int kp, sword16* vec1, int eta1,
/* Get the noise/error by calculating random bytes and sampling to a binomial /* Get the noise/error by calculating random bytes and sampling to a binomial
* distribution. * distribution.
* *
* @param [in, out] prf Psuedo-random function object. * @param [in, out] prf Pseudo-random function object.
* @param [in] kp Number of polynomials in vector. * @param [in] kp Number of polynomials in vector.
* @param [out] vec1 First Vector of polynomials. * @param [out] vec1 First Vector of polynomials.
* @param [out] vec2 Second Vector of polynomials. * @param [out] vec2 Second Vector of polynomials.

View File

@ -41,6 +41,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/wc_lms.h> #include <wolfssl/wolfcrypt/wc_lms.h>
#include <wolfssl/wolfcrypt/error-crypt.h> #include <wolfssl/wolfcrypt/error-crypt.h>
@ -103,7 +104,7 @@
#ifdef WC_LMS_DEBUG_PRINT_DATA #ifdef WC_LMS_DEBUG_PRINT_DATA
/* Print data when dubgging implementation. /* Print data when debugging implementation.
* *
* @param [in] name String to print before data. * @param [in] name String to print before data.
* @param [in] data Array of bytes. * @param [in] data Array of bytes.
@ -858,7 +859,7 @@ static int wc_lmots_msg_hash(LmsState* state, const byte* msg, word32 msgSz,
* } * }
* y[i] = tmp * y[i] = tmp
* } * }
* x[i] can be calculated on the fly using psueodo key generation in Appendix A. * x[i] can be calculated on the fly using pseudo key generation in Appendix A.
* Appendix A, The elements of the LM-OTS private keys are computed as: * Appendix A, The elements of the LM-OTS private keys are computed as:
* x_q[i] = H(I || u32str(q) || u16str(i) || u8str(0xff) || SEED). * x_q[i] = H(I || u32str(q) || u16str(i) || u8str(0xff) || SEED).
* *
@ -874,7 +875,7 @@ static int wc_lmots_compute_y_from_seed(LmsState* state, const byte* seed,
const byte* msg, word32 msgSz, const byte* c, byte* y) const byte* msg, word32 msgSz, const byte* c, byte* y)
{ {
const LmsParams* params = state->params; const LmsParams* params = state->params;
int ret = 0; int ret;
word16 i; word16 i;
byte q[LMS_MAX_NODE_LEN + LMS_CKSM_LEN]; byte q[LMS_MAX_NODE_LEN + LMS_CKSM_LEN];
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
@ -891,8 +892,8 @@ static int wc_lmots_compute_y_from_seed(LmsState* state, const byte* seed,
ret = wc_lmots_msg_hash(state, msg, msgSz, c, q); ret = wc_lmots_msg_hash(state, msg, msgSz, c, q);
if (ret == 0) { if (ret == 0) {
/* Calculate checksum list all coefficients. */ /* Calculate checksum list all coefficients. */
ret = wc_lmots_q_expand(q, params->hash_len, params->width, params->ls, ret = wc_lmots_q_expand(q, (word8)params->hash_len, params->width,
a); params->ls, a);
} }
#ifndef WC_LMS_FULL_HASH #ifndef WC_LMS_FULL_HASH
if (ret == 0) { if (ret == 0) {
@ -1062,8 +1063,8 @@ static int wc_lmots_compute_kc_from_sig(LmsState* state, const byte* msg,
} }
if (ret == 0) { if (ret == 0) {
/* Calculate checksum list all coefficients. */ /* Calculate checksum list all coefficients. */
ret = wc_lmots_q_expand(q, params->hash_len, params->width, params->ls, ret = wc_lmots_q_expand(q, (word8)params->hash_len, params->width,
a); params->ls, a);
} }
#ifndef WC_LMS_FULL_HASH #ifndef WC_LMS_FULL_HASH
if (ret == 0) { if (ret == 0) {
@ -1177,7 +1178,7 @@ static int wc_lmots_compute_kc_from_sig(LmsState* state, const byte* msg,
* } * }
* K = H(I || u32str(q) || u16str(D_PBLC) || y[0] || ... || y[p-1]) * K = H(I || u32str(q) || u16str(D_PBLC) || y[0] || ... || y[p-1])
* ... * ...
* x[i] can be calculated on the fly using psueodo key generation in Appendix A. * x[i] can be calculated on the fly using pseudo key generation in Appendix A.
* Appendix A, The elements of the LM-OTS private keys are computed as: * Appendix A, The elements of the LM-OTS private keys are computed as:
* x_q[i] = H(I || u32str(q) || u16str(i) || u8str(0xff) || SEED). * x_q[i] = H(I || u32str(q) || u16str(i) || u8str(0xff) || SEED).
* *
@ -3678,11 +3679,11 @@ int wc_hss_sigsleft(const LmsParams* params, const byte* priv_raw)
* *
* @param [in, out] state LMS state. * @param [in, out] state LMS state.
* @param [in] pub HSS public key. * @param [in] pub HSS public key.
* @param [in] msg Message to rifyn. * @param [in] msg Message to verify.
* @param [in] msgSz Length of message in bytes. * @param [in] msgSz Length of message in bytes.
* @param [in] sig Signature of message. * @param [in] sig Signature of message.
* @return 0 on success. * @return 0 on success.
* @return SIG_VERFIY_E on failure. * @return SIG_VERIFY_E on failure.
*/ */
int wc_hss_verify(LmsState* state, const byte* pub, const byte* msg, int wc_hss_verify(LmsState* state, const byte* pub, const byte* msg,
word32 msgSz, const byte* sig) word32 msgSz, const byte* sig)

View File

@ -2409,7 +2409,7 @@ static WC_INLINE void OCSPRespFreeCb(void* ioCtx, unsigned char* response)
enum { enum {
VERIFY_OVERRIDE_ERROR, VERIFY_OVERRIDE_ERROR,
VERIFY_FORCE_FAIL, VERIFY_FORCE_FAIL,
VERIFY_USE_PREVERFIY, VERIFY_USE_PREVERIFY,
VERIFY_OVERRIDE_DATE_ERR, VERIFY_OVERRIDE_DATE_ERR,
}; };
static THREAD_LS_T int myVerifyAction = VERIFY_OVERRIDE_ERROR; static THREAD_LS_T int myVerifyAction = VERIFY_OVERRIDE_ERROR;

View File

@ -88,6 +88,8 @@
#ifndef WC_LMS_H #ifndef WC_LMS_H
#define WC_LMS_H #define WC_LMS_H
#include <wolfssl/wolfcrypt/types.h>
#if defined(WOLFSSL_HAVE_LMS) && defined(WOLFSSL_WC_LMS) #if defined(WOLFSSL_HAVE_LMS) && defined(WOLFSSL_WC_LMS)
#include <wolfssl/wolfcrypt/lms.h> #include <wolfssl/wolfcrypt/lms.h>

View File

@ -1051,9 +1051,11 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
/* Windows API defines its own min() macro. */ /* Windows API defines its own min() macro. */
#if defined(USE_WINDOWS_API) #if defined(USE_WINDOWS_API)
#if defined(min) || defined(WOLFSSL_MYSQL_COMPATIBLE) #if defined(min) || defined(WOLFSSL_MYSQL_COMPATIBLE)
#undef WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MIN #define WOLFSSL_HAVE_MIN
#endif /* min */ #endif /* min */
#if defined(max) || defined(WOLFSSL_MYSQL_COMPATIBLE) #if defined(max) || defined(WOLFSSL_MYSQL_COMPATIBLE)
#undef WOLFSSL_HAVE_MAX
#define WOLFSSL_HAVE_MAX #define WOLFSSL_HAVE_MAX
#endif /* max */ #endif /* max */
#endif /* USE_WINDOWS_API */ #endif /* USE_WINDOWS_API */