Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
shalib.h File Reference
SHA256 Library API. More...
Go to the source code of this file.
Data Structures | |
| struct | prf_sec_param_t |
| PRF 256 stucture This structure is used to configure PRF calc operation: secret, label, seed and buffer before call shalib_prf_calc(). More... | |
| struct | sha256_temp_t |
| SHA temporary buffer database for saving current hash operation or resume saved. More... | |
Functions | |
| void | SHALIB_init_sha256 (void) |
| Init SHA registers. | |
| void | SHALIB_push_data_sha256 (const uint8_t *data, uint16_t len) |
| Push data SHALIB. | |
| void | SHALIB_finish_sha256 (uint8_t *buffer, uint8_t len) |
| Finish SHA-256 operation and get result to given buffer by given length. | |
| void | SHALIB_SHA256_HASH (const uint8_t *data_ptr, uint16_t data_len, uint8_t *buffer) |
| Calc SHA-256 by 1 function call. | |
| void | sha_resume_regs (const sha256_temp_t *ptr) |
| Resume old SHA-256 registers. | |
| void | sha_save_regs (sha256_temp_t *ptr) |
| Save SHA-256 registers. | |
| void | SHALIB_init_HMAC (const uint8_t *secret, uint8_t sec_len) |
| Init HMAC256 operation by given security material. | |
| void | SHALIB_finish_HMAC (uint8_t *buffer, uint8_t len) |
| Finish HMAC256 operation and save result in given buffer. | |
| prf_sec_param_t * | shalib_prf_param_get (void) |
| PRF API. | |
| void | shalib_prf_calc (void) |
| Finish PRF256 operation and save result in given buffer. | |
Detailed Description
SHA256 Library API.
SHA256 Library API:
There are two ways to calculate SHA256: 1. Calc by given 1 data and length pointer
- SHALIB_SHA256_HASH(), A function to calculate SHA256 for given data. 2. Calc by different data pointer sequence given separately
- SHALIB_init_sha256(), Init SHA registers
- SHALIB_push_data_sha256(), Give data sectors(s) one by one
- **** Give data
- SHALIB_push_data_sha256(), Give last data sequence
- SHALIB_finish_sha256(), Finish SHA256 by given data to given buffer
SHA256 register resume and save library API:
SHA256 Operation dataflow can come in many different timeslots or packets and between them, the application needs to calculated more SHA256 then SAVE and Resume operation SHA registers is usefully. -sha_resume_regs(), Load SHA registers from old HASH sessions -sha_save_regs(), Save SHA registers from current HASH sessions
HMAC256 process sequence:
1. SHALIB_init_HMAC(), Init HMAC IN process by given security signature material 2. SHALIB_push_data_sha256(), Give data sectors(s) one by one 3. SHALIB_finish_HMAC(), Finish HMAC and save SHA256 hash to given buffer
PRF256 process sequence:
1. shalib_prf_param_get(), Init PRF and get configure structure 2. Set the following parameters to configure structure:
- HMAC security signature pointer and length
- Label text and length
- Seed data and length
- PRF result pointer 3. shalib_prf_calc(), Calc PRF256 HASH
Definition in file shalib.h.
Function Documentation
| void sha_resume_regs | ( | const sha256_temp_t * | ptr ) |
Resume old SHA-256 registers.
- Parameters:
-
ptr A pointer to saved session.
| void sha_save_regs | ( | sha256_temp_t * | ptr ) |
Save SHA-256 registers.
- Parameters:
-
ptr A pointer to buffer.
| void SHALIB_finish_HMAC | ( | uint8_t * | buffer, |
| uint8_t | len | ||
| ) |
Finish HMAC256 operation and save result in given buffer.
- Parameters:
-
buffer A pointer to result buffer. len Length of 32-bit register to save to buffer (8= 256 bit and 4= 128-bit).
| void SHALIB_finish_sha256 | ( | uint8_t * | buffer, |
| uint8_t | len | ||
| ) |
Finish SHA-256 operation and get result to given buffer by given length.
The first `len` words of the SHA-256 are output to buffer.
- Parameters:
-
buffer A pointer to result buffer. len Length of 32-bit register to save to buffer (8= 256 bit and 4= 128-bit).
| void SHALIB_init_HMAC | ( | const uint8_t * | secret, |
| uint8_t | sec_len | ||
| ) |
Init HMAC256 operation by given security material.
- Parameters:
-
secret A pointer to security material. sec_len Length of security material.
| void SHALIB_init_sha256 | ( | void | ) |
Init SHA registers.
| void shalib_prf_calc | ( | void | ) |
Finish PRF256 operation and save result in given buffer.
| prf_sec_param_t* shalib_prf_param_get | ( | void | ) |
PRF API.
Init PRF library and SHA registers. This function returns configure structure where the user needs to set the following items: -Security material and length -Label text and length -Seed data and length -Buffer for 256 Result
- Returns:
- A pointer to PRF configure structure.
| void SHALIB_push_data_sha256 | ( | const uint8_t * | data, |
| uint16_t | len | ||
| ) |
Push data SHALIB.
- Parameters:
-
data A pointer to data. len Length of data.
| void SHALIB_SHA256_HASH | ( | const uint8_t * | data_ptr, |
| uint16_t | data_len, | ||
| uint8_t * | buffer | ||
| ) |
Calc SHA-256 by 1 function call.
- Parameters:
-
data_ptr A pointer to data. data_len Length of data. buffer A pointer to 256-bit buffer!!
Generated on Tue Jul 12 2022 12:29:02 by
1.7.2
