CryptographicEngine.VerifySignature(CryptographicKey, IBuffer, IBuffer) CryptographicEngine.VerifySignature(CryptographicKey, IBuffer, IBuffer) CryptographicEngine.VerifySignature(CryptographicKey, IBuffer, IBuffer) CryptographicEngine.VerifySignature(CryptographicKey, IBuffer, IBuffer) CryptographicEngine.VerifySignature(CryptographicKey, IBuffer, IBuffer) Method

Definition

Verifies a message signature.

public : static Platform::Boolean VerifySignature(CryptographicKey key, IBuffer data, IBuffer signature)
static bool VerifySignature(CryptographicKey key, IBuffer data, IBuffer signature) const;
public static bool VerifySignature(CryptographicKey key, IBuffer data, IBuffer signature)
Public Shared Function VerifySignature(key As CryptographicKey, data As IBuffer, signature As IBuffer) As bool
var bool = Windows.Security.Cryptography.Core.CryptographicEngine.verifySignature(key, data, signature);

Parameters

key
CryptographicKey CryptographicKey CryptographicKey

Key used for verification. This must be the same key previously used to sign the message.

data
IBuffer IBuffer IBuffer

Message to be verified.

signature
IBuffer IBuffer IBuffer

Signature previously computed over the message to be verified.

Returns

bool bool bool

true if the message is verified.

Examples

public void SampleVerifyHMAC(
    IBuffer buffMsg,
    CryptographicKey hmacKey,
    IBuffer buffHMAC)
{
    // The input key must be securely shared between the sender of the HMAC and 
    // the recipient. The recipient uses the CryptographicEngine.VerifySignature() 
    // method as follows to verify that the message has not been altered in transit.
    Boolean IsAuthenticated = CryptographicEngine.VerifySignature(hmacKey, buffMsg, buffHMAC);
    if (!IsAuthenticated)
    {
        throw new Exception("The message cannot be verified.");
    }
}

Remarks

To sign content, the sender typically creates a hash over the message, signs (encrypts) the hash, and then sends both the signature and the unencrypted message. The recipient uses the same key and algorithm to calculate a hash over the message, decrypts the signature, and compares the decrypted signature to the hash value. If they match, the recipient can be fairly certain that the message did, in fact, come from the sender and was not altered during transmission. For more information, see MACs, hashes, and signatures.