hu_RSAKeyGet()

Retrieves the key values and their lengths from an RSA private and/or public key object.

Synopsis:

#include "hursa.h"
 
int hu_RSAKeyGet(sb_Params rsaParams, sb_PrivateKey privateKey, sb_PublicKey publicKey, size_t *eLen, unsigned char *e, size_t *nLen, unsigned char *n, size_t *dLen, unsigned char *d, size_t *pLen, unsigned char *p, size_t *qLen, unsigned char *q, size_t *dModPLen, unsigned char *dModPm1, size_t *dModQLen, unsigned char *dModQm1, size_t *qInvLen, unsigned char *qInvModP, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

rsaParams

An RSA parameters object.

privateKey

An RSA private key object.

publicKey

An RSA public key object.

eLen

The length (in bytes) of the public exponent.

e

The public exponent.

nLen

The length (in bytes) of the modulus.

n

Modulus.

dLen

The length (in bytes) of the private exponent. (This is the same as nLen.)

d

The private exponent.

pLen

The length (in bytes) of the first prime p.

p

First large prime factor of the modulus.

qLen

The length (in bytes) of the second prime q.

q

Second large prime factor of the modulus.

dModPLen

The length (in bytes) of the d mod p-1 CRT coefficient. (This is the same as pLen.)

dModPm1

d mod p-1 CRT coefficient.

dModQLen

The length (in bytes) of the d mod q-1 CRT coefficient. (This is the same as qLen.)

dModQm1

d mod q-1 CRT coefficient.

qInvLen

The length (in bytes) of q inverse mod p CRT coefficient. (This is the same as pLen.)

qInvModP

q inverse mod p CRT coefficient.

sbCtx

A global context.

Library:

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

Description:

The following values and their lengths can be retrieved from an RSA private key: n, d, p, q, d mod p-1, d mod q-1, q inverse mod p.

The following values and their lengths can be retrieved from an RSA public key: n, e.

If the prime factors p and q were generated or computed by the library, this function will return the primes such that p is numerically greater or equal to q. Otherwise, if these primes were supplied during key setting, this function will return them as given.

If the length of a key data value is known, a pointer to a buffer large enough to hold the key data value should be passed in the appropriate argument and its length in the corresponding length argument. This function will copy the value into the buffer and set the actual length of the value in the length argument.

If key value buffer is NULL, then this function will set the correct length of the key value in the length argument. If the buffer is not NULL but buffer length is too small, this function will return an error.

Set both the parameter argument and its length to NULL for any parameters that are to be ignored.

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_INPUT

Both the private key and public key objects are NULL.

SB_ERR_BAD_PRIVATE_KEY

The private key object is invalid.

SB_ERR_BAD_PUBLIC_KEY

The public key object is invalid.

SB_ERR_PRI_KEY_NOT_EXPORTABLE

The private exponent (d) is not exportable.

SB_ERR_RSA_CRT_NOT_AVAILABLE

The CRT components (p, q, d mod p-1, d mod q-1, q inverse mod p) cannot be retrieved.

SB_SUCCESS

Success.