Skip to content

Commit

Permalink
Rename aead-tag-at-end to aead-epoch
Browse files Browse the repository at this point in the history
Change-Id: I9e9433b56dcbaa538d9bed30e50cf74948c647cc
Signed-off-by: Arne Schwabe <[email protected]>
  • Loading branch information
schwabe committed Oct 17, 2024
1 parent 0fca20e commit 34aaafd
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/openvpn/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ openvpn_encrypt_aead(struct buffer *buf, struct buffer work,
dmsg(D_PACKET_CONTENT, "ENCRYPT AD: %s",
format_hex(BPTR(&work), BLEN(&work), 0, &gc));

if (!(opt->flags & CO_AEAD_TAG_AT_THE_END))
if (!(opt->flags & CO_EPOCH_DATA_KEY_FORMAT))
{
/* Reserve space for authentication tag */
mac_out = buf_write_alloc(&work, mac_len);
Expand All @@ -149,7 +149,7 @@ openvpn_encrypt_aead(struct buffer *buf, struct buffer work,
ASSERT(buf_inc_len(&work, outlen));

/* if the tag is at end the end, allocate it now */
if (opt->flags & CO_AEAD_TAG_AT_THE_END)
if (opt->flags & CO_EPOCH_DATA_KEY_FORMAT)
{
/* Reserve space for authentication tag */
mac_out = buf_write_alloc(&work, mac_len);
Expand Down Expand Up @@ -475,7 +475,7 @@ openvpn_decrypt_aead(struct buffer *buf, struct buffer work,
uint8_t *tag_ptr = NULL;
int data_len = 0;

if (opt->flags & CO_AEAD_TAG_AT_THE_END)
if (opt->flags & CO_EPOCH_DATA_KEY_FORMAT)
{
data_len = BLEN(buf) - tag_size;
tag_ptr = BPTR(buf) + data_len;
Expand Down
7 changes: 4 additions & 3 deletions src/openvpn/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,10 @@ struct crypto_options
/**< Bit-flag indicating that renegotiations are using tls-crypt
* with a TLS-EKM derived key.
*/
#define CO_AEAD_TAG_AT_THE_END (1<<8)
/**< Bit-flag indicating that the AEAD tag is at the end of the
* packet.
#define CO_EPOCH_DATA_KEY_FORMAT (1<<8)
/**< Bit-flag indicating that the data format using
* AEAD tag is at the end of the packet and using epoch
* keys is used.
*/

unsigned int flags; /**< Bit-flags determining behavior of
Expand Down
4 changes: 2 additions & 2 deletions src/openvpn/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2392,9 +2392,9 @@ tls_print_deferred_options_results(struct context *c)
{
buf_printf(&out, " dyn-tls-crypt");
}
if (o->imported_protocol_flags & CO_AEAD_TAG_AT_THE_END)
if (o->imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT)
{
buf_printf(&out, " aead-tag-end");
buf_printf(&out, " aead-epoch");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/openvpn/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -8719,9 +8719,9 @@ add_option(struct options *options,
options->imported_protocol_flags |= CO_USE_DYNAMIC_TLS_CRYPT;
}
#endif
else if (streq(p[j], "aead-tag-end"))
else if (streq(p[j], "aead-epoch"))
{
options->imported_protocol_flags |= CO_AEAD_TAG_AT_THE_END;
options->imported_protocol_flags |= CO_EPOCH_DATA_KEY_FORMAT;
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/openvpn/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,9 @@ prepare_push_reply(struct context *c, struct gc_arena *gc,
buf_printf(&proto_flags, " dyn-tls-crypt");
}

if (o->imported_protocol_flags & CO_AEAD_TAG_AT_THE_END)
if (o->imported_protocol_flags & CO_EPOCH_DATA_KEY_FORMAT)
{
buf_printf(&proto_flags, " aead-tag-end");
buf_printf(&proto_flags, " aead-epoch");
}

if (buf_len(&proto_flags) > 0)
Expand Down
3 changes: 3 additions & 0 deletions src/openvpn/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
/** Support to dynamic tls-crypt (renegotiation with TLS-EKM derived tls-crypt key) */
#define IV_PROTO_DYN_TLS_CRYPT (1<<9)

/** Support the extended packet id and epoch format for data channel packets */
#define IV_PROTO_DATA_EPOCH (1<<10)

/** Supports the --dns option after all the incompatible changes */
#define IV_PROTO_DNS_OPTION_V2 (1<<11)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/openvpn/test_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static void
run_data_channel_with_cipher_end(const char *cipher)
{
struct crypto_options co = init_crypto_options(cipher, "none");
co.flags |= CO_AEAD_TAG_AT_THE_END;
co.flags |= CO_EPOCH_DATA_KEY_FORMAT;
do_data_channel_round_trip(&co);
uninit_crypto_options(&co);
}
Expand Down

0 comments on commit 34aaafd

Please sign in to comment.