Fortinet white logo
Fortinet white logo

Script Reference Guide

aes_dec(t)

aes_dec(t)

Decrypts data that was previously encrypted using the AES algorithm with the specified key and key size. Returns the decrypted data as a binary string.

Syntax

aes_dec(t);

Arguments

Name Description

t

A table that specifies the encrypted data to decrypt, the decryption key, and the key size.

Operations

The function performs AES decryption on the provided encrypted data using the specified key.

Field

Type

Required

Description

message

String

Yes

The encrypted data as a binary string (direct output from aes_enc()).

key

String

Yes

The decryption key. Length must match the key size (16, 24, or 32 bytes). Must be the same key used for encryption.

size

Number

Yes

The AES key size. Must be 128, 192, or 256.

Events

Applicable in all events.

Example

when HTTP_REQUEST {
t={};
t["message"]  = "MICK-TEST";
t["key"]  = "aaaaaaaaaabbbbbb"
t["size"]= 128 -- 128, 192, or 256, the corresponding key length is 16, 24, and 32
enc = aes_enc(t)
--aes decryption
a={};
a["message"]  = enc;
a["key"]  = "aaaaaaaaaabbbbbb"
a["size"]= 128;
dec = aes_dec(a);
debug("key length %s decrypted is %s\n",”128” ,dec);
}

Notes:

  • The message parameter for decryption should be the direct binary output from aes_enc() function.
  • No hexadecimal conversion is needed between encryption and decryption.
  • The key length must exactly match the AES key size requirement.
  • Uses ECB mode with PKCS#7 padding.
  • Automatically handles padding removal after decryption.

Supported Version

FortiADC version 5.2.x and later.

aes_dec(t)

aes_dec(t)

Decrypts data that was previously encrypted using the AES algorithm with the specified key and key size. Returns the decrypted data as a binary string.

Syntax

aes_dec(t);

Arguments

Name Description

t

A table that specifies the encrypted data to decrypt, the decryption key, and the key size.

Operations

The function performs AES decryption on the provided encrypted data using the specified key.

Field

Type

Required

Description

message

String

Yes

The encrypted data as a binary string (direct output from aes_enc()).

key

String

Yes

The decryption key. Length must match the key size (16, 24, or 32 bytes). Must be the same key used for encryption.

size

Number

Yes

The AES key size. Must be 128, 192, or 256.

Events

Applicable in all events.

Example

when HTTP_REQUEST {
t={};
t["message"]  = "MICK-TEST";
t["key"]  = "aaaaaaaaaabbbbbb"
t["size"]= 128 -- 128, 192, or 256, the corresponding key length is 16, 24, and 32
enc = aes_enc(t)
--aes decryption
a={};
a["message"]  = enc;
a["key"]  = "aaaaaaaaaabbbbbb"
a["size"]= 128;
dec = aes_dec(a);
debug("key length %s decrypted is %s\n",”128” ,dec);
}

Notes:

  • The message parameter for decryption should be the direct binary output from aes_enc() function.
  • No hexadecimal conversion is needed between encryption and decryption.
  • The key length must exactly match the AES key size requirement.
  • Uses ECB mode with PKCS#7 padding.
  • Automatically handles padding removal after decryption.

Supported Version

FortiADC version 5.2.x and later.