PATH:
opt
/
alt
/
tests
/
alt-php55-pecl-libsodium_1.0.6-1.el8
/
tests
--TEST-- Check for libsodium ed25519 signatures --SKIPIF-- <?php if (!extension_loaded("libsodium")) print "skip"; ?> --FILE-- <?php $keypair = \Sodium\crypto_sign_keypair(); var_dump(strlen($keypair) === \Sodium\CRYPTO_SIGN_KEYPAIRBYTES); $sk = \Sodium\crypto_sign_secretkey($keypair); var_dump(strlen($sk) === \Sodium\CRYPTO_SIGN_SECRETKEYBYTES); $pk = \Sodium\crypto_sign_publickey($keypair); var_dump(strlen($pk) === \Sodium\CRYPTO_SIGN_PUBLICKEYBYTES); var_dump($pk !== $sk); $keypair2 = \Sodium\crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk); var_dump($keypair === $keypair2); $alice_kp = \Sodium\crypto_sign_keypair(); $alice_secretkey = \Sodium\crypto_sign_secretkey($alice_kp); $alice_publickey = \Sodium\crypto_sign_publickey($alice_kp); $msg = "Here is the message, to be signed using Alice's secret key, and " . "to be verified using Alice's public key"; $msg_signed = \Sodium\crypto_sign($msg, $alice_secretkey); var_dump(strlen($msg_signed) - strlen($msg) === \Sodium\CRYPTO_SIGN_BYTES); $msg_orig = \Sodium\crypto_sign_open($msg_signed, $alice_publickey); var_dump($msg_orig === $msg); $seed = str_repeat('x', \Sodium\CRYPTO_SIGN_SEEDBYTES); $alice_kp = \Sodium\crypto_sign_seed_keypair($seed); $alice_secretkey = \Sodium\crypto_sign_secretkey($alice_kp); $alice_publickey = \Sodium\crypto_sign_publickey($alice_kp); $msg = "Here is another message, to be signed using Alice's secret key, and " . "to be verified using Alice's public key, which will be always the same " . "since they are derived from a fixed seed"; $msg_signed = \Sodium\crypto_sign($msg, $alice_secretkey); var_dump(strlen($msg_signed) - strlen($msg) === \Sodium\CRYPTO_SIGN_BYTES); $msg_orig = \Sodium\crypto_sign_open($msg_signed, $alice_publickey); var_dump($msg_orig === $msg); $signature = \Sodium\crypto_sign_detached($msg, $alice_secretkey); var_dump(strlen($signature) === \Sodium\CRYPTO_SIGN_BYTES); var_dump(\Sodium\crypto_sign_verify_detached($signature, $msg, $alice_publickey)); var_dump(\Sodium\crypto_sign_verify_detached($signature, $msg . "\0", $alice_publickey)); $calc_pubkey = \Sodium\crypto_sign_publickey_from_secretkey($alice_secretkey); var_dump(\Sodium\memcmp($calc_pubkey, $alice_publickey) === 0); $ed25519key = \Sodium\hex2bin("55b62f664bf1c359f58a6b91b89556f97284273510573055b9237d17f5a20564607f0626f49e63c2c8f814ed6d955bf8b005b33fd5fd56eaca93073d8eb99165"); $curve25519key = \Sodium\crypto_sign_ed25519_sk_to_curve25519($ed25519key); var_dump($curve25519key === \Sodium\hex2bin("381b2be5e3d38820deb1243fb58b4be654da30dd3ccde492cb88f937eb489363")); ?> --EXPECT-- bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(false) bool(true) bool(true)
[-] crypto_hex.phpt
[edit]
[-] pwhash_scrypt.phpt
[edit]
[-] crypto_generichash.phpt
[edit]
[-] crypto_auth.phpt
[edit]
[-] randombytes.phpt
[edit]
[-] crypto_secretbox.phpt
[edit]
[-] crypto_aead.phpt
[edit]
[-] crypto_kx.phpt
[edit]
[-] crypto_box.phpt
[edit]
[-] crypto_scalarmult.phpt
[edit]
[-] installed.phpt
[edit]
[-] crypto_sign.phpt
[edit]
[+]
..
[-] version.phpt
[edit]
[-] crypto_stream.phpt
[edit]
[-] crypto_shorthash.phpt
[edit]
[-] utils.phpt
[edit]