Skip to content

Commit

Permalink
C99 conforming static assert (#80)
Browse files Browse the repository at this point in the history
* Replace static assert keywords with a C99 compliant implementation and replace all string literal arguments to the OPENSSL_STATIC_ASSERT macro with preprocessor tokens

* Remove some c99 violating EOE symbols

* Improve c99 violation test

* Fix more C99 violations

* Oops, accidently forgot to clean up the cmake file

* Updated description

* Improve error code and language

* Add error example

Co-authored-by: Bryce Shang <[email protected]>
  • Loading branch information
torben-hansen and bryce-shang authored Dec 22, 2020
1 parent 19fd1be commit 4702a85
Show file tree
Hide file tree
Showing 43 changed files with 133 additions and 97 deletions.
2 changes: 1 addition & 1 deletion crypto/asn1/a_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a)
return -1;

OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
"long larger than uint64_t");
long_larger_than_uint64_t);

if (a->length > (int)sizeof(uint64_t)) {
/* hmm... a bit ugly */
Expand Down
2 changes: 1 addition & 1 deletion crypto/asn1/a_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
return -1;

OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
"long larger than uint64_t");
long_larger_than_uint64_t);

if (a->length > (int)sizeof(uint64_t)) {
/* hmm... a bit ugly, return all ones */
Expand Down
2 changes: 1 addition & 1 deletion crypto/base64/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static uint8_t conv_bin2ascii(uint8_t a) {
}

OPENSSL_STATIC_ASSERT(sizeof(((EVP_ENCODE_CTX *)(NULL))->data) % 3 == 0,
"data length must be a multiple of base64 chunk size");
_data_length_must_be_a_multiple_of_base64_chunk_size);

int EVP_EncodedLength(size_t *out_len, size_t len) {
if (len + 2 < len) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/cipher_extra/e_aesccm.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ struct aead_aes_ccm_ctx {

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_ccm_ctx),
"AEAD state is too small");
AEAD_state_is_too_small);
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_ccm_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment);
#endif

static int aead_aes_ccm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
Expand Down
4 changes: 2 additions & 2 deletions crypto/cipher_extra/e_aesctrhmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ struct aead_aes_ctr_hmac_sha256_ctx {

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_ctr_hmac_sha256_ctx),
"AEAD state is too small");
AEAD_state_is_too_small);
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_ctr_hmac_sha256_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment);
#endif

static void hmac_init(SHA256_CTX *out_inner, SHA256_CTX *out_outer,
Expand Down
8 changes: 4 additions & 4 deletions crypto/cipher_extra/e_aesgcmsiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ struct aead_aes_gcm_siv_asm_ctx {
// aligns to 16 bytes itself.
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) + 8 >=
sizeof(struct aead_aes_gcm_siv_asm_ctx),
"AEAD state is too small");
AEAD_state_is_too_small);
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >= 8,
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment)
#endif

// asm_ctx_from_ctx returns a 16-byte aligned context pointer from |ctx|.
Expand Down Expand Up @@ -571,11 +571,11 @@ struct aead_aes_gcm_siv_ctx {

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_gcm_siv_ctx),
"AEAD state is too small");
AEAD_state_is_too_small);
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_gcm_siv_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment);
#endif

static int aead_aes_gcm_siv_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
Expand Down
8 changes: 4 additions & 4 deletions crypto/cipher_extra/e_chacha20poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ struct aead_chacha20_poly1305_ctx {

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_chacha20_poly1305_ctx),
"AEAD state is too small");
AEAD_state_is_too_small);
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_chacha20_poly1305_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment);
#endif

// For convenience (the x86_64 calling convention allows only six parameters in
Expand Down Expand Up @@ -78,9 +78,9 @@ static int asm_capable(void) {
return sse41_capable;
}

OPENSSL_STATIC_ASSERT(sizeof(union open_data) == 48, "wrong open_data size");
OPENSSL_STATIC_ASSERT(sizeof(union open_data) == 48, wrong_open_data_size);
OPENSSL_STATIC_ASSERT(sizeof(union seal_data) == 48 + 8 + 8,
"wrong seal_data size");
wrong_seal_data_size);

// chacha20_poly1305_open is defined in chacha20_poly1305_x86_64.pl. It decrypts
// |plaintext_len| bytes from |ciphertext| and writes them to |out_plaintext|.
Expand Down
6 changes: 3 additions & 3 deletions crypto/cipher_extra/e_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ typedef struct {
} AEAD_TLS_CTX;

OPENSSL_STATIC_ASSERT(EVP_MAX_MD_SIZE < 256,
"mac_key_len does not fit in uint8_t");
mac_key_len_does_not_fit_in_uint8_t);

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(AEAD_TLS_CTX),
"AEAD state is too small");
AEAD_state_is_too_small);
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(AEAD_TLS_CTX),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment);
#endif

static void aead_tls_cleanup(EVP_AEAD_CTX *ctx) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/curve25519/curve25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ typedef uint32_t fe_limb_t;
#endif // BORINGSSL_CURVE25519_64BIT

OPENSSL_STATIC_ASSERT(sizeof(fe) == sizeof(fe_limb_t) * FE_NUM_LIMBS,
"fe_limb_t[FE_NUM_LIMBS] is inconsistent with fe");
fe_limb_t_FE_NUM_LIMBS_is_inconsistent_with_fe);

static void fe_frombytes_strict(fe *h, const uint8_t s[32]) {
// |fiat_25519_from_bytes| requires the top-most bit be clear.
Expand Down Expand Up @@ -313,7 +313,7 @@ static void fe_copy(fe *h, const fe *f) {

static void fe_copy_lt(fe_loose *h, const fe *f) {
OPENSSL_STATIC_ASSERT(sizeof(fe_loose) == sizeof(fe),
"fe and fe_loose mismatch");
fe_and_fe_loose_mismatch);
OPENSSL_memmove(h, f, sizeof(fe));
}
#if !defined(OPENSSL_SMALL)
Expand Down
2 changes: 1 addition & 1 deletion crypto/ec_extra/hash_to_curve.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int expand_message_xmd(const EVP_MD *md, uint8_t *out, size_t out_len,
EVP_MD_CTX_init(&ctx);

// Long DSTs are hashed down to size. See section 5.3.3.
OPENSSL_STATIC_ASSERT(EVP_MAX_MD_SIZE < 256, "hashed DST still too large");
OPENSSL_STATIC_ASSERT(EVP_MAX_MD_SIZE < 256, hashed_DST_still_too_large);
uint8_t dst_buf[EVP_MAX_MD_SIZE];
if (dst_len >= 256) {
static const char kPrefix[] = "H2C-OVERSIZE-DST-";
Expand Down
4 changes: 2 additions & 2 deletions crypto/err/err_data_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ func main() {
`)

for i, name := range libraryNames {
fmt.Fprintf(out, "OPENSSL_STATIC_ASSERT(ERR_LIB_%s == %d, \"library value changed\");\n", name, i+1)
fmt.Fprintf(out, "OPENSSL_STATIC_ASSERT(ERR_LIB_%s == %d, library_value_changed);\n", name, i+1)
}
fmt.Fprintf(out, "OPENSSL_STATIC_ASSERT(ERR_NUM_LIBS == %d, \"number of libraries changed\");\n", len(libraryNames)+1)
fmt.Fprintf(out, "OPENSSL_STATIC_ASSERT(ERR_NUM_LIBS == %d, number_of_libraries_changed);\n", len(libraryNames)+1)
out.WriteString("\n")

e.reasons.WriteTo(out, "Reason")
Expand Down
4 changes: 2 additions & 2 deletions crypto/evp/scrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// A block_t is a Salsa20 block.
typedef struct { uint32_t words[16]; } block_t;

OPENSSL_STATIC_ASSERT(sizeof(block_t) == 64, "block_t has padding");
OPENSSL_STATIC_ASSERT(sizeof(block_t) == 64, block_t_has_padding);

#define R(a, b) (((a) << (b)) | ((a) >> (32 - (b))))

Expand Down Expand Up @@ -173,7 +173,7 @@ int EVP_PBE_scrypt(const char *password, size_t password_len,

// Allocate and divide up the scratch space. |max_mem| fits in a size_t, which
// is no bigger than uint64_t, so none of these operations may overflow.
OPENSSL_STATIC_ASSERT(UINT64_MAX >= ((size_t)-1), "size_t exceeds uint64_t");
OPENSSL_STATIC_ASSERT(UINT64_MAX >= ((size_t)-1), size_t_exceeds_uint64_t);
size_t B_blocks = p * 2 * r;
size_t B_bytes = B_blocks * sizeof(block_t);
size_t T_blocks = 2 * r;
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/aes/aes_nohw.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ static inline aes_word_t aes_nohw_shift_right(aes_word_t a, aes_word_t i) {
#endif // OPENSSL_SSE2

OPENSSL_STATIC_ASSERT(AES_NOHW_BATCH_SIZE * 128 == 8 * 8 * sizeof(aes_word_t),
"batch size does not match word size");
batch_size_does_not_match_word_size)
OPENSSL_STATIC_ASSERT(AES_NOHW_WORD_SIZE == sizeof(aes_word_t),
"AES_NOHW_WORD_SIZE is incorrect");
AES_NOHW_WORD_SIZE_is_incorrect)


// Block representations.
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/bn/bn.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ void bn_select_words(BN_ULONG *r, BN_ULONG mask, const BN_ULONG *a,
const BN_ULONG *b, size_t num) {
for (size_t i = 0; i < num; i++) {
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
r[i] = constant_time_select_w(mask, a[i], b[i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/bn/cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
static int bn_cmp_words_consttime(const BN_ULONG *a, size_t a_len,
const BN_ULONG *b, size_t b_len) {
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
int ret = 0;
// Process the common words in little-endian order.
size_t min = a_len < b_len ? a_len : b_len;
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/bn/montgomery.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ static int bn_mont_ctx_set_N_and_n0(BN_MONT_CTX *mont, const BIGNUM *mod) {
// math instead of |uint64_t|-based math, which would be double-precision.
// However, currently only the assembler files know which is which.
OPENSSL_STATIC_ASSERT(BN_MONT_CTX_N0_LIMBS == 1 || BN_MONT_CTX_N0_LIMBS == 2,
"BN_MONT_CTX_N0_LIMBS value is invalid");
BN_MONT_CTX_N0_LIMBS_value_is_invalid);
OPENSSL_STATIC_ASSERT(
sizeof(BN_ULONG) * BN_MONT_CTX_N0_LIMBS == sizeof(uint64_t),
"uint64_t is insufficient precision for n0");
uint64_t_is_insufficient_precision_for_n0);
uint64_t n0 = bn_mont_n0(&mont->N);
mont->n0[0] = (BN_ULONG)n0;
#if BN_MONT_CTX_N0_LIMBS == 2
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/bn/montgomery_inv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
static uint64_t bn_neg_inv_mod_r_u64(uint64_t n);

OPENSSL_STATIC_ASSERT(BN_MONT_CTX_N0_LIMBS == 1 || BN_MONT_CTX_N0_LIMBS == 2,
"BN_MONT_CTX_N0_LIMBS value is invalid");
BN_MONT_CTX_N0_LIMBS_value_is_invalid)
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) * BN_MONT_CTX_N0_LIMBS ==
sizeof(uint64_t),
"uint64_t is insufficient precision for n0");
uint64_t_is_insufficient_precision_for_n0)

// LG_LITTLE_R is log_2(r).
#define LG_LITTLE_R (BN_MONT_CTX_N0_LIMBS * BN_BITS2)
Expand Down
4 changes: 2 additions & 2 deletions crypto/fipsmodule/bn/mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static void bn_mul_recursive(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
BN_ULONG c_pos = c + bn_add_words(&t[n2], t, &t[n2], n2);
bn_select_words(&t[n2], neg, &t[n2 * 2], &t[n2], n2);
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
c = constant_time_select_w(neg, c_neg, c_pos);

// We now have our three components. Add them together.
Expand Down Expand Up @@ -396,7 +396,7 @@ static void bn_mul_part_recursive(BN_ULONG *r, const BN_ULONG *a,
BN_ULONG c_pos = c + bn_add_words(&t[n2], t, &t[n2], n2);
bn_select_words(&t[n2], neg, &t[n2 * 2], &t[n2], n2);
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
c = constant_time_select_w(neg, c_neg, c_pos);

// We now have our three components. Add them together.
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/bn/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static crypto_word_t bn_less_than_word_mask(const BN_ULONG *a, size_t len,

// |a| < |b| iff a[1..len-1] are all zero and a[0] < b.
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
crypto_word_t mask = 0;
for (size_t i = 1; i < len; i++) {
mask |= a[i];
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/bn/rsaz_exp.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void RSAZ_1024_mod_exp_avx2(BN_ULONG result_norm[16],
BN_ULONG k0,
BN_ULONG storage[MOD_EXP_CTIME_STORAGE_LEN]) {
OPENSSL_STATIC_ASSERT(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH % 64 == 0,
"MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH is too small");
MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH_is_too_small);
assert((uintptr_t)storage % 64 == 0);

BN_ULONG *a_inv, *m, *result, *table_s = storage + 40 * 3, *R2 = table_s;
Expand Down
12 changes: 6 additions & 6 deletions crypto/fipsmodule/bn/shift.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ int BN_mask_bits(BIGNUM *a, int n) {

static int bn_count_low_zero_bits_word(BN_ULONG l) {
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
OPENSSL_STATIC_ASSERT(sizeof(int) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
OPENSSL_STATIC_ASSERT(BN_BITS2 == sizeof(BN_ULONG) * 8,
"BN_ULONG has padding bits");
BN_ULONG_has_padding_bits);
// C has very bizarre rules for types smaller than an int.
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) >= sizeof(int),
"BN_ULONG gets promoted to int");
BN_ULONG_gets_promoted_to_int);

crypto_word_t mask;
int bits = 0;
Expand Down Expand Up @@ -343,9 +343,9 @@ static int bn_count_low_zero_bits_word(BN_ULONG l) {

int BN_count_low_zero_bits(const BIGNUM *bn) {
OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);
OPENSSL_STATIC_ASSERT(sizeof(int) <= sizeof(crypto_word_t),
"crypto_word_t is too small");
crypto_word_t_is_too_small);

int ret = 0;
crypto_word_t saw_nonzero = 0;
Expand Down
14 changes: 7 additions & 7 deletions crypto/fipsmodule/cipher/e_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ static EVP_AES_GCM_CTX *aes_gcm_from_cipher_ctx(EVP_CIPHER_CTX *ctx) {
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(
alignof(EVP_AES_GCM_CTX) <= 16,
"EVP_AES_GCM_CTX needs more alignment than this function provides");
EVP_AES_GCM_CTX_needs_more_alignment_than_this_function_provides)
#endif

// |malloc| guarantees up to 4-byte alignment on 32-bit and 8-byte alignment
Expand Down Expand Up @@ -910,11 +910,11 @@ static int aead_aes_gcm_init_impl(struct aead_aes_gcm_ctx *gcm_ctx,

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_gcm_ctx),
"AEAD state is too small");
AEAD_state_is_too_small)
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_gcm_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment)
#endif

static int aead_aes_gcm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
Expand Down Expand Up @@ -1234,11 +1234,11 @@ struct aead_aes_gcm_tls12_ctx {

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_gcm_tls12_ctx),
"AEAD state is too small");
AEAD_state_is_too_small)
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_gcm_tls12_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment)
#endif

static int aead_aes_gcm_tls12_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
Expand Down Expand Up @@ -1328,11 +1328,11 @@ struct aead_aes_gcm_tls13_ctx {

OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_gcm_tls13_ctx),
"AEAD state is too small");
AEAD_state_is_too_small)
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_gcm_tls13_ctx),
"AEAD state has insufficient alignment");
AEAD_state_has_insufficient_alignment)
#endif

static int aead_aes_gcm_tls13_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/ec/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ void ec_affine_select(const EC_GROUP *group, EC_AFFINE *out, BN_ULONG mask,
void ec_precomp_select(const EC_GROUP *group, EC_PRECOMP *out, BN_ULONG mask,
const EC_PRECOMP *a, const EC_PRECOMP *b) {
OPENSSL_STATIC_ASSERT(sizeof(out->comb) == sizeof(*out),
"out->comb does not span the entire structure");
out_comb_does_not_span_the_entire_structure);
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(out->comb); i++) {
ec_affine_select(group, &out->comb[i], mask, &a->comb[i], &b->comb[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/ec/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extern "C" {
#define EC_MAX_WORDS ((EC_MAX_BYTES + BN_BYTES - 1) / BN_BYTES)

OPENSSL_STATIC_ASSERT(EC_MAX_WORDS <= BN_SMALL_MAX_WORDS,
"bn_*_small functions not usable");
bn__small_functions_not_usable)


// Scalars.
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/ec/p256.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void fiat_p256_to_generic(EC_FELEM *out, const fiat_p256_felem in) {
// zero when rounding up to |BN_ULONG|s.
OPENSSL_STATIC_ASSERT(
256 / 8 == sizeof(BN_ULONG) * ((256 + BN_BITS2 - 1) / BN_BITS2),
"fiat_p256_to_bytes leaves bytes uninitialized");
fiat_p256_to_bytes_leaves_bytes_uninitialized);
fiat_p256_to_bytes(out->bytes, in);
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/ec/simple_mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ int ec_GFp_mont_init_precomp(const EC_GROUP *group, EC_PRECOMP *out,
// cache pressure and makes the constant-time selects faster.)
OPENSSL_STATIC_ASSERT(
OPENSSL_ARRAY_SIZE(comb) == OPENSSL_ARRAY_SIZE(out->comb),
"comb sizes did not match");
comb_sizes_did_not_match);
return ec_jacobian_to_affine_batch(group, out->comb, comb,
OPENSSL_ARRAY_SIZE(comb));
}
Expand Down
Loading

0 comments on commit 4702a85

Please sign in to comment.