wincompat: fold random into genkey
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									197995d50c
								
							
						
					
					
						commit
						eb4665ecf0
					
				@ -28,7 +28,7 @@
 | 
				
			|||||||
#include "encoding.h"
 | 
					#include "encoding.h"
 | 
				
			||||||
#include "subcommands.h"
 | 
					#include "subcommands.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef WINCOMPAT
 | 
					#ifndef _WIN32
 | 
				
			||||||
static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
 | 
					static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ssize_t ret = 0;
 | 
						ssize_t ret = 0;
 | 
				
			||||||
@ -65,7 +65,11 @@ static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint
 | 
				
			|||||||
	return i == len;
 | 
						return i == len;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#include "wincompat/getrandom.c"
 | 
					#include <ntsecapi.h>
 | 
				
			||||||
 | 
					static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        return RtlGenRandom(out, len);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int genkey_main(int argc, char *argv[])
 | 
					int genkey_main(int argc, char *argv[])
 | 
				
			||||||
 | 
				
			|||||||
@ -18,8 +18,6 @@
 | 
				
			|||||||
#undef min
 | 
					#undef min
 | 
				
			||||||
#undef max
 | 
					#undef max
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define WINCOMPAT
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define IFNAMSIZ 64
 | 
					#define IFNAMSIZ 64
 | 
				
			||||||
#define EAI_SYSTEM -99
 | 
					#define EAI_SYSTEM -99
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,12 +0,0 @@
 | 
				
			|||||||
// SPDX-License-Identifier: GPL-2.0
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdbool.h>
 | 
					 | 
				
			||||||
#include <ntsecapi.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline bool __attribute__((__warn_unused_result__)) get_random_bytes(uint8_t *out, size_t len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return RtlGenRandom(out, len);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user