1 // Copyright 2020 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 5 #include "util/crypto/random_bytes.h" 6 7 #include "openssl/rand.h" 8 #include "util/osp_logging.h" 9 10 namespace openscreen { 11 GenerateRandomBytes16()12std::array<uint8_t, 16> GenerateRandomBytes16() { 13 std::array<uint8_t, 16> result; 14 GenerateRandomBytes(result.begin(), result.size()); 15 return result; 16 } 17 GenerateRandomBytes(uint8_t * out,int len)18void GenerateRandomBytes(uint8_t* out, int len) { 19 // Working cryptography is mandatory for our library to run. 20 OSP_CHECK(RAND_bytes(out, len) == 1); 21 } 22 23 } // namespace openscreen 24