mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/psa_crypto: support for SHA-{384,512-{224,256}}
This commit is contained in:
parent
12180f5e80
commit
ecf259579a
@ -835,8 +835,14 @@ groups:
|
||||
help: SHA-224 hardware acceleration present.
|
||||
- name: periph_hash_sha_256
|
||||
help: SHA-256 hardware acceleration present.
|
||||
- name: periph_hash_sha_384
|
||||
help: SHA-384 hardware acceleration present.
|
||||
- name: periph_hash_sha_512
|
||||
help: SHA-512 hardware acceleration present.
|
||||
- name: periph_hash_sha_512_224
|
||||
help: SHA-512/224 hardware acceleration present.
|
||||
- name: periph_hash_sha_512_256
|
||||
help: SHA-512/256 hardware acceleration present.
|
||||
- name: periph_hmac_sha_256
|
||||
help: HMAC SHA-256 hardware acceleration present.
|
||||
- name: periph_hwrng
|
||||
|
@ -182,7 +182,10 @@ FEATURES_EXISTING := \
|
||||
periph_hash_sha_1 \
|
||||
periph_hash_sha_224 \
|
||||
periph_hash_sha_256 \
|
||||
periph_hash_sha_384 \
|
||||
periph_hash_sha_512 \
|
||||
periph_hash_sha_512_224 \
|
||||
periph_hash_sha_512_256 \
|
||||
periph_hmac_sha_256 \
|
||||
periph_hwrng \
|
||||
periph_i2c \
|
||||
|
@ -29,7 +29,10 @@ PERIPH_IGNORE_MODULES := \
|
||||
periph_hash_sha_1 \
|
||||
periph_hash_sha_224 \
|
||||
periph_hash_sha_256 \
|
||||
periph_hash_sha_384 \
|
||||
periph_hash_sha_512 \
|
||||
periph_hash_sha_512_224 \
|
||||
periph_hash_sha_512_256 \
|
||||
periph_hmac_sha_256 \
|
||||
periph_i2c_hw \
|
||||
periph_i2c_sw \
|
||||
|
@ -361,7 +361,10 @@ PSEUDOMODULES += psa_riot_hashes_md5
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_1
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_224
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_256
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_384
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_512
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_512_224
|
||||
PSEUDOMODULES += psa_riot_hashes_sha_512_256
|
||||
PSEUDOMODULES += psa_riot_hashes_hmac_sha256
|
||||
PSEUDOMODULES += fortuna_reseed
|
||||
PSEUDOMODULES += riotboot_%
|
||||
|
47
sys/hashes/psa_riot_hashes/sha_384.c
Normal file
47
sys/hashes/psa_riot_hashes/sha_384.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2023 TU Dresden
|
||||
*
|
||||
* 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
|
||||
* @{
|
||||
*
|
||||
* @brief Glue code translating between PSA Crypto and the RIOT Hash module
|
||||
*
|
||||
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "psa/crypto.h"
|
||||
#include "hashes/psa/riot_hashes.h"
|
||||
|
||||
psa_status_t psa_hashes_sha384_setup(psa_hashes_sha384_ctx_t *ctx)
|
||||
{
|
||||
sha384_init((sha384_context_t *)ctx);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
psa_status_t psa_hashes_sha384_update(psa_hashes_sha384_ctx_t *ctx,
|
||||
const uint8_t *input,
|
||||
size_t input_length)
|
||||
{
|
||||
sha384_update((sha384_context_t *)ctx, input, input_length);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
psa_status_t psa_hashes_sha384_finish(psa_hashes_sha384_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length)
|
||||
{
|
||||
sha384_final((sha384_context_t *)ctx, hash);
|
||||
|
||||
(void)hash_size;
|
||||
(void)hash_length;
|
||||
return PSA_SUCCESS;
|
||||
}
|
47
sys/hashes/psa_riot_hashes/sha_512_224.c
Normal file
47
sys/hashes/psa_riot_hashes/sha_512_224.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2023 TU Dresden
|
||||
*
|
||||
* 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
|
||||
* @{
|
||||
*
|
||||
* @brief Glue code translating between PSA Crypto and the RIOT Hash module
|
||||
*
|
||||
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "psa/crypto.h"
|
||||
#include "hashes/psa/riot_hashes.h"
|
||||
|
||||
psa_status_t psa_hashes_sha512_224_setup(psa_hashes_sha512_224_ctx_t *ctx)
|
||||
{
|
||||
sha512_224_init((sha512_224_context_t *)ctx);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
psa_status_t psa_hashes_sha512_224_update(psa_hashes_sha512_224_ctx_t *ctx,
|
||||
const uint8_t *input,
|
||||
size_t input_length)
|
||||
{
|
||||
sha512_224_update((sha512_224_context_t *)ctx, input, input_length);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
psa_status_t psa_hashes_sha512_224_finish(psa_hashes_sha512_224_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length)
|
||||
{
|
||||
sha512_224_final((sha512_224_context_t *)ctx, hash);
|
||||
|
||||
(void)hash_size;
|
||||
(void)hash_length;
|
||||
return PSA_SUCCESS;
|
||||
}
|
47
sys/hashes/psa_riot_hashes/sha_512_256.c
Normal file
47
sys/hashes/psa_riot_hashes/sha_512_256.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2023 TU Dresden
|
||||
*
|
||||
* 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
|
||||
* @{
|
||||
*
|
||||
* @brief Glue code translating between PSA Crypto and the RIOT Hash module
|
||||
*
|
||||
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "psa/crypto.h"
|
||||
#include "hashes/psa/riot_hashes.h"
|
||||
|
||||
psa_status_t psa_hashes_sha512_256_setup(psa_hashes_sha512_256_ctx_t *ctx)
|
||||
{
|
||||
sha512_256_init((sha512_256_context_t *)ctx);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
psa_status_t psa_hashes_sha512_256_update(psa_hashes_sha512_256_ctx_t *ctx,
|
||||
const uint8_t *input,
|
||||
size_t input_length)
|
||||
{
|
||||
sha512_256_update((sha512_256_context_t *)ctx, input, input_length);
|
||||
return PSA_SUCCESS;
|
||||
}
|
||||
|
||||
psa_status_t psa_hashes_sha512_256_finish(psa_hashes_sha512_256_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length)
|
||||
{
|
||||
sha512_256_final((sha512_256_context_t *)ctx, hash);
|
||||
|
||||
(void)hash_size;
|
||||
(void)hash_length;
|
||||
return PSA_SUCCESS;
|
||||
}
|
@ -49,12 +49,30 @@ typedef sha224_context_t psa_hashes_sha224_ctx_t;
|
||||
typedef sha256_context_t psa_hashes_sha256_ctx_t;
|
||||
#endif
|
||||
|
||||
#if (IS_USED(MODULE_PSA_RIOT_HASHES_SHA_384))
|
||||
#include "hashes/sha384.h"
|
||||
|
||||
typedef sha384_context_t psa_hashes_sha384_ctx_t;
|
||||
#endif
|
||||
|
||||
#if (IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512))
|
||||
#include "hashes/sha512.h"
|
||||
|
||||
typedef sha512_context_t psa_hashes_sha512_ctx_t;
|
||||
#endif
|
||||
|
||||
#if (IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512_224))
|
||||
#include "hashes/sha512_224.h"
|
||||
|
||||
typedef sha512_224_context_t psa_hashes_sha512_224_ctx_t;
|
||||
#endif
|
||||
|
||||
#if (IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512_256))
|
||||
#include "hashes/sha512_256.h"
|
||||
|
||||
typedef sha512_256_context_t psa_hashes_sha512_256_ctx_t;
|
||||
#endif
|
||||
|
||||
#if (IS_USED(MODULE_PSA_RIOT_HASHES_HMAC_SHA256))
|
||||
#include "hashes/sha256.h"
|
||||
#endif
|
||||
|
@ -46,9 +46,18 @@ typedef union {
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_256) || defined(DOXYGEN)
|
||||
psa_hashes_sha256_ctx_t sha256; /**< SHA-256 context */
|
||||
#endif
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_384) || defined(DOXYGEN)
|
||||
psa_hashes_sha384_ctx_t sha384; /**< SHA-384 context */
|
||||
#endif
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_512) || defined(DOXYGEN)
|
||||
psa_hashes_sha512_ctx_t sha512; /**< SHA-512 context */
|
||||
#endif
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_512_224) || defined(DOXYGEN)
|
||||
psa_hashes_sha512_224_ctx_t sha512_224; /**< SHA-512/224 context */
|
||||
#endif
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_512_256) || defined(DOXYGEN)
|
||||
psa_hashes_sha512_256_ctx_t sha512_256; /**< SHA-512/256 context */
|
||||
#endif
|
||||
} psa_hash_context_t;
|
||||
#endif
|
||||
|
||||
|
@ -31,7 +31,9 @@ extern "C" {
|
||||
|
||||
#if IS_USED(MODULE_PSA_RIOT_HASHES_HMAC_SHA256) || IS_USED(MODULE_PSA_RIOT_HASHES_MD5) || \
|
||||
IS_USED(MODULE_PSA_RIOT_HASHES_SHA_1) || IS_USED(MODULE_PSA_RIOT_HASHES_SHA_224) || \
|
||||
IS_USED(MODULE_PSA_RIOT_HASHES_SHA_256) || IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512)
|
||||
IS_USED(MODULE_PSA_RIOT_HASHES_SHA_256) || IS_USED(MODULE_PSA_RIOT_HASHES_SHA_384) || \
|
||||
IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512) || IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512_224) || \
|
||||
IS_USED(MODULE_PSA_RIOT_HASHES_SHA_512_256)
|
||||
#include "hashes/psa/riot_hashes.h"
|
||||
#endif
|
||||
|
||||
@ -40,7 +42,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if IS_USED(MODULE_PERIPH_HASH_SHA_1) || IS_USED(MODULE_PERIPH_HASH_SHA_224) || \
|
||||
IS_USED(MODULE_PERIPH_HASH_SHA_256) || IS_USED(MODULE_PERIPH_HASH_SHA_512)
|
||||
IS_USED(MODULE_PERIPH_HASH_SHA_256) || IS_USED(MODULE_PERIPH_HASH_SHA_384) || \
|
||||
IS_USED(MODULE_PERIPH_HASH_SHA_512) || IS_USED(MODULE_PERIPH_HASH_SHA_512_224) || \
|
||||
IS_USED(MODULE_PERIPH_HASH_SHA_512_256)
|
||||
#include "psa_periph_hashes_ctx.h"
|
||||
#endif
|
||||
|
||||
|
@ -228,6 +228,30 @@ ifneq (,$(filter psa_hash_sha_256_backend_riot,$(USEMODULE)))
|
||||
USEMODULE += psa_riot_hashes_sha_256
|
||||
endif
|
||||
|
||||
## SHA-384
|
||||
ifneq (,$(filter psa_hash_sha_384,$(USEMODULE)))
|
||||
ifeq (,$(filter psa_hash_sha_384_custom_backend,$(USEMODULE)))
|
||||
FEATURES_OPTIONAL += periph_hash_sha_384
|
||||
include $(RIOTMAKE)/features_check.inc.mk
|
||||
# HACK: Due to kconfig migration, may cause problems
|
||||
ifneq (,$(filter periph_hash_sha_384,$(FEATURES_USED)))
|
||||
USEMODULE += psa_hash_sha_384_backend_periph
|
||||
else
|
||||
USEMODULE += psa_hash_sha_384_backend_riot
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter psa_hash_sha_384_backend_periph,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_hash_sha_384
|
||||
endif
|
||||
|
||||
ifneq (,$(filter psa_hash_sha_384_backend_riot,$(USEMODULE)))
|
||||
USEMODULE += hashes
|
||||
USEMODULE += psa_riot_hashes
|
||||
USEMODULE += psa_riot_hashes_sha_384
|
||||
endif
|
||||
|
||||
## SHA-512
|
||||
ifneq (,$(filter psa_hash_sha_512,$(USEMODULE)))
|
||||
ifeq (,$(filter psa_hash_sha_512_custom_backend,$(USEMODULE)))
|
||||
@ -251,6 +275,55 @@ ifneq (,$(filter psa_hash_sha_512_backend_riot,$(USEMODULE)))
|
||||
USEMODULE += psa_riot_hashes
|
||||
USEMODULE += psa_riot_hashes_sha_512
|
||||
endif
|
||||
|
||||
## SHA-512/224
|
||||
ifneq (,$(filter psa_hash_sha_512_224,$(USEMODULE)))
|
||||
ifeq (,$(filter psa_hash_sha_512_224_custom_backend,$(USEMODULE)))
|
||||
FEATURES_OPTIONAL += periph_hash_sha_512_224
|
||||
include $(RIOTMAKE)/features_check.inc.mk
|
||||
# HACK: Due to kconfig migration, may cause problems
|
||||
ifneq (,$(filter periph_hash_sha_512_224,$(FEATURES_USED)))
|
||||
USEMODULE += psa_hash_sha_512_224_backend_periph
|
||||
else
|
||||
USEMODULE += psa_hash_sha_512_224_backend_riot
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter psa_hash_sha_512_224_backend_periph,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_hash_sha_512_224
|
||||
endif
|
||||
|
||||
ifneq (,$(filter psa_hash_sha_512_224_backend_riot,$(USEMODULE)))
|
||||
USEMODULE += hashes
|
||||
USEMODULE += psa_riot_hashes
|
||||
USEMODULE += psa_riot_hashes_sha_512_224
|
||||
endif
|
||||
|
||||
## SHA-512/256
|
||||
ifneq (,$(filter psa_hash_sha_512_256,$(USEMODULE)))
|
||||
ifeq (,$(filter psa_hash_sha_512_256_custom_backend,$(USEMODULE)))
|
||||
FEATURES_OPTIONAL += periph_hash_sha_512_256
|
||||
include $(RIOTMAKE)/features_check.inc.mk
|
||||
# HACK: Due to kconfig migration, may cause problems
|
||||
ifneq (,$(filter periph_hash_sha_512_256,$(FEATURES_USED)))
|
||||
USEMODULE += psa_hash_sha_512_256_backend_periph
|
||||
else
|
||||
USEMODULE += psa_hash_sha_512_256_backend_riot
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter psa_hash_sha_512_256_backend_periph,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_hash_sha_512_256
|
||||
endif
|
||||
|
||||
ifneq (,$(filter psa_hash_sha_512_256_backend_riot,$(USEMODULE)))
|
||||
USEMODULE += hashes
|
||||
USEMODULE += psa_riot_hashes
|
||||
USEMODULE += psa_riot_hashes_sha_512_256
|
||||
endif
|
||||
|
||||
# Key Management
|
||||
ifneq (,$(filter psa_key_management,$(USEMODULE)))
|
||||
USEMODULE += psa_key_slot_mgmt
|
||||
|
@ -134,6 +134,18 @@ ifneq (,$(filter psa_hash_sha_256,$(USEMODULE)))
|
||||
endif
|
||||
endif
|
||||
|
||||
PSEUDOMODULES += psa_hash_sha_384
|
||||
PSEUDOMODULES += psa_hash_sha_384_backend_periph
|
||||
PSEUDOMODULES += psa_hash_sha_384_backend_riot
|
||||
PSEUDOMODULES += psa_hash_sha_384_custom_backend
|
||||
|
||||
# check that one and only one backend has been selected
|
||||
ifneq (,$(filter psa_hash_sha_384,$(USEMODULE)))
|
||||
ifneq (1,$(call backends,psa_hash_sha_384))
|
||||
$(error "One (and only one) backend should be selected for psa_hash_sha_384")
|
||||
endif
|
||||
endif
|
||||
|
||||
PSEUDOMODULES += psa_hash_sha_512
|
||||
PSEUDOMODULES += psa_hash_sha_512_backend_periph
|
||||
PSEUDOMODULES += psa_hash_sha_512_backend_riot
|
||||
@ -146,6 +158,30 @@ ifneq (,$(filter psa_hash_sha_512,$(USEMODULE)))
|
||||
endif
|
||||
endif
|
||||
|
||||
PSEUDOMODULES += psa_hash_sha_512_224
|
||||
PSEUDOMODULES += psa_hash_sha_512_224_backend_periph
|
||||
PSEUDOMODULES += psa_hash_sha_512_224_backend_riot
|
||||
PSEUDOMODULES += psa_hash_sha_512_224_custom_backend
|
||||
|
||||
# check that one and only one backend has been selected
|
||||
ifneq (,$(filter psa_hash_sha_512_224,$(USEMODULE)))
|
||||
ifneq (1,$(call backends,psa_hash_sha_512_224))
|
||||
$(error "One (and only one) backend should be selected for psa_hash_sha_512_224")
|
||||
endif
|
||||
endif
|
||||
|
||||
PSEUDOMODULES += psa_hash_sha_512_256
|
||||
PSEUDOMODULES += psa_hash_sha_512_256_backend_periph
|
||||
PSEUDOMODULES += psa_hash_sha_512_256_backend_riot
|
||||
PSEUDOMODULES += psa_hash_sha_512_256_custom_backend
|
||||
|
||||
# check that one and only one backend has been selected
|
||||
ifneq (,$(filter psa_hash_sha_512_256,$(USEMODULE)))
|
||||
ifneq (1,$(call backends,psa_hash_sha_512_256))
|
||||
$(error "One (and only one) backend should be selected for psa_hash_sha_512_256")
|
||||
endif
|
||||
endif
|
||||
|
||||
## Key Management
|
||||
PSEUDOMODULES += psa_key_management
|
||||
|
||||
|
@ -312,12 +312,30 @@
|
||||
* - psa_hash_sha_256_custom_backend
|
||||
* - psa_hash_sha_256_backend_riot
|
||||
*
|
||||
* #### SHA 384
|
||||
* - psa_hash_sha_384
|
||||
* - psa_hash_sha_384_backend_periph
|
||||
* - psa_hash_sha_384_custom_backend
|
||||
* - psa_hash_sha_384_backend_riot
|
||||
*
|
||||
* #### SHA 512
|
||||
* - psa_hash_sha_512
|
||||
* - psa_hash_sha_512_backend_periph
|
||||
* - psa_hash_sha_512_custom_backend
|
||||
* - psa_hash_sha_512_backend_riot
|
||||
*
|
||||
* #### SHA 512/224
|
||||
* - psa_hash_sha_512_224
|
||||
* - psa_hash_sha_512_224_backend_periph
|
||||
* - psa_hash_sha_512_224_custom_backend
|
||||
* - psa_hash_sha_512_224_backend_riot
|
||||
*
|
||||
* #### SHA 512/256
|
||||
* - psa_hash_sha_512_256
|
||||
* - psa_hash_sha_512_256_backend_periph
|
||||
* - psa_hash_sha_512_256_custom_backend
|
||||
* - psa_hash_sha_512_256_backend_riot
|
||||
*
|
||||
* ### MAC
|
||||
* - Base: psa_mac
|
||||
*
|
||||
@ -469,7 +487,7 @@
|
||||
* USEMODULE += psa_riot_hashes_sha_256
|
||||
*
|
||||
* will build the file at `sys/hashes/psa_riot_hashes/sha_256.c`, but none of the other files in
|
||||
* the directory).
|
||||
* the directory.
|
||||
*
|
||||
* To enable submodules for your implementation add the following to the directory makefile:
|
||||
* @code
|
||||
@ -568,7 +586,10 @@
|
||||
* - `psa_hashes_sha1_ctx_t`
|
||||
* - `psa_hashes_sha224_ctx_t`
|
||||
* - `psa_hashes_sha256_ctx_t`
|
||||
* - `psa_hashes_sha384_ctx_t`
|
||||
* - `psa_hashes_sha512_ctx_t`
|
||||
* - `psa_hashes_sha512_224_ctx_t`
|
||||
* - `psa_hashes_sha512_256_ctx_t`
|
||||
*
|
||||
* #### Ciphers
|
||||
* - `psa_cipher_aes_128_ctx_t`
|
||||
|
@ -66,7 +66,7 @@ psa_status_t psa_hashes_md5_finish(psa_hashes_md5_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* CONFIG_HASHES_MD5 */
|
||||
#endif /* MODULE_PSA_HASH_MD5 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_1) || defined(DOXYGEN)
|
||||
/**
|
||||
@ -105,7 +105,7 @@ psa_status_t psa_hashes_sha1_finish(psa_hashes_sha1_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* CONFIG_HASHES_SHA1 */
|
||||
#endif /* MODULE_PSA_HASH_SHA_1 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_224) || defined(DOXYGEN)
|
||||
/**
|
||||
@ -144,7 +144,7 @@ psa_status_t psa_hashes_sha224_finish(psa_hashes_sha224_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* CONFIG_HASHES_SHA224 */
|
||||
#endif /* MODULE_PSA_HASH_SHA_224 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_256) || defined(DOXYGEN)
|
||||
/**
|
||||
@ -183,7 +183,46 @@ psa_status_t psa_hashes_sha256_finish(psa_hashes_sha256_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* CONFIG_HASHES_SHA256 */
|
||||
#endif /* MODULE_PSA_HASH_SHA_256 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_384) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA384 hash setup
|
||||
* See @ref psa_hash_setup()
|
||||
*
|
||||
* @param ctx
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha384_setup(psa_hashes_sha384_ctx_t *ctx);
|
||||
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA384 hash update
|
||||
* See @ref psa_hash_update()
|
||||
*
|
||||
* @param ctx
|
||||
* @param input
|
||||
* @param input_length
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha384_update(psa_hashes_sha384_ctx_t *ctx,
|
||||
const uint8_t *input,
|
||||
size_t input_length);
|
||||
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA384 hash finish
|
||||
* See @ref psa_hash_finish()
|
||||
*
|
||||
* @param ctx
|
||||
* @param hash
|
||||
* @param hash_size
|
||||
* @param hash_length
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha384_finish(psa_hashes_sha384_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* MODULE_PSA_HASH_SHA_384 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_512) || defined(DOXYGEN)
|
||||
/**
|
||||
@ -222,7 +261,85 @@ psa_status_t psa_hashes_sha512_finish(psa_hashes_sha512_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* CONFIG_HASHES_SHA512 */
|
||||
#endif /* MODULE_PSA_HASH_SHA_512 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_512_224) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA512/224 hash setup
|
||||
* See @ref psa_hash_setup()
|
||||
*
|
||||
* @param ctx
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha512_224_setup(psa_hashes_sha512_224_ctx_t *ctx);
|
||||
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA512/224 hash update
|
||||
* See @ref psa_hash_update()
|
||||
*
|
||||
* @param ctx
|
||||
* @param input
|
||||
* @param input_length
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha512_224_update(psa_hashes_sha512_224_ctx_t *ctx,
|
||||
const uint8_t *input,
|
||||
size_t input_length);
|
||||
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA512/224 hash finish
|
||||
* See @ref psa_hash_finish()
|
||||
*
|
||||
* @param ctx
|
||||
* @param hash
|
||||
* @param hash_size
|
||||
* @param hash_length
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha512_224_finish(psa_hashes_sha512_224_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* MODULE_PSA_HASH_SHA_512_224 */
|
||||
|
||||
#if IS_USED(MODULE_PSA_HASH_SHA_512_256) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA512/256 hash setup
|
||||
* See @ref psa_hash_setup()
|
||||
*
|
||||
* @param ctx
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha512_256_setup(psa_hashes_sha512_256_ctx_t *ctx);
|
||||
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA512/256 hash update
|
||||
* See @ref psa_hash_update()
|
||||
*
|
||||
* @param ctx
|
||||
* @param input
|
||||
* @param input_length
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha512_256_update(psa_hashes_sha512_256_ctx_t *ctx,
|
||||
const uint8_t *input,
|
||||
size_t input_length);
|
||||
|
||||
/**
|
||||
* @brief Low level wrapper function to call a driver for an SHA512/256 hash finish
|
||||
* See @ref psa_hash_finish()
|
||||
*
|
||||
* @param ctx
|
||||
* @param hash
|
||||
* @param hash_size
|
||||
* @param hash_length
|
||||
* @return psa_status_t
|
||||
*/
|
||||
psa_status_t psa_hashes_sha512_256_finish(psa_hashes_sha512_256_ctx_t *ctx,
|
||||
uint8_t *hash,
|
||||
size_t hash_size,
|
||||
size_t *hash_length);
|
||||
#endif /* MODULE_PSA_HASH_SHA_512_256 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -81,6 +81,14 @@ psa_status_t psa_algorithm_dispatch_hash_setup(psa_hash_operation_t *operation,
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_384))
|
||||
case PSA_ALG_SHA_384:
|
||||
status = psa_hashes_sha384_setup(&operation->ctx.sha384);
|
||||
if (status != PSA_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512))
|
||||
case PSA_ALG_SHA_512:
|
||||
status = psa_hashes_sha512_setup(&operation->ctx.sha512);
|
||||
@ -89,6 +97,22 @@ psa_status_t psa_algorithm_dispatch_hash_setup(psa_hash_operation_t *operation,
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512_224))
|
||||
case PSA_ALG_SHA_512_224:
|
||||
status = psa_hashes_sha512_224_setup(&operation->ctx.sha512_224);
|
||||
if (status != PSA_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512_256))
|
||||
case PSA_ALG_SHA_512_256:
|
||||
status = psa_hashes_sha512_256_setup(&operation->ctx.sha512_256);
|
||||
if (status != PSA_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
(void)status;
|
||||
(void)operation;
|
||||
@ -120,10 +144,22 @@ psa_status_t psa_algorithm_dispatch_hash_update(psa_hash_operation_t *operation,
|
||||
case PSA_ALG_SHA_256:
|
||||
return psa_hashes_sha256_update(&operation->ctx.sha256, input, input_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_384))
|
||||
case PSA_ALG_SHA_384:
|
||||
return psa_hashes_sha384_update(&operation->ctx.sha384, input, input_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512))
|
||||
case PSA_ALG_SHA_512:
|
||||
return psa_hashes_sha512_update(&operation->ctx.sha512, input, input_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512_224))
|
||||
case PSA_ALG_SHA_512_224:
|
||||
return psa_hashes_sha512_224_update(&operation->ctx.sha512_224, input, input_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512_256))
|
||||
case PSA_ALG_SHA_512_256:
|
||||
return psa_hashes_sha512_256_update(&operation->ctx.sha512_256, input, input_length);
|
||||
#endif
|
||||
default:
|
||||
(void)operation;
|
||||
(void)input;
|
||||
@ -154,10 +190,22 @@ psa_status_t psa_algorithm_dispatch_hash_finish(psa_hash_operation_t *operation,
|
||||
case PSA_ALG_SHA_256:
|
||||
return psa_hashes_sha256_finish(&operation->ctx.sha256, hash, hash_size, hash_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_384))
|
||||
case PSA_ALG_SHA_384:
|
||||
return psa_hashes_sha384_finish(&operation->ctx.sha384, hash, hash_size, hash_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512))
|
||||
case PSA_ALG_SHA_512:
|
||||
return psa_hashes_sha512_finish(&operation->ctx.sha512, hash, hash_size, hash_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512_224))
|
||||
case PSA_ALG_SHA_512_224:
|
||||
return psa_hashes_sha512_224_finish(&operation->ctx.sha512_224, hash, hash_size, hash_length);
|
||||
#endif
|
||||
#if (IS_USED(MODULE_PSA_HASH_SHA_512_256))
|
||||
case PSA_ALG_SHA_512_256:
|
||||
return psa_hashes_sha512_256_finish(&operation->ctx.sha512_256, hash, hash_size, hash_length);
|
||||
#endif
|
||||
default:
|
||||
(void)operation;
|
||||
(void)hash;
|
||||
|
Loading…
Reference in New Issue
Block a user