mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	This commit adds a convenience method to secure random for initializing single types. It changes the random number generator in JS math random() to use newer constants by the author as well as initializes it with a higher quality seed.
		
			
				
	
	
		
			23 lines
		
	
	
	
		
			322 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
	
		
			322 B
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (c) 2024, the Ladybird developers.
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: BSD-2-Clause
 | 
						|
 */
 | 
						|
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <AK/Span.h>
 | 
						|
 | 
						|
namespace Crypto {
 | 
						|
 | 
						|
void fill_with_secure_random(Bytes);
 | 
						|
 | 
						|
template<typename T>
 | 
						|
inline T get_secure_random()
 | 
						|
{
 | 
						|
    T t;
 | 
						|
    fill_with_secure_random({ &t, sizeof(T) });
 | 
						|
    return t;
 | 
						|
}
 | 
						|
 | 
						|
}
 |