From 3585bbfd9ae9c9ce82854c91a1aae61a0d57720c Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 16 Nov 2015 13:28:13 +0700 Subject: More rename/delete --- crypto/src/crypto/prng/ISP80090Drbg.cs | 33 ------ crypto/test/src/crypto/prng/test/DRGBTestVector.cs | 129 --------------------- crypto/test/src/crypto/prng/test/DrbgTestVector.cs | 129 +++++++++++++++++++++ 3 files changed, 129 insertions(+), 162 deletions(-) delete mode 100644 crypto/src/crypto/prng/ISP80090Drbg.cs delete mode 100644 crypto/test/src/crypto/prng/test/DRGBTestVector.cs create mode 100644 crypto/test/src/crypto/prng/test/DrbgTestVector.cs (limited to 'crypto') diff --git a/crypto/src/crypto/prng/ISP80090Drbg.cs b/crypto/src/crypto/prng/ISP80090Drbg.cs deleted file mode 100644 index c39cf365f..000000000 --- a/crypto/src/crypto/prng/ISP80090Drbg.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Org.BouncyCastle.Crypto.Prng.Drbg -{ - /** - * Interface to SP800-90A deterministic random bit generators. - */ - public interface SP80090Drbg - { - /** - * Return the block size of the DRBG. - * - * @return the block size (in bits) produced by each round of the DRBG. - */ - int BlockSize { get; } - - /** - * Populate a passed in array with random data. - * - * @param output output array for generated bits. - * @param additionalInput additional input to be added to the DRBG in this step. - * @param predictionResistant true if a reseed should be forced, false otherwise. - * - * @return number of bits generated, -1 if a reseed required. - */ - int Generate(byte[] output, byte[] additionalInput, bool predictionResistant); - - /** - * Reseed the DRBG. - * - * @param additionalInput additional input to be added to the DRBG in this step. - */ - void Reseed(byte[] additionalInput); - } -} diff --git a/crypto/test/src/crypto/prng/test/DRGBTestVector.cs b/crypto/test/src/crypto/prng/test/DRGBTestVector.cs deleted file mode 100644 index a4129b9f8..000000000 --- a/crypto/test/src/crypto/prng/test/DRGBTestVector.cs +++ /dev/null @@ -1,129 +0,0 @@ -using Org.BouncyCastle.Utilities.Encoders; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Org.BouncyCastle.Crypto.Prng.Test -{ - public class DRBGTestVector - { - private IDigest _digest; - private IBlockCipher _cipher; - private int _keySizeInBits; - private IEntropySource _eSource; - private bool _pr; - private String _nonce; - private String _personalisation; - private int _ss; - private String[] _ev; - private List _ai = new List(); - - public DRBGTestVector(IDigest digest, IEntropySource eSource, bool predictionResistance, String nonce, int securityStrength, String[] expected) - { - _digest = digest; - _eSource = eSource; - _pr = predictionResistance; - _nonce = nonce; - _ss = securityStrength; - _ev = expected; - _personalisation = null; - } - - public DRBGTestVector(IBlockCipher cipher, int keySizeInBits, IEntropySource eSource, bool predictionResistance, String nonce, int securityStrength, String[] expected) - { - _cipher = cipher; - _keySizeInBits = keySizeInBits; - _eSource = eSource; - _pr = predictionResistance; - _nonce = nonce; - _ss = securityStrength; - _ev = expected; - _personalisation = null; - } - - public IDigest getDigest() - { - return _digest; - } - - public IBlockCipher getCipher() - { - return _cipher; - } - - public int keySizeInBits() - { - return _keySizeInBits; - } - - public DRBGTestVector addAdditionalInput(String input) - { - _ai.Add(input); - - return this; - } - - public DRBGTestVector setPersonalizationString(String p) - { - _personalisation = p; - - return this; - } - - public IEntropySource entropySource() - { - return _eSource; - } - - public bool predictionResistance() - { - return _pr; - } - - public byte[] nonce() - { - if (_nonce == null) - { - return null; - } - - return Hex.Decode(_nonce); - } - - public byte[] personalizationString() - { - if (_personalisation == null) - { - return null; - } - - return Hex.Decode(_personalisation); - } - - public int securityStrength() - { - return _ss; - } - - public byte[] expectedValue(int index) - { - return Hex.Decode(_ev[index]); - } - - public byte[] additionalInput(int position) - { - int len = _ai.Count; - byte[] rv; - if (position >= len) - { - rv = null; - } - else - { - rv = Hex.Decode((string)(_ai[position])); - } - return rv; - } - - } -} diff --git a/crypto/test/src/crypto/prng/test/DrbgTestVector.cs b/crypto/test/src/crypto/prng/test/DrbgTestVector.cs new file mode 100644 index 000000000..a4129b9f8 --- /dev/null +++ b/crypto/test/src/crypto/prng/test/DrbgTestVector.cs @@ -0,0 +1,129 @@ +using Org.BouncyCastle.Utilities.Encoders; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Org.BouncyCastle.Crypto.Prng.Test +{ + public class DRBGTestVector + { + private IDigest _digest; + private IBlockCipher _cipher; + private int _keySizeInBits; + private IEntropySource _eSource; + private bool _pr; + private String _nonce; + private String _personalisation; + private int _ss; + private String[] _ev; + private List _ai = new List(); + + public DRBGTestVector(IDigest digest, IEntropySource eSource, bool predictionResistance, String nonce, int securityStrength, String[] expected) + { + _digest = digest; + _eSource = eSource; + _pr = predictionResistance; + _nonce = nonce; + _ss = securityStrength; + _ev = expected; + _personalisation = null; + } + + public DRBGTestVector(IBlockCipher cipher, int keySizeInBits, IEntropySource eSource, bool predictionResistance, String nonce, int securityStrength, String[] expected) + { + _cipher = cipher; + _keySizeInBits = keySizeInBits; + _eSource = eSource; + _pr = predictionResistance; + _nonce = nonce; + _ss = securityStrength; + _ev = expected; + _personalisation = null; + } + + public IDigest getDigest() + { + return _digest; + } + + public IBlockCipher getCipher() + { + return _cipher; + } + + public int keySizeInBits() + { + return _keySizeInBits; + } + + public DRBGTestVector addAdditionalInput(String input) + { + _ai.Add(input); + + return this; + } + + public DRBGTestVector setPersonalizationString(String p) + { + _personalisation = p; + + return this; + } + + public IEntropySource entropySource() + { + return _eSource; + } + + public bool predictionResistance() + { + return _pr; + } + + public byte[] nonce() + { + if (_nonce == null) + { + return null; + } + + return Hex.Decode(_nonce); + } + + public byte[] personalizationString() + { + if (_personalisation == null) + { + return null; + } + + return Hex.Decode(_personalisation); + } + + public int securityStrength() + { + return _ss; + } + + public byte[] expectedValue(int index) + { + return Hex.Decode(_ev[index]); + } + + public byte[] additionalInput(int position) + { + int len = _ai.Count; + byte[] rv; + if (position >= len) + { + rv = null; + } + else + { + rv = Hex.Decode((string)(_ai[position])); + } + return rv; + } + + } +} -- cgit 1.5.1