@@ -10,15 +10,17 @@ if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
10
10
--FILE--
11
11
<?php
12
12
require_once __DIR__ . "/cipher_tests.inc " ;
13
- $ method = 'aes-256-ccm ' ;
14
- $ tests = openssl_get_cipher_tests ($ method );
13
+ $ methods = ['aes-128-ccm ' , 'aes-256-ccm ' ];
15
14
16
- foreach ($ tests as $ idx => $ test ) {
17
- echo "TEST $ idx \n" ;
18
- $ ct = openssl_encrypt ($ test ['pt ' ], $ method , $ test ['key ' ], OPENSSL_RAW_DATA ,
19
- $ test ['iv ' ], $ tag , $ test ['aad ' ], strlen ($ test ['tag ' ]));
20
- var_dump ($ test ['ct ' ] === $ ct );
21
- var_dump ($ test ['tag ' ] === $ tag );
15
+ foreach ($ methods as $ method ) {
16
+ $ tests = openssl_get_cipher_tests ($ method );
17
+ foreach ($ tests as $ idx => $ test ) {
18
+ echo "$ method - TEST $ idx \n" ;
19
+ $ ct = openssl_encrypt ($ test ['pt ' ], $ method , $ test ['key ' ], OPENSSL_RAW_DATA ,
20
+ $ test ['iv ' ], $ tag , $ test ['aad ' ], strlen ($ test ['tag ' ]));
21
+ var_dump ($ test ['ct ' ] === $ ct );
22
+ var_dump ($ test ['tag ' ] === $ tag );
23
+ }
22
24
}
23
25
24
26
// Empty IV error
@@ -32,7 +34,13 @@ var_dump(strlen($tag));
32
34
var_dump (openssl_encrypt ('data ' , $ method , 'password ' , 0 , str_repeat ('x ' , 16 ), $ tag , '' , 1024 ));
33
35
?>
34
36
--EXPECTF--
35
- TEST 0
37
+ aes-128-ccm - TEST 0
38
+ bool(true)
39
+ bool(true)
40
+ aes-128-ccm - TEST 1
41
+ bool(true)
42
+ bool(true)
43
+ aes-256-ccm - TEST 0
36
44
bool(true)
37
45
bool(true)
38
46
0 commit comments