Skip to content

Commit

Permalink
Support latest pkg:js, require Dart v3, update and fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jan 12, 2024
1 parent 59e0602 commit 3ec3cc2
Show file tree
Hide file tree
Showing 305 changed files with 1,246 additions and 1,526 deletions.
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';
12 changes: 6 additions & 6 deletions lib/asn1/asn1_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ class ASN1Utils {
.map((line) => line.trim())
.where((line) => line.isNotEmpty)
.toList();
var base64;
String base64;
if (checkHeader) {
if (lines.length < 2 ||
!lines.first.startsWith('-----BEGIN') ||
Expand All @@ -145,16 +145,16 @@ 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;
var b2 = innerSeq.elements!.elementAt(1) as ASN1ObjectIdentifier;
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;
Expand All @@ -178,7 +178,7 @@ class ASN1Utils {
var data = ObjectIdentifiers.getIdentifierByIdentifier(
curveNameOi.objectIdentifierAsString);
if (data != null) {
curveName = data['readableName'];
curveName = data['readableName'] as String;
}

x = privateKeyAsOctetString.valueBytes!;
Expand Down
Loading

0 comments on commit 3ec3cc2

Please sign in to comment.