From nobody Tue Nov 23 23:13:07 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B367618A229B; Tue, 23 Nov 2021 23:13:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HzKgS6gJnz3vsj; Tue, 23 Nov 2021 23:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 122981F726; Tue, 23 Nov 2021 23:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1ANND72e037989; Tue, 23 Nov 2021 23:13:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ANND7Mk037988; Tue, 23 Nov 2021 23:13:07 GMT (envelope-from git) Date: Tue, 23 Nov 2021 23:13:07 GMT Message-Id: <202111232313.1ANND7Mk037988@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 32993b8e581c - stable/13 - ktls: Add tests ensuring various invalid cipher suites are rejected. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 32993b8e581c9c92a9ff81fa7b5d5e3f2c1018f4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637709189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bBYyiktHqGc3OXtRH7qAY3bhYSO0cAXwbyJ0E0ToKLE=; b=SwAmMiSjTeQKTbX5Cr+TMUq2IM+w3hPrTNJXFF8J1K+FMNt2xalhUqEWU2rKVO19aoepld rezVMppL8UGDLBjGM+aFUSxVm+s4AAbL6VrZ9yV42gINiZm7F1msO7uvXTDIkHY3rAoIQ8 7HDgsGa7nFuBQ3LynV9ZGb5WVzMe6W4k2qXOc+jkNKSMKNdLGdWXAnJtmcIyKoOIRqfz4i 1AzgiOCsdTjIdWdbggFaF3xv1M+1k41Amfhfa4caKfCf2SnRDCPIKnk9ulBgVX1Kbp7OHm GeXmszC1XK+ew3S1vb4Lyoo2FNyu63jJIvdL1Lv+Yq6dl9EnQHW8ZtexR6eFbw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637709189; a=rsa-sha256; cv=none; b=SOLTAtdHJLoIhVDaiIt8vaeA7R7qi2WAzt+CpHKJ1UMLkeFjfsFcBTENusXSeCxzNIA93I b4q9uHAz96Ik324hdZxw2RVJP1BRWHzmKQ5IyeaZpKYxMrFoMTWBOdlXpS3NV4SKNS18cM /tR0eSIfCkhioImqiUmMS2K6Yln8/Lbs45gazUxRsuX8gsk7HSqtfN1B/1VxU0ok4esOP3 nFLz0wr0Icr2bsoohlp/vhgwNYTRDNP2J1tbav1qMI85sqUG+W+SXEuE5K4ZQp1KJp7Ijs zjdDhUvl77s2/WaF015jgQl+rlVvxFfdc4TQ/0jtHaF3PNOn0mtgpYb8OlZTZw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=32993b8e581c9c92a9ff81fa7b5d5e3f2c1018f4 commit 32993b8e581c9c92a9ff81fa7b5d5e3f2c1018f4 Author: John Baldwin AuthorDate: 2021-11-15 19:30:48 +0000 Commit: John Baldwin CommitDate: 2021-11-23 23:11:53 +0000 ktls: Add tests ensuring various invalid cipher suites are rejected. Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D32843 (cherry picked from commit d1c369f926e7d04354d044cc13d8ecfb3e325636) --- tests/sys/kern/ktls_test.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/sys/kern/ktls_test.c b/tests/sys/kern/ktls_test.c index 423ccf65cb0c..ef0f7405b3fd 100644 --- a/tests/sys/kern/ktls_test.c +++ b/tests/sys/kern/ktls_test.c @@ -1187,6 +1187,70 @@ AES_CBC_TESTS(GEN_TRANSMIT_PADDING_TESTS); */ TLS_10_TESTS(GEN_TRANSMIT_EMPTY_FRAGMENT_TEST); +static void +test_ktls_invalid_transmit_cipher_suite(struct tls_enable *en) +{ + int sockets[2]; + + ATF_REQUIRE_MSG(socketpair_tcp(sockets), "failed to create sockets"); + + ATF_REQUIRE(setsockopt(sockets[1], IPPROTO_TCP, TCP_TXTLS_ENABLE, en, + sizeof(*en)) == -1); + ATF_REQUIRE(errno == EINVAL); + + close(sockets[1]); + close(sockets[0]); +} + +#define GEN_INVALID_TRANSMIT_TEST(name, cipher_alg, key_size, auth_alg, \ + minor) \ +ATF_TC_WITHOUT_HEAD(ktls_transmit_invalid_##name); \ +ATF_TC_BODY(ktls_transmit_invalid_##name, tc) \ +{ \ + struct tls_enable en; \ + uint64_t seqno; \ + \ + ATF_REQUIRE_KTLS(); \ + seqno = random(); \ + build_tls_enable(cipher_alg, key_size, auth_alg, minor, seqno, \ + &en); \ + test_ktls_invalid_transmit_cipher_suite(&en); \ + free_tls_enable(&en); \ +} + +#define ADD_INVALID_TRANSMIT_TEST(name, cipher_alg, key_size, auth_alg, \ + minor) \ + ATF_TP_ADD_TC(tp, ktls_transmit_invalid_##name); + +#define INVALID_CIPHER_SUITES(M) \ + M(aes128_cbc_1_0_sha256, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_256_HMAC, TLS_MINOR_VER_ZERO) \ + M(aes128_cbc_1_0_sha384, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_384_HMAC, TLS_MINOR_VER_ZERO) \ + M(aes128_gcm_1_0, CRYPTO_AES_NIST_GCM_16, 128 / 8, 0, \ + TLS_MINOR_VER_ZERO) \ + M(chacha20_poly1305_1_0, CRYPTO_CHACHA20_POLY1305, 256 / 8, 0, \ + TLS_MINOR_VER_ZERO) \ + M(aes128_cbc_1_1_sha256, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_256_HMAC, TLS_MINOR_VER_ONE) \ + M(aes128_cbc_1_1_sha384, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_384_HMAC, TLS_MINOR_VER_ONE) \ + M(aes128_gcm_1_1, CRYPTO_AES_NIST_GCM_16, 128 / 8, 0, \ + TLS_MINOR_VER_ONE) \ + M(chacha20_poly1305_1_1, CRYPTO_CHACHA20_POLY1305, 256 / 8, 0, \ + TLS_MINOR_VER_ONE) \ + M(aes128_cbc_1_3_sha1, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA1_HMAC, TLS_MINOR_VER_THREE) \ + M(aes128_cbc_1_3_sha256, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_256_HMAC, TLS_MINOR_VER_THREE) \ + M(aes128_cbc_1_3_sha384, CRYPTO_AES_CBC, 128 / 8, \ + CRYPTO_SHA2_384_HMAC, TLS_MINOR_VER_THREE) + +/* + * Ensure that invalid cipher suites are rejected for transmit. + */ +INVALID_CIPHER_SUITES(GEN_INVALID_TRANSMIT_TEST); + ATF_TP_ADD_TCS(tp) { AES_CBC_TESTS(ADD_TRANSMIT_TESTS); @@ -1194,6 +1258,7 @@ ATF_TP_ADD_TCS(tp) CHACHA20_TESTS(ADD_TRANSMIT_TESTS); AES_CBC_TESTS(ADD_TRANSMIT_PADDING_TESTS); TLS_10_TESTS(ADD_TRANSMIT_EMPTY_FRAGMENT_TEST); + INVALID_CIPHER_SUITES(ADD_INVALID_TRANSMIT_TEST); return (atf_no_error()); }