[go: nahoru, domu]

blob: af904b2909db657a88a8a542d255deb68299162b [file] [log] [blame]
Avi Drissman201a9a832022-09-13 19:39:251// Copyright 2012 The Chromium Authors
mniknami@chromium.org9b205782012-08-02 20:22:252// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CRYPTO_RANDOM_H_
6#define CRYPTO_RANDOM_H_
7
wtc@chromium.org32c78712012-12-08 04:08:288#include <stddef.h>
mniknami@chromium.org9b205782012-08-02 20:22:259
Tom Sepezb0d0de602024-01-26 06:47:3110#include <vector>
11
Adam Langley9605f6f2020-03-12 19:16:3312#include "base/containers/span.h"
mniknami@chromium.org9b205782012-08-02 20:22:2513#include "crypto/crypto_export.h"
14
15namespace crypto {
16
Tom Sepezb0d0de602024-01-26 06:47:3117// Fills the given buffer with `length` random bytes of cryptographically
mniknami@chromium.org9b205782012-08-02 20:22:2518// secure random numbers.
mniknami@chromium.org9b205782012-08-02 20:22:2519CRYPTO_EXPORT void RandBytes(void *bytes, size_t length);
20
Tom Sepezb0d0de602024-01-26 06:47:3121// Fills `bytes` with cryptographically-secure random bits.
Adam Langley9605f6f2020-03-12 19:16:3322CRYPTO_EXPORT void RandBytes(base::span<uint8_t> bytes);
Tom Sepezb0d0de602024-01-26 06:47:3123
24// Returns a vector of `length` bytes filled with cryptographically-secure
25// random bits.
26CRYPTO_EXPORT std::vector<uint8_t> RandBytesAsVector(size_t length);
mniknami@chromium.org9b205782012-08-02 20:22:2527}
28
davidben6004dc52017-02-03 04:15:2929#endif // CRYPTO_RANDOM_H_