random.h 668 B

123456789101112131415161718192021222324
  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. #ifndef CRYPTO_RANDOM_H_
  5. #define CRYPTO_RANDOM_H_
  6. #include <stddef.h>
  7. #include "base/containers/span.h"
  8. #include "crypto/crypto_export.h"
  9. namespace crypto {
  10. // Fills the given buffer with |length| random bytes of cryptographically
  11. // secure random numbers.
  12. // |length| must be positive.
  13. CRYPTO_EXPORT void RandBytes(void *bytes, size_t length);
  14. // Fills |bytes| with cryptographically-secure random bits.
  15. CRYPTO_EXPORT void RandBytes(base::span<uint8_t> bytes);
  16. }
  17. #endif // CRYPTO_RANDOM_H_