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()  : 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
throws
InvalidArgumentException

Provided JWK is empty

throws
UnexpectedValueException

Provided JWK was invalid

throws
DomainException

OpenSSL failure

uses
createPemFromModulusAndExponent
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
throws
InvalidArgumentException

Provided JWK Set is empty

throws
UnexpectedValueException

Provided JWK Set was invalid

throws
DomainException

OpenSSL failure

uses
parseKey
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
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