Merge pull request #2326 from nghttp2/quic-rand-take2

quic: Use secure random generator for ngtcp2_rand
This commit is contained in:
Tatsuhiro Tsujikawa
2025-04-10 21:22:50 +09:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@@ -291,8 +291,11 @@ void Client::quic_write_qlog(const void *data, size_t datalen) {
namespace {
void rand(uint8_t *dest, size_t destlen, const ngtcp2_rand_ctx *rand_ctx) {
util::random_bytes(dest, dest + destlen,
*static_cast<std::mt19937 *>(rand_ctx->native_handle));
auto rv = RAND_bytes(dest, destlen);
if (rv != 1) {
assert(0);
abort();
}
}
} // namespace

View File

@@ -199,8 +199,11 @@ void Http3Upstream::qlog_write(const void *data, size_t datalen, bool fin) {
namespace {
void rand(uint8_t *dest, size_t destlen, const ngtcp2_rand_ctx *rand_ctx) {
util::random_bytes(dest, dest + destlen,
*static_cast<std::mt19937 *>(rand_ctx->native_handle));
auto rv = RAND_bytes(dest, destlen);
if (rv != 1) {
assert(0);
abort();
}
}
} // namespace