AESCTRDRBGX4_s.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef ti_drivers_aesctrdrbg_AESCTRDRBGX4_s__include
34 #define ti_drivers_aesctrdrbg_AESCTRDRBGX4_s__include
35 
36 #include <stdint.h>
37 
39 #include <ti/drivers/AESCTRDRBG.h>
40 
41 #include <third_party/tfm/interface/include/psa/error.h>
42 #include <third_party/tfm/interface/include/psa/service.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /*
49  * AES CTR DRBG secure message types
50  *
51  * The underlying AES CTR DRBG driver does not support callback return behavior,
52  * therefore this secure service can only support polling mode. If the non-secure
53  * client specifies blocking mode, polling mode will be automatically substituted.
54  */
55 #define AESCTRDRBG_S_MSG_TYPE_CONSTRUCT \
56  (CRYPTO_S_MSG_TYPE_INDEX_AESCTRDRBG | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 0U)))
57 #define AESCTRDRBG_S_MSG_TYPE_OPEN (CRYPTO_S_MSG_TYPE_INDEX_AESCTRDRBG | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 1U)))
58 #define AESCTRDRBG_S_MSG_TYPE_CLOSE \
59  (CRYPTO_S_MSG_TYPE_INDEX_AESCTRDRBG | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 2U)))
60 #define AESCTRDRBG_S_MSG_TYPE_RESEED \
61  (CRYPTO_S_MSG_TYPE_INDEX_AESCTRDRBG | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 3U)))
62 #define AESCTRDRBG_S_MSG_TYPE_GET_RANDOM_BYTES \
63  (CRYPTO_S_MSG_TYPE_INDEX_AESCTRDRBG | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 4U)))
64 #define AESCTRDRBG_S_MSG_TYPE_GENERATE_KEY \
65  (CRYPTO_S_MSG_TYPE_INDEX_AESCTRDRBG | ((int32_t)1 << (CRYPTO_S_MSG_TYPE_SHIFT + 5U)))
66 
67 /*
68  * Config pool size determines how many dynamic driver instances can be created
69  * by the non-secure client using AESCTRDRBG_construct().
70  */
71 #ifndef CONFIG_AESCTRDRBG_S_CONFIG_POOL_SIZE
72  #define CONFIG_AESCTRDRBG_S_CONFIG_POOL_SIZE 1
73 #endif
74 
75 /*
76  * ========= AES CTR DRBG Secure Message Structs =========
77  * These secure message structs correspond to the secure message types defined
78  * above. Together, they are used by non-secure client to make PSA calls to the
79  * AES CTR DRBG secure service. There is a single input vector for the PSA call
80  * which is a pointer to secure message struct. If the underlying function
81  * has a return value, there is a single output vector which is a pointer to
82  * storage for the return value.
83  */
84 typedef struct
85 {
89 
90 typedef struct
91 {
92  uint_least8_t index;
95 
96 typedef struct
97 {
100 
101 typedef struct
102 {
104  const void *seed;
105  const void *additionalData;
108 
109 typedef struct
110 {
112  void *randomBytes;
115 
116 typedef struct
117 {
121 
132 psa_status_t AESCTRDRBG_s_handlePsaMsg(psa_msg_t *msg);
133 
139 void AESCTRDRBG_s_init(void);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif /* ti_drivers_aesctrdrbg_AESCTRDRBGX4_s__include */
AESCTRDRBG_Handle handle
Definition: AESCTRDRBGX4_s.h:118
size_t additionalDataLength
Definition: AESCTRDRBGX4_s.h:106
const void * additionalData
Definition: AESCTRDRBGX4_s.h:105
AESCTRDRBG_Handle handle
Definition: AESCTRDRBGX4_s.h:98
const AESCTRDRBG_Params * params
Definition: AESCTRDRBGX4_s.h:87
psa_status_t AESCTRDRBG_s_handlePsaMsg(psa_msg_t *msg)
Handles PSA messages for AES CTR DRBG secure driver.
AES Global configuration.
Definition: AESCommon.h:154
void AESCTRDRBG_s_init(void)
Initializes the AES CTR DRBG secure driver.
CryptoKey datastructure.
Definition: CryptoKey.h:192
const void * seed
Definition: AESCTRDRBGX4_s.h:104
Secure Crypto Service.
void * randomBytes
Definition: AESCTRDRBGX4_s.h:112
Definition: AESCTRDRBGX4_s.h:109
AESCTRDRBG Parameters.
Definition: AESCTRDRBG.h:442
Definition: AESCTRDRBGX4_s.h:90
Definition: AESCTRDRBGX4_s.h:116
Definition: AESCTRDRBGX4_s.h:96
Definition: AESCTRDRBGX4_s.h:101
AESCTRDRBG driver header.
uint_least8_t index
Definition: AESCTRDRBGX4_s.h:92
size_t randomBytesSize
Definition: AESCTRDRBGX4_s.h:113
const AESCTRDRBG_Params * params
Definition: AESCTRDRBGX4_s.h:93
AESCTRDRBG_Handle handle
Definition: AESCTRDRBGX4_s.h:111
CryptoKey * randomKey
Definition: AESCTRDRBGX4_s.h:119
AESCTRDRBG_Config * config
Definition: AESCTRDRBGX4_s.h:86
AESCTRDRBG_Handle handle
Definition: AESCTRDRBGX4_s.h:103
Definition: AESCTRDRBGX4_s.h:84
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale