blob: fe2dbdfc1cb2b3f33b5ca72c8c03da9873d81cd4 [file] [log] [blame]
Gilles Peskine5cc7bc52017-11-03 11:58:25 +01001/**
2 * \file pk_info.h
3 *
4 * \brief Public Key cryptography abstraction layer: object interface
5 *
6 * Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
7 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 * This file is part of mbed TLS (https://tls.mbed.org)
22 */
23
24#ifndef MBEDTLS_PK_INFO_H
25#define MBEDTLS_PK_INFO_H
26
27#if !defined(MBEDTLS_CONFIG_FILE)
28#include "config.h"
29#else
30#include MBEDTLS_CONFIG_FILE
31#endif
32
33#include "pk.h"
34
35struct mbedtls_pk_info_t
36{
37 /** Key pair type with indication of supported algorithms */
38 mbedtls_pk_type_t type;
39
40 /** Type name */
41 const char *name;
42
43 /** Get key size in bits */
44 size_t (*get_bitlen)( const void *ctx );
45
46 /** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */
47 int (*can_do)( const void * ctx, mbedtls_pk_type_t type );
48
49 /** Verify signature */
50 int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg,
51 const unsigned char *hash, size_t hash_len,
52 const unsigned char *sig, size_t sig_len );
53
54 /** Make signature */
55 int (*sign_func)( void *ctx, mbedtls_md_type_t md_alg,
56 const unsigned char *hash, size_t hash_len,
57 unsigned char *sig, size_t *sig_len,
58 int (*f_rng)(void *, unsigned char *, size_t),
59 void *p_rng );
60
61 /** Decrypt message */
62 int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
63 unsigned char *output, size_t *olen, size_t osize,
64 int (*f_rng)(void *, unsigned char *, size_t),
65 void *p_rng );
66
67 /** Encrypt message */
68 int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
69 unsigned char *output, size_t *olen, size_t osize,
70 int (*f_rng)(void *, unsigned char *, size_t),
71 void *p_rng );
72
73 /** Check public-private key pair */
74 int (*check_pair_func)( const void *pub, const void *prv );
75
76 /** Allocate a new context */
77 void * (*ctx_alloc_func)( void );
78
79 /** Free the given context */
80 void (*ctx_free_func)( void *ctx );
81
82 /** Interface with the debug module */
83 void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items );
84
85 /** Signature size */
86 size_t (*signature_size_func)( const void *ctx );
87};
88
89#endif /* MBEDTLS_PK_INFO_H */