From b9ad66e7ca3b810714894a61ad381fc8b0539286 Mon Sep 17 00:00:00 2001 From: HamdaanAliQuatil <96776914+HamdaanAliQuatil@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:32:41 +0530 Subject: [PATCH] Refactor RsaPssPrivateKey and RsaPssPublicKey Class (#169) * refactor: update rsapss-private-key rsapss-public-key * style: format dart code --- lib/src/impl_ffi/impl_ffi.dart | 6 ++ lib/src/impl_ffi/impl_ffi.rsapss.dart | 83 +++++++++++++++---- lib/src/impl_interface/impl_interface.dart | 3 + .../impl_interface/impl_interface.rsapss.dart | 44 ++++++++++ lib/src/impl_js/impl_js.dart | 6 ++ lib/src/impl_js/impl_js.rsapss.dart | 83 +++++++++++++++---- lib/src/impl_stub.dart | 31 ------- lib/src/impl_stub/impl_stub.dart | 7 ++ lib/src/impl_stub/impl_stub.rsapss.dart | 54 ++++++++++++ lib/src/webcrypto/webcrypto.rsapss.dart | 79 +++++++++++------- 10 files changed, 307 insertions(+), 89 deletions(-) create mode 100644 lib/src/impl_interface/impl_interface.rsapss.dart create mode 100644 lib/src/impl_stub/impl_stub.rsapss.dart diff --git a/lib/src/impl_ffi/impl_ffi.dart b/lib/src/impl_ffi/impl_ffi.dart index bfa0dcf1..b0766b9a 100644 --- a/lib/src/impl_ffi/impl_ffi.dart +++ b/lib/src/impl_ffi/impl_ffi.dart @@ -98,4 +98,10 @@ final class _WebCryptoImpl implements WebCryptoImpl { @override final hkdfSecretKey = const _StaticHkdfSecretKeyImpl(); + + @override + final rsaPssPrivateKey = const _StaticRsaPssPrivateKeyImpl(); + + @override + final rsaPssPublicKey = const _StaticRsaPssPublicKeyImpl(); } diff --git a/lib/src/impl_ffi/impl_ffi.rsapss.dart b/lib/src/impl_ffi/impl_ffi.rsapss.dart index 0ec309ea..27c9b78f 100644 --- a/lib/src/impl_ffi/impl_ffi.rsapss.dart +++ b/lib/src/impl_ffi/impl_ffi.rsapss.dart @@ -33,22 +33,22 @@ String _rsaPssJwkAlgFromHash(_Hash hash) { throw UnsupportedError('hash is not supported'); } -Future rsaPssPrivateKey_importPkcs8Key( +Future rsaPssPrivateKey_importPkcs8Key( List keyData, Hash hash, ) async { // Validate and get hash function final h = _Hash.fromHash(hash); - return _RsaPssPrivateKey(_importPkcs8RsaPrivateKey(keyData), h); + return _RsaPssPrivateKeyImpl(_importPkcs8RsaPrivateKey(keyData), h); } -Future rsaPssPrivateKey_importJsonWebKey( +Future rsaPssPrivateKey_importJsonWebKey( Map jwk, Hash hash, ) async { // Validate and get hash function final h = _Hash.fromHash(hash); - return _RsaPssPrivateKey( + return _RsaPssPrivateKeyImpl( _importJwkRsaPrivateOrPublicKey( JsonWebKey.fromJson(jwk), isPrivateKey: true, @@ -59,7 +59,8 @@ Future rsaPssPrivateKey_importJsonWebKey( ); } -Future> rsaPssPrivateKey_generateKey( +Future> + rsaPssPrivateKey_generateKey( int modulusLength, BigInt publicExponent, Hash hash, @@ -68,27 +69,27 @@ Future> rsaPssPrivateKey_generateKey( final h = _Hash.fromHash(hash); final keys = _generateRsaKeyPair(modulusLength, publicExponent); return createKeyPair( - _RsaPssPrivateKey(keys.privateKey, h), - _RsaPssPublicKey(keys.publicKey, h), + _RsaPssPrivateKeyImpl(keys.privateKey, h), + _RsaPssPublicKeyImpl(keys.publicKey, h), ); } -Future rsaPssPublicKey_importSpkiKey( +Future rsaPssPublicKey_importSpkiKey( List keyData, Hash hash, ) async { // Validate and get hash function final h = _Hash.fromHash(hash); - return _RsaPssPublicKey(_importSpkiRsaPublicKey(keyData), h); + return _RsaPssPublicKeyImpl(_importSpkiRsaPublicKey(keyData), h); } -Future rsaPssPublicKey_importJsonWebKey( +Future rsaPssPublicKey_importJsonWebKey( Map jwk, Hash hash, ) async { // Validate and get hash function final h = _Hash.fromHash(hash); - return _RsaPssPublicKey( + return _RsaPssPublicKeyImpl( _importJwkRsaPrivateOrPublicKey( JsonWebKey.fromJson(jwk), isPrivateKey: false, @@ -99,11 +100,43 @@ Future rsaPssPublicKey_importJsonWebKey( ); } -class _RsaPssPrivateKey implements RsaPssPrivateKey { +final class _StaticRsaPssPrivateKeyImpl implements StaticRsaPssPrivateKeyImpl { + const _StaticRsaPssPrivateKeyImpl(); + + @override + Future importPkcs8Key( + List keyData, + Hash hash, + ) async { + return await rsaPssPrivateKey_importPkcs8Key(keyData, hash); + } + + @override + Future importJsonWebKey( + Map jwk, + Hash hash, + ) async { + return await rsaPssPrivateKey_importJsonWebKey(jwk, hash); + } + + @override + Future<(RsaPssPrivateKeyImpl, RsaPssPublicKeyImpl)> generateKey( + int modulusLength, + BigInt publicExponent, + Hash hash, + ) async { + final KeyPair keyPair = + await rsaPssPrivateKey_generateKey(modulusLength, publicExponent, hash); + + return (keyPair.privateKey, keyPair.publicKey); + } +} + +final class _RsaPssPrivateKeyImpl implements RsaPssPrivateKeyImpl { final _EvpPKey _key; final _Hash _hash; - _RsaPssPrivateKey(this._key, this._hash); + _RsaPssPrivateKeyImpl(this._key, this._hash); @override String toString() { @@ -148,11 +181,31 @@ class _RsaPssPrivateKey implements RsaPssPrivateKey { Future exportPkcs8Key() async => _exportPkcs8Key(_key); } -class _RsaPssPublicKey implements RsaPssPublicKey { +final class _StaticRsaPssPublicKeyImpl implements StaticRsaPssPublicKeyImpl { + const _StaticRsaPssPublicKeyImpl(); + + @override + Future importSpkiKey( + List keyData, + Hash hash, + ) async { + return await rsaPssPublicKey_importSpkiKey(keyData, hash); + } + + @override + Future importJsonWebKey( + Map jwk, + Hash hash, + ) async { + return await rsaPssPublicKey_importJsonWebKey(jwk, hash); + } +} + +final class _RsaPssPublicKeyImpl implements RsaPssPublicKeyImpl { final _EvpPKey _key; final _Hash _hash; - _RsaPssPublicKey(this._key, this._hash); + _RsaPssPublicKeyImpl(this._key, this._hash); @override String toString() { diff --git a/lib/src/impl_interface/impl_interface.dart b/lib/src/impl_interface/impl_interface.dart index f04c5d01..9be5bcec 100644 --- a/lib/src/impl_interface/impl_interface.dart +++ b/lib/src/impl_interface/impl_interface.dart @@ -28,6 +28,7 @@ part 'impl_interface.ecdh.dart'; part 'impl_interface.ecdsa.dart'; part 'impl_interface.rsaoaep.dart'; part 'impl_interface.hkdf.dart'; +part 'impl_interface.rsapss.dart'; /// A key-pair as returned from key generation. class KeyPair { @@ -90,4 +91,6 @@ abstract interface class WebCryptoImpl { StaticRsaOaepPrivateKeyImpl get rsaOaepPrivateKey; StaticRsaOaepPublicKeyImpl get rsaOaepPublicKey; StaticHkdfSecretKeyImpl get hkdfSecretKey; + StaticRsaPssPrivateKeyImpl get rsaPssPrivateKey; + StaticRsaPssPublicKeyImpl get rsaPssPublicKey; } diff --git a/lib/src/impl_interface/impl_interface.rsapss.dart b/lib/src/impl_interface/impl_interface.rsapss.dart new file mode 100644 index 00000000..14570d1f --- /dev/null +++ b/lib/src/impl_interface/impl_interface.rsapss.dart @@ -0,0 +1,44 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +part of 'impl_interface.dart'; + +abstract interface class StaticRsaPssPrivateKeyImpl { + Future importPkcs8Key(List keyData, Hash hash); + Future importJsonWebKey( + Map jwk, Hash hash); + Future<(RsaPssPrivateKeyImpl, RsaPssPublicKeyImpl)> generateKey( + int modulusLength, BigInt publicExponent, Hash hash); +} + +abstract interface class RsaPssPrivateKeyImpl { + Future signBytes(List data, int saltLength); + Future signStream(Stream> data, int saltLength); + Future exportPkcs8Key(); + Future> exportJsonWebKey(); +} + +abstract interface class StaticRsaPssPublicKeyImpl { + Future importSpkiKey(List keyData, Hash hash); + Future importJsonWebKey( + Map jwk, Hash hash); +} + +abstract interface class RsaPssPublicKeyImpl { + Future verifyBytes(List signature, List data, int saltLength); + Future verifyStream( + List signature, Stream> data, int saltLength); + Future exportSpkiKey(); + Future> exportJsonWebKey(); +} diff --git a/lib/src/impl_js/impl_js.dart b/lib/src/impl_js/impl_js.dart index 4a45d31f..2b20c90f 100644 --- a/lib/src/impl_js/impl_js.dart +++ b/lib/src/impl_js/impl_js.dart @@ -85,4 +85,10 @@ final class _WebCryptoImpl implements WebCryptoImpl { @override final hkdfSecretKey = const _StaticHkdfSecretKeyImpl(); + + @override + final rsaPssPrivateKey = const _StaticRsaPssPrivateKeyImpl(); + + @override + final rsaPssPublicKey = const _StaticRsaPssPublicKeyImpl(); } diff --git a/lib/src/impl_js/impl_js.rsapss.dart b/lib/src/impl_js/impl_js.rsapss.dart index 741059b8..bb2b71dd 100644 --- a/lib/src/impl_js/impl_js.rsapss.dart +++ b/lib/src/impl_js/impl_js.rsapss.dart @@ -18,11 +18,11 @@ part of 'impl_js.dart'; const _rsaPssAlgorithmName = 'RSA-PSS'; -Future rsaPssPrivateKey_importPkcs8Key( +Future rsaPssPrivateKey_importPkcs8Key( List keyData, Hash hash, ) async { - return _RsaPssPrivateKey(await _importKey( + return _RsaPssPrivateKeyImpl(await _importKey( 'pkcs8', keyData, subtle.Algorithm(name: _rsaPssAlgorithmName, hash: _getHashAlgorithm(hash)), @@ -31,11 +31,11 @@ Future rsaPssPrivateKey_importPkcs8Key( )); } -Future rsaPssPrivateKey_importJsonWebKey( +Future rsaPssPrivateKey_importJsonWebKey( Map jwk, Hash hash, ) async { - return _RsaPssPrivateKey(await _importJsonWebKey( + return _RsaPssPrivateKeyImpl(await _importJsonWebKey( jwk, subtle.Algorithm(name: _rsaPssAlgorithmName, hash: _getHashAlgorithm(hash)), _usagesSign, @@ -43,7 +43,8 @@ Future rsaPssPrivateKey_importJsonWebKey( )); } -Future> rsaPssPrivateKey_generateKey( +Future> + rsaPssPrivateKey_generateKey( int modulusLength, BigInt publicExponent, Hash hash, @@ -58,16 +59,16 @@ Future> rsaPssPrivateKey_generateKey( _usagesSignVerify, ); return createKeyPair( - _RsaPssPrivateKey(pair.privateKey), - _RsaPssPublicKey(pair.publicKey), + _RsaPssPrivateKeyImpl(pair.privateKey), + _RsaPssPublicKeyImpl(pair.publicKey), ); } -Future rsaPssPublicKey_importSpkiKey( +Future rsaPssPublicKey_importSpkiKey( List keyData, Hash hash, ) async { - return _RsaPssPublicKey(await _importKey( + return _RsaPssPublicKeyImpl(await _importKey( 'spki', keyData, subtle.Algorithm(name: _rsaPssAlgorithmName, hash: _getHashAlgorithm(hash)), @@ -76,11 +77,11 @@ Future rsaPssPublicKey_importSpkiKey( )); } -Future rsaPssPublicKey_importJsonWebKey( +Future rsaPssPublicKey_importJsonWebKey( Map jwk, Hash hash, ) async { - return _RsaPssPublicKey(await _importJsonWebKey( + return _RsaPssPublicKeyImpl(await _importJsonWebKey( jwk, subtle.Algorithm(name: _rsaPssAlgorithmName, hash: _getHashAlgorithm(hash)), _usagesVerify, @@ -88,9 +89,41 @@ Future rsaPssPublicKey_importJsonWebKey( )); } -class _RsaPssPrivateKey implements RsaPssPrivateKey { +final class _StaticRsaPssPrivateKeyImpl implements StaticRsaPssPrivateKeyImpl { + const _StaticRsaPssPrivateKeyImpl(); + + @override + Future importPkcs8Key( + List keyData, + Hash hash, + ) async { + return await rsaPssPrivateKey_importPkcs8Key(keyData, hash); + } + + @override + Future importJsonWebKey( + Map jwk, + Hash hash, + ) async { + return await rsaPssPrivateKey_importJsonWebKey(jwk, hash); + } + + @override + Future<(RsaPssPrivateKeyImpl, RsaPssPublicKeyImpl)> generateKey( + int modulusLength, + BigInt publicExponent, + Hash hash, + ) async { + final KeyPair keyPair = + await rsaPssPrivateKey_generateKey(modulusLength, publicExponent, hash); + + return (keyPair.privateKey, keyPair.publicKey); + } +} + +final class _RsaPssPrivateKeyImpl implements RsaPssPrivateKeyImpl { final subtle.JSCryptoKey _key; - _RsaPssPrivateKey(this._key); + _RsaPssPrivateKeyImpl(this._key); @override String toString() { @@ -130,9 +163,29 @@ class _RsaPssPrivateKey implements RsaPssPrivateKey { } } -class _RsaPssPublicKey implements RsaPssPublicKey { +final class _StaticRsaPssPublicKeyImpl implements StaticRsaPssPublicKeyImpl { + const _StaticRsaPssPublicKeyImpl(); + + @override + Future importSpkiKey( + List keyData, + Hash hash, + ) async { + return await rsaPssPublicKey_importSpkiKey(keyData, hash); + } + + @override + Future importJsonWebKey( + Map jwk, + Hash hash, + ) async { + return await rsaPssPublicKey_importJsonWebKey(jwk, hash); + } +} + +final class _RsaPssPublicKeyImpl implements RsaPssPublicKeyImpl { final subtle.JSCryptoKey _key; - _RsaPssPublicKey(this._key); + _RsaPssPublicKeyImpl(this._key); @override String toString() { diff --git a/lib/src/impl_stub.dart b/lib/src/impl_stub.dart index cb814484..e72b7e1e 100644 --- a/lib/src/impl_stub.dart +++ b/lib/src/impl_stub.dart @@ -81,37 +81,6 @@ Future rsassaPkcs1V15PublicKey_importJsonWebKey( //---------------------- RSA-PSS -Future rsaPssPrivateKey_importPkcs8Key( - List keyData, - Hash hash, -) => - throw _notImplemented; - -Future rsaPssPrivateKey_importJsonWebKey( - Map jwk, - Hash hash, -) => - throw _notImplemented; - -Future> rsaPssPrivateKey_generateKey( - int modulusLength, - BigInt publicExponent, - Hash hash, -) => - throw _notImplemented; - -Future rsaPssPublicKey_importSpkiKey( - List keyData, - Hash hash, -) => - throw _notImplemented; - -Future rsaPssPublicKey_importJsonWebKey( - Map jwk, - Hash hash, -) => - throw _notImplemented; - //---------------------- ECDSA //---------------------- RSA-OAEP diff --git a/lib/src/impl_stub/impl_stub.dart b/lib/src/impl_stub/impl_stub.dart index 6f7f08d9..2ede5cc0 100644 --- a/lib/src/impl_stub/impl_stub.dart +++ b/lib/src/impl_stub/impl_stub.dart @@ -27,6 +27,7 @@ part 'impl_stub.ecdh.dart'; part 'impl_stub.ecdsa.dart'; part 'impl_stub.rsaoaep.dart'; part 'impl_stub.hkdf.dart'; +part 'impl_stub.rsapss.dart'; const WebCryptoImpl webCryptImpl = _WebCryptoImpl(); @@ -68,4 +69,10 @@ final class _WebCryptoImpl implements WebCryptoImpl { @override final hkdfSecretKey = const _StaticHkdfSecretKeyImpl(); + + @override + final rsaPssPrivateKey = const _StaticRsaPssPrivateKeyImpl(); + + @override + final rsaPssPublicKey = const _StaticRsaPssPublicKeyImpl(); } diff --git a/lib/src/impl_stub/impl_stub.rsapss.dart b/lib/src/impl_stub/impl_stub.rsapss.dart new file mode 100644 index 00000000..c3b1d9bd --- /dev/null +++ b/lib/src/impl_stub/impl_stub.rsapss.dart @@ -0,0 +1,54 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +part of 'impl_stub.dart'; + +final class _StaticRsaPssPrivateKeyImpl implements StaticRsaPssPrivateKeyImpl { + const _StaticRsaPssPrivateKeyImpl(); + + Future importPkcs8Key( + List keyData, + Hash hash, + ) => + throw UnimplementedError('Not implemented'); + + Future importJsonWebKey( + Map jwk, + Hash hash, + ) => + throw UnimplementedError('Not implemented'); + + Future<(RsaPssPrivateKeyImpl, RsaPssPublicKeyImpl)> generateKey( + int modulusLength, + BigInt publicExponent, + Hash hash, + ) => + throw UnimplementedError('Not implemented'); +} + +final class _StaticRsaPssPublicKeyImpl implements StaticRsaPssPublicKeyImpl { + const _StaticRsaPssPublicKeyImpl(); + + Future importSpkiKey( + List keyData, + Hash hash, + ) => + throw UnimplementedError('Not implemented'); + + Future importJsonWebKey( + Map jwk, + Hash hash, + ) => + throw UnimplementedError('Not implemented'); +} diff --git a/lib/src/webcrypto/webcrypto.rsapss.dart b/lib/src/webcrypto/webcrypto.rsapss.dart index 2d06f6f2..969f70b2 100644 --- a/lib/src/webcrypto/webcrypto.rsapss.dart +++ b/lib/src/webcrypto/webcrypto.rsapss.dart @@ -64,9 +64,14 @@ part of 'webcrypto.dart'; /// [1]: https://tools.ietf.org/html/rfc3447 /// [2]: https://tools.ietf.org/html/rfc5208 /// [3]: https://tools.ietf.org/html/rfc7517 -@sealed -abstract class RsaPssPrivateKey { - RsaPssPrivateKey._(); // keep the constructor private. +final class RsaPssPrivateKey { + final RsaPssPrivateKeyImpl _impl; + + RsaPssPrivateKey._(this._impl); // keep the constructor private. + + factory RsaPssPrivateKey(RsaPssPrivateKeyImpl impl) { + return RsaPssPrivateKey._(impl); + } /// Import RSASSA-PSS private key in PKCS #8 format. /// @@ -104,8 +109,10 @@ abstract class RsaPssPrivateKey { static Future importPkcs8Key( List keyData, Hash hash, - ) { - return impl.rsaPssPrivateKey_importPkcs8Key(keyData, hash); + ) async { + final impl = + await webCryptImpl.rsaPssPrivateKey.importPkcs8Key(keyData, hash); + return RsaPssPrivateKey._(impl); } /// Import RSASSA-PSS private key in [JSON Web Key][1] format. @@ -151,8 +158,10 @@ abstract class RsaPssPrivateKey { static Future importJsonWebKey( Map jwk, Hash hash, - ) { - return impl.rsaPssPrivateKey_importJsonWebKey(jwk, hash); + ) async { + final impl = + await webCryptImpl.rsaPssPrivateKey.importJsonWebKey(jwk, hash); + return RsaPssPrivateKey._(impl); } /// Generate an RSASSA-PSS public/private key-pair. @@ -207,12 +216,14 @@ abstract class RsaPssPrivateKey { int modulusLength, BigInt publicExponent, Hash hash, - ) { - return impl.rsaPssPrivateKey_generateKey( - modulusLength, - publicExponent, - hash, - ); + ) async { + final (privateKeyImpl, publicKeyImpl) = await webCryptImpl.rsaPssPrivateKey + .generateKey(modulusLength, publicExponent, hash); + + final privateKey = RsaPssPrivateKey(privateKeyImpl); + final publicKey = RsaPssPublicKey(publicKeyImpl); + + return createKeyPair(privateKey, publicKey); } /// Sign [data] with this RSASSA-PSS private key. @@ -286,7 +297,8 @@ abstract class RsaPssPrivateKey { // Which makes it hard for us to say that it's not useful. // // Note: Web Cryptography specification references RFC 3447, not FIPS 186-4. - Future signBytes(List data, int saltLength); + Future signBytes(List data, int saltLength) => + _impl.signBytes(data, saltLength); /// Sign [data] with this RSASSA-PSS private key. /// @@ -340,7 +352,8 @@ abstract class RsaPssPrivateKey { /// /// [1]: https://tools.ietf.org/html/rfc3447#section-9.1 /// [2]: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf - Future signStream(Stream> data, int saltLength); + Future signStream(Stream> data, int saltLength) => + _impl.signStream(data, saltLength); /// Export this RSASSA-PSS private key in PKCS #8 format. /// @@ -369,7 +382,7 @@ abstract class RsaPssPrivateKey { /// ``` /// /// [1]: https://tools.ietf.org/html/rfc5208 - Future exportPkcs8Key(); + Future exportPkcs8Key() => _impl.exportPkcs8Key(); /// Export RSASSA-PSS private key in [JSON Web Key][1] format. /// @@ -397,7 +410,7 @@ abstract class RsaPssPrivateKey { /// ``` /// /// [1]: https://tools.ietf.org/html/rfc7517 - Future> exportJsonWebKey(); + Future> exportJsonWebKey() => _impl.exportJsonWebKey(); } /// RSASSA-PSS public key for verifying signatures. @@ -417,9 +430,14 @@ abstract class RsaPssPrivateKey { /// [1]: https://tools.ietf.org/html/rfc3447 /// [2]: https://tools.ietf.org/html/rfc5280 /// [3]: https://tools.ietf.org/html/rfc7517 -@sealed -abstract class RsaPssPublicKey { - RsaPssPublicKey._(); // keep the constructor private. +final class RsaPssPublicKey { + final RsaPssPublicKeyImpl _impl; + + RsaPssPublicKey._(this._impl); // keep the constructor private. + + factory RsaPssPublicKey(RsaPssPublicKeyImpl impl) { + return RsaPssPublicKey._(impl); + } /// Import RSASSA-PSS public key in SPKI format. /// @@ -457,8 +475,10 @@ abstract class RsaPssPublicKey { static Future importSpkiKey( List keyData, Hash hash, - ) { - return impl.rsaPssPublicKey_importSpkiKey(keyData, hash); + ) async { + final impl = + await webCryptImpl.rsaPssPublicKey.importSpkiKey(keyData, hash); + return RsaPssPublicKey._(impl); } /// Import RSASSA-PSS public key in [JSON Web Key][1] format. @@ -498,8 +518,9 @@ abstract class RsaPssPublicKey { static Future importJsonWebKey( Map jwk, Hash hash, - ) { - return impl.rsaPssPublicKey_importJsonWebKey(jwk, hash); + ) async { + final impl = await webCryptImpl.rsaPssPublicKey.importJsonWebKey(jwk, hash); + return RsaPssPublicKey._(impl); } /// Verify [signature] of [data] using this RSASSA-PSS public key. @@ -547,7 +568,8 @@ abstract class RsaPssPublicKey { List signature, List data, int saltLength, - ); + ) => + _impl.verifyBytes(signature, data, saltLength); /// Verify [signature] of [data] using this RSASSA-PSS public key. /// @@ -593,7 +615,8 @@ abstract class RsaPssPublicKey { List signature, Stream> data, int saltLength, - ); + ) => + _impl.verifyStream(signature, data, saltLength); /// Export RSASSA-PSS public key in SPKI format. /// @@ -622,7 +645,7 @@ abstract class RsaPssPublicKey { /// ``` /// /// [1]: https://tools.ietf.org/html/rfc5280 - Future exportSpkiKey(); + Future exportSpkiKey() => _impl.exportSpkiKey(); /// Export RSASSA-PSS public key in [JSON Web Key][1] format. /// @@ -650,5 +673,5 @@ abstract class RsaPssPublicKey { /// ``` /// /// [1]: https://tools.ietf.org/html/rfc7517 - Future> exportJsonWebKey(); + Future> exportJsonWebKey() => _impl.exportJsonWebKey(); }