diff options
author | Sergio Giro <sgiro@google.com> | 2016-02-01 10:41:58 +0000 |
---|---|---|
committer | Sergio Giro <sgiro@google.com> | 2016-02-01 10:41:58 +0000 |
commit | 53b61f9fe9d58034fcc7021137e92460f91b70ce (patch) | |
tree | 90632062175928181977c1ab3ab59951bc1146c3 /bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java | |
parent | 3eebc2629986481f9fc77ab101c0c9b8ff2f2660 (diff) | |
download | android_external_bouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.tar.gz android_external_bouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.tar.bz2 android_external_bouncycastle-53b61f9fe9d58034fcc7021137e92460f91b70ce.zip |
bouncycastle: Android tree with upstream code for version 1.52
Android tree as of
1af9aad12fedf1d93333e19f5ed0ab86f1cc4e2a
Change-Id: I714fa0954a5d000cd88d1fb78b0b7fe28246d404
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java')
-rw-r--r-- | bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java b/bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java index 8d326ff..4e1b881 100644 --- a/bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java +++ b/bcprov/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java @@ -6,7 +6,9 @@ import org.bouncycastle.asn1.nist.NISTNamedCurves; import org.bouncycastle.crypto.Digest; import org.bouncycastle.crypto.prng.EntropySource; import org.bouncycastle.math.ec.ECCurve; +import org.bouncycastle.math.ec.ECMultiplier; import org.bouncycastle.math.ec.ECPoint; +import org.bouncycastle.math.ec.FixedPointCombMultiplier; import org.bouncycastle.util.Arrays; import org.bouncycastle.util.BigIntegers; @@ -70,6 +72,7 @@ public class DualECSP800DRBG private ECPoint _Q; private byte[] _s; private int _sLength; + private ECMultiplier _fixedPointMultiplier = new FixedPointCombMultiplier(); /** * Construct a SP800-90A Dual EC DRBG. @@ -146,6 +149,16 @@ public class DualECSP800DRBG } /** + * Return the block size (in bits) of the DRBG. + * + * @return the number of bits produced on each internal round of the DRBG. + */ + public int getBlockSize() + { + return _outlen * 8; + } + + /** * Populate a passed in array with random data. * * @param output output array for generated bits. @@ -199,7 +212,7 @@ public class DualECSP800DRBG //System.err.println("S: " + new String(Hex.encode(_s))); - byte[] r = _Q.multiply(s).normalize().getAffineXCoord().toBigInteger().toByteArray(); + byte[] r = getScalarMultipleXCoord(_Q, s).toByteArray(); if (r.length > _outlen) { @@ -220,7 +233,7 @@ public class DualECSP800DRBG { s = getScalarMultipleXCoord(_P, s); - byte[] r = _Q.multiply(s).normalize().getAffineXCoord().toBigInteger().toByteArray(); + byte[] r = getScalarMultipleXCoord(_Q, s).toByteArray(); int required = output.length - outOffset; @@ -237,7 +250,7 @@ public class DualECSP800DRBG } // Need to preserve length of S as unsigned int. - _s = BigIntegers.asUnsignedByteArray(_sLength, _P.multiply(s).normalize().getAffineXCoord().toBigInteger()); + _s = BigIntegers.asUnsignedByteArray(_sLength, getScalarMultipleXCoord(_P, s)); return numberOfBits; } @@ -302,6 +315,6 @@ public class DualECSP800DRBG private BigInteger getScalarMultipleXCoord(ECPoint p, BigInteger s) { - return p.multiply(s).normalize().getAffineXCoord().toBigInteger(); + return _fixedPointMultiplier.multiply(p, s).normalize().getAffineXCoord().toBigInteger(); } } |