Get OPENSSL_COMPILE_ASSERT working in function bodies.
Change-Id: Ifc28887cbf91c7a80bdaf56e3bf80b2f8cfa7d53 Reviewed-on: https://boringssl-review.googlesource.com/13260 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
d1515a3b0a
commit
5db7c9b8c2
@ -78,6 +78,10 @@ extern "C" {
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
#define OPENSSL_COMPILE_ASSERT(cond, msg) _Static_assert(cond, #msg)
|
||||
#elif defined(__GNUC__)
|
||||
#define OPENSSL_COMPILE_ASSERT(cond, msg) \
|
||||
typedef char OPENSSL_COMPILE_ASSERT_##msg[((cond) ? 1 : -1)] \
|
||||
__attribute__((unused))
|
||||
#else
|
||||
#define OPENSSL_COMPILE_ASSERT(cond, msg) \
|
||||
typedef char OPENSSL_COMPILE_ASSERT_##msg[((cond) ? 1 : -1)]
|
||||
|
@ -26,9 +26,6 @@
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
OPENSSL_COMPILE_ASSERT(EVP_AEAD_MAX_NONCE_LENGTH < 256,
|
||||
variable_nonce_len_doesnt_fit_in_uint8_t);
|
||||
|
||||
SSL_AEAD_CTX *SSL_AEAD_CTX_new(enum evp_aead_direction_t direction,
|
||||
uint16_t version, const SSL_CIPHER *cipher,
|
||||
const uint8_t *enc_key, size_t enc_key_len,
|
||||
@ -78,6 +75,8 @@ SSL_AEAD_CTX *SSL_AEAD_CTX_new(enum evp_aead_direction_t direction,
|
||||
}
|
||||
|
||||
assert(EVP_AEAD_nonce_length(aead) <= EVP_AEAD_MAX_NONCE_LENGTH);
|
||||
OPENSSL_COMPILE_ASSERT(EVP_AEAD_MAX_NONCE_LENGTH < 256,
|
||||
variable_nonce_len_doesnt_fit_in_uint8_t);
|
||||
aead_ctx->variable_nonce_len = (uint8_t)EVP_AEAD_nonce_length(aead);
|
||||
if (mac_key_len == 0) {
|
||||
assert(fixed_iv_len <= sizeof(aead_ctx->fixed_nonce));
|
||||
|
@ -365,13 +365,13 @@ int SSL_set_signing_algorithm_prefs(SSL *ssl, const uint16_t *prefs,
|
||||
return set_signing_algorithm_prefs(ssl->cert, prefs, num_prefs);
|
||||
}
|
||||
|
||||
OPENSSL_COMPILE_ASSERT(sizeof(int) >= 2 * sizeof(uint16_t),
|
||||
digest_list_conversion_cannot_overflow);
|
||||
|
||||
int SSL_set_private_key_digest_prefs(SSL *ssl, const int *digest_nids,
|
||||
size_t num_digests) {
|
||||
OPENSSL_free(ssl->cert->sigalgs);
|
||||
|
||||
OPENSSL_COMPILE_ASSERT(sizeof(int) >= 2 * sizeof(uint16_t),
|
||||
digest_list_conversion_cannot_overflow);
|
||||
|
||||
ssl->cert->num_sigalgs = 0;
|
||||
ssl->cert->sigalgs = OPENSSL_malloc(sizeof(uint16_t) * 2 * num_digests);
|
||||
if (ssl->cert->sigalgs == NULL) {
|
||||
|
@ -3025,8 +3025,6 @@ int ssl_parse_clienthello_tlsext(SSL_HANDSHAKE *hs,
|
||||
return 1;
|
||||
}
|
||||
|
||||
OPENSSL_COMPILE_ASSERT(kNumExtensions <= sizeof(uint32_t) * 8, too_many_bits);
|
||||
|
||||
static int ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, CBS *cbs,
|
||||
int *out_alert) {
|
||||
SSL *const ssl = hs->ssl;
|
||||
@ -3066,6 +3064,9 @@ static int ssl_scan_serverhello_tlsext(SSL_HANDSHAKE *hs, CBS *cbs,
|
||||
continue;
|
||||
}
|
||||
|
||||
OPENSSL_COMPILE_ASSERT(kNumExtensions <= sizeof(hs->extensions.sent) * 8,
|
||||
too_many_bits);
|
||||
|
||||
if (!(hs->extensions.sent & (1u << ext_index)) &&
|
||||
type != TLSEXT_TYPE_renegotiate) {
|
||||
/* If the extension was never sent then it is illegal, except for the
|
||||
|
Loading…
Reference in New Issue
Block a user