diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-16 12:53:03 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-16 12:53:03 +0700 |
commit | 2a32a3776411760789304c66c53cd9dd19237372 (patch) | |
tree | a80d31d7e6845d13e4db79ea9e60fed7c08ff39f | |
parent | FIPS DRBG digest/hmac/CTR (diff) | |
download | BouncyCastle.NET-ed25519-2a32a3776411760789304c66c53cd9dd19237372.tar.xz |
Rename/delete some files
-rw-r--r-- | crypto/src/crypto/prng/ISP80090Drbg.cs (renamed from crypto/src/crypto/prng/SP80090Drbg.cs) | 0 | ||||
-rw-r--r-- | crypto/src/crypto/prng/Utils.cs | 103 | ||||
-rw-r--r-- | crypto/src/crypto/prng/drbg/DrbgUtilities.cs (renamed from crypto/src/crypto/prng/drbg/Utils.cs) | 0 |
3 files changed, 0 insertions, 103 deletions
diff --git a/crypto/src/crypto/prng/SP80090Drbg.cs b/crypto/src/crypto/prng/ISP80090Drbg.cs index c39cf365f..c39cf365f 100644 --- a/crypto/src/crypto/prng/SP80090Drbg.cs +++ b/crypto/src/crypto/prng/ISP80090Drbg.cs diff --git a/crypto/src/crypto/prng/Utils.cs b/crypto/src/crypto/prng/Utils.cs deleted file mode 100644 index e5fe7d4b2..000000000 --- a/crypto/src/crypto/prng/Utils.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections; - -using Org.BouncyCastle.Utilities; - -namespace Org.BouncyCastle.Crypto.Prng.Drbg -{ - internal class Utils - { - private static readonly IDictionary maxSecurityStrengths = Platform.CreateHashtable(); - - static Utils() - { - maxSecurityStrengths.Add("SHA-1", 128); - - maxSecurityStrengths.Add("SHA-224", 192); - maxSecurityStrengths.Add("SHA-256", 256); - maxSecurityStrengths.Add("SHA-384", 256); - maxSecurityStrengths.Add("SHA-512", 256); - - maxSecurityStrengths.Add("SHA-512/224", 192); - maxSecurityStrengths.Add("SHA-512/256", 256); - } - - internal static int getMaxSecurityStrength(IDigest d) - { - return (int)maxSecurityStrengths[d.AlgorithmName]; - } - - internal static int getMaxSecurityStrength(IMac m) - { - string name = m.AlgorithmName; - - return (int)maxSecurityStrengths[name.Substring(0, name.IndexOf("/"))]; - } - - /** - * Used by both Dual EC and Hash. - */ - internal static byte[] hash_df(IDigest digest, byte[] seedMaterial, int seedLength) - { - // 1. temp = the Null string. - // 2. . - // 3. counter = an 8-bit binary value representing the integer "1". - // 4. For i = 1 to len do - // Comment : In step 4.1, no_of_bits_to_return - // is used as a 32-bit string. - // 4.1 temp = temp || Hash (counter || no_of_bits_to_return || - // input_string). - // 4.2 counter = counter + 1. - // 5. requested_bits = Leftmost (no_of_bits_to_return) of temp. - // 6. Return SUCCESS and requested_bits. - byte[] temp = new byte[(seedLength + 7) / 8]; - - int len = temp.Length / digest.GetDigestSize(); - int counter = 1; - - byte[] dig = new byte[digest.GetDigestSize()]; - - for (int i = 0; i <= len; i++) - { - digest.Update((byte)counter); - - digest.Update((byte)(seedLength >> 24)); - digest.Update((byte)(seedLength >> 16)); - digest.Update((byte)(seedLength >> 8)); - digest.Update((byte)seedLength); - - digest.BlockUpdate(seedMaterial, 0, seedMaterial.Length); - - digest.DoFinal(dig, 0); - - int bytesToCopy = ((temp.Length - i * dig.Length) > dig.Length) - ? dig.Length - : (temp.Length - i * dig.Length); - Array.Copy(dig, 0, temp, i * dig.Length, bytesToCopy); - - counter++; - } - - // do a left shift to get rid of excess bits. - if (seedLength % 8 != 0) - { - int shift = 8 - (seedLength % 8); - uint carry = 0; - - for (int i = 0; i != temp.Length; i++) - { - uint b = (uint)(temp[i] & 0xff); - temp[i] = (byte)((b >> shift) | (carry << (8 - shift))); - carry = b; - } - } - - return temp; - } - - internal static bool isTooLarge(byte[] bytes, int maxBytes) - { - return bytes != null && bytes.Length > maxBytes; - } - } -} diff --git a/crypto/src/crypto/prng/drbg/Utils.cs b/crypto/src/crypto/prng/drbg/DrbgUtilities.cs index b5f3b5830..b5f3b5830 100644 --- a/crypto/src/crypto/prng/drbg/Utils.cs +++ b/crypto/src/crypto/prng/drbg/DrbgUtilities.cs |