1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16: 17: 18:
19: class Horde_Oauth_SignatureMethod_RsaSha1 extends Horde_Oauth_SignatureMethod
20: {
21: public function __construct($publicKey = null, $privateKey = null)
22: {
23: $this->_publicKey = $publicKey;
24: $this->_privateKey = $privateKey;
25: }
26:
27: public function getName()
28: {
29: return 'RSA-SHA1';
30: }
31:
32: public function sign($request, $consumer, $token)
33: {
34: $baseString = $request->getSignatureBaseString();
35:
36: $pkeyid = openssl_pkey_get_private($this->_privateKey);
37: $ok = openssl_sign($baseString, $signature, $pkeyid);
38: openssl_free_key($pkeyid);
39:
40: return base64_encode($signature);
41: }
42:
43: public function verify($signature, $request, $consumer, $token)
44: {
45: $decodedSignature = base64_decode($signature);
46: $baseString = $request->getSignatureBaseString();
47:
48: $pubkeyid = openssl_pkey_get_public($this->_publicKey);
49: $result = openssl_verify($baseString, $decodedSignature, $pubkeyid);
50: openssl_free_key($pubkeyid);
51:
52: return $result == 1;
53: }
54: }
55: