mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

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