You are here

public function OAuthSignatureMethod_RSA_SHA1::build_signature in jQuery social stream 8

Same name and namespace in other branches
  1. 8.2 src/Twitter/OAuthSignatureMethod_RSA_SHA1.php \Drupal\jquery_social_stream\Twitter\OAuthSignatureMethod_RSA_SHA1::build_signature()

Build up the signature NOTE: The output of this function MUST NOT be urlencoded. the encoding is handled in OAuthRequest when the final request is serialized

Parameters

OAuthRequest $request:

OAuthConsumer $consumer:

OAuthToken $token:

Return value

string

Overrides OAuthSignatureMethod::build_signature

File

src/Twitter/OAuthSignatureMethod_RSA_SHA1.php, line 32

Class

OAuthSignatureMethod_RSA_SHA1
The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA…

Namespace

Drupal\jquery_social_stream\Twitter

Code

public function build_signature($request, $consumer, $token) {
  $base_string = $request
    ->get_signature_base_string();
  $request->base_string = $base_string;

  // Fetch the private key cert based on the request
  $cert = $this
    ->fetch_private_cert($request);

  // Pull the private key ID from the certificate
  $privatekeyid = openssl_get_privatekey($cert);

  // Sign using the key
  $ok = openssl_sign($base_string, $signature, $privatekeyid);

  // Release the key resource
  openssl_free_key($privatekeyid);
  return base64_encode($signature);
}