hu_ECIESEncrypt()

Encrypts plaintext 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_ECIESEncrypt(sb_Params eccParams, sb_PublicKey publicKey, size_t addInfoKDFLen, const unsigned char *addInfoKDF, size_t addInfoHMACLen, const unsigned char *addInfoHMAC, size_t plaintextLen, const unsigned char *plaintext, size_t *ciphertextLen, unsigned char *ciphertext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

eccParams

An ECC parameters object.

publicKey

An ECC public 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.)

plaintextLen

The length (in bytes) of the plaintext.

plaintext

The plaintext.

ciphertextLen

The length (in bytes) of the ciphertext.

ciphertext

The ciphertext.

sbCtx

A global context.

Library:

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

Description:

A MAC tag forms part of the ciphertext and is used to verify integrity during decryption.

The ECC parameter object must have been created with an RNG context.

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

If ciphertext is NULL, or ciphertext is not NULL but ciphertextLen is too small, this function will set the correct length of the ciphertext in ciphertextLen.

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_NO_RNG

No RNG context was found in the parameters object.

SB_ERR_NULL_PUBLIC_KEY

The publicKey object is NULL.

SB_ERR_BAD_PUBLIC_KEY

The publicKey object is invalid.

SB_ERR_NULL_INPUT_BUF

Plaintext buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The length of the plaintext buffer is invalid.

SB_ERR_NULL_OUTPUT_BUF_LEN_PTR

The ciphertext buffer is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The length of the ciphertext buffer is invalid.

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