xts.c File Reference

XEX-based tweaked-codebook mode with ciphertext stealing (XTS) More...

#include "core/crypto.h"
#include "cipher_modes/xts.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t xtsInit (XtsContext *context, const CipherAlgo *cipherAlgo, const void *key, size_t keyLen)
 Initialize XTS context. More...
 
error_t xtsEncrypt (XtsContext *context, const uint8_t *i, const uint8_t *p, uint8_t *c, size_t length)
 Encrypt a data unit using XTS. More...
 
error_t xtsDecrypt (XtsContext *context, const uint8_t *i, const uint8_t *c, uint8_t *p, size_t length)
 Decrypt a data unit using XTS. More...
 
void xtsMul (uint8_t *x, const uint8_t *a)
 Multiplication by x in GF(2^128) More...
 
void xtsXorBlock (uint8_t *x, const uint8_t *a, const uint8_t *b)
 XOR operation. More...
 

Detailed Description

XEX-based tweaked-codebook mode with ciphertext stealing (XTS)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCRYPTO Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

XTS is a tweakable block cipher designed for encryption of sector-based storage. Refer to IEEE Std 1619 and SP 800-38E for more details

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file xts.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 37 of file xts.c.

Function Documentation

◆ xtsDecrypt()

error_t xtsDecrypt ( XtsContext context,
const uint8_t *  i,
const uint8_t *  c,
uint8_t *  p,
size_t  length 
)

Decrypt a data unit using XTS.

Parameters
[in]contextPointer to the XTS context
[in]iValue of the 128-bit tweak
[in]cPointer to the data unit to be decrypted (ciphertext)
[out]pPointer to the resulting data unit (plaintext)
[in]lengthLength of the data unit, in bytes
Returns
Error code

Definition at line 171 of file xts.c.

◆ xtsEncrypt()

error_t xtsEncrypt ( XtsContext context,
const uint8_t *  i,
const uint8_t *  p,
uint8_t *  c,
size_t  length 
)

Encrypt a data unit using XTS.

Parameters
[in]contextPointer to the XTS context
[in]iValue of the 128-bit tweak
[in]pPointer to the data unit to be encrypted (plaintext)
[out]cPointer to the resulting data unit (ciphertext)
[in]lengthLength of the data unit, in bytes
Returns
Error code

Definition at line 106 of file xts.c.

◆ xtsInit()

error_t xtsInit ( XtsContext context,
const CipherAlgo cipherAlgo,
const void *  key,
size_t  keyLen 
)

Initialize XTS context.

Parameters
[in]contextPointer to the XTS context
[in]cipherAlgoCipher algorithm
[in]keyPointer to the key
[in]keyLenLength of the key
Returns
Error code

Definition at line 57 of file xts.c.

◆ xtsMul()

void xtsMul ( uint8_t *  x,
const uint8_t *  a 
)

Multiplication by x in GF(2^128)

Parameters
[out]xPointer to the output block
[out]aPointer to the input block

Definition at line 252 of file xts.c.

◆ xtsXorBlock()

void xtsXorBlock ( uint8_t *  x,
const uint8_t *  a,
const uint8_t *  b 
)

XOR operation.

Parameters
[out]xBlock resulting from the XOR operation
[in]aFirst input block
[in]bSecond input block

Definition at line 282 of file xts.c.