mbed TLS v2.16.1
xtea.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: GPL-2.0
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  * This file is part of mbed TLS (https://tls.mbed.org)
25  */
26 #ifndef MBEDTLS_XTEA_H
27 #define MBEDTLS_XTEA_H
28 
29 #if !defined(MBEDTLS_CONFIG_FILE)
30 #include "config.h"
31 #else
32 #include MBEDTLS_CONFIG_FILE
33 #endif
34 
35 #include <stddef.h>
36 #include <stdint.h>
37 
38 #define MBEDTLS_XTEA_ENCRYPT 1
39 #define MBEDTLS_XTEA_DECRYPT 0
40 
41 #define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028
43 /* MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED is deprecated and should not be used. */
44 #define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #if !defined(MBEDTLS_XTEA_ALT)
51 // Regular implementation
52 //
53 
57 typedef struct mbedtls_xtea_context
58 {
59  uint32_t k[4];
60 }
62 
63 #else /* MBEDTLS_XTEA_ALT */
64 #include "xtea_alt.h"
65 #endif /* MBEDTLS_XTEA_ALT */
66 
73 
80 
87 void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] );
88 
100  int mode,
101  const unsigned char input[8],
102  unsigned char output[8] );
103 
104 #if defined(MBEDTLS_CIPHER_MODE_CBC)
105 
119  int mode,
120  size_t length,
121  unsigned char iv[8],
122  const unsigned char *input,
123  unsigned char *output);
124 #endif /* MBEDTLS_CIPHER_MODE_CBC */
125 
126 #if defined(MBEDTLS_SELF_TEST)
127 
133 int mbedtls_xtea_self_test( int verbose );
134 
135 #endif /* MBEDTLS_SELF_TEST */
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif /* xtea.h */
int mbedtls_xtea_crypt_ecb(mbedtls_xtea_context *ctx, int mode, const unsigned char input[8], unsigned char output[8])
XTEA cipher function.
int mbedtls_xtea_crypt_cbc(mbedtls_xtea_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output)
XTEA CBC cipher function.
void mbedtls_xtea_free(mbedtls_xtea_context *ctx)
Clear XTEA context.
Configuration options (set of defines)
void mbedtls_xtea_init(mbedtls_xtea_context *ctx)
Initialize XTEA context.
void mbedtls_xtea_setup(mbedtls_xtea_context *ctx, const unsigned char key[16])
XTEA key schedule.
uint32_t k[4]
Definition: xtea.h:59
struct mbedtls_xtea_context mbedtls_xtea_context
XTEA context structure.
int mbedtls_xtea_self_test(int verbose)
Checkup routine.
XTEA context structure.
Definition: xtea.h:57