diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-12 18:15:17 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-01-12 18:15:17 +0700 |
commit | 515f53364796324fc2b024e1ccab9b5adc4bcd7b (patch) | |
tree | d68c43f121785e680101c11f55ee9d1cb53b4d87 /crypto/src/openpgp/PgpV3SignatureGenerator.cs | |
parent | Refactoring around ParametersWithRandom (diff) | |
download | BouncyCastle.NET-ed25519-515f53364796324fc2b024e1ccab9b5adc4bcd7b.tar.xz |
Improvements to EdDSA use cases
- see https://github.com/bcgit/bc-csharp/issues/406
Diffstat (limited to 'crypto/src/openpgp/PgpV3SignatureGenerator.cs')
-rw-r--r-- | crypto/src/openpgp/PgpV3SignatureGenerator.cs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crypto/src/openpgp/PgpV3SignatureGenerator.cs b/crypto/src/openpgp/PgpV3SignatureGenerator.cs index 324dbd768..03dd8795d 100644 --- a/crypto/src/openpgp/PgpV3SignatureGenerator.cs +++ b/crypto/src/openpgp/PgpV3SignatureGenerator.cs @@ -47,20 +47,23 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp AsymmetricKeyParameter key = privKey.Key; - if (sig == null) - { - this.sig = PgpUtilities.CreateSigner(keyAlgorithm, hashAlgorithm, key); - } + this.sig = PgpUtilities.CreateSigner(keyAlgorithm, hashAlgorithm, key); try { - ICipherParameters cp = key; - if (random != null) - { - cp = new ParametersWithRandom(cp, random); - } + ICipherParameters cp = key; + + // TODO Ask SignerUtilities whether random is permitted? + if (keyAlgorithm == PublicKeyAlgorithmTag.EdDsa) + { + // EdDSA signers don't expect a SecureRandom + } + else + { + cp = ParameterUtilities.WithRandom(cp, random); + } - sig.Init(true, cp); + sig.Init(true, cp); } catch (InvalidKeyException e) { |