Merge in mingw changes.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3873 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -2,7 +2,13 @@
|
||||
|
||||
#include "ow-crypt.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength);
|
||||
#else
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
|
||||
JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
|
||||
JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
|
||||
@ -34,7 +40,11 @@ JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSVa
|
||||
int length;
|
||||
JS_ToInt32(context, &length, argv[0]);
|
||||
char buffer[16];
|
||||
#if defined(_WIN32)
|
||||
ssize_t bytes = SystemFunction036(buffer, sizeof(buffer)) ? sizeof(buffer) : 0;
|
||||
#else
|
||||
ssize_t bytes = getrandom(buffer, sizeof(buffer), 0);
|
||||
#endif
|
||||
char output[7 + 22 + 1];
|
||||
char* salt = crypt_gensalt_rn("$2b$", length, buffer, bytes, output, sizeof(output));
|
||||
JSValue result = JS_NewString(context, salt);
|
||||
|
Reference in New Issue
Block a user