Browse Source

upgrade depencencies. release 2.3.0

pull/5/head
Herbert Poul 3 years ago
parent
commit
48da32961f
  1. 4
      .github/workflows/dart.yml
  2. 3
      CHANGELOG.md
  3. 8
      lib/src/credentials/keyfile.dart
  4. 2
      lib/src/crypto/key_encrypter_kdf.dart
  5. 2
      lib/src/internal/crypto_utils.dart
  6. 1
      lib/src/internal/pointycastle_argon2.dart
  7. 9
      lib/src/kdbx_format.dart
  8. 12
      lib/src/utils/byte_utils.dart
  9. 8
      pubspec.yaml
  10. 2
      test/internal/byte_utils_test.dart
  11. 2
      test/internal/test_utils.dart
  12. 6
      test/merge/kdbx_merge_test.dart

4
.github/workflows/dart.yml

@ -22,9 +22,9 @@ jobs:
codesign --remove-signature $(which dart) codesign --remove-signature $(which dart)
if: startsWith(matrix.os, 'macos') if: startsWith(matrix.os, 'macos')
- name: Install dependencies - name: Install dependencies
run: pub get run: dart pub get
- name: Run tests - name: Run tests
run: pub run test run: dart run test
coverage: coverage:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

3
CHANGELOG.md

@ -1,9 +1,10 @@
## 2.3.0 (unreleased) ## 2.3.0
- Mark objects only as clean when saving was successful. - Mark objects only as clean when saving was successful.
- Only mark objects as clean if they have not been modified since we started saving. - Only mark objects as clean if they have not been modified since we started saving.
- Make credentials changeable. - Make credentials changeable.
- Add support for CustomData in entries. - Add support for CustomData in entries.
- Upgrade dependencies.
## 2.2.0 ## 2.2.0

8
lib/src/credentials/keyfile.dart

@ -123,11 +123,11 @@ class KeyFileCredentials implements CredentialsPart {
@visibleForTesting @visibleForTesting
static String hexFormatLikeKeepass(final String hexString) { static String hexFormatLikeKeepass(final String hexString) {
final hex = hexString.toUpperCase(); final hex = hexString.toUpperCase();
const _groups = 8; const groups = 8;
final remaining = hex.length % _groups; final remaining = hex.length % groups;
return [ return [
for (var i = 0; i < hex.length ~/ _groups; i++) for (var i = 0; i < hex.length ~/ groups; i++)
hex.substring(i * _groups, i * _groups + _groups), hex.substring(i * groups, i * groups + groups),
if (remaining != 0) hex.substring(hex.length - remaining) if (remaining != 0) hex.substring(hex.length - remaining)
].join(' '); ].join(' ');
// range(0, hexString.length / 8).map((i) => hexString.substring(i*_groups, i*_groups + _groups)); // range(0, hexString.length / 8).map((i) => hexString.substring(i*_groups, i*_groups + _groups));

2
lib/src/crypto/key_encrypter_kdf.dart

@ -143,7 +143,7 @@ class KeyEncrypterKdf {
} }
static Uint8List _encryptAesSync(EncryptAesArgs args) { static Uint8List _encryptAesSync(EncryptAesArgs args) {
final cipher = ECBBlockCipher(AESFastEngine()) final cipher = ECBBlockCipher(AESEngine())
..init(true, KeyParameter(args.encryptionKey!)); ..init(true, KeyParameter(args.encryptionKey!));
var out1 = Uint8List.fromList(args.key); var out1 = Uint8List.fromList(args.key);
var out2 = Uint8List(args.key.length); var out2 = Uint8List(args.key.length);

2
lib/src/internal/crypto_utils.dart

@ -32,7 +32,7 @@ class AesHelper {
{String mode = CBC_MODE}) { {String mode = CBC_MODE}) {
// Uint8List derivedKey = deriveKey(password); // Uint8List derivedKey = deriveKey(password);
final KeyParameter keyParam = KeyParameter(derivedKey); final KeyParameter keyParam = KeyParameter(derivedKey);
final BlockCipher aes = AESFastEngine(); final BlockCipher aes = AESEngine();
// Uint8List cipherIvBytes = base64.decode(ciphertext); // Uint8List cipherIvBytes = base64.decode(ciphertext);
final Uint8List iv = Uint8List(aes.blockSize) final Uint8List iv = Uint8List(aes.blockSize)

1
lib/src/internal/pointycastle_argon2.dart

@ -2,7 +2,6 @@ import 'dart:typed_data';
import 'package:argon2_ffi_base/argon2_ffi_base.dart'; import 'package:argon2_ffi_base/argon2_ffi_base.dart';
import 'package:pointycastle/export.dart' as pc; import 'package:pointycastle/export.dart' as pc;
import 'package:pointycastle/pointycastle.dart' as pc;
/// Dart-only implementation using pointycastle's Argon KDF. /// Dart-only implementation using pointycastle's Argon KDF.
class PointyCastleArgon2 extends Argon2 { class PointyCastleArgon2 extends Argon2 {

9
lib/src/kdbx_format.dart

@ -8,7 +8,6 @@ import 'package:argon2_ffi_base/argon2_ffi_base.dart';
import 'package:collection/collection.dart' show IterableExtension; import 'package:collection/collection.dart' show IterableExtension;
import 'package:crypto/crypto.dart' as crypto; import 'package:crypto/crypto.dart' as crypto;
import 'package:kdbx/kdbx.dart'; import 'package:kdbx/kdbx.dart';
import 'package:kdbx/src/credentials/credentials.dart';
import 'package:kdbx/src/crypto/key_encrypter_kdf.dart'; import 'package:kdbx/src/crypto/key_encrypter_kdf.dart';
import 'package:kdbx/src/crypto/protected_salt_generator.dart'; import 'package:kdbx/src/crypto/protected_salt_generator.dart';
import 'package:kdbx/src/internal/consts.dart'; import 'package:kdbx/src/internal/consts.dart';
@ -792,7 +791,7 @@ class KdbxFormat {
Uint8List _decryptContent( Uint8List _decryptContent(
KdbxHeader header, Uint8List masterKey, Uint8List encryptedPayload) { KdbxHeader header, Uint8List masterKey, Uint8List encryptedPayload) {
final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes; final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes;
final decryptCipher = CBCBlockCipher(AESFastEngine()); final decryptCipher = CBCBlockCipher(AESEngine());
decryptCipher.init( decryptCipher.init(
false, ParametersWithIV(KeyParameter(masterKey), encryptionIv)); false, ParametersWithIV(KeyParameter(masterKey), encryptionIv));
_logger.finer('decrypting ${encryptedPayload.length} with block size ' _logger.finer('decrypting ${encryptedPayload.length} with block size '
@ -824,7 +823,7 @@ class KdbxFormat {
KdbxHeader header, Uint8List cipherKey, Uint8List encryptedPayload) { KdbxHeader header, Uint8List cipherKey, Uint8List encryptedPayload) {
final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes; final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes;
final decryptCipher = CBCBlockCipher(AESFastEngine()); final decryptCipher = CBCBlockCipher(AESEngine());
decryptCipher.init( decryptCipher.init(
false, ParametersWithIV(KeyParameter(cipherKey), encryptionIv)); false, ParametersWithIV(KeyParameter(cipherKey), encryptionIv));
final paddedDecrypted = final paddedDecrypted =
@ -838,7 +837,7 @@ class KdbxFormat {
Uint8List _encryptContentV4Aes( Uint8List _encryptContentV4Aes(
KdbxHeader header, Uint8List cipherKey, Uint8List bytes) { KdbxHeader header, Uint8List cipherKey, Uint8List bytes) {
final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes; final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes;
final encryptCypher = CBCBlockCipher(AESFastEngine()); final encryptCypher = CBCBlockCipher(AESEngine());
encryptCypher.init( encryptCypher.init(
true, ParametersWithIV(KeyParameter(cipherKey), encryptionIv)); true, ParametersWithIV(KeyParameter(cipherKey), encryptionIv));
final paddedBytes = AesHelper.pad(bytes, encryptCypher.blockSize); final paddedBytes = AesHelper.pad(bytes, encryptCypher.blockSize);
@ -863,7 +862,7 @@ class KdbxFormat {
static Uint8List _encryptDataAes( static Uint8List _encryptDataAes(
Uint8List masterKey, Uint8List payload, Uint8List encryptionIv) { Uint8List masterKey, Uint8List payload, Uint8List encryptionIv) {
final encryptCipher = CBCBlockCipher(AESFastEngine()); final encryptCipher = CBCBlockCipher(AESEngine());
encryptCipher.init( encryptCipher.init(
true, ParametersWithIV(KeyParameter(masterKey), encryptionIv)); true, ParametersWithIV(KeyParameter(masterKey), encryptionIv));
return AesHelper.processBlocks( return AesHelper.processBlocks(

12
lib/src/utils/byte_utils.dart

@ -190,16 +190,16 @@ class WriterHelperDartWeb extends WriterHelper {
void writeUint64(int value, [LengthWriter? lengthWriter]) { void writeUint64(int value, [LengthWriter? lengthWriter]) {
lengthWriter?.call(8); lengthWriter?.call(8);
final _endian = Endian.little; const endian = Endian.little;
final highBits = value >> 32; final highBits = value >> 32;
final lowBits = value & mask32; final lowBits = value & mask32;
final byteData = ByteData(8); final byteData = ByteData(8);
if (_endian == Endian.big) { if (endian == Endian.big) {
byteData.setUint32(0, highBits, _endian); byteData.setUint32(0, highBits, endian);
byteData.setUint32(0 + bytesPerWord, lowBits, _endian); byteData.setUint32(0 + bytesPerWord, lowBits, endian);
} else { } else {
byteData.setUint32(0, lowBits, _endian); byteData.setUint32(0, lowBits, endian);
byteData.setUint32(0 + bytesPerWord, highBits, _endian); byteData.setUint32(0 + bytesPerWord, highBits, endian);
} }
_write(byteData); _write(byteData);
} }

8
pubspec.yaml

@ -1,6 +1,6 @@
name: kdbx name: kdbx
description: KeepassX format implementation in pure dart. (kdbx 3.x and 4.x support). description: KeepassX format implementation in pure dart. (kdbx 3.x and 4.x support).
version: 2.2.0 version: 2.3.0
homepage: https://github.com/authpass/kdbx.dart homepage: https://github.com/authpass/kdbx.dart
environment: environment:
@ -10,7 +10,7 @@ dependencies:
logging: '>=0.11.3+2 <2.0.0' logging: '>=0.11.3+2 <2.0.0'
crypto: '>=2.0.0 <4.0.0' crypto: '>=2.0.0 <4.0.0'
pointycastle: '>=3.0.0 <4.0.0' pointycastle: '>=3.0.0 <4.0.0'
xml: '>=4.4.0 <6.0.0' xml: '>=4.4.0 <7.0.0'
uuid: ">=3.0.0 <5.0.0" uuid: ">=3.0.0 <5.0.0"
meta: '>=1.0.0 <2.0.0' meta: '>=1.0.0 <2.0.0'
clock: '>=1.0.0 <2.0.0' clock: '>=1.0.0 <2.0.0'
@ -22,7 +22,7 @@ dependencies:
supercharged_dart: '>=1.2.0 <4.0.0' supercharged_dart: '>=1.2.0 <4.0.0'
synchronized: '>=2.2.0 <4.0.0' synchronized: '>=2.2.0 <4.0.0'
collection: ^1.15.0 collection: '>=1.15.0 <2.0.0'
# required for bin/ # required for bin/
args: '>1.5.0 <3.0.0' args: '>1.5.0 <3.0.0'
@ -30,6 +30,6 @@ dependencies:
argon2_ffi_base: ^1.1.0+1 argon2_ffi_base: ^1.1.0+1
dev_dependencies: dev_dependencies:
flutter_lints: ">=1.0.4 <2.0.0" flutter_lints: '>=2.0.0 <3.0.0'
test: '>=1.6.0 <2.0.0' test: '>=1.6.0 <2.0.0'
fake_async: ^1.2.0 fake_async: ^1.2.0

2
test/internal/byte_utils_test.dart

@ -9,7 +9,7 @@ void main() {
final bytesBuilder = BytesBuilder(); final bytesBuilder = BytesBuilder();
final writer = WriterHelper(bytesBuilder); final writer = WriterHelper(bytesBuilder);
writer.writeUint32(1); writer.writeUint32(1);
print('result: ' + ByteUtils.toHexList(writer.output.toBytes())); print('result: ${ByteUtils.toHexList(writer.output.toBytes())}');
expect(writer.output.toBytes(), hasLength(4)); expect(writer.output.toBytes(), hasLength(4));
}); });
test('uint64', () { test('uint64', () {

2
test/internal/test_utils.dart

@ -15,7 +15,7 @@ class TestUtil {
setupLogging(); setupLogging();
} }
static late final instance = TestUtil._(); static final instance = TestUtil._();
static final keyTitle = KdbxKey('Title'); static final keyTitle = KdbxKey('Title');

6
test/merge/kdbx_merge_test.dart

@ -50,10 +50,8 @@ void main() {
fileMod.body.rootGroup.entries.first fileMod.body.rootGroup.entries.first
.setString(KdbxKeyCommon.USER_NAME, PlainValue('changed.')); .setString(KdbxKeyCommon.USER_NAME, PlainValue('changed.'));
_logger.info('mod date: ' + _logger.info('mod date: ${fileMod.body.rootGroup.entries.first.times.lastModificationTime
fileMod.body.rootGroup.entries.first.times.lastModificationTime .get()}');
.get()
.toString());
final file2 = await testUtil.saveAndRead(fileMod); final file2 = await testUtil.saveAndRead(fileMod);
_logger.info('\n\n\nstarting merge.\n'); _logger.info('\n\n\nstarting merge.\n');

Loading…
Cancel
Save