Skip to content

Commit

Permalink
Tiny src improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
abderraouf-adjal committed Nov 28, 2015
1 parent ee26110 commit d1860ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions SpritzCipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SpritzCipher::SpritzCipher() { }


static void
static inline void
swap(uint8_t *a, uint8_t *b)
{
uint8_t t = *a;
Expand All @@ -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]);
}

Expand All @@ -73,7 +73,7 @@ SpritzCipher::whip(spritz_ctx *ctx)
update(ctx);
update(ctx);
}
ctx->w += 2;
ctx->w = (uint8_t)(ctx->w + 2);
}

void
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SpritzCipher
version=0.2.0
version=0.2.1
author=Abderraouf Adjal <[email protected]>
maintainer=Abderraouf Adjal <[email protected]>
sentence=Spritz cipher library, Secure random bytes generator, Flexible hash & MAC.
Expand Down

0 comments on commit d1860ee

Please sign in to comment.