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

TOMOYO Linux Cross Reference
Linux/include/crypto/morus640_glue.h

Version: ~ [ linux-5.18 ] ~ [ linux-5.17.9 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.41 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.117 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.195 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.244 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.280 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.315 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * The MORUS-640 Authenticated-Encryption Algorithm
  4  *   Common glue skeleton -- header file
  5  *
  6  * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com>
  7  * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved.
  8  *
  9  * This program is free software; you can redistribute it and/or modify it
 10  * under the terms of the GNU General Public License as published by the Free
 11  * Software Foundation; either version 2 of the License, or (at your option)
 12  * any later version.
 13  */
 14 
 15 #ifndef _CRYPTO_MORUS640_GLUE_H
 16 #define _CRYPTO_MORUS640_GLUE_H
 17 
 18 #include <linux/module.h>
 19 #include <linux/types.h>
 20 #include <crypto/algapi.h>
 21 #include <crypto/aead.h>
 22 #include <crypto/morus_common.h>
 23 
 24 #define MORUS640_WORD_SIZE 4
 25 #define MORUS640_BLOCK_SIZE (MORUS_BLOCK_WORDS * MORUS640_WORD_SIZE)
 26 
 27 struct morus640_block {
 28         u8 bytes[MORUS640_BLOCK_SIZE];
 29 };
 30 
 31 struct morus640_glue_ops {
 32         void (*init)(void *state, const void *key, const void *iv);
 33         void (*ad)(void *state, const void *data, unsigned int length);
 34         void (*enc)(void *state, const void *src, void *dst, unsigned int length);
 35         void (*dec)(void *state, const void *src, void *dst, unsigned int length);
 36         void (*enc_tail)(void *state, const void *src, void *dst, unsigned int length);
 37         void (*dec_tail)(void *state, const void *src, void *dst, unsigned int length);
 38         void (*final)(void *state, void *tag_xor, u64 assoclen, u64 cryptlen);
 39 };
 40 
 41 struct morus640_ctx {
 42         const struct morus640_glue_ops *ops;
 43         struct morus640_block key;
 44 };
 45 
 46 void crypto_morus640_glue_init_ops(struct crypto_aead *aead,
 47                                    const struct morus640_glue_ops *ops);
 48 int crypto_morus640_glue_setkey(struct crypto_aead *aead, const u8 *key,
 49                                 unsigned int keylen);
 50 int crypto_morus640_glue_setauthsize(struct crypto_aead *tfm,
 51                                      unsigned int authsize);
 52 int crypto_morus640_glue_encrypt(struct aead_request *req);
 53 int crypto_morus640_glue_decrypt(struct aead_request *req);
 54 
 55 int cryptd_morus640_glue_setkey(struct crypto_aead *aead, const u8 *key,
 56                                 unsigned int keylen);
 57 int cryptd_morus640_glue_setauthsize(struct crypto_aead *aead,
 58                                      unsigned int authsize);
 59 int cryptd_morus640_glue_encrypt(struct aead_request *req);
 60 int cryptd_morus640_glue_decrypt(struct aead_request *req);
 61 int cryptd_morus640_glue_init_tfm(struct crypto_aead *aead);
 62 void cryptd_morus640_glue_exit_tfm(struct crypto_aead *aead);
 63 
 64 #define MORUS640_DECLARE_ALGS(id, driver_name, priority) \
 65         static const struct morus640_glue_ops crypto_morus640_##id##_ops = {\
 66                 .init = crypto_morus640_##id##_init, \
 67                 .ad = crypto_morus640_##id##_ad, \
 68                 .enc = crypto_morus640_##id##_enc, \
 69                 .enc_tail = crypto_morus640_##id##_enc_tail, \
 70                 .dec = crypto_morus640_##id##_dec, \
 71                 .dec_tail = crypto_morus640_##id##_dec_tail, \
 72                 .final = crypto_morus640_##id##_final, \
 73         }; \
 74         \
 75         static int crypto_morus640_##id##_init_tfm(struct crypto_aead *tfm) \
 76         { \
 77                 crypto_morus640_glue_init_ops(tfm, &crypto_morus640_##id##_ops); \
 78                 return 0; \
 79         } \
 80         \
 81         static void crypto_morus640_##id##_exit_tfm(struct crypto_aead *tfm) \
 82         { \
 83         } \
 84         \
 85         struct aead_alg crypto_morus640_##id##_algs[] = {\
 86                 { \
 87                         .setkey = crypto_morus640_glue_setkey, \
 88                         .setauthsize = crypto_morus640_glue_setauthsize, \
 89                         .encrypt = crypto_morus640_glue_encrypt, \
 90                         .decrypt = crypto_morus640_glue_decrypt, \
 91                         .init = crypto_morus640_##id##_init_tfm, \
 92                         .exit = crypto_morus640_##id##_exit_tfm, \
 93                         \
 94                         .ivsize = MORUS_NONCE_SIZE, \
 95                         .maxauthsize = MORUS_MAX_AUTH_SIZE, \
 96                         .chunksize = MORUS640_BLOCK_SIZE, \
 97                         \
 98                         .base = { \
 99                                 .cra_flags = CRYPTO_ALG_INTERNAL, \
100                                 .cra_blocksize = 1, \
101                                 .cra_ctxsize = sizeof(struct morus640_ctx), \
102                                 .cra_alignmask = 0, \
103                                 \
104                                 .cra_name = "__morus640", \
105                                 .cra_driver_name = "__"driver_name, \
106                                 \
107                                 .cra_module = THIS_MODULE, \
108                         } \
109                 }, { \
110                         .setkey = cryptd_morus640_glue_setkey, \
111                         .setauthsize = cryptd_morus640_glue_setauthsize, \
112                         .encrypt = cryptd_morus640_glue_encrypt, \
113                         .decrypt = cryptd_morus640_glue_decrypt, \
114                         .init = cryptd_morus640_glue_init_tfm, \
115                         .exit = cryptd_morus640_glue_exit_tfm, \
116                         \
117                         .ivsize = MORUS_NONCE_SIZE, \
118                         .maxauthsize = MORUS_MAX_AUTH_SIZE, \
119                         .chunksize = MORUS640_BLOCK_SIZE, \
120                         \
121                         .base = { \
122                                 .cra_flags = CRYPTO_ALG_ASYNC, \
123                                 .cra_blocksize = 1, \
124                                 .cra_ctxsize = sizeof(struct crypto_aead *), \
125                                 .cra_alignmask = 0, \
126                                 \
127                                 .cra_priority = priority, \
128                                 \
129                                 .cra_name = "morus640", \
130                                 .cra_driver_name = driver_name, \
131                                 \
132                                 .cra_module = THIS_MODULE, \
133                         } \
134                 } \
135         }
136 
137 #endif /* _CRYPTO_MORUS640_GLUE_H */
138 

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