Mistake on this page?
Report an issue in GitHub or email us
compliance_crypto/test_c016/test_data.h
Go to the documentation of this file.
1 /** @file
2  * Copyright (c) 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[75];
22  psa_key_handle_t key_handle;
23  psa_key_type_t key_type;
24  psa_key_usage_t usage;
25  psa_algorithm_t key_alg;
26  size_t bits;
27  void *extra;
28  size_t extra_size;
29  uint32_t expected_bit_length;
30  uint32_t expected_key_length;
31  psa_status_t expected_status;
32 } test_data;
33 
34 #ifdef FUTURE_SUPPORT
35 static uint32_t rsa_extra = 3;
36 #endif
37 
38 static test_data check1[] = {
39 #ifdef ARCH_TEST_CIPER_MODE_CTR
40 #ifdef ARCH_TEST_AES_128
41 {"Test psa_generate_key 16 Byte AES\n", 1, PSA_KEY_TYPE_AES,
42  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
43  BYTES_TO_BITS(AES_16B_KEY_SIZE), NULL, 0,
44  BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS
45 },
46 #endif
47 
48 #ifdef ARCH_TEST_AES_192
49 {"Test psa_generate_key 24 Byte AES\n", 2, PSA_KEY_TYPE_AES,
50  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
51  BYTES_TO_BITS(AES_24B_KEY_SIZE), NULL, 0,
52  BYTES_TO_BITS(AES_24B_KEY_SIZE), AES_24B_KEY_SIZE, PSA_SUCCESS
53 },
54 #endif
55 
56 #ifdef ARCH_TEST_AES_256
57 {"Test psa_generate_key 32 Byte AES\n", 3, PSA_KEY_TYPE_AES,
58  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
59  BYTES_TO_BITS(AES_32B_KEY_SIZE), NULL, 0,
60  BYTES_TO_BITS(AES_32B_KEY_SIZE), AES_32B_KEY_SIZE, PSA_SUCCESS
61 },
62 #endif
63 
64 #ifdef ARCH_TEST_DES_1KEY
65 {"Test psa_generate_key with DES 64 bit key\n", 4, PSA_KEY_TYPE_DES,
66  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
67  BYTES_TO_BITS(DES_8B_KEY_SIZE), NULL, 0,
68  BYTES_TO_BITS(DES_8B_KEY_SIZE), DES_8B_KEY_SIZE, PSA_SUCCESS
69 },
70 #endif
71 
72 #ifdef ARCH_TEST_DES_2KEY
73 {"Test psa_generate_key with Triple DES 2-Key\n", 5, PSA_KEY_TYPE_DES,
74  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
75  BYTES_TO_BITS(DES3_2KEY_SIZE), NULL, 0,
76  BYTES_TO_BITS(DES3_2KEY_SIZE), DES3_2KEY_SIZE, PSA_SUCCESS
77 },
78 #endif
79 
80 #ifdef ARCH_TEST_DES_3KEY
81 {"Test psa_generate_key with Triple DES 3-Key\n", 6, PSA_KEY_TYPE_DES,
82  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
83  BYTES_TO_BITS(DES3_3KEY_SIZE), NULL, 0,
84  BYTES_TO_BITS(DES3_3KEY_SIZE), DES3_3KEY_SIZE, PSA_SUCCESS
85 },
86 #endif
87 
88 #ifdef ARCH_TEST_AES_256
89 {"Test psa_generate_key with Null extra and Non-Zero extra size\n", 7, PSA_KEY_TYPE_AES,
90  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
91  BYTES_TO_BITS(AES_32B_KEY_SIZE), NULL, sizeof(uint32_t),
92  0, 0, PSA_ERROR_INVALID_ARGUMENT
93 },
94 #endif
95 #endif
96 
97 #ifdef FUTURE_SUPPORT
98 {"Test psa_generate_key with RSA 2048 Keypair\n", 8, PSA_KEY_TYPE_RSA_KEYPAIR,
99  PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW,
100  2048, NULL, 0,
101  2048, 1193, PSA_SUCCESS
102 },
103 #endif
104 
105 #ifdef ARCH_TEST_ECC_CURVE_SECP224R1
106 #ifdef ARCH_TEST_ASYMMETRIC_ENCRYPTION
107 {"Test psa_generate_key with ECC KeyPair\n", 9,
108  PSA_KEY_TYPE_ECC_KEYPAIR(PSA_ECC_CURVE_SECP224R1),
109  PSA_KEY_USAGE_EXPORT, PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION,
110  224, NULL, 0,
111  224, 28, PSA_SUCCESS
112 },
113 #endif
114 #endif
115 
116 #ifdef FUTURE_SUPPORT
117 {"Test psa_generate_key with Non-Null extra for 32 Byte AES key\n", 10, PSA_KEY_TYPE_AES,
118  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
119  BYTES_TO_BITS(AES_32B_KEY_SIZE), &rsa_extra, sizeof(uint32_t),
120  0, 0, PSA_ERROR_INVALID_ARGUMENT
121 },
122 #endif
123 
124 #ifdef ARCH_TEST_RSA_PKCS1V15_SIGN_RAW
125 #ifdef ARCH_TEST_RSA_2048
126 {"Test psa_generate_key with RSA 2048 Public key\n", 11, PSA_KEY_TYPE_RSA_PUBLIC_KEY,
127  PSA_KEY_USAGE_EXPORT | PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY, PSA_ALG_RSA_PKCS1V15_SIGN_RAW,
128  2048, NULL, 0,
129  2048, 1193, PSA_ERROR_NOT_SUPPORTED
130 },
131 #endif
132 #endif
133 };
134 
135 static test_data check2[] = {
136 #ifdef ARCH_TEST_CIPER_MODE_CTR
137 #ifdef ARCH_TEST_AES_128
138 {"Test psa_generate_key negative cases\n", 12, PSA_KEY_TYPE_AES,
139  PSA_KEY_USAGE_EXPORT, PSA_ALG_CTR,
140  BYTES_TO_BITS(AES_16B_KEY_SIZE), NULL, 0,
141  BYTES_TO_BITS(AES_16B_KEY_SIZE), AES_16B_KEY_SIZE, PSA_SUCCESS
142 },
143 #endif
144 #endif
145 };
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.