version 1.5, 2014/06/24 01:13:21 |
version 1.6, 2014/07/03 12:42:16 |
|
|
chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL); |
chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL); |
chacha_encrypt_bytes(&ctx->main_ctx, |
chacha_encrypt_bytes(&ctx->main_ctx, |
poly_key, poly_key, sizeof(poly_key)); |
poly_key, poly_key, sizeof(poly_key)); |
/* Set Chacha's block counter to 1 */ |
|
chacha_ivsetup(&ctx->main_ctx, seqbuf, one); |
|
|
|
/* If decrypting, check tag before anything else */ |
/* If decrypting, check tag before anything else */ |
if (!do_encrypt) { |
if (!do_encrypt) { |
|
|
goto out; |
goto out; |
} |
} |
} |
} |
|
|
/* Crypt additional data */ |
/* Crypt additional data */ |
if (aadlen) { |
if (aadlen) { |
chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); |
chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); |
chacha_encrypt_bytes(&ctx->header_ctx, src, dest, aadlen); |
chacha_encrypt_bytes(&ctx->header_ctx, src, dest, aadlen); |
} |
} |
|
|
|
/* Set Chacha's block counter to 1 */ |
|
chacha_ivsetup(&ctx->main_ctx, seqbuf, one); |
chacha_encrypt_bytes(&ctx->main_ctx, src + aadlen, |
chacha_encrypt_bytes(&ctx->main_ctx, src + aadlen, |
dest + aadlen, len); |
dest + aadlen, len); |
|
|