From d1860ee7e7b028a48140633dedddcf66ffc0285e Mon Sep 17 00:00:00 2001 From: abderraouf-adjal Date: Sat, 28 Nov 2015 16:36:53 +0100 Subject: [PATCH] Tiny src improvements --- SpritzCipher.cpp | 12 +++++------- library.properties | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/SpritzCipher.cpp b/SpritzCipher.cpp index 62a3e80..9666e0b 100644 --- a/SpritzCipher.cpp +++ b/SpritzCipher.cpp @@ -33,7 +33,7 @@ SpritzCipher::SpritzCipher() { } -static void +static inline void swap(uint8_t *a, uint8_t *b) { uint8_t t = *a; @@ -57,9 +57,9 @@ SpritzCipher::stateInit(spritz_ctx *ctx) void SpritzCipher::update(spritz_ctx *ctx) { - ctx->i += ctx->w; - ctx->j = ctx->k + ctx->s[(uint8_t)(ctx->j + ctx->s[ctx->i])]; - ctx->k += ctx->i + ctx->s[ctx->j]; + ctx->i = (uint8_t)(ctx->i + ctx->w); + ctx->j = (uint8_t)(ctx->k + ctx->s[(uint8_t)(ctx->j + ctx->s[ctx->i])]); + ctx->k = (uint8_t)(ctx->k + ctx->i + ctx->s[ctx->j]); swap(&ctx->s[ctx->i], &ctx->s[ctx->j]); } @@ -73,7 +73,7 @@ SpritzCipher::whip(spritz_ctx *ctx) update(ctx); update(ctx); } - ctx->w += 2; + ctx->w = (uint8_t)(ctx->w + 2); } void @@ -205,7 +205,6 @@ void SpritzCipher::setup(spritz_ctx *ctx, const uint8_t *key, uint8_t keyLen) { - uint8_t i; stateInit(ctx); absorbBytes(ctx, key, keyLen); } @@ -216,7 +215,6 @@ SpritzCipher::setupIV(spritz_ctx *ctx, const uint8_t *key, uint8_t keyLen, const uint8_t *nonce, uint8_t nonceLen) { - uint8_t i; setup(ctx, key, keyLen); absorbStop(ctx); absorbBytes(ctx, nonce, nonceLen); diff --git a/library.properties b/library.properties index a56c095..464b841 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SpritzCipher -version=0.2.0 +version=0.2.1 author=Abderraouf Adjal maintainer=Abderraouf Adjal sentence=Spritz cipher library, Secure random bytes generator, Flexible hash & MAC.