LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
OAuthSignatureMethod.php
1<?php
2
3namespace ceLTIc\LTI\OAuth;
4
18{
19
25 abstract public function get_name();
26
40 abstract public function build_signature($request, $consumer, $token);
41
52 public function check_signature($request, $consumer, $token, $signature)
53 {
54 $built = $this->build_signature($request, $consumer, $token);
55
56 // Check for zero length, although unlikely here
57 if (strlen($built) == 0 || strlen($signature) == 0) {
58 return false;
59 }
60
61 if (strlen($built) != strlen($signature)) {
62 return false;
63 }
64
65 // Avoid a timing leak with a (hopefully) time insensitive compare
66 $result = 0;
67 for ($i = 0; $i < strlen($signature); $i++) {
68 $result |= ord($built[$i]) ^ ord($signature[$i]);
69 }
70
71 return $result == 0;
72 }
73
74}
Class to represent an OAuth signature method.
get_name()
Needs to return the name of the Signature Method (eg HMAC-SHA1).
check_signature($request, $consumer, $token, $signature)
Verifies that a given signature is correct.
build_signature($request, $consumer, $token)
Build up the signature.