Data Structures | |
struct | SHA256_memory_t |
A SHA256_memory_t variable of this type must be allocated before running any SHA256 functions. More... | |
Functions | |
void | AES_ECB_EncryptData (uint8_t *text, uint16_t textLen, uint8_t *aesKey) |
Use a random 128 bit key to encrypt data with the AES. More... | |
void | AES_ECB_DecryptData (uint8_t *text, uint16_t textLen, uint8_t *aesKey) |
Use a random 128 bit key to decrypt data with the AES. More... | |
int8_t | AES_CCM_EncryptData (uint8_t encryptFlag, uint8_t MACLen, uint8_t *nonce, uint8_t *plainText, uint16_t textLen, uint8_t *addDataBuf, uint16_t addBufLen, uint8_t *aesKey, uint8_t *MAC, uint8_t ccmLVal) |
Authenticate and optionally encrypt message plainText. More... | |
int8_t | AES_CCM_DecryptData (uint8_t decryptFlag, uint8_t MACLen, uint8_t *nonce, uint8_t *cipherText, uint16_t textLen, uint8_t *addDataBuf, uint16_t addBufLen, uint8_t *aesKey, uint8_t *MAC, uint8_t ccmLVal) |
Authenticate and optionally decrypt message cipherText. More... | |
uint8_t | AES_CTR_EncryptData (uint8_t *plainText, uint16_t textLen, uint8_t *aesKey, uint8_t *nonce, uint8_t *initVector) |
Encrypt plaintext using the AES key, nonce and initialization vector. More... | |
uint8_t | AES_CTR_DecryptData (uint8_t *cipherText, uint16_t textLen, uint8_t *aesKey, uint8_t *nonce, uint8_t *initVector) |
Decrypt ciphertext using the AES key, nonce and initialization vector. More... | |
void | ECC_initialize (uint32_t *pWorkzone) |
Pass pointer to ECC memory allocation to ECC engine. More... | |
uint8_t | ECC_generateKey (uint32_t *randString, uint32_t *privateKey, uint32_t *publicKey_x, uint32_t *publicKey_y) |
Generate a key. More... | |
uint8_t | ECC_ECDSA_sign (uint32_t *secretKey, uint32_t *text, uint32_t *randString, uint32_t *sign1, uint32_t *sign2) |
Sign data. More... | |
uint8_t | ECC_ECDSA_verify (uint32_t *publicKey_x, uint32_t *publicKey_y, uint32_t *text, uint32_t *sign1, uint32_t *sign2) |
Verify signature. More... | |
uint8_t | ECC_ECDH_computeSharedSecret (uint32_t *privateKey, uint32_t *publicKey_x, uint32_t *publicKey_y, uint32_t *sharedSecret_x, uint32_t *sharedSecret_y) |
Compute the shared secret. More... | |
uint8_t | SHA256_runFullAlgorithm (SHA256_memory_t *memory, uint8_t *pBufIn, uint32_t bufLen, uint8_t *pBufOut) |
Perform SHA256 on the the input data. More... | |
uint8_t | SHA256_initialize (SHA256_memory_t *workZone) |
Intializes the SHA256 engine. More... | |
uint8_t | SHA256_execute (SHA256_memory_t *config, uint8_t *pBufIn, uint32_t bufLen) |
Perform SHA256. More... | |
uint8_t | SHA256_output (SHA256_memory_t *memory, uint8_t *pBufOut) |
Complete the process by passing the modified data back. More... | |
int8_t AES_CCM_DecryptData | ( | uint8_t | decryptFlag, |
uint8_t | MACLen, | ||
uint8_t * | nonce, | ||
uint8_t * | cipherText, | ||
uint16_t | textLen, | ||
uint8_t * | addDataBuf, | ||
uint16_t | addBufLen, | ||
uint8_t * | aesKey, | ||
uint8_t * | MAC, | ||
uint8_t | ccmLVal | ||
) |
Authenticate and optionally decrypt message cipherText.
decryptFlag | Decryption flag.
|
MACLen | Length of MAC in bytes. |
nonce | Pointer to random nonce. Nonce length = 15 - ccmLVal. |
cipherText | Pointer to text to decrypt, input and output. |
textLen | Length of text to decrypt. |
addDataBuf | Pointer to additional data for authentication |
addBufLen | Additional authentication buffer length. |
aesKey | Pointer to the AES key or key expansion buffer. |
MAC | Pointer to 16 byte Message Authentication Code output buffer. |
ccmLVal | CCM L value to be used. Values {2,3}. |
Definition at line 98 of file rom_crypto.c.
int8_t AES_CCM_EncryptData | ( | uint8_t | encryptFlag, |
uint8_t | MACLen, | ||
uint8_t * | nonce, | ||
uint8_t * | plainText, | ||
uint16_t | textLen, | ||
uint8_t * | addDataBuf, | ||
uint16_t | addBufLen, | ||
uint8_t * | aesKey, | ||
uint8_t * | MAC, | ||
uint8_t | ccmLVal | ||
) |
Authenticate and optionally encrypt message plainText.
encryptFlag | Encryption flag.
|
MACLen | Length of MAC in bytes. |
nonce | Pointer to random nonce. Nonce length = 15 - ccmLVal. |
plainText | Pointer to text to encrypt, input and output. |
textLen | Length of text to encrypt. |
addDataBuf | Pointer to additional data for authentication |
addBufLen | Additional authentication buffer length. |
aesKey | Pointer to the AES key or key expansion buffer. |
MAC | Pointer to 16 byte Message Authentication Code output buffer. |
ccmLVal | CCM L value to be used. Values {2,3}. |
Definition at line 85 of file rom_crypto.c.
uint8_t AES_CTR_DecryptData | ( | uint8_t * | cipherText, |
uint16_t | textLen, | ||
uint8_t * | aesKey, | ||
uint8_t * | nonce, | ||
uint8_t * | initVector | ||
) |
Decrypt ciphertext using the AES key, nonce and initialization vector.
cipherText | Pointer to text to decrypt |
textLen | Length of text. |
aesKey | Pointer to 128 bit key used to encrypt text. |
nonce | Pointer to 4 byte nonce. |
initVector | Pointer to 8 byte random initialization vector. |
Definition at line 132 of file rom_crypto.c.
uint8_t AES_CTR_EncryptData | ( | uint8_t * | plainText, |
uint16_t | textLen, | ||
uint8_t * | aesKey, | ||
uint8_t * | nonce, | ||
uint8_t * | initVector | ||
) |
Encrypt plaintext using the AES key, nonce and initialization vector.
plainText | Pointer to text to encrypt. |
textLen | Length of text. |
aesKey | Pointer to 128 bit key used to encrypt text. |
nonce | Pointer to 4 byte nonce. |
initVector | Pointer to 8 byte random initialization vector. |
Definition at line 121 of file rom_crypto.c.
void AES_ECB_DecryptData | ( | uint8_t * | text, |
uint16_t | textLen, | ||
uint8_t * | aesKey | ||
) |
Use a random 128 bit key to decrypt data with the AES.
text | Pointer to data to decrypt. |
textLen | Length of text. |
aesKey | Pointer to 128 bit key used to decrypt. This is the same key that was used to originally encrypt this data. |
Definition at line 65 of file rom_crypto.c.
void AES_ECB_EncryptData | ( | uint8_t * | text, |
uint16_t | textLen, | ||
uint8_t * | aesKey | ||
) |
Use a random 128 bit key to encrypt data with the AES.
text | Pointer to data to encrypt. |
textLen | Length of text. |
aesKey | Pointer to 128 bit key used to encrypt text. |
Definition at line 56 of file rom_crypto.c.
uint8_t ECC_ECDH_computeSharedSecret | ( | uint32_t * | privateKey, |
uint32_t * | publicKey_x, | ||
uint32_t * | publicKey_y, | ||
uint32_t * | sharedSecret_x, | ||
uint32_t * | sharedSecret_y | ||
) |
Compute the shared secret.
privateKey | Pointer to private key, input. |
publicKey_x | Pointer to public key X-coordinate, input. |
publicKey_y | Pointer to public key Y-coordinate, input. |
sharedSecret_x | Pointer to shared secret X-coordinate, output. |
sharedSecret_y | Pointer to shared secret Y-coordinate, output. |
Definition at line 247 of file rom_crypto.c.
uint8_t ECC_ECDSA_sign | ( | uint32_t * | secretKey, |
uint32_t * | text, | ||
uint32_t * | randString, | ||
uint32_t * | sign1, | ||
uint32_t * | sign2 | ||
) |
Sign data.
secretKey | Pointer to the secret key, input. |
text | Pointer to the message, input. |
randString | Pointer to random string, input. |
sign1 | Pointer to signature part 1, output. |
sign2 | Pointer to signature part 2, output. |
Definition at line 225 of file rom_crypto.c.
uint8_t ECC_ECDSA_verify | ( | uint32_t * | publicKey_x, |
uint32_t * | publicKey_y, | ||
uint32_t * | text, | ||
uint32_t * | sign1, | ||
uint32_t * | sign2 | ||
) |
Verify signature.
publicKey_x | Pointer to public key X-coordinate, input. |
publicKey_y | Pointer to public key Y-coordinate, input. |
text | Pointer to message data, input. |
sign1 | Pointer to signature part 1, input. |
sign2 | Pointer to signature part 2, input. |
Definition at line 236 of file rom_crypto.c.
uint8_t ECC_generateKey | ( | uint32_t * | randString, |
uint32_t * | privateKey, | ||
uint32_t * | publicKey_x, | ||
uint32_t * | publicKey_y | ||
) |
Generate a key.
This is used for both ECDH and ECDSA.
randString | Pointer to random string, input. |
privateKey | Pointer to the private key, output. |
publicKey_x | Pointer to public key X-coordinate, output. |
publicKey_y | Pointer to public key Y-coordinate, output. |
Definition at line 213 of file rom_crypto.c.
void ECC_initialize | ( | uint32_t * | pWorkzone | ) |
Pass pointer to ECC memory allocation to ECC engine.
This function can be called again to point the ECC workzone at a different memory buffer.
pWorkzone | Pointer to memory allocated for computations, input. See description at beginning of ECC section for memory requirements. |
Definition at line 167 of file rom_crypto.c.
uint8_t SHA256_execute | ( | SHA256_memory_t * | config, |
uint8_t * | pBufIn, | ||
uint32_t | bufLen | ||
) |
Perform SHA256.
Must call SHA256_output() to receive output from this operation.
config | Pointer to memory for operations, input. |
pBufIn | Pointer to input text, input. |
bufLen | Length of input, input. |
Definition at line 294 of file rom_crypto.c.
uint8_t SHA256_initialize | ( | SHA256_memory_t * | workZone | ) |
Intializes the SHA256 engine.
This function must be called once before all other SHA256 functions other than SHA256_runFullAlgorithm().
workZone | Pointer to memory for operations, input. |
Definition at line 285 of file rom_crypto.c.
uint8_t SHA256_output | ( | SHA256_memory_t * | memory, |
uint8_t * | pBufOut | ||
) |
Complete the process by passing the modified data back.
memory | Pointer to memory for operations, input. |
pBufOut | Pointer to output buffer, output. Buffer must be at least 32 bytes long. |
Definition at line 303 of file rom_crypto.c.
uint8_t SHA256_runFullAlgorithm | ( | SHA256_memory_t * | memory, |
uint8_t * | pBufIn, | ||
uint32_t | bufLen, | ||
uint8_t * | pBufOut | ||
) |
Perform SHA256 on the the input data.
The input and output buffer can point to the same memory. This is the equivalent of calling SHA256_initialize(), SHA256_execute() and SHA256_output() sequentially.
memory | Pointer to memory for operations, input. |
pBufIn | Pointer to input buffer, input. |
bufLen | Length of input. |
pBufOut | Pointer to output buffer, output. |
Definition at line 275 of file rom_crypto.c.
#define ECC_A_COEF_LENGTH_ZERO 0xC5 |
Definition at line 204 of file rom_crypto.h.
#define ECC_A_COEF_TOO_LONG 0x5C |
Definition at line 203 of file rom_crypto.h.
#define ECC_BAD_WINDOW_SIZE 0x66 |
Definition at line 205 of file rom_crypto.h.
#define ECC_DIGEST_LENGTH_ZERO 0x72 |
Definition at line 215 of file rom_crypto.h.
#define ECC_DIGEST_TOO_LONG 0x27 |
Definition at line 214 of file rom_crypto.h.
#define ECC_ECC_KEY_LENGTH_ZERO 0x52 |
Definition at line 213 of file rom_crypto.h.
#define ECC_ECC_KEY_TOO_LONG 0x25 |
Definition at line 212 of file rom_crypto.h.
#define ECC_ECDH_COMMON_KEY_OK ECC_SCALAR_MUL_OK |
Definition at line 226 of file rom_crypto.h.
#define ECC_ECDH_KEYGEN_OK ECC_SCALAR_MUL_OK |
Definition at line 225 of file rom_crypto.h.
#define ECC_ECDSA_INVALID_SIGNATURE 0x5A |
Definition at line 217 of file rom_crypto.h.
#define ECC_ECDSA_KEYGEN_OK ECC_SCALAR_MUL_OK |
Definition at line 224 of file rom_crypto.h.
#define ECC_ECDSA_SIGN_OK 0x32 |
Definition at line 216 of file rom_crypto.h.
#define ECC_ECDSA_VALID_SIGNATURE 0xA5 |
Definition at line 218 of file rom_crypto.h.
#define ECC_MODULUS_EVEN 0xDC |
Definition at line 191 of file rom_crypto.h.
#define ECC_MODULUS_LARGER_THAN_255_WORDS 0xD2 |
Definition at line 192 of file rom_crypto.h.
#define ECC_MODULUS_LENGTH_ZERO 0x08 |
Definition at line 193 of file rom_crypto.h.
#define ECC_MODULUS_MSW_IS_ZERO 0x30 |
Definition at line 194 of file rom_crypto.h.
#define ECC_ORDER_EVEN 0x82 |
Definition at line 210 of file rom_crypto.h.
#define ECC_ORDER_LARGER_THAN_255_WORDS 0x28 |
Definition at line 209 of file rom_crypto.h.
#define ECC_ORDER_LENGTH_ZERO 0x6C |
Definition at line 198 of file rom_crypto.h.
#define ECC_ORDER_MSW_IS_ZERO 0x23 |
Definition at line 211 of file rom_crypto.h.
#define ECC_ORDER_TOO_LONG 0xC6 |
Definition at line 197 of file rom_crypto.h.
#define ECC_PRIME_NIST256_CURVE |
Definition at line 185 of file rom_crypto.h.
#define ECC_SCALAR_LENGTH_ZERO 0x53 |
Definition at line 196 of file rom_crypto.h.
#define ECC_SCALAR_MUL_OK 0x99 |
Definition at line 206 of file rom_crypto.h.
#define ECC_SCALAR_TOO_LONG 0x35 |
Definition at line 195 of file rom_crypto.h.
#define ECC_SIG_P1_LENGTH_ZERO 0x12 |
Definition at line 220 of file rom_crypto.h.
#define ECC_SIG_P1_TOO_LONG 0x11 |
Definition at line 219 of file rom_crypto.h.
#define ECC_SIG_P2_LENGTH_ZERO 0x21 |
Definition at line 222 of file rom_crypto.h.
#define ECC_SIG_P2_TOO_LONG 0x22 |
Definition at line 221 of file rom_crypto.h.
#define ECC_WINDOW_SIZE 3 |
Definition at line 179 of file rom_crypto.h.
Referenced by ECC_initialize().
#define ECC_X_COORD_LENGTH_ZERO 0xC3 |
Definition at line 200 of file rom_crypto.h.
#define ECC_X_COORD_TOO_LONG 0x3C |
Definition at line 199 of file rom_crypto.h.
#define ECC_Y_COORD_LENGTH_ZERO 0x56 |
Definition at line 202 of file rom_crypto.h.
#define ECC_Y_COORD_TOO_LONG 0x65 |
Definition at line 201 of file rom_crypto.h.