20142018 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Algorithm Details Hans Nilsson 2018-08-22 A algorithm_details.xml

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.

Ciphers

A cipher in the new api is categorized as either cipher_no_iv(), cipher_iv() or cipher_aead(). The letters IV are short for Initialization Vector and AEAD is an abreviation of Authenticated Encryption with Associated Data.

Due to irregular naming conventions, some cipher names in the old api are substitued by new names in the new api. For a list of retired names, see Retired cipher names.

To dynamically check availability, check that the name in the Cipher and Mode column is present in the list returned by crypto:supports(ciphers).

Ciphers without an IV - cipher_no_iv()

To be used with:

crypto_one_time/4 crypto_init/3

The ciphers are:

Cipher and Mode Key length
[bytes]
Block size
[bytes]
aes_128_ecb 16 16aes_192_ecb 24 16aes_256_ecb 32 16blowfish_ecb 16  8des_ecb  8  8rc4 16  1Ciphers without IV
Ciphers with an IV - cipher_iv()

To be used with:

crypto_one_time/5 crypto_init/4 crypto_dyn_iv_init/3

The ciphers are:

Cipher and Mode Key length
[bytes]
IV length
[bytes]
Block size
[bytes]
Limited to
OpenSSL versions
aes_128_cbc 16 16 16 aes_192_cbc 24 16 16 aes_256_cbc 32 16 16 aes_128_cfb8 16 16  1 aes_192_cfb8 24 16  1 aes_256_cfb8 32 16  1 aes_128_cfb12816 16  1 aes_192_cfb12824 16  1 aes_256_cfb12832 16  1 aes_128_ctr 16 16  1 aes_192_ctr 24 16  1 aes_256_ctr 32 16  1 aes_ige256 16 32 16 blowfish_cbc 16  8  8 blowfish_cfb6416  8  1 blowfish_ofb6416  8  1 chacha20 32 16  1 ≥1.1.0ddes_cbc  8  8  8 des_ede3_cbc 24  8  8 des_cfb  8  8  1 des_ede3_cfb 24  8  1 rc2_cbc 16  8  8 Ciphers with IV
Ciphers with AEAD - cipher_aead()

To be used with:

crypto_one_time_aead/6 crypto_one_time_aead/7

The ciphers are:

Cipher and Mode Key length
[bytes]
IV length
[bytes]
AAD length
[bytes]
Tag length
[bytes]
Block size
[bytes]
Limited to
OpenSSL versions
aes_128_ccm 16 7-13 any even 4-16
default: 12
any≥1.0.1
aes_192_ccm 24 7-13 any even 4-16
default: 12
any≥1.0.1
aes_256_ccm 32 7-13 any even 4-16
default: 12
any≥1.0.1
aes_128_gcm 16 ≥1 any 1-16
default: 16
any≥1.0.1
aes_192_gcm 24 ≥1 any 1-16
default: 16
any≥1.0.1
aes_256_gcm 32 ≥1 any 1-16
default: 16
any≥1.0.1
chacha20_poly130532 1-16 any 16 any≥1.1.0AEAD ciphers
Message Authentication Codes (MACs)

To be used in mac/4 and related functions.

CMAC

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 returned by crypto:supports(macs). Also check that the name in the Cipher and Mode column is present in the list returned by crypto:supports(ciphers).

Cipher and Mode Key length
[bytes]
Max Mac Length
(= default length)
[bytes]
aes_128_cbc 16 16aes_192_cbc 24 16aes_256_cbc 32 16aes_128_ecb 16 16aes_192_ecb 24 16aes_256_ecb 32 16blowfish_cbc 16  8blowfish_ecb 16  8des_cbc  8  8des_ecb  8  8des_ede3_cbc 24  8rc2_cbc 16  8CMAC cipher key lengths
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 returned by crypto:supports(macs) and that the hash name is present in the list returned by crypto:supports(hashs).

Hash Max Mac Length
(= default length)
[bytes]
sha 20sha224 28sha256 32sha384 48sha512 64sha3_224 28sha3_256 32sha3_384 48sha3_512 64blake2b 64blake2s 32md4 16md5 16ripemd160 20HMAC output sizes
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 returned by crypto:supports(macs).

The poly1305 mac wants an 32 bytes key and produces a 16 byte MAC by default.

Hash

To dynamically check availability, check that the wanted name in the Names column is present in the list returned by crypto:supports(hashs).

Type Names Limitated to
OpenSSL versions
SHA1shaSHA2sha224, sha256, sha384, sha512SHA3sha3_224, sha3_256, sha3_384, sha3_512≥1.1.1MD4md4MD5md5RIPEMDripemd160
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 returned by crypto:supports(public_keys).

The RSA options are experimental.

The exact set of options and there syntax may be changed without prior notice.

Option sign/verify public encrypt
private decrypt
private encrypt
public decrypt
{rsa_padding,rsa_x931_padding} x x {rsa_padding,rsa_pkcs1_padding} x x x {rsa_padding,rsa_pkcs1_pss_padding}
{rsa_pss_saltlen, -2..}
{rsa_mgf1_md, atom()}
x (2)
x (2)
x (2)
{rsa_padding,rsa_pkcs1_oaep_padding}
{rsa_mgf1_md, atom()}
{rsa_oaep_label, binary()}}
{rsa_oaep_md, atom()}
x (2)
x (2)
x (3)
x (3)
{rsa_padding,rsa_no_padding} x (1)

Notes:

(1) OpenSSL ≤ 1.0.0 (2) OpenSSL ≥ 1.0.1 (3) OpenSSL ≥ 1.1.0
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 returned by crypto:supports(public_keys).

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 returned by crypto:supports(public_keys). If the atom ec_gf2m also is present, the characteristic two field curves are available.

The actual supported named curves could be checked by examining the list returned by crypto:supports(curves).

EdDSA

EdDSA is available with OpenSSL 1.1.1 or later if not disabled by configuration. To dynamically check availability, check that the atom eddsa is present in the list returned by crypto:supports(public_keys).

Support for the curves ed25519 and ed448 is implemented. The actual supported named curves could be checked by examining the list with the list returned by crypto:supports(curves).

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 returned by crypto:supports(public_keys).

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 returned by crypto:supports(public_keys).

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 returned by crypto:supports(curves).