Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0 OR MIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * shash interface to the generic implementation of BLAKE2s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <crypto/internal/blake2s.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int crypto_blake2s_update_generic(struct shash_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 					 const u8 *in, unsigned int inlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	return crypto_blake2s_update(desc, in, inlen, blake2s_compress_generic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static int crypto_blake2s_final_generic(struct shash_desc *desc, u8 *out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	return crypto_blake2s_final(desc, out, blake2s_compress_generic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define BLAKE2S_ALG(name, driver_name, digest_size)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	{								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		.base.cra_name		= name,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		.base.cra_driver_name	= driver_name,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 		.base.cra_priority	= 100,				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		.base.cra_flags		= CRYPTO_ALG_OPTIONAL_KEY,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		.base.cra_blocksize	= BLAKE2S_BLOCK_SIZE,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		.base.cra_ctxsize	= sizeof(struct blake2s_tfm_ctx), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		.base.cra_module	= THIS_MODULE,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		.digestsize		= digest_size,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		.setkey			= crypto_blake2s_setkey,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		.init			= crypto_blake2s_init,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		.update			= crypto_blake2s_update_generic, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		.final			= crypto_blake2s_final_generic,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		.descsize		= sizeof(struct blake2s_state),	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static struct shash_alg blake2s_algs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	BLAKE2S_ALG("blake2s-128", "blake2s-128-generic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		    BLAKE2S_128_HASH_SIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	BLAKE2S_ALG("blake2s-160", "blake2s-160-generic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		    BLAKE2S_160_HASH_SIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	BLAKE2S_ALG("blake2s-224", "blake2s-224-generic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		    BLAKE2S_224_HASH_SIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	BLAKE2S_ALG("blake2s-256", "blake2s-256-generic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		    BLAKE2S_256_HASH_SIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static int __init blake2s_mod_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	return crypto_register_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static void __exit blake2s_mod_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	crypto_unregister_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) subsys_initcall(blake2s_mod_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) module_exit(blake2s_mod_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) MODULE_ALIAS_CRYPTO("blake2s-128");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) MODULE_ALIAS_CRYPTO("blake2s-128-generic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) MODULE_ALIAS_CRYPTO("blake2s-160");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) MODULE_ALIAS_CRYPTO("blake2s-160-generic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) MODULE_ALIAS_CRYPTO("blake2s-224");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) MODULE_ALIAS_CRYPTO("blake2s-224-generic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) MODULE_ALIAS_CRYPTO("blake2s-256");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) MODULE_ALIAS_CRYPTO("blake2s-256-generic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) MODULE_LICENSE("GPL v2");