CCM HAL

group nrf_ccm_hal

Hardware access layer for managing the AES CCM peripheral.

Defines

NRF_CCM_HAS_TASK_KSGEN

Presence of the KSGEN task.

NRF_CCM_HAS_TASK_CRYPT

Presence of the CRYPT task.

NRF_CCM_HAS_TASK_START

Presence of the START task.

NRF_CCM_HAS_TASK_RATEOVERRIDE

Presence of the RATEOVERRIDE task.

NRF_CCM_HAS_EVENT_ENDKSGEN

Presence of the ENDKSGEN event.

NRF_CCM_HAS_EVENT_ENDCRYPT

Presence of the ENDCRYPT event.

NRF_CCM_HAS_EVENT_END

Presence of the END event.

NRF_CCM_HAS_ADATAMASK

Presence of the ADATAMASK register.

NRF_CCM_HAS_CNFPTR

Presence of the CNFPTR register.

NRF_CCM_HAS_IN_AMOUNT

Presence of the IN.AMOUNT register.

NRF_CCM_HAS_OUT_AMOUNT

Presence of the OUT.AMOUNT register.

NRF_CCM_HAS_RATEOVERRIDE

Presence of the RATEOVERRIDE register.

NRF_CCM_HAS_ERRORSTATUS

Presence of the ERRORSTATUS register.

NRF_CCM_HAS_MICSTATUS

Presence of the MICSTATUS register.

NRF_CCM_HAS_MACSTATUS

Presence of the MACSTATUS register.

NRF_CCM_HAS_KEY

Presence of the KEY register.

NRF_CCM_HAS_NONCE

Presence of the NONCE register.

NRF_CCM_HAS_INPTR

Presence of the INPTR register.

NRF_CCM_HAS_OUTPTR

Presence of the OUTPTR register.

NRF_CCM_HAS_IN_PTR

Presence of the IN.PTR register.

NRF_CCM_HAS_OUT_PTR

Presence of the OUT.PTR register.

NRF_CCM_HAS_SCRATCHPTR

Presence of the SCRATCHPTR register.

NRF_CCM_HAS_MAXPACKETSIZE

Presence of the MAXPACKETSIZE.

NRF_CCM_HAS_MODE_FAST_DECRYPTION

Presence of AES fast decrypt mode.

NRF_CCM_HAS_MODE_PROTOCOL

Presence of protocol and packet format selection.

NRF_CCM_HAS_MODE_PROTOCOL_BLE

Presence of the BLE packet format.

NRF_CCM_HAS_MODE_PROTOCOL_IEEE802154

Presence of the 802.15.4 packet format.

NRF_CCM_HAS_MODE_LENGTH

Presence of the packet lengh configuration.

NRF_CCM_HAS_MODE_DATARATE_125KBPS

Support for 125 Kbps radio data rate.

NRF_CCM_HAS_MODE_DATARATE_125KBIT

Support for 125 Kbit radio data rate.

NRF_CCM_HAS_MODE_DATARATE_250KBIT

Support for 250 Kbit radio data rate.

NRF_CCM_HAS_MODE_DATARATE_500KBPS

Support for 500 Kbps radio data rate.

NRF_CCM_HAS_MODE_DATARATE_500KBIT

Support for 500 Kbit radio data rate.

NRF_CCM_HAS_MODE_DATARATE_4MBIT

Support for 4 Mbit radio data rate.

NRF_CCM_HAS_MODE_MACLEN

Presence of the CCM MAC length.

NRF_CCM_HAS_DATARATE

Presence of the radio data rate that the CCM shall run synchronous with.

NRF_CCM_HAS_HEADERMASK

Presence of the HEADERMASK register.

NRF_CCM_KEY_SIZE

AES key size.

NRF_CCM_IV_SIZE

Initialization vector size.

NRF_CCM_PKTCTR_SIZE

Packet counter configuration size.

Enums

enum nrf_ccm_task_t

CCM tasks.

Values:

enumerator NRF_CCM_TASK_KSGEN

Start generation of key-stream.

enumerator NRF_CCM_TASK_CRYPT

Start encryption/decryption.

enumerator NRF_CCM_TASK_STOP

Stop encryption/decryption.

enumerator NRF_CCM_TASK_START

Start encryption/decryption.

enumerator NRF_CCM_TASK_RATEOVERRIDE

Override DATARATE setting in MODE register.

enum nrf_ccm_event_t

CCM events.

Values:

enumerator NRF_CCM_EVENT_ENDKSGEN

Keystream generation complete.

enumerator NRF_CCM_EVENT_ENDCRYPT

Encrypt/decrypt complete.

enumerator NRF_CCM_EVENT_ERROR

CCM error event.

enumerator NRF_CCM_EVENT_END

Encrypt/decrypt complete.

enum nrf_ccm_short_mask_t

Types of CCM shorts.

Values:

enumerator NRF_CCM_SHORT_ENDKSGEN_CRYPT_MASK

Shortcut for starting encryption/decryption when the key-stream generation is complete.

enum nrf_ccm_int_mask_t

CCM interrupts.

Values:

enumerator NRF_CCM_INT_ENDKSGEN_MASK

Interrupt on ENDKSGEN event.

enumerator NRF_CCM_INT_ENDCRYPT_MASK

Interrupt on ENDCRYPT event.

enumerator NRF_CCM_INT_ERROR_MASK

Interrupt on ERROR event.

enumerator NRF_CCM_INT_END_MASK

Interrupt on END event.

enum nrf_ccm_error_t

CCM error status when ERROR event is generated.

Values:

enumerator NRF_CCM_ERROR_NO_ERROR

No errors have occurred.

enumerator NRF_CCM_ERROR_PREMATURE_INPTR_END

End of INPTR job list before CCM data structure was read.

enumerator NRF_CCM_ERROR_PREMATURE_OUTPTR_END

End of OUTPTR job list before CCM data structure was read.

enumerator NRF_CCM_ERROR_ENCRYPTION_TOO_SLOW

Encryption did not complete in time.

enum nrf_ccm_mode_t

CCM modes of operation.

Values:

enumerator NRF_CCM_MODE_ENCRYPTION

Encryption mode.

enumerator NRF_CCM_MODE_DECRYPTION

Decryption mode.

enumerator NRF_CCM_MODE_FAST_DECRYPTION

Fast decryption mode.

enum nrf_ccm_datarate_t

CCM data rates.

Values:

enumerator NRF_CCM_DATARATE_125K

125 Kbps.

enumerator NRF_CCM_DATARATE_250K

250 Kbps.

enumerator NRF_CCM_DATARATE_500K

500 Kbps.

enumerator NRF_CCM_DATARATE_1M

1 Mbps.

enumerator NRF_CCM_DATARATE_2M

2 Mbps.

enumerator NRF_CCM_DATARATE_4M

4 Mbps.

enum nrf_ccm_protocol_t

CCM protocol and packet format.

Values:

enumerator NRF_CCM_MODE_PROTOCOL_BLE

BLE packet format.

enumerator NRF_CCM_MODE_PROTOCOL_IEEE802154

802.15.4 packet format.

enum nrf_ccm_length_t

CCM packet length options.

Values:

enumerator NRF_CCM_LENGTH_DEFAULT

Default length.

enumerator NRF_CCM_LENGTH_EXTENDED

Extended length.

enum nrf_ccm_maclen_t

CCM MAC length.

Values:

enumerator NRF_CCM_MODE_MACLEN_M0

0 bytes.

enumerator NRF_CCM_MODE_MACLEN_M4

4 bytes.

enumerator NRF_CCM_MODE_MACLEN_M6

6 bytes.

enumerator NRF_CCM_MODE_MACLEN_M8

8 bytes.

enumerator NRF_CCM_MODE_MACLEN_M10

10 bytes.

enumerator NRF_CCM_MODE_MACLEN_M12

12 bytes.

enumerator NRF_CCM_MODE_MACLEN_M14

14 bytes.

enumerator NRF_CCM_MODE_MACLEN_M16

16 bytes.

Functions

NRF_STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type *p_reg, nrf_ccm_task_t task)

Function for activating a specific CCM task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task to be activated.

NRF_STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const *p_reg, nrf_ccm_task_t task)

Function for getting the address of a specific CCM task register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Requested task.

Returns:

Address of the specified task register.

NRF_STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type *p_reg, nrf_ccm_event_t event)

Function for clearing a specific CCM event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to clear.

NRF_STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const *p_reg, nrf_ccm_event_t event)

Function for retrieving the state of a specific CCM event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event to be checked.

Return values:
  • true – The event has been generated.

  • false – The event has not been generated.

NRF_STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const *p_reg, nrf_ccm_event_t event)

Function for getting the address of a specific CCM event register.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Requested event.

Returns:

Address of the specified event register.

NRF_STATIC_INLINE void nrf_ccm_shorts_enable(NRF_CCM_Type *p_reg, uint32_t mask)

Function for enabling the specified shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Shortcuts to be enabled.

NRF_STATIC_INLINE void nrf_ccm_shorts_disable(NRF_CCM_Type *p_reg, uint32_t mask)

Function for disabling the specified shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Shortcuts to be disabled.

NRF_STATIC_INLINE void nrf_ccm_shorts_set(NRF_CCM_Type *p_reg, uint32_t mask)

Function for setting the specified shortcuts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Shortcuts to be set.

NRF_STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type *p_reg, uint32_t mask)

Function for enabling specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be enabled. Use nrf_ccm_int_mask_t values for bit masking.

NRF_STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type *p_reg, uint32_t mask)

Function for disabling specified interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be disabled. Use nrf_ccm_int_mask_t values for bit masking.

NRF_STATIC_INLINE uint32_t nrf_ccm_int_enable_check(NRF_CCM_Type const *p_reg, uint32_t mask)

Function for checking if the specified interrupts are enabled.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be checked. Use nrf_ccm_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRF_STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type *p_reg)

Function for enabling the CCM peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type *p_reg)

Function for disabling the CCM peripheral.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRF_STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type *p_reg, nrf_ccm_config_t const *p_config)

Function for setting the CCM peripheral configuration.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_config[in] Pointer to the structure with configuration to be set.

NRF_STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type *p_reg, uint8_t size)

Function for setting the length of key-stream generated when the packet length is configured as extended.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • size[in] Maximum length of the key-stream.

NRF_STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const *p_reg)

Function for getting the MIC check result.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – The MIC check passed.

  • false – The MIC check failed.

NRF_STATIC_INLINE bool nrf_ccm_macstatus_get(NRF_CCM_Type const *p_reg)

Function for getting the MAC check result.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:
  • true – The MAC check passed.

  • false – The MAC check failed.

NRF_STATIC_INLINE nrf_ccm_error_t nrf_ccm_errorstatus_get(NRF_CCM_Type const *p_reg)

Function for getting the error status when ERROR event is generated.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Return values:

Error – status when the ERROR event is generated.

NRF_STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type *p_reg, nrf_ccm_cnf_t const *p_data)

Function for setting the pointer to the data structure holding the AES key and the CCM NONCE vector.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_data[in] Pointer to the data structure.

NRF_STATIC_INLINE nrf_ccm_cnf_t *nrf_ccm_cnfptr_get(NRF_CCM_Type const *p_reg)

Function for getting the pointer to the data structure holding the AES key and the CCM NONCE vector.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Pointer to the data structure.

NRF_STATIC_INLINE void nrf_ccm_key_set(NRF_CCM_Type *p_reg, uint32_t const *p_key)

Function for setting the AES key.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_key[in] Pointer to the AES 128-bit key value. The key shall be stored in big endian byte order.

NRF_STATIC_INLINE uint32_t volatile const *nrf_ccm_key_get(NRF_CCM_Type const *p_reg)

Function for getting the AES key.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Pointer to the AES 128-bit key value. The key is stored in big endian byte order.

NRF_STATIC_INLINE void nrf_ccm_nonce_set(NRF_CCM_Type *p_reg, uint32_t const *p_nonce)

Function for setting the AES nonce.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_nonce[in] Pointer to the AES 13-byte nonce value. The nonce shall be stored in big endian byte order.

NRF_STATIC_INLINE uint32_t volatile const *nrf_ccm_nonce_get(NRF_CCM_Type const *p_reg)

Function for getting the AES nonce.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Pointer to the AES 13-byte nonce value. The nonce is stored in big endian byte order.

NRF_STATIC_INLINE uint32_t nrf_ccm_in_amount_get(NRF_CCM_Type const *p_reg)

Function for getting number of bytes read from the input data, not including the job list structure.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Number of bytes read from the input data.

NRF_STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type *p_reg, uint32_t const *p_data)

Function for setting the input data pointer.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_data[in] Input data pointer.

NRF_STATIC_INLINE uint32_t *nrf_ccm_inptr_get(NRF_CCM_Type const *p_reg)

Function for getting the input data pointer.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Input data pointer.

NRF_STATIC_INLINE void nrf_ccm_in_ptr_set(NRF_CCM_Type *p_reg, nrf_vdma_job_t const *p_job)

Function for setting the pointer to a job list containing unencrypted CCM data structure in Encryption mode or encrypted CCM data structure in Decryption mode.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_job[in] Pointer to a job list.

NRF_STATIC_INLINE nrf_vdma_job_t *nrf_ccm_in_ptr_get(NRF_CCM_Type const *p_reg)

Function for getting the pointer to job list containing unencrypted CCM data structure in Encryption mode or encrypted CCM data structure in Decryption mode.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Pointer to a job list.

NRF_STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type *p_reg, uint32_t const *p_data)

Function for setting the output data pointer.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_data[in] Output data pointer.

NRF_STATIC_INLINE uint32_t *nrf_ccm_outptr_get(NRF_CCM_Type const *p_reg)

Function for getting the output data pointer.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Output data pointer.

NRF_STATIC_INLINE void nrf_ccm_out_ptr_set(NRF_CCM_Type *p_reg, nrf_vdma_job_t const *p_job)

Function for setting the pointer to a job list containing encrypted CCM data structure in Encryption mode or decrypted CCM data structure in Decryption mode.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_job[in] Pointer to a job list.

NRF_STATIC_INLINE nrf_vdma_job_t *nrf_ccm_out_ptr_get(NRF_CCM_Type const *p_reg)

Function for getting the pointer to a job list containing encrypted CCM data structure in Encryption mode or decrypted CCM data structure in Decryption mode.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Pointer to the job list.

NRF_STATIC_INLINE uint32_t nrf_ccm_out_amount_get(NRF_CCM_Type const *p_reg)

Function for getting number of bytes available in the output data, not including the job list structure.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Number of bytes available in the output data.

NRF_STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type *p_reg, uint32_t const *p_area)

Function for setting the pointer to the scratch area used for temporary storage.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_area[in] Pointer to the scratch area.

NRF_STATIC_INLINE uint32_t *nrf_ccm_scratchptr_get(NRF_CCM_Type const *p_reg)

Function for getting the pointer to the scratch area.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Pointer to the scratch area.

NRF_STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type *p_reg, nrf_ccm_datarate_t datarate)

Function for setting the data rate override value.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • datarate[in] Override value to be applied when the RATEOVERRIDE task is triggered.

NRF_STATIC_INLINE nrf_ccm_datarate_t nrf_ccm_datarate_override_get(NRF_CCM_Type const *p_reg)

Function for getting data override setting.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Data override setting.

NRF_STATIC_INLINE void nrf_ccm_adatamask_set(NRF_CCM_Type *p_reg, uint8_t adata_msk)

Function for setting the CCM adata mask.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • adata_msk[in] CCM adata mask.

NRF_STATIC_INLINE uint32_t nrf_ccm_adatamask_get(NRF_CCM_Type const *p_reg)

Function for getting bitmask for the first adata byte.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

CCM adata mask.

NRF_STATIC_INLINE void nrf_ccm_headermask_set(NRF_CCM_Type *p_reg, uint8_t header_msk)

Function for setting the CCM header mask.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • header_msk[in] CCM header mask.

NRF_STATIC_INLINE uint32_t nrf_ccm_headermask_get(NRF_CCM_Type const *p_reg)

Function for getting the bitmask for packet header (S0) before MIC generation/authentication.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

CCM header mask.

NRF_STATIC_INLINE void nrf_ccm_subscribe_set(NRF_CCM_Type *p_reg, nrf_ccm_task_t task, uint8_t channel)

Function for setting the subscribe configuration for a given CCM task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task for which to set the configuration.

  • channel[in] Channel through which to subscribe events.

NRF_STATIC_INLINE void nrf_ccm_subscribe_clear(NRF_CCM_Type *p_reg, nrf_ccm_task_t task)

Function for clearing the subscribe configuration for a given CCM task.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • task[in] Task for which to clear the configuration.

NRF_STATIC_INLINE void nrf_ccm_publish_set(NRF_CCM_Type *p_reg, nrf_ccm_event_t event, uint8_t channel)

Function for setting the publish configuration for a given CCM event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event for which to set the configuration.

  • channel[in] Channel through which to publish the event.

NRF_STATIC_INLINE void nrf_ccm_publish_clear(NRF_CCM_Type *p_reg, nrf_ccm_event_t event)

Function for clearing the publish configuration for a given CCM event.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • event[in] Event for which to clear the configuration.

struct nrf_ccm_cnf_t
#include <nrf_ccm.h>

CCM data structure.

Public Members

uint8_t key[16]

16-byte AES key.

uint8_t pktctr[9]

Packet counter configuration.

uint8_t iv[8]

8-byte initialization vector (IV).

struct nrf_ccm_config_t
#include <nrf_ccm.h>

CCM configuration.

Public Members

nrf_ccm_mode_t mode

Operation mode.

nrf_ccm_protocol_t protocol

Protocol and packet format.

nrf_ccm_datarate_t datarate

Data rate.

nrf_ccm_length_t length

Length of the CCM packet.

nrf_ccm_maclen_t mac_length

Length of the CCM MAC.