aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/src
diff options
context:
space:
mode:
authorYuki Ito <[email protected]>2016-03-25 17:55:17 +0900
committerYuki Ito <[email protected]>2016-03-26 12:01:36 +0900
commitf4f588683dce36c4470171cb6af74763778498ff (patch)
tree461c7d681d8b7d5d4045552c1dbfce989cd95b83 /lib/crypto/src
parentab418313123e98d5de15e2e71ac169afdad8d3f8 (diff)
downloadotp-f4f588683dce36c4470171cb6af74763778498ff.tar.gz
otp-f4f588683dce36c4470171cb6af74763778498ff.tar.bz2
otp-f4f588683dce36c4470171cb6af74763778498ff.zip
crypto: Enable AES-GCM tag length to change
This commit enables AES-GCM encryption/decryption to change its tag length between 1 to 16 bytes.
Diffstat (limited to 'lib/crypto/src')
-rw-r--r--lib/crypto/src/crypto.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/crypto/src/crypto.erl b/lib/crypto/src/crypto.erl
index 3e24ff2b0a..a9dbca3caf 100644
--- a/lib/crypto/src/crypto.erl
+++ b/lib/crypto/src/crypto.erl
@@ -302,6 +302,8 @@ block_encrypt(aes_ige256, Key, Ivec, Data) ->
aes_ige_crypt_nif(Key, Ivec, Data, true);
block_encrypt(aes_gcm, Key, Ivec, {AAD, Data}) ->
aes_gcm_encrypt(Key, Ivec, AAD, Data);
+block_encrypt(aes_gcm, Key, Ivec, {AAD, Data, TagLength}) ->
+ aes_gcm_encrypt(Key, Ivec, AAD, Data, TagLength);
block_encrypt(chacha20_poly1305, Key, Ivec, {AAD, Data}) ->
chacha20_poly1305_encrypt(Key, Ivec, AAD, Data).
@@ -917,7 +919,10 @@ aes_cfb_128_decrypt(Key, IVec, Data) ->
%%
%% AES - in Galois/Counter Mode (GCM)
%%
-aes_gcm_encrypt(_Key, _Ivec, _AAD, _In) -> ?nif_stub.
+%% The default tag length is EVP_GCM_TLS_TAG_LEN(16),
+aes_gcm_encrypt(Key, Ivec, AAD, In) ->
+ aes_gcm_encrypt(Key, Ivec, AAD, In, 16).
+aes_gcm_encrypt(_Key, _Ivec, _AAD, _In, _TagLength) -> ?nif_stub.
aes_gcm_decrypt(_Key, _Ivec, _AAD, _In, _Tag) -> ?nif_stub.
%%