Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 and 403]

(no description)

File Size: 323 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: JWK  - X-Ref

JSON Web Key implementation, based on this spec:
https://tools.ietf.org/html/draft-ietf-jose-json-web-key-41

PHP version 5

parseKeySet(array $jwks, string $defaultAlg = null)   X-Ref
Parse a set of JWK keys

param: array<mixed> $jwks The JSON Web Key Set as an associative array
param: string       $defaultAlg The algorithm for the Key object if "alg" is not set in the
return: array<string, Key> An associative array of key IDs (kid) to Key objects

parseKey(array $jwk, string $defaultAlg = null)   X-Ref
Parse a JWK key

param: array<mixed> $jwk An individual JWK
param: string       $defaultAlg The algorithm for the Key object if "alg" is not set in the
return: Key The key object for the JWK

createPemFromCrvAndXYCoordinates(string $crv, string $x, string $y)   X-Ref
Converts the EC JWK values to pem format.

param: string  $crv The EC curve (only P-256 is supported)
param: string  $x   The EC x-coordinate
param: string  $y   The EC y-coordinate
return: string

createPemFromModulusAndExponent(string $n,string $e)   X-Ref
Create a public key represented in PEM format from RSA modulus and exponent information

param: string $n The RSA modulus encoded in Base64
param: string $e The RSA exponent encoded in Base64
return: string The RSA public key represented in PEM format

encodeLength(int $length)   X-Ref
DER-encode the length

DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4.  See
{@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information.

param: int $length
return: string

encodeDER(int $type, string $value)   X-Ref
Encodes a value into a DER object.
Also defined in Firebase\JWT\JWT

param: int     $type DER tag
param: string  $value the value to encode
return: string  the encoded object

encodeOID(string $oid)   X-Ref
Encodes a string into a DER-encoded OID.

param: string $oid the OID string
return: string the binary DER-encoded OID