CryptoSys PKI Pro Manual

RSA_Decrypt

Decrypt a message encrypted using an RSA encryption scheme.

VBA/VB6 Syntax

Public Declare Function RSA_Decrypt Lib "diCrPKI.dll" (ByRef lpOutput As Byte, ByVal nOutBytes As Long, ByRef lpInput As Byte, ByVal nInputLen As Long, ByVal strPrivateKeyFile As String, ByVal strPassword As String, ByVal strParameters As String, ByVal nOptions As Long) As Long

nRet = RSA_Decrypt(lpOutput(0), nOutBytes, lpInput(0), nInputLen, strPrivateKeyFile, strPassword, strParameters, nOptions)

C/C++ Syntax

long __stdcall RSA_Decrypt(unsigned char *lpOutput, long nOutBytes, const unsigned char *lpInput, long nInputLen, const char *szPrivateKeyFile, const char *szPassword, const char *szParameters, long nOptions);

Parameters

lpOutput
[out] byte array to receive the decrypted output.
nOutBytes
[in] maximum length of the output array.
lpInput
[in] byte array containing the data to be decrypted.
nInputLen
[in] length of input in bytes.
szPrivateKeyFile
[in] specifying the name of the private key file (or a string containing the key in PEM format, or a valid internal private key string).
szPassword
[in] Password for encrypted private key, or "" if password is not required.
szParameters
[in] For future use. Specify "".
nOptions
[in] option flags. Include one of the following:-
PKI_EME_PKCSV1_5 (0) to decrypt using the RSAES-PKCS1-v1_5 encryption scheme (default).
PKI_EME_OAEP to decrypt using the RSAES-OAEP encryption scheme.

If you have selected PKI_EME_OAEP, then add one of these options to set the hash function used for EME-OAEP encoding:
PKI_HASH_SHA1 (0) to use SHA-1 (default).
PKI_HASH_SHA224 to use SHA-224
PKI_HASH_SHA256 to use SHA-256
PKI_HASH_SHA384 to use SHA-384
PKI_HASH_SHA512 to use SHA-512
and, optionally, add:-
PKI_MGF_MGF1SHA1 to force the MGF hash function to be SHA-1 (default = same as encoding hash function set above)

Returns (VBA/C)

If successful, the return value is the number of bytes required to store the full output data. If an error occurs, it returns a negative error code.

VBA Wrapper Syntax

Public Function rsaDecrypt (lpInput() As Byte, szPrivateKeyFile As String, szPassword As String, nOptions As Long, Optional szParameters As String = "") As Byte()

.NET Equivalent

Rsa.Decrypt Method

C++ (STL) Equivalent

static bvec_t dipki::Rsa::Decrypt (const bvec_t &data, const std::string &privateKeyFileOrString, const std::string &password="", EME method=EME::PKCSv1_5, HashAlg hashAlg=HashAlg::Sha1, AdvOpts advOpts=AdvOpts::Default)

Python Equivalent

static Rsa.decrypt(data, prikeyfileorstring, password="", method=EME.PKCSV1_5, hashalg=HashAlg.SHA1, advopts=AdvOpts.DEFAULT)

Remarks

Set nOutBytes to zero and/or lpOutput to 0 (or NULL) to return the required number of bytes. The output will always be shorter than the input length.

For RSA-OAEP you must set the correct options to match the parameters used for the encryption. For more details see RSA encryption and signature schemes.

Example (VBA core function)

See RSA_Encrypt.

Example (VBA wrapper function)

See example for VBA wrapper rsaEncrypt in RSA_Encrypt.

See Also

RSA_Encrypt RSA_DecodeMsg RSA_RawPrivate

[Contents] [Index]

[PREV: RSA_DecodeMsg...]   [Contents]   [Index]   
   [NEXT: RSA_EncodeMsg...]

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