This commit is contained in:
Igor Pavlov
2008-12-31 00:00:00 +00:00
committed by Kornel Lesiński
parent c1f1243a70
commit 3a524e5ba2
259 changed files with 2792 additions and 4855 deletions

57
CPP/7zip/Crypto/MyAes.cpp Executable file
View File

@@ -0,0 +1,57 @@
// Crypto/MyAes.cpp
#include "StdAfx.h"
#include "MyAes.h"
namespace NCrypto {
struct CAesTabInit { CAesTabInit() { AesGenTables();} } g_AesTabInit;
STDMETHODIMP CAesCbcEncoder::Init() { return S_OK; }
STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size)
{
return (UInt32)AesCbc_Encode(&Aes, data, size);
}
STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size)
{
if ((size & 0x7) != 0 || size < 16 || size > 32)
return E_INVALIDARG;
Aes_SetKeyEncode(&Aes.aes, data, size);
return S_OK;
}
STDMETHODIMP CAesCbcEncoder::SetInitVector(const Byte *data, UInt32 size)
{
if (size != AES_BLOCK_SIZE)
return E_INVALIDARG;
AesCbc_Init(&Aes, data);
return S_OK;
}
STDMETHODIMP CAesCbcDecoder::Init() { return S_OK; }
STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size)
{
return (UInt32)AesCbc_Decode(&Aes, data, size);
}
STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size)
{
if ((size & 0x7) != 0 || size < 16 || size > 32)
return E_INVALIDARG;
Aes_SetKeyDecode(&Aes.aes, data, size);
return S_OK;
}
STDMETHODIMP CAesCbcDecoder::SetInitVector(const Byte *data, UInt32 size)
{
if (size != AES_BLOCK_SIZE)
return E_INVALIDARG;
AesCbc_Init(&Aes, data);
return S_OK;
}
}