3 namespace Friendica\Security\OAuth1\Signature;
5 use Friendica\Security\OAuth1\OAuthRequest;
6 use Friendica\Security\OAuth1\OAuthUtil;
9 * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
10 * where the Signature Base String is the text and the key is the concatenated values (each first
11 * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
12 * character (ASCII code 38) even if empty.
13 * - Chapter 9.2 ("HMAC-SHA1")
15 class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod
23 * @param OAuthRequest $request
24 * @param \Friendica\Security\OAuth1\OAuthConsumer $consumer
25 * @param \Friendica\Security\OAuth1\OAuthToken $token
29 public function build_signature(OAuthRequest $request, \Friendica\Security\OAuth1\OAuthConsumer $consumer, \Friendica\Security\OAuth1\OAuthToken $token = null)
31 $base_string = $request->get_signature_base_string();
32 $request->base_string = $base_string;
36 ($token) ? $token->secret : "",
39 $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
40 $key = implode('&', $key_parts);
43 $r = base64_encode(hash_hmac('sha1', $base_string, $key, true));