diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-05 23:58:56 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-05 23:58:56 +0700 |
commit | 57892c7da152735b8d9d8a814029b9299f7feb8a (patch) | |
tree | 45349dd625ed9146a1257d1431c022d28ee3a244 /crypto | |
parent | Remove Times class (diff) | |
download | BouncyCastle.NET-ed25519-57892c7da152735b8d9d8a814029b9299f7feb8a.tar.xz |
Fix method names and refactoring
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/crypto/CipherKeyGenerator.cs | 16 | ||||
-rw-r--r-- | crypto/src/crypto/generators/DesEdeKeyGenerator.cs | 5 | ||||
-rw-r--r-- | crypto/src/crypto/generators/DesKeyGenerator.cs | 7 | ||||
-rw-r--r-- | crypto/src/crypto/generators/Poly1305KeyGenerator.cs | 6 | ||||
-rw-r--r-- | crypto/src/crypto/util/CipherKeyGeneratorFactory.cs | 6 |
5 files changed, 16 insertions, 24 deletions
diff --git a/crypto/src/crypto/CipherKeyGenerator.cs b/crypto/src/crypto/CipherKeyGenerator.cs index d8d9b29b5..80d4782db 100644 --- a/crypto/src/crypto/CipherKeyGenerator.cs +++ b/crypto/src/crypto/CipherKeyGenerator.cs @@ -37,19 +37,17 @@ namespace Org.BouncyCastle.Crypto * * @param param the parameters to be used for key generation */ - public void Init( - KeyGenerationParameters parameters) + public void Init(KeyGenerationParameters parameters) { if (parameters == null) - throw new ArgumentNullException("parameters"); + throw new ArgumentNullException(nameof(parameters)); this.uninitialised = false; - engineInit(parameters); + EngineInit(parameters); } - protected virtual void engineInit( - KeyGenerationParameters parameters) + protected virtual void EngineInit(KeyGenerationParameters parameters) { this.random = parameters.Random; this.strength = (parameters.Strength + 7) / 8; @@ -69,13 +67,13 @@ namespace Org.BouncyCastle.Crypto uninitialised = false; - engineInit(new KeyGenerationParameters(new SecureRandom(), defaultStrength)); + EngineInit(new KeyGenerationParameters(new SecureRandom(), defaultStrength)); } - return engineGenerateKey(); + return EngineGenerateKey(); } - protected virtual byte[] engineGenerateKey() + protected virtual byte[] EngineGenerateKey() { return SecureRandom.GetNextBytes(random, strength); } diff --git a/crypto/src/crypto/generators/DesEdeKeyGenerator.cs b/crypto/src/crypto/generators/DesEdeKeyGenerator.cs index 904cc71f1..24197e9da 100644 --- a/crypto/src/crypto/generators/DesEdeKeyGenerator.cs +++ b/crypto/src/crypto/generators/DesEdeKeyGenerator.cs @@ -26,8 +26,7 @@ namespace Org.BouncyCastle.Crypto.Generators * * @param param the parameters to be used for key generation */ - protected override void engineInit( - KeyGenerationParameters parameters) + protected override void EngineInit(KeyGenerationParameters parameters) { this.random = parameters.Random; this.strength = (parameters.Strength + 7) / 8; @@ -50,7 +49,7 @@ namespace Org.BouncyCastle.Crypto.Generators } } - protected override byte[] engineGenerateKey() + protected override byte[] EngineGenerateKey() { byte[] newKey = new byte[strength]; diff --git a/crypto/src/crypto/generators/DesKeyGenerator.cs b/crypto/src/crypto/generators/DesKeyGenerator.cs index 4c2051d89..5a1befd71 100644 --- a/crypto/src/crypto/generators/DesKeyGenerator.cs +++ b/crypto/src/crypto/generators/DesKeyGenerator.cs @@ -24,10 +24,9 @@ namespace Org.BouncyCastle.Crypto.Generators * * @param param the parameters to be used for key generation */ - protected override void engineInit( - KeyGenerationParameters parameters) + protected override void EngineInit(KeyGenerationParameters parameters) { - base.engineInit(parameters); + base.EngineInit(parameters); if (strength == 0 || strength == (56 / 8)) { @@ -40,7 +39,7 @@ namespace Org.BouncyCastle.Crypto.Generators } } - protected override byte[] engineGenerateKey() + protected override byte[] EngineGenerateKey() { byte[] newKey = new byte[DesParameters.DesKeyLength]; diff --git a/crypto/src/crypto/generators/Poly1305KeyGenerator.cs b/crypto/src/crypto/generators/Poly1305KeyGenerator.cs index cdb24bfa0..d7827fea9 100644 --- a/crypto/src/crypto/generators/Poly1305KeyGenerator.cs +++ b/crypto/src/crypto/generators/Poly1305KeyGenerator.cs @@ -31,7 +31,7 @@ namespace Org.BouncyCastle.Crypto.Generators /// <remarks> /// Poly1305 keys are always 256 bits, so the key length in the provided parameters is ignored. /// </remarks> - protected override void engineInit(KeyGenerationParameters param) + protected override void EngineInit(KeyGenerationParameters param) { // Poly1305 keys are always 256 bits this.random = param.Random; @@ -43,9 +43,9 @@ namespace Org.BouncyCastle.Crypto.Generators /// <code>k[0] ... k[15], r[0] ... r[15]</code> with the required bits in <code>r</code> cleared /// as per <see cref="Clamp(byte[])"/>. /// </summary> - protected override byte[] engineGenerateKey() + protected override byte[] EngineGenerateKey() { - byte[] key = base.engineGenerateKey(); + byte[] key = base.EngineGenerateKey(); Clamp(key); return key; } diff --git a/crypto/src/crypto/util/CipherKeyGeneratorFactory.cs b/crypto/src/crypto/util/CipherKeyGeneratorFactory.cs index efaad138c..2e48513ad 100644 --- a/crypto/src/crypto/util/CipherKeyGeneratorFactory.cs +++ b/crypto/src/crypto/util/CipherKeyGeneratorFactory.cs @@ -11,12 +11,8 @@ using Org.BouncyCastle.Security; namespace Org.BouncyCastle.Crypto.Utilities { - public class CipherKeyGeneratorFactory + public static class CipherKeyGeneratorFactory { - private CipherKeyGeneratorFactory() - { - } - /** * Create a key generator for the passed in Object Identifier. * |