konstantinullrich / crypton

A simple Dart library for asymmetric encryption and digital signatures
https://pub.dev/packages/crypton
MIT License
34 stars 12 forks source link

Getting warnings on VM startup after running a dart pub upgrade #38

Closed gkc closed 1 year ago

gkc commented 1 year ago

The latest version of asn1lib requires dart ^3.0.0 and makes a number of changes re nullability in its API (commit)

As a result, while running a program that uses the crypton package after running dart pub upgrade, everything still runs just fine but the Dart VM now prints out the following warnings when it starts up:

../../../../.pub-cache/hosted/pub.dev/crypton-2.1.0/lib/src/rsa/private_key.dart:23:40: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
    asn1Parser = ASN1Parser(privateKey.contentBytes()!);
                                       ^
../../../../.pub-cache/hosted/pub.dev/crypton-2.1.0/lib/src/rsa/private_key.dart:32:17: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
        modulus.valueAsBigInteger!,
                ^
../../../../.pub-cache/hosted/pub.dev/crypton-2.1.0/lib/src/rsa/private_key.dart:33:25: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
        privateExponent.valueAsBigInteger!,
                        ^
../../../../.pub-cache/hosted/pub.dev/crypton-2.1.0/lib/src/rsa/public_key.dart:23:56: Warning: Operand of null-aware operation '!' has type 'Uint8List' which excludes null.
 - 'Uint8List' is from 'dart:typed_data'.
    final publicKeyAsn = ASN1Parser(publicKeyBitString.contentBytes()!);
                                                       ^
../../../../.pub-cache/hosted/pub.dev/crypton-2.1.0/lib/src/rsa/public_key.dart:29:17: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
        modulus.valueAsBigInteger!, exponent.valueAsBigInteger!);
                ^
../../../../.pub-cache/hosted/pub.dev/crypton-2.1.0/lib/src/rsa/public_key.dart:29:46: Warning: Operand of null-aware operation '!' has type 'BigInt' which excludes null.
 - 'BigInt' is from 'dart:core'.
        modulus.valueAsBigInteger!, exponent.valueAsBigInteger!);
                                             ^

I'm happy to make a fix and send a pull request if you wish

konstantinullrich commented 1 year ago

I'll see what I can do :)

gkc commented 1 year ago

Thanks! I have already got a local branch in my fork which resolves this. I'll push & send you a PR later today

konstantinullrich commented 1 year ago

Sure :) I'd be happy to see how you implemented it :)