JWK
in package
JSON Web Key implementation, based on this spec: https://tools.ietf.org/html/draft-ietf-jose-json-web-key-41
PHP version 5
Tags
Table of Contents
- parseKey() : Key
- Parse a JWK key
- parseKeySet() : array<string, Key>
- Parse a set of JWK keys
- createPemFromModulusAndExponent() : string
- Create a public key represented in PEM format from RSA modulus and exponent information
- encodeLength() : string
- DER-encode the length
Methods
parseKey()
Parse a JWK key
public
static parseKey(array<string|int, mixed> $jwk[, string $defaultAlg = null ]) : Key
Parameters
- $jwk : array<string|int, mixed>
-
An individual JWK
- $defaultAlg : string = null
-
The algorithm for the Key object if "alg" is not set in the JSON Web Key Set
Tags
Return values
Key —The key object for the JWK
parseKeySet()
Parse a set of JWK keys
public
static parseKeySet(array<string|int, mixed> $jwks[, string $defaultAlg = null ]) : array<string, Key>
Parameters
- $jwks : array<string|int, mixed>
-
The JSON Web Key Set as an associative array
- $defaultAlg : string = null
-
The algorithm for the Key object if "alg" is not set in the JSON Web Key Set
Tags
Return values
array<string, Key> —An associative array of key IDs (kid) to Key objects
createPemFromModulusAndExponent()
Create a public key represented in PEM format from RSA modulus and exponent information
private
static createPemFromModulusAndExponent(string $n, string $e) : string
Parameters
- $n : string
-
The RSA modulus encoded in Base64
- $e : string
-
The RSA exponent encoded in Base64
Tags
Return values
string —The RSA public key represented in PEM format
encodeLength()
DER-encode the length
private
static encodeLength(int $length) : string
DER supports lengths up to (2**8)127, however, we'll only support lengths up to (28)**4. See X.690 paragraph 8.1.3 for more information.
Parameters
- $length : int