CryptoSys PKI Pro Manual

rsaMakeKeys

Generate an RSA public/private key pair and save as two key files.

Syntax

[VBA]
Public Function rsaMakeKeys ( _
    szPubKeyFile As String, _
    szPriKeyFile As String, _
    szPassword As String, _
    nBits As Long, _
    Optional nExpFermat As Long = PKI_RSAEXP_EQ_65537, _
    Optional szParams As String = "", _
    Optional nOptions As Long = 0 _
) As Long

Parameters

szPubKeyFile
Output filename for public key.
szPriKeyFile
Output filename for (encrypted) private key.
szPassword
Password for encrypted private key (required).
nBits
Required key modulus size in bits (min 96).
nExpFermat
Exponent [default=65537=F4]
szParams
Optional parameters. A set of attribute name=value pairs separated by a semicolon ";" (see remarks).
nOptions
Use 0 for defaults.
A flag to indicate the password-based encryption scheme to be used to encrypt the private key file. Select from:
PKI_PBE_SHA_3DES (0) for "pbeWithSHAAnd3-KeyTripleDES-CBC" from PKCS12 (default)
PKI_PBE_PBKDF2_DESEDE3 for PBKDF2 using des-EDE3-CBC
PKI_PBE_PBKDF2_AES128 for PBKDF2 using aes128-CBC
PKI_PBE_PBKDF2_AES192 for PBKDF2 using aes192-CBC
PKI_PBE_PBKDF2_AES256 for PBKDF2 using aes256-CBC
plus optionally one of the following to output in textual PEM format [default format=DER binary]
PKI_KEY_FORMAT_PEM
PKI_KEY_FORMAT_SSL
and, optionally, add PKI_KEYGEN_INDICATE to indicate progress in a console window.

Return Value

Long: Zero on success.

Remarks

Valid name-value pair parameters for szParams are:
count=integer : To set the iteration count used in the PBKDF2 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 user-supplied entropy for the key generation process, e.g. "rngseed=pqrrr1234xyz;".
Valid values for hmac-name are {hmacWithSHA1|hmacWithSHA224|hmacWithSHA256|hmacWithSHA384|hmacWithSHA512}.

Example

' 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)
[PREV: rsaKeyValue...]   [Contents]   [Index]   
   [NEXT: rsaPublicKeyFromPrivate...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.