hu_RSAPKCS1v15VerPadExponent()

Produces a plaintext block by applying the basic RSA primitive using a public key on a ciphertext block that was PKCS#1 v1.5 signature padded.

Synopsis:

#include "hursa.h"
 
int hu_RSAPKCS1v15VerPadExponent(sb_Params rsaParams, sb_PublicKey publicKey, size_t sigtextLen, const unsigned char *sigtext, size_t *messageLen, unsigned char *message, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

rsaParams

An RSA parameters object.

publicKey

An RSA public key object.

sigtextLen

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

sigtext

The ciphertext buffer.

messageLen

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

message

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 a modified version of the operation known as RSASSA-PKCS1-v1_5-Verify in PKCS#1 v2.1. The encoding of a message digest into an ASN.1 DigestInfo structure with DER is replaced by the plaintext message unchanged.

In other words, the operation consists of applying the basic RSA primitive on the ciphertext using a public key, ensuring that the decrypted block uses the block formatting of EMSA-PKCS1-v1_5-Encode, and returning the unpadded plaintext.

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

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

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_PUBLIC_KEY

The public key object is NULL.

SB_ERR_BAD_PUBLIC_KEY

The public 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 invalid.

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.