aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-03-18 12:04:53 +0100
committerHans Nilsson <[email protected]>2019-03-22 10:16:38 +0100
commit8528a54df1b6167dd6779bfa902a79ba058e8d06 (patch)
treec85066999e5edf22a021cdff5bcdc068c2b335d4 /lib/crypto
parent1b6895221c98b6be55088790c5fb3057f1c9b304 (diff)
downloadotp-8528a54df1b6167dd6779bfa902a79ba058e8d06.tar.gz
otp-8528a54df1b6167dd6779bfa902a79ba058e8d06.tar.bz2
otp-8528a54df1b6167dd6779bfa902a79ba058e8d06.zip
crypto: New types (block_cipher)
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/doc/src/crypto.xml9
-rw-r--r--lib/crypto/src/crypto.erl15
2 files changed, 19 insertions, 5 deletions
diff --git a/lib/crypto/doc/src/crypto.xml b/lib/crypto/doc/src/crypto.xml
index 83e10c4c78..0fac3f379e 100644
--- a/lib/crypto/doc/src/crypto.xml
+++ b/lib/crypto/doc/src/crypto.xml
@@ -192,7 +192,16 @@
<datatypes>
<datatype_title>Ciphers</datatype_title>
<datatype>
+ <name name="cipher"/>
<name name="stream_cipher"/>
+ <name name="block_cipher"/>
+ <desc>
+ <p>Ciphers known byt the CRYPTO application. Note that this list might be reduced if the
+ underlying libcrypto does not support all of them.</p>
+ </desc>
+ </datatype>
+
+ <datatype>
<name name="stream_cipher_iv"/>
<name name="stream_cipher_no_iv"/>
<desc>
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 503c347c56..aaba81f11b 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -277,6 +277,12 @@
-type edwards_curve_ed() :: ed25519 | ed448 .
%%%
+-type cipher() :: block_cipher()
+ | stream_cipher()
+ | aead_cipher() .
+
+-type block_cipher() :: block_cipher_with_iv() | block_cipher_without_iv() .
+
-type block_cipher_with_iv() :: cbc_cipher()
| cfb_cipher()
| aes_ige256
@@ -736,7 +742,7 @@ next_iv(Type, Data, _Ivec) ->
%%%
-spec crypto_init(Cipher, Key, EncryptFlag) -> State | ng_crypto_error()
- when Cipher :: block_cipher_without_iv()
+ when Cipher :: block_cipher_no_iv()
| stream_cipher_no_iv(),
Key :: iodata(),
EncryptFlag :: boolean(),
@@ -748,7 +754,7 @@ crypto_init(Cipher, Key, EncryptFlag) ->
-spec crypto_init(Cipher, Key, IV, EncryptFlag) -> State | ng_crypto_error()
when Cipher :: stream_cipher_iv()
- | block_cipher_with_iv(),
+ | block_cipher_iv(),
Key :: iodata(),
IV :: iodata(),
EncryptFlag :: boolean(),
@@ -761,7 +767,7 @@ crypto_init(Cipher, Key, IV, EncryptFlag) ->
%%%----------------------------------------------------------------
-spec crypto_init_dyn_iv(Cipher, Key, EncryptFlag) -> State | ng_crypto_error()
when Cipher :: stream_cipher_iv()
- | block_cipher_with_iv(),
+ | block_cipher_iv(),
Key :: iodata(),
EncryptFlag :: boolean(),
State :: crypto_state() .
@@ -812,8 +818,7 @@ crypto_update_dyn_iv(State, Data0, IV) ->
-spec crypto_one_shot(Cipher, Key, IV, Data, EncryptFlag) -> Result | ng_crypto_error()
when Cipher :: stream_cipher()
- | block_cipher_with_iv()
- | block_cipher_without_iv(),
+ | block_cipher(),
Key :: iodata(),
IV :: iodata() | undefined,
Data :: iodata(),