Skip to content

Commit 74de689

Browse files
authored
Merge pull request wolfSSL#8875 from kareem-wolfssl/zd20035
Fix SRP wolfCrypt test on lower FP_MAX/SP_INT_BITS configs
2 parents 27176a5 + fe5ae0c commit 74de689

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

wolfcrypt/test/test.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24152,7 +24152,6 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t dsa_test(void)
2415224152
#endif /* !NO_DSA */
2415324153

2415424154
#ifdef WOLFCRYPT_HAVE_SRP
24155-
2415624155
static wc_test_ret_t generate_random_salt(byte *buf, word32 size)
2415724156
{
2415824157
wc_test_ret_t ret = WC_TEST_RET_ENC_NC;
@@ -24170,21 +24169,48 @@ static wc_test_ret_t generate_random_salt(byte *buf, word32 size)
2417024169
return ret;
2417124170
}
2417224171

24172+
#if ((defined(FP_MAX_BITS) && (FP_MAX_BITS >= 3072)) \
24173+
|| (defined(SP_INT_BITS) && (SP_INT_BITS >= 3072)))
24174+
#define SRP_TEST_BUFFER_SIZE 192
24175+
#else
24176+
#define SRP_TEST_BUFFER_SIZE 128
24177+
#endif
24178+
2417324179
static wc_test_ret_t srp_test_digest(SrpType dgstType)
2417424180
{
2417524181
wc_test_ret_t r;
2417624182

24177-
byte clientPubKey[192]; /* A */
24178-
byte serverPubKey[192]; /* B */
24179-
word32 clientPubKeySz = 192;
24180-
word32 serverPubKeySz = 192;
24183+
byte clientPubKey[SRP_TEST_BUFFER_SIZE]; /* A */
24184+
byte serverPubKey[SRP_TEST_BUFFER_SIZE]; /* B */
24185+
word32 clientPubKeySz = SRP_TEST_BUFFER_SIZE;
24186+
word32 serverPubKeySz = SRP_TEST_BUFFER_SIZE;
2418124187

2418224188
byte username[] = "user";
2418324189
word32 usernameSz = 4;
2418424190

2418524191
byte password[] = "password";
2418624192
word32 passwordSz = 8;
2418724193

24194+
#if SRP_TEST_BUFFER_SIZE == 128
24195+
WOLFSSL_SMALL_STACK_STATIC const byte N[] = {
24196+
0xEE, 0xAF, 0x0A, 0xB9, 0xAD, 0xB3, 0x8D, 0xD6,
24197+
0x9C, 0x33, 0xF8, 0x0A, 0xFA, 0x8F, 0xC5, 0xE8,
24198+
0x60, 0x72, 0x61, 0x87, 0x75, 0xFF, 0x3C, 0x0B,
24199+
0x9E, 0xA2, 0x31, 0x4C, 0x9C, 0x25, 0x65, 0x76,
24200+
0xD6, 0x74, 0xDF, 0x74, 0x96, 0xEA, 0x81, 0xD3,
24201+
0x38, 0x3B, 0x48, 0x13, 0xD6, 0x92, 0xC6, 0xE0,
24202+
0xE0, 0xD5, 0xD8, 0xE2, 0x50, 0xB9, 0x8B, 0xE4,
24203+
0x8E, 0x49, 0x5C, 0x1D, 0x60, 0x89, 0xDA, 0xD1,
24204+
0x5D, 0xC7, 0xD7, 0xB4, 0x61, 0x54, 0xD6, 0xB6,
24205+
0xCE, 0x8E, 0xF4, 0xAD, 0x69, 0xB1, 0x5D, 0x49,
24206+
0x82, 0x55, 0x9B, 0x29, 0x7B, 0xCF, 0x18, 0x85,
24207+
0xC5, 0x29, 0xF5, 0x66, 0x66, 0x0E, 0x57, 0xEC,
24208+
0x68, 0xED, 0xBC, 0x3C, 0x05, 0x72, 0x6C, 0xC0,
24209+
0x2F, 0xD4, 0xCB, 0xF4, 0x97, 0x6E, 0xAA, 0x9A,
24210+
0xFD, 0x51, 0x38, 0xFE, 0x83, 0x76, 0x43, 0x5B,
24211+
0x9F, 0xC6, 0x1D, 0x2F, 0xC0, 0xEB, 0x06, 0xE3
24212+
};
24213+
#else
2418824214
WOLFSSL_SMALL_STACK_STATIC const byte N[] = {
2418924215
0xfc, 0x58, 0x7a, 0x8a, 0x70, 0xfb, 0x5a, 0x9a,
2419024216
0x5d, 0x39, 0x48, 0xbf, 0x1c, 0x46, 0xd8, 0x3b,
@@ -24211,14 +24237,16 @@ static wc_test_ret_t srp_test_digest(SrpType dgstType)
2421124237
0xb9, 0x26, 0x03, 0xba, 0xb5, 0x58, 0x6f, 0x6c,
2421224238
0x8b, 0x08, 0xa1, 0x7b, 0x6f, 0x42, 0xc9, 0x53
2421324239
};
24240+
#endif
2421424241

24242+
/* Generator is 2 for both cases. */
2421524243
WOLFSSL_SMALL_STACK_STATIC const byte g[] = {
2421624244
0x02
2421724245
};
2421824246

2421924247
byte salt[10];
2422024248

24221-
byte verifier[192];
24249+
byte verifier[SRP_TEST_BUFFER_SIZE];
2422224250
word32 v_size = (word32)sizeof(verifier);
2422324251

2422424252
word32 clientProofSz = SRP_MAX_DIGEST_SIZE;

0 commit comments

Comments
 (0)