2 * Copyright (c) 2019 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 /* Test vectors published in RFC2202 */
18 #include <vppinfra/clib.h>
19 #include <vnet/crypto/crypto.h>
20 #include <unittest/crypto/crypto.h>
22 static u8 sha1_tc1_key[] = {
23 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
24 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
25 0x0b, 0x0b, 0x0b, 0x0b
28 static char sha1_tc1_data[8] = "Hi There";
30 static u8 sha1_tc1_digest[] = {
31 0xb6, 0x17, 0x31, 0x86, 0x55, 0x05, 0x72, 0x64,
32 0xe2, 0x8b, 0xc0, 0xb6, 0xfb, 0x37, 0x8c, 0x8e,
33 0xf1, 0x46, 0xbe, 0x00
37 UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc1) = {
38 .name = "RFC2202 HMAC-SHA-1 TC1",
39 .op = VNET_CRYPTO_OP_SHA1_HMAC,
40 .key = TEST_DATA (sha1_tc1_key),
41 .data = TEST_DATA (sha1_tc1_data),
42 .expected = TEST_DATA (sha1_tc1_digest),
46 static u8 sha1_tc7_key[80] = {
47 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
48 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
49 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
50 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
51 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
52 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
53 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
54 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
55 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
56 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
59 static char sha1_tc7_data[73] =
60 "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data";
62 static u8 sha1_tc7_digest[20] = {
63 0xe8, 0xe9, 0x9d, 0x0f, 0x45, 0x23, 0x7d, 0x78,
64 0x6d, 0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08,
65 0xbb, 0xff, 0x1a, 0x91
69 UNITTEST_REGISTER_CRYPTO_TEST (rfc_2202_sha1_tc7) = {
70 .name = "RFC2202 HMAC-SHA-1 TC7",
71 .op = VNET_CRYPTO_OP_SHA1_HMAC,
72 .key = TEST_DATA (sha1_tc7_key),
73 .data = TEST_DATA (sha1_tc7_data),
74 .expected = TEST_DATA (sha1_tc7_digest),
79 * fd.io coding-style-patch-verification: ON
82 * eval: (c-set-style "gnu")