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 
9 #pragma once
10 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include "kernel_defines.h"
27 
28 #include "psa/crypto_includes.h"
29 
30 #if IS_USED(MODULE_PSA_HASH)
34 typedef union {
35 #if IS_USED(MODULE_PSA_HASH_MD5) || defined(DOXYGEN)
36  psa_hashes_md5_ctx_t md5;
37 #endif
38 #if IS_USED(MODULE_PSA_HASH_SHA_1) || defined(DOXYGEN)
40 #endif
41 #if IS_USED(MODULE_PSA_HASH_SHA_224) || defined(DOXYGEN)
43 #endif
44 #if IS_USED(MODULE_PSA_HASH_SHA_256) || defined(DOXYGEN)
46 #endif
47 #if IS_USED(MODULE_PSA_HASH_SHA_384) || defined(DOXYGEN)
48  psa_hashes_sha384_ctx_t sha384;
49 #endif
50 #if IS_USED(MODULE_PSA_HASH_SHA_512) || defined(DOXYGEN)
52 #endif
53 #if IS_USED(MODULE_PSA_HASH_SHA3_256) || IS_USED(MODULE_PSA_HASH_SHA3_384) \
54 || IS_USED(MODULE_PSA_HASH_SHA3_512) || defined(DOXYGEN)
55  psa_hashes_sha3_ctx_t sha3;
56 #endif
57 #if IS_USED(MODULE_PSA_HASH_SHA_512_224) || defined(DOXYGEN)
58  psa_hashes_sha512_224_ctx_t sha512_224;
59 #endif
60 #if IS_USED(MODULE_PSA_HASH_SHA_512_256) || defined(DOXYGEN)
61  psa_hashes_sha512_256_ctx_t sha512_256;
62 #endif
63 } psa_hash_context_t;
64 #endif
65 
66 #if IS_USED(MODULE_PSA_CIPHER)
70 typedef union {
71 #if IS_USED(MODULE_PSA_CIPHER_AES_128_ECB) ||\
72  IS_USED(MODULE_PSA_CIPHER_AES_128_CBC) ||\
73  defined(DOXYGEN)
74  psa_cipher_aes_128_ctx_t aes_128;
75 #endif
76 #if IS_USED(MODULE_PSA_CIPHER_AES_192_CBC) || defined(DOXYGEN)
77  psa_cipher_aes_192_ctx_t aes_192;
78 #endif
79 #if IS_USED(MODULE_PSA_CIPHER_AES_256_CBC) || defined(DOXYGEN)
80  psa_cipher_aes_256_ctx_t aes_256;
81 #endif
82 } psa_cipher_context_t;
83 #endif
84 
85 #if IS_USED(MODULE_PSA_SECURE_ELEMENT)
90 typedef struct {
91  psa_encrypt_or_decrypt_t direction;
93  union driver_context {
94  unsigned dummy;
95  #if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A) || defined(DOXYGEN)
96  atca_aes_cbc_ctx_t atca_aes_cbc;
97  #endif
98  } drv_ctx;
99 } psa_se_cipher_context_t;
100 #endif
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
psa_encrypt_or_decrypt_t
For encrypt-decrypt functions, whether the operation is an encryption or a decryption.
Definition: crypto_types.h:36
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.