Skip to content

Commit 35f6e42

Browse files
committed
SUNRPC: Add KDF KUnit tests for the RFC 6803 encryption types
The Camellia enctypes use a new KDF, so add some tests to ensure it is working properly. Tested-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent e1a9a38 commit 35f6e42

2 files changed

Lines changed: 127 additions & 1 deletion

File tree

net/sunrpc/.kunitconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ CONFIG_CRYPTO_CBC=y
1111
CONFIG_CRYPTO_CTS=y
1212
CONFIG_CRYPTO_ECB=y
1313
CONFIG_CRYPTO_HMAC=y
14+
CONFIG_CRYPTO_CMAC=y
1415
CONFIG_CRYPTO_MD5=y
1516
CONFIG_CRYPTO_SHA1=y
1617
CONFIG_CRYPTO_DES=y
1718
CONFIG_CRYPTO_AES=y
19+
CONFIG_CRYPTO_CAMELLIA=y
1820
CONFIG_NFS_FS=y
1921
CONFIG_SUNRPC=y
2022
CONFIG_SUNRPC_GSS=y
2123
CONFIG_RPCSEC_GSS_KRB5=y
2224
CONFIG_RPCSEC_GSS_KRB5_ENCTYPES_DES=y
2325
CONFIG_RPCSEC_GSS_KRB5_ENCTYPES_AES_SHA1=y
26+
CONFIG_RPCSEC_GSS_KRB5_ENCTYPES_CAMELLIA=y
2427
CONFIG_RPCSEC_GSS_KRB5_KUNIT_TEST=y

net/sunrpc/auth_gss/gss_krb5_test.c

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,131 @@ static struct kunit_suite rfc3962_suite = {
727727
.test_cases = rfc3962_test_cases,
728728
};
729729

730+
/*
731+
* From RFC 6803 Section 10. Test vectors
732+
*
733+
* Sample results for key derivation
734+
*
735+
* Copyright (c) 2012 IETF Trust and the persons identified as the
736+
* document authors. All rights reserved.
737+
*/
738+
739+
DEFINE_HEX_XDR_NETOBJ(camellia128_cts_cmac_basekey,
740+
0x57, 0xd0, 0x29, 0x72, 0x98, 0xff, 0xd9, 0xd3,
741+
0x5d, 0xe5, 0xa4, 0x7f, 0xb4, 0xbd, 0xe2, 0x4b
742+
);
743+
DEFINE_HEX_XDR_NETOBJ(camellia128_cts_cmac_Kc,
744+
0xd1, 0x55, 0x77, 0x5a, 0x20, 0x9d, 0x05, 0xf0,
745+
0x2b, 0x38, 0xd4, 0x2a, 0x38, 0x9e, 0x5a, 0x56
746+
);
747+
DEFINE_HEX_XDR_NETOBJ(camellia128_cts_cmac_Ke,
748+
0x64, 0xdf, 0x83, 0xf8, 0x5a, 0x53, 0x2f, 0x17,
749+
0x57, 0x7d, 0x8c, 0x37, 0x03, 0x57, 0x96, 0xab
750+
);
751+
DEFINE_HEX_XDR_NETOBJ(camellia128_cts_cmac_Ki,
752+
0x3e, 0x4f, 0xbd, 0xf3, 0x0f, 0xb8, 0x25, 0x9c,
753+
0x42, 0x5c, 0xb6, 0xc9, 0x6f, 0x1f, 0x46, 0x35
754+
);
755+
756+
DEFINE_HEX_XDR_NETOBJ(camellia256_cts_cmac_basekey,
757+
0xb9, 0xd6, 0x82, 0x8b, 0x20, 0x56, 0xb7, 0xbe,
758+
0x65, 0x6d, 0x88, 0xa1, 0x23, 0xb1, 0xfa, 0xc6,
759+
0x82, 0x14, 0xac, 0x2b, 0x72, 0x7e, 0xcf, 0x5f,
760+
0x69, 0xaf, 0xe0, 0xc4, 0xdf, 0x2a, 0x6d, 0x2c
761+
);
762+
DEFINE_HEX_XDR_NETOBJ(camellia256_cts_cmac_Kc,
763+
0xe4, 0x67, 0xf9, 0xa9, 0x55, 0x2b, 0xc7, 0xd3,
764+
0x15, 0x5a, 0x62, 0x20, 0xaf, 0x9c, 0x19, 0x22,
765+
0x0e, 0xee, 0xd4, 0xff, 0x78, 0xb0, 0xd1, 0xe6,
766+
0xa1, 0x54, 0x49, 0x91, 0x46, 0x1a, 0x9e, 0x50
767+
);
768+
DEFINE_HEX_XDR_NETOBJ(camellia256_cts_cmac_Ke,
769+
0x41, 0x2a, 0xef, 0xc3, 0x62, 0xa7, 0x28, 0x5f,
770+
0xc3, 0x96, 0x6c, 0x6a, 0x51, 0x81, 0xe7, 0x60,
771+
0x5a, 0xe6, 0x75, 0x23, 0x5b, 0x6d, 0x54, 0x9f,
772+
0xbf, 0xc9, 0xab, 0x66, 0x30, 0xa4, 0xc6, 0x04
773+
);
774+
DEFINE_HEX_XDR_NETOBJ(camellia256_cts_cmac_Ki,
775+
0xfa, 0x62, 0x4f, 0xa0, 0xe5, 0x23, 0x99, 0x3f,
776+
0xa3, 0x88, 0xae, 0xfd, 0xc6, 0x7e, 0x67, 0xeb,
777+
0xcd, 0x8c, 0x08, 0xe8, 0xa0, 0x24, 0x6b, 0x1d,
778+
0x73, 0xb0, 0xd1, 0xdd, 0x9f, 0xc5, 0x82, 0xb0
779+
);
780+
781+
DEFINE_HEX_XDR_NETOBJ(usage_checksum,
782+
0x00, 0x00, 0x00, 0x02, KEY_USAGE_SEED_CHECKSUM
783+
);
784+
DEFINE_HEX_XDR_NETOBJ(usage_encryption,
785+
0x00, 0x00, 0x00, 0x02, KEY_USAGE_SEED_ENCRYPTION
786+
);
787+
DEFINE_HEX_XDR_NETOBJ(usage_integrity,
788+
0x00, 0x00, 0x00, 0x02, KEY_USAGE_SEED_INTEGRITY
789+
);
790+
791+
static const struct gss_krb5_test_param rfc6803_kdf_test_params[] = {
792+
{
793+
.desc = "Derive Kc subkey for camellia128-cts-cmac",
794+
.enctype = ENCTYPE_CAMELLIA128_CTS_CMAC,
795+
.base_key = &camellia128_cts_cmac_basekey,
796+
.usage = &usage_checksum,
797+
.expected_result = &camellia128_cts_cmac_Kc,
798+
},
799+
{
800+
.desc = "Derive Ke subkey for camellia128-cts-cmac",
801+
.enctype = ENCTYPE_CAMELLIA128_CTS_CMAC,
802+
.base_key = &camellia128_cts_cmac_basekey,
803+
.usage = &usage_encryption,
804+
.expected_result = &camellia128_cts_cmac_Ke,
805+
},
806+
{
807+
.desc = "Derive Ki subkey for camellia128-cts-cmac",
808+
.enctype = ENCTYPE_CAMELLIA128_CTS_CMAC,
809+
.base_key = &camellia128_cts_cmac_basekey,
810+
.usage = &usage_integrity,
811+
.expected_result = &camellia128_cts_cmac_Ki,
812+
},
813+
{
814+
.desc = "Derive Kc subkey for camellia256-cts-cmac",
815+
.enctype = ENCTYPE_CAMELLIA256_CTS_CMAC,
816+
.base_key = &camellia256_cts_cmac_basekey,
817+
.usage = &usage_checksum,
818+
.expected_result = &camellia256_cts_cmac_Kc,
819+
},
820+
{
821+
.desc = "Derive Ke subkey for camellia256-cts-cmac",
822+
.enctype = ENCTYPE_CAMELLIA256_CTS_CMAC,
823+
.base_key = &camellia256_cts_cmac_basekey,
824+
.usage = &usage_encryption,
825+
.expected_result = &camellia256_cts_cmac_Ke,
826+
},
827+
{
828+
.desc = "Derive Ki subkey for camellia256-cts-cmac",
829+
.enctype = ENCTYPE_CAMELLIA256_CTS_CMAC,
830+
.base_key = &camellia256_cts_cmac_basekey,
831+
.usage = &usage_integrity,
832+
.expected_result = &camellia256_cts_cmac_Ki,
833+
},
834+
};
835+
836+
/* Creates the function rfc6803_kdf_gen_params */
837+
KUNIT_ARRAY_PARAM(rfc6803_kdf, rfc6803_kdf_test_params, gss_krb5_get_desc);
838+
839+
static struct kunit_case rfc6803_test_cases[] = {
840+
{
841+
.name = "RFC 6803 key derivation",
842+
.run_case = kdf_case,
843+
.generate_params = rfc6803_kdf_gen_params,
844+
},
845+
};
846+
847+
static struct kunit_suite rfc6803_suite = {
848+
.name = "RFC 6803 suite",
849+
.test_cases = rfc6803_test_cases,
850+
};
851+
730852
kunit_test_suites(&rfc3961_suite,
731-
&rfc3962_suite);
853+
&rfc3962_suite,
854+
&rfc6803_suite);
732855

733856
MODULE_DESCRIPTION("Test RPCSEC GSS Kerberos 5 functions");
734857
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)