summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--salsa.cpp18
-rw-r--r--sosemanuk.cpp10
2 files changed, 18 insertions, 10 deletions
diff --git a/salsa.cpp b/salsa.cpp
index a42e3dff..7e955423 100644
--- a/salsa.cpp
+++ b/salsa.cpp
@@ -8,6 +8,8 @@
#include "salsa.h"
#include "misc.h"
+#include "stdcpp.h"
+#include "smartptr.h"
#include "argnames.h"
#include "cpu.h"
#include "trap.h"
@@ -89,8 +91,11 @@ void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output
{
#endif // #ifdef CRYPTOPP_GENERATE_X64_MASM
+ // m_state.m_ptr was used below. Fetch it through data() member so we can make SecBlock's members private
+ word32* state = m_state.data();
+
#ifdef CRYPTOPP_X64_MASM_AVAILABLE
- Salsa20_OperateKeystream(output, input, iterationCount, m_rounds, m_state.data());
+ Salsa20_OperateKeystream(output, input, iterationCount, m_rounds, state);
return;
#endif
@@ -154,14 +159,13 @@ void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output
GNU_AS_INTEL_SYNTAX
AS_PUSH_IF86( bx)
#else
- void *s = m_state.data();
- word32 r = m_rounds;
+ word32 rounds = m_rounds;
AS2( mov REG_iterationCount, iterationCount)
AS2( mov REG_input, input)
AS2( mov REG_output, output)
- AS2( mov REG_state, s)
- AS2( mov REG_rounds, r)
+ AS2( mov REG_state, state)
+ AS2( mov REG_rounds, rounds)
#endif
#endif // #ifndef CRYPTOPP_GENERATE_X64_MASM
@@ -462,11 +466,11 @@ void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output
GNU_AS_ATT_SYNTAX
#if CRYPTOPP_BOOL_X64
: "+r" (input), "+r" (output), "+r" (iterationCount)
- : "r" (m_rounds), "r" (m_state.m_ptr), "r" (workspace)
+ : "r" (m_rounds), "r" (state), "r" (workspace)
: "%eax", "%rdx", "memory", "cc", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11", "%xmm12", "%xmm13", "%xmm14", "%xmm15"
#else
: "+a" (input), "+D" (output), "+c" (iterationCount)
- : "d" (m_rounds), "S" (m_state.m_ptr)
+ : "d" (m_rounds), "S" (state)
: "memory", "cc"
#endif
);
diff --git a/sosemanuk.cpp b/sosemanuk.cpp
index 52dd24b1..a642ac71 100644
--- a/sosemanuk.cpp
+++ b/sosemanuk.cpp
@@ -326,8 +326,11 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu
{
#endif // #ifdef CRYPTOPP_GENERATE_X64_MASM
+ // m_state.m_ptr was used below. Fetch it through data() member so we can make SecBlock's members private
+ word32* state = m_state.data();
+
#ifdef CRYPTOPP_X64_MASM_AVAILABLE
- Sosemanuk_OperateKeystream(iterationCount, input, output, m_state.data());
+ Sosemanuk_OperateKeystream(iterationCount, input, output, state);
return;
#endif
@@ -353,6 +356,7 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu
#ifdef __GNUC__
#if CRYPTOPP_BOOL_X64
FixedSizeAlignedSecBlock<byte, 80*4*2+12*4+8*WORD_SZ> workspace;
+ const byte* space = workspace.data();
#endif
__asm__ __volatile__
(
@@ -598,9 +602,9 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu
AS_POP_IF86( bx)
GNU_AS_ATT_SYNTAX
:
- : "a" (m_state.m_ptr), "c" (iterationCount), "S" (s_sosemanukMulTables), "D" (output), "d" (input)
+ : "a" (state), "c" (iterationCount), "S" (s_sosemanukMulTables), "D" (output), "d" (input)
#if CRYPTOPP_BOOL_X64
- , "r" (workspace.m_ptr)
+ , "r" (space)
: "memory", "cc", "%r9", "%r10", "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7"
#else
: "memory", "cc"