@@ -33,22 +33,22 @@ String _rsaPssJwkAlgFromHash(_Hash hash) {
3333 throw UnsupportedError ('hash is not supported' );
3434}
3535
36- Future <RsaPssPrivateKey > rsaPssPrivateKey_importPkcs8Key (
36+ Future <RsaPssPrivateKeyImpl > rsaPssPrivateKey_importPkcs8Key (
3737 List <int > keyData,
3838 Hash hash,
3939) async {
4040 // Validate and get hash function
4141 final h = _Hash .fromHash (hash);
42- return _RsaPssPrivateKey (_importPkcs8RsaPrivateKey (keyData), h);
42+ return _RsaPssPrivateKeyImpl (_importPkcs8RsaPrivateKey (keyData), h);
4343}
4444
45- Future <RsaPssPrivateKey > rsaPssPrivateKey_importJsonWebKey (
45+ Future <RsaPssPrivateKeyImpl > rsaPssPrivateKey_importJsonWebKey (
4646 Map <String , dynamic > jwk,
4747 Hash hash,
4848) async {
4949 // Validate and get hash function
5050 final h = _Hash .fromHash (hash);
51- return _RsaPssPrivateKey (
51+ return _RsaPssPrivateKeyImpl (
5252 _importJwkRsaPrivateOrPublicKey (
5353 JsonWebKey .fromJson (jwk),
5454 isPrivateKey: true ,
@@ -59,7 +59,8 @@ Future<RsaPssPrivateKey> rsaPssPrivateKey_importJsonWebKey(
5959 );
6060}
6161
62- Future <KeyPair <RsaPssPrivateKey , RsaPssPublicKey >> rsaPssPrivateKey_generateKey (
62+ Future <KeyPair <RsaPssPrivateKeyImpl , RsaPssPublicKeyImpl >>
63+ rsaPssPrivateKey_generateKey (
6364 int modulusLength,
6465 BigInt publicExponent,
6566 Hash hash,
@@ -68,27 +69,27 @@ Future<KeyPair<RsaPssPrivateKey, RsaPssPublicKey>> rsaPssPrivateKey_generateKey(
6869 final h = _Hash .fromHash (hash);
6970 final keys = _generateRsaKeyPair (modulusLength, publicExponent);
7071 return createKeyPair (
71- _RsaPssPrivateKey (keys.privateKey, h),
72- _RsaPssPublicKey (keys.publicKey, h),
72+ _RsaPssPrivateKeyImpl (keys.privateKey, h),
73+ _RsaPssPublicKeyImpl (keys.publicKey, h),
7374 );
7475}
7576
76- Future <RsaPssPublicKey > rsaPssPublicKey_importSpkiKey (
77+ Future <RsaPssPublicKeyImpl > rsaPssPublicKey_importSpkiKey (
7778 List <int > keyData,
7879 Hash hash,
7980) async {
8081 // Validate and get hash function
8182 final h = _Hash .fromHash (hash);
82- return _RsaPssPublicKey (_importSpkiRsaPublicKey (keyData), h);
83+ return _RsaPssPublicKeyImpl (_importSpkiRsaPublicKey (keyData), h);
8384}
8485
85- Future <RsaPssPublicKey > rsaPssPublicKey_importJsonWebKey (
86+ Future <RsaPssPublicKeyImpl > rsaPssPublicKey_importJsonWebKey (
8687 Map <String , dynamic > jwk,
8788 Hash hash,
8889) async {
8990 // Validate and get hash function
9091 final h = _Hash .fromHash (hash);
91- return _RsaPssPublicKey (
92+ return _RsaPssPublicKeyImpl (
9293 _importJwkRsaPrivateOrPublicKey (
9394 JsonWebKey .fromJson (jwk),
9495 isPrivateKey: false ,
@@ -99,11 +100,43 @@ Future<RsaPssPublicKey> rsaPssPublicKey_importJsonWebKey(
99100 );
100101}
101102
102- class _RsaPssPrivateKey implements RsaPssPrivateKey {
103+ final class _StaticRsaPssPrivateKeyImpl implements StaticRsaPssPrivateKeyImpl {
104+ const _StaticRsaPssPrivateKeyImpl ();
105+
106+ @override
107+ Future <RsaPssPrivateKeyImpl > importPkcs8Key (
108+ List <int > keyData,
109+ Hash hash,
110+ ) async {
111+ return await rsaPssPrivateKey_importPkcs8Key (keyData, hash);
112+ }
113+
114+ @override
115+ Future <RsaPssPrivateKeyImpl > importJsonWebKey (
116+ Map <String , dynamic > jwk,
117+ Hash hash,
118+ ) async {
119+ return await rsaPssPrivateKey_importJsonWebKey (jwk, hash);
120+ }
121+
122+ @override
123+ Future <(RsaPssPrivateKeyImpl , RsaPssPublicKeyImpl )> generateKey (
124+ int modulusLength,
125+ BigInt publicExponent,
126+ Hash hash,
127+ ) async {
128+ final KeyPair <RsaPssPrivateKeyImpl , RsaPssPublicKeyImpl > keyPair =
129+ await rsaPssPrivateKey_generateKey (modulusLength, publicExponent, hash);
130+
131+ return (keyPair.privateKey, keyPair.publicKey);
132+ }
133+ }
134+
135+ final class _RsaPssPrivateKeyImpl implements RsaPssPrivateKeyImpl {
103136 final _EvpPKey _key;
104137 final _Hash _hash;
105138
106- _RsaPssPrivateKey (this ._key, this ._hash);
139+ _RsaPssPrivateKeyImpl (this ._key, this ._hash);
107140
108141 @override
109142 String toString () {
@@ -148,11 +181,31 @@ class _RsaPssPrivateKey implements RsaPssPrivateKey {
148181 Future <Uint8List > exportPkcs8Key () async => _exportPkcs8Key (_key);
149182}
150183
151- class _RsaPssPublicKey implements RsaPssPublicKey {
184+ final class _StaticRsaPssPublicKeyImpl implements StaticRsaPssPublicKeyImpl {
185+ const _StaticRsaPssPublicKeyImpl ();
186+
187+ @override
188+ Future <RsaPssPublicKeyImpl > importSpkiKey (
189+ List <int > keyData,
190+ Hash hash,
191+ ) async {
192+ return await rsaPssPublicKey_importSpkiKey (keyData, hash);
193+ }
194+
195+ @override
196+ Future <RsaPssPublicKeyImpl > importJsonWebKey (
197+ Map <String , dynamic > jwk,
198+ Hash hash,
199+ ) async {
200+ return await rsaPssPublicKey_importJsonWebKey (jwk, hash);
201+ }
202+ }
203+
204+ final class _RsaPssPublicKeyImpl implements RsaPssPublicKeyImpl {
152205 final _EvpPKey _key;
153206 final _Hash _hash;
154207
155- _RsaPssPublicKey (this ._key, this ._hash);
208+ _RsaPssPublicKeyImpl (this ._key, this ._hash);
156209
157210 @override
158211 String toString () {
0 commit comments