uECC_HashContext => const uECC_HashContext

This is an important piece of "documentation" as it indicates to the
caller that a uECC_HashContext can be initialized and subsequently
used multiple times (for multiple signatures).
This commit is contained in:
Andrew Ruder
2015-12-23 15:42:14 -06:00
parent 0d853de6d1
commit 451d53a62e
3 changed files with 14 additions and 12 deletions
+7 -5
View File
@@ -1231,7 +1231,7 @@ int uECC_sign(const uint8_t *private_key,
/* Compute an HMAC using K as a key (as in RFC 6979). Note that K is always
the same size as the hash result size. */
static void HMAC_init(uECC_HashContext *hash_context, const uint8_t *K) {
static void HMAC_init(const uECC_HashContext *hash_context, const uint8_t *K) {
uint8_t *pad = hash_context->tmp + 2 * hash_context->result_size;
unsigned i;
for (i = 0; i < hash_context->result_size; ++i)
@@ -1243,13 +1243,15 @@ static void HMAC_init(uECC_HashContext *hash_context, const uint8_t *K) {
hash_context->update_hash(hash_context, pad, hash_context->block_size);
}
static void HMAC_update(uECC_HashContext *hash_context,
static void HMAC_update(const uECC_HashContext *hash_context,
const uint8_t *message,
unsigned message_size) {
hash_context->update_hash(hash_context, message, message_size);
}
static void HMAC_finish(uECC_HashContext *hash_context, const uint8_t *K, uint8_t *result) {
static void HMAC_finish(const uECC_HashContext *hash_context,
const uint8_t *K,
uint8_t *result) {
uint8_t *pad = hash_context->tmp + 2 * hash_context->result_size;
unsigned i;
for (i = 0; i < hash_context->result_size; ++i)
@@ -1266,7 +1268,7 @@ static void HMAC_finish(uECC_HashContext *hash_context, const uint8_t *K, uint8_
}
/* V = HMAC_K(V) */
static void update_V(uECC_HashContext *hash_context, uint8_t *K, uint8_t *V) {
static void update_V(const uECC_HashContext *hash_context, uint8_t *K, uint8_t *V) {
HMAC_init(hash_context, K);
HMAC_update(hash_context, V, hash_context->result_size);
HMAC_finish(hash_context, K, V);
@@ -1281,7 +1283,7 @@ static void update_V(uECC_HashContext *hash_context, uint8_t *K, uint8_t *V) {
int uECC_sign_deterministic(const uint8_t *private_key,
const uint8_t *message_hash,
unsigned hash_size,
uECC_HashContext *hash_context,
const uECC_HashContext *hash_context,
uint8_t *signature,
uECC_Curve curve) {
uint8_t *K = hash_context->tmp;