summaryrefslogtreecommitdiffstats
path: root/chromium/crypto/random.cc
blob: 500ef10207303958413b5795f33bd814b5a9225d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "crypto/random.h"

#include <stddef.h>

#include "base/rand_util.h"

namespace crypto {

void RandBytes(void *bytes, size_t length) {
  // It's OK to call base::RandBytes(), because it's already strongly random.
  // But _other_ code should go through this function to ensure that code which
  // needs secure randomness is easily discoverable.
  base::RandBytes(bytes, length);
}

void RandBytes(base::span<uint8_t> bytes) {
  RandBytes(bytes.data(), bytes.size());
}

}  // namespace crypto