aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2018-09-13 15:26:24 +0200
committerRaimo Niskanen <[email protected]>2018-09-13 15:26:24 +0200
commit0f79e3f3d95fd8f04e3893e50c9f27b9e04c2c7e (patch)
tree87acb66bf5106181443099db0c9ea6e1924125e8 /lib/stdlib/src
parent510048b8efd0a72706f3232f0842ee9828c63f79 (diff)
downloadotp-0f79e3f3d95fd8f04e3893e50c9f27b9e04c2c7e.tar.gz
otp-0f79e3f3d95fd8f04e3893e50c9f27b9e04c2c7e.tar.bz2
otp-0f79e3f3d95fd8f04e3893e50c9f27b9e04c2c7e.zip
Use long period counter for crypto_aes
Conflicts: lib/crypto/doc/src/crypto.xml lib/crypto/src/crypto.erl
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/rand.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/stdlib/src/rand.erl b/lib/stdlib/src/rand.erl
index fdf9709633..9854c778a1 100644
--- a/lib/stdlib/src/rand.erl
+++ b/lib/stdlib/src/rand.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2015-2017. All Rights Reserved.
+%% Copyright Ericsson AB 2015-2018. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
%% Test, dev and internal
-export([exro928_jump_2pow512/1, exro928_jump_2pow20/1,
+ exro928_seed/1, exro928_next/1, exro928_next_state/1,
format_jumpconst58/1, seed58/2]).
%% Debug
@@ -948,6 +949,9 @@ exs1024_jump({L, RL}, AS, JL, J, N, TN) ->
-opaque exro928_state() :: {list(uint58()), list(uint58())}.
+-spec exro928_seed(
+ list(uint58()) | integer() | {integer(), integer(), integer()}) ->
+ exro928_state().
exro928_seed(L) when is_list(L) ->
{seed58_nz(16, L), []};
exro928_seed(X) when is_integer(X) ->
@@ -979,7 +983,15 @@ exro928ss_next({[S15,S0|Ss], Rs}) ->
exro928ss_next({[S15], Rs}) ->
exro928ss_next({[S15|lists:reverse(Rs)], []}).
+-spec exro928_next(exro928_state()) -> {{uint58(),uint58()}, exro928_state()}.
+exro928_next({[S15,S0|Ss], Rs}) ->
+ SR = exro928_next_state(Ss, Rs, S15, S0),
+ {{S15,S0}, SR};
+exro928_next({[S15], Rs}) ->
+ exro928_next({[S15|lists:reverse(Rs)], []}).
+
%% Just update the state
+-spec exro928_next_state(exro928_state()) -> exro928_state().
exro928_next_state({[S15,S0|Ss], Rs}) ->
exro928_next_state(Ss, Rs, S15, S0);
exro928_next_state({[S15], Rs}) ->
@@ -1013,6 +1025,7 @@ exro928ss_uniform(Range, {Alg, SR}) ->
exro928_jump({Alg, SR}) ->
{Alg,exro928_jump_2pow512(SR)}.
+-spec exro928_jump_2pow512(exro928_state()) -> exro928_state().
exro928_jump_2pow512(SR) ->
polyjump(
SR, fun exro928_next_state/1,
@@ -1026,6 +1039,7 @@ exro928_jump_2pow512(SR) ->
16#7B7C4CC049C536E, 16#431801F9DB3AF2C,
16#41A1504ACD83F24, 16#6C41DCF2F867D7F]).
+-spec exro928_jump_2pow20(exro928_state()) -> exro928_state().
exro928_jump_2pow20(SR) ->
polyjump(
SR, fun exro928_next_state/1,
@@ -1209,6 +1223,7 @@ seed_nz(N, [S|Ss], M, NZ) ->
%% Splitmix seeders, lowest bits of SplitMix64, zeros skipped
%% =====================================================================
+-spec seed58(non_neg_integer(), uint64()) -> list(uint58()).
seed58(0, _X) ->
[];
seed58(N, X) ->
@@ -1224,6 +1239,7 @@ seed58(X_0) ->
{Z,X}
end.
+-spec seed64(non_neg_integer(), uint64()) -> list(uint64()).
seed64(0, _X) ->
[];
seed64(N, X) ->