Skip to main content

Cryptography

FunctionDescriptionMeta
crypto.hmac.equal

result := crypto.hmac.equal(mac1, mac2)

Returns a boolean representing the result of comparing two MACs for equality without leaking timing information.

Arguments:
mac1 (string)

mac1 to compare

mac2 (string)

mac2 to compare

Returns:
result (boolean)

true if the MACs are equals, false otherwise

v0.52.0 SDK-dependent
crypto.hmac.md5

y := crypto.hmac.md5(x, key)

Returns a string representing the MD5 HMAC of the input message using the input key.

Arguments:
x (string)

input string

key (string)

key to use

Returns:
y (string)

MD5-HMAC of x

v0.36.0 SDK-dependent
crypto.hmac.sha1

y := crypto.hmac.sha1(x, key)

Returns a string representing the SHA1 HMAC of the input message using the input key.

Arguments:
x (string)

input string

key (string)

key to use

Returns:
y (string)

SHA1-HMAC of x

v0.36.0 SDK-dependent
crypto.hmac.sha256

y := crypto.hmac.sha256(x, key)

Returns a string representing the SHA256 HMAC of the input message using the input key.

Arguments:
x (string)

input string

key (string)

key to use

Returns:
y (string)

SHA256-HMAC of x

v0.36.0 SDK-dependent
crypto.hmac.sha512

y := crypto.hmac.sha512(x, key)

Returns a string representing the SHA512 HMAC of the input message using the input key.

Arguments:
x (string)

input string

key (string)

key to use

Returns:
y (string)

SHA512-HMAC of x

v0.36.0 SDK-dependent
crypto.md5

y := crypto.md5(x)

Returns a string representing the input string hashed with the MD5 function

Arguments:
x (string)

input string

Returns:
y (string)

MD5-hash of x

SDK-dependent
crypto.parse_private_keys

output := crypto.parse_private_keys(keys)

Returns zero or more private keys from the given encoded string containing DER certificate data.

If the input is empty, the function will return null. The input string should be a list of one or more concatenated PEM blocks. The whole input of concatenated PEM blocks can optionally be Base64 encoded.

Arguments:
keys (string)

PEM encoded data containing one or more private keys as concatenated blocks. Optionally Base64 encoded.

Returns:
output (array[object[string: any]])

parsed private keys represented as objects

v0.55.0 SDK-dependent
crypto.sha1

y := crypto.sha1(x)

Returns a string representing the input string hashed with the SHA1 function

Arguments:
x (string)

input string

Returns:
y (string)

SHA1-hash of x

SDK-dependent
crypto.sha256

y := crypto.sha256(x)

Returns a string representing the input string hashed with the SHA256 function

Arguments:
x (string)

input string

Returns:
y (string)

SHA256-hash of x

SDK-dependent
crypto.x509.parse_and_verify_certificates

output := crypto.x509.parse_and_verify_certificates(certs)

Returns one or more certificates from the given string containing PEM or base64 encoded DER certificates after verifying the supplied certificates form a complete certificate chain back to a trusted root.

The first certificate is treated as the root and the last is treated as the leaf, with all others being treated as intermediates.

Arguments:
certs (string)

base64 encoded DER or PEM data containing two or more certificates where the first is a root CA, the last is a leaf certificate, and all others are intermediate CAs

Returns:
output (array<boolean, array[object[string: any]]>)

array of [valid, certs]: if the input certificate chain could be verified then valid is true and certs is an array of X.509 certificates represented as objects; if the input certificate chain could not be verified then valid is false and certs is []

v0.31.0 SDK-dependent
crypto.x509.parse_and_verify_certificates_with_options

output := crypto.x509.parse_and_verify_certificates_with_options(certs, options)

Returns one or more certificates from the given string containing PEM or base64 encoded DER certificates after verifying the supplied certificates form a complete certificate chain back to a trusted root. A config option passed as the second argument can be used to configure the validation options used.

The first certificate is treated as the root and the last is treated as the leaf, with all others being treated as intermediates.

Arguments:
certs (string)

base64 encoded DER or PEM data containing two or more certificates where the first is a root CA, the last is a leaf certificate, and all others are intermediate CAs

options (object[string: any])

object containing extra configs to verify the validity of certificates. options object supports four fields which maps to same fields in x509.VerifyOptions struct. DNSName, CurrentTime: Nanoseconds since the Unix Epoch as a number, MaxConstraintComparisons and KeyUsages. KeyUsages is list and can have possible values as in: "KeyUsageAny", "KeyUsageServerAuth", "KeyUsageClientAuth", "KeyUsageCodeSigning", "KeyUsageEmailProtection", "KeyUsageIPSECEndSystem", "KeyUsageIPSECTunnel", "KeyUsageIPSECUser", "KeyUsageTimeStamping", "KeyUsageOCSPSigning", "KeyUsageMicrosoftServerGatedCrypto", "KeyUsageNetscapeServerGatedCrypto", "KeyUsageMicrosoftCommercialCodeSigning", "KeyUsageMicrosoftKernelCodeSigning"

Returns:
output (array<boolean, array[object[string: any]]>)

array of [valid, certs]: if the input certificate chain could be verified then valid is true and certs is an array of X.509 certificates represented as objects; if the input certificate chain could not be verified then valid is false and certs is []

v0.63.0 SDK-dependent
crypto.x509.parse_certificate_request

output := crypto.x509.parse_certificate_request(csr)

Returns a PKCS #10 certificate signing request from the given PEM-encoded PKCS#10 certificate signing request.

Arguments:
csr (string)

base64 string containing either a PEM encoded or DER CSR or a string containing a PEM CSR

Returns:
output (object[string: any])

X.509 CSR represented as an object

v0.21.0 SDK-dependent
crypto.x509.parse_certificates

output := crypto.x509.parse_certificates(certs)

Returns zero or more certificates from the given encoded string containing DER certificate data.

If the input is empty, the function will return null. The input string should be a list of one or more concatenated PEM blocks. The whole input of concatenated PEM blocks can optionally be Base64 encoded.

Arguments:
certs (string)

base64 encoded DER or PEM data containing one or more certificates or a PEM string of one or more certificates

Returns:
output (array[object[string: any]])

parsed X.509 certificates represented as objects

SDK-dependent
crypto.x509.parse_keypair

output := crypto.x509.parse_keypair(cert, pem)

Returns a valid key pair

Arguments:
cert (string)

string containing PEM or base64 encoded DER certificates

pem (string)

string containing PEM or base64 encoded DER keys

Returns:
output (object[string: any])

if key pair is valid, returns the tls.certificate(https://pkg.go.dev/crypto/tls#Certificate) as an object. If the key pair is invalid, nil and an error are returned.

v0.53.0 SDK-dependent
crypto.x509.parse_rsa_private_key

output := crypto.x509.parse_rsa_private_key(pem)

Returns a JWK for signing a JWT from the given PEM-encoded RSA private key.

Arguments:
pem (string)

base64 string containing a PEM encoded RSA private key

Returns:
output (object[string: any])

JWK as an object

v0.33.0 SDK-dependent