Mercurial > vba-linux
comparison src/win32/7zip/7z/C/Aes.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:8ced16adf2e1 | 1:f9f4f1b99eed |
---|---|
1 /* Aes.h -- AES encryption / decryption | |
2 2008-08-05 | |
3 Igor Pavlov | |
4 Public domain */ | |
5 | |
6 #ifndef __AES_H | |
7 #define __AES_H | |
8 | |
9 #include "Types.h" | |
10 | |
11 #define AES_BLOCK_SIZE 16 | |
12 | |
13 typedef struct | |
14 { | |
15 unsigned numRounds2; /* = numRounds / 2 */ | |
16 UInt32 rkey[(14 + 1) * 4]; | |
17 } CAes; | |
18 | |
19 /* Call AesGenTables one time before other AES functions */ | |
20 void AesGenTables(void); | |
21 | |
22 /* keySize = 16 or 24 or 32 (bytes) */ | |
23 void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize); | |
24 void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize); | |
25 | |
26 /* Aes_Encode32 and Aes_Decode32 functions work with little-endian words. | |
27 src and dest are pointers to 4 UInt32 words. | |
28 arc and dest can point to same block */ | |
29 void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src); | |
30 void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src); | |
31 | |
32 typedef struct | |
33 { | |
34 UInt32 prev[4]; | |
35 CAes aes; | |
36 } CAesCbc; | |
37 | |
38 void AesCbc_Init(CAesCbc *p, const Byte *iv); /* iv size is AES_BLOCK_SIZE */ | |
39 | |
40 /* AesCbc_Encode and AesCbc_Decode: | |
41 if (res <= size): Filter have converted res bytes | |
42 if (res > size): Filter have not converted anything. And it needs at | |
43 least res = AES_BLOCK_SIZE bytes to convert one block */ | |
44 | |
45 SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size); | |
46 SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size); | |
47 | |
48 #endif |