mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-23 03:03:42 +00:00
c18e0dc66a
- 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
24 lines
No EOL
706 B
PHP
24 lines
No EOL
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)
|
|
);
|
|
};
|
|
} |