Skip to content

Override toString for All Private Classes #110

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

Merged
merged 2 commits into from
May 27, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.aescbc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ class _AesCbcSecretKey implements AesCbcSecretKey {
final Uint8List _key;
_AesCbcSecretKey(this._key);

@override
String toString() {
return 'Instance of \'AesCbcSecretKey\'';
}

@override
Future<Uint8List> decryptBytes(List<int> data, List<int> iv) async =>
await _bufferStream(decryptStream(Stream.value(data), iv));
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.aesctr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ class _AesCtrSecretKey implements AesCtrSecretKey {
final Uint8List _key;
_AesCtrSecretKey(this._key);

@override
String toString() {
return 'Instance of \'AesCtrSecretKey\'';
}

void _checkArguments(
List<int> counter,
int length,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.aesgcm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class _AesGcmSecretKey implements AesGcmSecretKey {
final Uint8List _key;
_AesGcmSecretKey(this._key);

@override
String toString() {
return 'Instance of \'AesGcmSecretKey\'';
}

@override
Future<Uint8List> decryptBytes(
List<int> data,
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_ffi/impl_ffi.ecdh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ class _EcdhPrivateKey implements EcdhPrivateKey {

_EcdhPrivateKey(this._key);

@override
String toString() {
return 'Instance of \'EcdhPrivateKey\'';
}

@override
Future<Uint8List> deriveBits(int length, EcdhPublicKey publicKey) async {
if (publicKey is! _EcdhPublicKey) {
Expand Down Expand Up @@ -167,6 +172,11 @@ class _EcdhPublicKey implements EcdhPublicKey {

_EcdhPublicKey(this._key);

@override
String toString() {
return 'Instance of \'EcdhPublicKey\'';
}

@override
Future<Map<String, dynamic>> exportJsonWebKey() async =>
// Neither Chrome or Firefox produces 'use': 'enc' for ECDH, we choose to
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_ffi/impl_ffi.ecdsa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ class _EcdsaPrivateKey implements EcdsaPrivateKey {

_EcdsaPrivateKey(this._key);

@override
String toString() {
return 'Instance of \'EcdsaPrivateKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data, Hash hash) =>
signStream(Stream.value(data), hash);
Expand All @@ -209,6 +214,11 @@ class _EcdsaPublicKey implements EcdsaPublicKey {

_EcdsaPublicKey(this._key);

@override
String toString() {
return 'Instance of \'EcdsaPublicKey\'';
}

@override
Future<bool> verifyBytes(List<int> signature, List<int> data, Hash hash) =>
verifyStream(signature, Stream.value(data), hash);
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.hkdf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class _HkdfSecretKey implements HkdfSecretKey {

_HkdfSecretKey(this._key);

@override
String toString() {
return 'Instance of \'HkdfSecretKey\'';
}

@override
Future<Uint8List> deriveBits(
int length,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.hmac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class _HmacSecretKey implements HmacSecretKey {

_HmacSecretKey(this._keyData, this._hash);

@override
String toString() {
return 'Instance of \'HmacSecretKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data) => signStream(Stream.value(data));

Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.pbkdf2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class _Pbkdf2SecretKey implements Pbkdf2SecretKey {

_Pbkdf2SecretKey(this._key);

@override
String toString() {
return 'Instance of \'Pbkdf2SecretKey\'';
}

@override
Future<Uint8List> deriveBits(
int length,
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_ffi/impl_ffi.rsaoaep.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ class _RsaOaepPrivateKey implements RsaOaepPrivateKey {

_RsaOaepPrivateKey(this._key, this._hash);

@override
String toString() {
return 'Instance of \'RsaOaepPrivateKey\'';
}

@override
Future<Uint8List> decryptBytes(List<int> data, {List<int>? label}) async {
return _rsaOaepeEncryptOrDecryptBytes(
Expand Down Expand Up @@ -204,6 +209,11 @@ class _RsaOaepPublicKey implements RsaOaepPublicKey {

_RsaOaepPublicKey(this._key, this._hash);

@override
String toString() {
return 'Instance of \'RsaOaepPublicKey\'';
}

@override
Future<Uint8List> encryptBytes(List<int> data, {List<int>? label}) async {
return _rsaOaepeEncryptOrDecryptBytes(
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_ffi/impl_ffi.rsapss.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class _RsaPssPrivateKey implements RsaPssPrivateKey {

_RsaPssPrivateKey(this._key, this._hash);

@override
String toString() {
return 'Instance of \'RsaPssPrivateKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data, int saltLength) {
return signStream(Stream.value(data), saltLength);
Expand Down Expand Up @@ -149,6 +154,11 @@ class _RsaPssPublicKey implements RsaPssPublicKey {

_RsaPssPublicKey(this._key, this._hash);

@override
String toString() {
return 'Instance of \'RsaPssPublicKey\'';
}

@override
Future<bool> verifyBytes(
List<int> signature,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_ffi/impl_ffi.rsassapkcs1v15.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ class _RsassaPkcs1V15PrivateKey implements RsassaPkcs1V15PrivateKey {

_RsassaPkcs1V15PrivateKey(this._key, this._hash);

@override
String toString() {
return 'Instance of \'RsassaPkcs1V15PrivateKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data) => signStream(Stream.value(data));

Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.aescbc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class _AesCbcSecretKey implements AesCbcSecretKey {
final subtle.JSCryptoKey _key;
_AesCbcSecretKey(this._key);

@override
String toString() {
return 'Instance of \'AesCbcSecretKey\'';
}

@override
Future<Uint8List> decryptBytes(List<int> data, List<int> iv) async {
return await _decrypt(
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.aesctr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class _AesCtrSecretKey implements AesCtrSecretKey {
final subtle.JSCryptoKey _key;
_AesCtrSecretKey(this._key);

@override
String toString() {
return 'Instance of \'AesCtrSecretKey\'';
}

@override
Future<Uint8List> decryptBytes(
List<int> data,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.aesgcm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class _AesGcmSecretKey implements AesGcmSecretKey {
final subtle.JSCryptoKey _key;
_AesGcmSecretKey(this._key);

@override
String toString() {
return 'Instance of \'AesGcmSecretKey\'';
}

@override
Future<Uint8List> decryptBytes(
List<int> data,
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_js/impl_js.ecdh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ class _EcdhPrivateKey implements EcdhPrivateKey {
final subtle.JSCryptoKey _key;
_EcdhPrivateKey(this._key);

@override
String toString() {
return 'Instance of \'EcdhPrivateKey\'';
}

@override
Future<Uint8List> deriveBits(int length, EcdhPublicKey publicKey) async {
if (publicKey is! _EcdhPublicKey) {
Expand Down Expand Up @@ -175,6 +180,11 @@ class _EcdhPublicKey implements EcdhPublicKey {
final subtle.JSCryptoKey _key;
_EcdhPublicKey(this._key);

@override
String toString() {
return 'Instance of \'EcdhPublicKey\'';
}

@override
Future<Map<String, dynamic>> exportJsonWebKey() async {
return await _exportJsonWebKey(_key);
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_js/impl_js.ecdsa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class _EcdsaPrivateKey implements EcdsaPrivateKey {
final subtle.JSCryptoKey _key;
_EcdsaPrivateKey(this._key);

@override
String toString() {
return 'Instance of \'EcdsaPrivateKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data, Hash hash) async {
return await _sign(
Expand Down Expand Up @@ -148,6 +153,11 @@ class _EcdsaPublicKey implements EcdsaPublicKey {
final subtle.JSCryptoKey _key;
_EcdsaPublicKey(this._key);

@override
String toString() {
return 'Instance of \'EcdsaPublicKey\'';
}

@override
Future<bool> verifyBytes(
List<int> signature, List<int> data, Hash hash) async {
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.hkdf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class _HkdfSecretKey implements HkdfSecretKey {
final subtle.JSCryptoKey _key;
_HkdfSecretKey(this._key);

@override
String toString() {
return 'Instance of \'HkdfSecretKey\'';
}

@override
Future<Uint8List> deriveBits(
int length,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.hmac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class _HmacSecretKey implements HmacSecretKey {
final subtle.JSCryptoKey _key;
_HmacSecretKey(this._key);

@override
String toString() {
return 'Instance of \'HmacSecretKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data) async {
return await _sign(_hmacAlgorithm, _key, data);
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.pbkdf2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class _Pbkdf2SecretKey implements Pbkdf2SecretKey {
final subtle.JSCryptoKey _key;
_Pbkdf2SecretKey(this._key);

@override
String toString() {
return 'Instance of \'Pbkdf2SecretKey\'';
}

@override
Future<Uint8List> deriveBits(
int length,
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_js/impl_js.rsaoaep.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class _RsaOaepPrivateKey implements RsaOaepPrivateKey {
final subtle.JSCryptoKey _key;
_RsaOaepPrivateKey(this._key);

@override
String toString() {
return 'Instance of \'RsaOaepPrivateKey\'';
}

@override
Future<Uint8List> decryptBytes(List<int> data, {List<int>? label}) async {
return _decrypt(
Expand Down Expand Up @@ -134,6 +139,11 @@ class _RsaOaepPublicKey implements RsaOaepPublicKey {
final subtle.JSCryptoKey _key;
_RsaOaepPublicKey(this._key);

@override
String toString() {
return 'Instance of \'RsaOaepPublicKey\'';
}

@override
Future<Uint8List> encryptBytes(List<int> data, {List<int>? label}) async {
return _encrypt(
Expand Down
10 changes: 10 additions & 0 deletions lib/src/impl_js/impl_js.rsapss.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class _RsaPssPrivateKey implements RsaPssPrivateKey {
final subtle.JSCryptoKey _key;
_RsaPssPrivateKey(this._key);

@override
String toString() {
return 'Instance of \'RsaPssPrivateKey\'';
}

@override
Future<Uint8List> signBytes(List<int> data, int saltLength) async {
if (saltLength < 0) {
Expand Down Expand Up @@ -129,6 +134,11 @@ class _RsaPssPublicKey implements RsaPssPublicKey {
final subtle.JSCryptoKey _key;
_RsaPssPublicKey(this._key);

@override
String toString() {
return 'Instance of \'RsaPssPublicKey\'';
}

@override
Future<bool> verifyBytes(
List<int> signature,
Expand Down
5 changes: 5 additions & 0 deletions lib/src/impl_js/impl_js.rsassapkcs1v15.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ class _RsassaPkcs1V15PublicKey implements RsassaPkcs1V15PublicKey {
final subtle.JSCryptoKey _key;
_RsassaPkcs1V15PublicKey(this._key);

@override
String toString() {
return 'Instance of \'RsassaPkcs1V15PublicKey\'';
}

@override
Future<bool> verifyBytes(List<int> signature, List<int> data) async {
return await _verify(_rsassaPkcs1V15Algorithm, _key, signature, data);
Expand Down
Loading