Data Structures | |
struct | scc_key_slot |
Defines | |
#define | SCC_KEY_SLOTS 20 |
#define | SCC_MAX_KEY_SIZE 32 |
#define | SCC_KEY_SLOT_SIZE 32 |
#define | SCM_NON_RESERVED_OFFSET (SCC_KEY_SLOTS * SCC_KEY_SLOT_SIZE) |
#define | SCC_CALLBACK_SIZE 4 |
#define | CRC_CCITT_START 0xFFFF |
#define | SCC_SPIN_COUNT 1000 |
#define | SCC_CIPHER_MAX_POLL_COUNT 100 |
#define | SCC_READ_REGISTER(offset) __raw_readl(scc_base+(offset)) |
#define | SCC_WRITE_REGISTER(offset, value) (void)__raw_writel(value, scc_base+(offset)) |
#define | SCC_BYTE_OFFSET(bp) ((uint32_t)(bp) % sizeof(uint32_t)) |
#define | SCC_WORD_PTR(bp) (((uint32_t)(bp)) & ~(sizeof(uint32_t)-1)) |
#define | SCC_BLOCK_SIZE_BYTES() scc_configuration.block_size_bytes |
#define | PADDING_BUFFER_MAX_BYTES (CRC_SIZE_BYTES + sizeof(scc_block_padding)) |
#define | CRC_SIZE_BYTES (sizeof(crc_t)) |
#define | CRC_POLYNOMIAL 0x1021 |
#define | CALC_CRC(byte_value, running_crc) |
#define | SCC_DRIVER_PAD_CHAR 0x80 |
#define | SCC_DRIVER_NAME "scc" |
Typedefs | |
typedef uint16_t | crc_t |
Enumerations | |
enum | scc_status { SCC_STATUS_INITIAL, SCC_STATUS_CHECKING, SCC_STATUS_UNIMPLEMENTED, SCC_STATUS_OK, SCC_STATUS_FAILED } |
Functions | |
static void | scc_perform_callbacks (void) |
static scc_return_t | scc_encrypt (uint32_t count_in_bytes, const uint8_t *data_in, uint32_t scm_control, uint8_t *data_out, int add_crc, unsigned long *count_out_bytes) |
static scc_return_t | scc_decrypt (uint32_t count_in_bytes, const uint8_t *data_in, uint32_t scm_control, uint8_t *data_out, int verify_crc, unsigned long *count_out_bytes) |
This header file should only ever be included by scc_driver.c
Compile-time flags minimally needed:
#define CALC_CRC | ( | byte_value, | |||
running_crc | ) |
Value:
{ \ uint8_t data; \ data = (0xff&(byte_value)) ^ (running_crc >> 8); \ running_crc = scc_crc_lookup_table[data] ^ (running_crc << 8); \ }
[in,out] | running_crc | A value of type crc_t where CRC is kept. This must be an rvalue and an lvalue. |
[in] | byte_value | The byte (uint8_t, char) to be put in the CRC |
#define CRC_CCITT_START 0xFFFF |
Initial CRC value for CCITT-CRC calculation.
#define CRC_POLYNOMIAL 0x1021 |
The polynomial used in CCITT-CRC calculation
#define CRC_SIZE_BYTES (sizeof(crc_t)) |
Shorthand (clearer, anyway) for number of bytes in a CRC.
#define PADDING_BUFFER_MAX_BYTES (CRC_SIZE_BYTES + sizeof(scc_block_padding)) |
Maximum number of additional bytes which may be added in CRC+padding mode.
#define SCC_BLOCK_SIZE_BYTES | ( | ) | scc_configuration.block_size_bytes |
Determine number of bytes in an SCC block
#define SCC_BYTE_OFFSET | ( | bp | ) | ((uint32_t)(bp) % sizeof(uint32_t)) |
Calculates the byte offset into a word
bp | The byte (char*) pointer |
#define SCC_CALLBACK_SIZE 4 |
The number of function pointers which can be stored in scc_callbacks. Defaults to 4, can be overridden with compile-line argument.
#define SCC_CIPHER_MAX_POLL_COUNT 100 |
Number of times to polling SCC while waiting for cipher or zeroizing function to complete. See also SCC_SPIN_COUNT.
#define SCC_DRIVER_NAME "scc" |
Name of the driver. Used (on Linux, anyway) when registering interrupts
#define SCC_DRIVER_PAD_CHAR 0x80 |
Value of 'beginning of padding' marker in driver-provided padding
#define SCC_KEY_SLOT_SIZE 32 |
This is the size, in bytes, of each key slot, and therefore the maximum size of the wrapped key.
#define SCC_KEY_SLOTS 20 |
Define the number of Stored Keys which the SCC driver will make available. Value shall be from 0 to 20. Default is zero (0).
#define SCC_MAX_KEY_SIZE 32 |
Maximum length of key/secret value which can be stored in SCC.
#define SCC_READ_REGISTER | ( | offset | ) | __raw_readl(scc_base+(offset)) |
Read a 32-bit value from an SCC register. Macro which depends upon scc_base. Linux readl()/writel() macros operate on 32-bit quantities, as do SCC register reads/writes.
offset | Register offset within SCC. |
#define SCC_SPIN_COUNT 1000 |
Number of times to spin between polling of SCC while waiting for cipher or zeroizing function to complete. See also SCC_CIPHER_MAX_POLL_COUNT.
#define SCC_WORD_PTR | ( | bp | ) | (((uint32_t)(bp)) & ~(sizeof(uint32_t)-1)) |
Converts (by rounding down) a byte pointer into a word pointer
bp | The byte (char*) pointer |
#define SCC_WRITE_REGISTER | ( | offset, | |||
value | ) | (void)__raw_writel(value, scc_base+(offset)) |
Write a 32-bit value to an SCC register. Macro depends upon scc_base. Linux readl()/writel() macros operate on 32-bit quantities, as do SCC register reads/writes.
offset | Register offset within SCC. | |
value | 32-bit value to store into the register |
#define SCM_NON_RESERVED_OFFSET (SCC_KEY_SLOTS * SCC_KEY_SLOT_SIZE) |
This is the offset into each RAM of the base of the area which is not used for Stored Keys.
typedef uint16_t crc_t |
Provide a typedef for the CRC which can be used in encrypt/decrypt
enum scc_status |
Gives high-level view of state of the SCC
static scc_return_t scc_decrypt | ( | uint32_t | count_in_bytes, | |
const uint8_t * | data_in, | |||
uint32_t | scm_control, | |||
uint8_t * | data_out, | |||
int | verify_crc, | |||
unsigned long * | count_out_bytes | |||
) | [static] |
Perform a decryption on the input. If verify_crc
is true, the last block (maybe the two last blocks) is special - it should contain a CRC and padding. These must be stripped and verified.
[in] | count_in_bytes | Count of bytes of ciphertext |
[in] | data_in | Pointer to the ciphertext |
[in] | scm_control | Bit values for the SCM_CONTROL register |
[in,out] | data_out | Pointer for storing plaintext |
[in] | verify_crc | Flag for running CRC - 0 no, else yes |
[in,out] | count_out_bytes | Number of bytes available at data_out |
static scc_return_t scc_encrypt | ( | uint32_t | count_in_bytes, | |
const uint8_t * | data_in, | |||
uint32_t | scm_control, | |||
uint8_t * | data_out, | |||
int | add_crc, | |||
unsigned long * | count_out_bytes | |||
) | [static] |
Perform an encryption on the input. If verify_crc
is true, a CRC must be calculated on the plaintext, and appended, with padding, before computing the ciphertext.
[in] | count_in_bytes | Count of bytes of plaintext |
[in] | data_in | Pointer to the plaintext |
[in] | scm_control | Bit values for the SCM_CONTROL register |
[in,out] | data_out | Pointer for storing ciphertext |
[in] | add_crc | Flag for computing CRC - 0 no, else yes |
[in,out] | count_out_bytes | Number of bytes available at data_out |
static void scc_perform_callbacks | ( | void | ) | [static] |
Perform callbacks registered by scc_monitor_security_failure().
Make sure callbacks only happen once... Since there may be some reason why the interrupt isn't generated, this routine could be called from base(task) level.
One at a time, go through scc_callbacks[] and call any non-null pointers.
© Freescale Semiconductor, Inc., 2007.
All rights reserved. Freescale Confidential Proprietary NDA Required |
![]() |