Skip to content

Commit 003caf4

Browse files
committed
SUNRPC: Add RFC 8009 checksum KUnit tests
RFC 8009 provides sample checksum results. Add KUnit tests to ensure our implementation derives the expected results for the provided sample input. Tested-by: Scott Mayhew <[email protected]> Reviewed-by: Simo Sorce <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent fcbad14 commit 003caf4

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

net/sunrpc/auth_gss/gss_krb5_test.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,12 +1514,65 @@ static const struct gss_krb5_test_param rfc8009_kdf_test_params[] = {
15141514
/* Creates the function rfc8009_kdf_gen_params */
15151515
KUNIT_ARRAY_PARAM(rfc8009_kdf, rfc8009_kdf_test_params, gss_krb5_get_desc);
15161516

1517+
/*
1518+
* From RFC 8009 Appendix A. Test Vectors
1519+
*
1520+
* These sample checksums use the above sample key derivation results,
1521+
* including use of the same base-key and key usage values.
1522+
*
1523+
* This test material is copyright (c) 2016 IETF Trust and the
1524+
* persons identified as the document authors. All rights reserved.
1525+
*/
1526+
1527+
DEFINE_HEX_XDR_NETOBJ(rfc8009_checksum_plaintext,
1528+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1529+
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1530+
0x10, 0x11, 0x12, 0x13, 0x14
1531+
);
1532+
DEFINE_HEX_XDR_NETOBJ(rfc8009_checksum_test1_expected_result,
1533+
0xd7, 0x83, 0x67, 0x18, 0x66, 0x43, 0xd6, 0x7b,
1534+
0x41, 0x1c, 0xba, 0x91, 0x39, 0xfc, 0x1d, 0xee
1535+
);
1536+
DEFINE_HEX_XDR_NETOBJ(rfc8009_checksum_test2_expected_result,
1537+
0x45, 0xee, 0x79, 0x15, 0x67, 0xee, 0xfc, 0xa3,
1538+
0x7f, 0x4a, 0xc1, 0xe0, 0x22, 0x2d, 0xe8, 0x0d,
1539+
0x43, 0xc3, 0xbf, 0xa0, 0x66, 0x99, 0x67, 0x2a
1540+
);
1541+
1542+
static const struct gss_krb5_test_param rfc8009_checksum_test_params[] = {
1543+
{
1544+
.desc = "Checksum with aes128-cts-hmac-sha256-128",
1545+
.enctype = ENCTYPE_AES128_CTS_HMAC_SHA256_128,
1546+
.base_key = &aes128_cts_hmac_sha256_128_basekey,
1547+
.usage = &usage_checksum,
1548+
.plaintext = &rfc8009_checksum_plaintext,
1549+
.expected_result = &rfc8009_checksum_test1_expected_result,
1550+
},
1551+
{
1552+
.desc = "Checksum with aes256-cts-hmac-sha384-192",
1553+
.enctype = ENCTYPE_AES256_CTS_HMAC_SHA384_192,
1554+
.base_key = &aes256_cts_hmac_sha384_192_basekey,
1555+
.usage = &usage_checksum,
1556+
.plaintext = &rfc8009_checksum_plaintext,
1557+
.expected_result = &rfc8009_checksum_test2_expected_result,
1558+
},
1559+
};
1560+
1561+
/* Creates the function rfc8009_checksum_gen_params */
1562+
KUNIT_ARRAY_PARAM(rfc8009_checksum, rfc8009_checksum_test_params,
1563+
gss_krb5_get_desc);
1564+
15171565
static struct kunit_case rfc8009_test_cases[] = {
15181566
{
15191567
.name = "RFC 8009 key derivation",
15201568
.run_case = kdf_case,
15211569
.generate_params = rfc8009_kdf_gen_params,
15221570
},
1571+
{
1572+
.name = "RFC 8009 checksum",
1573+
.run_case = checksum_case,
1574+
.generate_params = rfc8009_checksum_gen_params,
1575+
},
15231576
};
15241577

15251578
static struct kunit_suite rfc8009_suite = {

0 commit comments

Comments
 (0)