mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-26 06:53:52 +01:00
Split key attributes definitions into separate file, together with some basic support macros and helper functions. This allows PSA crypto backends to use this definitions without pulling in all the other type definitions. Signed-off-by: Armin Wolf <W_Armin@gmx.de>
191 lines
4.9 KiB
C
191 lines
4.9 KiB
C
/*
|
|
* Copyright (C) 2021 HAW Hamburg
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
* directory for more details.
|
|
*/
|
|
|
|
/**
|
|
* @ingroup sys_psa_crypto
|
|
* @{
|
|
*
|
|
* @file crypto_struct.h
|
|
* @brief Structure definitions for PSA Crypto
|
|
*
|
|
* @author Lena Boeckmann <lena.boeckmann@haw-hamburg.de>
|
|
*
|
|
*/
|
|
|
|
#ifndef PSA_CRYPTO_PSA_CRYPTO_STRUCT_H
|
|
#define PSA_CRYPTO_PSA_CRYPTO_STRUCT_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "crypto_types.h"
|
|
#include "crypto_sizes.h"
|
|
#include "crypto_contexts.h"
|
|
|
|
#if IS_USED(MODULE_PSA_AEAD) || defined(DOXYGEN)
|
|
/**
|
|
* @brief Structure storing an AEAD operation context
|
|
*
|
|
* @note Not implemented, yet
|
|
*/
|
|
struct psa_aead_operation_s {
|
|
int dummy; /**< Not implemented, yet */
|
|
};
|
|
|
|
/**
|
|
* @brief This macro returns a suitable initializer for an AEAD operation object of type
|
|
* @ref psa_aead_operation_t.
|
|
*/
|
|
#define PSA_AEAD_OPERATION_INIT { 0 }
|
|
|
|
/**
|
|
* @brief Return an initial value for an AEAD operation object.
|
|
*
|
|
* @return psa_aead_operation_s
|
|
*/
|
|
static inline struct psa_aead_operation_s psa_aead_operation_init(void)
|
|
{
|
|
const struct psa_aead_operation_s v = PSA_AEAD_OPERATION_INIT;
|
|
|
|
return v;
|
|
}
|
|
#endif /* MODULE_PSA_AEAD */
|
|
|
|
#if IS_USED(MODULE_PSA_CIPHER) || defined(DOXYGEN)
|
|
/**
|
|
* @brief Structure storing a cipher operation context
|
|
*/
|
|
struct psa_cipher_operation_s {
|
|
uint8_t iv_required : 1; /**< True if algorithm requires IV */
|
|
uint8_t iv_set : 1; /**< True if IV was already set */
|
|
uint8_t default_iv_length; /**< Default IV length for algorithm */
|
|
psa_algorithm_t alg; /**< Operation algorithm*/
|
|
/** Union containing cipher contexts for the executing backend */
|
|
union cipher_context {
|
|
psa_cipher_context_t cipher_ctx; /**< Cipher context */
|
|
#if IS_USED(MODULE_PSA_SECURE_ELEMENT_ATECCX08A) || defined(DOXYGEN)
|
|
psa_se_cipher_context_t se_ctx; /**< SE Cipher context */
|
|
#endif
|
|
} backend_ctx; /**< Backend specific cipher context */
|
|
};
|
|
|
|
/**
|
|
* @brief This macro returns a suitable initializer for a cipher operation
|
|
* object of type @ref psa_cipher_operation_t.
|
|
*/
|
|
#define PSA_CIPHER_OPERATION_INIT { 0 }
|
|
|
|
/**
|
|
* @brief Return an initial value for a cipher operation object.
|
|
*
|
|
* @return psa_cipher_operation_s
|
|
*/
|
|
static inline struct psa_cipher_operation_s psa_cipher_operation_init(void)
|
|
{
|
|
const struct psa_cipher_operation_s v = PSA_CIPHER_OPERATION_INIT;
|
|
|
|
return v;
|
|
}
|
|
#endif /* MODULE_PSA_CIPHER */
|
|
|
|
#if IS_USED(MODULE_PSA_KEY_DERIVATION) || defined(DOXYGEN)
|
|
/**
|
|
* @brief This macro returns a suitable initializer for a key derivation operation object of
|
|
* type @ref psa_key_derivation_operation_t.
|
|
*/
|
|
#define PSA_KEY_DERIVATION_OPERATION_INIT { 0 }
|
|
|
|
/**
|
|
* @brief Structure storing a key derivation context
|
|
*
|
|
* @note Not yet implemented
|
|
*/
|
|
struct psa_key_derivation_operation_s {
|
|
int dummy; /**< Not implemented yet */
|
|
};
|
|
|
|
/**
|
|
* @brief Return an initial value for a key derivation operation object.
|
|
*
|
|
* @return psa_key_derivation_operation_s
|
|
*/
|
|
static inline struct psa_key_derivation_operation_s psa_key_derivation_operation_init(void)
|
|
{
|
|
const struct psa_key_derivation_operation_s v = PSA_KEY_DERIVATION_OPERATION_INIT;
|
|
|
|
return v;
|
|
}
|
|
#endif /* MODULE_PSA_KEY_DERIVATION */
|
|
|
|
#if IS_USED(MODULE_PSA_HASH) || defined(DOXYGEN)
|
|
/**
|
|
* @brief Structure containing a hash context and algorithm
|
|
*/
|
|
struct psa_hash_operation_s {
|
|
psa_algorithm_t alg; /**< Operation algorithm */
|
|
#if IS_USED(MODULE_PSA_HASH)
|
|
psa_hash_context_t ctx; /**< Operation hash context */
|
|
#endif
|
|
};
|
|
|
|
/**
|
|
* @brief This macro returns a suitable initializer for a hash operation object of type
|
|
* @ref psa_hash_operation_t.
|
|
*/
|
|
#define PSA_HASH_OPERATION_INIT { 0 }
|
|
|
|
/**
|
|
* @brief Return an initial value for a hash operation object.
|
|
*
|
|
* @return struct psa_hash_operation_s
|
|
*/
|
|
static inline struct psa_hash_operation_s psa_hash_operation_init(void)
|
|
{
|
|
const struct psa_hash_operation_s v = PSA_HASH_OPERATION_INIT;
|
|
|
|
return v;
|
|
}
|
|
#endif /* MODULE_PSA_HASH */
|
|
|
|
#if IS_USED(MODULE_PSA_MAC) || defined(DOXYGEN)
|
|
/**
|
|
* @brief This macro returns a suitable initializer for a MAC operation object of type
|
|
* @ref psa_mac_operation_t.
|
|
*/
|
|
#define PSA_MAC_OPERATION_INIT { 0 }
|
|
|
|
/**
|
|
* @brief Structure storing a MAC operation context
|
|
*
|
|
* @note Not yet implemented
|
|
*/
|
|
struct psa_mac_operation_s {
|
|
int dummy; /**< Not yet implemented */
|
|
};
|
|
|
|
/**
|
|
* @brief Return an initial value for a MAC operation object.
|
|
*
|
|
* @return psa_mac_operation_s
|
|
*/
|
|
static inline struct psa_mac_operation_s psa_mac_operation_init(void)
|
|
{
|
|
const struct psa_mac_operation_s v = PSA_MAC_OPERATION_INIT;
|
|
|
|
return v;
|
|
}
|
|
#endif /* MODULE_PSA_MAC */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSA_CRYPTO_PSA_CRYPTO_STRUCT_H */
|
|
/** @} */
|