diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 20:45:17 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 20:45:17 +0700 |
commit | 9d4dde60ecdcfabf38eaa98c483b15263e0b99e5 (patch) | |
tree | df27be68a5e95d77c5cdc49b5d154581aa8fa605 /crypto/src/crmf | |
parent | Add missing file (diff) | |
download | BouncyCastle.NET-ed25519-9d4dde60ecdcfabf38eaa98c483b15263e0b99e5.tar.xz |
Add GetMaxResultLength method
Diffstat (limited to 'crypto/src/crmf')
-rw-r--r-- | crypto/src/crmf/PKMacBuilder.cs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crypto/src/crmf/PKMacBuilder.cs b/crypto/src/crmf/PKMacBuilder.cs index ae9baa3d0..7261a9daf 100644 --- a/crypto/src/crmf/PKMacBuilder.cs +++ b/crypto/src/crmf/PKMacBuilder.cs @@ -60,7 +60,7 @@ namespace Org.BouncyCastle.Crmf } } - internal class DefaultPKMacResult + internal sealed class DefaultPKMacResult : IBlockResult { private readonly IMac mac; @@ -77,21 +77,19 @@ namespace Org.BouncyCastle.Crmf return res; } - public int Collect(byte[] sig, int sigOff) + public int Collect(byte[] buf, int off) { - byte[] signature = Collect(); - signature.CopyTo(sig, sigOff); - return signature.Length; + return mac.DoFinal(buf, off); } #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER - public int Collect(Span<byte> destination) + public int Collect(Span<byte> output) { - byte[] result = Collect(); - result.CopyTo(destination); - return result.Length; + return mac.DoFinal(output); } #endif + + public int GetMaxResultLength() => mac.GetMacSize(); } public class PKMacBuilder |