5 Algorithm Details
This chapter describes details of algorithms in the crypto application.
The tables only documents the supported cryptos and key lengths. The user should not draw any conclusion on security from the supplied tables.
5.1 Ciphers
Block Ciphers
To be used in block_encrypt/3, block_encrypt/4, block_decrypt/3 and block_decrypt/4.
Available in all OpenSSL compatible with Erlang CRYPTO if not disabled by configuration.
To dynamically check availability, check that the name in the Cipher and Mode column is present in the list with the cipher tag in the return value of crypto:supports().
Cipher and Mode |
Key length [bytes] |
IV length [bytes] |
Block size [bytes] |
aes_cbc | 16, 24, 32 | 16 | 16 |
aes_cbc128 | 16 | 16 | 16 |
aes_cbc256 | 32 | 16 | 16 |
aes_cfb8 | 16, 24, 32 | 16 | any |
aes_ecb | 16, 24, 32 | 16 | |
aes_ige256 | 16 | 32 | 16 |
blowfish_cbc | 4-56 | 8 | 8 |
blowfish_cfb64 | 1- | 8 | any |
blowfish_ecb | 1- | 8 | |
blowfish_ofb64 | 1- | 8 | any |
des3_cbc (=DES EDE3 CBC) |
[8,8,8] | 8 | 8 |
des3_cfb (=DES EDE3 CFB) |
[8,8,8] | 8 | any |
des_cbc | 8 | 8 | 8 |
des_cfb | 8 | 8 | any |
des_ecb | 8 | 8 | |
des_ede3 (=DES EDE3 CBC) |
[8,8,8] | 8 | 8 |
rc2_cbc | 1- | 8 | 8 |
AEAD Ciphers
To be used in block_encrypt/4 and block_decrypt/4.
To dynamically check availability, check that the name in the Cipher and Mode column is present in the list with the cipher tag in the return value of crypto:supports().
Cipher and Mode |
Key length [bytes] |
IV length [bytes] |
AAD length [bytes] |
Tag length [bytes] |
Block size [bytes] |
Supported with OpenSSL versions |
aes_ccm | 16,24,32 | 7-13 | any | even 4-16 default: 12 | any | 1.1.0 - |
aes_gcm | 16,24,32 | 1- | any | 1-16 default: 16 | any | 1.1.0 - |
chacha20_poly1305 | 32 | 1-16 | any | 16 | any | 1.1.0 - |
Stream Ciphers
To be used in stream_init/2 and stream_init/3.
To dynamically check availability, check that the name in the Cipher and Mode column is present in the list with the cipher tag in the return value of crypto:supports().
Cipher and Mode |
Key length [bytes] |
IV length [bytes] |
Supported with OpenSSL versions |
aes_ctr | 16, 24, 32 | 16 | 1.0.1 - |
rc4 | 1- | all |
5.2 Message Authentication Codes (MACs)
CMAC
To be used in cmac/3 and cmac/4.
CMAC with the following ciphers are available with OpenSSL 1.0.1 or later if not disabled by configuration.
To dynamically check availability, check that the name cmac is present in the list with the macs tag in the return value of crypto:supports(). Also check that the name in the Cipher and Mode column is present in the list with the cipher tag in the return value.
Cipher and Mode |
Key length [bytes] |
Max Mac Length [bytes] |
aes_cbc | 16, 24, 32 | 16 |
aes_cbc128 | 16 | 16 |
aes_cbc256 | 32 | 16 |
aes_cfb8 | 16 | 1 |
blowfish_cbc | 4-56 | 8 |
blowfish_cfb64 | 1- | 1 |
blowfish_ecb | 1- | 8 |
blowfish_ofb64 | 1- | 1 |
des3_cbc (=DES EDE3 CBC) |
[8,8,8] | 8 |
des3_cfb (=DES EDE3 CFB) |
[8,8,8] | 1 |
des_cbc | 8 | 8 |
des_cfb | 8 | 1 |
des_ecb | 8 | 1 |
rc2_cbc | 1- | 8 |
HMAC
Available in all OpenSSL compatible with Erlang CRYPTO if not disabled by configuration.
To dynamically check availability, check that the name hmac is present in the list with the macs tag in the return value of crypto:supports().
POLY1305
POLY1305 is available with OpenSSL 1.1.1 or later if not disabled by configuration.
To dynamically check availability, check that the name poly1305 is present in the list with the macs tag in the return value of crypto:supports().
5.3 Hash
To dynamically check availability, check that the wanted name in the Names column is present in the list with the hashs tag in the return value of crypto:supports().
Type | Names |
Supported with OpenSSL versions |
SHA1 | sha | all |
SHA2 | sha224, sha256, sha384, sha512 | all |
SHA3 | sha3_224, sha3_256, sha3_384, sha3_512 | 1.1.1 - |
MD4 | md4 | all |
MD5 | md5 | all |
RIPEMD | ripemd160 | all |
5.4 Public Key Cryptography
RSA
RSA is available with all OpenSSL versions compatible with Erlang CRYPTO if not disabled by configuration. To dynamically check availability, check that the atom rsa is present in the list with the public_keys tag in the return value of crypto:supports().
The RSA options are experimental.
The exact set of options and there syntax may be changed without prior notice.
Option | sign/verify | encrypt/decrypt |
Supported with OpenSSL versions |
{rsa_mgf1_md,atom()} | x | x | 1.0.1 |
{rsa_oaep_label, binary()} | x | ||
{rsa_oaep_md, atom()} | x | ||
{rsa_padding,rsa_pkcs1_pss_padding} | x | 1.0.0 | |
{rsa_pss_saltlen, -2..} | x | 1.0.0 | |
{rsa_padding,rsa_no_padding} | x | x | |
{rsa_padding,rsa_pkcs1_padding} | x | x | |
{rsa_padding,rsa_sslv23_padding} | x | ||
{rsa_padding,rsa_x931_padding} | x |
DSS
DSS is available with OpenSSL versions compatible with Erlang CRYPTO if not disabled by configuration. To dynamically check availability, check that the atom dss is present in the list with the public_keys tag in the return value of crypto:supports().
ECDSA
ECDSA is available with OpenSSL 0.9.8o or later if not disabled by configuration. To dynamically check availability, check that the atom ecdsa is present in the list with the public_keys tag in the return value of crypto:supports(). If the atom ec_gf2m characteristic two field curves are available.
The actual supported named curves could be checked by examining the list with the curves tag in the return value of crypto:supports().
Diffie-Hellman
Diffie-Hellman computations are available with OpenSSL versions compatible with Erlang CRYPTO if not disabled by configuration. To dynamically check availability, check that the atom dh is present in the list with the public_keys tag in the return value of crypto:supports().
Elliptic Curve Diffie-Hellman
Elliptic Curve Diffie-Hellman is available with OpenSSL 0.9.8o or later if not disabled by configuration. To dynamically check availability, check that the atom ecdh is present in the list with the public_keys tag in the return value of crypto:supports().
The Edward curves x25519 and x448 are supported with OpenSSL 1.1.1 or later if not disabled by configuration.
The actual supported named curves could be checked by examining the list with the curves tag in the return value of crypto:supports().