aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2019-03-20 02:43:20 -0700
committerDamjan Marion <dmarion@me.com>2019-03-22 17:32:25 +0000
commit063dfa1587a58319fac139eab5e655ad1c555e33 (patch)
tree53c704e5e382842dcc037025b6814ba084c0c831
parent831d23866ab1010a7d7343aa1df024c8b65790b9 (diff)
crypto: implement rfc4231 test cases
Change-Id: I540241672a20f687d20bb70adbf2b33200f34167 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
-rw-r--r--src/plugins/unittest/crypto/crypto.h1
-rw-r--r--src/plugins/unittest/crypto/rfc2202_hmac_sha1.c16
-rw-r--r--src/plugins/unittest/crypto/rfc4231.c404
-rw-r--r--src/plugins/unittest/crypto_test.c3
4 files changed, 422 insertions, 2 deletions
diff --git a/src/plugins/unittest/crypto/crypto.h b/src/plugins/unittest/crypto/crypto.h
index fe6e7f2831c..1945c69fd4c 100644
--- a/src/plugins/unittest/crypto/crypto.h
+++ b/src/plugins/unittest/crypto/crypto.h
@@ -29,6 +29,7 @@ typedef struct unittest_crypto_test_registration
vnet_crypto_alg_t alg:8;
vnet_crypto_op_type_t op:8;
unittest_crypto_test_data_t iv, key, data, expected;
+ u8 hmac_trunc_len;
/* next */
struct unittest_crypto_test_registration *next;
diff --git a/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c b/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c
index 94ab03ca657..13505218891 100644
--- a/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c
+++ b/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c
@@ -152,6 +152,22 @@ UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc5) = {
};
/* *INDENT-ON* */
+static u8 sha1_tc5_digest_96[12] = {
+ 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f,
+ 0xe7, 0xf2, 0x7b, 0xe1
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc5_trunc) = {
+ .name = "RFC2202 HMAC-SHA-1-96 TC5-trunc",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc5_key),
+ .data = TEST_DATA (sha1_tc5_data),
+ .expected = TEST_DATA (sha1_tc5_digest_96),
+ .hmac_trunc_len = 12,
+};
+/* *INDENT-ON* */
+
static u8 sha1_tc6_key[80] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
diff --git a/src/plugins/unittest/crypto/rfc4231.c b/src/plugins/unittest/crypto/rfc4231.c
index 88a3debbe1e..4943e7d647d 100644
--- a/src/plugins/unittest/crypto/rfc4231.c
+++ b/src/plugins/unittest/crypto/rfc4231.c
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-/* Test vectors published in RFC2202 */
+/* Test vectors published in RFC4231 */
#include <vppinfra/clib.h>
#include <vnet/crypto/crypto.h>
@@ -95,6 +95,408 @@ UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc1_sha512) = {
};
/* *INDENT-ON* */
+static char tc2_key[4] = "Jefe";
+
+static char tc2_data[28] = "what do ya want for nothing?";
+
+static u8 tc2_digest_sha224[] = {
+ 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
+ 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
+ 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00,
+ 0x8f, 0xd0, 0x5e, 0x44
+};
+
+static u8 tc2_digest_sha256[] = {
+ 0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e,
+ 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7,
+ 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83,
+ 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43,
+};
+
+static u8 tc2_digest_sha384[] = {
+ 0xaf, 0x45, 0xd2, 0xe3, 0x76, 0x48, 0x40, 0x31,
+ 0x61, 0x7f, 0x78, 0xd2, 0xb5, 0x8a, 0x6b, 0x1b,
+ 0x9c, 0x7e, 0xf4, 0x64, 0xf5, 0xa0, 0x1b, 0x47,
+ 0xe4, 0x2e, 0xc3, 0x73, 0x63, 0x22, 0x44, 0x5e,
+ 0x8e, 0x22, 0x40, 0xca, 0x5e, 0x69, 0xe2, 0xc7,
+ 0x8b, 0x32, 0x39, 0xec, 0xfa, 0xb2, 0x16, 0x49,
+};
+
+static u8 tc2_digest_sha512[] = {
+ 0x16, 0x4b, 0x7a, 0x7b, 0xfc, 0xf8, 0x19, 0xe2,
+ 0xe3, 0x95, 0xfb, 0xe7, 0x3b, 0x56, 0xe0, 0xa3,
+ 0x87, 0xbd, 0x64, 0x22, 0x2e, 0x83, 0x1f, 0xd6,
+ 0x10, 0x27, 0x0c, 0xd7, 0xea, 0x25, 0x05, 0x54,
+ 0x97, 0x58, 0xbf, 0x75, 0xc0, 0x5a, 0x99, 0x4a,
+ 0x6d, 0x03, 0x4f, 0x65, 0xf8, 0xf0, 0xe6, 0xfd,
+ 0xca, 0xea, 0xb1, 0xa3, 0x4d, 0x4a, 0x6b, 0x4b,
+ 0x63, 0x6e, 0x07, 0x0a, 0x38, 0xbc, 0xe7, 0x37,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc2_sha224) = {
+ .name = "RFC4231 TC2",
+ .op = VNET_CRYPTO_OP_SHA224_HMAC,
+ .key = TEST_DATA (tc2_key),
+ .data = TEST_DATA (tc2_data),
+ .expected = TEST_DATA (tc2_digest_sha224),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc2_sha256) = {
+ .name = "RFC4231 TC2",
+ .op = VNET_CRYPTO_OP_SHA256_HMAC,
+ .key = TEST_DATA (tc2_key),
+ .data = TEST_DATA (tc2_data),
+ .expected = TEST_DATA (tc2_digest_sha256),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc2_sha384) = {
+ .name = "RFC4231 TC2",
+ .op = VNET_CRYPTO_OP_SHA384_HMAC,
+ .key = TEST_DATA (tc2_key),
+ .data = TEST_DATA (tc2_data),
+ .expected = TEST_DATA (tc2_digest_sha384),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc2_sha512) = {
+ .name = "RFC4231 TC2",
+ .op = VNET_CRYPTO_OP_SHA512_HMAC,
+ .key = TEST_DATA (tc2_key),
+ .data = TEST_DATA (tc2_data),
+ .expected = TEST_DATA (tc2_digest_sha512),
+};
+/* *INDENT-ON* */
+
+static u8 tc3_key[20] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa
+};
+
+static u8 tc3_data[50] = {
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
+ 0xdd, 0xdd,
+};
+
+static u8 tc3_digest_sha224[] = {
+ 0x7f, 0xb3, 0xcb, 0x35, 0x88, 0xc6, 0xc1, 0xf6,
+ 0xff, 0xa9, 0x69, 0x4d, 0x7d, 0x6a, 0xd2, 0x64,
+ 0x93, 0x65, 0xb0, 0xc1, 0xf6, 0x5d, 0x69, 0xd1,
+ 0xec, 0x83, 0x33, 0xea
+};
+
+static u8 tc3_digest_sha256[] = {
+ 0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46,
+ 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7,
+ 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22,
+ 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe
+};
+
+static u8 tc3_digest_sha384[] = {
+ 0x88, 0x06, 0x26, 0x08, 0xd3, 0xe6, 0xad, 0x8a,
+ 0x0a, 0xa2, 0xac, 0xe0, 0x14, 0xc8, 0xa8, 0x6f,
+ 0x0a, 0xa6, 0x35, 0xd9, 0x47, 0xac, 0x9f, 0xeb,
+ 0xe8, 0x3e, 0xf4, 0xe5, 0x59, 0x66, 0x14, 0x4b,
+ 0x2a, 0x5a, 0xb3, 0x9d, 0xc1, 0x38, 0x14, 0xb9,
+ 0x4e, 0x3a, 0xb6, 0xe1, 0x01, 0xa3, 0x4f, 0x27
+};
+
+static u8 tc3_digest_sha512[] = {
+ 0xfa, 0x73, 0xb0, 0x08, 0x9d, 0x56, 0xa2, 0x84,
+ 0xef, 0xb0, 0xf0, 0x75, 0x6c, 0x89, 0x0b, 0xe9,
+ 0xb1, 0xb5, 0xdb, 0xdd, 0x8e, 0xe8, 0x1a, 0x36,
+ 0x55, 0xf8, 0x3e, 0x33, 0xb2, 0x27, 0x9d, 0x39,
+ 0xbf, 0x3e, 0x84, 0x82, 0x79, 0xa7, 0x22, 0xc8,
+ 0x06, 0xb4, 0x85, 0xa4, 0x7e, 0x67, 0xc8, 0x07,
+ 0xb9, 0x46, 0xa3, 0x37, 0xbe, 0xe8, 0x94, 0x26,
+ 0x74, 0x27, 0x88, 0x59, 0xe1, 0x32, 0x92, 0xfb
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc3_sha224) = {
+ .name = "RFC4231 TC3",
+ .op = VNET_CRYPTO_OP_SHA224_HMAC,
+ .key = TEST_DATA (tc3_key),
+ .data = TEST_DATA (tc3_data),
+ .expected = TEST_DATA (tc3_digest_sha224),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc3_sha256) = {
+ .name = "RFC4231 TC3",
+ .op = VNET_CRYPTO_OP_SHA256_HMAC,
+ .key = TEST_DATA (tc3_key),
+ .data = TEST_DATA (tc3_data),
+ .expected = TEST_DATA (tc3_digest_sha256),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc3_sha384) = {
+ .name = "RFC4231 TC3",
+ .op = VNET_CRYPTO_OP_SHA384_HMAC,
+ .key = TEST_DATA (tc3_key),
+ .data = TEST_DATA (tc3_data),
+ .expected = TEST_DATA (tc3_digest_sha384),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc3_sha512) = {
+ .name = "RFC4231 TC3",
+ .op = VNET_CRYPTO_OP_SHA512_HMAC,
+ .key = TEST_DATA (tc3_key),
+ .data = TEST_DATA (tc3_data),
+ .expected = TEST_DATA (tc3_digest_sha512),
+};
+/* *INDENT-ON* */
+
+static u8 tc4_key[25] = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+ 0x19
+};
+
+static u8 tc4_data[50] = {
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
+ 0xcd, 0xcd
+};
+
+static u8 tc4_digest_sha224[] = {
+ 0x6c, 0x11, 0x50, 0x68, 0x74, 0x01, 0x3c, 0xac,
+ 0x6a, 0x2a, 0xbc, 0x1b, 0xb3, 0x82, 0x62, 0x7c,
+ 0xec, 0x6a, 0x90, 0xd8, 0x6e, 0xfc, 0x01, 0x2d,
+ 0xe7, 0xaf, 0xec, 0x5a
+};
+
+static u8 tc4_digest_sha256[] = {
+ 0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e,
+ 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a,
+ 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07,
+ 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b
+};
+
+static u8 tc4_digest_sha384[] = {
+ 0x3e, 0x8a, 0x69, 0xb7, 0x78, 0x3c, 0x25, 0x85,
+ 0x19, 0x33, 0xab, 0x62, 0x90, 0xaf, 0x6c, 0xa7,
+ 0x7a, 0x99, 0x81, 0x48, 0x08, 0x50, 0x00, 0x9c,
+ 0xc5, 0x57, 0x7c, 0x6e, 0x1f, 0x57, 0x3b, 0x4e,
+ 0x68, 0x01, 0xdd, 0x23, 0xc4, 0xa7, 0xd6, 0x79,
+ 0xcc, 0xf8, 0xa3, 0x86, 0xc6, 0x74, 0xcf, 0xfb
+};
+
+static u8 tc4_digest_sha512[] = {
+ 0xb0, 0xba, 0x46, 0x56, 0x37, 0x45, 0x8c, 0x69,
+ 0x90, 0xe5, 0xa8, 0xc5, 0xf6, 0x1d, 0x4a, 0xf7,
+ 0xe5, 0x76, 0xd9, 0x7f, 0xf9, 0x4b, 0x87, 0x2d,
+ 0xe7, 0x6f, 0x80, 0x50, 0x36, 0x1e, 0xe3, 0xdb,
+ 0xa9, 0x1c, 0xa5, 0xc1, 0x1a, 0xa2, 0x5e, 0xb4,
+ 0xd6, 0x79, 0x27, 0x5c, 0xc5, 0x78, 0x80, 0x63,
+ 0xa5, 0xf1, 0x97, 0x41, 0x12, 0x0c, 0x4f, 0x2d,
+ 0xe2, 0xad, 0xeb, 0xeb, 0x10, 0xa2, 0x98, 0xdd
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc4_sha224) = {
+ .name = "RFC4231 TC4",
+ .op = VNET_CRYPTO_OP_SHA224_HMAC,
+ .key = TEST_DATA (tc4_key),
+ .data = TEST_DATA (tc4_data),
+ .expected = TEST_DATA (tc4_digest_sha224),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc4_sha256) = {
+ .name = "RFC4231 TC4",
+ .op = VNET_CRYPTO_OP_SHA256_HMAC,
+ .key = TEST_DATA (tc4_key),
+ .data = TEST_DATA (tc4_data),
+ .expected = TEST_DATA (tc4_digest_sha256),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc4_sha384) = {
+ .name = "RFC4231 TC4",
+ .op = VNET_CRYPTO_OP_SHA384_HMAC,
+ .key = TEST_DATA (tc4_key),
+ .data = TEST_DATA (tc4_data),
+ .expected = TEST_DATA (tc4_digest_sha384),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc4_sha512) = {
+ .name = "RFC4231 TC4",
+ .op = VNET_CRYPTO_OP_SHA512_HMAC,
+ .key = TEST_DATA (tc4_key),
+ .data = TEST_DATA (tc4_data),
+ .expected = TEST_DATA (tc4_digest_sha512),
+};
+/* *INDENT-ON* */
+
+static u8 tc5_key[20] = {
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c
+};
+
+static u8 tc5_data[] = {
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x57, 0x69, 0x74,
+ 0x68, 0x20, 0x54, 0x72, 0x75, 0x6e, 0x63, 0x61,
+ 0x74, 0x69, 0x6f, 0x6e
+};
+
+static u8 tc5_digest_sha224[16] = {
+ 0x0e, 0x2a, 0xea, 0x68, 0xa9, 0x0c, 0x8d, 0x37,
+ 0xc9, 0x88, 0xbc, 0xdb, 0x9f, 0xca, 0x6f, 0xa8
+};
+
+static u8 tc5_digest_sha256[16] = {
+ 0xa3, 0xb6, 0x16, 0x74, 0x73, 0x10, 0x0e, 0xe0,
+ 0x6e, 0x0c, 0x79, 0x6c, 0x29, 0x55, 0x55, 0x2b
+};
+
+static u8 tc5_digest_sha384[16] = {
+ 0x3a, 0xbf, 0x34, 0xc3, 0x50, 0x3b, 0x2a, 0x23,
+ 0xa4, 0x6e, 0xfc, 0x61, 0x9b, 0xae, 0xf8, 0x97
+};
+
+static u8 tc5_digest_sha512[16] = {
+ 0x41, 0x5f, 0xad, 0x62, 0x71, 0x58, 0x0a, 0x53,
+ 0x1d, 0x41, 0x79, 0xbc, 0x89, 0x1d, 0x87, 0xa6
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc5_sha224) = {
+ .name = "RFC4231 TC5",
+ .op = VNET_CRYPTO_OP_SHA224_HMAC,
+ .key = TEST_DATA (tc5_key),
+ .data = TEST_DATA (tc5_data),
+ .expected = TEST_DATA (tc5_digest_sha224),
+ .hmac_trunc_len = 16,
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc5_sha256) = {
+ .name = "RFC4231 TC5",
+ .op = VNET_CRYPTO_OP_SHA256_HMAC,
+ .key = TEST_DATA (tc5_key),
+ .data = TEST_DATA (tc5_data),
+ .expected = TEST_DATA (tc5_digest_sha256),
+ .hmac_trunc_len = 16,
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc5_sha384) = {
+ .name = "RFC4231 TC5",
+ .op = VNET_CRYPTO_OP_SHA384_HMAC,
+ .key = TEST_DATA (tc5_key),
+ .data = TEST_DATA (tc5_data),
+ .expected = TEST_DATA (tc5_digest_sha384),
+ .hmac_trunc_len = 16,
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc5_sha512) = {
+ .name = "RFC4231 TC5",
+ .op = VNET_CRYPTO_OP_SHA512_HMAC,
+ .key = TEST_DATA (tc5_key),
+ .data = TEST_DATA (tc5_data),
+ .expected = TEST_DATA (tc5_digest_sha512),
+ .hmac_trunc_len = 16,
+};
+/* *INDENT-ON* */
+
+static u8 tc6_key[131] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa
+};
+
+static char tc6_data[54] =
+ "Test Using Larger Than Block-Size Key - Hash Key First";
+
+static u8 tc6_digest_sha224[] = {
+ 0x95, 0xe9, 0xa0, 0xdb, 0x96, 0x20, 0x95, 0xad,
+ 0xae, 0xbe, 0x9b, 0x2d, 0x6f, 0x0d, 0xbc, 0xe2,
+ 0xd4, 0x99, 0xf1, 0x12, 0xf2, 0xd2, 0xb7, 0x27,
+ 0x3f, 0xa6, 0x87, 0x0e
+};
+
+static u8 tc6_digest_sha256[] = {
+ 0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f,
+ 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f,
+ 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14,
+ 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54
+};
+
+static u8 tc6_digest_sha384[] = {
+ 0x4e, 0xce, 0x08, 0x44, 0x85, 0x81, 0x3e, 0x90,
+ 0x88, 0xd2, 0xc6, 0x3a, 0x04, 0x1b, 0xc5, 0xb4,
+ 0x4f, 0x9e, 0xf1, 0x01, 0x2a, 0x2b, 0x58, 0x8f,
+ 0x3c, 0xd1, 0x1f, 0x05, 0x03, 0x3a, 0xc4, 0xc6,
+ 0x0c, 0x2e, 0xf6, 0xab, 0x40, 0x30, 0xfe, 0x82,
+ 0x96, 0x24, 0x8d, 0xf1, 0x63, 0xf4, 0x49, 0x52
+};
+
+static u8 tc6_digest_sha512[] = {
+ 0x80, 0xb2, 0x42, 0x63, 0xc7, 0xc1, 0xa3, 0xeb,
+ 0xb7, 0x14, 0x93, 0xc1, 0xdd, 0x7b, 0xe8, 0xb4,
+ 0x9b, 0x46, 0xd1, 0xf4, 0x1b, 0x4a, 0xee, 0xc1,
+ 0x12, 0x1b, 0x01, 0x37, 0x83, 0xf8, 0xf3, 0x52,
+ 0x6b, 0x56, 0xd0, 0x37, 0xe0, 0x5f, 0x25, 0x98,
+ 0xbd, 0x0f, 0xd2, 0x21, 0x5d, 0x6a, 0x1e, 0x52,
+ 0x95, 0xe6, 0x4f, 0x73, 0xf6, 0x3f, 0x0a, 0xec,
+ 0x8b, 0x91, 0x5a, 0x98, 0x5d, 0x78, 0x65, 0x98
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc6_sha224) = {
+ .name = "RFC4231 TC6",
+ .op = VNET_CRYPTO_OP_SHA224_HMAC,
+ .key = TEST_DATA (tc6_key),
+ .data = TEST_DATA (tc6_data),
+ .expected = TEST_DATA (tc6_digest_sha224),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc6_sha256) = {
+ .name = "RFC4231 TC6",
+ .op = VNET_CRYPTO_OP_SHA256_HMAC,
+ .key = TEST_DATA (tc6_key),
+ .data = TEST_DATA (tc6_data),
+ .expected = TEST_DATA (tc6_digest_sha256),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc6_sha384) = {
+ .name = "RFC4231 TC6",
+ .op = VNET_CRYPTO_OP_SHA384_HMAC,
+ .key = TEST_DATA (tc6_key),
+ .data = TEST_DATA (tc6_data),
+ .expected = TEST_DATA (tc6_digest_sha384),
+};
+
+UNITTEST_REGISTER_CRYPTO_TEST (rfc4231_tc6_sha512) = {
+ .name = "RFC4231 TC6",
+ .op = VNET_CRYPTO_OP_SHA512_HMAC,
+ .key = TEST_DATA (tc6_key),
+ .data = TEST_DATA (tc6_data),
+ .expected = TEST_DATA (tc6_digest_sha512),
+};
+/* *INDENT-ON* */
+
static u8 tc7_key[131] = {
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
diff --git a/src/plugins/unittest/crypto_test.c b/src/plugins/unittest/crypto_test.c
index 1df483efd56..6d57cea82c7 100644
--- a/src/plugins/unittest/crypto_test.c
+++ b/src/plugins/unittest/crypto_test.c
@@ -69,6 +69,7 @@ test_crypto (vlib_main_t * vm, crypto_test_main_t * tm)
op->dst = computed_data + computed_data_total_len;
op->len = r->data.length;
op->key_len = r->key.length;
+ op->hmac_trunc_len = r->hmac_trunc_len;
computed_data_total_len += r->expected.length;
/* next */
r = r->next;
@@ -95,7 +96,7 @@ test_crypto (vlib_main_t * vm, crypto_test_main_t * tm)
if (fail & tm->verbose)
{
vlib_cli_output (vm, "Expected:\n%U\nCalculated:\n%U",
- format_hexdump, r->expected, r->expected.length,
+ format_hexdump, r->expected.data, r->expected.length,
format_hexdump, op->dst, r->expected.length);
}
}