@ -504,10 +504,10 @@ namespace crypto
@@ -504,10 +504,10 @@ namespace crypto
" vxorps %%ymm0, %%ymm1, %%ymm1 \n "
" vmovups %%ymm1, (%[hash]) \n "
" vzeroall \n " // end of AVX
" movups %%xmm0, 80(%[hash]) \n " // zero last 16 bytes
" movups %%xmm0, 80(%[hash]) \n " // zero last 16 bytes
:
: [ key ] " m " ( * ( const uint8_t * ) key ) , [ ipad ] " m " ( * ipads ) , [ opad ] " m " ( * opads ) ,
[ buf ] " r " ( buf ) , [ hash ] " r " ( hash )
[ buf ] " r " ( buf ) , [ hash ] " r " ( hash )
: " memory " , " %xmm0 " // TODO: change to %ymm0 later
) ;
# else
@ -698,18 +698,18 @@ namespace crypto
@@ -698,18 +698,18 @@ namespace crypto
# ifdef AESNI
__asm__
(
" movups (%[iv]), %%xmm1 \n "
" 1: \n "
" movups (%[in]), %%xmm0 \n "
" pxor %%xmm1, %%xmm0 \n "
EncryptAES256 ( sched )
" movaps %%xmm0, %%xmm1 \n "
" movups %%xmm0, (%[out]) \n "
" add $16, %[in] \n "
" add $16, %[out] \n "
" dec %[num] \n "
" jnz 1b \n "
" movups %%xmm1, (%[iv]) \n "
" movups (%[iv]), %%xmm1 \n "
" 1: \n "
" movups (%[in]), %%xmm0 \n "
" pxor %%xmm1, %%xmm0 \n "
EncryptAES256 ( sched )
" movaps %%xmm0, %%xmm1 \n "
" movups %%xmm0, (%[out]) \n "
" add $16, %[in] \n "
" add $16, %[out] \n "
" dec %[num] \n "
" jnz 1b \n "
" movups %%xmm1, (%[iv]) \n "
:
: [ iv ] " r " ( ( uint8_t * ) m_LastBlock ) , [ sched ] " r " ( m_ECBEncryption . GetKeySchedule ( ) ) ,
[ in ] " r " ( in ) , [ out ] " r " ( out ) , [ num ] " r " ( numBlocks )
@ -740,8 +740,8 @@ namespace crypto
@@ -740,8 +740,8 @@ namespace crypto
(
" movups (%[iv]), %%xmm1 \n "
" movups (%[in]), %%xmm0 \n "
" pxor %%xmm1, %%xmm0 \n "
EncryptAES256 ( sched )
" pxor %%xmm1, %%xmm0 \n "
EncryptAES256 ( sched )
" movups %%xmm0, (%[out]) \n "
" movups %%xmm0, (%[iv]) \n "
:
@ -760,18 +760,18 @@ namespace crypto
@@ -760,18 +760,18 @@ namespace crypto
__asm__
(
" movups (%[iv]), %%xmm1 \n "
" 1: \n "
" movups (%[in]), %%xmm0 \n "
" 1: \n "
" movups (%[in]), %%xmm0 \n "
" movaps %%xmm0, %%xmm2 \n "
DecryptAES256 ( sched )
DecryptAES256 ( sched )
" pxor %%xmm1, %%xmm0 \n "
" movups %%xmm0, (%[out]) \n "
" movups %%xmm0, (%[out]) \n "
" movaps %%xmm2, %%xmm1 \n "
" add $16, %[in] \n "
" add $16, %[out] \n "
" dec %[num] \n "
" jnz 1b \n "
" movups %%xmm1, (%[iv]) \n "
" add $16, %[in] \n "
" add $16, %[out] \n "
" dec %[num] \n "
" jnz 1b \n "
" movups %%xmm1, (%[iv]) \n "
:
: [ iv ] " r " ( ( uint8_t * ) m_IV ) , [ sched ] " r " ( m_ECBDecryption . GetKeySchedule ( ) ) ,
[ in ] " r " ( in ) , [ out ] " r " ( out ) , [ num ] " r " ( numBlocks )
@ -801,11 +801,11 @@ namespace crypto
@@ -801,11 +801,11 @@ namespace crypto
__asm__
(
" movups (%[iv]), %%xmm1 \n "
" movups (%[in]), %%xmm0 \n "
" movups (%[in]), %%xmm0 \n "
" movups %%xmm0, (%[iv]) \n "
DecryptAES256 ( sched )
DecryptAES256 ( sched )
" pxor %%xmm1, %%xmm0 \n "
" movups %%xmm0, (%[out]) \n "
" movups %%xmm0, (%[out]) \n "
:
: [ iv ] " r " ( ( uint8_t * ) m_IV ) , [ sched ] " r " ( m_ECBDecryption . GetKeySchedule ( ) ) ,
[ in ] " r " ( in ) , [ out ] " r " ( out )
@ -821,7 +821,7 @@ namespace crypto
@@ -821,7 +821,7 @@ namespace crypto
# ifdef AESNI
__asm__
(
// encrypt IV
// encrypt IV
" movups (%[in]), %%xmm0 \n "
EncryptAES256 ( sched_iv )
" movaps %%xmm0, %%xmm1 \n "
@ -831,14 +831,14 @@ namespace crypto
@@ -831,14 +831,14 @@ namespace crypto
// encrypt data, IV is xmm1
" 1: \n "
" add $16, %[in] \n "
" add $16, %[out] \n "
" movups (%[in]), %%xmm0 \n "
" pxor %%xmm1, %%xmm0 \n "
EncryptAES256 ( sched_l )
" movaps %%xmm0, %%xmm1 \n "
" movups %%xmm0, (%[out]) \n "
" dec %[num] \n "
" jnz 1b \n "
" add $16, %[out] \n "
" movups (%[in]), %%xmm0 \n "
" pxor %%xmm1, %%xmm0 \n "
EncryptAES256 ( sched_l )
" movaps %%xmm0, %%xmm1 \n "
" movups %%xmm0, (%[out]) \n "
" dec %[num] \n "
" jnz 1b \n "
:
: [ sched_iv ] " r " ( m_IVEncryption . GetKeySchedule ( ) ) , [ sched_l ] " r " ( m_LayerEncryption . GetKeySchedule ( ) ) ,
[ in ] " r " ( in ) , [ out ] " r " ( out ) , [ num ] " r " ( 63 ) // 63 blocks = 1008 bytes
@ -857,7 +857,7 @@ namespace crypto
@@ -857,7 +857,7 @@ namespace crypto
# ifdef AESNI
__asm__
(
// decrypt IV
// decrypt IV
" movups (%[in]), %%xmm0 \n "
DecryptAES256 ( sched_iv )
" movaps %%xmm0, %%xmm1 \n "
@ -867,18 +867,18 @@ namespace crypto
@@ -867,18 +867,18 @@ namespace crypto
// decrypt data, IV is xmm1
" 1: \n "
" add $16, %[in] \n "
" add $16, %[out] \n "
" add $16, %[out] \n "
" movups (%[in]), %%xmm0 \n "
" movaps %%xmm0, %%xmm2 \n "
DecryptAES256 ( sched_l )
DecryptAES256 ( sched_l )
" pxor %%xmm1, %%xmm0 \n "
" movups %%xmm0, (%[out]) \n "
" movups %%xmm0, (%[out]) \n "
" movaps %%xmm2, %%xmm1 \n "
" dec %[num] \n "
" jnz 1b \n "
" dec %[num] \n "
" jnz 1b \n "
:
: [ sched_iv ] " r " ( m_IVDecryption . GetKeySchedule ( ) ) , [ sched_l ] " r " ( m_LayerDecryption . GetKeySchedule ( ) ) ,
[ in ] " r " ( in ) , [ out ] " r " ( out ) , [ num ] " r " ( 63 ) // 63 blocks = 1008 bytes
[ in ] " r " ( in ) , [ out ] " r " ( out ) , [ num ] " r " ( 63 ) // 63 blocks = 1008 bytes
: " %xmm0 " , " %xmm1 " , " %xmm2 " , " cc " , " memory "
) ;
# else
@ -907,7 +907,7 @@ namespace crypto
@@ -907,7 +907,7 @@ namespace crypto
SSL_library_init ( ) ;
/* auto numLocks = CRYPTO_num_locks();
for ( int i = 0 ; i < numLocks ; i + + )
m_OpenSSLMutexes . emplace_back ( new std : : mutex ) ;
m_OpenSSLMutexes . emplace_back ( new std : : mutex ) ;
CRYPTO_set_locking_callback ( OpensslLockingCallback ) ; */
if ( precomputation )
{
@ -939,4 +939,3 @@ namespace crypto
@@ -939,4 +939,3 @@ namespace crypto
}
}
}