Fortinet white logo
Fortinet white logo

Script Reference Guide

HMAC_verify(alg, data, key, verify)

HMAC_verify(alg, data, key, verify)

Compares the provided signature against the current digest value. Returns true for a match, false for a mismatch.

Syntax

HMAC_verify(alg, data, key,verify);

Arguments

Name Description

alg

A string which specifies the type of hashing algorithms to use, must be MD5, SHA1, SHA256, SHA384, SHA512.

key

A string which is a secret key.

data

A string which will be calculated.

verify

A signature to compare the current digest against.

Events

Applicable in all events.

Example

when HTTP_REQUEST {
alg = "MD5"; -- or "SHA1", "SHA256", "SHA384", "SHA512"
data = "your data"
verify = "your result to compare"
key  = "123456789ABCDEF0123456789ABCDEF\121"; -- or you can generate a key using key_gen
re = HMAC_verify(alg, data, key, verify);
if re then
debug("verified\n")
else
debug("not verified\n")
end
}

Supported Version

FortiADC version 5.2.x and later.

HMAC_verify(alg, data, key, verify)

HMAC_verify(alg, data, key, verify)

Compares the provided signature against the current digest value. Returns true for a match, false for a mismatch.

Syntax

HMAC_verify(alg, data, key,verify);

Arguments

Name Description

alg

A string which specifies the type of hashing algorithms to use, must be MD5, SHA1, SHA256, SHA384, SHA512.

key

A string which is a secret key.

data

A string which will be calculated.

verify

A signature to compare the current digest against.

Events

Applicable in all events.

Example

when HTTP_REQUEST {
alg = "MD5"; -- or "SHA1", "SHA256", "SHA384", "SHA512"
data = "your data"
verify = "your result to compare"
key  = "123456789ABCDEF0123456789ABCDEF\121"; -- or you can generate a key using key_gen
re = HMAC_verify(alg, data, key, verify);
if re then
debug("verified\n")
else
debug("not verified\n")
end
}

Supported Version

FortiADC version 5.2.x and later.