diff options
author | Hans Nilsson <[email protected]> | 2019-03-12 15:07:43 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2019-03-19 12:45:55 +0100 |
commit | 5a313cb363e2f74ed0c602482c609fcc6dcc718a (patch) | |
tree | 864d35670c5fe0339f661747ab7eab05921a47d3 /lib/crypto/src | |
parent | 5e0d5aab3f2a61cf9d4f72cead77594c5fdde793 (diff) | |
download | otp-5a313cb363e2f74ed0c602482c609fcc6dcc718a.tar.gz otp-5a313cb363e2f74ed0c602482c609fcc6dcc718a.tar.bz2 otp-5a313cb363e2f74ed0c602482c609fcc6dcc718a.zip |
crypto: Rename SSL special functions
to crypto_init_dyn_iv/3 and crypto_update_dyn_iv/3
Diffstat (limited to 'lib/crypto/src')
-rw-r--r-- | lib/crypto/src/crypto.erl | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl index 4bceeb7510..5cf34f8069 100644 --- a/lib/crypto/src/crypto.erl +++ b/lib/crypto/src/crypto.erl @@ -56,9 +56,11 @@ ]). %% New interface --export([crypto_init/4, crypto_init/3, crypto_init/2, - crypto_update/2, crypto_update/3, - crypto_one_shot/5 +-export([crypto_init/4, crypto_init/3, + crypto_update/2, + crypto_one_shot/5, + crypto_init_dyn_iv/3, + crypto_update_dyn_iv/3 ]). @@ -721,24 +723,39 @@ next_iv(Type, Data, _Ivec) -> %%% Create and initialize a new state for encryption or decryption %%% +-spec crypto_init(Cipher, Key, EncryptFlag) -> State | ng_crypto_error() + when Cipher :: block_cipher_without_iv() + | stream_cipher_no_iv(), + Key :: iodata(), + EncryptFlag :: boolean(), + State :: crypto_state() . +crypto_init(Cipher, Key, EncryptFlag) -> + %% The IV is supposed to be supplied by calling crypto_update/3 + ng_crypto_init_nif(alias(Cipher), iolist_to_binary(Key), <<>>, EncryptFlag). + + -spec crypto_init(Cipher, Key, IV, EncryptFlag) -> State | ng_crypto_error() - when Cipher :: stream_cipher() - | block_cipher_with_iv() - | block_cipher_without_iv(), + when Cipher :: stream_cipher_iv() + | block_cipher_with_iv(), Key :: iodata(), - IV :: iodata() | undefined, + IV :: iodata(), EncryptFlag :: boolean(), State :: crypto_state() . -crypto_init(Cipher, Key, undefined, EncryptFlag) -> - %% The IV is supposed to be supplied by calling crypto_update/3 - ng_crypto_init_nif(alias(Cipher), - iolist_to_binary(Key), undefined, - EncryptFlag); - crypto_init(Cipher, Key, IV, EncryptFlag) -> - ng_crypto_init_nif(alias(Cipher), - iolist_to_binary(Key), iolist_to_binary(IV), - EncryptFlag). + ng_crypto_init_nif(alias(Cipher), iolist_to_binary(Key), iolist_to_binary(IV), EncryptFlag). + + + +%%%---------------------------------------------------------------- +-spec crypto_init_dyn_iv(Cipher, Key, EncryptFlag) -> State | ng_crypto_error() + when Cipher :: stream_cipher_iv() + | block_cipher_with_iv(), + Key :: iodata(), + EncryptFlag :: boolean(), + State :: crypto_state() . +crypto_init_dyn_iv(Cipher, Key, EncryptFlag) -> + %% The IV is supposed to be supplied by calling crypto_update/3 + ng_crypto_init_nif(alias(Cipher), iolist_to_binary(Key), undefined, EncryptFlag). %%%---------------------------------------------------------------- %%% @@ -760,12 +777,13 @@ crypto_update(State, Data0) -> end. --spec crypto_update(State, Data, IV) -> Result | ng_crypto_error() - when State :: crypto_state(), - Data :: iodata(), - IV :: iodata(), - Result :: binary() . -crypto_update(State, Data0, IV) -> +%%%---------------------------------------------------------------- +-spec crypto_update_dyn_iv(State, Data, IV) -> Result | ng_crypto_error() + when State :: crypto_state(), + Data :: iodata(), + IV :: iodata(), + Result :: binary() . +crypto_update_dyn_iv(State, Data0, IV) -> %% When State is from State = crypto_init(Cipher, Key, undefined, EncryptFlag) case iolist_to_binary(Data0) of <<>> -> @@ -774,7 +792,6 @@ crypto_update(State, Data0, IV) -> ng_crypto_update_nif(State, Data, iolist_to_binary(IV)) end. - %%%---------------------------------------------------------------- %%% %%% Encrypt/decrypt one set bytes. |