hu_RSAPKCS1v15SigPadExponent()

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

Synopsis:

#include "hursa.h"
 
int hu_RSAPKCS1v15SigPadExponent(sb_Params rsaParams, sb_PrivateKey privateKey, size_t messageLen, const unsigned char *message, size_t *sigtextLen, unsigned char *sigtext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

rsaParams

An RSA parameters object.

privateKey

An RSA private key object.

messageLen

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

message

The plaintext buffer.

sigtextLen

The length (in bytes) of the ciphertext buffer. This must be at least the modulus length.

sigtext

The ciphertext 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-Sign 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 padding the plaintext message using the block formatting of EMSA-PKCS1-v1_5-Encode, and applying the basic RSA primitive on the padded message using a private key.

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

If sigtext is NULL, this function will set the correct length of the ciphertext in sigtextLen. If sigtext is not NULL but sigtextLen is too small, this function will return an error and set the correct length of the ciphertext in sigtextLen.

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 plaintext buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The plaintext buffer length is invalid.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The ciphertext buffer length is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The ciphertext buffer length is invalid.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.