xref: /PHP-7.4/ext/hash/tests/hash_hkdf_edges.phpt (revision f73c0102)
1--TEST--
2Hash: hash_hkdf() function: edge cases
3--FILE--
4<?php
5
6/* Prototype  : string hkdf  ( string $algo  , string $ikm  [, int $length  , string $info = '' , string $salt = ''  ] )
7 * Description: HMAC-based Key Derivation Function
8 * Source code: ext/hash/hash.c
9*/
10
11echo "*** Testing hash_hkdf(): edge cases ***\n";
12
13$ikm = 'input key material';
14
15echo 'Length < digestSize: ', bin2hex(hash_hkdf('md5', $ikm, 7)), "\n";
16echo 'Length % digestSize != 0: ', bin2hex(hash_hkdf('md5', $ikm, 17)), "\n";
17echo 'Algo name case-sensitivity: ', (bin2hex(hash_hkdf('Md5', $ikm, 7)) === '98b16391063ece' ? 'true' : 'false'), "\n";
18echo "Non-crypto algo name case-sensitivity:\n";
19var_dump(hash_hkdf('jOaAt', $ikm));
20
21?>
22--EXPECTF--
23*** Testing hash_hkdf(): edge cases ***
24Length < digestSize: 98b16391063ece
25Length % digestSize != 0: 98b16391063ecee006a3ca8ee5776b1e5f
26Algo name case-sensitivity: true
27Non-crypto algo name case-sensitivity:
28
29Warning: hash_hkdf(): Non-cryptographic hashing algorithm: jOaAt in %s on line %d
30bool(false)
31