Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(no description)

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

Defines 1 class

JWK:: (4 methods):
  parseKeySet()
  parseKey()
  createPemFromModulusAndExponent()
  encodeLength()


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)   X-Ref
Parse a set of JWK keys

return: array<string, Key> An associative array of key IDs (kid) to Key objects
param: array $jwks The JSON Web Key Set as an associative array

parseKey(array $jwk)   X-Ref
Parse a JWK key

return: Key The key object for the JWK
param: array $jwk An individual JWK

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

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

encodeLength($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.

return: string
param: int $length