<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />

Org.BouncyCastle.Security.MacUtilities

public static class MacUtilities
Factory for IMac instances (HMAC, CMAC, GMAC, Poly1305, etc.) and convenience helpers for one-shot MAC computation.
public static byte[] CalculateMac(string algorithm, ICipherParameters cp, byte[] input)

One-shot MAC of input using the named algorithm and the supplied key parameters.

public static byte[] DoFinal(IMac mac)

Finalises mac and returns the resulting tag as a fresh array.

public static byte[] DoFinal(IMac mac, byte[] input)

Feeds input into mac, then finalises and returns the tag.

public static string GetAlgorithmName(DerObjectIdentifier oid)

Returns the canonical algorithm name registered for the given ASN.1 OID, or null if the OID is not mapped to a known MAC.

public static IMac GetMac(DerObjectIdentifier id)

Resolve and instantiate an IMac for the given ASN.1 algorithm OID.

public static IMac GetMac(string algorithm)

Resolve and instantiate an IMac by name (or alias).