summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2015-03-25 22:37:24 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2015-03-25 22:37:24 +0700
commit80c93e4f0b3469a5fea79325d417db8d473338a8 (patch)
tree9c6793912f599fdb909b449515ec0f4cad3c4333 /crypto/src
parentInclude ANSSI curves in getByOID lookup (diff)
parentFormatting (diff)
downloadBouncyCastle.NET-ed25519-80c93e4f0b3469a5fea79325d417db8d473338a8.tar.xz
Merge branch 'mpsinfo-duplicatedigest'
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/cms/CMSSignedDataGenerator.cs22
1 files changed, 14 insertions, 8 deletions
diff --git a/crypto/src/cms/CMSSignedDataGenerator.cs b/crypto/src/cms/CMSSignedDataGenerator.cs

index f31105c41..114b9631d 100644 --- a/crypto/src/cms/CMSSignedDataGenerator.cs +++ b/crypto/src/cms/CMSSignedDataGenerator.cs
@@ -93,19 +93,25 @@ namespace Org.BouncyCastle.Cms { AlgorithmIdentifier digAlgId = DigestAlgorithmID; string digestName = Helper.GetDigestAlgName(digestOID); - IDigest dig = Helper.GetDigestInstance(digestName); string signatureName = digestName + "with" + Helper.GetEncryptionAlgName(encOID); ISigner sig = Helper.GetSignatureInstance(signatureName); - // TODO Optimise the case where more than one signer with same digest - if (content != null) + byte[] hash; + if (outer._digests.Contains(digestOID)) { - content.Write(new DigOutputStream(dig)); - } - - byte[] hash = DigestUtilities.DoFinal(dig); - outer._digests.Add(digestOID, hash.Clone()); + hash = (byte[])outer._digests[digestOID]; + } + else + { + IDigest dig = Helper.GetDigestInstance(digestName); + if (content != null) + { + content.Write(new DigOutputStream(dig)); + } + hash = DigestUtilities.DoFinal(dig); + outer._digests.Add(digestOID, hash.Clone()); + } sig.Init(true, new ParametersWithRandom(key, random)); #if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT