Railgun JWT

Jwk extends JsonSerializable

Represents a JSON Web Key.

Table of Contents

Methods

getAlgorithm()  : string|null
Gets the algorithm of this key, equivalent to the "alg" field.
getId()  : string|null
Gets the ID of this key, equivalent to the "kid" field.
getPublicKey()  : Jwk|null
Gets an instance of Jwk that ensures it is backed by a public key.
sign()  : string
Signs data using this key. Only available if it is backed by a private key.
verify()  : bool
Verifies data against this key.

Methods

getAlgorithm()

Gets the algorithm of this key, equivalent to the "alg" field.

public getAlgorithm() : string|null
Return values
string|null

getId()

Gets the ID of this key, equivalent to the "kid" field.

public getId() : string|null
Return values
string|null

getPublicKey()

Gets an instance of Jwk that ensures it is backed by a public key.

public getPublicKey() : Jwk|null

Will return null if it is impossible to create a public representation of this key.

Return values
Jwk|null

sign()

Signs data using this key. Only available if it is backed by a private key.

public sign(string $data[, string|null $algo = null ]) : string
Parameters
$data : string

Data to be signed.

$algo : string|null = null

JWK algorithm to sign the data with.

Tags
throws
RuntimeException

If the data could not be signed, e.g. this JWK is not backed by a private key.

throws
InvalidArgumentException

If any of the argument types were not as expected.

Return values
string

verify()

Verifies data against this key.

public verify(string $data, string $signature[, string|null $algo = null ]) : bool
Parameters
$data : string

Data to be verified.

$signature : string

Signature of the data.

$algo : string|null = null

JWK algorithm to verify the data with.

Tags
throws
InvalidArgumentException

If any of the argument types were not as expected.

Return values
bool

        
On this page

Search results