1 /** @file supp_psa_api.h
2  *
3  *  @brief  This file provides crypto mbedtls PSA APIs for wpa supplicant.
4  *
5  *  Copyright 2023 NXP
6  *
7  *  SPDX-License-Identifier: BSD-3-Clause
8  *
9  */
10 
11 #ifndef SUPP_PSA_API_H
12 #define SUPP_PSA_API_H
13 
14 #include "includes.h"
15 #include "common.h"
16 
17 #include "psa/crypto.h"
18 #include "mbedtls/md.h"
19 
20 typedef enum
21 {
22     SUPP_PSA_BLOCK_SIZE_128 = 16,
23     SUPP_PSA_BLOCK_SIZE_160 = 20,
24     SUPP_PSA_BLOCK_SIZE_192 = 24,
25     SUPP_PSA_BLOCK_SIZE_244 = 28,
26     SUPP_PSA_BLOCK_SIZE_256 = 32,
27     SUPP_PSA_BLOCK_SIZE_384 = 48,
28     SUPP_PSA_BLOCK_SIZE_512 = 64,
29 } supp_psa_block_size_e;
30 
31 typedef enum
32 {
33     SUPP_PSA_KEY_BITS_128 = 128,
34     SUPP_PSA_KEY_BITS_192 = 192,
35     SUPP_PSA_KEY_BITS_256 = 256,
36 } supp_psa_key_bits_e;
37 
38 int aes_128_encrypt_block_psa(const u8 *key, const u8 *in, u8 *out);
39 int aes_128_cbc_encrypt_psa(const u8 *key, const u8 *iv, u8 *data, size_t data_len);
40 int aes_128_cbc_decrypt_psa(const u8 *key, const u8 *iv, u8 *data, size_t data_len);
41 int aes_ctr_encrypt_psa(const u8 *key, size_t key_len, const u8 *nonce, u8 *data, size_t data_len);
42 
43 int omac1_aes_vector_psa(const u8 *key, size_t key_len, size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac);
44 
45 int md_vector_psa(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac, mbedtls_md_type_t md_type);
46 
47 int hmac_vector_psa(const u8 *key,
48                     size_t key_len,
49                     size_t num_elem,
50                     const u8 *addr[],
51                     const size_t *len,
52                     u8 *mac,
53                     mbedtls_md_type_t md_type);
54 
55 int supp_psa_crypto_init(void);
56 void supp_psa_crypto_deinit(void);
57 #endif /* SUPP_PSA_API_H */
58