summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2017-07-16 15:36:32 +0100
committerRobert Newson <rnewson@apache.org>2017-07-16 15:36:34 +0100
commitd5acc902743603881e7079363e8028f397f3189a (patch)
tree8e51c9a9a48ba3e9c4174119659358ad7333c542
parentd3a5a71752f87e1f07f316c433e0cdb7fa78b804 (diff)
downloadcouchdb-d5acc902743603881e7079363e8028f397f3189a.tar.gz
use crypto:strong_rand_bytes
-rw-r--r--src/chttpd/src/chttpd.erl2
-rw-r--r--src/couch/src/couch_uuids.erl6
-rw-r--r--src/couch/test/couch_work_queue_tests.erl2
-rw-r--r--src/couch/test/couchdb_views_tests.erl2
-rw-r--r--src/couch_replicator/test/couch_replicator_large_atts_tests.erl2
-rw-r--r--src/couch_replicator/test/couch_replicator_many_leaves_tests.erl2
-rw-r--r--src/couch_replicator/test/couch_replicator_missing_stubs_tests.erl4
-rw-r--r--src/ddoc_cache/src/ddoc_cache_util.erl2
8 files changed, 11 insertions, 11 deletions
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index b9ac59b5d..9423fa9f4 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -204,7 +204,7 @@ handle_request_int(MochiReq) ->
Other -> Other
end,
- Nonce = couch_util:to_hex(crypto:rand_bytes(5)),
+ Nonce = couch_util:to_hex(crypto:strong_rand_bytes(5)),
HttpReq0 = #httpd{
mochi_req = MochiReq,
diff --git a/src/couch/src/couch_uuids.erl b/src/couch/src/couch_uuids.erl
index 0553243d0..ebe145c17 100644
--- a/src/couch/src/couch_uuids.erl
+++ b/src/couch/src/couch_uuids.erl
@@ -37,10 +37,10 @@ new() ->
gen_server:call(?MODULE, create).
random() ->
- list_to_binary(couch_util:to_hex(crypto:rand_bytes(16))).
+ list_to_binary(couch_util:to_hex(crypto:strong_rand_bytes(16))).
utc_random() ->
- utc_suffix(couch_util:to_hex(crypto:rand_bytes(9))).
+ utc_suffix(couch_util:to_hex(crypto:strong_rand_bytes(9))).
utc_suffix(Suffix) ->
Now = {_, _, Micro} = erlang:now(), % uniqueness is used.
@@ -100,7 +100,7 @@ handle_config_terminate(_Server, _Reason, _State) ->
erlang:send_after(?RELISTEN_DELAY, whereis(?MODULE), restart_config_listener).
new_prefix() ->
- couch_util:to_hex((crypto:rand_bytes(13))).
+ couch_util:to_hex((crypto:strong_rand_bytes(13))).
inc() ->
crypto:rand_uniform(1, 16#ffe).
diff --git a/src/couch/test/couch_work_queue_tests.erl b/src/couch/test/couch_work_queue_tests.erl
index 4f8101343..a192230ef 100644
--- a/src/couch/test/couch_work_queue_tests.erl
+++ b/src/couch/test/couch_work_queue_tests.erl
@@ -335,7 +335,7 @@ producer_loop(Parent, Q) ->
Parent ! {pong, Ref},
producer_loop(Parent, Q);
{produce, Ref, Size} ->
- Item = crypto:rand_bytes(Size),
+ Item = crypto:strong_rand_bytes(Size),
Parent ! {item, Ref, Item},
ok = couch_work_queue:queue(Q, Item),
producer_loop(Parent, Q)
diff --git a/src/couch/test/couchdb_views_tests.erl b/src/couch/test/couchdb_views_tests.erl
index 50c4da4ce..494d13bc1 100644
--- a/src/couch/test/couchdb_views_tests.erl
+++ b/src/couch/test/couchdb_views_tests.erl
@@ -461,7 +461,7 @@ populate_db(Db, BatchSize, N) when N > 0 ->
fun(_) ->
couch_doc:from_json_obj({[
{<<"_id">>, couch_uuids:new()},
- {<<"value">>, base64:encode(crypto:rand_bytes(1000))}
+ {<<"value">>, base64:encode(crypto:strong_rand_bytes(1000))}
]})
end,
lists:seq(1, BatchSize)),
diff --git a/src/couch_replicator/test/couch_replicator_large_atts_tests.erl b/src/couch_replicator/test/couch_replicator_large_atts_tests.erl
index 79e44b285..5e29ff11f 100644
--- a/src/couch_replicator/test/couch_replicator_large_atts_tests.erl
+++ b/src/couch_replicator/test/couch_replicator_large_atts_tests.erl
@@ -120,5 +120,5 @@ att(Name, Size, Type) ->
{name, Name},
{type, Type},
{att_len, Size},
- {data, fun(Count) -> crypto:rand_bytes(Count) end}
+ {data, fun(Count) -> crypto:strong_rand_bytes(Count) end}
]).
diff --git a/src/couch_replicator/test/couch_replicator_many_leaves_tests.erl b/src/couch_replicator/test/couch_replicator_many_leaves_tests.erl
index 3b804c40e..b2445a236 100644
--- a/src/couch_replicator/test/couch_replicator_many_leaves_tests.erl
+++ b/src/couch_replicator/test/couch_replicator_many_leaves_tests.erl
@@ -186,7 +186,7 @@ add_attachments(SourceDb, NumAtts, [{DocId, NumConflicts} | Rest]) ->
NewDocs = lists:foldl(
fun(#doc{atts = Atts, revs = {Pos, [Rev | _]}} = Doc, Acc) ->
NewAtts = lists:foldl(fun(I, AttAcc) ->
- AttData = crypto:rand_bytes(100),
+ AttData = crypto:strong_rand_bytes(100),
NewAtt = couch_att:new([
{name, ?io2b(["att_", ?i2l(I), "_",
couch_doc:rev_to_str({Pos, Rev})])},
diff --git a/src/couch_replicator/test/couch_replicator_missing_stubs_tests.erl b/src/couch_replicator/test/couch_replicator_missing_stubs_tests.erl
index e8ccd6470..9e92f1c31 100644
--- a/src/couch_replicator/test/couch_replicator_missing_stubs_tests.erl
+++ b/src/couch_replicator/test/couch_replicator_missing_stubs_tests.erl
@@ -114,7 +114,7 @@ should_update_source_docs(Source, Times) ->
populate_db(DbName) ->
{ok, Db} = couch_db:open_int(DbName, []),
- AttData = crypto:rand_bytes(6000),
+ AttData = crypto:strong_rand_bytes(6000),
Doc = #doc{
id = <<"doc1">>,
atts = [
@@ -146,7 +146,7 @@ db_fold_fun(FullDocInfo, {DbName, Times}) ->
{ok, Db2} = couch_db:reopen(Db),
NewDocVersion = Doc#doc{
revs = {Pos, [RevId]},
- body = {[{<<"value">>, base64:encode(crypto:rand_bytes(100))}]}
+ body = {[{<<"value">>, base64:encode(crypto:strong_rand_bytes(100))}]}
},
{ok, NewRev} = couch_db:update_doc(Db2, NewDocVersion, []),
NewRev
diff --git a/src/ddoc_cache/src/ddoc_cache_util.erl b/src/ddoc_cache/src/ddoc_cache_util.erl
index fb3c0b9d2..24c4b0d9e 100644
--- a/src/ddoc_cache/src/ddoc_cache_util.erl
+++ b/src/ddoc_cache/src/ddoc_cache_util.erl
@@ -19,7 +19,7 @@
new_uuid() ->
- to_hex(crypto:rand_bytes(16), []).
+ to_hex(crypto:strong_rand_bytes(16), []).
to_hex(<<>>, Acc) ->