diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/C/Aes.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,48 @@
     1.4 +/* Aes.h -- AES encryption / decryption
     1.5 +2008-08-05
     1.6 +Igor Pavlov
     1.7 +Public domain */
     1.8 +
     1.9 +#ifndef __AES_H
    1.10 +#define __AES_H
    1.11 +
    1.12 +#include "Types.h"
    1.13 +
    1.14 +#define AES_BLOCK_SIZE 16
    1.15 +
    1.16 +typedef struct
    1.17 +{
    1.18 +  unsigned numRounds2; /* = numRounds / 2 */
    1.19 +  UInt32 rkey[(14 + 1) * 4];
    1.20 +} CAes;
    1.21 +
    1.22 +/* Call AesGenTables one time before other AES functions */
    1.23 +void AesGenTables(void);
    1.24 +
    1.25 +/* keySize = 16 or 24 or 32 (bytes) */
    1.26 +void Aes_SetKeyEncode(CAes *p, const Byte *key, unsigned keySize);
    1.27 +void Aes_SetKeyDecode(CAes *p, const Byte *key, unsigned keySize);
    1.28 +
    1.29 +/* Aes_Encode32 and Aes_Decode32 functions work with little-endian words.
    1.30 +  src and dest are pointers to 4 UInt32 words.
    1.31 +  arc and dest can point to same block */
    1.32 +void Aes_Encode32(const CAes *p, UInt32 *dest, const UInt32 *src);
    1.33 +void Aes_Decode32(const CAes *p, UInt32 *dest, const UInt32 *src);
    1.34 +
    1.35 +typedef struct
    1.36 +{
    1.37 +  UInt32 prev[4];
    1.38 +  CAes aes;
    1.39 +} CAesCbc;
    1.40 +
    1.41 +void AesCbc_Init(CAesCbc *p, const Byte *iv); /* iv size is AES_BLOCK_SIZE */
    1.42 +
    1.43 +/* AesCbc_Encode and AesCbc_Decode:
    1.44 +  if (res <= size): Filter have converted res bytes
    1.45 +  if (res > size):  Filter have not converted anything. And it needs at
    1.46 +                    least res = AES_BLOCK_SIZE bytes to convert one block */
    1.47 +
    1.48 +SizeT AesCbc_Encode(CAesCbc *p, Byte *data, SizeT size);
    1.49 +SizeT AesCbc_Decode(CAesCbc *p, Byte *data, SizeT size);
    1.50 +
    1.51 +#endif