Expose the PSA key slot structure to internal modules
Move psa_key_slot_t to a new header psa_crypto_core.h, to prepare for moving the responsibility for some fields to psa_crypto_slot_management.c.
This commit is contained in:
parent
3f10812ff9
commit
039b90cf5b
3 changed files with 64 additions and 23 deletions
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "psa/crypto.h"
|
||||
|
||||
#include "psa_crypto_core.h"
|
||||
#include "psa_crypto_invasive.h"
|
||||
#include "psa_crypto_slot_management.h"
|
||||
/* Include internal declarations that are useful for implementing persistently
|
||||
|
@ -113,29 +114,6 @@ static inline int safer_memcmp( const uint8_t *a, const uint8_t *b, size_t n )
|
|||
/* Global data, support functions and library management */
|
||||
/****************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
psa_key_type_t type;
|
||||
psa_key_policy_t policy;
|
||||
psa_key_lifetime_t lifetime;
|
||||
psa_key_id_t persistent_storage_id;
|
||||
unsigned allocated : 1;
|
||||
union
|
||||
{
|
||||
struct raw_data
|
||||
{
|
||||
uint8_t *data;
|
||||
size_t bytes;
|
||||
} raw;
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
mbedtls_rsa_context *rsa;
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
mbedtls_ecp_keypair *ecp;
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
} data;
|
||||
} psa_key_slot_t;
|
||||
|
||||
static int key_type_is_raw_bytes( psa_key_type_t type )
|
||||
{
|
||||
return( PSA_KEY_TYPE_IS_UNSTRUCTURED( type ) );
|
||||
|
|
62
library/psa_crypto_core.h
Normal file
62
library/psa_crypto_core.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* PSA crypto core internal interfaces
|
||||
*/
|
||||
/* Copyright (C) 2018, ARM Limited, All Rights Reserved
|
||||
* 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.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#ifndef PSA_CRYPTO_CORE_H
|
||||
#define PSA_CRYPTO_CORE_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "psa/crypto.h"
|
||||
|
||||
#include "mbedtls/ecp.h"
|
||||
#include "mbedtls/rsa.h"
|
||||
|
||||
/** The data structure representing a key slot, containing key material
|
||||
* and metadata for one key.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
psa_key_type_t type;
|
||||
psa_key_policy_t policy;
|
||||
psa_key_lifetime_t lifetime;
|
||||
psa_key_id_t persistent_storage_id;
|
||||
unsigned allocated : 1;
|
||||
union
|
||||
{
|
||||
struct raw_data
|
||||
{
|
||||
uint8_t *data;
|
||||
size_t bytes;
|
||||
} raw;
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
mbedtls_rsa_context *rsa;
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
mbedtls_ecp_keypair *ecp;
|
||||
#endif /* MBEDTLS_ECP_C */
|
||||
} data;
|
||||
} psa_key_slot_t;
|
||||
|
||||
#endif /* PSA_CRYPTO_CORE_H */
|
|
@ -231,6 +231,7 @@
|
|||
<ClInclude Include="..\..\include\psa\crypto_platform.h" />
|
||||
<ClInclude Include="..\..\include\psa\crypto_sizes.h" />
|
||||
<ClInclude Include="..\..\include\psa\crypto_struct.h" />
|
||||
<ClInclude Include="..\..\library/psa_crypto_core.h" />
|
||||
<ClInclude Include="..\..\library/psa_crypto_invasive.h" />
|
||||
<ClInclude Include="..\..\library/psa_crypto_slot_management.h" />
|
||||
<ClInclude Include="..\..\library/psa_crypto_storage.h" />
|
||||
|
|
Loading…
Reference in a new issue