1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/**
* \file
* \author Egor Tensin <Egor.Tensin@gmail.com>
* \date 2015
* \copyright This file is licensed under the terms of the MIT License.
* See LICENSE.txt for details.
*/
#pragma once
#include "aes.h"
#include "error.h"
#include "mode.h"
#include <stdlib.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef union
{
AesNI_AES128_Key aes128_key;
AesNI_AES192_Key aes192_key;
AesNI_AES256_Key aes256_key;
}
AesNI_BoxAlgorithmParams;
typedef union
{
AesNI_AES128_RoundKeys aes128_encryption_keys;
AesNI_AES192_RoundKeys aes192_encryption_keys;
AesNI_AES256_RoundKeys aes256_encryption_keys;
}
AesNI_BoxEncryptionParams;
typedef union
{
AesNI_AES128_RoundKeys aes128_decryption_keys;
AesNI_AES192_RoundKeys aes192_decryption_keys;
AesNI_AES256_RoundKeys aes256_decryption_keys;
}
AesNI_BoxDecryptionParams;
typedef union
{
AesNI_AES_Block aes_block;
}
AesNI_BoxBlock;
typedef AesNI_StatusCode (*AesNI_BoxDeriveParams)(
const AesNI_BoxAlgorithmParams* params,
AesNI_BoxEncryptionParams*,
AesNI_BoxDecryptionParams*,
AesNI_ErrorDetails* err_details);
typedef AesNI_StatusCode (*AesNI_BoxEncryptBlock)(
const AesNI_BoxBlock* plaintext,
const AesNI_BoxEncryptionParams* params,
AesNI_BoxBlock* ciphertext,
AesNI_ErrorDetails* err_details);
typedef AesNI_StatusCode (*AesNI_BoxDecryptBlock)(
const AesNI_BoxBlock* ciphertext,
const AesNI_BoxDecryptionParams* params,
AesNI_BoxBlock* plaintext,
AesNI_ErrorDetails* err_details);
typedef AesNI_StatusCode (*AesNI_BoxXorBlock)(
AesNI_BoxBlock*,
const AesNI_BoxBlock*,
AesNI_ErrorDetails*);
typedef AesNI_StatusCode (*AesNI_BoxIncBlock)(
AesNI_BoxBlock*,
AesNI_ErrorDetails*);
typedef AesNI_StatusCode (*AesNI_BoxGetBlockSize)(
size_t*,
AesNI_ErrorDetails*);
typedef AesNI_StatusCode (*AesNI_BoxStoreBlock)(
void*,
const AesNI_BoxBlock*,
AesNI_ErrorDetails*);
typedef AesNI_StatusCode (*AesNI_BoxLoadBlock)(
AesNI_BoxBlock*,
const void*,
AesNI_ErrorDetails*);
typedef struct
{
AesNI_BoxDeriveParams derive_params;
AesNI_BoxEncryptBlock encrypt_block;
AesNI_BoxDecryptBlock decrypt_block;
AesNI_BoxXorBlock xor_block;
AesNI_BoxIncBlock inc_block;
AesNI_BoxGetBlockSize get_block_size;
AesNI_BoxStoreBlock store_block;
AesNI_BoxLoadBlock load_block;
}
AesNI_BoxAlgorithmInterface;
typedef struct
{
const AesNI_BoxAlgorithmInterface* algorithm;
AesNI_BoxEncryptionParams encrypt_params;
AesNI_BoxDecryptionParams decrypt_params;
AesNI_Mode mode;
AesNI_BoxBlock iv;
}
AesNI_Box;
#ifdef __cplusplus
}
#endif
|