Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support latest pkg:js, require Dart v3, update and fix lints #220

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/chrome.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 9 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
include: package:pedantic/analysis_options.yaml
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
2 changes: 0 additions & 2 deletions benchmark/all_benchmarks.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions benchmark/benchmark/block_cipher_benchmark.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 0 additions & 2 deletions benchmark/benchmark/digest_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.benchmark.digest_benchmark;

import 'dart:typed_data';

import 'package:pointycastle/pointycastle.dart';
Expand Down
6 changes: 2 additions & 4 deletions benchmark/benchmark/operation_benchmark.dart
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions benchmark/benchmark/rate_benchmark.dart
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions benchmark/benchmark/signer_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.benchmark.signer_benchmark;

import 'dart:typed_data';

import 'package:pointycastle/pointycastle.dart';
Expand Down
2 changes: 0 additions & 2 deletions benchmark/benchmark/stream_cipher_benchmark.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 0 additions & 2 deletions benchmark/block/aes_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.block.aes_benchmark;

import 'dart:typed_data';

import 'package:pointycastle/pointycastle.dart';
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/blake2b_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library benchmark.digests.blake2b_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/md2_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.md2_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/md4_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.md4_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/md5_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.md5_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/ripemd128_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.ripemd128_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/ripemd160_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.ripemd160_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/ripemd256_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.ripemd256_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/ripemd320_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.ripemd320_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha1_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha1_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha224_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha224_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha256_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha256_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha384_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha384_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha3_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha3_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha512_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha512_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/sha512t_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.sha512t_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/tiger_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.tiger_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
2 changes: 0 additions & 2 deletions benchmark/digests/whirlpool_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.digests.whirlpool_benchmark;

import '../benchmark/digest_benchmark.dart';

void main() {
Expand Down
16 changes: 8 additions & 8 deletions benchmark/signers/rsa_signer_benchmark.dart
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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<RSAPublicKey>(pubk), NullSecureRandom());
var privParamsFactory = () => ParametersWithRandom(
PrivateKeyParameter<RSAPrivateKey>(privk), NullSecureRandom());
// ignore: unused_element
ParametersWithRandom<PublicKeyParameter<RSAPublicKey>> pubParamsFactory() =>
ParametersWithRandom(
PublicKeyParameter<RSAPublicKey>(pubk), NullSecureRandom());
ParametersWithRandom<PrivateKeyParameter<RSAPrivateKey>>
privParamsFactory() => ParametersWithRandom(
PrivateKeyParameter<RSAPrivateKey>(privk), NullSecureRandom());

SignerBenchmark('Null/RSA', true, privParamsFactory).report();
}
2 changes: 0 additions & 2 deletions benchmark/src/ufixnum_benchmark.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 0 additions & 2 deletions benchmark/stream/salsa20_benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// See file LICENSE for more information.

library benchmark.stream.salsa20_benchmark;

import 'dart:typed_data';

import 'package:pointycastle/pointycastle.dart';
Expand Down
19 changes: 7 additions & 12 deletions lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
11 changes: 9 additions & 2 deletions lib/asn1/asn1_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -83,7 +89,8 @@ class ASN1Parser {
}

// Update the position
_position = _position + obj.totalEncodedByteLength;
_position =
_position + obj.totalEncodedByteLength + (isIndefiniteLength ? 2 : 0);
return obj;
}

Expand Down
Loading