Add tinycrypt 0.2.8

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/ext/tinycrypt/lib/source/ctr_prng.c b/ext/tinycrypt/lib/source/ctr_prng.c
index bac81d8..cac2cc4 100644
--- a/ext/tinycrypt/lib/source/ctr_prng.c
+++ b/ext/tinycrypt/lib/source/ctr_prng.c
@@ -50,15 +50,12 @@
  *  @param arr IN/OUT -- array to be incremented
  *  @param len IN -- size of arr in bytes
  */
-static void arrInc(uint8_t arr[], uint32_t len)
+static void arrInc(uint8_t arr[], unsigned int len)
 {
-	uint32_t i;
-	if (0 != arr)
-	{
-		for (i = len; i > 0U; i--)
-		{
-			if (++arr[i-1] != 0U)
-			{
+	unsigned int i;
+	if (0 != arr) {
+		for (i = len; i > 0U; i--) {
+			if (++arr[i-1] != 0U) {
 				break;
 			}
 		}
@@ -76,24 +73,21 @@
  */
 static void tc_ctr_prng_update(TCCtrPrng_t * const ctx, uint8_t const * const providedData)
 {
-	if (0 != ctx)
-	{
+	if (0 != ctx) {
 		/* 10.2.1.2 step 1 */
 		uint8_t temp[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE];
-		uint32_t len = 0U;
+		unsigned int len = 0U;
 
 		/* 10.2.1.2 step 2 */
-		while (len < sizeof temp)
-		{
-			uint32_t blocklen = sizeof(temp) - len;
+		while (len < sizeof temp) {
+			unsigned int blocklen = sizeof(temp) - len;
 			uint8_t output_block[TC_AES_BLOCK_SIZE];
 
 			/* 10.2.1.2 step 2.1 */
 			arrInc(ctx->V, sizeof ctx->V);
 
 			/* 10.2.1.2 step 2.2 */
-			if (blocklen > TC_AES_BLOCK_SIZE)
-			{
+			if (blocklen > TC_AES_BLOCK_SIZE) {
 				blocklen = TC_AES_BLOCK_SIZE;
 			}
 			(void)tc_aes_encrypt(output_block, ctx->V, &ctx->key);
@@ -105,11 +99,9 @@
 		}
 
 		/* 10.2.1.2 step 4 */
-		if (0 != providedData)
-		{
-			uint32_t i;
-			for (i = 0U; i < sizeof temp; i++)
-			{
+		if (0 != providedData) {
+			unsigned int i;
+			for (i = 0U; i < sizeof temp; i++) {
 				temp[i] ^= providedData[i];
 			}
 		}
@@ -122,24 +114,22 @@
 	}
 }
 
-int32_t tc_ctr_prng_init(TCCtrPrng_t * const ctx, 
-			uint8_t const * const entropy,
-			uint32_t entropyLen, 
-			uint8_t const * const personalization,
-			uint32_t pLen)
+int tc_ctr_prng_init(TCCtrPrng_t * const ctx, 
+		     uint8_t const * const entropy,
+		     unsigned int entropyLen, 
+		     uint8_t const * const personalization,
+		     unsigned int pLen)
 {
-	int32_t result = TC_CRYPTO_FAIL;	
-	uint32_t i;
+	int result = TC_CRYPTO_FAIL;	
+	unsigned int i;
 	uint8_t personalization_buf[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE] = {0U};
 	uint8_t seed_material[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE];
 	uint8_t zeroArr[TC_AES_BLOCK_SIZE] = {0U};
   
-	if (0 != personalization)
-	{
+	if (0 != personalization) {
 		/* 10.2.1.3.1 step 1 */
-		uint32_t len = pLen;
-		if (len > sizeof personalization_buf)
-		{
+		unsigned int len = pLen;
+		if (len > sizeof personalization_buf) {
 			len = sizeof personalization_buf;
 		}
 
@@ -147,12 +137,10 @@
 		memcpy(personalization_buf, personalization, len);
 	}
 
-	if ((0 != ctx) && (0 != entropy) && (entropyLen >= sizeof seed_material))
-	{
+	if ((0 != ctx) && (0 != entropy) && (entropyLen >= sizeof seed_material)) {
 		/* 10.2.1.3.1 step 3 */
 		memcpy(seed_material, entropy, sizeof seed_material);
-		for (i = 0U; i < sizeof seed_material; i++)
-		{
+		for (i = 0U; i < sizeof seed_material; i++) {
 			seed_material[i] ^= personalization_buf[i];
 		}
 
@@ -173,23 +161,21 @@
 	return result;
 }
 
-int32_t tc_ctr_prng_reseed(TCCtrPrng_t * const ctx, 
+int tc_ctr_prng_reseed(TCCtrPrng_t * const ctx, 
 			uint8_t const * const entropy,
-			uint32_t entropyLen,
+			unsigned int entropyLen,
 			uint8_t const * const additional_input,
-			uint32_t additionallen)
+			unsigned int additionallen)
 {
-	uint32_t i;
-	int32_t result = TC_CRYPTO_FAIL;
+	unsigned int i;
+	int result = TC_CRYPTO_FAIL;
 	uint8_t additional_input_buf[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE] = {0U};
 	uint8_t seed_material[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE];
 
-	if (0 != additional_input)
-	{
+	if (0 != additional_input) {
 		/* 10.2.1.4.1 step 1 */
-		uint32_t len = additionallen;
-		if (len > sizeof additional_input_buf)
-		{
+		unsigned int len = additionallen;
+		if (len > sizeof additional_input_buf) {
 			len = sizeof additional_input_buf;
 		}
 
@@ -197,13 +183,11 @@
 		memcpy(additional_input_buf, additional_input, len);
 	}
 	
-	uint32_t seedlen = (uint32_t)TC_AES_KEY_SIZE + (uint32_t)TC_AES_BLOCK_SIZE;
-	if ((0 != ctx) && (entropyLen >= seedlen))
-	{
+	unsigned int seedlen = (unsigned int)TC_AES_KEY_SIZE + (unsigned int)TC_AES_BLOCK_SIZE;
+	if ((0 != ctx) && (entropyLen >= seedlen)) {
 		/* 10.2.1.4.1 step 3 */
 		memcpy(seed_material, entropy, sizeof seed_material);
-		for (i = 0U; i < sizeof seed_material; i++)
-		{
+		for (i = 0U; i < sizeof seed_material; i++) {
 			seed_material[i] ^= additional_input_buf[i];
 		}
 
@@ -218,36 +202,30 @@
 	return result;
 }
 
-int32_t tc_ctr_prng_generate(TCCtrPrng_t * const ctx,
+int tc_ctr_prng_generate(TCCtrPrng_t * const ctx,
 			uint8_t const * const additional_input,
-			uint32_t additionallen,
+			unsigned int additionallen,
 			uint8_t * const out,
-			uint32_t outlen)
+			unsigned int outlen)
 {
 	/* 2^48 - see section 10.2.1 */
 	static const uint64_t MAX_REQS_BEFORE_RESEED = 0x1000000000000ULL; 
 
 	/* 2^19 bits - see section 10.2.1 */ 
-	static const uint32_t MAX_BYTES_PER_REQ = 65536U; 
+	static const unsigned int MAX_BYTES_PER_REQ = 65536U; 
 
-	int32_t result = TC_CRYPTO_FAIL;
+	unsigned int result = TC_CRYPTO_FAIL;
 
-	if ((0 != ctx) && (0 != out) && (outlen < MAX_BYTES_PER_REQ))
-	{
+	if ((0 != ctx) && (0 != out) && (outlen < MAX_BYTES_PER_REQ)) {
 		/* 10.2.1.5.1 step 1 */
-		if (ctx->reseedCount > MAX_REQS_BEFORE_RESEED)
-		{
+		if (ctx->reseedCount > MAX_REQS_BEFORE_RESEED) {
 			result = TC_CTR_PRNG_RESEED_REQ;
-		}
-		else
-		{
+		} else {
 			uint8_t additional_input_buf[TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE] = {0U};
-			if (0 != additional_input)
-			{
+			if (0 != additional_input) {
 				/* 10.2.1.5.1 step 2  */
-				uint32_t len = additionallen;
-				if (len > sizeof additional_input_buf)
-				{
+				unsigned int len = additionallen;
+				if (len > sizeof additional_input_buf) {
 					len = sizeof additional_input_buf;
 				}
 				memcpy(additional_input_buf, additional_input, len);
@@ -257,10 +235,9 @@
 			/* 10.2.1.5.1 step 3 - implicit */
 
 			/* 10.2.1.5.1 step 4 */
-			uint32_t len = 0U;      
-			while (len < outlen)
-			{
-				uint32_t blocklen = outlen - len;
+			unsigned int len = 0U;      
+			while (len < outlen) {
+				unsigned int blocklen = outlen - len;
 				uint8_t output_block[TC_AES_BLOCK_SIZE];
 
 				/* 10.2.1.5.1 step 4.1 */
@@ -270,8 +247,7 @@
 				(void)tc_aes_encrypt(output_block, ctx->V, &ctx->key);
       
 				/* 10.2.1.5.1 step 4.3/step 5 */
-				if (blocklen > TC_AES_BLOCK_SIZE)
-				{
+				if (blocklen > TC_AES_BLOCK_SIZE) {
 					blocklen = TC_AES_BLOCK_SIZE;
 				}
 				memcpy(&(out[len]), output_block, blocklen);
@@ -295,8 +271,7 @@
 
 void tc_ctr_prng_uninstantiate(TCCtrPrng_t * const ctx)
 {
-	if (0 != ctx)
-	{
+	if (0 != ctx) {
 		memset(ctx->key.words, 0x00, sizeof ctx->key.words);
 		memset(ctx->V,         0x00, sizeof ctx->V);
 		ctx->reseedCount = 0U;