IPWorks Encrypt 2020 C++ Edition

Questions / Feedback?

Decrypt Method

Decrypts the input data using the specified private key.

Syntax

ANSI (Cross Platform)
int Decrypt();

Unicode (Windows)
INT Decrypt();
- (void)decrypt;
#define MID_ELGAMAL_DECRYPT 4

IPWORKSENCRYPT_EXTERNAL int IPWORKSENCRYPT_CALL IPWorksEncrypt_Elgamal_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

This method decrypts the input data using the private key specified in the Key* properties. Alternatively, a certificate may be specified by setting Certificate

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

  • SetOutputStream
  • OutputFile
  • OutputMessage: The output data is written to this property if no other destination is specified.

When using streams you may need to additionally set CloseInputStreamAfterProcessing or CloseOutputStreamAfterProcessing.

Key Size and the Maximum Length of Data

RSA has an upper limit to the amount of data that can be encrypted or decrypted, also known as message length. This can typically be calculated as the size of the key minus the size of the RSA header and padding.

When not using OAEP, the following formula and table can be referenced. (RSA Key Bytes) - (Header Bytes) = Length of data, where Header Bytes is always 11.

RSA Key Length (bits)Length (bits)Length (bytes)
1024 936 117
2048 1960 245
3072 2984 373
4096 4008 501

When using OAEP, the following formula and table can be referenced. (RSA Key Bytes) - (2 * Hash Length Bytes) - 2 = Length of data. The table below assumes SHA-256 for the hash, so Hash Length Bytes is 32.

RSA Key Length (bits)Length (bits)Length (bytes)
1024 496 62
2048 1520 190
3072 2544 318
4096 3568 446

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Encrypt 2020 C++ Edition - Version 20.0 [Build 8155]