Add tinycrypt 0.2.8
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/ext/tinycrypt/lib/source/hmac.c b/ext/tinycrypt/lib/source/hmac.c
index e256846..89878ce 100644
--- a/ext/tinycrypt/lib/source/hmac.c
+++ b/ext/tinycrypt/lib/source/hmac.c
@@ -1,7 +1,7 @@
/* hmac.c - TinyCrypt implementation of the HMAC algorithm */
/*
- * Copyright (C) 2015 by Intel Corporation, All Rights Reserved.
+ * Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -34,11 +34,11 @@
#include <tinycrypt/constants.h>
#include <tinycrypt/utils.h>
-static void rekey(uint8_t *key, const uint8_t *new_key, uint32_t key_size)
+static void rekey(uint8_t *key, const uint8_t *new_key, unsigned int key_size)
{
const uint8_t inner_pad = (uint8_t) 0x36;
const uint8_t outer_pad = (uint8_t) 0x5c;
- uint32_t i;
+ unsigned int i;
for (i = 0; i < key_size; ++i) {
key[i] = inner_pad ^ new_key[i];
@@ -49,10 +49,10 @@
}
}
-int32_t tc_hmac_set_key(TCHmacState_t ctx,
- const uint8_t *key,
- uint32_t key_size)
+int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key,
+ unsigned int key_size)
{
+
/* input sanity check: */
if (ctx == (TCHmacState_t) 0 ||
key == (const uint8_t *) 0 ||
@@ -93,25 +93,25 @@
return TC_CRYPTO_SUCCESS;
}
-int32_t tc_hmac_init(TCHmacState_t ctx)
+int tc_hmac_init(TCHmacState_t ctx)
{
+
/* input sanity check: */
if (ctx == (TCHmacState_t) 0) {
return TC_CRYPTO_FAIL;
}
- (void)tc_sha256_init(&ctx->hash_state);
- (void)tc_sha256_update(&ctx->hash_state,
- ctx->key,
- TC_SHA256_BLOCK_SIZE);
+ (void) tc_sha256_init(&ctx->hash_state);
+ (void) tc_sha256_update(&ctx->hash_state, ctx->key, TC_SHA256_BLOCK_SIZE);
return TC_CRYPTO_SUCCESS;
}
-int32_t tc_hmac_update(TCHmacState_t ctx,
- const void *data,
- uint32_t data_length)
+int tc_hmac_update(TCHmacState_t ctx,
+ const void *data,
+ unsigned int data_length)
{
+
/* input sanity check: */
if (ctx == (TCHmacState_t) 0) {
return TC_CRYPTO_FAIL;
@@ -122,8 +122,9 @@
return TC_CRYPTO_SUCCESS;
}
-int32_t tc_hmac_final(uint8_t *tag, uint32_t taglen, TCHmacState_t ctx)
+int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx)
{
+
/* input sanity check: */
if (tag == (uint8_t *) 0 ||
taglen != TC_SHA256_DIGEST_SIZE ||