diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-05-11 04:49:21 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-05-11 04:49:21 +0400 |
commit | df64b5e5c271bf4cb322871f5b7a6c94f0eb0f5f (patch) | |
tree | 86bcc463cd739592b8f2562fd18a94f53aa7accf | |
parent | 6a5a73bc8648e8ce7f311d19be32b9a3366d3f4c (diff) |
further adjustments.
5 files changed, 16 insertions, 9 deletions
diff --git a/src/main/java/org/bouncycastle/crypto/prng/SP800SecureRandomBuilder.java b/src/main/java/org/bouncycastle/crypto/prng/SP800SecureRandomBuilder.java index e517f4de..203d78f9 100644 --- a/src/main/java/org/bouncycastle/crypto/prng/SP800SecureRandomBuilder.java +++ b/src/main/java/org/bouncycastle/crypto/prng/SP800SecureRandomBuilder.java @@ -196,7 +196,7 @@ public class SP800SecureRandomBuilder public SP80090DRBG get(EntropySource entropySource) { - return new DualECSP800DRBG(digest, entropySource, nonce, personalizationString, securityStrength); + return new DualECSP800DRBG(digest, securityStrength, entropySource, personalizationString, nonce); } } @@ -243,7 +243,7 @@ public class SP800SecureRandomBuilder public SP80090DRBG get(EntropySource entropySource) { - return new CTRSP800DRBG(blockCipher, keySizeInBits, entropySource, nonce, personalizationString, securityStrength); + return new CTRSP800DRBG(blockCipher, keySizeInBits, securityStrength, entropySource, personalizationString, nonce); } } } diff --git a/src/main/java/org/bouncycastle/crypto/prng/drbg/CTRSP800DRBG.java b/src/main/java/org/bouncycastle/crypto/prng/drbg/CTRSP800DRBG.java index 50f70467..b33a7664 100644 --- a/src/main/java/org/bouncycastle/crypto/prng/drbg/CTRSP800DRBG.java +++ b/src/main/java/org/bouncycastle/crypto/prng/drbg/CTRSP800DRBG.java @@ -19,8 +19,7 @@ public class CTRSP800DRBG private byte[] _V; private int _reseedCounter = 0; - public CTRSP800DRBG(BlockCipher engine, int keySizeInBits, EntropySource entropySource, byte[] nonce, - byte[] personalisationString, int securityStrength) + public CTRSP800DRBG(BlockCipher engine, int keySizeInBits, int securityStrength, EntropySource entropySource, byte[] personalisationString, byte[] nonce) { _entropySource = entropySource; diff --git a/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java b/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java index 518ae04e..ef529a8e 100644 --- a/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java +++ b/src/main/java/org/bouncycastle/crypto/prng/drbg/DualECSP800DRBG.java @@ -46,8 +46,16 @@ public class DualECSP800DRBG private byte[] _s; private int _sLength; - public DualECSP800DRBG(Digest digest, EntropySource entropySource, byte[] nonce, - byte[] personalisationString, int securityStrength) + /** + * Construct a SP800-90A Dual EC DRBG. + * + * @param digest source digest to use with the DRB stream. + * @param securityStrength security strength required (in bits) + * @param entropySource source of entropy to use for seeding/reseeding. + * @param personalizationString personalization string to distinguish this DRBG (may be null). + * @param nonce nonce to further distinguish this DRBG (may be null). + */ + public DualECSP800DRBG(Digest digest, int securityStrength, EntropySource entropySource, byte[] personalizationString, byte[] nonce) { if (securityStrength > digest.getDigestSize() * 8) // TODO: this may, or may not be correct, but it's good enough for now { @@ -62,7 +70,7 @@ public class DualECSP800DRBG // TODO: validate entropy length byte[] entropy = entropySource.getEntropy(); - byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalisationString); + byte[] seedMaterial = Arrays.concatenate(entropy, nonce, personalizationString); if (securityStrength <= 128) { diff --git a/src/test/java/org/bouncycastle/crypto/test/CTRDRBGTest.java b/src/test/java/org/bouncycastle/crypto/test/CTRDRBGTest.java index 59d2177b..c5f2b9d2 100644 --- a/src/test/java/org/bouncycastle/crypto/test/CTRDRBGTest.java +++ b/src/test/java/org/bouncycastle/crypto/test/CTRDRBGTest.java @@ -311,7 +311,7 @@ public class CTRDRBGTest byte[] nonce = tv.nonce(); byte[] personalisationString = tv.personalizationString(); - SP80090DRBG d = new CTRSP800DRBG(tv.getCipher(), tv.keySizeInBits(), tv.entropySource(), nonce, personalisationString, tv.securityStrength()); + SP80090DRBG d = new CTRSP800DRBG(tv.getCipher(), tv.keySizeInBits(), tv.securityStrength(), tv.entropySource(), personalisationString, nonce); byte[] output = new byte[tv.expectedValue(0).length]; diff --git a/src/test/java/org/bouncycastle/crypto/test/DualECDRBGTest.java b/src/test/java/org/bouncycastle/crypto/test/DualECDRBGTest.java index 8764b694..9ae53bfb 100644 --- a/src/test/java/org/bouncycastle/crypto/test/DualECDRBGTest.java +++ b/src/test/java/org/bouncycastle/crypto/test/DualECDRBGTest.java @@ -272,7 +272,7 @@ public class DualECDRBGTest byte[] nonce = tv.nonce(); byte[] personalisationString = tv.personalizationString(); - SP80090DRBG d = new DualECSP800DRBG(tv.getDigest(), tv.entropySource(), nonce, personalisationString, tv.securityStrength()); + SP80090DRBG d = new DualECSP800DRBG(tv.getDigest(), tv.securityStrength(), tv.entropySource(), personalisationString, nonce); byte[] output = new byte[tv.expectedValue(0).length]; |