Mistake on this page?
Report an issue in GitHub or email us
compliance_crypto/test_c013/test_data.h
Go to the documentation of this file.
1 /** @file
2  * Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
3  * SPDX-License-Identifier : Apache-2.0
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 #include "val_crypto.h"
19 
20 typedef struct {
21  char test_desc[50];
22  psa_algorithm_t alg;
23  char input;
24  size_t input_length;
25  char hash[32];
26  size_t hash_length;
27  psa_status_t expected_status;
28 } test_data;
29 
30 static const char sha384_hash[] = {
31 0x43, 0x72, 0xe3, 0x8a, 0x92, 0xa2, 0x8b, 0x5d, 0x2c, 0x39, 0x1e, 0x62,
32 0x45, 0x2a, 0x86, 0xd5, 0x0e, 0x02, 0x67, 0x22, 0x8b, 0xe1, 0x76, 0xc7, 0x7d, 0x24, 0x02, 0xef,
33 0xfe, 0x9f, 0xa5, 0x0d, 0xe4, 0x07, 0xbb, 0xb8, 0x51, 0xb3, 0x7d, 0x59, 0x04, 0xab, 0xa2, 0xde,
34 0xde, 0x74, 0xda, 0x2a};
35 
36 static const char sha512_hash[] = {
37 0x29, 0x6e, 0x22, 0x67, 0xd7, 0x4c, 0x27, 0x8d, 0xaa, 0xaa, 0x94, 0x0d,
38 0x17, 0xb0, 0xcf, 0xb7, 0x4a, 0x50, 0x83, 0xf8, 0xe0, 0x69, 0x72, 0x6d, 0x8c, 0x84, 0x1c, 0xbe,
39 0x59, 0x6e, 0x04, 0x31, 0xcb, 0x77, 0x41, 0xa5, 0xb5, 0x0f, 0x71, 0x66, 0x6c, 0xfd, 0x54, 0xba,
40 0xcb, 0x7b, 0x00, 0xae, 0xa8, 0x91, 0x49, 0x9c, 0xf4, 0xef, 0x6a, 0x03, 0xc8, 0xa8, 0x3f, 0xe3,
41 0x7c, 0x3f, 0x7b, 0xaf};
42 
43 static test_data check1[] = {
44 #ifdef ARCH_TEST_MD2
45 {"Test psa_hash_verify with MD2 algorithm\n",
46  PSA_ALG_MD2, 0xbd, 1,
47  {0x8c, 0x9c, 0x17, 0x66, 0x5d, 0x25, 0xb3, 0x5f, 0xc4, 0x13, 0xc4, 0x18, 0x05, 0xc6, 0x79, 0xcf},
48  16, PSA_SUCCESS,
49 },
50 #endif
51 
52 #ifdef ARCH_TEST_MD4
53 {"Test psa_hash_verify with MD4 algorithm\n",
54  PSA_ALG_MD4, 0xbd, 1,
55  {0x18, 0xc3, 0x3f, 0x97, 0x29, 0x7e, 0xfe, 0x5f, 0x8a, 0x73, 0x22, 0x58, 0x28, 0x9f, 0xda, 0x25},
56  16, PSA_SUCCESS,
57 },
58 #endif
59 
60 #ifdef ARCH_TEST_MD5
61 {"Test psa_hash_verify with MD5 algorithm\n",
62  PSA_ALG_MD5, 0xbd, 1,
63  {0xab, 0xae, 0x57, 0xcb, 0x56, 0x2e, 0xcf, 0x29, 0x5b, 0x4a, 0x37, 0xa7, 0x6e, 0xfe, 0x61, 0xfb},
64  16, PSA_SUCCESS,
65 },
66 #endif
67 
68 #ifdef ARCH_TEST_RIPEMD160
69 {"Test psa_hash_verify with RIPEMD160 algorithm\n",
70  PSA_ALG_RIPEMD160, 0xbd, 1,
71  {0x50, 0x89, 0x26, 0x5e, 0xe5, 0xd9, 0xaf, 0x75, 0xd1, 0x2d, 0xbf, 0x7e, 0xa2, 0xf2, 0x7d, 0xbd,
72  0xee, 0x43, 0x5b, 0x37},
73  20, PSA_SUCCESS,
74 },
75 #endif
76 
77 #ifdef ARCH_TEST_SHA1
78 {"Test psa_hash_verify with SHA1 algorithm\n",
79  PSA_ALG_SHA_1, 0xbd, 1,
80  {0x90, 0x34, 0xaa, 0xf4, 0x51, 0x43, 0x99, 0x6a, 0x2b, 0x14, 0x46, 0x5c, 0x35, 0x2a, 0xb0, 0xc6,
81  0xfa, 0x26, 0xb2, 0x21},
82  20, PSA_SUCCESS,
83 },
84 #endif
85 
86 #ifdef ARCH_TEST_SHA224
87 {"Test psa_hash_verify with SHA224 algorithm\n",
88  PSA_ALG_SHA_224, 0xbd, 1,
89  {0xb1, 0xe4, 0x6b, 0xb9, 0xef, 0xe4, 0x5a, 0xf5, 0x54, 0x36, 0x34, 0x49, 0xc6, 0x94, 0x5a, 0x0d,
90  0x61, 0x69, 0xfc, 0x3a, 0x5a, 0x39, 0x6a, 0x56, 0xcb, 0x97, 0xcb, 0x57},
91  28, PSA_SUCCESS,
92 },
93 #endif
94 
95 #ifdef ARCH_TEST_SHA256
96 {"Test psa_hash_verify with SHA256 algorithm\n",
97  PSA_ALG_SHA_256, 0xbd, 1,
98  {0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70,
99  0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b},
100  32, PSA_SUCCESS,
101 },
102 #endif
103 
104 #ifdef ARCH_TEST_SHA384
105 {"Test psa_hash_verify with SHA384 algorithm\n",
106  PSA_ALG_SHA_384, 0xbd, 1, {0}, 48, PSA_SUCCESS,
107 },
108 #endif
109 
110 #ifdef ARCH_TEST_SHA512
111 {"Test psa_hash_verify with SHA512 algorithm\n",
112  PSA_ALG_SHA_512, 0xbd, 1, {0}, 64, PSA_SUCCESS,
113 },
114 #endif
115 
116 #ifdef ARCH_TEST_SHA256
117 {"Test psa_hash_verify with incorrect expected hash\n",
118  PSA_ALG_SHA_256, 0xbd, 1,
119  {0x68, 0x32, 0x57, 0x20, 0xab, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70,
120  0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x78},
121  32, PSA_ERROR_INVALID_SIGNATURE,
122 },
123 
124 {"Test psa_hash_verify with incorrect hash length\n",
125  PSA_ALG_SHA_256, 0xbd, 1,
126  {0x68, 0x32, 0x57, 0x20, 0xaa, 0xbd, 0x7c, 0x82, 0xf3, 0x0f, 0x55, 0x4b, 0x31, 0x3d, 0x05, 0x70,
127  0xc9, 0x5a, 0xcc, 0xbb, 0x7d, 0xc4, 0xb5, 0xaa, 0xe1, 0x12, 0x04, 0xc0, 0x8f, 0xfe, 0x73, 0x2b},
128  31, PSA_ERROR_INVALID_SIGNATURE,
129 },
130 #endif
131 };
Copyright (c) 2018-2019, Arm Limited or its affiliates.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.