Skip to content

Commit d795cc0

Browse files
vvfedorenkokuba-moo
authored andcommitted
selftests/tls: fix selftest with CHACHA20-POLY1305
TLS selftests were broken also because of use of structure that was not exported to UAPI. Fix by defining the union in tests. Fixes: 4f336e8 (selftests/tls: add CHACHA20-POLY1305 to tls selftests) Reported-by: Rong Chen <rong.a.chen@intel.com> Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru> Link: https://lore.kernel.org/r/1612384634-5377-1-git-send-email-vfedorenko@novek.ru Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 2a80c15 commit d795cc0

File tree

1 file changed

+10
-5
lines changed
  • tools/testing/selftests/net

1 file changed

+10
-5
lines changed

tools/testing/selftests/net/tls.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ FIXTURE_VARIANT_ADD(tls, 13_chacha)
133133

134134
FIXTURE_SETUP(tls)
135135
{
136-
union tls_crypto_context tls12;
136+
union {
137+
struct tls12_crypto_info_aes_gcm_128 aes128;
138+
struct tls12_crypto_info_chacha20_poly1305 chacha20;
139+
} tls12;
137140
struct sockaddr_in addr;
138141
socklen_t len;
139142
int sfd, ret;
@@ -143,14 +146,16 @@ FIXTURE_SETUP(tls)
143146
len = sizeof(addr);
144147

145148
memset(&tls12, 0, sizeof(tls12));
146-
tls12.info.version = variant->tls_version;
147-
tls12.info.cipher_type = variant->cipher_type;
148149
switch (variant->cipher_type) {
149150
case TLS_CIPHER_CHACHA20_POLY1305:
150-
tls12_sz = sizeof(tls12_crypto_info_chacha20_poly1305);
151+
tls12_sz = sizeof(struct tls12_crypto_info_chacha20_poly1305);
152+
tls12.chacha20.info.version = variant->tls_version;
153+
tls12.chacha20.info.cipher_type = variant->cipher_type;
151154
break;
152155
case TLS_CIPHER_AES_GCM_128:
153-
tls12_sz = sizeof(tls12_crypto_info_aes_gcm_128);
156+
tls12_sz = sizeof(struct tls12_crypto_info_aes_gcm_128);
157+
tls12.aes128.info.version = variant->tls_version;
158+
tls12.aes128.info.cipher_type = variant->cipher_type;
154159
break;
155160
default:
156161
tls12_sz = 0;

0 commit comments

Comments
 (0)