JsonWebKey class
JSON Web Key (JWK) represents a cryptographic key
Constructors
- JsonWebKey.fromCryptoKeys({PublicKey? publicKey, PrivateKey? privateKey, String? keyId})
-
Creates a JsonWebKey from a
PublicKey
and/orPrivateKey
factory -
JsonWebKey.fromKeyPair({required KeyPair keyPair, required Map<
String, dynamic> json}) - JsonWebKey.fromPem(String pem, {String? keyId})
-
Parses a PEM encoded public or private key
factory
- JsonWebKey.generate(String? algorithm, {int? keyBitLength})
-
Generates a random key suitable for the specified
algorithm
factory
Properties
- algorithm → String?
-
The algorithm intended for use with the key.
no setter
- cryptoKeyPair → KeyPair
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyId → String?
-
Key ID used to match a specific key.
no setter
-
keyOperations
→ Set<
String> ? -
The operation(s) that the key is intended to be used for.
no setter
- keyType → String
-
The cryptographic algorithm family used with the key, such as
RSA
orEC
.no setter - publicKeyUse → String?
-
The intended use of the public key.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
x509CertificateChain
→ List<
X509Certificate> ? -
A chain of one or more PKIX certificates.
no setter
- x509CertificateSha256Thumbprint → String?
-
A base64url encoded SHA-256 thumbprint (a.k.a. digest) of the DER encoding
of an X.509 certificate.
no setter
- x509CertificateThumbprint → String?
-
A base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER encoding
of an X.509 certificate.
no setter
- x509Url → Uri?
-
A resource for an X.509 public key certificate or certificate chain.
no setter
Methods
-
algorithmForOperation(
String operation) → String? -
Returns a JSON Web Algorithm name that can be used with this key for
operation
-
decrypt(
List< int> data, {List<int> ? initializationVector, List<int> ? authenticationTag, List<int> ? additionalAuthenticatedData, String? algorithm}) → List<int> - Decrypt content and validate decryption, if applicable
-
encrypt(
List< int> data, {List<int> ? initializationVector, List<int> ? additionalAuthenticatedData, String? algorithm}) → EncryptionResult - Encrypt content
-
getTyped<
T> (String key, {T factory(dynamic v)?}) → T? -
Returns the property
key
as a typed objectinherited -
getTypedList<
T> (String key, {T factory(dynamic v)?}) → List< T> ? -
Returns the property
key
as a typed listinherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sign(
List< int> data, {String? algorithm}) → List<int> - Compute digital signature or MAC
-
toBase64EncodedString(
) → String -
Returns the base64 representation
inherited
-
toBytes(
) → List< int> -
Returns the bytes representing the encoded JSON
inherited
-
toJson(
) → Map< String, dynamic> -
Returns a JSON representation
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unwrapKey(
List< int> data, {String? algorithm}) → JsonWebKey - Decrypt key and validate decryption, if applicable
-
usableForAlgorithm(
String algorithm) → bool -
Returns true if this key can be used with the JSON Web Algorithm
identified by
algorithm
-
usableForOperation(
String operation) → bool -
Returns true if this key can be used for the
operation
-
verify(
List< int> data, List<int> signature, {String? algorithm}) → bool - Verify digital signature or MAC
-
wrapKey(
JsonWebKey key, {String? algorithm}) → List< int> - Encrypt key
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String key) → dynamic -
Returns the property
key
as a core dart valueinherited
Static Methods
-
ec(
{required String curve, BigInt? xCoordinate, BigInt? yCoordinate, BigInt? privateKey, String? keyId, String? algorithm}) → JsonWebKey - Creates a JsonWebKey of type EC
-
fromJson(
Map< String, dynamic> json) → JsonWebKey? - Constructs a JsonWebKey from its JSON representation
-
rsa(
{required BigInt modulus, BigInt? exponent, BigInt? privateExponent, BigInt? firstPrimeFactor, BigInt? secondPrimeFactor, String? keyId, String? algorithm}) → JsonWebKey - Creates a JsonWebKey of type RSA
-
symmetric(
{required BigInt key, String? keyId}) → JsonWebKey - Creates a JsonWebKey of type oct