xref: /PHP-8.2/ext/hash/tests/hash_hkdf_edges.phpt (revision b5c7a83d)
1--TEST--
2Hash: hash_hkdf() function: edge cases
3--FILE--
4<?php
5
6echo "*** Testing hash_hkdf(): edge cases ***\n";
7
8$ikm = 'input key material';
9
10echo 'Length < digestSize: ', bin2hex(hash_hkdf('md5', $ikm, 7)), "\n";
11echo 'Length % digestSize != 0: ', bin2hex(hash_hkdf('md5', $ikm, 17)), "\n";
12echo 'Algo name case-sensitivity: ', (bin2hex(hash_hkdf('Md5', $ikm, 7)) === '98b16391063ece' ? 'true' : 'false'), "\n";
13echo "Non-crypto algo name case-sensitivity:\n";
14
15try {
16    var_dump(hash_hkdf('jOaAt', $ikm));
17}
18catch (\Error $e) {
19    echo '[Error] ' . $e->getMessage() . "\n";
20}
21
22?>
23--EXPECT--
24*** Testing hash_hkdf(): edge cases ***
25Length < digestSize: 98b16391063ece
26Length % digestSize != 0: 98b16391063ecee006a3ca8ee5776b1e5f
27Algo name case-sensitivity: true
28Non-crypto algo name case-sensitivity:
29[Error] hash_hkdf(): Argument #1 ($algo) must be a valid cryptographic hashing algorithm
30