Aes.c (p7zip_15.14.1_src_all) | : | Aes.c (p7zip_16.02_src_all) | ||
---|---|---|---|---|
/* Aes.c -- AES encryption / decryption | /* Aes.c -- AES encryption / decryption | |||
2015-02-23 : Igor Pavlov : Public domain */ | 2016-05-21 : Igor Pavlov : Public domain */ | |||
#include "Precomp.h" | #include "Precomp.h" | |||
#include "Aes.h" | #include "Aes.h" | |||
#include "CpuArch.h" | #include "CpuArch.h" | |||
static UInt32 T[256 * 4]; | static UInt32 T[256 * 4]; | |||
static const Byte Sbox[256] = { | static const Byte Sbox[256] = { | |||
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, | |||
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, | |||
skipping to change at line 170 | skipping to change at line 170 | |||
void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize) | void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize) | |||
{ | { | |||
unsigned i, num; | unsigned i, num; | |||
Aes_SetKey_Enc(w, key, keySize); | Aes_SetKey_Enc(w, key, keySize); | |||
num = keySize + 20; | num = keySize + 20; | |||
w += 8; | w += 8; | |||
for (i = 0; i < num; i++) | for (i = 0; i < num; i++) | |||
{ | { | |||
UInt32 r = w[i]; | UInt32 r = w[i]; | |||
w[i] = | w[i] = | |||
D[ Sbox[gb0(r)]] ^ | D[ (unsigned)Sbox[gb0(r)]] ^ | |||
D[0x100 + Sbox[gb1(r)]] ^ | D[0x100 + (unsigned)Sbox[gb1(r)]] ^ | |||
D[0x200 + Sbox[gb2(r)]] ^ | D[0x200 + (unsigned)Sbox[gb2(r)]] ^ | |||
D[0x300 + Sbox[gb3(r)]]; | D[0x300 + (unsigned)Sbox[gb3(r)]]; | |||
} | } | |||
} | } | |||
/* Aes_Encode and Aes_Decode functions work with little-endian words. | /* Aes_Encode and Aes_Decode functions work with little-endian words. | |||
src and dest are pointers to 4 UInt32 words. | src and dest are pointers to 4 UInt32 words. | |||
src and dest can point to same block */ | src and dest can point to same block */ | |||
static void Aes_Encode(const UInt32 *w, UInt32 *dest, const UInt32 *src) | static void Aes_Encode(const UInt32 *w, UInt32 *dest, const UInt32 *src) | |||
{ | { | |||
UInt32 s[4]; | UInt32 s[4]; | |||
End of changes. 2 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |