EFM32 Pearl Gecko Software Documentation
efm32pg1-doc-4.2.1
|
Cryptography accelerator peripheral API. More...
Macros | |
#define | CRYPTO_MAX_SEQUENCE_INSTRUCTIONS (20) |
#define | CRYPTO_INSTRUCTIONSEQUENSE_DEFAULT |
Typedefs | |
typedef uint32_t | CRYPTO_Data_TypeDef[CRYPTO_DATA_SIZE_IN_32BIT_WORDS] |
typedef uint32_t | CRYPTO_DData_TypeDef[CRYPTO_DDATA_SIZE_IN_32BIT_WORDS] |
typedef uint32_t | CRYPTO_QData_TypeDef[CRYPTO_QDATA_SIZE_IN_32BIT_WORDS] |
typedef uint32_t | CRYPTO_Data260_TypeDef[CRYPTO_DATA260_SIZE_IN_32BIT_WORDS] |
typedef uint32_t | CRYPTO_KeyBuf_TypeDef[CRYPTO_KEYBUF_SIZE_IN_32BIT_WORDS] |
typedef uint8_t | CRYPTO_InstructionSequence_TypeDef[CRYPTO_MAX_SEQUENCE_INSTRUCTIONS] |
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] |
typedef void(* | CRYPTO_AES_CtrFuncPtr_TypeDef) (uint8_t *ctr) |
AES counter modification function pointer. More... | |
Enumerations | |
enum | CRYPTO_DataReg_TypeDef { cryptoRegDATA0 = (uint32_t) &CRYPTO->DATA0, cryptoRegDATA1 = (uint32_t) &CRYPTO->DATA1, cryptoRegDATA2 = (uint32_t) &CRYPTO->DATA2, cryptoRegDATA3 = (uint32_t) &CRYPTO->DATA3, cryptoRegDATA0XOR = (uint32_t) &CRYPTO->DATA0XOR } |
enum | CRYPTO_DDataReg_TypeDef { cryptoRegDDATA0 = (uint32_t) &CRYPTO->DDATA0, cryptoRegDDATA1 = (uint32_t) &CRYPTO->DDATA1, cryptoRegDDATA2 = (uint32_t) &CRYPTO->DDATA2, cryptoRegDDATA3 = (uint32_t) &CRYPTO->DDATA3, cryptoRegDDATA4 = (uint32_t) &CRYPTO->DDATA4, cryptoRegDDATA0BIG = (uint32_t) &CRYPTO->DDATA0BIG } |
enum | CRYPTO_QDataReg_TypeDef { cryptoRegQDATA0 = (uint32_t) &CRYPTO->QDATA0, cryptoRegQDATA1 = (uint32_t) &CRYPTO->QDATA1, cryptoRegQDATA1BIG = (uint32_t) &CRYPTO->QDATA1BIG } |
enum | CRYPTO_ModulusType_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 } |
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 } |
Functions | |
void | CRYPTO_ModulusSet (CRYPTO_ModulusType_TypeDef modType) |
Set the modulus type used for wide arithmetic operations. More... | |
__STATIC_INLINE void | CRYPTO_MulOperandWidthSet (CRYPTO_MulOperandWidth_TypeDef mulOperandWidth) |
Set the number of bits in the operands of the MUL instruction. More... | |
__STATIC_INLINE void | CRYPTO_ResultWidthSet (CRYPTO_ResultWidth_TypeDef resultWidth) |
Set the width of the results of the non-modulus instructions. More... | |
__STATIC_INLINE void | CRYPTO_IncWidthSet (CRYPTO_IncWidth_TypeDef incWidth) |
Set the width of the DATA1 increment instruction DATA1INC. More... | |
__STATIC_INLINE void | CRYPTO_BurstToCrypto (volatile uint32_t *reg, const uint32_t *val) |
Write a 128 bit value into a crypto register. More... | |
__STATIC_INLINE void | CRYPTO_BurstFromCrypto (volatile uint32_t *reg, uint32_t *val) |
Read a 128 bit value from a crypto register. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__STATIC_INLINE void | CRYPTO_QDataWrite (CRYPTO_QDataReg_TypeDef qdataReg, CRYPTO_QData_TypeDef val) |
Write 512 bits of data to a QDATAX register in the CRYPTO module. More... | |
__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. More... | |
__STATIC_INLINE void | CRYPTO_KeyBufWrite (CRYPTO_KeyBuf_TypeDef val, CRYPTO_KeyWidth_TypeDef keyWidth) |
Set the key value to be used by the CRYPTO module. More... | |
void | CRYPTO_KeyRead (CRYPTO_KeyBuf_TypeDef val, CRYPTO_KeyWidth_TypeDef keyWidth) |
Read the key value currently used by the CRYPTO module. More... | |
__STATIC_INLINE void | CRYPTO_KeyBuf128Write (const uint32_t *val) |
Quick write 128 bit key to the CRYPTO module. More... | |
__STATIC_INLINE bool | CRYPTO_CarryIsSet (void) |
Quick read access of the Carry bit from arithmetic operations. More... | |
__STATIC_INLINE uint8_t | CRYPTO_DData0_4LSBitsRead (void) |
Quick read access of the 4 LSbits of the DDATA0 register. More... | |
__STATIC_INLINE void | CRYPTO_DData0Read260 (CRYPTO_Data260_TypeDef val) |
Read 260 bits from the DDATA0 register. More... | |
__STATIC_INLINE void | CRYPTO_DData0Write260 (const CRYPTO_Data260_TypeDef val) |
Write 260 bits to the DDATA0 register. More... | |
__STATIC_INLINE bool | CRYPTO_DData1_MSBitRead (void) |
Quick read the MSbit of the DDATA1 register. More... | |
__STATIC_INLINE void | CRYPTO_InstructionSequenceLoad (const CRYPTO_InstructionSequence_TypeDef instructionSequence) |
Load a sequence of instructions to be executed on the current values in the data registers. More... | |
__STATIC_INLINE void | CRYPTO_InstructionSequenceExecute (void) |
Execute the current programmed instruction sequence. More... | |
__STATIC_INLINE bool | CRYPTO_InstructionSequenceDone (void) |
Check whether the execution of an instruction sequence has completed. More... | |
__STATIC_INLINE void | CRYPTO_InstructionSequenceWait (void) |
Wait for completion of the current sequence of instructions. More... | |
__STATIC_INLINE void | CRYPTO_InstructionWait (void) |
Wait for completion of the current command. More... | |
void | CRYPTO_SHA_1 (const uint8_t *msg, uint64_t msgLen, CRYPTO_SHA1_Digest_TypeDef msgDigest) |
Perform a SHA-1 hash operation on a message. More... | |
void | CRYPTO_SHA_256 (const uint8_t *msg, uint64_t msgLen, CRYPTO_SHA256_Digest_TypeDef msgDigest) |
Perform a SHA-256 hash operation on a message. More... | |
void | CRYPTO_Mul (uint32_t *A, int aSize, uint32_t *B, int bSize, uint32_t *R, int rSize) |
Multiply two big integers. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_AES_CTRUpdate32Bit (uint8_t *ctr) |
Update last 32 bits of 128 bit counter, by incrementing with 1. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
void | CRYPTO_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. More... | |
__STATIC_INLINE void | CRYPTO_IntClear (uint32_t flags) |
Clear one or more pending CRYPTO interrupts. More... | |
__STATIC_INLINE void | CRYPTO_IntDisable (uint32_t flags) |
Disable one or more CRYPTO interrupts. More... | |
__STATIC_INLINE void | CRYPTO_IntEnable (uint32_t flags) |
Enable one or more CRYPTO interrupts. More... | |
__STATIC_INLINE uint32_t | CRYPTO_IntGet (void) |
Get pending CRYPTO interrupt flags. More... | |
__STATIC_INLINE uint32_t | CRYPTO_IntGetEnabled (void) |
Get enabled and pending CRYPTO interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More... | |
__STATIC_INLINE void | CRYPTO_IntSet (uint32_t flags) |
Set one or more pending CRYPTO interrupts from SW. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__STATIC_INLINE void | AES_CTRUpdate32Bit (uint8_t *ctr) |
Update last 32 bits of 128 bit counter, by incrementing with 1. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__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. More... | |
__STATIC_INLINE void | cryptoBigintZeroize (uint32_t *words32bits, int num32bitWords) |
Set 32bit word array to zero. More... | |
__STATIC_INLINE void | cryptoBigintIncrement (uint32_t *words32bits, int num32bitWords) |
Increment value of 32bit word array by one. More... | |
static void | CRYPTO_AES_CBCx (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. More... | |
static void | CRYPTO_AES_CFBx (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. More... | |
static void | CRYPTO_AES_CTRx (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. More... | |
static void | CRYPTO_AES_ECBx (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. More... | |
static void | CRYPTO_AES_OFBx (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. More... | |
static void | CRYPTO_AES_ProcessLoop (uint32_t len, CRYPTO_DataReg_TypeDef inReg, uint32_t *in, CRYPTO_DataReg_TypeDef outReg, uint32_t *out) |
Function performs generic AES loop. More... | |
This API is intended for use on Silicon Labs target devices, and provides a thin software interface for the functions of the crypto module, including
The AES APIs include support for AES-128 and AES-256 with block cipher modes:
For the AES APIs Input/output data (plaintext, ciphertext, key etc) are treated as byte arrays, starting with most significant byte. Ie, 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 in order to not break security. Please refer to specific cipher mode theory for details.
References:
The SHA APIs include support for
The SHA-1 implementation is FIPS-180-1 compliant, ref:
The SHA-256 implementation is FIPS-180-2 compliant, ref:
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 in order to implement modular exponentiation. Some RSA implementations use a number representation including arrays of 32bit words of variable size. The user should compile with -D USE_VARIABLE_SIZED_DATA_LOADS in order to load these numbers directly into CRYPTO without converting the number representation.
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:
In multi sequence mode the software starts by loading input data, then 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, there is just one instruction sequence which is loaded initially. The sequence can be setup to run multiple times. The 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 on how to program the instruction sequences please refer to the reference manual of the particular Silicon Labs device.
In order to load input data to the CRYPTO module use any of the following functions:
In order to read output data from the CRYPTO module use any of the following functions:
In order to load an instruction sequence to the CRYPTO module use CRYPTO_InstructionSequenceLoad.
In order to execute the current instruction sequence in the CRYPTO module use CRYPTO_InstructionSequenceExecute.
In order to check whether an instruction sequence has completed use CRYPTO_InstructionSequenceDone.
In order to wait for an instruction sequence to complete use CRYPTO_InstructionSequenceWait.
In order 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.
#define CRYPTO_MAX_SEQUENCE_INSTRUCTIONS (20) |
The max number of crypto instructions in an instruction sequence
Definition at line 423 of file em_crypto.h.
#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 438 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 289 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 296 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 307 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 317 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 323 of file em_crypto.h.
typedef uint8_t CRYPTO_InstructionSequence_TypeDef[CRYPTO_MAX_SEQUENCE_INSTRUCTIONS] |
Instruction sequence type. The user should fill in the desired operations from step1, then step2 etc. 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 432 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 448 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 451 of file em_crypto.h.
typedef void(* CRYPTO_AES_CtrFuncPtr_TypeDef) (uint8_t *ctr) |
[in] | ctr | Counter value to be modified. |
Definition at line 464 of file em_crypto.h.
CRYPTO Data registers. These register 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 330 of file em_crypto.h.
CRYPTO DData (Double Data) registers. These 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 344 of file em_crypto.h.
CRYPTO QData (Quad data) registers. These registers are used to load 512 bit values as input and output data for cryptographic and big integer arithmetic functions of the CRYPTO module.
Enumerator | |
---|---|
cryptoRegQDATA0 |
512 bit QDATA0 register |
cryptoRegQDATA1 |
512 bit QDATA1 register |
cryptoRegQDATA1BIG |
512 bit QDATA1BIG register, big-endian access to QDATA1 |
Definition at line 359 of file em_crypto.h.
CRYPTO modulus types.
Definition at line 367 of file em_crypto.h.
CRYPTO multiplication widths for wide arithmetic operations.
Enumerator | |
---|---|
cryptoMulOperand256Bits |
256 bits operands |
cryptoMulOperand128Bits |
128 bits operands |
cryptoMulOperandModulusBits |
MUL operand width is specified by the modulus type. |
Definition at line 387 of file em_crypto.h.
CRYPTO result widths for MUL operations.
Enumerator | |
---|---|
cryptoResult128Bits |
Multiplication result width is 128 bits |
cryptoResult256Bits |
Multiplication result width is 256 bits |
cryptoResult260Bits |
Multiplication result width is 260 bits |
Definition at line 397 of file em_crypto.h.
CRYPTO result widths for MUL operations.
Enumerator | |
---|---|
cryptoInc1byte |
inc width is 1 byte |
cryptoInc2byte |
inc width is 2 byte |
cryptoInc3byte |
inc width is 3 byte |
cryptoInc4byte |
inc width is 4 byte |
Definition at line 405 of file em_crypto.h.
CRYPTO key width.
Enumerator | |
---|---|
cryptoKey128Bits |
Key width is 128 bits |
cryptoKey256Bits |
Key width is 256 bits |
Definition at line 414 of file em_crypto.h.
void CRYPTO_ModulusSet | ( | CRYPTO_ModulusType_TypeDef | modType | ) |
This function sets the modulus type to be used by the Modulus instructions of the CRYPTO module.
[in] | modType | Modulus type. |
Definition at line 307 of file em_crypto.c.
References _CRYPTO_WAC_MODOP_MASK, _CRYPTO_WAC_MODULUS_MASK, CRYPTO, CRYPTO_WAC_MODOP_BINARY, CRYPTO_WAC_MODOP_REGULAR, cryptoModulusBin128, cryptoModulusBin256, cryptoModulusEccB163, cryptoModulusEccB163KOrder, cryptoModulusEccB163Order, cryptoModulusEccB233, cryptoModulusEccB233KOrder, cryptoModulusEccB233Order, cryptoModulusEccP192, cryptoModulusEccP192Order, cryptoModulusEccP224, cryptoModulusEccP224Order, cryptoModulusEccP256, cryptoModulusEccP256Order, and cryptoModulusGcmBin128.
__STATIC_INLINE void CRYPTO_MulOperandWidthSet | ( | CRYPTO_MulOperandWidth_TypeDef | mulOperandWidth | ) |
This function sets the number of bits to be used in the operands of the MUL instruction.
[in] | mulOperandWidth | Multiplication width in bits. |
Definition at line 492 of file em_crypto.h.
References _CRYPTO_WAC_MULWIDTH_MASK, and CRYPTO.
__STATIC_INLINE void CRYPTO_ResultWidthSet | ( | CRYPTO_ResultWidth_TypeDef | resultWidth | ) |
This function sets the result width of the non-modulus instructions.
[in] | resultWidth | Result width of non-modulus instructions. |
Definition at line 507 of file em_crypto.h.
References _CRYPTO_WAC_RESULTWIDTH_MASK, and CRYPTO.
Referenced by CRYPTO_SHA_1(), and CRYPTO_SHA_256().
__STATIC_INLINE void CRYPTO_IncWidthSet | ( | CRYPTO_IncWidth_TypeDef | incWidth | ) |
This function sets the width of the DATA1 increment instruction CRYPTO_CMD_INSTR_DATA1INC.
[in] | incWidth | incrementation width. |
Definition at line 523 of file em_crypto.h.
References _CRYPTO_CTRL_INCWIDTH_MASK, and CRYPTO.
__STATIC_INLINE void CRYPTO_BurstToCrypto | ( | volatile uint32_t * | reg, |
const uint32_t * | val | ||
) |
[in] | reg | 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 546 of file em_crypto.h.
Referenced by CRYPTO_AES_DecryptKey128(), CRYPTO_AES_DecryptKey256(), CRYPTO_DataWrite(), CRYPTO_DDataWrite(), CRYPTO_KeyBuf128Write(), CRYPTO_KeyBufWrite(), and CRYPTO_QDataWrite().
__STATIC_INLINE void CRYPTO_BurstFromCrypto | ( | volatile uint32_t * | reg, |
uint32_t * | val | ||
) |
[in] | reg | 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 577 of file em_crypto.h.
Referenced by CRYPTO_AES_DecryptKey128(), CRYPTO_AES_DecryptKey256(), CRYPTO_DataRead(), CRYPTO_DDataRead(), CRYPTO_KeyRead(), and CRYPTO_QDataRead().
__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. The data value is typically input to a big integer operation (see crypto instructions).
[in] | dataReg | The 128 bit DATA register. |
[in] | val | Value of the data to write to the DATA register. |
Definition at line 603 of file em_crypto.h.
References CRYPTO_BurstToCrypto().
Referenced by CRYPTO_AES_CBCx(), CRYPTO_AES_CFBx(), CRYPTO_AES_CTRx(), CRYPTO_AES_OFBx(), CRYPTO_AES_ProcessLoop(), and 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. The data value is typically output from a big integer operation (see crypto instructions)
[in] | dataReg | The 128 bit DATA register. |
[out] | val | Location where to store the value in memory. |
Definition at line 621 of file em_crypto.h.
References CRYPTO_BurstFromCrypto().
Referenced by CRYPTO_AES_CTRx(), CRYPTO_AES_ProcessLoop(), and CRYPTO_Mul().
__STATIC_INLINE void CRYPTO_DDataWrite | ( | CRYPTO_DDataReg_TypeDef | ddataReg, |
const CRYPTO_DData_TypeDef | val | ||
) |
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).
[in] | ddataReg | The 256 bit DDATA register. |
[in] | val | Value of the data to write to the DDATA register. |
Definition at line 639 of file em_crypto.h.
References CRYPTO_BurstToCrypto().
Referenced by CRYPTO_DData0Write260(), CRYPTO_KeyBufWrite(), CRYPTO_SHA_1(), and CRYPTO_SHA_256().
__STATIC_INLINE void CRYPTO_DDataRead | ( | CRYPTO_DDataReg_TypeDef | ddataReg, |
CRYPTO_DData_TypeDef | val | ||
) |
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).
[in] | ddataReg | The 256 bit DDATA register. |
[out] | val | Location where to store the value in memory. |
Definition at line 658 of file em_crypto.h.
References CRYPTO_BurstFromCrypto().
Referenced by CRYPTO_DData0Read260(), and CRYPTO_SHA_256().
__STATIC_INLINE void CRYPTO_QDataWrite | ( | CRYPTO_QDataReg_TypeDef | qdataReg, |
CRYPTO_QData_TypeDef | val | ||
) |
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).
[in] | qdataReg | The 512 bits QDATA register. |
[in] | val | Value of the data to write to the QDATA register. |
Definition at line 677 of file em_crypto.h.
References CRYPTO_BurstToCrypto().
Referenced by CRYPTO_SHA_1(), and CRYPTO_SHA_256().
__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. The data value is typically input to a big integer operation (see crypto instructions).
[in] | qdataReg | The 512 bits QDATA register. |
[in] | val | Value of the data to write to the QDATA register. |
Definition at line 698 of file em_crypto.h.
References CRYPTO_BurstFromCrypto().
__STATIC_INLINE void CRYPTO_KeyBufWrite | ( | CRYPTO_KeyBuf_TypeDef | val, |
CRYPTO_KeyWidth_TypeDef | keyWidth | ||
) |
Write 128 or 256 bit key to the KEYBUF register in the crypto module.
[in] | val | Value of the data to write to the KEYBUF register. |
[in] | keyWidth | Key width - 128 or 256 bits |
Definition at line 717 of file em_crypto.h.
References _CRYPTO_CTRL_AES_AES128, _CRYPTO_CTRL_AES_AES256, _CRYPTO_CTRL_AES_SHIFT, BUS_RegBitWrite(), CRYPTO, CRYPTO_BurstToCrypto(), CRYPTO_DDataWrite(), cryptoKey256Bits, and cryptoRegDDATA4.
Referenced by CRYPTO_AES_CBCx(), CRYPTO_AES_CFBx(), CRYPTO_AES_CTRx(), CRYPTO_AES_ECBx(), and CRYPTO_AES_OFBx().
void CRYPTO_KeyRead | ( | CRYPTO_KeyBuf_TypeDef | val, |
CRYPTO_KeyWidth_TypeDef | keyWidth | ||
) |
Read 128 bits or 256 bits from KEY register in the CRYPTO module.
[in] | val | Value of the data to write to the KEYBUF register. |
[in] | keyWidth | Key width - 128 or 256 bits |
Definition at line 354 of file em_crypto.c.
References CRYPTO, CRYPTO_BurstFromCrypto(), and cryptoKey256Bits.
__STATIC_INLINE void CRYPTO_KeyBuf128Write | ( | const uint32_t * | val | ) |
Quick write 128 bit key to the KEYBUF register in the CRYPTO module.
[in] | val | Value of the data to write to the KEYBUF register. |
Definition at line 747 of file em_crypto.h.
References CRYPTO, and CRYPTO_BurstToCrypto().
__STATIC_INLINE bool CRYPTO_CarryIsSet | ( | void | ) |
This function reads the carry bit of the CRYPTO ALU.
Definition at line 762 of file em_crypto.h.
References _CRYPTO_DSTATUS_CARRY_MASK, _CRYPTO_DSTATUS_CARRY_SHIFT, and CRYPTO.
Referenced by CRYPTO_Mul().
__STATIC_INLINE uint8_t CRYPTO_DData0_4LSBitsRead | ( | void | ) |
This function quickly retrieves the 4 least significant bits of the DDATA0 register via the DDATA0LSBS bit field in the DSTATUS register.
Definition at line 779 of file em_crypto.h.
References _CRYPTO_DSTATUS_DDATA0LSBS_MASK, _CRYPTO_DSTATUS_DDATA0LSBS_SHIFT, and CRYPTO.
__STATIC_INLINE void CRYPTO_DData0Read260 | ( | CRYPTO_Data260_TypeDef | val | ) |
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);
[out] | val | Location where to store the value in memory. |
Definition at line 797 of file em_crypto.h.
References _CRYPTO_DSTATUS_DDATA0MSBS_MASK, _CRYPTO_DSTATUS_DDATA0MSBS_SHIFT, CRYPTO, CRYPTO_DDataRead(), and cryptoRegDDATA0.
__STATIC_INLINE void CRYPTO_DData0Write260 | ( | const CRYPTO_Data260_TypeDef | val | ) |
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);
[out] | val | Location where of the value in memory. |
Definition at line 816 of file em_crypto.h.
References _CRYPTO_DDATA0BYTE32_DDATA0BYTE32_MASK, CRYPTO, CRYPTO_DDataWrite(), and cryptoRegDDATA0.
__STATIC_INLINE bool CRYPTO_DData1_MSBitRead | ( | void | ) |
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.
Definition at line 835 of file em_crypto.h.
References _CRYPTO_DSTATUS_DDATA1MSB_MASK, _CRYPTO_DSTATUS_DDATA1MSB_SHIFT, and CRYPTO.
__STATIC_INLINE void CRYPTO_InstructionSequenceLoad | ( | const CRYPTO_InstructionSequence_TypeDef | instructionSequence | ) |
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.
[in] | instructionSequence | Instruction sequence to load. |
Definition at line 853 of file em_crypto.h.
References CRYPTO.
__STATIC_INLINE void CRYPTO_InstructionSequenceExecute | ( | void | ) |
This function starts the execution of the current instruction sequence in the CRYPTO module.
Definition at line 872 of file em_crypto.h.
References CRYPTO, and CRYPTO_CMD_SEQSTART.
Referenced by CRYPTO_Mul().
__STATIC_INLINE bool CRYPTO_InstructionSequenceDone | ( | void | ) |
This function checks whether an instruction sequence has completed.
Definition at line 888 of file em_crypto.h.
References CRYPTO, CRYPTO_STATUS_INSTRRUNNING, and CRYPTO_STATUS_SEQRUNNING.
Referenced by CRYPTO_InstructionSequenceWait().
__STATIC_INLINE void CRYPTO_InstructionSequenceWait | ( | void | ) |
This function "busy"-waits until the execution of the ongoing instruction sequence has completed.
Definition at line 903 of file em_crypto.h.
References CRYPTO_InstructionSequenceDone().
__STATIC_INLINE void CRYPTO_InstructionWait | ( | void | ) |
This function "busy"-waits until the execution of the ongoing instruction has completed.
Definition at line 917 of file em_crypto.h.
References CRYPTO, and CRYPTO_IF_INSTRDONE.
void CRYPTO_SHA_1 | ( | const uint8_t * | msg, |
uint64_t | msgLen, | ||
CRYPTO_SHA1_Digest_TypeDef | msgDigest | ||
) |
This function performs a SHA-1 hash operation on the message specified by msg with length msgLen, and returns the message digest in msgDigest.
[in] | msg | Message to hash. |
[in] | msgLen | Length of message in bytes. |
[out] | msgDigest | Message digest. |
Definition at line 378 of file em_crypto.c.
References CRYPTO, CRYPTO_CMD_INSTR_DDATA0TODDATA1, CRYPTO_CMD_INSTR_DDATA1TODDATA0, CRYPTO_CMD_INSTR_MADD32, CRYPTO_CMD_INSTR_SELDDATA0DDATA1, CRYPTO_CMD_INSTR_SHA, CRYPTO_CTRL_SHA_SHA1, CRYPTO_DDataWrite(), CRYPTO_QDataWrite(), CRYPTO_ResultWidthSet(), cryptoRegDDATA1, cryptoRegQDATA1BIG, and cryptoResult256Bits.
void CRYPTO_SHA_256 | ( | const uint8_t * | msg, |
uint64_t | msgLen, | ||
CRYPTO_SHA256_Digest_TypeDef | msgDigest | ||
) |
This function performs a SHA-256 hash operation on the message specified by msg with length msgLen, and returns the message digest in msgDigest.
[in] | msg | Message to hash. |
[in] | msgLen | Length of message in bytes. |
[out] | msgDigest | Message digest. |
Definition at line 495 of file em_crypto.c.
References CRYPTO, CRYPTO_CMD_INSTR_DDATA0TODDATA1, CRYPTO_CMD_INSTR_DDATA1TODDATA0, CRYPTO_CMD_INSTR_MADD32, CRYPTO_CMD_INSTR_SELDDATA0DDATA1, CRYPTO_CMD_INSTR_SHA, CRYPTO_CTRL_SHA_SHA2, CRYPTO_DDataRead(), CRYPTO_DDataWrite(), CRYPTO_QDataWrite(), CRYPTO_ResultWidthSet(), cryptoRegDDATA0BIG, cryptoRegDDATA1, cryptoRegQDATA1BIG, and cryptoResult256Bits.
void CRYPTO_Mul | ( | uint32_t * | A, |
int | aSize, | ||
uint32_t * | B, | ||
int | bSize, | ||
uint32_t * | R, | ||
int | rSize | ||
) |
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.
[in] | A | operand A |
[in] | aSize | size of operand A in bits |
[in] | B | operand B |
[in] | bSize | size of operand B in bits |
[out] | R | result of multiplication |
[in] | rSize | size of result buffer R in bits |
Definition at line 641 of file em_crypto.c.
References CRYPTO, CRYPTO_CarryIsSet(), CRYPTO_CMD_INSTR_ADDIC, CRYPTO_CMD_INSTR_CCLR, CRYPTO_CMD_INSTR_CLR, CRYPTO_CMD_INSTR_DATA1TODATA0, CRYPTO_CMD_INSTR_DATATODMA0, CRYPTO_CMD_INSTR_DDATA0TODDATA2, CRYPTO_CMD_INSTR_DDATA2TODDATA1, CRYPTO_CMD_INSTR_DMA0TODATA, CRYPTO_CMD_INSTR_DMA1TODATA, CRYPTO_CMD_INSTR_MULO, CRYPTO_CMD_INSTR_SELDDATA0DDATA2, CRYPTO_CMD_INSTR_SELDDATA1DDATA3, CRYPTO_CMD_INSTR_SELDDATA2DDATA3, CRYPTO_CTRL_DMA0MODE_FULL, CRYPTO_CTRL_DMA0RSEL_DATA0, CRYPTO_CTRL_DMA1MODE_FULL, CRYPTO_CTRL_DMA1RSEL_DATA1, CRYPTO_DataRead(), CRYPTO_DataWrite(), CRYPTO_InstructionSequenceExecute(), CRYPTO_SEQCTRL_BLOCKSIZE_16BYTES, CRYPTO_WAC_MULWIDTH_MUL128, CRYPTO_WAC_RESULTWIDTH_256BIT, cryptoBigintIncrement(), cryptoBigintZeroize(), cryptoRegDATA0, cryptoRegDATA1, and cryptoRegDATA2.
void CRYPTO_AES_CBC128 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
const uint8_t * | iv, | ||
bool | encrypt | ||
) |
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 *
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | key | When doing encryption, this is the 128 bit encryption key. When doing decryption, 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 879 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_CBCx(), CRYPTO_CTRL_AES_AES128, and cryptoKey128Bits.
Referenced by AES_CBC128().
void CRYPTO_AES_CBC256 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
const uint8_t * | iv, | ||
bool | encrypt | ||
) |
Please see CRYPTO_AES_CBC128() for CBC figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | key | When doing encryption, this is the 256 bit encryption key. When doing decryption, 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 921 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_CBCx(), CRYPTO_CTRL_AES_AES256, and cryptoKey256Bits.
Referenced by AES_CBC256().
void CRYPTO_AES_CFB128 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
const uint8_t * | iv, | ||
bool | encrypt | ||
) |
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 *
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 990 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_CFBx(), CRYPTO_CTRL_AES_AES128, and cryptoKey128Bits.
Referenced by AES_CFB128().
void CRYPTO_AES_CFB256 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
const uint8_t * | iv, | ||
bool | encrypt | ||
) |
Please see CRYPTO_AES_CFB128() for CFB figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 1029 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_CFBx(), CRYPTO_CTRL_AES_AES256, and cryptoKey256Bits.
Referenced by AES_CFB256().
void CRYPTO_AES_CTR128 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
uint8_t * | ctr, | ||
CRYPTO_AES_CtrFuncPtr_TypeDef | ctrFunc | ||
) |
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 *
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 | 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 1101 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_CTRx(), CRYPTO_CTRL_AES_AES128, and cryptoKey128Bits.
Referenced by AES_CTR128().
void CRYPTO_AES_CTR256 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
uint8_t * | ctr, | ||
CRYPTO_AES_CtrFuncPtr_TypeDef | ctrFunc | ||
) |
Please see CRYPTO_AES_CTR128() for CTR figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 | 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 1143 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_CTRx(), CRYPTO_CTRL_AES_AES256, and cryptoKey256Bits.
Referenced by AES_CTR256().
void CRYPTO_AES_CTRUpdate32Bit | ( | uint8_t * | ctr | ) |
Notice that no special consideration is given to possible wrap around. If 32 least significant bits are 0xFFFFFFFF, they will be updated to 0x00000000, ignoring overflow.
Please refer to general comments on layout and byte ordering of parameters.
[in,out] | ctr | Buffer holding 128 bit counter to be updated. |
Definition at line 1168 of file em_crypto.c.
Referenced by AES_CTRUpdate32Bit().
void CRYPTO_AES_DecryptKey128 | ( | uint8_t * | out, |
const uint8_t * | in | ||
) |
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | 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 | Buffer holding 128 bit encryption key. Must be at least 16 bytes long. |
Definition at line 1190 of file em_crypto.c.
References CRYPTO, CRYPTO_BurstFromCrypto(), CRYPTO_BurstToCrypto(), CRYPTO_CMD_INSTR_AESENC, CRYPTO_CTRL_AES_AES128, CRYPTO_IF_INSTRDONE, and CRYPTO_IntClear().
Referenced by AES_DecryptKey128().
void CRYPTO_AES_DecryptKey256 | ( | uint8_t * | out, |
const uint8_t * | in | ||
) |
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | 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 | Buffer holding 256 bit encryption key. Must be at least 32 bytes long. |
Definition at line 1222 of file em_crypto.c.
References CRYPTO, CRYPTO_BurstFromCrypto(), CRYPTO_BurstToCrypto(), CRYPTO_CMD_INSTR_AESENC, and CRYPTO_CTRL_AES_AES256.
Referenced by AES_DecryptKey256().
void CRYPTO_AES_ECB128 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
bool | encrypt | ||
) |
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 *
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | key | When doing encryption, this is the 128 bit encryption key. When doing decryption, 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 1292 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_ECBx(), CRYPTO_CTRL_AES_AES128, and cryptoKey128Bits.
Referenced by AES_ECB128().
void CRYPTO_AES_ECB256 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
bool | encrypt | ||
) |
Please see CRYPTO_AES_ECB128() for ECB figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | key | When doing encryption, this is the 256 bit encryption key. When doing decryption, 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 1330 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_ECBx(), CRYPTO_CTRL_AES_AES256, and cryptoKey256Bits.
Referenced by AES_ECB256().
void CRYPTO_AES_OFB128 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
const uint8_t * | iv | ||
) |
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 *
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 1397 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_OFBx(), CRYPTO_CTRL_AES_AES128, and cryptoKey128Bits.
Referenced by AES_OFB128().
void CRYPTO_AES_OFB256 | ( | uint8_t * | out, |
const uint8_t * | in, | ||
unsigned int | len, | ||
const uint8_t * | key, | ||
const uint8_t * | iv | ||
) |
Please see CRYPTO_AES_OFB128() for OFB figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 1432 of file em_crypto.c.
References CRYPTO, CRYPTO_AES_OFBx(), CRYPTO_CTRL_AES_AES256, and cryptoKey256Bits.
Referenced by AES_OFB256().
__STATIC_INLINE void CRYPTO_IntClear | ( | uint32_t | flags | ) |
[in] | flags | 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 1015 of file em_crypto.h.
References CRYPTO.
Referenced by CRYPTO_AES_DecryptKey128().
__STATIC_INLINE void CRYPTO_IntDisable | ( | uint32_t | flags | ) |
[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 1028 of file em_crypto.h.
References CRYPTO.
__STATIC_INLINE void CRYPTO_IntEnable | ( | uint32_t | flags | ) |
[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 1046 of file em_crypto.h.
References CRYPTO.
__STATIC_INLINE uint32_t CRYPTO_IntGet | ( | void | ) |
Definition at line 1062 of file em_crypto.h.
References CRYPTO.
__STATIC_INLINE uint32_t CRYPTO_IntGetEnabled | ( | void | ) |
Definition at line 1081 of file em_crypto.h.
References CRYPTO.
__STATIC_INLINE void CRYPTO_IntSet | ( | uint32_t | flags | ) |
[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 1094 of file em_crypto.h.
References CRYPTO.
__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 | ||
) |
Definition at line 1113 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 | ||
) |
Definition at line 1132 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 | ||
) |
Definition at line 1150 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 | ||
) |
Definition at line 1168 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 | ||
) |
Definition at line 1186 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 | ||
) |
Definition at line 1204 of file em_crypto.h.
References CRYPTO_AES_CTR256().
__STATIC_INLINE void AES_CTRUpdate32Bit | ( | uint8_t * | ctr | ) |
Definition at line 1222 of file em_crypto.h.
References CRYPTO_AES_CTRUpdate32Bit().
__STATIC_INLINE void AES_DecryptKey128 | ( | uint8_t * | out, |
const uint8_t * | in | ||
) |
Definition at line 1236 of file em_crypto.h.
References CRYPTO_AES_DecryptKey128().
__STATIC_INLINE void AES_DecryptKey256 | ( | uint8_t * | out, |
const uint8_t * | in | ||
) |
Definition at line 1250 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 | ||
) |
Definition at line 1264 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 | ||
) |
Definition at line 1282 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 | ||
) |
Definition at line 1299 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 | ||
) |
Definition at line 1316 of file em_crypto.h.
References CRYPTO_AES_OFB256().
__STATIC_INLINE void cryptoBigintZeroize | ( | uint32_t * | words32bits, |
int | num32bitWords | ||
) |
[in] | words32bits | Pointer to 32bit word array |
[in] | num32bitWords | Number of 32bit words in array |
Definition at line 600 of file em_crypto.c.
Referenced by CRYPTO_Mul().
__STATIC_INLINE void cryptoBigintIncrement | ( | uint32_t * | words32bits, |
int | num32bitWords | ||
) |
[in] | words32bits | Pointer to 32bit word array |
[in] | num32bitWords | Number of 32bit words in array |
Definition at line 614 of file em_crypto.c.
Referenced by CRYPTO_Mul().
|
static |
Please see CRYPTO_AES_CBC128() for CBC figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | key | When doing encryption, this is the 256 bit encryption key. When doing decryption, 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 1479 of file em_crypto.c.
References _CRYPTO_SEQ0_INSTR0_SHIFT, _CRYPTO_SEQ0_INSTR1_SHIFT, _CRYPTO_SEQ0_INSTR2_SHIFT, _CRYPTO_SEQ0_INSTR3_SHIFT, CRYPTO, CRYPTO_AES_ProcessLoop(), CRYPTO_CMD_INSTR_AESDEC, CRYPTO_CMD_INSTR_AESENC, CRYPTO_CMD_INSTR_DATA1TODATA0, CRYPTO_CMD_INSTR_DATA1TODATA0XOR, CRYPTO_CMD_INSTR_DATA1TODATA2, CRYPTO_CMD_INSTR_DATA2TODATA0XOR, CRYPTO_DataWrite(), CRYPTO_KeyBufWrite(), cryptoRegDATA0, cryptoRegDATA1, and cryptoRegDATA2.
Referenced by CRYPTO_AES_CBC128(), and CRYPTO_AES_CBC256().
|
static |
Please see CRYPTO_AES_CFB128() for CFB figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 1559 of file em_crypto.c.
References _CRYPTO_SEQ0_INSTR0_SHIFT, _CRYPTO_SEQ0_INSTR1_SHIFT, _CRYPTO_SEQ0_INSTR2_SHIFT, _CRYPTO_SEQ0_INSTR3_SHIFT, CRYPTO, CRYPTO_AES_ProcessLoop(), CRYPTO_CMD_INSTR_AESENC, CRYPTO_CMD_INSTR_DATA1TODATA0XOR, CRYPTO_CMD_INSTR_DATA1TODATA2, CRYPTO_CMD_INSTR_DATA2TODATA0, CRYPTO_DataWrite(), CRYPTO_KeyBufWrite(), cryptoRegDATA0, cryptoRegDATA1, and cryptoRegDATA2.
Referenced by CRYPTO_AES_CFB128(), and CRYPTO_AES_CFB256().
|
static |
Please see CRYPTO_AES_CTR128() for CTR figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 | 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. |
[in] | keyWidth | Set to cryptoKey128Bits or cryptoKey256Bits. |
Definition at line 1643 of file em_crypto.c.
References _CRYPTO_SEQ0_INSTR0_SHIFT, _CRYPTO_SEQ0_INSTR1_SHIFT, _CRYPTO_SEQ0_INSTR2_SHIFT, _CRYPTO_SEQ0_INSTR3_SHIFT, _CRYPTO_SEQ1_INSTR4_SHIFT, CRYPTO, CRYPTO_AES_ProcessLoop(), CRYPTO_CMD_INSTR_AESENC, CRYPTO_CMD_INSTR_DATA0TODATA3, CRYPTO_CMD_INSTR_DATA1INC, CRYPTO_CMD_INSTR_DATA1TODATA0, CRYPTO_CMD_INSTR_DATA2TODATA0XOR, CRYPTO_CTRL_INCWIDTH_INCWIDTH4, CRYPTO_DataRead(), CRYPTO_DataWrite(), CRYPTO_KeyBufWrite(), cryptoRegDATA0, cryptoRegDATA1, and cryptoRegDATA2.
Referenced by CRYPTO_AES_CTR128(), and CRYPTO_AES_CTR256().
|
static |
Please see CRYPTO_AES_ECB128() for ECB figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | key | When doing encryption, this is the 256 bit encryption key. When doing decryption, 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 1707 of file em_crypto.c.
References _CRYPTO_SEQ0_INSTR0_SHIFT, _CRYPTO_SEQ0_INSTR1_SHIFT, CRYPTO, CRYPTO_AES_ProcessLoop(), CRYPTO_CMD_INSTR_AESDEC, CRYPTO_CMD_INSTR_AESENC, CRYPTO_CMD_INSTR_DATA0TODATA1, CRYPTO_KeyBufWrite(), cryptoRegDATA0, and cryptoRegDATA1.
Referenced by CRYPTO_AES_ECB128(), and CRYPTO_AES_ECB256().
|
static |
Please see CRYPTO_AES_OFB128() for OFB figure.
Please refer to general comments on layout and byte ordering of parameters.
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | len | 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 1766 of file em_crypto.c.
References _CRYPTO_SEQ0_INSTR0_SHIFT, _CRYPTO_SEQ0_INSTR1_SHIFT, _CRYPTO_SEQ0_INSTR2_SHIFT, _CRYPTO_SEQ0_INSTR3_SHIFT, _CRYPTO_SEQ1_INSTR4_SHIFT, _CRYPTO_SEQ1_INSTR5_SHIFT, CRYPTO, CRYPTO_AES_ProcessLoop(), CRYPTO_CMD_INSTR_AESENC, CRYPTO_CMD_INSTR_DATA0TODATA1, CRYPTO_CMD_INSTR_DATA0TODATA2, CRYPTO_CMD_INSTR_DATA1TODATA0XOR, CRYPTO_CMD_INSTR_DATA2TODATA0, CRYPTO_DataWrite(), CRYPTO_KeyBufWrite(), cryptoRegDATA0, cryptoRegDATA1, and cryptoRegDATA2.
Referenced by CRYPTO_AES_OFB128(), and CRYPTO_AES_OFB256().
|
inlinestatic |
Function loads given register with provided input data. Triggers CRYPTO to perform sequence of instructions and read specified output register to output buffer.
[in] | len | Number of bytes to encrypt/decrypt. Must be a multiple of 16. |
[in] | inReg | Input register - one of DATA0,DATA1,DATA2,DATA3 |
[in] | in | Buffer holding data to encrypt/decrypt. Must be at least len long. |
[in] | outReg | Output register - one of DATA0,DATA1,DATA2,DATA3 |
[out] | out | Buffer to place encrypted/decrypted data. Must be at least len long. It may be set equal to in , in which case the input buffer is overwritten. |
Definition at line 1820 of file em_crypto.c.
References _CRYPTO_SEQCTRL_LENGTHA_SHIFT, CRYPTO, CRYPTO_CMD_SEQSTART, CRYPTO_DataRead(), and CRYPTO_DataWrite().
Referenced by CRYPTO_AES_CBCx(), CRYPTO_AES_CFBx(), CRYPTO_AES_CTRx(), CRYPTO_AES_ECBx(), and CRYPTO_AES_OFBx().