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