diff --git a/auth_hmac.c b/auth_hmac.c index f3f7956..44c9e6b 100644 --- a/auth_hmac.c +++ b/auth_hmac.c @@ -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; } diff --git a/auth_poly1305.c b/auth_poly1305.c index ca7960a..ce705e4 100644 --- a/auth_poly1305.c +++ b/auth_poly1305.c @@ -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; } diff --git a/cipher_chacha20.c b/cipher_chacha20.c index dbc480e..786e645 100644 --- a/cipher_chacha20.c +++ b/cipher_chacha20.c @@ -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; } diff --git a/hash_sha224_sha256.c b/hash_sha224_sha256.c index 0e64357..3ddf490 100644 --- a/hash_sha224_sha256.c +++ b/hash_sha224_sha256.c @@ -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; } diff --git a/hash_sha384_sha512.c b/hash_sha384_sha512.c index 320ba9c..934ae77 100644 --- a/hash_sha384_sha512.c +++ b/hash_sha384_sha512.c @@ -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; }