forked from cory/tildefriends
Lower android min sdk version to 26, and use libuv's random code.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4569 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
14a2207064
commit
17c0266998
4
Makefile
4
Makefile
@ -38,7 +38,7 @@ CFLAGS += \
|
||||
ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/34.0.0
|
||||
ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-33
|
||||
ANDROID_NDK ?= $(ANDROID_SDK)/ndk/26.0.10792818
|
||||
ANDROID_MIN_SDK_VERSION := 28
|
||||
ANDROID_MIN_SDK_VERSION := 26
|
||||
|
||||
ANDROID_ARMV7A_TARGETS := \
|
||||
out/androiddebug-armv7a/tildefriends \
|
||||
@ -691,7 +691,7 @@ release-apk: out/TildeFriends-arm-release.apk out/TildeFriends-x86-release.apk
|
||||
.PHONY: release-apk
|
||||
|
||||
releaseapkgo: out/TildeFriends-arm-release.apk
|
||||
@adb install $<
|
||||
@adb install -r $<
|
||||
@adb shell am start com.unprompted.tildefriends/.MainActivity
|
||||
.PHONY: releaseapkgo
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
package="com.unprompted.tildefriends"
|
||||
android:versionCode="12"
|
||||
android:versionName="0.0.12-wip">
|
||||
<uses-sdk android:minSdkVersion="28"/>
|
||||
<uses-sdk android:minSdkVersion="26"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application android:label="Tilde Friends" android:usesCleartextTraffic="true" android:debuggable="true">
|
||||
<meta-data android:name="android.max_aspect" android:value="2.1"/>
|
||||
|
@ -1,23 +1,12 @@
|
||||
#include "bcrypt.js.h"
|
||||
|
||||
#include "task.h"
|
||||
|
||||
#include "ow-crypt.h"
|
||||
|
||||
#include "quickjs.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength);
|
||||
#elif __APPLE__
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_IPHONE
|
||||
#include <CommonCrypto/CommonRandom.h>
|
||||
#else
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#else
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#include <uv.h>
|
||||
|
||||
JSValue _crypt_hashpw(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
|
||||
JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
|
||||
@ -49,19 +38,8 @@ JSValue _crypt_gensalt(JSContext* context, JSValueConst this_val, int argc, JSVa
|
||||
int length = 0;
|
||||
JS_ToInt32(context, &length, argv[0]);
|
||||
char buffer[16];
|
||||
#if defined(_WIN32)
|
||||
ssize_t bytes = SystemFunction036(buffer, sizeof(buffer)) ? sizeof(buffer) : 0;
|
||||
#elif defined(__APPLE__) && TARGET_OS_IPHONE
|
||||
ssize_t bytes = CCRandomGenerateBytes(buffer, sizeof(buffer)) == kCCSuccess ? sizeof(buffer) : 0;
|
||||
#elif defined(__APPLE__) && !TARGET_OS_IPHONE
|
||||
ssize_t bytes = 0;
|
||||
if (getentropy(buffer, sizeof(buffer)) == 0)
|
||||
{
|
||||
bytes = sizeof(buffer);
|
||||
}
|
||||
#else
|
||||
ssize_t bytes = getrandom(buffer, sizeof(buffer), 0);
|
||||
#endif
|
||||
tf_task_t* task = tf_task_get(context);
|
||||
size_t bytes = uv_random(tf_task_get_loop(task), &(uv_random_t) { 0 }, buffer, sizeof(buffer), 0, NULL) == 0 ? sizeof(buffer) : 0;
|
||||
char output[7 + 22 + 1];
|
||||
char* salt = crypt_gensalt_rn("$2b$", length, buffer, bytes, output, sizeof(output));
|
||||
JSValue result = JS_NewString(context, salt);
|
||||
|
Loading…
Reference in New Issue
Block a user