Generate an RSA key pair and save as two key files.
Public Declare Function RSA_MakeKeysXtd Lib "diCrPKI.dll" (ByVal strPubKeyFile As String, ByVal strPriKeyFile As String, ByVal strPassword As String, ByVal nBits As Long, ByVal nExpFermat As Long, ByVal strParams As String, ByVal nOptions As Long) As Long
nRet = RSA_MakeKeysXtd(strPubKeyFile, strPriKeyFile, strPassword, nBits, nExpFermat, strParams, nOptionFlags)
long __stdcall RSA_MakeKeysXtd(const char *szPubKeyFile, const char *szPriKeyFile, const char *szPassword, long nBits, long nExpFermat, const char *szParams, long nOptions);
""
for defaults.
Otherwise include a set of attribute-value pairs separated by a semi-colon ";" to set options from the following
count=<nnn>
to set the iteration count in the encrypted private key used in the PBKDF method,
e.g. "count=5000;"
[default=2048
]
prf=<hmac-name>
to change the HMAC algorithm used in the PBKDF2 method,
e.g. "prf=hmacWithSHA256;"
[default=hmacwithSHA1
]
rngseed=<string>
to add some extra user-specified additional seed for the random number generator,
e.g. "rngseed=pqrrr1234xyz;"
{hmacWithSHA1|hmacWithSHA224|hmacWithSHA256|hmacWithSHA384|hmacWithSHA512}
.
"pbeWithSHAAnd3-KeyTripleDES-CBC"
from PKCS12 (default)des-EDE3-CBC
aes128-CBC
aes192-CBC
aes256-CBC
If successful, the return value is zero; otherwise it returns a nonzero error code.
static Rsa.make_keys(pubkeyfile, prikeyfile, nbits, exponent, password, pbes=0, params='', fileformat=0)
The RSA keys are stored by default as a pair of DER-encoded binary files.
Setting the PKI_KEYGEN_INDICATE flag will show progress in a separate console window (actually two, one for p and one for q). Having a console window show progress will keep a parent application (like MS Access) happy and prevent it hanging due to boredom. The program will close these console windows down automatically (do not use Ctrl-C or Ctrl-Break: it will kill your entire process altogether!). Do not use the PKI_KEYGEN_INDICATE option in a multi-threaded environment. For console-based programs, this option just shows the progress in the standard output.
Dim r As Long ' Create a 2048-bit RSA key pair using defaults r = rsaMakeKeys("myrsa2048.pub", "myrsa2048.p8e", "password", 2048) ' Same but using stronger security and in PEM format r = rsaMakeKeys("myrsa2048ex.pub", "myrsa2048ex.p8e", "password1", 2048,,"count=6000;prf=hmacWithSHA256", PKI_PBE_PBKDF2_AES128 Or PKI_KEY_FORMAT_PEM)