ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\WOPI\Discovery\ProofKey Class Reference

A public RSA key of a WOPI client, as published in its discovery with base64 encoded modulus and exponent. More...

+ Collaboration diagram for ILIAS\WOPI\Discovery\ProofKey:

Public Member Functions

 __construct (public string $modulus, public string $exponent)
 
 toPem ()
 

Static Private Member Functions

static integer (string $bytes)
 
static der (int $tag, string $content)
 

Detailed Description

A public RSA key of a WOPI client, as published in its discovery with base64 encoded modulus and exponent.

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 29 of file ProofKey.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WOPI\Discovery\ProofKey::__construct ( public string  $modulus,
public string  $exponent 
)

Definition at line 31 of file ProofKey.php.

34 {
35 }

Member Function Documentation

◆ der()

static ILIAS\WOPI\Discovery\ProofKey::der ( int  $tag,
string  $content 
)
staticprivate

Definition at line 65 of file ProofKey.php.

65 : string
66 {
67 $length = strlen($content);
68 if ($length < 0x80) {
69 return chr($tag) . chr($length) . $content;
70 }
71 $length_bytes = ltrim(pack('N', $length), "\x00");
72
73 return chr($tag) . chr(0x80 | strlen($length_bytes)) . $length_bytes . $content;
74 }

Referenced by ILIAS\WOPI\Discovery\ProofKey\integer(), and ILIAS\WOPI\Discovery\ProofKey\toPem().

+ Here is the caller graph for this function:

◆ integer()

static ILIAS\WOPI\Discovery\ProofKey::integer ( string  $bytes)
staticprivate

Definition at line 55 of file ProofKey.php.

55 : string
56 {
57 $bytes = ltrim($bytes, "\x00");
58 if ($bytes === '' || (ord($bytes[0]) & 0x80) !== 0) {
59 $bytes = "\x00" . $bytes;
60 }
61
62 return self::der(0x02, $bytes);
63 }
static der(int $tag, string $content)
Definition: ProofKey.php:65

References ILIAS\WOPI\Discovery\ProofKey\der().

+ Here is the call graph for this function:

◆ toPem()

ILIAS\WOPI\Discovery\ProofKey::toPem ( )

Definition at line 37 of file ProofKey.php.

37 : string
38 {
39 $modulus = base64_decode($this->modulus, true);
40 $exponent = base64_decode($this->exponent, true);
41 if ($modulus === false || $exponent === false || $modulus === '' || $exponent === '') {
42 throw new \InvalidArgumentException('Invalid proof key');
43 }
44
45 // SubjectPublicKeyInfo: SEQUENCE { SEQUENCE { rsaEncryption, NULL }, BIT STRING { RSAPublicKey } }
46 $rsa_public_key = self::der(0x30, self::integer($modulus) . self::integer($exponent));
47 $algorithm = self::der(0x30, self::der(0x06, "\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01") . self::der(0x05, ''));
48 $info = self::der(0x30, $algorithm . self::der(0x03, "\x00" . $rsa_public_key));
49
50 return "-----BEGIN PUBLIC KEY-----\n"
51 . chunk_split(base64_encode($info), 64, "\n")
52 . "-----END PUBLIC KEY-----\n";
53 }
$info
Definition: entry_point.php:21

References $info, and ILIAS\WOPI\Discovery\ProofKey\der().

Referenced by ILIAS\WOPI\Handler\ProofValidator\verify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: