Neos\Flow\Security\Cryptography\RsaWalletServicePhp::verifySignature PHP Метод

verifySignature() публичный Метод

Checks whether the given signature is valid for the given plaintext with the public key identified by the given fingerprint
public verifySignature ( string $plaintext, string $signature, string $fingerprint ) : boolean
$plaintext string The plaintext to sign
$signature string The signature that should be verified
$fingerprint string The fingerprint to identify the public key (RSA public key fingerprint)
Результат boolean TRUE if the signature is correct for the given plaintext and public key
    public function verifySignature($plaintext, $signature, $fingerprint)
    {
        if ($fingerprint === null || !isset($this->keys[$fingerprint])) {
            throw new InvalidKeyPairIdException('Invalid keypair fingerprint given', 1304959763);
        }
        $verifyResult = openssl_verify($plaintext, $signature, $this->getPublicKey($fingerprint)->getKeyString());
        return $verifyResult === 1;
    }

Usage Example

 /**
  * @test
  */
 public function signAndVerifySignatureBasicallyWorks()
 {
     $plaintext = 'trustworthy data!';
     $signature = $this->rsaWalletService->sign($plaintext, $this->keyPairUuid);
     $this->assertTrue($this->rsaWalletService->verifySignature($plaintext, $signature, $this->keyPairUuid));
     $this->assertFalse($this->rsaWalletService->verifySignature('modified data!', $signature, $this->keyPairUuid));
 }