1Crypt::KeyDerivation(3)User Contributed Perl DocumentatioCnrypt::KeyDerivation(3)
2
3
4
6 Crypt::KeyDerivation - PBKDF1, PBKFD2 and HKDF key derivation functions
7
9 ### PBKDF1/2
10 $derived_key1 = pbkdf1($password, $salt, $iteration_count, $hash_name, $len);
11 $derived_key2 = pbkdf2($password, $salt, $iteration_count, $hash_name, $len);
12
13 ### HKDF & co.
14 $derived_key3 = hkdf($keying_material, $salt, $hash_name, $len, $info);
15 $prk = hkdf_extract($keying_material, $salt, $hash_name);
16 $okm1 = hkdf_expand($prk, $hash_name, $len, $info);
17
19 Provides an interface to Key derivation functions:
20
21 · PBKFD1 and PBKDF according to PKCS#5 v2.0
22 <https://tools.ietf.org/html/rfc2898>
23
24 · HKDF (+ related) according to <https://tools.ietf.org/html/rfc5869>
25
27 pbkdf1
28 BEWARE: if you are not sure, do not use "pbkdf1" but rather choose
29 "pbkdf2".
30
31 $derived_key = pbkdf1($password, $salt, $iteration_count, $hash_name, $len);
32 #or
33 $derived_key = pbkdf1($password, $salt, $iteration_count, $hash_name);
34 #or
35 $derived_key = pbkdf1($password, $salt, $iteration_count);
36 #or
37 $derived_key = pbkdf1($password, $salt);
38
39 # $password ......... input keying material (password)
40 # $salt ............. salt/nonce (expected length: 8)
41 # $iteration_count .. optional, DEFAULT: 5000
42 # $hash_name ........ optional, DEFAULT: 'SHA256'
43 # $len .............. optional, derived key len, DEFAULT: 32
44
45 pbkdf2
46 $derived_key = pbkdf2($password, $salt, $iteration_count, $hash_name, $len);
47 #or
48 $derived_key = pbkdf2($password, $salt, $iteration_count, $hash_name);
49 #or
50 $derived_key = pbkdf2($password, $salt, $iteration_count);
51 #or
52 $derived_key = pbkdf2($password, $salt);
53
54 # $password ......... input keying material (password)
55 # $salt ............. salt/nonce
56 # $iteration_count .. optional, DEFAULT: 5000
57 # $hash_name ........ optional, DEFAULT: 'SHA256'
58 # $len .............. optional, derived key len, DEFAULT: 32
59
60 hkdf
61 $okm2 = hkdf($password, $salt, $hash_name, $len, $info);
62 #or
63 $okm2 = hkdf($password, $salt, $hash_name, $len);
64 #or
65 $okm2 = hkdf($password, $salt, $hash_name);
66 #or
67 $okm2 = hkdf($password, $salt);
68
69 # $password ... input keying material (password)
70 # $salt ....... salt/nonce, if undef defaults to HashLen zero octets
71 # $hash_name .. optional, DEFAULT: 'SHA256'
72 # $len ........ optional, derived key len, DEFAULT: 32
73 # $info ....... optional context and application specific information, DEFAULT: ''
74
75 hkdf_extract
76 $prk = hkdf_extract($password, $salt, $hash_name);
77 #or
78 $prk = hkdf_extract($password, $salt, $hash_name);
79
80 # $password ... input keying material (password)
81 # $salt ....... salt/nonce, if undef defaults to HashLen zero octets
82 # $hash_name .. optional, DEFAULT: 'SHA256'
83
84 hkdf_expand
85 $okm = hkdf_expand($pseudokey, $hash_name, $len, $info);
86 #or
87 $okm = hkdf_expand($pseudokey, $hash_name, $len);
88 #or
89 $okm = hkdf_expand($pseudokey, $hash_name);
90 #or
91 $okm = hkdf_expand($pseudokey);
92
93 # $pseudokey .. input keying material
94 # $hash_name .. optional, DEFAULT: 'SHA256'
95 # $len ........ optional, derived key len, DEFAULT: 32
96 # $info ....... optional context and application specific information, DEFAULT: ''
97
98
99
100perl v5.30.1 2020-01-29 Crypt::KeyDerivation(3)