1--TEST--
2Crypto\Cipher::decrypt basic usage.
3--FILE--
4<?php
5$key = str_repeat('x', 32);
6$iv = str_repeat('i', 16);
7
8$ciphertext = pack("H*", '8f8853a1685607133cb9ee0fc7a5b8a57103935cbc39ea680def0db0767e954e');
9
10$cipher = new Crypto\Cipher('aes-256-cbc');
11
12// key length
13try {
14	$cipher->decrypt($ciphertext, 'short_key', $iv);
15}
16catch (Crypto\CipherException $e) {
17	if ($e->getCode() === Crypto\CipherException::KEY_LENGTH_INVALID) {
18		echo "SHORT KEY\n";
19	}
20}
21
22// iv length
23try {
24	$cipher->decrypt($ciphertext, $key, 'short_iv');
25}
26catch (Crypto\CipherException $e) {
27	if ($e->getCode() === Crypto\CipherException::IV_LENGTH_INVALID) {
28		echo "SHORT IV\n";
29	}
30}
31
32// init first
33echo $cipher->decrypt($ciphertext, $key, $iv) . "\n";
34
35?>
36--EXPECT--
37SHORT KEY
38SHORT IV
39aaaaaaaaaaaaaaaa
40