hu_DESEncryptMsg()

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

Synopsis:

#include "hudes.h"
 
int hu_DESEncryptMsg(sb_Params desParams, sb_Key desKey, 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:

desParams

A DES parameters object.

desKey

A DES key object.

ivLen

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

iv

The initial vector.

length

The length (in bytes) of plaintext. The acceptable values are multiples of SB_DES_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 is required for the SB_DES_CBC, SB_DES_CFB64 and SB_DES_OFB64 modes of operation. iv is ignored for SB_DES_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.

Note: 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 desParams object is NULL.

SB_ERR_BAD_PARAMS

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

SB_ERR_NULL_KEY

The desKey object is NULL.

SB_ERR_BAD_KEY

The desKey object is invalid.

SB_ERR_NULL_IV

The initial vector, iv, is NULL.

SB_ERR_BAD_IV_LEN

The length of the initial vector, ivLen, is invalid.

SB_ERR_NULL_INPUT_BUF

The plaintext buffer is NULL.

SB_ERR_NULL_OUTPUT_BUF

The ciphertext buffer is NULL.

SB_SUCCESS

Success.