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