Documentation

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
category

Authentication

author

Bui Sy Nguyen nguyenbs@gmail.com

license

http://opensource.org/licenses/BSD-3-Clause 3-clause BSD

link
https://github.com/firebase/php-jwt

Table of Contents

parseKey()  : resource|array<string|int, mixed>
Parse a JWK key
parseKeySet()  : array<string|int, mixed>
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) : resource|array<string|int, mixed>
Parameters
$jwk : array<string|int, mixed>

An individual JWK

Tags
throws
InvalidArgumentException

Provided JWK is empty

throws
UnexpectedValueException

Provided JWK was invalid

throws
DomainException

OpenSSL failure

uses
createPemFromModulusAndExponent
Return values
resource|array<string|int, mixed>

An associative array that represents the key

parseKeySet()

Parse a set of JWK keys

public static parseKeySet(array<string|int, mixed> $jwks) : array<string|int, mixed>
Parameters
$jwks : array<string|int, mixed>

The JSON Web Key Set as an associative array

Tags
throws
InvalidArgumentException

Provided JWK Set is empty

throws
UnexpectedValueException

Provided JWK Set was invalid

throws
DomainException

OpenSSL failure

uses
parseKey
Return values
array<string|int, mixed>

An associative array that represents the set of keys

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
uses
encodeLength
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
Return values
string

Search results