Skip to content

Commit

Permalink
Salsa20: Fix in the nonce and the counter handling to comply with the…
Browse files Browse the repository at this point in the history
… Salsa20 standard
  • Loading branch information
Rafał Fabich committed Apr 25, 2019
1 parent d04dd31 commit df1e413
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/salsa20.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void cf_salsa20_init(cf_salsa20_ctx *ctx, const uint8_t *key, size_t nkey, const
}

memset(ctx->nonce, 0, sizeof ctx->nonce);
memcpy(ctx->nonce + 8, nonce, 8);
memcpy(ctx->nonce, nonce, 8);
ctx->nblock = 0;
ctx->ncounter = 8;
}
Expand All @@ -152,7 +152,7 @@ static void cf_salsa20_next_block(void *vctx, uint8_t *out)
ctx->nonce,
ctx->constant,
out);
incr_le(ctx->nonce, ctx->ncounter);
incr_le(ctx->nonce + 8, ctx->ncounter);
}

void cf_salsa20_cipher(cf_salsa20_ctx *ctx, const uint8_t *input, uint8_t *output, size_t bytes)
Expand Down

0 comments on commit df1e413

Please # to comment.