xref: /PHP-7.3/ext/hash/tests/bug52240.phpt (revision 423c1927)
1--TEST--
2Bug #52240 (hash_copy() does not copy the HMAC key, causes wrong results and PHP crashes)
3--SKIPIF--
4<?php extension_loaded('hash') or die('skip'); ?>
5--FILE--
6<?php
7
8$h = hash_init('md5', HASH_HMAC, '123456');
9$h2 = hash_copy($h);
10var_dump(hash_final($h));
11$h3 = hash_copy($h2);
12var_dump(hash_final($h2));
13var_dump(hash_final($h3));
14
15?>
16--EXPECT--
17string(32) "cab1380ea86d8acc9aa62390a58406aa"
18string(32) "cab1380ea86d8acc9aa62390a58406aa"
19string(32) "cab1380ea86d8acc9aa62390a58406aa"
20