1Crypt::KeyDerivation(3)User Contributed Perl DocumentatioCnrypt::KeyDerivation(3)
2
3
4

NAME

6       Crypt::KeyDerivation - PBKDF1, PBKDF2 and HKDF key derivation functions
7

SYNOPSIS

9         use Crypt::KeyDerivation ':all';
10
11         ### PBKDF1/2
12         $derived_key1 = pbkdf1($password, $salt, $iteration_count, $hash_name, $len);
13         $derived_key2 = pbkdf2($password, $salt, $iteration_count, $hash_name, $len);
14
15         ### HKDF & co.
16         $derived_key3 = hkdf($keying_material, $salt, $hash_name, $len, $info);
17         $prk  = hkdf_extract($keying_material, $salt, $hash_name);
18         $okm1 = hkdf_expand($prk, $hash_name, $len, $info);
19

DESCRIPTION

21       Provides an interface to Key derivation functions:
22
23       •   PBKDF1 and PBKDF according to PKCS#5 v2.0
24           <https://tools.ietf.org/html/rfc2898>
25
26       •   HKDF (+ related) according to <https://tools.ietf.org/html/rfc5869>
27

FUNCTIONS

29   pbkdf1
30       BEWARE: if you are not sure, do not use "pbkdf1" but rather choose
31       "pbkdf2".
32
33         $derived_key = pbkdf1($password, $salt, $iteration_count, $hash_name, $len);
34         #or
35         $derived_key = pbkdf1($password, $salt, $iteration_count, $hash_name);
36         #or
37         $derived_key = pbkdf1($password, $salt, $iteration_count);
38         #or
39         $derived_key = pbkdf1($password, $salt);
40
41         # $password ......... input keying material  (password)
42         # $salt ............. salt/nonce (expected length: 8)
43         # $iteration_count .. optional, DEFAULT: 5000
44         # $hash_name ........ optional, DEFAULT: 'SHA256'
45         # $len .............. optional, derived key len, DEFAULT: 32
46
47   pbkdf2
48         $derived_key = pbkdf2($password, $salt, $iteration_count, $hash_name, $len);
49         #or
50         $derived_key = pbkdf2($password, $salt, $iteration_count, $hash_name);
51         #or
52         $derived_key = pbkdf2($password, $salt, $iteration_count);
53         #or
54         $derived_key = pbkdf2($password, $salt);
55
56         # $password ......... input keying material (password)
57         # $salt ............. salt/nonce
58         # $iteration_count .. optional, DEFAULT: 5000
59         # $hash_name ........ optional, DEFAULT: 'SHA256'
60         # $len .............. optional, derived key len, DEFAULT: 32
61
62   hkdf
63         $okm2 = hkdf($password, $salt, $hash_name, $len, $info);
64         #or
65         $okm2 = hkdf($password, $salt, $hash_name, $len);
66         #or
67         $okm2 = hkdf($password, $salt, $hash_name);
68         #or
69         $okm2 = hkdf($password, $salt);
70
71         # $password ... input keying material (password)
72         # $salt ....... salt/nonce, if undef defaults to HashLen zero octets
73         # $hash_name .. optional, DEFAULT: 'SHA256'
74         # $len ........ optional, derived key len, DEFAULT: 32
75         # $info ....... optional context and application specific information, DEFAULT: ''
76
77   hkdf_extract
78         $prk  = hkdf_extract($password, $salt, $hash_name);
79         #or
80         $prk  = hkdf_extract($password, $salt, $hash_name);
81
82         # $password ... input keying material (password)
83         # $salt ....... salt/nonce, if undef defaults to HashLen zero octets
84         # $hash_name .. optional, DEFAULT: 'SHA256'
85
86   hkdf_expand
87         $okm = hkdf_expand($pseudokey, $hash_name, $len, $info);
88         #or
89         $okm = hkdf_expand($pseudokey, $hash_name, $len);
90         #or
91         $okm = hkdf_expand($pseudokey, $hash_name);
92         #or
93         $okm = hkdf_expand($pseudokey);
94
95         # $pseudokey .. input keying material
96         # $hash_name .. optional, DEFAULT: 'SHA256'
97         # $len ........ optional, derived key len, DEFAULT: 32
98         # $info ....... optional context and application specific information, DEFAULT: ''
99
100
101
102perl v5.34.0                      2022-02-14           Crypt::KeyDerivation(3)
Impressum