Refactor signing backend (#690)

Cleaned up the AES driver and removed some cppcheck isues
in the process.
This commit is contained in:
Patrick Fallberg
2016-12-25 16:12:40 +01:00
committed by Henrik Ekblad
parent 61e6cecb3f
commit 1040fbebc5
27 changed files with 398 additions and 14004 deletions
+1 -1
View File
@@ -177,7 +177,6 @@ static uint8_t swi_receive_bytes(uint8_t count, uint8_t *buffer)
static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
{
uint8_t count_byte;
uint8_t i;
uint8_t ret_code;
@@ -189,6 +188,7 @@ static uint8_t sha204p_receive_response(uint8_t size, uint8_t *response)
ret_code = swi_receive_bytes(size, response);
if (ret_code == SWI_FUNCTION_RETCODE_SUCCESS || ret_code == SWI_FUNCTION_RETCODE_RX_FAIL) {
uint8_t count_byte;
count_byte = response[SHA204_BUFFER_POS_COUNT];
if ((count_byte < SHA204_RSP_SIZE_MIN) || (count_byte > size)) {
return SHA204_INVALID_SIZE;
+10
View File
@@ -32,6 +32,16 @@ const uint8_t sha256InitState[] PROGMEM = {
0x19,0xcd,0xe0,0x5b // H7
};
Sha256Class::Sha256Class()
{
memset(keyBuffer, 0, BLOCK_LENGTH);
memset(innerHash, 0, HASH_LENGTH);
memset(buffer.b, 0, BLOCK_LENGTH);
memset(state.b, 0, BLOCK_LENGTH);
bufferOffset = 0;
byteCount = 0;
}
void Sha256Class::init(void)
{
memcpy_P(state.b,sha256InitState,32);
+1
View File
@@ -19,6 +19,7 @@ union _state {
class Sha256Class
{
public:
Sha256Class(); // Constructor
void init(void);
void initHmac(const uint8_t* secret, int secretLength);
uint8_t* result(void);