diff options
author | David Hook <dgh@cryptoworkshop.com> | 2022-08-25 12:58:05 +1000 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2022-08-25 12:58:05 +1000 |
commit | fa5fc2339e292e53a8c1c9cc16c2e8242f5066d1 (patch) | |
tree | 5487957c1417f3ae0028dd62de3d2b26368135eb /crypto/src/security | |
parent | initial CRYSTALS-Kyber implementation (diff) | |
parent | Span-based variant for IMac.DoFinal (diff) | |
download | BouncyCastle.NET-ed25519-fa5fc2339e292e53a8c1c9cc16c2e8242f5066d1.tar.xz |
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'crypto/src/security')
-rw-r--r-- | crypto/src/security/DigestUtilities.cs | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/crypto/src/security/DigestUtilities.cs b/crypto/src/security/DigestUtilities.cs index 2c9e89277..035280fd6 100644 --- a/crypto/src/security/DigestUtilities.cs +++ b/crypto/src/security/DigestUtilities.cs @@ -266,9 +266,22 @@ namespace Org.BouncyCastle.Security public static byte[] CalculateDigest(string algorithm, byte[] input) { IDigest digest = GetDigest(algorithm); - digest.BlockUpdate(input, 0, input.Length); - return DoFinal(digest); + return DoFinal(digest, input); + } + + public static byte[] CalculateDigest(string algorithm, byte[] buf, int off, int len) + { + IDigest digest = GetDigest(algorithm); + return DoFinal(digest, buf, off, len); + } + +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public static byte[] CalculateDigest(string algorithm, ReadOnlySpan<byte> buffer) + { + IDigest digest = GetDigest(algorithm); + return DoFinal(digest, buffer); } +#endif public static byte[] DoFinal(IDigest digest) { @@ -282,5 +295,19 @@ namespace Org.BouncyCastle.Security digest.BlockUpdate(input, 0, input.Length); return DoFinal(digest); } + + public static byte[] DoFinal(IDigest digest, byte[] buf, int off, int len) + { + digest.BlockUpdate(buf, off, len); + return DoFinal(digest); + } + +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public static byte[] DoFinal(IDigest digest, ReadOnlySpan<byte> buffer) + { + digest.BlockUpdate(buffer); + return DoFinal(digest); + } +#endif } } |