1 /*
2  *  This file is part of the optimized implementation of the Picnic signature scheme.
3  *  See the accompanying documentation for complete details.
4  *
5  *  The code is provided under the MIT license, see LICENSE for
6  *  more details.
7  *  SPDX-License-Identifier: MIT
8  */
9 
10 #include "randomness.h"
11 #include <oqs/rand.h>
12 
13 /* OQS note: random functions using OQS's */
rand_bits(uint8_t * dst,size_t num_bits)14 int rand_bits(uint8_t* dst, size_t num_bits) {
15   const size_t num_bytes = (num_bits + 7) / 8;
16   const size_t num_extra_bits = num_bits % 8;
17 
18   OQS_randombytes(dst, num_bytes);
19 
20   if (num_extra_bits) {
21     dst[num_bytes - 1] &= UINT8_C(0xff) << (8 - num_extra_bits);
22   }
23 
24   return 0;
25 }
26