Modified mbed TLS headers for AES functionality only to reduce build size

Dependents:   BLE_Gateway_Linker_fix BLE_Gateway

Fork of mbedtls by sandbox

Committer:
electronichamsters
Date:
Mon Jul 10 04:00:25 2017 +0000
Revision:
5:f09f5ed830ca
Parent:
1:24750b9ad5ef
working gateway

Who changed what in which revision?

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