mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
markrad
Date:
Thu Jan 05 00:18:44 2017 +0000
Revision:
0:cdf462088d13
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 /**
markrad 0:cdf462088d13 2 * \file pk.h
markrad 0:cdf462088d13 3 *
markrad 0:cdf462088d13 4 * \brief Public Key abstraction layer: wrapper functions
markrad 0:cdf462088d13 5 *
markrad 0:cdf462088d13 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 7 * SPDX-License-Identifier: Apache-2.0
markrad 0:cdf462088d13 8 *
markrad 0:cdf462088d13 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
markrad 0:cdf462088d13 10 * not use this file except in compliance with the License.
markrad 0:cdf462088d13 11 * You may obtain a copy of the License at
markrad 0:cdf462088d13 12 *
markrad 0:cdf462088d13 13 * http://www.apache.org/licenses/LICENSE-2.0
markrad 0:cdf462088d13 14 *
markrad 0:cdf462088d13 15 * Unless required by applicable law or agreed to in writing, software
markrad 0:cdf462088d13 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
markrad 0:cdf462088d13 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
markrad 0:cdf462088d13 18 * See the License for the specific language governing permissions and
markrad 0:cdf462088d13 19 * limitations under the License.
markrad 0:cdf462088d13 20 *
markrad 0:cdf462088d13 21 * This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 22 */
markrad 0:cdf462088d13 23
markrad 0:cdf462088d13 24 #ifndef MBEDTLS_PK_WRAP_H
markrad 0:cdf462088d13 25 #define MBEDTLS_PK_WRAP_H
markrad 0:cdf462088d13 26
markrad 0:cdf462088d13 27 #if !defined(MBEDTLS_CONFIG_FILE)
markrad 0:cdf462088d13 28 #include "config.h"
markrad 0:cdf462088d13 29 #else
markrad 0:cdf462088d13 30 #include MBEDTLS_CONFIG_FILE
markrad 0:cdf462088d13 31 #endif
markrad 0:cdf462088d13 32
markrad 0:cdf462088d13 33 #include "pk.h"
markrad 0:cdf462088d13 34
markrad 0:cdf462088d13 35 struct mbedtls_pk_info_t
markrad 0:cdf462088d13 36 {
markrad 0:cdf462088d13 37 /** Public key type */
markrad 0:cdf462088d13 38 mbedtls_pk_type_t type;
markrad 0:cdf462088d13 39
markrad 0:cdf462088d13 40 /** Type name */
markrad 0:cdf462088d13 41 const char *name;
markrad 0:cdf462088d13 42
markrad 0:cdf462088d13 43 /** Get key size in bits */
markrad 0:cdf462088d13 44 size_t (*get_bitlen)( const void * );
markrad 0:cdf462088d13 45
markrad 0:cdf462088d13 46 /** Tell if the context implements this type (e.g. ECKEY can do ECDSA) */
markrad 0:cdf462088d13 47 int (*can_do)( mbedtls_pk_type_t type );
markrad 0:cdf462088d13 48
markrad 0:cdf462088d13 49 /** Verify signature */
markrad 0:cdf462088d13 50 int (*verify_func)( void *ctx, mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 51 const unsigned char *hash, size_t hash_len,
markrad 0:cdf462088d13 52 const unsigned char *sig, size_t sig_len );
markrad 0:cdf462088d13 53
markrad 0:cdf462088d13 54 /** Make signature */
markrad 0:cdf462088d13 55 int (*sign_func)( void *ctx, mbedtls_md_type_t md_alg,
markrad 0:cdf462088d13 56 const unsigned char *hash, size_t hash_len,
markrad 0:cdf462088d13 57 unsigned char *sig, size_t *sig_len,
markrad 0:cdf462088d13 58 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 59 void *p_rng );
markrad 0:cdf462088d13 60
markrad 0:cdf462088d13 61 /** Decrypt message */
markrad 0:cdf462088d13 62 int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
markrad 0:cdf462088d13 63 unsigned char *output, size_t *olen, size_t osize,
markrad 0:cdf462088d13 64 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 65 void *p_rng );
markrad 0:cdf462088d13 66
markrad 0:cdf462088d13 67 /** Encrypt message */
markrad 0:cdf462088d13 68 int (*encrypt_func)( void *ctx, const unsigned char *input, size_t ilen,
markrad 0:cdf462088d13 69 unsigned char *output, size_t *olen, size_t osize,
markrad 0:cdf462088d13 70 int (*f_rng)(void *, unsigned char *, size_t),
markrad 0:cdf462088d13 71 void *p_rng );
markrad 0:cdf462088d13 72
markrad 0:cdf462088d13 73 /** Check public-private key pair */
markrad 0:cdf462088d13 74 int (*check_pair_func)( const void *pub, const void *prv );
markrad 0:cdf462088d13 75
markrad 0:cdf462088d13 76 /** Allocate a new context */
markrad 0:cdf462088d13 77 void * (*ctx_alloc_func)( void );
markrad 0:cdf462088d13 78
markrad 0:cdf462088d13 79 /** Free the given context */
markrad 0:cdf462088d13 80 void (*ctx_free_func)( void *ctx );
markrad 0:cdf462088d13 81
markrad 0:cdf462088d13 82 /** Interface with the debug module */
markrad 0:cdf462088d13 83 void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items );
markrad 0:cdf462088d13 84
markrad 0:cdf462088d13 85 };
markrad 0:cdf462088d13 86 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
markrad 0:cdf462088d13 87 /* Container for RSA-alt */
markrad 0:cdf462088d13 88 typedef struct
markrad 0:cdf462088d13 89 {
markrad 0:cdf462088d13 90 void *key;
markrad 0:cdf462088d13 91 mbedtls_pk_rsa_alt_decrypt_func decrypt_func;
markrad 0:cdf462088d13 92 mbedtls_pk_rsa_alt_sign_func sign_func;
markrad 0:cdf462088d13 93 mbedtls_pk_rsa_alt_key_len_func key_len_func;
markrad 0:cdf462088d13 94 } mbedtls_rsa_alt_context;
markrad 0:cdf462088d13 95 #endif
markrad 0:cdf462088d13 96
markrad 0:cdf462088d13 97 #if defined(MBEDTLS_RSA_C)
markrad 0:cdf462088d13 98 extern const mbedtls_pk_info_t mbedtls_rsa_info;
markrad 0:cdf462088d13 99 #endif
markrad 0:cdf462088d13 100
markrad 0:cdf462088d13 101 #if defined(MBEDTLS_ECP_C)
markrad 0:cdf462088d13 102 extern const mbedtls_pk_info_t mbedtls_eckey_info;
markrad 0:cdf462088d13 103 extern const mbedtls_pk_info_t mbedtls_eckeydh_info;
markrad 0:cdf462088d13 104 #endif
markrad 0:cdf462088d13 105
markrad 0:cdf462088d13 106 #if defined(MBEDTLS_ECDSA_C)
markrad 0:cdf462088d13 107 extern const mbedtls_pk_info_t mbedtls_ecdsa_info;
markrad 0:cdf462088d13 108 #endif
markrad 0:cdf462088d13 109
markrad 0:cdf462088d13 110 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
markrad 0:cdf462088d13 111 extern const mbedtls_pk_info_t mbedtls_rsa_alt_info;
markrad 0:cdf462088d13 112 #endif
markrad 0:cdf462088d13 113
markrad 0:cdf462088d13 114 #endif /* MBEDTLS_PK_WRAP_H */