protected byte [ ] PBKDF2 ( PRF prf , byte [ ] S , int c , int dkLen ) { if ( S == null ) { S = new byte [ 0 ] ; } int hLen = prf . getHLen ( ) ; int l = ceil ( dkLen , hLen ) ; int r = dkLen - ( l - 1 ) * hLen ; byte T [ ] = new byte [ l * hLen ] ; int ti_offset = 0 ; for ( int i = 1 ; i <= l ; i ++ ) { _F ( T , ti_offset , prf , S , c , i ) ; ti_offset += hLen ; } if ( r < hLen ) { // Incomplete last block byte DK [ ] = new byte [ dkLen ] ; System . arraycopy ( T , 0 , DK , 0 , dkLen ) ; return DK ; } return T ; }
Core Password Based Key Derivation Function 2 .