hu_RSAPKCS1v15Dec()

Decrypts a single ciphertext block by applying the PKCS#1 v1.5 decryption scheme with an RSA private key.

Synopsis:

#include "hursa.h"
 
int hu_RSAPKCS1v15Dec(sb_Params rsaParams, sb_PrivateKey privateKey, size_t ciphertextLen, const unsigned char *ciphertext, size_t *plaintextLen, unsigned char *plaintext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

rsaParams

An RSA parameters object.

privateKey

An RSA private key object.

ciphertextLen

The length (in bytes) of the ciphertext buffer. This must be equal to the modulus length.

ciphertext

The ciphertext buffer.

plaintextLen

The length (in bytes) of the plaintext. This will be at most the modulus length minus 11.

plaintext

The plaintext buffer.

sbCtx

A global context.

Library:

libhuapi (For the qcc command, use the -l huapi option to link against this library)

Description:

This function implements the operation known as RSAES-PKCS1-v1_5-Decrypt in PKCS#1 v2.1.

If the length of the plaintext is known, a pointer to a buffer large enough to hold the plaintext should be passed in plaintext and its length in plaintextLen. This function will copy the plaintext into plaintext and set the actual length of the plaintext in plaintextLen.

If plaintext is NULL, or plaintext is not NULL but plaintextLen is too small, this function will set the maximum length of the plaintext in plaintextLen.

The length of the modulus can be determined by calling hu_RSAKeyGet() and retrieving the nLen argument.

Returns:

SB_ERR_NULL_PARAMS

The rsaParams object is NULL.

SB_ERR_BAD_PARAMS

The tag for the params object is not of the expected type.

SB_ERR_NULL_PRIVATE_KEY

The private key object is NULL.

SB_ERR_BAD_PRIVATE_KEY

The private key object is invalid.

SB_ERR_NULL_INPUT_BUF

The ciphertext buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The ciphertext buffer length is incorrect.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The plaintext buffer length is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The plaintext buffer length is invalid.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.