linux/drivers/mxc/security/sahara2/fsl_shw_auth.c File Reference

Defines

#define CBC_BUF_LEN   4096
#define COMPUTE_NIST_AUTH_LEN_SIZE(l)
#define STORE_NIST_AUTH_LEN(l, p)

Functions

static fsl_shw_return_t process_assoc_from_nist_params (sah_Link **link1, uint32_t *data_len, fsl_shw_uco_t *user_ctx, fsl_shw_acco_t *auth_ctx, const uint8_t *auth_data, uint32_t auth_data_length, uint8_t **temp_buf)
static fsl_shw_return_t add_assoc_preamble (sah_Head_Desc **desc_chain, fsl_shw_uco_t *user_ctx, fsl_shw_acco_t *auth_ctx, int encrypt, const uint8_t *auth_data, uint32_t auth_data_length)
fsl_shw_return_t fsl_shw_gen_encrypt (fsl_shw_uco_t *user_ctx, fsl_shw_acco_t *auth_ctx, fsl_shw_sko_t *cipher_key_info, fsl_shw_sko_t *auth_key_info, uint32_t auth_data_length, const uint8_t *auth_data, uint32_t payload_length, const uint8_t *payload, uint8_t *ct, uint8_t *auth_value)
fsl_shw_return_t fsl_shw_auth_decrypt (fsl_shw_uco_t *user_ctx, fsl_shw_acco_t *auth_ctx, fsl_shw_sko_t *cipher_key_info, fsl_shw_sko_t *auth_key_info, uint32_t auth_data_length, const uint8_t *auth_data, uint32_t payload_length, const uint8_t *ct, const uint8_t *auth_value, uint8_t *payload)

Variables

static uint8_t garbage_output [16]
static uint8_t block_zeros [16]

Detailed Description

This file contains the routines which do the combined encrypt+authentication functions. For now, only AES-CCM is supported.


Define Documentation

#define CBC_BUF_LEN   4096

Size of buffer to repetively sink useless CBC output

Referenced by add_assoc_preamble().

#define COMPUTE_NIST_AUTH_LEN_SIZE (  ) 
Value:
({                                                                            \
    unsigned val;                                                             \
    uint32_t len = l;                                                         \
    if (len == 0) {                                                           \
        val = 0;                                                              \
    } else if (len < 65280) {                                                 \
        val = 2;                                                              \
    } else {                    /* cannot handle >= 2^32 */                   \
        val = 6;                                                              \
    }                                                                         \
    val;                                                                      \
})

Compute the size, in bytes, of the encoded auth length

Parameters:
l The actual associated data length
Returns:
The encoded length

Referenced by process_assoc_from_nist_params().

#define STORE_NIST_AUTH_LEN ( l,
 ) 
Value:
{                                                                             \
    register uint32_t L = l;                                                  \
    if ((uint32_t)(l) < 65280) {                                              \
        (p)[1] = L & 0xff;                                                    \
        L >>= 8;                                                              \
        (p)[0] = L & 0xff;                                                    \
    } else {                    /* cannot handle >= 2^32 */                   \
        int i;                                                                \
        for (i = 5; i > 1; i--) {                                             \
            (p)[i] = L & 0xff;                                                \
            L >>= 8;                                                          \
        }                                                                     \
        (p)[1] = 0xfe;  /* Markers */                                         \
        (p)[0] = 0xff;                                                        \
    }                                                                         \
}

Store the encoded Auth Length into the Auth Data

Parameters:
l The actual Auth Length
p Location to store encoding (must be uint8_t*)
Returns:
void

Referenced by process_assoc_from_nist_params().


Function Documentation

static fsl_shw_return_t add_assoc_preamble ( sah_Head_Desc **  desc_chain,
fsl_shw_uco_t user_ctx,
fsl_shw_acco_t auth_ctx,
int  encrypt,
const uint8_t *  auth_data,
uint32_t  auth_data_length 
) [inline, static]

Add a Descriptor which will process with CBC the NIST preamble data

Parameters:
desc_chain Current chain
user_ctx User's context
auth_ctx Inf encrypt 0 => decrypt, non-zero => encrypt
auth_data Additional auth data for this call
auth_data_length Length in bytes of auth_data
Returns:
A return code of type fsl_shw_return_t.

References CBC_BUF_LEN, fsl_shw_acco_t::CCM_ctx_info, fsl_shw_acco_t::flags, FSL_RETURN_NO_RESOURCE_S, FSL_RETURN_OK_S, fsl_shw_uco_t::mem_util, sah_Mem_Util::mu_malloc, sah_Mem_Util::mu_ref, process_assoc_from_nist_params(), SAH_HDR_SKHA_CBC_ICV, SAH_HDR_SKHA_ENC_DEC, SAH_OUTPUT_LINK, SAH_OWNS_LINK_DATA, and SAH_USES_LINK_DATA.

Referenced by fsl_shw_auth_decrypt(), and fsl_shw_gen_encrypt().

static fsl_shw_return_t process_assoc_from_nist_params ( sah_Link **  link1,
uint32_t *  data_len,
fsl_shw_uco_t user_ctx,
fsl_shw_acco_t auth_ctx,
const uint8_t *  auth_data,
uint32_t  auth_data_length,
uint8_t **  temp_buf 
) [inline, static]

Append a descriptor chain which will compute CBC over the formatted associated data blocks.

Parameters:
[in,out] link1 Where to append the new link
[in,out] data_len Location of current/updated auth-only data length
user_ctx Info for acquiring memory
auth_ctx Location of block0 value
auth_data Unformatted associated data
auth_data_length Length in octets of auth_data
[in,out] temp_buf Location of in-process data.
Returns:
A return code of type fsl_shw_return_t.

References block_zeros, fsl_shw_acco_t::CCM_ctx_info, COMPUTE_NIST_AUTH_LEN_SIZE, FSL_RETURN_OK_S, fsl_shw_uco_t::mem_util, SAH_OWNS_LINK_DATA, SAH_USES_LINK_DATA, and STORE_NIST_AUTH_LEN.

Referenced by add_assoc_preamble().


Variable Documentation

uint8_t block_zeros[16] [static]
Initial value:
 {
        0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0
}

Block of zeroes which is maximum Symmetric block size, used for initializing context register, etc.

Referenced by fsl_shw_auth_decrypt(), fsl_shw_gen_encrypt(), and process_assoc_from_nist_params().

uint8_t garbage_output[16] [static]

Place to store useless output (while bumping CTR0 to CTR1, for instance. Must be maximum Symmetric block size

Referenced by fsl_shw_gen_encrypt().

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