hu_ECIESDecrypt()

Decrypts ciphertext using ECIES with XOR encryption, standard Diffie-Hellman, ANSI X9.42/X9.63 KDF with SHA-1 and HMAC-SHA-1 primitives.

Synopsis:

#include "huecc.h"
 
int hu_ECIESDecrypt(sb_Params eccParams, sb_PrivateKey privateKey, size_t addInfoKDFLen, const unsigned char *addInfoKDF, size_t addInfoHMACLen, const unsigned char *addInfoHMAC, size_t ciphertextLen, const unsigned char *ciphertext, size_t *plaintextLen, unsigned char *plaintext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

eccParams

An ECC parameters object.

privateKey

An ECC private key object.

addInfoKDFLen

The length (in bytes) of additional information for KDF. (Optional)

addInfoKDF

Additional information for KDF. (Optional - set to NULL if not used.)

addInfoHMACLen

The length (in bytes) of additional information for HMAC. (Optional)

addInfoHMAC

Additional information for HMAC. (Optional - set to NULL if not used.)

ciphertextLen

The length (in bytes) of the ciphertext.

ciphertext

The ciphertext.

plaintextLen

The length (in bytes) of the plaintext.

plaintext

The plaintext.

sbCtx

A global context.

Library:

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

Description:

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

If plaintext is NULL, this function will set the correct length of the plaintext in plaintextLen. If plaintext is not NULL but plaintextLen is too small, this function will return an error.

If this function returns SB_FAIL_ECIES_HMAC, the integrity check on the ciphertext failed, and could be due to using the wrong private key or corrupted ciphertext or MAC tag.

Returns:

SB_ERR_NULL_PARAMS

The eccParams 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 privateKey object NULL.

SB_ERR_BAD_PRIVATE_KEY

The privateKey object invalid.

SB_ERR_NULL_INPUT_BUF

The ciphertext buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The length of the ciphertext buffer length is invalid.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The plaintext buffer is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The length of the plaintext buffer is invalid.

SB_ERR_BAD_INPUT

The ephemeral public key in the ciphertext is invalid.

SB_FAIL_ECIES_HMAC

The ciphertext integrity check failed.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.

Last modified: 2014-05-14



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus