Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: morus - Mark MORUS SIMD glue as x86-specific

Commit 56e8e57fc3a7 ("crypto: morus - Add common SIMD glue code for
MORUS") accidetally consiedered the glue code to be usable by different
architectures, but it seems to be only usable on x86.

This patch moves it under arch/x86/crypto and adds 'depends on X86' to
the Kconfig options and also removes the prompt to hide these internal
options from the user.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Ondrej Mosnacek <omosnacek@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ondrej Mosnacek and committed by
Herbert Xu
2808f173 92a4c9fe

+153 -150
+3
arch/x86/crypto/Makefile
··· 42 42 obj-$(CONFIG_CRYPTO_AEGIS128L_AESNI_SSE2) += aegis128l-aesni.o 43 43 obj-$(CONFIG_CRYPTO_AEGIS256_AESNI_SSE2) += aegis256-aesni.o 44 44 45 + obj-$(CONFIG_CRYPTO_MORUS640_GLUE) += morus640_glue.o 46 + obj-$(CONFIG_CRYPTO_MORUS1280_GLUE) += morus1280_glue.o 47 + 45 48 obj-$(CONFIG_CRYPTO_MORUS640_SSE2) += morus640-sse2.o 46 49 obj-$(CONFIG_CRYPTO_MORUS1280_SSE2) += morus1280-sse2.o 47 50
+4 -2
crypto/Kconfig
··· 341 341 Support for the MORUS-640 dedicated AEAD algorithm. 342 342 343 343 config CRYPTO_MORUS640_GLUE 344 - tristate "MORUS-640 AEAD algorithm (glue for SIMD optimizations)" 344 + tristate 345 + depends on X86 345 346 select CRYPTO_AEAD 346 347 select CRYPTO_CRYPTD 347 348 help ··· 364 363 Support for the MORUS-1280 dedicated AEAD algorithm. 365 364 366 365 config CRYPTO_MORUS1280_GLUE 367 - tristate "MORUS-1280 AEAD algorithm (glue for SIMD optimizations)" 366 + tristate 367 + depends on X86 368 368 select CRYPTO_AEAD 369 369 select CRYPTO_CRYPTD 370 370 help
-2
crypto/Makefile
··· 91 91 obj-$(CONFIG_CRYPTO_AEGIS256) += aegis256.o 92 92 obj-$(CONFIG_CRYPTO_MORUS640) += morus640.o 93 93 obj-$(CONFIG_CRYPTO_MORUS1280) += morus1280.o 94 - obj-$(CONFIG_CRYPTO_MORUS640_GLUE) += morus640_glue.o 95 - obj-$(CONFIG_CRYPTO_MORUS1280_GLUE) += morus1280_glue.o 96 94 obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o 97 95 obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o 98 96 obj-$(CONFIG_CRYPTO_MCRYPTD) += mcryptd.o
+71 -75
crypto/morus1280_glue.c arch/x86/crypto/morus640_glue.c
··· 1 1 /* 2 - * The MORUS-1280 Authenticated-Encryption Algorithm 3 - * Common glue skeleton 2 + * The MORUS-640 Authenticated-Encryption Algorithm 3 + * Common x86 SIMD glue skeleton 4 4 * 5 5 * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com> 6 6 * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. ··· 14 14 #include <crypto/cryptd.h> 15 15 #include <crypto/internal/aead.h> 16 16 #include <crypto/internal/skcipher.h> 17 - #include <crypto/morus1280_glue.h> 17 + #include <crypto/morus640_glue.h> 18 18 #include <crypto/scatterwalk.h> 19 19 #include <linux/err.h> 20 20 #include <linux/init.h> ··· 23 23 #include <linux/scatterlist.h> 24 24 #include <asm/fpu/api.h> 25 25 26 - struct morus1280_state { 27 - struct morus1280_block s[MORUS_STATE_BLOCKS]; 26 + struct morus640_state { 27 + struct morus640_block s[MORUS_STATE_BLOCKS]; 28 28 }; 29 29 30 - struct morus1280_ops { 30 + struct morus640_ops { 31 31 int (*skcipher_walk_init)(struct skcipher_walk *walk, 32 32 struct aead_request *req, bool atomic); 33 33 ··· 37 37 unsigned int length); 38 38 }; 39 39 40 - static void crypto_morus1280_glue_process_ad( 41 - struct morus1280_state *state, 42 - const struct morus1280_glue_ops *ops, 40 + static void crypto_morus640_glue_process_ad( 41 + struct morus640_state *state, 42 + const struct morus640_glue_ops *ops, 43 43 struct scatterlist *sg_src, unsigned int assoclen) 44 44 { 45 45 struct scatter_walk walk; 46 - struct morus1280_block buf; 46 + struct morus640_block buf; 47 47 unsigned int pos = 0; 48 48 49 49 scatterwalk_start(&walk, sg_src); ··· 53 53 void *mapped = scatterwalk_map(&walk); 54 54 const u8 *src = (const u8 *)mapped; 55 55 56 - if (pos + size >= MORUS1280_BLOCK_SIZE) { 56 + if (pos + size >= MORUS640_BLOCK_SIZE) { 57 57 if (pos > 0) { 58 - unsigned int fill = MORUS1280_BLOCK_SIZE - pos; 58 + unsigned int fill = MORUS640_BLOCK_SIZE - pos; 59 59 memcpy(buf.bytes + pos, src, fill); 60 - ops->ad(state, buf.bytes, MORUS1280_BLOCK_SIZE); 60 + ops->ad(state, buf.bytes, MORUS640_BLOCK_SIZE); 61 61 pos = 0; 62 62 left -= fill; 63 63 src += fill; 64 64 } 65 65 66 66 ops->ad(state, src, left); 67 - src += left & ~(MORUS1280_BLOCK_SIZE - 1); 68 - left &= MORUS1280_BLOCK_SIZE - 1; 67 + src += left & ~(MORUS640_BLOCK_SIZE - 1); 68 + left &= MORUS640_BLOCK_SIZE - 1; 69 69 } 70 70 71 71 memcpy(buf.bytes + pos, src, left); ··· 78 78 } 79 79 80 80 if (pos > 0) { 81 - memset(buf.bytes + pos, 0, MORUS1280_BLOCK_SIZE - pos); 82 - ops->ad(state, buf.bytes, MORUS1280_BLOCK_SIZE); 81 + memset(buf.bytes + pos, 0, MORUS640_BLOCK_SIZE - pos); 82 + ops->ad(state, buf.bytes, MORUS640_BLOCK_SIZE); 83 83 } 84 84 } 85 85 86 - static void crypto_morus1280_glue_process_crypt(struct morus1280_state *state, 87 - struct morus1280_ops ops, 88 - struct aead_request *req) 86 + static void crypto_morus640_glue_process_crypt(struct morus640_state *state, 87 + struct morus640_ops ops, 88 + struct aead_request *req) 89 89 { 90 90 struct skcipher_walk walk; 91 91 u8 *cursor_src, *cursor_dst; ··· 100 100 101 101 ops.crypt_blocks(state, cursor_src, cursor_dst, chunksize); 102 102 103 - base = chunksize & ~(MORUS1280_BLOCK_SIZE - 1); 103 + base = chunksize & ~(MORUS640_BLOCK_SIZE - 1); 104 104 cursor_src += base; 105 105 cursor_dst += base; 106 - chunksize &= MORUS1280_BLOCK_SIZE - 1; 106 + chunksize &= MORUS640_BLOCK_SIZE - 1; 107 107 108 108 if (chunksize > 0) 109 109 ops.crypt_tail(state, cursor_src, cursor_dst, ··· 113 113 } 114 114 } 115 115 116 - int crypto_morus1280_glue_setkey(struct crypto_aead *aead, const u8 *key, 117 - unsigned int keylen) 116 + int crypto_morus640_glue_setkey(struct crypto_aead *aead, const u8 *key, 117 + unsigned int keylen) 118 118 { 119 - struct morus1280_ctx *ctx = crypto_aead_ctx(aead); 119 + struct morus640_ctx *ctx = crypto_aead_ctx(aead); 120 120 121 - if (keylen == MORUS1280_BLOCK_SIZE) { 122 - memcpy(ctx->key.bytes, key, MORUS1280_BLOCK_SIZE); 123 - } else if (keylen == MORUS1280_BLOCK_SIZE / 2) { 124 - memcpy(ctx->key.bytes, key, keylen); 125 - memcpy(ctx->key.bytes + keylen, key, keylen); 126 - } else { 121 + if (keylen != MORUS640_BLOCK_SIZE) { 127 122 crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); 128 123 return -EINVAL; 129 124 } 130 125 126 + memcpy(ctx->key.bytes, key, MORUS640_BLOCK_SIZE); 131 127 return 0; 132 128 } 133 - EXPORT_SYMBOL_GPL(crypto_morus1280_glue_setkey); 129 + EXPORT_SYMBOL_GPL(crypto_morus640_glue_setkey); 134 130 135 - int crypto_morus1280_glue_setauthsize(struct crypto_aead *tfm, 136 - unsigned int authsize) 131 + int crypto_morus640_glue_setauthsize(struct crypto_aead *tfm, 132 + unsigned int authsize) 137 133 { 138 134 return (authsize <= MORUS_MAX_AUTH_SIZE) ? 0 : -EINVAL; 139 135 } 140 - EXPORT_SYMBOL_GPL(crypto_morus1280_glue_setauthsize); 136 + EXPORT_SYMBOL_GPL(crypto_morus640_glue_setauthsize); 141 137 142 - static void crypto_morus1280_glue_crypt(struct aead_request *req, 143 - struct morus1280_ops ops, 144 - unsigned int cryptlen, 145 - struct morus1280_block *tag_xor) 138 + static void crypto_morus640_glue_crypt(struct aead_request *req, 139 + struct morus640_ops ops, 140 + unsigned int cryptlen, 141 + struct morus640_block *tag_xor) 146 142 { 147 143 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 148 - struct morus1280_ctx *ctx = crypto_aead_ctx(tfm); 149 - struct morus1280_state state; 144 + struct morus640_ctx *ctx = crypto_aead_ctx(tfm); 145 + struct morus640_state state; 150 146 151 147 kernel_fpu_begin(); 152 148 153 149 ctx->ops->init(&state, &ctx->key, req->iv); 154 - crypto_morus1280_glue_process_ad(&state, ctx->ops, req->src, req->assoclen); 155 - crypto_morus1280_glue_process_crypt(&state, ops, req); 150 + crypto_morus640_glue_process_ad(&state, ctx->ops, req->src, req->assoclen); 151 + crypto_morus640_glue_process_crypt(&state, ops, req); 156 152 ctx->ops->final(&state, tag_xor, req->assoclen, cryptlen); 157 153 158 154 kernel_fpu_end(); 159 155 } 160 156 161 - int crypto_morus1280_glue_encrypt(struct aead_request *req) 157 + int crypto_morus640_glue_encrypt(struct aead_request *req) 162 158 { 163 159 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 164 - struct morus1280_ctx *ctx = crypto_aead_ctx(tfm); 165 - struct morus1280_ops OPS = { 160 + struct morus640_ctx *ctx = crypto_aead_ctx(tfm); 161 + struct morus640_ops OPS = { 166 162 .skcipher_walk_init = skcipher_walk_aead_encrypt, 167 163 .crypt_blocks = ctx->ops->enc, 168 164 .crypt_tail = ctx->ops->enc_tail, 169 165 }; 170 166 171 - struct morus1280_block tag = {}; 167 + struct morus640_block tag = {}; 172 168 unsigned int authsize = crypto_aead_authsize(tfm); 173 169 unsigned int cryptlen = req->cryptlen; 174 170 175 - crypto_morus1280_glue_crypt(req, OPS, cryptlen, &tag); 171 + crypto_morus640_glue_crypt(req, OPS, cryptlen, &tag); 176 172 177 173 scatterwalk_map_and_copy(tag.bytes, req->dst, 178 174 req->assoclen + cryptlen, authsize, 1); 179 175 return 0; 180 176 } 181 - EXPORT_SYMBOL_GPL(crypto_morus1280_glue_encrypt); 177 + EXPORT_SYMBOL_GPL(crypto_morus640_glue_encrypt); 182 178 183 - int crypto_morus1280_glue_decrypt(struct aead_request *req) 179 + int crypto_morus640_glue_decrypt(struct aead_request *req) 184 180 { 185 - static const u8 zeros[MORUS1280_BLOCK_SIZE] = {}; 181 + static const u8 zeros[MORUS640_BLOCK_SIZE] = {}; 186 182 187 183 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 188 - struct morus1280_ctx *ctx = crypto_aead_ctx(tfm); 189 - struct morus1280_ops OPS = { 184 + struct morus640_ctx *ctx = crypto_aead_ctx(tfm); 185 + struct morus640_ops OPS = { 190 186 .skcipher_walk_init = skcipher_walk_aead_decrypt, 191 187 .crypt_blocks = ctx->ops->dec, 192 188 .crypt_tail = ctx->ops->dec_tail, 193 189 }; 194 190 195 - struct morus1280_block tag; 191 + struct morus640_block tag; 196 192 unsigned int authsize = crypto_aead_authsize(tfm); 197 193 unsigned int cryptlen = req->cryptlen - authsize; 198 194 199 195 scatterwalk_map_and_copy(tag.bytes, req->src, 200 196 req->assoclen + cryptlen, authsize, 0); 201 197 202 - crypto_morus1280_glue_crypt(req, OPS, cryptlen, &tag); 198 + crypto_morus640_glue_crypt(req, OPS, cryptlen, &tag); 203 199 204 200 return crypto_memneq(tag.bytes, zeros, authsize) ? -EBADMSG : 0; 205 201 } 206 - EXPORT_SYMBOL_GPL(crypto_morus1280_glue_decrypt); 202 + EXPORT_SYMBOL_GPL(crypto_morus640_glue_decrypt); 207 203 208 - void crypto_morus1280_glue_init_ops(struct crypto_aead *aead, 209 - const struct morus1280_glue_ops *ops) 204 + void crypto_morus640_glue_init_ops(struct crypto_aead *aead, 205 + const struct morus640_glue_ops *ops) 210 206 { 211 - struct morus1280_ctx *ctx = crypto_aead_ctx(aead); 207 + struct morus640_ctx *ctx = crypto_aead_ctx(aead); 212 208 ctx->ops = ops; 213 209 } 214 - EXPORT_SYMBOL_GPL(crypto_morus1280_glue_init_ops); 210 + EXPORT_SYMBOL_GPL(crypto_morus640_glue_init_ops); 215 211 216 - int cryptd_morus1280_glue_setkey(struct crypto_aead *aead, const u8 *key, 217 - unsigned int keylen) 212 + int cryptd_morus640_glue_setkey(struct crypto_aead *aead, const u8 *key, 213 + unsigned int keylen) 218 214 { 219 215 struct cryptd_aead **ctx = crypto_aead_ctx(aead); 220 216 struct cryptd_aead *cryptd_tfm = *ctx; 221 217 222 218 return crypto_aead_setkey(&cryptd_tfm->base, key, keylen); 223 219 } 224 - EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_setkey); 220 + EXPORT_SYMBOL_GPL(cryptd_morus640_glue_setkey); 225 221 226 - int cryptd_morus1280_glue_setauthsize(struct crypto_aead *aead, 227 - unsigned int authsize) 222 + int cryptd_morus640_glue_setauthsize(struct crypto_aead *aead, 223 + unsigned int authsize) 228 224 { 229 225 struct cryptd_aead **ctx = crypto_aead_ctx(aead); 230 226 struct cryptd_aead *cryptd_tfm = *ctx; 231 227 232 228 return crypto_aead_setauthsize(&cryptd_tfm->base, authsize); 233 229 } 234 - EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_setauthsize); 230 + EXPORT_SYMBOL_GPL(cryptd_morus640_glue_setauthsize); 235 231 236 - int cryptd_morus1280_glue_encrypt(struct aead_request *req) 232 + int cryptd_morus640_glue_encrypt(struct aead_request *req) 237 233 { 238 234 struct crypto_aead *aead = crypto_aead_reqtfm(req); 239 235 struct cryptd_aead **ctx = crypto_aead_ctx(aead); ··· 244 248 245 249 return crypto_aead_encrypt(req); 246 250 } 247 - EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_encrypt); 251 + EXPORT_SYMBOL_GPL(cryptd_morus640_glue_encrypt); 248 252 249 - int cryptd_morus1280_glue_decrypt(struct aead_request *req) 253 + int cryptd_morus640_glue_decrypt(struct aead_request *req) 250 254 { 251 255 struct crypto_aead *aead = crypto_aead_reqtfm(req); 252 256 struct cryptd_aead **ctx = crypto_aead_ctx(aead); ··· 261 265 262 266 return crypto_aead_decrypt(req); 263 267 } 264 - EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_decrypt); 268 + EXPORT_SYMBOL_GPL(cryptd_morus640_glue_decrypt); 265 269 266 - int cryptd_morus1280_glue_init_tfm(struct crypto_aead *aead) 270 + int cryptd_morus640_glue_init_tfm(struct crypto_aead *aead) 267 271 { 268 272 struct cryptd_aead *cryptd_tfm; 269 273 struct cryptd_aead **ctx = crypto_aead_ctx(aead); ··· 283 287 crypto_aead_set_reqsize(aead, crypto_aead_reqsize(&cryptd_tfm->base)); 284 288 return 0; 285 289 } 286 - EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_init_tfm); 290 + EXPORT_SYMBOL_GPL(cryptd_morus640_glue_init_tfm); 287 291 288 - void cryptd_morus1280_glue_exit_tfm(struct crypto_aead *aead) 292 + void cryptd_morus640_glue_exit_tfm(struct crypto_aead *aead) 289 293 { 290 294 struct cryptd_aead **ctx = crypto_aead_ctx(aead); 291 295 292 296 cryptd_free_aead(*ctx); 293 297 } 294 - EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_exit_tfm); 298 + EXPORT_SYMBOL_GPL(cryptd_morus640_glue_exit_tfm); 295 299 296 300 MODULE_LICENSE("GPL"); 297 301 MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>"); 298 - MODULE_DESCRIPTION("MORUS-1280 AEAD mode -- glue for optimizations"); 302 + MODULE_DESCRIPTION("MORUS-640 AEAD mode -- glue for x86 optimizations");
+75 -71
crypto/morus640_glue.c arch/x86/crypto/morus1280_glue.c
··· 1 1 /* 2 - * The MORUS-640 Authenticated-Encryption Algorithm 3 - * Common glue skeleton 2 + * The MORUS-1280 Authenticated-Encryption Algorithm 3 + * Common x86 SIMD glue skeleton 4 4 * 5 5 * Copyright (c) 2016-2018 Ondrej Mosnacek <omosnacek@gmail.com> 6 6 * Copyright (C) 2017-2018 Red Hat, Inc. All rights reserved. ··· 14 14 #include <crypto/cryptd.h> 15 15 #include <crypto/internal/aead.h> 16 16 #include <crypto/internal/skcipher.h> 17 - #include <crypto/morus640_glue.h> 17 + #include <crypto/morus1280_glue.h> 18 18 #include <crypto/scatterwalk.h> 19 19 #include <linux/err.h> 20 20 #include <linux/init.h> ··· 23 23 #include <linux/scatterlist.h> 24 24 #include <asm/fpu/api.h> 25 25 26 - struct morus640_state { 27 - struct morus640_block s[MORUS_STATE_BLOCKS]; 26 + struct morus1280_state { 27 + struct morus1280_block s[MORUS_STATE_BLOCKS]; 28 28 }; 29 29 30 - struct morus640_ops { 30 + struct morus1280_ops { 31 31 int (*skcipher_walk_init)(struct skcipher_walk *walk, 32 32 struct aead_request *req, bool atomic); 33 33 ··· 37 37 unsigned int length); 38 38 }; 39 39 40 - static void crypto_morus640_glue_process_ad( 41 - struct morus640_state *state, 42 - const struct morus640_glue_ops *ops, 40 + static void crypto_morus1280_glue_process_ad( 41 + struct morus1280_state *state, 42 + const struct morus1280_glue_ops *ops, 43 43 struct scatterlist *sg_src, unsigned int assoclen) 44 44 { 45 45 struct scatter_walk walk; 46 - struct morus640_block buf; 46 + struct morus1280_block buf; 47 47 unsigned int pos = 0; 48 48 49 49 scatterwalk_start(&walk, sg_src); ··· 53 53 void *mapped = scatterwalk_map(&walk); 54 54 const u8 *src = (const u8 *)mapped; 55 55 56 - if (pos + size >= MORUS640_BLOCK_SIZE) { 56 + if (pos + size >= MORUS1280_BLOCK_SIZE) { 57 57 if (pos > 0) { 58 - unsigned int fill = MORUS640_BLOCK_SIZE - pos; 58 + unsigned int fill = MORUS1280_BLOCK_SIZE - pos; 59 59 memcpy(buf.bytes + pos, src, fill); 60 - ops->ad(state, buf.bytes, MORUS640_BLOCK_SIZE); 60 + ops->ad(state, buf.bytes, MORUS1280_BLOCK_SIZE); 61 61 pos = 0; 62 62 left -= fill; 63 63 src += fill; 64 64 } 65 65 66 66 ops->ad(state, src, left); 67 - src += left & ~(MORUS640_BLOCK_SIZE - 1); 68 - left &= MORUS640_BLOCK_SIZE - 1; 67 + src += left & ~(MORUS1280_BLOCK_SIZE - 1); 68 + left &= MORUS1280_BLOCK_SIZE - 1; 69 69 } 70 70 71 71 memcpy(buf.bytes + pos, src, left); ··· 78 78 } 79 79 80 80 if (pos > 0) { 81 - memset(buf.bytes + pos, 0, MORUS640_BLOCK_SIZE - pos); 82 - ops->ad(state, buf.bytes, MORUS640_BLOCK_SIZE); 81 + memset(buf.bytes + pos, 0, MORUS1280_BLOCK_SIZE - pos); 82 + ops->ad(state, buf.bytes, MORUS1280_BLOCK_SIZE); 83 83 } 84 84 } 85 85 86 - static void crypto_morus640_glue_process_crypt(struct morus640_state *state, 87 - struct morus640_ops ops, 88 - struct aead_request *req) 86 + static void crypto_morus1280_glue_process_crypt(struct morus1280_state *state, 87 + struct morus1280_ops ops, 88 + struct aead_request *req) 89 89 { 90 90 struct skcipher_walk walk; 91 91 u8 *cursor_src, *cursor_dst; ··· 100 100 101 101 ops.crypt_blocks(state, cursor_src, cursor_dst, chunksize); 102 102 103 - base = chunksize & ~(MORUS640_BLOCK_SIZE - 1); 103 + base = chunksize & ~(MORUS1280_BLOCK_SIZE - 1); 104 104 cursor_src += base; 105 105 cursor_dst += base; 106 - chunksize &= MORUS640_BLOCK_SIZE - 1; 106 + chunksize &= MORUS1280_BLOCK_SIZE - 1; 107 107 108 108 if (chunksize > 0) 109 109 ops.crypt_tail(state, cursor_src, cursor_dst, ··· 113 113 } 114 114 } 115 115 116 - int crypto_morus640_glue_setkey(struct crypto_aead *aead, const u8 *key, 117 - unsigned int keylen) 116 + int crypto_morus1280_glue_setkey(struct crypto_aead *aead, const u8 *key, 117 + unsigned int keylen) 118 118 { 119 - struct morus640_ctx *ctx = crypto_aead_ctx(aead); 119 + struct morus1280_ctx *ctx = crypto_aead_ctx(aead); 120 120 121 - if (keylen != MORUS640_BLOCK_SIZE) { 121 + if (keylen == MORUS1280_BLOCK_SIZE) { 122 + memcpy(ctx->key.bytes, key, MORUS1280_BLOCK_SIZE); 123 + } else if (keylen == MORUS1280_BLOCK_SIZE / 2) { 124 + memcpy(ctx->key.bytes, key, keylen); 125 + memcpy(ctx->key.bytes + keylen, key, keylen); 126 + } else { 122 127 crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); 123 128 return -EINVAL; 124 129 } 125 130 126 - memcpy(ctx->key.bytes, key, MORUS640_BLOCK_SIZE); 127 131 return 0; 128 132 } 129 - EXPORT_SYMBOL_GPL(crypto_morus640_glue_setkey); 133 + EXPORT_SYMBOL_GPL(crypto_morus1280_glue_setkey); 130 134 131 - int crypto_morus640_glue_setauthsize(struct crypto_aead *tfm, 132 - unsigned int authsize) 135 + int crypto_morus1280_glue_setauthsize(struct crypto_aead *tfm, 136 + unsigned int authsize) 133 137 { 134 138 return (authsize <= MORUS_MAX_AUTH_SIZE) ? 0 : -EINVAL; 135 139 } 136 - EXPORT_SYMBOL_GPL(crypto_morus640_glue_setauthsize); 140 + EXPORT_SYMBOL_GPL(crypto_morus1280_glue_setauthsize); 137 141 138 - static void crypto_morus640_glue_crypt(struct aead_request *req, 139 - struct morus640_ops ops, 140 - unsigned int cryptlen, 141 - struct morus640_block *tag_xor) 142 + static void crypto_morus1280_glue_crypt(struct aead_request *req, 143 + struct morus1280_ops ops, 144 + unsigned int cryptlen, 145 + struct morus1280_block *tag_xor) 142 146 { 143 147 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 144 - struct morus640_ctx *ctx = crypto_aead_ctx(tfm); 145 - struct morus640_state state; 148 + struct morus1280_ctx *ctx = crypto_aead_ctx(tfm); 149 + struct morus1280_state state; 146 150 147 151 kernel_fpu_begin(); 148 152 149 153 ctx->ops->init(&state, &ctx->key, req->iv); 150 - crypto_morus640_glue_process_ad(&state, ctx->ops, req->src, req->assoclen); 151 - crypto_morus640_glue_process_crypt(&state, ops, req); 154 + crypto_morus1280_glue_process_ad(&state, ctx->ops, req->src, req->assoclen); 155 + crypto_morus1280_glue_process_crypt(&state, ops, req); 152 156 ctx->ops->final(&state, tag_xor, req->assoclen, cryptlen); 153 157 154 158 kernel_fpu_end(); 155 159 } 156 160 157 - int crypto_morus640_glue_encrypt(struct aead_request *req) 161 + int crypto_morus1280_glue_encrypt(struct aead_request *req) 158 162 { 159 163 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 160 - struct morus640_ctx *ctx = crypto_aead_ctx(tfm); 161 - struct morus640_ops OPS = { 164 + struct morus1280_ctx *ctx = crypto_aead_ctx(tfm); 165 + struct morus1280_ops OPS = { 162 166 .skcipher_walk_init = skcipher_walk_aead_encrypt, 163 167 .crypt_blocks = ctx->ops->enc, 164 168 .crypt_tail = ctx->ops->enc_tail, 165 169 }; 166 170 167 - struct morus640_block tag = {}; 171 + struct morus1280_block tag = {}; 168 172 unsigned int authsize = crypto_aead_authsize(tfm); 169 173 unsigned int cryptlen = req->cryptlen; 170 174 171 - crypto_morus640_glue_crypt(req, OPS, cryptlen, &tag); 175 + crypto_morus1280_glue_crypt(req, OPS, cryptlen, &tag); 172 176 173 177 scatterwalk_map_and_copy(tag.bytes, req->dst, 174 178 req->assoclen + cryptlen, authsize, 1); 175 179 return 0; 176 180 } 177 - EXPORT_SYMBOL_GPL(crypto_morus640_glue_encrypt); 181 + EXPORT_SYMBOL_GPL(crypto_morus1280_glue_encrypt); 178 182 179 - int crypto_morus640_glue_decrypt(struct aead_request *req) 183 + int crypto_morus1280_glue_decrypt(struct aead_request *req) 180 184 { 181 - static const u8 zeros[MORUS640_BLOCK_SIZE] = {}; 185 + static const u8 zeros[MORUS1280_BLOCK_SIZE] = {}; 182 186 183 187 struct crypto_aead *tfm = crypto_aead_reqtfm(req); 184 - struct morus640_ctx *ctx = crypto_aead_ctx(tfm); 185 - struct morus640_ops OPS = { 188 + struct morus1280_ctx *ctx = crypto_aead_ctx(tfm); 189 + struct morus1280_ops OPS = { 186 190 .skcipher_walk_init = skcipher_walk_aead_decrypt, 187 191 .crypt_blocks = ctx->ops->dec, 188 192 .crypt_tail = ctx->ops->dec_tail, 189 193 }; 190 194 191 - struct morus640_block tag; 195 + struct morus1280_block tag; 192 196 unsigned int authsize = crypto_aead_authsize(tfm); 193 197 unsigned int cryptlen = req->cryptlen - authsize; 194 198 195 199 scatterwalk_map_and_copy(tag.bytes, req->src, 196 200 req->assoclen + cryptlen, authsize, 0); 197 201 198 - crypto_morus640_glue_crypt(req, OPS, cryptlen, &tag); 202 + crypto_morus1280_glue_crypt(req, OPS, cryptlen, &tag); 199 203 200 204 return crypto_memneq(tag.bytes, zeros, authsize) ? -EBADMSG : 0; 201 205 } 202 - EXPORT_SYMBOL_GPL(crypto_morus640_glue_decrypt); 206 + EXPORT_SYMBOL_GPL(crypto_morus1280_glue_decrypt); 203 207 204 - void crypto_morus640_glue_init_ops(struct crypto_aead *aead, 205 - const struct morus640_glue_ops *ops) 208 + void crypto_morus1280_glue_init_ops(struct crypto_aead *aead, 209 + const struct morus1280_glue_ops *ops) 206 210 { 207 - struct morus640_ctx *ctx = crypto_aead_ctx(aead); 211 + struct morus1280_ctx *ctx = crypto_aead_ctx(aead); 208 212 ctx->ops = ops; 209 213 } 210 - EXPORT_SYMBOL_GPL(crypto_morus640_glue_init_ops); 214 + EXPORT_SYMBOL_GPL(crypto_morus1280_glue_init_ops); 211 215 212 - int cryptd_morus640_glue_setkey(struct crypto_aead *aead, const u8 *key, 213 - unsigned int keylen) 216 + int cryptd_morus1280_glue_setkey(struct crypto_aead *aead, const u8 *key, 217 + unsigned int keylen) 214 218 { 215 219 struct cryptd_aead **ctx = crypto_aead_ctx(aead); 216 220 struct cryptd_aead *cryptd_tfm = *ctx; 217 221 218 222 return crypto_aead_setkey(&cryptd_tfm->base, key, keylen); 219 223 } 220 - EXPORT_SYMBOL_GPL(cryptd_morus640_glue_setkey); 224 + EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_setkey); 221 225 222 - int cryptd_morus640_glue_setauthsize(struct crypto_aead *aead, 223 - unsigned int authsize) 226 + int cryptd_morus1280_glue_setauthsize(struct crypto_aead *aead, 227 + unsigned int authsize) 224 228 { 225 229 struct cryptd_aead **ctx = crypto_aead_ctx(aead); 226 230 struct cryptd_aead *cryptd_tfm = *ctx; 227 231 228 232 return crypto_aead_setauthsize(&cryptd_tfm->base, authsize); 229 233 } 230 - EXPORT_SYMBOL_GPL(cryptd_morus640_glue_setauthsize); 234 + EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_setauthsize); 231 235 232 - int cryptd_morus640_glue_encrypt(struct aead_request *req) 236 + int cryptd_morus1280_glue_encrypt(struct aead_request *req) 233 237 { 234 238 struct crypto_aead *aead = crypto_aead_reqtfm(req); 235 239 struct cryptd_aead **ctx = crypto_aead_ctx(aead); ··· 248 244 249 245 return crypto_aead_encrypt(req); 250 246 } 251 - EXPORT_SYMBOL_GPL(cryptd_morus640_glue_encrypt); 247 + EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_encrypt); 252 248 253 - int cryptd_morus640_glue_decrypt(struct aead_request *req) 249 + int cryptd_morus1280_glue_decrypt(struct aead_request *req) 254 250 { 255 251 struct crypto_aead *aead = crypto_aead_reqtfm(req); 256 252 struct cryptd_aead **ctx = crypto_aead_ctx(aead); ··· 265 261 266 262 return crypto_aead_decrypt(req); 267 263 } 268 - EXPORT_SYMBOL_GPL(cryptd_morus640_glue_decrypt); 264 + EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_decrypt); 269 265 270 - int cryptd_morus640_glue_init_tfm(struct crypto_aead *aead) 266 + int cryptd_morus1280_glue_init_tfm(struct crypto_aead *aead) 271 267 { 272 268 struct cryptd_aead *cryptd_tfm; 273 269 struct cryptd_aead **ctx = crypto_aead_ctx(aead); ··· 287 283 crypto_aead_set_reqsize(aead, crypto_aead_reqsize(&cryptd_tfm->base)); 288 284 return 0; 289 285 } 290 - EXPORT_SYMBOL_GPL(cryptd_morus640_glue_init_tfm); 286 + EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_init_tfm); 291 287 292 - void cryptd_morus640_glue_exit_tfm(struct crypto_aead *aead) 288 + void cryptd_morus1280_glue_exit_tfm(struct crypto_aead *aead) 293 289 { 294 290 struct cryptd_aead **ctx = crypto_aead_ctx(aead); 295 291 296 292 cryptd_free_aead(*ctx); 297 293 } 298 - EXPORT_SYMBOL_GPL(cryptd_morus640_glue_exit_tfm); 294 + EXPORT_SYMBOL_GPL(cryptd_morus1280_glue_exit_tfm); 299 295 300 296 MODULE_LICENSE("GPL"); 301 297 MODULE_AUTHOR("Ondrej Mosnacek <omosnacek@gmail.com>"); 302 - MODULE_DESCRIPTION("MORUS-640 AEAD mode -- glue for optimizations"); 298 + MODULE_DESCRIPTION("MORUS-1280 AEAD mode -- glue for x86 optimizations");