Skip to content

Commit

Permalink
v2.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasroussel committed Aug 21, 2023
1 parent fe696b8 commit 1e69c81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.9.1

- Adding a new class factory `ECPublicKey.cert`

## 2.9.0

- Adding `basic_utils` package to handle PEM & key parsing
Expand Down
9 changes: 9 additions & 0 deletions lib/src/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ class ECPublicKey extends JWTKey {
ECPublicKey.clone(ECPublicKey _key) : key = _key.key;
ECPublicKey.bytes(Uint8List bytes)
: key = CryptoUtils.ecPublicKeyFromDerBytes(bytes);
ECPublicKey.cert(String pem) {
final x509 = X509Utils.x509CertificateFromPem(pem);
final bytes = x509.tbsCertificate?.subjectPublicKeyInfo.bytes;
if (bytes == null) {
throw JWTParseException('x509 Certificate parsing failed');
}

key = CryptoUtils.ecPublicKeyFromDerBytes(hexToUint8List(bytes));
}
}

/// For EdDSA algorithm, in sign method
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_jsonwebtoken
description: A dart implementation of the famous javascript library 'jsonwebtoken' (JWT).
version: 2.9.0
version: 2.9.1
repository: https://github.com/jonasroussel/dart_jsonwebtoken
homepage: https://github.com/jonasroussel/dart_jsonwebtoken#readme

Expand Down

0 comments on commit 1e69c81

Please sign in to comment.