aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2019-03-19 10:37:06 -0700
committerFilip Tehlar <ftehlar@cisco.com>2019-03-20 00:56:41 -0700
commite225f71766a75364523e6892a709ca95a3e043c1 (patch)
tree4c2c9ee4e1e4d3127394ddca25d71a401b4ccf47 /src
parent76ef6094cb550ebb452a7068b02ff5fc6da420c7 (diff)
tests: implement crypto tests per RFC2202
Change-Id: I18b30d5ee8aa60c34d52b7716b5feb7225cb0d59 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/crypto_openssl/main.c1
-rw-r--r--src/plugins/unittest/CMakeLists.txt3
-rw-r--r--src/plugins/unittest/crypto/rfc2202.c84
-rw-r--r--src/plugins/unittest/crypto/rfc2202_hmac_md5.c202
-rw-r--r--src/plugins/unittest/crypto/rfc2202_hmac_sha1.c212
-rw-r--r--src/vnet/crypto/crypto.h1
6 files changed, 418 insertions, 85 deletions
diff --git a/src/plugins/crypto_openssl/main.c b/src/plugins/crypto_openssl/main.c
index 30c9c03f643..b4679ee8915 100644
--- a/src/plugins/crypto_openssl/main.c
+++ b/src/plugins/crypto_openssl/main.c
@@ -44,6 +44,7 @@ static openssl_per_thread_data_t *per_thread_data = 0;
_(AES_256_CBC, EVP_aes_256_cbc)
#define foreach_openssl_hmac_op \
+ _(MD5, EVP_md5) \
_(SHA1, EVP_sha1) \
_(SHA224, EVP_sha224) \
_(SHA256, EVP_sha256) \
diff --git a/src/plugins/unittest/CMakeLists.txt b/src/plugins/unittest/CMakeLists.txt
index 555404b24a6..81db615da0f 100644
--- a/src/plugins/unittest/CMakeLists.txt
+++ b/src/plugins/unittest/CMakeLists.txt
@@ -17,7 +17,8 @@ add_vpp_plugin(unittest
bihash_test.c
crypto_test.c
crypto/aes_cbc.c
- crypto/rfc2202.c
+ crypto/rfc2202_hmac_sha1.c
+ crypto/rfc2202_hmac_md5.c
crypto/rfc4231.c
fib_test.c
interface_test.c
diff --git a/src/plugins/unittest/crypto/rfc2202.c b/src/plugins/unittest/crypto/rfc2202.c
deleted file mode 100644
index 935aafd9bca..00000000000
--- a/src/plugins/unittest/crypto/rfc2202.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* Test vectors published in RFC2202 */
-
-#include <vppinfra/clib.h>
-#include <vnet/crypto/crypto.h>
-#include <unittest/crypto/crypto.h>
-
-static u8 sha1_tc1_key[] = {
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
- 0x0b, 0x0b, 0x0b, 0x0b
-};
-
-static char sha1_tc1_data[8] = "Hi There";
-
-static u8 sha1_tc1_digest[] = {
- 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
- 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
- 0xf1, 0x46, 0xbe, 0x00
-};
-
-/* *INDENT-OFF* */
-UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc1) = {
- .name = "RFC2202 HMAC-SHA-1 TC1",
- .op = VNET_CRYPTO_OP_SHA1_HMAC,
- .key = TEST_DATA (sha1_tc1_key),
- .data = TEST_DATA (sha1_tc1_data),
- .expected = TEST_DATA (sha1_tc1_digest),
-};
-/* *INDENT-ON* */
-
-static u8 sha1_tc7_key[80] = {
- 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 sha1_tc7_data[73] =
- "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
-
-static u8 sha1_tc7_digest[20] = {
- 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78,
- 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08,
- 0xbb, 0xff, 0x1a, 0x91
-};
-
-/* *INDENT-OFF* */
-UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc7) = {
- .name = "RFC2202 HMAC-SHA-1 TC7",
- .op = VNET_CRYPTO_OP_SHA1_HMAC,
- .key = TEST_DATA (sha1_tc7_key),
- .data = TEST_DATA (sha1_tc7_data),
- .expected = TEST_DATA (sha1_tc7_digest),
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/plugins/unittest/crypto/rfc2202_hmac_md5.c b/src/plugins/unittest/crypto/rfc2202_hmac_md5.c
new file mode 100644
index 00000000000..da6da7e47f4
--- /dev/null
+++ b/src/plugins/unittest/crypto/rfc2202_hmac_md5.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Test vectors published in RFC2202 */
+
+#include <vppinfra/clib.h>
+#include <vnet/crypto/crypto.h>
+#include <unittest/crypto/crypto.h>
+
+static u8 md5_tc1_key[16] = {
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
+};
+
+static char md5_tc1_data[8] = "Hi There";
+
+static u8 md5_tc1_digest[] = {
+ 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
+ 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc1) = {
+ .name = "RFC2202 HMAC-MD5 TC1",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc1_key),
+ .data = TEST_DATA (md5_tc1_data),
+ .expected = TEST_DATA (md5_tc1_digest),
+};
+/* *INDENT-ON* */
+
+static char md5_tc2_key[4] = "Jefe";
+
+static char md5_tc2_data[28] = "what do ya want for nothing?";
+
+static u8 md5_tc2_digest[] = {
+ 0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
+ 0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc2) = {
+ .name = "RFC2202 HMAC-MD5 TC2",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc2_key),
+ .data = TEST_DATA (md5_tc2_data),
+ .expected = TEST_DATA (md5_tc2_digest),
+};
+/* *INDENT-ON* */
+
+static char md5_tc3_key[16] = {
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
+};
+
+static char md5_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 md5_tc3_digest[] = {
+ 0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
+ 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc3) = {
+ .name = "RFC2202 HMAC-MD5 TC3",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc3_key),
+ .data = TEST_DATA (md5_tc3_data),
+ .expected = TEST_DATA (md5_tc3_digest),
+};
+/* *INDENT-ON* */
+
+static u8 md5_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 md5_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 md5_tc4_digest[] = {
+ 0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
+ 0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc4) = {
+ .name = "RFC2202 HMAC-MD5 TC4",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc4_key),
+ .data = TEST_DATA (md5_tc4_data),
+ .expected = TEST_DATA (md5_tc4_digest),
+};
+/* *INDENT-ON* */
+
+static u8 md5_tc5_key[16] = {
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+};
+
+static char md5_tc5_data[20] = "Test With Truncation";
+
+static u8 md5_tc5_digest[] = {
+ 0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
+ 0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc5) = {
+ .name = "RFC2202 HMAC-MD5 TC5",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc5_key),
+ .data = TEST_DATA (md5_tc5_data),
+ .expected = TEST_DATA (md5_tc5_digest),
+};
+/* *INDENT-ON* */
+
+static u8 md5_tc6_key[80] = {
+ 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 md5_tc6_data[54] =
+ "Test Using Larger Than Block-Size Key - Hash Key First";
+
+static u8 md5_tc6_digest[] = {
+ 0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f,
+ 0x0b, 0x62, 0xe6, 0xce, 0x61, 0xb9, 0xd0, 0xcd,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc6) = {
+ .name = "RFC2202 HMAC-MD5 TC6",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc6_key),
+ .data = TEST_DATA (md5_tc6_data),
+ .expected = TEST_DATA (md5_tc6_digest),
+};
+/* *INDENT-ON* */
+
+static char md5_tc7_data[73] =
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
+
+static u8 md5_tc7_digest[] = {
+ 0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee,
+ 0x1f, 0xb1, 0xf5, 0x62, 0xdb, 0x3a, 0xa5, 0x3e,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_md5_tc7) = {
+ .name = "RFC2202 HMAC-MD5 TC7",
+ .op = VNET_CRYPTO_OP_MD5_HMAC,
+ .key = TEST_DATA (md5_tc6_key),
+ .data = TEST_DATA (md5_tc7_data),
+ .expected = TEST_DATA (md5_tc7_digest),
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c b/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c
new file mode 100644
index 00000000000..94ab03ca657
--- /dev/null
+++ b/src/plugins/unittest/crypto/rfc2202_hmac_sha1.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Test vectors published in RFC2202 */
+
+#include <vppinfra/clib.h>
+#include <vnet/crypto/crypto.h>
+#include <unittest/crypto/crypto.h>
+
+static u8 sha1_tc1_key[] = {
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
+ 0x0b, 0x0b, 0x0b, 0x0b
+};
+
+static char sha1_tc1_data[8] = "Hi There";
+
+static u8 sha1_tc1_digest[] = {
+ 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
+ 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
+ 0xf1, 0x46, 0xbe, 0x00
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc1) = {
+ .name = "RFC2202 HMAC-SHA-1 TC1",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc1_key),
+ .data = TEST_DATA (sha1_tc1_data),
+ .expected = TEST_DATA (sha1_tc1_digest),
+};
+/* *INDENT-ON* */
+
+static char sha1_tc2_key[4] = "Jefe";
+
+static char sha1_tc2_data[28] = "what do ya want for nothing?";
+
+static u8 sha1_tc2_digest[] = {
+ 0xef, 0xfc, 0xdf, 0x6a, 0xe5, 0xeb, 0x2f, 0xa2,
+ 0xd2, 0x74, 0x16, 0xd5, 0xf1, 0x84, 0xdf, 0x9c,
+ 0x25, 0x9a, 0x7c, 0x79
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc2) = {
+ .name = "RFC2202 HMAC-SHA-1 TC2",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc2_key),
+ .data = TEST_DATA (sha1_tc2_data),
+ .expected = TEST_DATA (sha1_tc2_digest),
+};
+/* *INDENT-ON* */
+
+static u8 sha1_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 sha1_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 sha1_tc3_digest[] = {
+ 0x12, 0x5d, 0x73, 0x42, 0xb9, 0xac, 0x11, 0xcd,
+ 0x91, 0xa3, 0x9a, 0xf4, 0x8a, 0xa1, 0x7b, 0x4f,
+ 0x63, 0xf1, 0x75, 0xd3,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc3) = {
+ .name = "RFC2202 HMAC-SHA-1 TC3",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc3_key),
+ .data = TEST_DATA (sha1_tc3_data),
+ .expected = TEST_DATA (sha1_tc3_digest),
+};
+/* *INDENT-ON* */
+
+static u8 sha1_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 sha1_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 sha1_tc4_digest[] = {
+ 0x4c, 0x90, 0x07, 0xf4, 0x02, 0x62, 0x50, 0xc6,
+ 0xbc, 0x84, 0x14, 0xf9, 0xbf, 0x50, 0xc8, 0x6c,
+ 0x2d, 0x72, 0x35, 0xda,
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc4) = {
+ .name = "RFC2202 HMAC-SHA-1 TC4",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc4_key),
+ .data = TEST_DATA (sha1_tc4_data),
+ .expected = TEST_DATA (sha1_tc4_digest),
+};
+/* *INDENT-ON* */
+
+static u8 sha1_tc5_key[20] = {
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0x0c, 0x0c, 0x0c
+};
+
+static char sha1_tc5_data[20] = "Test With Truncation";
+
+static u8 sha1_tc5_digest[] = {
+ 0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f,
+ 0xe7, 0xf2, 0x7b, 0xe1, 0xd5, 0x8b, 0xb9, 0x32,
+ 0x4a, 0x9a, 0x5a, 0x04
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc5) = {
+ .name = "RFC2202 HMAC-SHA-1 TC5",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc5_key),
+ .data = TEST_DATA (sha1_tc5_data),
+ .expected = TEST_DATA (sha1_tc5_digest),
+};
+/* *INDENT-ON* */
+
+static u8 sha1_tc6_key[80] = {
+ 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 sha1_tc6_data[54] =
+ "Test Using Larger Than Block-Size Key - Hash Key First";
+
+static u8 sha1_tc6_digest[] = {
+ 0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e,
+ 0x95, 0x70, 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55,
+ 0xed, 0x40, 0x21, 0x12
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc6) = {
+ .name = "RFC2202 HMAC-SHA-1 TC6",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc6_key),
+ .data = TEST_DATA (sha1_tc6_data),
+ .expected = TEST_DATA (sha1_tc6_digest),
+};
+/* *INDENT-ON* */
+
+static char sha1_tc7_data[73] =
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
+
+static u8 sha1_tc7_digest[20] = {
+ 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78,
+ 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08,
+ 0xbb, 0xff, 0x1a, 0x91
+};
+
+/* *INDENT-OFF* */
+UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc7) = {
+ .name = "RFC2202 HMAC-SHA-1 TC7",
+ .op = VNET_CRYPTO_OP_SHA1_HMAC,
+ .key = TEST_DATA (sha1_tc6_key),
+ .data = TEST_DATA (sha1_tc7_data),
+ .expected = TEST_DATA (sha1_tc7_digest),
+};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/crypto/crypto.h b/src/vnet/crypto/crypto.h
index 9f4c85b36f5..4c9467f272f 100644
--- a/src/vnet/crypto/crypto.h
+++ b/src/vnet/crypto/crypto.h
@@ -28,6 +28,7 @@
_(AES_256_CBC, "aes-256-cbc")
#define foreach_hmac_alg \
+ _(MD5, "md5") \
_(SHA1, "sha-1") \
_(SHA224, "sha-224") \
_(SHA256, "sha-256") \