summary refs log tree commit diff
path: root/crypto/src/crypto/operators/DefaultDigestResult.cs
blob: 60625c421ffaedc8cb22811c070100528dc3b0e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;

using Org.BouncyCastle.Security;

namespace Org.BouncyCastle.Crypto.Operators
{
    public sealed class DefaultDigestResult
        : IBlockResult
    {
        private readonly IDigest m_digest;

        public DefaultDigestResult(IDigest digest)
        {
            m_digest = digest;
        }

        public byte[] Collect() => DigestUtilities.DoFinal(m_digest);

        public int Collect(byte[] buf, int off) => m_digest.DoFinal(buf, off);

#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
        public int Collect(Span<byte> output) => m_digest.DoFinal(output);
#endif

        public int GetMaxResultLength() => m_digest.GetDigestSize();
    }
}