diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-28 13:04:07 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-28 13:04:07 +0700 |
commit | 0f3b8a392bc23cc1b9a4320987e61c3f64b0639a (patch) | |
tree | cfda5d47a3bd90ae725b96b6994c6b779882d444 /crypto/src/x509/X509Utilities.cs | |
parent | Refactoring (diff) | |
download | BouncyCastle.NET-ed25519-0f3b8a392bc23cc1b9a4320987e61c3f64b0639a.tar.xz |
Refactoring around digest calculation
Diffstat (limited to '')
-rw-r--r-- | crypto/src/x509/X509Utilities.cs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/src/x509/X509Utilities.cs b/crypto/src/x509/X509Utilities.cs index 45fa75916..5051b1b4e 100644 --- a/crypto/src/x509/X509Utilities.cs +++ b/crypto/src/x509/X509Utilities.cs @@ -10,6 +10,8 @@ using Org.BouncyCastle.Asn1.TeleTrust; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X9; using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.Crypto.Operators; +using Org.BouncyCastle.Security; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Collections; @@ -127,6 +129,14 @@ namespace Org.BouncyCastle.X509 m_exParams.Add("SHA512WITHRSAANDMGF1", CreatePssParams(sha512AlgId, 64)); } + internal static byte[] CalculateDigest(DerObjectIdentifier oid, Asn1Encodable asn1Encodable) + { + var digest = DigestUtilities.GetDigest(oid); + var digestCalculator = new DefaultDigestCalculator(digest); + var digestResult = CalculateResult(digestCalculator, asn1Encodable); + return digestResult.Collect(); + } + internal static TResult CalculateResult<TResult>(IStreamCalculator<TResult> streamCalculator, Asn1Encodable asn1Encodable) { @@ -195,6 +205,11 @@ namespace Org.BouncyCastle.X509 return CollectDerBitString(result); } + internal static DerBitString GenerateDigest(IDigestFactory digestFactory, Asn1Encodable asn1Encodable) + { + return GenerateBitString(digestFactory.CreateCalculator(), asn1Encodable); + } + internal static DerBitString GenerateMac(IMacFactory macFactory, Asn1Encodable asn1Encodable) { return GenerateBitString(macFactory.CreateCalculator(), asn1Encodable); |