diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-09-10 00:19:15 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-09-10 00:19:15 +0700 |
commit | 7248688e6f513cbdde1ccc1d39904cb964b0c88a (patch) | |
tree | 55e3287103febeeec1d759b7c691951306d087e9 /crypto/src/security/ParameterUtilities.cs | |
parent | Port ChaCha20Poly1305 from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-7248688e6f513cbdde1ccc1d39904cb964b0c88a.tar.xz |
Add ChaCha ciphers to factory classes
Diffstat (limited to '')
-rw-r--r-- | crypto/src/security/ParameterUtilities.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crypto/src/security/ParameterUtilities.cs b/crypto/src/security/ParameterUtilities.cs index dc6992833..0ff1bdb4a 100644 --- a/crypto/src/security/ParameterUtilities.cs +++ b/crypto/src/security/ParameterUtilities.cs @@ -65,6 +65,11 @@ namespace Org.BouncyCastle.Security AddAlgorithm("CAST5", "1.2.840.113533.7.66.10"); AddAlgorithm("CAST6"); + AddAlgorithm("CHACHA"); + AddAlgorithm("CHACHA7539", + "CHACHA20", + "CHACHA20-POLY1305", + PkcsObjectIdentifiers.IdAlgAeadChaCha20Poly1305); AddAlgorithm("DES", OiwObjectIdentifiers.DesCbc, OiwObjectIdentifiers.DesCfb, @@ -114,7 +119,8 @@ namespace Org.BouncyCastle.Security AddAlgorithm("VMPC-KSA3"); AddAlgorithm("XTEA"); - AddBasicIVSizeEntries(8, "BLOWFISH", "DES", "DESEDE", "DESEDE3"); + AddBasicIVSizeEntries(8, "BLOWFISH", "CHACHA", "DES", "DESEDE", "DESEDE3", "SALSA20"); + AddBasicIVSizeEntries(12, "CHACHA7539"); AddBasicIVSizeEntries(16, "AES", "AES128", "AES192", "AES256", "CAMELLIA", "CAMELLIA128", "CAMELLIA192", "CAMELLIA256", "NOEKEON", "SEED", "SM4"); @@ -315,13 +321,9 @@ namespace Org.BouncyCastle.Security return new DerOctetString(CreateIV(random, ivLength)); } - private static byte[] CreateIV( - SecureRandom random, - int ivLength) + private static byte[] CreateIV(SecureRandom random, int ivLength) { - byte[] iv = new byte[ivLength]; - random.NextBytes(iv); - return iv; + return SecureRandom.GetNextBytes(random, ivLength); } private static int FindBasicIVSize( |