Browse Source

use the original ChaCha7539 from pointycastle.

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

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

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

12
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

Loading…
Cancel
Save