diff --git a/.github/workflows/chrome.workflow.yml b/.github/workflows/chrome.workflow.yml index b8e3f9fe..4cdee531 100644 --- a/.github/workflows/chrome.workflow.yml +++ b/.github/workflows/chrome.workflow.yml @@ -31,4 +31,4 @@ jobs: run: dart pub get - name: Test chrome - run: dart pub run test -p chrome + run: dart pub run test -j 1 -p chrome diff --git a/CHANGELOG.md b/CHANGELOG.md index 21790726..0bcd3d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +#### Version 3.7.4 (2024-01-11) + +* Support the latest version of `package:js`. +* Require Dart v3.0 + #### 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 d4fcc1ad..130172cb 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 c3e79a7c..a9a36a70 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 2a019d6d..fbaf7fb7 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 c8545835..ee7d712b 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 faaebafe..74903b2f 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 @@ class OperationBenchmark extends BenchmarkBase { 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 b9df7b00..b7d78e4e 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 @@ abstract class RateBenchmark extends BenchmarkBase { 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 a3f232c7..94f4ba14 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 22208dd3..c316256a 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 a08fa655..ddff9750 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 e4496674..38195180 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 3862b2ac..1e77224c 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 4e9fbc1f..28f3862b 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 be2ff014..5eddb9bf 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 81cabdc5..382cb08a 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 a09a8759..8994cc5c 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 c98bbf9f..7d2e4eb5 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 c732a38e..f03d4881 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 df44fef8..93deb6fd 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 56da90e5..5cf4ca7d 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 4e01049a..b0ff8251 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 7d77fe58..024c1f49 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 ce0a31d6..1084e484 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 d00b1993..c41bfd23 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 e3c3e921..a5b85cac 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 ee0ad4d4..5c07b61a 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 7774a82b..62e02f67 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 07168923..4ac67381 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 @@ void main() { var pubk = RSAPublicKey(modulus, publicExponent); var privk = RSAPrivateKey(modulus, privateExponent, p, q); - // ignore: unused_local_variable - var pubParamsFactory = () => ParametersWithRandom( - PublicKeyParameter(pubk), NullSecureRandom()); - var privParamsFactory = () => ParametersWithRandom( - PrivateKeyParameter(privk), NullSecureRandom()); + // ignore: unused_element + ParametersWithRandom> pubParamsFactory() => + ParametersWithRandom( + PublicKeyParameter(pubk), NullSecureRandom()); + ParametersWithRandom> + privParamsFactory() => ParametersWithRandom( + PrivateKeyParameter(privk), NullSecureRandom()); SignerBenchmark('Null/RSA', true, privParamsFactory).report(); } diff --git a/benchmark/src/ufixnum_benchmark.dart b/benchmark/src/ufixnum_benchmark.dart index f3ecaba0..d01f611d 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 0c78a050..355a7cff 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 298948f3..352a25e6 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_iv.dart'; 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 ff860fcd..55884043 100644 --- a/lib/asn1/asn1_parser.dart +++ b/lib/asn1/asn1_parser.dart @@ -57,7 +57,13 @@ class ASN1Parser { 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 (_position < length + valueStartPosition) { length = length + valueStartPosition; } else { length = bytes!.length - _position; @@ -83,7 +89,8 @@ class ASN1Parser { } // 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 13c15604..1cd86637 100644 --- a/lib/asn1/asn1_utils.dart +++ b/lib/asn1/asn1_utils.dart @@ -47,7 +47,7 @@ class ASN1Utils { 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 @@ class ASN1Utils { 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 @@ class ASN1Utils { {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 @@ class ASN1Utils { 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 @@ class ASN1Utils { 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/pkcs/pkcs10/asn1_certification_request.dart b/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart index 7e49fe24..afe19708 100644 --- a/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart +++ b/lib/asn1/pkcs/pkcs10/asn1_certification_request.dart @@ -26,13 +26,13 @@ class ASN1CertificationRequest extends ASN1Object { 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 6ec6f45f..ff7e9663 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 @@ class ASN1CertificationRequestInfo extends ASN1Object { 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 fbebff5e..44000225 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 @@ class ASN1SubjectPublicKeyInfo extends ASN1Object { 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 9e75dc5e..7874bc09 100644 --- a/lib/asn1/pkcs/pkcs12/asn1_authenticated_safe.dart +++ b/lib/asn1/pkcs/pkcs12/asn1_authenticated_safe.dart @@ -16,11 +16,9 @@ class ASN1AuthenticatedSafe extends ASN1Object { 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 22d7285c..fef3c6b0 100644 --- a/lib/asn1/pkcs/pkcs12/asn1_cert_bag.dart +++ b/lib/asn1/pkcs/pkcs12/asn1_cert_bag.dart @@ -30,19 +30,17 @@ class ASN1CertBag extends ASN1Object { /// /// 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 f626b8d0..54aea594 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 @@ class ASN1SafeContents extends ASN1Object { 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 203fb433..f15e20e2 100644 --- a/lib/asn1/primitives/asn1_bit_string.dart +++ b/lib/asn1/primitives/asn1_bit_string.dart @@ -37,7 +37,7 @@ class ASN1BitString extends ASN1Object { /// /// 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 @@ class ASN1BitString extends ASN1Object { 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 @@ class ASN1BitString extends ASN1Object { /// 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 @@ class ASN1BitString extends ASN1Object { 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 @@ class ASN1BitString extends ASN1Object { 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 0e4cb399..0b9d190e 100644 --- a/lib/asn1/primitives/asn1_bmp_string.dart +++ b/lib/asn1/primitives/asn1_bmp_string.dart @@ -92,11 +92,11 @@ class ASN1BMPString extends ASN1Object { 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 +110,9 @@ class ASN1BMPString extends ASN1Object { /// 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 3b2f4f0a..6eb00568 100644 --- a/lib/asn1/primitives/asn1_boolean.dart +++ b/lib/asn1/primitives/asn1_boolean.dart @@ -29,8 +29,7 @@ class ASN1Boolean extends ASN1Object { /// /// 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 ca19dd79..d8fc6730 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 @@ class ASN1Enumerated extends ASN1Integer { /// /// 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 6685d0ac..58f75bee 100644 --- a/lib/asn1/primitives/asn1_generalized_time.dart +++ b/lib/asn1/primitives/asn1_generalized_time.dart @@ -19,7 +19,7 @@ class ASN1GeneralizedTime extends ASN1Object { /// /// 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 0a514b39..7adcff6c 100644 --- a/lib/asn1/primitives/asn1_ia5_string.dart +++ b/lib/asn1/primitives/asn1_ia5_string.dart @@ -83,11 +83,11 @@ class ASN1IA5String extends ASN1Object { 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 @@ class ASN1IA5String extends ASN1Object { /// 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 c30f3699..2e936eb6 100644 --- a/lib/asn1/primitives/asn1_integer.dart +++ b/lib/asn1/primitives/asn1_integer.dart @@ -27,8 +27,7 @@ class ASN1Integer extends ASN1Object { /// /// 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 f2e304bd..b626c407 100644 --- a/lib/asn1/primitives/asn1_null.dart +++ b/lib/asn1/primitives/asn1_null.dart @@ -17,7 +17,7 @@ class ASN1Null extends ASN1Object { /// /// 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 6967ad4d..76b9ecdd 100644 --- a/lib/asn1/primitives/asn1_object_identifier.dart +++ b/lib/asn1/primitives/asn1_object_identifier.dart @@ -35,14 +35,14 @@ class ASN1ObjectIdentifier extends ASN1Object { /// /// 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 = []; 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 @@ class ASN1ObjectIdentifier extends ASN1Object { } } 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 5c1bc943..d518655a 100644 --- a/lib/asn1/primitives/asn1_octet_string.dart +++ b/lib/asn1/primitives/asn1_octet_string.dart @@ -80,11 +80,11 @@ class ASN1OctetString extends ASN1Object { 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 @@ class ASN1OctetString extends ASN1Object { /// 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 a6c7cdaf..f12c897f 100644 --- a/lib/asn1/primitives/asn1_printable_string.dart +++ b/lib/asn1/primitives/asn1_printable_string.dart @@ -83,11 +83,11 @@ class ASN1PrintableString extends ASN1Object { 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 @@ class ASN1PrintableString extends ASN1Object { /// 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 989b339f..325181af 100644 --- a/lib/asn1/primitives/asn1_sequence.dart +++ b/lib/asn1/primitives/asn1_sequence.dart @@ -20,8 +20,7 @@ class ASN1Sequence extends ASN1Object { /// /// 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 @@ class ASN1Sequence extends ASN1Object { 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 @@ class ASN1Sequence extends ASN1Object { /// 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 ab9f2c83..895c0897 100644 --- a/lib/asn1/primitives/asn1_set.dart +++ b/lib/asn1/primitives/asn1_set.dart @@ -20,7 +20,7 @@ class ASN1Set extends ASN1Object { /// /// 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 @@ class ASN1Set extends ASN1Object { 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 @@ class ASN1Set extends ASN1Object { /// 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 95aca61f..f4a6a34c 100644 --- a/lib/asn1/primitives/asn1_teletext_string.dart +++ b/lib/asn1/primitives/asn1_teletext_string.dart @@ -83,11 +83,11 @@ class ASN1TeletextString extends ASN1Object { 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 @@ class ASN1TeletextString extends ASN1Object { /// 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 a6a0b933..e1608328 100644 --- a/lib/asn1/primitives/asn1_utc_time.dart +++ b/lib/asn1/primitives/asn1_utc_time.dart @@ -28,8 +28,7 @@ class ASN1UtcTime extends ASN1Object { /// /// 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 @@ class ASN1UtcTime extends ASN1Object { 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 d382bbeb..8bb6b915 100644 --- a/lib/asn1/primitives/asn1_utf8_string.dart +++ b/lib/asn1/primitives/asn1_utf8_string.dart @@ -83,11 +83,11 @@ class ASN1UTF8String extends ASN1Object { 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 @@ class ASN1UTF8String extends ASN1Object { /// 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 d56b4bb9..7d7631c1 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 @@ class ASN1AttributeTypeAndValue extends ASN1Object { 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 c934a080..8805826b 100644 --- a/lib/asymmetric/api.dart +++ b/lib/asymmetric/api.dart @@ -33,13 +33,9 @@ class RSAPrivateKey extends RSAAsymmetricKey implements PrivateKey { /// 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 @@ class RSAPrivateKey extends RSAAsymmetricKey implements PrivateKey { // 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 @@ class RSAPrivateKey extends RSAAsymmetricKey implements PrivateKey { 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 @@ class RSAPrivateKey extends RSAAsymmetricKey implements PrivateKey { /// 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 @@ class RSAPublicKey extends RSAAsymmetricKey implements PublicKey { 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 @@ class RSASignature implements Signature { @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 @@ class PSSSignature implements Signature { 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 0b28bedb..7d9f36ce 100644 --- a/lib/asymmetric/ec_elgamal.dart +++ b/lib/asymmetric/ec_elgamal.dart @@ -48,7 +48,7 @@ class ECElGamalEncryptor implements ECEncryptor { _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 @@ class ECElGamalDecryptor implements ECDecryptor { void init(CipherParameters params) { var akparams = params as AsymmetricKeyParameter; 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 e101e80c..d1caf356 100644 --- a/lib/asymmetric/oaep.dart +++ b/lib/asymmetric/oaep.dart @@ -379,7 +379,7 @@ class OAEPEncoding extends BaseAsymmetricBlockCipher { // 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 05b3933e..e0834c52 100644 --- a/lib/asymmetric/pkcs1.dart +++ b/lib/asymmetric/pkcs1.dart @@ -57,7 +57,7 @@ class PKCS1Encoding extends BaseAsymmetricBlockCipher { _engine.init(forEncryption, akparams); - _forPrivateKey = (akparams.key is PrivateKey); + _forPrivateKey = akparams.key is PrivateKey; _forEncryption = forEncryption; } @@ -100,7 +100,7 @@ class PKCS1Encoding extends BaseAsymmetricBlockCipher { } 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 @@ class PKCS1Encoding extends BaseAsymmetricBlockCipher { 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 2e5cd94d..e01ece12 100644 --- a/lib/asymmetric/rsa.dart +++ b/lib/asymmetric/rsa.dart @@ -63,9 +63,9 @@ class RSAEngine extends BaseAsymmetricBlockCipher { _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 @@ class RSAEngine extends BaseAsymmetricBlockCipher { 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 @@ class RSAEngine extends BaseAsymmetricBlockCipher { 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 dda9bc13..5a106349 100644 --- a/lib/block/aes.dart +++ b/lib/block/aes.dart @@ -15,12 +15,12 @@ class AESEngine extends BaseBlockCipher { StaticFactoryConfig(BlockCipher, 'AES', () => AESEngine()); int _ROUNDS = 0; - List>? _WorkingKey; + late List> _WorkingKey; bool _forEncryption = false; List _s = List.empty(); - final _S = [ + static const _S = [ 99, 124, 119, @@ -279,7 +279,7 @@ class AESEngine extends BaseBlockCipher { 22, ]; - final _Si = [ + static const _Si = [ 82, 9, 106, @@ -538,7 +538,7 @@ class AESEngine extends BaseBlockCipher { 125, ]; - final _rcon = [ + static const _rcon = [ 0x01, 0x02, 0x04, @@ -571,7 +571,7 @@ class AESEngine extends BaseBlockCipher { 0x91 ]; - final _T0 = [ + static const _T0 = [ 0xa56363c6, 0x847c7cf8, 0x997777ee, @@ -830,7 +830,7 @@ class AESEngine extends BaseBlockCipher { 0x3a16162c ]; - final _Tinv0 = [ + static const _Tinv0 = [ 0x50a7f451, 0x5365417e, 0xc3a4171a, @@ -1091,20 +1091,20 @@ class AESEngine extends BaseBlockCipher { 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 @@ class AESEngine extends BaseBlockCipher { } 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 @@ class AESEngine extends BaseBlockCipher { } } - List>? generateWorkingKey(bool forEncryption, KeyParameter params) { + List> 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 @@ class AESEngine extends BaseBlockCipher { 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 @@ class AESEngine extends BaseBlockCipher { 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 @@ class AESEngine extends BaseBlockCipher { @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 @@ class AESEngine extends BaseBlockCipher { return _BLOCK_SIZE; } - void _encryptBlock(input, inOff, Uint8List out, int outOff, KW) { + void _encryptBlock( + input, int inOff, Uint8List out, int outOff, List> 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 @@ class AESEngine extends BaseBlockCipher { 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 @@ class AESEngine extends BaseBlockCipher { 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> 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 @@ class AESEngine extends BaseBlockCipher { 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 371d5d41..d514187d 100644 --- a/lib/block/aes_fast.dart +++ b/lib/block/aes_fast.dart @@ -17,8 +17,7 @@ import 'package:pointycastle/src/ufixnum.dart'; /// 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 @@ class AESFastEngine extends BaseBlockCipher { 6; // This is not always true for the generalized Rijndael that allows larger block sizes _workingKey = List.generate( _rounds + 1, - (int i) => - List.filled(4, 0, growable: false)); // 4 words in a block + (int i) => + List.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 @@ class AESFastEngine extends BaseBlockCipher { 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> kw) { @@ -230,91 +229,91 @@ class AESFastEngine extends BaseBlockCipher { 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 _m2 = 0x7f7f7f7f; 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 _invMcol(int x) { } 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/des_base.dart b/lib/block/des_base.dart index ca40a65a..9104aac2 100644 --- a/lib/block/des_base.dart +++ b/lib/block/des_base.dart @@ -705,7 +705,7 @@ class DesBase { if (encrypting) { m = shiftl32(i, 1); } else { - m = shiftl32((15 - i), 1); + m = shiftl32(15 - i, 1); } n = m + 1; @@ -749,14 +749,14 @@ class DesBase { 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 @@ class DesBase { 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 @@ class DesBase { 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 @@ class DesBase { 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 1f787e44..bcd74c16 100644 --- a/lib/block/modes/ccm.dart +++ b/lib/block/modes/ccm.dart @@ -25,8 +25,8 @@ class CCMBlockCipher extends BaseAEADBlockCipher { late KeyParameter _keyParam; - var associatedText = BytesBuilder(); - var data = BytesBuilder(); + BytesBuilder associatedText = BytesBuilder(); + BytesBuilder data = BytesBuilder(); late bool _forEncryption; @@ -39,7 +39,7 @@ class CCMBlockCipher extends BaseAEADBlockCipher { 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 @@ class CCMBlockCipher extends BaseAEADBlockCipher { } @override - void init(forEncryption, covariant CipherParameters params) { + void init(bool forEncryption, covariant CipherParameters params) { _forEncryption = forEncryption; KeyParameter key; @@ -121,7 +121,7 @@ class CCMBlockCipher extends BaseAEADBlockCipher { } 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 @@ class CCMBlockCipher extends BaseAEADBlockCipher { 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 @@ class CCMBlockCipher extends BaseAEADBlockCipher { 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 @@ class CCMBlockCipher extends BaseAEADBlockCipher { } @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 9ed7c2b2..769146a4 100644 --- a/lib/block/modes/ctr.dart +++ b/lib/block/modes/ctr.dart @@ -18,6 +18,5 @@ class CTRBlockCipher extends StreamCipherAsBlockCipher { 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 8f9333c1..b46b33ac 100644 --- a/lib/block/modes/gcm.dart +++ b/lib/block/modes/gcm.dart @@ -28,7 +28,7 @@ class GCMBlockCipher extends BaseAEADBlockCipher { 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 d1275823..8ebba7e7 100644 --- a/lib/block/modes/gctr.dart +++ b/lib/block/modes/gctr.dart @@ -5,8 +5,8 @@ library impl.block_cipher.modes.gctr; 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 4197d5d5..035ae677 100644 --- a/lib/block/modes/sic.dart +++ b/lib/block/modes/sic.dart @@ -19,6 +19,5 @@ class SICBlockCipher extends StreamCipherAsBlockCipher { 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 b18e0a26..4e7a9193 100644 --- a/lib/block/rc2_engine.dart +++ b/lib/block/rc2_engine.dart @@ -314,7 +314,7 @@ class RC2Engine extends BaseBlockCipher { var newKey = List.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 @@ class RC2Engine extends BaseBlockCipher { } 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 @@ class RC2Engine extends BaseBlockCipher { } 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/digests/cshake.dart b/lib/digests/cshake.dart index 83bda202..98aa4e4f 100644 --- a/lib/digests/cshake.dart +++ b/lib/digests/cshake.dart @@ -62,7 +62,7 @@ class CSHAKEDigest extends SHAKEDigest implements Xof { 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 7c1c0e13..7ad74ea4 100644 --- a/lib/digests/sha1.dart +++ b/lib/digests/sha1.dart @@ -134,11 +134,11 @@ class SHA1Digest extends MD4FamilyDigest implements Digest { 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 cf7b0e5f..9b7a4dae 100644 --- a/lib/digests/sha224.dart +++ b/lib/digests/sha224.dart @@ -117,9 +117,9 @@ class SHA224Digest extends MD4FamilyDigest implements Digest { 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 7472d9e0..53f9290b 100644 --- a/lib/digests/shake.dart +++ b/lib/digests/shake.dart @@ -72,7 +72,7 @@ class SHAKEDigest extends KeccakEngine implements Xof { absorbBits(finalInput, finalBits); } - squeeze(out, outOff, (outLen) * 8); + squeeze(out, outOff, outLen * 8); reset(); @@ -85,7 +85,7 @@ class SHAKEDigest extends KeccakEngine implements Xof { 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 9d60c86e..6ea86395 100644 --- a/lib/digests/sm3.dart +++ b/lib/digests/sm3.dart @@ -108,22 +108,22 @@ class SM3Digest extends MD4FamilyDigest implements Digest { } /// 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 9b7e9f6d..8b5ddf81 100644 --- a/lib/digests/whirlpool.dart +++ b/lib/digests/whirlpool.dart @@ -159,7 +159,7 @@ class WhirlpoolDigest extends BaseDigest implements Digest { 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 @@ class WhirlpoolDigest extends BaseDigest implements Digest { } 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 9a32d446..79396229 100644 --- a/lib/digests/xof_utils.dart +++ b/lib/digests/xof_utils.dart @@ -29,7 +29,7 @@ class XofUtils { 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 7d55769f..425ce64c 100644 --- a/lib/ecc/api.dart +++ b/lib/ecc/api.dart @@ -66,9 +66,6 @@ abstract class ECPoint { bool get isInfinity; - @override - bool operator ==(other); - Uint8List getEncoded([bool compressed = true]); ECPoint? operator +(ECPoint? b); @@ -81,9 +78,6 @@ abstract class ECPoint { /// 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 @@ class ECPrivateKey extends ECAsymmetricKey implements PrivateKey { /// 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 @@ class ECPublicKey extends ECAsymmetricKey implements PublicKey { /// 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 @@ class ECSignature implements Signature { @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 @@ class ECPair { 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 248415c4..16a2452e 100644 --- a/lib/ecc/curves/brainpoolp160r1.dart +++ b/lib/ecc/curves/brainpoolp160r1.dart @@ -25,10 +25,9 @@ class ECCurve_brainpoolp160r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp160r1; static ECCurve_brainpoolp160r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp160r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp160r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp160r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 9a2ea5d4..f4f363c3 100644 --- a/lib/ecc/curves/brainpoolp160t1.dart +++ b/lib/ecc/curves/brainpoolp160t1.dart @@ -25,10 +25,9 @@ class ECCurve_brainpoolp160t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp160t1; static ECCurve_brainpoolp160t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp160t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp160t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp160t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 a01bd0b4..2b1232e0 100644 --- a/lib/ecc/curves/brainpoolp192r1.dart +++ b/lib/ecc/curves/brainpoolp192r1.dart @@ -29,10 +29,9 @@ class ECCurve_brainpoolp192r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp192r1; static ECCurve_brainpoolp192r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp192r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp192r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp192r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 c1f12baf..3c98ef33 100644 --- a/lib/ecc/curves/brainpoolp192t1.dart +++ b/lib/ecc/curves/brainpoolp192t1.dart @@ -29,10 +29,9 @@ class ECCurve_brainpoolp192t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp192t1; static ECCurve_brainpoolp192t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp192t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp192t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp192t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 f6885ab2..b529e04a 100644 --- a/lib/ecc/curves/brainpoolp224r1.dart +++ b/lib/ecc/curves/brainpoolp224r1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp224r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp224r1; static ECCurve_brainpoolp224r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp224r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp224r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp224r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 2764d058..efc0fd88 100644 --- a/lib/ecc/curves/brainpoolp224t1.dart +++ b/lib/ecc/curves/brainpoolp224t1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp224t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp224t1; static ECCurve_brainpoolp224t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt? _h, List? seed) => - ECCurve_brainpoolp224t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt? h, List? seed) => + ECCurve_brainpoolp224t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp224t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt? _h, List? 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 d7a7b277..ed0f89b8 100644 --- a/lib/ecc/curves/brainpoolp256r1.dart +++ b/lib/ecc/curves/brainpoolp256r1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp256r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp256r1; static ECCurve_brainpoolp256r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp256r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp256r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp256r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 31670bb5..690fe102 100644 --- a/lib/ecc/curves/brainpoolp256t1.dart +++ b/lib/ecc/curves/brainpoolp256t1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp256t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp256t1; static ECCurve_brainpoolp256t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp256t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp256t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp256t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 81b9f800..9618df0c 100644 --- a/lib/ecc/curves/brainpoolp320r1.dart +++ b/lib/ecc/curves/brainpoolp320r1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp320r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp320r1; static ECCurve_brainpoolp320r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp320r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp320r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp320r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 54546f8e..289d43de 100644 --- a/lib/ecc/curves/brainpoolp320t1.dart +++ b/lib/ecc/curves/brainpoolp320t1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp320t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp320t1; static ECCurve_brainpoolp320t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp320t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp320t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp320t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 d99436b0..ae2749ab 100644 --- a/lib/ecc/curves/brainpoolp384r1.dart +++ b/lib/ecc/curves/brainpoolp384r1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp384r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp384r1; static ECCurve_brainpoolp384r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp384r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp384r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp384r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 f7e1ad13..a0479de9 100644 --- a/lib/ecc/curves/brainpoolp384t1.dart +++ b/lib/ecc/curves/brainpoolp384t1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp384t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp384t1; static ECCurve_brainpoolp384t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp384t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp384t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp384t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 13e445d7..b9ac142c 100644 --- a/lib/ecc/curves/brainpoolp512r1.dart +++ b/lib/ecc/curves/brainpoolp512r1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp512r1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp512r1; static ECCurve_brainpoolp512r1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp512r1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp512r1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp512r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 8c904bd2..461dc62b 100644 --- a/lib/ecc/curves/brainpoolp512t1.dart +++ b/lib/ecc/curves/brainpoolp512t1.dart @@ -33,10 +33,9 @@ class ECCurve_brainpoolp512t1 extends ECDomainParametersImpl { seed: null) as ECCurve_brainpoolp512t1; static ECCurve_brainpoolp512t1 _make(String domainName, ECCurve curve, - ECPoint G, BigInt n, BigInt _h, List? seed) => - ECCurve_brainpoolp512t1._super(domainName, curve, G, n, _h, seed); + ECPoint G, BigInt n, BigInt h, List? seed) => + ECCurve_brainpoolp512t1._super(domainName, curve, G, n, h, seed); - ECCurve_brainpoolp512t1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 8d660ba3..37d1113a 100644 --- a/lib/ecc/curves/gostr3410_2001_cryptopro_a.dart +++ b/lib/ecc/curves/gostr3410_2001_cryptopro_a.dart @@ -33,11 +33,10 @@ class ECCurve_gostr3410_2001_cryptopro_a extends ECDomainParametersImpl { 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? seed) => + ECCurve curve, ECPoint G, BigInt n, BigInt h, List? 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? 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 7901e297..74f2fb49 100644 --- a/lib/ecc/curves/gostr3410_2001_cryptopro_b.dart +++ b/lib/ecc/curves/gostr3410_2001_cryptopro_b.dart @@ -35,11 +35,10 @@ class ECCurve_gostr3410_2001_cryptopro_b extends ECDomainParametersImpl { 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? seed) => + ECCurve curve, ECPoint G, BigInt n, BigInt h, List? 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? 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 98c36513..18e3b73c 100644 --- a/lib/ecc/curves/gostr3410_2001_cryptopro_c.dart +++ b/lib/ecc/curves/gostr3410_2001_cryptopro_c.dart @@ -33,11 +33,10 @@ class ECCurve_gostr3410_2001_cryptopro_c extends ECDomainParametersImpl { 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? seed) => + ECCurve curve, ECPoint G, BigInt n, BigInt h, List? 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? 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 8d6730e6..0fc1c2fa 100644 --- a/lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart +++ b/lib/ecc/curves/gostr3410_2001_cryptopro_xcha.dart @@ -34,11 +34,10 @@ class ECCurve_gostr3410_2001_cryptopro_xcha extends ECDomainParametersImpl { 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? seed) => + ECCurve curve, ECPoint G, BigInt n, BigInt h, List? 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? 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 a7080e75..545cb7a7 100644 --- a/lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart +++ b/lib/ecc/curves/gostr3410_2001_cryptopro_xchb.dart @@ -34,11 +34,10 @@ class ECCurve_gostr3410_2001_cryptopro_xchb extends ECDomainParametersImpl { 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? seed) => + ECCurve curve, ECPoint G, BigInt n, BigInt h, List? 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? 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 b6aa4ff0..f175fd80 100644 --- a/lib/ecc/curves/prime192v1.dart +++ b/lib/ecc/curves/prime192v1.dart @@ -29,10 +29,9 @@ class ECCurve_prime192v1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime192v1; static ECCurve_prime192v1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime192v1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime192v1._super(domainName, curve, G, n, h, seed); - ECCurve_prime192v1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime192v1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/prime192v2.dart b/lib/ecc/curves/prime192v2.dart index 5980970e..6fed7c3a 100644 --- a/lib/ecc/curves/prime192v2.dart +++ b/lib/ecc/curves/prime192v2.dart @@ -29,10 +29,9 @@ class ECCurve_prime192v2 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime192v2; static ECCurve_prime192v2 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime192v2._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime192v2._super(domainName, curve, G, n, h, seed); - ECCurve_prime192v2._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime192v2._super(super.domainName, super.curve, super.G, super.n, + BigInt super.h, List super.seed); } diff --git a/lib/ecc/curves/prime192v3.dart b/lib/ecc/curves/prime192v3.dart index df5392b9..32229329 100644 --- a/lib/ecc/curves/prime192v3.dart +++ b/lib/ecc/curves/prime192v3.dart @@ -29,10 +29,9 @@ class ECCurve_prime192v3 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime192v3; static ECCurve_prime192v3 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime192v3._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime192v3._super(domainName, curve, G, n, h, seed); - ECCurve_prime192v3._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime192v3._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/prime239v1.dart b/lib/ecc/curves/prime239v1.dart index 68409fd5..2c034e98 100644 --- a/lib/ecc/curves/prime239v1.dart +++ b/lib/ecc/curves/prime239v1.dart @@ -34,10 +34,9 @@ class ECCurve_prime239v1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime239v1; static ECCurve_prime239v1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime239v1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime239v1._super(domainName, curve, G, n, h, seed); - ECCurve_prime239v1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime239v1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/prime239v2.dart b/lib/ecc/curves/prime239v2.dart index e5d7af56..1d681b5c 100644 --- a/lib/ecc/curves/prime239v2.dart +++ b/lib/ecc/curves/prime239v2.dart @@ -34,10 +34,9 @@ class ECCurve_prime239v2 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime239v2; static ECCurve_prime239v2 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime239v2._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime239v2._super(domainName, curve, G, n, h, seed); - ECCurve_prime239v2._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime239v2._super(super.domainName, super.curve, super.G, super.n, + BigInt super.h, List super.seed); } diff --git a/lib/ecc/curves/prime239v3.dart b/lib/ecc/curves/prime239v3.dart index 0d9db77f..4d011138 100644 --- a/lib/ecc/curves/prime239v3.dart +++ b/lib/ecc/curves/prime239v3.dart @@ -34,10 +34,9 @@ class ECCurve_prime239v3 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime239v3; static ECCurve_prime239v3 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime239v3._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime239v3._super(domainName, curve, G, n, h, seed); - ECCurve_prime239v3._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime239v3._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/prime256v1.dart b/lib/ecc/curves/prime256v1.dart index 934875e9..bc32d19f 100644 --- a/lib/ecc/curves/prime256v1.dart +++ b/lib/ecc/curves/prime256v1.dart @@ -33,10 +33,9 @@ class ECCurve_prime256v1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_prime256v1; static ECCurve_prime256v1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_prime256v1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_prime256v1._super(domainName, curve, G, n, h, seed); - ECCurve_prime256v1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_prime256v1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp112r1.dart b/lib/ecc/curves/secp112r1.dart index a7256d4d..91031edd 100644 --- a/lib/ecc/curves/secp112r1.dart +++ b/lib/ecc/curves/secp112r1.dart @@ -26,10 +26,9 @@ class ECCurve_secp112r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp112r1; static ECCurve_secp112r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp112r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp112r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp112r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp112r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp112r2.dart b/lib/ecc/curves/secp112r2.dart index 61773cfd..ae475265 100644 --- a/lib/ecc/curves/secp112r2.dart +++ b/lib/ecc/curves/secp112r2.dart @@ -26,10 +26,9 @@ class ECCurve_secp112r2 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp112r2; static ECCurve_secp112r2 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp112r2._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp112r2._super(domainName, curve, G, n, h, seed); - ECCurve_secp112r2._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp112r2._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp128r1.dart b/lib/ecc/curves/secp128r1.dart index f1ebd86e..132f4969 100644 --- a/lib/ecc/curves/secp128r1.dart +++ b/lib/ecc/curves/secp128r1.dart @@ -26,10 +26,9 @@ class ECCurve_secp128r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp128r1; static ECCurve_secp128r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp128r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp128r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp128r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp128r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp128r2.dart b/lib/ecc/curves/secp128r2.dart index 384ac00c..88508f6e 100644 --- a/lib/ecc/curves/secp128r2.dart +++ b/lib/ecc/curves/secp128r2.dart @@ -26,10 +26,9 @@ class ECCurve_secp128r2 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp128r2; static ECCurve_secp128r2 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp128r2._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp128r2._super(domainName, curve, G, n, h, seed); - ECCurve_secp128r2._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp128r2._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp160k1.dart b/lib/ecc/curves/secp160k1.dart index df4bf42f..889a3bcc 100644 --- a/lib/ecc/curves/secp160k1.dart +++ b/lib/ecc/curves/secp160k1.dart @@ -25,10 +25,9 @@ class ECCurve_secp160k1 extends ECDomainParametersImpl { seed: null) as ECCurve_secp160k1; static ECCurve_secp160k1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? seed) => - ECCurve_secp160k1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List? seed) => + ECCurve_secp160k1._super(domainName, curve, G, n, h, seed); - ECCurve_secp160k1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 9474867e..6692d232 100644 --- a/lib/ecc/curves/secp160r1.dart +++ b/lib/ecc/curves/secp160r1.dart @@ -26,10 +26,9 @@ class ECCurve_secp160r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp160r1; static ECCurve_secp160r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp160r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp160r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp160r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp160r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp160r2.dart b/lib/ecc/curves/secp160r2.dart index 562b9f5b..a43e3dc7 100644 --- a/lib/ecc/curves/secp160r2.dart +++ b/lib/ecc/curves/secp160r2.dart @@ -26,10 +26,9 @@ class ECCurve_secp160r2 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp160r2; static ECCurve_secp160r2 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp160r2._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp160r2._super(domainName, curve, G, n, h, seed); - ECCurve_secp160r2._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp160r2._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp192k1.dart b/lib/ecc/curves/secp192k1.dart index 7ee7d9f7..34ebf1a4 100644 --- a/lib/ecc/curves/secp192k1.dart +++ b/lib/ecc/curves/secp192k1.dart @@ -27,10 +27,9 @@ class ECCurve_secp192k1 extends ECDomainParametersImpl { seed: null) as ECCurve_secp192k1; static ECCurve_secp192k1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? seed) => - ECCurve_secp192k1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List? seed) => + ECCurve_secp192k1._super(domainName, curve, G, n, h, seed); - ECCurve_secp192k1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 a7b21a05..b1cdee22 100644 --- a/lib/ecc/curves/secp192r1.dart +++ b/lib/ecc/curves/secp192r1.dart @@ -30,10 +30,9 @@ class ECCurve_secp192r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp192r1; static ECCurve_secp192r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp192r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp192r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp192r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp192r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp224k1.dart b/lib/ecc/curves/secp224k1.dart index 4dffd5d7..32e87a5a 100644 --- a/lib/ecc/curves/secp224k1.dart +++ b/lib/ecc/curves/secp224k1.dart @@ -29,10 +29,9 @@ class ECCurve_secp224k1 extends ECDomainParametersImpl { seed: null) as ECCurve_secp224k1; static ECCurve_secp224k1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? seed) => - ECCurve_secp224k1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List? seed) => + ECCurve_secp224k1._super(domainName, curve, G, n, h, seed); - ECCurve_secp224k1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 e514065f..9323ecee 100644 --- a/lib/ecc/curves/secp224r1.dart +++ b/lib/ecc/curves/secp224r1.dart @@ -34,10 +34,9 @@ class ECCurve_secp224r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp224r1; static ECCurve_secp224r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp224r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp224r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp224r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp224r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp256k1.dart b/lib/ecc/curves/secp256k1.dart index b298cbd9..39952bf0 100644 --- a/lib/ecc/curves/secp256k1.dart +++ b/lib/ecc/curves/secp256k1.dart @@ -29,10 +29,9 @@ class ECCurve_secp256k1 extends ECDomainParametersImpl { seed: null) as ECCurve_secp256k1; static ECCurve_secp256k1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? seed) => - ECCurve_secp256k1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List? seed) => + ECCurve_secp256k1._super(domainName, curve, G, n, h, seed); - ECCurve_secp256k1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List? 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 313c9c12..d17eabf0 100644 --- a/lib/ecc/curves/secp256r1.dart +++ b/lib/ecc/curves/secp256r1.dart @@ -33,10 +33,9 @@ class ECCurve_secp256r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp256r1; static ECCurve_secp256r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp256r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp256r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp256r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp256r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp384r1.dart b/lib/ecc/curves/secp384r1.dart index 7f9d041b..c6c48c66 100644 --- a/lib/ecc/curves/secp384r1.dart +++ b/lib/ecc/curves/secp384r1.dart @@ -33,10 +33,9 @@ class ECCurve_secp384r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp384r1; static ECCurve_secp384r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp384r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp384r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp384r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp384r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/curves/secp521r1.dart b/lib/ecc/curves/secp521r1.dart index 709b3054..be2da275 100644 --- a/lib/ecc/curves/secp521r1.dart +++ b/lib/ecc/curves/secp521r1.dart @@ -33,10 +33,9 @@ class ECCurve_secp521r1 extends ECDomainParametersImpl { radix: 16)) as ECCurve_secp521r1; static ECCurve_secp521r1 _make(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) => - ECCurve_secp521r1._super(domainName, curve, G, n, _h, seed); + BigInt n, BigInt h, List seed) => + ECCurve_secp521r1._super(domainName, curve, G, n, h, seed); - ECCurve_secp521r1._super(String domainName, ECCurve curve, ECPoint G, - BigInt n, BigInt _h, List seed) - : super(domainName, curve, G, n, _h, seed); + ECCurve_secp521r1._super(super.domainName, super.curve, super.G, super.n, + BigInt super._h, List super.seed); } diff --git a/lib/ecc/ecc_base.dart b/lib/ecc/ecc_base.dart index 683946ca..c11d34db 100644 --- a/lib/ecc/ecc_base.dart +++ b/lib/ecc/ecc_base.dart @@ -42,7 +42,7 @@ abstract class ECFieldElementBase implements ECFieldElement { 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 @@ abstract class ECPointBase implements ECPoint { [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 @@ abstract class ECCurveBase implements ECCurve { 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 ced7404b..30c7fa53 100644 --- a/lib/ecc/ecc_fp.dart +++ b/lib/ecc/ecc_fp.dart @@ -6,7 +6,7 @@ import 'dart:typed_data'; 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 @@ class ECFieldElement extends ecc.ECFieldElementBase { V = V + q!; } - V = (V >> 1); + V = V >> 1; //assert V.multiply(V).mod(q).equals(x); @@ -184,7 +184,7 @@ class ECFieldElement extends ecc.ECFieldElementBase { } @override - bool operator ==(other) { + bool operator ==(Object other) { if (other is ECFieldElement) { return (q == other.q) && (x == other.x); } @@ -368,7 +368,7 @@ class ECCurve extends ecc.ECCurveBase { } @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 @@ List _windowNaf(int width, BigInt k) { var wnaf = List.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/key_derivators/argon2_native_int_impl.dart b/lib/key_derivators/argon2_native_int_impl.dart index 649242fa..045c4347 100644 --- a/lib/key_derivators/argon2_native_int_impl.dart +++ b/lib/key_derivators/argon2_native_int_impl.dart @@ -81,7 +81,7 @@ class Argon2BytesGenerator extends BaseKeyDerivator { '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 @@ class Argon2BytesGenerator extends BaseKeyDerivator { /* 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 @@ class Argon2BytesGenerator extends BaseKeyDerivator { } 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 @@ class Argon2BytesGenerator extends BaseKeyDerivator { } } - static int _intToLong(int x) => (x & M32L); + static int _intToLong(int x) => x & M32L; } class _FillBlock { @@ -642,11 +642,11 @@ class _Block { } 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 on List { diff --git a/lib/key_derivators/argon2_register64_impl.dart b/lib/key_derivators/argon2_register64_impl.dart index ede2bd27..338e4946 100644 --- a/lib/key_derivators/argon2_register64_impl.dart +++ b/lib/key_derivators/argon2_register64_impl.dart @@ -4,8 +4,8 @@ import 'package:pointycastle/api.dart'; 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 @@ class Argon2BytesGenerator extends BaseKeyDerivator { '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 @@ class Argon2BytesGenerator extends BaseKeyDerivator { /* 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 @@ class Argon2BytesGenerator extends BaseKeyDerivator { 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 @@ class _Block { } _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 on List { diff --git a/lib/key_derivators/concat_kdf.dart b/lib/key_derivators/concat_kdf.dart index ed7e9c87..5aa8b9b2 100644 --- a/lib/key_derivators/concat_kdf.dart +++ b/lib/key_derivators/concat_kdf.dart @@ -36,7 +36,7 @@ class ConcatKDFDerivator extends BaseKeyDerivator { 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 ffc6dbcd..faf4cd10 100644 --- a/lib/key_derivators/pkcs12_parameter_generator.dart +++ b/lib/key_derivators/pkcs12_parameter_generator.dart @@ -12,11 +12,11 @@ class PKCS12ParametersGenerator implements PBEParametersGenerator { 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 @@ class PKCS12ParametersGenerator implements PBEParametersGenerator { } 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 @@ class PKCS12ParametersGenerator implements PBEParametersGenerator { } 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 19050e52..1101ea50 100644 --- a/lib/key_derivators/scrypt.dart +++ b/lib/key_derivators/scrypt.dart @@ -24,7 +24,7 @@ class Scrypt extends BaseKeyDerivator { 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 450d699d..dc84dacb 100644 --- a/lib/key_generators/rsa_key_generator.dart +++ b/lib/key_generators/rsa_key_generator.dart @@ -96,7 +96,7 @@ class RSAKeyGenerator implements KeyGenerator { } // calculate the modulus - n = (p * q); + n = p * q; if (n.bitLength == _params.bitStrength) { break; @@ -114,11 +114,12 @@ class RSAKeyGenerator implements KeyGenerator { } // 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 @@ bool _millerRabin(BigInt b, int t) { /// 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/cmac.dart b/lib/macs/cmac.dart index 8b0a81e0..c3170801 100644 --- a/lib/macs/cmac.dart +++ b/lib/macs/cmac.dart @@ -106,7 +106,7 @@ class CMac extends BaseMac { 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 @@ class CMac extends BaseMac { } 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 b0cceec8..9ee4b516 100644 --- a/lib/macs/poly1305.dart +++ b/lib/macs/poly1305.dart @@ -71,7 +71,7 @@ class Poly1305 extends BaseMac { @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 @@ class Poly1305 extends BaseMac { 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 @@ class Poly1305 extends BaseMac { params = params.parameters!; } - if (!(params is KeyParameter)) { + if (params is! KeyParameter) { throw ArgumentError('Poly1305 requires a key.'); } @@ -279,10 +279,10 @@ class Poly1305 extends BaseMac { 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 8e16a132..927ee5cf 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 @@ class PaddedBlockCipherImpl implements PaddedBlockCipher { @override String get algorithmName => - cipher.algorithmName + '/' + padding.algorithmName; + '${cipher.algorithmName}/${padding.algorithmName}'; @override int get blockSize => cipher.blockSize; @@ -66,11 +66,11 @@ class PaddedBlockCipherImpl implements PaddedBlockCipher { 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); @@ -90,7 +90,7 @@ class PaddedBlockCipherImpl implements PaddedBlockCipher { 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 c7d73f09..db4fca43 100644 --- a/lib/paddings/iso7816d4.dart +++ b/lib/paddings/iso7816d4.dart @@ -26,7 +26,7 @@ class ISO7816d4Padding extends BasePadding { /// 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 e59da6b0..0fff9dfd 100644 --- a/lib/paddings/pkcs7.dart +++ b/lib/paddings/pkcs7.dart @@ -24,7 +24,7 @@ class PKCS7Padding extends BasePadding { @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 eae33e7a..1d1e7be1 100644 --- a/lib/signers/ecdsa_signer.dart +++ b/lib/signers/ecdsa_signer.dart @@ -293,7 +293,7 @@ class _RFC6979KCalculator { 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 @@ class _RFC6979KCalculator { 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 @@ class _RFC6979KCalculator { 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 591a2ee3..49f73f8f 100644 --- a/lib/signers/rsa_signer.dart +++ b/lib/signers/rsa_signer.dart @@ -131,7 +131,6 @@ class RSASigner implements Signer { } } 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 @@ class RSASigner implements Signer { 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 8adc373d..19ddab8a 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 b1a27ef8..cdae436a 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 7f281fda..c3ff9bc6 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 6dcbd49a..fa0ae747 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 { diff --git a/lib/src/api/asymmetric_key_parameter.dart b/lib/src/api/asymmetric_key_parameter.dart index 1310156c..9fa58d8f 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 diff --git a/lib/src/api/block_cipher.dart b/lib/src/api/block_cipher.dart index 80d8fd04..d08c22b7 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 a9e4fa60..84081b2e 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 caeaea65..32484f31 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 732ee411..086d0178 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 4c1b2c23..87e52129 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 f6e15e8e..269bc516 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 ba07d8f4..727aec01 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 08931e12..cb4be126 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 7506413a..20835ac8 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 4852bde0..3d17086a 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 4794d56f..a33958da 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 b20d69ed..a5cdf9fe 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 4f134862..d0a77133 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 181a4015..3779edd1 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 908a5d8a..79608e82 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 0cc55470..994e3b19 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 07c1ce54..acc4550e 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 814c4f29..4a97c692 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 fa993b0a..a8f2a3b4 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 63374cbd..8ee7bb7d 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 diff --git a/lib/src/api/public_key.dart b/lib/src/api/public_key.dart index 47d097d5..5ab25d72 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 2488d871..a93ef83f 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 diff --git a/lib/src/api/rc2_parameters.dart b/lib/src/api/rc2_parameters.dart index efae81d9..14a742dd 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 ce4e2da1..bacb5b6c 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 @@ class RegistryFactoryException implements Exception { 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 f3ef5c49..649086c3 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 02d5fcbe..19527ccd 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 7a73b232..a07088b6 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 c29d539c..d9a11cc4 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 ff5abad2..3dc5e74b 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 463e74a7..34e52f35 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 4a347738..64dd5751 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 bae94f67..bdf965b5 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 5e299c3f..d18dacf9 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 a8c03097..bd022a11 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 f2cf53c3..a7477fb3 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 ae3721a1..46ebe98c 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 4fddca68..bcf50758 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 53eedef4..d332fc5c 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 73a38d0a..45a4f679 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 3873d630..48f39d38 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 7996696e..33c95fb4 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 48408453..99d55408 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 f6b253aa..8956a3ed 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 c0395157..9f6a9a6c 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 @@ abstract class KeccakEngine extends BaseDigest { int get byteLength => _rate ~/ 8; @override - int get digestSize => (fixedOutputLength ~/ 8); + int get digestSize => fixedOutputLength ~/ 8; int get rate => _rate; @@ -147,7 +145,7 @@ abstract class KeccakEngine extends BaseDigest { 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 @@ abstract class KeccakEngine extends BaseDigest { } int remaining; - while ((remaining = (len - count)) >= rateBytes) { + while ((remaining = len - count) >= rateBytes) { _keccakAbsorb(data, off + count); count += rateBytes; } @@ -169,10 +167,6 @@ abstract class KeccakEngine extends BaseDigest { _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 @@ abstract class KeccakEngine extends BaseDigest { 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 @@ abstract class KeccakEngine extends BaseDigest { void _keccakExtract() { _keccakPermutation(); - _dataQueue.setRange(0, (_rate >> 3), _state); + _dataQueue.setRange(0, _rate >> 3, _state); _bitsInQueue = _rate; } @@ -253,11 +232,11 @@ abstract class KeccakEngine extends BaseDigest { } 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 @@ abstract class KeccakEngine extends BaseDigest { } } - _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 ffc5e0e6..44451041 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 @@ abstract class LongSHA2FamilyDigest extends BaseDigest { 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 ee4e0403..49e297fd 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 @@ abstract class MD4FamilyDigest extends BaseDigest { 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 97149360..316e8901 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 a41a6340..a92fe9d2 100644 --- a/lib/src/platform_check/abstract.dart +++ b/lib/src/platform_check/abstract.dart @@ -18,14 +18,14 @@ class PlatformGeneric extends Platform { @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/web.dart b/lib/src/platform_check/web.dart index 48646c1f..3ce9e6c4 100644 --- a/lib/src/platform_check/web.dart +++ b/lib/src/platform_check/web.dart @@ -56,7 +56,7 @@ class _JsBuiltInEntropySource implements EntropySource { class _JsNodeEntropySource implements EntropySource { @override Uint8List getBytes(int len) { - NodeCrypto j = require('crypto'); + final j = require('crypto') as NodeCrypto; var list = Uint8List(len); j.randomFillSync(list); return list; diff --git a/lib/src/registration.dart b/lib/src/registration.dart index 48eb7f0c..827a8892 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 414dc7e6..881be78f 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 9aacb46a..a168d0ef 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 @@ class StaticFactoryConfig extends FactoryConfig { 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 @@ class DynamicFactoryConfig extends FactoryConfig { 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 515ab930..1b63b9c6 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 @@ final _MASK32_HI_BITS = [ //////////////////////////////////////////////////////////////////////////////////////////////////// // 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 @@ int rotr8(int x, int n) { //////////////////////////////////////////////////////////////////////////////////////////////////// // 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 @@ int unpack16(dynamic inp, int offset, Endian endian) { //////////////////////////////////////////////////////////////////////////////////////////////////// // 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 @@ int shiftl32(int x, int n) { 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 @@ int rotr32(int x, int n) { 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 @@ class Register64 { 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 @@ class Register64 { 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 @@ class Register64 { _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 @@ class Register64 { 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 @@ class Register64 { // 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 @@ class Register64 { 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 @@ class Register64 { // |................................|................................| // |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 @@ class Register64 { } 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 @@ class Register64 { 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 @@ class Register64 { } 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 @@ class Register64 { 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 16de83b6..0ba221d6 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 @@ bool constantTimeAreEqual(Uint8List expected, Uint8List supplied) { 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 @@ BigInt decodeBigInt(List bytes) { 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 @@ BigInt decodeBigIntWithSign(int sign, List magnitude) { 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 @@ bool constantTimeAreEqualOffset( 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 @@ abstract class Longs { } var hi32 = (n >> 32) & 0xFFFFFFFF; - var lo32 = (n) & 0xFFFFFFFF; + var lo32 = n & 0xFFFFFFFF; if (distance >= 32) { var swap = hi32; @@ -305,21 +303,21 @@ abstract class Longs { } } - 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 @@ int unsignedShiftRight64(int n, int count) { } 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 a65164d1..4ed9dc7b 100644 --- a/lib/srp/srp6_client.dart +++ b/lib/srp/srp6_client.dart @@ -2,9 +2,9 @@ library impl.srp_client; 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 @@ class SRP6Client implements SRPClient { 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 47ec256e..63877513 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 @@ class SRP6Server implements SRPServer { 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 5733a75f..f5d53a93 100644 --- a/lib/srp/srp6_util.dart +++ b/lib/srp/srp6_util.dart @@ -1,8 +1,9 @@ library src.srp_util; +import 'dart:math' as math; import 'dart:typed_data'; + import 'package:pointycastle/pointycastle.dart'; -import 'dart:math' as math; class SRP6Util { static final _byteMask = BigInt.from(0xff); @@ -58,7 +59,7 @@ class SRP6Util { 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 @@ class SRP6Util { /// @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 @@ class SRP6Util { 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 e3900687..b096ca0d 100644 --- a/lib/stream/chacha20poly1305.dart +++ b/lib/stream/chacha20poly1305.dart @@ -60,8 +60,7 @@ class ChaCha20Poly1305 extends BaseAEADCipher { 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 @@ class ChaCha20Poly1305 extends BaseAEADCipher { 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 4d3343df..76adefeb 100644 --- a/lib/stream/ctr.dart +++ b/lib/stream/ctr.dart @@ -17,7 +17,7 @@ class CTRStreamCipher extends SICStreamCipher { 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 4553c4ed..dd72c435 100644 --- a/lib/stream/rc4_engine.dart +++ b/lib/stream/rc4_engine.dart @@ -62,8 +62,8 @@ class RC4Engine extends BaseStreamCipher { _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 @@ class RC4Engine extends BaseStreamCipher { _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 024b387e..d81aa1c4 100644 --- a/lib/stream/salsa20.dart +++ b/lib/stream/salsa20.dart @@ -154,38 +154,38 @@ class Salsa20Engine extends BaseStreamCipher { 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 9d3bb50a..67632e81 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,17 +1,16 @@ name: pointycastle -version: 3.7.3 +version: 3.7.4 description: A Dart library implementing cryptographic algorithms and primitives, modeled on the BouncyCastle library. homepage: https://github.com/bcgit/pc-dart environment: - sdk: '>=2.14.0 <3.0.0' + sdk: ^3.0.0 dependencies: collection: ^1.15.0 convert: ^3.0.0 - js: ^0.6.3 + js: '>=0.6.3 <0.8.0' 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 99c73b4a..a629bd72 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 2c748843..161b0e03 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/primitives/asn1_sequence_test.dart b/test/asn1/primitives/asn1_sequence_test.dart index 47d89d0f..8ae2eeda 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 @@ void main() { 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 4acdd1bd..2c5b3493 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 37482556..5cecced4 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 @@ void rsaOaepStandardTests() { // 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 @@ void rsaOaepStandardTests() { 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 @@ void rsaOaepStandardTests() { 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 @@ void rsaOaepStandardTests() { ParametersWithRandom( PublicKeyParameter(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 @@ void rsaOaepStandardTests() { dec.init(false, PrivateKeyParameter(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 @@ void rsaesOaepFromBC() { ]; test('RSAESOAEP decryption vectors from BC', () { - vectors.forEach((Vector v) { + for (var v in vectors) { var rsaesOaep = OAEPEncoding(RSAEngine()); rsaesOaep.init( false, PrivateKeyParameter(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 @@ void rsaesOaepFromBC() { 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 @@ class _OAEPTestEntropySource extends SecureRandomBase { @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 c942ebea..33792c7d 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_asymmetric_block_cipher.dart'; import '../test/src/null_secure_random.dart'; void main() { - var pubpar = () => ParametersWithRandom( - PublicKeyParameter(NullPublicKey()), NullSecureRandom()); - var privpar = () => ParametersWithRandom( - PrivateKeyParameter(NullPrivateKey()), NullSecureRandom()); + ParametersWithRandom> pubpar() => + ParametersWithRandom( + PublicKeyParameter(NullPublicKey()), NullSecureRandom()); + ParametersWithRandom> 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 d8eae29b..1c55eef4 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 @@ void main() { // 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 @@ void main() { // Test using the RSA key pair to perform block cipher encryption/decryption. - var pubpar = () => PublicKeyParameter(pubk); - var privpar = () => PrivateKeyParameter(privk); + PublicKeyParameter pubpar() => + PublicKeyParameter(pubk); + PrivateKeyParameter privpar() => + PrivateKeyParameter(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 39c8d5b1..a52ad809 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 da3a83b5..1c9e6f63 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 @@ KeyParameter kp(String src) { 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 @@ void blockCipherMCTTest(int id, int iterations, BlockCipher cipher, } } - 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 @@ void blockCipherMCTTest(int id, int iterations, BlockCipher cipher, } } - expect(_input, equals(out), reason: '$id did not match input'); + expect(input0, equals(out), reason: '$id did not match input'); }); } diff --git a/test/digests/blake2b_test.dart b/test/digests/blake2b_test.dart index f593c5d1..e0c14985 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 @@ import '../test/src/helpers.dart'; 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 @@ void main() { ] ]; - 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 @@ void main() { 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 b92b7352..d385eb42 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 @@ void testRegressions() { expect( sum, equals(createUint8ListFromHexString( - "51e16cafd44b120fde44105f299b8343c22899851da30bb33a481d4b81c2ef3e"))); + '51e16cafd44b120fde44105f299b8343c22899851da30bb33a481d4b81c2ef3e'))); }); }); } @@ -182,7 +179,7 @@ void exerciseDigest(KeccakDigest digest, List expected) { 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 @@ void exerciseKeccakMac(Digest digest, List keys, List data, 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 6a92fc88..a2719aae 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 eb99af22..9b1f7d47 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 2d3f06f3..13b97d57 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 269a8ab2..9c3079ef 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 518b2a08..81660eeb 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 780e69a9..cfe504a6 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 587241d1..70016743 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 56f2f6ec..5963e6b0 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 dda5c173..85d78cf6 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 4fccb6f6..64c79f57 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 035e2883..e09c7225 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 97d6076d..52b3b510 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 c9a0b296..aa162bf2 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 062df51b..d2a45709 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 86e728bb..fa533e4f 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 @@ void main() { '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 96cb1952..076efdd4 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 cadc7929..b06e7ff1 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 917ffe49..8eaff46e 100644 --- a/test/ecc/ecdh_test.dart +++ b/test/ecc/ecdh_test.dart @@ -23,7 +23,7 @@ class ECDHTestvector { } 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 @@ void main() { 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 @@ void main() { 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 f0b88bca..49020859 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 @@ void main() { 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 0357a23e..65c1c519 100644 --- a/test/key_derivators/argon2_nonvm_test.dart +++ b/test/key_derivators/argon2_nonvm_test.dart @@ -19,7 +19,7 @@ const int DEFAULT_OUTPUTLEN = 32; /// 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 2843bc85..cfdadca7 100644 --- a/test/key_derivators/argon2_vm_test.dart +++ b/test/key_derivators/argon2_vm_test.dart @@ -20,7 +20,7 @@ const int DEFAULT_OUTPUTLEN = 32; /// 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 a4176719..c8c4e9f9 100644 --- a/test/key_derivators/concatkdf_nonvm_test.dart +++ b/test/key_derivators/concatkdf_nonvm_test.dart @@ -24,7 +24,7 @@ Uint8List nullSafeBytes(dynamic src) { } 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 @@ void main() { // Form a maps of known correct results. // - var validDKMAFT = Map(); - var validVALResult = Map(); + var validDKMAFT = {}; + var validVALResult = {}; 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 @@ void main() { // 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 @@ void main() { 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 @@ void main() { } // 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 @@ Uint8List _convertToBigEndian(int l) { 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 loadRsp() { } 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 45229804..0caeccb5 100644 --- a/test/key_derivators/concatkdf_test.dart +++ b/test/key_derivators/concatkdf_test.dart @@ -25,7 +25,7 @@ Uint8List nullSafeBytes(dynamic src) { } 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 @@ void main() { // Form a maps of known correct results. // - var validDKMAFT = Map(); - var validVALResult = Map(); + var validDKMAFT = {}; + var validVALResult = {}; 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 @@ void main() { // 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 @@ void main() { 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 @@ void main() { } // 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 @@ Uint8List _convertToBigEndian(int l) { 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 2df2d777..24734067 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 2bcb1c27..2eb4105b 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 32f716f4..88f0804c 100644 --- a/test/key_derivators/pkcs12_parameter_generator_test.dart +++ b/test/key_derivators/pkcs12_parameter_generator_test.dart @@ -13,7 +13,7 @@ void main() { 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 1368831b..a849905b 100644 --- a/test/key_derivators/scrypt_nonvm_test.dart +++ b/test/key_derivators/scrypt_nonvm_test.dart @@ -20,11 +20,10 @@ void main() { // 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 df0d04ea..dccb081d 100644 --- a/test/key_derivators/scrypt_vm_test.dart +++ b/test/key_derivators/scrypt_vm_test.dart @@ -17,7 +17,7 @@ import '../test/src/helpers.dart'; /// [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 cf348a11..821e8f27 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 d0cb2884..19e510a9 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 @@ void _exponentTests(AsymmetricKeyPair pair, BigInt expectedPublicExponent) { 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 8b9b5502..49b226e4 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 c23003cb..44abad13 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 ce12a6ab..2fd75ced 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 2f5975f9..8ed8ca4b 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 38dcee92..494efae0 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 cbe18af9..bbd6e055 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 0e142701..ab44ce01 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 @@ void main() { 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 03f3fd48..7d19c0de 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 f21403e2..30bb6195 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 6d331593..e431dd16 100644 --- a/test/modes/gcm_test.dart +++ b/test/modes/gcm_test.dart @@ -35,7 +35,7 @@ void main() { // final expectedSHA256 = createUint8ListFromHexString( - "1679DCC9C8AD4B75BE69BBCABE46D4F32472F48C24595D5280EC5B44E77B3105"); + '1679DCC9C8AD4B75BE69BBCABE46D4F32472F48C24595D5280EC5B44E77B3105'); var dig = SHA256Digest(); dig.update(encrypted, 0, encrypted.length); @@ -81,9 +81,9 @@ void main() { 'iv': createUint8ListFromHexString('cafebabefacedbaddecaf888'), 'aad': createUint8ListFromHexString(''), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', 'output': - '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985', + '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091473f5985', 'mac': createUint8ListFromHexString('4d5c2af327cd64a62cf35abd2ba6fab4') }, { @@ -93,9 +93,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091', + '42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8f6a5aac84aa051ba30b396a0aac973d58e091', 'mac': createUint8ListFromHexString('5bc94fbc3221a5db94fae95ae7121a47') }, { @@ -105,9 +105,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598', + '61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b097544d4896b424989b5e1ebac0f07c23f4598', 'mac': createUint8ListFromHexString('3612d2e79e3b0785561be14aaca2fccb') }, { @@ -118,9 +118,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5', + '8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccdcb281d48c7c6fd62875d2aca417034c34aee5', 'mac': createUint8ListFromHexString('619cc5aefffe0bfa462af43c1699d050') }, { @@ -150,9 +150,9 @@ void main() { 'iv': createUint8ListFromHexString('cafebabefacedbaddecaf888'), 'aad': createUint8ListFromHexString(''), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', 'output': - '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256', + '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256', 'mac': createUint8ListFromHexString('9924a7c8587336bfb118024db8674a14') }, { @@ -163,9 +163,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710', + '3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710', 'mac': createUint8ListFromHexString('2519498e80f1478f37ba55bd6d27618c') }, { @@ -176,9 +176,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7', + '0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7', 'mac': createUint8ListFromHexString('65dcc57fcf623a24094fcca40d3533f8') }, { @@ -190,9 +190,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - 'd27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b', + 'd27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b', 'mac': createUint8ListFromHexString('dcf566ff291c25bbb8568fc3d376a6d9') }, { @@ -222,9 +222,9 @@ void main() { 'iv': createUint8ListFromHexString('cafebabefacedbaddecaf888'), 'aad': createUint8ListFromHexString(''), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', 'output': - '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad', + '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662898015ad', 'mac': createUint8ListFromHexString('b094dac5d93471bdec1a502270e3cc6c') }, { @@ -235,9 +235,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662', + '522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b08b1056828838c5f61e6393ba7a0abcc9f662', 'mac': createUint8ListFromHexString('76fc6ece0f4e1768cddf8853bb2d551b') }, { @@ -248,9 +248,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - 'c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f', + 'c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954cc2363bc73f7862ac430e64abe499f47c9b1f', 'mac': createUint8ListFromHexString('3a337dbf46a792c45e454913fe2ea8f2') }, { @@ -262,9 +262,9 @@ void main() { 'aad': createUint8ListFromHexString( 'feedfacedeadbeeffeedfacedeadbeefabaddad2'), 'input': - 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', + 'd9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'output': - '5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f', + '5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f', 'mac': createUint8ListFromHexString('a44a8266ee1c8eb0c8b5d4cf5ae9f19a') }, ]; @@ -273,8 +273,8 @@ void main() { 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 42df0aa8..c663abb3 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 e552d8a5..b35051df 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 784affff..7bb6c709 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 94a4c6e7..f322a84a 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 611bb26a..15d25ff0 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 299acc83..ffa7e1fd 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 516df72e..1df9b872 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 816617ad..282d2310 100644 --- a/test/platform/platform_native_test.dart +++ b/test/platform/platform_native_test.dart @@ -3,8 +3,8 @@ import 'package:pointycastle/src/platform_check/platform_check.dart'; 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 945c445d..33a044e5 100644 --- a/test/platform/platform_web_test.dart +++ b/test/platform/platform_web_test.dart @@ -4,7 +4,7 @@ import 'package:test/test.dart'; 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 07286764..a1c4eb41 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 @@ void main() { 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 cfaeb08c..71a16b0e 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 @@ void main() { 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 b9ea6592..767a795e 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 648a5ff5..59edd895 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 @@ void main() { 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 6a714b7e..3a4a336d 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 @@ void main() { var Qy = BigInt.parse( '6264116558863692852155702059476882343593676720209154057133'); var Q = eccDomain.curve.createPoint(Qx, Qy); - var verifyParams = () => PublicKeyParameter(ECPublicKey(Q, eccDomain)); + PublicKeyParameter verifyParams() => + PublicKeyParameter(ECPublicKey(Q, eccDomain)); var d = BigInt.parse( '3062713166230336928689662410859599564103408831862304472446'); var privParams = PrivateKeyParameter(ECPrivateKey(d, eccDomain)); - var signParams = () => ParametersWithRandom(privParams, NullSecureRandom()); + ParametersWithRandom> 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 964a44a6..3c1547e8 100644 --- a/test/signers/ecdsa_vec.dart +++ b/test/signers/ecdsa_vec.dart @@ -2855,7 +2855,7 @@ dynamic sigVerVec = jsonDecode(''' ] '''); -dynamic sigGenVec = jsonDecode(''' +List sigGenVec = jsonDecode(''' [ { }, @@ -4144,4 +4144,4 @@ dynamic sigGenVec = jsonDecode(''' ] } ] -'''); +''') as List; diff --git a/test/signers/ecdsa_vector_vm_test.dart b/test/signers/ecdsa_vector_vm_test.dart index 4eb8f23c..fa92877e 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 @@ void sigVer() { 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 @@ void sigVer() { 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 @@ void checkSigVer(ECDomainParameters domainParameters, String alg, dynamic grp, 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 @@ void checkSigVer(ECDomainParameters domainParameters, String alg, dynamic grp, 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 @@ void sigGen() { 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 @@ void sigGen() { 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 @@ void sigGen() { 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 @@ void sigGen() { 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 sigGen() { } 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 d99ae29c..cc0bb3b8 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 @@ void main() { }); } -var pubParams = (RSAPublicKey pubk, Uint8List salt) => () => ParametersWithSalt( - PublicKeyParameter(pubk), - salt, - ); -var privParams = (RSAPrivateKey privk, Uint8List salt) => +ParametersWithSalt> Function() Function( + RSAPublicKey pubk, Uint8List salt) pubParams = + (RSAPublicKey pubk, Uint8List salt) => () => ParametersWithSalt( + PublicKeyParameter(pubk), + salt, + ); +ParametersWithSalt> Function() Function( + RSAPrivateKey privk, Uint8List salt) privParams = (RSAPrivateKey privk, + Uint8List salt) => () => ParametersWithSalt(PrivateKeyParameter(privk), salt); void _testSign( diff --git a/test/signers/rsa_signer_test.dart b/test/signers/rsa_signer_test.dart index a0610448..a5fa8e62 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 @@ void main() { var pubk = RSAPublicKey(modulus, publicExponent); var privk = RSAPrivateKey(modulus, privateExponent, p, q); - var pubParams = () => ParametersWithRandom( - PublicKeyParameter(pubk), NullSecureRandom()); - var privParams = () => ParametersWithRandom( - PrivateKeyParameter(privk), NullSecureRandom()); + ParametersWithRandom> pubParams() => + ParametersWithRandom( + PublicKeyParameter(pubk), NullSecureRandom()); + ParametersWithRandom> privParams() => + ParametersWithRandom( + PrivateKeyParameter(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 3c90cf11..676f7121 100644 --- a/test/src/ct_nonvm_test.dart +++ b/test/src/ct_nonvm_test.dart @@ -18,7 +18,7 @@ void main() { 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 @@ void main() { 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 @@ void main() { // 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 @@ void main() { // 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 c98d93d3..8259c099 100644 --- a/test/src/ct_test.dart +++ b/test/src/ct_test.dart @@ -19,7 +19,7 @@ void main() { 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 @@ void main() { 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 @@ void main() { // 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 6323d906..417d8619 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 8cca2e46..0ee7be83 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 6b4ebe5d..862cd3a5 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 @@ void main() { 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 @@ void main() { 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 @@ void main() { 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 @@ void main() { 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 @@ void main() { 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 TestSRP6Client extends SRP6Client { } 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 dbfcb7b6..cbc54a42 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 bb8f53a1..2d30fe16 100644 --- a/test/stream/eax_test.dart +++ b/test/stream/eax_test.dart @@ -46,9 +46,7 @@ void main() { () => 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 randomTests() { 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 @@ void randomTest(SecureRandom srng) { 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 cd257792..3439d9a3 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 0e1d3222..46e5522f 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 7bf9ea95..531ce4e7 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 @@ void runBlockCipherTests(BlockCipher cipher, CipherParameters? params, var plainText = plainCipherTextPairs[i]; var cipherText = plainCipherTextPairs[i + 1]; - test('${formatAsTruncated(plainText)}', + test(formatAsTruncated(plainText), () => _runBlockCipherTest(cipher, params, plainText, cipherText)); } }); @@ -27,7 +25,7 @@ void runBlockCipherTests(BlockCipher cipher, CipherParameters? params, 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 685303aa..60474086 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 @@ void runDigestTests(Digest digest, List plainDigestTextPairs) { 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 8d19b06c..ee988a86 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 @@ void runKeyDerivatorTests( 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 c9255da1..0b07abaa 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 3fad0691..c0d7f2e2 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 @@ void runMacTests(Mac mac, List plainDigestTextPairs) { 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 @@ class Rfc4231TestVector { 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 2abf228c..46629ad3 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 5c382975..f0063aad 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 c2ca0a73..e3147512 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 @@ void runSignerTests(Signer signer, CipherParameters Function() signParams, 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 @@ void runSignerTests(Signer signer, CipherParameters Function() signParams, 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 @@ void runSignerTestsFail(Signer signer, CipherParameters Function() signParams, 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 @@ void runSignerTestsFail(Signer signer, CipherParameters Function() signParams, 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 8be00d96..272f124e 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 @@ void runStreamCipherTests(StreamCipher cipher, CipherParameters params, var plainText = plainCipherTextPairs[i]; var cipherText = plainCipherTextPairs[i + 1]; - test('${formatAsTruncated(plainText)}', + test(formatAsTruncated(plainText), () => _runStreamCipherTest(cipher, params, plainText, cipherText)); } }); @@ -28,7 +26,7 @@ void runStreamCipherTests(StreamCipher cipher, CipherParameters params, 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 6e346a0c..a052c991 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 6782a7fa..db2e77d0 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 @@ import 'package:test/test.dart'; 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 @@ String _format(double val) { } 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 @@ class _IsAllZeros extends Matcher { 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 2d84859a..34001e2d 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 c2eb22ff..22e678cd 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 97a8803f..b845f5e2 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 b7a02ca9..ac75759e 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 c5a198f5..b67bf26d 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/examples/aes-cbc-direct.dart b/tutorials/examples/aes-cbc-direct.dart index 2a8000b3..7b8c0846 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'; @@ -153,10 +153,9 @@ Uint8List passphraseToKey(String passPhrase, 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 @@ FortunaRandom? _secureRandom; void katTest() { // Encryption tests - [ + for (var testCase in [ [ 'CBCGFSbox128.rsp: encrypt 0', '00000000000000000000000000000000', // key @@ -231,7 +230,7 @@ void katTest() { '014730f80ac625fe84f026c60bfd547d', '5c9d844ed46f9885085e5d6a4f94c7d7', ] - ].forEach((testCase) { + ]) { final name = testCase[0]; final key = testCase[1]; final iv = testCase[2]; @@ -243,11 +242,11 @@ void katTest() { print('$name: failed'); throw AssertionError('$name: failed'); } - }); + } // Decryption tests - [ + for (var testCase in [ [ 'CBCGFSbox128.rsp: decrypt 0', '00000000000000000000000000000000', // key @@ -269,7 +268,7 @@ void katTest() { '1bc704f1bce135ceb810341b216d7abe', // ciphertext '91fbef2d15a97816060bee1feaa49afe', // plaintext ] - ].forEach((testCase) { + ]) { final name = testCase[0]; final key = testCase[1]; final iv = testCase[2]; @@ -281,7 +280,7 @@ void katTest() { print('$name: failed'); throw AssertionError('$name: failed'); } - }); + } } //---------------------------------------------------------------- @@ -313,7 +312,7 @@ in culpa qui officia deserunt mollit anim id est laborum. 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 2129c8c3..4afdc185 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 @@ Uint8List passphraseToKey(String passPhrase, 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 @@ SecureRandom? _secureRandom; void katTest() { // Encryption tests - [ + for (var testCase in [ [ 'CBCGFSbox128.rsp: encrypt 0', '00000000000000000000000000000000', // key @@ -243,7 +242,7 @@ void katTest() { '014730f80ac625fe84f026c60bfd547d', '5c9d844ed46f9885085e5d6a4f94c7d7', ] - ].forEach((testCase) { + ]) { final name = testCase[0]; final key = testCase[1]; final iv = testCase[2]; @@ -255,11 +254,11 @@ void katTest() { print('$name: failed'); throw AssertionError('$name: failed'); } - }); + } // Decryption tests - [ + for (var testCase in [ [ 'CBCGFSbox128.rsp: decrypt 0', '00000000000000000000000000000000', // key @@ -281,7 +280,7 @@ void katTest() { '1bc704f1bce135ceb810341b216d7abe', // ciphertext '91fbef2d15a97816060bee1feaa49afe', // plaintext ] - ].forEach((testCase) { + ]) { final name = testCase[0]; final key = testCase[1]; final iv = testCase[2]; @@ -293,7 +292,7 @@ void katTest() { print('$name: failed'); throw AssertionError('$name: failed'); } - }); + } } //---------------------------------------------------------------- @@ -325,7 +324,7 @@ in culpa qui officia deserunt mollit anim id est laborum. 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 d2a997c6..f0ba5dc2 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 @@ void main(List args) { 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 02af975d..f57eeadc 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 82342453..6f02e02d 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 d37ff528..02549356 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 2cbeb1ad..8b5d80c8 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 @@ void useRegistry() { 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(_pair.privateKey)); + ..init(true, PrivateKeyParameter(pair.privateKey)); - final _signature = + final signature = signer.generateSignature(Uint8List.fromList(_data)) as RSASignature; final verifier = Signer('SHA-256/RSA') - ..init(false, PublicKeyParameter(_pair.publicKey)); - final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature); + ..init(false, PublicKeyParameter(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 909dbb8f..6aa48d4c 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 @@ void useRegistry() { 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(_pair.privateKey)); + ..init(true, PrivateKeyParameter(pair.privateKey)); - final _signature = + final signature = signer.generateSignature(Uint8List.fromList(_data)) as RSASignature; final verifier = Signer('SHA-256/RSA') - ..init(false, PublicKeyParameter(_pair.publicKey)); - final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature); + ..init(false, PublicKeyParameter(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 @@ void useConstructors() { 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 @@ void useConstructors() { 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(_pair.privateKey)); + ..init(true, PrivateKeyParameter(pair.privateKey)); - final _signature = signer.generateSignature(Uint8List.fromList(_data)); + final signature = signer.generateSignature(Uint8List.fromList(_data)); final verifier = RSASigner(SHA256Digest(), '0609608648016503040201') - ..init(false, PublicKeyParameter(_pair.publicKey)); - final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature); + ..init(false, PublicKeyParameter(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 6addc216..af93f007 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 @@ void useRegistry() { 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(_pair.privateKey)); + ..init(true, PrivateKeyParameter(pair.privateKey)); - final _signature = + final signature = signer.generateSignature(Uint8List.fromList(_data)) as RSASignature; final verifier = Signer('SHA-256/RSA') - ..init(false, PublicKeyParameter(_pair.publicKey)); - final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature); + ..init(false, PublicKeyParameter(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 @@ void useConstructors() { 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 @@ void useConstructors() { 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(_pair.privateKey)); + ..init(true, PrivateKeyParameter(pair.privateKey)); - final _signature = signer.generateSignature(Uint8List.fromList(_data)); + final signature = signer.generateSignature(Uint8List.fromList(_data)); final verifier = RSASigner(SHA256Digest(), '0609608648016503040201') - ..init(false, PublicKeyParameter(_pair.publicKey)); - final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature); + ..init(false, PublicKeyParameter(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 21da5048..558a805d 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 @@ void useRegistry() { 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(_pair.privateKey)); + ..init(true, PrivateKeyParameter(pair.privateKey)); - final _signature = + final signature = signer.generateSignature(Uint8List.fromList(_data)) as RSASignature; final verifier = Signer('SHA-256/RSA') - ..init(false, PublicKeyParameter(_pair.publicKey)); - final sigOk = verifier.verifySignature(Uint8List.fromList(_data), _signature); + ..init(false, PublicKeyParameter(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 e308423b..0087881e 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 @@ List decodeBERObjectIdentifier(Uint8List bytes) { 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 @@ Uint8List encodeBERObjectIdentifier(String oidStr, {int tag = 0x06}) { 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 = []; // 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 60fc3257..d509ecc4 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 @@ void main(List args) { // Use the key pair - final plaintext = (longText) ? longPlaintext : shortPlaintext; + final plaintext = longText ? longPlaintext : shortPlaintext; if (verbose) { print('Plaintext: $plaintext\n'); }