1 // SPDX-License-Identifier: GPL-2.0 1 2 /* 3 * sha512-ce-glue.c - SHA-384/SHA-512 using AR 4 * 5 * Copyright (C) 2018 Linaro Ltd <ard.biesheuv 6 * 7 * This program is free software; you can redi 8 * it under the terms of the GNU General Publi 9 * published by the Free Software Foundation. 10 */ 11 12 #include <asm/neon.h> 13 #include <asm/simd.h> 14 #include <linux/unaligned.h> 15 #include <crypto/internal/hash.h> 16 #include <crypto/internal/simd.h> 17 #include <crypto/sha2.h> 18 #include <crypto/sha512_base.h> 19 #include <linux/cpufeature.h> 20 #include <linux/crypto.h> 21 #include <linux/module.h> 22 23 MODULE_DESCRIPTION("SHA-384/SHA-512 secure has 24 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@ 25 MODULE_LICENSE("GPL v2"); 26 MODULE_ALIAS_CRYPTO("sha384"); 27 MODULE_ALIAS_CRYPTO("sha512"); 28 29 asmlinkage int __sha512_ce_transform(struct sh 30 int block 31 32 asmlinkage void sha512_block_data_order(u64 *d 33 34 static void sha512_ce_transform(struct sha512_ 35 int blocks) 36 { 37 while (blocks) { 38 int rem; 39 40 kernel_neon_begin(); 41 rem = __sha512_ce_transform(ss 42 kernel_neon_end(); 43 src += (blocks - rem) * SHA512 44 blocks = rem; 45 } 46 } 47 48 static void sha512_arm64_transform(struct sha5 49 int blocks) 50 { 51 sha512_block_data_order(sst->state, sr 52 } 53 54 static int sha512_ce_update(struct shash_desc 55 unsigned int len) 56 { 57 sha512_block_fn *fn = crypto_simd_usab 58 59 60 sha512_base_do_update(desc, data, len, 61 return 0; 62 } 63 64 static int sha512_ce_finup(struct shash_desc * 65 unsigned int len, u 66 { 67 sha512_block_fn *fn = crypto_simd_usab 68 69 70 sha512_base_do_update(desc, data, len, 71 sha512_base_do_finalize(desc, fn); 72 return sha512_base_finish(desc, out); 73 } 74 75 static int sha512_ce_final(struct shash_desc * 76 { 77 sha512_block_fn *fn = crypto_simd_usab 78 79 80 sha512_base_do_finalize(desc, fn); 81 return sha512_base_finish(desc, out); 82 } 83 84 static struct shash_alg algs[] = { { 85 .init = sha384_base_ 86 .update = sha512_ce_up 87 .final = sha512_ce_fi 88 .finup = sha512_ce_fi 89 .descsize = sizeof(struc 90 .digestsize = SHA384_DIGES 91 .base.cra_name = "sha384", 92 .base.cra_driver_name = "sha384-ce", 93 .base.cra_priority = 200, 94 .base.cra_blocksize = SHA512_BLOCK 95 .base.cra_module = THIS_MODULE, 96 }, { 97 .init = sha512_base_ 98 .update = sha512_ce_up 99 .final = sha512_ce_fi 100 .finup = sha512_ce_fi 101 .descsize = sizeof(struc 102 .digestsize = SHA512_DIGES 103 .base.cra_name = "sha512", 104 .base.cra_driver_name = "sha512-ce", 105 .base.cra_priority = 200, 106 .base.cra_blocksize = SHA512_BLOCK 107 .base.cra_module = THIS_MODULE, 108 } }; 109 110 static int __init sha512_ce_mod_init(void) 111 { 112 return crypto_register_shashes(algs, A 113 } 114 115 static void __exit sha512_ce_mod_fini(void) 116 { 117 crypto_unregister_shashes(algs, ARRAY_ 118 } 119 120 module_cpu_feature_match(SHA512, sha512_ce_mod 121 module_exit(sha512_ce_mod_fini); 122
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.