diff --git a/example/pubspec.lock b/example/pubspec.lock index f56fca2..6b28c10 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -14,7 +14,7 @@ packages: name: argon2_ffi_base url: "https://pub.dartlang.org" source: hosted - version: "0.1.0+1" + version: "0.1.1" async: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c20255f..4966e44 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: flutter: sdk: flutter - argon2_ffi_base: '>=0.0.1 <1.0.0' + argon2_ffi_base: '>=0.1.1 <1.0.0' dev_dependencies: flutter_test: diff --git a/ios/Classes/argon2_ffi.c b/ios/Classes/argon2_ffi.c index 8081c42..2b78d99 100644 --- a/ios/Classes/argon2_ffi.c +++ b/ios/Classes/argon2_ffi.c @@ -4,10 +4,12 @@ #include #include "argon2src/argon2.h" +#define _CRT_SECURE_NO_WARNINGS + //#include //extern "C" __attribute__((visibility("default"))) __attribute__((used)) -int32_t native_add(int32_t x, int32_t y) { +ARGON2_PUBLIC int32_t native_add(int32_t x, int32_t y) { return x + y; } //EOF @@ -81,7 +83,11 @@ char *hashStuff(char *hashPwd) { uint8_t salt[SALTLEN]; memset(salt, 0x00, SALTLEN); + #ifdef _MSC_VER + uint8_t *pwd = (uint8_t *) _strdup(PWD); + #else uint8_t *pwd = (uint8_t *) strdup(PWD); + #endif uint32_t pwdlen = strlen((char *) pwd); uint32_t t_cost = 2; // 1-pass computation @@ -100,12 +106,12 @@ void debugBytes(uint8_t *bytes, int length) { } } -char *hp_argon2_hash(uint8_t *key, uint32_t keylen, uint8_t *salt, uint32_t saltlen, +ARGON2_PUBLIC char *hp_argon2_hash(uint8_t *key, uint32_t keylen, uint8_t *salt, uint32_t saltlen, uint32_t m_cost, uint32_t t_cost /* iterations*/, uint32_t parallelism, uint32_t hashlen, uint8_t type, int32_t version) { - uint8_t hash1[hashlen]; + uint8_t *hash1 = malloc(sizeof(uint8_t) * hashlen); PRINT_DEBUG("keylen: %ld, saltlen: %ld, m_cost: %ld, t_cost: %ld, parallelism: %ld, hashlen: %ld, type: %d, version: %02x\n", (long)keylen, (long)saltlen, (long)m_cost, (long)t_cost, (long)parallelism, (long)hashlen, type, version); PRINT_DEBUG("key: "); @@ -132,6 +138,7 @@ char *hp_argon2_hash(uint8_t *key, uint32_t keylen, uint8_t *salt, uint32_t salt debugBytes(hash1, hashlen); PRINT_DEBUG("\n"); char *b64ret = b64_encode(hash1, hashlen); + free(hash1); return b64ret; } diff --git a/pubspec.lock b/pubspec.lock index 2a88224..0872a4b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: argon2_ffi_base url: "https://pub.dartlang.org" source: hosted - version: "0.0.1" + version: "0.1.0+1" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.2" boolean_selector: dependency: transitive description: @@ -22,6 +22,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0-nullsafety" charcode: dependency: transitive description: @@ -42,7 +49,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.15.0-nullsafety" fake_async: dependency: transitive description: @@ -80,14 +87,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety" path: dependency: transitive description: @@ -113,7 +120,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -141,20 +148,20 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.9.0-18.0 <2.9.0" diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 02ae9e1..0f77797 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,16 +1,28 @@ cmake_minimum_required(VERSION 3.15) set(PROJECT_NAME "argon2_ffi") -project(${PROJECT_NAME} LANGUAGES CXX) +project(${PROJECT_NAME} LANGUAGES C CXX) set(PLUGIN_NAME "${PROJECT_NAME}_plugin") add_library(${PLUGIN_NAME} SHARED "${PLUGIN_NAME}.cpp" + + ../ios/Classes/argon2_ffi.c + + ../ios/Classes/argon2src/argon2.c + ../ios/Classes/argon2src/core.c + ../ios/Classes/argon2src/encoding.c + ../ios/Classes/argon2src/genkat.c + ../ios/Classes/argon2src/ref.c + ../ios/Classes/argon2src/thread.c + ../ios/Classes/argon2src/blake2/blake2b.c + ) apply_standard_settings(${PLUGIN_NAME}) set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) +target_compile_options(${PLUGIN_NAME} PRIVATE /W4 /WX /wd"4100" /wd"4267" /wd"4204" /wd"4996") target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)