1
1
--TEST--
2
2
Check for libsodium stream
3
3
--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 " ; ?>
5
5
--FILE--
6
6
<?php
7
7
$ nonce = random_bytes (SODIUM_CRYPTO_STREAM_XCHACHA20_NONCEBYTES );
@@ -32,10 +32,30 @@ $stream6 = sodium_crypto_stream_xchacha20_xor($stream5, $nonce, $key);
32
32
33
33
var_dump ($ stream6 === $ stream );
34
34
35
+ try {
36
+ sodium_crypto_stream_xchacha20 (-1 , $ nonce , $ key );
37
+ } catch (SodiumException $ ex ) {
38
+ echo $ ex ->getMessage (), "\n" ;
39
+ }
35
40
try {
36
41
sodium_crypto_stream_xchacha20 ($ len , substr ($ nonce , 1 ), $ key );
37
42
} 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" ;
39
59
}
40
60
41
61
?>
@@ -49,4 +69,8 @@ bool(true)
49
69
bool(true)
50
70
bool(true)
51
71
bool(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