blob: 88b0127c685fb487c484741510401ee05e2b8102 [file] [log] [blame]
Gilles Peskinea899a722019-06-24 14:06:43 +02001/*
2 * PSA crypto support for secure element drivers
3 */
4/* Copyright (C) 2019, ARM Limited, All Rights Reserved
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * This file is part of Mbed TLS (https://tls.mbed.org)
20 */
21
22#ifndef PSA_CRYPTO_SE_H
23#define PSA_CRYPTO_SE_H
24
25#if !defined(MBEDTLS_CONFIG_FILE)
26#include "mbedtls/config.h"
27#else
28#include MBEDTLS_CONFIG_FILE
29#endif
30
31#include "psa/crypto.h"
32#include "psa/crypto_se_driver.h"
33
34/** The maximum number of registered secure element driver lifetimes. */
35#define PSA_MAX_SE_DRIVERS 4
36
Gilles Peskined0890212019-06-24 14:34:43 +020037/** Unregister all secure element drivers.
38 *
39 * \warning Do not call this function while the library is in the initialized
40 * state. This function is only intended to be called at the end
41 * of mbedtls_psa_crypto_free().
42 */
43void psa_unregister_all_se_drivers( void );
44
Gilles Peskinef989dbe2019-06-26 18:18:12 +020045/** A structure that describes a registered secure element driver.
46 *
47 * A secure element driver table entry contains a pointer to the
48 * driver's method table and a pointer to the driver's slot usage
49 * structure.
50 */
51typedef struct psa_se_drv_table_entry_s psa_se_drv_table_entry_t;
52
53/** Return the secure element driver table entry for a lifetime value.
54 *
55 * \param lifetime The lifetime value to query.
56 *
57 * \return The driver table entry for \p lifetime, or
58 * \p NULL if \p lifetime does not correspond to a registered driver.
59 */
60const psa_se_drv_table_entry_t *psa_get_se_driver_entry(
61 psa_key_lifetime_t lifetime );
62
63/** Return the method table for a secure element driver.
64 *
65 * \param[in] drv The driver table entry to access.
66 *
67 * \return The driver table entry for \p lifetime, or
68 * \p NULL if \p lifetime does not correspond to a registered driver.
69 */
70const psa_drv_se_t *psa_get_se_driver_methods(
71 const psa_se_drv_table_entry_t *drv );
72
73/** Return the secure element driver method table for a lifetime value.
74 *
75 * \param lifetime The lifetime value to query.
76 *
77 * \return The driver method table for \p lifetime, or
78 * \p NULL if \p lifetime does not correspond to a registered driver.
79 */
80const psa_drv_se_t *psa_get_se_driver(
81 psa_key_lifetime_t lifetime );
82
Gilles Peskinea899a722019-06-24 14:06:43 +020083#endif /* PSA_CRYPTO_SE_H */