imx-test-3.0.35-4.1.0/test/mxc_sahara_test/user_wrap.c File Reference

Test code for Wrapped (Black) Key support in FSL SHW API. More...

Functions

static void init_key_and_sym_ctx (fsl_shw_key_alg_t key_alg, unsigned key_len, fsl_shw_sko_t *key_info, fsl_shw_scco_t *sym_ctx)
static int create_key (fsl_shw_uco_t *my_ctx, fsl_shw_sko_t *key_info, fsl_shw_scco_t *sym_ctx, const uint8_t *plaintext, uint32_t len, uint8_t *encrypt_output)
static int extract_reestablish_key (fsl_shw_uco_t *my_ctx, fsl_shw_kso_t *my_keystore, uint32_t ownerid, uint32_t handle, fsl_shw_scco_t *sym_ctx, const uint8_t *ciphertext, const uint8_t *expected_plaintext, uint32_t len)
void run_user_wrap (fsl_shw_uco_t *my_ctx, uint32_t *total_passed_count, uint32_t *total_failed_count)

Variables

static const unsigned char known_key []
static unsigned char known_plaintext []
static const unsigned char TDES_known_ciphertext []
static const unsigned char ARC4_known_ciphertext []

Detailed Description

Test code for Wrapped (Black) Key support in FSL SHW API.

This file contains vectors and code to test fsl_shw_establish_key(), fsl_shw_extract_key(), fsl_shw_release_key(), and the functions associated with the Secret Key Object.


Function Documentation

static int create_key ( fsl_shw_uco_t my_ctx,
fsl_shw_sko_t key_info,
fsl_shw_scco_t sym_ctx,
const uint8_t *  plaintext,
uint32_t  len,
uint8_t *  encrypt_output 
) [static]

Establish a generated key and then verify that encryptiong and decryption both work on it. As a side effect, leave encrypted value in the calling argument.

References FSL_RETURN_OK_S, fsl_shw_establish_key(), fsl_shw_symmetric_decrypt(), and fsl_shw_symmetric_encrypt().

Referenced by run_user_wrap().

static int extract_reestablish_key ( fsl_shw_uco_t my_ctx,
fsl_shw_kso_t my_keystore,
uint32_t  ownerid,
uint32_t  handle,
fsl_shw_scco_t sym_ctx,
const uint8_t *  ciphertext,
const uint8_t *  expected_plaintext,
uint32_t  len 
) [static]

Wrap a key and then unwrap it. Use it to decrypt a message, then verify that the message matches the expected message.

References FSL_RETURN_OK_S, fsl_shw_establish_key(), fsl_shw_extract_key(), fsl_shw_release_key(), fsl_shw_sko_calculate_wrapped_size, fsl_shw_symmetric_decrypt(), and init_key_and_sym_ctx().

Referenced by run_user_wrap().

static void init_key_and_sym_ctx ( fsl_shw_key_alg_t  key_alg,
unsigned  key_len,
fsl_shw_sko_t key_info,
fsl_shw_scco_t sym_ctx 
) [static]

Helper function to set values in Secret Key and Symmetric Cipher Context objects according to the key algorithm and key length passed in.

References FSL_KEY_ALG_DES, FSL_KEY_ALG_TDES, fsl_shw_sko_init, fsl_shw_sko_set_flags, FSL_SKO_KEY_IGNORE_PARITY, FSL_SYM_MODE_ECB, and FSL_SYM_MODE_STREAM.

Referenced by extract_reestablish_key(), and run_user_wrap().

void run_user_wrap ( fsl_shw_uco_t my_ctx,
uint32_t *  total_passed_count,
uint32_t *  total_failed_count 
)

Variable Documentation

const unsigned char ARC4_known_ciphertext[] [static]
Initial value:
 {
        0x38, 0xeb, 0x67, 0x0a, 0x6b, 0x26, 0x2b, 0x6f,
        0x40, 0x15, 0x42, 0x04, 0x2f, 0xee, 0x48, 0x9a,
        0x78, 0x75, 0x22, 0xba, 0x70, 0x20, 0xec, 0x78,
        0x89, 0x60, 0x3c, 0xd9, 0xf9, 0x97, 0x6e, 0x0f,
        0x2f, 0xad, 0xe0, 0x02, 0xc5, 0x7e, 0xfd, 0xc3,
        0x3a, 0x93, 0x74, 0xb3, 0x5f, 0xdb, 0xd0, 0xdf,
        0xe2, 0xbc, 0x7c, 0x24, 0xa3, 0xe0, 0xde, 0x78,
        0x11, 0x08, 0x25, 0x02, 0xae, 0xea, 0x04, 0x17
}

Result of encrypting Known plaintext with 15-byte ARC4 key.

Referenced by run_user_wrap().

const unsigned char known_key[] [static]
Initial value:
 {
        0x2C, 0x82, 0x96, 0xE0, 0x2E, 0x5F, 0x5C, 0x19,
        0xAA, 0x29, 0xA6, 0xCF, 0x97, 0x05, 0x5C, 0xD2,
        0xA8, 0xEC, 0xE4, 0x1D, 0xAC, 0x47, 0x7B, 0x6F
}

Key for Known Answer test

Referenced by run_user_wrap().

unsigned char known_plaintext[] [static]
Initial value:
 {
        0x0F, 0xEB, 0x9B, 0x5C, 0x22, 0x0B, 0xA5, 0x13,
        0x5D, 0x0F, 0x55, 0x06, 0xC7, 0xD6, 0x75, 0xAF,
        0x76, 0x20, 0x1A, 0x91, 0x78, 0x31, 0x75, 0x94,
        0x67, 0xB7, 0x3D, 0x23, 0x90, 0xEC, 0x4E, 0x4F,
        0x84, 0x55, 0xB0, 0xED, 0x4B, 0x81, 0x70, 0x85,
        0x1D, 0xB1, 0xD5, 0x48, 0x85, 0x7A, 0x13, 0x40,
        0x76, 0x74, 0x7C, 0x92, 0x97, 0x75, 0xB3, 0x14,
        0xA7, 0xE5, 0x02, 0x4F, 0xB4, 0x2F, 0x1E, 0x03
}

Plaintext for Known Answer test

Referenced by run_user_wrap().

const unsigned char TDES_known_ciphertext[] [static]
Initial value:
 {
        0x79, 0xA2, 0xCB, 0x79, 0x43, 0x66, 0x07, 0x61,
        0xB6, 0x53, 0xEF, 0x8B, 0xD9, 0x6C, 0xD6, 0x45,
        0xF4, 0xEF, 0x29, 0x4F, 0x37, 0x07, 0x5F, 0x2B,
        0xBE, 0xE9, 0x5E, 0x6A, 0x27, 0x29, 0x02, 0x45,
        0x22, 0x7F, 0x80, 0x16, 0xFF, 0x21, 0x83, 0xB4,
        0x19, 0x80, 0xED, 0x66, 0x37, 0x28, 0x8E, 0xA0,
        0xEA, 0x7F, 0x3A, 0x96, 0x37, 0xE2, 0x07, 0x24,
        0x87, 0x42, 0x35, 0xCB, 0x11, 0xDE, 0xEB, 0xC3
}

Result of encrypting Known plaintext with 24-byte TDES key in ECB mode.

Referenced by run_user_wrap().

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen