aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-04-11 13:02:55 +0200
committerHans Nilsson <[email protected]>2019-04-11 13:02:55 +0200
commit4ac92628f07df87787888fd47a3efa11c9025e5e (patch)
treea334d9ed7777105aff47ece0c7470190a258ea5f
parent5c3a51b042806d7d953424948b6c65cbcde6900b (diff)
parentbd8abd7b5cfb55bcc7becc2bf2344ec5f9a0185f (diff)
downloadotp-4ac92628f07df87787888fd47a3efa11c9025e5e.tar.gz
otp-4ac92628f07df87787888fd47a3efa11c9025e5e.tar.bz2
otp-4ac92628f07df87787888fd47a3efa11c9025e5e.zip
Merge branch 'hans/crypto/rename_api/OTP-15644'
* hans/crypto/rename_api/OTP-15644: crypto: Rename 'crypto_(init|update)_dyn_iv' to 'crypto_dyn_iv_(init|update)' crypto: Rename crypto_aead to crypto_one_time_aead
-rw-r--r--lib/crypto/doc/src/crypto.xml12
-rw-r--r--lib/crypto/doc/src/new_api.xml10
-rw-r--r--lib/crypto/src/crypto.erl30
-rw-r--r--lib/crypto/test/crypto_SUITE.erl14
4 files changed, 33 insertions, 33 deletions
diff --git a/lib/crypto/doc/src/crypto.xml b/lib/crypto/doc/src/crypto.xml
index db53eed738..641738247e 100644
--- a/lib/crypto/doc/src/crypto.xml
+++ b/lib/crypto/doc/src/crypto.xml
@@ -702,13 +702,13 @@
</func>
<func>
- <name name="crypto_init_dyn_iv" arity="3" since="OTP 22.0"/>
+ <name name="crypto_dyn_iv_init" arity="3" since="OTP 22.0"/>
<fsummary>Initializes a series of encryptions or decryptions where the IV is provided later</fsummary>
<desc>
<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
Initializes a series of encryptions or decryptions where the IV is provided later.
The actual encryption or decryption is done by
- <seealso marker="crypto#crypto_update_dyn_iv/3">crypto_update_dyn_iv/3</seealso>.
+ <seealso marker="crypto#crypto_dyn_iv_update/3">crypto_dyn_iv_update/3</seealso>.
</p>
<p>For encryption, set the <c>EncryptFlag</c> to <c>true</c>. For decryption, set it to <c>false</c>.
</p>
@@ -718,13 +718,13 @@
</func>
<func>
- <name name="crypto_update_dyn_iv" arity="3" since="OTP 22.0"/>
+ <name name="crypto_dyn_iv_update" arity="3" since="OTP 22.0"/>
<fsummary>Do an actual crypto operation on a part of the full text and the IV is supplied for each part</fsummary>
<desc>
<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
Do an actual crypto operation on a part of the full text and the IV is supplied for each part.
The <c>State</c> should be created with
- <seealso marker="crypto#crypto_init_dyn_iv/3">crypto_init_dyn_iv/3</seealso>.
+ <seealso marker="crypto#crypto_dyn_iv_init/3">crypto_dyn_iv_init/3</seealso>.
</p>
<p>See <seealso marker="crypto:new_api#the-new-api">examples in the User's Guide.</seealso>
</p>
@@ -754,8 +754,8 @@
</func>
<func>
- <name name="crypto_aead" arity="6" since="OTP 22.0"/>
- <name name="crypto_aead" arity="7" since="OTP 22.0"/>
+ <name name="crypto_one_time_aead" arity="6" since="OTP 22.0"/>
+ <name name="crypto_one_time_aead" arity="7" since="OTP 22.0"/>
<fsummary>Do a complete encrypt or decrypt with an AEAD cipher of the full text</fsummary>
<desc>
<p>Part of the <seealso marker="crypto:new_api#the-new-api">new API</seealso>.
diff --git a/lib/crypto/doc/src/new_api.xml b/lib/crypto/doc/src/new_api.xml
index e5e108d973..79096b55e8 100644
--- a/lib/crypto/doc/src/new_api.xml
+++ b/lib/crypto/doc/src/new_api.xml
@@ -71,14 +71,14 @@
<list>
<item><seealso marker="crypto#crypto_one_time/4">crypto_one_time/4</seealso></item>
<item><seealso marker="crypto#crypto_one_time/5">crypto_one_time/5</seealso></item>
- <item><seealso marker="crypto#crypto_aead/6">crypto_aead/6</seealso></item>
- <item><seealso marker="crypto#crypto_aead/7">crypto_aead/7</seealso></item>
+ <item><seealso marker="crypto#crypto_one_time_aead/6">crypto_one_time_aead/6</seealso></item>
+ <item><seealso marker="crypto#crypto_one_time_aead/7">crypto_one_time_aead/7</seealso></item>
</list>
<p>In those functions the internal crypto state is first created and initialized
with the cipher type, the key and possibly other data. Then the data is encrypted or decrypted,
the crypto state is de-allocated and the result of the crypto operation is returned.
</p>
- <p>The <c>crypto_aead</c> functions are for the ciphers of mode <c>ccm</c> or
+ <p>The <c>crypto_one_time_aead</c> functions are for the ciphers of mode <c>ccm</c> or
<c>gcm</c>, and for the cipher <c>chacha20-poly1305</c>.
</p>
<p>For repeated encryption or decryption of a text divided in parts, where the internal
@@ -99,8 +99,8 @@
for each part, the functions are:
</p>
<list>
- <item><seealso marker="crypto#crypto_init_dyn_iv/3">crypto_init_dyn_iv/3</seealso></item>
- <item><seealso marker="crypto#crypto_update_dyn_iv/3">crypto_update_dyn_iv/3</seealso></item>
+ <item><seealso marker="crypto#crypto_dyn_iv_init/3">crypto_dyn_iv_init/3</seealso></item>
+ <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>
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index a99ab2faea..3b431cceba 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -59,9 +59,9 @@
-export([crypto_init/4, crypto_init/3,
crypto_update/2,
crypto_one_time/4, crypto_one_time/5,
- crypto_aead/6, crypto_aead/7,
- crypto_init_dyn_iv/3,
- crypto_update_dyn_iv/3
+ crypto_one_time_aead/6, crypto_one_time_aead/7,
+ crypto_dyn_iv_init/3,
+ crypto_dyn_iv_update/3
]).
@@ -733,9 +733,9 @@ block_encrypt(Type, Key0, Ivec, Data) ->
?COMPAT(
case Data of
{AAD, PlainText} ->
- crypto_aead(alias(Type,Key), Key, Ivec, PlainText, AAD, true);
+ crypto_one_time_aead(alias(Type,Key), Key, Ivec, PlainText, AAD, true);
{AAD, PlainText, TagLength} ->
- crypto_aead(alias(Type,Key), Key, Ivec, PlainText, AAD, TagLength, true);
+ crypto_one_time_aead(alias(Type,Key), Key, Ivec, PlainText, AAD, TagLength, true);
PlainText ->
crypto_one_time(alias(Type,Key), Key, Ivec, PlainText, true)
end).
@@ -764,7 +764,7 @@ block_decrypt(Type, Key0, Ivec, Data) ->
?COMPAT(
case Data of
{AAD, CryptoText, Tag} ->
- crypto_aead(alias(Type,Key), Key, Ivec, CryptoText, AAD, Tag, false);
+ crypto_one_time_aead(alias(Type,Key), Key, Ivec, CryptoText, AAD, Tag, false);
CryptoText ->
crypto_one_time(alias(Type,Key), Key, Ivec, CryptoText, false)
end).
@@ -901,12 +901,12 @@ crypto_init(Cipher, Key, IV, EncryptFlag) ->
%%%----------------------------------------------------------------
--spec crypto_init_dyn_iv(Cipher, Key, EncryptFlag) -> State | descriptive_error()
+-spec crypto_dyn_iv_init(Cipher, Key, EncryptFlag) -> State | descriptive_error()
when Cipher :: cipher_iv(),
Key :: iodata(),
EncryptFlag :: boolean(),
State :: crypto_state() .
-crypto_init_dyn_iv(Cipher, Key, EncryptFlag) ->
+crypto_dyn_iv_init(Cipher, Key, EncryptFlag) ->
%% The IV is supposed to be supplied by calling crypto_update/3
ng_crypto_init_nif(Cipher, iolist_to_binary(Key), undefined, EncryptFlag).
@@ -931,12 +931,12 @@ crypto_update(State, Data0) ->
%%%----------------------------------------------------------------
--spec crypto_update_dyn_iv(State, Data, IV) -> Result | descriptive_error()
+-spec crypto_dyn_iv_update(State, Data, IV) -> Result | descriptive_error()
when State :: crypto_state(),
Data :: iodata(),
IV :: iodata(),
Result :: binary() .
-crypto_update_dyn_iv(State, Data0, IV) ->
+crypto_dyn_iv_update(State, Data0, IV) ->
%% When State is from State = crypto_init(Cipher, Key, undefined, EncryptFlag)
case iolist_to_binary(Data0) of
<<>> ->
@@ -982,7 +982,7 @@ crypto_one_time(Cipher, Key, IV, Data0, EncryptFlag) ->
end.
--spec crypto_aead(Cipher, Key, IV, InText, AAD, EncFlag::true) ->
+-spec crypto_one_time_aead(Cipher, Key, IV, InText, AAD, EncFlag::true) ->
Result | descriptive_error()
when Cipher :: cipher_aead(),
Key :: iodata(),
@@ -994,11 +994,11 @@ crypto_one_time(Cipher, Key, IV, Data0, EncryptFlag) ->
OutCryptoText :: binary(),
OutTag :: binary().
-crypto_aead(Cipher, Key, IV, PlainText, AAD, true) ->
- crypto_aead(Cipher, Key, IV, PlainText, AAD, aead_tag_len(Cipher), true).
+crypto_one_time_aead(Cipher, Key, IV, PlainText, AAD, true) ->
+ crypto_one_time_aead(Cipher, Key, IV, PlainText, AAD, aead_tag_len(Cipher), true).
--spec crypto_aead(Cipher, Key, IV, InText, AAD, TagOrTagLength, EncFlag) ->
+-spec crypto_one_time_aead(Cipher, Key, IV, InText, AAD, TagOrTagLength, EncFlag) ->
Result | descriptive_error()
when Cipher :: cipher_aead(),
Key :: iodata(),
@@ -1016,7 +1016,7 @@ crypto_aead(Cipher, Key, IV, PlainText, AAD, true) ->
OutTag :: binary(),
OutPlainText :: binary().
-crypto_aead(Cipher, Key, IV, TextIn, AAD, TagOrTagLength, EncFlg) ->
+crypto_one_time_aead(Cipher, Key, IV, TextIn, AAD, TagOrTagLength, EncFlg) ->
aead_cipher(Cipher, Key, IV, TextIn, AAD, TagOrTagLength, EncFlg).
diff --git a/lib/crypto/test/crypto_SUITE.erl b/lib/crypto/test/crypto_SUITE.erl
index 6a2727a622..880fd7ab0b 100644
--- a/lib/crypto/test/crypto_SUITE.erl
+++ b/lib/crypto/test/crypto_SUITE.erl
@@ -621,15 +621,15 @@ do_api_ng_tls({Type, Key, IV, PlainTexts}=_X) ->
do_api_ng_tls({Type, Key, IV, PlainText0, ExpectedEncText}=_X) ->
ct:log("~p",[_X]),
PlainText = iolist_to_binary(lazy_eval(PlainText0)),
- Renc = crypto:crypto_init_dyn_iv(Type, Key, true),
- Rdec = crypto:crypto_init_dyn_iv(Type, Key, false),
- EncTxt = crypto:crypto_update_dyn_iv(Renc, PlainText, IV),
+ Renc = crypto:crypto_dyn_iv_init(Type, Key, true),
+ Rdec = crypto:crypto_dyn_iv_init(Type, Key, false),
+ EncTxt = crypto:crypto_dyn_iv_update(Renc, PlainText, IV),
case ExpectedEncText of
undefined ->
ok;
EncTxt ->
%% Now check that the state is NOT updated:
- case crypto:crypto_update_dyn_iv(Renc, PlainText, IV) of
+ case crypto:crypto_dyn_iv_update(Renc, PlainText, IV) of
EncTxt ->
ok;
EncTxt2 ->
@@ -640,10 +640,10 @@ do_api_ng_tls({Type, Key, IV, PlainText0, ExpectedEncText}=_X) ->
ct:log("1st encode~nIn: ~p~nExpected: ~p~nEnc: ~p~n", [{Type,Key,IV,PlainText}, ExpectedEncText, OtherEnc]),
ct:fail("api_ng_tls (encode)",[])
end,
- case crypto:crypto_update_dyn_iv(Rdec, EncTxt, IV) of
+ case crypto:crypto_dyn_iv_update(Rdec, EncTxt, IV) of
PlainText ->
%% Now check that the state is NOT updated:
- case crypto:crypto_update_dyn_iv(Rdec, EncTxt, IV) of
+ case crypto:crypto_dyn_iv_update(Rdec, EncTxt, IV) of
PlainText ->
ok;
PlainText2 ->
@@ -1183,7 +1183,7 @@ aead_cipher({Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, Info}
catch
error:E ->
ct:log("~p",[{Type, Key, PlainText, IV, AAD, CipherText, CipherTag, TagLen, Info}]),
- try crypto:crypto_aead(Type, Key, IV, PlainText, AAD, TagLen, true)
+ try crypto:crypto_one_time_aead(Type, Key, IV, PlainText, AAD, TagLen, true)
of
RR ->
ct:log("Works: ~p",[RR])