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

View File

@ -151,19 +151,19 @@ poly1305_auth(uint8_t *out, size_t *outlen, void *initparams,
}
static struct lc_auth_impl poly1305_impl = {
.init = &poly1305_init,
.update = &poly1305_update,
.final = &poly1305_final,
.auth = &poly1305_auth,
.argsz = sizeof(struct poly1305_state),
.blocklen = LC_POLY1305_BLOCKLEN,
.taglen = LC_POLY1305_TAGLEN,
};
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,
.auth = &poly1305_auth,
.argsz = sizeof(struct poly1305_state),
.blocklen = LC_POLY1305_BLOCKLEN,
.taglen = LC_POLY1305_TAGLEN,
};
return &poly1305_impl;
}

View File

@ -240,44 +240,44 @@ xchacha20_anycrypt(uint8_t *out, size_t *outlen, void *initparams,
}
static struct lc_cipher_impl chacha20_impl = {
.encrypt_init = &chacha20_anycrypt_init,
.encrypt_update = &chacha20_anycrypt_update,
.encrypt_final = &chacha20_anycrypt_final,
.encrypt = &chacha20_anycrypt,
.decrypt_init = &chacha20_anycrypt_init,
.decrypt_update = &chacha20_anycrypt_update,
.decrypt_final = &chacha20_anycrypt_final,
.decrypt = &chacha20_anycrypt,
.argsz = sizeof(struct chacha20_state),
.blocklen = LC_CHACHA20_BLOCKLEN,
};
static struct lc_cipher_impl xchacha20_impl = {
.encrypt_init = &xchacha20_anycrypt_init,
.encrypt_update = &chacha20_anycrypt_update,
.encrypt_final = &chacha20_anycrypt_final,
.encrypt = &xchacha20_anycrypt,
.decrypt_init = &xchacha20_anycrypt_init,
.decrypt_update = &chacha20_anycrypt_update,
.decrypt_final = &chacha20_anycrypt_final,
.decrypt = &xchacha20_anycrypt,
.argsz = sizeof(struct chacha20_state),
.blocklen = LC_XCHACHA20_BLOCKLEN,
};
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,
.encrypt = &chacha20_anycrypt,
.decrypt_init = &chacha20_anycrypt_init,
.decrypt_update = &chacha20_anycrypt_update,
.decrypt_final = &chacha20_anycrypt_final,
.decrypt = &chacha20_anycrypt,
.argsz = sizeof(struct chacha20_state),
.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,
.encrypt_final = &chacha20_anycrypt_final,
.encrypt = &xchacha20_anycrypt,
.decrypt_init = &xchacha20_anycrypt_init,
.decrypt_update = &chacha20_anycrypt_update,
.decrypt_final = &chacha20_anycrypt_final,
.decrypt = &xchacha20_anycrypt,
.argsz = sizeof(struct chacha20_state),
.blocklen = LC_XCHACHA20_BLOCKLEN,
};
return &xchacha20_impl;
}

View File

@ -252,36 +252,36 @@ sha256_hash(uint8_t *out, size_t *outlen, const uint8_t *in, size_t inlen)
}
static struct lc_hash_impl sha224_impl = {
.init = &sha224_init,
.update = &sha224_update,
.final = &sha224_final,
.hash = &sha224_hash,
.argsz = sizeof(struct sha256_state),
.blocklen = LC_SHA224_BLOCKLEN,
.hashlen = LC_SHA224_HASHLEN,
};
static struct lc_hash_impl sha256_impl = {
.init = &sha256_init,
.update = &sha256_update,
.final = &sha256_final,
.hash = &sha256_hash,
.argsz = sizeof(struct sha256_state),
.blocklen = LC_SHA256_BLOCKLEN,
.hashlen = LC_SHA256_HASHLEN,
};
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,
.hash = &sha224_hash,
.argsz = sizeof(struct sha256_state),
.blocklen = LC_SHA224_BLOCKLEN,
.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,
.final = &sha256_final,
.hash = &sha256_hash,
.argsz = sizeof(struct sha256_state),
.blocklen = LC_SHA256_BLOCKLEN,
.hashlen = LC_SHA256_HASHLEN,
};
return &sha256_impl;
}

View File

@ -257,36 +257,36 @@ sha512_hash(uint8_t *out, size_t *outlen, const uint8_t *in, size_t inlen)
}
static struct lc_hash_impl sha384_impl = {
.init = &sha384_init,
.update = &sha384_update,
.final = &sha384_final,
.hash = &sha384_hash,
.argsz = sizeof(struct sha512_state),
.blocklen = LC_SHA384_BLOCKLEN,
.hashlen = LC_SHA384_HASHLEN,
};
static struct lc_hash_impl sha512_impl = {
.init = &sha512_init,
.update = &sha512_update,
.final = &sha512_final,
.hash = &sha512_hash,
.argsz = sizeof(struct sha512_state),
.blocklen = LC_SHA512_BLOCKLEN,
.hashlen = LC_SHA512_HASHLEN,
};
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,
.hash = &sha384_hash,
.argsz = sizeof(struct sha512_state),
.blocklen = LC_SHA384_BLOCKLEN,
.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,
.final = &sha512_final,
.hash = &sha512_hash,
.argsz = sizeof(struct sha512_state),
.blocklen = LC_SHA512_BLOCKLEN,
.hashlen = LC_SHA512_HASHLEN,
};
return &sha512_impl;
}