Skip to content

Commit a120b83

Browse files
authored
Merge pull request #7585 from kaleb-himes/SRTP-KDF-CODEREVIEW
Add FIPS required forward declaration of streaming struct
2 parents 385a097 + 8ca8827 commit a120b83

3 files changed

Lines changed: 39 additions & 13 deletions

File tree

tests/api.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24918,6 +24918,7 @@ static int test_wc_ecc_export_x963_ex(void)
2491824918
XMEMSET(&key, 0, sizeof(ecc_key));
2491924919
XMEMSET(&rng, 0, sizeof(WC_RNG));
2492024920
XMEMSET(out, 0, outlen);
24921+
PRIVATE_KEY_UNLOCK();
2492124922

2492224923
ExpectIntEQ(wc_ecc_init(&key), 0);
2492324924
ExpectIntEQ(wc_InitRng(&rng), 0);
@@ -24958,6 +24959,7 @@ static int test_wc_ecc_export_x963_ex(void)
2495824959
ExpectIntEQ(wc_ecc_export_x963_ex(&key, out, &outlen, NOCOMP),
2495924960
ECC_BAD_ARG_E);
2496024961
#endif
24962+
PRIVATE_KEY_LOCK();
2496124963

2496224964
DoExpectIntEQ(wc_FreeRng(&rng), 0);
2496324965
wc_ecc_free(&key);
@@ -25049,6 +25051,7 @@ static int test_wc_ecc_import_private_key(void)
2504925051
XMEMSET(&rng, 0, sizeof(WC_RNG));
2505025052
XMEMSET(privKey, 0, privKeySz);
2505125053
XMEMSET(x963Key, 0, x963KeySz);
25054+
PRIVATE_KEY_UNLOCK();
2505225055

2505325056
ExpectIntEQ(wc_ecc_init(&key), 0);
2505425057
ExpectIntEQ(wc_ecc_init(&keyImp), 0);
@@ -25071,6 +25074,7 @@ static int test_wc_ecc_import_private_key(void)
2507125074
x963KeySz, NULL), BAD_FUNC_ARG);
2507225075
ExpectIntEQ(wc_ecc_import_private_key(NULL, privKeySz, x963Key, x963KeySz,
2507325076
&keyImp), BAD_FUNC_ARG);
25077+
PRIVATE_KEY_LOCK();
2507425078

2507525079
DoExpectIntEQ(wc_FreeRng(&rng), 0);
2507625080
wc_ecc_free(&keyImp);
@@ -25101,6 +25105,7 @@ static int test_wc_ecc_export_private_only(void)
2510125105
XMEMSET(&key, 0, sizeof(ecc_key));
2510225106
XMEMSET(&rng, 0, sizeof(WC_RNG));
2510325107
XMEMSET(out, 0, outlen);
25108+
PRIVATE_KEY_UNLOCK();
2510425109

2510525110
ExpectIntEQ(wc_ecc_init(&key), 0);
2510625111
ExpectIntEQ(wc_InitRng(&rng), 0);
@@ -25115,6 +25120,7 @@ static int test_wc_ecc_export_private_only(void)
2511525120
ExpectIntEQ(wc_ecc_export_private_only(NULL, out, &outlen), BAD_FUNC_ARG);
2511625121
ExpectIntEQ(wc_ecc_export_private_only(&key, NULL, &outlen), BAD_FUNC_ARG);
2511725122
ExpectIntEQ(wc_ecc_export_private_only(&key, out, NULL), BAD_FUNC_ARG);
25123+
PRIVATE_KEY_LOCK();
2511825124

2511925125
DoExpectIntEQ(wc_FreeRng(&rng), 0);
2512025126
wc_ecc_free(&key);
@@ -25712,6 +25718,7 @@ static int test_wc_ecc_shared_secret_ssh(void)
2571225718
XMEMSET(&key2, 0, sizeof(ecc_key));
2571325719
XMEMSET(&rng, 0, sizeof(WC_RNG));
2571425720
XMEMSET(secret, 0, secretLen);
25721+
PRIVATE_KEY_UNLOCK();
2571525722

2571625723
/* Make keys */
2571725724
ExpectIntEQ(wc_ecc_init(&key), 0);
@@ -25751,6 +25758,7 @@ static int test_wc_ecc_shared_secret_ssh(void)
2575125758
key.type = ECC_PUBLICKEY;
2575225759
ExpectIntEQ(wc_ecc_shared_secret_ssh(&key, &key2.pubkey, secret,
2575325760
&secretLen), ECC_BAD_ARG_E);
25761+
PRIVATE_KEY_LOCK();
2575425762

2575525763
DoExpectIntEQ(wc_FreeRng(&rng), 0);
2575625764
wc_ecc_free(&key);
@@ -26678,6 +26686,7 @@ static int test_wc_EccPrivateKeyToDer(void)
2667826686

2667926687
XMEMSET(&eccKey, 0, sizeof(ecc_key));
2668026688
XMEMSET(&rng, 0, sizeof(WC_RNG));
26689+
PRIVATE_KEY_UNLOCK();
2668126690

2668226691
ExpectIntEQ(wc_InitRng(&rng), 0);
2668326692
ExpectIntEQ(wc_ecc_init(&eccKey), 0);
@@ -26718,6 +26727,7 @@ static int test_wc_EccPrivateKeyToDer(void)
2671826727
EVP_PKEY_free(pkey); /* EC_KEY should be free'd by free'ing pkey */
2671926728
}
2672026729
#endif
26730+
PRIVATE_KEY_LOCK();
2672126731
#endif
2672226732
return EXPECT_RESULT();
2672326733
} /* End test_wc_EccPrivateKeyToDer*/

wolfssl/wolfcrypt/aes.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,18 +420,19 @@ struct Aes {
420420
Aes tweak;
421421
};
422422

423-
#ifndef WC_AESXTS_TYPE_DEFINED
424-
typedef struct XtsAes XtsAes;
425-
#define WC_AESXTS_TYPE_DEFINED
426-
#endif
427-
428423
#ifdef WOLFSSL_AESXTS_STREAM
429424
struct XtsAesStreamData {
430425
byte tweak_block[AES_BLOCK_SIZE];
431426
word32 bytes_crypted_with_this_tweak;
432427
};
433428
#endif
434429

430+
#ifndef WC_AESXTS_TYPE_DEFINED
431+
typedef struct XtsAes XtsAes;
432+
typedef struct XtsAesStreamData XtsAesStreamData;
433+
#define WC_AESXTS_TYPE_DEFINED
434+
#endif
435+
435436
#endif
436437

437438

@@ -456,9 +457,15 @@ struct Aes {
456457
#endif
457458

458459
#ifdef HAVE_AESGCM
459-
typedef struct Gmac {
460+
struct Gmac {
460461
Aes aes;
461-
} Gmac;
462+
};
463+
464+
#ifndef WC_AESGCM_TYPE_DEFINED
465+
typedef struct Gmac Gmac;
466+
#define WC_AESGCM_TYPE_DEFINED
467+
#endif
468+
462469
#endif /* HAVE_AESGCM */
463470
#endif /* HAVE_FIPS */
464471

wolfssl/wolfcrypt/ecc.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ typedef byte ecc_oid_t;
297297

298298
/* ECC set type defined a GF(p) curve */
299299
#ifndef WOLFSSL_ECC_CURVE_STATIC
300-
typedef struct ecc_set_type {
300+
struct ecc_set_type {
301301
int size; /* The size of the curve in octets */
302302
int id; /* id of this curve */
303303
const char* name; /* name of this curve */
@@ -311,13 +311,13 @@ typedef struct ecc_set_type {
311311
word32 oidSz;
312312
word32 oidSum; /* sum of encoded OID bytes */
313313
int cofactor;
314-
} ecc_set_type;
314+
};
315315
#else
316316
#define MAX_ECC_NAME 16
317317
#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 2)
318318
/* The values are stored as text strings. */
319319

320-
typedef struct ecc_set_type {
320+
struct ecc_set_type {
321321
int size; /* The size of the curve in octets */
322322
int id; /* id of this curve */
323323
char name[MAX_ECC_NAME]; /* name of this curve */
@@ -331,7 +331,7 @@ typedef struct ecc_set_type {
331331
word32 oidSz;
332332
word32 oidSum; /* sum of encoded OID bytes */
333333
int cofactor;
334-
} ecc_set_type;
334+
};
335335
#endif
336336

337337

@@ -441,10 +441,19 @@ typedef struct alt_fp_int {
441441
#define WC_ECCKEY_TYPE_DEFINED
442442
#endif
443443

444+
#ifndef WC_ECCPOINT_TYPE_DEFINED
445+
typedef struct ecc_point ecc_point;
446+
#define WC_ECCPOINT_TYPE_DEFINED
447+
#endif
448+
449+
#ifndef WC_ECCSET_TYPE_DEFINED
450+
typedef struct ecc_set_type ecc_set_type;
451+
#define WC_ECCSET_TYPE_DEFINED
452+
#endif
444453

445454
/* A point on an ECC curve, stored in Jacobian format such that (x,y,z) =>
446455
(x/z^2, y/z^3, 1) when interpreted as affine */
447-
typedef struct {
456+
struct ecc_point {
448457
#ifndef ALT_ECC_SIZE
449458
mp_int x[1]; /* The x coordinate */
450459
mp_int y[1]; /* The y coordinate */
@@ -458,7 +467,7 @@ typedef struct {
458467
#if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_ECC_NO_SMALL_STACK)
459468
ecc_key* key;
460469
#endif
461-
} ecc_point;
470+
};
462471

463472
/* ECC Flags */
464473
enum {

0 commit comments

Comments
 (0)