1--TEST--
2Stream cipher ccm error
3--SKIPIF--
4<?php
5if (!Crypto\Cipher::hasMode(Crypto\Cipher::MODE_CCM)) {
6	die("Skip: CCM mode not defined (update OpenSSL version)");
7}
8?>
9--FILE--
10<?php
11$algorithm = 'aes-256-ccm';
12$key = str_repeat('x', 32);
13$iv = str_repeat('i', 16);
14$aad = str_repeat('b', 16);
15$tag = pack("H*", 'f3c2954804f101d3342f6b37ba46ac8e');
16
17$context = stream_context_create(array(
18	'crypto' => array(
19		'filters' => array(
20			array(
21				'type' => 'cipher',
22				'action' => 'decrypt',
23				'algorithm' => $algorithm,
24				'key' => $key,
25				'iv'  => $iv,
26				'tag' => $tag,
27				'aad' => $aad,
28			)
29		)
30	),
31));
32
33$filename = (dirname( __FILE__) . "/stream_filters_cipher_ccm_error.tmp");
34
35$stream = fopen("crypto.file://" . $filename, "w", false, $context);
36if (!$stream) {
37	echo "NOT SUPPORTED";
38}
39?>
40--CLEAN--
41<?php
42$filename = (dirname( __FILE__) . "/stream_filters_cipher_ccm_error.tmp");
43if (file_exists($filename))
44	unlink($filename);
45?>
46--EXPECTF--
47Warning: fopen(): The CCM mode is not supported in stream in %s on line %d
48
49Warning: %s failed to open stream: operation failed in %s on line %d
50NOT SUPPORTED
51