xref: /aosp_15_r20/external/federated-compute/fcp/secagg/shared/crypto_rand_prng.h (revision 14675a029014e728ec732f129a32e299b2da0601)
1 /*
2  * Copyright 2018 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FCP_SECAGG_SHARED_CRYPTO_RAND_PRNG_H_
18 #define FCP_SECAGG_SHARED_CRYPTO_RAND_PRNG_H_
19 
20 #include <cstdint>
21 
22 #include "fcp/secagg/shared/prng.h"
23 
24 namespace fcp {
25 namespace secagg {
26 
27 // A cryptographically strong Pseudorandom Number Generator based on OpenSSL,
28 // which seeds using /dev/urandom on UNIX-like operating systems, and other
29 // sources of randomness on Windows.
30 //
31 // This class is thread-safe.
32 
33 class CryptoRandPrng : public SecurePrng {
34  public:
35   CryptoRandPrng() = default;
36 
37   uint8_t Rand8() override;
38   uint64_t Rand64() override;
39 };
40 
41 }  // namespace secagg
42 }  // namespace fcp
43 #endif  // FCP_SECAGG_SHARED_CRYPTO_RAND_PRNG_H_
44