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

TOMOYO Linux Cross Reference
Linux/arch/arm/crypto/aes_glue.c

Version: ~ [ linux-5.8 ] ~ [ linux-5.7.14 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.57 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.138 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.193 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.232 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.232 ] ~ [ 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.85 ] ~ [ 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-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  * Glue Code for the asm optimized version of the AES Cipher Algorithm
  3  */
  4 
  5 #include <linux/module.h>
  6 #include <linux/crypto.h>
  7 #include <crypto/aes.h>
  8 
  9 #include "aes_glue.h"
 10 
 11 EXPORT_SYMBOL(AES_encrypt);
 12 EXPORT_SYMBOL(AES_decrypt);
 13 EXPORT_SYMBOL(private_AES_set_encrypt_key);
 14 EXPORT_SYMBOL(private_AES_set_decrypt_key);
 15 
 16 static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 17 {
 18         struct AES_CTX *ctx = crypto_tfm_ctx(tfm);
 19         AES_encrypt(src, dst, &ctx->enc_key);
 20 }
 21 
 22 static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 23 {
 24         struct AES_CTX *ctx = crypto_tfm_ctx(tfm);
 25         AES_decrypt(src, dst, &ctx->dec_key);
 26 }
 27 
 28 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
 29                 unsigned int key_len)
 30 {
 31         struct AES_CTX *ctx = crypto_tfm_ctx(tfm);
 32 
 33         switch (key_len) {
 34         case AES_KEYSIZE_128:
 35                 key_len = 128;
 36                 break;
 37         case AES_KEYSIZE_192:
 38                 key_len = 192;
 39                 break;
 40         case AES_KEYSIZE_256:
 41                 key_len = 256;
 42                 break;
 43         default:
 44                 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
 45                 return -EINVAL;
 46         }
 47 
 48         if (private_AES_set_encrypt_key(in_key, key_len, &ctx->enc_key) == -1) {
 49                 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
 50                 return -EINVAL;
 51         }
 52         /* private_AES_set_decrypt_key expects an encryption key as input */
 53         ctx->dec_key = ctx->enc_key;
 54         if (private_AES_set_decrypt_key(in_key, key_len, &ctx->dec_key) == -1) {
 55                 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
 56                 return -EINVAL;
 57         }
 58         return 0;
 59 }
 60 
 61 static struct crypto_alg aes_alg = {
 62         .cra_name               = "aes",
 63         .cra_driver_name        = "aes-asm",
 64         .cra_priority           = 200,
 65         .cra_flags              = CRYPTO_ALG_TYPE_CIPHER,
 66         .cra_blocksize          = AES_BLOCK_SIZE,
 67         .cra_ctxsize            = sizeof(struct AES_CTX),
 68         .cra_module             = THIS_MODULE,
 69         .cra_list               = LIST_HEAD_INIT(aes_alg.cra_list),
 70         .cra_u  = {
 71                 .cipher = {
 72                         .cia_min_keysize        = AES_MIN_KEY_SIZE,
 73                         .cia_max_keysize        = AES_MAX_KEY_SIZE,
 74                         .cia_setkey             = aes_set_key,
 75                         .cia_encrypt            = aes_encrypt,
 76                         .cia_decrypt            = aes_decrypt
 77                 }
 78         }
 79 };
 80 
 81 static int __init aes_init(void)
 82 {
 83         return crypto_register_alg(&aes_alg);
 84 }
 85 
 86 static void __exit aes_fini(void)
 87 {
 88         crypto_unregister_alg(&aes_alg);
 89 }
 90 
 91 module_init(aes_init);
 92 module_exit(aes_fini);
 93 
 94 MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm (ASM)");
 95 MODULE_LICENSE("GPL");
 96 MODULE_ALIAS_CRYPTO("aes");
 97 MODULE_ALIAS_CRYPTO("aes-asm");
 98 MODULE_AUTHOR("David McCullough <ucdevel@gmail.com>");
 99 

~ [ 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