crypto_contexts.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef PSA_CRYPTO_PSA_CRYPTO_CONTEXTS_H
21 #define PSA_CRYPTO_PSA_CRYPTO_CONTEXTS_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "kernel_defines.h"
28 
29 #include "psa/crypto_includes.h"
30 
31 
32 #if IS_USED(MODULE_PSA_HASH)
36 typedef union {
37 #if IS_USED(MODULE_PSA_HASH_MD5) || defined(DOXYGEN)
38  psa_hashes_md5_ctx_t md5;
39 #endif
40 #if IS_USED(MODULE_PSA_HASH_SHA_1) || defined(DOXYGEN)
42 #endif
43 #if IS_USED(MODULE_PSA_HASH_SHA_224) || defined(DOXYGEN)
45 #endif
46 #if IS_USED(MODULE_PSA_HASH_SHA_256) || defined(DOXYGEN)
48 #endif
49 #if IS_USED(MODULE_PSA_HASH_SHA_384) || defined(DOXYGEN)
50  psa_hashes_sha384_ctx_t sha384;
51 #endif
52 #if IS_USED(MODULE_PSA_HASH_SHA_512) || defined(DOXYGEN)
54 #endif
55 #if IS_USED(MODULE_PSA_HASH_SHA3_256) || IS_USED(MODULE_PSA_HASH_SHA3_384) \
56 || IS_USED(MODULE_PSA_HASH_SHA3_512) || defined(DOXYGEN)
57  psa_hashes_sha3_ctx_t sha3;
58 #endif
59 #if IS_USED(MODULE_PSA_HASH_SHA_512_224) || defined(DOXYGEN)
60  psa_hashes_sha512_224_ctx_t sha512_224;
61 #endif
62 #if IS_USED(MODULE_PSA_HASH_SHA_512_256) || defined(DOXYGEN)
63  psa_hashes_sha512_256_ctx_t sha512_256;
64 #endif
65 } psa_hash_context_t;
66 #endif
67 
68 #if IS_USED(MODULE_PSA_CIPHER)
72 typedef union {
73 #if IS_USED(MODULE_PSA_CIPHER_AES_128_ECB) ||\
74  IS_USED(MODULE_PSA_CIPHER_AES_128_CBC) ||\
75  defined(DOXYGEN)
76  psa_cipher_aes_128_ctx_t aes_128;
77 #endif
78 #if IS_USED(MODULE_PSA_CIPHER_AES_192_CBC) || defined(DOXYGEN)
79  psa_cipher_aes_192_ctx_t aes_192;
80 #endif
81 #if IS_USED(MODULE_PSA_CIPHER_AES_256_CBC) || defined(DOXYGEN)
82  psa_cipher_aes_256_ctx_t aes_256;
83 #endif
84 } psa_cipher_context_t;
85 #endif
86 
87 #if IS_USED(MODULE_PSA_SECURE_ELEMENT)
92 typedef struct {
93  psa_encrypt_or_decrypt_t direction;
95  union driver_context {
96  unsigned dummy;
97  #if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A) || defined(DOXYGEN)
98  atca_aes_cbc_ctx_t atca_aes_cbc;
99  #endif
100  } drv_ctx;
101 } psa_se_cipher_context_t;
102 #endif
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* PSA_CRYPTO_PSA_CRYPTO_CONTEXTS_H */
psa_encrypt_or_decrypt_t
For encrypt-decrypt functions, whether the operation is an encryption or a decryption.
Definition: crypto_types.h:37
void md5(void *digest, const void *data, size_t len)
Calculate a MD5 hash from the given data.
void sha1(void *digest, const void *data, size_t len)
Calculate a SHA1 hash from the given data.
void sha224(const void *data, size_t len, void *digest)
A wrapper function to simplify the generation of a hash, this is useful for generating sha224 for one...
void sha256(const void *data, size_t len, void *digest)
A wrapper function to simplify the generation of a hash, this is useful for generating sha256 for one...
void sha384(const void *data, size_t len, void *digest)
A wrapper function to simplify the generation of a hash.
void sha512_224(const void *data, size_t len, void *digest)
A wrapper function to simplify the generation of a hash.
void sha512_256(const void *data, size_t len, void *digest)
A wrapper function to simplify the generation of a hash.
void sha512(const void *data, size_t len, void *digest)
A wrapper function to simplify the generation of a hash.
Common macros and compiler attributes/pragmas configuration.
SaSiAesUserContext_t psa_cipher_aes_128_ctx_t
Map driver specific AES context to PSA context.
CRYS_HASHUserContext_t psa_hashes_sha224_ctx_t
Map driver specific SHA224 context to PSA context.
CRYS_HASHUserContext_t psa_hashes_sha256_ctx_t
Map driver specific SHA256 context to PSA context.
CRYS_HASHUserContext_t psa_hashes_sha512_ctx_t
Map driver specific SHA512 context to PSA context.
CRYS_HASHUserContext_t psa_hashes_sha1_ctx_t
Map driver specific SHA1 context to PSA context.