]> cvs.zerfleddert.de Git - proxmark3-svn/blob - common/mbedtls/cipher_internal.h
Fix format-truncation warning, missing string.h inclusion and strnlen warning (#723)
[proxmark3-svn] / common / mbedtls / cipher_internal.h
1 /**
2 * \file cipher_internal.h
3 *
4 * \brief Cipher wrappers.
5 *
6 * \author Adriaan de Jong <dejong@fox-it.com>
7 */
8 /*
9 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
10 * SPDX-License-Identifier: GPL-2.0
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 *
26 * This file is part of mbed TLS (https://tls.mbed.org)
27 */
28 #ifndef MBEDTLS_CIPHER_WRAP_H
29 #define MBEDTLS_CIPHER_WRAP_H
30
31 #if !defined(MBEDTLS_CONFIG_FILE)
32 #include "config.h"
33 #else
34 #include MBEDTLS_CONFIG_FILE
35 #endif
36
37 #include "cipher.h"
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /**
44 * Base cipher information. The non-mode specific functions and values.
45 */
46 struct mbedtls_cipher_base_t
47 {
48 /** Base Cipher type (e.g. MBEDTLS_CIPHER_ID_AES) */
49 mbedtls_cipher_id_t cipher;
50
51 /** Encrypt using ECB */
52 int (*ecb_func)( void *ctx, mbedtls_operation_t mode,
53 const unsigned char *input, unsigned char *output );
54
55 #if defined(MBEDTLS_CIPHER_MODE_CBC)
56 /** Encrypt using CBC */
57 int (*cbc_func)( void *ctx, mbedtls_operation_t mode, size_t length,
58 unsigned char *iv, const unsigned char *input,
59 unsigned char *output );
60 #endif
61
62 #if defined(MBEDTLS_CIPHER_MODE_CFB)
63 /** Encrypt using CFB (Full length) */
64 int (*cfb_func)( void *ctx, mbedtls_operation_t mode, size_t length, size_t *iv_off,
65 unsigned char *iv, const unsigned char *input,
66 unsigned char *output );
67 #endif
68
69 #if defined(MBEDTLS_CIPHER_MODE_OFB)
70 /** Encrypt using OFB (Full length) */
71 int (*ofb_func)( void *ctx, size_t length, size_t *iv_off,
72 unsigned char *iv,
73 const unsigned char *input,
74 unsigned char *output );
75 #endif
76
77 #if defined(MBEDTLS_CIPHER_MODE_CTR)
78 /** Encrypt using CTR */
79 int (*ctr_func)( void *ctx, size_t length, size_t *nc_off,
80 unsigned char *nonce_counter, unsigned char *stream_block,
81 const unsigned char *input, unsigned char *output );
82 #endif
83
84 #if defined(MBEDTLS_CIPHER_MODE_XTS)
85 /** Encrypt or decrypt using XTS. */
86 int (*xts_func)( void *ctx, mbedtls_operation_t mode, size_t length,
87 const unsigned char data_unit[16],
88 const unsigned char *input, unsigned char *output );
89 #endif
90
91 #if defined(MBEDTLS_CIPHER_MODE_STREAM)
92 /** Encrypt using STREAM */
93 int (*stream_func)( void *ctx, size_t length,
94 const unsigned char *input, unsigned char *output );
95 #endif
96
97 /** Set key for encryption purposes */
98 int (*setkey_enc_func)( void *ctx, const unsigned char *key,
99 unsigned int key_bitlen );
100
101 /** Set key for decryption purposes */
102 int (*setkey_dec_func)( void *ctx, const unsigned char *key,
103 unsigned int key_bitlen);
104
105 /** Allocate a new context */
106 void * (*ctx_alloc_func)( void );
107
108 /** Free the given context */
109 void (*ctx_free_func)( void *ctx );
110
111 };
112
113 typedef struct
114 {
115 mbedtls_cipher_type_t type;
116 const mbedtls_cipher_info_t *info;
117 } mbedtls_cipher_definition_t;
118
119 extern const mbedtls_cipher_definition_t mbedtls_cipher_definitions[];
120
121 extern int mbedtls_cipher_supported[];
122
123 #ifdef __cplusplus
124 }
125 #endif
126
127 #endif /* MBEDTLS_CIPHER_WRAP_H */
Impressum, Datenschutz