ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\FileDelivery\Token\Signer\HMACSigner Class Reference
+ Inheritance diagram for ILIAS\FileDelivery\Token\Signer\HMACSigner:
+ Collaboration diagram for ILIAS\FileDelivery\Token\Signer\HMACSigner:

Public Member Functions

 __construct (private Algorithm $algorithm)
 
 sign (string $signable_payload, SigningKey $signing_key)
 
 verify (string $data, string $signature, int $validity, SigningKey $signing_key)
 

Protected Member Functions

 getAlgorithm ()
 

Additional Inherited Members

- Data Fields inherited from ILIAS\FileDelivery\Token\Signer\Signer
const SEPARATOR = '.'
 

Detailed Description

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

Definition at line 29 of file HMACSigner.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\FileDelivery\Token\Signer\HMACSigner::__construct ( private Algorithm  $algorithm)

Definition at line 31 of file HMACSigner.php.

33  {
34  }

Member Function Documentation

◆ getAlgorithm()

ILIAS\FileDelivery\Token\Signer\HMACSigner::getAlgorithm ( )
protected

Definition at line 36 of file HMACSigner.php.

Referenced by ILIAS\FileDelivery\Token\Signer\HMACSigner\sign().

36  : string
37  {
38  return $this->algorithm->getName();
39  }
+ Here is the caller graph for this function:

◆ sign()

ILIAS\FileDelivery\Token\Signer\HMACSigner::sign ( string  $signable_payload,
SigningKey  $signing_key 
)

Implements ILIAS\FileDelivery\Token\Signer\Signer.

Definition at line 41 of file HMACSigner.php.

References ILIAS\FileDelivery\Token\Signer\Key\Signing\SigningKey\get(), and ILIAS\FileDelivery\Token\Signer\HMACSigner\getAlgorithm().

Referenced by ILIAS\FileDelivery\Token\Signer\HMACSigner\verify().

44  : string {
45  // sign the payload using hmac_hash
46  return hash_hmac(
47  $this->getAlgorithm(),
48  $signable_payload,
49  $signing_key->get(),
50  false
51  );
52  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verify()

ILIAS\FileDelivery\Token\Signer\HMACSigner::verify ( string  $data,
string  $signature,
int  $validity,
SigningKey  $signing_key 
)

Implements ILIAS\FileDelivery\Token\Signer\Signer.

Definition at line 54 of file HMACSigner.php.

References ILIAS\FileDelivery\Token\Signer\HMACSigner\sign().

59  : bool {
60  $signature_check = $this->sign($data, $signing_key);
61  if ($signature_check !== $signature) {
62  return false;
63  }
64  return !($validity > 0 && $validity < time());
65  }
sign(string $signable_payload, SigningKey $signing_key)
Definition: HMACSigner.php:41
+ Here is the call graph for this function:

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