Browse Source

add windows support

master
Herbert Poul 4 years ago
parent
commit
a2a69e6081
  1. 2
      example/pubspec.lock
  2. 2
      example/pubspec.yaml
  3. 13
      ios/Classes/argon2_ffi.c
  4. 27
      pubspec.lock
  5. 14
      windows/CMakeLists.txt

2
example/pubspec.lock

@ -14,7 +14,7 @@ packages:
name: argon2_ffi_base name: argon2_ffi_base
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.0+1" version: "0.1.1"
async: async:
dependency: transitive dependency: transitive
description: description:

2
example/pubspec.yaml

@ -8,7 +8,7 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
argon2_ffi_base: '>=0.0.1 <1.0.0' argon2_ffi_base: '>=0.1.1 <1.0.0'
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

13
ios/Classes/argon2_ffi.c

@ -4,10 +4,12 @@
#include <stdio.h> #include <stdio.h>
#include "argon2src/argon2.h" #include "argon2src/argon2.h"
#define _CRT_SECURE_NO_WARNINGS
//#include <android/log.h> //#include <android/log.h>
//extern "C" __attribute__((visibility("default"))) __attribute__((used)) //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; return x + y;
} }
//EOF //EOF
@ -81,7 +83,11 @@ char *hashStuff(char *hashPwd) {
uint8_t salt[SALTLEN]; uint8_t salt[SALTLEN];
memset(salt, 0x00, SALTLEN); memset(salt, 0x00, SALTLEN);
#ifdef _MSC_VER
uint8_t *pwd = (uint8_t *) _strdup(PWD);
#else
uint8_t *pwd = (uint8_t *) strdup(PWD); uint8_t *pwd = (uint8_t *) strdup(PWD);
#endif
uint32_t pwdlen = strlen((char *) pwd); uint32_t pwdlen = strlen((char *) pwd);
uint32_t t_cost = 2; // 1-pass computation 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 m_cost,
uint32_t t_cost /* iterations*/, uint32_t parallelism, uint32_t t_cost /* iterations*/, uint32_t parallelism,
uint32_t hashlen, uint32_t hashlen,
uint8_t type, int32_t version) { 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", 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); (long)keylen, (long)saltlen, (long)m_cost, (long)t_cost, (long)parallelism, (long)hashlen, type, version);
PRINT_DEBUG("key: "); 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); debugBytes(hash1, hashlen);
PRINT_DEBUG("\n"); PRINT_DEBUG("\n");
char *b64ret = b64_encode(hash1, hashlen); char *b64ret = b64_encode(hash1, hashlen);
free(hash1);
return b64ret; return b64ret;
} }

27
pubspec.lock

@ -7,14 +7,14 @@ packages:
name: argon2_ffi_base name: argon2_ffi_base
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.0.1" version: "0.1.0+1"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.1" version: "2.4.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -22,6 +22,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
@ -42,7 +49,7 @@ packages:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.12" version: "1.15.0-nullsafety"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -80,14 +87,14 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.6" version: "0.12.8"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.8" version: "1.3.0-nullsafety"
path: path:
dependency: transitive dependency: transitive
description: description:
@ -113,7 +120,7 @@ packages:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.3" version: "1.9.5"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@ -141,20 +148,20 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.15" version: "0.2.17"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.6" version: "1.3.0-nullsafety"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.1.0-nullsafety"
sdks: sdks:
dart: ">=2.7.0 <3.0.0" dart: ">=2.9.0-18.0 <2.9.0"

14
windows/CMakeLists.txt

@ -1,16 +1,28 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
set(PROJECT_NAME "argon2_ffi") set(PROJECT_NAME "argon2_ffi")
project(${PROJECT_NAME} LANGUAGES CXX) project(${PROJECT_NAME} LANGUAGES C CXX)
set(PLUGIN_NAME "${PROJECT_NAME}_plugin") set(PLUGIN_NAME "${PROJECT_NAME}_plugin")
add_library(${PLUGIN_NAME} SHARED add_library(${PLUGIN_NAME} SHARED
"${PLUGIN_NAME}.cpp" "${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}) apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden) CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) 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 target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include") "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)

Loading…
Cancel
Save