public function Verifier::verifyMessage in Automatic Updates 8
Same name and namespace in other branches
- 7 vendor/drupal/php-signify/src/Verifier.php \Drupal\Signify\Verifier::verifyMessage()
Verify a string message signed with plain Signify format.
Parameters
string $signed_message: The string contents of the signify signature and message (e.g. the contents of a .sig file.)
Return value
string The message if the verification passed.
Throws
\SodiumException Thrown when there is an unexpected crypto error or missing library.
\Drupal\Signify\VerifierException Thrown when the message was not verified by the signature.
2 calls to Verifier::verifyMessage()
- Verifier::verifyChecksumList in vendor/
drupal/ php-signify/ src/ Verifier.php - Verify a signed checksum list, and then verify the checksum for each file in the list.
- Verifier::verifyCsigMessage in vendor/
drupal/ php-signify/ src/ Verifier.php - Verify a string message signed with CSIG chained-signature extended Signify format.
File
- vendor/
drupal/ php-signify/ src/ Verifier.php, line 125
Class
Namespace
Drupal\SignifyCode
public function verifyMessage($signed_message) {
$pubkey = $this
->getPublicKey();
// Simple split of signify signature and embedded message; input
// validation occurs in parseB64String().
$embedded_message_index = 0;
for ($i = 1; $i <= 2 && $embedded_message_index !== false; $i++) {
$embedded_message_index = strpos($signed_message, "\n", $embedded_message_index + 1);
}
$signature = substr($signed_message, 0, $embedded_message_index + 1);
$message = substr($signed_message, $embedded_message_index + 1);
if ($message === false) {
$message = '';
}
$sig = $this
->parseB64String($signature, SODIUM_CRYPTO_SIGN_BYTES);
if ($pubkey->keyNum !== $sig->keyNum) {
throw new VerifierException('verification failed: checked against wrong key');
}
$valid = sodium_crypto_sign_verify_detached($sig->data, $message, $pubkey->data);
if (!$valid) {
throw new VerifierException('Signature did not match');
}
return $message;
}