2014 2018 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

### 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
Block cipher key lengths

### 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
AEAD cipher key lengths

### 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
Stream cipher key lengths

## 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
CMAC 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 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().

## 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

## 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 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 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().

### 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 with the public_keys tag in the return value of crypto:supports().

Support for the curves ed25519 and ed448 is implemented. 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().