friendica-addons/securemail/vendor/singpolyma/openpgp-php/lib/openpgp_sodium.php
Hypolite Petovan c18e0dc66a [securemail] Upgrade singpolyma/openpgp to version 0.6.0
- Add missing use statement in SecureTestEmail
- Address https://github.com/friendica/friendica/issues/12011#issuecomment-1321196332
- phpseclib version 3 dependency is implied from the core so it is removed from the addon
2022-11-24 14:04:53 -05:00

24 lines
706 B
PHP

<?php
function sodium_make_verifier($pk) {
return function($m, $s) use ($pk) {
if($pk instanceof OpenPGP_Message) {
foreach($pk as $p) {
if($p instanceof OpenPGP_PublicKeyPacket) {
if(substr($p->fingerprint, strlen($s->issuer())*-1) == $s->issuer()) {
$pk = $p;
break;
}
}
}
}
if ($pk->algorithm != 22) throw new Exception("Only EdDSA supported");
if (bin2hex($pk->key['oid']) != '2b06010401da470f01') throw new Exception("Only ed25519 supported");
return sodium_crypto_sign_verify_detached(
implode($s->data),
hash($s->hash_algorithm_name(), $m, true),
substr($pk->key['p'], 1)
);
};
}