~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/crypto/sha512-glue.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.10 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.83 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.153 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.200 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.200 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.76 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * sha512-glue.c - accelerated SHA-384/512 for ARM
  3  *
  4  * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License version 2 as
  8  * published by the Free Software Foundation.
  9  */
 10 
 11 #include <crypto/internal/hash.h>
 12 #include <crypto/sha.h>
 13 #include <crypto/sha512_base.h>
 14 #include <linux/crypto.h>
 15 #include <linux/module.h>
 16 
 17 #include <asm/hwcap.h>
 18 #include <asm/neon.h>
 19 
 20 #include "sha512.h"
 21 
 22 MODULE_DESCRIPTION("Accelerated SHA-384/SHA-512 secure hash for ARM");
 23 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 24 MODULE_LICENSE("GPL v2");
 25 
 26 MODULE_ALIAS_CRYPTO("sha384");
 27 MODULE_ALIAS_CRYPTO("sha512");
 28 MODULE_ALIAS_CRYPTO("sha384-arm");
 29 MODULE_ALIAS_CRYPTO("sha512-arm");
 30 
 31 asmlinkage void sha512_block_data_order(u64 *state, u8 const *src, int blocks);
 32 
 33 int sha512_arm_update(struct shash_desc *desc, const u8 *data,
 34                       unsigned int len)
 35 {
 36         return sha512_base_do_update(desc, data, len,
 37                 (sha512_block_fn *)sha512_block_data_order);
 38 }
 39 
 40 int sha512_arm_final(struct shash_desc *desc, u8 *out)
 41 {
 42         sha512_base_do_finalize(desc,
 43                 (sha512_block_fn *)sha512_block_data_order);
 44         return sha512_base_finish(desc, out);
 45 }
 46 
 47 int sha512_arm_finup(struct shash_desc *desc, const u8 *data,
 48                      unsigned int len, u8 *out)
 49 {
 50         sha512_base_do_update(desc, data, len,
 51                 (sha512_block_fn *)sha512_block_data_order);
 52         return sha512_arm_final(desc, out);
 53 }
 54 
 55 static struct shash_alg sha512_arm_algs[] = { {
 56         .init                   = sha384_base_init,
 57         .update                 = sha512_arm_update,
 58         .final                  = sha512_arm_final,
 59         .finup                  = sha512_arm_finup,
 60         .descsize               = sizeof(struct sha512_state),
 61         .digestsize             = SHA384_DIGEST_SIZE,
 62         .base                   = {
 63                 .cra_name               = "sha384",
 64                 .cra_driver_name        = "sha384-arm",
 65                 .cra_priority           = 250,
 66                 .cra_flags              = CRYPTO_ALG_TYPE_SHASH,
 67                 .cra_blocksize          = SHA512_BLOCK_SIZE,
 68                 .cra_module             = THIS_MODULE,
 69         }
 70 },  {
 71         .init                   = sha512_base_init,
 72         .update                 = sha512_arm_update,
 73         .final                  = sha512_arm_final,
 74         .finup                  = sha512_arm_finup,
 75         .descsize               = sizeof(struct sha512_state),
 76         .digestsize             = SHA512_DIGEST_SIZE,
 77         .base                   = {
 78                 .cra_name               = "sha512",
 79                 .cra_driver_name        = "sha512-arm",
 80                 .cra_priority           = 250,
 81                 .cra_flags              = CRYPTO_ALG_TYPE_SHASH,
 82                 .cra_blocksize          = SHA512_BLOCK_SIZE,
 83                 .cra_module             = THIS_MODULE,
 84         }
 85 } };
 86 
 87 static int __init sha512_arm_mod_init(void)
 88 {
 89         int err;
 90 
 91         err = crypto_register_shashes(sha512_arm_algs,
 92                                       ARRAY_SIZE(sha512_arm_algs));
 93         if (err)
 94                 return err;
 95 
 96         if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && cpu_has_neon()) {
 97                 err = crypto_register_shashes(sha512_neon_algs,
 98                                               ARRAY_SIZE(sha512_neon_algs));
 99                 if (err)
100                         goto err_unregister;
101         }
102         return 0;
103 
104 err_unregister:
105         crypto_unregister_shashes(sha512_arm_algs,
106                                   ARRAY_SIZE(sha512_arm_algs));
107 
108         return err;
109 }
110 
111 static void __exit sha512_arm_mod_fini(void)
112 {
113         crypto_unregister_shashes(sha512_arm_algs,
114                                   ARRAY_SIZE(sha512_arm_algs));
115         if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && cpu_has_neon())
116                 crypto_unregister_shashes(sha512_neon_algs,
117                                           ARRAY_SIZE(sha512_neon_algs));
118 }
119 
120 module_init(sha512_arm_mod_init);
121 module_exit(sha512_arm_mod_fini);
122 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp