Jwk class

A JWK (RFC 7517: "JSON Web Key") formatted cryptographic key.

Examples of JSON representation

AES 128 bit key

final key = Jwt.fromJson({
  "kty": "OCT",
  "alg":"A128KW",
  "k": "{BYTES_IN_BASE64URI}",
});

Ed25519 private key

final key = Jwt.fromJson({
  "kty": "OKP",
  "crv": "Ed25519",
  "d": "{BYTES_IN_BASE64URI}",
  "x": "{BYTES_IN_BASE64URI}",
});

P-256 private key

final key = Jwt.fromJson({
  "kty": "EC",
  "crv": "P-256",
  "d": "{BYTES_IN_BASE64URI}",
  "x": "{BYTES_IN_BASE64URI}",
  "y": "{BYTES_IN_BASE64URI}",
});

RSA private key

final key = Jwt.fromJson({
  "kty": "RSA",
  "n": "{BYTES_IN_BASE64URI}",
  "e": "{BYTES_IN_BASE64URI}",
  "d": "{BYTES_IN_BASE64URI}",
  "q": "{BYTES_IN_BASE64URI}",
  "dp": "{BYTES_IN_BASE64URI}",
  "dq": "{BYTES_IN_BASE64URI}",
  "qi": "{BYTES_IN_BASE64URI}",
})

Constructors

Jwk({String? alg, String? crv, String? cty, List<int>? d, List<int>? dp, List<int>? dq, List<int>? e, List<int>? k, String? keyOps, String? kid, String? kty, List<int>? n, List<int>? p, List<int>? q, List<int>? qi, String? use, List<int>? x, List<int>? x5c, List<int>? x5t, String? x5u, List<int>? y})
const

Properties

alg String?
Algorithm of the key.
final
crv String?
Elliptic curve name.
final
cty String?
Parameter cty.
final
d List<int>?
Parameter d.
final
dp List<int>?
RSA private key parameter dp.
final
dq List<int>?
RSA private key parameter dq.
final
e List<int>?
RSA exponent. This is public information.
final
hashCode int
The hash code for this object.
no setteroverride
k List<int>?
Parameter k.
final
keyOps String?
Operations.
final
kid String?
ID of the key.
final
kty String?
Key type.
final
n List<int>?
RSA modulus. This is public information.
final
p List<int>?
RSA private key parameter p.
final
q List<int>?
RSA private key parameter q.
final
qi List<int>?
RSA private key parameter qi.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
use String?
Use of the key.
final
x List<int>?
Parameter x.
final
x5c List<int>?
X.509 Certificate Chain.
final
x5t List<int>?
X.509 Certificate SHA-1 Thumbprint.
final
x5u String?
X.509 URL.
final
y List<int>?
Parameter y.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toBuilder() JwkBuilder
Constructs JwkBuilder from this object.
toJson() Map<String, Object?>
Constructs a JSON object from this object.
toKeyPair() → KeyPair
Constructs a KeyPair from this Jwk.
toPublicKey() → PublicKey?
Constructs a PublicKey from this Jwk.
toSecretKey() → SecretKey
Constructs a SecretKey from this Jwk.
toString() String
A string representation of this object.
inherited
toUtf8() List<int>
Encodes the output of toJson() as a string.

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

base64UriDecode(String s) List<int>
base64UriEncode(List<int> bytes) String
fromJson(Map jwk) Jwk
Constructs a private key from decoded JSON tree.
fromKeyPair(KeyPair keyPair) Future<Jwk>
Converts KeyPair to Jwk.
fromPublicKey(PublicKey publicKey) Jwk
Converts PublicKey into Jwk.
fromSecretKey(SecretKey secretKey, {required Cipher cipher}) Future<Jwk>
Converts SecretKey into Jwk.
fromUtf8(List<int> bytes) Jwk
Constructs a private key from encoded JSON tree.