libnx  v4.6.0
aes_xts.h
Go to the documentation of this file.
1 /**
2  * @file aes_xts.h
3  * @brief Hardware accelerated AES-XTS implementation.
4  * @copyright libnx Authors
5  */
6 #pragma once
7 #include "aes.h"
8 
9 /// Context for AES-128 XTS.
10 typedef struct {
11  Aes128Context aes_ctx;
12  Aes128Context tweak_ctx;
13  u8 tweak[AES_BLOCK_SIZE];
14  u8 buffer[AES_BLOCK_SIZE];
15  size_t num_buffered;
17 
18 /// Context for AES-192 XTS.
19 typedef struct {
20  Aes192Context aes_ctx;
21  Aes192Context tweak_ctx;
22  u8 tweak[AES_BLOCK_SIZE];
23  u8 buffer[AES_BLOCK_SIZE];
24  size_t num_buffered;
26 
27 /// Context for AES-256 XTS.
28 typedef struct {
29  Aes256Context aes_ctx;
30  Aes256Context tweak_ctx;
31  u8 tweak[AES_BLOCK_SIZE];
32  u8 buffer[AES_BLOCK_SIZE];
33  size_t num_buffered;
35 
36 /// 128-bit XTS API.
37 void aes128XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
38 void aes128XtsContextResetTweak(Aes128XtsContext *ctx, const void *tweak);
39 void aes128XtsContextResetSector(Aes128XtsContext *ctx, uint64_t sector, bool is_nintendo);
40 size_t aes128XtsEncrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size);
41 size_t aes128XtsDecrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size);
42 
43 /// 192-bit XTS API.
44 void aes192XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
45 void aes192XtsContextResetTweak(Aes192XtsContext *ctx, const void *tweak);
46 void aes192XtsContextResetSector(Aes192XtsContext *ctx, uint64_t sector, bool is_nintendo);
47 size_t aes192XtsEncrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size);
48 size_t aes192XtsDecrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size);
49 
50 /// 256-bit XTS API.
51 void aes256XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor);
52 void aes256XtsContextResetTweak(Aes256XtsContext *ctx, const void *tweak);
53 void aes256XtsContextResetSector(Aes256XtsContext *ctx, uint64_t sector, bool is_nintendo);
54 size_t aes256XtsEncrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size);
55 size_t aes256XtsDecrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size);
Hardware accelerated AES-ECB implementation.
void aes128XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor)
128-bit XTS API.
void aes192XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor)
192-bit XTS API.
void aes256XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor)
256-bit XTS API.
Context for AES-128 operations.
Definition: aes.h:41
Context for AES-128 XTS.
Definition: aes_xts.h:10
Context for AES-192 operations.
Definition: aes.h:46
Context for AES-192 XTS.
Definition: aes_xts.h:19
Context for AES-256 operations.
Definition: aes.h:51
Context for AES-256 XTS.
Definition: aes_xts.h:28
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19