hu_RSAPSSNoHashSign()

Generates a signature on the given message digest by applying the PKCS#1 v2.1 signature scheme.

Synopsis:

#include "hursapss.h"
 
int hu_RSAPSSNoHashSign(sb_Params rsaParams, sb_PrivateKey privateKey, int hashAlgId, size_t digestLen, const unsigned char *digest, size_t saltLen, size_t *signatureLen, unsigned char *signature, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

rsaParams

An RSA parameters object.

privateKey

An RSA private key object.

hashAlgId

The message digest algorithm identifier. The acceptable values are one of the SB_RSA_PSS_* macros.

digestLen

The length in bytes of the message digest.

digest

The message digest.

saltLen

The length of the salt. The recommended value is digestLen.

signatureLen

The length in bytes of the signature. This must be at least the modulus length.

signature

The signature value.

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 RSASSA-PSS-Sign in PKCS#1 v2.1.

This function uses the EMSA-PSS encoding method, with the MGF1 Mask Generation function as described in PKCS#1 v2.1.

This function assumes that the input is a message digest produced by the specified digest algorithm; no digest operation will be performed on the input. The specified message digest algorithm will be used in the EMSA-PSS encoding method as well.

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

If signature is NULL, or signature is not NULL but signatureLen is too small, this function will return an error.

The value of saltLen determines the length of the salt that will be used in the signature operation. It is recommended in PKCS#1 v2.1 that this value be the same as digestLen. The salt length used for the verification operation must match the salt length used for

the signature operation. The recommended salt length should always be used unless the salt length is clearly specified and known by both the signer and the verifier.

The modulus being used must be large enough for the data being signed. Thus, the minimum size of the modulus depends on both the saltLen and digestLen. This minimum is roughly equal to the sum of saltLen and digestLen. The exact relation that must be preserved is: ((# of bits in the modulus) - 1) >= 8*digestLen + 8*saltLen + 9

The RSA parameter object must have been created with an RNG context if saltLen is not zero.

Returns:

SB_ERR_NULL_PARAMS

The rsaParams object is NULL.

SB_ERR_BAD_PARAMS

The rsaParams object is invalid.

SB_ERR_NULL_PRIVATE_KEY

The private key object is NULL.

SB_ERR_BAD_PRIVATE_KEY

The private key object is invalid.

SB_ERR_BAD_HASH_TYPE

The message digest algorithm identifier is invalid.

SB_ERR_NULL_INPUT_BUF

The message digest buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The length of the message digest is invalid.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The length of the signature buffer is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The signature buffer is invalid.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.