Merge branch 'master' of github.com:Tienisto/pc-dart into Tienisto-master
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..60aaefb
--- /dev/null
+++ b/.DS_Store
Binary files differ
diff --git a/.github/workflows/chrome.workflow.yml b/.github/workflows/chrome.workflow.yml
index b8e3f9f..4e5bbaf 100644
--- a/.github/workflows/chrome.workflow.yml
+++ b/.github/workflows/chrome.workflow.yml
@@ -20,15 +20,21 @@
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ sdk: [3.2.0, stable, dev]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - uses: actions/checkout@v3
- - uses: dart-lang/setup-dart@v1
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
+ - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
+ with:
+ sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
- name: Test chrome
- run: dart pub run test -p chrome
+ run: dart test -j 1 -p chrome
diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml
new file mode 100644
index 0000000..e35f657
--- /dev/null
+++ b/.github/workflows/health.yaml
@@ -0,0 +1,12 @@
+name: Health
+on:
+ pull_request:
+ branches: [ main ]
+ types: [opened, synchronize, reopened, labeled, unlabeled]
+jobs:
+ health:
+ uses: dart-lang/ecosystem/.github/workflows/health.yaml@9fabe464ea1d8408774de74d2ac759c1f90ae480
+ with:
+ checks: "version,changelog,license,do-not-submit,breaking,coverage,leaking"
+ permissions:
+ pull-requests: write
\ No newline at end of file
diff --git a/.github/workflows/node.workflow.yml b/.github/workflows/node.workflow.yml
index 9694ba9..53996c6 100644
--- a/.github/workflows/node.workflow.yml
+++ b/.github/workflows/node.workflow.yml
@@ -20,15 +20,21 @@
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ sdk: [3.2.0, stable, dev]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - uses: actions/checkout@v3
- - uses: dart-lang/setup-dart@v1
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
+ - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
+ with:
+ sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
- name: Test node
- run: dart pub run test -p node
+ run: dart test -p node
diff --git a/.github/workflows/post_summaries.yaml b/.github/workflows/post_summaries.yaml
new file mode 100644
index 0000000..fac7e53
--- /dev/null
+++ b/.github/workflows/post_summaries.yaml
@@ -0,0 +1,16 @@
+name: Comment on the pull request
+
+on:
+ # Trigger this workflow after the Health workflow completes. This workflow will have permissions to
+ # do things like create comments on the PR, even if the original workflow couldn't.
+ workflow_run:
+ workflows:
+ - Health
+ types:
+ - completed
+
+jobs:
+ upload:
+ uses: dart-lang/ecosystem/.github/workflows/post_summaries.yaml@main
+ permissions:
+ pull-requests: write
\ No newline at end of file
diff --git a/.github/workflows/vm.workflow.yml b/.github/workflows/vm.workflow.yml
index 791b7e1..0c3b9e6 100644
--- a/.github/workflows/vm.workflow.yml
+++ b/.github/workflows/vm.workflow.yml
@@ -19,16 +19,29 @@
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
- runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu, macos, windows]
+ sdk: [stable]
+ include:
+ - os: ubuntu
+ sdk: 3.2.0
+ - os: ubuntu
+ sdk: dev
+
+ runs-on: ${{ matrix.os }}-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - uses: actions/checkout@v3
- - uses: dart-lang/setup-dart@v1
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
+ - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
+ with:
+ sdk: ${{ matrix.sdk }}
- name: Install dependencies
run: dart pub get
- name: Test dartvm
- run: dart pub run test -p vm
+ run: dart test -p vm
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2179072..706cae3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,25 @@
Changelog
=========
+#### Version 3.9.1 (2024-05-07)
+
+* Add crypto in topics to pubspec.yaml (PR #237)
+* remove unnecessary ! operator from some files (PR #236)
+
+#### Version 3.9.0 (2024-04-19)
+
+* Update minimum SDK version to 3.2.0 (PR #231)
+
+#### Version 3.8.0 (2024-03-24)
+
+* Add dart2wasm support (PR #225)
+
+#### Version 3.7.4 (2024-01-15)
+
+* Support the latest version of `package:js`. (PR #220)
+* Require Dart v3.0 (PR #220)
+* Support parsing of nested objects with indefinite lengths (PR #215)
+
#### Version 3.7.3 (2023-04-14)
* PSSSigner requires only salt length to verify signature
diff --git a/analysis_options.yaml b/analysis_options.yaml
index d4fcc1a..130172c 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1 +1,9 @@
-include: package:pedantic/analysis_options.yaml
\ No newline at end of file
+include: package:lints/recommended.yaml
+
+analyzer:
+ errors:
+ constant_identifier_names: ignore
+ file_names: ignore # these should be fixed
+ no_leading_underscores_for_local_identifiers: ignore # should be fixed!
+ non_constant_identifier_names: ignore
+ unnecessary_library_directive: ignore # blocked by dartdoc changes
diff --git a/benchmark/all_benchmarks.dart b/benchmark/all_benchmarks.dart
index c3e79a7..a9a36a7 100644
--- a/benchmark/all_benchmarks.dart
+++ b/benchmark/all_benchmarks.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library pointycastle.benchmark.all_benchmarks;
-
import './block/aes_benchmark.dart' as aes_benchmark;
import './digests/md2_benchmark.dart' as md2_benchmark;
import './digests/md4_benchmark.dart' as md4_benchmark;
diff --git a/benchmark/benchmark/block_cipher_benchmark.dart b/benchmark/benchmark/block_cipher_benchmark.dart
index 2a019d6..fbaf7fb 100644
--- a/benchmark/benchmark/block_cipher_benchmark.dart
+++ b/benchmark/benchmark/block_cipher_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.benchmark.block_cipher_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/benchmark/benchmark/digest_benchmark.dart b/benchmark/benchmark/digest_benchmark.dart
index c854583..ee7d712 100644
--- a/benchmark/benchmark/digest_benchmark.dart
+++ b/benchmark/benchmark/digest_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.benchmark.digest_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/benchmark/benchmark/operation_benchmark.dart b/benchmark/benchmark/operation_benchmark.dart
index faaebaf..74903b2 100644
--- a/benchmark/benchmark/operation_benchmark.dart
+++ b/benchmark/benchmark/operation_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.benchmark.rate_benchmark;
-
import 'package:benchmark_harness/benchmark_harness.dart';
typedef Operation = void Function();
@@ -14,9 +12,9 @@
int? _iterations;
- OperationBenchmark(String name, this._operation,
+ OperationBenchmark(super.name, this._operation,
[this._runLengthMillis = _RUN_LENGTH_MILLIS])
- : super(name, emitter: OperationEmitter()) {
+ : super(emitter: OperationEmitter()) {
emitter.benchmark = this;
}
diff --git a/benchmark/benchmark/rate_benchmark.dart b/benchmark/benchmark/rate_benchmark.dart
index b9df7b0..b7d78e4 100644
--- a/benchmark/benchmark/rate_benchmark.dart
+++ b/benchmark/benchmark/rate_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.benchmark.rate_benchmark;
-
import 'package:benchmark_harness/benchmark_harness.dart';
abstract class RateBenchmark extends BenchmarkBase {
@@ -10,7 +8,7 @@
int _totalData = 0;
int _iterations = 0;
- RateBenchmark(String name) : super(name, emitter: RateEmitter()) {
+ RateBenchmark(super.name) : super(emitter: RateEmitter()) {
emitter.benchmark = this;
}
diff --git a/benchmark/benchmark/signer_benchmark.dart b/benchmark/benchmark/signer_benchmark.dart
index a3f232c..94f4ba1 100644
--- a/benchmark/benchmark/signer_benchmark.dart
+++ b/benchmark/benchmark/signer_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.benchmark.signer_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/benchmark/benchmark/stream_cipher_benchmark.dart b/benchmark/benchmark/stream_cipher_benchmark.dart
index 22208dd..c316256 100644
--- a/benchmark/benchmark/stream_cipher_benchmark.dart
+++ b/benchmark/benchmark/stream_cipher_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.benchmark.stream_cipher_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/benchmark/block/aes_benchmark.dart b/benchmark/block/aes_benchmark.dart
index a08fa65..ddff975 100644
--- a/benchmark/block/aes_benchmark.dart
+++ b/benchmark/block/aes_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.block.aes_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/benchmark/digests/blake2b_benchmark.dart b/benchmark/digests/blake2b_benchmark.dart
index e449667..3819518 100644
--- a/benchmark/digests/blake2b_benchmark.dart
+++ b/benchmark/digests/blake2b_benchmark.dart
@@ -1,5 +1,3 @@
-library benchmark.digests.blake2b_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/md2_benchmark.dart b/benchmark/digests/md2_benchmark.dart
index 3862b2a..1e77224 100644
--- a/benchmark/digests/md2_benchmark.dart
+++ b/benchmark/digests/md2_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.md2_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/md4_benchmark.dart b/benchmark/digests/md4_benchmark.dart
index 4e9fbc1..28f3862 100644
--- a/benchmark/digests/md4_benchmark.dart
+++ b/benchmark/digests/md4_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.md4_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/md5_benchmark.dart b/benchmark/digests/md5_benchmark.dart
index be2ff01..5eddb9b 100644
--- a/benchmark/digests/md5_benchmark.dart
+++ b/benchmark/digests/md5_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.md5_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/ripemd128_benchmark.dart b/benchmark/digests/ripemd128_benchmark.dart
index 81cabdc..382cb08 100644
--- a/benchmark/digests/ripemd128_benchmark.dart
+++ b/benchmark/digests/ripemd128_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.ripemd128_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/ripemd160_benchmark.dart b/benchmark/digests/ripemd160_benchmark.dart
index a09a875..8994cc5 100644
--- a/benchmark/digests/ripemd160_benchmark.dart
+++ b/benchmark/digests/ripemd160_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.ripemd160_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/ripemd256_benchmark.dart b/benchmark/digests/ripemd256_benchmark.dart
index c98bbf9..7d2e4eb 100644
--- a/benchmark/digests/ripemd256_benchmark.dart
+++ b/benchmark/digests/ripemd256_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.ripemd256_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/ripemd320_benchmark.dart b/benchmark/digests/ripemd320_benchmark.dart
index c732a38..f03d488 100644
--- a/benchmark/digests/ripemd320_benchmark.dart
+++ b/benchmark/digests/ripemd320_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.ripemd320_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha1_benchmark.dart b/benchmark/digests/sha1_benchmark.dart
index df44fef..93deb6f 100644
--- a/benchmark/digests/sha1_benchmark.dart
+++ b/benchmark/digests/sha1_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha1_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha224_benchmark.dart b/benchmark/digests/sha224_benchmark.dart
index 56da90e..5cf4ca7 100644
--- a/benchmark/digests/sha224_benchmark.dart
+++ b/benchmark/digests/sha224_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha224_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha256_benchmark.dart b/benchmark/digests/sha256_benchmark.dart
index 4e01049..b0ff825 100644
--- a/benchmark/digests/sha256_benchmark.dart
+++ b/benchmark/digests/sha256_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha256_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha384_benchmark.dart b/benchmark/digests/sha384_benchmark.dart
index 7d77fe5..024c1f4 100644
--- a/benchmark/digests/sha384_benchmark.dart
+++ b/benchmark/digests/sha384_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha384_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha3_benchmark.dart b/benchmark/digests/sha3_benchmark.dart
index ce0a31d..1084e48 100644
--- a/benchmark/digests/sha3_benchmark.dart
+++ b/benchmark/digests/sha3_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha3_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha512_benchmark.dart b/benchmark/digests/sha512_benchmark.dart
index d00b199..c41bfd2 100644
--- a/benchmark/digests/sha512_benchmark.dart
+++ b/benchmark/digests/sha512_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha512_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/sha512t_benchmark.dart b/benchmark/digests/sha512t_benchmark.dart
index e3c3e92..a5b85ca 100644
--- a/benchmark/digests/sha512t_benchmark.dart
+++ b/benchmark/digests/sha512t_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.sha512t_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/tiger_benchmark.dart b/benchmark/digests/tiger_benchmark.dart
index ee0ad4d..5c07b61 100644
--- a/benchmark/digests/tiger_benchmark.dart
+++ b/benchmark/digests/tiger_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.tiger_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/digests/whirlpool_benchmark.dart b/benchmark/digests/whirlpool_benchmark.dart
index 7774a82..62e02f6 100644
--- a/benchmark/digests/whirlpool_benchmark.dart
+++ b/benchmark/digests/whirlpool_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.digests.whirlpool_benchmark;
-
import '../benchmark/digest_benchmark.dart';
void main() {
diff --git a/benchmark/signers/rsa_signer_benchmark.dart b/benchmark/signers/rsa_signer_benchmark.dart
index 0716892..4ac6738 100644
--- a/benchmark/signers/rsa_signer_benchmark.dart
+++ b/benchmark/signers/rsa_signer_benchmark.dart
@@ -1,12 +1,10 @@
// See file LICENSE for more information.
-library benchmark.signers.rsa_signer_benchmark;
-
import 'package:pointycastle/pointycastle.dart';
-import '../benchmark/signer_benchmark.dart';
// ignore: directives_ordering
import '../../test/test/src/null_secure_random.dart';
+import '../benchmark/signer_benchmark.dart';
void main() {
var modulus = BigInt.parse(
@@ -22,11 +20,13 @@
var pubk = RSAPublicKey(modulus, publicExponent);
var privk = RSAPrivateKey(modulus, privateExponent, p, q);
- // ignore: unused_local_variable
- var pubParamsFactory = () => ParametersWithRandom(
- PublicKeyParameter<RSAPublicKey>(pubk), NullSecureRandom());
- var privParamsFactory = () => ParametersWithRandom(
- PrivateKeyParameter<RSAPrivateKey>(privk), NullSecureRandom());
+ // ignore: unused_element
+ ParametersWithRandom<PublicKeyParameter<RSAPublicKey>> pubParamsFactory() =>
+ ParametersWithRandom(
+ PublicKeyParameter<RSAPublicKey>(pubk), NullSecureRandom());
+ ParametersWithRandom<PrivateKeyParameter<RSAPrivateKey>>
+ privParamsFactory() => ParametersWithRandom(
+ PrivateKeyParameter<RSAPrivateKey>(privk), NullSecureRandom());
SignerBenchmark('Null/RSA', true, privParamsFactory).report();
}
diff --git a/benchmark/src/ufixnum_benchmark.dart b/benchmark/src/ufixnum_benchmark.dart
index f3ecaba..d01f611 100644
--- a/benchmark/src/ufixnum_benchmark.dart
+++ b/benchmark/src/ufixnum_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.api.ufixnum_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/src/ufixnum.dart';
diff --git a/benchmark/stream/salsa20_benchmark.dart b/benchmark/stream/salsa20_benchmark.dart
index 0c78a05..355a7cf 100644
--- a/benchmark/stream/salsa20_benchmark.dart
+++ b/benchmark/stream/salsa20_benchmark.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library benchmark.stream.salsa20_benchmark;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/lib/api.dart b/lib/api.dart
index 298948f..352a25e 100644
--- a/lib/api.dart
+++ b/lib/api.dart
@@ -5,27 +5,25 @@
/// It declares all abstract types used by the Pointy Castle library.
/// In addition, it implements the factories mechanism that allows
/// users to instantiate algorithms by their standard name.
-library api;
+library;
import 'dart:typed_data';
import 'src/registry/registry.dart';
import 'src/utils.dart';
+part 'src/api/aead_block_cipher.dart';
part 'src/api/aead_cipher.dart';
-
part 'src/api/aead_parameters.dart';
-
part 'src/api/algorithm.dart';
-
part 'src/api/asymmetric_block_cipher.dart';
-
part 'src/api/asymmetric_key.dart';
-
part 'src/api/asymmetric_key_pair.dart';
part 'src/api/asymmetric_key_parameter.dart';
part 'src/api/block_cipher.dart';
part 'src/api/cipher_parameters.dart';
+part 'src/api/des_parameters.dart';
+part 'src/api/desede_parameters.dart';
part 'src/api/digest.dart';
part 'src/api/key_derivator.dart';
part 'src/api/key_generator.dart';
@@ -39,20 +37,17 @@
part 'src/api/parameters_with_random.dart';
part 'src/api/parameters_with_salt.dart';
part 'src/api/parameters_with_salt_configuration.dart';
+part 'src/api/pbe_parameters_generator.dart';
part 'src/api/private_key.dart';
part 'src/api/private_key_parameter.dart';
part 'src/api/public_key.dart';
part 'src/api/public_key_parameter.dart';
+part 'src/api/rc2_parameters.dart';
part 'src/api/registry_factory_exception.dart';
part 'src/api/secure_random.dart';
part 'src/api/signature.dart';
part 'src/api/signer.dart';
-part 'src/api/stream_cipher.dart';
part 'src/api/srp_client.dart';
part 'src/api/srp_server.dart';
-part 'src/api/aead_block_cipher.dart';
+part 'src/api/stream_cipher.dart';
part 'src/api/xof.dart';
-part 'src/api/rc2_parameters.dart';
-part 'src/api/des_parameters.dart';
-part 'src/api/desede_parameters.dart';
-part 'src/api/pbe_parameters_generator.dart';
diff --git a/lib/asn1/asn1_parser.dart b/lib/asn1/asn1_parser.dart
index ff860fc..e131335 100644
--- a/lib/asn1/asn1_parser.dart
+++ b/lib/asn1/asn1_parser.dart
@@ -57,7 +57,13 @@
var valueStartPosition =
ASN1Utils.calculateValueStartPosition(bytes!.sublist(_position));
- if (_position < length + valueStartPosition) {
+
+ var isIndefiniteLength = false;
+
+ if (length == -1) {
+ length = ASN1Utils.calculateIndefiniteLength(bytes!, _position) + 2;
+ isIndefiniteLength = true;
+ } else if (bytes!.length - _position > length + valueStartPosition) {
length = length + valueStartPosition;
} else {
length = bytes!.length - _position;
@@ -83,7 +89,8 @@
}
// Update the position
- _position = _position + obj.totalEncodedByteLength;
+ _position =
+ _position + obj.totalEncodedByteLength + (isIndefiniteLength ? 2 : 0);
return obj;
}
diff --git a/lib/asn1/asn1_utils.dart b/lib/asn1/asn1_utils.dart
index 13c1560..1cd8663 100644
--- a/lib/asn1/asn1_utils.dart
+++ b/lib/asn1/asn1_utils.dart
@@ -47,7 +47,7 @@
length = 0;
for (var i = 0; i < numLengthBytes; i++) {
length <<= 8;
- length |= (encodedBytes[valueStartPosition++] & 0xFF);
+ length |= encodedBytes[valueStartPosition++] & 0xFF;
}
return length;
}
@@ -119,13 +119,53 @@
return false;
}
+ ///
+ /// Calculates the indefinite length of the ASN1 object.
+ /// Throws an [ArgumentError] if the end of content octets is not found.
+ ///
+ static int calculateIndefiniteLength(Uint8List bytes, int startPosition) {
+ var currentPosition = startPosition;
+ var indefiniteLengthObjects = 0;
+ while (currentPosition < bytes.length - 1) {
+ if (bytes[currentPosition] == 0x00 &&
+ bytes[currentPosition + 1] == 0x00) {
+ indefiniteLengthObjects--;
+ if (indefiniteLengthObjects == 0) {
+ return currentPosition - startPosition;
+ }
+ currentPosition += 2;
+ } else {
+ final nextLength =
+ ASN1Utils.decodeLength(bytes.sublist(currentPosition));
+ final valueStartPosition = ASN1Utils.calculateValueStartPosition(
+ bytes.sublist(currentPosition));
+ if (nextLength == 0) {
+ throw ArgumentError('Invalid length of zero.');
+ }
+ if (valueStartPosition <= 0) {
+ throw ArgumentError(
+ 'Invalid value start position: $valueStartPosition');
+ }
+
+ if (nextLength == -1) {
+ indefiniteLengthObjects++;
+ currentPosition += valueStartPosition;
+ } else {
+ currentPosition += valueStartPosition + nextLength;
+ }
+ }
+ }
+
+ throw ArgumentError('End of content octets not found');
+ }
+
static Uint8List getBytesFromPEMString(String pem,
{bool checkHeader = true}) {
var lines = LineSplitter.split(pem)
.map((line) => line.trim())
.where((line) => line.isNotEmpty)
.toList();
- var base64;
+ String base64;
if (checkHeader) {
if (lines.length < 2 ||
!lines.first.startsWith('-----BEGIN') ||
@@ -145,8 +185,8 @@
{bool pkcs8 = false}) {
var asn1Parser = ASN1Parser(bytes);
var topLevelSeq = asn1Parser.nextObject() as ASN1Sequence;
- var curveName;
- var x;
+ late String curveName;
+ Uint8List x;
if (pkcs8) {
// Parse the PKCS8 format
var innerSeq = topLevelSeq.elements!.elementAt(1) as ASN1Sequence;
@@ -154,7 +194,7 @@
var b2Data = b2.objectIdentifierAsString;
var b2Curvedata = ObjectIdentifiers.getIdentifierByIdentifier(b2Data);
if (b2Curvedata != null) {
- curveName = b2Curvedata['readableName'];
+ curveName = b2Curvedata['readableName'] as String;
}
var octetString = topLevelSeq.elements!.elementAt(2) as ASN1OctetString;
@@ -178,7 +218,7 @@
var data = ObjectIdentifiers.getIdentifierByIdentifier(
curveNameOi.objectIdentifierAsString);
if (data != null) {
- curveName = data['readableName'];
+ curveName = data['readableName'] as String;
}
x = privateKeyAsOctetString.valueBytes!;
diff --git a/lib/asn1/object_identifiers_database.dart b/lib/asn1/object_identifiers_database.dart
index 7f2f43d..a36cdb7 100644
--- a/lib/asn1/object_identifiers_database.dart
+++ b/lib/asn1/object_identifiers_database.dart
@@ -3,6 +3,104 @@
///
const oi = [
{
+ 'identifierString': '1.2.860.3.15.1.1.1.1.4',
+ 'readableName':
+ 'UZDST 1092:2009 I digital signature parameters, UNICON.UZ paramset B',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 1, 1, 4]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.3.2.1.0',
+ 'readableName': 'UZDST 1106:2009 II test digest parameters',
+ 'identifier': [1, 2, 860, 3, 15, 1, 3, 2, 1, 0]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.2.1.1',
+ 'readableName':
+ 'UZDST 1092:2009 II signature parameters, UNICON.UZ paramset A',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 2, 1, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.2.1.2',
+ 'readableName':
+ 'UZDST 1092:2009 II signature parameters, UNICON.UZ paramset B',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 2, 1, 2]
+ },
+ {
+ 'identifierString': '1.2.860.3.16.1.1',
+ 'readableName': 'Identifikatsionniy Nomer Nalogoplatelshika',
+ 'identifier': [1, 2, 860, 3, 16, 1, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.16.1.2',
+ 'readableName': 'Personalniy Identifikatsionniy Nomer Fizicheskogo Litsa',
+ 'identifier': [1, 2, 860, 3, 16, 1, 2]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.1.1',
+ 'readableName': 'UZDST 1092:2009 I digital signature public key',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 1, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.2.1',
+ 'readableName': 'UZDST 1092:2009 II digital signature public key',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 2, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.1.2.2.2',
+ 'readableName':
+ 'UZDST 1092:2009 I/1106:2009 digital signature algorithm with message digest',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 1, 2, 2, 2]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.2.2.2.2',
+ 'readableName':
+ 'UZDST 1092:2009 II/1106:2009 digital signature algorithm with message digest',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 2, 2, 2, 2]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.1.1.1',
+ 'readableName':
+ 'UZDST 1092:2009 I digital signature parameters, SICNT paramset A',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 1, 1, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.1.1.2',
+ 'readableName':
+ 'UZDST 1092:2009 I digital signature parameters, SICNT paramset B',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 1, 1, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.1.1.1.3',
+ 'readableName':
+ 'UZDST 1092:2009 I digital signature parameters, UNICON.UZ paramset A',
+ 'identifier': [1, 2, 860, 3, 15, 1, 1, 1, 1, 3]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.3.2.1.1',
+ 'readableName': 'UZDST 1106:2009 II default digest parameters',
+ 'identifier': [1, 2, 860, 3, 15, 1, 3, 2, 1, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.2.1',
+ 'readableName': 'UZDST 1105:2009 symmetric cipher',
+ 'identifier': [1, 2, 860, 3, 15, 1, 2, 1]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.3.2',
+ 'readableName': 'UZDST 1106:2009 II digest',
+ 'identifier': [1, 2, 860, 3, 15, 1, 3, 2]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.4.2',
+ 'readableName': 'UZDST 1106:2009 II digest based HMAC',
+ 'identifier': [1, 2, 860, 3, 15, 1, 4, 2]
+ },
+ {
+ 'identifierString': '1.2.860.3.15.1.12.2.1',
+ 'readableName': 'PBE with UZDST 1106:2009 II and UZDST 1105:2009',
+ 'identifier': [1, 2, 860, 3, 15, 1, 12, 2, 1]
+ },
+ {
'identifierString': '1.2.840.113549.1.9.22.1',
'readableName': 'x509Certificate',
'identifier': [1, 2, 840, 113549, 1, 9, 22, 1]
@@ -278,6 +376,26 @@
'identifier': [1, 2, 840, 10045, 3, 1, 1]
},
{
+ 'identifierString': '1.3.101.110',
+ 'readableName': 'curveX25519',
+ 'identifier': [1, 3, 101, 110]
+ },
+ {
+ 'identifierString': '1.3.101.111',
+ 'readableName': 'curveX448',
+ 'identifier': [1, 3, 101, 111]
+ },
+ {
+ 'identifierString': '1.3.101.112',
+ 'readableName': 'curveEd25519',
+ 'identifier': [1, 3, 101, 112]
+ },
+ {
+ 'identifierString': '1.3.101.113',
+ 'readableName': 'curveEd448',
+ 'identifier': [1, 3, 101, 113]
+ },
+ {
'identifierString': '1.3.132.0.1',
'readableName': 'ansit163k1',
'identifier': [1, 3, 132, 0, 1]
@@ -588,6 +706,11 @@
'identifier': [1, 3, 132, 0, 34]
},
{
+ 'identifierString': '1.2.840.10045.3.1.7',
+ 'readableName': 'secp256r1',
+ 'identifier': [1, 2, 840, 10045, 3, 1, 7]
+ },
+ {
'identifierString': '1.3.132.0.10',
'readableName': 'secp256k1',
'identifier': [1, 3, 132, 0, 10]
diff --git a/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart b/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart
index 7e49fe2..afe1970 100644
--- a/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart
+++ b/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart
@@ -26,13 +26,13 @@
if (seq.elements == null || seq.elements!.length != 3) {
throw ArgumentError('');
}
- if (!(seq.elements!.elementAt(0) is ASN1Sequence)) {
+ if (seq.elements!.elementAt(0) is! ASN1Sequence) {
throw ArgumentError('Element at index 0 has to be ASN1Sequence');
}
- if (!(seq.elements!.elementAt(1) is ASN1Sequence)) {
+ if (seq.elements!.elementAt(1) is! ASN1Sequence) {
throw ArgumentError('Element at index 1 has to be ASN1Sequence');
}
- if (!(seq.elements!.elementAt(2) is ASN1BitString)) {
+ if (seq.elements!.elementAt(2) is! ASN1BitString) {
throw ArgumentError('Element at index 2 has to be ASN1BitString');
}
certificationRequestInfo = seq.elements!.elementAt(0);
diff --git a/lib/asn1/pkcs/pkcs10/asn1_certification_request_info.dart b/lib/asn1/pkcs/pkcs10/asn1_certification_request_info.dart
index 6ec6f45..ff7e966 100644
--- a/lib/asn1/pkcs/pkcs10/asn1_certification_request_info.dart
+++ b/lib/asn1/pkcs/pkcs10/asn1_certification_request_info.dart
@@ -36,7 +36,7 @@
if (seq.elements == null || seq.elements!.length != 3) {
throw ArgumentError('');
}
- if (!(seq.elements!.elementAt(0) is ASN1Integer)) {
+ if (seq.elements!.elementAt(0) is! ASN1Integer) {
throw ArgumentError('Element at index 0 has to be ASN1Integer');
}
version = seq.elements!.elementAt(0) as ASN1Integer;
diff --git a/lib/asn1/pkcs/pkcs10/asn1_subject_public_key_info.dart b/lib/asn1/pkcs/pkcs10/asn1_subject_public_key_info.dart
index fbebff5..4400022 100644
--- a/lib/asn1/pkcs/pkcs10/asn1_subject_public_key_info.dart
+++ b/lib/asn1/pkcs/pkcs10/asn1_subject_public_key_info.dart
@@ -23,10 +23,10 @@
if (seq.elements == null || seq.elements!.length != 2) {
throw ArgumentError('');
}
- if (!(seq.elements!.elementAt(0) is ASN1Sequence)) {
+ if (seq.elements!.elementAt(0) is! ASN1Sequence) {
throw ArgumentError('Element at index 0 has to be ASN1Sequence');
}
- if (!(seq.elements!.elementAt(1) is ASN1BitString)) {
+ if (seq.elements!.elementAt(1) is! ASN1BitString) {
throw ArgumentError('Element at index 1 has to be ASN1BitString');
}
algorithm = ASN1AlgorithmIdentifier.fromSequence(
diff --git a/lib/asn1/pkcs/pkcs12/asn1_authenticated_safe.dart b/lib/asn1/pkcs/pkcs12/asn1_authenticated_safe.dart
index 9e75dc5..7874bc0 100644
--- a/lib/asn1/pkcs/pkcs12/asn1_authenticated_safe.dart
+++ b/lib/asn1/pkcs/pkcs12/asn1_authenticated_safe.dart
@@ -16,11 +16,9 @@
ASN1AuthenticatedSafe.fromSequence(ASN1Sequence seq) {
info = [];
if (seq.elements != null) {
- seq.elements!.forEach(
- (element) {
- info.add(ASN1ContentInfo.fromSequence(element as ASN1Sequence));
- },
- );
+ for (var element in seq.elements!) {
+ info.add(ASN1ContentInfo.fromSequence(element as ASN1Sequence));
+ }
}
}
diff --git a/lib/asn1/pkcs/pkcs12/asn1_cert_bag.dart b/lib/asn1/pkcs/pkcs12/asn1_cert_bag.dart
index 22d7285..fef3c6b 100644
--- a/lib/asn1/pkcs/pkcs12/asn1_cert_bag.dart
+++ b/lib/asn1/pkcs/pkcs12/asn1_cert_bag.dart
@@ -30,19 +30,17 @@
///
/// Constructor to create the CertBag for a X509 Certificate.
///
- ASN1CertBag.forX509Certificate(ASN1OctetString certValue) {
+ ASN1CertBag.forX509Certificate(ASN1OctetString this.certValue) {
certId =
ASN1ObjectIdentifier.fromIdentifierString('1.2.840.113549.1.9.22.1');
- this.certValue = certValue;
}
///
/// Constructor to create the CertBag for a SDSI Certificate.
///
- ASN1CertBag.forSdsiCertificate(ASN1IA5String certValue) {
+ ASN1CertBag.forSdsiCertificate(ASN1IA5String this.certValue) {
certId =
ASN1ObjectIdentifier.fromIdentifierString('1.2.840.113549.1.9.22.2');
- this.certValue = certValue;
}
///
diff --git a/lib/asn1/pkcs/pkcs12/asn1_safe_contents.dart b/lib/asn1/pkcs/pkcs12/asn1_safe_contents.dart
index f626b8d..54aea59 100644
--- a/lib/asn1/pkcs/pkcs12/asn1_safe_contents.dart
+++ b/lib/asn1/pkcs/pkcs12/asn1_safe_contents.dart
@@ -1,4 +1,3 @@
-
import 'dart:typed_data';
import 'package:pointycastle/asn1.dart';
@@ -22,13 +21,13 @@
ASN1SafeContents.fromSequence(ASN1Sequence seq) {
safeBags = [];
if (seq.elements != null) {
- seq.elements!.forEach((element) {
+ for (var element in seq.elements!) {
if (element is ASN1SafeBag) {
safeBags.add(element);
} else if (element is ASN1Sequence) {
safeBags.add(ASN1SafeBag.fromSequence(element));
}
- });
+ }
}
}
diff --git a/lib/asn1/primitives/asn1_bit_string.dart b/lib/asn1/primitives/asn1_bit_string.dart
index 203fb43..f15e20e 100644
--- a/lib/asn1/primitives/asn1_bit_string.dart
+++ b/lib/asn1/primitives/asn1_bit_string.dart
@@ -37,7 +37,7 @@
///
/// Creates an [ASN1BitString] entity from the given [encodedBytes].
///
- ASN1BitString.fromBytes(Uint8List bytes) : super.fromBytes(bytes) {
+ ASN1BitString.fromBytes(Uint8List super.bytes) : super.fromBytes() {
if (ASN1Utils.isConstructed(encodedBytes!.elementAt(0))) {
elements = [];
var parser = ASN1Parser(valueBytes);
@@ -95,11 +95,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
}
@@ -111,9 +111,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
@@ -146,7 +146,7 @@
var parser = ASN1Parser(stringValues as Uint8List?);
var next = parser.nextObject();
var dump = next.dump(spaces: spaces + dumpIndent);
- sb.write('BIT STRING (${(bits.length)} bit)\n$dump');
+ sb.write('BIT STRING (${bits.length} bit)\n$dump');
} else {
var sb2 = StringBuffer();
for (var v in stringValues!) {
@@ -157,7 +157,7 @@
if (unusedbits != null) {
bits = bits.substring(0, bits.length - unusedbits!);
}
- sb.write('BIT STRING (${(bits.length)} bit) ');
+ sb.write('BIT STRING (${bits.length} bit) ');
sb.write(bits);
}
}
diff --git a/lib/asn1/primitives/asn1_bmp_string.dart b/lib/asn1/primitives/asn1_bmp_string.dart
index 0e4cb39..580d3c6 100644
--- a/lib/asn1/primitives/asn1_bmp_string.dart
+++ b/lib/asn1/primitives/asn1_bmp_string.dart
@@ -1,4 +1,3 @@
-import 'dart:convert';
import 'dart:typed_data';
import 'package:pointycastle/asn1/asn1_encoding_rule.dart';
@@ -45,13 +44,17 @@
}
stringValue = sb.toString();
} else {
- var sb = StringBuffer();
- for (var b in valueBytes!) {
- if (b != 0) {
- sb.write(ascii.decode([b]));
- }
+ var utf16CodeUnits = <int>[];
+
+ for (var i = 0; i < valueBytes!.length; i += 2) {
+ // Combine High-Byte and Low-Byte to create a UTF-16 code unit
+ var highByte = valueBytes![i];
+ var lowByte = valueBytes![i + 1];
+ utf16CodeUnits.add((highByte << 8) | lowByte);
}
- stringValue = sb.toString();
+
+ // Decode UTF-16 code units into a Dart String
+ stringValue = String.fromCharCodes(utf16CodeUnits);
}
}
@@ -74,10 +77,11 @@
switch (encodingRule) {
case ASN1EncodingRule.ENCODING_DER:
case ASN1EncodingRule.ENCODING_BER_LONG_LENGTH_FORM:
+ // Kodierung in UTF-16-Big-Endian (UCS-2)
var l = <int>[];
- for (var c in stringValue!.codeUnits) {
- l.add(0);
- l.add(c);
+ for (var codeUnit in stringValue!.codeUnits) {
+ l.add((codeUnit >> 8) & 0xFF); // High-Byte
+ l.add(codeUnit & 0xFF); // Low-Byte
}
valueBytes = Uint8List.fromList(l);
break;
@@ -92,11 +96,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
case ASN1EncodingRule.ENCODING_BER_PADDED:
throw UnsupportedAsn1EncodingRuleException(encodingRule);
@@ -110,9 +114,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
diff --git a/lib/asn1/primitives/asn1_boolean.dart b/lib/asn1/primitives/asn1_boolean.dart
index 3b2f4f0..6eb0056 100644
--- a/lib/asn1/primitives/asn1_boolean.dart
+++ b/lib/asn1/primitives/asn1_boolean.dart
@@ -29,8 +29,7 @@
///
/// Creates an [ASN1Boolean] entity from the given [encodedBytes].
///
- ASN1Boolean.fromBytes(Uint8List encodedBytes)
- : super.fromBytes(encodedBytes) {
+ ASN1Boolean.fromBytes(Uint8List super.encodedBytes) : super.fromBytes() {
boolValue = (valueBytes![0] == BOOLEAN_TRUE_VALUE);
}
diff --git a/lib/asn1/primitives/asn1_enumerated.dart b/lib/asn1/primitives/asn1_enumerated.dart
index ca19dd7..d8fc673 100644
--- a/lib/asn1/primitives/asn1_enumerated.dart
+++ b/lib/asn1/primitives/asn1_enumerated.dart
@@ -1,5 +1,3 @@
-import 'dart:typed_data';
-
import 'package:pointycastle/asn1/asn1_tags.dart';
import 'package:pointycastle/asn1/primitives/asn1_integer.dart';
@@ -16,6 +14,5 @@
///
/// Creates an [ASN1Enumerated] entity from the given [encodedBytes].
///
- ASN1Enumerated.fromBytes(Uint8List encodedBytes)
- : super.fromBytes(encodedBytes);
+ ASN1Enumerated.fromBytes(super.encodedBytes) : super.fromBytes();
}
diff --git a/lib/asn1/primitives/asn1_generalized_time.dart b/lib/asn1/primitives/asn1_generalized_time.dart
index 6685d0a..58f75be 100644
--- a/lib/asn1/primitives/asn1_generalized_time.dart
+++ b/lib/asn1/primitives/asn1_generalized_time.dart
@@ -19,7 +19,7 @@
///
/// Creates an [ASN1GeneralizedTime] entity from the given [encodedBytes].
///
- ASN1GeneralizedTime.fromBytes(Uint8List bytes) : super.fromBytes(bytes) {
+ ASN1GeneralizedTime.fromBytes(Uint8List super.bytes) : super.fromBytes() {
var octets = valueBytes!;
var stringValue = ascii.decode(octets);
var year = stringValue.substring(0, 4);
diff --git a/lib/asn1/primitives/asn1_ia5_string.dart b/lib/asn1/primitives/asn1_ia5_string.dart
index 0a514b3..7adcff6 100644
--- a/lib/asn1/primitives/asn1_ia5_string.dart
+++ b/lib/asn1/primitives/asn1_ia5_string.dart
@@ -83,11 +83,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
case ASN1EncodingRule.ENCODING_BER_PADDED:
throw UnsupportedAsn1EncodingRuleException(encodingRule);
@@ -101,9 +101,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
diff --git a/lib/asn1/primitives/asn1_integer.dart b/lib/asn1/primitives/asn1_integer.dart
index c30f369..2e936eb 100644
--- a/lib/asn1/primitives/asn1_integer.dart
+++ b/lib/asn1/primitives/asn1_integer.dart
@@ -27,8 +27,7 @@
///
/// Creates an [ASN1Integer] entity from the given [encodedBytes].
///
- ASN1Integer.fromBytes(Uint8List encodedBytes)
- : super.fromBytes(encodedBytes) {
+ ASN1Integer.fromBytes(Uint8List super.encodedBytes) : super.fromBytes() {
integer = decodeBigInt(valueBytes!);
}
diff --git a/lib/asn1/primitives/asn1_null.dart b/lib/asn1/primitives/asn1_null.dart
index f2e304b..b626c40 100644
--- a/lib/asn1/primitives/asn1_null.dart
+++ b/lib/asn1/primitives/asn1_null.dart
@@ -17,7 +17,7 @@
///
/// Creates an [ASN1Null] entity from the given [encodedBytes].
///
- ASN1Null.fromBytes(Uint8List encodedBytes) : super.fromBytes(encodedBytes);
+ ASN1Null.fromBytes(Uint8List super.encodedBytes) : super.fromBytes();
///
/// Encode the [ASN1Null] to the byte representation.
diff --git a/lib/asn1/primitives/asn1_object_identifier.dart b/lib/asn1/primitives/asn1_object_identifier.dart
index 6967ad4..76b9ecd 100644
--- a/lib/asn1/primitives/asn1_object_identifier.dart
+++ b/lib/asn1/primitives/asn1_object_identifier.dart
@@ -35,14 +35,14 @@
///
/// Creates an [ASN1ObjectIdentifier] entity from the given [encodedBytes].
///
- ASN1ObjectIdentifier.fromBytes(Uint8List encodedBytes)
- : super.fromBytes(encodedBytes) {
+ ASN1ObjectIdentifier.fromBytes(Uint8List super.encodedBytes)
+ : super.fromBytes() {
var value = 0;
var first = true;
BigInt? bigValue;
var list = <int>[];
var sb = StringBuffer();
- valueBytes!.forEach((element) {
+ for (var element in valueBytes!) {
var b = element & 0xff;
if (value < 0x80000000000000) {
value = value * 128 + (b & 0x7f);
@@ -66,15 +66,15 @@
}
} else {
bigValue ??= BigInt.from(value);
- bigValue = bigValue! << (7);
- bigValue = bigValue! | BigInt.from(b & 0x7f);
+ bigValue = bigValue << (7);
+ bigValue = bigValue | BigInt.from(b & 0x7f);
if ((b & 0x80) == 0) {
sb.write('.$bigValue');
bigValue = null;
value = 0;
}
}
- });
+ }
objectIdentifierAsString = sb.toString();
objectIdentifier = Uint8List.fromList(list);
var identifier =
diff --git a/lib/asn1/primitives/asn1_octet_string.dart b/lib/asn1/primitives/asn1_octet_string.dart
index 5c1bc94..d518655 100644
--- a/lib/asn1/primitives/asn1_octet_string.dart
+++ b/lib/asn1/primitives/asn1_octet_string.dart
@@ -80,11 +80,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
case ASN1EncodingRule.ENCODING_BER_PADDED:
throw UnsupportedAsn1EncodingRuleException(encodingRule);
@@ -97,9 +97,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
diff --git a/lib/asn1/primitives/asn1_printable_string.dart b/lib/asn1/primitives/asn1_printable_string.dart
index a6c7cda..f12c897 100644
--- a/lib/asn1/primitives/asn1_printable_string.dart
+++ b/lib/asn1/primitives/asn1_printable_string.dart
@@ -83,11 +83,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
case ASN1EncodingRule.ENCODING_BER_PADDED:
throw UnsupportedAsn1EncodingRuleException(encodingRule);
@@ -101,9 +101,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
diff --git a/lib/asn1/primitives/asn1_sequence.dart b/lib/asn1/primitives/asn1_sequence.dart
index 989b339..325181a 100644
--- a/lib/asn1/primitives/asn1_sequence.dart
+++ b/lib/asn1/primitives/asn1_sequence.dart
@@ -20,8 +20,7 @@
///
/// Creates an [ASN1Sequence] entity from the given [encodedBytes].
///
- ASN1Sequence.fromBytes(Uint8List encodedBytes)
- : super.fromBytes(encodedBytes) {
+ ASN1Sequence.fromBytes(Uint8List super.encodedBytes) : super.fromBytes() {
elements = [];
var parser = ASN1Parser(valueBytes);
while (parser.hasNext()) {
@@ -51,11 +50,11 @@
valueByteLength = _childLength();
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
}
return super.encode();
}
@@ -65,9 +64,9 @@
///
int _childLength() {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
return l;
}
diff --git a/lib/asn1/primitives/asn1_set.dart b/lib/asn1/primitives/asn1_set.dart
index ab9f2c8..895c089 100644
--- a/lib/asn1/primitives/asn1_set.dart
+++ b/lib/asn1/primitives/asn1_set.dart
@@ -20,7 +20,7 @@
///
/// Creates an [ASN1Set] entity from the given [encodedBytes].
///
- ASN1Set.fromBytes(Uint8List encodedBytes) : super.fromBytes(encodedBytes) {
+ ASN1Set.fromBytes(Uint8List super.encodedBytes) : super.fromBytes() {
elements = [];
var parser = ASN1Parser(valueBytes);
while (parser.hasNext()) {
@@ -50,11 +50,11 @@
valueByteLength = _childLength();
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
}
return super.encode();
}
@@ -64,9 +64,9 @@
///
int _childLength() {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
return l;
}
diff --git a/lib/asn1/primitives/asn1_teletext_string.dart b/lib/asn1/primitives/asn1_teletext_string.dart
index 95aca61..f4a6a34 100644
--- a/lib/asn1/primitives/asn1_teletext_string.dart
+++ b/lib/asn1/primitives/asn1_teletext_string.dart
@@ -83,11 +83,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
case ASN1EncodingRule.ENCODING_BER_PADDED:
throw UnsupportedAsn1EncodingRuleException(encodingRule);
@@ -101,9 +101,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
diff --git a/lib/asn1/primitives/asn1_utc_time.dart b/lib/asn1/primitives/asn1_utc_time.dart
index a6a0b93..e160832 100644
--- a/lib/asn1/primitives/asn1_utc_time.dart
+++ b/lib/asn1/primitives/asn1_utc_time.dart
@@ -28,8 +28,7 @@
///
/// Creates an [ASN1UtcTime] entity from the given [encodedBytes].
///
- ASN1UtcTime.fromBytes(Uint8List encodedBytes)
- : super.fromBytes(encodedBytes) {
+ ASN1UtcTime.fromBytes(Uint8List super.encodedBytes) : super.fromBytes() {
var stringValue = ascii.decode(valueBytes!);
var formatedStringValue = _format(stringValue);
time = DateTime.parse(formatedStringValue);
@@ -76,11 +75,11 @@
String _format(String stringValue) {
var y2 = int.parse(stringValue.substring(0, 2));
if (y2 > 75) {
- stringValue = '19' + stringValue;
+ stringValue = '19$stringValue';
} else {
- stringValue = '20' + stringValue;
+ stringValue = '20$stringValue';
}
- return stringValue.substring(0, 8) + 'T' + stringValue.substring(8);
+ return '${stringValue.substring(0, 8)}T${stringValue.substring(8)}';
}
@override
diff --git a/lib/asn1/primitives/asn1_utf8_string.dart b/lib/asn1/primitives/asn1_utf8_string.dart
index d382bbe..8bb6b91 100644
--- a/lib/asn1/primitives/asn1_utf8_string.dart
+++ b/lib/asn1/primitives/asn1_utf8_string.dart
@@ -83,11 +83,11 @@
ASN1EncodingRule.ENCODING_BER_CONSTRUCTED_INDEFINITE_LENGTH);
valueBytes = Uint8List(valueByteLength!);
var i = 0;
- elements!.forEach((obj) {
+ for (var obj in elements!) {
var b = obj.encode();
valueBytes!.setRange(i, i + b.length, b);
i += b.length;
- });
+ }
break;
case ASN1EncodingRule.ENCODING_BER_PADDED:
throw UnsupportedAsn1EncodingRuleException(encodingRule);
@@ -101,9 +101,9 @@
///
int _childLength({bool isIndefinite = false}) {
var l = 0;
- elements!.forEach((ASN1Object obj) {
+ for (var obj in elements!) {
l += obj.encode().length;
- });
+ }
if (isIndefinite) {
return l + 2;
}
diff --git a/lib/asn1/x501/asn1_attribute_type_and_value.dart b/lib/asn1/x501/asn1_attribute_type_and_value.dart
index d56b4bb..7d7631c 100644
--- a/lib/asn1/x501/asn1_attribute_type_and_value.dart
+++ b/lib/asn1/x501/asn1_attribute_type_and_value.dart
@@ -28,7 +28,7 @@
if (seq.elements == null || seq.elements!.length != 2) {
throw ArgumentError('');
}
- if (!(seq.elements!.elementAt(0) is ASN1ObjectIdentifier)) {
+ if (seq.elements!.elementAt(0) is! ASN1ObjectIdentifier) {
throw ArgumentError('Element at index 0 has to be ASN1ObjectIdentifier');
}
if (seq.elements!.elementAt(1) is ASN1TeletextString ||
diff --git a/lib/asymmetric/api.dart b/lib/asymmetric/api.dart
index c934a08..8805826 100644
--- a/lib/asymmetric/api.dart
+++ b/lib/asymmetric/api.dart
@@ -33,13 +33,9 @@
/// The optional parameter is retained for backward compatibility, but it
/// does not need to be provided.
- RSAPrivateKey(
- BigInt modulus,
- BigInt privateExponent,
- this.p,
- this.q,
+ RSAPrivateKey(BigInt modulus, BigInt privateExponent, this.p, this.q,
[@Deprecated('Public exponent is calculated from the other values')
- BigInt? publicExponent])
+ BigInt? publicExponent])
: super(modulus, privateExponent) {
// Check RSA relationship between p, q and modulus hold true.
@@ -49,8 +45,7 @@
// Calculate the correct RSA public exponent
- _pubExp =
- privateExponent.modInverse(((p! - BigInt.one) * (q! - BigInt.one)));
+ _pubExp = privateExponent.modInverse((p! - BigInt.one) * (q! - BigInt.one));
// If explicitly provided, the public exponent value must be correct.
if (publicExponent != null && publicExponent != _pubExp) {
@@ -74,7 +69,7 @@
BigInt? get pubExponent => publicExponent;
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is RSAPrivateKey) {
return other.privateExponent == privateExponent &&
other.modulus == modulus;
@@ -89,7 +84,7 @@
/// Public keys in RSA
class RSAPublicKey extends RSAAsymmetricKey implements PublicKey {
/// Create an RSA public key for the given parameters.
- RSAPublicKey(BigInt modulus, BigInt exponent) : super(modulus, exponent);
+ RSAPublicKey(BigInt super.modulus, BigInt super.exponent);
/// Get public exponent [e]
@Deprecated('Use get publicExponent')
@@ -99,7 +94,7 @@
BigInt? get publicExponent => exponent;
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is RSAPublicKey) {
return (other.modulus == modulus) &&
(other.publicExponent == publicExponent);
@@ -120,7 +115,7 @@
@override
String toString() => bytes.toString();
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is! RSASignature) return false;
if (other.bytes.length != bytes.length) return false;
@@ -146,7 +141,7 @@
String toString() => bytes.toString();
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is! PSSSignature) return false;
if (other.bytes.length != bytes.length) return false;
diff --git a/lib/asymmetric/ec_elgamal.dart b/lib/asymmetric/ec_elgamal.dart
index 0b28bed..7d9f36c 100644
--- a/lib/asymmetric/ec_elgamal.dart
+++ b/lib/asymmetric/ec_elgamal.dart
@@ -48,7 +48,7 @@
_random = _newSecureRandom();
}
var k = akparams.key as ECAsymmetricKey;
- if (!(k is ECPublicKey)) {
+ if (k is! ECPublicKey) {
throw ArgumentError('ECPublicKey is required for encryption.');
}
_key = k;
@@ -72,7 +72,7 @@
void init(CipherParameters params) {
var akparams = params as AsymmetricKeyParameter<AsymmetricKey>;
var k = akparams.key as ECAsymmetricKey;
- if (!(k is ECPrivateKey)) {
+ if (k is! ECPrivateKey) {
throw ArgumentError('ECPrivateKey is required for decryption.');
}
_key = k;
diff --git a/lib/asymmetric/oaep.dart b/lib/asymmetric/oaep.dart
index e101e80..d8cfaf8 100644
--- a/lib/asymmetric/oaep.dart
+++ b/lib/asymmetric/oaep.dart
@@ -7,6 +7,7 @@
import 'package:pointycastle/api.dart';
import 'package:pointycastle/digests/sha1.dart';
import 'package:pointycastle/digests/sha256.dart';
+import 'package:pointycastle/digests/sha512.dart';
import 'package:pointycastle/random/fortuna_random.dart';
import 'package:pointycastle/src/impl/base_asymmetric_block_cipher.dart';
import 'package:pointycastle/src/platform_check/platform_check.dart';
@@ -81,6 +82,10 @@
[Uint8List? encodingParams]) =>
OAEPEncoding._(() => SHA256Digest(), engine, encodingParams);
+ factory OAEPEncoding.withSHA512(AsymmetricBlockCipher engine,
+ [Uint8List? encodingParams]) =>
+ OAEPEncoding._(() => SHA512Digest(), engine, encodingParams);
+
factory OAEPEncoding.withCustomDigest(
DigestFactory digestFactory, AsymmetricBlockCipher engine,
[Uint8List? encodingParams]) =>
@@ -379,7 +384,7 @@
// 5.2 Check length
- var wrongData = (block.length < (2 * defHash.length) + 1);
+ var wrongData = block.length < (2 * defHash.length) + 1;
// 5.4 Calculate _seedMask_ = MGF(maskedDB, hLen)
//
diff --git a/lib/asymmetric/pkcs1.dart b/lib/asymmetric/pkcs1.dart
index 05b3933..e0834c5 100644
--- a/lib/asymmetric/pkcs1.dart
+++ b/lib/asymmetric/pkcs1.dart
@@ -57,7 +57,7 @@
_engine.init(forEncryption, akparams);
- _forPrivateKey = (akparams.key is PrivateKey);
+ _forPrivateKey = akparams.key is PrivateKey;
_forEncryption = forEncryption;
}
@@ -100,7 +100,7 @@
}
var block = Uint8List(_engine.inputBlockSize);
- var padLength = (block.length - inpLen - 1);
+ var padLength = block.length - inpLen - 1;
if (_forPrivateKey) {
block[0] = 0x01; // type code 1
@@ -166,7 +166,7 @@
throw ArgumentError('No data found in block, only padding');
}
- var rlen = (block.length - start);
+ var rlen = block.length - start;
out.setRange(outOff, outOff + rlen, block.sublist(start));
return rlen;
}
diff --git a/lib/asymmetric/rsa.dart b/lib/asymmetric/rsa.dart
index 2e5cd94..e01ece1 100644
--- a/lib/asymmetric/rsa.dart
+++ b/lib/asymmetric/rsa.dart
@@ -63,9 +63,9 @@
_key = params.key;
if (_key is RSAPrivateKey) {
- var privKey = (_key as RSAPrivateKey);
- var pSub1 = (privKey.p! - BigInt.one);
- var qSub1 = (privKey.q! - BigInt.one);
+ var privKey = _key as RSAPrivateKey;
+ var pSub1 = privKey.p! - BigInt.one;
+ var qSub1 = privKey.q! - BigInt.one;
_dP = privKey.privateExponent!.remainder(pSub1);
_dQ = privKey.privateExponent!.remainder(qSub1);
_qInv = privKey.q!.modInverse(privKey.p!);
@@ -116,20 +116,20 @@
if (_forEncryption) {
if ((output[0] == 0) && (output.length > outputBlockSize)) {
// have ended up with an extra zero byte, copy down.
- var len = (output.length - 1);
+ var len = output.length - 1;
out.setRange(outOff, outOff + len, output.sublist(1));
return len;
}
if (output.length < outputBlockSize) {
// have ended up with less bytes than normal, lengthen
var len = outputBlockSize;
- out.setRange((outOff + len - output.length), (outOff + len), output);
+ out.setRange(outOff + len - output.length, outOff + len, output);
return len;
}
} else {
if (output[0] == 0) {
// have ended up with an extra zero byte, copy down.
- var len = (output.length - 1);
+ var len = output.length - 1;
out.setRange(outOff, outOff + len, output.sublist(1));
return len;
}
@@ -141,12 +141,12 @@
BigInt _processBigInteger(BigInt input) {
if (_key is RSAPrivateKey) {
- var privKey = (_key as RSAPrivateKey);
+ var privKey = _key as RSAPrivateKey;
BigInt mP, mQ, h, m;
- mP = (input.remainder(privKey.p!)).modPow(_dP, privKey.p!);
+ mP = input.remainder(privKey.p!).modPow(_dP, privKey.p!);
- mQ = (input.remainder(privKey.q!)).modPow(_dQ, privKey.q!);
+ mQ = input.remainder(privKey.q!).modPow(_dQ, privKey.q!);
h = mP - mQ;
h = h * _qInv;
diff --git a/lib/block/aes.dart b/lib/block/aes.dart
index dda9bc1..5a10634 100644
--- a/lib/block/aes.dart
+++ b/lib/block/aes.dart
@@ -15,12 +15,12 @@
StaticFactoryConfig(BlockCipher, 'AES', () => AESEngine());
int _ROUNDS = 0;
- List<List<int>>? _WorkingKey;
+ late List<List<int>> _WorkingKey;
bool _forEncryption = false;
List<int> _s = List.empty();
- final _S = [
+ static const _S = [
99,
124,
119,
@@ -279,7 +279,7 @@
22,
];
- final _Si = [
+ static const _Si = [
82,
9,
106,
@@ -538,7 +538,7 @@
125,
];
- final _rcon = [
+ static const _rcon = [
0x01,
0x02,
0x04,
@@ -571,7 +571,7 @@
0x91
];
- final _T0 = [
+ static const _T0 = [
0xa56363c6,
0x847c7cf8,
0x997777ee,
@@ -830,7 +830,7 @@
0x3a16162c
];
- final _Tinv0 = [
+ static const _Tinv0 = [
0x50a7f451,
0x5365417e,
0xc3a4171a,
@@ -1091,20 +1091,20 @@
int _shift(int r, int shift) => rotr32(r, shift);
- final int _m1 = 0x80808080;
- final int _m2 = 0x7f7f7f7f;
- final int _m3 = 0x0000001b;
- final int _m4 = 0xC0C0C0C0;
- final int _m5 = 0x3f3f3f3f;
+ static const int _m1 = 0x80808080;
+ static const int _m2 = 0x7f7f7f7f;
+ static const int _m3 = 0x0000001b;
+ static const int _m4 = 0xC0C0C0C0;
+ static const int _m5 = 0x3f3f3f3f;
int _fFmulX(int x) {
- var lsr = shiftr32((x & _m1), 7);
- return (((x & _m2) << 1) ^ lsr * _m3);
+ var lsr = shiftr32(x & _m1, 7);
+ return ((x & _m2) << 1) ^ lsr * _m3;
}
int _fFmulX2(int x) {
- var t0 = shiftl32((x & _m5), 2); // int t0 = (x & m5) << 2;
- var t1 = (x & _m4);
+ var t0 = shiftl32(x & _m5, 2); // int t0 = (x & m5) << 2;
+ var t1 = x & _m4;
t1 ^= shiftr32(t1, 1);
return t0 ^ shiftr32(t1, 2) ^ shiftr32(t1, 5);
}
@@ -1127,10 +1127,10 @@
}
int _subWord(int x) {
- return (_S[x & 255] & 255 |
+ return _S[x & 255] & 255 |
((_S[(x >> 8) & 255] & 255) << 8) |
((_S[(x >> 16) & 255] & 255) << 16) |
- _S[(x >> 24) & 255] << 24);
+ _S[(x >> 24) & 255] << 24;
}
static const _BLOCK_SIZE = 16;
@@ -1157,7 +1157,7 @@
}
}
- List<List<int>>? generateWorkingKey(bool forEncryption, KeyParameter params) {
+ List<List<int>> generateWorkingKey(bool forEncryption, KeyParameter params) {
var key = params.key;
var keyLen = key.length;
if (keyLen < 16 || keyLen > 32 || (keyLen & 7) != 0) {
@@ -1209,7 +1209,7 @@
var col4 = unpack32(key, 16, Endian.little);
var col5 = unpack32(key, 20, Endian.little);
- var i = 1, rcon = 1, colx;
+ int i = 1, rcon = 1, colx;
for (;;) {
W[i][0] = col4;
W[i][1] = col5;
@@ -1270,7 +1270,7 @@
var col7 = unpack32(key, 28, Endian.little);
W[1][3] = col7;
- var i = 2, rcon = 1, colx;
+ int i = 2, rcon = 1, colx;
for (;;) {
colx = _subWord(_shift(col7, 8)) ^ rcon;
rcon <<= 1;
@@ -1321,10 +1321,6 @@
@override
int processBlock(Uint8List inp, int inpOff, Uint8List out, int outOff) {
- if (_WorkingKey == null) {
- throw StateError('AES engine not initialised');
- }
-
if ((inpOff + (32 / 2)) > inp.lengthInBytes) {
throw ArgumentError('Input buffer too short');
}
@@ -1342,7 +1338,8 @@
return _BLOCK_SIZE;
}
- void _encryptBlock(input, inOff, Uint8List out, int outOff, KW) {
+ void _encryptBlock(
+ input, int inOff, Uint8List out, int outOff, List<List<int>> KW) {
var C0 = unpack32(input, inOff + 0, Endian.little);
var C1 = unpack32(input, inOff + 4, Endian.little);
var C2 = unpack32(input, inOff + 8, Endian.little);
@@ -1352,7 +1349,7 @@
var t1 = C1 ^ KW[0][1];
var t2 = C2 ^ KW[0][2];
- var r = 1, r0, r1, r2, r3 = C3 ^ KW[0][3];
+ int r = 1, r0, r1, r2, r3 = C3 ^ KW[0][3];
while (r < _ROUNDS - 1) {
r0 = _T0[t0 & 255] ^
@@ -1447,7 +1444,8 @@
pack32(C3, out, outOff + 12, Endian.little);
}
- void _decryptBlock(input, inOff, Uint8List out, int outOff, KW) {
+ void _decryptBlock(
+ input, int inOff, Uint8List out, int outOff, List<List<int>> KW) {
var C0 = unpack32(input, inOff + 0, Endian.little);
var C1 = unpack32(input, inOff + 4, Endian.little);
var C2 = unpack32(input, inOff + 8, Endian.little);
@@ -1457,7 +1455,7 @@
var t1 = C1 ^ KW[_ROUNDS][1];
var t2 = C2 ^ KW[_ROUNDS][2];
- var r = _ROUNDS - 1, r0, r1, r2, r3 = C3 ^ KW[_ROUNDS][3];
+ int r = _ROUNDS - 1, r0, r1, r2, r3 = C3 ^ KW[_ROUNDS][3];
while (r > 1) {
r0 = _Tinv0[t0 & 255] ^
_shift(_Tinv0[(r3 >> 8) & 255], 24) ^
diff --git a/lib/block/aes_fast.dart b/lib/block/aes_fast.dart
index 371d5d4..d514187 100644
--- a/lib/block/aes_fast.dart
+++ b/lib/block/aes_fast.dart
@@ -17,8 +17,7 @@
/// deprecated: Unfortunately this class is has a few side channel issues.
/// In an environment where encryption/decryption may be closely observed it
/// should not be used.
-///
-@deprecated
+@Deprecated('Has side-channel issues.')
class AESFastEngine extends BaseBlockCipher {
static const _BLOCK_SIZE = 16;
@@ -56,8 +55,8 @@
6; // This is not always true for the generalized Rijndael that allows larger block sizes
_workingKey = List.generate(
_rounds + 1,
- (int i) =>
- List<int>.filled(4, 0, growable: false)); // 4 words in a block
+ (int i) =>
+ List<int>.filled(4, 0, growable: false)); // 4 words in a block
// Copy the key into the round key array.
var keyView = ByteData.view(
@@ -131,92 +130,92 @@
r = 1;
while (r < _rounds - 1) {
r0 = _t0[_c0 & 255] ^
- _t1[(_c1 >> 8) & 255] ^
- _t2[(_c2 >> 16) & 255] ^
- _t3[(_c3 >> 24) & 255] ^
- kw[r][0]!.toInt();
+ _t1[(_c1 >> 8) & 255] ^
+ _t2[(_c2 >> 16) & 255] ^
+ _t3[(_c3 >> 24) & 255] ^
+ kw[r][0]!.toInt();
r1 = _t0[_c1 & 255] ^
- _t1[(_c2 >> 8) & 255] ^
- _t2[(_c3 >> 16) & 255] ^
- _t3[(_c0 >> 24) & 255] ^
- kw[r][1]!.toInt();
+ _t1[(_c2 >> 8) & 255] ^
+ _t2[(_c3 >> 16) & 255] ^
+ _t3[(_c0 >> 24) & 255] ^
+ kw[r][1]!.toInt();
r2 = _t0[_c2 & 255] ^
- _t1[(_c3 >> 8) & 255] ^
- _t2[(_c0 >> 16) & 255] ^
- _t3[(_c1 >> 24) & 255] ^
- kw[r][2]!.toInt();
+ _t1[(_c3 >> 8) & 255] ^
+ _t2[(_c0 >> 16) & 255] ^
+ _t3[(_c1 >> 24) & 255] ^
+ kw[r][2]!.toInt();
r3 = _t0[_c3 & 255] ^
- _t1[(_c0 >> 8) & 255] ^
- _t2[(_c1 >> 16) & 255] ^
- _t3[(_c2 >> 24) & 255] ^
- kw[r][3]!.toInt();
+ _t1[(_c0 >> 8) & 255] ^
+ _t2[(_c1 >> 16) & 255] ^
+ _t3[(_c2 >> 24) & 255] ^
+ kw[r][3]!.toInt();
r++;
_c0 = _t0[r0 & 255] ^
- _t1[(r1 >> 8) & 255] ^
- _t2[(r2 >> 16) & 255] ^
- _t3[(r3 >> 24) & 255] ^
- kw[r][0]!.toInt();
+ _t1[(r1 >> 8) & 255] ^
+ _t2[(r2 >> 16) & 255] ^
+ _t3[(r3 >> 24) & 255] ^
+ kw[r][0]!.toInt();
_c1 = _t0[r1 & 255] ^
- _t1[(r2 >> 8) & 255] ^
- _t2[(r3 >> 16) & 255] ^
- _t3[(r0 >> 24) & 255] ^
- kw[r][1]!.toInt();
+ _t1[(r2 >> 8) & 255] ^
+ _t2[(r3 >> 16) & 255] ^
+ _t3[(r0 >> 24) & 255] ^
+ kw[r][1]!.toInt();
_c2 = _t0[r2 & 255] ^
- _t1[(r3 >> 8) & 255] ^
- _t2[(r0 >> 16) & 255] ^
- _t3[(r1 >> 24) & 255] ^
- kw[r][2]!.toInt();
+ _t1[(r3 >> 8) & 255] ^
+ _t2[(r0 >> 16) & 255] ^
+ _t3[(r1 >> 24) & 255] ^
+ kw[r][2]!.toInt();
_c3 = _t0[r3 & 255] ^
- _t1[(r0 >> 8) & 255] ^
- _t2[(r1 >> 16) & 255] ^
- _t3[(r2 >> 24) & 255] ^
- kw[r][3]!.toInt();
+ _t1[(r0 >> 8) & 255] ^
+ _t2[(r1 >> 16) & 255] ^
+ _t3[(r2 >> 24) & 255] ^
+ kw[r][3]!.toInt();
r++;
}
r0 = _t0[_c0 & 255] ^
- _t1[(_c1 >> 8) & 255] ^
- _t2[(_c2 >> 16) & 255] ^
- _t3[(_c3 >> 24) & 255] ^
- kw[r][0]!.toInt();
+ _t1[(_c1 >> 8) & 255] ^
+ _t2[(_c2 >> 16) & 255] ^
+ _t3[(_c3 >> 24) & 255] ^
+ kw[r][0]!.toInt();
r1 = _t0[_c1 & 255] ^
- _t1[(_c2 >> 8) & 255] ^
- _t2[(_c3 >> 16) & 255] ^
- _t3[(_c0 >> 24) & 255] ^
- kw[r][1]!.toInt();
+ _t1[(_c2 >> 8) & 255] ^
+ _t2[(_c3 >> 16) & 255] ^
+ _t3[(_c0 >> 24) & 255] ^
+ kw[r][1]!.toInt();
r2 = _t0[_c2 & 255] ^
- _t1[(_c3 >> 8) & 255] ^
- _t2[(_c0 >> 16) & 255] ^
- _t3[(_c1 >> 24) & 255] ^
- kw[r][2]!.toInt();
+ _t1[(_c3 >> 8) & 255] ^
+ _t2[(_c0 >> 16) & 255] ^
+ _t3[(_c1 >> 24) & 255] ^
+ kw[r][2]!.toInt();
r3 = _t0[_c3 & 255] ^
- _t1[(_c0 >> 8) & 255] ^
- _t2[(_c1 >> 16) & 255] ^
- _t3[(_c2 >> 24) & 255] ^
- kw[r][3]!.toInt();
+ _t1[(_c0 >> 8) & 255] ^
+ _t2[(_c1 >> 16) & 255] ^
+ _t3[(_c2 >> 24) & 255] ^
+ kw[r][3]!.toInt();
r++;
// the final round's table is a simple function of S so we don't use a whole other four tables for it
_c0 = (_s[r0 & 255] & 255) ^
- ((_s[(r1 >> 8) & 255] & 255) << 8) ^
- ((_s[(r2 >> 16) & 255] & 255) << 16) ^
- (_s[(r3 >> 24) & 255] << 24) ^
- kw[r][0]!.toInt();
+ ((_s[(r1 >> 8) & 255] & 255) << 8) ^
+ ((_s[(r2 >> 16) & 255] & 255) << 16) ^
+ (_s[(r3 >> 24) & 255] << 24) ^
+ kw[r][0]!.toInt();
_c1 = (_s[r1 & 255] & 255) ^
- ((_s[(r2 >> 8) & 255] & 255) << 8) ^
- ((_s[(r3 >> 16) & 255] & 255) << 16) ^
- (_s[(r0 >> 24) & 255] << 24) ^
- kw[r][1]!.toInt();
+ ((_s[(r2 >> 8) & 255] & 255) << 8) ^
+ ((_s[(r3 >> 16) & 255] & 255) << 16) ^
+ (_s[(r0 >> 24) & 255] << 24) ^
+ kw[r][1]!.toInt();
_c2 = (_s[r2 & 255] & 255) ^
- ((_s[(r3 >> 8) & 255] & 255) << 8) ^
- ((_s[(r0 >> 16) & 255] & 255) << 16) ^
- (_s[(r1 >> 24) & 255] << 24) ^
- kw[r][2]!.toInt();
+ ((_s[(r3 >> 8) & 255] & 255) << 8) ^
+ ((_s[(r0 >> 16) & 255] & 255) << 16) ^
+ (_s[(r1 >> 24) & 255] << 24) ^
+ kw[r][2]!.toInt();
_c3 = (_s[r3 & 255] & 255) ^
- ((_s[(r0 >> 8) & 255] & 255) << 8) ^
- ((_s[(r1 >> 16) & 255] & 255) << 16) ^
- (_s[(r2 >> 24) & 255] << 24) ^
- kw[r][3]!.toInt();
+ ((_s[(r0 >> 8) & 255] & 255) << 8) ^
+ ((_s[(r1 >> 16) & 255] & 255) << 16) ^
+ (_s[(r2 >> 24) & 255] << 24) ^
+ kw[r][3]!.toInt();
}
void _decryptBlock(List<List<int?>> kw) {
@@ -230,91 +229,91 @@
r = _rounds - 1;
while (r > 1) {
r0 = _tinv0[_c0 & 255] ^
- _tinv1[(_c3 >> 8) & 255] ^
- _tinv2[(_c2 >> 16) & 255] ^
- _tinv3[(_c1 >> 24) & 255] ^
- kw[r][0]!.toInt();
+ _tinv1[(_c3 >> 8) & 255] ^
+ _tinv2[(_c2 >> 16) & 255] ^
+ _tinv3[(_c1 >> 24) & 255] ^
+ kw[r][0]!.toInt();
r1 = _tinv0[_c1 & 255] ^
- _tinv1[(_c0 >> 8) & 255] ^
- _tinv2[(_c3 >> 16) & 255] ^
- _tinv3[(_c2 >> 24) & 255] ^
- kw[r][1]!.toInt();
+ _tinv1[(_c0 >> 8) & 255] ^
+ _tinv2[(_c3 >> 16) & 255] ^
+ _tinv3[(_c2 >> 24) & 255] ^
+ kw[r][1]!.toInt();
r2 = _tinv0[_c2 & 255] ^
- _tinv1[(_c1 >> 8) & 255] ^
- _tinv2[(_c0 >> 16) & 255] ^
- _tinv3[(_c3 >> 24) & 255] ^
- kw[r][2]!.toInt();
+ _tinv1[(_c1 >> 8) & 255] ^
+ _tinv2[(_c0 >> 16) & 255] ^
+ _tinv3[(_c3 >> 24) & 255] ^
+ kw[r][2]!.toInt();
r3 = _tinv0[_c3 & 255] ^
- _tinv1[(_c2 >> 8) & 255] ^
- _tinv2[(_c1 >> 16) & 255] ^
- _tinv3[(_c0 >> 24) & 255] ^
- kw[r][3]!.toInt();
+ _tinv1[(_c2 >> 8) & 255] ^
+ _tinv2[(_c1 >> 16) & 255] ^
+ _tinv3[(_c0 >> 24) & 255] ^
+ kw[r][3]!.toInt();
r--;
_c0 = _tinv0[r0 & 255] ^
- _tinv1[(r3 >> 8) & 255] ^
- _tinv2[(r2 >> 16) & 255] ^
- _tinv3[(r1 >> 24) & 255] ^
- kw[r][0]!.toInt();
+ _tinv1[(r3 >> 8) & 255] ^
+ _tinv2[(r2 >> 16) & 255] ^
+ _tinv3[(r1 >> 24) & 255] ^
+ kw[r][0]!.toInt();
_c1 = _tinv0[r1 & 255] ^
- _tinv1[(r0 >> 8) & 255] ^
- _tinv2[(r3 >> 16) & 255] ^
- _tinv3[(r2 >> 24) & 255] ^
- kw[r][1]!.toInt();
+ _tinv1[(r0 >> 8) & 255] ^
+ _tinv2[(r3 >> 16) & 255] ^
+ _tinv3[(r2 >> 24) & 255] ^
+ kw[r][1]!.toInt();
_c2 = _tinv0[r2 & 255] ^
- _tinv1[(r1 >> 8) & 255] ^
- _tinv2[(r0 >> 16) & 255] ^
- _tinv3[(r3 >> 24) & 255] ^
- kw[r][2]!.toInt();
+ _tinv1[(r1 >> 8) & 255] ^
+ _tinv2[(r0 >> 16) & 255] ^
+ _tinv3[(r3 >> 24) & 255] ^
+ kw[r][2]!.toInt();
_c3 = _tinv0[r3 & 255] ^
- _tinv1[(r2 >> 8) & 255] ^
- _tinv2[(r1 >> 16) & 255] ^
- _tinv3[(r0 >> 24) & 255] ^
- kw[r][3]!.toInt();
+ _tinv1[(r2 >> 8) & 255] ^
+ _tinv2[(r1 >> 16) & 255] ^
+ _tinv3[(r0 >> 24) & 255] ^
+ kw[r][3]!.toInt();
r--;
}
r0 = _tinv0[_c0 & 255] ^
- _tinv1[(_c3 >> 8) & 255] ^
- _tinv2[(_c2 >> 16) & 255] ^
- _tinv3[(_c1 >> 24) & 255] ^
- kw[r][0]!.toInt();
+ _tinv1[(_c3 >> 8) & 255] ^
+ _tinv2[(_c2 >> 16) & 255] ^
+ _tinv3[(_c1 >> 24) & 255] ^
+ kw[r][0]!.toInt();
r1 = _tinv0[_c1 & 255] ^
- _tinv1[(_c0 >> 8) & 255] ^
- _tinv2[(_c3 >> 16) & 255] ^
- _tinv3[(_c2 >> 24) & 255] ^
- kw[r][1]!.toInt();
+ _tinv1[(_c0 >> 8) & 255] ^
+ _tinv2[(_c3 >> 16) & 255] ^
+ _tinv3[(_c2 >> 24) & 255] ^
+ kw[r][1]!.toInt();
r2 = _tinv0[_c2 & 255] ^
- _tinv1[(_c1 >> 8) & 255] ^
- _tinv2[(_c0 >> 16) & 255] ^
- _tinv3[(_c3 >> 24) & 255] ^
- kw[r][2]!.toInt();
+ _tinv1[(_c1 >> 8) & 255] ^
+ _tinv2[(_c0 >> 16) & 255] ^
+ _tinv3[(_c3 >> 24) & 255] ^
+ kw[r][2]!.toInt();
r3 = _tinv0[_c3 & 255] ^
- _tinv1[(_c2 >> 8) & 255] ^
- _tinv2[(_c1 >> 16) & 255] ^
- _tinv3[(_c0 >> 24) & 255] ^
- kw[r][3]!.toInt();
+ _tinv1[(_c2 >> 8) & 255] ^
+ _tinv2[(_c1 >> 16) & 255] ^
+ _tinv3[(_c0 >> 24) & 255] ^
+ kw[r][3]!.toInt();
// the final round's table is a simple function of Si so we don't use a whole other four tables for it
_c0 = (_si[r0 & 255] & 255) ^
- ((_si[(r3 >> 8) & 255] & 255) << 8) ^
- ((_si[(r2 >> 16) & 255] & 255) << 16) ^
- (_si[(r1 >> 24) & 255] << 24) ^
- kw[0][0]!.toInt();
+ ((_si[(r3 >> 8) & 255] & 255) << 8) ^
+ ((_si[(r2 >> 16) & 255] & 255) << 16) ^
+ (_si[(r1 >> 24) & 255] << 24) ^
+ kw[0][0]!.toInt();
_c1 = (_si[r1 & 255] & 255) ^
- ((_si[(r0 >> 8) & 255] & 255) << 8) ^
- ((_si[(r3 >> 16) & 255] & 255) << 16) ^
- (_si[(r2 >> 24) & 255] << 24) ^
- kw[0][1]!.toInt();
+ ((_si[(r0 >> 8) & 255] & 255) << 8) ^
+ ((_si[(r3 >> 16) & 255] & 255) << 16) ^
+ (_si[(r2 >> 24) & 255] << 24) ^
+ kw[0][1]!.toInt();
_c2 = (_si[r2 & 255] & 255) ^
- ((_si[(r1 >> 8) & 255] & 255) << 8) ^
- ((_si[(r0 >> 16) & 255] & 255) << 16) ^
- (_si[(r3 >> 24) & 255] << 24) ^
- kw[0][2]!.toInt();
+ ((_si[(r1 >> 8) & 255] & 255) << 8) ^
+ ((_si[(r0 >> 16) & 255] & 255) << 16) ^
+ (_si[(r3 >> 24) & 255] << 24) ^
+ kw[0][2]!.toInt();
_c3 = (_si[r3 & 255] & 255) ^
- ((_si[(r2 >> 8) & 255] & 255) << 8) ^
- ((_si[(r1 >> 16) & 255] & 255) << 16) ^
- (_si[(r0 >> 24) & 255] << 24) ^
- kw[0][3]!.toInt();
+ ((_si[(r2 >> 8) & 255] & 255) << 8) ^
+ ((_si[(r1 >> 16) & 255] & 255) << 16) ^
+ (_si[(r0 >> 24) & 255] << 24) ^
+ kw[0][3]!.toInt();
}
void _unpackBlock(ByteData view, int off) {
@@ -341,8 +340,8 @@
const int _m3 = 0x0000001b;
int _fFmulX(int x) {
- var lsr = shiftr32((x & _m1), 7);
- return (((x & _m2) << 1) ^ lsr * _m3);
+ var lsr = shiftr32(x & _m1, 7);
+ return ((x & _m2) << 1) ^ lsr * _m3;
}
///
@@ -367,10 +366,10 @@
}
int _subWord(int x) {
- return (_s[x & 255] & 255 |
+ return _s[x & 255] & 255 |
((_s[(x >> 8) & 255] & 255) << 8) |
((_s[(x >> 16) & 255] & 255) << 16) |
- _s[(x >> 24) & 255] << 24);
+ _s[(x >> 24) & 255] << 24;
}
// The S box
diff --git a/lib/block/blowfish.dart b/lib/block/blowfish.dart
new file mode 100644
index 0000000..0f1dc30
--- /dev/null
+++ b/lib/block/blowfish.dart
@@ -0,0 +1,466 @@
+// See file LICENSE for more information.
+
+library impl.block_cipher.blowfish;
+
+import 'dart:core';
+import 'dart:typed_data';
+
+import 'package:pointycastle/api.dart';
+import 'package:pointycastle/src/impl/base_block_cipher.dart';
+import 'package:pointycastle/src/registry/registry.dart';
+
+/// A class that provides Blowfish key encryption operations,
+/// such as encoding data and generating keys.
+/// Author Nguyen Van Nguyen <nguyennv1981@gmail.com>
+class BlowfishEngine extends BaseBlockCipher {
+ static final FactoryConfig factoryConfig = StaticFactoryConfig(
+ BlockCipher,
+ 'Blowfish',
+ () => BlowfishEngine(),
+ );
+
+ static const _kp = [
+ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, // 0 - 3
+ 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
+ 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
+ 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
+ 0x9216d5d9, 0x8979fb1b
+ ];
+
+ static const _sBox0 = [
+ 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, // 0 - 3
+ 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
+ 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
+ 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
+ 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
+ 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
+ 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
+ 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
+ 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
+ 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
+ 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
+ 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
+ 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
+ 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
+ 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
+ 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
+ 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
+ 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
+ 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
+ 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
+ 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
+ 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
+ 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
+ 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
+ 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
+ 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
+ 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
+ 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
+ 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
+ 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
+ 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
+ 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
+ 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
+ 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
+ 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
+ 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
+ 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
+ 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
+ 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
+ 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
+ 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
+ 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
+ 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
+ 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
+ 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
+ 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
+ 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
+ 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
+ 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
+ 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
+ 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
+ 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
+ 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
+ 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
+ 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
+ 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
+ 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
+ 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
+ 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
+ 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
+ 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
+ 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
+ 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
+ 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
+ ];
+
+ static const _sBox1 = [
+ 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, // 0 - 3
+ 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
+ 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+ 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
+ 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
+ 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+ 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
+ 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
+ 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+ 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
+ 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
+ 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+ 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
+ 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
+ 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+ 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
+ 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
+ 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+ 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
+ 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
+ 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+ 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
+ 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
+ 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+ 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
+ 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
+ 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+ 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
+ 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
+ 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+ 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
+ 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
+ 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+ 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
+ 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
+ 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+ 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
+ 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
+ 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+ 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
+ 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
+ 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+ 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
+ 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
+ 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+ 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
+ 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
+ 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+ 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
+ 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
+ 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+ 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
+ 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
+ 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+ 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
+ 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
+ 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+ 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
+ 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
+ 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+ 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
+ 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
+ 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+ 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
+ ];
+
+ static const _sBox2 = [
+ 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, // 0 - 3
+ 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
+ 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
+ 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
+ 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
+ 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
+ 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
+ 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
+ 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
+ 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
+ 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
+ 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
+ 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
+ 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
+ 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
+ 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
+ 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
+ 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
+ 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
+ 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
+ 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
+ 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
+ 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
+ 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
+ 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
+ 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
+ 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
+ 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
+ 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
+ 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
+ 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
+ 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
+ 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
+ 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
+ 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
+ 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
+ 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
+ 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
+ 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
+ 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
+ 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
+ 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
+ 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
+ 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
+ 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
+ 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
+ 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
+ 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
+ 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
+ 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
+ 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
+ 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
+ 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
+ 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
+ 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
+ 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
+ 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
+ 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
+ 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
+ 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
+ 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
+ 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
+ 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
+ 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
+ ];
+
+ static const _sBox3 = [
+ 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, // 0 - 3
+ 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
+ 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
+ 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
+ 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
+ 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
+ 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
+ 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
+ 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
+ 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
+ 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
+ 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
+ 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
+ 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
+ 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
+ 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
+ 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
+ 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
+ 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
+ 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
+ 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
+ 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
+ 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
+ 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
+ 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
+ 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
+ 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
+ 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
+ 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
+ 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
+ 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
+ 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
+ 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
+ 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
+ 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
+ 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
+ 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
+ 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
+ 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
+ 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
+ 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
+ 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
+ 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
+ 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
+ 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
+ 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
+ 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
+ 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
+ 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
+ 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
+ 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
+ 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
+ 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
+ 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
+ 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
+ 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
+ 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
+ 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
+ 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
+ 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
+ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
+ 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
+ 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
+ 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
+ ];
+
+ static const _rounds = 16;
+ static const _sBoxSK = 256;
+ static const _pSZ = _rounds + 2;
+
+ static const BLOCK_SIZE = 8;
+
+ bool _forEncryption = false;
+
+ late Uint8List _workingKey;
+
+ /// the s-boxes
+ final _s0 = List<int>.filled(_sBoxSK, 0);
+ final _s1 = List<int>.filled(_sBoxSK, 0);
+ final _s2 = List<int>.filled(_sBoxSK, 0);
+ final _s3 = List<int>.filled(_sBoxSK, 0);
+
+ /// the p-array
+ final _p = List<int>.filled(_pSZ, 0);
+
+ @override
+ String get algorithmName => 'Blowfish';
+
+ @override
+ int get blockSize => BLOCK_SIZE;
+
+ @override
+ void reset() {}
+
+ @override
+ void init(final bool forEncryption, final CipherParameters? params) {
+ if (params is KeyParameter) {
+ _forEncryption = forEncryption;
+ _workingKey = params.key;
+ _setKey(_workingKey);
+ } else {
+ throw ArgumentError(
+ 'Invalid parameter passed to $algorithmName init - ${params.runtimeType}',
+ );
+ }
+ }
+
+ @override
+ int processBlock(
+ final Uint8List input,
+ final int inOff,
+ final Uint8List output,
+ final int outOff,
+ ) {
+ if (_workingKey.isEmpty) {
+ throw StateError('$algorithmName not initialised');
+ }
+ if ((inOff + BLOCK_SIZE) > input.lengthInBytes) {
+ throw ArgumentError('Input buffer too short for $algorithmName engine');
+ }
+ if ((outOff + BLOCK_SIZE) > output.lengthInBytes) {
+ throw ArgumentError('Output buffer too short for $algorithmName engine');
+ }
+
+ if (_forEncryption) {
+ _encryptBlock(input, inOff, output, outOff);
+ } else {
+ _decryptBlock(input, inOff, output, outOff);
+ }
+
+ return BLOCK_SIZE;
+ }
+
+ int _f(final int x) {
+ return ((_s0[(x >> 24) & 0xff] + _s1[(x >> 16) & 0xff]) ^
+ _s2[(x >> 8) & 0xff]) +
+ _s3[x & 0xff];
+ }
+
+ /// apply the encryption cycle to each value pair in the table.
+ void _processTable(int xl, int xr, final List<int> table) {
+ final size = table.length;
+ for (var s = 0; s < size; s += 2) {
+ xl ^= _p[0];
+ for (var i = 1; i < _rounds; i += 2) {
+ xr ^= _f(xl) ^ _p[i];
+ xl ^= _f(xr) ^ _p[i + 1];
+ }
+ xr ^= _p[_rounds + 1];
+ table[s] = xr;
+ table[s + 1] = xl;
+
+ /// end of cycle swap
+ xr = xl;
+ xl = table[s];
+ }
+ }
+
+ void _setKey(final Uint8List key) {
+ if (key.length < 4 || key.length > 56) {
+ throw ArgumentError('Key length must be in range 32 to 448 bits');
+ }
+ _s0.setAll(0, _sBox0.sublist(0, _sBoxSK));
+ _s1.setAll(0, _sBox1.sublist(0, _sBoxSK));
+ _s2.setAll(0, _sBox2.sublist(0, _sBoxSK));
+ _s3.setAll(0, _sBox3.sublist(0, _sBoxSK));
+
+ _p.setAll(0, _kp.sublist(0, _pSZ));
+
+ final keyLength = key.length;
+ var keyIndex = 0;
+
+ for (var i = 0; i < _pSZ; i++) {
+ var data = 0x0000000;
+ for (var j = 0; j < 4; j++) {
+ data = (data << 8) | key[keyIndex++];
+ if (keyIndex >= keyLength) {
+ keyIndex = 0;
+ }
+ }
+ _p[i] ^= data;
+ }
+
+ _processTable(0, 0, _p);
+ _processTable(_p[_pSZ - 2], _p[_pSZ - 1], _s0);
+ _processTable(_s0[_sBoxSK - 2], _s0[_sBoxSK - 1], _s1);
+ _processTable(_s1[_sBoxSK - 2], _s1[_sBoxSK - 1], _s2);
+ _processTable(_s2[_sBoxSK - 2], _s2[_sBoxSK - 1], _s3);
+ }
+
+ void _encryptBlock(
+ final Uint8List src,
+ final int srcIndex,
+ final Uint8List dst,
+ final int dstIndex,
+ ) {
+ var xl = src.sublist(srcIndex).buffer.asByteData().getInt32(0);
+ var xr = src.sublist(srcIndex + 4).buffer.asByteData().getInt32(0);
+
+ xl ^= _p[0];
+
+ for (var i = 1; i < _rounds; i += 2) {
+ xr ^= _f(xl) ^ _p[i];
+ xl ^= _f(xr) ^ _p[i + 1];
+ }
+ xr ^= _p[_rounds + 1];
+
+ dst.setAll(dstIndex, _pack32(xr));
+ dst.setAll(dstIndex + 4, _pack32(xl));
+ }
+
+ void _decryptBlock(
+ final Uint8List src,
+ final int srcIndex,
+ final Uint8List dst,
+ final int dstIndex,
+ ) {
+ var xl = src.sublist(srcIndex).buffer.asByteData().getInt32(0);
+ var xr = src.sublist(srcIndex + 4).buffer.asByteData().getInt32(0);
+
+ xl ^= _p[_rounds + 1];
+
+ for (var i = _rounds; i > 0; i -= 2) {
+ xr ^= _f(xl) ^ _p[i];
+ xl ^= _f(xr) ^ _p[i - 1];
+ }
+
+ xr ^= _p[0];
+ dst.setAll(dstIndex, _pack32(xr));
+ dst.setAll(dstIndex + 4, _pack32(xl));
+ }
+
+ static Uint8List _pack32(int x) =>
+ Uint8List(4)..buffer.asByteData().setInt32(0, x);
+}
diff --git a/lib/block/camellia.dart b/lib/block/camellia.dart
new file mode 100644
index 0000000..08e6a89
--- /dev/null
+++ b/lib/block/camellia.dart
@@ -0,0 +1,698 @@
+// See file LICENSE for more information.
+
+library impl.block_cipher.camellia;
+
+import 'dart:typed_data';
+
+import 'dart:core';
+
+import 'package:pointycastle/api.dart';
+import 'package:pointycastle/src/impl/base_block_cipher.dart';
+import 'package:pointycastle/src/registry/registry.dart';
+
+/// Camellia - based on RFC 3713.
+/// Author Nguyen Van Nguyen <nguyennv1981@gmail.com>
+class CamelliaEngine extends BaseBlockCipher {
+ static final FactoryConfig factoryConfig = StaticFactoryConfig(
+ BlockCipher,
+ 'Camellia',
+ () => CamelliaEngine(),
+ );
+
+ static const BLOCK_SIZE = 16;
+
+ static const _mask8 = 0xff;
+
+ static const _mask32 = 0xffffffff;
+
+ static const _sigma = [
+ 0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, // 0 - 3
+ 0xc6ef372f, 0xe94f82be, 0x54ff53a5, 0xf1d36f1c,
+ 0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd
+ ];
+
+ //// The first camellia sbox
+ static const _sbox1_1110 = [
+ 0x70707000, 0x82828200, 0x2c2c2c00, 0xececec00, 0xb3b3b300,
+ 0x27272700, // 0 - 5
+ 0xc0c0c000, 0xe5e5e500, 0xe4e4e400, 0x85858500, 0x57575700, 0x35353500,
+ 0xeaeaea00, 0x0c0c0c00, 0xaeaeae00, 0x41414100, 0x23232300, 0xefefef00,
+ 0x6b6b6b00, 0x93939300, 0x45454500, 0x19191900, 0xa5a5a500, 0x21212100,
+ 0xededed00, 0x0e0e0e00, 0x4f4f4f00, 0x4e4e4e00, 0x1d1d1d00, 0x65656500,
+ 0x92929200, 0xbdbdbd00, 0x86868600, 0xb8b8b800, 0xafafaf00, 0x8f8f8f00,
+ 0x7c7c7c00, 0xebebeb00, 0x1f1f1f00, 0xcecece00, 0x3e3e3e00, 0x30303000,
+ 0xdcdcdc00, 0x5f5f5f00, 0x5e5e5e00, 0xc5c5c500, 0x0b0b0b00, 0x1a1a1a00,
+ 0xa6a6a600, 0xe1e1e100, 0x39393900, 0xcacaca00, 0xd5d5d500, 0x47474700,
+ 0x5d5d5d00, 0x3d3d3d00, 0xd9d9d900, 0x01010100, 0x5a5a5a00, 0xd6d6d600,
+ 0x51515100, 0x56565600, 0x6c6c6c00, 0x4d4d4d00, 0x8b8b8b00, 0x0d0d0d00,
+ 0x9a9a9a00, 0x66666600, 0xfbfbfb00, 0xcccccc00, 0xb0b0b000, 0x2d2d2d00,
+ 0x74747400, 0x12121200, 0x2b2b2b00, 0x20202000, 0xf0f0f000, 0xb1b1b100,
+ 0x84848400, 0x99999900, 0xdfdfdf00, 0x4c4c4c00, 0xcbcbcb00, 0xc2c2c200,
+ 0x34343400, 0x7e7e7e00, 0x76767600, 0x05050500, 0x6d6d6d00, 0xb7b7b700,
+ 0xa9a9a900, 0x31313100, 0xd1d1d100, 0x17171700, 0x04040400, 0xd7d7d700,
+ 0x14141400, 0x58585800, 0x3a3a3a00, 0x61616100, 0xdedede00, 0x1b1b1b00,
+ 0x11111100, 0x1c1c1c00, 0x32323200, 0x0f0f0f00, 0x9c9c9c00, 0x16161600,
+ 0x53535300, 0x18181800, 0xf2f2f200, 0x22222200, 0xfefefe00, 0x44444400,
+ 0xcfcfcf00, 0xb2b2b200, 0xc3c3c300, 0xb5b5b500, 0x7a7a7a00, 0x91919100,
+ 0x24242400, 0x08080800, 0xe8e8e800, 0xa8a8a800, 0x60606000, 0xfcfcfc00,
+ 0x69696900, 0x50505000, 0xaaaaaa00, 0xd0d0d000, 0xa0a0a000, 0x7d7d7d00,
+ 0xa1a1a100, 0x89898900, 0x62626200, 0x97979700, 0x54545400, 0x5b5b5b00,
+ 0x1e1e1e00, 0x95959500, 0xe0e0e000, 0xffffff00, 0x64646400, 0xd2d2d200,
+ 0x10101000, 0xc4c4c400, 0x00000000, 0x48484800, 0xa3a3a300, 0xf7f7f700,
+ 0x75757500, 0xdbdbdb00, 0x8a8a8a00, 0x03030300, 0xe6e6e600, 0xdadada00,
+ 0x09090900, 0x3f3f3f00, 0xdddddd00, 0x94949400, 0x87878700, 0x5c5c5c00,
+ 0x83838300, 0x02020200, 0xcdcdcd00, 0x4a4a4a00, 0x90909000, 0x33333300,
+ 0x73737300, 0x67676700, 0xf6f6f600, 0xf3f3f300, 0x9d9d9d00, 0x7f7f7f00,
+ 0xbfbfbf00, 0xe2e2e200, 0x52525200, 0x9b9b9b00, 0xd8d8d800, 0x26262600,
+ 0xc8c8c800, 0x37373700, 0xc6c6c600, 0x3b3b3b00, 0x81818100, 0x96969600,
+ 0x6f6f6f00, 0x4b4b4b00, 0x13131300, 0xbebebe00, 0x63636300, 0x2e2e2e00,
+ 0xe9e9e900, 0x79797900, 0xa7a7a700, 0x8c8c8c00, 0x9f9f9f00, 0x6e6e6e00,
+ 0xbcbcbc00, 0x8e8e8e00, 0x29292900, 0xf5f5f500, 0xf9f9f900, 0xb6b6b600,
+ 0x2f2f2f00, 0xfdfdfd00, 0xb4b4b400, 0x59595900, 0x78787800, 0x98989800,
+ 0x06060600, 0x6a6a6a00, 0xe7e7e700, 0x46464600, 0x71717100, 0xbababa00,
+ 0xd4d4d400, 0x25252500, 0xababab00, 0x42424200, 0x88888800, 0xa2a2a200,
+ 0x8d8d8d00, 0xfafafa00, 0x72727200, 0x07070700, 0xb9b9b900, 0x55555500,
+ 0xf8f8f800, 0xeeeeee00, 0xacacac00, 0x0a0a0a00, 0x36363600, 0x49494900,
+ 0x2a2a2a00, 0x68686800, 0x3c3c3c00, 0x38383800, 0xf1f1f100, 0xa4a4a400,
+ 0x40404000, 0x28282800, 0xd3d3d300, 0x7b7b7b00, 0xbbbbbb00, 0xc9c9c900,
+ 0x43434300, 0xc1c1c100, 0x15151500, 0xe3e3e300, 0xadadad00, 0xf4f4f400,
+ 0x77777700, 0xc7c7c700, 0x80808000, 0x9e9e9e00
+ ];
+
+ /// The second camellia sbox
+ static const _sbox2_0222 = [
+ 0x00e0e0e0, 0x00050505, 0x00585858, 0x00d9d9d9, 0x00676767,
+ 0x004e4e4e, // 0 - 5
+ 0x00818181, 0x00cbcbcb, 0x00c9c9c9, 0x000b0b0b, 0x00aeaeae, 0x006a6a6a,
+ 0x00d5d5d5, 0x00181818, 0x005d5d5d, 0x00828282, 0x00464646, 0x00dfdfdf,
+ 0x00d6d6d6, 0x00272727, 0x008a8a8a, 0x00323232, 0x004b4b4b, 0x00424242,
+ 0x00dbdbdb, 0x001c1c1c, 0x009e9e9e, 0x009c9c9c, 0x003a3a3a, 0x00cacaca,
+ 0x00252525, 0x007b7b7b, 0x000d0d0d, 0x00717171, 0x005f5f5f, 0x001f1f1f,
+ 0x00f8f8f8, 0x00d7d7d7, 0x003e3e3e, 0x009d9d9d, 0x007c7c7c, 0x00606060,
+ 0x00b9b9b9, 0x00bebebe, 0x00bcbcbc, 0x008b8b8b, 0x00161616, 0x00343434,
+ 0x004d4d4d, 0x00c3c3c3, 0x00727272, 0x00959595, 0x00ababab, 0x008e8e8e,
+ 0x00bababa, 0x007a7a7a, 0x00b3b3b3, 0x00020202, 0x00b4b4b4, 0x00adadad,
+ 0x00a2a2a2, 0x00acacac, 0x00d8d8d8, 0x009a9a9a, 0x00171717, 0x001a1a1a,
+ 0x00353535, 0x00cccccc, 0x00f7f7f7, 0x00999999, 0x00616161, 0x005a5a5a,
+ 0x00e8e8e8, 0x00242424, 0x00565656, 0x00404040, 0x00e1e1e1, 0x00636363,
+ 0x00090909, 0x00333333, 0x00bfbfbf, 0x00989898, 0x00979797, 0x00858585,
+ 0x00686868, 0x00fcfcfc, 0x00ececec, 0x000a0a0a, 0x00dadada, 0x006f6f6f,
+ 0x00535353, 0x00626262, 0x00a3a3a3, 0x002e2e2e, 0x00080808, 0x00afafaf,
+ 0x00282828, 0x00b0b0b0, 0x00747474, 0x00c2c2c2, 0x00bdbdbd, 0x00363636,
+ 0x00222222, 0x00383838, 0x00646464, 0x001e1e1e, 0x00393939, 0x002c2c2c,
+ 0x00a6a6a6, 0x00303030, 0x00e5e5e5, 0x00444444, 0x00fdfdfd, 0x00888888,
+ 0x009f9f9f, 0x00656565, 0x00878787, 0x006b6b6b, 0x00f4f4f4, 0x00232323,
+ 0x00484848, 0x00101010, 0x00d1d1d1, 0x00515151, 0x00c0c0c0, 0x00f9f9f9,
+ 0x00d2d2d2, 0x00a0a0a0, 0x00555555, 0x00a1a1a1, 0x00414141, 0x00fafafa,
+ 0x00434343, 0x00131313, 0x00c4c4c4, 0x002f2f2f, 0x00a8a8a8, 0x00b6b6b6,
+ 0x003c3c3c, 0x002b2b2b, 0x00c1c1c1, 0x00ffffff, 0x00c8c8c8, 0x00a5a5a5,
+ 0x00202020, 0x00898989, 0x00000000, 0x00909090, 0x00474747, 0x00efefef,
+ 0x00eaeaea, 0x00b7b7b7, 0x00151515, 0x00060606, 0x00cdcdcd, 0x00b5b5b5,
+ 0x00121212, 0x007e7e7e, 0x00bbbbbb, 0x00292929, 0x000f0f0f, 0x00b8b8b8,
+ 0x00070707, 0x00040404, 0x009b9b9b, 0x00949494, 0x00212121, 0x00666666,
+ 0x00e6e6e6, 0x00cecece, 0x00ededed, 0x00e7e7e7, 0x003b3b3b, 0x00fefefe,
+ 0x007f7f7f, 0x00c5c5c5, 0x00a4a4a4, 0x00373737, 0x00b1b1b1, 0x004c4c4c,
+ 0x00919191, 0x006e6e6e, 0x008d8d8d, 0x00767676, 0x00030303, 0x002d2d2d,
+ 0x00dedede, 0x00969696, 0x00262626, 0x007d7d7d, 0x00c6c6c6, 0x005c5c5c,
+ 0x00d3d3d3, 0x00f2f2f2, 0x004f4f4f, 0x00191919, 0x003f3f3f, 0x00dcdcdc,
+ 0x00797979, 0x001d1d1d, 0x00525252, 0x00ebebeb, 0x00f3f3f3, 0x006d6d6d,
+ 0x005e5e5e, 0x00fbfbfb, 0x00696969, 0x00b2b2b2, 0x00f0f0f0, 0x00313131,
+ 0x000c0c0c, 0x00d4d4d4, 0x00cfcfcf, 0x008c8c8c, 0x00e2e2e2, 0x00757575,
+ 0x00a9a9a9, 0x004a4a4a, 0x00575757, 0x00848484, 0x00111111, 0x00454545,
+ 0x001b1b1b, 0x00f5f5f5, 0x00e4e4e4, 0x000e0e0e, 0x00737373, 0x00aaaaaa,
+ 0x00f1f1f1, 0x00dddddd, 0x00595959, 0x00141414, 0x006c6c6c, 0x00929292,
+ 0x00545454, 0x00d0d0d0, 0x00787878, 0x00707070, 0x00e3e3e3, 0x00494949,
+ 0x00808080, 0x00505050, 0x00a7a7a7, 0x00f6f6f6, 0x00777777, 0x00939393,
+ 0x00868686, 0x00838383, 0x002a2a2a, 0x00c7c7c7, 0x005b5b5b, 0x00e9e9e9,
+ 0x00eeeeee, 0x008f8f8f, 0x00010101, 0x003d3d3d
+ ];
+
+ /// The third camellia sbox
+ static const _sbox3_3033 = [
+ 0x38003838, 0x41004141, 0x16001616, 0x76007676, 0xd900d9d9,
+ 0x93009393, // 0 - 5
+ 0x60006060, 0xf200f2f2, 0x72007272, 0xc200c2c2, 0xab00abab, 0x9a009a9a,
+ 0x75007575, 0x06000606, 0x57005757, 0xa000a0a0, 0x91009191, 0xf700f7f7,
+ 0xb500b5b5, 0xc900c9c9, 0xa200a2a2, 0x8c008c8c, 0xd200d2d2, 0x90009090,
+ 0xf600f6f6, 0x07000707, 0xa700a7a7, 0x27002727, 0x8e008e8e, 0xb200b2b2,
+ 0x49004949, 0xde00dede, 0x43004343, 0x5c005c5c, 0xd700d7d7, 0xc700c7c7,
+ 0x3e003e3e, 0xf500f5f5, 0x8f008f8f, 0x67006767, 0x1f001f1f, 0x18001818,
+ 0x6e006e6e, 0xaf00afaf, 0x2f002f2f, 0xe200e2e2, 0x85008585, 0x0d000d0d,
+ 0x53005353, 0xf000f0f0, 0x9c009c9c, 0x65006565, 0xea00eaea, 0xa300a3a3,
+ 0xae00aeae, 0x9e009e9e, 0xec00ecec, 0x80008080, 0x2d002d2d, 0x6b006b6b,
+ 0xa800a8a8, 0x2b002b2b, 0x36003636, 0xa600a6a6, 0xc500c5c5, 0x86008686,
+ 0x4d004d4d, 0x33003333, 0xfd00fdfd, 0x66006666, 0x58005858, 0x96009696,
+ 0x3a003a3a, 0x09000909, 0x95009595, 0x10001010, 0x78007878, 0xd800d8d8,
+ 0x42004242, 0xcc00cccc, 0xef00efef, 0x26002626, 0xe500e5e5, 0x61006161,
+ 0x1a001a1a, 0x3f003f3f, 0x3b003b3b, 0x82008282, 0xb600b6b6, 0xdb00dbdb,
+ 0xd400d4d4, 0x98009898, 0xe800e8e8, 0x8b008b8b, 0x02000202, 0xeb00ebeb,
+ 0x0a000a0a, 0x2c002c2c, 0x1d001d1d, 0xb000b0b0, 0x6f006f6f, 0x8d008d8d,
+ 0x88008888, 0x0e000e0e, 0x19001919, 0x87008787, 0x4e004e4e, 0x0b000b0b,
+ 0xa900a9a9, 0x0c000c0c, 0x79007979, 0x11001111, 0x7f007f7f, 0x22002222,
+ 0xe700e7e7, 0x59005959, 0xe100e1e1, 0xda00dada, 0x3d003d3d, 0xc800c8c8,
+ 0x12001212, 0x04000404, 0x74007474, 0x54005454, 0x30003030, 0x7e007e7e,
+ 0xb400b4b4, 0x28002828, 0x55005555, 0x68006868, 0x50005050, 0xbe00bebe,
+ 0xd000d0d0, 0xc400c4c4, 0x31003131, 0xcb00cbcb, 0x2a002a2a, 0xad00adad,
+ 0x0f000f0f, 0xca00caca, 0x70007070, 0xff00ffff, 0x32003232, 0x69006969,
+ 0x08000808, 0x62006262, 0x00000000, 0x24002424, 0xd100d1d1, 0xfb00fbfb,
+ 0xba00baba, 0xed00eded, 0x45004545, 0x81008181, 0x73007373, 0x6d006d6d,
+ 0x84008484, 0x9f009f9f, 0xee00eeee, 0x4a004a4a, 0xc300c3c3, 0x2e002e2e,
+ 0xc100c1c1, 0x01000101, 0xe600e6e6, 0x25002525, 0x48004848, 0x99009999,
+ 0xb900b9b9, 0xb300b3b3, 0x7b007b7b, 0xf900f9f9, 0xce00cece, 0xbf00bfbf,
+ 0xdf00dfdf, 0x71007171, 0x29002929, 0xcd00cdcd, 0x6c006c6c, 0x13001313,
+ 0x64006464, 0x9b009b9b, 0x63006363, 0x9d009d9d, 0xc000c0c0, 0x4b004b4b,
+ 0xb700b7b7, 0xa500a5a5, 0x89008989, 0x5f005f5f, 0xb100b1b1, 0x17001717,
+ 0xf400f4f4, 0xbc00bcbc, 0xd300d3d3, 0x46004646, 0xcf00cfcf, 0x37003737,
+ 0x5e005e5e, 0x47004747, 0x94009494, 0xfa00fafa, 0xfc00fcfc, 0x5b005b5b,
+ 0x97009797, 0xfe00fefe, 0x5a005a5a, 0xac00acac, 0x3c003c3c, 0x4c004c4c,
+ 0x03000303, 0x35003535, 0xf300f3f3, 0x23002323, 0xb800b8b8, 0x5d005d5d,
+ 0x6a006a6a, 0x92009292, 0xd500d5d5, 0x21002121, 0x44004444, 0x51005151,
+ 0xc600c6c6, 0x7d007d7d, 0x39003939, 0x83008383, 0xdc00dcdc, 0xaa00aaaa,
+ 0x7c007c7c, 0x77007777, 0x56005656, 0x05000505, 0x1b001b1b, 0xa400a4a4,
+ 0x15001515, 0x34003434, 0x1e001e1e, 0x1c001c1c, 0xf800f8f8, 0x52005252,
+ 0x20002020, 0x14001414, 0xe900e9e9, 0xbd00bdbd, 0xdd00dddd, 0xe400e4e4,
+ 0xa100a1a1, 0xe000e0e0, 0x8a008a8a, 0xf100f1f1, 0xd600d6d6, 0x7a007a7a,
+ 0xbb00bbbb, 0xe300e3e3, 0x40004040, 0x4f004f4f
+ ];
+
+ /// The fourth camellia sbox
+ static const _sbox4_4404 = [
+ 0x70700070, 0x2c2c002c, 0xb3b300b3, 0xc0c000c0, 0xe4e400e4,
+ 0x57570057, // 0 - 5
+ 0xeaea00ea, 0xaeae00ae, 0x23230023, 0x6b6b006b, 0x45450045, 0xa5a500a5,
+ 0xeded00ed, 0x4f4f004f, 0x1d1d001d, 0x92920092, 0x86860086, 0xafaf00af,
+ 0x7c7c007c, 0x1f1f001f, 0x3e3e003e, 0xdcdc00dc, 0x5e5e005e, 0x0b0b000b,
+ 0xa6a600a6, 0x39390039, 0xd5d500d5, 0x5d5d005d, 0xd9d900d9, 0x5a5a005a,
+ 0x51510051, 0x6c6c006c, 0x8b8b008b, 0x9a9a009a, 0xfbfb00fb, 0xb0b000b0,
+ 0x74740074, 0x2b2b002b, 0xf0f000f0, 0x84840084, 0xdfdf00df, 0xcbcb00cb,
+ 0x34340034, 0x76760076, 0x6d6d006d, 0xa9a900a9, 0xd1d100d1, 0x04040004,
+ 0x14140014, 0x3a3a003a, 0xdede00de, 0x11110011, 0x32320032, 0x9c9c009c,
+ 0x53530053, 0xf2f200f2, 0xfefe00fe, 0xcfcf00cf, 0xc3c300c3, 0x7a7a007a,
+ 0x24240024, 0xe8e800e8, 0x60600060, 0x69690069, 0xaaaa00aa, 0xa0a000a0,
+ 0xa1a100a1, 0x62620062, 0x54540054, 0x1e1e001e, 0xe0e000e0, 0x64640064,
+ 0x10100010, 0x00000000, 0xa3a300a3, 0x75750075, 0x8a8a008a, 0xe6e600e6,
+ 0x09090009, 0xdddd00dd, 0x87870087, 0x83830083, 0xcdcd00cd, 0x90900090,
+ 0x73730073, 0xf6f600f6, 0x9d9d009d, 0xbfbf00bf, 0x52520052, 0xd8d800d8,
+ 0xc8c800c8, 0xc6c600c6, 0x81810081, 0x6f6f006f, 0x13130013, 0x63630063,
+ 0xe9e900e9, 0xa7a700a7, 0x9f9f009f, 0xbcbc00bc, 0x29290029, 0xf9f900f9,
+ 0x2f2f002f, 0xb4b400b4, 0x78780078, 0x06060006, 0xe7e700e7, 0x71710071,
+ 0xd4d400d4, 0xabab00ab, 0x88880088, 0x8d8d008d, 0x72720072, 0xb9b900b9,
+ 0xf8f800f8, 0xacac00ac, 0x36360036, 0x2a2a002a, 0x3c3c003c, 0xf1f100f1,
+ 0x40400040, 0xd3d300d3, 0xbbbb00bb, 0x43430043, 0x15150015, 0xadad00ad,
+ 0x77770077, 0x80800080, 0x82820082, 0xecec00ec, 0x27270027, 0xe5e500e5,
+ 0x85850085, 0x35350035, 0x0c0c000c, 0x41410041, 0xefef00ef, 0x93930093,
+ 0x19190019, 0x21210021, 0x0e0e000e, 0x4e4e004e, 0x65650065, 0xbdbd00bd,
+ 0xb8b800b8, 0x8f8f008f, 0xebeb00eb, 0xcece00ce, 0x30300030, 0x5f5f005f,
+ 0xc5c500c5, 0x1a1a001a, 0xe1e100e1, 0xcaca00ca, 0x47470047, 0x3d3d003d,
+ 0x01010001, 0xd6d600d6, 0x56560056, 0x4d4d004d, 0x0d0d000d, 0x66660066,
+ 0xcccc00cc, 0x2d2d002d, 0x12120012, 0x20200020, 0xb1b100b1, 0x99990099,
+ 0x4c4c004c, 0xc2c200c2, 0x7e7e007e, 0x05050005, 0xb7b700b7, 0x31310031,
+ 0x17170017, 0xd7d700d7, 0x58580058, 0x61610061, 0x1b1b001b, 0x1c1c001c,
+ 0x0f0f000f, 0x16160016, 0x18180018, 0x22220022, 0x44440044, 0xb2b200b2,
+ 0xb5b500b5, 0x91910091, 0x08080008, 0xa8a800a8, 0xfcfc00fc, 0x50500050,
+ 0xd0d000d0, 0x7d7d007d, 0x89890089, 0x97970097, 0x5b5b005b, 0x95950095,
+ 0xffff00ff, 0xd2d200d2, 0xc4c400c4, 0x48480048, 0xf7f700f7, 0xdbdb00db,
+ 0x03030003, 0xdada00da, 0x3f3f003f, 0x94940094, 0x5c5c005c, 0x02020002,
+ 0x4a4a004a, 0x33330033, 0x67670067, 0xf3f300f3, 0x7f7f007f, 0xe2e200e2,
+ 0x9b9b009b, 0x26260026, 0x37370037, 0x3b3b003b, 0x96960096, 0x4b4b004b,
+ 0xbebe00be, 0x2e2e002e, 0x79790079, 0x8c8c008c, 0x6e6e006e, 0x8e8e008e,
+ 0xf5f500f5, 0xb6b600b6, 0xfdfd00fd, 0x59590059, 0x98980098, 0x6a6a006a,
+ 0x46460046, 0xbaba00ba, 0x25250025, 0x42420042, 0xa2a200a2, 0xfafa00fa,
+ 0x07070007, 0x55550055, 0xeeee00ee, 0x0a0a000a, 0x49490049, 0x68680068,
+ 0x38380038, 0xa4a400a4, 0x28280028, 0x7b7b007b, 0xc9c900c9, 0xc1c100c1,
+ 0xe3e300e3, 0xf4f400f4, 0xc7c700c7, 0x9e9e009e
+ ];
+
+ bool initialised = false;
+
+ late bool _keyIs128;
+
+ final _subkey = List.filled(24 * 4, 0);
+
+ /// for whitening
+ final _kw = List.filled(4 * 2, 0);
+
+ /// for FL and FL^(-1)
+ final _ke = List.filled(6 * 2, 0);
+
+ /// for encryption and decryption
+ final _state = List.filled(4, 0);
+
+ @override
+ String get algorithmName => 'Camellia';
+
+ @override
+ int get blockSize => BLOCK_SIZE;
+
+ @override
+ void init(bool forEncryption, CipherParameters? params) {
+ if (params is! KeyParameter) {
+ throw Exception('Only simple KeyParameter expected.');
+ }
+
+ _setKey(forEncryption, params.key);
+
+ initialised = true;
+ }
+
+ @override
+ int processBlock(
+ Uint8List input,
+ int inOff,
+ Uint8List output,
+ int outOff,
+ ) {
+ if (!initialised) {
+ throw Exception('$algorithmName engine not initialised');
+ }
+
+ if ((inOff + BLOCK_SIZE) > input.length) {
+ throw Exception('Input buffer too short');
+ }
+ if ((outOff + BLOCK_SIZE) > output.length) {
+ throw Exception('Output buffer too short');
+ }
+ if (_keyIs128) {
+ return _processBlock128(input, inOff, output, outOff);
+ } else {
+ return _processBlock256(input, inOff, output, outOff);
+ }
+ }
+
+ @override
+ void reset() {}
+
+ static void _roldq(
+ int rot,
+ List<int> ki,
+ int inOff,
+ List<int> ko,
+ int outOff,
+ ) {
+ ko[outOff] =
+ _shiftLeft32(ki[inOff], rot) | _shiftRight32(ki[1 + inOff], 32 - rot);
+ ko[1 + outOff] = _shiftLeft32(ki[1 + inOff], rot) |
+ _shiftRight32(ki[2 + inOff], 32 - rot);
+ ko[2 + outOff] = _shiftLeft32(ki[2 + inOff], rot) |
+ _shiftRight32(ki[3 + inOff], 32 - rot);
+ ko[3 + outOff] =
+ _shiftLeft32(ki[3 + inOff], rot) | _shiftRight32(ki[inOff], 32 - rot);
+ ki[inOff] = ko[outOff];
+ ki[1 + inOff] = ko[1 + outOff];
+ ki[2 + inOff] = ko[2 + outOff];
+ ki[3 + inOff] = ko[3 + outOff];
+ }
+
+ static void _decroldq(
+ int rot,
+ List<int> ki,
+ int inOff,
+ List<int> ko,
+ int outOff,
+ ) {
+ ko[2 + outOff] =
+ _shiftLeft32(ki[inOff], rot) | _shiftRight32(ki[1 + inOff], 32 - rot);
+ ko[3 + outOff] = _shiftLeft32(ki[1 + inOff], rot) |
+ _shiftRight32(ki[2 + inOff], 32 - rot);
+ ko[outOff] = _shiftLeft32(ki[2 + inOff], rot) |
+ _shiftRight32(ki[3 + inOff], 32 - rot);
+ ko[1 + outOff] =
+ _shiftLeft32(ki[3 + inOff], rot) | _shiftRight32(ki[inOff], 32 - rot);
+ ki[inOff] = ko[2 + outOff];
+ ki[1 + inOff] = ko[3 + outOff];
+ ki[2 + inOff] = ko[outOff];
+ ki[3 + inOff] = ko[1 + outOff];
+ }
+
+ static void _roldqo32(
+ int rot,
+ List<int> ki,
+ int inOff,
+ List<int> ko,
+ int outOff,
+ ) {
+ ko[outOff] = _shiftLeft32(ki[1 + inOff], rot - 32) |
+ _shiftRight32(ki[2 + inOff], 64 - rot);
+ ko[1 + outOff] = _shiftLeft32(ki[2 + inOff], rot - 32) |
+ _shiftRight32(ki[3 + inOff], 64 - rot);
+ ko[2 + outOff] = _shiftLeft32(ki[3 + inOff], rot - 32) |
+ _shiftRight32(ki[inOff], 64 - rot);
+ ko[3 + outOff] = _shiftLeft32(ki[inOff], rot - 32) |
+ _shiftRight32(ki[1 + inOff], 64 - rot);
+ ki[inOff] = ko[outOff];
+ ki[1 + inOff] = ko[1 + outOff];
+ ki[2 + inOff] = ko[2 + outOff];
+ ki[3 + inOff] = ko[3 + outOff];
+ }
+
+ static void _decroldqo32(
+ int rot,
+ List<int> ki,
+ int inOff,
+ List<int> ko,
+ int outOff,
+ ) {
+ ko[2 + outOff] = _shiftLeft32(ki[1 + inOff], rot - 32) |
+ _shiftRight32(ki[2 + inOff], 64 - rot);
+ ko[3 + outOff] = _shiftLeft32(ki[2 + inOff], rot - 32) |
+ _shiftRight32(ki[3 + inOff], 64 - rot);
+ ko[outOff] = _shiftLeft32(ki[3 + inOff], rot - 32) |
+ _shiftRight32(ki[inOff], 64 - rot);
+ ko[1 + outOff] = _shiftLeft32(ki[inOff], rot - 32) |
+ _shiftRight32(ki[1 + inOff], 64 - rot);
+ ki[inOff] = ko[2 + outOff];
+ ki[1 + inOff] = ko[3 + outOff];
+ ki[2 + inOff] = ko[outOff];
+ ki[3 + inOff] = ko[1 + outOff];
+ }
+
+ static int _bytes2uint(Uint8List src, int offset) {
+ return _unpack32(src.sublist(offset, offset + 4));
+ }
+
+ static void _uint2bytes(int word, Uint8List dst, int offset) {
+ dst.setRange(offset, offset + 4, _pack32(word.toUnsigned(32)));
+ }
+
+ static void _camelliaF2(List<int> s, List<int> skey, int keyoff) {
+ var t1 = s[0] ^ skey[keyoff];
+ var u = _sbox4_4404[t1 & _mask8];
+ u ^= _sbox3_3033[(t1 >> 8) & _mask8];
+ u ^= _sbox2_0222[(t1 >> 16) & _mask8];
+ u ^= _sbox1_1110[(t1 >> 24) & _mask8];
+
+ var t2 = s[1] ^ skey[1 + keyoff];
+ var v = _sbox1_1110[t2 & _mask8];
+ v ^= _sbox4_4404[(t2 >> 8) & _mask8];
+ v ^= _sbox3_3033[(t2 >> 16) & _mask8];
+ v ^= _sbox2_0222[(t2 >> 24) & _mask8];
+
+ s[2] ^= u ^ v;
+ s[3] ^= u ^ v ^ _rotateRight32(u, 8);
+
+ t1 = s[2] ^ skey[2 + keyoff];
+ u = _sbox4_4404[t1 & _mask8];
+ u ^= _sbox3_3033[(t1 >> 8) & _mask8];
+ u ^= _sbox2_0222[(t1 >> 16) & _mask8];
+ u ^= _sbox1_1110[(t1 >> 24) & _mask8];
+ t2 = s[3] ^ skey[3 + keyoff];
+ v = _sbox1_1110[t2 & _mask8];
+ v ^= _sbox4_4404[(t2 >> 8) & _mask8];
+ v ^= _sbox3_3033[(t2 >> 16) & _mask8];
+ v ^= _sbox2_0222[(t2 >> 24) & _mask8];
+
+ s[0] ^= u ^ v;
+ s[1] ^= u ^ v ^ _rotateRight32(u, 8);
+ }
+
+ static void _camelliaFLs(List<int> s, List<int> fkey, int keyoff) {
+ s[1] ^= _rotateLeft32(s[0] & fkey[keyoff], 1);
+ s[0] ^= fkey[1 + keyoff] | s[1];
+
+ s[2] ^= fkey[3 + keyoff] | s[3];
+ s[3] ^= _rotateLeft32(fkey[2 + keyoff] & s[2], 1);
+ }
+
+ void _setKey(bool forEncryption, Uint8List key) {
+ final k = List.filled(8, 0);
+ final ka = List.filled(4, 0);
+ final kb = List.filled(4, 0);
+ final t = List.filled(4, 0);
+
+ switch (key.length) {
+ case 16:
+ _keyIs128 = true;
+ k[0] = _bytes2uint(key, 0);
+ k[1] = _bytes2uint(key, 4);
+ k[2] = _bytes2uint(key, 8);
+ k[3] = _bytes2uint(key, 12);
+ break;
+ case 24:
+ k[0] = _bytes2uint(key, 0);
+ k[1] = _bytes2uint(key, 4);
+ k[2] = _bytes2uint(key, 8);
+ k[3] = _bytes2uint(key, 12);
+ k[4] = _bytes2uint(key, 16);
+ k[5] = _bytes2uint(key, 20);
+ k[6] = ~k[4];
+ k[7] = ~k[5];
+ _keyIs128 = false;
+ break;
+ case 32:
+ k[0] = _bytes2uint(key, 0);
+ k[1] = _bytes2uint(key, 4);
+ k[2] = _bytes2uint(key, 8);
+ k[3] = _bytes2uint(key, 12);
+ k[4] = _bytes2uint(key, 16);
+ k[5] = _bytes2uint(key, 20);
+ k[6] = _bytes2uint(key, 24);
+ k[7] = _bytes2uint(key, 28);
+ _keyIs128 = false;
+ break;
+ default:
+ throw Exception('Key size are only 16/24/32 bytes.');
+ }
+
+ for (var i = 0; i < 4; i++) {
+ ka[i] = k[i] ^ k[i + 4];
+ }
+ /* compute KA */
+ _camelliaF2(ka, _sigma, 0);
+ for (var i = 0; i < 4; i++) {
+ ka[i] ^= k[i];
+ }
+ _camelliaF2(ka, _sigma, 4);
+
+ if (_keyIs128) {
+ if (forEncryption) {
+ /* KL dependant keys */
+ _kw[0] = k[0];
+ _kw[1] = k[1];
+ _kw[2] = k[2];
+ _kw[3] = k[3];
+ _roldq(15, k, 0, _subkey, 4);
+ _roldq(30, k, 0, _subkey, 12);
+ _roldq(15, k, 0, t, 0);
+ _subkey[18] = t[2];
+ _subkey[19] = t[3];
+ _roldq(17, k, 0, _ke, 4);
+ _roldq(17, k, 0, _subkey, 24);
+ _roldq(17, k, 0, _subkey, 32);
+ /* KA dependant keys */
+ _subkey[0] = ka[0];
+ _subkey[1] = ka[1];
+ _subkey[2] = ka[2];
+ _subkey[3] = ka[3];
+ _roldq(15, ka, 0, _subkey, 8);
+ _roldq(15, ka, 0, _ke, 0);
+ _roldq(15, ka, 0, t, 0);
+ _subkey[16] = t[0];
+ _subkey[17] = t[1];
+ _roldq(15, ka, 0, _subkey, 20);
+ _roldqo32(34, ka, 0, _subkey, 28);
+ _roldq(17, ka, 0, _kw, 4);
+ } else {
+ // decryption
+ /* KL dependant keys */
+ _kw[4] = k[0];
+ _kw[5] = k[1];
+ _kw[6] = k[2];
+ _kw[7] = k[3];
+ _decroldq(15, k, 0, _subkey, 28);
+ _decroldq(30, k, 0, _subkey, 20);
+ _decroldq(15, k, 0, t, 0);
+ _subkey[16] = t[0];
+ _subkey[17] = t[1];
+ _decroldq(17, k, 0, _ke, 0);
+ _decroldq(17, k, 0, _subkey, 8);
+ _decroldq(17, k, 0, _subkey, 0);
+ /* KA dependant keys */
+ _subkey[34] = ka[0];
+ _subkey[35] = ka[1];
+ _subkey[32] = ka[2];
+ _subkey[33] = ka[3];
+ _decroldq(15, ka, 0, _subkey, 24);
+ _decroldq(15, ka, 0, _ke, 4);
+ _decroldq(15, ka, 0, t, 0);
+ _subkey[18] = t[2];
+ _subkey[19] = t[3];
+ _decroldq(15, ka, 0, _subkey, 12);
+ _decroldqo32(34, ka, 0, _subkey, 4);
+ _roldq(17, ka, 0, _kw, 0);
+ }
+ } else {
+ // 192bit or 256bit
+ /* compute KB */
+ for (var i = 0; i < 4; i++) {
+ kb[i] = ka[i] ^ k[i + 4];
+ }
+ _camelliaF2(kb, _sigma, 8);
+
+ if (forEncryption) {
+ /* KL dependant keys */
+ _kw[0] = k[0];
+ _kw[1] = k[1];
+ _kw[2] = k[2];
+ _kw[3] = k[3];
+ _roldqo32(45, k, 0, _subkey, 16);
+ _roldq(15, k, 0, _ke, 4);
+ _roldq(17, k, 0, _subkey, 32);
+ _roldqo32(34, k, 0, _subkey, 44);
+ /* KR dependant keys */
+ _roldq(15, k, 4, _subkey, 4);
+ _roldq(15, k, 4, _ke, 0);
+ _roldq(30, k, 4, _subkey, 24);
+ _roldqo32(34, k, 4, _subkey, 36);
+ /* KA dependant keys */
+ _roldq(15, ka, 0, _subkey, 8);
+ _roldq(30, ka, 0, _subkey, 20);
+ /* 32bit rotation */
+ _ke[8] = ka[1];
+ _ke[9] = ka[2];
+ _ke[10] = ka[3];
+ _ke[11] = ka[0];
+ _roldqo32(49, ka, 0, _subkey, 40);
+
+ /* KB dependant keys */
+ _subkey[0] = kb[0];
+ _subkey[1] = kb[1];
+ _subkey[2] = kb[2];
+ _subkey[3] = kb[3];
+ _roldq(30, kb, 0, _subkey, 12);
+ _roldq(30, kb, 0, _subkey, 28);
+ _roldqo32(51, kb, 0, _kw, 4);
+ } else {
+ // decryption
+ /* KL dependant keys */
+ _kw[4] = k[0];
+ _kw[5] = k[1];
+ _kw[6] = k[2];
+ _kw[7] = k[3];
+ _decroldqo32(45, k, 0, _subkey, 28);
+ _decroldq(15, k, 0, _ke, 4);
+ _decroldq(17, k, 0, _subkey, 12);
+ _decroldqo32(34, k, 0, _subkey, 0);
+ /* KR dependant keys */
+ _decroldq(15, k, 4, _subkey, 40);
+ _decroldq(15, k, 4, _ke, 8);
+ _decroldq(30, k, 4, _subkey, 20);
+ _decroldqo32(34, k, 4, _subkey, 8);
+ /* KA dependant keys */
+ _decroldq(15, ka, 0, _subkey, 36);
+ _decroldq(30, ka, 0, _subkey, 24);
+ /* 32bit rotation */
+ _ke[2] = ka[1];
+ _ke[3] = ka[2];
+ _ke[0] = ka[3];
+ _ke[1] = ka[0];
+ _decroldqo32(49, ka, 0, _subkey, 4);
+
+ /* KB dependant keys */
+ _subkey[46] = kb[0];
+ _subkey[47] = kb[1];
+ _subkey[44] = kb[2];
+ _subkey[45] = kb[3];
+ _decroldq(30, kb, 0, _subkey, 32);
+ _decroldq(30, kb, 0, _subkey, 16);
+ _roldqo32(51, kb, 0, _kw, 0);
+ }
+ }
+ }
+
+ int _processBlock128(
+ Uint8List input,
+ int inOff,
+ Uint8List output,
+ int outOff,
+ ) {
+ for (var i = 0; i < 4; i++) {
+ _state[i] = _bytes2uint(input, inOff + (i * 4));
+ _state[i] ^= _kw[i];
+ }
+
+ _camelliaF2(_state, _subkey, 0);
+ _camelliaF2(_state, _subkey, 4);
+ _camelliaF2(_state, _subkey, 8);
+ _camelliaFLs(_state, _ke, 0);
+ _camelliaF2(_state, _subkey, 12);
+ _camelliaF2(_state, _subkey, 16);
+ _camelliaF2(_state, _subkey, 20);
+ _camelliaFLs(_state, _ke, 4);
+ _camelliaF2(_state, _subkey, 24);
+ _camelliaF2(_state, _subkey, 28);
+ _camelliaF2(_state, _subkey, 32);
+
+ _state[2] ^= _kw[4];
+ _state[3] ^= _kw[5];
+ _state[0] ^= _kw[6];
+ _state[1] ^= _kw[7];
+
+ _uint2bytes(_state[2], output, outOff);
+ _uint2bytes(_state[3], output, outOff + 4);
+ _uint2bytes(_state[0], output, outOff + 8);
+ _uint2bytes(_state[1], output, outOff + 12);
+
+ return BLOCK_SIZE;
+ }
+
+ int _processBlock256(
+ Uint8List input,
+ int inOff,
+ Uint8List output,
+ int outOff,
+ ) {
+ for (var i = 0; i < 4; i++) {
+ _state[i] = _bytes2uint(input, inOff + (i * 4));
+ _state[i] ^= _kw[i];
+ }
+
+ _camelliaF2(_state, _subkey, 0);
+ _camelliaF2(_state, _subkey, 4);
+ _camelliaF2(_state, _subkey, 8);
+ _camelliaFLs(_state, _ke, 0);
+ _camelliaF2(_state, _subkey, 12);
+ _camelliaF2(_state, _subkey, 16);
+ _camelliaF2(_state, _subkey, 20);
+ _camelliaFLs(_state, _ke, 4);
+ _camelliaF2(_state, _subkey, 24);
+ _camelliaF2(_state, _subkey, 28);
+ _camelliaF2(_state, _subkey, 32);
+ _camelliaFLs(_state, _ke, 8);
+ _camelliaF2(_state, _subkey, 36);
+ _camelliaF2(_state, _subkey, 40);
+ _camelliaF2(_state, _subkey, 44);
+
+ _state[2] ^= _kw[4];
+ _state[3] ^= _kw[5];
+ _state[0] ^= _kw[6];
+ _state[1] ^= _kw[7];
+
+ _uint2bytes(_state[2], output, outOff);
+ _uint2bytes(_state[3], output, outOff + 4);
+ _uint2bytes(_state[0], output, outOff + 8);
+ _uint2bytes(_state[1], output, outOff + 12);
+ return BLOCK_SIZE;
+ }
+
+ static int _unpack32(Uint8List x) => x.buffer.asByteData().getUint32(0);
+ static Uint8List _pack32(int x) =>
+ Uint8List(4)..buffer.asByteData().setUint32(0, x);
+
+ static int _shiftLeft32(int x, int n) {
+ return (x & _mask32) << n;
+ }
+
+ static int _shiftRight32(int x, int n) {
+ return (x & _mask32) >> n;
+ }
+
+ static int _rotateLeft32(int x, int n) {
+ x = x & _mask32;
+ return (x << n) | (x >> 32 - n);
+ }
+
+ static int _rotateRight32(int x, int n) {
+ x = x & _mask32;
+ return (x >> n) | (x << 32 - n);
+ }
+}
diff --git a/lib/block/des_base.dart b/lib/block/des_base.dart
index ca40a65..9104aac 100644
--- a/lib/block/des_base.dart
+++ b/lib/block/des_base.dart
@@ -705,7 +705,7 @@
if (encrypting) {
m = shiftl32(i, 1);
} else {
- m = shiftl32((15 - i), 1);
+ m = shiftl32(15 - i, 1);
}
n = m + 1;
@@ -749,14 +749,14 @@
i1 = newKey[i];
i2 = newKey[i + 1];
- newKey[i] = (shiftl32((i1 & 0x00fc0000), 6)) |
- (shiftl32((i1 & 0x00000fc0), 10)) |
- (shiftr32((i2 & 0x00fc0000), 10)) |
- (shiftr32((i2 & 0x00000fc0), 6));
+ newKey[i] = (shiftl32(i1 & 0x00fc0000, 6)) |
+ (shiftl32(i1 & 0x00000fc0, 10)) |
+ (shiftr32(i2 & 0x00fc0000, 10)) |
+ (shiftr32(i2 & 0x00000fc0, 6));
- newKey[i + 1] = (shiftl32((i1 & 0x0003f000), 12)) |
- (shiftl32((i1 & 0x0000003f), 16)) |
- (shiftr32((i2 & 0x0003f000), 4)) |
+ newKey[i + 1] = (shiftl32(i1 & 0x0003f000, 12)) |
+ (shiftl32(i1 & 0x0000003f, 16)) |
+ (shiftr32(i2 & 0x0003f000, 4)) |
(i2 & 0x0000003f);
}
@@ -777,16 +777,16 @@
work = ((shiftr32(left, 4)) ^ right) & 0x0f0f0f0f;
right ^= work;
- left ^= (shiftl32(work, 4));
+ left ^= shiftl32(work, 4);
work = ((shiftr32(left, 16)) ^ right) & 0x0000ffff;
right ^= work;
- left ^= (shiftl32(work, 16));
+ left ^= shiftl32(work, 16);
work = ((shiftr32(right, 2)) ^ left) & 0x33333333;
left ^= work;
- right ^= (shiftl32(work, 2));
+ right ^= shiftl32(work, 2);
work = ((shiftr32(right, 8)) ^ left) & 0x00ff00ff;
left ^= work;
- right ^= (shiftl32(work, 8));
+ right ^= shiftl32(work, 8);
right = (shiftl32(right, 1)) | (shiftr32(right, 31));
work = (left ^ right) & 0xaaaaaaaa;
left ^= work;
@@ -828,16 +828,16 @@
left = (shiftl32(left, 31)) | (shiftr32(left, 1));
work = ((shiftr32(left, 8)) ^ right) & 0x00ff00ff;
right ^= work;
- left ^= (shiftl32(work, 8));
+ left ^= shiftl32(work, 8);
work = ((shiftr32(left, 2)) ^ right) & 0x33333333;
right ^= work;
- left ^= (shiftl32(work, 2));
+ left ^= shiftl32(work, 2);
work = ((shiftr32(right, 16)) ^ left) & 0x0000ffff;
left ^= work;
- right ^= (shiftl32(work, 16));
+ right ^= shiftl32(work, 16);
work = ((shiftr32(right, 4)) ^ left) & 0x0f0f0f0f;
left ^= work;
- right ^= (shiftl32(work, 4));
+ right ^= shiftl32(work, 4);
_intToBigEndian(right, out, outOff);
_intToBigEndian(left, out, outOff + 4);
@@ -847,14 +847,14 @@
bs[off] = shiftr32(n, 24);
bs[++off] = shiftr32(n, 16);
bs[++off] = shiftr32(n, 8);
- bs[++off] = (n);
+ bs[++off] = n;
}
int _bigEndianToInt(Uint8List bs, int off) {
var n = shiftl32(bs[off], 24);
- n |= shiftl32((bs[++off] & 0xff), 16);
- n |= shiftl32((bs[++off] & 0xff), 8);
- n |= (bs[++off] & 0xff);
+ n |= shiftl32(bs[++off] & 0xff, 16);
+ n |= shiftl32(bs[++off] & 0xff, 8);
+ n |= bs[++off] & 0xff;
return n;
}
}
diff --git a/lib/block/modes/ccm.dart b/lib/block/modes/ccm.dart
index 1f787e4..bcd74c1 100644
--- a/lib/block/modes/ccm.dart
+++ b/lib/block/modes/ccm.dart
@@ -25,8 +25,8 @@
late KeyParameter _keyParam;
- var associatedText = BytesBuilder();
- var data = BytesBuilder();
+ BytesBuilder associatedText = BytesBuilder();
+ BytesBuilder data = BytesBuilder();
late bool _forEncryption;
@@ -39,7 +39,7 @@
return CCMBlockCipher(underlying);
});
- CCMBlockCipher(BlockCipher underlyingCipher) : super(underlyingCipher) {
+ CCMBlockCipher(super.underlyingCipher) {
_macBlock = Uint8List(blockSize);
if (blockSize != 16) {
throw ArgumentError('CCM requires a block size of 16');
@@ -54,7 +54,7 @@
}
@override
- void init(forEncryption, covariant CipherParameters params) {
+ void init(bool forEncryption, covariant CipherParameters params) {
_forEncryption = forEncryption;
KeyParameter key;
@@ -121,7 +121,7 @@
}
var iv = Uint8List(blockSize);
- iv[0] = ((q - 1) & 0x7);
+ iv[0] = (q - 1) & 0x7;
arrayCopy(nonce, 0, iv, 1, nonce.length);
BlockCipher ctrCipher =
@@ -234,7 +234,7 @@
var q = dataLen;
var count = 1;
while (q > 0) {
- b0[b0.length - count] = (q & 0xff);
+ b0[b0.length - count] = q & 0xff;
q = cshiftr32(q, 8);
count++;
}
@@ -249,16 +249,16 @@
var textLength = _getAssociatedTextLength();
if (textLength < ((1 << 16) - (1 << 8))) {
- cMac.updateByte((textLength >> 8));
+ cMac.updateByte(textLength >> 8);
cMac.updateByte(textLength);
extra = 2;
} else {
cMac.updateByte(0xff);
cMac.updateByte(0xfe);
- cMac.updateByte((textLength >> 24));
- cMac.updateByte((textLength >> 16));
- cMac.updateByte((textLength >> 8));
+ cMac.updateByte(textLength >> 24);
+ cMac.updateByte(textLength >> 16);
+ cMac.updateByte(textLength >> 8);
cMac.updateByte(textLength);
extra = 6;
@@ -315,8 +315,8 @@
}
@override
- int getOutputSize(int len) {
- var totalData = len + data.length;
+ int getOutputSize(int length) {
+ var totalData = length + data.length;
if (forEncryption) {
return totalData + macSize;
diff --git a/lib/block/modes/ctr.dart b/lib/block/modes/ctr.dart
index 9ed7c2b..769146a 100644
--- a/lib/block/modes/ctr.dart
+++ b/lib/block/modes/ctr.dart
@@ -18,6 +18,5 @@
underlying.blockSize, CTRStreamCipher(underlying));
});
- CTRBlockCipher(int blockSize, StreamCipher underlyingCipher)
- : super(blockSize, underlyingCipher);
+ CTRBlockCipher(super.blockSize, super.underlyingCipher);
}
diff --git a/lib/block/modes/gcm.dart b/lib/block/modes/gcm.dart
index 8f9333c..b46b33a 100644
--- a/lib/block/modes/gcm.dart
+++ b/lib/block/modes/gcm.dart
@@ -28,7 +28,7 @@
late int _processedBytes;
int _blocksRemaining = 0;
- GCMBlockCipher(BlockCipher cipher) : super(cipher);
+ GCMBlockCipher(super.cipher);
@override
String get algorithmName => '${underlyingCipher.algorithmName}/GCM';
diff --git a/lib/block/modes/gctr.dart b/lib/block/modes/gctr.dart
index d127582..8ebba7e 100644
--- a/lib/block/modes/gctr.dart
+++ b/lib/block/modes/gctr.dart
@@ -5,8 +5,8 @@
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
-import 'package:pointycastle/src/registry/registry.dart';
import 'package:pointycastle/src/impl/base_block_cipher.dart';
+import 'package:pointycastle/src/registry/registry.dart';
import 'package:pointycastle/src/ufixnum.dart';
/// Implementation of GOST 28147 OFB counter mode (GCTR) on top of a [BlockCipher].
diff --git a/lib/block/modes/sic.dart b/lib/block/modes/sic.dart
index 4197d5d..035ae67 100644
--- a/lib/block/modes/sic.dart
+++ b/lib/block/modes/sic.dart
@@ -19,6 +19,5 @@
underlying.blockSize, SICStreamCipher(underlying));
});
- SICBlockCipher(int blockSize, StreamCipher underlyingCipher)
- : super(blockSize, underlyingCipher);
+ SICBlockCipher(super.blockSize, super.underlyingCipher);
}
diff --git a/lib/block/rc2_engine.dart b/lib/block/rc2_engine.dart
index b18e0a2..4e7a919 100644
--- a/lib/block/rc2_engine.dart
+++ b/lib/block/rc2_engine.dart
@@ -314,7 +314,7 @@
var newKey = List<int>.generate(64, (index) => 0);
for (var i = 0; i != newKey.length; i++) {
- newKey[i] = (xKey[2 * i] + (xKey[2 * i + 1] << 8));
+ newKey[i] = xKey[2 * i] + (xKey[2 * i + 1] << 8);
}
return newKey;
@@ -426,13 +426,13 @@
}
out[outOff + 0] = x10;
- out[outOff + 1] = (x10 >> 8);
+ out[outOff + 1] = x10 >> 8;
out[outOff + 2] = x32;
- out[outOff + 3] = (x32 >> 8);
+ out[outOff + 3] = x32 >> 8;
out[outOff + 4] = x54;
- out[outOff + 5] = (x54 >> 8);
+ out[outOff + 5] = x54 >> 8;
out[outOff + 6] = x76;
- out[outOff + 7] = (x76 >> 8);
+ out[outOff + 7] = x76 >> 8;
}
void decryptBlock(Uint8List input, int inOff, Uint8List out, int outOff) {
@@ -487,12 +487,12 @@
}
out[outOff + 0] = x10;
- out[outOff + 1] = (x10 >> 8);
+ out[outOff + 1] = x10 >> 8;
out[outOff + 2] = x32;
- out[outOff + 3] = (x32 >> 8);
+ out[outOff + 3] = x32 >> 8;
out[outOff + 4] = x54;
- out[outOff + 5] = (x54 >> 8);
+ out[outOff + 5] = x54 >> 8;
out[outOff + 6] = x76;
- out[outOff + 7] = (x76 >> 8);
+ out[outOff + 7] = x76 >> 8;
}
}
diff --git a/lib/block/twofish.dart b/lib/block/twofish.dart
new file mode 100644
index 0000000..f78eb17
--- /dev/null
+++ b/lib/block/twofish.dart
@@ -0,0 +1,694 @@
+// See file LICENSE for more information.
+
+library impl.block_cipher.twofish;
+
+import 'dart:core';
+import 'dart:typed_data';
+
+import 'package:pointycastle/api.dart';
+import 'package:pointycastle/src/impl/base_block_cipher.dart';
+import 'package:pointycastle/src/registry/registry.dart';
+
+/// A class that provides Twofish encryption operations.
+/// Author Nguyen Van Nguyen <nguyennv1981@gmail.com>
+class TwofishEngine extends BaseBlockCipher {
+ static final FactoryConfig factoryConfig = StaticFactoryConfig(
+ BlockCipher,
+ 'Twofish',
+ () => TwofishEngine(),
+ );
+
+ /// Q-Table 0
+ static const _q0 = [
+ 0xa9, 0x67, 0xb3, 0xe8, 0x04, 0xfd, 0xa3, 0x76, // 0 - 7
+ 0x9a, 0x92, 0x80, 0x78, 0xe4, 0xdd, 0xd1, 0x38,
+ 0x0d, 0xc6, 0x35, 0x98, 0x18, 0xf7, 0xec, 0x6c,
+ 0x43, 0x75, 0x37, 0x26, 0xfa, 0x13, 0x94, 0x48,
+ 0xf2, 0xd0, 0x8b, 0x30, 0x84, 0x54, 0xdf, 0x23,
+ 0x19, 0x5b, 0x3d, 0x59, 0xf3, 0xae, 0xa2, 0x82,
+ 0x63, 0x01, 0x83, 0x2e, 0xd9, 0x51, 0x9b, 0x7c,
+ 0xa6, 0xeb, 0xa5, 0xbe, 0x16, 0x0c, 0xe3, 0x61,
+ 0xc0, 0x8c, 0x3a, 0xf5, 0x73, 0x2c, 0x25, 0x0b,
+ 0xbb, 0x4e, 0x89, 0x6b, 0x53, 0x6a, 0xb4, 0xf1,
+ 0xe1, 0xe6, 0xbd, 0x45, 0xe2, 0xf4, 0xb6, 0x66,
+ 0xcc, 0x95, 0x03, 0x56, 0xd4, 0x1c, 0x1e, 0xd7,
+ 0xfb, 0xc3, 0x8e, 0xb5, 0xe9, 0xcf, 0xbf, 0xba,
+ 0xea, 0x77, 0x39, 0xaf, 0x33, 0xc9, 0x62, 0x71,
+ 0x81, 0x79, 0x09, 0xad, 0x24, 0xcd, 0xf9, 0xd8,
+ 0xe5, 0xc5, 0xb9, 0x4d, 0x44, 0x08, 0x86, 0xe7,
+ 0xa1, 0x1d, 0xaa, 0xed, 0x06, 0x70, 0xb2, 0xd2,
+ 0x41, 0x7b, 0xa0, 0x11, 0x31, 0xc2, 0x27, 0x90,
+ 0x20, 0xf6, 0x60, 0xff, 0x96, 0x5c, 0xb1, 0xab,
+ 0x9e, 0x9c, 0x52, 0x1b, 0x5f, 0x93, 0x0a, 0xef,
+ 0x91, 0x85, 0x49, 0xee, 0x2d, 0x4f, 0x8f, 0x3b,
+ 0x47, 0x87, 0x6d, 0x46, 0xd6, 0x3e, 0x69, 0x64,
+ 0x2a, 0xce, 0xcb, 0x2f, 0xfc, 0x97, 0x05, 0x7a,
+ 0xac, 0x7f, 0xd5, 0x1a, 0x4b, 0x0e, 0xa7, 0x5a,
+ 0x28, 0x14, 0x3f, 0x29, 0x88, 0x3c, 0x4c, 0x02,
+ 0xb8, 0xda, 0xb0, 0x17, 0x55, 0x1f, 0x8a, 0x7d,
+ 0x57, 0xc7, 0x8d, 0x74, 0xb7, 0xc4, 0x9f, 0x72,
+ 0x7e, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34,
+ 0x6e, 0x50, 0xde, 0x68, 0x65, 0xbc, 0xdb, 0xf8,
+ 0xc8, 0xa8, 0x2b, 0x40, 0xdc, 0xfe, 0x32, 0xa4,
+ 0xca, 0x10, 0x21, 0xf0, 0xd3, 0x5d, 0x0f, 0x00,
+ 0x6f, 0x9d, 0x36, 0x42, 0x4a, 0x5e, 0xc1, 0xe0
+ ];
+
+ /// Q-Table 1
+ static const _q1 = [
+ 0x75, 0xf3, 0xc6, 0xf4, 0xdb, 0x7b, 0xfb, 0xc8, // 0 - 7
+ 0x4a, 0xd3, 0xe6, 0x6b, 0x45, 0x7d, 0xe8, 0x4b,
+ 0xd6, 0x32, 0xd8, 0xfd, 0x37, 0x71, 0xf1, 0xe1,
+ 0x30, 0x0f, 0xf8, 0x1b, 0x87, 0xfa, 0x06, 0x3f,
+ 0x5e, 0xba, 0xae, 0x5b, 0x8a, 0x00, 0xbc, 0x9d,
+ 0x6d, 0xc1, 0xb1, 0x0e, 0x80, 0x5d, 0xd2, 0xd5,
+ 0xa0, 0x84, 0x07, 0x14, 0xb5, 0x90, 0x2c, 0xa3,
+ 0xb2, 0x73, 0x4c, 0x54, 0x92, 0x74, 0x36, 0x51,
+ 0x38, 0xb0, 0xbd, 0x5a, 0xfc, 0x60, 0x62, 0x96,
+ 0x6c, 0x42, 0xf7, 0x10, 0x7c, 0x28, 0x27, 0x8c,
+ 0x13, 0x95, 0x9c, 0xc7, 0x24, 0x46, 0x3b, 0x70,
+ 0xca, 0xe3, 0x85, 0xcb, 0x11, 0xd0, 0x93, 0xb8,
+ 0xa6, 0x83, 0x20, 0xff, 0x9f, 0x77, 0xc3, 0xcc,
+ 0x03, 0x6f, 0x08, 0xbf, 0x40, 0xe7, 0x2b, 0xe2,
+ 0x79, 0x0c, 0xaa, 0x82, 0x41, 0x3a, 0xea, 0xb9,
+ 0xe4, 0x9a, 0xa4, 0x97, 0x7e, 0xda, 0x7a, 0x17,
+ 0x66, 0x94, 0xa1, 0x1d, 0x3d, 0xf0, 0xde, 0xb3,
+ 0x0b, 0x72, 0xa7, 0x1c, 0xef, 0xd1, 0x53, 0x3e,
+ 0x8f, 0x33, 0x26, 0x5f, 0xec, 0x76, 0x2a, 0x49,
+ 0x81, 0x88, 0xee, 0x21, 0xc4, 0x1a, 0xeb, 0xd9,
+ 0xc5, 0x39, 0x99, 0xcd, 0xad, 0x31, 0x8b, 0x01,
+ 0x18, 0x23, 0xdd, 0x1f, 0x4e, 0x2d, 0xf9, 0x48,
+ 0x4f, 0xf2, 0x65, 0x8e, 0x78, 0x5c, 0x58, 0x19,
+ 0x8d, 0xe5, 0x98, 0x57, 0x67, 0x7f, 0x05, 0x64,
+ 0xaf, 0x63, 0xb6, 0xfe, 0xf5, 0xb7, 0x3c, 0xa5,
+ 0xce, 0xe9, 0x68, 0x44, 0xe0, 0x4d, 0x43, 0x69,
+ 0x29, 0x2e, 0xac, 0x15, 0x59, 0xa8, 0x0a, 0x9e,
+ 0x6e, 0x47, 0xdf, 0x34, 0x35, 0x6a, 0xcf, 0xdc,
+ 0x22, 0xc9, 0xc0, 0x9b, 0x89, 0xd4, 0xed, 0xab,
+ 0x12, 0xa2, 0x0d, 0x52, 0xbb, 0x02, 0x2f, 0xa9,
+ 0xd7, 0x61, 0x1e, 0xb4, 0x50, 0x04, 0xf6, 0xc2,
+ 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xbe, 0x91
+ ];
+
+ /// M-Table 0
+ static const _m0 = [
+ 0xbcbc3275, 0xecec21f3, 0x202043c6, 0xb3b3c9f4, 0xdada03db, 0x02028b7b,
+ 0xe2e22bfb, 0x9e9efac8, // 0 - 7
+ 0xc9c9ec4a, 0xd4d409d3, 0x18186be6, 0x1e1e9f6b, 0x98980e45, 0xb2b2387d,
+ 0xa6a6d2e8, 0x2626b74b,
+ 0x3c3c57d6, 0x93938a32, 0x8282eed8, 0x525298fd, 0x7b7bd437, 0xbbbb3771,
+ 0x5b5b97f1, 0x474783e1,
+ 0x24243c30, 0x5151e20f, 0xbabac6f8, 0x4a4af31b, 0xbfbf4887, 0x0d0d70fa,
+ 0xb0b0b306, 0x7575de3f,
+ 0xd2d2fd5e, 0x7d7d20ba, 0x666631ae, 0x3a3aa35b, 0x59591c8a, 0x00000000,
+ 0xcdcd93bc, 0x1a1ae09d,
+ 0xaeae2c6d, 0x7f7fabc1, 0x2b2bc7b1, 0xbebeb90e, 0xe0e0a080, 0x8a8a105d,
+ 0x3b3b52d2, 0x6464bad5,
+ 0xd8d888a0, 0xe7e7a584, 0x5f5fe807, 0x1b1b1114, 0x2c2cc2b5, 0xfcfcb490,
+ 0x3131272c, 0x808065a3,
+ 0x73732ab2, 0x0c0c8173, 0x79795f4c, 0x6b6b4154, 0x4b4b0292, 0x53536974,
+ 0x94948f36, 0x83831f51,
+ 0x2a2a3638, 0xc4c49cb0, 0x2222c8bd, 0xd5d5f85a, 0xbdbdc3fc, 0x48487860,
+ 0xffffce62, 0x4c4c0796,
+ 0x4141776c, 0xc7c7e642, 0xebeb24f7, 0x1c1c1410, 0x5d5d637c, 0x36362228,
+ 0x6767c027, 0xe9e9af8c,
+ 0x4444f913, 0x1414ea95, 0xf5f5bb9c, 0xcfcf18c7, 0x3f3f2d24, 0xc0c0e346,
+ 0x7272db3b, 0x54546c70,
+ 0x29294cca, 0xf0f035e3, 0x0808fe85, 0xc6c617cb, 0xf3f34f11, 0x8c8ce4d0,
+ 0xa4a45993, 0xcaca96b8,
+ 0x68683ba6, 0xb8b84d83, 0x38382820, 0xe5e52eff, 0xadad569f, 0x0b0b8477,
+ 0xc8c81dc3, 0x9999ffcc,
+ 0x5858ed03, 0x19199a6f, 0x0e0e0a08, 0x95957ebf, 0x70705040, 0xf7f730e7,
+ 0x6e6ecf2b, 0x1f1f6ee2,
+ 0xb5b53d79, 0x09090f0c, 0x616134aa, 0x57571682, 0x9f9f0b41, 0x9d9d803a,
+ 0x111164ea, 0x2525cdb9,
+ 0xafafdde4, 0x4545089a, 0xdfdf8da4, 0xa3a35c97, 0xeaead57e, 0x353558da,
+ 0xededd07a, 0x4343fc17,
+ 0xf8f8cb66, 0xfbfbb194, 0x3737d3a1, 0xfafa401d, 0xc2c2683d, 0xb4b4ccf0,
+ 0x32325dde, 0x9c9c71b3,
+ 0x5656e70b, 0xe3e3da72, 0x878760a7, 0x15151b1c, 0xf9f93aef, 0x6363bfd1,
+ 0x3434a953, 0x9a9a853e,
+ 0xb1b1428f, 0x7c7cd133, 0x88889b26, 0x3d3da65f, 0xa1a1d7ec, 0xe4e4df76,
+ 0x8181942a, 0x91910149,
+ 0x0f0ffb81, 0xeeeeaa88, 0x161661ee, 0xd7d77321, 0x9797f5c4, 0xa5a5a81a,
+ 0xfefe3feb, 0x6d6db5d9,
+ 0x7878aec5, 0xc5c56d39, 0x1d1de599, 0x7676a4cd, 0x3e3edcad, 0xcbcb6731,
+ 0xb6b6478b, 0xefef5b01,
+ 0x12121e18, 0x6060c523, 0x6a6ab0dd, 0x4d4df61f, 0xcecee94e, 0xdede7c2d,
+ 0x55559df9, 0x7e7e5a48,
+ 0x2121b24f, 0x03037af2, 0xa0a02665, 0x5e5e198e, 0x5a5a6678, 0x65654b5c,
+ 0x62624e58, 0xfdfd4519,
+ 0x0606f48d, 0x404086e5, 0xf2f2be98, 0x3333ac57, 0x17179067, 0x05058e7f,
+ 0xe8e85e05, 0x4f4f7d64,
+ 0x89896aaf, 0x10109563, 0x74742fb6, 0x0a0a75fe, 0x5c5c92f5, 0x9b9b74b7,
+ 0x2d2d333c, 0x3030d6a5,
+ 0x2e2e49ce, 0x494989e9, 0x46467268, 0x77775544, 0xa8a8d8e0, 0x9696044d,
+ 0x2828bd43, 0xa9a92969,
+ 0xd9d97929, 0x8686912e, 0xd1d187ac, 0xf4f44a15, 0x8d8d1559, 0xd6d682a8,
+ 0xb9b9bc0a, 0x42420d9e,
+ 0xf6f6c16e, 0x2f2fb847, 0xdddd06df, 0x23233934, 0xcccc6235, 0xf1f1c46a,
+ 0xc1c112cf, 0x8585ebdc,
+ 0x8f8f9e22, 0x7171a1c9, 0x9090f0c0, 0xaaaa539b, 0x0101f189, 0x8b8be1d4,
+ 0x4e4e8ced, 0x8e8e6fab,
+ 0xababa212, 0x6f6f3ea2, 0xe6e6540d, 0xdbdbf252, 0x92927bbb, 0xb7b7b602,
+ 0x6969ca2f, 0x3939d9a9,
+ 0xd3d30cd7, 0xa7a72361, 0xa2a2ad1e, 0xc3c399b4, 0x6c6c4450, 0x07070504,
+ 0x04047ff6, 0x272746c2,
+ 0xacaca716, 0xd0d07625, 0x50501386, 0xdcdcf756, 0x84841a55, 0xe1e15109,
+ 0x7a7a25be, 0x1313ef91
+ ];
+
+ /// M-Table 1
+ static const _m1 = [
+ 0xa9d93939, 0x67901717, 0xb3719c9c, 0xe8d2a6a6, 0x04050707, 0xfd985252,
+ 0xa3658080, 0x76dfe4e4, // 0 - 7
+ 0x9a084545, 0x92024b4b, 0x80a0e0e0, 0x78665a5a, 0xe4ddafaf, 0xddb06a6a,
+ 0xd1bf6363, 0x38362a2a,
+ 0x0d54e6e6, 0xc6432020, 0x3562cccc, 0x98bef2f2, 0x181e1212, 0xf724ebeb,
+ 0xecd7a1a1, 0x6c774141,
+ 0x43bd2828, 0x7532bcbc, 0x37d47b7b, 0x269b8888, 0xfa700d0d, 0x13f94444,
+ 0x94b1fbfb, 0x485a7e7e,
+ 0xf27a0303, 0xd0e48c8c, 0x8b47b6b6, 0x303c2424, 0x84a5e7e7, 0x54416b6b,
+ 0xdf06dddd, 0x23c56060,
+ 0x1945fdfd, 0x5ba33a3a, 0x3d68c2c2, 0x59158d8d, 0xf321ecec, 0xae316666,
+ 0xa23e6f6f, 0x82165757,
+ 0x63951010, 0x015befef, 0x834db8b8, 0x2e918686, 0xd9b56d6d, 0x511f8383,
+ 0x9b53aaaa, 0x7c635d5d,
+ 0xa63b6868, 0xeb3ffefe, 0xa5d63030, 0xbe257a7a, 0x16a7acac, 0x0c0f0909,
+ 0xe335f0f0, 0x6123a7a7,
+ 0xc0f09090, 0x8cafe9e9, 0x3a809d9d, 0xf5925c5c, 0x73810c0c, 0x2c273131,
+ 0x2576d0d0, 0x0be75656,
+ 0xbb7b9292, 0x4ee9cece, 0x89f10101, 0x6b9f1e1e, 0x53a93434, 0x6ac4f1f1,
+ 0xb499c3c3, 0xf1975b5b,
+ 0xe1834747, 0xe66b1818, 0xbdc82222, 0x450e9898, 0xe26e1f1f, 0xf4c9b3b3,
+ 0xb62f7474, 0x66cbf8f8,
+ 0xccff9999, 0x95ea1414, 0x03ed5858, 0x56f7dcdc, 0xd4e18b8b, 0x1c1b1515,
+ 0x1eada2a2, 0xd70cd3d3,
+ 0xfb2be2e2, 0xc31dc8c8, 0x8e195e5e, 0xb5c22c2c, 0xe9894949, 0xcf12c1c1,
+ 0xbf7e9595, 0xba207d7d,
+ 0xea641111, 0x77840b0b, 0x396dc5c5, 0xaf6a8989, 0x33d17c7c, 0xc9a17171,
+ 0x62ceffff, 0x7137bbbb,
+ 0x81fb0f0f, 0x793db5b5, 0x0951e1e1, 0xaddc3e3e, 0x242d3f3f, 0xcda47676,
+ 0xf99d5555, 0xd8ee8282,
+ 0xe5864040, 0xc5ae7878, 0xb9cd2525, 0x4d049696, 0x44557777, 0x080a0e0e,
+ 0x86135050, 0xe730f7f7,
+ 0xa1d33737, 0x1d40fafa, 0xaa346161, 0xed8c4e4e, 0x06b3b0b0, 0x706c5454,
+ 0xb22a7373, 0xd2523b3b,
+ 0x410b9f9f, 0x7b8b0202, 0xa088d8d8, 0x114ff3f3, 0x3167cbcb, 0xc2462727,
+ 0x27c06767, 0x90b4fcfc,
+ 0x20283838, 0xf67f0404, 0x60784848, 0xff2ee5e5, 0x96074c4c, 0x5c4b6565,
+ 0xb1c72b2b, 0xab6f8e8e,
+ 0x9e0d4242, 0x9cbbf5f5, 0x52f2dbdb, 0x1bf34a4a, 0x5fa63d3d, 0x9359a4a4,
+ 0x0abcb9b9, 0xef3af9f9,
+ 0x91ef1313, 0x85fe0808, 0x49019191, 0xee611616, 0x2d7cdede, 0x4fb22121,
+ 0x8f42b1b1, 0x3bdb7272,
+ 0x47b82f2f, 0x8748bfbf, 0x6d2caeae, 0x46e3c0c0, 0xd6573c3c, 0x3e859a9a,
+ 0x6929a9a9, 0x647d4f4f,
+ 0x2a948181, 0xce492e2e, 0xcb17c6c6, 0x2fca6969, 0xfcc3bdbd, 0x975ca3a3,
+ 0x055ee8e8, 0x7ad0eded,
+ 0xac87d1d1, 0x7f8e0505, 0xd5ba6464, 0x1aa8a5a5, 0x4bb72626, 0x0eb9bebe,
+ 0xa7608787, 0x5af8d5d5,
+ 0x28223636, 0x14111b1b, 0x3fde7575, 0x2979d9d9, 0x88aaeeee, 0x3c332d2d,
+ 0x4c5f7979, 0x02b6b7b7,
+ 0xb896caca, 0xda583535, 0xb09cc4c4, 0x17fc4343, 0x551a8484, 0x1ff64d4d,
+ 0x8a1c5959, 0x7d38b2b2,
+ 0x57ac3333, 0xc718cfcf, 0x8df40606, 0x74695353, 0xb7749b9b, 0xc4f59797,
+ 0x9f56adad, 0x72dae3e3,
+ 0x7ed5eaea, 0x154af4f4, 0x229e8f8f, 0x12a2abab, 0x584e6262, 0x07e85f5f,
+ 0x99e51d1d, 0x34392323,
+ 0x6ec1f6f6, 0x50446c6c, 0xde5d3232, 0x68724646, 0x6526a0a0, 0xbc93cdcd,
+ 0xdb03dada, 0xf8c6baba,
+ 0xc8fa9e9e, 0xa882d6d6, 0x2bcf6e6e, 0x40507070, 0xdceb8585, 0xfe750a0a,
+ 0x328a9393, 0xa48ddfdf,
+ 0xca4c2929, 0x10141c1c, 0x2173d7d7, 0xf0ccb4b4, 0xd309d4d4, 0x5d108a8a,
+ 0x0fe25151, 0x00000000,
+ 0x6f9a1919, 0x9de01a1a, 0x368f9494, 0x42e6c7c7, 0x4aecc9c9, 0x5efdd2d2,
+ 0xc1ab7f7f, 0xe0d8a8a8
+ ];
+
+ /// M-Table 2
+ static const _m2 = [
+ 0xbc75bc32, 0xecf3ec21, 0x20c62043, 0xb3f4b3c9, 0xdadbda03, 0x027b028b,
+ 0xe2fbe22b, 0x9ec89efa, // 0 - 7
+ 0xc94ac9ec, 0xd4d3d409, 0x18e6186b, 0x1e6b1e9f, 0x9845980e, 0xb27db238,
+ 0xa6e8a6d2, 0x264b26b7,
+ 0x3cd63c57, 0x9332938a, 0x82d882ee, 0x52fd5298, 0x7b377bd4, 0xbb71bb37,
+ 0x5bf15b97, 0x47e14783,
+ 0x2430243c, 0x510f51e2, 0xbaf8bac6, 0x4a1b4af3, 0xbf87bf48, 0x0dfa0d70,
+ 0xb006b0b3, 0x753f75de,
+ 0xd25ed2fd, 0x7dba7d20, 0x66ae6631, 0x3a5b3aa3, 0x598a591c, 0x00000000,
+ 0xcdbccd93, 0x1a9d1ae0,
+ 0xae6dae2c, 0x7fc17fab, 0x2bb12bc7, 0xbe0ebeb9, 0xe080e0a0, 0x8a5d8a10,
+ 0x3bd23b52, 0x64d564ba,
+ 0xd8a0d888, 0xe784e7a5, 0x5f075fe8, 0x1b141b11, 0x2cb52cc2, 0xfc90fcb4,
+ 0x312c3127, 0x80a38065,
+ 0x73b2732a, 0x0c730c81, 0x794c795f, 0x6b546b41, 0x4b924b02, 0x53745369,
+ 0x9436948f, 0x8351831f,
+ 0x2a382a36, 0xc4b0c49c, 0x22bd22c8, 0xd55ad5f8, 0xbdfcbdc3, 0x48604878,
+ 0xff62ffce, 0x4c964c07,
+ 0x416c4177, 0xc742c7e6, 0xebf7eb24, 0x1c101c14, 0x5d7c5d63, 0x36283622,
+ 0x672767c0, 0xe98ce9af,
+ 0x441344f9, 0x149514ea, 0xf59cf5bb, 0xcfc7cf18, 0x3f243f2d, 0xc046c0e3,
+ 0x723b72db, 0x5470546c,
+ 0x29ca294c, 0xf0e3f035, 0x088508fe, 0xc6cbc617, 0xf311f34f, 0x8cd08ce4,
+ 0xa493a459, 0xcab8ca96,
+ 0x68a6683b, 0xb883b84d, 0x38203828, 0xe5ffe52e, 0xad9fad56, 0x0b770b84,
+ 0xc8c3c81d, 0x99cc99ff,
+ 0x580358ed, 0x196f199a, 0x0e080e0a, 0x95bf957e, 0x70407050, 0xf7e7f730,
+ 0x6e2b6ecf, 0x1fe21f6e,
+ 0xb579b53d, 0x090c090f, 0x61aa6134, 0x57825716, 0x9f419f0b, 0x9d3a9d80,
+ 0x11ea1164, 0x25b925cd,
+ 0xafe4afdd, 0x459a4508, 0xdfa4df8d, 0xa397a35c, 0xea7eead5, 0x35da3558,
+ 0xed7aedd0, 0x431743fc,
+ 0xf866f8cb, 0xfb94fbb1, 0x37a137d3, 0xfa1dfa40, 0xc23dc268, 0xb4f0b4cc,
+ 0x32de325d, 0x9cb39c71,
+ 0x560b56e7, 0xe372e3da, 0x87a78760, 0x151c151b, 0xf9eff93a, 0x63d163bf,
+ 0x345334a9, 0x9a3e9a85,
+ 0xb18fb142, 0x7c337cd1, 0x8826889b, 0x3d5f3da6, 0xa1eca1d7, 0xe476e4df,
+ 0x812a8194, 0x91499101,
+ 0x0f810ffb, 0xee88eeaa, 0x16ee1661, 0xd721d773, 0x97c497f5, 0xa51aa5a8,
+ 0xfeebfe3f, 0x6dd96db5,
+ 0x78c578ae, 0xc539c56d, 0x1d991de5, 0x76cd76a4, 0x3ead3edc, 0xcb31cb67,
+ 0xb68bb647, 0xef01ef5b,
+ 0x1218121e, 0x602360c5, 0x6add6ab0, 0x4d1f4df6, 0xce4ecee9, 0xde2dde7c,
+ 0x55f9559d, 0x7e487e5a,
+ 0x214f21b2, 0x03f2037a, 0xa065a026, 0x5e8e5e19, 0x5a785a66, 0x655c654b,
+ 0x6258624e, 0xfd19fd45,
+ 0x068d06f4, 0x40e54086, 0xf298f2be, 0x335733ac, 0x17671790, 0x057f058e,
+ 0xe805e85e, 0x4f644f7d,
+ 0x89af896a, 0x10631095, 0x74b6742f, 0x0afe0a75, 0x5cf55c92, 0x9bb79b74,
+ 0x2d3c2d33, 0x30a530d6,
+ 0x2ece2e49, 0x49e94989, 0x46684672, 0x77447755, 0xa8e0a8d8, 0x964d9604,
+ 0x284328bd, 0xa969a929,
+ 0xd929d979, 0x862e8691, 0xd1acd187, 0xf415f44a, 0x8d598d15, 0xd6a8d682,
+ 0xb90ab9bc, 0x429e420d,
+ 0xf66ef6c1, 0x2f472fb8, 0xdddfdd06, 0x23342339, 0xcc35cc62, 0xf16af1c4,
+ 0xc1cfc112, 0x85dc85eb,
+ 0x8f228f9e, 0x71c971a1, 0x90c090f0, 0xaa9baa53, 0x018901f1, 0x8bd48be1,
+ 0x4eed4e8c, 0x8eab8e6f,
+ 0xab12aba2, 0x6fa26f3e, 0xe60de654, 0xdb52dbf2, 0x92bb927b, 0xb702b7b6,
+ 0x692f69ca, 0x39a939d9,
+ 0xd3d7d30c, 0xa761a723, 0xa21ea2ad, 0xc3b4c399, 0x6c506c44, 0x07040705,
+ 0x04f6047f, 0x27c22746,
+ 0xac16aca7, 0xd025d076, 0x50865013, 0xdc56dcf7, 0x8455841a, 0xe109e151,
+ 0x7abe7a25, 0x139113ef
+ ];
+
+ /// M-Table 3
+ static const _m3 = [
+ 0xd939a9d9, 0x90176790, 0x719cb371, 0xd2a6e8d2, 0x05070405, 0x9852fd98,
+ 0x6580a365, 0xdfe476df, // 0 - 7
+ 0x08459a08, 0x024b9202, 0xa0e080a0, 0x665a7866, 0xddafe4dd, 0xb06addb0,
+ 0xbf63d1bf, 0x362a3836,
+ 0x54e60d54, 0x4320c643, 0x62cc3562, 0xbef298be, 0x1e12181e, 0x24ebf724,
+ 0xd7a1ecd7, 0x77416c77,
+ 0xbd2843bd, 0x32bc7532, 0xd47b37d4, 0x9b88269b, 0x700dfa70, 0xf94413f9,
+ 0xb1fb94b1, 0x5a7e485a,
+ 0x7a03f27a, 0xe48cd0e4, 0x47b68b47, 0x3c24303c, 0xa5e784a5, 0x416b5441,
+ 0x06dddf06, 0xc56023c5,
+ 0x45fd1945, 0xa33a5ba3, 0x68c23d68, 0x158d5915, 0x21ecf321, 0x3166ae31,
+ 0x3e6fa23e, 0x16578216,
+ 0x95106395, 0x5bef015b, 0x4db8834d, 0x91862e91, 0xb56dd9b5, 0x1f83511f,
+ 0x53aa9b53, 0x635d7c63,
+ 0x3b68a63b, 0x3ffeeb3f, 0xd630a5d6, 0x257abe25, 0xa7ac16a7, 0x0f090c0f,
+ 0x35f0e335, 0x23a76123,
+ 0xf090c0f0, 0xafe98caf, 0x809d3a80, 0x925cf592, 0x810c7381, 0x27312c27,
+ 0x76d02576, 0xe7560be7,
+ 0x7b92bb7b, 0xe9ce4ee9, 0xf10189f1, 0x9f1e6b9f, 0xa93453a9, 0xc4f16ac4,
+ 0x99c3b499, 0x975bf197,
+ 0x8347e183, 0x6b18e66b, 0xc822bdc8, 0x0e98450e, 0x6e1fe26e, 0xc9b3f4c9,
+ 0x2f74b62f, 0xcbf866cb,
+ 0xff99ccff, 0xea1495ea, 0xed5803ed, 0xf7dc56f7, 0xe18bd4e1, 0x1b151c1b,
+ 0xada21ead, 0x0cd3d70c,
+ 0x2be2fb2b, 0x1dc8c31d, 0x195e8e19, 0xc22cb5c2, 0x8949e989, 0x12c1cf12,
+ 0x7e95bf7e, 0x207dba20,
+ 0x6411ea64, 0x840b7784, 0x6dc5396d, 0x6a89af6a, 0xd17c33d1, 0xa171c9a1,
+ 0xceff62ce, 0x37bb7137,
+ 0xfb0f81fb, 0x3db5793d, 0x51e10951, 0xdc3eaddc, 0x2d3f242d, 0xa476cda4,
+ 0x9d55f99d, 0xee82d8ee,
+ 0x8640e586, 0xae78c5ae, 0xcd25b9cd, 0x04964d04, 0x55774455, 0x0a0e080a,
+ 0x13508613, 0x30f7e730,
+ 0xd337a1d3, 0x40fa1d40, 0x3461aa34, 0x8c4eed8c, 0xb3b006b3, 0x6c54706c,
+ 0x2a73b22a, 0x523bd252,
+ 0x0b9f410b, 0x8b027b8b, 0x88d8a088, 0x4ff3114f, 0x67cb3167, 0x4627c246,
+ 0xc06727c0, 0xb4fc90b4,
+ 0x28382028, 0x7f04f67f, 0x78486078, 0x2ee5ff2e, 0x074c9607, 0x4b655c4b,
+ 0xc72bb1c7, 0x6f8eab6f,
+ 0x0d429e0d, 0xbbf59cbb, 0xf2db52f2, 0xf34a1bf3, 0xa63d5fa6, 0x59a49359,
+ 0xbcb90abc, 0x3af9ef3a,
+ 0xef1391ef, 0xfe0885fe, 0x01914901, 0x6116ee61, 0x7cde2d7c, 0xb2214fb2,
+ 0x42b18f42, 0xdb723bdb,
+ 0xb82f47b8, 0x48bf8748, 0x2cae6d2c, 0xe3c046e3, 0x573cd657, 0x859a3e85,
+ 0x29a96929, 0x7d4f647d,
+ 0x94812a94, 0x492ece49, 0x17c6cb17, 0xca692fca, 0xc3bdfcc3, 0x5ca3975c,
+ 0x5ee8055e, 0xd0ed7ad0,
+ 0x87d1ac87, 0x8e057f8e, 0xba64d5ba, 0xa8a51aa8, 0xb7264bb7, 0xb9be0eb9,
+ 0x6087a760, 0xf8d55af8,
+ 0x22362822, 0x111b1411, 0xde753fde, 0x79d92979, 0xaaee88aa, 0x332d3c33,
+ 0x5f794c5f, 0xb6b702b6,
+ 0x96cab896, 0x5835da58, 0x9cc4b09c, 0xfc4317fc, 0x1a84551a, 0xf64d1ff6,
+ 0x1c598a1c, 0x38b27d38,
+ 0xac3357ac, 0x18cfc718, 0xf4068df4, 0x69537469, 0x749bb774, 0xf597c4f5,
+ 0x56ad9f56, 0xdae372da,
+ 0xd5ea7ed5, 0x4af4154a, 0x9e8f229e, 0xa2ab12a2, 0x4e62584e, 0xe85f07e8,
+ 0xe51d99e5, 0x39233439,
+ 0xc1f66ec1, 0x446c5044, 0x5d32de5d, 0x72466872, 0x26a06526, 0x93cdbc93,
+ 0x03dadb03, 0xc6baf8c6,
+ 0xfa9ec8fa, 0x82d6a882, 0xcf6e2bcf, 0x50704050, 0xeb85dceb, 0x750afe75,
+ 0x8a93328a, 0x8ddfa48d,
+ 0x4c29ca4c, 0x141c1014, 0x73d72173, 0xccb4f0cc, 0x09d4d309, 0x108a5d10,
+ 0xe2510fe2, 0x00000000,
+ 0x9a196f9a, 0xe01a9de0, 0x8f94368f, 0xe6c742e6, 0xecc94aec, 0xfdd25efd,
+ 0xab7fc1ab, 0xd8a8e0d8
+ ];
+
+ /// The Key Schedule List
+ final List<int> _subKey = [];
+
+ /// The Key depended S-Table 0
+ final _sTable0 = List.filled(256, 0);
+
+ /// The Key depended S-Table 1
+ final _sTable1 = List.filled(256, 0);
+
+ /// The Key depended S-Table 2
+ final _sTable2 = List.filled(256, 0);
+
+ /// The Key depended S-Table 3
+ final _sTable3 = List.filled(256, 0);
+
+ static const BLOCK_SIZE = 16;
+
+ bool _forEncryption = false;
+
+ Uint8List _workingKey = Uint8List(0);
+
+ @override
+ String get algorithmName => 'Twofish';
+
+ @override
+ int get blockSize => BLOCK_SIZE;
+
+ @override
+ void init(bool forEncryption, CipherParameters? params) {
+ if (params is KeyParameter) {
+ _forEncryption = forEncryption;
+ _workingKey = params.key;
+ final keyBits = _workingKey.length * 8;
+ if (!(keyBits == 128 || keyBits == 192 || keyBits == 256)) {
+ throw ArgumentError('Key length not 128/192/256 bits.');
+ }
+ _setupKey(_workingKey);
+ } else {
+ throw ArgumentError(
+ 'Invalid parameter passed to $algorithmName init - ${params.runtimeType}',
+ );
+ }
+ }
+
+ @override
+ int processBlock(
+ Uint8List input,
+ int inOff,
+ Uint8List output,
+ int outOff,
+ ) {
+ if (_workingKey.isEmpty) {
+ throw StateError('$algorithmName not initialised');
+ }
+ if ((inOff + BLOCK_SIZE) > input.lengthInBytes) {
+ throw ArgumentError('Input buffer too short for $algorithmName engine');
+ }
+ if ((outOff + BLOCK_SIZE) > output.lengthInBytes) {
+ throw ArgumentError('Output buffer too short for $algorithmName engine');
+ }
+
+ if (_forEncryption) {
+ _encryptBlock(input, inOff, output, outOff);
+ } else {
+ _decryptBlock(input, inOff, output, outOff);
+ }
+
+ return BLOCK_SIZE;
+ }
+
+ @override
+ void reset() {
+ if (_workingKey.isNotEmpty) {
+ _setupKey(_workingKey);
+ }
+ }
+
+ void _setupKey(final Uint8List key) {
+ switch (key.length) {
+ case 16:
+ final list1 =
+ _mdsrem(_unpack32Le(key.sublist(0)), _unpack32Le(key.sublist(4)));
+ final list2 =
+ _mdsrem(_unpack32Le(key.sublist(8)), _unpack32Le(key.sublist(12)));
+
+ for (var i = 0, j = 1; i < 40; i += 2, j += 2) {
+ var a = _m0[_q0[_q0[i] ^ key[8]] ^ key[0]] ^
+ _m1[_q0[_q1[i] ^ key[9]] ^ key[1]] ^
+ _m2[_q1[_q0[i] ^ key[10]] ^ key[2]] ^
+ _m3[_q1[_q1[i] ^ key[11]] ^ key[3]];
+ var b = _m0[_q0[_q0[j] ^ key[12]] ^ key[4]] ^
+ _m1[_q0[_q1[j] ^ key[13]] ^ key[5]] ^
+ _m2[_q1[_q0[j] ^ key[14]] ^ key[6]] ^
+ _m3[_q1[_q1[j] ^ key[15]] ^ key[7]];
+ b = (b << 8) | (b >> 24 & 0xff);
+ a += b;
+ _subKey.add(a);
+ a += b;
+ _subKey.add(a << 9 | a >> 23 & 0x1ff);
+ }
+
+ for (var i = 0; i < 256; ++i) {
+ _sTable0[i] = _m0[_q0[_q0[i] ^ list1[3]] ^ list2[3]];
+ _sTable1[i] = _m1[_q0[_q1[i] ^ list1[2]] ^ list2[2]];
+ _sTable2[i] = _m2[_q1[_q0[i] ^ list1[1]] ^ list2[1]];
+ _sTable3[i] = _m3[_q1[_q1[i] ^ list1[0]] ^ list2[0]];
+ }
+ break;
+ case 24:
+ final list1 =
+ _mdsrem(_unpack32Le(key.sublist(0)), _unpack32Le(key.sublist(4)));
+ final list2 =
+ _mdsrem(_unpack32Le(key.sublist(8)), _unpack32Le(key.sublist(12)));
+ final list3 =
+ _mdsrem(_unpack32Le(key.sublist(16)), _unpack32Le(key.sublist(20)));
+
+ for (var i = 0, j = 1; i < 40; i += 2, j += 2) {
+ var a = _m0[_q0[_q0[_q1[i] ^ key[16]] ^ key[8]] ^ key[0]] ^
+ _m1[_q0[_q1[_q1[i] ^ key[17]] ^ key[9]] ^ key[1]] ^
+ _m2[_q1[_q0[_q0[i] ^ key[18]] ^ key[10]] ^ key[2]] ^
+ _m3[_q1[_q1[_q0[i] ^ key[19]] ^ key[11]] ^ key[3]];
+ var b = _m0[_q0[_q0[_q1[j] ^ key[20]] ^ key[12]] ^ key[4]] ^
+ _m1[_q0[_q1[_q1[j] ^ key[21]] ^ key[13]] ^ key[5]] ^
+ _m2[_q1[_q0[_q0[j] ^ key[22]] ^ key[14]] ^ key[6]] ^
+ _m3[_q1[_q1[_q0[j] ^ key[23]] ^ key[15]] ^ key[7]];
+
+ b = (b << 8) | (b >> 24 & 0xff);
+ a += b;
+ _subKey.add(a);
+ a += b;
+ _subKey.add(a << 9 | a >> 23 & 0x1ff);
+ }
+
+ for (var i = 0; i < 256; ++i) {
+ _sTable0[i] = _m0[_q0[_q0[_q1[i] ^ list1[3]] ^ list2[3]] ^ list3[3]];
+ _sTable1[i] = _m1[_q0[_q1[_q1[i] ^ list1[2]] ^ list2[2]] ^ list3[2]];
+ _sTable2[i] = _m2[_q1[_q0[_q0[i] ^ list1[1]] ^ list2[1]] ^ list3[1]];
+ _sTable3[i] = _m3[_q1[_q1[_q0[i] ^ list1[0]] ^ list2[0]] ^ list3[0]];
+ }
+ break;
+ case 32:
+ final list1 =
+ _mdsrem(_unpack32Le(key.sublist(0)), _unpack32Le(key.sublist(4)));
+ final list2 =
+ _mdsrem(_unpack32Le(key.sublist(8)), _unpack32Le(key.sublist(12)));
+ final list3 =
+ _mdsrem(_unpack32Le(key.sublist(16)), _unpack32Le(key.sublist(20)));
+ final list4 =
+ _mdsrem(_unpack32Le(key.sublist(24)), _unpack32Le(key.sublist(28)));
+
+ for (var i = 0, j = 1; i < 40; i += 2, j += 2) {
+ var a = _m0[
+ _q0[_q0[_q1[_q1[i] ^ key[24]] ^ key[16]] ^ key[8]] ^ key[0]] ^
+ _m1[_q0[_q1[_q1[_q0[i] ^ key[25]] ^ key[17]] ^ key[9]] ^ key[1]] ^
+ _m2[_q1[_q0[_q0[_q0[i] ^ key[26]] ^ key[18]] ^ key[10]] ^
+ key[2]] ^
+ _m3[_q1[_q1[_q0[_q1[i] ^ key[27]] ^ key[19]] ^ key[11]] ^ key[3]];
+ var b = _m0[_q0[_q0[_q1[_q1[j] ^ key[28]] ^ key[20]] ^ key[12]] ^
+ key[4]] ^
+ _m1[_q0[_q1[_q1[_q0[j] ^ key[29]] ^ key[21]] ^ key[13]] ^
+ key[5]] ^
+ _m2[_q1[_q0[_q0[_q0[j] ^ key[30]] ^ key[22]] ^ key[14]] ^
+ key[6]] ^
+ _m3[_q1[_q1[_q0[_q1[j] ^ key[31]] ^ key[23]] ^ key[15]] ^ key[7]];
+ b = (b << 8) | (b >> 24 & 0xff);
+ a = a + b;
+ _subKey.add(a);
+ a = a + b;
+ _subKey.add(a << 9 | a >> 23 & 0x1ff);
+ }
+
+ for (var i = 0; i < 256; ++i) {
+ _sTable0[i] = _m0[
+ _q0[_q0[_q1[_q1[i] ^ list1[3]] ^ list2[3]] ^ list3[3]] ^
+ list4[3]];
+ _sTable1[i] = _m1[
+ _q0[_q1[_q1[_q0[i] ^ list1[2]] ^ list2[2]] ^ list3[2]] ^
+ list4[2]];
+ _sTable2[i] = _m2[
+ _q1[_q0[_q0[_q0[i] ^ list1[1]] ^ list2[1]] ^ list3[1]] ^
+ list4[1]];
+ _sTable3[i] = _m3[
+ _q1[_q1[_q0[_q1[i] ^ list1[0]] ^ list2[0]] ^ list3[0]] ^
+ list4[0]];
+ }
+ break;
+ default:
+ }
+ }
+
+ /// Encrypt the given input starting at the given offset and place
+ /// the result in the provided buffer starting at the given offset.
+ /// The input will be an exact multiple of our blocksize.
+ void _encryptBlock(
+ final Uint8List input,
+ final int inOff,
+ final Uint8List output,
+ final int outOff,
+ ) {
+ var r0 = _unpack32Le(input.sublist(inOff)) ^ _subKey[0];
+ var r1 = _unpack32Le(input.sublist(inOff + 4)) ^ _subKey[1];
+ var r2 = _unpack32Le(input.sublist(inOff + 8)) ^ _subKey[2];
+ var r3 = _unpack32Le(input.sublist(inOff + 12)) ^ _subKey[3];
+
+ var ki = 7;
+ while (ki < 39) {
+ var t0 = _sTable0[r0 & 0xff] ^
+ _sTable1[(r0 >> 8) & 0xff] ^
+ _sTable2[(r0 >> 16) & 0xff] ^
+ _sTable3[(r0 >> 24) & 0xff];
+ var t1 = _sTable0[(r1 >> 24) & 0xff] ^
+ _sTable1[r1 & 0xff] ^
+ _sTable2[(r1 >> 8) & 0xff] ^
+ _sTable3[(r1 >> 16) & 0xff];
+
+ r2 ^= t0 + t1 + _subKey[++ki];
+ r2 = (r2 >> 1 & 0x7fffffff) | (r2 << 31);
+ r3 = (((r3 >> 31) & 1) | (r3 << 1)) ^ (t0 + (t1 << 1) + _subKey[++ki]);
+
+ t0 = _sTable0[r2 & 0xff] ^
+ _sTable1[(r2 >> 8) & 0xff] ^
+ _sTable2[(r2 >> 16) & 0xff] ^
+ _sTable3[(r2 >> 24) & 0xff];
+ t1 = _sTable0[(r3 >> 24) & 0xff] ^
+ _sTable1[r3 & 0xff] ^
+ _sTable2[(r3 >> 8) & 0xff] ^
+ _sTable3[(r3 >> 16) & 0xff];
+
+ r0 ^= t0 + t1 + _subKey[++ki];
+ r0 = (r0 >> 1 & 0x7fffffff) | (r0 << 31);
+ r1 = (((r1 >> 31) & 1) | (r1 << 1)) ^ (t0 + (t1 << 1) + _subKey[++ki]);
+ }
+
+ output.setAll(outOff, _pack32Le(r2 ^ _subKey[4]));
+ output.setAll(outOff + 4, _pack32Le(r3 ^ _subKey[5]));
+ output.setAll(outOff + 8, _pack32Le(r0 ^ _subKey[6]));
+ output.setAll(outOff + 12, _pack32Le(r1 ^ _subKey[7]));
+ }
+
+ /// Decrypt the given input starting at the given offset and place
+ /// the result in the provided buffer starting at the given offset.
+ /// The input will be an exact multiple of our blocksize.
+ void _decryptBlock(
+ final Uint8List input,
+ final int inOff,
+ final Uint8List output,
+ final int outOff,
+ ) {
+ var r0 = _subKey[4] ^ _unpack32Le(input.sublist(inOff));
+ var r1 = _subKey[5] ^ _unpack32Le(input.sublist(inOff + 4));
+ var r2 = _subKey[6] ^ _unpack32Le(input.sublist(inOff + 8));
+ var r3 = _subKey[7] ^ _unpack32Le(input.sublist(inOff + 12));
+
+ var ki = 40;
+ while (ki > 8) {
+ var t0 = _sTable0[r0 & 0xff] ^
+ _sTable1[r0 >> 8 & 0xff] ^
+ _sTable2[r0 >> 16 & 0xff] ^
+ _sTable3[r0 >> 24 & 0xff];
+ var t1 = _sTable0[r1 >> 24 & 0xff] ^
+ _sTable1[r1 & 0xff] ^
+ _sTable2[r1 >> 8 & 0xff] ^
+ _sTable3[r1 >> 16 & 0xff];
+
+ r3 ^= t0 + (t1 << 1) + _subKey[--ki];
+ r3 = r3 >> 1 & 0x7fffffff | r3 << 31;
+ r2 = (r2 >> 31 & 0x1 | r2 << 1) ^ (t0 + t1 + _subKey[--ki]);
+
+ t0 = _sTable0[r2 & 0xff] ^
+ _sTable1[r2 >> 8 & 0xff] ^
+ _sTable2[r2 >> 16 & 0xff] ^
+ _sTable3[r2 >> 24 & 0xff];
+ t1 = _sTable0[r3 >> 24 & 0xff] ^
+ _sTable1[r3 & 0xff] ^
+ _sTable2[r3 >> 8 & 0xff] ^
+ _sTable3[r3 >> 16 & 0xff];
+
+ r1 ^= t0 + (t1 << 1) + _subKey[--ki];
+ r1 = r1 >> 1 & 0x7fffffff | r1 << 31;
+ r0 = (r0 >> 31 & 0x1 | r0 << 1) ^ (t0 + t1 + _subKey[--ki]);
+ }
+
+ output.setAll(outOff, _pack32Le(r2 ^ _subKey[0]));
+ output.setAll(outOff + 4, _pack32Le(r3 ^ _subKey[1]));
+ output.setAll(outOff + 8, _pack32Le(r0 ^ _subKey[2]));
+ output.setAll(outOff + 12, _pack32Le(r1 ^ _subKey[3]));
+ }
+
+ List<int> _mdsrem(final int x, final int y) {
+ var a = x;
+ var b = y;
+
+ /// No gain by unrolling this loop.
+ for (var i = 0; i < 8; ++i) {
+ /// Get most significant coefficient.
+ final t = 0xff & (b >> 24);
+
+ /// Shift the others up.
+ b = (b << 8) | (0xff & (a >> 24));
+ a <<= 8;
+
+ var u = t << 1;
+
+ /// Subtract the modular polynomial on overflow.
+ if ((t & 0x80) > 0) {
+ u ^= 0x14d;
+ }
+
+ /// Remove t * (a * x^2 + 1).
+ b ^= t ^ (u << 16);
+
+ /// Form u = a*t + t/a = t*(a + 1/a).
+ u ^= 0x7fffffff & (t >> 1);
+
+ /// Add the modular polynomial on underflow.
+ if ((t & 0x01) > 0) {
+ u ^= 0xa6;
+ }
+
+ /// Remove t * (a + 1/a) * (x^3 + x).
+ b ^= (u << 24) | (u << 8);
+ }
+ return [0xff & b >> 24, 0xff & b >> 16, 0xff & b >> 8, 0xff & b];
+ }
+
+ static int _unpack32Le(Uint8List x) =>
+ x.buffer.asByteData().getUint32(0, Endian.little);
+ static Uint8List _pack32Le(int x) =>
+ Uint8List(4)..buffer.asByteData().setUint32(0, x, Endian.little);
+}
diff --git a/lib/digests/cshake.dart b/lib/digests/cshake.dart
index 83bda20..98aa4e4 100644
--- a/lib/digests/cshake.dart
+++ b/lib/digests/cshake.dart
@@ -62,7 +62,7 @@
absorbBits(0x00, 2);
}
- squeeze(out, outOff, (outLen) * 8);
+ squeeze(out, outOff, outLen * 8);
return outLen;
} else {
diff --git a/lib/digests/sha1.dart b/lib/digests/sha1.dart
index 7c1c0e1..7ad74ea 100644
--- a/lib/digests/sha1.dart
+++ b/lib/digests/sha1.dart
@@ -134,11 +134,11 @@
static const _Y3 = 0x8f1bbcdc;
static const _Y4 = 0xca62c1d6;
- int _f(int u, int v, int w) => ((u & v) | ((~u) & w));
+ int _f(int u, int v, int w) => (u & v) | ((~u) & w);
- int _h(int u, int v, int w) => (u ^ v ^ w);
+ int _h(int u, int v, int w) => u ^ v ^ w;
- int _g(int u, int v, int w) => ((u & v) | (u & w) | (v & w));
+ int _g(int u, int v, int w) => (u & v) | (u & w) | (v & w);
@override
int get byteLength => 64;
diff --git a/lib/digests/sha224.dart b/lib/digests/sha224.dart
index cf7b0e5..9b7a4da 100644
--- a/lib/digests/sha224.dart
+++ b/lib/digests/sha224.dart
@@ -117,9 +117,9 @@
state[7] = clip32(state[7] + h);
}
- int _ch(int x, int y, int z) => ((x & y) ^ ((~x) & z));
+ int _ch(int x, int y, int z) => (x & y) ^ ((~x) & z);
- int _maj(int x, int y, int z) => ((x & y) ^ (x & z) ^ (y & z));
+ int _maj(int x, int y, int z) => (x & y) ^ (x & z) ^ (y & z);
int _sum0(int x) => rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
diff --git a/lib/digests/shake.dart b/lib/digests/shake.dart
index 7472d9e..53f9290 100644
--- a/lib/digests/shake.dart
+++ b/lib/digests/shake.dart
@@ -72,7 +72,7 @@
absorbBits(finalInput, finalBits);
}
- squeeze(out, outOff, (outLen) * 8);
+ squeeze(out, outOff, outLen * 8);
reset();
@@ -85,7 +85,7 @@
absorbBits(0x0F, 4);
}
- squeeze(out, outOff, (outLen) * 8);
+ squeeze(out, outOff, outLen * 8);
return outLen;
}
diff --git a/lib/digests/sm3.dart b/lib/digests/sm3.dart
index 9d60c86..6ea8639 100644
--- a/lib/digests/sm3.dart
+++ b/lib/digests/sm3.dart
@@ -108,22 +108,22 @@
}
/// FF1 Function
- static final _FF1 = (X, Y, Z) => ((X) ^ (Y) ^ (Z));
+ static int _FF1(int X, int Y, int Z) => X ^ Y ^ Z;
/// FF2 Function
- static final _FF2 = (X, Y, Z) => (((X) & (Y)) | ((X) & (Z)) | ((Y) & (Z)));
+ static int _FF2(int X, int Y, int Z) => (X & Y) | (X & Z) | (Y & Z);
/// GG1 Function
static final _GG1 = _FF1;
/// GG2 Function
- static final _GG2 = (X, Y, Z) => (((X) & (Y)) | ((~X) & (Z)));
+ static int _GG2(int X, int Y, int Z) => (X & Y) | ((~X) & Z);
/// P0 Function
- static final _P0 = (X) => ((X) ^ rotl32((X), 9) ^ rotl32((X), 17));
+ static int _P0(int X) => X ^ rotl32(X, 9) ^ rotl32(X, 17);
/// P1 Function
- static final _P1 = (X) => ((X) ^ rotl32((X), 15) ^ rotl32((X), 23));
+ static int _P1(int X) => X ^ rotl32(X, 15) ^ rotl32(X, 23);
@override
int get byteLength => 64;
diff --git a/lib/digests/whirlpool.dart b/lib/digests/whirlpool.dart
index 9b7e9f6..8b5ddf8 100644
--- a/lib/digests/whirlpool.dart
+++ b/lib/digests/whirlpool.dart
@@ -159,7 +159,7 @@
void _increment([int bits = 8]) {
assert(bits <= 0xFFFFFFFF);
- var i = (_bitCount.length - 1);
+ var i = _bitCount.length - 1;
_bitCount[i].sum(bits);
while (_bitCount[i] == _r64Zero) {
@@ -184,10 +184,10 @@
}
if (_bufferPos > 32) {
- final padCount = (_buffer.length - _bufferPos);
+ final padCount = _buffer.length - _bufferPos;
update(_zerosList, 0, padCount);
} else {
- final padCount = (32 - _bufferPos);
+ final padCount = 32 - _bufferPos;
update(_zerosList, 0, padCount);
}
diff --git a/lib/digests/xof_utils.dart b/lib/digests/xof_utils.dart
index 9a32d44..7939622 100644
--- a/lib/digests/xof_utils.dart
+++ b/lib/digests/xof_utils.dart
@@ -29,7 +29,7 @@
b[n] = n;
for (var i = 0; i < n; i++) {
- b[i] = (strLen >> (8 * (n - i - 1)));
+ b[i] = strLen >> (8 * (n - i - 1));
}
return b;
diff --git a/lib/ecc/api.dart b/lib/ecc/api.dart
index 7d55769..425ce64 100644
--- a/lib/ecc/api.dart
+++ b/lib/ecc/api.dart
@@ -66,9 +66,6 @@
bool get isInfinity;
- @override
- bool operator ==(other);
-
Uint8List getEncoded([bool compressed = true]);
ECPoint? operator +(ECPoint? b);
@@ -81,9 +78,6 @@
/// Multiply this point by the given number [k].
ECPoint? operator *(BigInt? k);
-
- @override
- int get hashCode => super.hashCode;
}
/// An elliptic curve
@@ -126,7 +120,7 @@
/// Create an ECC private key for the given d and domain parameters.
ECPrivateKey(this.d, ECDomainParameters? parameters) : super(parameters);
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is! ECPrivateKey) return false;
return (other.parameters == parameters) && (other.d == d);
}
@@ -145,7 +139,7 @@
/// Create an ECC public key for the given Q and domain parameters.
ECPublicKey(this.Q, ECDomainParameters? parameters) : super(parameters);
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is! ECPublicKey) return false;
return (other.parameters == parameters) && (other.Q == Q);
}
@@ -185,7 +179,7 @@
@override
String toString() => '(${r.toString()},${s.toString()})';
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is! ECSignature) return false;
return (other.r == r) && (other.s == s);
}
@@ -204,7 +198,7 @@
const ECPair(this.x, this.y);
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is! ECPair) return false;
return (other.x == x) && (other.y == y);
}
diff --git a/lib/ecc/curves/brainpoolp160r1.dart b/lib/ecc/curves/brainpoolp160r1.dart
index 248415c..16a2452 100644
--- a/lib/ecc/curves/brainpoolp160r1.dart
+++ b/lib/ecc/curves/brainpoolp160r1.dart
@@ -25,10 +25,9 @@
seed: null) as ECCurve_brainpoolp160r1;
static ECCurve_brainpoolp160r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp160r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp160r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp160r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp160r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp160t1.dart b/lib/ecc/curves/brainpoolp160t1.dart
index 9a2ea5d..f4f363c 100644
--- a/lib/ecc/curves/brainpoolp160t1.dart
+++ b/lib/ecc/curves/brainpoolp160t1.dart
@@ -25,10 +25,9 @@
seed: null) as ECCurve_brainpoolp160t1;
static ECCurve_brainpoolp160t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp160t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp160t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp160t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp160t1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp192r1.dart b/lib/ecc/curves/brainpoolp192r1.dart
index a01bd0b..2b1232e 100644
--- a/lib/ecc/curves/brainpoolp192r1.dart
+++ b/lib/ecc/curves/brainpoolp192r1.dart
@@ -29,10 +29,9 @@
seed: null) as ECCurve_brainpoolp192r1;
static ECCurve_brainpoolp192r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp192r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp192r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp192r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp192r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp192t1.dart b/lib/ecc/curves/brainpoolp192t1.dart
index c1f12ba..3c98ef3 100644
--- a/lib/ecc/curves/brainpoolp192t1.dart
+++ b/lib/ecc/curves/brainpoolp192t1.dart
@@ -29,10 +29,9 @@
seed: null) as ECCurve_brainpoolp192t1;
static ECCurve_brainpoolp192t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp192t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp192t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp192t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp192t1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp224r1.dart b/lib/ecc/curves/brainpoolp224r1.dart
index f6885ab..b529e04 100644
--- a/lib/ecc/curves/brainpoolp224r1.dart
+++ b/lib/ecc/curves/brainpoolp224r1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp224r1;
static ECCurve_brainpoolp224r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp224r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp224r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp224r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp224r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp224t1.dart b/lib/ecc/curves/brainpoolp224t1.dart
index 2764d05..efc0fd8 100644
--- a/lib/ecc/curves/brainpoolp224t1.dart
+++ b/lib/ecc/curves/brainpoolp224t1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp224t1;
static ECCurve_brainpoolp224t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt? _h, List<int>? seed) =>
- ECCurve_brainpoolp224t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt? h, List<int>? seed) =>
+ ECCurve_brainpoolp224t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp224t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt? _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp224t1._super(
+ super.domainName, super.curve, super.G, super.n, super.h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp256r1.dart b/lib/ecc/curves/brainpoolp256r1.dart
index d7a7b27..ed0f89b 100644
--- a/lib/ecc/curves/brainpoolp256r1.dart
+++ b/lib/ecc/curves/brainpoolp256r1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp256r1;
static ECCurve_brainpoolp256r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp256r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp256r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp256r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp256r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp256t1.dart b/lib/ecc/curves/brainpoolp256t1.dart
index 31670bb..690fe10 100644
--- a/lib/ecc/curves/brainpoolp256t1.dart
+++ b/lib/ecc/curves/brainpoolp256t1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp256t1;
static ECCurve_brainpoolp256t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp256t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp256t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp256t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp256t1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp320r1.dart b/lib/ecc/curves/brainpoolp320r1.dart
index 81b9f80..9618df0 100644
--- a/lib/ecc/curves/brainpoolp320r1.dart
+++ b/lib/ecc/curves/brainpoolp320r1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp320r1;
static ECCurve_brainpoolp320r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp320r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp320r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp320r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp320r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp320t1.dart b/lib/ecc/curves/brainpoolp320t1.dart
index 54546f8..289d43d 100644
--- a/lib/ecc/curves/brainpoolp320t1.dart
+++ b/lib/ecc/curves/brainpoolp320t1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp320t1;
static ECCurve_brainpoolp320t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp320t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp320t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp320t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp320t1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp384r1.dart b/lib/ecc/curves/brainpoolp384r1.dart
index d99436b..ae2749a 100644
--- a/lib/ecc/curves/brainpoolp384r1.dart
+++ b/lib/ecc/curves/brainpoolp384r1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp384r1;
static ECCurve_brainpoolp384r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp384r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp384r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp384r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp384r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super.h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp384t1.dart b/lib/ecc/curves/brainpoolp384t1.dart
index f7e1ad1..a0479de 100644
--- a/lib/ecc/curves/brainpoolp384t1.dart
+++ b/lib/ecc/curves/brainpoolp384t1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp384t1;
static ECCurve_brainpoolp384t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp384t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp384t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp384t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp384t1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp512r1.dart b/lib/ecc/curves/brainpoolp512r1.dart
index 13e445d..b9ac142 100644
--- a/lib/ecc/curves/brainpoolp512r1.dart
+++ b/lib/ecc/curves/brainpoolp512r1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp512r1;
static ECCurve_brainpoolp512r1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp512r1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp512r1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp512r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp512r1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super.h, super.seed);
}
diff --git a/lib/ecc/curves/brainpoolp512t1.dart b/lib/ecc/curves/brainpoolp512t1.dart
index 8c904bd..461dc62 100644
--- a/lib/ecc/curves/brainpoolp512t1.dart
+++ b/lib/ecc/curves/brainpoolp512t1.dart
@@ -33,10 +33,9 @@
seed: null) as ECCurve_brainpoolp512t1;
static ECCurve_brainpoolp512t1 _make(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_brainpoolp512t1._super(domainName, curve, G, n, _h, seed);
+ ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_brainpoolp512t1._super(domainName, curve, G, n, h, seed);
- ECCurve_brainpoolp512t1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_brainpoolp512t1._super(super.domainName, super.curve, super.G,
+ super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/gostr3410_2001_cryptopro_a.dart b/lib/ecc/curves/gostr3410_2001_cryptopro_a.dart
index 8d660ba..37d1113 100644
--- a/lib/ecc/curves/gostr3410_2001_cryptopro_a.dart
+++ b/lib/ecc/curves/gostr3410_2001_cryptopro_a.dart
@@ -33,11 +33,10 @@
seed: null) as ECCurve_gostr3410_2001_cryptopro_a;
static ECCurve_gostr3410_2001_cryptopro_a _make(String domainName,
- ECCurve curve, ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
+ ECCurve curve, ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
ECCurve_gostr3410_2001_cryptopro_a._super(
- domainName, curve, G, n, _h, seed);
+ domainName, curve, G, n, h, seed);
- ECCurve_gostr3410_2001_cryptopro_a._super(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_gostr3410_2001_cryptopro_a._super(super.domainName, super.curve,
+ super.G, super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/gostr3410_2001_cryptopro_b.dart b/lib/ecc/curves/gostr3410_2001_cryptopro_b.dart
index 7901e29..74f2fb4 100644
--- a/lib/ecc/curves/gostr3410_2001_cryptopro_b.dart
+++ b/lib/ecc/curves/gostr3410_2001_cryptopro_b.dart
@@ -35,11 +35,10 @@
seed: null) as ECCurve_gostr3410_2001_cryptopro_b;
static ECCurve_gostr3410_2001_cryptopro_b _make(String domainName,
- ECCurve curve, ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
+ ECCurve curve, ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
ECCurve_gostr3410_2001_cryptopro_b._super(
- domainName, curve, G, n, _h, seed);
+ domainName, curve, G, n, h, seed);
- ECCurve_gostr3410_2001_cryptopro_b._super(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_gostr3410_2001_cryptopro_b._super(super.domainName, super.curve,
+ super.G, super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/gostr3410_2001_cryptopro_c.dart b/lib/ecc/curves/gostr3410_2001_cryptopro_c.dart
index 98c3651..18e3b73 100644
--- a/lib/ecc/curves/gostr3410_2001_cryptopro_c.dart
+++ b/lib/ecc/curves/gostr3410_2001_cryptopro_c.dart
@@ -33,11 +33,10 @@
seed: null) as ECCurve_gostr3410_2001_cryptopro_c;
static ECCurve_gostr3410_2001_cryptopro_c _make(String domainName,
- ECCurve curve, ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
+ ECCurve curve, ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
ECCurve_gostr3410_2001_cryptopro_c._super(
- domainName, curve, G, n, _h, seed);
+ domainName, curve, G, n, h, seed);
- ECCurve_gostr3410_2001_cryptopro_c._super(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_gostr3410_2001_cryptopro_c._super(super.domainName, super.curve,
+ super.G, super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart b/lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart
index 8d6730e..0fc1c2f 100644
--- a/lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart
+++ b/lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart
@@ -34,11 +34,10 @@
seed: null) as ECCurve_gostr3410_2001_cryptopro_xcha;
static ECCurve_gostr3410_2001_cryptopro_xcha _make(String domainName,
- ECCurve curve, ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
+ ECCurve curve, ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
ECCurve_gostr3410_2001_cryptopro_xcha._super(
- domainName, curve, G, n, _h, seed);
+ domainName, curve, G, n, h, seed);
- ECCurve_gostr3410_2001_cryptopro_xcha._super(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_gostr3410_2001_cryptopro_xcha._super(super.domainName, super.curve,
+ super.G, super.n, BigInt super.h, super.seed);
}
diff --git a/lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart b/lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart
index a7080e7..545cb7a 100644
--- a/lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart
+++ b/lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart
@@ -34,11 +34,10 @@
seed: null) as ECCurve_gostr3410_2001_cryptopro_xchb;
static ECCurve_gostr3410_2001_cryptopro_xchb _make(String domainName,
- ECCurve curve, ECPoint G, BigInt n, BigInt _h, List<int>? seed) =>
+ ECCurve curve, ECPoint G, BigInt n, BigInt h, List<int>? seed) =>
ECCurve_gostr3410_2001_cryptopro_xchb._super(
- domainName, curve, G, n, _h, seed);
+ domainName, curve, G, n, h, seed);
- ECCurve_gostr3410_2001_cryptopro_xchb._super(String domainName, ECCurve curve,
- ECPoint G, BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_gostr3410_2001_cryptopro_xchb._super(super.domainName, super.curve,
+ super.G, super.n, BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/prime192v1.dart b/lib/ecc/curves/prime192v1.dart
index b6aa4ff..f175fd8 100644
--- a/lib/ecc/curves/prime192v1.dart
+++ b/lib/ecc/curves/prime192v1.dart
@@ -29,10 +29,9 @@
radix: 16)) as ECCurve_prime192v1;
static ECCurve_prime192v1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime192v1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime192v1._super(domainName, curve, G, n, h, seed);
- ECCurve_prime192v1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime192v1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/prime192v2.dart b/lib/ecc/curves/prime192v2.dart
index 5980970..6fed7c3 100644
--- a/lib/ecc/curves/prime192v2.dart
+++ b/lib/ecc/curves/prime192v2.dart
@@ -29,10 +29,9 @@
radix: 16)) as ECCurve_prime192v2;
static ECCurve_prime192v2 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime192v2._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime192v2._super(domainName, curve, G, n, h, seed);
- ECCurve_prime192v2._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime192v2._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super.h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/prime192v3.dart b/lib/ecc/curves/prime192v3.dart
index df5392b..3222932 100644
--- a/lib/ecc/curves/prime192v3.dart
+++ b/lib/ecc/curves/prime192v3.dart
@@ -29,10 +29,9 @@
radix: 16)) as ECCurve_prime192v3;
static ECCurve_prime192v3 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime192v3._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime192v3._super(domainName, curve, G, n, h, seed);
- ECCurve_prime192v3._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime192v3._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/prime239v1.dart b/lib/ecc/curves/prime239v1.dart
index 68409fd..2c034e9 100644
--- a/lib/ecc/curves/prime239v1.dart
+++ b/lib/ecc/curves/prime239v1.dart
@@ -34,10 +34,9 @@
radix: 16)) as ECCurve_prime239v1;
static ECCurve_prime239v1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime239v1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime239v1._super(domainName, curve, G, n, h, seed);
- ECCurve_prime239v1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime239v1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/prime239v2.dart b/lib/ecc/curves/prime239v2.dart
index e5d7af5..1d681b5 100644
--- a/lib/ecc/curves/prime239v2.dart
+++ b/lib/ecc/curves/prime239v2.dart
@@ -34,10 +34,9 @@
radix: 16)) as ECCurve_prime239v2;
static ECCurve_prime239v2 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime239v2._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime239v2._super(domainName, curve, G, n, h, seed);
- ECCurve_prime239v2._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime239v2._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super.h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/prime239v3.dart b/lib/ecc/curves/prime239v3.dart
index 0d9db77..4d01113 100644
--- a/lib/ecc/curves/prime239v3.dart
+++ b/lib/ecc/curves/prime239v3.dart
@@ -34,10 +34,9 @@
radix: 16)) as ECCurve_prime239v3;
static ECCurve_prime239v3 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime239v3._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime239v3._super(domainName, curve, G, n, h, seed);
- ECCurve_prime239v3._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime239v3._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/prime256v1.dart b/lib/ecc/curves/prime256v1.dart
index 934875e..bc32d19 100644
--- a/lib/ecc/curves/prime256v1.dart
+++ b/lib/ecc/curves/prime256v1.dart
@@ -33,10 +33,9 @@
radix: 16)) as ECCurve_prime256v1;
static ECCurve_prime256v1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_prime256v1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_prime256v1._super(domainName, curve, G, n, h, seed);
- ECCurve_prime256v1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_prime256v1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp112r1.dart b/lib/ecc/curves/secp112r1.dart
index a7256d4..91031ed 100644
--- a/lib/ecc/curves/secp112r1.dart
+++ b/lib/ecc/curves/secp112r1.dart
@@ -26,10 +26,9 @@
radix: 16)) as ECCurve_secp112r1;
static ECCurve_secp112r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp112r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp112r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp112r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp112r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp112r2.dart b/lib/ecc/curves/secp112r2.dart
index 61773cf..ae47526 100644
--- a/lib/ecc/curves/secp112r2.dart
+++ b/lib/ecc/curves/secp112r2.dart
@@ -26,10 +26,9 @@
radix: 16)) as ECCurve_secp112r2;
static ECCurve_secp112r2 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp112r2._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp112r2._super(domainName, curve, G, n, h, seed);
- ECCurve_secp112r2._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp112r2._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp128r1.dart b/lib/ecc/curves/secp128r1.dart
index f1ebd86..132f496 100644
--- a/lib/ecc/curves/secp128r1.dart
+++ b/lib/ecc/curves/secp128r1.dart
@@ -26,10 +26,9 @@
radix: 16)) as ECCurve_secp128r1;
static ECCurve_secp128r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp128r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp128r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp128r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp128r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp128r2.dart b/lib/ecc/curves/secp128r2.dart
index 384ac00..88508f6 100644
--- a/lib/ecc/curves/secp128r2.dart
+++ b/lib/ecc/curves/secp128r2.dart
@@ -26,10 +26,9 @@
radix: 16)) as ECCurve_secp128r2;
static ECCurve_secp128r2 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp128r2._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp128r2._super(domainName, curve, G, n, h, seed);
- ECCurve_secp128r2._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp128r2._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp160k1.dart b/lib/ecc/curves/secp160k1.dart
index df4bf42..889a3bc 100644
--- a/lib/ecc/curves/secp160k1.dart
+++ b/lib/ecc/curves/secp160k1.dart
@@ -25,10 +25,9 @@
seed: null) as ECCurve_secp160k1;
static ECCurve_secp160k1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_secp160k1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_secp160k1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp160k1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp160k1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/secp160r1.dart b/lib/ecc/curves/secp160r1.dart
index 9474867..6692d23 100644
--- a/lib/ecc/curves/secp160r1.dart
+++ b/lib/ecc/curves/secp160r1.dart
@@ -26,10 +26,9 @@
radix: 16)) as ECCurve_secp160r1;
static ECCurve_secp160r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp160r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp160r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp160r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp160r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp160r2.dart b/lib/ecc/curves/secp160r2.dart
index 562b9f5..a43e3dc 100644
--- a/lib/ecc/curves/secp160r2.dart
+++ b/lib/ecc/curves/secp160r2.dart
@@ -26,10 +26,9 @@
radix: 16)) as ECCurve_secp160r2;
static ECCurve_secp160r2 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp160r2._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp160r2._super(domainName, curve, G, n, h, seed);
- ECCurve_secp160r2._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp160r2._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp192k1.dart b/lib/ecc/curves/secp192k1.dart
index 7ee7d9f..34ebf1a 100644
--- a/lib/ecc/curves/secp192k1.dart
+++ b/lib/ecc/curves/secp192k1.dart
@@ -27,10 +27,9 @@
seed: null) as ECCurve_secp192k1;
static ECCurve_secp192k1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_secp192k1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_secp192k1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp192k1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp192k1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/secp192r1.dart b/lib/ecc/curves/secp192r1.dart
index a7b21a0..b1cdee2 100644
--- a/lib/ecc/curves/secp192r1.dart
+++ b/lib/ecc/curves/secp192r1.dart
@@ -30,10 +30,9 @@
radix: 16)) as ECCurve_secp192r1;
static ECCurve_secp192r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp192r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp192r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp192r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp192r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp224k1.dart b/lib/ecc/curves/secp224k1.dart
index 4dffd5d..32e87a5 100644
--- a/lib/ecc/curves/secp224k1.dart
+++ b/lib/ecc/curves/secp224k1.dart
@@ -29,10 +29,9 @@
seed: null) as ECCurve_secp224k1;
static ECCurve_secp224k1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_secp224k1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_secp224k1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp224k1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp224k1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/secp224r1.dart b/lib/ecc/curves/secp224r1.dart
index e514065..9323ece 100644
--- a/lib/ecc/curves/secp224r1.dart
+++ b/lib/ecc/curves/secp224r1.dart
@@ -34,10 +34,9 @@
radix: 16)) as ECCurve_secp224r1;
static ECCurve_secp224r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp224r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp224r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp224r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp224r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp256k1.dart b/lib/ecc/curves/secp256k1.dart
index b298cbd..39952bf 100644
--- a/lib/ecc/curves/secp256k1.dart
+++ b/lib/ecc/curves/secp256k1.dart
@@ -29,10 +29,9 @@
seed: null) as ECCurve_secp256k1;
static ECCurve_secp256k1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed) =>
- ECCurve_secp256k1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int>? seed) =>
+ ECCurve_secp256k1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp256k1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int>? seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp256k1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, super.seed);
}
diff --git a/lib/ecc/curves/secp256r1.dart b/lib/ecc/curves/secp256r1.dart
index 313c9c1..d17eabf 100644
--- a/lib/ecc/curves/secp256r1.dart
+++ b/lib/ecc/curves/secp256r1.dart
@@ -33,10 +33,9 @@
radix: 16)) as ECCurve_secp256r1;
static ECCurve_secp256r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp256r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp256r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp256r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp256r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp384r1.dart b/lib/ecc/curves/secp384r1.dart
index 7f9d041..c6c48c6 100644
--- a/lib/ecc/curves/secp384r1.dart
+++ b/lib/ecc/curves/secp384r1.dart
@@ -33,10 +33,9 @@
radix: 16)) as ECCurve_secp384r1;
static ECCurve_secp384r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp384r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp384r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp384r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp384r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/curves/secp521r1.dart b/lib/ecc/curves/secp521r1.dart
index 709b305..be2da27 100644
--- a/lib/ecc/curves/secp521r1.dart
+++ b/lib/ecc/curves/secp521r1.dart
@@ -33,10 +33,9 @@
radix: 16)) as ECCurve_secp521r1;
static ECCurve_secp521r1 _make(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed) =>
- ECCurve_secp521r1._super(domainName, curve, G, n, _h, seed);
+ BigInt n, BigInt h, List<int> seed) =>
+ ECCurve_secp521r1._super(domainName, curve, G, n, h, seed);
- ECCurve_secp521r1._super(String domainName, ECCurve curve, ECPoint G,
- BigInt n, BigInt _h, List<int> seed)
- : super(domainName, curve, G, n, _h, seed);
+ ECCurve_secp521r1._super(super.domainName, super.curve, super.G, super.n,
+ BigInt super._h, List<int> super.seed);
}
diff --git a/lib/ecc/ecc_base.dart b/lib/ecc/ecc_base.dart
index 683946c..c11d34d 100644
--- a/lib/ecc/ecc_base.dart
+++ b/lib/ecc/ecc_base.dart
@@ -42,7 +42,7 @@
int get fieldSize;
@override
- int get byteLength => ((fieldSize + 7) ~/ 8);
+ int get byteLength => (fieldSize + 7) ~/ 8;
@override
ECFieldElementBase operator +(covariant ECFieldElementBase b);
@@ -90,14 +90,14 @@
[this._multiplier = _fpNafMultiplier]);
@override
- bool get isInfinity => (x == null && y == null);
+ bool get isInfinity => x == null && y == null;
set preCompInfo(PreCompInfo preCompInfo) {
_preCompInfo = preCompInfo;
}
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is ECPointBase) {
if (isInfinity) {
return other.isInfinity;
@@ -231,7 +231,7 @@
default:
throw ArgumentError(
- 'Invalid point encoding 0x' + encoded[0].toRadixString(16));
+ 'Invalid point encoding 0x${encoded[0].toRadixString(16)}');
}
return p;
diff --git a/lib/ecc/ecc_fp.dart b/lib/ecc/ecc_fp.dart
index ced7404..30c7fa5 100644
--- a/lib/ecc/ecc_fp.dart
+++ b/lib/ecc/ecc_fp.dart
@@ -6,7 +6,7 @@
import 'package:pointycastle/api.dart';
import 'package:pointycastle/ecc/ecc_base.dart'
- hide ECFieldElementBase, ECPointBase, ECCurveBase;
+ hide ECCurveBase, ECFieldElementBase, ECPointBase;
import 'package:pointycastle/ecc/ecc_base.dart' as ecc;
import 'package:pointycastle/src/utils.dart' as utils;
@@ -131,7 +131,7 @@
V = V + q!;
}
- V = (V >> 1);
+ V = V >> 1;
//assert V.multiply(V).mod(q).equals(x);
@@ -184,7 +184,7 @@
}
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is ECFieldElement) {
return (q == other.q) && (x == other.x);
}
@@ -368,7 +368,7 @@
}
@override
- bool operator ==(other) {
+ bool operator ==(Object other) {
if (other is ECCurve) {
return q == other.q && a == other.a && b == other.b;
}
@@ -525,7 +525,7 @@
var wnaf = List<int?>.filled(k.bitLength + 1, null, growable: false);
// 2^width as short and BigInt
- var pow2wB = (1 << width);
+ var pow2wB = 1 << width;
var pow2wBI = BigInt.from(pow2wB);
var i = 0;
diff --git a/lib/export.dart b/lib/export.dart
index d6d6655..9933d4a 100644
--- a/lib/export.dart
+++ b/lib/export.dart
@@ -20,6 +20,9 @@
export 'package:pointycastle/block/aes.dart';
export 'package:pointycastle/block/desede_engine.dart';
export 'package:pointycastle/block/rc2_engine.dart';
+export 'package:pointycastle/block/blowfish.dart';
+export 'package:pointycastle/block/camellia.dart';
+export 'package:pointycastle/block/twofish.dart';
// block/modes
export 'package:pointycastle/block/modes/cbc.dart';
diff --git a/lib/key_derivators/argon2_native_int_impl.dart b/lib/key_derivators/argon2_native_int_impl.dart
index 649242f..045c434 100644
--- a/lib/key_derivators/argon2_native_int_impl.dart
+++ b/lib/key_derivators/argon2_native_int_impl.dart
@@ -81,7 +81,7 @@
'lanes must be less than $MAX_PARALLELISM');
} else if (parameters.memory < 2 * parameters.lanes) {
throw ArgumentError.value(parameters.memory, 'parameters.memory',
- 'memory is less than: ${(2 * parameters.lanes)} expected ${(2 * parameters.lanes)}');
+ 'memory is less than: ${2 * parameters.lanes} expected ${2 * parameters.lanes}');
} else if (parameters.iterations < MIN_ITERATIONS) {
throw ArgumentError.value(parameters.iterations, 'parameters.iterations',
'iterations is less than: $MIN_ITERATIONS');
@@ -188,7 +188,7 @@
/* 2 Creating a new block */
var prevBlock = _memory[prevOffset];
- var refBlock = _memory[((_laneLength) * refLane + refColumn)];
+ var refBlock = _memory[(_laneLength * refLane + refColumn)];
var currentBlock = _memory[currentOffset];
if (withXor) {
@@ -270,7 +270,7 @@
}
int _getRefLane(_Position position, int pseudoRandom) {
- var refLane = (unsignedShiftRight64(pseudoRandom, 32) % _parameters.lanes);
+ var refLane = unsignedShiftRight64(pseudoRandom, 32) % _parameters.lanes;
if ((position.pass == 0) && (position.slice == 0)) {
/* Can not reference other lanes yet */
@@ -446,7 +446,7 @@
}
}
- static int _intToLong(int x) => (x & M32L);
+ static int _intToLong(int x) => x & M32L;
}
class _FillBlock {
@@ -642,11 +642,11 @@
}
class _Position {
- int pass;
- int lane;
- int slice;
+ late int pass;
+ late int lane;
+ late int slice;
- _Position([this.pass = 0, this.lane = 0, this.slice = 0]);
+ _Position();
}
extension _SetFrom<T> on List<T> {
diff --git a/lib/key_derivators/argon2_register64_impl.dart b/lib/key_derivators/argon2_register64_impl.dart
index ede2bd2..338e494 100644
--- a/lib/key_derivators/argon2_register64_impl.dart
+++ b/lib/key_derivators/argon2_register64_impl.dart
@@ -4,8 +4,8 @@
import 'package:pointycastle/digests/blake2b.dart';
import 'package:pointycastle/src/impl/base_key_derivator.dart';
import 'package:pointycastle/src/registry/registry.dart';
-import 'package:pointycastle/src/utils.dart';
import 'package:pointycastle/src/ufixnum.dart';
+import 'package:pointycastle/src/utils.dart';
import 'api.dart';
@@ -77,7 +77,7 @@
'lanes must be less than $MAX_PARALLELISM');
} else if (parameters.memory < 2 * parameters.lanes) {
throw ArgumentError.value(parameters.memory, 'parameters.memory',
- 'memory is less than: ${(2 * parameters.lanes)} expected ${(2 * parameters.lanes)}');
+ 'memory is less than: ${2 * parameters.lanes} expected ${2 * parameters.lanes}');
} else if (parameters.iterations < MIN_ITERATIONS) {
throw ArgumentError.value(parameters.iterations, 'parameters.iterations',
'iterations is less than: $MIN_ITERATIONS');
@@ -184,7 +184,7 @@
/* 2 Creating a new block */
var prevBlock = _memory[prevOffset];
- var refBlock = _memory[((_laneLength) * refLane + refColumn)];
+ var refBlock = _memory[(_laneLength * refLane + refColumn)];
var currentBlock = _memory[currentOffset];
if (withXor) {
@@ -266,14 +266,14 @@
if (addressIndex == 0) {
_nextAddresses(filler, inputBlock!, addressBlock!);
}
- return (addressBlock!._v[addressIndex]);
+ return addressBlock!._v[addressIndex];
} else {
- return (_memory[prevOffset]._v[0]);
+ return _memory[prevOffset]._v[0];
}
}
int _getRefLane(_Position position, Register64 pseudoRandom) {
- var refLane = (pseudoRandom.hi32 % _parameters.lanes);
+ var refLane = pseudoRandom.hi32 % _parameters.lanes;
if ((position.pass == 0) && (position.slice == 0)) {
/* Can not reference other lanes yet */
@@ -672,17 +672,19 @@
}
_Block clear() {
- _v.forEach((Register64 reg) => reg.set(0));
+ for (var reg in _v) {
+ reg.set(0);
+ }
return this;
}
}
class _Position {
- int pass;
- int lane;
- int slice;
+ late int pass;
+ late int lane;
+ late int slice;
- _Position([this.pass = 0, this.lane = 0, this.slice = 0]);
+ _Position();
}
extension _SetFrom<T> on List<T> {
diff --git a/lib/key_derivators/concat_kdf.dart b/lib/key_derivators/concat_kdf.dart
index ed7e9c8..5aa8b9b 100644
--- a/lib/key_derivators/concat_kdf.dart
+++ b/lib/key_derivators/concat_kdf.dart
@@ -36,7 +36,7 @@
counter[0] = (counterInt >> 24) & 255;
counter[1] = (counterInt >> 16) & 255;
counter[2] = (counterInt >> 8) & 255;
- counter[3] = (counterInt) & 255;
+ counter[3] = counterInt & 255;
_digest.update(counter, 0, 4);
_digest.update(_parameters.ikm, 0, _parameters.ikm.length);
_digest.update(_parameters.salt ?? inp.sublist(inpOff), 0,
diff --git a/lib/key_derivators/pkcs12_parameter_generator.dart b/lib/key_derivators/pkcs12_parameter_generator.dart
index ffc6dbc..faf4cd1 100644
--- a/lib/key_derivators/pkcs12_parameter_generator.dart
+++ b/lib/key_derivators/pkcs12_parameter_generator.dart
@@ -12,11 +12,11 @@
return PKCS12ParametersGenerator(mac);
});
- static final int KEY_MATERIAL = 1;
+ static const int KEY_MATERIAL = 1;
- static final int IV_MATERIAL = 2;
+ static const int IV_MATERIAL = 2;
- static final int MAC_MATERIAL = 3;
+ static const int MAC_MATERIAL = 3;
Digest digest;
@@ -81,7 +81,7 @@
}
Uint8List S;
if (salt.isNotEmpty) {
- S = Uint8List((v * (((salt.length + v) - 1) ~/ v)));
+ S = Uint8List(v * (((salt.length + v) - 1) ~/ v));
for (var i = 0; i != S.length; i++) {
S[i] = salt[i % salt.length];
}
@@ -90,18 +90,18 @@
}
Uint8List P;
if (password.isNotEmpty) {
- P = Uint8List((v * (((password.length + v) - 1) ~/ v)));
+ P = Uint8List(v * (((password.length + v) - 1) ~/ v));
for (var i = 0; i != P.length; i++) {
P[i] = password[i % password.length];
}
} else {
P = Uint8List(0);
}
- var I = Uint8List((S.length + P.length));
+ var I = Uint8List(S.length + P.length);
_arrayCopy(S, 0, I, 0, S.length);
_arrayCopy(P, 0, I, S.length, P.length);
var B = Uint8List(v);
- var c = (((n + u) - 1) ~/ u);
+ var c = ((n + u) - 1) ~/ u;
var A = Uint8List(u);
for (var i = 1; i <= c; i++) {
digest.update(D, 0, D.length);
diff --git a/lib/key_derivators/scrypt.dart b/lib/key_derivators/scrypt.dart
index 19050e5..1101ea5 100644
--- a/lib/key_derivators/scrypt.dart
+++ b/lib/key_derivators/scrypt.dart
@@ -24,7 +24,7 @@
static final FactoryConfig factoryConfig =
StaticFactoryConfig(KeyDerivator, 'scrypt', () => Scrypt());
- static final int _maxValue = 0x7fffffff;
+ static const int _maxValue = 0x7fffffff;
ScryptParameters? _params;
diff --git a/lib/key_generators/rsa_key_generator.dart b/lib/key_generators/rsa_key_generator.dart
index d11f7cc..9b3af75 100644
--- a/lib/key_generators/rsa_key_generator.dart
+++ b/lib/key_generators/rsa_key_generator.dart
@@ -96,7 +96,7 @@
}
// calculate the modulus
- n = (p * q);
+ n = p * q;
if (n.bitLength == _params.bitStrength) {
break;
@@ -114,11 +114,12 @@
}
// calculate the private exponent
- var pSub1 = (p - BigInt.one);
- var qSub1 = (q - BigInt.one);
- var phi = (pSub1 * qSub1);
+ var pSub1 = p - BigInt.one;
+ var qSub1 = q - BigInt.one;
+ var phi = pSub1 * qSub1;
var d = e.modInverse(phi);
+ // ignore: deprecated_member_use_from_same_package
return AsymmetricKeyPair(RSAPublicKey(n, e), RSAPrivateKey(n, d, p, q, e));
}
}
@@ -285,7 +286,7 @@
/// test primality with certainty >= 1-.5^t */
bool _isProbablePrime(BigInt b, int t) {
// Implementation borrowed from bignum.BigIntegerDartvm.
- var i;
+ int i;
var x = b.abs();
if (b <= _lowprimes.last) {
for (i = 0; i < _lowprimes.length; ++i) {
diff --git a/lib/macs/cbc_block_cipher_mac.dart b/lib/macs/cbc_block_cipher_mac.dart
index 0f843c0..63d3a19 100644
--- a/lib/macs/cbc_block_cipher_mac.dart
+++ b/lib/macs/cbc_block_cipher_mac.dart
@@ -100,7 +100,7 @@
@override
String get algorithmName {
- var paddingName = _padding != null ? '/${_padding!.algorithmName}' : '';
+ var paddingName = _padding != null ? '/${_padding.algorithmName}' : '';
return '${_cipher.algorithmName}_CMAC$paddingName';
}
@@ -200,7 +200,7 @@
_bufOff = 0;
}
- _padding!.addPadding(_buf, _bufOff);
+ _padding.addPadding(_buf, _bufOff);
}
_cipher.processBlock(_buf, 0, _mac, 0);
diff --git a/lib/macs/cmac.dart b/lib/macs/cmac.dart
index 8b0a81e..c317080 100644
--- a/lib/macs/cmac.dart
+++ b/lib/macs/cmac.dart
@@ -106,7 +106,7 @@
var bit = 0;
while (--i >= 0) {
var b = block[i] & 0xff;
- output[i] = ((b << 1) | bit);
+ output[i] = (b << 1) | bit;
bit = (b >> 7) & 1;
}
return bit;
@@ -173,10 +173,10 @@
}
final out = Uint8List(4);
- out[3] = (xor >> 0);
- out[2] = (xor >> 8);
- out[1] = (xor >> 16);
- out[0] = (xor >> 24);
+ out[3] = xor >> 0;
+ out[2] = xor >> 8;
+ out[1] = xor >> 16;
+ out[0] = xor >> 24;
return out;
}
diff --git a/lib/macs/poly1305.dart b/lib/macs/poly1305.dart
index b0cceec..9ee4b51 100644
--- a/lib/macs/poly1305.dart
+++ b/lib/macs/poly1305.dart
@@ -71,7 +71,7 @@
@override
String get algorithmName =>
- cipher == null ? 'Poly1305' : cipher!.algorithmName + '/Poly1305';
+ cipher == null ? 'Poly1305' : '${cipher!.algorithmName}/Poly1305';
@override
int get macSize => BLOCK_SIZE;
@@ -99,7 +99,7 @@
Uint8List? nonce;
if (cipher != null) {
- if (!(params is ParametersWithIV)) {
+ if (params is! ParametersWithIV) {
throw ArgumentError(
'Poly1305 requires an IV when used with a block cipher.');
}
@@ -108,7 +108,7 @@
params = params.parameters!;
}
- if (!(params is KeyParameter)) {
+ if (params is! KeyParameter) {
throw ArgumentError('Poly1305 requires a key.');
}
@@ -279,10 +279,10 @@
h4 = (h4 & nb) | (g4 & b);
int f0, f1, f2, f3;
- f0 = (h0 | shiftl32(h1, 26)) + (k0);
- f1 = (cshiftr32(h1, 6) | shiftl32(h2, 20)) + (k1);
- f2 = (cshiftr32(h2, 12) | shiftl32(h3, 14)) + (k2);
- f3 = (cshiftr32(h3, 18) | shiftl32(h4, 8)) + (k3);
+ f0 = (h0 | shiftl32(h1, 26)) + k0;
+ f1 = (cshiftr32(h1, 6) | shiftl32(h2, 20)) + k1;
+ f2 = (cshiftr32(h2, 12) | shiftl32(h3, 14)) + k2;
+ f3 = (cshiftr32(h3, 18) | shiftl32(h4, 8)) + k3;
var outByte = ByteData.view(out.buffer, out.offsetInBytes, out.length);
pack32(f0 & 0xffffffff, outByte, outOff, Endian.little);
diff --git a/lib/padded_block_cipher/padded_block_cipher_impl.dart b/lib/padded_block_cipher/padded_block_cipher_impl.dart
index 8e16a13..ae859b4 100644
--- a/lib/padded_block_cipher/padded_block_cipher_impl.dart
+++ b/lib/padded_block_cipher/padded_block_cipher_impl.dart
@@ -30,7 +30,7 @@
@override
String get algorithmName =>
- cipher.algorithmName + '/' + padding.algorithmName;
+ '${cipher.algorithmName}/${padding.algorithmName}';
@override
int get blockSize => cipher.blockSize;
@@ -49,11 +49,11 @@
}
@override
- Uint8List process(Uint8List? data) {
- var inputBlocks = (data!.length + blockSize - 1) ~/ blockSize;
+ Uint8List process(Uint8List data) {
+ var inputBlocks = (data.length + blockSize - 1) ~/ blockSize;
int outputBlocks;
- if (_encrypting!) {
+ if (_encrypting ?? false) {
outputBlocks = (data.length + blockSize) ~/ blockSize;
} else {
if ((data.length % blockSize) != 0) {
@@ -66,11 +66,11 @@
var out = Uint8List(outputBlocks * blockSize);
for (var i = 0; i < (inputBlocks - 1); i++) {
- var offset = (i * blockSize);
+ var offset = i * blockSize;
processBlock(data, offset, out, offset);
}
- var lastBlockOffset = ((inputBlocks - 1) * blockSize);
+ var lastBlockOffset = (inputBlocks - 1) * blockSize;
var lastBlockSize = doFinal(data, lastBlockOffset, out, lastBlockOffset);
return out.sublist(0, lastBlockOffset + lastBlockSize);
@@ -83,14 +83,14 @@
@override
int doFinal(Uint8List inp, int inpOff, Uint8List out, int outOff) {
- if (_encrypting!) {
+ if (_encrypting ?? false) {
var lastInputBlock = Uint8List(blockSize)..setAll(0, inp.sublist(inpOff));
var remainder = inp.length - inpOff;
if (remainder < blockSize) {
// Padding goes embedded in last block of data
- padding.addPadding(lastInputBlock, (inp.length - inpOff));
+ padding.addPadding(lastInputBlock, inp.length - inpOff);
processBlock(lastInputBlock, 0, out, outOff);
diff --git a/lib/paddings/iso7816d4.dart b/lib/paddings/iso7816d4.dart
index c7d73f0..db4fca4 100644
--- a/lib/paddings/iso7816d4.dart
+++ b/lib/paddings/iso7816d4.dart
@@ -26,7 +26,7 @@
/// number of bytes added.
@override
int addPadding(Uint8List data, int offset) {
- var added = (data.length - offset);
+ var added = data.length - offset;
data[offset] = 0x80;
offset++;
diff --git a/lib/paddings/pkcs7.dart b/lib/paddings/pkcs7.dart
index e59da6b..0fff9df 100644
--- a/lib/paddings/pkcs7.dart
+++ b/lib/paddings/pkcs7.dart
@@ -24,7 +24,7 @@
@override
int addPadding(Uint8List data, int offset) {
- var code = (data.length - offset);
+ var code = data.length - offset;
while (offset < data.length) {
data[offset] = code;
diff --git a/lib/signers/ecdsa_signer.dart b/lib/signers/ecdsa_signer.dart
index eae33e7..3e4510f 100644
--- a/lib/signers/ecdsa_signer.dart
+++ b/lib/signers/ecdsa_signer.dart
@@ -91,7 +91,7 @@
dynamic kCalculator;
if (_kMac != null) {
- kCalculator = _RFC6979KCalculator(_kMac!, n, _pvkey!.d!, message);
+ kCalculator = _RFC6979KCalculator(_kMac, n, _pvkey!.d!, message);
} else {
kCalculator = _RandomKCalculator(n, _random!);
}
@@ -163,8 +163,8 @@
Uint8List _hashMessageIfNeeded(Uint8List message) {
if (_digest != null) {
- _digest!.reset();
- return _digest!.process(message);
+ _digest.reset();
+ return _digest.process(message);
} else {
return message;
}
@@ -293,7 +293,7 @@
var x = Uint8List((_n.bitLength + 7) ~/ 8);
var dVal = _asUnsignedByteArray(d);
- x.setRange((x.length - dVal.length), x.length, dVal);
+ x.setRange(x.length - dVal.length, x.length, dVal);
var m = Uint8List((_n.bitLength + 7) ~/ 8);
@@ -305,7 +305,7 @@
var mVal = _asUnsignedByteArray(mInt);
- m.setRange((m.length - mVal.length), m.length, mVal);
+ m.setRange(m.length - mVal.length, m.length, mVal);
_mac.init(KeyParameter(_K));
@@ -342,7 +342,7 @@
if ((t.length - tOff) < _V.length) {
t.setRange(tOff, t.length, _V);
- tOff += (t.length - tOff);
+ tOff += t.length - tOff;
} else {
t.setRange(tOff, tOff + _V.length, _V);
tOff += _V.length;
diff --git a/lib/signers/rsa_signer.dart b/lib/signers/rsa_signer.dart
index 591a2ee..49f73f8 100644
--- a/lib/signers/rsa_signer.dart
+++ b/lib/signers/rsa_signer.dart
@@ -131,7 +131,6 @@
}
}
return true; //return Arrays.constantTimeAreEqual(sig, expected);
-
} else if (sig.length == expected.length - 2) {
// NULL left out
var sigOffset = sig.length - hash.length - 2;
@@ -143,11 +142,11 @@
var nonEqual = 0;
for (var i = 0; i < hash.length; i++) {
- nonEqual |= (sig[sigOffset + i] ^ expected[expectedOffset + i]);
+ nonEqual |= sig[sigOffset + i] ^ expected[expectedOffset + i];
}
for (var i = 0; i < sigOffset; i++) {
- nonEqual |= (sig[i] ^ expected[i]); // check header less NULL
+ nonEqual |= sig[i] ^ expected[i]; // check header less NULL
}
return nonEqual == 0;
diff --git a/lib/src/api/algorithm.dart b/lib/src/api/algorithm.dart
index 8adc373..19ddab8 100644
--- a/lib/src/api/algorithm.dart
+++ b/lib/src/api/algorithm.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// All algorithms defined by Pointy Castle inherit from this class.
abstract class Algorithm {
diff --git a/lib/src/api/asymmetric_block_cipher.dart b/lib/src/api/asymmetric_block_cipher.dart
index b1a27ef..cdae436 100644
--- a/lib/src/api/asymmetric_block_cipher.dart
+++ b/lib/src/api/asymmetric_block_cipher.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// Asymmetric block cipher engines are expected to conform to this interface.
abstract class AsymmetricBlockCipher extends Algorithm {
diff --git a/lib/src/api/asymmetric_key.dart b/lib/src/api/asymmetric_key.dart
index 7f281fd..c3ff9bc 100644
--- a/lib/src/api/asymmetric_key.dart
+++ b/lib/src/api/asymmetric_key.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that asymmetric (public and private) keys conform to.
abstract class AsymmetricKey {}
diff --git a/lib/src/api/asymmetric_key_pair.dart b/lib/src/api/asymmetric_key_pair.dart
index 6dcbd49..fa0ae74 100644
--- a/lib/src/api/asymmetric_key_pair.dart
+++ b/lib/src/api/asymmetric_key_pair.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// A pair of public and private asymmetric keys.
class AsymmetricKeyPair<B extends PublicKey, V extends PrivateKey> {
diff --git a/lib/src/api/asymmetric_key_parameter.dart b/lib/src/api/asymmetric_key_parameter.dart
index 1310156..9fa58d8 100644
--- a/lib/src/api/asymmetric_key_parameter.dart
+++ b/lib/src/api/asymmetric_key_parameter.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// Abstract [CipherParameters] to hold an asymmetric (public or private) key
abstract class AsymmetricKeyParameter<T extends AsymmetricKey>
diff --git a/lib/src/api/block_cipher.dart b/lib/src/api/block_cipher.dart
index 80d8fd0..d08c22b 100644
--- a/lib/src/api/block_cipher.dart
+++ b/lib/src/api/block_cipher.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// Block cipher engines are expected to conform to this interface.
abstract class BlockCipher extends Algorithm {
diff --git a/lib/src/api/cipher_parameters.dart b/lib/src/api/cipher_parameters.dart
index a9e4fa6..84081b2 100644
--- a/lib/src/api/cipher_parameters.dart
+++ b/lib/src/api/cipher_parameters.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// All cipher initialization parameters classes implement this.
abstract class CipherParameters {}
diff --git a/lib/src/api/des_parameters.dart b/lib/src/api/des_parameters.dart
index caeaea6..32484f3 100644
--- a/lib/src/api/des_parameters.dart
+++ b/lib/src/api/des_parameters.dart
@@ -1,7 +1,7 @@
-part of api;
+part of '../../api.dart';
class DESParameters extends KeyParameter {
final int DES_KEY_LENGTH = 8;
- DESParameters(Uint8List key) : super(key);
+ DESParameters(super.key);
}
diff --git a/lib/src/api/desede_parameters.dart b/lib/src/api/desede_parameters.dart
index 732ee41..086d017 100644
--- a/lib/src/api/desede_parameters.dart
+++ b/lib/src/api/desede_parameters.dart
@@ -1,7 +1,7 @@
-part of api;
+part of '../../api.dart';
class DESedeParameters extends DESParameters {
final int DES_EDE_KEY_LENGTH = 24;
- DESedeParameters(Uint8List key) : super(key);
+ DESedeParameters(super.key);
}
diff --git a/lib/src/api/digest.dart b/lib/src/api/digest.dart
index 4c1b2c2..87e5212 100644
--- a/lib/src/api/digest.dart
+++ b/lib/src/api/digest.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that a message digest conforms to.
abstract class Digest extends Algorithm {
diff --git a/lib/src/api/key_derivator.dart b/lib/src/api/key_derivator.dart
index f6e15e8..269bc51 100644
--- a/lib/src/api/key_derivator.dart
+++ b/lib/src/api/key_derivator.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that a symmetric key derivator conforms to.
///
diff --git a/lib/src/api/key_generator.dart b/lib/src/api/key_generator.dart
index ba07d8f..727aec0 100644
--- a/lib/src/api/key_generator.dart
+++ b/lib/src/api/key_generator.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that asymmetric key generators conform to.
///
diff --git a/lib/src/api/key_generator_parameters.dart b/lib/src/api/key_generator_parameters.dart
index 08931e1..cb4be12 100644
--- a/lib/src/api/key_generator_parameters.dart
+++ b/lib/src/api/key_generator_parameters.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// Abstract [CipherParameters] to init an asymmetric key generator.
abstract class KeyGeneratorParameters implements CipherParameters {
diff --git a/lib/src/api/key_parameter.dart b/lib/src/api/key_parameter.dart
index 7506413..20835ac 100644
--- a/lib/src/api/key_parameter.dart
+++ b/lib/src/api/key_parameter.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// [CipherParameters] consisting of just a key of arbitrary length.
class KeyParameter extends CipherParameters {
diff --git a/lib/src/api/mac.dart b/lib/src/api/mac.dart
index 4852bde..3d17086 100644
--- a/lib/src/api/mac.dart
+++ b/lib/src/api/mac.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that a MAC (message authentication code) conforms to.
abstract class Mac extends Algorithm {
diff --git a/lib/src/api/padded_block_cipher.dart b/lib/src/api/padded_block_cipher.dart
index 4794d56..a33958d 100644
--- a/lib/src/api/padded_block_cipher.dart
+++ b/lib/src/api/padded_block_cipher.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// All padded block ciphers conform to this interface.
///
diff --git a/lib/src/api/padded_block_cipher_parameters.dart b/lib/src/api/padded_block_cipher_parameters.dart
index b20d69e..a5cdf9f 100644
--- a/lib/src/api/padded_block_cipher_parameters.dart
+++ b/lib/src/api/padded_block_cipher_parameters.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// [CipherParameters] for [PaddedBlockCipher]s consisting of two underlying [CipherParameters], one for the [BlockCipher] (of
/// type [UnderlyingCipherParameters]) and the other for the [Padding] (of type [PaddingCipherParameters]).
diff --git a/lib/src/api/padding.dart b/lib/src/api/padding.dart
index 4f13486..d0a7713 100644
--- a/lib/src/api/padding.dart
+++ b/lib/src/api/padding.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that a padding conforms to.
abstract class Padding extends Algorithm {
diff --git a/lib/src/api/parameters_with_iv.dart b/lib/src/api/parameters_with_iv.dart
index 181a401..3779edd 100644
--- a/lib/src/api/parameters_with_iv.dart
+++ b/lib/src/api/parameters_with_iv.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// [CipherParameters] consisting of an underlying [CipherParameters] (of type [UnderlyingParameters]) and an initialization
/// vector of arbitrary length.
diff --git a/lib/src/api/parameters_with_random.dart b/lib/src/api/parameters_with_random.dart
index 908a5d8..79608e8 100644
--- a/lib/src/api/parameters_with_random.dart
+++ b/lib/src/api/parameters_with_random.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
//TODO consider mixin
/// [CipherParameters] consisting of an underlying [CipherParameters] (of type
diff --git a/lib/src/api/parameters_with_salt.dart b/lib/src/api/parameters_with_salt.dart
index 0cc5547..994e3b1 100644
--- a/lib/src/api/parameters_with_salt.dart
+++ b/lib/src/api/parameters_with_salt.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// [CipherParameters] consisting of an underlying [CipherParameters] (of type
/// [UnderlyingParameters]) and an acompanying salt of type [Uint8List].
diff --git a/lib/src/api/parameters_with_salt_configuration.dart b/lib/src/api/parameters_with_salt_configuration.dart
index 07c1ce5..acc4550 100644
--- a/lib/src/api/parameters_with_salt_configuration.dart
+++ b/lib/src/api/parameters_with_salt_configuration.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// [CipherParameters] consisting of an underlying [CipherParameters] (of type
/// [UnderlyingParameters]), an acompanying [SecureRandom], and salt length.
diff --git a/lib/src/api/pbe_parameters_generator.dart b/lib/src/api/pbe_parameters_generator.dart
index 814c4f2..4a97c69 100644
--- a/lib/src/api/pbe_parameters_generator.dart
+++ b/lib/src/api/pbe_parameters_generator.dart
@@ -1,4 +1,4 @@
-part of api;
+part of '../../api.dart';
abstract class PBEParametersGenerator {
factory PBEParametersGenerator(String algorithmName) =>
diff --git a/lib/src/api/private_key.dart b/lib/src/api/private_key.dart
index fa993b0..a8f2a3b 100644
--- a/lib/src/api/private_key.dart
+++ b/lib/src/api/private_key.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that asymmetric private keys conform to.
abstract class PrivateKey implements AsymmetricKey {}
diff --git a/lib/src/api/private_key_parameter.dart b/lib/src/api/private_key_parameter.dart
index 63374cb..8ee7bb7 100644
--- a/lib/src/api/private_key_parameter.dart
+++ b/lib/src/api/private_key_parameter.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// A [CipherParameters] to hold an asymmetric private key
class PrivateKeyParameter<T extends PrivateKey>
diff --git a/lib/src/api/public_key.dart b/lib/src/api/public_key.dart
index 47d097d..5ab25d7 100644
--- a/lib/src/api/public_key.dart
+++ b/lib/src/api/public_key.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface that asymmetric public keys conform to.
abstract class PublicKey implements AsymmetricKey {}
diff --git a/lib/src/api/public_key_parameter.dart b/lib/src/api/public_key_parameter.dart
index 2488d87..a93ef83 100644
--- a/lib/src/api/public_key_parameter.dart
+++ b/lib/src/api/public_key_parameter.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// A [CipherParameters] to hold an asymmetric public key
class PublicKeyParameter<T extends PublicKey>
diff --git a/lib/src/api/rc2_parameters.dart b/lib/src/api/rc2_parameters.dart
index efae81d..14a742d 100644
--- a/lib/src/api/rc2_parameters.dart
+++ b/lib/src/api/rc2_parameters.dart
@@ -1,4 +1,4 @@
-part of api;
+part of '../../api.dart';
class RC2Parameters extends KeyParameter {
late int effectiveKeyBits;
diff --git a/lib/src/api/registry_factory_exception.dart b/lib/src/api/registry_factory_exception.dart
index ce4e2da..bacb5b6 100644
--- a/lib/src/api/registry_factory_exception.dart
+++ b/lib/src/api/registry_factory_exception.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// This kind of exception is thrown when a user tries to create an algorithm
/// or domain parameters that were not correctly registered. This can be
@@ -12,13 +12,12 @@
RegistryFactoryException(this.message);
RegistryFactoryException.unknown(String algorithm, [Type? type])
- : this('No algorithm registered' +
- (type != null ? ' of type $type' : '') +
- ' with name: $algorithm');
+ : this(
+ 'No algorithm registered${type != null ? ' of type $type' : ''} with name: $algorithm');
RegistryFactoryException.invalid(String algorithm, [Type? type])
- : this('Algorithm name $algorithm is invalid' +
- (type != null ? ' of type $type' : ''));
+ : this(
+ 'Algorithm name $algorithm is invalid${type != null ? ' of type $type' : ''}');
@override
String toString() => 'RegistryFactoryException: $message';
diff --git a/lib/src/api/secure_random.dart b/lib/src/api/secure_random.dart
index f3ef5c4..649086c 100644
--- a/lib/src/api/secure_random.dart
+++ b/lib/src/api/secure_random.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// A synchronous secure random number generator (RNG).
///
diff --git a/lib/src/api/signature.dart b/lib/src/api/signature.dart
index 02d5fcb..19527cc 100644
--- a/lib/src/api/signature.dart
+++ b/lib/src/api/signature.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// An interface for signatures created by a [Signer]
abstract class Signature {}
diff --git a/lib/src/api/signer.dart b/lib/src/api/signer.dart
index 7a73b23..a07088b 100644
--- a/lib/src/api/signer.dart
+++ b/lib/src/api/signer.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// An interface for DSAs (digital signature algorithms)
abstract class Signer extends Algorithm {
diff --git a/lib/src/api/srp_client.dart b/lib/src/api/srp_client.dart
index c29d539..d9a11cc 100644
--- a/lib/src/api/srp_client.dart
+++ b/lib/src/api/srp_client.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
abstract class SRPClient {
///Computes the client evidence message M1 using the previously received values.
diff --git a/lib/src/api/srp_server.dart b/lib/src/api/srp_server.dart
index ff5abad..3dc5e74 100644
--- a/lib/src/api/srp_server.dart
+++ b/lib/src/api/srp_server.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// Implements the server side SRP-6a protocol. Note that this class is stateful, and therefore NOT threadsafe.
/// This implementation of SRP is based on the optimized message sequence put forth by Thomas Wu in the paper
diff --git a/lib/src/api/stream_cipher.dart b/lib/src/api/stream_cipher.dart
index 463e74a..34e52f3 100644
--- a/lib/src/api/stream_cipher.dart
+++ b/lib/src/api/stream_cipher.dart
@@ -1,6 +1,6 @@
// See file LICENSE for more information.
-part of api;
+part of '../../api.dart';
/// The interface stream ciphers conform to.
abstract class StreamCipher extends Algorithm {
diff --git a/lib/src/api/xof.dart b/lib/src/api/xof.dart
index 4a34773..64dd575 100644
--- a/lib/src/api/xof.dart
+++ b/lib/src/api/xof.dart
@@ -1,4 +1,4 @@
-part of api;
+part of '../../api.dart';
abstract class Xof extends Digest {
/// Create the Xof specified by the standard [algorithmName].
diff --git a/lib/src/ct.dart b/lib/src/ct.dart
index bae94f6..bdf965b 100644
--- a/lib/src/ct.dart
+++ b/lib/src/ct.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.utils;
-
import 'dart:typed_data';
///
diff --git a/lib/src/ec_standard_curve_constructor.dart b/lib/src/ec_standard_curve_constructor.dart
index 5e299c3..d18dacf 100644
--- a/lib/src/ec_standard_curve_constructor.dart
+++ b/lib/src/ec_standard_curve_constructor.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.registry.ec_standard_curve_constructor;
-
import 'package:pointycastle/ecc/ecc_base.dart';
import 'package:pointycastle/ecc/ecc_fp.dart' as fp;
import 'package:pointycastle/src/utils.dart' as utils;
diff --git a/lib/src/impl/base_aead_block_cipher.dart b/lib/src/impl/base_aead_block_cipher.dart
index a8c0309..bd022a1 100644
--- a/lib/src/impl/base_aead_block_cipher.dart
+++ b/lib/src/impl/base_aead_block_cipher.dart
@@ -1,5 +1,3 @@
-library src.impl.base_aead_block_cipher;
-
import 'dart:math' show min;
import 'dart:typed_data';
diff --git a/lib/src/impl/base_aead_cipher.dart b/lib/src/impl/base_aead_cipher.dart
index f2cf53c..a7477fb 100644
--- a/lib/src/impl/base_aead_cipher.dart
+++ b/lib/src/impl/base_aead_cipher.dart
@@ -1,5 +1,3 @@
-library src.impl.base_aead_cipher;
-
import 'dart:typed_data';
import '../../api.dart';
diff --git a/lib/src/impl/base_asymmetric_block_cipher.dart b/lib/src/impl/base_asymmetric_block_cipher.dart
index ae3721a..46ebe98 100644
--- a/lib/src/impl/base_asymmetric_block_cipher.dart
+++ b/lib/src/impl/base_asymmetric_block_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_asymmetric_block_cipher;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/base_block_cipher.dart b/lib/src/impl/base_block_cipher.dart
index 4fddca6..bcf5075 100644
--- a/lib/src/impl/base_block_cipher.dart
+++ b/lib/src/impl/base_block_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_block_cipher;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/base_digest.dart b/lib/src/impl/base_digest.dart
index 53eedef..d332fc5 100644
--- a/lib/src/impl/base_digest.dart
+++ b/lib/src/impl/base_digest.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_digest;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/base_key_derivator.dart b/lib/src/impl/base_key_derivator.dart
index 73a38d0..45a4f67 100644
--- a/lib/src/impl/base_key_derivator.dart
+++ b/lib/src/impl/base_key_derivator.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_key_derivator;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/base_mac.dart b/lib/src/impl/base_mac.dart
index 3873d63..48f39d3 100644
--- a/lib/src/impl/base_mac.dart
+++ b/lib/src/impl/base_mac.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_mac;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/base_padding.dart b/lib/src/impl/base_padding.dart
index 7996696..33c95fb 100644
--- a/lib/src/impl/base_padding.dart
+++ b/lib/src/impl/base_padding.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_padding;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/base_stream_cipher.dart b/lib/src/impl/base_stream_cipher.dart
index 4840845..99d5540 100644
--- a/lib/src/impl/base_stream_cipher.dart
+++ b/lib/src/impl/base_stream_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.base_stream_cipher;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/impl/entropy.dart b/lib/src/impl/entropy.dart
index f6b253a..8956a3e 100644
--- a/lib/src/impl/entropy.dart
+++ b/lib/src/impl/entropy.dart
@@ -1,5 +1,3 @@
-library impl.entropy;
-
import 'dart:typed_data';
/// Defines an entropy source, this is not to be confused with a rng.
diff --git a/lib/src/impl/keccak_engine.dart b/lib/src/impl/keccak_engine.dart
index c039515..9f6a9a6 100644
--- a/lib/src/impl/keccak_engine.dart
+++ b/lib/src/impl/keccak_engine.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.digests.keccak_engine;
-
import 'dart:math';
import 'dart:typed_data';
@@ -84,7 +82,7 @@
int get byteLength => _rate ~/ 8;
@override
- int get digestSize => (fixedOutputLength ~/ 8);
+ int get digestSize => fixedOutputLength ~/ 8;
int get rate => _rate;
@@ -147,7 +145,7 @@
var available = rateBytes - bytesInQueue;
if (len < available) {
_dataQueue.setRange(bytesInQueue, bytesInQueue + len, data, off);
- _bitsInQueue += (len << 3);
+ _bitsInQueue += len << 3;
return;
}
@@ -160,7 +158,7 @@
}
int remaining;
- while ((remaining = (len - count)) >= rateBytes) {
+ while ((remaining = len - count) >= rateBytes) {
_keccakAbsorb(data, off + count);
count += rateBytes;
}
@@ -169,10 +167,6 @@
_bitsInQueue = remaining << 3;
}
- void _clearDataQueueSection(int off, int len) {
- _dataQueue.fillRange(off, off + len, 0);
- }
-
void _doUpdate(Uint8List data, int off, int len) {
absorbRange(data, off, len);
}
@@ -194,21 +188,6 @@
fixedOutputLength = (1600 - theRate) ~/ 2;
}
- void _absorb(int data) {
- if ((_bitsInQueue % ~8) != 0) {
- throw StateError('attempt to absorb with odd length queue');
- }
- if (squeezing) {
- throw StateError('attempt to absorb while squeezing');
- }
-
- dataQueue[_bitsInQueue >> 3] = data & 0xFF;
- if ((_bitsInQueue += 8) == _rate) {
- _keccakAbsorb(_dataQueue, 0);
- _bitsInQueue = 0;
- }
- }
-
void _keccakAbsorb(Uint8List? data, int off) {
var count = _rate >> 3;
for (var i = 0; i < count; ++i) {
@@ -220,7 +199,7 @@
void _keccakExtract() {
_keccakPermutation();
- _dataQueue.setRange(0, (_rate >> 3), _state);
+ _dataQueue.setRange(0, _rate >> 3, _state);
_bitsInQueue = _rate;
}
@@ -253,11 +232,11 @@
}
void _padAndSwitchToSqueezingPhase() {
- _dataQueue[_bitsInQueue >> 3] |= (1 << (_bitsInQueue & 7));
+ _dataQueue[_bitsInQueue >> 3] |= 1 << (_bitsInQueue & 7);
if (++_bitsInQueue == _rate) {
_keccakAbsorb(_dataQueue, 0);
} else {
- var full = (_bitsInQueue >> 6), partial = _bitsInQueue & 63;
+ var full = _bitsInQueue >> 6, partial = _bitsInQueue & 63;
for (var i = 0; i < full * 8; ++i) {
_state[i] ^= _dataQueue[i];
}
@@ -278,7 +257,7 @@
}
}
- _state[((_rate - 1) >> 3)] ^= (1 << 7);
+ _state[((_rate - 1) >> 3)] ^= 1 << 7;
_bitsInQueue = 0;
_squeezing = true;
}
diff --git a/lib/src/impl/long_sha2_family_digest.dart b/lib/src/impl/long_sha2_family_digest.dart
index ffc5e0e..4445104 100644
--- a/lib/src/impl/long_sha2_family_digest.dart
+++ b/lib/src/impl/long_sha2_family_digest.dart
@@ -1,11 +1,9 @@
// See file LICENSE for more information.
-library src.impl.digests.long_sha2_family_digest;
-
import 'dart:typed_data';
-import 'package:pointycastle/src/ufixnum.dart';
import 'package:pointycastle/src/impl/base_digest.dart';
+import 'package:pointycastle/src/ufixnum.dart';
/// Base implementation of SHA-2 family algorithms SHA-384 and SHA-512.
abstract class LongSHA2FamilyDigest extends BaseDigest {
@@ -158,44 +156,92 @@
var t = 0;
for (var i = 0; i < 10; i++) {
// t = 8 * i
- h..sum(_sum1(e))..sum(_ch(e, f, g))..sum(_k[t])..sum(_w[t++]);
+ h
+ ..sum(_sum1(e))
+ ..sum(_ch(e, f, g))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
d.sum(h);
- h..sum(_sum0(a))..sum(_maj(a, b, c));
+ h
+ ..sum(_sum0(a))
+ ..sum(_maj(a, b, c));
// t = 8 * i + 1
- g..sum(_sum1(d))..sum(_ch(d, e, f))..sum(_k[t])..sum(_w[t++]);
+ g
+ ..sum(_sum1(d))
+ ..sum(_ch(d, e, f))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
c.sum(g);
- g..sum(_sum0(h))..sum(_maj(h, a, b));
+ g
+ ..sum(_sum0(h))
+ ..sum(_maj(h, a, b));
// t = 8 * i + 2
- f..sum(_sum1(c))..sum(_ch(c, d, e))..sum(_k[t])..sum(_w[t++]);
+ f
+ ..sum(_sum1(c))
+ ..sum(_ch(c, d, e))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
b.sum(f);
- f..sum(_sum0(g))..sum(_maj(g, h, a));
+ f
+ ..sum(_sum0(g))
+ ..sum(_maj(g, h, a));
// t = 8 * i + 3
- e..sum(_sum1(b))..sum(_ch(b, c, d))..sum(_k[t])..sum(_w[t++]);
+ e
+ ..sum(_sum1(b))
+ ..sum(_ch(b, c, d))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
a.sum(e);
- e..sum(_sum0(f))..sum(_maj(f, g, h));
+ e
+ ..sum(_sum0(f))
+ ..sum(_maj(f, g, h));
// t = 8 * i + 4
- d..sum(_sum1(a))..sum(_ch(a, b, c))..sum(_k[t])..sum(_w[t++]);
+ d
+ ..sum(_sum1(a))
+ ..sum(_ch(a, b, c))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
h.sum(d);
- d..sum(_sum0(e))..sum(_maj(e, f, g));
+ d
+ ..sum(_sum0(e))
+ ..sum(_maj(e, f, g));
// t = 8 * i + 5
- c..sum(_sum1(h))..sum(_ch(h, a, b))..sum(_k[t])..sum(_w[t++]);
+ c
+ ..sum(_sum1(h))
+ ..sum(_ch(h, a, b))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
g.sum(c);
- c..sum(_sum0(d))..sum(_maj(d, e, f));
+ c
+ ..sum(_sum0(d))
+ ..sum(_maj(d, e, f));
// t = 8 * i + 6
- b..sum(_sum1(g))..sum(_ch(g, h, a))..sum(_k[t])..sum(_w[t++]);
+ b
+ ..sum(_sum1(g))
+ ..sum(_ch(g, h, a))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
f.sum(b);
- b..sum(_sum0(c))..sum(_maj(c, d, e));
+ b
+ ..sum(_sum0(c))
+ ..sum(_maj(c, d, e));
// t = 8 * i + 7
- a..sum(_sum1(f))..sum(_ch(f, g, h))..sum(_k[t])..sum(_w[t++]);
+ a
+ ..sum(_sum1(f))
+ ..sum(_ch(f, g, h))
+ ..sum(_k[t])
+ ..sum(_w[t++]);
e.sum(a);
- a..sum(_sum0(b))..sum(_maj(b, c, d));
+ a
+ ..sum(_sum0(b))
+ ..sum(_maj(b, c, d));
}
h1.sum(a);
diff --git a/lib/src/impl/md4_family_digest.dart b/lib/src/impl/md4_family_digest.dart
index ee4e040..49e297f 100644
--- a/lib/src/impl/md4_family_digest.dart
+++ b/lib/src/impl/md4_family_digest.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.digests.md4_family_digest;
-
import 'dart:typed_data';
import 'package:pointycastle/src/ufixnum.dart';
@@ -186,7 +184,7 @@
void _packState(Uint8List out, int outOff) {
for (var i = 0; i < _packedStateSize; i++) {
- pack32(state[i], out, (outOff + i * 4), _endian);
+ pack32(state[i], out, outOff + i * 4, _endian);
}
}
}
diff --git a/lib/src/impl/secure_random_base.dart b/lib/src/impl/secure_random_base.dart
index 9714936..316e890 100644
--- a/lib/src/impl/secure_random_base.dart
+++ b/lib/src/impl/secure_random_base.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.impl.random.secure_random_base;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/lib/src/platform_check/abstract.dart b/lib/src/platform_check/abstract.dart
index a41a634..a92fe9d 100644
--- a/lib/src/platform_check/abstract.dart
+++ b/lib/src/platform_check/abstract.dart
@@ -18,14 +18,14 @@
@override
EntropySource platformEntropySource() {
- return _genericEntropySource();
+ return _GenericEntropySource();
}
}
Platform getPlatform() => PlatformGeneric.instance;
// Uses the built in entropy source
-class _genericEntropySource implements EntropySource {
+class _GenericEntropySource implements EntropySource {
final _src = Random.secure();
@override
diff --git a/lib/src/platform_check/node_crypto.dart b/lib/src/platform_check/node_crypto.dart
index 36f6a37..5f798a8 100644
--- a/lib/src/platform_check/node_crypto.dart
+++ b/lib/src/platform_check/node_crypto.dart
@@ -1,12 +1,17 @@
/// Wrapper for needed NodeJS Crypto library function and require.
-@JS()
library nodecryto;
-import 'package:js/js.dart';
-
-external dynamic require(String id);
+import 'dart:js_interop';
+import 'dart:js_interop_unsafe';
@JS()
+external JSObject require(String id);
+
+@JS()
+@staticInterop
class NodeCrypto {
- external randomFillSync(buf);
+ static JSAny randomFillSync(JSAny buf) {
+ final crypto = require('crypto');
+ return crypto.callMethod('randomFillSync'.toJS, buf);
+ }
}
diff --git a/lib/src/platform_check/web.dart b/lib/src/platform_check/web.dart
index 48646c1..59ef673 100644
--- a/lib/src/platform_check/web.dart
+++ b/lib/src/platform_check/web.dart
@@ -1,8 +1,8 @@
@JS()
+import 'dart:js_interop';
import 'dart:math';
import 'dart:typed_data';
-import 'package:js/js.dart';
import 'package:pointycastle/src/impl/entropy.dart';
import 'node_crypto.dart';
@@ -56,9 +56,8 @@
class _JsNodeEntropySource implements EntropySource {
@override
Uint8List getBytes(int len) {
- NodeCrypto j = require('crypto');
var list = Uint8List(len);
- j.randomFillSync(list);
+ NodeCrypto.randomFillSync(list.buffer.toJS);
return list;
}
}
diff --git a/lib/src/registration.dart b/lib/src/registration.dart
index 48eb7f0..827a889 100644
--- a/lib/src/registration.dart
+++ b/lib/src/registration.dart
@@ -2,7 +2,7 @@
//
//
-////TODO find out that these two methods are for!
+//TODO find out that these two methods are for!
//BlockCipher _cfbBlockCipherFactory(String algorithmName) {
// var parts = algorithmName.split("/");
//
diff --git a/lib/src/registry/registration.dart b/lib/src/registry/registration.dart
index 414dc7e..881be78 100644
--- a/lib/src/registry/registration.dart
+++ b/lib/src/registry/registration.dart
@@ -1,5 +1,3 @@
-library src.registry.impl;
-
import 'package:pointycastle/export.dart';
import 'package:pointycastle/key_derivators/concat_kdf.dart';
import 'package:pointycastle/key_derivators/ecdh_kdf.dart';
diff --git a/lib/src/registry/registry.dart b/lib/src/registry/registry.dart
index 9aacb46..a168d0e 100644
--- a/lib/src/registry/registry.dart
+++ b/lib/src/registry/registry.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.registry;
-
import 'package:pointycastle/api.dart';
import 'package:pointycastle/src/registry/registration.dart';
@@ -27,8 +25,7 @@
final String algorithmName;
final RegistrableConstructor factory;
- StaticFactoryConfig(Type type, this.algorithmName, this.factory)
- : super(type);
+ StaticFactoryConfig(super.type, this.algorithmName, this.factory);
}
// From the PatternCharacter rule here:
@@ -47,7 +44,7 @@
final RegExp regExp;
final DynamicConstructorFactory factory;
- DynamicFactoryConfig(Type type, this.regExp, this.factory) : super(type);
+ DynamicFactoryConfig(super.type, this.regExp, this.factory);
DynamicFactoryConfig.regex(
Type type, String regexString, DynamicConstructorFactory factory)
diff --git a/lib/src/ufixnum.dart b/lib/src/ufixnum.dart
index 515ab93..1b63b9c 100644
--- a/lib/src/ufixnum.dart
+++ b/lib/src/ufixnum.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.ufixnum;
-
import 'dart:typed_data';
const _MASK_3 = 0x07;
@@ -51,44 +49,44 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// 8 bit operations
//
-int clip8(int x) => (x & _MASK_8);
+int clip8(int x) => x & _MASK_8;
int csum8(int x, int y) => sum8(clip8(x), clip8(y));
int sum8(int x, int y) {
assert((x >= 0) && (x <= _MASK_8));
assert((y >= 0) && (y <= _MASK_8));
- return ((x + y) & _MASK_8);
+ return (x + y) & _MASK_8;
}
int csub8(int x, int y) => sub8(clip8(x), clip8(y));
int sub8(int x, int y) {
assert((x >= 0) && (x <= _MASK_8));
assert((y >= 0) && (y <= _MASK_8));
- return ((x - y) & _MASK_8);
+ return (x - y) & _MASK_8;
}
int cshiftl8(int x, int n) => shiftl8(clip8(x), n);
int shiftl8(int x, int n) {
assert((x >= 0) && (x <= _MASK_8));
- return ((x << (n & _MASK_3)) & _MASK_8);
+ return (x << (n & _MASK_3)) & _MASK_8;
}
int cshiftr8(int x, int n) => shiftr8(clip8(x), n);
int shiftr8(int x, int n) {
assert((x >= 0) && (x <= _MASK_8));
- return (x >> (n & _MASK_3));
+ return x >> (n & _MASK_3);
}
int cneg8(int x) => neg8(clip8(x));
int neg8(int x) {
assert((x >= 0) && (x <= _MASK_8));
- return (-x & _MASK_8);
+ return -x & _MASK_8;
}
int cnot8(int x) => not8(clip8(x));
int not8(int x) {
assert((x >= 0) && (x <= _MASK_8));
- return (~x & _MASK_8);
+ return ~x & _MASK_8;
}
int crotl8(int x, int n) => rotl8(clip8(x), n);
@@ -110,7 +108,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// 16 bit operations
//
-int clip16(int x) => (x & _MASK_16);
+int clip16(int x) => x & _MASK_16;
/// Packs a 16 bit integer into a byte buffer. The [out] parameter can be an [Uint8List] or a
/// [ByteData] if you will run it several times against the same buffer and want faster execution.
@@ -135,20 +133,20 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// 32 bit operations
//
-int clip32(int x) => (x & _MASK_32);
+int clip32(int x) => x & _MASK_32;
int csum32(int x, int y) => sum32(clip32(x), clip32(y));
int sum32(int x, int y) {
assert((x >= 0) && (x <= _MASK_32));
assert((y >= 0) && (y <= _MASK_32));
- return ((x + y) & _MASK_32);
+ return (x + y) & _MASK_32;
}
int csub32(int x, int y) => sub32(clip32(x), clip32(y));
int sub32(int x, int y) {
assert((x >= 0) && (x <= _MASK_32));
assert((y >= 0) && (y <= _MASK_32));
- return ((x - y) & _MASK_32);
+ return (x - y) & _MASK_32;
}
int cshiftl32(int x, int n) => shiftl32(clip32(x), n);
@@ -156,26 +154,26 @@
assert((x >= 0) && (x <= _MASK_32));
n &= _MASK_5;
x &= _MASK32_HI_BITS[n];
- return ((x << n) & _MASK_32);
+ return (x << n) & _MASK_32;
}
int cshiftr32(int x, int n) => shiftr32(clip32(x), n);
int shiftr32(int x, int n) {
assert((x >= 0) && (x <= _MASK_32));
n &= _MASK_5;
- return (x >> n);
+ return x >> n;
}
int cneg32(int x) => neg32(clip32(x));
int neg32(int x) {
assert((x >= 0) && (x <= _MASK_32));
- return (-x & _MASK_32);
+ return -x & _MASK_32;
}
int cnot32(int x) => not32(clip32(x));
int not32(int x) {
assert((x >= 0) && (x <= _MASK_32));
- return (~x & _MASK_32);
+ return ~x & _MASK_32;
}
int crotl32(int x, int n) => rotl32(clip32(x), n);
@@ -191,7 +189,7 @@
assert(n >= 0);
assert((x >= 0) && (x <= _MASK_32));
n &= _MASK_5;
- return (x >> n) | shiftl32(x, (32 - n));
+ return (x >> n) | shiftl32(x, 32 - n);
}
/// Packs a 32 bit integer into a byte buffer. The [out] parameter can be an [Uint8List] or a
@@ -221,7 +219,7 @@
late int _hi32;
late int _lo32;
- Register64([dynamic hiOrLo32OrY = 0, int? lo32]) {
+ Register64([Object hiOrLo32OrY = 0, int? lo32]) {
set(hiOrLo32OrY, lo32);
}
@@ -229,14 +227,15 @@
int get hi32 => _hi32;
@override
- bool operator ==(Object y) =>
- y is Register64 ? (((_hi32 == y._hi32) && (_lo32 == y._lo32))) : false;
+ bool operator ==(Object other) => other is Register64
+ ? (((_hi32 == other._hi32) && (_lo32 == other._lo32)))
+ : false;
bool operator <(Register64 y) =>
- ((_hi32 < y._hi32) || ((_hi32 == y._hi32) && (_lo32 < y._lo32)));
- bool operator <=(Register64 y) => ((this < y) || (this == y));
+ (_hi32 < y._hi32) || ((_hi32 == y._hi32) && (_lo32 < y._lo32));
+ bool operator <=(Register64 y) => (this < y) || (this == y);
bool operator >(Register64 y) =>
- ((_hi32 > y._hi32) || ((_hi32 == y._hi32) && (_lo32 > y._lo32)));
- bool operator >=(Register64 y) => ((this > y) || (this == y));
+ (_hi32 > y._hi32) || ((_hi32 == y._hi32) && (_lo32 > y._lo32));
+ bool operator >=(Register64 y) => (this > y) || (this == y);
void set(dynamic hiOrLo32OrY, [int? lo32]) {
if (lo32 == null) {
@@ -244,14 +243,14 @@
_hi32 = hiOrLo32OrY._hi32;
_lo32 = hiOrLo32OrY._lo32;
} else {
- assert(hiOrLo32OrY <= _MASK_32);
+ assert(hiOrLo32OrY as int <= _MASK_32);
_hi32 = 0;
- _lo32 = hiOrLo32OrY;
+ _lo32 = hiOrLo32OrY as int;
}
} else {
- assert(hiOrLo32OrY <= _MASK_32);
+ assert(hiOrLo32OrY as int <= _MASK_32);
assert(lo32 <= _MASK_32);
- _hi32 = hiOrLo32OrY;
+ _hi32 = hiOrLo32OrY as int;
_lo32 = lo32;
}
}
@@ -259,25 +258,25 @@
void sum(dynamic y) {
if (y is int) {
y &= _MASK_32;
- var slo32 = (_lo32 + y);
- _lo32 = (slo32 & _MASK_32);
+ var slo32 = _lo32 + y;
+ _lo32 = slo32 & _MASK_32;
if (slo32 != _lo32) {
_hi32++;
_hi32 &= _MASK_32;
}
} else {
var slo32 = _lo32 + y._lo32 as int;
- _lo32 = (slo32 & _MASK_32);
+ _lo32 = slo32 & _MASK_32;
var carry = ((slo32 != _lo32) ? 1 : 0);
- _hi32 = (((_hi32 + y._hi32 + carry) as int) & _MASK_32);
+ _hi32 = ((_hi32 + y._hi32 + carry) as int) & _MASK_32;
}
}
void sumReg(Register64 y) {
- var slo32 = (_lo32 + y._lo32);
- _lo32 = (slo32 & _MASK_32);
+ var slo32 = _lo32 + y._lo32;
+ _lo32 = slo32 & _MASK_32;
var carry = ((slo32 != _lo32) ? 1 : 0);
- _hi32 = ((_hi32 + y._hi32 + carry) & _MASK_32);
+ _hi32 = (_hi32 + y._hi32 + carry) & _MASK_32;
}
void sub(dynamic y) {
@@ -289,7 +288,7 @@
// Grab 16-bit chunks.
final a0 = _lo32 & _MASK_16;
final a1 = (_lo32 >> 16) & _MASK_16;
- final a2 = (_hi32 & _MASK_16);
+ final a2 = _hi32 & _MASK_16;
final a3 = (_hi32 >> 16) & _MASK_16;
late int b0, b1, b2, b3;
if (y is int) {
@@ -299,7 +298,7 @@
b1 = (y >> 16) & _MASK_16;
b2 = b3 = 0;
} else /* if (y is Register64) */ {
- b0 = y._lo32 & _MASK_16;
+ b0 = (y as Register64)._lo32 & _MASK_16;
b1 = (y._lo32 >> 16) & _MASK_16;
b2 = y._hi32 & _MASK_16;
b3 = (y._hi32 >> 16) & _MASK_16;
@@ -338,13 +337,13 @@
// |................................|................................|
// |xxxxxxxxxxxxxxxx................|................................| p3
var slo32 = p0 + ((p1 & _MASK_16) << 16);
- _lo32 = (slo32 & _MASK_32);
+ _lo32 = slo32 & _MASK_32;
var carry = ((slo32 != _lo32) ? 1 : 0);
// p1 is a 33-bit integer, shiftr operation will ignore 33th-bit on js
var carry2 = ((p1 & _MASK_32) != p1) ? 0x10000 : 0;
var shi32 =
((p1 & _MASK_32) >> 16) + p2 + ((p3 & _MASK_16) << 16) + carry + carry2;
- _hi32 = (shi32 & _MASK_32);
+ _hi32 = shi32 & _MASK_32;
}
void neg() {
@@ -353,8 +352,8 @@
}
void not() {
- _hi32 = (~_hi32 & _MASK_32);
- _lo32 = (~_lo32 & _MASK_32);
+ _hi32 = ~_hi32 & _MASK_32;
+ _lo32 = ~_lo32 & _MASK_32;
}
void and(Register64 y) {
@@ -377,7 +376,7 @@
if (n == 0) {
// do nothing
} else if (n >= 32) {
- _hi32 = shiftl32(_lo32, (n - 32));
+ _hi32 = shiftl32(_lo32, n - 32);
_lo32 = 0;
} else {
_hi32 = shiftl32(_hi32, n);
@@ -439,9 +438,9 @@
} else {
var hi32 = _hi32;
_hi32 = _hi32 >> n;
- _hi32 |= shiftl32(_lo32, (32 - n));
+ _hi32 |= shiftl32(_lo32, 32 - n);
_lo32 = _lo32 >> n;
- _lo32 |= shiftl32(hi32, (32 - n));
+ _lo32 |= shiftl32(hi32, 32 - n);
}
}
}
@@ -511,14 +510,14 @@
void _padWrite(StringBuffer sb, int value) {
var str = value.toRadixString(16);
- for (var i = (8 - str.length); i > 0; i--) {
+ for (var i = 8 - str.length; i > 0; i--) {
sb.write('0');
}
sb.write(str);
}
@override
- int get hashCode => super.hashCode;
+ int get hashCode => Object.hash(_hi32, _lo32);
}
class Register64List {
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 16de83b..0ba221d 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.utils;
-
import 'dart:typed_data';
import 'package:pointycastle/src/platform_check/platform_check.dart';
@@ -33,10 +31,10 @@
var nonEqual = expected.length ^ supplied.length;
for (var i = 0; i != len; i++) {
- nonEqual |= (expected[i] ^ supplied[i]);
+ nonEqual |= expected[i] ^ supplied[i];
}
for (var i = len; i < supplied.length; i++) {
- nonEqual |= (supplied[i] ^ ~supplied[i]);
+ nonEqual |= supplied[i] ^ ~supplied[i];
}
return nonEqual == 0;
@@ -58,7 +56,7 @@
result = BigInt.zero;
for (var i = 0; i < bytes.length; i++) {
var item = bytes[bytes.length - i - 1];
- result |= (BigInt.from(item) << (8 * i));
+ result |= BigInt.from(item) << (8 * i);
}
}
return result != BigInt.zero
@@ -86,7 +84,7 @@
result = BigInt.from(0);
for (var i = 0; i < magnitude.length; i++) {
var item = magnitude[magnitude.length - i - 1];
- result |= (BigInt.from(item) << (8 * i));
+ result |= BigInt.from(item) << (8 * i);
}
}
@@ -160,7 +158,7 @@
var d = 0;
for (var i = 0; i < len; ++i) {
- d |= (a[aOff + i] ^ b[bOff + i]);
+ d |= a[aOff + i] ^ b[bOff + i];
}
return 0 == d;
}
@@ -292,7 +290,7 @@
}
var hi32 = (n >> 32) & 0xFFFFFFFF;
- var lo32 = (n) & 0xFFFFFFFF;
+ var lo32 = n & 0xFFFFFFFF;
if (distance >= 32) {
var swap = hi32;
@@ -305,21 +303,21 @@
}
}
- final distance32 = (32 - distance);
+ final distance32 = 32 - distance;
final m = _MASK32_HI_BITS[distance32];
final hi32cp = hi32;
hi32 = hi32 >> distance;
- hi32 |= (((lo32 & m) << distance32) & _MASK_32);
+ hi32 |= ((lo32 & m) << distance32) & _MASK_32;
lo32 = lo32 >> distance;
- lo32 |= (((hi32cp & m) << distance32) & _MASK_32);
+ lo32 |= ((hi32cp & m) << distance32) & _MASK_32;
return (hi32 << 32) | lo32;
}
- static int toInt32(int n) => (n & 0xFFFFFFFF);
+ static int toInt32(int n) => n & 0xFFFFFFFF;
}
const mask64 = (0xFFFFFFFF << 32) + 0xFFFFFFFF;
@@ -330,9 +328,9 @@
} else {
count &= 0x1f;
if (n >= 0) {
- return (n >> count);
+ return n >> count;
} else {
- return (n >> count) ^ ((mask64) ^ ((1 << (64 - count)) - 1));
+ return (n >> count) ^ (mask64 ^ ((1 << (64 - count)) - 1));
}
}
}
diff --git a/lib/srp/srp6_client.dart b/lib/srp/srp6_client.dart
index a65164d..4ed9dc7 100644
--- a/lib/srp/srp6_client.dart
+++ b/lib/srp/srp6_client.dart
@@ -2,9 +2,9 @@
import 'dart:typed_data';
+import 'package:pointycastle/api.dart';
import 'package:pointycastle/srp/srp6_standard_groups.dart';
import 'package:pointycastle/srp/srp6_util.dart';
-import 'package:pointycastle/api.dart';
class SRP6Client implements SRPClient {
late BigInt N;
@@ -51,7 +51,7 @@
var exp = (u! * x!) + a!;
var tmp = g.modPow(x!, N) * (k % N);
- return (B! - (tmp % (N))).modPow(exp, N);
+ return (B! - (tmp % N)).modPow(exp, N);
}
@override
diff --git a/lib/srp/srp6_server.dart b/lib/srp/srp6_server.dart
index 47ec256..6387751 100644
--- a/lib/srp/srp6_server.dart
+++ b/lib/srp/srp6_server.dart
@@ -1,8 +1,8 @@
library impl.srp_server;
+import 'package:pointycastle/api.dart';
import 'package:pointycastle/srp/srp6_standard_groups.dart';
import 'package:pointycastle/srp/srp6_util.dart';
-import 'package:pointycastle/api.dart';
class SRP6Server implements SRPServer {
late BigInt N;
@@ -69,7 +69,7 @@
BigInt? generateServerCredentials() {
var k = SRP6Util.calculateK(digest, N, g);
b = selectPrivateValue();
- B = ((k * v + g.modPow(b!, N)) % N);
+ B = (k * v + g.modPow(b!, N)) % N;
return B;
}
diff --git a/lib/srp/srp6_util.dart b/lib/srp/srp6_util.dart
index 5733a75..f5d53a9 100644
--- a/lib/srp/srp6_util.dart
+++ b/lib/srp/srp6_util.dart
@@ -1,8 +1,9 @@
library src.srp_util;
-import 'dart:typed_data';
-import 'package:pointycastle/pointycastle.dart';
import 'dart:math' as math;
+import 'dart:typed_data';
+
+import 'package:pointycastle/pointycastle.dart';
class SRP6Util {
static final _byteMask = BigInt.from(0xff);
@@ -58,7 +59,7 @@
var min = BigInt.one << (minBits - 1);
var max = N - BigInt.one;
- var result;
+ BigInt result;
do {
result = random.nextBigInteger(minBits);
} while (result > max || result < min);
@@ -109,8 +110,8 @@
/// @return the final Key value.
static BigInt calculateKey(Digest digest, BigInt N, BigInt? S) {
var padLength = (N.bitLength + 7) ~/ 8;
- var _S = getPadded(S!, padLength);
- digest.update(_S, 0, _S.length);
+ var S0 = getPadded(S!, padLength);
+ digest.update(S0, 0, S0.length);
var output = Uint8List(digest.digestSize);
digest.doFinal(output, 0);
@@ -139,7 +140,7 @@
var bs = encodeBigInt(n);
if (bs.length < length) {
var tmp = Uint8List(length);
- var start = (length - bs.length);
+ var start = length - bs.length;
for (var i = 0; start < length; i++, start++) {
tmp[start] = bs[i];
}
diff --git a/lib/stream/chacha20poly1305.dart b/lib/stream/chacha20poly1305.dart
index e390068..b096ca0 100644
--- a/lib/stream/chacha20poly1305.dart
+++ b/lib/stream/chacha20poly1305.dart
@@ -60,8 +60,7 @@
var macSizeBits = aeadParams.macSize;
if ((MAC_SIZE * 8) != macSizeBits) {
- throw ArgumentError(
- 'Invalid value for MAC size: ' + macSizeBits.toString());
+ throw ArgumentError('Invalid value for MAC size: $macSizeBits');
}
initKeyParam = aeadParams.parameters as KeyParameter;
@@ -117,7 +116,7 @@
case State.ENC_DATA:
return total + MAC_SIZE;
default:
- throw StateError('state = ' + _state.toString());
+ throw StateError('state = $_state');
}
}
diff --git a/lib/stream/ctr.dart b/lib/stream/ctr.dart
index 4d3343d..76adefe 100644
--- a/lib/stream/ctr.dart
+++ b/lib/stream/ctr.dart
@@ -17,7 +17,7 @@
return CTRStreamCipher(BlockCipher(digestName!));
});
- CTRStreamCipher(BlockCipher underlyingCipher) : super(underlyingCipher);
+ CTRStreamCipher(super.underlyingCipher);
@override
String get algorithmName => '${underlyingCipher.algorithmName}/CTR';
}
diff --git a/lib/stream/rc4_engine.dart b/lib/stream/rc4_engine.dart
index 4553c4e..dd72c43 100644
--- a/lib/stream/rc4_engine.dart
+++ b/lib/stream/rc4_engine.dart
@@ -62,8 +62,8 @@
_engineState![_y] = tmp;
// xor
- out[i + outOff] = (inp[i + inpOff] ^
- _engineState![(_engineState![_x] + _engineState![_y]) & 0xff]);
+ out[i + outOff] = inp[i + inpOff] ^
+ _engineState![(_engineState![_x] + _engineState![_y]) & 0xff];
}
}
@@ -83,8 +83,7 @@
_engineState![_y] = tmp;
// xor
- return (inp ^
- _engineState![(_engineState![_x] + _engineState![_y]) & 0xff]);
+ return inp ^ _engineState![(_engineState![_x] + _engineState![_y]) & 0xff];
}
void setKey(Uint8List keyBytes) {
diff --git a/lib/stream/salsa20.dart b/lib/stream/salsa20.dart
index 024b387..d81aa1c 100644
--- a/lib/stream/salsa20.dart
+++ b/lib/stream/salsa20.dart
@@ -154,38 +154,38 @@
x.setAll(0, input);
for (var i = rounds; i > 0; i -= 2) {
- x[4] ^= crotl32((x[0] + x[12]), 7);
- x[8] ^= crotl32((x[4] + x[0]), 9);
- x[12] ^= crotl32((x[8] + x[4]), 13);
- x[0] ^= crotl32((x[12] + x[8]), 18);
- x[9] ^= crotl32((x[5] + x[1]), 7);
- x[13] ^= crotl32((x[9] + x[5]), 9);
- x[1] ^= crotl32((x[13] + x[9]), 13);
- x[5] ^= crotl32((x[1] + x[13]), 18);
- x[14] ^= crotl32((x[10] + x[6]), 7);
- x[2] ^= crotl32((x[14] + x[10]), 9);
- x[6] ^= crotl32((x[2] + x[14]), 13);
- x[10] ^= crotl32((x[6] + x[2]), 18);
- x[3] ^= crotl32((x[15] + x[11]), 7);
- x[7] ^= crotl32((x[3] + x[15]), 9);
- x[11] ^= crotl32((x[7] + x[3]), 13);
- x[15] ^= crotl32((x[11] + x[7]), 18);
- x[1] ^= crotl32((x[0] + x[3]), 7);
- x[2] ^= crotl32((x[1] + x[0]), 9);
- x[3] ^= crotl32((x[2] + x[1]), 13);
- x[0] ^= crotl32((x[3] + x[2]), 18);
- x[6] ^= crotl32((x[5] + x[4]), 7);
- x[7] ^= crotl32((x[6] + x[5]), 9);
- x[4] ^= crotl32((x[7] + x[6]), 13);
- x[5] ^= crotl32((x[4] + x[7]), 18);
- x[11] ^= crotl32((x[10] + x[9]), 7);
- x[8] ^= crotl32((x[11] + x[10]), 9);
- x[9] ^= crotl32((x[8] + x[11]), 13);
- x[10] ^= crotl32((x[9] + x[8]), 18);
- x[12] ^= crotl32((x[15] + x[14]), 7);
- x[13] ^= crotl32((x[12] + x[15]), 9);
- x[14] ^= crotl32((x[13] + x[12]), 13);
- x[15] ^= crotl32((x[14] + x[13]), 18);
+ x[4] ^= crotl32(x[0] + x[12], 7);
+ x[8] ^= crotl32(x[4] + x[0], 9);
+ x[12] ^= crotl32(x[8] + x[4], 13);
+ x[0] ^= crotl32(x[12] + x[8], 18);
+ x[9] ^= crotl32(x[5] + x[1], 7);
+ x[13] ^= crotl32(x[9] + x[5], 9);
+ x[1] ^= crotl32(x[13] + x[9], 13);
+ x[5] ^= crotl32(x[1] + x[13], 18);
+ x[14] ^= crotl32(x[10] + x[6], 7);
+ x[2] ^= crotl32(x[14] + x[10], 9);
+ x[6] ^= crotl32(x[2] + x[14], 13);
+ x[10] ^= crotl32(x[6] + x[2], 18);
+ x[3] ^= crotl32(x[15] + x[11], 7);
+ x[7] ^= crotl32(x[3] + x[15], 9);
+ x[11] ^= crotl32(x[7] + x[3], 13);
+ x[15] ^= crotl32(x[11] + x[7], 18);
+ x[1] ^= crotl32(x[0] + x[3], 7);
+ x[2] ^= crotl32(x[1] + x[0], 9);
+ x[3] ^= crotl32(x[2] + x[1], 13);
+ x[0] ^= crotl32(x[3] + x[2], 18);
+ x[6] ^= crotl32(x[5] + x[4], 7);
+ x[7] ^= crotl32(x[6] + x[5], 9);
+ x[4] ^= crotl32(x[7] + x[6], 13);
+ x[5] ^= crotl32(x[4] + x[7], 18);
+ x[11] ^= crotl32(x[10] + x[9], 7);
+ x[8] ^= crotl32(x[11] + x[10], 9);
+ x[9] ^= crotl32(x[8] + x[11], 13);
+ x[10] ^= crotl32(x[9] + x[8], 18);
+ x[12] ^= crotl32(x[15] + x[14], 7);
+ x[13] ^= crotl32(x[12] + x[15], 9);
+ x[14] ^= crotl32(x[13] + x[12], 13);
+ x[15] ^= crotl32(x[14] + x[13], 18);
}
for (var i = 0; i < _STATE_SIZE; ++i) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 9d3bb50..b04d42a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,17 +1,18 @@
name: pointycastle
-version: 3.7.3
+version: 3.9.1
description: A Dart library implementing cryptographic algorithms and primitives, modeled on the BouncyCastle library.
homepage: https://github.com/bcgit/pc-dart
+topics:
+ - crypto
+
environment:
- sdk: '>=2.14.0 <3.0.0'
+ sdk: ^3.2.0
dependencies:
collection: ^1.15.0
convert: ^3.0.0
- js: ^0.6.3
dev_dependencies:
- benchmark_harness: ^2.0.0-nullsafety
- matcher: ^0.12.10-nullsafety
- test: ^1.16.0-nullsafety
- pedantic: ^1.10.0-nullsafety
+ benchmark_harness: ^2.0.0
+ lints: ^3.0.0
+ test: ^1.16.0
diff --git a/test/adapters/stream_cipher_as_block_cipher_test.dart b/test/adapters/stream_cipher_as_block_cipher_test.dart
index 99c73b4..a629bd7 100644
--- a/test/adapters/stream_cipher_as_block_cipher_test.dart
+++ b/test/adapters/stream_cipher_as_block_cipher_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.adapters.stream_cipher_as_block_cipher_test;
-
import 'package:test/test.dart';
import 'package:pointycastle/adapters/stream_cipher_as_block_cipher.dart';
diff --git a/test/asn1/asn1_all_test-disabled.dart b/test/asn1/asn1_all_test-disabled.dart
index 2c74884..161b0e0 100644
--- a/test/asn1/asn1_all_test-disabled.dart
+++ b/test/asn1/asn1_all_test-disabled.dart
@@ -2,6 +2,7 @@
/// Collection of ASN1 related tests.
/// Invoker for <-->/all_tests_web.dart
///
+library;
import 'asn1_object_test.dart' as object_test;
import 'asn1_utils_test.dart' as utils_test;
diff --git a/test/asn1/asn1_parser_test.dart b/test/asn1/asn1_parser_test.dart
index b642c02..5834325 100644
--- a/test/asn1/asn1_parser_test.dart
+++ b/test/asn1/asn1_parser_test.dart
@@ -176,6 +176,7 @@
expect(set1.elements!.elementAt(0) is ASN1Sequence, true);
var seq1 = set1.elements!.elementAt(0) as ASN1Sequence;
+ expect(seq1.encodedBytes!.length, seq1.totalEncodedByteLength);
expect(seq1.elements!.length, 2);
expect(seq1.elements!.elementAt(0) is ASN1ObjectIdentifier, true);
expect(seq1.elements!.elementAt(1) is ASN1PrintableString, true);
@@ -189,6 +190,7 @@
expect(set2.elements!.elementAt(0) is ASN1Sequence, true);
var seq2 = set2.elements!.elementAt(0) as ASN1Sequence;
+ expect(seq2.encodedBytes!.length, seq2.totalEncodedByteLength);
expect(seq2.elements!.length, 2);
expect(seq2.elements!.elementAt(0) is ASN1ObjectIdentifier, true);
expect(seq2.elements!.elementAt(1) is ASN1PrintableString, true);
@@ -202,6 +204,7 @@
expect(set3.elements!.elementAt(0) is ASN1Sequence, true);
var seq3 = set3.elements!.elementAt(0) as ASN1Sequence;
+ expect(seq3.encodedBytes!.length, seq3.totalEncodedByteLength);
expect(seq3.elements!.length, 2);
expect(seq3.elements!.elementAt(0) is ASN1ObjectIdentifier, true);
expect(seq3.elements!.elementAt(1) is ASN1PrintableString, true);
@@ -215,6 +218,7 @@
expect(set4.elements!.elementAt(0) is ASN1Sequence, true);
var seq4 = set4.elements!.elementAt(0) as ASN1Sequence;
+ expect(seq4.encodedBytes!.length, seq4.totalEncodedByteLength);
expect(seq4.elements!.length, 2);
expect(seq4.elements!.elementAt(0) is ASN1ObjectIdentifier, true);
expect(seq4.elements!.elementAt(1) is ASN1PrintableString, true);
@@ -286,6 +290,7 @@
expect(e1.elements!.length, 8);
expect(e1.totalEncodedByteLength, 1444);
+ expect(e1.encodedBytes!.length, 1444);
expect(e1.valueByteLength, 1440);
expect(e1.elements!.elementAt(1) is ASN1Integer, true);
expect(e1.elements!.elementAt(2) is ASN1Sequence, true);
@@ -309,8 +314,15 @@
expect(
integer2.integer.toString(), '49732821766751726239505489314635506967');
+ var seq1 = e1.elements!.elementAt(2) as ASN1Sequence;
+ expect(seq1.encodedBytes!.length, seq1.totalEncodedByteLength);
+
+ var seq2 = e1.elements!.elementAt(3) as ASN1Sequence;
+ expect(seq2.encodedBytes!.length, seq2.totalEncodedByteLength);
+
expect(e2.elements!.length, 2);
expect(e2.totalEncodedByteLength, 15);
+ expect(e2.encodedBytes!.length, 15);
expect(e2.valueByteLength, 13);
expect(e2.elements!.elementAt(0) is ASN1ObjectIdentifier, true);
expect(e2.elements!.elementAt(1) is ASN1Null, true);
diff --git a/test/asn1/primitives/asn1_bmp_string_test.dart b/test/asn1/primitives/asn1_bmp_string_test.dart
index d7e2494..35d5487 100644
--- a/test/asn1/primitives/asn1_bmp_string_test.dart
+++ b/test/asn1/primitives/asn1_bmp_string_test.dart
@@ -406,4 +406,16 @@
var asn1Object = ASN1BMPString.fromBytes(bytes);
expect(asn1Object.dump(), expected);
});
+
+ test('ASN1BMPString handles non ASCII', () {
+ var czechText = "ÄŒech";
+
+ var bmpString = ASN1BMPString(stringValue: czechText);
+
+ Uint8List encodedBytes = bmpString.encode();
+
+ var decodedBmpString = ASN1BMPString.fromBytes(encodedBytes);
+
+ expect(decodedBmpString.stringValue, equals(czechText));
+ });
}
diff --git a/test/asn1/primitives/asn1_sequence_test.dart b/test/asn1/primitives/asn1_sequence_test.dart
index 47d89d0..8ae2eed 100644
--- a/test/asn1/primitives/asn1_sequence_test.dart
+++ b/test/asn1/primitives/asn1_sequence_test.dart
@@ -1,6 +1,7 @@
import 'dart:typed_data';
import 'package:pointycastle/asn1/primitives/asn1_ia5_string.dart';
+import 'package:pointycastle/asn1/primitives/asn1_integer.dart';
import 'package:pointycastle/asn1/primitives/asn1_null.dart';
import 'package:pointycastle/asn1/primitives/asn1_object_identifier.dart';
import 'package:pointycastle/asn1/primitives/asn1_sequence.dart';
@@ -59,6 +60,108 @@
expect(asn1Object.elements!.elementAt(1) is ASN1Null, true);
});
+ test('Test named constructor fromBytes with nested indefinite length', () {
+ /*
+ SEQUENCE (3 elem, indefinite length)
+ INTEGER 1
+ SEQUENCE (1 elem, indefinite length)
+ OBJECT IDENTIFIER 1.2.840.113549.1.7.1 data (PKCS #7)
+ INTEGER 1
+ */
+ var bytes = Uint8List.fromList([
+ 0x30,
+ 0x80,
+ 0x02,
+ 0x01,
+ 0x01,
+ 0x30,
+ 0x80,
+ 0x06,
+ 0x09,
+ 0x2A,
+ 0x86,
+ 0x48,
+ 0x86,
+ 0xF7,
+ 0x0D,
+ 0x01,
+ 0x07,
+ 0x01,
+ 0x00,
+ 0x00,
+ 0x02,
+ 0x01,
+ 0x01,
+ 0x00,
+ 0x00
+ ]);
+
+ var valueBytes = Uint8List.fromList([
+ 0x02,
+ 0x01,
+ 0x01,
+ 0x30,
+ 0x80,
+ 0x06,
+ 0x09,
+ 0x2A,
+ 0x86,
+ 0x48,
+ 0x86,
+ 0xF7,
+ 0x0D,
+ 0x01,
+ 0x07,
+ 0x01,
+ 0x00,
+ 0x00,
+ 0x02,
+ 0x01,
+ 0x01,
+ ]);
+
+ var innerSequenceBytes = Uint8List.fromList([
+ 0x30,
+ 0x80,
+ 0x06,
+ 0x09,
+ 0x2A,
+ 0x86,
+ 0x48,
+ 0x86,
+ 0xF7,
+ 0x0D,
+ 0x01,
+ 0x07,
+ 0x01,
+ 0x00,
+ 0x00
+ ]);
+
+ var innerSequenceValueBytes = Uint8List.fromList(
+ [0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01]);
+
+ var asn1Object = ASN1Sequence.fromBytes(bytes);
+ expect(asn1Object.tag, 48);
+ expect(asn1Object.isConstructed, true);
+ expect(asn1Object.encodedBytes, bytes);
+ expect(asn1Object.valueByteLength, 21);
+ expect(asn1Object.valueStartPosition, 2);
+ expect(asn1Object.valueBytes, valueBytes);
+ expect(asn1Object.elements!.length, 3);
+ expect(asn1Object.elements!.elementAt(0) is ASN1Integer, true);
+ expect(asn1Object.elements!.elementAt(1) is ASN1Sequence, true);
+ expect(asn1Object.elements!.elementAt(2) is ASN1Integer, true);
+
+ final innerSequence = asn1Object.elements!.elementAt(1) as ASN1Sequence;
+ expect(innerSequence.tag, 48);
+ expect(innerSequence.isConstructed, true);
+ expect(innerSequence.encodedBytes, innerSequenceBytes);
+ expect(innerSequence.valueByteLength, 11);
+ expect(innerSequence.valueStartPosition, 2);
+ expect(innerSequence.valueBytes, innerSequenceValueBytes);
+ });
+
test('Test encode', () {
// Test encoding with zero elements given
var asn1Object = ASN1Sequence(elements: []);
diff --git a/test/asymmetric/ec_elgamal_test.dart b/test/asymmetric/ec_elgamal_test.dart
index 4acdd1b..2c5b349 100644
--- a/test/asymmetric/ec_elgamal_test.dart
+++ b/test/asymmetric/ec_elgamal_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.asymmetric.ec_elgamal_test;
-
import 'package:pointycastle/asymmetric/ec_elgamal.dart';
import 'package:pointycastle/ecc/ecc_fp.dart' as fp;
import 'package:pointycastle/export.dart';
diff --git a/test/asymmetric/oaep_test.dart b/test/asymmetric/oaep_test.dart
index 3748255..5cecced 100644
--- a/test/asymmetric/oaep_test.dart
+++ b/test/asymmetric/oaep_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.asymmetric.oaep_test;
-
import 'dart:typed_data';
import 'package:pointycastle/export.dart';
@@ -215,6 +213,7 @@
// Instantiate the RSA key pair objects
final publicKey = RSAPublicKey(n, e);
+ // ignore: deprecated_member_use_from_same_package
final privateKey = RSAPrivateKey(n, privateExponent, p, q, e);
//----------------
@@ -409,7 +408,7 @@
final outBuf = Uint8List(decryptor.outputBlockSize);
// ignore: unused_local_variable
- final _outputSize = decryptor.processBlock(
+ final outputSize0 = decryptor.processBlock(
tamperedCiphertext, 0, tamperedCiphertext.length, outBuf, 0);
fail('tampered with ciphertext still decrypted');
@@ -507,7 +506,7 @@
final testFixedRndSeed = Uint8List.fromList(numbers.reversed.toList());
// print('FixedSecureRandom seed: $testFixedRndSeed (from x = $x)');
- final processTestCaseWith = (AsymmetricBlockCipher blockCipher) {
+ Uint8List processTestCaseWith(AsymmetricBlockCipher blockCipher) {
final rnd = _OAEPTestEntropySource()
..seed(KeyParameter(testFixedRndSeed));
@@ -518,10 +517,10 @@
ParametersWithRandom(
PublicKeyParameter<RSAPublicKey>(publicKey), rnd));
- final _buf = Uint8List(enc.outputBlockSize);
- final _len = enc.processBlock(testMsg, 0, testMsg.length, _buf, 0);
- return _buf.sublist(0, _len);
- };
+ final buf = Uint8List(enc.outputBlockSize);
+ final len = enc.processBlock(testMsg, 0, testMsg.length, buf, 0);
+ return buf.sublist(0, len);
+ }
// Use null block cipher to obtain the EM (encryption does nothing)
@@ -554,9 +553,9 @@
dec.init(false, PrivateKeyParameter<RSAPrivateKey>(privateKey));
- final _decBuf = Uint8List(dec.outputBlockSize);
- final _decSize = dec.processBlock(cipher, 0, cipher.length, _decBuf, 0);
- final decrypted = _decBuf.sublist(0, _decSize);
+ final decBuf = Uint8List(dec.outputBlockSize);
+ final decSize = dec.processBlock(cipher, 0, cipher.length, decBuf, 0);
+ final decrypted = decBuf.sublist(0, decSize);
expect(decrypted, equals(testMsg));
}
@@ -927,18 +926,18 @@
];
test('RSAESOAEP decryption vectors from BC', () {
- vectors.forEach((Vector v) {
+ for (var v in vectors) {
var rsaesOaep = OAEPEncoding(RSAEngine());
rsaesOaep.init(
false, PrivateKeyParameter<RSAPrivateKey>(v.getPrivateKey()));
final output = Uint8List(v.pt!.length);
final size = rsaesOaep.processBlock(v.ct!, 0, v.ct!.length, output, 0);
expect(output, equals(v.pt, size));
- });
+ }
});
test('RSAESOAEP encryption vectors from BC', () {
- vectors.forEach((Vector v) {
+ for (var v in vectors) {
var rng = _OAEPTestEntropySource();
rng.seed(KeyParameter(v.seed!));
@@ -950,7 +949,7 @@
final output = Uint8List(v.ct!.length);
final size = rsaesOaep.processBlock(v.pt!, 0, v.pt!.length, output, 0);
expect(output, equals(v.ct, size));
- });
+ }
});
}
@@ -990,14 +989,14 @@
@override
void seed(covariant KeyParameter params) {
- _values = (params).key;
+ _values = params.key;
_next = 0;
}
}
/// Broke RSA Engine that allows us to modify the output len;
class _RSABroken extends RSAEngine {
- var wrongSizeDelta = 0;
+ int wrongSizeDelta = 0;
@override
int get outputBlockSize {
diff --git a/test/asymmetric/pkcs1_test.dart b/test/asymmetric/pkcs1_test.dart
index c942ebe..33792c7 100644
--- a/test/asymmetric/pkcs1_test.dart
+++ b/test/asymmetric/pkcs1_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.asymmetric.pkcs1_test;
-
import 'package:pointycastle/pointycastle.dart';
import 'package:pointycastle/src/registry/registry.dart';
@@ -10,10 +8,12 @@
import '../test/src/null_secure_random.dart';
void main() {
- var pubpar = () => ParametersWithRandom(
- PublicKeyParameter(NullPublicKey()), NullSecureRandom());
- var privpar = () => ParametersWithRandom(
- PrivateKeyParameter(NullPrivateKey()), NullSecureRandom());
+ ParametersWithRandom<PublicKeyParameter<PublicKey>> pubpar() =>
+ ParametersWithRandom(
+ PublicKeyParameter(NullPublicKey()), NullSecureRandom());
+ ParametersWithRandom<PrivateKeyParameter<PrivateKey>> privpar() =>
+ ParametersWithRandom(
+ PrivateKeyParameter(NullPrivateKey()), NullSecureRandom());
registry.register(NullAsymmetricBlockCipher.factoryConfig);
registry.register(NullSecureRandom.factoryConfig);
diff --git a/test/asymmetric/rsa_test.dart b/test/asymmetric/rsa_test.dart
index d8eae29..1c55eef 100644
--- a/test/asymmetric/rsa_test.dart
+++ b/test/asymmetric/rsa_test.dart
@@ -1,9 +1,7 @@
// See file LICENSE for more information.
-library test.asymmetric.rsa_test;
-
-import 'package:test/test.dart';
import 'package:pointycastle/pointycastle.dart';
+import 'package:test/test.dart';
import '../test/runners/asymmetric_block_cipher.dart';
@@ -32,7 +30,14 @@
// Wrong public exponent provided to the constructor raises an exception.
// ignore: deprecated_member_use_from_same_package
expect(
- () => RSAPrivateKey(modulus, privateExponent, p, q, BigInt.zero),
+ () => RSAPrivateKey(
+ modulus,
+ privateExponent,
+ p,
+ q,
+ // ignore: deprecated_member_use_from_same_package
+ BigInt.zero,
+ ),
throwsA(predicate((dynamic e) =>
e is ArgumentError &&
e.message ==
@@ -41,8 +46,10 @@
// Test using the RSA key pair to perform block cipher encryption/decryption.
- var pubpar = () => PublicKeyParameter<RSAPublicKey>(pubk);
- var privpar = () => PrivateKeyParameter<RSAPrivateKey>(privk);
+ PublicKeyParameter<RSAPublicKey> pubpar() =>
+ PublicKeyParameter<RSAPublicKey>(pubk);
+ PrivateKeyParameter<RSAPrivateKey> privpar() =>
+ PrivateKeyParameter<RSAPrivateKey>(privk);
runAsymmetricBlockCipherTests(AsymmetricBlockCipher('RSA'), pubpar, privpar, [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit...',
diff --git a/test/block/aes_fast_test.dart b/test/block/aes_fast_test.dart
index 39c8d5b..a52ad80 100644
--- a/test/block/aes_fast_test.dart
+++ b/test/block/aes_fast_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.block.aes_fast_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/block/aes_test.dart b/test/block/aes_test.dart
index da3a83b..1c9e6f6 100644
--- a/test/block/aes_test.dart
+++ b/test/block/aes_test.dart
@@ -1,5 +1,3 @@
-library test.block.aes_fast_test;
-
import 'dart:typed_data';
import 'package:pointycastle/block/aes.dart';
@@ -175,38 +173,38 @@
void blockCipherTest(int id, BlockCipher cipher, CipherParameters parameters,
String input, String output) {
test('AES BlockCipher Test: $id ', () {
- var _input = createUint8ListFromHexString(input);
- var _output = createUint8ListFromHexString(output);
+ var input0 = createUint8ListFromHexString(input);
+ var output0 = createUint8ListFromHexString(output);
cipher.init(true, parameters);
- var out = Uint8List(_input.length);
+ var out = Uint8List(input0.length);
var p = 0;
- while (p < _input.length) {
- p += cipher.processBlock(_input, p, out, p);
+ while (p < input0.length) {
+ p += cipher.processBlock(input0, p, out, p);
}
- expect(_output, equals(out), reason: '$id did not match output');
+ expect(output0, equals(out), reason: '$id did not match output');
cipher.init(false, parameters);
- out = Uint8List(_output.length);
+ out = Uint8List(output0.length);
p = 0;
- while (p < _output.length) {
- p += cipher.processBlock(_output, p, out, p);
+ while (p < output0.length) {
+ p += cipher.processBlock(output0, p, out, p);
}
- expect(_input, equals(out), reason: '$id did not match input');
+ expect(input0, equals(out), reason: '$id did not match input');
});
}
void blockCipherMCTTest(int id, int iterations, BlockCipher cipher,
CipherParameters parameters, String input, String output) {
test('AES BlockCipher MCT Test: $id ', () {
- var _input = createUint8ListFromHexString(input);
- var _output = createUint8ListFromHexString(output);
+ var input0 = createUint8ListFromHexString(input);
+ var output0 = createUint8ListFromHexString(output);
cipher.init(true, parameters);
- var out = Uint8List(_input.length);
- out.setRange(0, out.length, _input);
+ var out = Uint8List(input0.length);
+ out.setRange(0, out.length, input0);
for (var i = 0; i != iterations; i++) {
var p = 0;
@@ -215,7 +213,7 @@
}
}
- expect(_output, equals(out), reason: '$id did not match output');
+ expect(output0, equals(out), reason: '$id did not match output');
cipher.init(false, parameters);
@@ -226,6 +224,6 @@
}
}
- expect(_input, equals(out), reason: '$id did not match input');
+ expect(input0, equals(out), reason: '$id did not match input');
});
}
diff --git a/test/block/blowfish_test.dart b/test/block/blowfish_test.dart
new file mode 100644
index 0000000..df1e47c
--- /dev/null
+++ b/test/block/blowfish_test.dart
@@ -0,0 +1,29 @@
+import 'package:pointycastle/api.dart';
+import 'package:pointycastle/block/blowfish.dart';
+import 'package:test/test.dart';
+
+import '../test/src/helpers.dart';
+
+void main() {
+ group('Blowfish Engine', () {
+ blockCipherTest(0, BlowfishEngine(), _kp('0000000000000000'), '0000000000000000', '4ef997456198dd78');
+
+ blockCipherTest(1, BlowfishEngine(), _kp('ffffffffffffffff'), 'ffffffffffffffff', '51866fd5b85ecb8a');
+
+ blockCipherTest(2, BlowfishEngine(), _kp('3000000000000000'), '1000000000000001', '7d856f9a613063f2');
+
+ blockCipherTest(3, BlowfishEngine(), _kp('1111111111111111'), '1111111111111111', '2466dd878b963c9d');
+
+ blockCipherTest(4, BlowfishEngine(), _kp('0123456789abcdef'), '1111111111111111', '61f9c3802281b096');
+
+ blockCipherTest(5, BlowfishEngine(), _kp('fedcba9876543210'), '0123456789abcdef', '0aceab0fc6a0a28d');
+
+ blockCipherTest(6, BlowfishEngine(), _kp('7ca110454a1a6e57'), '01a1d6d039776742', '59c68245eb05282b');
+
+ blockCipherTest(7, BlowfishEngine(), _kp('0131d9619dc1376e'), '5cd54ca83def57da', 'b1b8cc0b250f09a0');
+ });
+}
+
+KeyParameter _kp(String key) {
+ return KeyParameter(createUint8ListFromHexString(key));
+}
diff --git a/test/block/camellia_test.dart b/test/block/camellia_test.dart
new file mode 100644
index 0000000..55176e3
--- /dev/null
+++ b/test/block/camellia_test.dart
@@ -0,0 +1,40 @@
+import 'package:pointycastle/api.dart';
+import 'package:pointycastle/block/camellia.dart';
+import 'package:test/test.dart';
+
+import '../test/src/helpers.dart';
+
+void main() {
+ group('Camellia Engine', () {
+ blockCipherTest(0, CamelliaEngine(), _kp('00000000000000000000000000000000'), '80000000000000000000000000000000',
+ '07923a39eb0a817d1c4d87bdb82d1f1c');
+
+ blockCipherTest(1, CamelliaEngine(), _kp('80000000000000000000000000000000'), '00000000000000000000000000000000',
+ '6c227f749319a3aa7da235a9bba05a2c');
+
+ blockCipherTest(2, CamelliaEngine(), _kp('0123456789abcdeffedcba9876543210'), '0123456789abcdeffedcba9876543210',
+ '67673138549669730857065648eabe43');
+
+ blockCipherTest(3, CamelliaEngine(), _kp('0123456789abcdeffedcba98765432100011223344556677'),
+ '0123456789abcdeffedcba9876543210', 'b4993401b3e996f84ee5cee7d79b09b9');
+
+ blockCipherTest(4, CamelliaEngine(), _kp('000000000000000000000000000000000000000000000000'),
+ '00040000000000000000000000000000', '9bca6c88b928c1b0f57f99866583a9bc');
+
+ blockCipherTest(5, CamelliaEngine(), _kp('949494949494949494949494949494949494949494949494'),
+ '636eb22d84b006381235641bcf0308d2', '94949494949494949494949494949494');
+
+ blockCipherTest(6, CamelliaEngine(), _kp('0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff'),
+ '0123456789abcdeffedcba9876543210', '9acc237dff16d76c20ef7c919e3a7509');
+
+ blockCipherTest(7, CamelliaEngine(), _kp('4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a'),
+ '057764fe3a500edbd988c5c3b56cba9a', '4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a4a');
+
+ blockCipherTest(8, CamelliaEngine(), _kp('0303030303030303030303030303030303030303030303030303030303030303'),
+ '7968b08aba92193f2295121ef8d75c8a', '03030303030303030303030303030303');
+ });
+}
+
+KeyParameter _kp(String key) {
+ return KeyParameter(createUint8ListFromHexString(key));
+}
diff --git a/test/block/twofish_test.dart b/test/block/twofish_test.dart
new file mode 100644
index 0000000..daebcdf
--- /dev/null
+++ b/test/block/twofish_test.dart
@@ -0,0 +1,36 @@
+import 'package:pointycastle/api.dart';
+import 'package:pointycastle/block/modes/cbc.dart';
+import 'package:pointycastle/block/twofish.dart';
+import 'package:test/test.dart';
+
+import '../test/src/helpers.dart';
+
+void main() {
+ group('Twofish Engine', () {
+ final input = '000102030405060708090a0b0c0d0e0f';
+
+ blockCipherTest(0, TwofishEngine(), _kp('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), input,
+ '8ef0272c42db838bcf7b07af0ec30f38');
+
+ blockCipherTest(1, TwofishEngine(), _kp('000102030405060708090a0b0c0d0e0f1011121314151617'), input,
+ '95accc625366547617f8be4373d10cd7');
+
+ blockCipherTest(
+ 2, TwofishEngine(), _kp('000102030405060708090a0b0c0d0e0f'), input, '9fb63337151be9c71306d159ea7afaa4');
+
+ blockCipherTest(
+ 3,
+ CBCBlockCipher(TwofishEngine()),
+ _kpWithIV('0123456789abcdef1234567890abcdef', '1234567890abcdef0123456789abcdef'),
+ input,
+ 'd6bfdbb2090562e960273783127e2658');
+ });
+}
+
+KeyParameter _kp(String key) {
+ return KeyParameter(createUint8ListFromHexString(key));
+}
+
+ParametersWithIV<KeyParameter> _kpWithIV(String key, String iv) {
+ return ParametersWithIV(_kp(key), createUint8ListFromHexString(iv));
+}
diff --git a/test/digests/blake2b_test.dart b/test/digests/blake2b_test.dart
index f593c5d..e0c1498 100644
--- a/test/digests/blake2b_test.dart
+++ b/test/digests/blake2b_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.blake2b_test;
-
import 'dart:typed_data';
import 'package:pointycastle/digests/blake2b.dart';
@@ -13,7 +11,7 @@
void main() {
group('PR108 regression test', () {
- test("vectors from: https://blake2.net/blake2b-test.txt", () {
+ test('vectors from: https://blake2.net/blake2b-test.txt', () {
var vec = [
[
'',
@@ -47,7 +45,7 @@
]
];
- vec.forEach((set) {
+ for (var set in vec) {
var input = createUint8ListFromHexString(set[0]);
var key = createUint8ListFromHexString(set[1]);
var dig = Blake2bDigest(key: key);
@@ -56,7 +54,7 @@
dig.doFinal(res, 0);
var expected = createUint8ListFromHexString(set[2]);
expect(res, equals(expected));
- });
+ }
});
});
diff --git a/test/digests/keccak_test.dart b/test/digests/keccak_test.dart
index b92b735..d385eb4 100644
--- a/test/digests/keccak_test.dart
+++ b/test/digests/keccak_test.dart
@@ -1,10 +1,7 @@
// See file LICENSE for more information.
-library test.digests.keccak_test;
-
import 'dart:typed_data';
-import 'package:pointycastle/digests/keccak.dart';
import 'package:pointycastle/export.dart';
import 'package:test/test.dart';
@@ -58,7 +55,7 @@
expect(
sum,
equals(createUint8ListFromHexString(
- "51e16cafd44b120fde44105f299b8343c22899851da30bb33a481d4b81c2ef3e")));
+ '51e16cafd44b120fde44105f299b8343c22899851da30bb33a481d4b81c2ef3e')));
});
});
}
@@ -182,7 +179,7 @@
reason: 'Keccak mismatch on ${digest.algorithmName} 64k a single');
for (var i = 0; i != k64.length; i++) {
- k64[i] = (97 + (i % 26));
+ k64[i] = 97 + (i % 26);
}
digest.update(k64, 0, k64.length);
@@ -319,7 +316,7 @@
reason: 'Keccak HMAC mismatch on ${digest.algorithmName}');
}
- mac = Mac(digest.algorithmName + '/HMAC') as HMac;
+ mac = Mac('${digest.algorithmName}/HMAC') as HMac;
mac.init(_truncKey);
diff --git a/test/digests/md2_test.dart b/test/digests/md2_test.dart
index 6a92fc8..a2719aa 100644
--- a/test/digests/md2_test.dart
+++ b/test/digests/md2_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.md2_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/md4_test.dart b/test/digests/md4_test.dart
index eb99af2..9b1f7d4 100644
--- a/test/digests/md4_test.dart
+++ b/test/digests/md4_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.md4_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/md5_test.dart b/test/digests/md5_test.dart
index 2d3f06f..13b97d5 100644
--- a/test/digests/md5_test.dart
+++ b/test/digests/md5_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.md5_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/ripemd128_test.dart b/test/digests/ripemd128_test.dart
index 269a8ab..9c3079e 100644
--- a/test/digests/ripemd128_test.dart
+++ b/test/digests/ripemd128_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.ripemd128_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/ripemd160_test.dart b/test/digests/ripemd160_test.dart
index 518b2a0..81660ee 100644
--- a/test/digests/ripemd160_test.dart
+++ b/test/digests/ripemd160_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.ripemd160_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/ripemd256_test.dart b/test/digests/ripemd256_test.dart
index 780e69a..cfe504a 100644
--- a/test/digests/ripemd256_test.dart
+++ b/test/digests/ripemd256_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.ripemd256_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/ripemd320_test.dart b/test/digests/ripemd320_test.dart
index 587241d..7001674 100644
--- a/test/digests/ripemd320_test.dart
+++ b/test/digests/ripemd320_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.ripemd320_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sha1_test.dart b/test/digests/sha1_test.dart
index 56f2f6e..5963e6b 100644
--- a/test/digests/sha1_test.dart
+++ b/test/digests/sha1_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha1_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sha224_test.dart b/test/digests/sha224_test.dart
index dda5c17..85d78cf 100644
--- a/test/digests/sha224_test.dart
+++ b/test/digests/sha224_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha224_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sha256_test.dart b/test/digests/sha256_test.dart
index 4fccb6f..64c79f5 100644
--- a/test/digests/sha256_test.dart
+++ b/test/digests/sha256_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha256_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sha384_test.dart b/test/digests/sha384_test.dart
index 035e288..e09c722 100644
--- a/test/digests/sha384_test.dart
+++ b/test/digests/sha384_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha384_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sha3_test.dart b/test/digests/sha3_test.dart
index 97d6076..52b3b51 100644
--- a/test/digests/sha3_test.dart
+++ b/test/digests/sha3_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha3_test.dart;
-
import 'dart:typed_data';
import 'package:pointycastle/digests/sha3.dart';
diff --git a/test/digests/sha512_test.dart b/test/digests/sha512_test.dart
index c9a0b29..aa162bf 100644
--- a/test/digests/sha512_test.dart
+++ b/test/digests/sha512_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha512_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sha512t_test.dart b/test/digests/sha512t_test.dart
index 062df51..d2a4570 100644
--- a/test/digests/sha512t_test.dart
+++ b/test/digests/sha512t_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sha512t_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/sm3_test.dart b/test/digests/sm3_test.dart
index 86e728b..fa533e4 100644
--- a/test/digests/sm3_test.dart
+++ b/test/digests/sm3_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.sm3_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -20,8 +18,8 @@
'debe9ff92275b8a138604889c18e5a4d6fdb70e5387e5765293dcba39c0c5732',
]);
- group("optional SM3 tests", () {
- test("64K Digest", () {
+ group('optional SM3 tests', () {
+ test('64K Digest', () {
var dig = Digest('SM3');
for (var i = 0; i < 65536; i++) {
diff --git a/test/digests/tiger_test.dart b/test/digests/tiger_test.dart
index 96cb195..076efdd 100644
--- a/test/digests/tiger_test.dart
+++ b/test/digests/tiger_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.tiger_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/digests/whirlpool_test.dart b/test/digests/whirlpool_test.dart
index cadc792..b06e7ff 100644
--- a/test/digests/whirlpool_test.dart
+++ b/test/digests/whirlpool_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.digests.whirlpool_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/digest.dart';
diff --git a/test/ecc/ecdh_test.dart b/test/ecc/ecdh_test.dart
index 917ffe4..8eaff46 100644
--- a/test/ecc/ecdh_test.dart
+++ b/test/ecc/ecdh_test.dart
@@ -23,7 +23,7 @@
}
class P256Testvector extends ECDHTestvector {
- P256Testvector(index, String a, String bx, String by, String z)
+ P256Testvector(int index, String a, String bx, String by, String z)
: super(index, a, bx, by, z, ECDomainParameters('secp256r1'));
}
@@ -201,7 +201,7 @@
return pcecKeyPair;
}
- for (int i = 0; i < 100; i++) {
+ for (var i = 0; i < 100; i++) {
var key1 = generateKeyPair(i);
var key2 = generateKeyPair(i + 1);
var ecdsa1 = ECDHBasicAgreement()..init(key1.privateKey as ECPrivateKey);
@@ -280,7 +280,7 @@
test('Test ECDH with bouncycastle derived testvector for brainpool', () {
var z = BigInt.parse(
- "62035452719449902544084895701129591677592844515050058000761959332847413670618")
+ '62035452719449902544084895701129591677592844515050058000761959332847413670618')
.toRadixString(16);
var bx = BigInt.parse(
'53535355328855043322505278710464138773506437230442680203030305357393812004243')
diff --git a/test/impl_test.dart b/test/impl_test.dart
index f0b88bc..4902085 100644
--- a/test/impl_test.dart
+++ b/test/impl_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.impl_test;
-
import 'package:pointycastle/src/platform_check/platform_check.dart';
import 'package:test/test.dart';
import 'test/runners/registry.dart';
@@ -157,7 +155,7 @@
test(
'StreamCipher returns valid implementations on platforms without full width integer',
() {
- testStreamCipher('Salsa20');
+ testStreamCipher('Salsa20');
testStreamCipher('AES/SIC');
testStreamCipher('AES/CTR');
testStreamCipher('ChaCha20/20');
diff --git a/test/key_derivators/argon2_nonvm_test.dart b/test/key_derivators/argon2_nonvm_test.dart
index 0357a23..65c1c51 100644
--- a/test/key_derivators/argon2_nonvm_test.dart
+++ b/test/key_derivators/argon2_nonvm_test.dart
@@ -19,7 +19,7 @@
/// The linked project was adapted for the purposes of this project, since it
/// is a 1:1 port of BouncyCastle's Java implementation.
void main() {
- final timeout = Timeout.parse("15m");
+ final timeout = Timeout.parse('15m');
group('Argon2BytesGenerator - non dart vm', () {
//
diff --git a/test/key_derivators/argon2_vm_test.dart b/test/key_derivators/argon2_vm_test.dart
index 2843bc8..cfdadca 100644
--- a/test/key_derivators/argon2_vm_test.dart
+++ b/test/key_derivators/argon2_vm_test.dart
@@ -20,7 +20,7 @@
/// The linked project was adapted for the purposes of this project, since it
/// is a 1:1 port of BouncyCastle's Java implementation.
void main() {
- final timeout = Timeout.parse("15m");
+ final timeout = Timeout.parse('15m');
group('Argon2BytesGenerator -- non-js platforms', () {
/* Multiple test cases for various input values */
diff --git a/test/key_derivators/concatkdf_nonvm_test.dart b/test/key_derivators/concatkdf_nonvm_test.dart
index a417671..c8c4e9f 100644
--- a/test/key_derivators/concatkdf_nonvm_test.dart
+++ b/test/key_derivators/concatkdf_nonvm_test.dart
@@ -24,7 +24,7 @@
}
void main() {
- var acvpToDart = Map();
+ var acvpToDart = {};
acvpToDart['SHA2-224'] = 'SHA-224';
acvpToDart['SHA2-256'] = 'SHA-256';
acvpToDart['SHA2-384'] = 'SHA-384';
@@ -56,19 +56,17 @@
// Form a maps of known correct results.
//
- var validDKMAFT = Map<String, Uint8List>();
- var validVALResult = Map<String, bool>();
+ var validDKMAFT = <String, Uint8List>{};
+ var validVALResult = <String, bool>{};
rsp[1]['testGroups'].forEach((group) {
group['tests'].forEach((test) {
if (test['dkm'] != null) {
- validDKMAFT[
- group['tgId'].toString() + ':' + test['tcId'].toString()] =
+ validDKMAFT['${group['tgId']}:${test['tcId']}'] =
createUint8ListFromHexString(test['dkm']);
} else {
- validVALResult[group['tgId'].toString() +
- ':' +
- test['tcId'].toString()] = test['testPassed'];
+ validVALResult['${group['tgId']}:${test['tcId']}'] =
+ test['testPassed'];
}
});
});
@@ -109,8 +107,7 @@
// AFT test, IUT must generate a DKM that must match what NIST
// is expecting.
//
- var knownDKM = validDKMAFT[
- group['tgId'].toString() + ':' + test['tcId'].toString()];
+ var knownDKM = validDKMAFT['${group['tgId']}:${test['tcId']}'];
expect(key, equals(knownDKM));
} else {
// VAL test
@@ -121,9 +118,7 @@
var dkm = createUint8ListFromHexString(test['dkm']);
var tp = constantTimeAreEqual(dkm, key);
expect(
- validVALResult[
- group['tgId'].toString() + ':' + test['tcId'].toString()],
- equals(tp));
+ validVALResult['${group['tgId']}:${test['tcId']}'], equals(tp));
}
});
});
@@ -253,14 +248,13 @@
}
// Helpers for ECDH-ES
-Uint8List computerOtherInfo(
- String _encryptionAlgorithmName, int _keybitLength) {
- var l = _encryptionAlgorithmName.codeUnits.length.toUnsigned(32);
+Uint8List computerOtherInfo(String encryptionAlgorithmName, int keybitLength) {
+ var l = encryptionAlgorithmName.codeUnits.length.toUnsigned(32);
var ll = _convertToBigEndian(l);
- var a = Uint8List.fromList(_encryptionAlgorithmName.codeUnits);
+ var a = Uint8List.fromList(encryptionAlgorithmName.codeUnits);
// add apu, apv, fixed to empty for now
var zero = _convertToBigEndian(0);
- var k = _convertToBigEndian(_keybitLength);
+ var k = _convertToBigEndian(keybitLength);
return Uint8List.fromList([...ll, ...a, ...zero, ...zero, ...k]);
}
@@ -269,12 +263,12 @@
ll[0] = (l >> 24) & 255;
ll[1] = (l >> 16) & 255;
ll[2] = (l >> 8) & 255;
- ll[3] = (l) & 255;
+ ll[3] = l & 255;
return ll;
}
-dynamic loadRsp() {
- var s = '''[
+List loadRsp() {
+ const s = '''[
{
"acvVersion": "1.0"
},
@@ -2088,7 +2082,7 @@
}
dynamic loadReq() {
- var s = '''[
+ const s = '''[
{
"acvVersion": "1.0"
},
diff --git a/test/key_derivators/concatkdf_test.dart b/test/key_derivators/concatkdf_test.dart
index 4522980..0caeccb 100644
--- a/test/key_derivators/concatkdf_test.dart
+++ b/test/key_derivators/concatkdf_test.dart
@@ -25,7 +25,7 @@
}
void main() {
- var acvpToDart = Map();
+ var acvpToDart = {};
acvpToDart['SHA2-224'] = 'SHA-224';
acvpToDart['SHA2-256'] = 'SHA-256';
acvpToDart['SHA2-384'] = 'SHA-384';
@@ -57,19 +57,17 @@
// Form a maps of known correct results.
//
- var validDKMAFT = Map<String, Uint8List>();
- var validVALResult = Map<String, bool>();
+ var validDKMAFT = <String, Uint8List>{};
+ var validVALResult = <String, bool>{};
rsp[1]['testGroups'].forEach((group) {
group['tests'].forEach((test) {
if (test['dkm'] != null) {
- validDKMAFT[
- group['tgId'].toString() + ':' + test['tcId'].toString()] =
+ validDKMAFT['${group['tgId']}:${test['tcId']}'] =
createUint8ListFromHexString(test['dkm']);
} else {
- validVALResult[group['tgId'].toString() +
- ':' +
- test['tcId'].toString()] = test['testPassed'];
+ validVALResult['${group['tgId']}:${test['tcId']}'] =
+ test['testPassed'];
}
});
});
@@ -110,8 +108,7 @@
// AFT test, IUT must generate a DKM that must match what NIST
// is expecting.
//
- var knownDKM = validDKMAFT[
- group['tgId'].toString() + ':' + test['tcId'].toString()];
+ var knownDKM = validDKMAFT['${group['tgId']}:${test['tcId']}'];
expect(key, equals(knownDKM));
} else {
// VAL test
@@ -122,9 +119,7 @@
var dkm = createUint8ListFromHexString(test['dkm']);
var tp = constantTimeAreEqual(dkm, key);
expect(
- validVALResult[
- group['tgId'].toString() + ':' + test['tcId'].toString()],
- equals(tp));
+ validVALResult['${group['tgId']}:${test['tcId']}'], equals(tp));
}
});
});
@@ -254,13 +249,13 @@
}
// Helpers for ECDH-ES
-Uint8List computerOtherInfo(String _encryptionAlgorithmName, int _keybitLength) {
- var l = _encryptionAlgorithmName.codeUnits.length.toUnsigned(32);
+Uint8List computerOtherInfo(String encryptionAlgorithmName, int keybitLength) {
+ var l = encryptionAlgorithmName.codeUnits.length.toUnsigned(32);
var ll = _convertToBigEndian(l);
- var a = Uint8List.fromList(_encryptionAlgorithmName.codeUnits);
+ var a = Uint8List.fromList(encryptionAlgorithmName.codeUnits);
//TODO: add apu, apv, fixed to empty for now
var zero = _convertToBigEndian(0);
- var k = _convertToBigEndian(_keybitLength);
+ var k = _convertToBigEndian(keybitLength);
return Uint8List.fromList([...ll, ...a, ...zero, ...zero, ...k]);
}
@@ -269,6 +264,6 @@
ll[0] = (l >> 24) & 255;
ll[1] = (l >> 16) & 255;
ll[2] = (l >> 8) & 255;
- ll[3] = (l) & 255;
+ ll[3] = l & 255;
return ll;
}
diff --git a/test/key_derivators/hkdf_test.dart b/test/key_derivators/hkdf_test.dart
index 2df2d77..2473406 100644
--- a/test/key_derivators/hkdf_test.dart
+++ b/test/key_derivators/hkdf_test.dart
@@ -1,12 +1,8 @@
// See file LICENSE for more information.
-library test.key_derivators.hkdf_test;
-
import 'dart:typed_data';
import 'package:pointycastle/export.dart';
-import 'package:pointycastle/key_derivators/hkdf.dart';
-import 'package:pointycastle/pointycastle.dart';
import 'package:test/test.dart';
import '../test/runners/key_derivators.dart';
diff --git a/test/key_derivators/pbkdf2_test.dart b/test/key_derivators/pbkdf2_test.dart
index 2bcb1c2..2eb4105 100644
--- a/test/key_derivators/pbkdf2_test.dart
+++ b/test/key_derivators/pbkdf2_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.key_derivators.pbkdf2_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/key_derivators.dart';
diff --git a/test/key_derivators/pkcs12_parameter_generator_test.dart b/test/key_derivators/pkcs12_parameter_generator_test.dart
index 32f716f..88f0804 100644
--- a/test/key_derivators/pkcs12_parameter_generator_test.dart
+++ b/test/key_derivators/pkcs12_parameter_generator_test.dart
@@ -13,7 +13,7 @@
var bytes = Uint8List((password.length + 1) * 2);
for (var i = 0; i != password.length; i++) {
- bytes[i * 2] = (password[i] >>> 8);
+ bytes[i * 2] = password[i] >>> 8;
bytes[i * 2 + 1] = password[i];
}
diff --git a/test/key_derivators/scrypt_nonvm_test.dart b/test/key_derivators/scrypt_nonvm_test.dart
index 1368831..a849905 100644
--- a/test/key_derivators/scrypt_nonvm_test.dart
+++ b/test/key_derivators/scrypt_nonvm_test.dart
@@ -20,11 +20,10 @@
// This is a sanity test for the js platform
//
- var scrypt = KeyDerivator('scrypt');
- runKeyDerivatorTests(scrypt, [
- ScryptParameters(1024, 8, 16, 64, createUint8ListFromString('NaCl')),
- 'password',
- 'fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640'
- ]);
-
+ var scrypt = KeyDerivator('scrypt');
+ runKeyDerivatorTests(scrypt, [
+ ScryptParameters(1024, 8, 16, 64, createUint8ListFromString('NaCl')),
+ 'password',
+ 'fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640'
+ ]);
}
diff --git a/test/key_derivators/scrypt_vm_test.dart b/test/key_derivators/scrypt_vm_test.dart
index df0d04e..dccb081 100644
--- a/test/key_derivators/scrypt_vm_test.dart
+++ b/test/key_derivators/scrypt_vm_test.dart
@@ -17,7 +17,7 @@
/// [http://tools.ietf.org/html/draft-josefsson-scrypt-kdf-00#page-10] (which at the time of writing
/// this test had typos because it interchanged N and r parameters).
void main() {
- group("scrypt - vm ", () {
+ group('scrypt - vm ', () {
var scrypt = KeyDerivator('scrypt');
runKeyDerivatorTests(scrypt, [
ScryptParameters(1024, 8, 16, 64, createUint8ListFromString('NaCl')),
diff --git a/test/key_generators/ec_key_generator_test.dart b/test/key_generators/ec_key_generator_test.dart
index cf348a1..821e8f2 100644
--- a/test/key_generators/ec_key_generator_test.dart
+++ b/test/key_generators/ec_key_generator_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.key_generators.ec_key_generator_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/key_generators.dart';
import '../test/src/null_secure_random.dart';
diff --git a/test/key_generators/rsa_key_generator_test.dart b/test/key_generators/rsa_key_generator_test.dart
index d0cb288..19e510a 100644
--- a/test/key_generators/rsa_key_generator_test.dart
+++ b/test/key_generators/rsa_key_generator_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.key_generators.rsa_key_generator_test;
-
import 'package:pointycastle/pointycastle.dart';
import 'package:pointycastle/src/platform_check/platform_check.dart';
import 'package:test/test.dart';
@@ -244,6 +242,13 @@
AsymmetricKeyPair _keyPair(String n, String e, String d, String p, String q,
String pubExpInPrivateKey) =>
AsymmetricKeyPair(
- RSAPublicKey(BigInt.parse(n), BigInt.parse(e)),
- RSAPrivateKey(BigInt.parse(n), BigInt.parse(d), BigInt.parse(p),
- BigInt.parse(q), BigInt.parse(pubExpInPrivateKey)));
+ RSAPublicKey(BigInt.parse(n), BigInt.parse(e)),
+ RSAPrivateKey(
+ BigInt.parse(n),
+ BigInt.parse(d),
+ BigInt.parse(p),
+ BigInt.parse(q),
+ // ignore: deprecated_member_use_from_same_package
+ BigInt.parse(pubExpInPrivateKey),
+ ),
+ );
diff --git a/test/macs/cbc_block_cipher_mac_test.dart b/test/macs/cbc_block_cipher_mac_test.dart
index 8b9b550..49b226e 100644
--- a/test/macs/cbc_block_cipher_mac_test.dart
+++ b/test/macs/cbc_block_cipher_mac_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.macs.cbc_block_cipher_mac_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/mac.dart';
diff --git a/test/macs/cmac_test.dart b/test/macs/cmac_test.dart
index c23003c..44abad1 100644
--- a/test/macs/cmac_test.dart
+++ b/test/macs/cmac_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.macs.cmac_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/macs/hmac_test.dart b/test/macs/hmac_test.dart
index ce12a6a..2fd75ce 100644
--- a/test/macs/hmac_test.dart
+++ b/test/macs/hmac_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.hmacs.hmac_test;
-
import 'dart:typed_data';
import 'package:pointycastle/export.dart';
diff --git a/test/macs/poly1305_test.dart b/test/macs/poly1305_test.dart
index 2f5975f..8ed8ca4 100644
--- a/test/macs/poly1305_test.dart
+++ b/test/macs/poly1305_test.dart
@@ -4,8 +4,6 @@
library test.macs.poly1305_test;
import 'package:pointycastle/export.dart';
-import 'package:pointycastle/macs/poly1305.dart';
-import 'package:pointycastle/pointycastle.dart';
import 'package:test/test.dart';
import '../test/runners/mac.dart';
diff --git a/test/macs/poly1305_web_test.dart b/test/macs/poly1305_web_test.dart
index 38dcee9..494efae 100644
--- a/test/macs/poly1305_web_test.dart
+++ b/test/macs/poly1305_web_test.dart
@@ -3,12 +3,10 @@
library test.macs.poly1305_test;
+import 'package:pointycastle/export.dart';
import 'package:pointycastle/src/platform_check/platform_check.dart';
import 'package:test/test.dart';
-import 'package:pointycastle/export.dart';
-import 'package:pointycastle/macs/poly1305.dart';
-
void main() {
group('Poly1305 - js', () {
test('must emit PlatformException', () {
diff --git a/test/modes/cbc_test.dart b/test/modes/cbc_test.dart
index cbe18af..bbd6e05 100644
--- a/test/modes/cbc_test.dart
+++ b/test/modes/cbc_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.cbc_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/modes/ccm_test.dart b/test/modes/ccm_test.dart
index 0e14270..ab44ce0 100644
--- a/test/modes/ccm_test.dart
+++ b/test/modes/ccm_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.gcm_test;
-
import 'dart:typed_data';
import 'package:pointycastle/block/aes.dart';
@@ -51,11 +49,8 @@
for (var map in paramList) {
test(map['name'], () {
var encrypter = CCMBlockCipher(AESEngine());
- var params = AEADParameters(
- KeyParameter((map['key'] as Uint8List)),
- map['tl'] as int,
- (map['iv'] as Uint8List),
- (map['aad'] as Uint8List));
+ var params = AEADParameters(KeyParameter(map['key'] as Uint8List),
+ map['tl'] as int, map['iv'] as Uint8List, map['aad'] as Uint8List);
encrypter.init(true, params);
var result = encrypter
diff --git a/test/modes/cfb_test.dart b/test/modes/cfb_test.dart
index 03f3fd4..7d19c0d 100644
--- a/test/modes/cfb_test.dart
+++ b/test/modes/cfb_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.cfb_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/modes/ecb_test.dart b/test/modes/ecb_test.dart
index f21403e..30bb619 100644
--- a/test/modes/ecb_test.dart
+++ b/test/modes/ecb_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.ecb_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/modes/gcm_test.dart b/test/modes/gcm_test.dart
index 6d33159..e431dd1 100644
--- a/test/modes/gcm_test.dart
+++ b/test/modes/gcm_test.dart
@@ -35,7 +35,7 @@
//
final expectedSHA256 = createUint8ListFromHexString(
- "1679DCC9C8AD4B75BE69BBCABE46D4F32472F48C24595D5280EC5B44E77B3105");
+ '1679DCC9C8AD4B75BE69BBCABE46D4F32472F48C24595D5280EC5B44E77B3105');
var dig = SHA256Digest();
dig.update(encrypted, 0, encrypted.length);
@@ -81,9 +81,9 @@
'iv': createUint8ListFromHexString('cafebabefacedbaddecaf888'),
'aad': createUint8ListFromHexString(''),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
'output':
- '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985',
+ '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985',
'mac': createUint8ListFromHexString('4d5c2af327cd64a62cf35abd2ba6fab4')
},
{
@@ -93,9 +93,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091',
+ '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091',
'mac': createUint8ListFromHexString('5bc94fbc3221a5db94fae95ae7121a47')
},
{
@@ -105,9 +105,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598',
+ '61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598',
'mac': createUint8ListFromHexString('3612d2e79e3b0785561be14aaca2fccb')
},
{
@@ -118,9 +118,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5',
+ '8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5',
'mac': createUint8ListFromHexString('619cc5aefffe0bfa462af43c1699d050')
},
{
@@ -150,9 +150,9 @@
'iv': createUint8ListFromHexString('cafebabefacedbaddecaf888'),
'aad': createUint8ListFromHexString(''),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
'output':
- '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256',
+ '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256',
'mac': createUint8ListFromHexString('9924a7c8587336bfb118024db8674a14')
},
{
@@ -163,9 +163,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710',
+ '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710',
'mac': createUint8ListFromHexString('2519498e80f1478f37ba55bd6d27618c')
},
{
@@ -176,9 +176,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7',
+ '0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7',
'mac': createUint8ListFromHexString('65dcc57fcf623a24094fcca40d3533f8')
},
{
@@ -190,9 +190,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- 'd27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b',
+ 'd27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b',
'mac': createUint8ListFromHexString('dcf566ff291c25bbb8568fc3d376a6d9')
},
{
@@ -222,9 +222,9 @@
'iv': createUint8ListFromHexString('cafebabefacedbaddecaf888'),
'aad': createUint8ListFromHexString(''),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255',
'output':
- '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad',
+ '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad',
'mac': createUint8ListFromHexString('b094dac5d93471bdec1a502270e3cc6c')
},
{
@@ -235,9 +235,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662',
+ '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662',
'mac': createUint8ListFromHexString('76fc6ece0f4e1768cddf8853bb2d551b')
},
{
@@ -248,9 +248,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- 'c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f',
+ 'c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f',
'mac': createUint8ListFromHexString('3a337dbf46a792c45e454913fe2ea8f2')
},
{
@@ -262,9 +262,9 @@
'aad': createUint8ListFromHexString(
'feedfacedeadbeeffeedfacedeadbeefabaddad2'),
'input':
- 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39',
'output':
- '5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f',
+ '5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f',
'mac': createUint8ListFromHexString('a44a8266ee1c8eb0c8b5d4cf5ae9f19a')
},
];
@@ -273,8 +273,8 @@
for (var map in paramList) {
test(map['name'], () {
var encrypter = GCMBlockCipher(AESEngine());
- var params = AEADParameters(KeyParameter((map['key'] as Uint8List)),
- 16 * 8, (map['iv'] as Uint8List), (map['aad'] as Uint8List));
+ var params = AEADParameters(KeyParameter(map['key'] as Uint8List),
+ 16 * 8, map['iv'] as Uint8List, map['aad'] as Uint8List);
encrypter.init(true, params);
var result = encrypter
.process(createUint8ListFromHexString(map['input'] as String));
diff --git a/test/modes/gctr_test.dart b/test/modes/gctr_test.dart
index 42df0aa..c663abb 100644
--- a/test/modes/gctr_test.dart
+++ b/test/modes/gctr_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.gctr_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/modes/ige_test.dart b/test/modes/ige_test.dart
index e552d8a..b35051d 100644
--- a/test/modes/ige_test.dart
+++ b/test/modes/ige_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.ige_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/block_cipher.dart';
diff --git a/test/modes/ofb_test.dart b/test/modes/ofb_test.dart
index 784afff..7bb6c70 100644
--- a/test/modes/ofb_test.dart
+++ b/test/modes/ofb_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.ofb_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/modes/sic_test.dart b/test/modes/sic_test.dart
index 94a4c6e..f322a84 100644
--- a/test/modes/sic_test.dart
+++ b/test/modes/sic_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.modes.sic_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/paddings/iso7816d4_test.dart b/test/paddings/iso7816d4_test.dart
index 611bb26..15d25ff 100644
--- a/test/paddings/iso7816d4_test.dart
+++ b/test/paddings/iso7816d4_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.paddings.iso7816d4_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/padding.dart';
diff --git a/test/paddings/padded_block_cipher_test.dart b/test/paddings/padded_block_cipher_test.dart
index 299acc8..ffa7e1f 100644
--- a/test/paddings/padded_block_cipher_test.dart
+++ b/test/paddings/padded_block_cipher_test.dart
@@ -1,9 +1,6 @@
// See file LICENSE for more information.
-library test.padded_block_cipher_test;
-
import 'package:pointycastle/export.dart';
-import 'package:pointycastle/pointycastle.dart';
import 'package:pointycastle/src/registry/registry.dart';
import 'package:test/test.dart';
diff --git a/test/paddings/pkcs7_test.dart b/test/paddings/pkcs7_test.dart
index 516df72..1df9b87 100644
--- a/test/paddings/pkcs7_test.dart
+++ b/test/paddings/pkcs7_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.paddings.pkcs7_test;
-
import 'dart:typed_data' show Uint8List;
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/platform/platform_native_test.dart b/test/platform/platform_native_test.dart
index 816617a..282d231 100644
--- a/test/platform/platform_native_test.dart
+++ b/test/platform/platform_native_test.dart
@@ -3,8 +3,8 @@
import 'package:test/test.dart';
void main() {
- test("is native", () {
- expect(Platform.instance.platform, isNot(equals("web")));
+ test('is native', () {
+ expect(Platform.instance.platform, isNot(equals('web')));
expect(Platform.instance.isNative, equals(true));
expect(Platform.instance.fullWidthInteger, equals(true));
});
diff --git a/test/platform/platform_web_test.dart b/test/platform/platform_web_test.dart
index 945c445..33a044e 100644
--- a/test/platform/platform_web_test.dart
+++ b/test/platform/platform_web_test.dart
@@ -4,7 +4,7 @@
void main() {
test('is not native', () {
- expect(Platform.instance.platform, equals("web"));
+ expect(Platform.instance.platform, equals('web'));
expect(Platform.instance.isNative, equals(false));
expect(Platform.instance.fullWidthInteger, equals(false));
});
diff --git a/test/random/auto_seed_block_ctr_random_test.dart b/test/random/auto_seed_block_ctr_random_test.dart
index 0728676..a1c4eb4 100644
--- a/test/random/auto_seed_block_ctr_random_test.dart
+++ b/test/random/auto_seed_block_ctr_random_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.random.auto_seed_block_ctr_random_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -12,7 +10,7 @@
group('AutoSeedBlockCtrRandom:', () {
final rnd = SecureRandom('AES/CTR/AUTO-SEED-PRNG');
- test('${rnd.algorithmName}', () {
+ test(rnd.algorithmName, () {
final key = Uint8List(16);
final keyParam = KeyParameter(key);
final params = ParametersWithIV(keyParam, Uint8List(16));
diff --git a/test/random/block_ctr_random_test.dart b/test/random/block_ctr_random_test.dart
index cfaeb08..71a16b0 100644
--- a/test/random/block_ctr_random_test.dart
+++ b/test/random/block_ctr_random_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.random.block_ctr_random_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -12,7 +10,7 @@
group('BlockCtrRandom:', () {
final rnd = SecureRandom('AES/CTR/PRNG');
- test('${rnd.algorithmName}', () {
+ test(rnd.algorithmName, () {
final key = Uint8List(16);
final keyParam = KeyParameter(key);
final params = ParametersWithIV(keyParam, Uint8List(16));
diff --git a/test/random/fixed_rng_test.dart b/test/random/fixed_rng_test.dart
index b9ea659..767a795 100644
--- a/test/random/fixed_rng_test.dart
+++ b/test/random/fixed_rng_test.dart
@@ -1,5 +1,3 @@
-library test.random.fixed_rng_test.dart;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/test/random/fortuna_random_test.dart b/test/random/fortuna_random_test.dart
index 648a5ff..59edd89 100644
--- a/test/random/fortuna_random_test.dart
+++ b/test/random/fortuna_random_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.random.fortuna_random_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -12,7 +10,7 @@
group('Fortuna:', () {
final rnd = SecureRandom('Fortuna');
- test('${rnd.algorithmName}', () {
+ test(rnd.algorithmName, () {
final key = Uint8List(32);
final keyParam = KeyParameter(key);
diff --git a/test/signers/ecdsa_signer_test.dart b/test/signers/ecdsa_signer_test.dart
index 6a714b7..3a4a336 100644
--- a/test/signers/ecdsa_signer_test.dart
+++ b/test/signers/ecdsa_signer_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.signers.ecdsa_signer_test;
-
import 'package:pointycastle/pointycastle.dart';
import 'package:pointycastle/signers/ecdsa_signer.dart';
@@ -17,12 +15,14 @@
var Qy = BigInt.parse(
'6264116558863692852155702059476882343593676720209154057133');
var Q = eccDomain.curve.createPoint(Qx, Qy);
- var verifyParams = () => PublicKeyParameter(ECPublicKey(Q, eccDomain));
+ PublicKeyParameter<PublicKey> verifyParams() =>
+ PublicKeyParameter(ECPublicKey(Q, eccDomain));
var d = BigInt.parse(
'3062713166230336928689662410859599564103408831862304472446');
var privParams = PrivateKeyParameter(ECPrivateKey(d, eccDomain));
- var signParams = () => ParametersWithRandom(privParams, NullSecureRandom());
+ ParametersWithRandom<PrivateKeyParameter<PrivateKey>> signParams() =>
+ ParametersWithRandom(privParams, NullSecureRandom());
runSignerTests(Signer('SHA-1/ECDSA'), signParams, verifyParams, [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit ........',
diff --git a/test/signers/ecdsa_vec.dart b/test/signers/ecdsa_vec.dart
index 964a44a..3c1547e 100644
--- a/test/signers/ecdsa_vec.dart
+++ b/test/signers/ecdsa_vec.dart
@@ -2855,7 +2855,7 @@
]
''');
-dynamic sigGenVec = jsonDecode('''
+List sigGenVec = jsonDecode('''
[
{
},
@@ -4144,4 +4144,4 @@
]
}
]
-''');
+''') as List;
diff --git a/test/signers/ecdsa_vector_vm_test.dart b/test/signers/ecdsa_vector_vm_test.dart
index 4eb8f23..fa92877 100644
--- a/test/signers/ecdsa_vector_vm_test.dart
+++ b/test/signers/ecdsa_vector_vm_test.dart
@@ -1,11 +1,9 @@
// See file LICENSE for more information.
-library test.signers.ecdsa_vector_test;
-
-import 'package:pointycastle/ecc/api.dart';
import 'package:pointycastle/export.dart';
import 'package:pointycastle/src/utils.dart';
import 'package:test/test.dart';
+
import '../test/src/fixed_secure_random.dart';
import '../test/src/helpers.dart';
import 'ecdsa_vec.dart';
@@ -41,7 +39,7 @@
domainParameters = ECCurve_secp521r1();
break;
default:
- throw ArgumentError('curve not supported in this test: ' + hashAlg);
+ throw ArgumentError('curve not supported in this test: $hashAlg');
}
String alg;
@@ -60,10 +58,10 @@
alg = 'SHA-512/ECDSA';
break;
default:
- throw ArgumentError('hash alg not supported in this test: ' + hashAlg);
+ throw ArgumentError('hash alg not supported in this test: $hashAlg');
}
- group("ECDSA SigVer", () {
+ group('ECDSA SigVer', () {
grp['tests'].forEach((test) {
checkSigVer(domainParameters, alg, grp, test);
});
@@ -75,14 +73,14 @@
dynamic vector) {
group("${grp["tgId"]} ${grp["curve"]} ${grp["hashAlg"]}", () {
test("test ${vector["tcId"]}", () {
- BigInt qX =
+ var qX =
decodeBigIntWithSign(1, createUint8ListFromHexString(vector['qx']));
- BigInt qY =
+ var qY =
decodeBigIntWithSign(1, createUint8ListFromHexString(vector['qy']));
- BigInt r =
+ var r =
decodeBigIntWithSign(1, createUint8ListFromHexString(vector['r']));
- BigInt s =
+ var s =
decodeBigIntWithSign(1, createUint8ListFromHexString(vector['s']));
bool expectedResult = vector['testPassed'];
@@ -97,7 +95,7 @@
var signer = Signer(alg);
signer.init(false, params);
- bool result = signer.verifySignature(message, new ECSignature(r, s));
+ var result = signer.verifySignature(message, ECSignature(r, s));
expect(expectedResult, equals(result));
});
@@ -110,11 +108,9 @@
vectors[1]['testGroups'].forEach((grp) {
String hashAlg = grp['hashAlg'];
String curve = grp['curve'];
- BigInt d = decodeBigIntWithSign(1, createUint8ListFromHexString(grp['d']));
- BigInt qX =
- decodeBigIntWithSign(1, createUint8ListFromHexString(grp['qx']));
- BigInt qY =
- decodeBigIntWithSign(1, createUint8ListFromHexString(grp['qy']));
+ var d = decodeBigIntWithSign(1, createUint8ListFromHexString(grp['d']));
+ var qX = decodeBigIntWithSign(1, createUint8ListFromHexString(grp['qx']));
+ var qY = decodeBigIntWithSign(1, createUint8ListFromHexString(grp['qy']));
// "P-224","P-256","P-384","P-521","B-233","B-283","B-409","B-571","K-233","K-283","K-409","K-571"
@@ -133,7 +129,7 @@
domainParameters = ECCurve_secp521r1();
break;
default:
- throw ArgumentError('curve not supported in this test: ' + hashAlg);
+ throw ArgumentError('curve not supported in this test: $hashAlg');
}
String alg;
@@ -152,7 +148,7 @@
alg = 'SHA-512/ECDSA';
break;
default:
- throw ArgumentError('hash alg not supported in this test: ' + hashAlg);
+ throw ArgumentError('hash alg not supported in this test: $hashAlg');
}
var keyPair = AsymmetricKeyPair(
@@ -160,7 +156,7 @@
domainParameters.curve.createPoint(qX, qY), domainParameters),
ECPrivateKey(d, domainParameters));
- group("ECDSA SigGen", () {
+ group('ECDSA SigGen', () {
grp['tests'].forEach((test) {
checkSigGen(keyPair, alg, grp, test);
});
@@ -169,7 +165,7 @@
}
void checkSigGen(
- AsymmetricKeyPair keyPair, String alg, dynamic grp, dynamic vector) {
+ AsymmetricKeyPair keyPair, String alg, dynamic grp, Map vector) {
group("${grp["tgId"]} ${grp["curve"]} ${grp["hashAlg"]}", () {
test("test ${vector["tcId"]}", () {
var seed = createUint8ListFromHexString(vector['seed']);
diff --git a/test/signers/pss_signer_test.dart b/test/signers/pss_signer_test.dart
index d99ae29..cc0bb3b 100644
--- a/test/signers/pss_signer_test.dart
+++ b/test/signers/pss_signer_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.signers.pss_signer_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -214,11 +212,15 @@
});
}
-var pubParams = (RSAPublicKey pubk, Uint8List salt) => () => ParametersWithSalt(
- PublicKeyParameter<RSAPublicKey>(pubk),
- salt,
- );
-var privParams = (RSAPrivateKey privk, Uint8List salt) =>
+ParametersWithSalt<PublicKeyParameter<RSAPublicKey>> Function() Function(
+ RSAPublicKey pubk, Uint8List salt) pubParams =
+ (RSAPublicKey pubk, Uint8List salt) => () => ParametersWithSalt(
+ PublicKeyParameter<RSAPublicKey>(pubk),
+ salt,
+ );
+ParametersWithSalt<PrivateKeyParameter<RSAPrivateKey>> Function() Function(
+ RSAPrivateKey privk, Uint8List salt) privParams = (RSAPrivateKey privk,
+ Uint8List salt) =>
() => ParametersWithSalt(PrivateKeyParameter<RSAPrivateKey>(privk), salt);
void _testSign(
diff --git a/test/signers/rsa_signer_test.dart b/test/signers/rsa_signer_test.dart
index a061044..a5fa8e6 100644
--- a/test/signers/rsa_signer_test.dart
+++ b/test/signers/rsa_signer_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.signers.rsa_signer_test;
-
import 'package:pointycastle/pointycastle.dart';
import '../test/runners/signer.dart';
@@ -22,10 +20,12 @@
var pubk = RSAPublicKey(modulus, publicExponent);
var privk = RSAPrivateKey(modulus, privateExponent, p, q);
- var pubParams = () => ParametersWithRandom(
- PublicKeyParameter<RSAPublicKey>(pubk), NullSecureRandom());
- var privParams = () => ParametersWithRandom(
- PrivateKeyParameter<RSAPrivateKey>(privk), NullSecureRandom());
+ ParametersWithRandom<PublicKeyParameter<RSAPublicKey>> pubParams() =>
+ ParametersWithRandom(
+ PublicKeyParameter<RSAPublicKey>(pubk), NullSecureRandom());
+ ParametersWithRandom<PrivateKeyParameter<RSAPrivateKey>> privParams() =>
+ ParametersWithRandom(
+ PrivateKeyParameter<RSAPrivateKey>(privk), NullSecureRandom());
runSignerTests(Signer('SHA-1/RSA'), privParams, pubParams, [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit...',
diff --git a/test/src/ct_nonvm_test.dart b/test/src/ct_nonvm_test.dart
index 3c90cf1..676f712 100644
--- a/test/src/ct_nonvm_test.dart
+++ b/test/src/ct_nonvm_test.dart
@@ -18,7 +18,7 @@
group('ct', () {
test('xor monte', () {
- for (int j = 0; j < 1000; j++) {
+ for (var j = 0; j < 1000; j++) {
var len = rand.nextInt(256);
var x = Uint8List.fromList(
List.generate(len, (index) => rand.nextInt(256)));
@@ -27,7 +27,7 @@
var enable = rand.nextInt(10) >= 5;
var reason =
- "$enable ${formatBytesAsHexString(x)} ${formatBytesAsHexString(y)}";
+ '$enable ${formatBytesAsHexString(x)} ${formatBytesAsHexString(y)}';
var xExpected = Uint8List.fromList(x);
_xor(xExpected, y, enable);
@@ -39,9 +39,9 @@
// Should be all zero
//
CT_xor(y, y, true);
- y.forEach((element) {
+ for (var element in y) {
expect(element, equals(0));
- });
+ }
}
});
@@ -58,7 +58,7 @@
// naive non ct xor
void _xor(Uint8List x, Uint8List y, bool enable) {
if (enable) {
- for (int t = 0; t < x.length; t++) {
+ for (var t = 0; t < x.length; t++) {
x[t] = x[t] ^ y[t];
}
}
diff --git a/test/src/ct_test.dart b/test/src/ct_test.dart
index c98d93d..8259c09 100644
--- a/test/src/ct_test.dart
+++ b/test/src/ct_test.dart
@@ -19,7 +19,7 @@
group('ct', () {
test('xor monte', () {
- for (int j = 0; j < 500000; j++) {
+ for (var j = 0; j < 500000; j++) {
var len = rand.nextInt(256);
var x = Uint8List.fromList(
List.generate(len, (index) => rand.nextInt(256)));
@@ -28,7 +28,7 @@
var enable = rand.nextInt(10) >= 5;
var reason =
- "$enable ${formatBytesAsHexString(x)} ${formatBytesAsHexString(y)}";
+ '$enable ${formatBytesAsHexString(x)} ${formatBytesAsHexString(y)}';
var xExpected = Uint8List.fromList(x);
_xor(xExpected, y, enable);
@@ -40,9 +40,9 @@
// Should be all zero
//
CT_xor(y, y, true);
- y.forEach((element) {
+ for (var element in y) {
expect(element, equals(0));
- });
+ }
}
});
diff --git a/test/src/ufixnum_test.dart b/test/src/ufixnum_test.dart
index 6323d90..417d861 100644
--- a/test/src/ufixnum_test.dart
+++ b/test/src/ufixnum_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.ufixnum_test;
-
import 'dart:typed_data';
import 'package:pointycastle/src/ufixnum.dart';
diff --git a/test/src/utils_test.dart b/test/src/utils_test.dart
index 8cca2e4..0ee7be8 100644
--- a/test/src/utils_test.dart
+++ b/test/src/utils_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library src.utils_test;
-
import 'package:pointycastle/src/utils.dart';
import 'package:test/test.dart';
diff --git a/test/srp/srp_test.dart b/test/srp/srp_test.dart
index 6b4ebe5..862cd3a 100644
--- a/test/srp/srp_test.dart
+++ b/test/srp/srp_test.dart
@@ -1,14 +1,12 @@
-library test.srp_test;
-
import 'dart:typed_data';
+
+import 'package:convert/convert.dart';
+import 'package:pointycastle/pointycastle.dart';
import 'package:pointycastle/srp/srp6_client.dart';
import 'package:pointycastle/srp/srp6_server.dart';
import 'package:pointycastle/srp/srp6_standard_groups.dart';
import 'package:pointycastle/srp/srp6_util.dart';
import 'package:pointycastle/srp/srp6_verifier_generator.dart';
-
-import 'package:convert/convert.dart';
-import 'package:pointycastle/pointycastle.dart';
import 'package:test/test.dart';
void main() {
@@ -22,34 +20,34 @@
var N = SRP6StandardGroups.rfc5054_1024.N;
var g = SRP6StandardGroups.rfc5054_1024.g;
- var expect_k =
+ var expectK =
BigInt.parse('7556AA045AEF2CDD07ABAF0F665C3E818913186F', radix: 16);
- var expect_x =
+ var expectX =
BigInt.parse('94B7555AABE9127CC58CCF4993DB6CF84D16C124', radix: 16);
- var expect_v = BigInt.parse(
+ var expectV = BigInt.parse(
'7E273DE8696FFC4F4E337D05B4B375BEB0DDE1569E8FA00A9886D812'
'9BADA1F1822223CA1A605B530E379BA4729FDC59F105B4787E5186F5'
'C671085A1447B52A48CF1970B4FB6F8400BBF4CEBFBB168152E08AB5'
'EA53D15C1AFF87B2B9DA6E04E058AD51CC72BFC9033B564E26480D78'
'E955A5E29E7AB245DB2BE315E2099AFB',
radix: 16);
- var expect_A = BigInt.parse(
+ var expectA = BigInt.parse(
'61D5E490F6F1B79547B0704C436F523DD0E560F0C64115BB72557EC4'
'4352E8903211C04692272D8B2D1A5358A2CF1B6E0BFCF99F921530EC'
'8E39356179EAE45E42BA92AEACED825171E1E8B9AF6D9C03E1327F44'
'BE087EF06530E69F66615261EEF54073CA11CF5858F0EDFDFE15EFEA'
'B349EF5D76988A3672FAC47B0769447B',
radix: 16);
- var expect_B = BigInt.parse(
+ var expectB = BigInt.parse(
'BD0C61512C692C0CB6D041FA01BB152D4916A1E77AF46AE105393011'
'BAF38964DC46A0670DD125B95A981652236F99D9B681CBF87837EC99'
'6C6DA04453728610D0C6DDB58B318885D7D82C7F8DEB75CE7BD4FBAA'
'37089E6F9C6059F388838E7A00030B331EB76840910440B1B27AAEAE'
'EB4012B7D7665238A8E3FB004B117B58',
radix: 16);
- var expect_u =
+ var expectU =
BigInt.parse('CE38B9593487DA98554ED47D70A7AE5F462EF019', radix: 16);
- var expect_S = BigInt.parse(
+ var expectS = BigInt.parse(
'B0DC82BABCF30674AE450C0287745E7990A3381F63B387AAF271A10D'
'233861E359B48220F7C4693C9AE12B0A6F67809F0876E2D013800D6C'
'41BB59B6D5979B5C00A172B4A2A5903A0BDCAF8A709585EB2AFAFA8F'
@@ -58,19 +56,19 @@
radix: 16);
var k = SRP6Util.calculateK(Digest('SHA-1'), N, g);
- if (k.compareTo(expect_k) != 0) {
- fail("wrong value of 'k', expected $expect_k got $k");
+ if (k.compareTo(expectK) != 0) {
+ fail("wrong value of 'k', expected $expectK got $k");
}
var x = SRP6Util.calculateX(Digest('SHA-1'), N, s, I, P);
- if (x.compareTo(expect_x) != 0) {
+ if (x.compareTo(expectX) != 0) {
fail("wrong value of 'x'");
}
var gen = SRP6VerifierGenerator(
group: SRP6StandardGroups.rfc5054_1024, digest: Digest('SHA-1'));
var v = gen.generateVerifier(s, I, P);
- if (v.compareTo(expect_v) != 0) {
+ if (v.compareTo(expectV) != 0) {
fail("wrong value of 'v'");
}
@@ -80,7 +78,7 @@
random: random);
var A = client.generateClientCredentials(s, I, P);
- if (A!.compareTo(expect_A) != 0) {
+ if (A!.compareTo(expectA) != 0) {
fail("wrong value of 'A'");
}
@@ -91,22 +89,22 @@
random: random);
var B = server.generateServerCredentials();
- if (B!.compareTo(expect_B) != 0) {
- fail("wrong value of 'B', expected $expect_B got $B");
+ if (B!.compareTo(expectB) != 0) {
+ fail("wrong value of 'B', expected $expectB got $B");
}
var u = SRP6Util.calculateU(Digest('SHA-1'), N, A, B);
- if (u.compareTo(expect_u) != 0) {
+ if (u.compareTo(expectU) != 0) {
fail("wrong value of 'u'");
}
var clientS = client.calculateSecret(B);
- if (clientS!.compareTo(expect_S) != 0) {
+ if (clientS!.compareTo(expectS) != 0) {
fail("wrong value of 'S' (client)");
}
var serverS = server.calculateSecret(A);
- if (serverS!.compareTo(expect_S) != 0) {
+ if (serverS!.compareTo(expectS) != 0) {
fail("wrong value of 'S' (server)");
}
});
@@ -269,13 +267,12 @@
final random = SecureRandom('AES/CTR/AUTO-SEED-PRNG');
class TestSRP6Client extends SRP6Client {
- @override
- var a = BigInt.parse(
- '60975527035CF2AD1989806F0407210BC81EDC04E2762A56AFD529DDDA2D4393',
- radix: 16);
-
- TestSRP6Client({required SRP6GroupParameters group, digest, random})
- : super(group: group, digest: digest, random: random);
+ TestSRP6Client(
+ {required super.group, required super.digest, required super.random}) {
+ a = BigInt.parse(
+ '60975527035CF2AD1989806F0407210BC81EDC04E2762A56AFD529DDDA2D4393',
+ radix: 16);
+ }
@override
BigInt? selectPrivateValue() {
@@ -284,13 +281,15 @@
}
class TestSRP6Server extends SRP6Server {
- @override
- var b = BigInt.parse(
- 'E487CB59D31AC550471E81F00F6928E01DDA08E974A004F49E61F5D105284D20',
- radix: 16);
-
- TestSRP6Server({required SRP6GroupParameters group, v, digest, random})
- : super(group: group, v: v, digest: digest, random: random);
+ TestSRP6Server(
+ {required super.group,
+ required super.v,
+ required super.digest,
+ required super.random}) {
+ b = BigInt.parse(
+ 'E487CB59D31AC550471E81F00F6928E01DDA08E974A004F49E61F5D105284D20',
+ radix: 16);
+ }
@override
BigInt? selectPrivateValue() {
diff --git a/test/stream/chacha20_test.dart b/test/stream/chacha20_test.dart
index dbfcb7b..cbc54a4 100644
--- a/test/stream/chacha20_test.dart
+++ b/test/stream/chacha20_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.stream.chacha20_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/stream/eax_test.dart b/test/stream/eax_test.dart
index bb8f53a..2d30fe1 100644
--- a/test/stream/eax_test.dart
+++ b/test/stream/eax_test.dart
@@ -46,9 +46,7 @@
() => eax.init(false, KeyParameter(K1)), throwsArgumentError));
});
- group('eax random', () {
- randomTests();
- });
+ group('eax random', randomTests);
/* AEADTestUtil from bouncycastle/java needs to be ported
AEADTestUtil.testReset(this, new EAXBlockCipher(new AESEngine()), new EAXBlockCipher(new AESEngine()), new AEADParameters(new KeyParameter(K1), 32, N2));
@@ -187,10 +185,10 @@
void randomTest(SecureRandom srng) {
test('randomTest', () {
- var DAT_LEN = unsignedShiftRight64(srng.nextUint32(), 22);
+ var datLen = unsignedShiftRight64(srng.nextUint32(), 22);
var nonce = srng.nextBytes(NONCE_LEN);
var authen = srng.nextBytes(AUTHEN_LEN);
- var datIn = srng.nextBytes(DAT_LEN);
+ var datIn = srng.nextBytes(datLen);
var key = srng.nextBytes(16);
var engine = AESEngine();
@@ -201,7 +199,7 @@
eaxCipher.init(true, params);
var intrDat = Uint8List(eaxCipher.getOutputSize(datIn.length));
- var outOff = eaxCipher.processBytes(datIn, 0, DAT_LEN, intrDat, 0);
+ var outOff = eaxCipher.processBytes(datIn, 0, datLen, intrDat, 0);
outOff += eaxCipher.doFinal(intrDat, outOff);
eaxCipher.init(false, params);
diff --git a/test/stream/salsa20_test.dart b/test/stream/salsa20_test.dart
index cd25779..3439d9a 100644
--- a/test/stream/salsa20_test.dart
+++ b/test/stream/salsa20_test.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.stream.salsa20_test;
-
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/test/runners/asymmetric_block_cipher.dart b/test/test/runners/asymmetric_block_cipher.dart
index 0e1d322..46e5522 100644
--- a/test/test/runners/asymmetric_block_cipher.dart
+++ b/test/test/runners/asymmetric_block_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.asymmetric_block_cipher_tests;
-
import 'package:test/test.dart';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/test/runners/block_cipher.dart b/test/test/runners/block_cipher.dart
index 7bf9ea9..531ce4e 100644
--- a/test/test/runners/block_cipher.dart
+++ b/test/test/runners/block_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.block_cipher_tests;
-
import 'dart:typed_data';
import 'package:test/test.dart';
@@ -17,7 +15,7 @@
var plainText = plainCipherTextPairs[i];
var cipherText = plainCipherTextPairs[i + 1];
- test('${formatAsTruncated(plainText)}',
+ test(formatAsTruncated(plainText),
() => _runBlockCipherTest(cipher, params, plainText, cipherText));
}
});
@@ -27,7 +25,7 @@
var plainText = plainCipherTextPairs[i];
var cipherText = plainCipherTextPairs[i + 1];
- test('${formatAsTruncated(plainText)}',
+ test(formatAsTruncated(plainText),
() => _runBlockDecipherTest(cipher, params, cipherText, plainText));
}
});
diff --git a/test/test/runners/digest.dart b/test/test/runners/digest.dart
index 685303a..6047408 100644
--- a/test/test/runners/digest.dart
+++ b/test/test/runners/digest.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.digest_tests;
-
import 'dart:typed_data';
import 'package:test/test.dart';
@@ -16,7 +14,7 @@
var plainText = plainDigestTextPairs[i];
var digestText = plainDigestTextPairs[i + 1];
- test('${formatAsTruncated(plainText)}',
+ test(formatAsTruncated(plainText),
() => _runDigestTest(digest, plainText, digestText));
}
});
diff --git a/test/test/runners/key_derivators.dart b/test/test/runners/key_derivators.dart
index 8d19b06..ee988a8 100644
--- a/test/test/runners/key_derivators.dart
+++ b/test/test/runners/key_derivators.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.key_derivators_tests;
-
import 'package:test/test.dart';
import 'package:pointycastle/pointycastle.dart';
@@ -17,7 +15,7 @@
var key = paramsPasswordKeyTuples[i + 2];
test(
- '${formatAsTruncated(password as String)}',
+ formatAsTruncated(password as String),
() => _runKeyDerivatorTest(keyDerivator, params as CipherParameters,
password, key as String));
}
diff --git a/test/test/runners/key_generators.dart b/test/test/runners/key_generators.dart
index c9255da..0b07aba 100644
--- a/test/test/runners/key_generators.dart
+++ b/test/test/runners/key_generators.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.key_generators_tests;
-
import 'package:test/test.dart';
import 'package:pointycastle/pointycastle.dart';
diff --git a/test/test/runners/mac.dart b/test/test/runners/mac.dart
index 3fad069..c0d7f2e 100644
--- a/test/test/runners/mac.dart
+++ b/test/test/runners/mac.dart
@@ -1,11 +1,9 @@
// See file LICENSE for more information.
-library test.test.mac_tests;
-
import 'dart:typed_data' show Uint8List;
-import 'package:test/test.dart';
import 'package:pointycastle/pointycastle.dart';
+import 'package:test/test.dart';
import '../src/helpers.dart';
@@ -23,7 +21,7 @@
var plainText = plainDigestTextPairs[i].plainText;
var digestText = plainDigestTextPairs[i].hexDigestText;
- test('${formatAsTruncated(plainText.toString())}',
+ test(formatAsTruncated(plainText.toString()),
() => _runMacTest(mac, plainText, digestText));
}
});
@@ -77,8 +75,7 @@
final d = hmac.process(data);
- final result =
- formatBytesAsHexString(((truncate128)) ? d.sublist(0, 16) : d);
+ final result = formatBytesAsHexString(truncate128 ? d.sublist(0, 16) : d);
//print('$testName: $result');
expect(result, equals(expected));
});
diff --git a/test/test/runners/padding.dart b/test/test/runners/padding.dart
index 2abf228..46629ad 100644
--- a/test/test/runners/padding.dart
+++ b/test/test/runners/padding.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.padding_tests;
-
import 'dart:typed_data' show Uint8List;
import 'package:test/test.dart';
diff --git a/test/test/runners/registry.dart b/test/test/runners/registry.dart
index 5c38297..f0063aa 100644
--- a/test/test/runners/registry.dart
+++ b/test/test/runners/registry.dart
@@ -1,11 +1,7 @@
// See file LICENSE for more information.
-library test.test.registry_tests;
-
import 'package:pointycastle/pointycastle.dart';
-
import 'package:test/test.dart';
-import 'package:matcher/matcher.dart';
void testAsymmetricBlockCipher(String algorithmName) {
var cipher = AsymmetricBlockCipher(algorithmName);
diff --git a/test/test/runners/signer.dart b/test/test/runners/signer.dart
index c2ca0a7..e314751 100644
--- a/test/test/runners/signer.dart
+++ b/test/test/runners/signer.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.signer_tests;
-
import 'package:test/test.dart';
import 'package:pointycastle/pointycastle.dart';
@@ -16,7 +14,7 @@
var signature = messageSignaturePairs[i + 1];
test(
- '${formatAsTruncated(message as String)}',
+ formatAsTruncated(message as String),
() => _runGenerateSignatureTest(
signer, signParams, message, signature as Signature));
}
@@ -28,7 +26,7 @@
var signature = messageSignaturePairs[i + 1];
test(
- '${formatAsTruncated(message as String)}',
+ formatAsTruncated(message as String),
() => _runVerifySignatureTest(
signer, verifyParams, message, signature as Signature));
}
@@ -71,7 +69,7 @@
var signature = messageSignaturePairs[i + 1];
test(
- '${formatAsTruncated(message as String)}',
+ formatAsTruncated(message as String),
() => _runGenerateSignatureTestFail(
signer, signParams, message, signature as Signature));
}
@@ -83,7 +81,7 @@
var signature = messageSignaturePairs[i + 1];
test(
- '${formatAsTruncated(message as String)}',
+ formatAsTruncated(message as String),
() => _runVerifySignatureTestFail(
signer, verifyParams, message, signature as Signature));
}
diff --git a/test/test/runners/stream_cipher.dart b/test/test/runners/stream_cipher.dart
index 8be00d9..272f124 100644
--- a/test/test/runners/stream_cipher.dart
+++ b/test/test/runners/stream_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.stream_cipher_tests;
-
import 'dart:typed_data';
import 'package:test/test.dart';
@@ -17,7 +15,7 @@
var plainText = plainCipherTextPairs[i];
var cipherText = plainCipherTextPairs[i + 1];
- test('${formatAsTruncated(plainText)}',
+ test(formatAsTruncated(plainText),
() => _runStreamCipherTest(cipher, params, plainText, cipherText));
}
});
@@ -28,7 +26,7 @@
var cipherText = plainCipherTextPairs[i + 1];
test(
- '${formatAsTruncated(plainText)}',
+ formatAsTruncated(plainText),
() =>
_runStreamDecipherTest(cipher, params, cipherText, plainText));
}
diff --git a/test/test/src/fixed_secure_random.dart b/test/test/src/fixed_secure_random.dart
index 6e346a0..a052c99 100644
--- a/test/test/src/fixed_secure_random.dart
+++ b/test/test/src/fixed_secure_random.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library impl.secure_random.test.src.fixed_secure_random;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/test/test/src/helpers.dart b/test/test/src/helpers.dart
index 6782a7f..db2e77d 100644
--- a/test/test/src/helpers.dart
+++ b/test/test/src/helpers.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library test.test.src.helpers;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
@@ -14,7 +12,7 @@
String formatAsTruncated(String str) {
if (str.length > 26) {
- return str.substring(0, 26) + '[...]';
+ return '${str.substring(0, 26)}[...]';
} else if (str.isEmpty) {
return '(empty string)';
} else {
@@ -44,9 +42,7 @@
} else if (val.isNaN) {
return 'NaN';
} else {
- return val.floor().toString() +
- '.' +
- (100 * (val - val.toInt())).toInt().toString();
+ return '${val.floor()}.${(100 * (val - val.toInt())).toInt()}';
}
}
@@ -111,44 +107,44 @@
void blockCipherTest(int id, BlockCipher cipher, CipherParameters parameters,
String input, String output) {
test('BlockCipher Test: $id ', () {
- var _input = createUint8ListFromHexString(input);
- var _output = createUint8ListFromHexString(output);
+ var input0 = createUint8ListFromHexString(input);
+ var output0 = createUint8ListFromHexString(output);
cipher.init(true, parameters);
- var out = Uint8List(_input.length);
+ var out = Uint8List(input0.length);
var p = 0;
- while (p < _input.length) {
- p += cipher.processBlock(_input, p, out, p);
+ while (p < input0.length) {
+ p += cipher.processBlock(input0, p, out, p);
}
- expect(_output, equals(out), reason: '$id did not match output');
+ expect(output0, equals(out), reason: '$id did not match output');
cipher.init(false, parameters);
- out = Uint8List(_output.length);
+ out = Uint8List(output0.length);
p = 0;
- while (p < _output.length) {
- p += cipher.processBlock(_output, p, out, p);
+ while (p < output0.length) {
+ p += cipher.processBlock(output0, p, out, p);
}
- expect(_input, equals(out), reason: '$id did not match input');
+ expect(input0, equals(out), reason: '$id did not match input');
});
}
void streamCipherTest(int id, StreamCipher cipher, CipherParameters parameters,
String input, String output) {
test('StreamCipher Test: $id ', () {
- var _input = createUint8ListFromHexString(input);
- var _output = createUint8ListFromHexString(output);
+ var input0 = createUint8ListFromHexString(input);
+ var output0 = createUint8ListFromHexString(output);
cipher.init(true, parameters);
- var out = cipher.process(_input);
+ var out = cipher.process(input0);
- expect(_output, equals(out), reason: '$id did not match output');
+ expect(output0, equals(out), reason: '$id did not match output');
cipher.init(false, parameters);
out = cipher.process(out);
- expect(_input, equals(out), reason: '$id did not match input');
+ expect(input0, equals(out), reason: '$id did not match input');
});
}
diff --git a/test/test/src/null_asymmetric_block_cipher.dart b/test/test/src/null_asymmetric_block_cipher.dart
index 2d84859..34001e2 100644
--- a/test/test/src/null_asymmetric_block_cipher.dart
+++ b/test/test/src/null_asymmetric_block_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library impl.asymmetric_block_cipher.test.null_asymmetric_block_cipher;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/test/test/src/null_block_cipher.dart b/test/test/src/null_block_cipher.dart
index c2eb22f..22e678c 100644
--- a/test/test/src/null_block_cipher.dart
+++ b/test/test/src/null_block_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library impl.block_cipher.test.src.null_block_cipher;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/test/test/src/null_digest.dart b/test/test/src/null_digest.dart
index 97a8803..b845f5e 100644
--- a/test/test/src/null_digest.dart
+++ b/test/test/src/null_digest.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library impl.block_chipher.test.src.null_digest;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/test/test/src/null_secure_random.dart b/test/test/src/null_secure_random.dart
index b7a02ca..ac75759 100644
--- a/test/test/src/null_secure_random.dart
+++ b/test/test/src/null_secure_random.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library impl.secure_random.test.src.null_secure_random;
-
import 'package:pointycastle/api.dart';
import 'package:pointycastle/src/impl/secure_random_base.dart';
import 'package:pointycastle/src/registry/registry.dart';
diff --git a/test/test/src/null_stream_cipher.dart b/test/test/src/null_stream_cipher.dart
index c5a198f..b67bf26 100644
--- a/test/test/src/null_stream_cipher.dart
+++ b/test/test/src/null_stream_cipher.dart
@@ -1,7 +1,5 @@
// See file LICENSE for more information.
-library impl.stream_cipher.test.src.null_stream_cipher;
-
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
diff --git a/tutorials/aes-cbc.md b/tutorials/aes-cbc.md
index 36ab934..11d553d 100644
--- a/tutorials/aes-cbc.md
+++ b/tutorials/aes-cbc.md
@@ -46,7 +46,7 @@
Uint8List key, Uint8List iv, Uint8List paddedPlaintext) {
assert([128, 192, 256].contains(key.length * 8));
assert(128 == iv.length * 8);
- assert(128 == paddedPlaintext.length * 8);
+ assert(0 == paddedPlaintext.length % 16);
// Create a CBC block cipher with AES, and initialize with key and IV
@@ -69,7 +69,7 @@
Uint8List aesCbcDecrypt(Uint8List key, Uint8List iv, Uint8List cipherText) {
assert([128, 192, 256].contains(key.length * 8));
assert(128 == iv.length * 8);
- assert(128 == cipherText.length * 8);
+ assert(0 == cipherText.length % 16);
// Create a CBC block cipher with AES, and initialize with key and IV
diff --git a/tutorials/examples/aes-cbc-direct.dart b/tutorials/examples/aes-cbc-direct.dart
index 2a8000b..a22bb34 100644
--- a/tutorials/examples/aes-cbc-direct.dart
+++ b/tutorials/examples/aes-cbc-direct.dart
@@ -1,9 +1,9 @@
/// Encrypt and decrypt using AES
-
+///
/// Note: this example use Pointy Castle WITHOUT the registry.
+library;
import 'dart:convert';
-import 'dart:math';
import 'dart:typed_data';
import 'package:pointycastle/export.dart';
@@ -19,7 +19,7 @@
Uint8List key, Uint8List iv, Uint8List paddedPlaintext) {
assert([128, 192, 256].contains(key.length * 8));
assert(128 == iv.length * 8);
- assert(128 == paddedPlaintext.length * 8);
+ assert(0 == paddedPlaintext.length % 16);
// Create a CBC block cipher with AES, and initialize with key and IV
@@ -42,7 +42,7 @@
Uint8List aesCbcDecrypt(Uint8List key, Uint8List iv, Uint8List cipherText) {
assert([128, 192, 256].contains(key.length * 8));
assert(128 == iv.length * 8);
- assert(128 == cipherText.length * 8);
+ assert(0 == cipherText.length % 16);
// Create a CBC block cipher with AES, and initialize with key and IV
@@ -153,10 +153,9 @@
final numBytes = bitLength ~/ 8;
final kd = PBKDF2KeyDerivator(HMac(SHA256Digest(), 64)) // 64 for SHA-256
- ..init(
- Pbkdf2Parameters(utf8.encode(salt) as Uint8List, iterations, numBytes));
+ ..init(Pbkdf2Parameters(utf8.encode(salt), iterations, numBytes));
- return kd.process(utf8.encode(passPhrase) as Uint8List);
+ return kd.process(utf8.encode(passPhrase));
}
//----------------------------------------------------------------
@@ -188,7 +187,7 @@
void katTest() {
// Encryption tests
- [
+ for (var testCase in [
[
'CBCGFSbox128.rsp: encrypt 0',
'00000000000000000000000000000000', // key
@@ -231,7 +230,7 @@
'014730f80ac625fe84f026c60bfd547d',
'5c9d844ed46f9885085e5d6a4f94c7d7',
]
- ].forEach((testCase) {
+ ]) {
final name = testCase[0];
final key = testCase[1];
final iv = testCase[2];
@@ -243,11 +242,11 @@
print('$name: failed');
throw AssertionError('$name: failed');
}
- });
+ }
// Decryption tests
- [
+ for (var testCase in [
[
'CBCGFSbox128.rsp: decrypt 0',
'00000000000000000000000000000000', // key
@@ -269,7 +268,7 @@
'1bc704f1bce135ceb810341b216d7abe', // ciphertext
'91fbef2d15a97816060bee1feaa49afe', // plaintext
]
- ].forEach((testCase) {
+ ]) {
final name = testCase[0];
final key = testCase[1];
final iv = testCase[2];
@@ -281,7 +280,7 @@
print('$name: failed');
throw AssertionError('$name: failed');
}
- });
+ }
}
//----------------------------------------------------------------
@@ -313,7 +312,7 @@
final cipherText = aesCbcEncrypt(
passphraseToKey(passphrase, salt: randomSalt, bitLength: aesSize),
iv,
- pad(utf8.encode(textToEncrypt) as Uint8List, 16));
+ pad(utf8.encode(textToEncrypt), 16));
// If the encrypted data was to be stored or transmitted to the receiver,
// it will have to store the cipher-text, Initialization Vector (IV) and
diff --git a/tutorials/examples/aes-cbc-registry.dart b/tutorials/examples/aes-cbc-registry.dart
index 2129c8c..4afdc18 100644
--- a/tutorials/examples/aes-cbc-registry.dart
+++ b/tutorials/examples/aes-cbc-registry.dart
@@ -1,9 +1,9 @@
/// Encrypt and decrypt using AES
-
+///
/// Note: this example use Pointy Castle WITH the registry.
+library;
import 'dart:convert';
-import 'dart:math';
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -166,10 +166,9 @@
final numBytes = bitLength ~/ 8;
final kd = KeyDerivator('SHA-256/HMAC/PBKDF2')
- ..init(
- Pbkdf2Parameters(utf8.encode(salt) as Uint8List, iterations, numBytes));
+ ..init(Pbkdf2Parameters(utf8.encode(salt), iterations, numBytes));
- return kd.process(utf8.encode(passPhrase) as Uint8List);
+ return kd.process(utf8.encode(passPhrase));
}
//----------------------------------------------------------------
@@ -200,7 +199,7 @@
void katTest() {
// Encryption tests
- [
+ for (var testCase in [
[
'CBCGFSbox128.rsp: encrypt 0',
'00000000000000000000000000000000', // key
@@ -243,7 +242,7 @@
'014730f80ac625fe84f026c60bfd547d',
'5c9d844ed46f9885085e5d6a4f94c7d7',
]
- ].forEach((testCase) {
+ ]) {
final name = testCase[0];
final key = testCase[1];
final iv = testCase[2];
@@ -255,11 +254,11 @@
print('$name: failed');
throw AssertionError('$name: failed');
}
- });
+ }
// Decryption tests
- [
+ for (var testCase in [
[
'CBCGFSbox128.rsp: decrypt 0',
'00000000000000000000000000000000', // key
@@ -281,7 +280,7 @@
'1bc704f1bce135ceb810341b216d7abe', // ciphertext
'91fbef2d15a97816060bee1feaa49afe', // plaintext
]
- ].forEach((testCase) {
+ ]) {
final name = testCase[0];
final key = testCase[1];
final iv = testCase[2];
@@ -293,7 +292,7 @@
print('$name: failed');
throw AssertionError('$name: failed');
}
- });
+ }
}
//----------------------------------------------------------------
@@ -325,7 +324,7 @@
final cipherText = aesCbcEncrypt(
passphraseToKey(passphrase, salt: randomSalt, bitLength: aesSize),
iv,
- pad(utf8.encode(textToEncrypt) as Uint8List, 16));
+ pad(utf8.encode(textToEncrypt), 16));
// If the encrypted data was to be stored or transmitted to the receiver,
// it will have to store the cipher-text, Initialization Vector (IV) and
diff --git a/tutorials/examples/digest-direct.dart b/tutorials/examples/digest-direct.dart
index d2a997c..f0ba5dc 100644
--- a/tutorials/examples/digest-direct.dart
+++ b/tutorials/examples/digest-direct.dart
@@ -13,6 +13,7 @@
/// echo -n 'Hello world!' | shasum -a 256
///
/// Note: this example use Pointy Castle WITHOUT the registry.
+library;
import 'dart:convert';
import 'dart:typed_data';
@@ -39,7 +40,7 @@
for (final data in valuesToDigest) {
print('Data: "$data"');
- final hash = sha256Digest(utf8.encode(data) as Uint8List);
+ final hash = sha256Digest(utf8.encode(data));
print('SHA-256: $hash');
print('SHA-256: ${bin2hex(hash)}'); // output in hexadecimal
}
diff --git a/tutorials/examples/digest-registry.dart b/tutorials/examples/digest-registry.dart
index 02af975..f57eead 100644
--- a/tutorials/examples/digest-registry.dart
+++ b/tutorials/examples/digest-registry.dart
@@ -11,6 +11,7 @@
/// md5 -s 'Hello world!'
///
/// Note: this example use Pointy Castle WITH the registry.
+library;
import 'dart:convert';
import 'dart:typed_data';
diff --git a/tutorials/examples/hmac-direct.dart b/tutorials/examples/hmac-direct.dart
index 8234245..6f02e02 100644
--- a/tutorials/examples/hmac-direct.dart
+++ b/tutorials/examples/hmac-direct.dart
@@ -7,6 +7,7 @@
/// dart hmac-sha1.dart "mykey" "Hello world!"
///
/// Note: this example use Pointy Castle WITHOUT the registry.
+library;
import 'dart:convert';
import 'dart:typed_data';
diff --git a/tutorials/examples/hmac-registry.dart b/tutorials/examples/hmac-registry.dart
index d37ff52..0254935 100644
--- a/tutorials/examples/hmac-registry.dart
+++ b/tutorials/examples/hmac-registry.dart
@@ -7,6 +7,7 @@
/// dart hmac-sha256.dart "mykey" "Hello world!"
///
/// Note: this example use Pointy Castle WITH the registry.
+library;
import 'dart:convert';
import 'dart:typed_data';
diff --git a/tutorials/examples/import-demo/import-demo-1.dart b/tutorials/examples/import-demo/import-demo-1.dart
index 2cbeb1a..8b5d80c 100644
--- a/tutorials/examples/import-demo/import-demo-1.dart
+++ b/tutorials/examples/import-demo/import-demo-1.dart
@@ -17,9 +17,9 @@
/// but they can or cannot be used depending on what imports were used.
///
/// To see the differences between the examples, run 'diff' on the files.
+library;
import 'dart:convert';
-import 'dart:math';
import 'dart:typed_data';
import 'package:pointycastle/pointycastle.dart';
@@ -35,73 +35,72 @@
final sha1 = Digest('SHA-1');
final md5 = Digest('MD5');
- final _digest = sha256.process(Uint8List.fromList(_data));
+ final digest = sha256.process(Uint8List.fromList(_data));
final hmacSha256 = Mac('SHA-256/HMAC');
final hmacSha512 = Mac('SHA-512/HMAC');
final hmacMd5 = Mac('MD5/HMAC');
- final _hmacValue = hmacSha256.process(Uint8List.fromList(_data));
+ final hmacValue = hmacSha256.process(Uint8List.fromList(_data));
//final kd = KeyDerivator('SHA-256/HMAC/PBKDF2');
- final _sGen = Random.secure();
- final _seed = Platform.instance.platformEntropySource().getBytes(32);
- final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(_seed));
+ final seed = Platform.instance.platformEntropySource().getBytes(32);
+ final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(seed));
// AES-CBC encryption
- final _salt = secRnd.nextBytes(32);
+ final salt = secRnd.nextBytes(32);
final keyDerivator256 = KeyDerivator('SHA-256/HMAC/PBKDF2')
- ..init(Pbkdf2Parameters(_salt, 10000, 256 ~/ 8));
+ ..init(Pbkdf2Parameters(salt, 10000, 256 ~/ 8));
final aes256key = keyDerivator256.process(Uint8List.fromList(_secret));
- final _iv = secRnd.nextBytes(128 ~/ 8);
+ final iv = secRnd.nextBytes(128 ~/ 8);
final aesCbc = BlockCipher('AES/CBC')
- ..init(true, ParametersWithIV(KeyParameter(aes256key), _iv));
+ ..init(true, ParametersWithIV(KeyParameter(aes256key), iv));
- final _paddedData = Uint8List(
+ final paddedData = Uint8List(
_data.length + (aesCbc.blockSize - (_data.length % aesCbc.blockSize)))
..setAll(0, _data);
- Padding('PKCS7').addPadding(_paddedData, _data.length);
+ Padding('PKCS7').addPadding(paddedData, _data.length);
- final _ciphertext = aesCbc.process(_paddedData);
+ final ciphertext = aesCbc.process(paddedData);
// RSA key generation and signing
final keyGen = KeyGenerator('RSA');
keyGen.init(ParametersWithRandom(
RSAKeyGeneratorParameters(BigInt.parse('65537'), 2048, 64), secRnd));
- final _pair = keyGen.generateKeyPair();
+ final pair = keyGen.generateKeyPair();
final signer = Signer('SHA-256/RSA')
- ..init(true, PrivateKeyParameter<RSAPrivateKey>(_pair.privateKey));
+ ..init(true, PrivateKeyParameter<RSAPrivateKey>(pair.privateKey));
- final _signature =
+ final signature =
signer.generateSignature(Uint8List.fromList(_data)) as RSASignature;
final verifier = Signer('SHA-256/RSA')
- ..init(false, PublicKeyParameter<RSAPublicKey>(_pair.publicKey));
- final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature);
+ ..init(false, PublicKeyParameter<RSAPublicKey>(pair.publicKey));
+ final sigOk = verifier.verifySignature(Uint8List.fromList(_data), signature);
print('''
Data: '${utf8.decode(_data)}'
-SHA-256: ${bin2hex(_digest)}
+SHA-256: ${bin2hex(digest)}
SHA-1: ${bin2hex(sha1.process(Uint8List.fromList(_data)))}
MD5: ${bin2hex(md5.process(Uint8List.fromList(_data)), separator: ':')}
-HMAC-SHA256: ${bin2hex(_hmacValue)}
+HMAC-SHA256: ${bin2hex(hmacValue)}
HMAC-512: ${bin2hex(hmacSha512.process(Uint8List.fromList(_data)))}
HMAC-MD5: ${bin2hex(hmacMd5.process(Uint8List.fromList(_data)))}
AES-CBC ciphertext:
-${bin2hex(_ciphertext, wrap: 64)}
+${bin2hex(ciphertext, wrap: 64)}
Signature:
-${bin2hex(_signature.bytes, wrap: 64)}
+${bin2hex(signature.bytes, wrap: 64)}
Verifies: $sigOk
''');
}
diff --git a/tutorials/examples/import-demo/import-demo-2.dart b/tutorials/examples/import-demo/import-demo-2.dart
index 909dbb8..6aa48d4 100644
--- a/tutorials/examples/import-demo/import-demo-2.dart
+++ b/tutorials/examples/import-demo/import-demo-2.dart
@@ -17,9 +17,9 @@
/// but they can or cannot be used depending on what imports were used.
///
/// To see the differences between the examples, run 'diff' on the files.
+library;
import 'dart:convert';
-import 'dart:math';
import 'dart:typed_data';
import 'package:pointycastle/export.dart';
@@ -35,73 +35,72 @@
final sha1 = Digest('SHA-1');
final md5 = Digest('MD5');
- final _digest = sha256.process(Uint8List.fromList(_data));
+ final digest = sha256.process(Uint8List.fromList(_data));
final hmacSha256 = Mac('SHA-256/HMAC');
final hmacSha512 = Mac('SHA-512/HMAC');
final hmacMd5 = Mac('MD5/HMAC');
- final _hmacValue = hmacSha256.process(Uint8List.fromList(_data));
+ final hmacValue = hmacSha256.process(Uint8List.fromList(_data));
//final kd = KeyDerivator('SHA-256/HMAC/PBKDF2');
- final _sGen = Random.secure();
- final _seed = Platform.instance.platformEntropySource().getBytes(32);
- final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(_seed));
+ final seed = Platform.instance.platformEntropySource().getBytes(32);
+ final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(seed));
// AES-CBC encryption
- final _salt = secRnd.nextBytes(32);
+ final salt = secRnd.nextBytes(32);
final keyDerivator256 = KeyDerivator('SHA-256/HMAC/PBKDF2')
- ..init(Pbkdf2Parameters(_salt, 10000, 256 ~/ 8));
+ ..init(Pbkdf2Parameters(salt, 10000, 256 ~/ 8));
final aes256key = keyDerivator256.process(Uint8List.fromList(_secret));
- final _iv = secRnd.nextBytes(128 ~/ 8);
+ final iv = secRnd.nextBytes(128 ~/ 8);
final aesCbc = BlockCipher('AES/CBC')
- ..init(true, ParametersWithIV(KeyParameter(aes256key), _iv));
+ ..init(true, ParametersWithIV(KeyParameter(aes256key), iv));
- final _paddedData = Uint8List(
+ final paddedData = Uint8List(
_data.length + (aesCbc.blockSize - (_data.length % aesCbc.blockSize)))
..setAll(0, _data);
- Padding('PKCS7').addPadding(_paddedData, _data.length);
+ Padding('PKCS7').addPadding(paddedData, _data.length);
- final _ciphertext = aesCbc.process(_paddedData);
+ final ciphertext = aesCbc.process(paddedData);
// RSA key generation and signing
final keyGen = KeyGenerator('RSA');
keyGen.init(ParametersWithRandom(
RSAKeyGeneratorParameters(BigInt.parse('65537'), 2048, 64), secRnd));
- final _pair = keyGen.generateKeyPair();
+ final pair = keyGen.generateKeyPair();
final signer = Signer('SHA-256/RSA')
- ..init(true, PrivateKeyParameter<RSAPrivateKey>(_pair.privateKey));
+ ..init(true, PrivateKeyParameter<RSAPrivateKey>(pair.privateKey));
- final _signature =
+ final signature =
signer.generateSignature(Uint8List.fromList(_data)) as RSASignature;
final verifier = Signer('SHA-256/RSA')
- ..init(false, PublicKeyParameter<RSAPublicKey>(_pair.publicKey));
- final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature);
+ ..init(false, PublicKeyParameter<RSAPublicKey>(pair.publicKey));
+ final sigOk = verifier.verifySignature(Uint8List.fromList(_data), signature);
print('''
Data: '${utf8.decode(Uint8List.fromList(_data))}'
-SHA-256: ${bin2hex(_digest)}
+SHA-256: ${bin2hex(digest)}
SHA-1: ${bin2hex(sha1.process(Uint8List.fromList(_data)))}
MD5: ${bin2hex(md5.process(Uint8List.fromList(_data)), separator: ':')}
-HMAC-SHA256: ${bin2hex(_hmacValue)}
+HMAC-SHA256: ${bin2hex(hmacValue)}
HMAC-512: ${bin2hex(hmacSha512.process(Uint8List.fromList(_data)))}
HMAC-MD5: ${bin2hex(hmacMd5.process(Uint8List.fromList(_data)))}
AES-CBC ciphertext:
-${bin2hex(_ciphertext, wrap: 64)}
+${bin2hex(ciphertext, wrap: 64)}
Signature:
-${bin2hex(_signature.bytes, wrap: 64)}
+${bin2hex(signature.bytes, wrap: 64)}
Verifies: $sigOk
''');
}
@@ -113,7 +112,7 @@
final sha1 = SHA1Digest();
final md5 = MD5Digest();
- final _digest = sha256.process(Uint8List.fromList(_data));
+ final digest = sha256.process(Uint8List.fromList(_data));
// HMAC
@@ -124,66 +123,65 @@
final hmacMd5 = HMac(MD5Digest(), 64)
..init(KeyParameter(Uint8List.fromList(_secret)));
- final _hmacValue = hmacSha256.process(Uint8List.fromList(_data));
+ final hmacValue = hmacSha256.process(Uint8List.fromList(_data));
// Secure random number generator
- final _sGen = Random.secure();
- final _seed = Platform.instance.platformEntropySource().getBytes(32);
- final secRnd = FortunaRandom()..seed(KeyParameter(_seed));
+ final seed = Platform.instance.platformEntropySource().getBytes(32);
+ final secRnd = FortunaRandom()..seed(KeyParameter(seed));
// AES-CBC encryption
- final _salt = secRnd.nextBytes(32);
+ final salt = secRnd.nextBytes(32);
final keyDerivator256 = PBKDF2KeyDerivator(HMac(SHA256Digest(), 64))
- ..init(Pbkdf2Parameters(_salt, 10000, 256 ~/ 8));
+ ..init(Pbkdf2Parameters(salt, 10000, 256 ~/ 8));
final aes256key = keyDerivator256.process(Uint8List.fromList(_secret));
- final _iv = secRnd.nextBytes(128 ~/ 8);
+ final iv = secRnd.nextBytes(128 ~/ 8);
final aesCbc = CBCBlockCipher(AESEngine())
- ..init(true, ParametersWithIV(KeyParameter(aes256key), _iv));
+ ..init(true, ParametersWithIV(KeyParameter(aes256key), iv));
- final _paddedData = Uint8List(
+ final paddedData = Uint8List(
_data.length + (aesCbc.blockSize - (_data.length % aesCbc.blockSize)))
..setAll(0, _data);
- PKCS7Padding().addPadding(_paddedData, _data.length);
+ PKCS7Padding().addPadding(paddedData, _data.length);
- final _ciphertext = aesCbc.process(_paddedData);
+ final ciphertext = aesCbc.process(paddedData);
// RSA key generation and signing
final keyGen = RSAKeyGenerator();
keyGen.init(ParametersWithRandom(
RSAKeyGeneratorParameters(BigInt.parse('65537'), 2048, 64), secRnd));
- final _pair = keyGen.generateKeyPair();
+ final pair = keyGen.generateKeyPair();
final signer = RSASigner(SHA256Digest(), '0609608648016503040201')
- ..init(true, PrivateKeyParameter<RSAPrivateKey>(_pair.privateKey));
+ ..init(true, PrivateKeyParameter<RSAPrivateKey>(pair.privateKey));
- final _signature = signer.generateSignature(Uint8List.fromList(_data));
+ final signature = signer.generateSignature(Uint8List.fromList(_data));
final verifier = RSASigner(SHA256Digest(), '0609608648016503040201')
- ..init(false, PublicKeyParameter<RSAPublicKey>(_pair.publicKey));
- final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature);
+ ..init(false, PublicKeyParameter<RSAPublicKey>(pair.publicKey));
+ final sigOk = verifier.verifySignature(Uint8List.fromList(_data), signature);
print('''
Data: '${utf8.decode(Uint8List.fromList(_data))}'
-SHA-256: ${bin2hex(_digest)}
+SHA-256: ${bin2hex(digest)}
SHA-1: ${bin2hex(sha1.process(Uint8List.fromList(_data)))}
MD5: ${bin2hex(md5.process(Uint8List.fromList(_data)), separator: ':')}
-HMAC-SHA256: ${bin2hex(_hmacValue)}
+HMAC-SHA256: ${bin2hex(hmacValue)}
HMAC-512: ${bin2hex(hmacSha512.process(Uint8List.fromList(_data)))}
HMAC-MD5: ${bin2hex(hmacMd5.process(Uint8List.fromList(_data)))}
AES-CBC ciphertext:
-${bin2hex(_ciphertext, wrap: 64)}
+${bin2hex(ciphertext, wrap: 64)}
Signature:
-${bin2hex(_signature.bytes, wrap: 64)}
+${bin2hex(signature.bytes, wrap: 64)}
Verifies: $sigOk
''');
}
diff --git a/tutorials/examples/import-demo/import-demo-3.dart b/tutorials/examples/import-demo/import-demo-3.dart
index 6addc21..af93f00 100644
--- a/tutorials/examples/import-demo/import-demo-3.dart
+++ b/tutorials/examples/import-demo/import-demo-3.dart
@@ -17,8 +17,9 @@
/// but they can or cannot be used depending on what imports were used.
///
/// To see the differences between the examples, run 'diff' on the files.
+library;
+
import 'dart:convert';
-import 'dart:math';
import 'dart:typed_data';
import 'package:pointycastle/api.dart';
@@ -49,73 +50,72 @@
final sha1 = Digest('SHA-1');
final md5 = Digest('MD5');
- final _digest = sha256.process(Uint8List.fromList(_data));
+ final digest = sha256.process(Uint8List.fromList(_data));
final hmacSha256 = Mac('SHA-256/HMAC');
final hmacSha512 = Mac('SHA-512/HMAC');
final hmacMd5 = Mac('MD5/HMAC');
- final _hmacValue = hmacSha256.process(Uint8List.fromList(_data));
+ final hmacValue = hmacSha256.process(Uint8List.fromList(_data));
//final kd = KeyDerivator('SHA-256/HMAC/PBKDF2');
- final _sGen = Random.secure();
- final _seed = Platform.instance.platformEntropySource().getBytes(32);
- final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(_seed));
+ final seed = Platform.instance.platformEntropySource().getBytes(32);
+ final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(seed));
// AES-CBC encryption
- final _salt = secRnd.nextBytes(32);
+ final salt = secRnd.nextBytes(32);
final keyDerivator256 = KeyDerivator('SHA-256/HMAC/PBKDF2')
- ..init(Pbkdf2Parameters(_salt, 10000, 256 ~/ 8));
+ ..init(Pbkdf2Parameters(salt, 10000, 256 ~/ 8));
final aes256key = keyDerivator256.process(Uint8List.fromList(_secret));
- final _iv = secRnd.nextBytes(128 ~/ 8);
+ final iv = secRnd.nextBytes(128 ~/ 8);
final aesCbc = BlockCipher('AES/CBC')
- ..init(true, ParametersWithIV(KeyParameter(aes256key), _iv));
+ ..init(true, ParametersWithIV(KeyParameter(aes256key), iv));
- final _paddedData = Uint8List(
+ final paddedData = Uint8List(
_data.length + (aesCbc.blockSize - (_data.length % aesCbc.blockSize)))
..setAll(0, _data);
- Padding('PKCS7').addPadding(_paddedData, _data.length);
+ Padding('PKCS7').addPadding(paddedData, _data.length);
- final _ciphertext = aesCbc.process(_paddedData);
+ final ciphertext = aesCbc.process(paddedData);
// RSA key generation and signing
final keyGen = KeyGenerator('RSA');
keyGen.init(ParametersWithRandom(
RSAKeyGeneratorParameters(BigInt.parse('65537'), 2048, 64), secRnd));
- final _pair = keyGen.generateKeyPair();
+ final pair = keyGen.generateKeyPair();
final signer = Signer('SHA-256/RSA')
- ..init(true, PrivateKeyParameter<RSAPrivateKey>(_pair.privateKey));
+ ..init(true, PrivateKeyParameter<RSAPrivateKey>(pair.privateKey));
- final _signature =
+ final signature =
signer.generateSignature(Uint8List.fromList(_data)) as RSASignature;
final verifier = Signer('SHA-256/RSA')
- ..init(false, PublicKeyParameter<RSAPublicKey>(_pair.publicKey));
- final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature);
+ ..init(false, PublicKeyParameter<RSAPublicKey>(pair.publicKey));
+ final sigOk = verifier.verifySignature(Uint8List.fromList(_data), signature);
print('''
Data: '${utf8.decode(_data)}'
-SHA-256: ${bin2hex(_digest)}
+SHA-256: ${bin2hex(digest)}
SHA-1: ${bin2hex(sha1.process(Uint8List.fromList(_data)))}
MD5: ${bin2hex(md5.process(Uint8List.fromList(_data)), separator: ':')}
-HMAC-SHA256: ${bin2hex(_hmacValue)}
+HMAC-SHA256: ${bin2hex(hmacValue)}
HMAC-512: ${bin2hex(hmacSha512.process(Uint8List.fromList(_data)))}
HMAC-MD5: ${bin2hex(hmacMd5.process(Uint8List.fromList(_data)))}
AES-CBC ciphertext:
-${bin2hex(_ciphertext, wrap: 64)}
+${bin2hex(ciphertext, wrap: 64)}
Signature:
-${bin2hex(_signature.bytes, wrap: 64)}
+${bin2hex(signature.bytes, wrap: 64)}
Verifies: $sigOk
''');
}
@@ -127,7 +127,7 @@
final sha1 = SHA1Digest();
final md5 = MD5Digest();
- final _digest = sha256.process(Uint8List.fromList(_data));
+ final digest = sha256.process(Uint8List.fromList(_data));
// HMAC
@@ -138,66 +138,65 @@
final hmacMd5 = HMac(MD5Digest(), 64)
..init(KeyParameter(Uint8List.fromList(_secret)));
- final _hmacValue = hmacSha256.process(Uint8List.fromList(_data));
+ final hmacValue = hmacSha256.process(Uint8List.fromList(_data));
// Secure random number generator
- final _sGen = Random.secure();
- final _seed = Platform.instance.platformEntropySource().getBytes(32);
- final secRnd = FortunaRandom()..seed(KeyParameter(_seed));
+ final seed = Platform.instance.platformEntropySource().getBytes(32);
+ final secRnd = FortunaRandom()..seed(KeyParameter(seed));
// AES-CBC encryption
- final _salt = secRnd.nextBytes(32);
+ final salt = secRnd.nextBytes(32);
final keyDerivator256 = PBKDF2KeyDerivator(HMac(SHA256Digest(), 64))
- ..init(Pbkdf2Parameters(_salt, 10000, 256 ~/ 8));
+ ..init(Pbkdf2Parameters(salt, 10000, 256 ~/ 8));
final aes256key = keyDerivator256.process(Uint8List.fromList(_secret));
- final _iv = secRnd.nextBytes(128 ~/ 8);
+ final iv = secRnd.nextBytes(128 ~/ 8);
final aesCbc = CBCBlockCipher(AESEngine())
- ..init(true, ParametersWithIV(KeyParameter(aes256key), _iv));
+ ..init(true, ParametersWithIV(KeyParameter(aes256key), iv));
- final _paddedData = Uint8List(
+ final paddedData = Uint8List(
_data.length + (aesCbc.blockSize - (_data.length % aesCbc.blockSize)))
..setAll(0, _data);
- PKCS7Padding().addPadding(_paddedData, _data.length);
+ PKCS7Padding().addPadding(paddedData, _data.length);
- final _ciphertext = aesCbc.process(_paddedData);
+ final ciphertext = aesCbc.process(paddedData);
// RSA key generation and signing
final keyGen = RSAKeyGenerator();
keyGen.init(ParametersWithRandom(
RSAKeyGeneratorParameters(BigInt.parse('65537'), 2048, 64), secRnd));
- final _pair = keyGen.generateKeyPair();
+ final pair = keyGen.generateKeyPair();
final signer = RSASigner(SHA256Digest(), '0609608648016503040201')
- ..init(true, PrivateKeyParameter<RSAPrivateKey>(_pair.privateKey));
+ ..init(true, PrivateKeyParameter<RSAPrivateKey>(pair.privateKey));
- final _signature = signer.generateSignature(Uint8List.fromList(_data));
+ final signature = signer.generateSignature(Uint8List.fromList(_data));
final verifier = RSASigner(SHA256Digest(), '0609608648016503040201')
- ..init(false, PublicKeyParameter<RSAPublicKey>(_pair.publicKey));
- final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature);
+ ..init(false, PublicKeyParameter<RSAPublicKey>(pair.publicKey));
+ final sigOk = verifier.verifySignature(Uint8List.fromList(_data), signature);
print('''
Data: '${utf8.decode(_data)}'
-SHA-256: ${bin2hex(_digest)}
+SHA-256: ${bin2hex(digest)}
SHA-1: ${bin2hex(sha1.process(Uint8List.fromList(_data)))}
MD5: ${bin2hex(md5.process(Uint8List.fromList(_data)), separator: ':')}
-HMAC-SHA256: ${bin2hex(_hmacValue)}
+HMAC-SHA256: ${bin2hex(hmacValue)}
HMAC-512: ${bin2hex(hmacSha512.process(Uint8List.fromList(_data)))}
HMAC-MD5: ${bin2hex(hmacMd5.process(Uint8List.fromList(_data)))}
AES-CBC ciphertext:
-${bin2hex(_ciphertext, wrap: 64)}
+${bin2hex(ciphertext, wrap: 64)}
Signature:
-${bin2hex(_signature.bytes, wrap: 64)}
+${bin2hex(signature.bytes, wrap: 64)}
Verifies: $sigOk
''');
}
diff --git a/tutorials/examples/import-demo/import-demo-4.dart b/tutorials/examples/import-demo/import-demo-4.dart
index 21da504..558a805 100644
--- a/tutorials/examples/import-demo/import-demo-4.dart
+++ b/tutorials/examples/import-demo/import-demo-4.dart
@@ -17,10 +17,11 @@
/// but they can or cannot be used depending on what imports were used.
///
/// To see the differences between the examples, run 'diff' on the files.
+library;
import 'dart:convert';
-import 'dart:math';
import 'dart:typed_data';
+
import 'package:pointycastle/api.dart';
import 'package:pointycastle/asymmetric/api.dart';
import 'package:pointycastle/key_derivators/api.dart';
@@ -44,73 +45,72 @@
final sha1 = Digest('SHA-1');
final md5 = Digest('MD5');
- final _digest = sha256.process(Uint8List.fromList(_data));
+ final digest = sha256.process(Uint8List.fromList(_data));
final hmacSha256 = Mac('SHA-256/HMAC');
final hmacSha512 = Mac('SHA-512/HMAC');
final hmacMd5 = Mac('MD5/HMAC');
- final _hmacValue = hmacSha256.process(Uint8List.fromList(_data));
+ final hmacValue = hmacSha256.process(Uint8List.fromList(_data));
//final kd = KeyDerivator('SHA-256/HMAC/PBKDF2');
- final _sGen = Random.secure();
- final _seed = Platform.instance.platformEntropySource().getBytes(32);
- final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(_seed));
+ final seed = Platform.instance.platformEntropySource().getBytes(32);
+ final secRnd = SecureRandom('Fortuna')..seed(KeyParameter(seed));
// AES-CBC encryption
- final _salt = secRnd.nextBytes(32);
+ final salt = secRnd.nextBytes(32);
final keyDerivator256 = KeyDerivator('SHA-256/HMAC/PBKDF2')
- ..init(Pbkdf2Parameters(_salt, 10000, 256 ~/ 8));
+ ..init(Pbkdf2Parameters(salt, 10000, 256 ~/ 8));
final aes256key = keyDerivator256.process(Uint8List.fromList(_secret));
- final _iv = secRnd.nextBytes(128 ~/ 8);
+ final iv = secRnd.nextBytes(128 ~/ 8);
final aesCbc = BlockCipher('AES/CBC')
- ..init(true, ParametersWithIV(KeyParameter(aes256key), _iv));
+ ..init(true, ParametersWithIV(KeyParameter(aes256key), iv));
- final _paddedData = Uint8List(
+ final paddedData = Uint8List(
_data.length + (aesCbc.blockSize - (_data.length % aesCbc.blockSize)))
..setAll(0, _data);
- Padding('PKCS7').addPadding(_paddedData, _data.length);
+ Padding('PKCS7').addPadding(paddedData, _data.length);
- final _ciphertext = aesCbc.process(_paddedData);
+ final ciphertext = aesCbc.process(paddedData);
// RSA key generation and signing
final keyGen = KeyGenerator('RSA');
keyGen.init(ParametersWithRandom(
RSAKeyGeneratorParameters(BigInt.parse('65537'), 2048, 64), secRnd));
- final _pair = keyGen.generateKeyPair();
+ final pair = keyGen.generateKeyPair();
final signer = Signer('SHA-256/RSA')
- ..init(true, PrivateKeyParameter<RSAPrivateKey>(_pair.privateKey));
+ ..init(true, PrivateKeyParameter<RSAPrivateKey>(pair.privateKey));
- final _signature =
+ final signature =
signer.generateSignature(Uint8List.fromList(_data)) as RSASignature;
final verifier = Signer('SHA-256/RSA')
- ..init(false, PublicKeyParameter<RSAPublicKey>(_pair.publicKey));
- final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature);
+ ..init(false, PublicKeyParameter<RSAPublicKey>(pair.publicKey));
+ final sigOk = verifier.verifySignature(Uint8List.fromList(_data), signature);
print('''
Data: '${utf8.decode(_data)}'
-SHA-256: ${bin2hex(_digest)}
+SHA-256: ${bin2hex(digest)}
SHA-1: ${bin2hex(sha1.process(Uint8List.fromList(_data)))}
MD5: ${bin2hex(md5.process(Uint8List.fromList(_data)), separator: ':')}
-HMAC-SHA256: ${bin2hex(_hmacValue)}
+HMAC-SHA256: ${bin2hex(hmacValue)}
HMAC-512: ${bin2hex(hmacSha512.process(Uint8List.fromList(_data)))}
HMAC-MD5: ${bin2hex(hmacMd5.process(Uint8List.fromList(_data)))}
AES-CBC ciphertext:
-${bin2hex(_ciphertext, wrap: 64)}
+${bin2hex(ciphertext, wrap: 64)}
Signature:
-${bin2hex(_signature.bytes, wrap: 64)}
+${bin2hex(signature.bytes, wrap: 64)}
Verifies: $sigOk
''');
}
diff --git a/tutorials/examples/oid-util.dart b/tutorials/examples/oid-util.dart
index e308423..0087881 100644
--- a/tutorials/examples/oid-util.dart
+++ b/tutorials/examples/oid-util.dart
@@ -9,6 +9,7 @@
///
/// This program was written to check some of the "magic values" in the
/// Pointy Castle source code.
+library;
import 'dart:typed_data';
@@ -124,7 +125,7 @@
throw const FormatException('incomplete OID content');
}
if ((contentStart + contentLength) < bytes.length) {
- throw const FormatException(('extra bytes after OID'));
+ throw const FormatException('extra bytes after OID');
}
return components;
@@ -180,13 +181,13 @@
if (bytes.length - 2 < 127) {
// Length can be represented by a single byte: use the bytes as the result
- bytes[1] = (bytes.length - 2);
+ bytes[1] = bytes.length - 2;
return Uint8List.fromList(bytes);
} else {
// Length needs multiple bytes: create bigger list and copy the bytes to it
final lengthEnc = <int>[]; // first encode the length (temporary LSB order)
- var v = (bytes.length - 2);
+ var v = bytes.length - 2;
while (0 < v) {
lengthEnc.add(v & 0x7F);
v >>= 7;
diff --git a/tutorials/examples/rsa-demo.dart b/tutorials/examples/rsa-demo.dart
index 68dfab5..a4556c1 100644
--- a/tutorials/examples/rsa-demo.dart
+++ b/tutorials/examples/rsa-demo.dart
@@ -6,6 +6,7 @@
///
/// Invoke with "-v" to print extra information.
/// Invoke with "-l" to use longer plaintext.
+library;
import 'dart:convert';
import 'dart:typed_data';
@@ -408,7 +409,7 @@
// Use the key pair
- final plaintext = (longText) ? longPlaintext : shortPlaintext;
+ final plaintext = longText ? longPlaintext : shortPlaintext;
if (verbose) {
print('Plaintext: $plaintext\n');
}