lib/JWX/JWE/CompressionAlgorithm/DeflateAlgorithm.php 1 location
|
@@ 42-50 (lines=9) @@
|
39 |
|
* @see \JWX\JWE\CompressionAlgorithm::compress() |
40 |
|
* @throws \RuntimeException |
41 |
|
*/ |
42 |
|
public function compress($data) { |
43 |
|
$ret = @gzdeflate($data, $this->_compressionLevel); |
44 |
|
if (false === $ret) { |
45 |
|
$err = error_get_last(); |
46 |
|
$msg = isset($err) ? $err["message"] : "gzdeflate() failed."; |
47 |
|
throw new \RuntimeException($msg); |
48 |
|
} |
49 |
|
return $ret; |
50 |
|
} |
51 |
|
|
52 |
|
/** |
53 |
|
* |
lib/JWX/JWS/Algorithm/HMACAlgorithm.php 1 location
|
@@ 76-84 (lines=9) @@
|
73 |
|
return new $cls($jwk->key()); |
74 |
|
} |
75 |
|
|
76 |
|
public function computeSignature($data) { |
77 |
|
$result = @hash_hmac($this->_hashAlgo(), $data, $this->_key, true); |
78 |
|
if (false === $result) { |
79 |
|
$err = error_get_last(); |
80 |
|
$msg = isset($err) ? $err["message"] : "hash_hmac() failed."; |
81 |
|
throw new \RuntimeException($msg); |
82 |
|
} |
83 |
|
return $result; |
84 |
|
} |
85 |
|
|
86 |
|
public function validateSignature($data, $signature) { |
87 |
|
return $this->computeSignature($data) === $signature; |
lib/JWX/Util/Base64.php 1 location
|
@@ 66-74 (lines=9) @@
|
63 |
|
* @throws \RuntimeException If encoding fails |
64 |
|
* @return string |
65 |
|
*/ |
66 |
|
public static function encode($data) { |
67 |
|
$ret = @base64_encode($data); |
68 |
|
if (!is_string($ret)) { |
69 |
|
$err = error_get_last(); |
70 |
|
$msg = isset($err) ? $err["message"] : "base64_encode() failed."; |
71 |
|
throw new \RuntimeException($msg); |
72 |
|
} |
73 |
|
return $ret; |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* Decode a string from base64 encoding. |