From 938e788fb404e9e270975d36db5e27d7e136ef09 Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Tue, 30 Apr 2019 16:47:42 +0200 Subject: crypto: Document supports/1 --- lib/crypto/doc/src/crypto.xml | 40 ++++++++++++++++++++++++++++------------ lib/crypto/doc/src/new_api.xml | 10 +++++++++- lib/crypto/src/crypto.erl | 21 +++++++++++++++++++++ 3 files changed, 58 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/crypto/doc/src/crypto.xml b/lib/crypto/doc/src/crypto.xml index 641738247e..751cf9d1fc 100644 --- a/lib/crypto/doc/src/crypto.xml +++ b/lib/crypto/doc/src/crypto.xml @@ -772,6 +772,19 @@

+ + + + Provide a list of available crypto algorithms. + +

Can be used to determine which crypto algorithms that are supported + by the underlying libcrypto library

+

See hash_info/1 and cipher_info/1 + for information about the hash and cipher algorithms. +

+
+
+
@@ -1425,18 +1438,6 @@ FloatValue = rand:uniform(). % again - - - Provide a list of available crypto algorithms. - -

Can be used to determine which crypto algorithms that are supported - by the underlying libcrypto library

-

See hash_info/1 and cipher_info/1 - for information about the hash and cipher algorithms. -

-
-
- Provide a list of available named elliptic curves. @@ -1947,6 +1948,21 @@ FloatValue = rand:uniform(). % again + + + Provide a list of available crypto algorithms. + +

Don't use this function for new programs! Use + supports/1 in + the new api.

+

Can be used to determine which crypto algorithms that are supported + by the underlying libcrypto library

+

See hash_info/1 and cipher_info/1 + for information about the hash and cipher algorithms. +

+
+
+ diff --git a/lib/crypto/doc/src/new_api.xml b/lib/crypto/doc/src/new_api.xml index 79096b55e8..58ace97554 100644 --- a/lib/crypto/doc/src/new_api.xml +++ b/lib/crypto/doc/src/new_api.xml @@ -59,6 +59,7 @@ stream_init/3 stream_encrypt/2 stream_decrypt/2 + suppports/0

They are not deprecated for now, but may be in a future.

@@ -94,7 +95,7 @@ crypto_update does the acual encryption or decryption. Note that AEAD ciphers can't be handled this way due to their nature.

-

Finally, for repeated encryption or decryption of a text divided in parts where the +

For repeated encryption or decryption of a text divided in parts where the same cipher and same key is used, but a new initialization vector (nounce) should be applied for each part, the functions are:

@@ -103,6 +104,13 @@ crypto_dyn_iv_update/3

An example of where those functions are needed, is when handling the TLS protocol.

+

For information about available algorithms, use: +

+ + supports/1 + hash_info/1 + cipher_info/1 +
Examples of crypto_init/4 and crypto_update/2 diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl index 98378412d4..8ffdde2b90 100644 --- a/lib/crypto/src/crypto.erl +++ b/lib/crypto/src/crypto.erl @@ -509,6 +509,27 @@ supports() -> {rsa_opts, rsa_opts_algorithms()} ]. + +-spec supports(Type) -> Support + when Type :: hashs + | ciphers + | public_keys + | macs + | curves + | rsa_opts, + Support :: Hashs + | Ciphers + | PKs + | Macs + | Curves + | RSAopts, + Hashs :: [sha1() | sha2() | sha3() | blake2() | ripemd160 | compatibility_only_hash()], + Ciphers :: [cipher()], + PKs :: [rsa | dss | ecdsa | dh | ecdh | ec_gf2m], + Macs :: [hmac | cmac | poly1305], + Curves :: [ec_named_curve() | edwards_curve_dh() | edwards_curve_ed()], + RSAopts :: [rsa_sign_verify_opt() | rsa_opt()] . + supports(hashs) -> hash_algorithms(); supports(public_keys) -> pubkey_algorithms(); supports(ciphers) -> cipher_algorithms(); -- cgit v1.2.3