mbed client on ethernet with LWIP
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbedtls/mbedtls/cipher_internal.h@11:cada08fc8a70, 2016-06-09 (annotated)
- Committer:
- mbedAustin
- Date:
- Thu Jun 09 17:08:36 2016 +0000
- Revision:
- 11:cada08fc8a70
Commit for public Consumption
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 11:cada08fc8a70 | 1 | /** |
mbedAustin | 11:cada08fc8a70 | 2 | * \file cipher_internal.h |
mbedAustin | 11:cada08fc8a70 | 3 | * |
mbedAustin | 11:cada08fc8a70 | 4 | * \brief Cipher wrappers. |
mbedAustin | 11:cada08fc8a70 | 5 | * |
mbedAustin | 11:cada08fc8a70 | 6 | * \author Adriaan de Jong <dejong@fox-it.com> |
mbedAustin | 11:cada08fc8a70 | 7 | * |
mbedAustin | 11:cada08fc8a70 | 8 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
mbedAustin | 11:cada08fc8a70 | 9 | * SPDX-License-Identifier: Apache-2.0 |
mbedAustin | 11:cada08fc8a70 | 10 | * |
mbedAustin | 11:cada08fc8a70 | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
mbedAustin | 11:cada08fc8a70 | 12 | * not use this file except in compliance with the License. |
mbedAustin | 11:cada08fc8a70 | 13 | * You may obtain a copy of the License at |
mbedAustin | 11:cada08fc8a70 | 14 | * |
mbedAustin | 11:cada08fc8a70 | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
mbedAustin | 11:cada08fc8a70 | 16 | * |
mbedAustin | 11:cada08fc8a70 | 17 | * Unless required by applicable law or agreed to in writing, software |
mbedAustin | 11:cada08fc8a70 | 18 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
mbedAustin | 11:cada08fc8a70 | 19 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbedAustin | 11:cada08fc8a70 | 20 | * See the License for the specific language governing permissions and |
mbedAustin | 11:cada08fc8a70 | 21 | * limitations under the License. |
mbedAustin | 11:cada08fc8a70 | 22 | * |
mbedAustin | 11:cada08fc8a70 | 23 | * This file is part of mbed TLS (https://tls.mbed.org) |
mbedAustin | 11:cada08fc8a70 | 24 | */ |
mbedAustin | 11:cada08fc8a70 | 25 | #ifndef MBEDTLS_CIPHER_WRAP_H |
mbedAustin | 11:cada08fc8a70 | 26 | #define MBEDTLS_CIPHER_WRAP_H |
mbedAustin | 11:cada08fc8a70 | 27 | |
mbedAustin | 11:cada08fc8a70 | 28 | #if !defined(MBEDTLS_CONFIG_FILE) |
mbedAustin | 11:cada08fc8a70 | 29 | #include "config.h" |
mbedAustin | 11:cada08fc8a70 | 30 | #else |
mbedAustin | 11:cada08fc8a70 | 31 | #include MBEDTLS_CONFIG_FILE |
mbedAustin | 11:cada08fc8a70 | 32 | #endif |
mbedAustin | 11:cada08fc8a70 | 33 | |
mbedAustin | 11:cada08fc8a70 | 34 | #include "cipher.h" |
mbedAustin | 11:cada08fc8a70 | 35 | |
mbedAustin | 11:cada08fc8a70 | 36 | #ifdef __cplusplus |
mbedAustin | 11:cada08fc8a70 | 37 | extern "C" { |
mbedAustin | 11:cada08fc8a70 | 38 | #endif |
mbedAustin | 11:cada08fc8a70 | 39 | |
mbedAustin | 11:cada08fc8a70 | 40 | /** |
mbedAustin | 11:cada08fc8a70 | 41 | * Base cipher information. The non-mode specific functions and values. |
mbedAustin | 11:cada08fc8a70 | 42 | */ |
mbedAustin | 11:cada08fc8a70 | 43 | struct mbedtls_cipher_base_t |
mbedAustin | 11:cada08fc8a70 | 44 | { |
mbedAustin | 11:cada08fc8a70 | 45 | /** Base Cipher type (e.g. MBEDTLS_CIPHER_ID_AES) */ |
mbedAustin | 11:cada08fc8a70 | 46 | mbedtls_cipher_id_t cipher; |
mbedAustin | 11:cada08fc8a70 | 47 | |
mbedAustin | 11:cada08fc8a70 | 48 | /** Encrypt using ECB */ |
mbedAustin | 11:cada08fc8a70 | 49 | int (*ecb_func)( void *ctx, mbedtls_operation_t mode, |
mbedAustin | 11:cada08fc8a70 | 50 | const unsigned char *input, unsigned char *output ); |
mbedAustin | 11:cada08fc8a70 | 51 | |
mbedAustin | 11:cada08fc8a70 | 52 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
mbedAustin | 11:cada08fc8a70 | 53 | /** Encrypt using CBC */ |
mbedAustin | 11:cada08fc8a70 | 54 | int (*cbc_func)( void *ctx, mbedtls_operation_t mode, size_t length, |
mbedAustin | 11:cada08fc8a70 | 55 | unsigned char *iv, const unsigned char *input, |
mbedAustin | 11:cada08fc8a70 | 56 | unsigned char *output ); |
mbedAustin | 11:cada08fc8a70 | 57 | #endif |
mbedAustin | 11:cada08fc8a70 | 58 | |
mbedAustin | 11:cada08fc8a70 | 59 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
mbedAustin | 11:cada08fc8a70 | 60 | /** Encrypt using CFB (Full length) */ |
mbedAustin | 11:cada08fc8a70 | 61 | int (*cfb_func)( void *ctx, mbedtls_operation_t mode, size_t length, size_t *iv_off, |
mbedAustin | 11:cada08fc8a70 | 62 | unsigned char *iv, const unsigned char *input, |
mbedAustin | 11:cada08fc8a70 | 63 | unsigned char *output ); |
mbedAustin | 11:cada08fc8a70 | 64 | #endif |
mbedAustin | 11:cada08fc8a70 | 65 | |
mbedAustin | 11:cada08fc8a70 | 66 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
mbedAustin | 11:cada08fc8a70 | 67 | /** Encrypt using CTR */ |
mbedAustin | 11:cada08fc8a70 | 68 | int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, |
mbedAustin | 11:cada08fc8a70 | 69 | unsigned char *nonce_counter, unsigned char *stream_block, |
mbedAustin | 11:cada08fc8a70 | 70 | const unsigned char *input, unsigned char *output ); |
mbedAustin | 11:cada08fc8a70 | 71 | #endif |
mbedAustin | 11:cada08fc8a70 | 72 | |
mbedAustin | 11:cada08fc8a70 | 73 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
mbedAustin | 11:cada08fc8a70 | 74 | /** Encrypt using STREAM */ |
mbedAustin | 11:cada08fc8a70 | 75 | int (*stream_func)( void *ctx, size_t length, |
mbedAustin | 11:cada08fc8a70 | 76 | const unsigned char *input, unsigned char *output ); |
mbedAustin | 11:cada08fc8a70 | 77 | #endif |
mbedAustin | 11:cada08fc8a70 | 78 | |
mbedAustin | 11:cada08fc8a70 | 79 | /** Set key for encryption purposes */ |
mbedAustin | 11:cada08fc8a70 | 80 | int (*setkey_enc_func)( void *ctx, const unsigned char *key, |
mbedAustin | 11:cada08fc8a70 | 81 | unsigned int key_bitlen ); |
mbedAustin | 11:cada08fc8a70 | 82 | |
mbedAustin | 11:cada08fc8a70 | 83 | /** Set key for decryption purposes */ |
mbedAustin | 11:cada08fc8a70 | 84 | int (*setkey_dec_func)( void *ctx, const unsigned char *key, |
mbedAustin | 11:cada08fc8a70 | 85 | unsigned int key_bitlen); |
mbedAustin | 11:cada08fc8a70 | 86 | |
mbedAustin | 11:cada08fc8a70 | 87 | /** Allocate a new context */ |
mbedAustin | 11:cada08fc8a70 | 88 | void * (*ctx_alloc_func)( void ); |
mbedAustin | 11:cada08fc8a70 | 89 | |
mbedAustin | 11:cada08fc8a70 | 90 | /** Free the given context */ |
mbedAustin | 11:cada08fc8a70 | 91 | void (*ctx_free_func)( void *ctx ); |
mbedAustin | 11:cada08fc8a70 | 92 | |
mbedAustin | 11:cada08fc8a70 | 93 | }; |
mbedAustin | 11:cada08fc8a70 | 94 | |
mbedAustin | 11:cada08fc8a70 | 95 | typedef struct |
mbedAustin | 11:cada08fc8a70 | 96 | { |
mbedAustin | 11:cada08fc8a70 | 97 | mbedtls_cipher_type_t type; |
mbedAustin | 11:cada08fc8a70 | 98 | const mbedtls_cipher_info_t *info; |
mbedAustin | 11:cada08fc8a70 | 99 | } mbedtls_cipher_definition_t; |
mbedAustin | 11:cada08fc8a70 | 100 | |
mbedAustin | 11:cada08fc8a70 | 101 | extern const mbedtls_cipher_definition_t mbedtls_cipher_definitions[]; |
mbedAustin | 11:cada08fc8a70 | 102 | |
mbedAustin | 11:cada08fc8a70 | 103 | extern int mbedtls_cipher_supported[]; |
mbedAustin | 11:cada08fc8a70 | 104 | |
mbedAustin | 11:cada08fc8a70 | 105 | #ifdef __cplusplus |
mbedAustin | 11:cada08fc8a70 | 106 | } |
mbedAustin | 11:cada08fc8a70 | 107 | #endif |
mbedAustin | 11:cada08fc8a70 | 108 | |
mbedAustin | 11:cada08fc8a70 | 109 | #endif /* MBEDTLS_CIPHER_WRAP_H */ |