2021-04-26 12:16:27 +02:00
|
|
|
/*
|
|
|
|
* Context structure declaration of the Mbed TLS software-based PSA drivers
|
|
|
|
* called through the PSA Crypto driver dispatch layer.
|
|
|
|
* This file contains the context structures of those algorithms which need to
|
|
|
|
* rely on other algorithms, i.e. are 'composite' algorithms.
|
|
|
|
*
|
|
|
|
* \note This file may not be included directly. Applications must
|
|
|
|
* include psa/crypto.h.
|
|
|
|
*
|
|
|
|
* \note This header and its content is not part of the Mbed TLS API and
|
|
|
|
* applications must not depend on it. Its main purpose is to define the
|
|
|
|
* multi-part state objects of the Mbed TLS software-based PSA drivers. The
|
|
|
|
* definition of these objects are then used by crypto_struct.h to define the
|
|
|
|
* implementation-defined types of PSA multi-part state objects.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Copyright The Mbed TLS Contributors
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PSA_CRYPTO_BUILTIN_COMPOSITES_H
|
|
|
|
#define PSA_CRYPTO_BUILTIN_COMPOSITES_H
|
|
|
|
|
|
|
|
#include <psa/crypto_driver_common.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MAC multi-part operation definitions.
|
|
|
|
*/
|
2021-03-19 17:05:52 +01:00
|
|
|
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC) || \
|
|
|
|
defined(MBEDTLS_PSA_BUILTIN_ALG_HMAC)
|
|
|
|
#define MBEDTLS_PSA_BUILTIN_MAC
|
|
|
|
#endif
|
2021-04-26 12:16:27 +02:00
|
|
|
|
2021-03-19 17:05:52 +01:00
|
|
|
#if defined(PSA_WANT_ALG_HMAC)
|
2021-04-26 12:16:27 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2021-03-22 14:49:06 +01:00
|
|
|
/** The HMAC algorithm in use */
|
|
|
|
psa_algorithm_t alg;
|
|
|
|
/** The hash context. */
|
|
|
|
struct psa_hash_operation_s hash_ctx;
|
|
|
|
/** The HMAC part of the context. */
|
|
|
|
uint8_t opad[PSA_HMAC_MAX_HASH_BLOCK_SIZE];
|
|
|
|
} psa_hmac_internal_data_t;
|
2021-03-22 12:21:10 +01:00
|
|
|
|
2021-03-22 14:49:06 +01:00
|
|
|
#define MBEDTLS_PSA_HMAC_OPERATION_INIT {0, PSA_HASH_OPERATION_INIT, {0}}
|
2021-03-19 17:05:52 +01:00
|
|
|
#endif /* PSA_WANT_ALG_HMAC */
|
2021-04-26 12:16:27 +02:00
|
|
|
|
2021-03-19 15:24:23 +01:00
|
|
|
#include "mbedtls/cmac.h"
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
psa_algorithm_t alg;
|
2021-03-19 17:05:52 +01:00
|
|
|
unsigned int key_set : 1;
|
|
|
|
unsigned int iv_required : 1;
|
|
|
|
unsigned int iv_set : 1;
|
|
|
|
unsigned int has_input : 1;
|
|
|
|
unsigned int is_sign : 1;
|
|
|
|
uint8_t mac_size;
|
|
|
|
unsigned int id;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
|
|
|
|
#if defined(PSA_WANT_ALG_HMAC)
|
2021-03-22 14:49:06 +01:00
|
|
|
psa_hmac_internal_data_t hmac;
|
2021-03-19 17:05:52 +01:00
|
|
|
#endif
|
|
|
|
#if defined(MBEDTLS_CMAC_C)
|
|
|
|
mbedtls_cipher_context_t cmac;
|
|
|
|
#endif
|
|
|
|
} ctx;
|
2021-03-19 15:24:23 +01:00
|
|
|
} mbedtls_psa_mac_operation_t;
|
|
|
|
|
2021-03-19 17:05:52 +01:00
|
|
|
#define MBEDTLS_PSA_MAC_OPERATION_INIT {0, 0, 0, 0, 0, 0, 0, 0, {0}}
|
2021-03-19 15:24:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY.
|
|
|
|
*/
|
|
|
|
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
|
|
|
|
|
|
|
typedef mbedtls_psa_mac_operation_t mbedtls_transparent_test_driver_mac_operation_t;
|
|
|
|
typedef mbedtls_psa_mac_operation_t mbedtls_opaque_test_driver_mac_operation_t;
|
|
|
|
|
|
|
|
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT MBEDTLS_PSA_MAC_OPERATION_INIT
|
|
|
|
#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT MBEDTLS_PSA_MAC_OPERATION_INIT
|
|
|
|
|
|
|
|
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
|
|
|
|
2021-04-26 12:16:27 +02:00
|
|
|
#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
|