|
|
|
@ -45,7 +45,7 @@ void ECBCryptoAESNI::ExpandKey (const AESKey& key)
@@ -45,7 +45,7 @@ void ECBCryptoAESNI::ExpandKey (const AESKey& key)
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ECBEncryptionAESNI::Encrypt (const ChipherBlock * in, ChipherBlock * out) |
|
|
|
|
void ECBEncryptionAESNI::Encrypt (const CipherBlock * in, CipherBlock * out) |
|
|
|
|
{ |
|
|
|
|
__asm__ |
|
|
|
|
( |
|
|
|
@ -57,7 +57,7 @@ void ECBEncryptionAESNI::Encrypt (const ChipherBlock * in, ChipherBlock * out)
@@ -57,7 +57,7 @@ void ECBEncryptionAESNI::Encrypt (const ChipherBlock * in, ChipherBlock * out)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ECBDecryptionAESNI::Decrypt (const ChipherBlock * in, ChipherBlock * out) |
|
|
|
|
void ECBDecryptionAESNI::Decrypt (const CipherBlock * in, CipherBlock * out) |
|
|
|
|
{ |
|
|
|
|
__asm__ |
|
|
|
|
( |
|
|
|
@ -94,7 +94,7 @@ void ECBDecryptionAESNI::SetKey (const AESKey& key)
@@ -94,7 +94,7 @@ void ECBDecryptionAESNI::SetKey (const AESKey& key)
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out) |
|
|
|
|
void CBCEncryption::Encrypt (int numBlocks, const CipherBlock * in, CipherBlock * out) |
|
|
|
|
{ |
|
|
|
|
#ifdef AESNI |
|
|
|
|
__asm__ |
|
|
|
@ -131,7 +131,7 @@ void CBCEncryption::Encrypt (const uint8_t * in, std::size_t len, uint8_t * out)
@@ -131,7 +131,7 @@ void CBCEncryption::Encrypt (const uint8_t * in, std::size_t len, uint8_t * out)
|
|
|
|
|
// len/16
|
|
|
|
|
int numBlocks = len >> 4; |
|
|
|
|
if (numBlocks > 0) |
|
|
|
|
Encrypt (numBlocks, (const ChipherBlock *)in, (ChipherBlock *)out); |
|
|
|
|
Encrypt (numBlocks, (const CipherBlock *)in, (CipherBlock *)out); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CBCEncryption::Encrypt (const uint8_t * in, uint8_t * out) |
|
|
|
@ -151,11 +151,11 @@ void CBCEncryption::Encrypt (const uint8_t * in, uint8_t * out)
@@ -151,11 +151,11 @@ void CBCEncryption::Encrypt (const uint8_t * in, uint8_t * out)
|
|
|
|
|
: "%xmm0", "%xmm1", "memory" |
|
|
|
|
); |
|
|
|
|
#else |
|
|
|
|
Encrypt (1, (const ChipherBlock *)in, (ChipherBlock *)out); |
|
|
|
|
Encrypt (1, (const CipherBlock *)in, (CipherBlock *)out); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out) |
|
|
|
|
void CBCDecryption::Decrypt (int numBlocks, const CipherBlock * in, CipherBlock * out) |
|
|
|
|
{ |
|
|
|
|
#ifdef AESNI |
|
|
|
|
__asm__ |
|
|
|
@ -181,7 +181,7 @@ void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBloc
@@ -181,7 +181,7 @@ void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBloc
|
|
|
|
|
#else |
|
|
|
|
for (int i = 0; i < numBlocks; i++) |
|
|
|
|
{ |
|
|
|
|
ChipherBlock tmp = in[i]; |
|
|
|
|
CipherBlock tmp = in[i]; |
|
|
|
|
m_ECBDecryption.Decrypt (in + i, out + i); |
|
|
|
|
out[i] ^= m_IV; |
|
|
|
|
m_IV = tmp; |
|
|
|
@ -193,7 +193,7 @@ void CBCDecryption::Decrypt (const uint8_t * in, std::size_t len, uint8_t * out)
@@ -193,7 +193,7 @@ void CBCDecryption::Decrypt (const uint8_t * in, std::size_t len, uint8_t * out)
|
|
|
|
|
{ |
|
|
|
|
int numBlocks = len >> 4; |
|
|
|
|
if (numBlocks > 0) |
|
|
|
|
Decrypt (numBlocks, (const ChipherBlock *)in, (ChipherBlock *)out); |
|
|
|
|
Decrypt (numBlocks, (const CipherBlock *)in, (CipherBlock *)out); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CBCDecryption::Decrypt (const uint8_t * in, uint8_t * out) |
|
|
|
@ -213,7 +213,7 @@ void CBCDecryption::Decrypt (const uint8_t * in, uint8_t * out)
@@ -213,7 +213,7 @@ void CBCDecryption::Decrypt (const uint8_t * in, uint8_t * out)
|
|
|
|
|
: "%xmm0", "%xmm1", "memory" |
|
|
|
|
); |
|
|
|
|
#else |
|
|
|
|
Decrypt (1, (const ChipherBlock *)in, (ChipherBlock *)out); |
|
|
|
|
Decrypt (1, (const CipherBlock *)in, (CipherBlock *)out); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|