Created
August 9, 2019 19:23
-
-
Save davidstrauss/f4a6038e3a7450e2f64ebfc6ee2db3db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$msg = file_get_contents('artifact1.php'); | |
$pubkey_enc = 'RWT/sFZ5HK1Dq173idkKlbBz3gRngoqnchtMp4QdPZpdHJ+8Jpa2ZR8t'; | |
$pubkey = base64_decode($pubkey_enc, TRUE); | |
$sig_enc = 'RWT/sFZ5HK1Dqz/qStQ9zRdmnZowrMNaMRe/B1gEGRBF+GcEYt95YG/2iN+HNPAddtZVRGaU+QW1NPlhDbtGpvY682aQKvvhBgI='; | |
$sig = base64_decode($sig_enc, TRUE); | |
file_put_contents('sig.raw', $sig); | |
$sig = substr($sig, 10, SODIUM_CRYPTO_SIGN_BYTES); | |
echo 'Siglen: '; | |
echo strlen($sig) . "\n"; | |
echo 'Sig should be len: '; | |
echo SODIUM_CRYPTO_SIGN_BYTES . "\n"; | |
$pubkey = substr($pubkey, 10, SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES); | |
echo 'Pubkey len: '; | |
echo strlen($pubkey) . "\n"; | |
echo 'Sig should be len: '; | |
echo SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES . "\n"; | |
//echo 'Pubkey: '; | |
//echo $pubkey . "\n"; | |
//echo 'Sig: '; | |
//echo $sig . "\n"; | |
echo 'Verify: '; | |
$works = sodium_crypto_sign_verify_detached($sig, $msg, $pubkey); | |
if ($works) { | |
echo "success\n"; | |
} else { | |
echo "fail\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment