mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Enable same buffer for in and out on ARM A-32 (GH #683)
This commit is contained in:
parent
1acbedd4f8
commit
49d852ee8c
27
strciphr.cpp
27
strciphr.cpp
@ -203,12 +203,18 @@ void CFB_CipherTemplate<BASE>::ProcessData(byte *outString, const byte *inString
|
||||
//
|
||||
// Also see https://github.com/weidai11/cryptopp/issues/683.
|
||||
//
|
||||
#if !defined(__arm__)
|
||||
unsigned int alignment = policy.GetAlignment();
|
||||
if (policy.CanIterate() && length >= bytesPerIteration && IsAlignedOn(outString, alignment))
|
||||
// UPDATE: It appears the issue is related to alignment checks. When we made
|
||||
// the alignment check result volatile GCC and Clang stopped
|
||||
// short-circuiting the transform, which is what we wanted. I suspect
|
||||
// there's a little more to the issue, but we can enable the block again.
|
||||
|
||||
const unsigned int alignment = policy.GetAlignment();
|
||||
volatile bool isAligned = IsAlignedOn(outString, alignment);
|
||||
if (policy.CanIterate() && length >= bytesPerIteration && isAligned)
|
||||
{
|
||||
isAligned &= IsAlignedOn(inString, alignment);
|
||||
const CipherDir cipherDir = GetCipherDir(*this);
|
||||
if (IsAlignedOn(inString, alignment))
|
||||
if (isAligned)
|
||||
policy.Iterate(outString, inString, cipherDir, length / bytesPerIteration);
|
||||
else
|
||||
{
|
||||
@ -226,11 +232,6 @@ void CFB_CipherTemplate<BASE>::ProcessData(byte *outString, const byte *inString
|
||||
// to use ptrdiff_t when subtracting pointers. We believe the relevant code paths
|
||||
// are clean.
|
||||
//
|
||||
// There are two remaining open questions. The first is aliasing rules. Char-types
|
||||
// are not bound by aliasing rules so we are OK. The second is array const-ness.
|
||||
// The arrays are created in datatest.cpp and they are non-const. Since the original
|
||||
// objects are non-const we are OK casting const-ness away as buffers are twiddled.
|
||||
//
|
||||
// One workaround is a distinct and aligned temporary buffer. It [mostly] works
|
||||
// as expected but requires an extra allocation (casts not shown):
|
||||
//
|
||||
@ -241,11 +242,11 @@ void CFB_CipherTemplate<BASE>::ProcessData(byte *outString, const byte *inString
|
||||
memcpy(outString, inString, length);
|
||||
policy.Iterate(outString, outString, cipherDir, length / bytesPerIteration);
|
||||
}
|
||||
inString = PtrAdd(inString, length - length % bytesPerIteration);
|
||||
outString = PtrAdd(outString, length - length % bytesPerIteration);
|
||||
length %= bytesPerIteration;
|
||||
const size_t remainder = length % bytesPerIteration;
|
||||
inString = PtrAdd(inString, length - remainder);
|
||||
outString = PtrAdd(outString, length - remainder);
|
||||
length = remainder;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (length >= bytesPerIteration)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user