blob: 9e70512d73755d60fd67d74f0aaad4cc64f1f97e [file] [log] [blame]
Gilles Peskine9ef733f2018-02-07 21:05:37 +01001/**
2 * \file psa/crypto_struct.h
3 *
4 * \brief PSA cryptography module: Mbed TLS structured type implementations
5 */
6/*
7 * Copyright (C) 2018, ARM Limited, All Rights Reserved
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 *
22 * This file is part of mbed TLS (https://tls.mbed.org)
23 */
24
25#ifndef PSA_CRYPTO_STRUCT_H
26#define PSA_CRYPTO_STRUCT_H
27
28/* Include the Mbed TLS configuration file, the way Mbed TLS does it
29 * in each of its header files. */
30#if !defined(MBEDTLS_CONFIG_FILE)
31#include "../mbedtls/config.h"
32#else
33#include MBEDTLS_CONFIG_FILE
34#endif
35
36#include "mbedtls/cipher.h"
37#include "mbedtls/cmac.h"
38#include "mbedtls/gcm.h"
39#include "mbedtls/md.h"
40#include "mbedtls/md2.h"
41#include "mbedtls/md4.h"
42#include "mbedtls/md5.h"
43#include "mbedtls/ripemd160.h"
44#include "mbedtls/sha1.h"
45#include "mbedtls/sha256.h"
46#include "mbedtls/sha512.h"
47
48struct psa_hash_operation_s
49{
50 psa_algorithm_t alg;
51 union
52 {
53#if defined(MBEDTLS_MD2_C)
54 mbedtls_md2_context md2;
55#endif
56#if defined(MBEDTLS_MD4_C)
57 mbedtls_md4_context md4;
58#endif
59#if defined(MBEDTLS_MD5_C)
60 mbedtls_md5_context md5;
61#endif
62#if defined(MBEDTLS_RIPEMD160_C)
63 mbedtls_ripemd160_context ripemd160;
64#endif
65#if defined(MBEDTLS_SHA1_C)
66 mbedtls_sha1_context sha1;
67#endif
68#if defined(MBEDTLS_SHA256_C)
69 mbedtls_sha256_context sha256;
70#endif
71#if defined(MBEDTLS_SHA512_C)
72 mbedtls_sha512_context sha512;
73#endif
74 } ctx;
75};
76
77struct psa_mac_operation_s
78{
79 psa_algorithm_t alg;
80 int key_set : 1;
81 int iv_required : 1;
82 int iv_set : 1;
83 int has_input : 1;
84 uint8_t mac_size;
85 union
86 {
87#if defined(MBEDTLS_MD_C)
88 mbedtls_md_context_t hmac;
89#endif
90#if defined(MBEDTLS_CMAC_C)
91 mbedtls_cipher_context_t cmac;
92#endif
93 } ctx;
94};
95
Gilles Peskine428dc5a2018-03-03 21:27:18 +010096struct psa_cipher_operation_s
97{
98 psa_algorithm_t alg;
99 int key_set : 1;
100 int iv_set : 1;
101 uint8_t iv_size;
102 uint8_t block_size;
103 union
104 {
105 } ctx;
106};
107
Gilles Peskine3b555712018-03-03 21:27:57 +0100108struct psa_aead_operation_s
109{
110 psa_algorithm_t alg;
111 int key_set : 1;
112 int iv_set : 1;
113 int ad_set : 1;
114 uint8_t iv_size;
115 uint8_t block_size;
116 union
117 {
118 } ctx;
119};
120
Gilles Peskine9ef733f2018-02-07 21:05:37 +0100121#endif /* PSA_CRYPTO_STRUCT_H */