1--TEST--
2Crypto\Cipher::getTag in GCM mode basic usage.
3--SKIPIF--
4<?php
5if (!Crypto\Cipher::hasMode(Crypto\Cipher::MODE_GCM))
6	die("Skip: GCM mode not defined (update OpenSSL version)");
7?>
8--FILE--
9<?php
10$key = str_repeat('x', 32);
11$iv = str_repeat('i', 16);
12
13$data = str_repeat('a', 16);
14
15$cipher = new Crypto\Cipher('aes-256-gcm');
16
17try {
18	$cipher->getTag();
19}
20catch (Crypto\CipherException $e) {
21	if ($e->getCode() == Crypto\CipherException::TAG_GETTER_FORBIDDEN) {
22		echo "FLOW\n";
23	}
24}
25
26// init first
27echo bin2hex($cipher->encrypt($data, $key, $iv)) . "\n";
28echo bin2hex($cipher->getTag()) . "\n";
29
30
31?>
32--EXPECT--
33FLOW
34622070d3bea6f720943d1198a7e6afa5
35ed39e13f9a9fdf19036ad2f1ed5d2d1f
36