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)
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:

3
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

8
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));

2
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);

2
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)

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:pointycastle/export.dart' as pc;
import 'package:pointycastle/pointycastle.dart' as pc;
/// Dart-only implementation using pointycastle's Argon KDF.
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: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(

12
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);
}

8
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

2
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', () {

2
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');

6
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');

Loading…
Cancel
Save