summary refs log tree commit diff
path: root/crypto/src/crmf/PKMacValueGenerator.cs
blob: 0809de348758bcbeadfb95b43bfe1e229d279f23 (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
28
using System;

using Org.BouncyCastle.Asn1.Crmf;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.X509;

namespace Org.BouncyCastle.Crmf
{
    internal static class PKMacValueGenerator
    {
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER
        internal static PKMacValue Generate(PKMacBuilder builder, ReadOnlySpan<char> password,
            SubjectPublicKeyInfo keyInfo)
        {
            var macFactory = builder.Build(password);
            var macValue = X509Utilities.GenerateMac(macFactory, keyInfo);
            return new PKMacValue((AlgorithmIdentifier)macFactory.AlgorithmDetails, macValue);
        }
#else
        internal static PKMacValue Generate(PKMacBuilder builder, char[] password, SubjectPublicKeyInfo keyInfo)
        {
            var macFactory = builder.Build(password);
            var macValue = X509Utilities.GenerateMac(macFactory, keyInfo);
            return new PKMacValue((AlgorithmIdentifier)macFactory.AlgorithmDetails, macValue);
        }
#endif
    }
}