random.cc 673 B

12345678910111213141516171819202122232425
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "crypto/random.h"
  5. #include <stddef.h>
  6. #include "base/rand_util.h"
  7. namespace crypto {
  8. void RandBytes(void *bytes, size_t length) {
  9. // It's OK to call base::RandBytes(), because it's already strongly random.
  10. // But _other_ code should go through this function to ensure that code which
  11. // needs secure randomness is easily discoverable.
  12. base::RandBytes(bytes, length);
  13. }
  14. void RandBytes(base::span<uint8_t> bytes) {
  15. RandBytes(bytes.data(), bytes.size());
  16. }
  17. } // namespace crypto