mbed TLS v2.28.3
Loading...
Searching...
No Matches
xtea.h
Go to the documentation of this file.
1
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22#ifndef MBEDTLS_XTEA_H
23#define MBEDTLS_XTEA_H
24
25#if !defined(MBEDTLS_CONFIG_FILE)
26#include "mbedtls/config.h"
27#else
28#include MBEDTLS_CONFIG_FILE
29#endif
30
31#include <stddef.h>
32#include <stdint.h>
33
34#define MBEDTLS_XTEA_ENCRYPT 1
35#define MBEDTLS_XTEA_DECRYPT 0
36
38#define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028
39
40/* MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED is deprecated and should not be used. */
42#define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#if !defined(MBEDTLS_XTEA_ALT)
49// Regular implementation
50//
51
55typedef struct mbedtls_xtea_context {
56 uint32_t k[4];
57}
59
60#else /* MBEDTLS_XTEA_ALT */
61#include "xtea_alt.h"
62#endif /* MBEDTLS_XTEA_ALT */
63
70
77
84void mbedtls_xtea_setup(mbedtls_xtea_context *ctx, const unsigned char key[16]);
85
97 int mode,
98 const unsigned char input[8],
99 unsigned char output[8]);
100
101#if defined(MBEDTLS_CIPHER_MODE_CBC)
116 int mode,
117 size_t length,
118 unsigned char iv[8],
119 const unsigned char *input,
120 unsigned char *output);
121#endif /* MBEDTLS_CIPHER_MODE_CBC */
122
123#if defined(MBEDTLS_SELF_TEST)
124
130int mbedtls_xtea_self_test(int verbose);
131
132#endif /* MBEDTLS_SELF_TEST */
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* xtea.h */
Configuration options (set of defines)
XTEA context structure.
Definition: xtea.h:55
uint32_t k[4]
Definition: xtea.h:56
void mbedtls_xtea_setup(mbedtls_xtea_context *ctx, const unsigned char key[16])
XTEA key schedule.
void mbedtls_xtea_free(mbedtls_xtea_context *ctx)
Clear XTEA context.
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_self_test(int verbose)
Checkup routine.
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_init(mbedtls_xtea_context *ctx)
Initialize XTEA context.