Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / crypto / tests / SPAKE2P_HMAC_test_vectors.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 /**
19  * @file - This file contains hmac test vectors.
20  */
21
22 #ifndef _SPAKE2P_FE_HMAC_TEST_VECTORS_H_
23 #define _SPAKE2P_FE_HMAC_TEST_VECTORS_H_
24
25 namespace chip {
26 namespace Crypto {
27
28 struct spake2p_hmac_tv
29 {
30     const uint8_t * key;
31     size_t key_len;
32     const uint8_t * input;
33     size_t input_len;
34     const uint8_t * output;
35     size_t output_len;
36 };
37
38 static const uint8_t chiptest_be68c22260b3_key_1[]    = { 0x28, 0xd7, 0x74, 0x50, 0xc1, 0xc6, 0x64, 0x3b, 0xcc, 0x72, 0xb6,
39                                                        0xf0, 0x03, 0xf2, 0x7b, 0x92, 0x37, 0x16, 0xde, 0x1c, 0x9b, 0x38,
40                                                        0x1f, 0x1f, 0xee, 0xf7, 0x08, 0xb8, 0x55, 0xa0, 0x2d, 0xbe };
41 static const uint8_t chiptest_be68c22260b3_input_2[]  = { 0xdd };
42 static const uint8_t chiptest_be68c22260b3_output_3[] = { 0x87, 0x0b, 0xf5, 0xd9, 0x95, 0x46, 0x0b, 0x9b, 0x69, 0xfa, 0xe8,
43                                                           0x73, 0x89, 0xb9, 0x31, 0xb9, 0xe0, 0x97, 0x2a, 0xf8, 0xe1, 0x38,
44                                                           0x9e, 0x9a, 0x64, 0xe4, 0x2a, 0xca, 0x7e, 0xaf, 0xdc, 0x5d };
45 static const struct spake2p_hmac_tv chiptest_be68c22260b3_test_vector_4 = {
46     .key        = chiptest_be68c22260b3_key_1,
47     .key_len    = 32,
48     .input      = chiptest_be68c22260b3_input_2,
49     .input_len  = 1,
50     .output     = chiptest_be68c22260b3_output_3,
51     .output_len = 32,
52 };
53 static const uint8_t chiptest_be68c22260b3_key_5[]    = { 0x28, 0xd7, 0x74, 0x50, 0xc1, 0xc6, 0x64, 0x3b, 0xcc, 0x72, 0xb6,
54                                                        0xf0, 0x03, 0xf2, 0x7b, 0x92, 0x37, 0x16, 0xde, 0x1c, 0x9b, 0x38,
55                                                        0x1f, 0x1f, 0xee, 0xf7, 0x08, 0xb8, 0x55, 0xa0, 0x2d, 0xbe };
56 static const uint8_t chiptest_be68c22260b3_input_6[]  = { 0x84, 0xb7, 0xf1, 0xda, 0xca, 0x02, 0x91, 0x56, 0xea, 0x47, 0xda, 0x9b };
57 static const uint8_t chiptest_be68c22260b3_output_7[] = { 0x56, 0x0c, 0x73, 0x79, 0x45, 0xff, 0x4a, 0x10, 0x28, 0x62, 0x9e,
58                                                           0xa3, 0x45, 0xda, 0xec, 0x57, 0x8d, 0x2e, 0xc3, 0xa7, 0x14, 0x63,
59                                                           0x64, 0xfa, 0x26, 0x9a, 0x14, 0xad, 0x04, 0x4c, 0x1c, 0xaa };
60 static const struct spake2p_hmac_tv chiptest_be68c22260b3_test_vector_8 = {
61     .key        = chiptest_be68c22260b3_key_5,
62     .key_len    = 32,
63     .input      = chiptest_be68c22260b3_input_6,
64     .input_len  = 12,
65     .output     = chiptest_be68c22260b3_output_7,
66     .output_len = 32,
67 };
68 static const uint8_t chiptest_be68c22260b3_key_9[]     = { 0x28, 0xd7, 0x74, 0x50, 0xc1, 0xc6, 0x64, 0x3b, 0xcc, 0x72, 0xb6,
69                                                        0xf0, 0x03, 0xf2, 0x7b, 0x92, 0x37, 0x16, 0xde, 0x1c, 0x9b, 0x38,
70                                                        0x1f, 0x1f, 0xee, 0xf7, 0x08, 0xb8, 0x55, 0xa0, 0x2d, 0xbe };
71 static const uint8_t chiptest_be68c22260b3_input_10[]  = { 0xe0, 0x82, 0x91, 0xf0, 0x39, 0xe4, 0x78, 0xc3, 0xdf, 0xb2, 0x82,
72                                                           0xb6, 0x99, 0x3b, 0xae, 0x80, 0x1f, 0xa0, 0xd3, 0xd0, 0xb0, 0x39,
73                                                           0x20, 0xb6, 0x3e, 0x17, 0xeb, 0x1e, 0xbb, 0x55, 0x0b, 0x64 };
74 static const uint8_t chiptest_be68c22260b3_output_11[] = { 0xf2, 0x93, 0x0f, 0xcc, 0x89, 0x78, 0xa4, 0x93, 0xc7, 0x79, 0xd4,
75                                                            0x1f, 0x7e, 0xb9, 0x6d, 0x50, 0xfe, 0xa3, 0x5b, 0x3f, 0x36, 0xf3,
76                                                            0xed, 0x04, 0x80, 0x98, 0x51, 0x37, 0x4b, 0xdf, 0xa3, 0x86 };
77 static const struct spake2p_hmac_tv chiptest_be68c22260b3_test_vector_12 = {
78     .key        = chiptest_be68c22260b3_key_9,
79     .key_len    = 32,
80     .input      = chiptest_be68c22260b3_input_10,
81     .input_len  = 32,
82     .output     = chiptest_be68c22260b3_output_11,
83     .output_len = 32,
84 };
85 static const uint8_t chiptest_be68c22260b3_key_13[]    = { 0x28, 0xd7, 0x74, 0x50, 0xc1, 0xc6, 0x64, 0x3b, 0xcc, 0x72, 0xb6,
86                                                         0xf0, 0x03, 0xf2, 0x7b, 0x92, 0x37, 0x16, 0xde, 0x1c, 0x9b, 0x38,
87                                                         0x1f, 0x1f, 0xee, 0xf7, 0x08, 0xb8, 0x55, 0xa0, 0x2d, 0xbe };
88 static const uint8_t chiptest_be68c22260b3_input_14[]  = { 0x2a, 0xc0, 0xae, 0x52, 0xdf, 0x1c, 0x83, 0x0a, 0x95, 0x59, 0x7a,
89                                                           0x43, 0xd5, 0xa6, 0xed, 0x1a, 0x46, 0x4d, 0xf6, 0x96, 0x4d, 0x28,
90                                                           0x12, 0x2f, 0x98, 0x16, 0x9e, 0xb4, 0x92, 0x0b, 0x8e, 0x56, 0x50,
91                                                           0x31, 0x09, 0x74, 0xa0, 0x23, 0x8f, 0x0e, 0x5d, 0x80, 0x7e, 0x91,
92                                                           0x8d, 0x9e, 0x4c, 0x89, 0x00, 0x17, 0x0f, 0x95, 0x59, 0x81, 0x5d,
93                                                           0x06, 0x1d, 0x71, 0xbf, 0xb7, 0xc6, 0x1d, 0x2c, 0x0d };
94 static const uint8_t chiptest_be68c22260b3_output_15[] = { 0x97, 0xac, 0x84, 0xe7, 0x3a, 0x68, 0x94, 0xa7, 0x25, 0xb1, 0x11,
95                                                            0x92, 0x69, 0x15, 0x95, 0x5a, 0xf8, 0xf6, 0x16, 0xc2, 0xc7, 0xe3,
96                                                            0x7c, 0xd8, 0xaf, 0x2c, 0x27, 0x23, 0x9a, 0x33, 0x6f, 0xc4 };
97 static const struct spake2p_hmac_tv chiptest_be68c22260b3_test_vector_16 = {
98     .key        = chiptest_be68c22260b3_key_13,
99     .key_len    = 32,
100     .input      = chiptest_be68c22260b3_input_14,
101     .input_len  = 64,
102     .output     = chiptest_be68c22260b3_output_15,
103     .output_len = 32,
104 };
105 static const uint8_t chiptest_be68c22260b3_key_17[]   = { 0x28, 0xd7, 0x74, 0x50, 0xc1, 0xc6, 0x64, 0x3b, 0xcc, 0x72, 0xb6,
106                                                         0xf0, 0x03, 0xf2, 0x7b, 0x92, 0x37, 0x16, 0xde, 0x1c, 0x9b, 0x38,
107                                                         0x1f, 0x1f, 0xee, 0xf7, 0x08, 0xb8, 0x55, 0xa0, 0x2d, 0xbe };
108 static const uint8_t chiptest_be68c22260b3_input_18[] = {
109     0x77, 0xf0, 0xd4, 0x66, 0xdb, 0x6e, 0x39, 0x13, 0x60, 0x59, 0xc3, 0xdc, 0x10, 0x6e, 0x3f, 0x1d, 0x79, 0x86, 0xb3,
110     0x66, 0xbd, 0x63, 0x0b, 0xdd, 0x65, 0xf3, 0x68, 0x09, 0x27, 0x9d, 0x70, 0x79, 0x90, 0x96, 0xd2, 0x34, 0xbf, 0x86,
111     0x21, 0x56, 0x1b, 0x85, 0xce, 0x8c, 0x64, 0xe6, 0x4a, 0x6e, 0x53, 0x6b, 0x84, 0x67, 0x6e, 0xc8, 0x65, 0xc1, 0x2f,
112     0x27, 0xcf, 0xeb, 0xd8, 0x5f, 0xb3, 0x29, 0x22, 0x64, 0xc1, 0x35, 0x09, 0x0e, 0x40, 0x49, 0x6c, 0x94, 0xad, 0xd2,
113     0x10, 0x3c, 0x49, 0x2b, 0x0c, 0x11, 0x11, 0x82, 0xc3, 0x3c, 0xa2, 0xb7, 0xad, 0x54, 0x16, 0x9b, 0x53, 0xc5, 0xb9,
114     0x79, 0xb6, 0xf3, 0xa6, 0xc2, 0x10, 0xf9, 0xc6, 0xec, 0x19, 0xe1, 0x5e, 0x2d, 0x8e, 0x7f, 0xff, 0x51, 0x32, 0x65,
115     0x11, 0x1a, 0xc7, 0x64, 0xd1, 0xcc, 0x7a, 0x22, 0x70, 0x70, 0xe0, 0x5c, 0x80, 0x79
116 };
117 static const uint8_t chiptest_be68c22260b3_output_19[] = { 0x15, 0x43, 0xb3, 0x80, 0x61, 0xde, 0x82, 0x82, 0x7a, 0x7d, 0x02,
118                                                            0xb6, 0x50, 0xae, 0xb6, 0xf8, 0x3f, 0x18, 0xf3, 0xec, 0x67, 0x0a,
119                                                            0x6e, 0xcd, 0x8d, 0x04, 0xe1, 0xb1, 0xd0, 0x89, 0xae, 0x66 };
120 static const struct spake2p_hmac_tv chiptest_be68c22260b3_test_vector_20 = {
121     .key        = chiptest_be68c22260b3_key_17,
122     .key_len    = 32,
123     .input      = chiptest_be68c22260b3_input_18,
124     .input_len  = 128,
125     .output     = chiptest_be68c22260b3_output_19,
126     .output_len = 32,
127 };
128 static const struct spake2p_hmac_tv * hmac_tvs[] = { &chiptest_be68c22260b3_test_vector_4, &chiptest_be68c22260b3_test_vector_8,
129                                                      &chiptest_be68c22260b3_test_vector_12, &chiptest_be68c22260b3_test_vector_16,
130                                                      &chiptest_be68c22260b3_test_vector_20 };
131
132 } // namespace Crypto
133 } // namespace chip
134
135 #endif