18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: (GPL-2.0-only OR Apache-2.0) 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * BLAKE2b reference source code package - reference C implementations 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the 68c2ecf20Sopenharmony_ci * terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at 78c2ecf20Sopenharmony_ci * your option. The terms of these licenses can be found at: 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 108c2ecf20Sopenharmony_ci * - OpenSSL license : https://www.openssl.org/source/license.html 118c2ecf20Sopenharmony_ci * - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0 128c2ecf20Sopenharmony_ci * 138c2ecf20Sopenharmony_ci * More information about the BLAKE2 hash function can be found at 148c2ecf20Sopenharmony_ci * https://blake2.net. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * Note: the original sources have been modified for inclusion in linux kernel 178c2ecf20Sopenharmony_ci * in terms of coding style, using generic helpers and simplifications of error 188c2ecf20Sopenharmony_ci * handling. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include <asm/unaligned.h> 228c2ecf20Sopenharmony_ci#include <linux/module.h> 238c2ecf20Sopenharmony_ci#include <linux/string.h> 248c2ecf20Sopenharmony_ci#include <linux/kernel.h> 258c2ecf20Sopenharmony_ci#include <linux/bitops.h> 268c2ecf20Sopenharmony_ci#include <crypto/internal/hash.h> 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define BLAKE2B_160_DIGEST_SIZE (160 / 8) 298c2ecf20Sopenharmony_ci#define BLAKE2B_256_DIGEST_SIZE (256 / 8) 308c2ecf20Sopenharmony_ci#define BLAKE2B_384_DIGEST_SIZE (384 / 8) 318c2ecf20Sopenharmony_ci#define BLAKE2B_512_DIGEST_SIZE (512 / 8) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cienum blake2b_constant { 348c2ecf20Sopenharmony_ci BLAKE2B_BLOCKBYTES = 128, 358c2ecf20Sopenharmony_ci BLAKE2B_KEYBYTES = 64, 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistruct blake2b_state { 398c2ecf20Sopenharmony_ci u64 h[8]; 408c2ecf20Sopenharmony_ci u64 t[2]; 418c2ecf20Sopenharmony_ci u64 f[2]; 428c2ecf20Sopenharmony_ci u8 buf[BLAKE2B_BLOCKBYTES]; 438c2ecf20Sopenharmony_ci size_t buflen; 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistatic const u64 blake2b_IV[8] = { 478c2ecf20Sopenharmony_ci 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 488c2ecf20Sopenharmony_ci 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 498c2ecf20Sopenharmony_ci 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 508c2ecf20Sopenharmony_ci 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic const u8 blake2b_sigma[12][16] = { 548c2ecf20Sopenharmony_ci { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, 558c2ecf20Sopenharmony_ci { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, 568c2ecf20Sopenharmony_ci { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, 578c2ecf20Sopenharmony_ci { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, 588c2ecf20Sopenharmony_ci { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, 598c2ecf20Sopenharmony_ci { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, 608c2ecf20Sopenharmony_ci { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, 618c2ecf20Sopenharmony_ci { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, 628c2ecf20Sopenharmony_ci { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, 638c2ecf20Sopenharmony_ci { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, 648c2ecf20Sopenharmony_ci { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, 658c2ecf20Sopenharmony_ci { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistatic void blake2b_increment_counter(struct blake2b_state *S, const u64 inc) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci S->t[0] += inc; 718c2ecf20Sopenharmony_ci S->t[1] += (S->t[0] < inc); 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define G(r,i,a,b,c,d) \ 758c2ecf20Sopenharmony_ci do { \ 768c2ecf20Sopenharmony_ci a = a + b + m[blake2b_sigma[r][2*i+0]]; \ 778c2ecf20Sopenharmony_ci d = ror64(d ^ a, 32); \ 788c2ecf20Sopenharmony_ci c = c + d; \ 798c2ecf20Sopenharmony_ci b = ror64(b ^ c, 24); \ 808c2ecf20Sopenharmony_ci a = a + b + m[blake2b_sigma[r][2*i+1]]; \ 818c2ecf20Sopenharmony_ci d = ror64(d ^ a, 16); \ 828c2ecf20Sopenharmony_ci c = c + d; \ 838c2ecf20Sopenharmony_ci b = ror64(b ^ c, 63); \ 848c2ecf20Sopenharmony_ci } while (0) 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#define ROUND(r) \ 878c2ecf20Sopenharmony_ci do { \ 888c2ecf20Sopenharmony_ci G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \ 898c2ecf20Sopenharmony_ci G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \ 908c2ecf20Sopenharmony_ci G(r,2,v[ 2],v[ 6],v[10],v[14]); \ 918c2ecf20Sopenharmony_ci G(r,3,v[ 3],v[ 7],v[11],v[15]); \ 928c2ecf20Sopenharmony_ci G(r,4,v[ 0],v[ 5],v[10],v[15]); \ 938c2ecf20Sopenharmony_ci G(r,5,v[ 1],v[ 6],v[11],v[12]); \ 948c2ecf20Sopenharmony_ci G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \ 958c2ecf20Sopenharmony_ci G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \ 968c2ecf20Sopenharmony_ci } while (0) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic void blake2b_compress(struct blake2b_state *S, 998c2ecf20Sopenharmony_ci const u8 block[BLAKE2B_BLOCKBYTES]) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci u64 m[16]; 1028c2ecf20Sopenharmony_ci u64 v[16]; 1038c2ecf20Sopenharmony_ci size_t i; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci for (i = 0; i < 16; ++i) 1068c2ecf20Sopenharmony_ci m[i] = get_unaligned_le64(block + i * sizeof(m[i])); 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci for (i = 0; i < 8; ++i) 1098c2ecf20Sopenharmony_ci v[i] = S->h[i]; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci v[ 8] = blake2b_IV[0]; 1128c2ecf20Sopenharmony_ci v[ 9] = blake2b_IV[1]; 1138c2ecf20Sopenharmony_ci v[10] = blake2b_IV[2]; 1148c2ecf20Sopenharmony_ci v[11] = blake2b_IV[3]; 1158c2ecf20Sopenharmony_ci v[12] = blake2b_IV[4] ^ S->t[0]; 1168c2ecf20Sopenharmony_ci v[13] = blake2b_IV[5] ^ S->t[1]; 1178c2ecf20Sopenharmony_ci v[14] = blake2b_IV[6] ^ S->f[0]; 1188c2ecf20Sopenharmony_ci v[15] = blake2b_IV[7] ^ S->f[1]; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci ROUND(0); 1218c2ecf20Sopenharmony_ci ROUND(1); 1228c2ecf20Sopenharmony_ci ROUND(2); 1238c2ecf20Sopenharmony_ci ROUND(3); 1248c2ecf20Sopenharmony_ci ROUND(4); 1258c2ecf20Sopenharmony_ci ROUND(5); 1268c2ecf20Sopenharmony_ci ROUND(6); 1278c2ecf20Sopenharmony_ci ROUND(7); 1288c2ecf20Sopenharmony_ci ROUND(8); 1298c2ecf20Sopenharmony_ci ROUND(9); 1308c2ecf20Sopenharmony_ci ROUND(10); 1318c2ecf20Sopenharmony_ci ROUND(11); 1328c2ecf20Sopenharmony_ci#ifdef CONFIG_CC_IS_CLANG 1338c2ecf20Sopenharmony_ci#pragma nounroll /* https://bugs.llvm.org/show_bug.cgi?id=45803 */ 1348c2ecf20Sopenharmony_ci#endif 1358c2ecf20Sopenharmony_ci for (i = 0; i < 8; ++i) 1368c2ecf20Sopenharmony_ci S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#undef G 1408c2ecf20Sopenharmony_ci#undef ROUND 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct blake2b_tfm_ctx { 1438c2ecf20Sopenharmony_ci u8 key[BLAKE2B_KEYBYTES]; 1448c2ecf20Sopenharmony_ci unsigned int keylen; 1458c2ecf20Sopenharmony_ci}; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistatic int blake2b_setkey(struct crypto_shash *tfm, const u8 *key, 1488c2ecf20Sopenharmony_ci unsigned int keylen) 1498c2ecf20Sopenharmony_ci{ 1508c2ecf20Sopenharmony_ci struct blake2b_tfm_ctx *tctx = crypto_shash_ctx(tfm); 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci if (keylen == 0 || keylen > BLAKE2B_KEYBYTES) 1538c2ecf20Sopenharmony_ci return -EINVAL; 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci memcpy(tctx->key, key, keylen); 1568c2ecf20Sopenharmony_ci tctx->keylen = keylen; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci return 0; 1598c2ecf20Sopenharmony_ci} 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistatic int blake2b_init(struct shash_desc *desc) 1628c2ecf20Sopenharmony_ci{ 1638c2ecf20Sopenharmony_ci struct blake2b_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); 1648c2ecf20Sopenharmony_ci struct blake2b_state *state = shash_desc_ctx(desc); 1658c2ecf20Sopenharmony_ci const int digestsize = crypto_shash_digestsize(desc->tfm); 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci memset(state, 0, sizeof(*state)); 1688c2ecf20Sopenharmony_ci memcpy(state->h, blake2b_IV, sizeof(state->h)); 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci /* Parameter block is all zeros except index 0, no xor for 1..7 */ 1718c2ecf20Sopenharmony_ci state->h[0] ^= 0x01010000 | tctx->keylen << 8 | digestsize; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci if (tctx->keylen) { 1748c2ecf20Sopenharmony_ci /* 1758c2ecf20Sopenharmony_ci * Prefill the buffer with the key, next call to _update or 1768c2ecf20Sopenharmony_ci * _final will process it 1778c2ecf20Sopenharmony_ci */ 1788c2ecf20Sopenharmony_ci memcpy(state->buf, tctx->key, tctx->keylen); 1798c2ecf20Sopenharmony_ci state->buflen = BLAKE2B_BLOCKBYTES; 1808c2ecf20Sopenharmony_ci } 1818c2ecf20Sopenharmony_ci return 0; 1828c2ecf20Sopenharmony_ci} 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_cistatic int blake2b_update(struct shash_desc *desc, const u8 *in, 1858c2ecf20Sopenharmony_ci unsigned int inlen) 1868c2ecf20Sopenharmony_ci{ 1878c2ecf20Sopenharmony_ci struct blake2b_state *state = shash_desc_ctx(desc); 1888c2ecf20Sopenharmony_ci const size_t left = state->buflen; 1898c2ecf20Sopenharmony_ci const size_t fill = BLAKE2B_BLOCKBYTES - left; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci if (!inlen) 1928c2ecf20Sopenharmony_ci return 0; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci if (inlen > fill) { 1958c2ecf20Sopenharmony_ci state->buflen = 0; 1968c2ecf20Sopenharmony_ci /* Fill buffer */ 1978c2ecf20Sopenharmony_ci memcpy(state->buf + left, in, fill); 1988c2ecf20Sopenharmony_ci blake2b_increment_counter(state, BLAKE2B_BLOCKBYTES); 1998c2ecf20Sopenharmony_ci /* Compress */ 2008c2ecf20Sopenharmony_ci blake2b_compress(state, state->buf); 2018c2ecf20Sopenharmony_ci in += fill; 2028c2ecf20Sopenharmony_ci inlen -= fill; 2038c2ecf20Sopenharmony_ci while (inlen > BLAKE2B_BLOCKBYTES) { 2048c2ecf20Sopenharmony_ci blake2b_increment_counter(state, BLAKE2B_BLOCKBYTES); 2058c2ecf20Sopenharmony_ci blake2b_compress(state, in); 2068c2ecf20Sopenharmony_ci in += BLAKE2B_BLOCKBYTES; 2078c2ecf20Sopenharmony_ci inlen -= BLAKE2B_BLOCKBYTES; 2088c2ecf20Sopenharmony_ci } 2098c2ecf20Sopenharmony_ci } 2108c2ecf20Sopenharmony_ci memcpy(state->buf + state->buflen, in, inlen); 2118c2ecf20Sopenharmony_ci state->buflen += inlen; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci return 0; 2148c2ecf20Sopenharmony_ci} 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_cistatic int blake2b_final(struct shash_desc *desc, u8 *out) 2178c2ecf20Sopenharmony_ci{ 2188c2ecf20Sopenharmony_ci struct blake2b_state *state = shash_desc_ctx(desc); 2198c2ecf20Sopenharmony_ci const int digestsize = crypto_shash_digestsize(desc->tfm); 2208c2ecf20Sopenharmony_ci size_t i; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci blake2b_increment_counter(state, state->buflen); 2238c2ecf20Sopenharmony_ci /* Set last block */ 2248c2ecf20Sopenharmony_ci state->f[0] = (u64)-1; 2258c2ecf20Sopenharmony_ci /* Padding */ 2268c2ecf20Sopenharmony_ci memset(state->buf + state->buflen, 0, BLAKE2B_BLOCKBYTES - state->buflen); 2278c2ecf20Sopenharmony_ci blake2b_compress(state, state->buf); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci /* Avoid temporary buffer and switch the internal output to LE order */ 2308c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(state->h); i++) 2318c2ecf20Sopenharmony_ci __cpu_to_le64s(&state->h[i]); 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci memcpy(out, state->h, digestsize); 2348c2ecf20Sopenharmony_ci return 0; 2358c2ecf20Sopenharmony_ci} 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_cistatic struct shash_alg blake2b_algs[] = { 2388c2ecf20Sopenharmony_ci { 2398c2ecf20Sopenharmony_ci .base.cra_name = "blake2b-160", 2408c2ecf20Sopenharmony_ci .base.cra_driver_name = "blake2b-160-generic", 2418c2ecf20Sopenharmony_ci .base.cra_priority = 100, 2428c2ecf20Sopenharmony_ci .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, 2438c2ecf20Sopenharmony_ci .base.cra_blocksize = BLAKE2B_BLOCKBYTES, 2448c2ecf20Sopenharmony_ci .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), 2458c2ecf20Sopenharmony_ci .base.cra_module = THIS_MODULE, 2468c2ecf20Sopenharmony_ci .digestsize = BLAKE2B_160_DIGEST_SIZE, 2478c2ecf20Sopenharmony_ci .setkey = blake2b_setkey, 2488c2ecf20Sopenharmony_ci .init = blake2b_init, 2498c2ecf20Sopenharmony_ci .update = blake2b_update, 2508c2ecf20Sopenharmony_ci .final = blake2b_final, 2518c2ecf20Sopenharmony_ci .descsize = sizeof(struct blake2b_state), 2528c2ecf20Sopenharmony_ci }, { 2538c2ecf20Sopenharmony_ci .base.cra_name = "blake2b-256", 2548c2ecf20Sopenharmony_ci .base.cra_driver_name = "blake2b-256-generic", 2558c2ecf20Sopenharmony_ci .base.cra_priority = 100, 2568c2ecf20Sopenharmony_ci .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, 2578c2ecf20Sopenharmony_ci .base.cra_blocksize = BLAKE2B_BLOCKBYTES, 2588c2ecf20Sopenharmony_ci .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), 2598c2ecf20Sopenharmony_ci .base.cra_module = THIS_MODULE, 2608c2ecf20Sopenharmony_ci .digestsize = BLAKE2B_256_DIGEST_SIZE, 2618c2ecf20Sopenharmony_ci .setkey = blake2b_setkey, 2628c2ecf20Sopenharmony_ci .init = blake2b_init, 2638c2ecf20Sopenharmony_ci .update = blake2b_update, 2648c2ecf20Sopenharmony_ci .final = blake2b_final, 2658c2ecf20Sopenharmony_ci .descsize = sizeof(struct blake2b_state), 2668c2ecf20Sopenharmony_ci }, { 2678c2ecf20Sopenharmony_ci .base.cra_name = "blake2b-384", 2688c2ecf20Sopenharmony_ci .base.cra_driver_name = "blake2b-384-generic", 2698c2ecf20Sopenharmony_ci .base.cra_priority = 100, 2708c2ecf20Sopenharmony_ci .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, 2718c2ecf20Sopenharmony_ci .base.cra_blocksize = BLAKE2B_BLOCKBYTES, 2728c2ecf20Sopenharmony_ci .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), 2738c2ecf20Sopenharmony_ci .base.cra_module = THIS_MODULE, 2748c2ecf20Sopenharmony_ci .digestsize = BLAKE2B_384_DIGEST_SIZE, 2758c2ecf20Sopenharmony_ci .setkey = blake2b_setkey, 2768c2ecf20Sopenharmony_ci .init = blake2b_init, 2778c2ecf20Sopenharmony_ci .update = blake2b_update, 2788c2ecf20Sopenharmony_ci .final = blake2b_final, 2798c2ecf20Sopenharmony_ci .descsize = sizeof(struct blake2b_state), 2808c2ecf20Sopenharmony_ci }, { 2818c2ecf20Sopenharmony_ci .base.cra_name = "blake2b-512", 2828c2ecf20Sopenharmony_ci .base.cra_driver_name = "blake2b-512-generic", 2838c2ecf20Sopenharmony_ci .base.cra_priority = 100, 2848c2ecf20Sopenharmony_ci .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY, 2858c2ecf20Sopenharmony_ci .base.cra_blocksize = BLAKE2B_BLOCKBYTES, 2868c2ecf20Sopenharmony_ci .base.cra_ctxsize = sizeof(struct blake2b_tfm_ctx), 2878c2ecf20Sopenharmony_ci .base.cra_module = THIS_MODULE, 2888c2ecf20Sopenharmony_ci .digestsize = BLAKE2B_512_DIGEST_SIZE, 2898c2ecf20Sopenharmony_ci .setkey = blake2b_setkey, 2908c2ecf20Sopenharmony_ci .init = blake2b_init, 2918c2ecf20Sopenharmony_ci .update = blake2b_update, 2928c2ecf20Sopenharmony_ci .final = blake2b_final, 2938c2ecf20Sopenharmony_ci .descsize = sizeof(struct blake2b_state), 2948c2ecf20Sopenharmony_ci } 2958c2ecf20Sopenharmony_ci}; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistatic int __init blake2b_mod_init(void) 2988c2ecf20Sopenharmony_ci{ 2998c2ecf20Sopenharmony_ci return crypto_register_shashes(blake2b_algs, ARRAY_SIZE(blake2b_algs)); 3008c2ecf20Sopenharmony_ci} 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistatic void __exit blake2b_mod_fini(void) 3038c2ecf20Sopenharmony_ci{ 3048c2ecf20Sopenharmony_ci crypto_unregister_shashes(blake2b_algs, ARRAY_SIZE(blake2b_algs)); 3058c2ecf20Sopenharmony_ci} 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_cisubsys_initcall(blake2b_mod_init); 3088c2ecf20Sopenharmony_cimodule_exit(blake2b_mod_fini); 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ciMODULE_AUTHOR("David Sterba <kdave@kernel.org>"); 3118c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("BLAKE2b generic implementation"); 3128c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 3138c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-160"); 3148c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-160-generic"); 3158c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-256"); 3168c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-256-generic"); 3178c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-384"); 3188c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-384-generic"); 3198c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-512"); 3208c2ecf20Sopenharmony_ciMODULE_ALIAS_CRYPTO("blake2b-512-generic"); 321