Attribute VB_Name = "basPassword"
Option Explicit
Public Sub Show_GetPassword()
Dim strPassword As String
Dim strPrivateKey As String
Dim strPriKeyFile As String
Dim nLen As Long
' Pre-dimension string to receive password
strPassword = String(255, " ")
nLen = PWD_Prompt(strPassword, Len(strPassword), "Your caption here")
If nLen <= 0 Then
' Cope with user not entering a password
' Your error handling here...
MsgBox "You must enter a password...", vbExclamation
Exit Sub
Else
strPassword = Left$(strPassword, nLen)
End If
' Now we have a password, we can read in the private key from the encrypted pkcs-8 file
strPriKeyFile = "C:\Test\MyEncPriKey.bin"
strPrivateKey = rsaReadPrivateKey(strPriKeyFile, strPassword)
' We are done with the password now, so erase it immediately
Call WIPE_String(strPassword, Len(strPassword))
strPassword = ""
' Were we successful in reading the private key?
If Len(strPrivateKey) <= 0 Then
' Cope with failure to read private key file
' ...
End If
' Now do something with the private key,
' say, nRet = RSA_RawPrivate(abBlock(0), nBlockLen, strPrivateKey, 0)
' ...
' IMPORTANT: Make sure we erase the secret data completely before we quit
Call WIPE_String(strPrivateKey, Len(strPrivateKey))
strPrivateKey = ""
End Sub