Code Duplication    Length = 14-15 lines in 2 locations

api/functions.php 1 location

@@ 2170-2184 (lines=15) @@
2167
    }
2168
}
2169
2170
function teampass_pbkdf2_hash($p, $s, $c, $kl, $st = 0, $a = 'sha256')
2171
{
2172
    $kb = $st + $kl;
2173
    $dk = '';
2174
2175
    for ($block = 1; $block <= $kb; $block++) {
2176
        $ib = $h = hash_hmac($a, $s.pack('N', $block), $p, true);
2177
        for ($i = 1; $i < $c; $i++) {
2178
            $ib ^= ($h = hash_hmac($a, $h, $p, true));
2179
        }
2180
        $dk .= $ib;
2181
    }
2182
2183
    return substr($dk, $st, $kl);
2184
}
2185

sources/main.functions.php 1 location

@@ 61-74 (lines=14) @@
58
}
59
60
//generate pbkdf2 compliant hash
61
function strHashPbkdf2($p, $s, $c, $kl, $a = 'sha256', $st = 0)
62
{
63
    $kb = $st + $kl; // Key blocks to compute
64
    $dk = ''; // Derived key
65
66
    for ($block = 1; $block <= $kb; $block++) { // Create key
67
        $ib = $h = hash_hmac($a, $s.pack('N', $block), $p, true); // Initial hash for this block
68
        for ($i = 1; $i < $c; $i++) { // Perform block iterations
69
            $ib ^= ($h = hash_hmac($a, $h, $p, true)); // XOR each iterate
70
        }
71
        $dk .= $ib; // Append iterated block
72
    }
73
    return substr($dk, $st, $kl); // Return derived key of correct length
74
}
75
76
/**
77
 * stringUtf8Decode()