aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/crypto.c
diff options
context:
space:
mode:
authorAndrew Bennett <[email protected]>2016-01-14 18:26:28 +0100
committerSverker Eriksson <[email protected]>2016-01-14 18:31:36 +0100
commit64248a85e221a905aa37fbb8dd0ab1d4f4551be0 (patch)
tree7a4c2afd30ee273d00dc4128f00bbe7ba7b60cbc /lib/crypto/c_src/crypto.c
parentb855206a1a7788216717ca272f44e9beb1f58e7c (diff)
downloadotp-64248a85e221a905aa37fbb8dd0ab1d4f4551be0.tar.gz
otp-64248a85e221a905aa37fbb8dd0ab1d4f4551be0.tar.bz2
otp-64248a85e221a905aa37fbb8dd0ab1d4f4551be0.zip
crypto: Fix bug for multiple blocks for AES-ECB
Diffstat (limited to 'lib/crypto/c_src/crypto.c')
-rw-r--r--lib/crypto/c_src/crypto.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 9de8dc74c2..3c73c318ed 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -2042,6 +2042,7 @@ static ERL_NIF_TERM aes_ecb_crypt(ErlNifEnv* env, int argc, const ERL_NIF_TERM a
ErlNifBinary key_bin, data_bin;
AES_KEY aes_key;
int i;
+ int j;
unsigned char* ret_ptr;
ERL_NIF_TERM ret;
@@ -2064,7 +2065,9 @@ static ERL_NIF_TERM aes_ecb_crypt(ErlNifEnv* env, int argc, const ERL_NIF_TERM a
}
ret_ptr = enif_make_new_binary(env, data_bin.size, &ret);
- AES_ecb_encrypt(data_bin.data, ret_ptr, &aes_key, i);
+ for (j = 0; j < data_bin.size; j += 16) {
+ AES_ecb_encrypt(data_bin.data+j, ret_ptr+j, &aes_key, i);
+ }
CONSUME_REDS(env,data_bin);
return ret;
}