HmacJwk
in package
implements
Jwk
Represents a HMAC JSON Web Key.
Table of Contents
Interfaces
- Jwk
- Represents a JSON Web Key.
Methods
- __construct() : mixed
- algorithms() : array<string|int, string>
- Registered JWK aliases of native hashing algorithms.
- defineAlgorithm() : void
- Defines an algorithm alias.
- 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(string $key[, string|null $algo = null ][, string|null $id = null ]) : mixed
Parameters
- $key : string
- $algo : string|null = null
- $id : string|null = null
algorithms()
Registered JWK aliases of native hashing algorithms.
public
static algorithms() : array<string|int, string>
Return values
array<string|int, string>defineAlgorithm()
Defines an algorithm alias.
public
static defineAlgorithm(string $alias, string $algo) : void
Parameters
- $alias : string
-
JWK algorithm.
- $algo : string
-
Native PHP algorithm.
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.