xtea.h
mbedtls/config.h
stddef.h
stdint.h
mbedtls/check_config.h
mbedtls/config.h
xtea.h
limits.h
stddef.h
stdint.h
mbedtls_xtea_context
MBEDTLS_XTEA_ENCRYPT
1
MBEDTLS_XTEA_DECRYPT
0
MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH
-0x0028

The data input has an invalid length.

MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED
-0x0029

XTEA hardware accelerator failed.

struct mbedtls_xtea_context typedef struct mbedtls_xtea_context mbedtls_xtea_context mbedtls_xtea_context

XTEA context structure.

void void mbedtls_xtea_init (mbedtls_xtea_context *ctx) mbedtls_xtea_init mbedtls_xtea_context * ctx

Initialize XTEA context.

ctx

XTEA context to be initialized

void void mbedtls_xtea_free (mbedtls_xtea_context *ctx) mbedtls_xtea_free mbedtls_xtea_context * ctx

Clear XTEA context.

ctx

XTEA context to be cleared

void void mbedtls_xtea_setup (mbedtls_xtea_context *ctx, const unsigned char key[16]) mbedtls_xtea_setup mbedtls_xtea_context * ctx const unsigned char key [16]

XTEA key schedule.

ctx

XTEA context to be initialized

key

the secret key

int int mbedtls_xtea_crypt_ecb (mbedtls_xtea_context *ctx, int mode, const unsigned char input[8], unsigned char output[8]) mbedtls_xtea_crypt_ecb mbedtls_xtea_context * ctx int mode const unsigned char input [8] unsigned char output [8]

XTEA cipher function.

ctx

XTEA context

mode

MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT

input

8-byte input block

output

8-byte output block

0 if successful

int 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) 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.

ctx

XTEA context

mode

MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT

length

the length of input, multiple of 8

iv

initialization vector for CBC mode

input

input block

output

output block

0 if successful, MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH if the length % 8 != 0

int int mbedtls_xtea_self_test (int verbose) mbedtls_xtea_self_test int verbose

Checkup routine.

0 if successful, or 1 if the test failed

XTEA block cipher (32-bit)

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */
    #ifndefMBEDTLS_XTEA_H
    #defineMBEDTLS_XTEA_H

    #if!defined(MBEDTLS_CONFIG_FILE)
    #include"mbedtls/config.h"
    #else
    #includeMBEDTLS_CONFIG_FILE
    #endif

    #include<stddef.h>
    #include<stdint.h>

    #defineMBEDTLS_XTEA_ENCRYPT1
    #defineMBEDTLS_XTEA_DECRYPT0

    #defineMBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH-0x0028

    /*MBEDTLS_ERR_XTEA_HW_ACCEL_FAILEDisdeprecatedandshouldnotbeused.*/
    #defineMBEDTLS_ERR_XTEA_HW_ACCEL_FAILED-0x0029

    #ifdef__cplusplus
    extern"C"{
    #endif

    #if!defined(MBEDTLS_XTEA_ALT)
    //Regularimplementation
    //

    typedefstructmbedtls_xtea_context{
    uint32_tk[4];
    }
    mbedtls_xtea_context;

    #else/*MBEDTLS_XTEA_ALT*/
    #include"xtea_alt.h"
    #endif/*MBEDTLS_XTEA_ALT*/

    voidmbedtls_xtea_init(mbedtls_xtea_context*ctx);

    voidmbedtls_xtea_free(mbedtls_xtea_context*ctx);

    voidmbedtls_xtea_setup(mbedtls_xtea_context*ctx,constunsignedcharkey[16]);

    intmbedtls_xtea_crypt_ecb(mbedtls_xtea_context*ctx,
    intmode,
    constunsignedcharinput[8],
    unsignedcharoutput[8]);

    #ifdefined(MBEDTLS_CIPHER_MODE_CBC)
    intmbedtls_xtea_crypt_cbc(mbedtls_xtea_context*ctx,
    intmode,
    size_tlength,
    unsignedchariv[8],
    constunsignedchar*input,
    unsignedchar*output);
    #endif/*MBEDTLS_CIPHER_MODE_CBC*/

    #ifdefined(MBEDTLS_SELF_TEST)

    intmbedtls_xtea_self_test(intverbose);

    #endif/*MBEDTLS_SELF_TEST*/

    #ifdef__cplusplus
    }
    #endif

    #endif/*xtea.h*/