AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

This is the response object from the VerifyMac operation.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceResponse
    Amazon.KeyManagementService.Model.VerifyMacResponse

Namespace: Amazon.KeyManagementService.Model
Assembly: AWSSDK.KeyManagementService.dll
Version: 3.x.y.z

Syntax

C#
public class VerifyMacResponse : AmazonWebServiceResponse

The VerifyMacResponse type exposes the following members

Constructors

NameDescription
Public Method VerifyMacResponse()

Properties

NameTypeDescription
Public Property ContentLength System.Int64 Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property HttpStatusCode System.Net.HttpStatusCode Inherited from Amazon.Runtime.AmazonWebServiceResponse.
Public Property KeyId System.String

Gets and sets the property KeyId.

The HMAC KMS key used in the verification.

Public Property MacAlgorithm Amazon.KeyManagementService.MacAlgorithmSpec

Gets and sets the property MacAlgorithm.

The MAC algorithm used in the verification.

Public Property MacValid System.Boolean

Gets and sets the property MacValid.

A Boolean value that indicates whether the HMAC was verified. A value of True indicates that the HMAC (Mac) was generated with the specified Message, HMAC KMS key (KeyID) and MacAlgorithm..

If the HMAC is not verified, the VerifyMac operation fails with a KMSInvalidMacException exception. This exception indicates that one or more of the inputs changed since the HMAC was computed.

Public Property ResponseMetadata Amazon.Runtime.ResponseMetadata Inherited from Amazon.Runtime.AmazonWebServiceResponse.

Examples

This example verifies an HMAC for a particular message, HMAC KMS keys, and MAC algorithm. A value of 'true' in the MacValid value in the response indicates that the HMAC is valid.

To verify an HMAC


var client = new AmazonKeyManagementServiceClient();
var response = client.VerifyMac(new VerifyMacRequest 
{
    KeyId = "1234abcd-12ab-34cd-56ef-1234567890ab", // The HMAC KMS key input to the HMAC algorithm.
    Mac = new MemoryStream(<HMAC_TAG>), // The HMAC to be verified.
    MacAlgorithm = "HMAC_SHA_384", // The HMAC algorithm requested for the operation.
    Message = new MemoryStream(Hello World) // The message input to the HMAC algorithm.
});

string keyId = response.KeyId; // The key ARN of the HMAC key used in the operation.
string macAlgorithm = response.MacAlgorithm; // The HMAC algorithm used in the operation.
bool macValid = response.MacValid; // A value of 'true' indicates that verification succeeded. If verification fails, the call to VerifyMac fails.

            

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5