SecLibJwk
in package
implements
Jwk
Implements a PHP Sec Lib backed JWK.
Table of Contents
Interfaces
- Jwk
- Represents a JSON Web Key.
Methods
- __construct() : mixed
- __sleep() : array<string|int, mixed>
- __wakeup() : void
- decode() : array<int|string, Jwk>
- Decodes a JWK key set into SecLibJwk (or HmacJwk if "kty": "oct") instances.
- 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.
- jsonSerialize() : mixed
- 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
__construct()
public
__construct(PrivateKey)|PublicKey) $key[, SecLibJwkAlgorithm|string|null $algo = null ][, string|null $id = null ]) : mixed
Parameters
- $key : PrivateKey)|PublicKey)
- $algo : SecLibJwkAlgorithm|string|null = null
- $id : string|null = null
Tags
__sleep()
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>__wakeup()
public
__wakeup() : void
decode()
Decodes a JWK key set into SecLibJwk (or HmacJwk if "kty": "oct") instances.
public
static decode(string|array<string, mixed>|array{keys: array}|object $jwks) : array<int|string, Jwk>
The way PHPSecLib loads JWKs is a little bit quirky in my opinion, but this handles all that for you.
Parameters
-
$jwks
: string|array<string, mixed>|array{keys: array
}|object -
Keys to decode, may also be a single key without the keys wrapping.
Tags
Return values
array<int|string, Jwk>getAlgorithm()
Gets the algorithm of this key, equivalent to the "alg" field.
public
getAlgorithm() : string|null
Return values
string|nullgetId()
Gets the ID of this key, equivalent to the "kid" field.
public
getId() : string|null
Return values
string|nullgetPublicKey()
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|nulljsonSerialize()
public
jsonSerialize() : mixed
Attributes
- #[ReturnTypeWillChange]
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.
Return values
stringverify()
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.