CRYPTO
Detailed Description
Cryptography accelerator peripheral API.
For cryptographic support, users should consider the crypto APIs of the mbedTLS library provided by Silicon Labs instead of the interface provided in
em_crypto.h
. The mbedTLS library provides a much richer crypto API, including hardware acceleration of several functions.
The main purpose of
em_crypto.h
is to implement a thin software interface for the CRYPTO hardware functions especially for the accelerated APIs of the mbedTLS library. Additionally
em_crypto.h
implement the AES API of the
em_aes.h
(supported by classic EFM32) for backwards compatibility. The following list summarizes the
em_crypto.h
inteface:
- AES (Advanced Encryption Standard) AES
- SHA (Secure Hash Algorithm) SHA
- Big Integer multiplier CRYPTO_Mul
- Functions for loading data and executing instruction sequences Load and Execute Instruction Sequences
AES
The AES APIs include support for AES-128 and AES-256 with block cipher modes:
- CBC - Cipher Block Chaining mode
- CFB - Cipher Feedback mode
- CTR - Counter mode
- ECB - Electronic Code Book mode
- OFB - Output Feedback mode
For the AES APIs input/output data (plaintext, ciphertext, key, and so on) are treated as byte arrays, starting with most significant byte. In other words, 32 bytes of plaintext (B0...B31) is located in memory in the same order, with B0 at the lower address and B31 at the higher address.
Byte arrays must always be a multiple of AES block size, ie. a multiple of 16. Padding, if required, is done at the end of the byte array.
Byte arrays should be word (32 bit) aligned for performance considerations, since the array is accessed with 32 bit access type. The core MCUs supports unaligned accesses, but with a performance penalty.
It is possible to specify the same output buffer as input buffer as long as they point to the same address. In that case the provided input buffer is replaced with the encrypted/decrypted output. Notice that the buffers must be exactly overlapping. If partly overlapping, the behavior is undefined.
It is up to the user to use a cipher mode according to its requirements to avoid breaking security. See the specific cipher mode theory for details.
References:
- Wikipedia - Cipher modes, en.wikipedia.org/wiki/Cipher_modes
- Recommendation for Block Cipher Modes of Operation, NIST Special Publication 800-38A, 2001 Edition, csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
- Recommendation for Block Cipher Modes of Operation, csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
SHA
The SHA APIs include support for
- SHA-1 CRYPTO_SHA_1
- SHA-256 CRYPTO_SHA_256
The SHA-1 implementation is FIPS-180-1 compliant, ref:
- Wikipedia - SHA-1, en.wikipedia.org/wiki/SHA-1
- SHA-1 spec - www.itl.nist.gov/fipspubs/fip180-1.htm
The SHA-256 implementation is FIPS-180-2 compliant, ref:
- Wikipedia - SHA-2, en.wikipedia.org/wiki/SHA-2
- SHA-2 spec - csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
CRYPTO_Mul
CRYPTO_Mul is a function for multiplying big integers that are bigger than the operand size of the MUL instruction, which is 128 bits. CRYPTO_Mul multiplies all partial operands of the input operands using MUL to form a resulting number which may be twice the size of the operands.
CRPYTO_Mul is typically used by RSA implementations, which perform a huge amount of multiplication and square operations to implement modular exponentiation. Some RSA implementations use a number representation including arrays of 32bit words of variable size. Compile with -D USE_VARIABLE_SIZED_DATA_LOADS in order to load these numbers directly into CRYPTO without converting the number representation.
Load and Execute Instruction Sequences
The functions for loading data and executing instruction sequences can be used to implement complex algorithms like elliptic curve cryptography (ECC)) and authenticated encryption algorithms. There are two typical modes of operation:
- Multi-sequence operation
- Single static instruction sequence operation
In multi-sequence mode the software starts by loading input data, an instruction sequence, execute, and finally read the result. This process is repeated until the full crypto operation is complete.
When using a single static instruction sequence, only one instruction sequence is loaded initially. The sequence can be set up to run multiple times. Data can be loaded during the execution of the sequence by using DMA, BUFC and/or programmed I/O directly from the MCU core. For details about how to program the instruction sequences, see the reference manual of the particular Silicon Labs device.
To load input data to the CRYPTO module, use any of the following functions:
- CRYPTO_DataWrite - Write 128 bits to a DATA register.
- CRYPTO_DDataWrite - Write 256 bits to a DDATA register.
- CRYPTO_QDataWrite - Write 512 bits to a QDATA register.
In order to read output data from the CRYPTO module use any of the following functions:
- CRYPTO_DataRead - Read 128 bits from a DATA register.
- CRYPTO_DDataRead - Read 256 bits from a DDATA register.
- CRYPTO_QDataRead - Read 512 bits from a QDATA register.
To load an instruction sequence to the CRYPTO module, use CRYPTO_InstructionSequenceLoad .
To execute the current instruction sequence in the CRYPTO module, use CRYPTO_InstructionSequenceExecute .
To check whether an instruction sequence has completed, use CRYPTO_InstructionSequenceDone .
To wait for an instruction sequence to complete, use CRYPTO_InstructionSequenceWait .
To optimally load (with regards to speed) and execute an instruction sequence, use any of the CRYPTO_EXECUTE_X macros (where X is in the range 1-20) defined in
em_crypto.h
. E.g. CRYPTO_EXECUTE_19.
Macros |
|
#define | CRYPTO_INSTRUCTIONSEQUENSE_DEFAULT |
#define | CRYPTO_MAX_SEQUENCE_INSTRUCTIONS (20) |
Typedefs |
|
typedef void(* | CRYPTO_AES_CtrFuncPtr_TypeDef ) (uint8_t *ctr) |
AES counter modification function pointer.
|
|
typedef uint32_t | CRYPTO_Data260_TypeDef [CRYPTO_DATA260_SIZE_IN_32BIT_WORDS] |
typedef uint32_t | CRYPTO_Data_TypeDef [CRYPTO_DATA_SIZE_IN_32BIT_WORDS] |
typedef volatile uint32_t * | CRYPTO_DataReg_TypeDef |
typedef uint32_t | CRYPTO_DData_TypeDef [CRYPTO_DDATA_SIZE_IN_32BIT_WORDS] |
typedef volatile uint32_t * | CRYPTO_DDataReg_TypeDef |
typedef uint8_t | CRYPTO_InstructionSequence_TypeDef [ CRYPTO_MAX_SEQUENCE_INSTRUCTIONS ] |
typedef uint32_t | CRYPTO_KeyBuf_TypeDef [CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS] |
typedef uint32_t | CRYPTO_QData_TypeDef [CRYPTO_QDATA_SIZE_IN_32BIT_WORDS] |
typedef volatile uint32_t * | CRYPTO_QDataReg_TypeDef |
typedef uint8_t | CRYPTO_SHA1_Digest_TypeDef [CRYPTO_SHA1_DIGEST_SIZE_IN_BYTES] |
typedef uint8_t | CRYPTO_SHA256_Digest_TypeDef [CRYPTO_SHA256_DIGEST_SIZE_IN_BYTES] |
Enumerations |
|
enum |
CRYPTO_IncWidth_TypeDef
{
cryptoInc1byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH1, cryptoInc2byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH2, cryptoInc3byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH3, cryptoInc4byte = CRYPTO_CTRL_INCWIDTH_INCWIDTH4 } |
enum |
CRYPTO_KeyWidth_TypeDef
{
cryptoKey128Bits = 8, cryptoKey256Bits = 16 } |
enum |
CRYPTO_ModulusId_TypeDef
{
cryptoModulusBin256 = CRYPTO_WAC_MODULUS_BIN256, cryptoModulusBin128 = CRYPTO_WAC_MODULUS_BIN128, cryptoModulusGcmBin128 = CRYPTO_WAC_MODULUS_GCMBIN128, cryptoModulusEccB233 = CRYPTO_WAC_MODULUS_ECCBIN233P, cryptoModulusEccB163 = CRYPTO_WAC_MODULUS_ECCBIN163P, cryptoModulusEccP256 = CRYPTO_WAC_MODULUS_ECCPRIME256P, cryptoModulusEccP224 = CRYPTO_WAC_MODULUS_ECCPRIME224P, cryptoModulusEccP192 = CRYPTO_WAC_MODULUS_ECCPRIME192P, cryptoModulusEccB233Order = CRYPTO_WAC_MODULUS_ECCBIN233N, cryptoModulusEccB233KOrder = CRYPTO_WAC_MODULUS_ECCBIN233KN, cryptoModulusEccB163Order = CRYPTO_WAC_MODULUS_ECCBIN163N, cryptoModulusEccB163KOrder = CRYPTO_WAC_MODULUS_ECCBIN163KN, cryptoModulusEccP256Order = CRYPTO_WAC_MODULUS_ECCPRIME256N, cryptoModulusEccP224Order = CRYPTO_WAC_MODULUS_ECCPRIME224N, cryptoModulusEccP192Order = CRYPTO_WAC_MODULUS_ECCPRIME192N } |
enum |
CRYPTO_MulOperandWidth_TypeDef
{
cryptoMulOperand256Bits = CRYPTO_WAC_MULWIDTH_MUL256, cryptoMulOperand128Bits = CRYPTO_WAC_MULWIDTH_MUL128, cryptoMulOperandModulusBits = CRYPTO_WAC_MULWIDTH_MULMOD } |
enum |
CRYPTO_ResultWidth_TypeDef
{
cryptoResult128Bits = CRYPTO_WAC_RESULTWIDTH_128BIT, cryptoResult256Bits = CRYPTO_WAC_RESULTWIDTH_256BIT, cryptoResult260Bits = CRYPTO_WAC_RESULTWIDTH_260BIT } |
Functions |
|
__STATIC_INLINE void | AES_CBC128 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 128 bit key.
|
|
__STATIC_INLINE void | AES_CBC256 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 256 bit key.
|
|
__STATIC_INLINE void | AES_CFB128 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 128 bit key.
|
|
__STATIC_INLINE void | AES_CFB256 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 256 bit key.
|
|
__STATIC_INLINE void | AES_CTR128 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc) |
AES Counter (CTR) cipher mode encryption/decryption, 128 bit key.
|
|
__STATIC_INLINE void | AES_CTR256 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc) |
AES Counter (CTR) cipher mode encryption/decryption, 256 bit key.
|
|
__STATIC_INLINE void | AES_CTRUpdate32Bit (uint8_t *ctr) |
Update last 32 bits of 128 bit counter, by incrementing with 1.
|
|
__STATIC_INLINE void | AES_DecryptKey128 (uint8_t *out, const uint8_t *in) |
Generate 128 bit AES decryption key from 128 bit encryption key. The decryption key is used for some cipher modes when decrypting.
|
|
__STATIC_INLINE void | AES_DecryptKey256 (uint8_t *out, const uint8_t *in) |
Generate 256 bit AES decryption key from 256 bit encryption key. The decryption key is used for some cipher modes when decrypting.
|
|
__STATIC_INLINE void | AES_ECB128 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 128 bit key.
|
|
__STATIC_INLINE void | AES_ECB256 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 256 bit key.
|
|
__STATIC_INLINE void | AES_OFB128 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv) |
AES Output feedback (OFB) cipher mode encryption/decryption, 128 bit key.
|
|
__STATIC_INLINE void | AES_OFB256 (uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv) |
AES Output feedback (OFB) cipher mode encryption/decryption, 256 bit key.
|
|
void | CRYPTO_AES_CBC128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 128 bit key.
|
|
void | CRYPTO_AES_CBC256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 256 bit key.
|
|
static void | CRYPTO_AES_CBCx (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt, CRYPTO_KeyWidth_TypeDef keyWidth) |
Cipher-block chaining (CBC) cipher mode encryption/decryption, 128/256 bit key.
|
|
void | CRYPTO_AES_CFB128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 128 bit key.
|
|
void | CRYPTO_AES_CFB256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 256 bit key.
|
|
static void | CRYPTO_AES_CFBx (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt, CRYPTO_KeyWidth_TypeDef keyWidth) |
Cipher feedback (CFB) cipher mode encryption/decryption, 128/256 bit key.
|
|
void | CRYPTO_AES_CTR128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc) |
AES Counter (CTR) cipher mode encryption/decryption, 128 bit key.
|
|
void | CRYPTO_AES_CTR256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc) |
AES Counter (CTR) cipher mode encryption/decryption, 256 bit key.
|
|
void | CRYPTO_AES_CTRUpdate32Bit (uint8_t *ctr) |
Update the last 32 bits of 128 bit counter by incrementing with 1.
|
|
static void | CRYPTO_AES_CTRx (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, uint8_t *ctr, CRYPTO_AES_CtrFuncPtr_TypeDef ctrFunc, CRYPTO_KeyWidth_TypeDef keyWidth) |
Counter (CTR) cipher mode encryption/decryption, 128/256 bit key.
|
|
void | CRYPTO_AES_DecryptKey128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in) |
Generate 128 bit AES decryption key from 128 bit encryption key. The decryption key is used for some cipher modes when decrypting.
|
|
void | CRYPTO_AES_DecryptKey256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in) |
Generate 256 bit AES decryption key from 256 bit encryption key. The decryption key is used for some cipher modes when decrypting.
|
|
void | CRYPTO_AES_ECB128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 128 bit key.
|
|
void | CRYPTO_AES_ECB256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 256 bit key.
|
|
static void | CRYPTO_AES_ECBx (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, bool encrypt, CRYPTO_KeyWidth_TypeDef keyWidth) |
Electronic Codebook (ECB) cipher mode encryption/decryption, 128/256 bit key.
|
|
void | CRYPTO_AES_OFB128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv) |
AES Output feedback (OFB) cipher mode encryption/decryption, 128 bit key.
|
|
void | CRYPTO_AES_OFB256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv) |
AES Output feedback (OFB) cipher mode encryption/decryption, 256 bit key.
|
|
static void | CRYPTO_AES_OFBx (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, CRYPTO_KeyWidth_TypeDef keyWidth) |
Output feedback (OFB) cipher mode encryption/decryption, 128/256 bit key.
|
|
void | CRYPTO_AES_PCBC128 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Propagating Cipher-block chaining (PCBC) cipher mode encryption/decryption, 128 bit key.
|
|
void | CRYPTO_AES_PCBC256 (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt) |
AES Propagating Cipher-block chaining (PCBC) cipher mode encryption/decryption, 256 bit key.
|
|
static void | CRYPTO_AES_PCBCx (CRYPTO_TypeDef *crypto, uint8_t *out, const uint8_t *in, unsigned int len, const uint8_t *key, const uint8_t *iv, bool encrypt, CRYPTO_KeyWidth_TypeDef keyWidth) |
Propagating cipher-block chaining (PCBC) cipher mode encryption/decryption, 128/256 bit key.
|
|
__STATIC_INLINE void | CRYPTO_AES_ProcessLoop (CRYPTO_TypeDef *crypto, unsigned int len, CRYPTO_DataReg_TypeDef inReg, const uint8_t *in, CRYPTO_DataReg_TypeDef outReg, uint8_t *out) |
Perform generic AES loop.
|
|
__STATIC_INLINE void | CRYPTO_BurstFromCrypto (volatile uint32_t *reg, uint32_t *val) |
Read a 128 bit value from a crypto register.
|
|
__STATIC_INLINE void | CRYPTO_BurstToCrypto (volatile uint32_t *reg, const uint32_t *val) |
Write a 128 bit value into a crypto register.
|
|
__STATIC_INLINE bool | CRYPTO_CarryIsSet (CRYPTO_TypeDef *crypto) |
Quick read access of the carry bit from arithmetic operations.
|
|
__STATIC_INLINE void | CRYPTO_DataRead ( CRYPTO_DataReg_TypeDef dataReg, CRYPTO_Data_TypeDef val) |
Read 128 bits of data from a DATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_DataReadUnaligned (volatile uint32_t *reg, uint8_t *val) |
Read 128 bits of data from a DATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_DataWrite ( CRYPTO_DataReg_TypeDef dataReg, const CRYPTO_Data_TypeDef val) |
Write 128 bits of data to a DATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_DataWriteUnaligned (volatile uint32_t *reg, const uint8_t *val) |
Write 128 bits of data to a DATAX register in the CRYPTO module.
|
|
__STATIC_INLINE uint8_t | CRYPTO_DData0_4LSBitsRead (CRYPTO_TypeDef *crypto) |
Quick read access of the 4 LSbits of the DDATA0 register.
|
|
__STATIC_INLINE void | CRYPTO_DData0Read260 (CRYPTO_TypeDef *crypto, CRYPTO_Data260_TypeDef val) |
Read 260 bits from the DDATA0 register.
|
|
__STATIC_INLINE void | CRYPTO_DData0Write260 (CRYPTO_TypeDef *crypto, const CRYPTO_Data260_TypeDef val) |
Write 260 bits to the DDATA0 register.
|
|
__STATIC_INLINE bool | CRYPTO_DData1_MSBitRead (CRYPTO_TypeDef *crypto) |
Quick read the MSbit of the DDATA1 register.
|
|
__STATIC_INLINE void | CRYPTO_DDataRead ( CRYPTO_DDataReg_TypeDef ddataReg, CRYPTO_DData_TypeDef val) |
Read 256 bits of data from a DDATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_DDataWrite ( CRYPTO_DDataReg_TypeDef ddataReg, const CRYPTO_DData_TypeDef val) |
Write 256 bits of data to a DDATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_IncWidthSet (CRYPTO_TypeDef *crypto, CRYPTO_IncWidth_TypeDef incWidth) |
Set the width of the DATA1 increment instruction DATA1INC.
|
|
__STATIC_INLINE bool | CRYPTO_InstructionSequenceDone (CRYPTO_TypeDef *crypto) |
Check whether the execution of an instruction sequence has completed.
|
|
__STATIC_INLINE void | CRYPTO_InstructionSequenceExecute (CRYPTO_TypeDef *crypto) |
Execute the current programmed instruction sequence.
|
|
__STATIC_INLINE void | CRYPTO_InstructionSequenceLoad (CRYPTO_TypeDef *crypto, const CRYPTO_InstructionSequence_TypeDef instructionSequence) |
Load a sequence of instructions to be executed on the current values in the data registers.
|
|
__STATIC_INLINE void | CRYPTO_InstructionSequenceWait (CRYPTO_TypeDef *crypto) |
Wait for completion of the current sequence of instructions.
|
|
__STATIC_INLINE void | CRYPTO_InstructionWait (CRYPTO_TypeDef *crypto) |
Wait for completion of the current command.
|
|
__STATIC_INLINE void | CRYPTO_IntClear (CRYPTO_TypeDef *crypto, uint32_t flags) |
Clear one or more pending CRYPTO interrupts.
|
|
__STATIC_INLINE void | CRYPTO_IntDisable (CRYPTO_TypeDef *crypto, uint32_t flags) |
Disable one or more CRYPTO interrupts.
|
|
__STATIC_INLINE void | CRYPTO_IntEnable (CRYPTO_TypeDef *crypto, uint32_t flags) |
Enable one or more CRYPTO interrupts.
|
|
__STATIC_INLINE uint32_t | CRYPTO_IntGet (CRYPTO_TypeDef *crypto) |
Get pending CRYPTO interrupt flags.
|
|
__STATIC_INLINE uint32_t | CRYPTO_IntGetEnabled (CRYPTO_TypeDef *crypto) |
Get enabled and pending CRYPTO interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.
|
|
__STATIC_INLINE void | CRYPTO_IntSet (CRYPTO_TypeDef *crypto, uint32_t flags) |
Set one or more pending CRYPTO interrupts from software.
|
|
__STATIC_INLINE void | CRYPTO_KeyBuf128Write (CRYPTO_TypeDef *crypto, const uint32_t *val) |
Quick write 128 bit key to the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_KeyBufWrite (CRYPTO_TypeDef *crypto, CRYPTO_KeyBuf_TypeDef val, CRYPTO_KeyWidth_TypeDef keyWidth) |
Set the key value to be used by the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_KeyBufWriteUnaligned (CRYPTO_TypeDef *crypto, const uint8_t *val, CRYPTO_KeyWidth_TypeDef keyWidth) |
Set the key value to be used by the CRYPTO module.
|
|
void | CRYPTO_KeyRead (CRYPTO_TypeDef *crypto, CRYPTO_KeyBuf_TypeDef val, CRYPTO_KeyWidth_TypeDef keyWidth) |
Read the key value currently used by the CRYPTO module.
|
|
void | CRYPTO_ModulusSet (CRYPTO_TypeDef *crypto, CRYPTO_ModulusId_TypeDef modType) |
Set the modulus type used for wide arithmetic operations.
|
|
void | CRYPTO_Mul (CRYPTO_TypeDef *crypto, uint32_t *A, int aSize, uint32_t *B, int bSize, uint32_t *R, int rSize) |
Multiply two big integers.
|
|
__STATIC_INLINE void | CRYPTO_MulOperandWidthSet (CRYPTO_TypeDef *crypto, CRYPTO_MulOperandWidth_TypeDef mulOperandWidth) |
Set the number of bits in the operands of the MUL instruction.
|
|
__STATIC_INLINE void | CRYPTO_QDataRead ( CRYPTO_QDataReg_TypeDef qdataReg, CRYPTO_QData_TypeDef val) |
Read 512 bits of data from a QDATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_QDataWrite ( CRYPTO_QDataReg_TypeDef qdataReg, const CRYPTO_QData_TypeDef val) |
Write 512 bits of data to a QDATAX register in the CRYPTO module.
|
|
__STATIC_INLINE void | CRYPTO_ResultWidthSet (CRYPTO_TypeDef *crypto, CRYPTO_ResultWidth_TypeDef resultWidth) |
Set the width of the results of the non-modulus instructions.
|
|
void | CRYPTO_SHA_1 (CRYPTO_TypeDef *crypto, const uint8_t *msg, uint64_t msgLen, CRYPTO_SHA1_Digest_TypeDef msgDigest) |
Perform a SHA-1 hash operation on a message.
|
|
void | CRYPTO_SHA_256 (CRYPTO_TypeDef *crypto, const uint8_t *msg, uint64_t msgLen, CRYPTO_SHA256_Digest_TypeDef msgDigest) |
Perform a SHA-256 hash operation on a message.
|
|
__STATIC_INLINE void | cryptoBigintIncrement (uint32_t *words32bits, unsigned num32bitWords) |
Increment value of 32bit word array by one.
|
|
__STATIC_INLINE void | cryptoBigintZeroize (uint32_t *words32bits, unsigned num32bitWords) |
Set the 32 bit word array to zero.
|
|
Macro Definition Documentation
#define CRYPTO_INSTRUCTIONSEQUENSE_DEFAULT |
Default instruction sequence consisting of all ENDs. The user can initialize the instruction sequence with this default value set and fill in the desired operations from step 1. The first END instruction marks the end of the sequence.
Definition at line
554
of file
em_crypto.h
.
#define CRYPTO_MAX_SEQUENCE_INSTRUCTIONS (20) |
The maximum number of crypto instructions in an instruction sequence.
Definition at line
539
of file
em_crypto.h
.
Typedef Documentation
typedef void(* CRYPTO_AES_CtrFuncPtr_TypeDef) (uint8_t *ctr) |
AES counter modification function pointer.
- Note
-
This is defined for backwards compatibility with EFM32
em_aes.h
. The CRYPTO implementation of counter mode does not support counter update callbacks.
- Parameters
-
[in] ctr
A counter value to be modified.
Definition at line
580
of file
em_crypto.h
.
typedef uint32_t CRYPTO_Data260_TypeDef[CRYPTO_DATA260_SIZE_IN_32BIT_WORDS] |
CRYPTO data type used for data load functions. This data type is capable of storing a 260 bits value as used by the CRYPTO_DData0Write260 function.
Note that this data type is multiple of 32 bit words, so the actual storage used by this type is 32x9=288 bits.
Definition at line
458
of file
em_crypto.h
.
typedef uint32_t CRYPTO_Data_TypeDef[CRYPTO_DATA_SIZE_IN_32BIT_WORDS] |
CRYPTO data types used for data load functions. This data type is capable of storing a 128 bits value as used in the crypto DATA registers.
Definition at line
430
of file
em_crypto.h
.
typedef volatile uint32_t* CRYPTO_DataReg_TypeDef |
CRYPTO 128 bit Data register pointer type. The 128 bit registers are used to load 128 bit values as input and output data for cryptographic and big integer arithmetic functions of the CRYPTO module.
Definition at line
471
of file
em_crypto.h
.
typedef uint32_t CRYPTO_DData_TypeDef[CRYPTO_DDATA_SIZE_IN_32BIT_WORDS] |
CRYPTO data type used for data load functions. This data type is capable of storing a 256 bits value as used in the crypto DDATA registers.
Definition at line
437
of file
em_crypto.h
.
typedef volatile uint32_t* CRYPTO_DDataReg_TypeDef |
CRYPTO 256 bit DData (Double Data) register pointer type. The 256 bit registers are used to load 256 bit values as input and output data for cryptographic and big integer arithmetic functions of the CRYPTO module.
Definition at line
478
of file
em_crypto.h
.
typedef uint8_t CRYPTO_InstructionSequence_TypeDef[ CRYPTO_MAX_SEQUENCE_INSTRUCTIONS ] |
Instruction sequence type. Fill in the desired operations from step1, step2, and so on. The CRYPTO_CMD_INSTR_END marks the end of the sequence. Bit fields are used to format the memory layout of the struct equal to the sequence registers in the CRYPTO module.
Definition at line
548
of file
em_crypto.h
.
typedef uint32_t CRYPTO_KeyBuf_TypeDef[CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS] |
CRYPTO data type used for data load functions. This data type is capable of storing 256 bits as used in the crypto KEYBUF register.
Definition at line
464
of file
em_crypto.h
.
typedef uint32_t CRYPTO_QData_TypeDef[CRYPTO_QDATA_SIZE_IN_32BIT_WORDS] |
CRYPTO data type used for data load functions. This data type is capable of storing a 512 bits value as used in the crypto QDATA registers.
Definition at line
448
of file
em_crypto.h
.
typedef volatile uint32_t* CRYPTO_QDataReg_TypeDef |
CRYPTO 512 bit QData (Quad data) register pointer type. The 512 bit registers are used to load 512 bit values as input and output data for cryptographic and big integer arithmetic functions of the CRYPTO module.
Definition at line
485
of file
em_crypto.h
.
typedef uint8_t CRYPTO_SHA1_Digest_TypeDef[CRYPTO_SHA1_DIGEST_SIZE_IN_BYTES] |
SHA-1 Digest type.
Definition at line
564
of file
em_crypto.h
.
typedef uint8_t CRYPTO_SHA256_Digest_TypeDef[CRYPTO_SHA256_DIGEST_SIZE_IN_BYTES] |
SHA-256 Digest type.
Definition at line
567
of file
em_crypto.h
.
Enumeration Type Documentation
CRYPTO modulus identifiers.
Definition at line
488
of file
em_crypto.h
.
Function Documentation
__STATIC_INLINE void AES_CBC128 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 128 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CBC128 instead.
Definition at line
1353
of file
em_crypto.h
.
References CRYPTO_AES_CBC128() .
__STATIC_INLINE void AES_CBC256 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 256 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CBC256 instead.
Definition at line
1372
of file
em_crypto.h
.
References CRYPTO_AES_CBC256() .
__STATIC_INLINE void AES_CFB128 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 128 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CFB128 instead.
Definition at line
1390
of file
em_crypto.h
.
References CRYPTO_AES_CFB128() .
__STATIC_INLINE void AES_CFB256 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 256 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CFB256 instead.
Definition at line
1408
of file
em_crypto.h
.
References CRYPTO_AES_CFB256() .
__STATIC_INLINE void AES_CTR128 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
uint8_t * |
ctr,
|
||
CRYPTO_AES_CtrFuncPtr_TypeDef |
ctrFunc
|
||
) |
AES Counter (CTR) cipher mode encryption/decryption, 128 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CTR128 instead.
Definition at line
1426
of file
em_crypto.h
.
References CRYPTO_AES_CTR128() .
__STATIC_INLINE void AES_CTR256 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
uint8_t * |
ctr,
|
||
CRYPTO_AES_CtrFuncPtr_TypeDef |
ctrFunc
|
||
) |
AES Counter (CTR) cipher mode encryption/decryption, 256 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CTR256 instead.
Definition at line
1444
of file
em_crypto.h
.
References CRYPTO_AES_CTR256() .
__STATIC_INLINE void AES_CTRUpdate32Bit | ( | uint8_t * |
ctr
|
) |
Update last 32 bits of 128 bit counter, by incrementing with 1.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_CTRUpdate32Bit instead.
Definition at line
1462
of file
em_crypto.h
.
References CRYPTO_AES_CTRUpdate32Bit() .
__STATIC_INLINE void AES_DecryptKey128 | ( | uint8_t * |
out,
|
const uint8_t * |
in
|
||
) |
Generate 128 bit AES decryption key from 128 bit encryption key. The decryption key is used for some cipher modes when decrypting.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_DecryptKey128 instead.
Definition at line
1476
of file
em_crypto.h
.
References CRYPTO_AES_DecryptKey128() .
__STATIC_INLINE void AES_DecryptKey256 | ( | uint8_t * |
out,
|
const uint8_t * |
in
|
||
) |
Generate 256 bit AES decryption key from 256 bit encryption key. The decryption key is used for some cipher modes when decrypting.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_DecryptKey256 instead.
Definition at line
1490
of file
em_crypto.h
.
References CRYPTO_AES_DecryptKey256() .
__STATIC_INLINE void AES_ECB128 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
bool |
encrypt
|
||
) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 128 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_ECB128 instead.
Definition at line
1504
of file
em_crypto.h
.
References CRYPTO_AES_ECB128() .
__STATIC_INLINE void AES_ECB256 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
bool |
encrypt
|
||
) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 256 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_ECB256 instead.
Definition at line
1522
of file
em_crypto.h
.
References CRYPTO_AES_ECB256() .
__STATIC_INLINE void AES_OFB128 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv
|
||
) |
AES Output feedback (OFB) cipher mode encryption/decryption, 128 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_OFB128 instead.
Definition at line
1539
of file
em_crypto.h
.
References CRYPTO_AES_OFB128() .
__STATIC_INLINE void AES_OFB256 | ( | uint8_t * |
out,
|
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv
|
||
) |
AES Output feedback (OFB) cipher mode encryption/decryption, 256 bit key.
-
Deprecated:
- This function preserves backwards compatibility. Use CRYPTO_AES_OFB256 instead.
Definition at line
1556
of file
em_crypto.h
.
References CRYPTO_AES_OFB256() .
void CRYPTO_AES_CBC128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 128 bit key.
Encryption:
* Plaintext Plaintext * | | * V V * InitVector ->XOR +-------------->XOR * | | | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | encryption | | | encryption | * +--------------+ | +--------------+ * |---------+ | * V V * Ciphertext Ciphertext *
Decryption:
* Ciphertext Ciphertext * |----------+ | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | decryption | | | decryption | * +--------------+ | +--------------+ * | | | * V | V * InitVector ->XOR +-------------->XOR * | | * V V * Plaintext Plaintext *
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 128 bit encryption key. When decrypting, this is the 128 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey128() . If this argument is null, the key will not be loaded, as it is assumed the key has been loaded into KEYHA previously. [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
844
of file
em_crypto.c
.
References CRYPTO_AES_CBCx() , and cryptoKey128Bits .
Referenced by AES_CBC128() .
void CRYPTO_AES_CBC256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher-block chaining (CBC) cipher mode encryption/decryption, 256 bit key.
See CRYPTO_AES_CBC128() for the CBC figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 256 bit encryption key. When decrypting, this is the 256 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey256() . [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
890
of file
em_crypto.c
.
References CRYPTO_AES_CBCx() , and cryptoKey256Bits .
Referenced by AES_CBC256() .
|
static |
Cipher-block chaining (CBC) cipher mode encryption/decryption, 128/256 bit key.
See CRYPTO_AES_CBC128() for CBC figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 256 bit encryption key. When decrypting, this is the 256 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey256() . [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt. [in] keyWidth
Set to cryptoKey128Bits or cryptoKey256Bits.
Definition at line
1698
of file
em_crypto.c
.
References CRYPTO_AES_ProcessLoop() , CRYPTO_DataWriteUnaligned() , and CRYPTO_KeyBufWriteUnaligned() .
Referenced by CRYPTO_AES_CBC128() , and CRYPTO_AES_CBC256() .
void CRYPTO_AES_CFB128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 128 bit key.
Encryption:
* InitVector +----------------+ * | | | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | encryption | | | encryption | * +--------------+ | +--------------+ * | | | * V | V * Plaintext ->XOR | Plaintext ->XOR * |---------+ | * V V * Ciphertext Ciphertext *
Decryption:
* InitVector +----------------+ * | | | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | encryption | | | encryption | * +--------------+ | +--------------+ * | | | * V | V * XOR<- Ciphertext XOR<- Ciphertext * | | * V V * Plaintext Plaintext *
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
128 bit encryption key is used for both encryption and decryption modes. [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
1086
of file
em_crypto.c
.
References CRYPTO_AES_CFBx() , and cryptoKey128Bits .
Referenced by AES_CFB128() .
void CRYPTO_AES_CFB256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Cipher feedback (CFB) cipher mode encryption/decryption, 256 bit key.
See CRYPTO_AES_CFB128() for the CFB figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
256 bit encryption key is used for both encryption and decryption modes. [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
1129
of file
em_crypto.c
.
References CRYPTO_AES_CFBx() , and cryptoKey256Bits .
Referenced by AES_CFB256() .
|
static |
Cipher feedback (CFB) cipher mode encryption/decryption, 128/256 bit key.
See CRYPTO_AES_CFB128() for CFB figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
256 bit encryption key is used for both encryption and decryption modes. [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt. [in] keyWidth
Set to cryptoKey128Bits or cryptoKey256Bits.
Definition at line
1843
of file
em_crypto.c
.
References CRYPTO_AES_ProcessLoop() , CRYPTO_DataWriteUnaligned() , and CRYPTO_KeyBufWriteUnaligned() .
Referenced by CRYPTO_AES_CFB128() , and CRYPTO_AES_CFB256() .
void CRYPTO_AES_CTR128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
uint8_t * |
ctr,
|
||
CRYPTO_AES_CtrFuncPtr_TypeDef |
ctrFunc
|
||
) |
AES Counter (CTR) cipher mode encryption/decryption, 128 bit key.
Encryption:
* Counter Counter * | | * V V * +--------------+ +--------------+ * Key ->| Block cipher | Key ->| Block cipher | * | encryption | | encryption | * +--------------+ +--------------+ * | | * Plaintext ->XOR Plaintext ->XOR * | | * V V * Ciphertext Ciphertext *
Decryption:
* Counter Counter * | | * V V * +--------------+ +--------------+ * Key ->| Block cipher | Key ->| Block cipher | * | encryption | | encryption | * +--------------+ +--------------+ * | | * Ciphertext ->XOR Ciphertext ->XOR * | | * V V * Plaintext Plaintext *
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
128 bit encryption key. If this argument is null, the key will not be loaded, as it is assumed the key has been loaded into KEYHA previously. [in,out] ctr
128 bit initial counter value. The counter is updated after each AES block encoding through use of ctrFunc
.[in] ctrFunc
A function used to update the counter value. Not supported by CRYPTO. This parameter is included for backwards compatibility with the EFM32 em_aes.h
API.
Definition at line
1205
of file
em_crypto.c
.
References CRYPTO_AES_CTRx() , and cryptoKey128Bits .
Referenced by AES_CTR128() .
void CRYPTO_AES_CTR256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
uint8_t * |
ctr,
|
||
CRYPTO_AES_CtrFuncPtr_TypeDef |
ctrFunc
|
||
) |
AES Counter (CTR) cipher mode encryption/decryption, 256 bit key.
See CRYPTO_AES_CTR128() for CTR figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
256 bit encryption key. [in,out] ctr
128 bit initial counter value. The counter is updated after each AES block encoding through use of ctrFunc
.[in] ctrFunc
A function used to update counter value. Not supported by CRYPTO. This parameter is included in order for backwards compatibility with the EFM32 em_aes.h
API.
Definition at line
1251
of file
em_crypto.c
.
References CRYPTO_AES_CTRx() , and cryptoKey256Bits .
Referenced by AES_CTR256() .
void CRYPTO_AES_CTRUpdate32Bit | ( | uint8_t * |
ctr
|
) |
Update the last 32 bits of 128 bit counter by incrementing with 1.
Notice that no special consideration is given to the possible wrap around. If 32 least significant bits are 0xFFFFFFFF, they will be updated to 0x00000000, ignoring overflow.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in,out] ctr
A buffer holding 128 bit counter to be updated.
Definition at line
1277
of file
em_crypto.c
.
Referenced by AES_CTRUpdate32Bit() .
|
static |
Counter (CTR) cipher mode encryption/decryption, 128/256 bit key.
See CRYPTO_AES_CTR128() for CTR figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
256 bit encryption key. [in,out] ctr
128 bit initial counter value. The counter is updated after each AES block encoding through use of ctrFunc
.[in] ctrFunc
A function used to update counter value. Not supported by CRYPTO. This parameter is included for backwards compatibility with the EFM32 em_aes.h
API.[in] keyWidth
Set to cryptoKey128Bits or cryptoKey256Bits.
Definition at line
1921
of file
em_crypto.c
.
References CRYPTO_AES_ProcessLoop() , CRYPTO_DataReadUnaligned() , CRYPTO_DataWriteUnaligned() , and CRYPTO_KeyBufWriteUnaligned() .
Referenced by CRYPTO_AES_CTR128() , and CRYPTO_AES_CTR256() .
void CRYPTO_AES_DecryptKey128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in
|
||
) |
Generate 128 bit AES decryption key from 128 bit encryption key. The decryption key is used for some cipher modes when decrypting.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place 128 bit decryption key. Must be at least 16 bytes long. It may be set equal to in
, in which case the input buffer is overwritten.[in] in
A buffer holding 128 bit encryption key. Must be at least 16 bytes long.
Definition at line
1302
of file
em_crypto.c
.
References CRYPTO_DataReadUnaligned() , CRYPTO_DataWriteUnaligned() , and CRYPTO_InstructionSequenceWait() .
Referenced by AES_DecryptKey128() .
void CRYPTO_AES_DecryptKey256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in
|
||
) |
Generate 256 bit AES decryption key from 256 bit encryption key. The decryption key is used for some cipher modes when decrypting.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place 256 bit decryption key. Must be at least 32 bytes long. It may be set equal to in
, in which case the input buffer is overwritten.[in] in
A buffer holding 256 bit encryption key. Must be at least 32 bytes long.
Definition at line
1340
of file
em_crypto.c
.
References CRYPTO_DataReadUnaligned() , CRYPTO_DataWriteUnaligned() , and CRYPTO_InstructionSequenceWait() .
Referenced by AES_DecryptKey256() .
void CRYPTO_AES_ECB128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
bool |
encrypt
|
||
) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 128 bit key.
Encryption:
* Plaintext Plaintext * | | * V V * +--------------+ +--------------+ * Key ->| Block cipher | Key ->| Block cipher | * | encryption | | encryption | * +--------------+ +--------------+ * | | * V V * Ciphertext Ciphertext *
Decryption:
* Ciphertext Ciphertext * | | * V V * +--------------+ +--------------+ * Key ->| Block cipher | Key ->| Block cipher | * | decryption | | decryption | * +--------------+ +--------------+ * | | * V V * Plaintext Plaintext *
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 128 bit encryption key. When decrypting, this is the 128 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey128() . [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
1417
of file
em_crypto.c
.
References CRYPTO_AES_ECBx() , and cryptoKey128Bits .
Referenced by AES_ECB128() .
void CRYPTO_AES_ECB256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
bool |
encrypt
|
||
) |
AES Electronic Codebook (ECB) cipher mode encryption/decryption, 256 bit key.
See CRYPTO_AES_ECB128() for ECB figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 256 bit encryption key. When decrypting, this is the 256 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey256() . [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
1459
of file
em_crypto.c
.
References CRYPTO_AES_ECBx() , and cryptoKey256Bits .
Referenced by AES_ECB256() .
|
static |
Electronic Codebook (ECB) cipher mode encryption/decryption, 128/256 bit key.
See CRYPTO_AES_ECB128() for ECB figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 256 bit encryption key. When decrypting, this is the 256 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey256() . [in] encrypt
Set to true to encrypt, false to decrypt. [in] keyWidth
Set to cryptoKey128Bits or cryptoKey256Bits.
Definition at line
1988
of file
em_crypto.c
.
References CRYPTO_AES_ProcessLoop() , and CRYPTO_KeyBufWriteUnaligned() .
Referenced by CRYPTO_AES_ECB128() , and CRYPTO_AES_ECB256() .
void CRYPTO_AES_OFB128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv
|
||
) |
AES Output feedback (OFB) cipher mode encryption/decryption, 128 bit key.
Encryption:
* InitVector +----------------+ * | | | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | encryption | | | encryption | * +--------------+ | +--------------+ * | | | * |---------+ | * V V * Plaintext ->XOR Plaintext ->XOR * | | * V V * Ciphertext Ciphertext *
Decryption:
* InitVector +----------------+ * | | | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | encryption | | | encryption | * +--------------+ | +--------------+ * | | | * |---------+ | * V V * Ciphertext ->XOR Ciphertext ->XOR * | | * V V * Plaintext Plaintext *
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
128 bit encryption key. [in] iv
128 bit initialization vector to use.
Definition at line
1530
of file
em_crypto.c
.
References CRYPTO_AES_OFBx() , and cryptoKey128Bits .
Referenced by AES_OFB128() .
void CRYPTO_AES_OFB256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv
|
||
) |
AES Output feedback (OFB) cipher mode encryption/decryption, 256 bit key.
See CRYPTO_AES_OFB128() for OFB figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
256 bit encryption key. [in] iv
128 bit initialization vector to use.
Definition at line
1569
of file
em_crypto.c
.
References CRYPTO_AES_OFBx() , and cryptoKey256Bits .
Referenced by AES_OFB256() .
|
static |
Output feedback (OFB) cipher mode encryption/decryption, 128/256 bit key.
See CRYPTO_AES_OFB128() for OFB figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
256 bit encryption key. [in] iv
128 bit initialization vector to use. [in] keyWidth
Set to cryptoKey128Bits or cryptoKey256Bits.
Definition at line
2048
of file
em_crypto.c
.
References CRYPTO_AES_ProcessLoop() , CRYPTO_DataWriteUnaligned() , and CRYPTO_KeyBufWriteUnaligned() .
Referenced by CRYPTO_AES_OFB128() , and CRYPTO_AES_OFB256() .
void CRYPTO_AES_PCBC128 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Propagating Cipher-block chaining (PCBC) cipher mode encryption/decryption, 128 bit key.
Encryption:
* Plaintext Plaintext * |--------------+ | * V V V * InitVector ->XOR +-->XOR-------->XOR * | | | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | encryption | | | encryption | * +--------------+ | +--------------+ * |---------+ | * V V * Ciphertext Ciphertext *
Decryption:
* Ciphertext Ciphertext * |----------+ | * V | V * +--------------+ | +--------------+ * Key ->| Block cipher | | Key ->| Block cipher | * | decryption | | | decryption | * +--------------+ | +--------------+ * | | | * V V V * InitVector ->XOR +--->XOR------------>XOR * |---+ | * V V * Plaintext Plaintext *
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 128 bit encryption key. When decrypting, this is the 128 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey128() . If this argument is null, the key will not be loaded, as it is assumed the key has been loaded into KEYHA previously. [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
967
of file
em_crypto.c
.
References CRYPTO_AES_PCBCx() , and cryptoKey128Bits .
void CRYPTO_AES_PCBC256 | ( | CRYPTO_TypeDef * |
crypto,
|
uint8_t * |
out,
|
||
const uint8_t * |
in,
|
||
unsigned int |
len,
|
||
const uint8_t * |
key,
|
||
const uint8_t * |
iv,
|
||
bool |
encrypt
|
||
) |
AES Propagating Cipher-block chaining (PCBC) cipher mode encryption/decryption, 256 bit key.
See CRYPTO_AES_PCBC128() for the PCBC figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 256 bit encryption key. When decrypting, this is the 256 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey256() . [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt.
Definition at line
1013
of file
em_crypto.c
.
References CRYPTO_AES_PCBCx() , and cryptoKey256Bits .
|
static |
Propagating cipher-block chaining (PCBC) cipher mode encryption/decryption, 128/256 bit key.
See CRYPTO_AES_PCBC128() for PCBC figure.
See general comments on layout and byte ordering of parameters.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.[in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] key
When encrypting, this is the 256 bit encryption key. When decrypting, this is the 256 bit decryption key. The decryption key may be generated from the encryption key with CRYPTO_AES_DecryptKey256() . [in] iv
128 bit initialization vector to use. [in] encrypt
Set to true to encrypt, false to decrypt. [in] keyWidth
Set to cryptoKey128Bits or cryptoKey256Bits.
Definition at line
1771
of file
em_crypto.c
.
References CRYPTO_AES_ProcessLoop() , CRYPTO_DataWriteUnaligned() , and CRYPTO_KeyBufWriteUnaligned() .
Referenced by CRYPTO_AES_PCBC128() , and CRYPTO_AES_PCBC256() .
__STATIC_INLINE void CRYPTO_AES_ProcessLoop | ( | CRYPTO_TypeDef * |
crypto,
|
unsigned int |
len,
|
||
CRYPTO_DataReg_TypeDef |
inReg,
|
||
const uint8_t * |
in,
|
||
CRYPTO_DataReg_TypeDef |
outReg,
|
||
uint8_t * |
out
|
||
) |
Perform generic AES loop.
Function loads given register with provided input data. Triggers CRYPTO to perform sequence of instructions and read specified output register to output buffer.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] len
A number of bytes to encrypt/decrypt. Must be a multiple of 16. [in] inReg
An input register - one of DATA0,DATA1,DATA2,DATA3 [in] in
A buffer holding data to encrypt/decrypt. Must be at least len
long.[in] outReg
An output register - one of DATA0,DATA1,DATA2,DATA3 [out] out
A buffer to place encrypted/decrypted data. Must be at least len
long. It may be set equal toin
, in which case the input buffer is overwritten.
Definition at line
2105
of file
em_crypto.c
.
References CRYPTO_DataRead() , CRYPTO_DataReadUnaligned() , CRYPTO_DataWrite() , CRYPTO_DataWriteUnaligned() , CRYPTO_InstructionSequenceExecute() , and CRYPTO_InstructionSequenceWait() .
Referenced by CRYPTO_AES_CBCx() , CRYPTO_AES_CFBx() , CRYPTO_AES_CTRx() , CRYPTO_AES_ECBx() , CRYPTO_AES_OFBx() , and CRYPTO_AES_PCBCx() .
__STATIC_INLINE void CRYPTO_BurstFromCrypto | ( | volatile uint32_t * |
reg,
|
uint32_t * |
val
|
||
) |
Read a 128 bit value from a crypto register.
- Note
- This function provides a low-level API for reading one of the multi-word registers in the crypto peripheral. Applications should use CRYPTO_DataRead , CRYPTO_DDataRead or CRYPTO_QDataRead for reading the value of DATA, DDATA, and QDATA registers.
- Parameters
-
[in] reg
A pointer to the crypto register. [out] val
This is a pointer to an array that is capable of holding 4 32 bit integers that will be filled with the 128 bit value from the crypto register.
Definition at line
716
of file
em_crypto.h
.
Referenced by CRYPTO_DataRead() , CRYPTO_DDataRead() , CRYPTO_KeyRead() , and CRYPTO_QDataRead() .
__STATIC_INLINE void CRYPTO_BurstToCrypto | ( | volatile uint32_t * |
reg,
|
const uint32_t * |
val
|
||
) |
Write a 128 bit value into a crypto register.
- Note
- This function provides a low-level API for writing to the multi-word registers in the crypto peripheral. Applications should use CRYPTO_DataWrite , CRYPTO_DDataWrite or CRYPTO_QDataWrite for writing to DATA, DDATA, and QDATA registers.
- Parameters
-
[in] reg
A pointer to the crypto register. [in] val
This is a pointer to 4 32 bit integers that contains the 128 bit value which will be written to the crypto register.
Definition at line
684
of file
em_crypto.h
.
Referenced by CRYPTO_DataWrite() , CRYPTO_DDataWrite() , CRYPTO_KeyBuf128Write() , CRYPTO_KeyBufWrite() , and CRYPTO_QDataWrite() .
__STATIC_INLINE bool CRYPTO_CarryIsSet | ( | CRYPTO_TypeDef * |
crypto
|
) |
Quick read access of the carry bit from arithmetic operations.
This function reads the carry bit of the CRYPTO ALU.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
- Returns
- Returns 'true' if carry is 1, and 'false' if carry is 0.
Definition at line
914
of file
em_crypto.h
.
Referenced by CRYPTO_Mul() .
__STATIC_INLINE void CRYPTO_DataRead | ( | CRYPTO_DataReg_TypeDef |
dataReg,
|
CRYPTO_Data_TypeDef |
val
|
||
) |
Read 128 bits of data from a DATAX register in the CRYPTO module.
Read 128 bits of data from a DATAX register in the crypto module. The data value is typically output from a big integer operation (see crypto instructions)
- Parameters
-
[in] dataReg
The 128 bit DATA register. [out] val
Location where to store the value in memory.
Definition at line
760
of file
em_crypto.h
.
References CRYPTO_BurstFromCrypto() .
Referenced by CRYPTO_AES_ProcessLoop() , CRYPTO_DataReadUnaligned() , and CRYPTO_Mul() .
__STATIC_INLINE void CRYPTO_DataReadUnaligned | ( | volatile uint32_t * |
reg,
|
uint8_t * |
val
|
||
) |
Read 128 bits of data from a DATAX register in the CRYPTO module.
- Parameters
-
[in] dataReg
The 128 bit DATA register. [out] val
Location where to store the value in memory.
Definition at line
1591
of file
em_crypto.c
.
References CRYPTO_DataRead() .
Referenced by CRYPTO_AES_CTRx() , CRYPTO_AES_DecryptKey128() , CRYPTO_AES_DecryptKey256() , and CRYPTO_AES_ProcessLoop() .
__STATIC_INLINE void CRYPTO_DataWrite | ( | CRYPTO_DataReg_TypeDef |
dataReg,
|
const CRYPTO_Data_TypeDef |
val
|
||
) |
Write 128 bits of data to a DATAX register in the CRYPTO module.
Write 128 bits of data to a DATAX register in the crypto module. The data value is typically input to a big integer operation (see crypto instructions).
- Parameters
-
[in] dataReg
The 128 bit DATA register. [in] val
Value of the data to write to the DATA register.
Definition at line
742
of file
em_crypto.h
.
References CRYPTO_BurstToCrypto() .
Referenced by CRYPTO_AES_ProcessLoop() , CRYPTO_DataWriteUnaligned() , and CRYPTO_Mul() .
__STATIC_INLINE void CRYPTO_DataWriteUnaligned | ( | volatile uint32_t * |
reg,
|
const uint8_t * |
val
|
||
) |
Write 128 bits of data to a DATAX register in the CRYPTO module.
- Parameters
-
[in] dataReg
The 128 bit DATA register. [in] val
Pointer to value to write to the DATA register.
Definition at line
1612
of file
em_crypto.c
.
References CRYPTO_DataWrite() .
Referenced by CRYPTO_AES_CBCx() , CRYPTO_AES_CFBx() , CRYPTO_AES_CTRx() , CRYPTO_AES_DecryptKey128() , CRYPTO_AES_DecryptKey256() , CRYPTO_AES_OFBx() , CRYPTO_AES_PCBCx() , and CRYPTO_AES_ProcessLoop() .
__STATIC_INLINE uint8_t CRYPTO_DData0_4LSBitsRead | ( | CRYPTO_TypeDef * |
crypto
|
) |
Quick read access of the 4 LSbits of the DDATA0 register.
This function quickly retrieves the 4 least significant bits of the DDATA0 register via the DDATA0LSBS bit field in the DSTATUS register.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
- Returns
- Returns the 4 LSbits of DDATA0.
Definition at line
934
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_DData0Read260 | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_Data260_TypeDef |
val
|
||
) |
Read 260 bits from the DDATA0 register.
This functions reads 260 bits from the DDATA0 register in the CRYPTO module. The data value is typically output from a big integer operation (see crypto instructions) when the result width is set to 260 bits by calling CRYPTO_ResultWidthSet(cryptoResult260Bits);
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [out] val
A location to store the value in memory.
Definition at line
956
of file
em_crypto.h
.
References CRYPTO_DDataRead() .
__STATIC_INLINE void CRYPTO_DData0Write260 | ( | CRYPTO_TypeDef * |
crypto,
|
const CRYPTO_Data260_TypeDef |
val
|
||
) |
Write 260 bits to the DDATA0 register.
This functions writes 260 bits to the DDATA0 register in the CRYPTO module. The data value is typically input to a big integer operation (see crypto instructions) when the result width is set to 260 bits by calling CRYPTO_ResultWidthSet(cryptoResult260Bits);
- Parameters
-
[in] crypto
Pointer to CRYPTO peripheral register block. [out] val
Location where of the value in memory.
Definition at line
980
of file
em_crypto.h
.
References CRYPTO_DDataWrite() .
__STATIC_INLINE bool CRYPTO_DData1_MSBitRead | ( | CRYPTO_TypeDef * |
crypto
|
) |
Quick read the MSbit of the DDATA1 register.
This function reads the most significant bit (bit 255) of the DDATA1 register via the DDATA1MSB bit field in the DSTATUS register. This can be used to quickly check the signedness of a big integer resident in the CRYPTO module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
- Returns
- Returns 'true' if MSbit is 1, and 'false' if MSbit is 0.
Definition at line
1003
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_DDataRead | ( | CRYPTO_DDataReg_TypeDef |
ddataReg,
|
CRYPTO_DData_TypeDef |
val
|
||
) |
Read 256 bits of data from a DDATAX register in the CRYPTO module.
Read 256 bits of data from a DDATAX (Double Data) register in the crypto module. The data value is typically output from a big integer operation (see crypto instructions).
- Parameters
-
[in] ddataReg
The 256 bit DDATA register. [out] val
Location where to store the value in memory.
Definition at line
797
of file
em_crypto.h
.
References CRYPTO_BurstFromCrypto() .
Referenced by CRYPTO_DData0Read260() , and CRYPTO_SHA_256() .
__STATIC_INLINE void CRYPTO_DDataWrite | ( | CRYPTO_DDataReg_TypeDef |
ddataReg,
|
const CRYPTO_DData_TypeDef |
val
|
||
) |
Write 256 bits of data to a DDATAX register in the CRYPTO module.
Write 256 bits of data into a DDATAX (Double Data) register in the crypto module. The data value is typically input to a big integer operation (see crypto instructions).
- Parameters
-
[in] ddataReg
The 256 bit DDATA register. [in] val
Value of the data to write to the DDATA register.
Definition at line
778
of file
em_crypto.h
.
References CRYPTO_BurstToCrypto() .
Referenced by CRYPTO_DData0Write260() , CRYPTO_KeyBufWrite() , and CRYPTO_SHA_256() .
__STATIC_INLINE void CRYPTO_IncWidthSet | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_IncWidth_TypeDef |
incWidth
|
||
) |
Set the width of the DATA1 increment instruction DATA1INC.
This function sets the width of the DATA1 increment instruction CRYPTO_CMD_INSTR_DATA1INC.
- Parameters
-
[in] crypto
A pointer to CRYPTO peripheral register block. [in] incWidth
An incrementation width.
Definition at line
660
of file
em_crypto.h
.
__STATIC_INLINE bool CRYPTO_InstructionSequenceDone | ( | CRYPTO_TypeDef * |
crypto
|
) |
Check whether the execution of an instruction sequence has completed.
This function checks whether an instruction sequence has completed.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
- Returns
- Returns 'true' if the instruction sequence is done, and 'false' if not.
Definition at line
1068
of file
em_crypto.h
.
Referenced by CRYPTO_InstructionSequenceWait() .
__STATIC_INLINE void CRYPTO_InstructionSequenceExecute | ( | CRYPTO_TypeDef * |
crypto
|
) |
Execute the current programmed instruction sequence.
This function starts the execution of the current instruction sequence in the CRYPTO module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
Definition at line
1049
of file
em_crypto.h
.
Referenced by CRYPTO_AES_ProcessLoop() , and CRYPTO_Mul() .
__STATIC_INLINE void CRYPTO_InstructionSequenceLoad | ( | CRYPTO_TypeDef * |
crypto,
|
const CRYPTO_InstructionSequence_TypeDef |
instructionSequence
|
||
) |
Load a sequence of instructions to be executed on the current values in the data registers.
This function loads a sequence of instructions to the crypto module. The instructions will be executed when the CRYPTO_InstructionSequenceExecute function is called. The first END marks the end of the sequence.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] instructionSequence
An instruction sequence to load.
Definition at line
1026
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_InstructionSequenceWait | ( | CRYPTO_TypeDef * |
crypto
|
) |
Wait for completion of the current sequence of instructions.
This function "busy"-waits until the execution of the ongoing instruction sequence has completed.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
Definition at line
1086
of file
em_crypto.h
.
References CRYPTO_InstructionSequenceDone() .
Referenced by CRYPTO_AES_DecryptKey128() , CRYPTO_AES_DecryptKey256() , CRYPTO_AES_ProcessLoop() , CRYPTO_SHA_1() , and CRYPTO_SHA_256() .
__STATIC_INLINE void CRYPTO_InstructionWait | ( | CRYPTO_TypeDef * |
crypto
|
) |
Wait for completion of the current command.
This function "busy"-waits until the execution of the ongoing instruction has completed.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
Definition at line
1103
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_IntClear | ( | CRYPTO_TypeDef * |
crypto,
|
uint32_t |
flags
|
||
) |
Clear one or more pending CRYPTO interrupts.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] flags
A pending CRYPTO interrupt source to clear. Use a bitwise logic OR combination of valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).
Definition at line
1233
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_IntDisable | ( | CRYPTO_TypeDef * |
crypto,
|
uint32_t |
flags
|
||
) |
Disable one or more CRYPTO interrupts.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] flags
CRYPTO interrupt sources to disable. Use a bitwise logic OR combination of valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).
Definition at line
1249
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_IntEnable | ( | CRYPTO_TypeDef * |
crypto,
|
uint32_t |
flags
|
||
) |
Enable one or more CRYPTO interrupts.
- Note
- Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using CRYPTO_IntClear() prior to enabling if such a pending interrupt should be ignored.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] flags
CRYPTO interrupt sources to enable. Use a bitwise logic OR combination of valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).
Definition at line
1270
of file
em_crypto.h
.
__STATIC_INLINE uint32_t CRYPTO_IntGet | ( | CRYPTO_TypeDef * |
crypto
|
) |
Get pending CRYPTO interrupt flags.
- Note
- The event bits are not cleared by the use of this function.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
- Returns
- CRYPTO interrupt sources pending. A bitwise logic OR combination of valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).
Definition at line
1289
of file
em_crypto.h
.
__STATIC_INLINE uint32_t CRYPTO_IntGetEnabled | ( | CRYPTO_TypeDef * |
crypto
|
) |
Get enabled and pending CRYPTO interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.
- Note
- Interrupt flags are not cleared by the use of this function.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block.
- Returns
-
Pending and enabled CRYPTO interrupt sources The return value is the bitwise AND of
- the enabled interrupt sources in CRYPTO_IEN and
- the pending interrupt flags CRYPTO_IF
Definition at line
1311
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_IntSet | ( | CRYPTO_TypeDef * |
crypto,
|
uint32_t |
flags
|
||
) |
Set one or more pending CRYPTO interrupts from software.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] flags
CRYPTO interrupt sources to set to pending. Use a bitwise logic OR combination of valid interrupt flags for the CRYPTO module (CRYPTO_IF_nnn).
Definition at line
1334
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_KeyBuf128Write | ( | CRYPTO_TypeDef * |
crypto,
|
const uint32_t * |
val
|
||
) |
Quick write 128 bit key to the CRYPTO module.
Quick write 128 bit key to the KEYBUF register in the CRYPTO module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] val
Value of the data to write to the KEYBUF register.
Definition at line
895
of file
em_crypto.h
.
References CRYPTO_BurstToCrypto() .
__STATIC_INLINE void CRYPTO_KeyBufWrite | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_KeyBuf_TypeDef |
val,
|
||
CRYPTO_KeyWidth_TypeDef |
keyWidth
|
||
) |
Set the key value to be used by the CRYPTO module.
Write 128 or 256 bit key to the KEYBUF register in the crypto module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] val
Value of the data to write to the KEYBUF register. [in] keyWidth
Key width - 128 or 256 bits.
Definition at line
862
of file
em_crypto.h
.
References BUS_RegBitWrite() , CRYPTO_BurstToCrypto() , CRYPTO_DDataWrite() , and cryptoKey256Bits .
Referenced by CRYPTO_KeyBufWriteUnaligned() .
__STATIC_INLINE void CRYPTO_KeyBufWriteUnaligned | ( | CRYPTO_TypeDef * |
crypto,
|
const uint8_t * |
val,
|
||
CRYPTO_KeyWidth_TypeDef |
keyWidth
|
||
) |
Set the key value to be used by the CRYPTO module.
Write 128 or 256 bit key to the KEYBUF register in the crypto module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] val
Pointer to value to write to the KEYBUF register. [in] keyWidth
Key width - 128 or 256 bits.
Definition at line
1643
of file
em_crypto.c
.
References CRYPTO_KeyBufWrite() , and cryptoKey128Bits .
Referenced by CRYPTO_AES_CBCx() , CRYPTO_AES_CFBx() , CRYPTO_AES_CTRx() , CRYPTO_AES_ECBx() , CRYPTO_AES_OFBx() , and CRYPTO_AES_PCBCx() .
void CRYPTO_KeyRead | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_KeyBuf_TypeDef |
val,
|
||
CRYPTO_KeyWidth_TypeDef |
keyWidth
|
||
) |
Read the key value currently used by the CRYPTO module.
Read 128 bits or 256 bits from the KEY register in the CRYPTO module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] val
A value of the data to write to the KEYBUF register. [in] keyWidth
Key width - 128 or 256 bits
Definition at line
261
of file
em_crypto.c
.
References CRYPTO_BurstFromCrypto() , and cryptoKey256Bits .
void CRYPTO_ModulusSet | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_ModulusId_TypeDef |
modulusId
|
||
) |
Set the modulus type used for wide arithmetic operations.
Set the modulus used for wide modular operations.
This function sets the modulus type to be used by the modulus instructions of the CRYPTO module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] modType
A modulus type.
This function sets the modulus to be used by the modular instructions of the CRYPTO module.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] modulusId
A modulus identifier.
Definition at line
207
of file
em_crypto.c
.
References cryptoModulusBin128 , cryptoModulusBin256 , cryptoModulusEccB163 , cryptoModulusEccB163KOrder , cryptoModulusEccB163Order , cryptoModulusEccB233 , cryptoModulusEccB233KOrder , cryptoModulusEccB233Order , cryptoModulusEccP192 , cryptoModulusEccP192Order , cryptoModulusEccP224 , cryptoModulusEccP224Order , cryptoModulusEccP256 , cryptoModulusEccP256Order , and cryptoModulusGcmBin128 .
void CRYPTO_Mul | ( | CRYPTO_TypeDef * |
crypto,
|
uint32_t * |
A,
|
||
int |
aSize,
|
||
uint32_t * |
B,
|
||
int |
bSize,
|
||
uint32_t * |
R,
|
||
int |
rSize
|
||
) |
Multiply two big integers.
This function uses the CRYPTO unit to multiply two big integer operands. If USE_VARIABLE_SIZED_DATA_LOADS is defined, the sizes of the operands may be any multiple of 32 bits. If USE_VARIABLE_SIZED_DATA_LOADS is not defined, the sizes of the operands must be a multiple of 128 bits.
- Parameters
-
[in] A
An operand A [in] aSize
The size of the operand A in bits [in] B
An operand B [in] bSize
The size of the operand B in bits [out] R
The result of multiplication [in] rSize
The size of the result buffer R in bits
Definition at line
596
of file
em_crypto.c
.
References CRYPTO_CarryIsSet() , CRYPTO_DataRead() , CRYPTO_DataWrite() , CRYPTO_InstructionSequenceExecute() , cryptoBigintIncrement() , and cryptoBigintZeroize() .
__STATIC_INLINE void CRYPTO_MulOperandWidthSet | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_MulOperandWidth_TypeDef |
mulOperandWidth
|
||
) |
Set the number of bits in the operands of the MUL instruction.
This function sets the number of bits to be used in the operands of the MUL instruction.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] mulOperandWidth
Multiplication width in bits.
Definition at line
618
of file
em_crypto.h
.
__STATIC_INLINE void CRYPTO_QDataRead | ( | CRYPTO_QDataReg_TypeDef |
qdataReg,
|
CRYPTO_QData_TypeDef |
val
|
||
) |
Read 512 bits of data from a QDATAX register in the CRYPTO module.
Read 512 bits of data from a QDATAX register in the crypto module. The data value is typically input to a big integer operation (see crypto instructions).
- Parameters
-
[in] qdataReg
The 512 bits QDATA register. [in] val
Value of the data to write to the QDATA register.
Definition at line
837
of file
em_crypto.h
.
References CRYPTO_BurstFromCrypto() .
__STATIC_INLINE void CRYPTO_QDataWrite | ( | CRYPTO_QDataReg_TypeDef |
qdataReg,
|
const CRYPTO_QData_TypeDef |
val
|
||
) |
Write 512 bits of data to a QDATAX register in the CRYPTO module.
Write 512 bits of data into a QDATAX (Quad Data) register in the crypto module The data value is typically input to a big integer operation (see crypto instructions).
- Parameters
-
[in] qdataReg
The 512 bits QDATA register. [in] val
Value of the data to write to the QDATA register.
Definition at line
816
of file
em_crypto.h
.
References CRYPTO_BurstToCrypto() .
Referenced by CRYPTO_SHA_1() , and CRYPTO_SHA_256() .
__STATIC_INLINE void CRYPTO_ResultWidthSet | ( | CRYPTO_TypeDef * |
crypto,
|
CRYPTO_ResultWidth_TypeDef |
resultWidth
|
||
) |
Set the width of the results of the non-modulus instructions.
This function sets the result width of the non-modulus instructions.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] resultWidth
A result width of non-modulus instructions.
Definition at line
639
of file
em_crypto.h
.
Referenced by CRYPTO_SHA_1() , and CRYPTO_SHA_256() .
void CRYPTO_SHA_1 | ( | CRYPTO_TypeDef * |
crypto,
|
const uint8_t * |
msg,
|
||
uint64_t |
msgLen,
|
||
CRYPTO_SHA1_Digest_TypeDef |
msgDigest
|
||
) |
Perform a SHA-1 hash operation on a message.
This function performs a SHA-1 hash operation on the message specified by msg with length msgLen and returns the message digest in msgDigest.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] msg
Message to hash. [in] msgLen
Length of message in bytes. [out] msgDigest
A message digest.
Definition at line
293
of file
em_crypto.c
.
References CRYPTO_InstructionSequenceWait() , CRYPTO_QDataWrite() , CRYPTO_ResultWidthSet() , and cryptoResult256Bits .
void CRYPTO_SHA_256 | ( | CRYPTO_TypeDef * |
crypto,
|
const uint8_t * |
msg,
|
||
uint64_t |
msgLen,
|
||
CRYPTO_SHA256_Digest_TypeDef |
msgDigest
|
||
) |
Perform a SHA-256 hash operation on a message.
This function performs a SHA-256 hash operation on the message specified by msg with length msgLen and returns the message digest in msgDigest.
- Parameters
-
[in] crypto
A pointer to the CRYPTO peripheral register block. [in] msg
A message to hash. [in] msgLen
The length of message in bytes. [out] msgDigest
A message digest.
Definition at line
431
of file
em_crypto.c
.
References CRYPTO_DDataRead() , CRYPTO_DDataWrite() , CRYPTO_InstructionSequenceWait() , CRYPTO_QDataWrite() , CRYPTO_ResultWidthSet() , and cryptoResult256Bits .
__STATIC_INLINE void cryptoBigintIncrement | ( | uint32_t * |
words32bits,
|
unsigned |
num32bitWords
|
||
) |
Increment value of 32bit word array by one.
- Parameters
-
[in] words32bits
Pointer to 32bit word array [in] num32bitWords
Number of 32bit words in array
Definition at line
567
of file
em_crypto.c
.
Referenced by CRYPTO_Mul() .
__STATIC_INLINE void cryptoBigintZeroize | ( | uint32_t * |
words32bits,
|
unsigned |
num32bitWords
|
||
) |
Set the 32 bit word array to zero.
- Parameters
-
[in] words32bits
A pointer to the 32 bit word array. [in] num32bitWords
A number of 32 bit words in array.
Definition at line
551
of file
em_crypto.c
.
Referenced by CRYPTO_Mul() .