History

selftests: tls: test some invalid inputs for setsockopt

This test will need to be updated if new ciphers are added.

Sabrina Dubroca committed 3 years ago

Commit 4bfb6221 parent f27ad621 file · +25 −0Browse files

Unified · Split

tools/testing/selftests/net/tls.c+25−0
@@ -241,6 +241,31 @@ TEST_F(tls_basic, base_base) · 240 unmodified lines
241 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);241 EXPECT_EQ(memcmp(buf, test_str, send_len), 0);
242};242};
243 243
244TEST_F(tls_basic, bad_cipher)
245{
246 struct tls_crypto_info_keys tls12;
247
248 tls12.crypto_info.version = 200;
249 tls12.crypto_info.cipher_type = TLS_CIPHER_AES_GCM_128;
250 EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1);
251
252 tls12.crypto_info.version = TLS_1_2_VERSION;
253 tls12.crypto_info.cipher_type = 50;
254 EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1);
255
256 tls12.crypto_info.version = TLS_1_2_VERSION;
257 tls12.crypto_info.cipher_type = 59;
258 EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1);
259
260 tls12.crypto_info.version = TLS_1_2_VERSION;
261 tls12.crypto_info.cipher_type = 10;
262 EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1);
263
264 tls12.crypto_info.version = TLS_1_2_VERSION;
265 tls12.crypto_info.cipher_type = 70;
266 EXPECT_EQ(setsockopt(self->fd, SOL_TLS, TLS_TX, &tls12, sizeof(struct tls12_crypto_info_aes_gcm_128)), -1);
267}
268
244FIXTURE(tls)269FIXTURE(tls)
245{270{
246 int fd, cfd;271 int fd, cfd;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t