Hi Sir or Madam,
I am deeply urgently needed help on PBKDF2 matter. I had build a local external function for this. (See Below). But, i get error which i spent days still couldnt know how to solve it. Can anyone help me? I am totally new on external function. Luckily there Topwiz free code for me to use and refer. I just followed some of the sample. But still have problem . Please see below for my codes. Your help is highly appreciated.
(A)
Function ulong BCryptDeriveKeyPBKDF2 ( &
longptr hPrf, &
blob pbPassword, &
ulong cbPassword, &
blob pbSalt, &
ulong cbSalt, &
ulong cIterations, &
Ref blob pbDerivedKey, &
ulong cbDerivedKey, &
ulong dwFlags &
) Library "bcrypt.dll"
***********************************************************
(B)
//PBKDF2 - start
ULONG lul_salt
BLOB lblb_key
BLOB lblb_password
BLOB lblb_salt
//to generate random number - salt
of_gensalt(lul_salt)
messagebox('Ul_salt',string(lul_salt))
//*************
// not using the Ansi/Unicode option
lblb_password = Blob(ls_password, EncodingAnsi!)
lblb_salt = Blob(string(lul_salt))
// generate
lblb_key =in_bc.of_getderivedkey(lblb_password, lblb_salt)
If IsNull(lblb_key) Then
MessageBox(in_bc.LastFunction + " Failed", &
in_bc.LastErrText, StopSign!)
Return 1
End If
//*************
//PBKDF2 - end
***********************************************************
(C) - of_gensalt
aul_Random = in_bc.of_RandomNbr()
If IsNull(aul_Random) Then
MessageBox(in_bc.LastFunction + " Failed", &
in_bc.LastErrText, StopSign!)
Return
End If
***********************************************************
(D) - of_getderivedkey
public function blob of_getderivedkey (ref blob alblb_password, ref blob alblb_salt);
BLOB lblb_resultkey
BLOB lblb_NullReturn
ULONG lul_password_len
ULONG lul_salt_len
SetNull(lblb_NullReturn)
// open an algorithm handle
If Not NT_SUCCESS(BCryptOpenAlgorithmProvider(il_hRanAlg, &
BCRYPT_SHA512_ALGORITHM, 0, 0)) Then
of_ErrorCleanup("BCryptOpenAlgorithmProvider")
Return lblb_NullReturn
End If
lul_password_len= len(alblb_password)
lul_salt_len = len(alblb_salt)
// Allocate Plain Text Buffer
//lblb_resultkey = Blob(Space(256), iEncoding)
messagebox('il_hAlg',string(il_hAlg))
If Not NT_SUCCESS(BCryptDeriveKeyPBKDF2(il_hAlg, &
alblb_password, lul_password_len, &
alblb_salt, lul_salt_len, &
1000, lblb_resultkey, 0 ,0))Then
of_ErrorCleanup("BCryptDeriveKeyPBKDF2")
Return lblb_NullReturn
End If
// trim off any extra space
//lblb_resultkey = BlobMid(lblb_resultkey, 1, 256)
of_FinalCleanup()
//
Return lblb_resultkey