Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2013-10-03 07:31:16 +0400
committerPeter Dettman <peter.dettman@bouncycastle.org>2013-10-03 07:31:16 +0400
commite336912cf9f1cc7a7d5f1285ae853c9155270981 (patch)
treefe4c622e0ce16c14b8a9f6c8819370cb5e573313 /core/src/main/java/org/bouncycastle/math
parent6abb9a359c3d92ed7b9832235df5dd701948b042 (diff)
Add a couple more "registers" to remove 1/4 of shift-adds
Diffstat (limited to 'core/src/main/java/org/bouncycastle/math')
-rw-r--r--core/src/main/java/org/bouncycastle/math/ec/LongArray.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/core/src/main/java/org/bouncycastle/math/ec/LongArray.java b/core/src/main/java/org/bouncycastle/math/ec/LongArray.java
index ad3e6225..4b972fc6 100644
--- a/core/src/main/java/org/bouncycastle/math/ec/LongArray.java
+++ b/core/src/main/java/org/bouncycastle/math/ec/LongArray.java
@@ -521,35 +521,52 @@ class LongArray
long[] c1 = new long[cLen];
long[] c2 = new long[cLen];
long[] c3 = new long[cLen];
+ long[] c10 = new long[cLen];
+ long[] c32 = new long[cLen];
- long bit1 = 1L << 48;
+ long bit3 = 1L << 48;
for (;;)
{
- long bit2 = bit1 >>> 16, bit3 = bit2 >>> 16, bit4 = bit3 >>> 16;
+ long bit2 = bit3 >>> 16, bit1 = bit2 >>> 16, bit0 = bit1 >>> 16;
+ long bit32 = bit3 | bit2, bit10 = bit1 | bit0;
for (int aPos = 0; aPos < aLen; ++aPos)
{
long aVal = a[aPos];
- if ((aVal & bit1) != 0)
+
+ if ((aVal & bit32) == bit32)
+ {
+ addShiftedByWordsQuick(c32, aPos, b);
+ }
+ else
+ if ((aVal & bit3) != 0)
{
addShiftedByWordsQuick(c3, aPos, b);
}
+ else
if ((aVal & bit2) != 0)
{
addShiftedByWordsQuick(c2, aPos, b);
}
- if ((aVal & bit3) != 0)
+
+ if ((aVal & bit10) == bit10)
+ {
+ addShiftedByWordsQuick(c10, aPos, b);
+ }
+ else
+ if ((aVal & bit1) != 0)
{
addShiftedByWordsQuick(c1, aPos, b);
}
- if ((aVal & bit4) != 0)
+ else
+ if ((aVal & bit0) != 0)
{
addShiftedByWordsQuick(c0, aPos, b);
}
}
- if ((bit1 <<= 1) == 0L)
+ if ((bit3 <<= 1) == 0L)
{
break;
}
@@ -557,6 +574,11 @@ class LongArray
shiftLeftQuick(b);
}
+ addQuick(c3, c32, cLen);
+ addQuick(c2, c32, cLen);
+ addQuick(c1, c10, cLen);
+ addQuick(c0, c10, cLen);
+
addShiftedByBitsQuick(c0, c1, cLen, 16);
addShiftedByBitsQuick(c0, c2, cLen, 32);
addShiftedByBitsQuick(c0, c3, cLen, 48);