Browse Source

use the original ChaCha7539 from pointycastle.

remove-cryptography-dependency
Herbert Poul 4 years ago
parent
commit
1a3f42961a
  1. 4
      lib/src/crypto/protected_salt_generator.dart
  2. 3
      lib/src/kdbx_format.dart
  3. 12
      pubspec.yaml

4
lib/src/crypto/protected_salt_generator.dart

@ -51,8 +51,8 @@ class ChachaPointyCastleProtectedSaltGenerator extends ProtectedSaltGenerator {
final secretKey = hash.bytes.sublist(0, 32); final secretKey = hash.bytes.sublist(0, 32);
final nonce = hash.bytes.sublist(32, 32 + 12); final nonce = hash.bytes.sublist(32, 32 + 12);
final chacha20 = ChaCha20Engine(); final chacha20 = ChaCha7539Engine()
chacha20.init( ..init(
null, null,
ParametersWithIV( ParametersWithIV(
KeyParameter(secretKey as Uint8List), nonce as Uint8List)); KeyParameter(secretKey as Uint8List), nonce as Uint8List));

3
lib/src/kdbx_format.dart

@ -23,6 +23,7 @@ import 'package:kdbx/src/kdbx_xml.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:pointycastle/export.dart'; import 'package:pointycastle/export.dart';
import 'package:pointycastle/stream/chacha7539.dart';
import 'package:xml/xml.dart' as xml; import 'package:xml/xml.dart' as xml;
final _logger = Logger('kdbx.format'); final _logger = Logger('kdbx.format');
@ -542,7 +543,7 @@ class KdbxFormat {
Uint8List transformContentV4ChaCha20( Uint8List transformContentV4ChaCha20(
KdbxHeader header, Uint8List encrypted, Uint8List cipherKey) { KdbxHeader header, Uint8List encrypted, Uint8List cipherKey) {
final encryptionIv = header.fields[HeaderFields.EncryptionIV].bytes; final encryptionIv = header.fields[HeaderFields.EncryptionIV].bytes;
final engine = ChaCha20Engine() final engine = ChaCha7539Engine()
..init(false, ParametersWithIV(KeyParameter(cipherKey), encryptionIv)); ..init(false, ParametersWithIV(KeyParameter(cipherKey), encryptionIv));
return engine.process(encrypted); return engine.process(encrypted);
} }

12
pubspec.yaml

@ -35,13 +35,13 @@ dev_dependencies:
test: '>=1.6.0 <2.0.0' test: '>=1.6.0 <2.0.0'
dependency_overrides: dependency_overrides:
# pointycastle:
# git:
# url: https://github.com/bcgit/pc-dart.git
# ref: 7c8a8b47faa75432fe3fb9a739db4a289e12b341
pointycastle: pointycastle:
git: git:
url: https://github.com/authpass/pc-dart.git url: https://github.com/bcgit/pc-dart.git
ref: 38fa40e966153b3d3cf93a9bd95228f76af3b9d7 ref: 7c8a8b47faa75432fe3fb9a739db4a289e12b341
# pointycastle:
# git:
# url: https://github.com/authpass/pc-dart.git
# ref: 38fa40e966153b3d3cf93a9bd95228f76af3b9d7
# pointycastle: # pointycastle:
# path: /Users/herbert/dev/pointycastle # path: /Users/herbert/dev/pointycastle

Loading…
Cancel
Save