From 1a3f42961a4c82dbdc85ef7d1729ba8d0a993130 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Sun, 2 Aug 2020 17:15:49 +0200 Subject: [PATCH] use the original ChaCha7539 from pointycastle. --- lib/src/crypto/protected_salt_generator.dart | 10 +++++----- lib/src/kdbx_format.dart | 3 ++- pubspec.yaml | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/src/crypto/protected_salt_generator.dart b/lib/src/crypto/protected_salt_generator.dart index 3bfa3ee..d32359e 100644 --- a/lib/src/crypto/protected_salt_generator.dart +++ b/lib/src/crypto/protected_salt_generator.dart @@ -51,11 +51,11 @@ class ChachaPointyCastleProtectedSaltGenerator extends ProtectedSaltGenerator { final secretKey = hash.bytes.sublist(0, 32); final nonce = hash.bytes.sublist(32, 32 + 12); - final chacha20 = ChaCha20Engine(); - chacha20.init( - null, - ParametersWithIV( - KeyParameter(secretKey as Uint8List), nonce as Uint8List)); + final chacha20 = ChaCha7539Engine() + ..init( + null, + ParametersWithIV( + KeyParameter(secretKey as Uint8List), nonce as Uint8List)); return ChachaPointyCastleProtectedSaltGenerator._(chacha20); } diff --git a/lib/src/kdbx_format.dart b/lib/src/kdbx_format.dart index 98c2321..bc3f7f8 100644 --- a/lib/src/kdbx_format.dart +++ b/lib/src/kdbx_format.dart @@ -23,6 +23,7 @@ import 'package:kdbx/src/kdbx_xml.dart'; import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; import 'package:pointycastle/export.dart'; +import 'package:pointycastle/stream/chacha7539.dart'; import 'package:xml/xml.dart' as xml; final _logger = Logger('kdbx.format'); @@ -542,7 +543,7 @@ class KdbxFormat { Uint8List transformContentV4ChaCha20( KdbxHeader header, Uint8List encrypted, Uint8List cipherKey) { final encryptionIv = header.fields[HeaderFields.EncryptionIV].bytes; - final engine = ChaCha20Engine() + final engine = ChaCha7539Engine() ..init(false, ParametersWithIV(KeyParameter(cipherKey), encryptionIv)); return engine.process(encrypted); } diff --git a/pubspec.yaml b/pubspec.yaml index b292552..f253ceb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,13 +35,13 @@ dev_dependencies: test: '>=1.6.0 <2.0.0' dependency_overrides: -# pointycastle: -# git: -# url: https://github.com/bcgit/pc-dart.git -# ref: 7c8a8b47faa75432fe3fb9a739db4a289e12b341 pointycastle: git: - url: https://github.com/authpass/pc-dart.git - ref: 38fa40e966153b3d3cf93a9bd95228f76af3b9d7 + url: https://github.com/bcgit/pc-dart.git + ref: 7c8a8b47faa75432fe3fb9a739db4a289e12b341 +# pointycastle: +# git: +# url: https://github.com/authpass/pc-dart.git +# ref: 38fa40e966153b3d3cf93a9bd95228f76af3b9d7 # pointycastle: # path: /Users/herbert/dev/pointycastle