11--TEST--
22Check for libsodium stream
33--SKIPIF--
4- <?php if (!extension_loaded ("sodium " ) || !defined ('CRYPTO_STREAM_XCHACHA20_KEYBYTES ' )) print "skip " ; ?>
4+ <?php if (!extension_loaded ("sodium " ) || !defined ('SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES ' )) print "skip " ; ?>
55--FILE--
66<?php
77$ nonce = random_bytes (SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES );
@@ -32,10 +32,30 @@ $stream6 = sodium_crypto_stream_xchacha20_xor($stream5, $nonce, $key);
3232
3333var_dump ($ stream6 === $ stream );
3434
35+ try {
36+ sodium_crypto_stream_xchacha20 (-1 , $ nonce , $ key );
37+ } catch (SodiumException $ ex ) {
38+ echo $ ex ->getMessage (), "\n" ;
39+ }
3540try {
3641 sodium_crypto_stream_xchacha20 ($ len , substr ($ nonce , 1 ), $ key );
3742} catch (SodiumException $ ex ) {
38- var_dump (true );
43+ echo $ ex ->getMessage (), "\n" ;
44+ }
45+ try {
46+ sodium_crypto_stream_xchacha20 ($ len , $ nonce , substr ($ key , 1 ));
47+ } catch (SodiumException $ ex ) {
48+ echo $ ex ->getMessage (), "\n" ;
49+ }
50+ try {
51+ sodium_crypto_stream_xchacha20_xor ($ stream , substr ($ nonce , 1 ), $ key );
52+ } catch (SodiumException $ ex ) {
53+ echo $ ex ->getMessage (), "\n" ;
54+ }
55+ try {
56+ sodium_crypto_stream_xchacha20_xor ($ stream , $ nonce , substr ($ key , 1 ));
57+ } catch (SodiumException $ ex ) {
58+ echo $ ex ->getMessage (), "\n" ;
3959}
4060
4161?>
@@ -49,4 +69,8 @@ bool(true)
4969bool(true)
5070bool(true)
5171bool(true)
52- bool(true)
72+ sodium_crypto_stream_xchacha20(): Argument #1 ($length) must be greater than 0
73+ sodium_crypto_stream_xchacha20(): Argument #2 ($nonce) must be SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES bytes long
74+ sodium_crypto_stream_xchacha20(): Argument #3 ($key) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long
75+ sodium_crypto_stream_xchacha20_xor(): Argument #2 ($nonce) must be SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES bytes long
76+ sodium_crypto_stream_xchacha20_xor(): Argument #3 ($key) must be SODIUM_CRYPTO_STREAM_XCHACHA20_KEYBYTES bytes long
0 commit comments