diff options
author | David Hook <dgh@cryptoworkshop.com> | 2022-09-20 16:14:16 +1000 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2022-09-20 16:14:16 +1000 |
commit | 29713a2a41a0ef69b13466ece39ac92d2db6bcc3 (patch) | |
tree | 86c31daa9fc496d5f6e2a37d17f6b562d57de542 /crypto/src | |
parent | Add MapElements methods (diff) | |
download | BouncyCastle.NET-ed25519-29713a2a41a0ef69b13466ece39ac92d2db6bcc3.tar.xz |
added randomized signing
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/pqc/crypto/crystals/dilithium/DilithiumEngine.cs | 3 | ||||
-rw-r--r-- | crypto/src/pqc/crypto/crystals/dilithium/DilithiumSigner.cs | 13 |
2 files changed, 7 insertions, 9 deletions
diff --git a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumEngine.cs b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumEngine.cs index b5ac413e4..9b6479eaf 100644 --- a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumEngine.cs +++ b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumEngine.cs @@ -17,7 +17,6 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium public const int RootOfUnity = 1753; public const int SeedBytes = 32; public const int CrhBytes = 64; - public const bool RandomizedSigning = false; public const int PolyT1PackedBytes = 320; public const int PolyT0PackedBytes = 416; @@ -185,7 +184,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium ShakeDigest256.BlockUpdate(msg, 0, msglen); ShakeDigest256.DoFinal(mu, 0, CrhBytes); - if (RandomizedSigning) + if (_random != null) { _random.NextBytes(rhoPrime); } diff --git a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumSigner.cs b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumSigner.cs index 98b19ff3e..58b9d1803 100644 --- a/crypto/src/pqc/crypto/crystals/dilithium/DilithiumSigner.cs +++ b/crypto/src/pqc/crypto/crystals/dilithium/DilithiumSigner.cs @@ -12,9 +12,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium private SecureRandom random; - public DilithiumSigner(SecureRandom random) + public DilithiumSigner() { - this.random = random; } public void Init(bool forSigning, ICipherParameters param) @@ -22,15 +21,15 @@ namespace Org.BouncyCastle.Pqc.Crypto.Crystals.Dilithium if (forSigning) { if (param is ParametersWithRandom) - { + { privKey = (DilithiumPrivateKeyParameters)((ParametersWithRandom)param).Parameters; random = ((ParametersWithRandom)param).Random; } else - { - privKey = (DilithiumPrivateKeyParameters)param; - random = new SecureRandom(); - } + { + privKey = (DilithiumPrivateKeyParameters)param; + random = null; + } } else { |