<commit_before><?php
require_once "Crypt/RSA.php";

class Services_Signing_Openssl extends Services_Signing_Base {
	/*
	 * Public key cache prevent us to acually decode and call OpenSSL
	 * to create an OpenSSL handle to the public key, saving CPU cycles
	 */
	private $_pubKeyCache = array();

	/*
	 * Actually validates the RSA signature
	 */
	protected function checkRsaSignature($toCheck, $signature, $rsaKey, $useCache) {
		if (isset($this->_pubKeyCache[$rsaKey['modulo'] . $rsaKey['exponent']])) {
			$openSslPubKey = $this->_pubKeyCache[$rsaKey['modulo'] . $rsaKey['exponent']];
			$verified = openssl_verify($toCheck, $signature, $openSslPubKey);
		} else {
			# Initialize the public key to verify with
			$pubKey['n'] = base64_decode($rsaKey['modulo']);
			$pubKey['e'] = base64_decode($rsaKey['exponent']);

			$openSslPubKey = openssl_get_publickey($this->seclibToOpenSsl($pubKey));<commit_msg>Fix for OpenSSL key verifying #1550<commit_after><?php
require_once "Crypt/RSA.php";

class Services_Signing_Openssl extends Services_Signing_Base {
	/*
	 * Public key cache prevent us to acually decode and call OpenSSL
	 * to create an OpenSSL handle to the public key, saving CPU cycles
	 */
	private $_pubKeyCache = array();

	/*
	 * Actually validates the RSA signature
	 */
	protected function checkRsaSignature($toCheck, $signature, $rsaKey, $useCache) {
		# First decode the signature
		$signature = base64_decode($signature);

		if (isset($this->_pubKeyCache[$rsaKey['modulo'] . $rsaKey['exponent']])) {
			$openSslPubKey = $this->_pubKeyCache[$rsaKey['modulo'] . $rsaKey['exponent']];
			$verified = openssl_verify($toCheck, $signature, $openSslPubKey);
		} else {
			# Initialize the public key to verify with
			$pubKey['n'] = base64_decode($rsaKey['modulo']);
			$pubKey['e'] = base64_decode($rsaKey['exponent']);

			$openSslPubKey = openssl_get_publickey($this->seclibToOpenSsl($pubKey));
{'fraction_non_alphanumeric': 0.14046121593291405, 'fraction_numerical': 0.007337526205450734, 'mean_word_length': 5.4711864406779664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3219667', 'n_tokens_mistral': 681, 'n_tokens_neox': 623, 'n_words': 146}