aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-04-30 16:47:42 +0200
committerHans Nilsson <[email protected]>2019-04-30 16:55:02 +0200
commit938e788fb404e9e270975d36db5e27d7e136ef09 (patch)
tree07185c619cff6767ad2b166898843dba715419e5
parentc500d66b68ff0fe174128926318f3eead4dcbb15 (diff)
downloadotp-938e788fb404e9e270975d36db5e27d7e136ef09.tar.gz
otp-938e788fb404e9e270975d36db5e27d7e136ef09.tar.bz2
otp-938e788fb404e9e270975d36db5e27d7e136ef09.zip
crypto: Document supports/1
-rw-r--r--lib/crypto/doc/src/crypto.xml40
-rw-r--r--lib/crypto/doc/src/new_api.xml10
-rw-r--r--lib/crypto/src/crypto.erl21
3 files changed, 58 insertions, 13 deletions
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 @@
</p>
</desc>
</func>
+
+ <func>
+ <name name="supports" arity="1" since="OTP 22.0"/>
+ <fsummary>Provide a list of available crypto algorithms.</fsummary>
+ <desc>
+ <p> Can be used to determine which crypto algorithms that are supported
+ by the underlying libcrypto library</p>
+ <p>See <seealso marker="#hash_info-1">hash_info/1</seealso> and <seealso marker="#cipher_info-1">cipher_info/1</seealso>
+ for information about the hash and cipher algorithms.
+ </p>
+ </desc>
+ </func>
+
</funcs>
<section>
@@ -1425,18 +1438,6 @@ FloatValue = rand:uniform(). % again
</desc>
</func>
- <func>
- <name name="supports" arity="0" since="OTP R16B01"/>
- <fsummary>Provide a list of available crypto algorithms.</fsummary>
- <desc>
- <p> Can be used to determine which crypto algorithms that are supported
- by the underlying libcrypto library</p>
- <p>See <seealso marker="#hash_info-1">hash_info/1</seealso> and <seealso marker="#cipher_info-1">cipher_info/1</seealso>
- for information about the hash and cipher algorithms.
- </p>
- </desc>
- </func>
-
<func>
<name name="ec_curves" arity="0" since="OTP 17.0"/>
<fsummary>Provide a list of available named elliptic curves.</fsummary>
@@ -1947,6 +1948,21 @@ FloatValue = rand:uniform(). % again
</desc>
</func>
+ <func>
+ <name name="supports" arity="0" since="OTP R16B01"/>
+ <fsummary>Provide a list of available crypto algorithms.</fsummary>
+ <desc>
+ <dont><p>Don't use this function for new programs! Use
+ <seealso marker="crypto#supports-1">supports/1</seealso> in
+ <seealso marker="crypto:new_api">the new api</seealso>.</p></dont>
+ <p> Can be used to determine which crypto algorithms that are supported
+ by the underlying libcrypto library</p>
+ <p>See <seealso marker="#hash_info-1">hash_info/1</seealso> and <seealso marker="#cipher_info-1">cipher_info/1</seealso>
+ for information about the hash and cipher algorithms.
+ </p>
+ </desc>
+ </func>
+
</funcs>
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 @@
<item><seealso marker="crypto#stream_init-2">stream_init/3</seealso></item>
<item><seealso marker="crypto#stream_encrypt-2">stream_encrypt/2</seealso></item>
<item><seealso marker="crypto#stream_decrypt-2">stream_decrypt/2</seealso></item>
+ <item><seealso marker="crypto#supports-0">suppports/0</seealso></item>
</list>
<p>They are not deprecated for now, but may be in a future.
</p>
@@ -94,7 +95,7 @@
<c>crypto_update</c> does the acual encryption or decryption. Note that AEAD ciphers
can't be handled this way due to their nature.
</p>
- <p>Finally, for repeated encryption or decryption of a text divided in parts where the
+ <p>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:
</p>
@@ -103,6 +104,13 @@
<item><seealso marker="crypto#crypto_dyn_iv_update/3">crypto_dyn_iv_update/3</seealso></item>
</list>
<p>An example of where those functions are needed, is when handling the TLS protocol.</p>
+ <p>For information about available algorithms, use:
+ </p>
+ <list>
+ <item><seealso marker="crypto#supports-1">supports/1</seealso></item>
+ <item><seealso marker="crypto#hash_info-1">hash_info/1</seealso></item>
+ <item><seealso marker="crypto#cipher_info-1">cipher_info/1</seealso></item>
+ </list>
<section>
<title>Examples of crypto_init/4 and crypto_update/2</title>
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();