File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,29 @@ abstract class EcdhPrivateKey {
204
204
// https://tools.ietf.org/html/rfc6090#appendix-B
205
205
Future <Uint8List > deriveBits (int length, EcdhPublicKey publicKey);
206
206
207
+ /// Export the [EcdhPrivateKey] as a [PKCS #8][1] key.
208
+ ///
209
+ /// Returns the DER encoding of the _PrivateKeyInfo_ structure specified in [RFC 5208][1] as a list of bytes.
210
+ ///
211
+ /// **Example**
212
+ /// ```dart
213
+ /// import 'package:pem/pem.dart';
214
+ /// import 'package:webcrypto/webcrypto.dart';
215
+ ///
216
+ /// Future<void> main() async {
217
+ /// // Generate a key-pair
218
+ /// final kp = await EcdhPrivateKey.generateKey(EllipticCurve.p256);
219
+ ///
220
+ /// // Export the private key.
221
+ /// final exportedPkcs8Key = await kp.privateKey.exportPkcs8Key();
222
+ ///
223
+ /// // Private keys are often encoded as PEM.
224
+ /// // This encodes the key in base64 and wraps it with:
225
+ /// // '-----BEGIN PRIVATE KEY----'...
226
+ /// print(PemCodec(PemLabel.privateKey).encode(exportedPkcs8Key));
227
+ /// }
228
+ /// ```
229
+ /// [1] : https://datatracker.ietf.org/doc/html/rfc5208
207
230
Future <Uint8List > exportPkcs8Key ();
208
231
209
232
/// Export the [EcdhPrivateKey] as a [JSON Web Key][1] .
You can’t perform that action at this time.
0 commit comments