cipher/chacha20: rename _common to _anycrypt

This commit is contained in:
Lucas Gabriel Vuotto 2024-06-08 13:39:49 +00:00
parent 2a24aa4f70
commit 9c76a90301
1 changed files with 24 additions and 24 deletions

View File

@ -31,7 +31,7 @@
static int static int
chacha20_common_init(void *arg, const void *initparams) chacha20_anycrypt_init(void *arg, const void *initparams)
{ {
const struct lc_chacha20_params *params = initparams; const struct lc_chacha20_params *params = initparams;
struct chacha20_ctx *ctx = arg; struct chacha20_ctx *ctx = arg;
@ -50,7 +50,7 @@ chacha20_common_init(void *arg, const void *initparams)
} }
static int static int
xchacha20_common_init(void *arg, const void *initparams) xchacha20_anycrypt_init(void *arg, const void *initparams)
{ {
const struct lc_xchacha20_params *params = initparams; const struct lc_xchacha20_params *params = initparams;
struct chacha20_ctx *ctx = arg; struct chacha20_ctx *ctx = arg;
@ -83,7 +83,7 @@ xchacha20_common_init(void *arg, const void *initparams)
} }
static int static int
chacha20_common_update(void *arg, uint8_t *out, size_t *outlen, chacha20_anycrypt_update(void *arg, uint8_t *out, size_t *outlen,
const uint8_t *in, size_t inlen) const uint8_t *in, size_t inlen)
{ {
struct chacha20_ctx *ctx = arg; struct chacha20_ctx *ctx = arg;
@ -145,7 +145,7 @@ chacha20_common_update(void *arg, uint8_t *out, size_t *outlen,
} }
static int static int
chacha20_common_final(void *arg, uint8_t *out, size_t *outlen) chacha20_anycrypt_final(void *arg, uint8_t *out, size_t *outlen)
{ {
struct chacha20_ctx *ctx = arg; struct chacha20_ctx *ctx = arg;
size_t i, off; size_t i, off;
@ -178,7 +178,7 @@ chacha20_common_final(void *arg, uint8_t *out, size_t *outlen)
} }
static int static int
chacha20_common(uint8_t *out, size_t *outlen, const void *initparams, chacha20_anycrypt(uint8_t *out, size_t *outlen, const void *initparams,
const uint8_t *in, size_t inlen) const uint8_t *in, size_t inlen)
{ {
struct chacha20_ctx ctx; struct chacha20_ctx ctx;
@ -196,9 +196,9 @@ chacha20_common(uint8_t *out, size_t *outlen, const void *initparams,
return 1; return 1;
} }
rc = chacha20_common_init(&ctx, initparams) && rc = chacha20_anycrypt_init(&ctx, initparams) &&
chacha20_common_update(&ctx, out, &l0, in, inlen) && chacha20_anycrypt_update(&ctx, out, &l0, in, inlen) &&
chacha20_common_final(&ctx, out + l0, &l1); chacha20_anycrypt_final(&ctx, out + l0, &l1);
if (rc) if (rc)
*outlen = l0 + l1; *outlen = l0 + l1;
@ -214,30 +214,30 @@ chacha20_ctx_new(void)
static struct lc_cipher_impl chacha20_impl = { static struct lc_cipher_impl chacha20_impl = {
.encrypt_init = &chacha20_common_init, .encrypt_init = &chacha20_anycrypt_init,
.encrypt_update = &chacha20_common_update, .encrypt_update = &chacha20_anycrypt_update,
.encrypt_final = &chacha20_common_final, .encrypt_final = &chacha20_anycrypt_final,
.encrypt = &chacha20_common, .encrypt = &chacha20_anycrypt,
.decrypt_init = &chacha20_common_init, .decrypt_init = &chacha20_anycrypt_init,
.decrypt_update = &chacha20_common_update, .decrypt_update = &chacha20_anycrypt_update,
.decrypt_final = &chacha20_common_final, .decrypt_final = &chacha20_anycrypt_final,
.decrypt = &chacha20_common, .decrypt = &chacha20_anycrypt,
.ctx_new = &chacha20_ctx_new, .ctx_new = &chacha20_ctx_new,
.ctx_free = NULL, .ctx_free = NULL,
}; };
static struct lc_cipher_impl xchacha20_impl = { static struct lc_cipher_impl xchacha20_impl = {
.encrypt_init = &xchacha20_common_init, .encrypt_init = &xchacha20_anycrypt_init,
.encrypt_update = &chacha20_common_update, .encrypt_update = &chacha20_anycrypt_update,
.encrypt_final = &chacha20_common_final, .encrypt_final = &chacha20_anycrypt_final,
.encrypt = &chacha20_common, .encrypt = &chacha20_anycrypt,
.decrypt_init = &xchacha20_common_init, .decrypt_init = &xchacha20_anycrypt_init,
.decrypt_update = &chacha20_common_update, .decrypt_update = &chacha20_anycrypt_update,
.decrypt_final = &chacha20_common_final, .decrypt_final = &chacha20_anycrypt_final,
.decrypt = &chacha20_common, .decrypt = &chacha20_anycrypt,
.ctx_new = &chacha20_ctx_new, .ctx_new = &chacha20_ctx_new,
.ctx_free = NULL, .ctx_free = NULL,