Replace bools in cipher_entry_st with flags field.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
.implicit_iv = 4,
.explicit_iv = 8,
.cipher_iv = 12,
- .only_aead = 1,
+ .flags = GNUTLS_CIPHER_FLAG_ONLY_AEAD,
.tagsize = 16},
{ .name = "AES-256-CCM",
.id = GNUTLS_CIPHER_AES_256_CCM,
.implicit_iv = 4,
.explicit_iv = 8,
.cipher_iv = 12,
- .only_aead = 1,
+ .flags = GNUTLS_CIPHER_FLAG_ONLY_AEAD,
.tagsize = 16},
{ .name = "AES-128-CCM-8",
.id = GNUTLS_CIPHER_AES_128_CCM_8,
.implicit_iv = 4,
.explicit_iv = 8,
.cipher_iv = 12,
- .only_aead = 1,
+ .flags = GNUTLS_CIPHER_FLAG_ONLY_AEAD,
.tagsize = 8},
{ .name = "AES-256-CCM-8",
.id = GNUTLS_CIPHER_AES_256_CCM_8,
.implicit_iv = 4,
.explicit_iv = 8,
.cipher_iv = 12,
- .only_aead = 1,
+ .flags = GNUTLS_CIPHER_FLAG_ONLY_AEAD,
.tagsize = 8},
{ .name = "ARCFOUR-128",
.id = GNUTLS_CIPHER_ARCFOUR_128,
.type = CIPHER_AEAD,
.implicit_iv = 12,
.explicit_iv = 0,
- .xor_nonce = 1,
- .cipher_iv = 12,
/* in chacha20 we don't need a rekey after 2^24 messages */
- .no_rekey = 1,
+ .flags = GNUTLS_CIPHER_FLAG_XOR_NONCE | GNUTLS_CIPHER_FLAG_NO_REKEY,
+ .cipher_iv = 12,
.tagsize = 16
},
{ .name = "CAMELLIA-128-GCM",
cipher_data += blocksize;
}
} else { /* AEAD */
- if (params->cipher->xor_nonce == 0) {
+ if ((params->cipher->flags & GNUTLS_CIPHER_FLAG_XOR_NONCE) == 0) {
/* Values in AEAD are pretty fixed in TLS 1.2 for 128-bit block
*/
if (params->write.iv_size != imp_iv_size)
if (unlikely(ciphertext->size < (tag_size + exp_iv_size)))
return gnutls_assert_val(GNUTLS_E_DECRYPTION_FAILED);
- if (params->cipher->xor_nonce == 0) {
+ if ((params->cipher->flags & GNUTLS_CIPHER_FLAG_XOR_NONCE) == 0) {
/* Values in AEAD are pretty fixed in TLS 1.2 for 128-bit block
*/
if (unlikely(params->read.iv_size != 4))
return gnutls_assert_val(GNUTLS_E_UNWANTED_ALGORITHM);
e = cipher_to_entry(cipher);
- if (e == NULL || e->only_aead)
+ if (e == NULL || (e->flags & GNUTLS_CIPHER_FLAG_ONLY_AEAD))
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
*handle = gnutls_calloc(1, sizeof(api_cipher_hd_st));
else if (tag_size > (unsigned)_gnutls_cipher_get_tag_size(h->ctx_enc.e))
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
- if (handle->ctx_enc.e->only_aead || handle->ctx_enc.encrypt == NULL) {
+ if ((handle->ctx_enc.e->flags & GNUTLS_CIPHER_FLAG_ONLY_AEAD) || handle->ctx_enc.encrypt == NULL) {
/* ciphertext cannot be produced in a piecemeal approach */
struct iov_store_st auth;
struct iov_store_st ptext;
* AEAD ciphers. When an AEAD cipher is used registered with gnutls_crypto_register_aead_cipher(),
* then this becomes a convenience function as it missed the lower-level primitives
* necessary for piecemeal encryption. */
- if (handle->ctx_enc.e->only_aead || handle->ctx_enc.encrypt == NULL) {
+ if ((handle->ctx_enc.e->flags & GNUTLS_CIPHER_FLAG_ONLY_AEAD) || handle->ctx_enc.encrypt == NULL) {
/* ciphertext cannot be produced in a piecemeal approach */
struct iov_store_st auth;
struct iov_store_st ptext;
* AEAD ciphers. When an AEAD cipher is used registered with gnutls_crypto_register_aead_cipher(),
* then this becomes a convenience function as it missed the lower-level primitives
* necessary for piecemeal encryption. */
- if (handle->ctx_enc.e->only_aead || handle->ctx_enc.encrypt == NULL) {
+ if ((handle->ctx_enc.e->flags & GNUTLS_CIPHER_FLAG_ONLY_AEAD) || handle->ctx_enc.encrypt == NULL) {
/* ciphertext cannot be produced in a piecemeal approach */
struct iov_store_st auth;
struct iov_store_st ctext;
struct record_parameters_st;
typedef struct record_parameters_st record_parameters_st;
+#define GNUTLS_CIPHER_FLAG_ONLY_AEAD (1 << 0) /* When set, this cipher is only available through the new AEAD API */
+#define GNUTLS_CIPHER_FLAG_XOR_NONCE (1 << 1) /* In this TLS AEAD cipher xor the implicit_iv with the nonce */
+#define GNUTLS_CIPHER_FLAG_NO_REKEY (1 << 2) /* whether this tls1.3 cipher doesn't need to rekey after 2^24 messages */
+
/* cipher and mac parameters */
typedef struct cipher_entry_st {
const char *name;
uint16_t explicit_iv; /* the size of explicit IV - the IV stored in record */
uint16_t cipher_iv; /* the size of IV needed by the cipher */
uint16_t tagsize;
- bool xor_nonce; /* In this TLS AEAD cipher xor the implicit_iv with the nonce */
- bool only_aead; /* When set, this cipher is only available through the new AEAD API */
- bool no_rekey; /* whether this tls1.3 cipher doesn't need to rekey after 2^24 messages */
+ unsigned flags;
} cipher_entry_st;
typedef struct gnutls_cipher_suite_entry_st {
(int) cipher_size);
if (vers->tls13_sem && !(session->internals.flags & GNUTLS_NO_AUTO_REKEY) &&
- !(record_params->cipher->no_rekey)) {
+ !(record_params->cipher->flags & GNUTLS_CIPHER_FLAG_NO_REKEY)) {
if (unlikely(record_state->sequence_number.i[7] == 0xfd &&
record_state->sequence_number.i[6] == 0xff &&
record_state->sequence_number.i[5] == 0xff)) {