Skip to content

Commit

Permalink
Merge pull request #121 from obsidiansystems/jg-replace-blake2b
Browse files Browse the repository at this point in the history
Replace in-app blake2b with firmware blake2b.
  • Loading branch information
jonored authored Nov 26, 2019
2 parents e6ca81e + 7339018 commit d03e108
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 677 deletions.
8 changes: 3 additions & 5 deletions src/apdu_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "apdu.h"
#include "baking_auth.h"
#include "base58.h"
#include "blake2.h"
#include "globals.h"
#include "key_macros.h"
#include "keys.h"
Expand All @@ -25,7 +24,7 @@
static inline void conditional_init_hash_state(blake2b_hash_state_t *const state) {
check_null(state);
if (!state->initialized) {
b2b_init(&state->state, SIGN_HASH_SIZE);
cx_blake2b_init(&state->state, SIGN_HASH_SIZE*8); // cx_blake2b_init takes size in bits.
state->initialized = true;
}
}
Expand All @@ -43,7 +42,7 @@ static void blake2b_incremental_hash(
while (*out_length > B2B_BLOCKBYTES) {
if (current - out > (int)out_size) THROW(EXC_MEMORY_ERROR);
conditional_init_hash_state(state);
b2b_update(&state->state, current, B2B_BLOCKBYTES);
cx_hash((cx_hash_t *) &state->state, 0, current, B2B_BLOCKBYTES, NULL, 0);
*out_length -= B2B_BLOCKBYTES;
current += B2B_BLOCKBYTES;
}
Expand All @@ -64,8 +63,7 @@ static void blake2b_finish_hash(

conditional_init_hash_state(state);
blake2b_incremental_hash(buff, buff_size, buff_length, state);
b2b_update(&state->state, buff, *buff_length);
b2b_final(&state->state, out, out_size);
cx_hash((cx_hash_t *) &state->state, CX_LAST, buff, *buff_length, out, out_size);
}

static int perform_signature(bool const on_hash, bool const send_hash);
Expand Down
166 changes: 0 additions & 166 deletions src/blake2-impl.h

This file was deleted.

154 changes: 0 additions & 154 deletions src/blake2.h

This file was deleted.

Loading

0 comments on commit d03e108

Please sign in to comment.