mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
psa: cipher: Move to driver operation context application allocation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
59
include/psa/crypto_builtin_cipher.h
Normal file
59
include/psa/crypto_builtin_cipher.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Context structure declaration of the software-based driver which performs
|
||||
* cipher operations through the PSA Crypto driver dispatch layer.
|
||||
*/
|
||||
/*
|
||||
* 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_CIPHER_H
|
||||
#define PSA_CRYPTO_BUILTIN_CIPHER_H
|
||||
|
||||
#include <psa/crypto_driver_common.h>
|
||||
#include "mbedtls/cipher.h"
|
||||
|
||||
typedef struct {
|
||||
/** Context structure for the Mbed TLS cipher implementation. */
|
||||
psa_algorithm_t alg;
|
||||
uint8_t iv_size;
|
||||
uint8_t block_size;
|
||||
mbedtls_cipher_context_t cipher;
|
||||
} mbedtls_psa_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}}
|
||||
|
||||
/*
|
||||
* BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY.
|
||||
*/
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
|
||||
typedef mbedtls_psa_cipher_operation_t
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int initialised : 1;
|
||||
mbedtls_transparent_test_driver_cipher_operation_t ctx;
|
||||
} mbedtls_opaque_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
{ 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* PSA_CRYPTO_BUILTIN_CIPHER_H */
|
@ -31,6 +31,7 @@
|
||||
|
||||
/* Include the context structure definitions for the Mbed TLS software drivers */
|
||||
#include "psa/crypto_builtin_hash.h"
|
||||
#include "psa/crypto_builtin_cipher.h"
|
||||
|
||||
/* Define the context to be used for an operation that is executed through the
|
||||
* PSA Driver wrapper layer as the union of all possible driver's contexts.
|
||||
@ -47,5 +48,17 @@ typedef union {
|
||||
#endif
|
||||
} psa_driver_hash_context_t;
|
||||
|
||||
typedef union {
|
||||
unsigned dummy; /* Make sure this structure is always non-empty */
|
||||
mbedtls_psa_cipher_operation_t mbedtls_ctx;
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
mbedtls_transparent_test_driver_cipher_operation_t
|
||||
transparent_test_driver_ctx;
|
||||
|
||||
mbedtls_opaque_test_driver_cipher_operation_t
|
||||
opaque_test_driver_ctx;
|
||||
#endif
|
||||
} psa_driver_cipher_context_t;
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_H */
|
||||
/* End of automatically generated file. */
|
||||
|
@ -65,18 +65,12 @@ extern "C" {
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "mbedtls/cipher.h"
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/gcm.h"
|
||||
|
||||
/* Include the context definition for the compiled-in drivers */
|
||||
#include "psa/crypto_driver_contexts.h"
|
||||
|
||||
typedef struct {
|
||||
/** Context structure for the assigned driver, when id is not zero. */
|
||||
void* ctx;
|
||||
} psa_operation_driver_context_t;
|
||||
|
||||
struct psa_hash_operation_s
|
||||
{
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
@ -136,14 +130,6 @@ static inline struct psa_mac_operation_s psa_mac_operation_init( void )
|
||||
return( v );
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
/** Context structure for the Mbed TLS cipher implementation. */
|
||||
psa_algorithm_t alg;
|
||||
uint8_t iv_size;
|
||||
uint8_t block_size;
|
||||
mbedtls_cipher_context_t cipher;
|
||||
} mbedtls_psa_cipher_operation_t;
|
||||
|
||||
struct psa_cipher_operation_s
|
||||
{
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
@ -156,12 +142,8 @@ struct psa_cipher_operation_s
|
||||
|
||||
unsigned int iv_required : 1;
|
||||
unsigned int iv_set : 1;
|
||||
union
|
||||
{
|
||||
unsigned dummy; /* Enable easier initializing of the union. */
|
||||
mbedtls_psa_cipher_operation_t mbedtls_ctx;
|
||||
psa_operation_driver_context_t driver;
|
||||
} ctx;
|
||||
|
||||
psa_driver_cipher_context_t ctx;
|
||||
};
|
||||
|
||||
#define PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}}
|
||||
|
Reference in New Issue
Block a user