diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 2e4abe7..8937e21 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -22,9 +22,9 @@ jobs: codesign --remove-signature $(which dart) if: startsWith(matrix.os, 'macos') - name: Install dependencies - run: pub get + run: dart pub get - name: Run tests - run: pub run test + run: dart run test coverage: runs-on: ubuntu-latest steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b0031a..27caa9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ -## 2.3.0 (unreleased) +## 2.3.0 - Mark objects only as clean when saving was successful. - Only mark objects as clean if they have not been modified since we started saving. - Make credentials changeable. - Add support for CustomData in entries. +- Upgrade dependencies. ## 2.2.0 diff --git a/lib/src/credentials/keyfile.dart b/lib/src/credentials/keyfile.dart index aa1a81f..ab9a234 100644 --- a/lib/src/credentials/keyfile.dart +++ b/lib/src/credentials/keyfile.dart @@ -123,11 +123,11 @@ class KeyFileCredentials implements CredentialsPart { @visibleForTesting static String hexFormatLikeKeepass(final String hexString) { final hex = hexString.toUpperCase(); - const _groups = 8; - final remaining = hex.length % _groups; + const groups = 8; + final remaining = hex.length % groups; return [ - for (var i = 0; i < hex.length ~/ _groups; i++) - hex.substring(i * _groups, i * _groups + _groups), + for (var i = 0; i < hex.length ~/ groups; i++) + hex.substring(i * groups, i * groups + groups), if (remaining != 0) hex.substring(hex.length - remaining) ].join(' '); // range(0, hexString.length / 8).map((i) => hexString.substring(i*_groups, i*_groups + _groups)); diff --git a/lib/src/crypto/key_encrypter_kdf.dart b/lib/src/crypto/key_encrypter_kdf.dart index 60f993a..03a9dec 100644 --- a/lib/src/crypto/key_encrypter_kdf.dart +++ b/lib/src/crypto/key_encrypter_kdf.dart @@ -143,7 +143,7 @@ class KeyEncrypterKdf { } static Uint8List _encryptAesSync(EncryptAesArgs args) { - final cipher = ECBBlockCipher(AESFastEngine()) + final cipher = ECBBlockCipher(AESEngine()) ..init(true, KeyParameter(args.encryptionKey!)); var out1 = Uint8List.fromList(args.key); var out2 = Uint8List(args.key.length); diff --git a/lib/src/internal/crypto_utils.dart b/lib/src/internal/crypto_utils.dart index cfc115c..a2888d2 100644 --- a/lib/src/internal/crypto_utils.dart +++ b/lib/src/internal/crypto_utils.dart @@ -32,7 +32,7 @@ class AesHelper { {String mode = CBC_MODE}) { // Uint8List derivedKey = deriveKey(password); final KeyParameter keyParam = KeyParameter(derivedKey); - final BlockCipher aes = AESFastEngine(); + final BlockCipher aes = AESEngine(); // Uint8List cipherIvBytes = base64.decode(ciphertext); final Uint8List iv = Uint8List(aes.blockSize) diff --git a/lib/src/internal/pointycastle_argon2.dart b/lib/src/internal/pointycastle_argon2.dart index 7e77c9d..e7d3ad5 100644 --- a/lib/src/internal/pointycastle_argon2.dart +++ b/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:pointycastle/export.dart' as pc; -import 'package:pointycastle/pointycastle.dart' as pc; /// Dart-only implementation using pointycastle's Argon KDF. class PointyCastleArgon2 extends Argon2 { diff --git a/lib/src/kdbx_format.dart b/lib/src/kdbx_format.dart index 622388f..044cba2 100644 --- a/lib/src/kdbx_format.dart +++ b/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:crypto/crypto.dart' as crypto; 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/protected_salt_generator.dart'; import 'package:kdbx/src/internal/consts.dart'; @@ -792,7 +791,7 @@ class KdbxFormat { Uint8List _decryptContent( KdbxHeader header, Uint8List masterKey, Uint8List encryptedPayload) { final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes; - final decryptCipher = CBCBlockCipher(AESFastEngine()); + final decryptCipher = CBCBlockCipher(AESEngine()); decryptCipher.init( false, ParametersWithIV(KeyParameter(masterKey), encryptionIv)); _logger.finer('decrypting ${encryptedPayload.length} with block size ' @@ -824,7 +823,7 @@ class KdbxFormat { KdbxHeader header, Uint8List cipherKey, Uint8List encryptedPayload) { final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes; - final decryptCipher = CBCBlockCipher(AESFastEngine()); + final decryptCipher = CBCBlockCipher(AESEngine()); decryptCipher.init( false, ParametersWithIV(KeyParameter(cipherKey), encryptionIv)); final paddedDecrypted = @@ -838,7 +837,7 @@ class KdbxFormat { Uint8List _encryptContentV4Aes( KdbxHeader header, Uint8List cipherKey, Uint8List bytes) { final encryptionIv = header.fields[HeaderFields.EncryptionIV]!.bytes; - final encryptCypher = CBCBlockCipher(AESFastEngine()); + final encryptCypher = CBCBlockCipher(AESEngine()); encryptCypher.init( true, ParametersWithIV(KeyParameter(cipherKey), encryptionIv)); final paddedBytes = AesHelper.pad(bytes, encryptCypher.blockSize); @@ -863,7 +862,7 @@ class KdbxFormat { static Uint8List _encryptDataAes( Uint8List masterKey, Uint8List payload, Uint8List encryptionIv) { - final encryptCipher = CBCBlockCipher(AESFastEngine()); + final encryptCipher = CBCBlockCipher(AESEngine()); encryptCipher.init( true, ParametersWithIV(KeyParameter(masterKey), encryptionIv)); return AesHelper.processBlocks( diff --git a/lib/src/utils/byte_utils.dart b/lib/src/utils/byte_utils.dart index 27d4133..6937c04 100644 --- a/lib/src/utils/byte_utils.dart +++ b/lib/src/utils/byte_utils.dart @@ -190,16 +190,16 @@ class WriterHelperDartWeb extends WriterHelper { void writeUint64(int value, [LengthWriter? lengthWriter]) { lengthWriter?.call(8); - final _endian = Endian.little; + const endian = Endian.little; final highBits = value >> 32; final lowBits = value & mask32; final byteData = ByteData(8); - if (_endian == Endian.big) { - byteData.setUint32(0, highBits, _endian); - byteData.setUint32(0 + bytesPerWord, lowBits, _endian); + if (endian == Endian.big) { + byteData.setUint32(0, highBits, endian); + byteData.setUint32(0 + bytesPerWord, lowBits, endian); } else { - byteData.setUint32(0, lowBits, _endian); - byteData.setUint32(0 + bytesPerWord, highBits, _endian); + byteData.setUint32(0, lowBits, endian); + byteData.setUint32(0 + bytesPerWord, highBits, endian); } _write(byteData); } diff --git a/pubspec.yaml b/pubspec.yaml index 246b175..11f4125 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: kdbx 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 environment: @@ -10,7 +10,7 @@ dependencies: logging: '>=0.11.3+2 <2.0.0' crypto: '>=2.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" meta: '>=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' synchronized: '>=2.2.0 <4.0.0' - collection: ^1.15.0 + collection: '>=1.15.0 <2.0.0' # required for bin/ args: '>1.5.0 <3.0.0' @@ -30,6 +30,6 @@ dependencies: argon2_ffi_base: ^1.1.0+1 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' fake_async: ^1.2.0 diff --git a/test/internal/byte_utils_test.dart b/test/internal/byte_utils_test.dart index 82a1dca..2c3a9b4 100644 --- a/test/internal/byte_utils_test.dart +++ b/test/internal/byte_utils_test.dart @@ -9,7 +9,7 @@ void main() { final bytesBuilder = BytesBuilder(); final writer = WriterHelper(bytesBuilder); writer.writeUint32(1); - print('result: ' + ByteUtils.toHexList(writer.output.toBytes())); + print('result: ${ByteUtils.toHexList(writer.output.toBytes())}'); expect(writer.output.toBytes(), hasLength(4)); }); test('uint64', () { diff --git a/test/internal/test_utils.dart b/test/internal/test_utils.dart index 5e9846e..5db5a94 100644 --- a/test/internal/test_utils.dart +++ b/test/internal/test_utils.dart @@ -15,7 +15,7 @@ class TestUtil { setupLogging(); } - static late final instance = TestUtil._(); + static final instance = TestUtil._(); static final keyTitle = KdbxKey('Title'); diff --git a/test/merge/kdbx_merge_test.dart b/test/merge/kdbx_merge_test.dart index 7bd46c7..d30cdd0 100644 --- a/test/merge/kdbx_merge_test.dart +++ b/test/merge/kdbx_merge_test.dart @@ -50,10 +50,8 @@ void main() { fileMod.body.rootGroup.entries.first .setString(KdbxKeyCommon.USER_NAME, PlainValue('changed.')); - _logger.info('mod date: ' + - fileMod.body.rootGroup.entries.first.times.lastModificationTime - .get() - .toString()); + _logger.info('mod date: ${fileMod.body.rootGroup.entries.first.times.lastModificationTime + .get()}'); final file2 = await testUtil.saveAndRead(fileMod); _logger.info('\n\n\nstarting merge.\n');