vertx / io.vertx.ext.jwt / JWK

JWK

class JWK : Crypto

JWK https://tools.ietf.org/html/rfc7517 In a nutshell a JWK is a Key(Pair) encoded as JSON. This implementation follows the spec with some limitations: * Supported algorithms are: "RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512" The rationale for this choice is to support the required algorithms for JWT. The constructor takes a single JWK (the the KeySet) or a PEM encoded pair (used by Google and useful for importing standard PEM files from OpenSSL). * Certificate chains (x5c) only allow a single element chain, certificate urls and fingerprints are not considered.

Author
Paulo Lopes

Constructors

<init>

JWK(algorithm: String, pemPub: String, pemSec: String)
JWK(algorithm: String, isCertificate: Boolean, pemPub: String, pemSec: String)

Creates a Key(Pair) from pem formatted strings.

JWK(algorithm: String, hmac: String)

Creates a Symmetric Key from a base64 encoded string.

JWK(json: JsonObject)

Functions

decrypt

fun decrypt(payload: ByteArray): ByteArray

encrypt

fun encrypt(payload: ByteArray): ByteArray

getAlgorithm

fun getAlgorithm(): String

getId

fun getId(): String

sign

fun sign(payload: ByteArray): ByteArray

verify

fun verify(expected: ByteArray, payload: ByteArray): Boolean