blob: 1c6e4c526474dbed1e27cdc22bb785c99503cab1 [file] [log] [blame]
Ronald Cron7cb9c3d2021-03-10 12:21:48 +01001/*
2 * Context structure declaration of the software-based driver which performs
3 * cipher operations through the PSA Crypto driver dispatch layer.
4 */
5/*
6 * Copyright The Mbed TLS Contributors
7 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22#ifndef PSA_CRYPTO_BUILTIN_CIPHER_H
23#define PSA_CRYPTO_BUILTIN_CIPHER_H
24
25#include <psa/crypto_driver_common.h>
26#include "mbedtls/cipher.h"
27
28typedef struct {
29 /** Context structure for the Mbed TLS cipher implementation. */
30 psa_algorithm_t alg;
31 uint8_t iv_size;
32 uint8_t block_size;
33 mbedtls_cipher_context_t cipher;
34} mbedtls_psa_cipher_operation_t;
35
36#define MBEDTLS_PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}}
37
38/*
39 * BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY.
40 */
41#if defined(PSA_CRYPTO_DRIVER_TEST)
42
43typedef mbedtls_psa_cipher_operation_t
44 mbedtls_transparent_test_driver_cipher_operation_t;
45
46typedef struct {
47 unsigned int initialised : 1;
48 mbedtls_transparent_test_driver_cipher_operation_t ctx;
49} mbedtls_opaque_test_driver_cipher_operation_t;
50
51#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
52 MBEDTLS_PSA_CIPHER_OPERATION_INIT
53
54#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
55 { 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
56
57#endif /* PSA_CRYPTO_DRIVER_TEST */
58
59#endif /* PSA_CRYPTO_BUILTIN_CIPHER_H */