hu_DESKeySet()

Creates an DES key object from the given key value(s) that can later be used for encryption and/or decryption.

Synopsis:

#include "hudes.h"
 
int hu_DESKeySet(sb_Params desParams, size_t key1Len, const unsigned char *key1, size_t key2Len, const unsigned char *key2, size_t key3Len, const unsigned char *key3, sb_Key *desKey, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

desParams

A DES parameters object.

key1Len

The length (in bytes) of key1. The only acceptable value is SB_DES_KEY_SIZE.

key1

Key 1 value.

key2Len

The length (in bytes) of key1. The only acceptable value is SB_DES_KEY_SIZE. Ignored if the mode is SB_DES_DES.

key2

Key 2 value. Ignored if the mode is SB_DES_DES.

key3Len

The length (in bytes) of key1. The only acceptable value is SB_DES_KEY_SIZE. Ignored if the mode is SB_DES_DES.

key3

Key 3 value. Ignored if the mode is SB_DES_DES.

desKey

The DES key object pointer.

sbCtx

The global context.

Library:

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

Description:

If the algorithm is SB_DES_DES, a key value must be given in key1. The key2 and key3 arguments will be ignored.

If the algorithm is SB_DES_TDES or SB_DES_DESX, all three key buffers must be given.

For SB_DES_DESX, key 1 is the encryption key, key 2 is the prewhitening key and key 3 is the postwhitening key.

If the parity mode is SB_DES_PARITY_ON, an error will be returned if any of the encryption keys have incorrect parity.

If the weak key mode is SB_DES_WEAK_KEY_ON, an error will be returned if any of the encryption keys match a known weak key.

Returns:

SB_ERR_NULL_PARAMS

The desParams parameters object is NULL.

SB_ERR_BAD_PARAMS

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

SB_ERR_BAD_KEY_LEN

Key length is invalid.

SB_ERR_BAD_KEY_PARITY

Key value has incorrect parity.

SB_ERR_WEAK_KEY

Key value is known to be weak.

SB_ERR_NULL_KEY_PTR

Key object pointer is NULL.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.