hu_RSAKEMRawSecretEncrypt()

This function performs the first two steps of RSA KEM: generating a random number and encrypting it with a public key.

Synopsis:

#include "hursa.h"
 
int hu_RSAKEMRawSecretEncrypt(sb_Params RSAParams, sb_PublicKey publicKey, size_t *secretLen, unsigned char *secret, size_t *ciphertextLen, unsigned char *ciphertext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

RSAParams

RSA parameters object.

publicKey

Public key object.

secretLen

The length (in bytes) of the secret. On input, this must not less than the modulus length.

secret

The buffer for the generated random number.

ciphertextLen

The length (in bytes) of the ciphertext. On input, this must not less than the modulus length.

ciphertext

Ciphertext.

sbCtx

Memory callback data.

Library:

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

Description:

If the secret or ciphertext buffer is set to NULL, the necessary length will be returned to secretLen or ciphertextLen.

If the length of the secret or ciphertext buffer is larger than necessary, this function will set secretLen or ciphertextLen to the right value upon return.

Returns:

SB_ERR_NULL_PARAMS

RSA parameters object is NULL.

SB_ERR_BAD_PARAMS

RSA parameters object is invalid.

SB_ERR_NULL_PUBLIC_KEY

Public key object is NULL.

SB_ERR_BAD_PUBLIC_KEY

Public key object is invalid.

SB_ERR_NULL_CONTEXT

The rngCtx in RSAParams is NULL.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The secretLen or ciphertextLen is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The secretLen or ciphertextLen is shorter than necessary.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.