diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index aec8772..1cdc282 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -4,14 +4,18 @@ on: [push] jobs: build: + strategy: + matrix: + os: ['ubuntu-latest', 'windows-2019', 'macos-latest'] + dart_channel: ['stable'] - runs-on: ubuntu-latest - - container: - image: google/dart:2.8 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v1 + - uses: cedx/setup-dart@v2 + with: + release-channel: ${{ matrix.dart_channel }} - name: Install dependencies run: pub get - name: Run tests diff --git a/README.md b/README.md index 744e78b..905ffd9 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,24 @@ TODO root directory contains shared libraris (libargon2*) which are built from https://github.com/authpass/argon2_ffi +* MacOS: + * argon2_ffi/ios/Classes + * `cmake . && cmake --build .` + * `cp libargon2_ffi.dylib kdbx.dart/` +* Linux: + * argon2_ffi/ios/Classes + * `cmake . && cmake --build .` + * `cp libargon2_ffi.so kdbx.dart/` +* Windows: + * Install Visual Studio Commnity Edition with C++ Development environment + * Start "Developer Command Prompt for VS 2019" + * argon2_ffi/ios/Classes: + ``` + cmake . + cmake --build . + cp Debug\argon2_ffi.dll C:\kdbx.dart\argon2_ffi_plugin.dll + ``` + # OLD INFO: # TODO diff --git a/argon2_ffi_plugin.dll b/argon2_ffi_plugin.dll new file mode 100644 index 0000000..5f76e1b Binary files /dev/null and b/argon2_ffi_plugin.dll differ diff --git a/bin/_argon2.dart b/bin/_argon2.dart deleted file mode 100644 index c536463..0000000 --- a/bin/_argon2.dart +++ /dev/null @@ -1,24 +0,0 @@ -// ignore_for_file: non_constant_identifier_names - -//typedef HashStuff = Pointer Function(Pointer str); -import 'dart:ffi'; -import 'dart:io'; - -import 'package:argon2_ffi_base/argon2_ffi_base.dart'; - -// TODO: This should be somehow combined with the test variant -// which also loads the requierd dylib/so files. - -class Argon2Test extends Argon2Base { - Argon2Test() { - final argon2lib = Platform.isMacOS - ? DynamicLibrary.open('libargon2_ffi.dylib') - : DynamicLibrary.open('./libargon2_ffi.so'); - argon2hash = argon2lib - .lookup>('hp_argon2_hash') - .asFunction(); - } - - @override - Argon2Hash argon2hash; -} diff --git a/bin/kdbx.dart b/bin/kdbx.dart index 3181c99..aa6a2e3 100644 --- a/bin/kdbx.dart +++ b/bin/kdbx.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'dart:ffi'; import 'dart:io'; +import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:args/args.dart'; import 'package:args/command_runner.dart'; import 'package:kdbx/kdbx.dart'; @@ -11,13 +13,13 @@ import 'package:logging/logging.dart'; import 'package:logging_appenders/logging_appenders.dart'; import 'package:prompts/prompts.dart' as prompts; -import '_argon2.dart'; - final _logger = Logger('kdbx'); void main(List arguments) { exitCode = 0; - + final path = Platform.script.resolve('../argon2_ffi_plugin.dll').toFilePath(); + print('loading $path'); + DynamicLibrary.open(path); final runner = KdbxCommandRunner('kdbx', 'Kdbx Utility'); runner.run(arguments).catchError((dynamic error, StackTrace stackTrace) { if (error is! UsageException) { @@ -92,7 +94,7 @@ abstract class KdbxFileCommand extends Command { final keyFileData = keyFile == null ? null : await File(keyFile).readAsBytes(); - final file = await KdbxFormat(Argon2Test()).read( + final file = await KdbxFormat(Argon2FfiFlutter()).read( bytes, Credentials.composite(ProtectedValue.fromString(password), keyFileData), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index 188055a..31a1933 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + argon2_ffi_base: + dependency: transitive + description: + name: argon2_ffi_base + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1" args: dependency: transitive description: @@ -231,6 +238,6 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.7.0" + version: "4.2.0" sdks: dart: ">=2.8.0 <3.0.0" diff --git a/test/internal/test_utils.dart b/test/internal/test_utils.dart index 0b221bd..3bcd93e 100644 --- a/test/internal/test_utils.dart +++ b/test/internal/test_utils.dart @@ -1,5 +1,4 @@ //typedef HashStuff = Pointer Function(Pointer str); -import 'dart:ffi'; import 'dart:io'; import 'dart:typed_data'; @@ -8,26 +7,12 @@ import 'package:kdbx/kdbx.dart'; // ignore_for_file: non_constant_identifier_names -class Argon2Test extends Argon2Base { - Argon2Test() { - final argon2lib = Platform.isMacOS - ? DynamicLibrary.open('libargon2_ffi.dylib') - : DynamicLibrary.open('./libargon2_ffi.so'); - argon2hash = argon2lib - .lookup>('hp_argon2_hash') - .asFunction(); - } - - @override - Argon2Hash argon2hash; -} - class TestUtil { static Future readKdbxFile( String filePath, { String password = 'asdf', }) async { - final kdbxFormat = KdbxFormat(Argon2Test()); + final kdbxFormat = KdbxFormat(Argon2FfiFlutter()); final data = await File(filePath).readAsBytes(); final file = await kdbxFormat.read( data, Credentials(ProtectedValue.fromString(password))); @@ -36,7 +21,7 @@ class TestUtil { static Future readKdbxFileBytes(Uint8List data, {String password = 'asdf'}) async { - final kdbxFormat = KdbxFormat(Argon2Test()); + final kdbxFormat = KdbxFormat(Argon2FfiFlutter()); final file = await kdbxFormat.read( data, Credentials(ProtectedValue.fromString(password))); return file; diff --git a/test/kdbx4_test.dart b/test/kdbx4_test.dart index 52f0a1e..472ef64 100644 --- a/test/kdbx4_test.dart +++ b/test/kdbx4_test.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:kdbx/kdbx.dart'; import 'package:kdbx/src/kdbx_header.dart'; import 'package:logging/logging.dart'; @@ -15,7 +16,7 @@ final _logger = Logger('kdbx4_test'); void main() { Logger.root.level = Level.ALL; PrintAppender().attachToLogger(Logger.root); - final kdbxFormat = KdbxFormat(Argon2Test()); + final kdbxFormat = KdbxFormat(Argon2FfiFlutter()); group('Reading', () { test('bubb', () async { final data = await File('test/keepassxcpasswords.kdbx').readAsBytes();