hu_ARC2EncryptMsg()

Encrypts a plaintext buffer using the given ARC2 parameters and key.

Synopsis:

#include "huarc2.h"
 
int hu_ARC2EncryptMsg(sb_Params arc2Params, sb_Key arc2Key, size_t ivLen, const unsigned char *iv, size_t length, const unsigned char *plaintext, unsigned char *ciphertext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

arc2Params

An ARC2 parameters object.

arc2Key

An ARC2 key object.

ivLen

The length (in bytes) of initial vector. The only acceptable value is SB_ARC2_IV_SIZE.

iv

The initial vector.

length

The length (in bytes) of plaintext. The acceptable values are multiples of SB_ARC2_BLOCK_SIZE.

plaintext

The plaintext buffer.

ciphertext

The ciphertext buffer.

sbCtx

A global context.

Library:

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

Description:

An initial vector, iv, is required for the SB_ARC2_CBC, SB_ARC2_CFB64 and SB_ARC2_OFB64 modes of operation. iv is ignored for SB_ARC2_ECB, as an initial vector is not required for that mode.

The plaintext and ciphertext buffers must be the same length, and may overlap in memory subject to the constraints described in the API Reference section on overlapping buffers.

This function should only be called for blocks of plaintext and ciphertext that can be stored entirely in memory.

Returns:

SB_ERR_NULL_PARAMS

The arc2Params parameters object is NULL.

SB_ERR_BAD_PARAMS

The tag for the params object is not of the expected type.

SB_ERR_NULL_KEY

The arc2Key key object is NULL.

SB_ERR_BAD_KEY

The arc2Key key object is invalid.

SB_ERR_NULL_IV

The initial vector, iv, is NULL.

SB_ERR_BAD_IV_LEN

ivLen is an invalid initial vector length.

SB_ERR_NULL_INPUT_BUF

The plaintext plaintext buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The plaintext plaintext buffer length is invalid.

SB_ERR_NULL_OUTPUT_BUF

The ciphertext ciphertext buffer is NULL.

SB_SUCCESS

Success.