aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-12-04 12:10:42 +0100
committerBjörn Gustavsson <[email protected]>2015-12-07 11:49:41 +0100
commitdee396ffd32dcd68c47cab983c75ba32f921b9db (patch)
tree725879bdb69561bc7f7a2ea8d6cccbda620d6192 /lib/compiler/src
parente656b6e26de27db6a4235961f7e667998d3a2832 (diff)
downloadotp-dee396ffd32dcd68c47cab983c75ba32f921b9db.tar.gz
otp-dee396ffd32dcd68c47cab983c75ba32f921b9db.tar.bz2
otp-dee396ffd32dcd68c47cab983c75ba32f921b9db.zip
compile: Eliminate use of the obsolete 'random' module
The 'random' module is used to pad the end of a block with random bytes. The appropriate function to use in this case crypto:rand_bytes/1.
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/compile.erl11
1 files changed, 1 insertions, 10 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index a2a23a2b90..b61c104b3c 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -1306,21 +1306,12 @@ generate_key(String) when is_list(String) ->
encrypt({des3_cbc=Type,Key,IVec,BlockSize}, Bin0) ->
Bin1 = case byte_size(Bin0) rem BlockSize of
0 -> Bin0;
- N -> list_to_binary([Bin0,random_bytes(BlockSize-N)])
+ N -> list_to_binary([Bin0,crypto:rand_bytes(BlockSize-N)])
end,
Bin = crypto:block_encrypt(Type, Key, IVec, Bin1),
TypeString = atom_to_list(Type),
list_to_binary([0,length(TypeString),TypeString,Bin]).
-random_bytes(N) ->
- _ = random:seed(erlang:time_offset(),
- erlang:monotonic_time(),
- erlang:unique_integer()),
- random_bytes_1(N, []).
-
-random_bytes_1(0, Acc) -> Acc;
-random_bytes_1(N, Acc) -> random_bytes_1(N-1, [random:uniform(255)|Acc]).
-
save_core_code(St) ->
{ok,St#compile{core_code=cerl:from_records(St#compile.code)}}.