Mistake on this page?
Report an issue in GitHub or email us
val_crypto.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 #ifndef _VAL_CRYPTO_H_
19 #define _VAL_CRYPTO_H_
20 
21 #include "val.h"
22 #include "psa/client.h"
23 #include "crypto_values.h"
24 #include "crypto.h"
25 
26 #define BYTES_TO_BITS(byte) (byte * 8)
27 
28 /* Size */
29 #define AES_16B_KEY_SIZE 16
30 #define AES_24B_KEY_SIZE 24
31 #define AES_32B_KEY_SIZE 32
32 #define AES_18B_KEY_SIZE 18
33 #define AES_34B_KEY_SIZE 34
34 #define DES_8B_KEY_SIZE 8
35 #define DES3_2KEY_SIZE 16
36 #define DES3_3KEY_SIZE 24
37 #define SIZE_32B 32
38 #define SIZE_50B 50
39 #define SIZE_128B 128
40 #define SIZE_256B 256
41 #define SIZE_512B 512
42 #define BUFFER_SIZE 1200
43 #define HASH_64B 64
44 #define BUFFER_SIZE_HIGH 5130
45 
46 /* Key Slot */
47 #define INVALID_KEY_SLOT 0xDEAD
48 #define ZERO_KEY_SLOT 0
49 #define OCCUPIED_KEY_SLOT 1
50 #define MAX_KEY_SLOT 32
51 
52 #define PSA_KEY_LIFETIME_INVALID 0xFFFFFFFF
53 #define PSA_KEY_USAGE_INVALID 0xFFFFFFFF
54 #define PSA_ALG_INVALID 0xFFFFFFFF
55 
56 enum crypto_function_code {
57  VAL_CRYPTO_INIT = 0x1,
58  VAL_CRYPTO_GENERATE_RANDOM = 0x2,
59  VAL_CRYPTO_IMPORT_KEY = 0x3,
60  VAL_CRYPTO_EXPORT_KEY = 0x4,
61  VAL_CRYPTO_EXPORT_PUBLIC_KEY = 0x5,
62  VAL_CRYPTO_DESTROY_KEY = 0x6,
63  VAL_CRYPTO_GET_KEY_INFO = 0x7,
64  VAL_CRYPTO_KEY_POLICY_INIT = 0x8,
65  VAL_CRYPTO_KEY_POLICY_SET_USAGE = 0x9,
66  VAL_CRYPTO_KEY_POLICY_GET_USAGE = 0xA,
67  VAL_CRYPTO_KEY_POLICY_GET_ALGORITHM = 0xB,
68  VAL_CRYPTO_SET_KEY_POLICY = 0xC,
69  VAL_CRYPTO_GET_KEY_POLICY = 0xD,
70  VAL_CRYPTO_GET_KEY_INFORMATION = 0xE,
71  VAL_CRYPTO_GET_KEY_LIFETIME = 0xF,
72  VAL_CRYPTO_HASH_SETUP = 0x11,
73  VAL_CRYPTO_HASH_UPDATE = 0x12,
74  VAL_CRYPTO_HASH_VERIFY = 0x13,
75  VAL_CRYPTO_HASH_FINISH = 0x14,
76  VAL_CRYPTO_HASH_ABORT = 0x15,
77  VAL_CRYPTO_GENERATE_KEY = 0x16,
78  VAL_CRYPTO_GENERATOR_READ = 0x17,
79  VAL_CRYPTO_KEY_DERIVATION = 0x18,
80  VAL_CRYPTO_GET_GENERATOR_CAPACITY = 0x19,
81  VAL_CRYPTO_GENERATOR_IMPORT_KEY = 0x1A,
82  VAL_CRYPTO_GENERATOR_ABORT = 0x1B,
83  VAL_CRYPTO_AEAD_ENCRYPT = 0x1C,
84  VAL_CRYPTO_AEAD_DECRYPT = 0x1D,
85  VAL_CRYPTO_MAC_SIGN_SETUP = 0x1E,
86  VAL_CRYPTO_MAC_UPDATE = 0x1F,
87  VAL_CRYPTO_MAC_SIGN_FINISH = 0x20,
88  VAL_CRYPTO_MAC_VERIFY_SETUP = 0x21,
89  VAL_CRYPTO_MAC_VERIFY_FINISH = 0x22,
90  VAL_CRYPTO_MAC_ABORT = 0x23,
91  VAL_CRYPTO_ASYMMTERIC_ENCRYPT = 0x24,
92  VAL_CRYPTO_ASYMMTERIC_DECRYPT = 0x25,
93  VAL_CRYPTO_CIPHER_ENCRYPT_SETUP = 0x26,
94  VAL_CRYPTO_CIPHER_DECRYPT_SETUP = 0x2A,
95  VAL_CRYPTO_CIPHER_GENERATE_IV = 0x2B,
96  VAL_CRYPTO_CIPHER_SET_IV = 0x2C,
97  VAL_CRYPTO_CIPHER_UPDATE = 0x2D,
98  VAL_CRYPTO_CIPHER_FINISH = 0x2E,
99  VAL_CRYPTO_CIPHER_ABORT = 0x2F,
100  VAL_CRYPTO_ASYMMTERIC_SIGN = 0x30,
101  VAL_CRYPTO_ASYMMTERIC_VERIFY = 0x31,
102  VAL_CRYPTO_KEY_AGREEMENT = 0x32,
103  VAL_CRYPTO_ALLOCATE_KEY = 0x33,
104  VAL_CRYPTO_FREE = 0xFE,
105 };
106 
107 int32_t val_crypto_function(int type, ...);
108 #endif /* _VAL_CRYPTO_H_ */
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.