diff options
Diffstat (limited to 'crypto/src/crypto/BufferedAsymmetricBlockCipher.cs')
-rw-r--r-- | crypto/src/crypto/BufferedAsymmetricBlockCipher.cs | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/crypto/src/crypto/BufferedAsymmetricBlockCipher.cs b/crypto/src/crypto/BufferedAsymmetricBlockCipher.cs index bf00f3ece..83c2fe70c 100644 --- a/crypto/src/crypto/BufferedAsymmetricBlockCipher.cs +++ b/crypto/src/crypto/BufferedAsymmetricBlockCipher.cs @@ -1,7 +1,4 @@ using System; -using System.Diagnostics; - -using Org.BouncyCastle.Crypto.Engines; namespace Org.BouncyCastle.Crypto { @@ -111,7 +108,18 @@ namespace Org.BouncyCastle.Crypto return null; } - /** +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override int ProcessBytes(ReadOnlySpan<byte> input, Span<byte> output) + { + Check.DataLength(input, buffer.Length - bufOff, "attempt to process message too long for cipher"); + + input.CopyTo(buffer.AsSpan(bufOff)); + bufOff += input.Length; + return 0; + } +#endif + + /** * process the contents of the buffer using the underlying * cipher. * @@ -139,7 +147,24 @@ namespace Org.BouncyCastle.Crypto return DoFinal(); } - /// <summary>Reset the buffer</summary> +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override int DoFinal(Span<byte> output) + { + int result = 0; + if (bufOff > 0) + { + byte[] outBytes = cipher.ProcessBlock(buffer, 0, bufOff); + outBytes.CopyTo(output); + result = outBytes.Length; + } + + Reset(); + + return result; + } +#endif + + /// <summary>Reset the buffer</summary> public override void Reset() { if (buffer != null) |