Skip to content

Commit 8d9d4ac

Browse files
authored
Merge pull request #135 from kenta-wakasa/add_p256k_key_pair_type
Add p256k key pair type
2 parents 19b1b49 + 94052b9 commit 8d9d4ac

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cryptography/lib/src/cryptography/key_pair_type.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ class KeyPairType<S extends KeyPairData, P extends PublicKey> {
3535
webCryptoCurve: 'P-256',
3636
);
3737

38+
/// Key pair type for [Ecdh] and [Ecdsa] with P-256 curve.
39+
///
40+
/// Keys of this type can be generated with [EcKeyPairGenerator].
41+
static const KeyPairType p256k = KeyPairType<EcKeyPairData, EcPublicKey>._(
42+
name: 'p256k',
43+
ellipticBits: 256,
44+
webCryptoCurve: 'P-256K',
45+
);
46+
3847
/// Key pair type for [Ecdh] and [Ecdsa] with P-384 curve.
3948
///
4049
/// Keys of this type can be generated with [EcKeyPairGenerator].

jwk/lib/jwk.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ class Jwk {
369369
case 'EC':
370370
final type = const <String, KeyPairType>{
371371
'P-256': KeyPairType.p256,
372+
'secp256k1': KeyPairType.p256k,
372373
'P-384': KeyPairType.p384,
373374
'P-521': KeyPairType.p521,
374375
}[crv];
@@ -430,6 +431,7 @@ class Jwk {
430431
case 'EC':
431432
final type = const <String, KeyPairType>{
432433
'P-256': KeyPairType.p256,
434+
'secp256k1': KeyPairType.p256k,
433435
'P-384': KeyPairType.p384,
434436
'P-521': KeyPairType.p521,
435437
}[crv];
@@ -560,6 +562,7 @@ class Jwk {
560562
if (keyPair is EcKeyPairData) {
561563
final crv = const <KeyPairType, String>{
562564
KeyPairType.p256: 'P-256',
565+
KeyPairType.p256k: 'secp256k1',
563566
KeyPairType.p384: 'P-384',
564567
KeyPairType.p521: 'P-521',
565568
}[keyPair.type];
@@ -606,6 +609,7 @@ class Jwk {
606609
if (publicKey is EcPublicKey) {
607610
final crv = const <KeyPairType, String>{
608611
KeyPairType.p256: 'P-256',
612+
KeyPairType.p256k: 'secp256k1',
609613
KeyPairType.p384: 'P-384',
610614
KeyPairType.p521: 'P-521',
611615
}[publicKey.type];

0 commit comments

Comments
 (0)