Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

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 

Generate a (CCM) auth code and encrypt the payload.

Perform Generation-Encryption by doing a Cipher and a Hash.

Generate the authentication value auth_value as well as encrypt the payload into ct (the ciphertext). This is a one-shot function, so all of the auth_data and the total message payload must passed in one call. This also means that the flags in the auth_ctx must be FSL_ACCO_CTX_INIT and FSL_ACCO_CTX_FINALIZE.

user_ctx A user context from fsl_shw_register_user().
auth_ctx Controlling object for Authenticate-decrypt.
cipher_key_info The key being used for the cipher part of this operation. In CCM mode, this key is used for both parts.
auth_key_info The key being used for the authentication part of this operation. In CCM mode, this key is ignored and may be NULL.
auth_data_length Length, in octets, of auth_data.
auth_data Data to be authenticated but not encrypted.
payload_length Length, in octets, of payload.
payload Pointer to the plaintext to be encrypted.
[out] ct Pointer to the where the encrypted payload will be stored. Must be payload_length octets long.
[out] auth_value Pointer to where the generated authentication field will be stored. Must be as many octets as indicated by MAC length in the function_ctx.
A return code of type fsl_shw_return_t.
This is a very complicated function. Seven (or eight) descriptors are required to perform a CCM calculation.

First: Load CTR0 and key.

Second: Run an octet of data through to bump to CTR1. (This could be done in software, but software will have to bump and later decrement - or copy and bump.

Third: (in Virtio) Load a descriptor with data of zeros for CBC IV.

Fourth: Run any (optional) "additional data" through the CBC-mode portion of the algorithm.

Fifth: Run the payload through in CCM mode.

Sixth: Extract the unencrypted MAC.

Seventh: Load CTR0.

Eighth: Encrypt the MAC.

user_ctx The user's context
auth_ctx Info on this Auth operation
cipher_key_info Key to encrypt payload
auth_key_info (unused - same key in CCM)
auth_data_length Length in bytes of auth_data
auth_data Any auth-only data
payload_length Length in bytes of payload
payload The data to encrypt
[out] ct The location to store encrypted data
[out] auth_value The location to store authentication code
A return code of type fsl_shw_return_t.

Definition at line 2168 of file shw_driver.c.

      volatile fsl_shw_return_t status = FSL_RETURN_ERROR_S;

      /* Unused */
      (void)auth_key_info;    /* save compilation warning */

      return status;

Generated by  Doxygen 1.6.0   Back to index