@@ -33,22 +33,22 @@ String _rsaOaepJwkAlgFromHash(_Hash hash) {
33
33
throw UnsupportedError ('hash is not supported' );
34
34
}
35
35
36
- Future <RsaOaepPrivateKey > rsaOaepPrivateKey_importPkcs8Key (
36
+ Future <RsaOaepPrivateKeyImpl > rsaOaepPrivateKey_importPkcs8Key (
37
37
List <int > keyData,
38
38
Hash hash,
39
39
) async {
40
40
// Get hash first, to avoid a leak of EVP_PKEY if _Hash.fromHash throws
41
41
final h = _Hash .fromHash (hash);
42
- return _RsaOaepPrivateKey (_importPkcs8RsaPrivateKey (keyData), h);
42
+ return _RsaOaepPrivateKeyImpl (_importPkcs8RsaPrivateKey (keyData), h);
43
43
}
44
44
45
- Future <RsaOaepPrivateKey > rsaOaepPrivateKey_importJsonWebKey (
45
+ Future <RsaOaepPrivateKeyImpl > rsaOaepPrivateKey_importJsonWebKey (
46
46
Map <String , dynamic > jwk,
47
47
Hash hash,
48
48
) async {
49
49
// Get hash first, to avoid a leak of EVP_PKEY if _Hash.fromHash throws
50
50
final h = _Hash .fromHash (hash);
51
- return _RsaOaepPrivateKey (
51
+ return _RsaOaepPrivateKeyImpl (
52
52
_importJwkRsaPrivateOrPublicKey (
53
53
JsonWebKey .fromJson (jwk),
54
54
isPrivateKey: true ,
@@ -59,7 +59,7 @@ Future<RsaOaepPrivateKey> rsaOaepPrivateKey_importJsonWebKey(
59
59
);
60
60
}
61
61
62
- Future <KeyPair <RsaOaepPrivateKey , RsaOaepPublicKey >>
62
+ Future <KeyPair <RsaOaepPrivateKeyImpl , RsaOaepPublicKeyImpl >>
63
63
rsaOaepPrivateKey_generateKey (
64
64
int modulusLength,
65
65
BigInt publicExponent,
@@ -69,27 +69,27 @@ Future<KeyPair<RsaOaepPrivateKey, RsaOaepPublicKey>>
69
69
final h = _Hash .fromHash (hash);
70
70
final keys = _generateRsaKeyPair (modulusLength, publicExponent);
71
71
return createKeyPair (
72
- _RsaOaepPrivateKey (keys.privateKey, h),
73
- _RsaOaepPublicKey (keys.publicKey, h),
72
+ _RsaOaepPrivateKeyImpl (keys.privateKey, h),
73
+ _RsaOaepPublicKeyImpl (keys.publicKey, h),
74
74
);
75
75
}
76
76
77
- Future <RsaOaepPublicKey > rsaOaepPublicKey_importSpkiKey (
77
+ Future <RsaOaepPublicKeyImpl > rsaOaepPublicKey_importSpkiKey (
78
78
List <int > keyData,
79
79
Hash hash,
80
80
) async {
81
81
// Get hash first, to avoid a leak of EVP_PKEY if _Hash.fromHash throws
82
82
final h = _Hash .fromHash (hash);
83
- return _RsaOaepPublicKey (_importSpkiRsaPublicKey (keyData), h);
83
+ return _RsaOaepPublicKeyImpl (_importSpkiRsaPublicKey (keyData), h);
84
84
}
85
85
86
- Future <RsaOaepPublicKey > rsaOaepPublicKey_importJsonWebKey (
86
+ Future <RsaOaepPublicKeyImpl > rsaOaepPublicKey_importJsonWebKey (
87
87
Map <String , dynamic > jwk,
88
88
Hash hash,
89
89
) async {
90
90
// Get hash first, to avoid a leak of EVP_PKEY if _Hash.fromHash throws
91
91
final h = _Hash .fromHash (hash);
92
- return _RsaOaepPublicKey (
92
+ return _RsaOaepPublicKeyImpl (
93
93
_importJwkRsaPrivateOrPublicKey (
94
94
JsonWebKey .fromJson (jwk),
95
95
isPrivateKey: false ,
@@ -167,11 +167,40 @@ Future<Uint8List> _rsaOaepeEncryptOrDecryptBytes(
167
167
});
168
168
}
169
169
170
- class _RsaOaepPrivateKey implements RsaOaepPrivateKey {
170
+ final class _StaticRsaOaepPrivateKeyImpl
171
+ implements StaticRsaOaepPrivateKeyImpl {
172
+ const _StaticRsaOaepPrivateKeyImpl ();
173
+
174
+ @override
175
+ Future <RsaOaepPrivateKeyImpl > importPkcs8Key (List <int > keyData, Hash hash) =>
176
+ rsaOaepPrivateKey_importPkcs8Key (keyData, hash);
177
+
178
+ @override
179
+ Future <RsaOaepPrivateKeyImpl > importJsonWebKey (
180
+ Map <String , dynamic > jwk,
181
+ Hash hash,
182
+ ) =>
183
+ rsaOaepPrivateKey_importJsonWebKey (jwk, hash);
184
+
185
+ @override
186
+ Future <(RsaOaepPrivateKeyImpl , RsaOaepPublicKeyImpl )> generateKey (
187
+ int modulusLength,
188
+ BigInt publicExponent,
189
+ Hash hash,
190
+ ) async {
191
+ final KeyPair <RsaOaepPrivateKeyImpl , RsaOaepPublicKeyImpl > keyPair =
192
+ await rsaOaepPrivateKey_generateKey (
193
+ modulusLength, publicExponent, hash);
194
+
195
+ return (keyPair.privateKey, keyPair.publicKey);
196
+ }
197
+ }
198
+
199
+ final class _RsaOaepPrivateKeyImpl implements RsaOaepPrivateKeyImpl {
171
200
final _EvpPKey _key;
172
201
final _Hash _hash;
173
202
174
- _RsaOaepPrivateKey (this ._key, this ._hash);
203
+ _RsaOaepPrivateKeyImpl (this ._key, this ._hash);
175
204
176
205
@override
177
206
String toString () {
@@ -203,11 +232,29 @@ class _RsaOaepPrivateKey implements RsaOaepPrivateKey {
203
232
Future <Uint8List > exportPkcs8Key () async => _exportPkcs8Key (_key);
204
233
}
205
234
206
- class _RsaOaepPublicKey implements RsaOaepPublicKey {
235
+ final class _StaticRsaOaepPublicKeyImpl implements StaticRsaOaepPublicKeyImpl {
236
+ const _StaticRsaOaepPublicKeyImpl ();
237
+
238
+ @override
239
+ Future <RsaOaepPublicKeyImpl > importSpkiKey (
240
+ List <int > keyData,
241
+ Hash hash,
242
+ ) =>
243
+ rsaOaepPublicKey_importSpkiKey (keyData, hash);
244
+
245
+ @override
246
+ Future <RsaOaepPublicKeyImpl > importJsonWebKey (
247
+ Map <String , dynamic > jwk,
248
+ Hash hash,
249
+ ) =>
250
+ rsaOaepPublicKey_importJsonWebKey (jwk, hash);
251
+ }
252
+
253
+ final class _RsaOaepPublicKeyImpl implements RsaOaepPublicKeyImpl {
207
254
final _EvpPKey _key;
208
255
final _Hash _hash;
209
256
210
- _RsaOaepPublicKey (this ._key, this ._hash);
257
+ _RsaOaepPublicKeyImpl (this ._key, this ._hash);
211
258
212
259
@override
213
260
String toString () {
0 commit comments