This commit is contained in:
Jonas Roussel
2023-08-21 16:32:35 +02:00
parent fe696b8e25
commit 1e69c815c5
3 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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