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,7 +116,10 @@ hmac_auth(uint8_t *out, size_t *outlen, void *initparams, const uint8_t *in,
}
static struct lc_auth_impl hmac_impl = {
const struct lc_auth_impl *
lc_auth_impl_hmac(void)
{
static struct lc_auth_impl hmac_impl = {
.init = &hmac_init,
.update = &hmac_update,
.final = &hmac_final,
@ -125,10 +128,7 @@ static struct lc_auth_impl hmac_impl = {
.argsz = sizeof(struct hmac_state),
.blocklen = 0,
.taglen = 0,
};
};
const struct lc_auth_impl *
lc_auth_impl_hmac(void)
{
return &hmac_impl;
}

View File

@ -151,7 +151,10 @@ poly1305_auth(uint8_t *out, size_t *outlen, void *initparams,
}
static struct lc_auth_impl poly1305_impl = {
const struct lc_auth_impl *
lc_auth_impl_poly1305(void)
{
static struct lc_auth_impl poly1305_impl = {
.init = &poly1305_init,
.update = &poly1305_update,
.final = &poly1305_final,
@ -160,10 +163,7 @@ static struct lc_auth_impl poly1305_impl = {
.argsz = sizeof(struct poly1305_state),
.blocklen = LC_POLY1305_BLOCKLEN,
.taglen = LC_POLY1305_TAGLEN,
};
};
const struct lc_auth_impl *
lc_auth_impl_poly1305(void)
{
return &poly1305_impl;
}

View File

@ -240,7 +240,10 @@ xchacha20_anycrypt(uint8_t *out, size_t *outlen, void *initparams,
}
static struct lc_cipher_impl chacha20_impl = {
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,
.encrypt_final = &chacha20_anycrypt_final,
@ -253,9 +256,15 @@ static struct lc_cipher_impl chacha20_impl = {
.argsz = sizeof(struct chacha20_state),
.blocklen = LC_CHACHA20_BLOCKLEN,
};
};
static struct lc_cipher_impl xchacha20_impl = {
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,
.encrypt_final = &chacha20_anycrypt_final,
@ -268,16 +277,7 @@ static struct lc_cipher_impl xchacha20_impl = {
.argsz = sizeof(struct chacha20_state),
.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,7 +252,10 @@ sha256_hash(uint8_t *out, size_t *outlen, const uint8_t *in, size_t inlen)
}
static struct lc_hash_impl sha224_impl = {
const struct lc_hash_impl *
lc_hash_impl_sha224(void)
{
static struct lc_hash_impl sha224_impl = {
.init = &sha224_init,
.update = &sha224_update,
.final = &sha224_final,
@ -261,9 +264,15 @@ static struct lc_hash_impl sha224_impl = {
.argsz = sizeof(struct sha256_state),
.blocklen = LC_SHA224_BLOCKLEN,
.hashlen = LC_SHA224_HASHLEN,
};
};
static struct lc_hash_impl sha256_impl = {
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,
.final = &sha256_final,
@ -272,16 +281,7 @@ static struct lc_hash_impl sha256_impl = {
.argsz = sizeof(struct sha256_state),
.blocklen = LC_SHA256_BLOCKLEN,
.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,7 +257,10 @@ sha512_hash(uint8_t *out, size_t *outlen, const uint8_t *in, size_t inlen)
}
static struct lc_hash_impl sha384_impl = {
const struct lc_hash_impl *
lc_hash_impl_sha384(void)
{
static struct lc_hash_impl sha384_impl = {
.init = &sha384_init,
.update = &sha384_update,
.final = &sha384_final,
@ -266,9 +269,15 @@ static struct lc_hash_impl sha384_impl = {
.argsz = sizeof(struct sha512_state),
.blocklen = LC_SHA384_BLOCKLEN,
.hashlen = LC_SHA384_HASHLEN,
};
};
static struct lc_hash_impl sha512_impl = {
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,
.final = &sha512_final,
@ -277,16 +286,7 @@ static struct lc_hash_impl sha512_impl = {
.argsz = sizeof(struct sha512_state),
.blocklen = LC_SHA512_BLOCKLEN,
.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;
}