diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-12-21 12:34:49 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-12-21 12:34:49 +0700 |
commit | 3c508655db514af6702bb51be63dc0b3d176e11b (patch) | |
tree | 2ae0176a5616ecc1b0b30a85a29f2805dc4b5241 /crypto/src/cmp | |
parent | AesWrap: update from bc-java (diff) | |
download | BouncyCastle.NET-ed25519-3c508655db514af6702bb51be63dc0b3d176e11b.tar.xz |
Span-based alternatives to char[]
Diffstat (limited to 'crypto/src/cmp')
-rw-r--r-- | crypto/src/cmp/ProtectedPkiMessage.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/src/cmp/ProtectedPkiMessage.cs b/crypto/src/cmp/ProtectedPkiMessage.cs index 8c9a4b152..df4c45143 100644 --- a/crypto/src/cmp/ProtectedPkiMessage.cs +++ b/crypto/src/cmp/ProtectedPkiMessage.cs @@ -119,6 +119,22 @@ namespace Org.BouncyCastle.Cmp return Arrays.FixedTimeEquals(result.Collect(), m_pkiMessage.Protection.GetBytes()); } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public virtual bool Verify(PKMacBuilder pkMacBuilder, ReadOnlySpan<char> password) + { + if (!CmpObjectIdentifiers.passwordBasedMac.Equals(m_pkiMessage.Header.ProtectionAlg.Algorithm)) + throw new InvalidOperationException("protection algorithm is not mac based"); + + PbmParameter parameter = PbmParameter.GetInstance(m_pkiMessage.Header.ProtectionAlg.Parameters); + + pkMacBuilder.SetParameters(parameter); + + IBlockResult result = Process(pkMacBuilder.Build(password).CreateCalculator()); + + return Arrays.FixedTimeEquals(result.Collect(), m_pkiMessage.Protection.GetBytes()); + } +#endif + private TResult Process<TResult>(IStreamCalculator<TResult> streamCalculator) { Asn1EncodableVector avec = new Asn1EncodableVector(); |