source: src/router/php7/ext/openssl/tests/openssl_decrypt_ccm.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 6 weeks ago

update php

File size: 1.2 KB
Line 
1--TEST--
2openssl_decrypt() with CCM cipher algorithm tests
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl"))
6        die("skip");
7if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
8        die("skip: aes-256-ccm not available");
9?>
10--FILE--
11<?php
12require_once __DIR__ . "/cipher_tests.inc";
13$method = 'aes-256-ccm';
14$tests = openssl_get_cipher_tests($method);
15
16foreach ($tests as $idx => $test) {
17        echo "TEST $idx\n";
18        $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
19                $test['iv'], $test['tag'], $test['aad']);
20        var_dump($test['pt'] === $pt);
21}
22
23// no IV
24var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
25    NULL, $test['tag'], $test['aad']));
26// failed because no AAD
27var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
28    $test['iv'], $test['tag']));
29// failed because wrong tag
30var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
31    $test['iv'], str_repeat('x', 10), $test['aad']));
32
33?>
34--EXPECTF--
35TEST 0
36bool(true)
37
38Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed, the expected length is 12 bytes in %s on line %d
39bool(false)
40bool(false)
41bool(false)
Note: See TracBrowser for help on using the repository browser.