summaryrefslogtreecommitdiff
path: root/adv-simd.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-08-15 03:16:08 -0400
committerJeffrey Walton <noloader@gmail.com>2018-08-15 03:16:08 -0400
commitc26aad8a25a08fe42d06f421a68e5fb13afa9fe0 (patch)
tree9eccc1823722af5eddd6f3f576a16f3d60df0f8c /adv-simd.h
parent1253bccf060d4c9356b087084d85d7ab9584a91e (diff)
downloadcryptopp-git-c26aad8a25a08fe42d06f421a68e5fb13afa9fe0.tar.gz
Use PtrSub to subtract offset from pointer
Diffstat (limited to 'adv-simd.h')
-rw-r--r--adv-simd.h41
1 files changed, 17 insertions, 24 deletions
diff --git a/adv-simd.h b/adv-simd.h
index e0d871a1..22c66443 100644
--- a/adv-simd.h
+++ b/adv-simd.h
@@ -291,9 +291,9 @@ inline size_t AdvancedProcessBlocks64_6x2_NEON(F2 func2, F6 func6,
inIncrement += inIncrement ? blockSize : 0;
xorIncrement += xorIncrement ? blockSize : 0;
outIncrement += outIncrement ? blockSize : 0;
- inBlocks -= inIncrement;
- xorBlocks -= xorIncrement;
- outBlocks -= outIncrement;
+ inBlocks = PtrAdd(inBlocks, inIncrement);
+ xorBlocks = PtrSub(xorBlocks, xorIncrement);
+ outBlocks = PtrSub(outBlocks, outIncrement);
}
else
{
@@ -981,9 +981,9 @@ inline size_t AdvancedProcessBlocks64_2x1_SSE(F1 func1, F2 func2,
inIncrement += inIncrement ? blockSize : 0;
xorIncrement += xorIncrement ? blockSize : 0;
outIncrement += outIncrement ? blockSize : 0;
- inBlocks -= inIncrement;
- xorBlocks -= xorIncrement;
- outBlocks -= outIncrement;
+ inBlocks = PtrSub(inBlocks, inIncrement);
+ xorBlocks = PtrSub(xorBlocks, xorIncrement);
+ outBlocks = PtrSub(outBlocks, outIncrement);
}
else
{
@@ -1229,9 +1229,9 @@ inline size_t AdvancedProcessBlocks64_6x2_SSE(F2 func2, F6 func6,
inIncrement += inIncrement ? blockSize : 0;
xorIncrement += xorIncrement ? blockSize : 0;
outIncrement += outIncrement ? blockSize : 0;
- inBlocks -= inIncrement;
- xorBlocks -= xorIncrement;
- outBlocks -= outIncrement;
+ inBlocks = PtrSub(inBlocks, inIncrement);
+ xorBlocks = PtrSub(xorBlocks, xorIncrement);
+ outBlocks = PtrSub(outBlocks, outIncrement);
}
else
{
@@ -1731,9 +1731,9 @@ inline size_t AdvancedProcessBlocks64_4x1_SSE(F1 func1, F4 func4,
inIncrement += inIncrement ? blockSize : 0;
xorIncrement += xorIncrement ? blockSize : 0;
outIncrement += outIncrement ? blockSize : 0;
- inBlocks -= inIncrement;
- xorBlocks -= xorIncrement;
- outBlocks -= outIncrement;
+ inBlocks = PtrSub(inBlocks, inIncrement);
+ xorBlocks = PtrSub(xorBlocks, xorIncrement);
+ outBlocks = PtrSub(outBlocks, outIncrement);
}
else
{
@@ -1797,7 +1797,7 @@ NAMESPACE_BEGIN(CryptoPP)
/// \details The subkey type is usually word32 or word64. F2 and F6 must use the
/// same word type.
template <typename F2, typename F6, typename W>
-inline size_t AdvancedProcessBlocks64_6x2_ALTIVEC(F2 func2, F6 func6,
+size_t AdvancedProcessBlocks64_6x2_ALTIVEC(F2 func2, F6 func6,
const W *subKeys, size_t rounds, const byte *inBlocks,
const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
{
@@ -2001,9 +2001,9 @@ inline size_t AdvancedProcessBlocks64_6x2_ALTIVEC(F2 func2, F6 func6,
inIncrement += inIncrement ? blockSize : 0;
xorIncrement += xorIncrement ? blockSize : 0;
outIncrement += outIncrement ? blockSize : 0;
- inBlocks -= inIncrement;
- xorBlocks -= xorIncrement;
- outBlocks -= outIncrement;
+ inBlocks = PtrSub(inBlocks, inIncrement);
+ xorBlocks = PtrSub(xorBlocks, xorIncrement);
+ outBlocks = PtrSub(outBlocks, outIncrement);
}
else
{
@@ -2125,14 +2125,7 @@ inline size_t AdvancedProcessBlocks128_4x1_ALTIVEC(F1 func1, F4 func4,
// located at index 15. The vector addition using a 32-bit element
// generates a carry into inBlocks[14] and then CTR_ModePolicy
// increments inBlocks[14] too.
- //
- // To find this bug we needed a test case with a ctr of 0xNN...FA.
- // The last octet is 0xFA and adding 6 creates the wrap to trigger
- // the issue. If the last octet was 0xFC then 4 would trigger it.
- // We dumb-lucked into the test with SPECK-128. The test case of
- // interest is the one with IV 348ECA9766C09F04 826520DE47A212FA.
- uint8x16_p temp = VectorAdd((uint8x16_p)block3, (uint8x16_p)s_one);
- VectorStoreBE(temp, const_cast<byte*>(inBlocks));
+ const_cast<byte*>(inBlocks)[15] += 6;
}
else
{