mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-05-17 19:42:19 +00:00
Move pk_info structure to its own file
This is in preparation to adding support for opaque keys in the pk layer. The header files are for use as follows: * pk.h for users of the pk interface. * pk_info.h for implementers of opaque key engines. * pk_internal.h only inside libmbedcrypto to implement built-in pk types.
This commit is contained in:
parent
cd062d84d6
commit
5cc7bc596d
89
include/mbedtls/pk_info.h
Normal file
89
include/mbedtls/pk_info.h
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/**
|
||||||
|
* \file pk_info.h
|
||||||
|
*
|
||||||
|
* \brief Public Key cryptography abstraction layer: object interface
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2017, 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 MBEDTLS_PK_INFO_H
|
||||||
|
#define MBEDTLS_PK_INFO_H
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||||
|
#include "config.h"
|
||||||
|
#else
|
||||||
|
#include MBEDTLS_CONFIG_FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "pk.h"
|
||||||
|
|
||||||
|
struct mbedtls_pk_info_t
|
||||||
|
{
|
||||||
|
/** Key pair type with indication of supported algorithms */
|
||||||
|
mbedtls_pk_type_t type;
|
||||||
|
|
||||||
|
/** Type name */
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
/** Get key size in bits */
|
||||||
|
size_t (*get_bitlen)( const void *ctx );
|
||||||
|
|
||||||
|
/** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */
|
||||||
|
int (*can_do)( const void * ctx, mbedtls_pk_type_t type );
|
||||||
|
|
||||||
|
/** Verify signature */
|
||||||
|
int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg,
|
||||||
|
const unsigned char *hash, size_t hash_len,
|
||||||
|
const unsigned char *sig, size_t sig_len );
|
||||||
|
|
||||||
|
/** Make signature */
|
||||||
|
int (*sign_func)( void *ctx, mbedtls_md_type_t md_alg,
|
||||||
|
const unsigned char *hash, size_t hash_len,
|
||||||
|
unsigned char *sig, size_t *sig_len,
|
||||||
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
|
void *p_rng );
|
||||||
|
|
||||||
|
/** Decrypt message */
|
||||||
|
int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
|
||||||
|
unsigned char *output, size_t *olen, size_t osize,
|
||||||
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
|
void *p_rng );
|
||||||
|
|
||||||
|
/** Encrypt message */
|
||||||
|
int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
|
||||||
|
unsigned char *output, size_t *olen, size_t osize,
|
||||||
|
int (*f_rng)(void *, unsigned char *, size_t),
|
||||||
|
void *p_rng );
|
||||||
|
|
||||||
|
/** Check public-private key pair */
|
||||||
|
int (*check_pair_func)( const void *pub, const void *prv );
|
||||||
|
|
||||||
|
/** Allocate a new context */
|
||||||
|
void * (*ctx_alloc_func)( void );
|
||||||
|
|
||||||
|
/** Free the given context */
|
||||||
|
void (*ctx_free_func)( void *ctx );
|
||||||
|
|
||||||
|
/** Interface with the debug module */
|
||||||
|
void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items );
|
||||||
|
|
||||||
|
/** Signature size */
|
||||||
|
size_t (*signature_size_func)( const void *ctx );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_PK_INFO_H */
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* \file pk.h
|
* \file pk_internal.h
|
||||||
*
|
*
|
||||||
* \brief Public Key cryptography abstraction layer: wrapper functions
|
* \brief Public Key cryptography abstraction layer: built-in key types
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
* Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MBEDTLS_PK_WRAP_H
|
#ifndef MBEDTLS_PK_INTERNAL_H
|
||||||
#define MBEDTLS_PK_WRAP_H
|
#define MBEDTLS_PK_INTERNAL_H
|
||||||
|
|
||||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -32,60 +32,6 @@
|
||||||
|
|
||||||
#include "pk.h"
|
#include "pk.h"
|
||||||
|
|
||||||
struct mbedtls_pk_info_t
|
|
||||||
{
|
|
||||||
/** Key pair type with indication of supported algorithms */
|
|
||||||
mbedtls_pk_type_t type;
|
|
||||||
|
|
||||||
/** Type name */
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
/** Get key size in bits */
|
|
||||||
size_t (*get_bitlen)( const void *ctx );
|
|
||||||
|
|
||||||
/** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */
|
|
||||||
int (*can_do)( const void * ctx, mbedtls_pk_type_t type );
|
|
||||||
|
|
||||||
/** Verify signature */
|
|
||||||
int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg,
|
|
||||||
const unsigned char *hash, size_t hash_len,
|
|
||||||
const unsigned char *sig, size_t sig_len );
|
|
||||||
|
|
||||||
/** Make signature */
|
|
||||||
int (*sign_func)( void *ctx, mbedtls_md_type_t md_alg,
|
|
||||||
const unsigned char *hash, size_t hash_len,
|
|
||||||
unsigned char *sig, size_t *sig_len,
|
|
||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
|
||||||
void *p_rng );
|
|
||||||
|
|
||||||
/** Decrypt message */
|
|
||||||
int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
|
|
||||||
unsigned char *output, size_t *olen, size_t osize,
|
|
||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
|
||||||
void *p_rng );
|
|
||||||
|
|
||||||
/** Encrypt message */
|
|
||||||
int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
|
|
||||||
unsigned char *output, size_t *olen, size_t osize,
|
|
||||||
int (*f_rng)(void *, unsigned char *, size_t),
|
|
||||||
void *p_rng );
|
|
||||||
|
|
||||||
/** Check public-private key pair */
|
|
||||||
int (*check_pair_func)( const void *pub, const void *prv );
|
|
||||||
|
|
||||||
/** Allocate a new context */
|
|
||||||
void * (*ctx_alloc_func)( void );
|
|
||||||
|
|
||||||
/** Free the given context */
|
|
||||||
void (*ctx_free_func)( void *ctx );
|
|
||||||
|
|
||||||
/** Interface with the debug module */
|
|
||||||
void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items );
|
|
||||||
|
|
||||||
/** Signature size */
|
|
||||||
size_t (*signature_size_func)( const void *ctx );
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||||
/* Container for RSA-alt */
|
/* Container for RSA-alt */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -114,4 +60,4 @@ extern const mbedtls_pk_info_t mbedtls_ecdsa_info;
|
||||||
extern const mbedtls_pk_info_t mbedtls_rsa_alt_info;
|
extern const mbedtls_pk_info_t mbedtls_rsa_alt_info;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* MBEDTLS_PK_WRAP_H */
|
#endif /* MBEDTLS_PK_INTERNAL_H */
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#if defined(MBEDTLS_PK_C)
|
#if defined(MBEDTLS_PK_C)
|
||||||
#include "mbedtls/pk.h"
|
#include "mbedtls/pk.h"
|
||||||
#include "mbedtls/pk_internal.h"
|
#include "mbedtls/pk_internal.h"
|
||||||
|
#include "mbedtls/pk_info.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_RSA_C)
|
#if defined(MBEDTLS_RSA_C)
|
||||||
#include "mbedtls/rsa.h"
|
#include "mbedtls/rsa.h"
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PK_C)
|
#if defined(MBEDTLS_PK_C)
|
||||||
|
#include "mbedtls/pk_info.h"
|
||||||
#include "mbedtls/pk_internal.h"
|
#include "mbedtls/pk_internal.h"
|
||||||
|
|
||||||
/* Even if RSA not activated, for the sake of RSA-alt */
|
/* Even if RSA not activated, for the sake of RSA-alt */
|
||||||
|
|
|
@ -191,6 +191,7 @@
|
||||||
<ClInclude Include="..\..\include\mbedtls\padlock.h" />
|
<ClInclude Include="..\..\include\mbedtls\padlock.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\pem.h" />
|
<ClInclude Include="..\..\include\mbedtls\pem.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\pk.h" />
|
<ClInclude Include="..\..\include\mbedtls\pk.h" />
|
||||||
|
<ClInclude Include="..\..\include\mbedtls\pk_info.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\pk_internal.h" />
|
<ClInclude Include="..\..\include\mbedtls\pk_internal.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\pkcs11.h" />
|
<ClInclude Include="..\..\include\mbedtls\pkcs11.h" />
|
||||||
<ClInclude Include="..\..\include\mbedtls\pkcs12.h" />
|
<ClInclude Include="..\..\include\mbedtls\pkcs12.h" />
|
||||||
|
|
Loading…
Reference in a new issue