mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-11 14:15:39 +00:00
New header crypto_sizes.h
This header will contain macros that calculate buffer sizes, whose semantics are standardized but whose definitions are implementation-specific because they depend on the available algorithms and on some permitted buffer size tolerances. Move size macros from crypto_struct.h to crypto_sizes.h, because these definitions need to be available both in the frontend and in the backend, whereas structures have different contents.
This commit is contained in:
parent
0e60fd536e
commit
0cad07c2fb
|
@ -2070,6 +2070,10 @@ psa_status_t psa_generate_key(psa_key_slot_t key,
|
|||
}
|
||||
#endif
|
||||
|
||||
/* The file "crypto_sizes.h" contains definitions for size calculation
|
||||
* macros whose definitions are implementation-specific. */
|
||||
#include "crypto_sizes.h"
|
||||
|
||||
/* The file "crypto_struct.h" contains definitions for
|
||||
* implementation-specific structs that are declared above. */
|
||||
#include "crypto_struct.h"
|
||||
|
|
50
include/psa/crypto_sizes.h
Normal file
50
include/psa/crypto_sizes.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* \file psa/crypto_sizes.h
|
||||
*
|
||||
* \brief PSA cryptography module: Mbed TLS buffer size macros
|
||||
*
|
||||
* This file contains the definitions of macros that are useful to
|
||||
* compute buffer sizes. The signatures and semantics of these macros
|
||||
* are standardized, but the definitions are not, because they depend on
|
||||
* the available algorithms and, in some cases, on permitted tolerances
|
||||
* on buffer sizes.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2018, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#ifndef PSA_CRYPTO_SIZES_H
|
||||
#define PSA_CRYPTO_SIZES_H
|
||||
|
||||
/* Include the Mbed TLS configuration file, the way Mbed TLS does it
|
||||
* in each of its header files. */
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "../mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#define PSA_HASH_MAX_SIZE 64
|
||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
|
||||
#else
|
||||
#define PSA_HASH_MAX_SIZE 32
|
||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64
|
||||
#endif
|
||||
|
||||
#endif /* PSA_CRYPTO_SIZES_H */
|
|
@ -45,14 +45,6 @@
|
|||
#include "mbedtls/sha256.h"
|
||||
#include "mbedtls/sha512.h"
|
||||
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#define PSA_HASH_MAX_SIZE 64
|
||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
|
||||
#else
|
||||
#define PSA_HASH_MAX_SIZE 32
|
||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64
|
||||
#endif
|
||||
|
||||
struct psa_hash_operation_s
|
||||
{
|
||||
psa_algorithm_t alg;
|
||||
|
|
Loading…
Reference in a new issue