From 17ff8aec3a0d2e0a520849c42c40a154a0831495 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 22 May 2023 15:37:34 -0500 Subject: initial commit --- vendor/eher/oauth/src/Eher/OAuth/RsaSha1.php | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 vendor/eher/oauth/src/Eher/OAuth/RsaSha1.php (limited to 'vendor/eher/oauth/src/Eher/OAuth/RsaSha1.php') diff --git a/vendor/eher/oauth/src/Eher/OAuth/RsaSha1.php b/vendor/eher/oauth/src/Eher/OAuth/RsaSha1.php new file mode 100644 index 0000000..a749ce3 --- /dev/null +++ b/vendor/eher/oauth/src/Eher/OAuth/RsaSha1.php @@ -0,0 +1,70 @@ +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); + } + + public function check_signature($request, $consumer, $token, $signature) { + $decoded_sig = base64_decode($signature); + + $base_string = $request->get_signature_base_string(); + + // Fetch the public key cert based on the request + $cert = $this->fetch_public_cert($request); + + // Pull the public key ID from the certificate + $publickeyid = openssl_get_publickey($cert); + + // Check the computed signature against the one passed in the query + $ok = openssl_verify($base_string, $decoded_sig, $publickeyid); + + // Release the key resource + openssl_free_key($publickeyid); + + return $ok == 1; + } +} -- cgit v1.2.3-70-g09d2