Move *_impl to their returning functions

This commit is contained in:
Lucas Gabriel Vuotto 2024-06-16 01:51:00 +00:00
parent 21251045f4
commit 24ef318572
5 changed files with 96 additions and 96 deletions

View File

@ -116,6 +116,9 @@ hmac_auth(uint8_t *out, size_t *outlen, void *initparams, const uint8_t *in,
}
const struct lc_auth_impl *
lc_auth_impl_hmac(void)
{
static struct lc_auth_impl hmac_impl = {
.init = &hmac_init,
.update = &hmac_update,
@ -127,8 +130,5 @@ static struct lc_auth_impl hmac_impl = {
.taglen = 0,
};
const struct lc_auth_impl *
lc_auth_impl_hmac(void)
{
return &hmac_impl;
}

View File

@ -151,6 +151,9 @@ poly1305_auth(uint8_t *out, size_t *outlen, void *initparams,
}
const struct lc_auth_impl *
lc_auth_impl_poly1305(void)
{
static struct lc_auth_impl poly1305_impl = {
.init = &poly1305_init,
.update = &poly1305_update,
@ -162,8 +165,5 @@ static struct lc_auth_impl poly1305_impl = {
.taglen = LC_POLY1305_TAGLEN,
};
const struct lc_auth_impl *
lc_auth_impl_poly1305(void)
{
return &poly1305_impl;
}

View File

@ -240,6 +240,9 @@ xchacha20_anycrypt(uint8_t *out, size_t *outlen, void *initparams,
}
const struct lc_cipher_impl *
lc_cipher_impl_chacha20(void)
{
static struct lc_cipher_impl chacha20_impl = {
.encrypt_init = &chacha20_anycrypt_init,
.encrypt_update = &chacha20_anycrypt_update,
@ -255,6 +258,12 @@ static struct lc_cipher_impl chacha20_impl = {
.blocklen = LC_CHACHA20_BLOCKLEN,
};
return &chacha20_impl;
}
const struct lc_cipher_impl *
lc_cipher_impl_xchacha20(void)
{
static struct lc_cipher_impl xchacha20_impl = {
.encrypt_init = &xchacha20_anycrypt_init,
.encrypt_update = &chacha20_anycrypt_update,
@ -270,14 +279,5 @@ static struct lc_cipher_impl xchacha20_impl = {
.blocklen = LC_XCHACHA20_BLOCKLEN,
};
const struct lc_cipher_impl *
lc_cipher_impl_chacha20(void)
{
return &chacha20_impl;
}
const struct lc_cipher_impl *
lc_cipher_impl_xchacha20(void)
{
return &xchacha20_impl;
}

View File

@ -252,6 +252,9 @@ sha256_hash(uint8_t *out, size_t *outlen, const uint8_t *in, size_t inlen)
}
const struct lc_hash_impl *
lc_hash_impl_sha224(void)
{
static struct lc_hash_impl sha224_impl = {
.init = &sha224_init,
.update = &sha224_update,
@ -263,6 +266,12 @@ static struct lc_hash_impl sha224_impl = {
.hashlen = LC_SHA224_HASHLEN,
};
return &sha224_impl;
}
const struct lc_hash_impl *
lc_hash_impl_sha256(void)
{
static struct lc_hash_impl sha256_impl = {
.init = &sha256_init,
.update = &sha256_update,
@ -274,14 +283,5 @@ static struct lc_hash_impl sha256_impl = {
.hashlen = LC_SHA256_HASHLEN,
};
const struct lc_hash_impl *
lc_hash_impl_sha224(void)
{
return &sha224_impl;
}
const struct lc_hash_impl *
lc_hash_impl_sha256(void)
{
return &sha256_impl;
}

View File

@ -257,6 +257,9 @@ sha512_hash(uint8_t *out, size_t *outlen, const uint8_t *in, size_t inlen)
}
const struct lc_hash_impl *
lc_hash_impl_sha384(void)
{
static struct lc_hash_impl sha384_impl = {
.init = &sha384_init,
.update = &sha384_update,
@ -268,6 +271,12 @@ static struct lc_hash_impl sha384_impl = {
.hashlen = LC_SHA384_HASHLEN,
};
return &sha384_impl;
}
const struct lc_hash_impl *
lc_hash_impl_sha512(void)
{
static struct lc_hash_impl sha512_impl = {
.init = &sha512_init,
.update = &sha512_update,
@ -279,14 +288,5 @@ static struct lc_hash_impl sha512_impl = {
.hashlen = LC_SHA512_HASHLEN,
};
const struct lc_hash_impl *
lc_hash_impl_sha384(void)
{
return &sha384_impl;
}
const struct lc_hash_impl *
lc_hash_impl_sha512(void)
{
return &sha512_impl;
}