1 /* 1 /* 2 * Key Wrapping: RFC3394 / NIST SP800-38F 2 * Key Wrapping: RFC3394 / NIST SP800-38F 3 * 3 * 4 * Copyright (C) 2015, Stephan Mueller <smuell 4 * Copyright (C) 2015, Stephan Mueller <smueller@chronox.de> 5 * 5 * 6 * Redistribution and use in source and binary 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that t 7 * modification, are permitted provided that the following conditions 8 * are met: 8 * are met: 9 * 1. Redistributions of source code must reta 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, and the entire permission notice 10 * notice, and the entire permission notice in its entirety, 11 * including the disclaimer of warranties. 11 * including the disclaimer of warranties. 12 * 2. Redistributions in binary form must repr 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials pro 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used t 15 * 3. The name of the author may not be used to endorse or promote 16 * products derived from this software with 16 * products derived from this software without specific prior 17 * written permission. 17 * written permission. 18 * 18 * 19 * ALTERNATIVELY, this product may be distribu 19 * ALTERNATIVELY, this product may be distributed under the terms of 20 * the GNU General Public License, in which ca 20 * the GNU General Public License, in which case the provisions of the GPL2 21 * are required INSTEAD OF the above restricti 21 * are required INSTEAD OF the above restrictions. (This clause is 22 * necessary due to a potential bad interactio 22 * necessary due to a potential bad interaction between the GPL and 23 * the restrictions contained in a BSD-style c 23 * the restrictions contained in a BSD-style copyright.) 24 * 24 * 25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY 25 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 26 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 * OF MERCHANTABILITY AND FITNESS FOR A PARTIC 27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF 28 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT S 28 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL 29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT L 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 31 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF US 31 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND O 32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIAB 33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 35 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED O 35 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH 36 * DAMAGE. 36 * DAMAGE. 37 */ 37 */ 38 38 39 /* 39 /* 40 * Note for using key wrapping: 40 * Note for using key wrapping: 41 * 41 * 42 * * The result of the encryption operati 42 * * The result of the encryption operation is the ciphertext starting 43 * with the 2nd semiblock. The first se 43 * with the 2nd semiblock. The first semiblock is provided as the IV. 44 * The IV used to start the encryption 44 * The IV used to start the encryption operation is the default IV. 45 * 45 * 46 * * The input for the decryption is the 46 * * The input for the decryption is the first semiblock handed in as an 47 * IV. The ciphertext is the data start 47 * IV. The ciphertext is the data starting with the 2nd semiblock. The 48 * return code of the decryption operat 48 * return code of the decryption operation will be EBADMSG in case an 49 * integrity error occurs. 49 * integrity error occurs. 50 * 50 * 51 * To obtain the full result of an encryption 51 * To obtain the full result of an encryption as expected by SP800-38F, the 52 * caller must allocate a buffer of plaintext 52 * caller must allocate a buffer of plaintext + 8 bytes: 53 * 53 * 54 * unsigned int datalen = ptlen + crypto_ 54 * unsigned int datalen = ptlen + crypto_skcipher_ivsize(tfm); 55 * u8 data[datalen]; 55 * u8 data[datalen]; 56 * u8 *iv = data; 56 * u8 *iv = data; 57 * u8 *pt = data + crypto_skcipher_ivsize 57 * u8 *pt = data + crypto_skcipher_ivsize(tfm); 58 * <ensure that pt contains the p 58 * <ensure that pt contains the plaintext of size ptlen> 59 * sg_init_one(&sg, pt, ptlen); !! 59 * sg_init_one(&sg, ptdata, ptlen); 60 * skcipher_request_set_crypt(req, &sg, & 60 * skcipher_request_set_crypt(req, &sg, &sg, ptlen, iv); 61 * 61 * 62 * ==> After encryption, data now contain 62 * ==> After encryption, data now contains full KW result as per SP800-38F. 63 * 63 * 64 * In case of decryption, ciphertext now alrea 64 * In case of decryption, ciphertext now already has the expected length 65 * and must be segmented appropriately: 65 * and must be segmented appropriately: 66 * 66 * 67 * unsigned int datalen = CTLEN; 67 * unsigned int datalen = CTLEN; 68 * u8 data[datalen]; 68 * u8 data[datalen]; 69 * <ensure that data contains ful 69 * <ensure that data contains full ciphertext> 70 * u8 *iv = data; 70 * u8 *iv = data; 71 * u8 *ct = data + crypto_skcipher_ivsize 71 * u8 *ct = data + crypto_skcipher_ivsize(tfm); 72 * unsigned int ctlen = datalen - crypto_ 72 * unsigned int ctlen = datalen - crypto_skcipher_ivsize(tfm); 73 * sg_init_one(&sg, ct, ctlen); !! 73 * sg_init_one(&sg, ctdata, ctlen); 74 * skcipher_request_set_crypt(req, &sg, & !! 74 * skcipher_request_set_crypt(req, &sg, &sg, ptlen, iv); 75 * 75 * 76 * ==> After decryption (which hopefully 76 * ==> After decryption (which hopefully does not return EBADMSG), the ct 77 * pointer now points to the plaintext of 77 * pointer now points to the plaintext of size ctlen. 78 * 78 * 79 * Note 2: KWP is not implemented as this woul 79 * Note 2: KWP is not implemented as this would defy in-place operation. 80 * If somebody wants to wrap non-align 80 * If somebody wants to wrap non-aligned data, he should simply pad 81 * the input with zeros to fill it up 81 * the input with zeros to fill it up to the 8 byte boundary. 82 */ 82 */ 83 83 84 #include <linux/module.h> 84 #include <linux/module.h> 85 #include <linux/crypto.h> 85 #include <linux/crypto.h> 86 #include <linux/scatterlist.h> 86 #include <linux/scatterlist.h> 87 #include <crypto/scatterwalk.h> 87 #include <crypto/scatterwalk.h> 88 #include <crypto/internal/cipher.h> << 89 #include <crypto/internal/skcipher.h> 88 #include <crypto/internal/skcipher.h> 90 89 >> 90 struct crypto_kw_ctx { >> 91 struct crypto_cipher *child; >> 92 }; >> 93 91 struct crypto_kw_block { 94 struct crypto_kw_block { 92 #define SEMIBSIZE 8 95 #define SEMIBSIZE 8 93 __be64 A; 96 __be64 A; 94 __be64 R; 97 __be64 R; 95 }; 98 }; 96 99 97 /* 100 /* 98 * Fast forward the SGL to the "end" length mi 101 * Fast forward the SGL to the "end" length minus SEMIBSIZE. 99 * The start in the SGL defined by the fast-fo 102 * The start in the SGL defined by the fast-forward is returned with 100 * the walk variable 103 * the walk variable 101 */ 104 */ 102 static void crypto_kw_scatterlist_ff(struct sc 105 static void crypto_kw_scatterlist_ff(struct scatter_walk *walk, 103 struct sc 106 struct scatterlist *sg, 104 unsigned 107 unsigned int end) 105 { 108 { 106 unsigned int skip = 0; 109 unsigned int skip = 0; 107 110 108 /* The caller should only operate on f 111 /* The caller should only operate on full SEMIBLOCKs. */ 109 BUG_ON(end < SEMIBSIZE); 112 BUG_ON(end < SEMIBSIZE); 110 113 111 skip = end - SEMIBSIZE; 114 skip = end - SEMIBSIZE; 112 while (sg) { 115 while (sg) { 113 if (sg->length > skip) { 116 if (sg->length > skip) { 114 scatterwalk_start(walk 117 scatterwalk_start(walk, sg); 115 scatterwalk_advance(wa 118 scatterwalk_advance(walk, skip); 116 break; 119 break; 117 } !! 120 } else >> 121 skip -= sg->length; 118 122 119 skip -= sg->length; << 120 sg = sg_next(sg); 123 sg = sg_next(sg); 121 } 124 } 122 } 125 } 123 126 124 static int crypto_kw_decrypt(struct skcipher_r !! 127 static int crypto_kw_decrypt(struct blkcipher_desc *desc, >> 128 struct scatterlist *dst, struct scatterlist *src, >> 129 unsigned int nbytes) 125 { 130 { 126 struct crypto_skcipher *tfm = crypto_s !! 131 struct crypto_blkcipher *tfm = desc->tfm; 127 struct crypto_cipher *cipher = skciphe !! 132 struct crypto_kw_ctx *ctx = crypto_blkcipher_ctx(tfm); >> 133 struct crypto_cipher *child = ctx->child; 128 struct crypto_kw_block block; 134 struct crypto_kw_block block; 129 struct scatterlist *src, *dst; !! 135 struct scatterlist *lsrc, *ldst; 130 u64 t = 6 * ((req->cryptlen) >> 3); !! 136 u64 t = 6 * ((nbytes) >> 3); 131 unsigned int i; 137 unsigned int i; 132 int ret = 0; 138 int ret = 0; 133 139 134 /* 140 /* 135 * Require at least 2 semiblocks (note 141 * Require at least 2 semiblocks (note, the 3rd semiblock that is 136 * required by SP800-38F is the IV. 142 * required by SP800-38F is the IV. 137 */ 143 */ 138 if (req->cryptlen < (2 * SEMIBSIZE) || !! 144 if (nbytes < (2 * SEMIBSIZE) || nbytes % SEMIBSIZE) 139 return -EINVAL; 145 return -EINVAL; 140 146 141 /* Place the IV into block A */ 147 /* Place the IV into block A */ 142 memcpy(&block.A, req->iv, SEMIBSIZE); !! 148 memcpy(&block.A, desc->info, SEMIBSIZE); 143 149 144 /* 150 /* 145 * src scatterlist is read-only. dst s 151 * src scatterlist is read-only. dst scatterlist is r/w. During the 146 * first loop, src points to req->src !! 152 * first loop, lsrc points to src and ldst to dst. For any 147 * subsequent round, the code operates !! 153 * subsequent round, the code operates on dst only. 148 */ 154 */ 149 src = req->src; !! 155 lsrc = src; 150 dst = req->dst; !! 156 ldst = dst; 151 157 152 for (i = 0; i < 6; i++) { 158 for (i = 0; i < 6; i++) { 153 struct scatter_walk src_walk, 159 struct scatter_walk src_walk, dst_walk; 154 unsigned int nbytes = req->cry !! 160 unsigned int tmp_nbytes = nbytes; 155 161 156 while (nbytes) { !! 162 while (tmp_nbytes) { 157 /* move pointer by nby !! 163 /* move pointer by tmp_nbytes in the SGL */ 158 crypto_kw_scatterlist_ !! 164 crypto_kw_scatterlist_ff(&src_walk, lsrc, tmp_nbytes); 159 /* get the source bloc 165 /* get the source block */ 160 scatterwalk_copychunks 166 scatterwalk_copychunks(&block.R, &src_walk, SEMIBSIZE, 161 167 false); 162 168 163 /* perform KW operatio 169 /* perform KW operation: modify IV with counter */ 164 block.A ^= cpu_to_be64 170 block.A ^= cpu_to_be64(t); 165 t--; 171 t--; 166 /* perform KW operatio 172 /* perform KW operation: decrypt block */ 167 crypto_cipher_decrypt_ !! 173 crypto_cipher_decrypt_one(child, (u8*)&block, 168 !! 174 (u8*)&block); 169 175 170 /* move pointer by nby !! 176 /* move pointer by tmp_nbytes in the SGL */ 171 crypto_kw_scatterlist_ !! 177 crypto_kw_scatterlist_ff(&dst_walk, ldst, tmp_nbytes); 172 /* Copy block->R into 178 /* Copy block->R into place */ 173 scatterwalk_copychunks 179 scatterwalk_copychunks(&block.R, &dst_walk, SEMIBSIZE, 174 180 true); 175 181 176 nbytes -= SEMIBSIZE; !! 182 tmp_nbytes -= SEMIBSIZE; 177 } 183 } 178 184 179 /* we now start to operate on 185 /* we now start to operate on the dst SGL only */ 180 src = req->dst; !! 186 lsrc = dst; 181 dst = req->dst; !! 187 ldst = dst; 182 } 188 } 183 189 184 /* Perform authentication check */ 190 /* Perform authentication check */ 185 if (block.A != cpu_to_be64(0xa6a6a6a6a 191 if (block.A != cpu_to_be64(0xa6a6a6a6a6a6a6a6ULL)) 186 ret = -EBADMSG; 192 ret = -EBADMSG; 187 193 188 memzero_explicit(&block, sizeof(struct 194 memzero_explicit(&block, sizeof(struct crypto_kw_block)); 189 195 190 return ret; 196 return ret; 191 } 197 } 192 198 193 static int crypto_kw_encrypt(struct skcipher_r !! 199 static int crypto_kw_encrypt(struct blkcipher_desc *desc, >> 200 struct scatterlist *dst, struct scatterlist *src, >> 201 unsigned int nbytes) 194 { 202 { 195 struct crypto_skcipher *tfm = crypto_s !! 203 struct crypto_blkcipher *tfm = desc->tfm; 196 struct crypto_cipher *cipher = skciphe !! 204 struct crypto_kw_ctx *ctx = crypto_blkcipher_ctx(tfm); >> 205 struct crypto_cipher *child = ctx->child; 197 struct crypto_kw_block block; 206 struct crypto_kw_block block; 198 struct scatterlist *src, *dst; !! 207 struct scatterlist *lsrc, *ldst; 199 u64 t = 1; 208 u64 t = 1; 200 unsigned int i; 209 unsigned int i; 201 210 202 /* 211 /* 203 * Require at least 2 semiblocks (note 212 * Require at least 2 semiblocks (note, the 3rd semiblock that is 204 * required by SP800-38F is the IV tha 213 * required by SP800-38F is the IV that occupies the first semiblock. 205 * This means that the dst memory must 214 * This means that the dst memory must be one semiblock larger than src. 206 * Also ensure that the given data is 215 * Also ensure that the given data is aligned to semiblock. 207 */ 216 */ 208 if (req->cryptlen < (2 * SEMIBSIZE) || !! 217 if (nbytes < (2 * SEMIBSIZE) || nbytes % SEMIBSIZE) 209 return -EINVAL; 218 return -EINVAL; 210 219 211 /* 220 /* 212 * Place the predefined IV into block 221 * Place the predefined IV into block A -- for encrypt, the caller 213 * does not need to provide an IV, but 222 * does not need to provide an IV, but he needs to fetch the final IV. 214 */ 223 */ 215 block.A = cpu_to_be64(0xa6a6a6a6a6a6a6 224 block.A = cpu_to_be64(0xa6a6a6a6a6a6a6a6ULL); 216 225 217 /* 226 /* 218 * src scatterlist is read-only. dst s 227 * src scatterlist is read-only. dst scatterlist is r/w. During the 219 * first loop, src points to req->src !! 228 * first loop, lsrc points to src and ldst to dst. For any 220 * subsequent round, the code operates !! 229 * subsequent round, the code operates on dst only. 221 */ 230 */ 222 src = req->src; !! 231 lsrc = src; 223 dst = req->dst; !! 232 ldst = dst; 224 233 225 for (i = 0; i < 6; i++) { 234 for (i = 0; i < 6; i++) { 226 struct scatter_walk src_walk, 235 struct scatter_walk src_walk, dst_walk; 227 unsigned int nbytes = req->cry !! 236 unsigned int tmp_nbytes = nbytes; 228 237 229 scatterwalk_start(&src_walk, s !! 238 scatterwalk_start(&src_walk, lsrc); 230 scatterwalk_start(&dst_walk, d !! 239 scatterwalk_start(&dst_walk, ldst); 231 240 232 while (nbytes) { !! 241 while (tmp_nbytes) { 233 /* get the source bloc 242 /* get the source block */ 234 scatterwalk_copychunks 243 scatterwalk_copychunks(&block.R, &src_walk, SEMIBSIZE, 235 244 false); 236 245 237 /* perform KW operatio 246 /* perform KW operation: encrypt block */ 238 crypto_cipher_encrypt_ !! 247 crypto_cipher_encrypt_one(child, (u8 *)&block, 239 248 (u8 *)&block); 240 /* perform KW operatio 249 /* perform KW operation: modify IV with counter */ 241 block.A ^= cpu_to_be64 250 block.A ^= cpu_to_be64(t); 242 t++; 251 t++; 243 252 244 /* Copy block->R into 253 /* Copy block->R into place */ 245 scatterwalk_copychunks 254 scatterwalk_copychunks(&block.R, &dst_walk, SEMIBSIZE, 246 255 true); 247 256 248 nbytes -= SEMIBSIZE; !! 257 tmp_nbytes -= SEMIBSIZE; 249 } 258 } 250 259 251 /* we now start to operate on 260 /* we now start to operate on the dst SGL only */ 252 src = req->dst; !! 261 lsrc = dst; 253 dst = req->dst; !! 262 ldst = dst; 254 } 263 } 255 264 256 /* establish the IV for the caller to 265 /* establish the IV for the caller to pick up */ 257 memcpy(req->iv, &block.A, SEMIBSIZE); !! 266 memcpy(desc->info, &block.A, SEMIBSIZE); 258 267 259 memzero_explicit(&block, sizeof(struct 268 memzero_explicit(&block, sizeof(struct crypto_kw_block)); 260 269 261 return 0; 270 return 0; 262 } 271 } 263 272 264 static int crypto_kw_create(struct crypto_temp !! 273 static int crypto_kw_setkey(struct crypto_tfm *parent, const u8 *key, >> 274 unsigned int keylen) 265 { 275 { 266 struct skcipher_instance *inst; !! 276 struct crypto_kw_ctx *ctx = crypto_tfm_ctx(parent); 267 struct crypto_alg *alg; !! 277 struct crypto_cipher *child = ctx->child; 268 int err; 278 int err; 269 279 270 inst = skcipher_alloc_instance_simple( !! 280 crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); 271 if (IS_ERR(inst)) !! 281 crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) & 272 return PTR_ERR(inst); !! 282 CRYPTO_TFM_REQ_MASK); >> 283 err = crypto_cipher_setkey(child, key, keylen); >> 284 crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) & >> 285 CRYPTO_TFM_RES_MASK); >> 286 return err; >> 287 } >> 288 >> 289 static int crypto_kw_init_tfm(struct crypto_tfm *tfm) >> 290 { >> 291 struct crypto_instance *inst = crypto_tfm_alg_instance(tfm); >> 292 struct crypto_spawn *spawn = crypto_instance_ctx(inst); >> 293 struct crypto_kw_ctx *ctx = crypto_tfm_ctx(tfm); >> 294 struct crypto_cipher *cipher; >> 295 >> 296 cipher = crypto_spawn_cipher(spawn); >> 297 if (IS_ERR(cipher)) >> 298 return PTR_ERR(cipher); >> 299 >> 300 ctx->child = cipher; >> 301 return 0; >> 302 } 273 303 274 alg = skcipher_ialg_simple(inst); !! 304 static void crypto_kw_exit_tfm(struct crypto_tfm *tfm) >> 305 { >> 306 struct crypto_kw_ctx *ctx = crypto_tfm_ctx(tfm); >> 307 >> 308 crypto_free_cipher(ctx->child); >> 309 } >> 310 >> 311 static struct crypto_instance *crypto_kw_alloc(struct rtattr **tb) >> 312 { >> 313 struct crypto_instance *inst = NULL; >> 314 struct crypto_alg *alg = NULL; >> 315 int err; >> 316 >> 317 err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER); >> 318 if (err) >> 319 return ERR_PTR(err); >> 320 >> 321 alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER, >> 322 CRYPTO_ALG_TYPE_MASK); >> 323 if (IS_ERR(alg)) >> 324 return ERR_CAST(alg); 275 325 276 err = -EINVAL; !! 326 inst = ERR_PTR(-EINVAL); 277 /* Section 5.1 requirement for KW */ 327 /* Section 5.1 requirement for KW */ 278 if (alg->cra_blocksize != sizeof(struc 328 if (alg->cra_blocksize != sizeof(struct crypto_kw_block)) 279 goto out_free_inst; !! 329 goto err; 280 330 281 inst->alg.base.cra_blocksize = SEMIBSI !! 331 inst = crypto_alloc_instance("kw", alg); 282 inst->alg.base.cra_alignmask = 0; !! 332 if (IS_ERR(inst)) 283 inst->alg.ivsize = SEMIBSIZE; !! 333 goto err; 284 << 285 inst->alg.encrypt = crypto_kw_encrypt; << 286 inst->alg.decrypt = crypto_kw_decrypt; << 287 << 288 err = skcipher_register_instance(tmpl, << 289 if (err) { << 290 out_free_inst: << 291 inst->free(inst); << 292 } << 293 334 294 return err; !! 335 inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER; >> 336 inst->alg.cra_priority = alg->cra_priority; >> 337 inst->alg.cra_blocksize = SEMIBSIZE; >> 338 inst->alg.cra_alignmask = 0; >> 339 inst->alg.cra_type = &crypto_blkcipher_type; >> 340 inst->alg.cra_blkcipher.ivsize = SEMIBSIZE; >> 341 inst->alg.cra_blkcipher.min_keysize = alg->cra_cipher.cia_min_keysize; >> 342 inst->alg.cra_blkcipher.max_keysize = alg->cra_cipher.cia_max_keysize; >> 343 >> 344 inst->alg.cra_ctxsize = sizeof(struct crypto_kw_ctx); >> 345 >> 346 inst->alg.cra_init = crypto_kw_init_tfm; >> 347 inst->alg.cra_exit = crypto_kw_exit_tfm; >> 348 >> 349 inst->alg.cra_blkcipher.setkey = crypto_kw_setkey; >> 350 inst->alg.cra_blkcipher.encrypt = crypto_kw_encrypt; >> 351 inst->alg.cra_blkcipher.decrypt = crypto_kw_decrypt; >> 352 >> 353 err: >> 354 crypto_mod_put(alg); >> 355 return inst; >> 356 } >> 357 >> 358 static void crypto_kw_free(struct crypto_instance *inst) >> 359 { >> 360 crypto_drop_spawn(crypto_instance_ctx(inst)); >> 361 kfree(inst); 295 } 362 } 296 363 297 static struct crypto_template crypto_kw_tmpl = 364 static struct crypto_template crypto_kw_tmpl = { 298 .name = "kw", 365 .name = "kw", 299 .create = crypto_kw_create, !! 366 .alloc = crypto_kw_alloc, >> 367 .free = crypto_kw_free, 300 .module = THIS_MODULE, 368 .module = THIS_MODULE, 301 }; 369 }; 302 370 303 static int __init crypto_kw_init(void) 371 static int __init crypto_kw_init(void) 304 { 372 { 305 return crypto_register_template(&crypt 373 return crypto_register_template(&crypto_kw_tmpl); 306 } 374 } 307 375 308 static void __exit crypto_kw_exit(void) 376 static void __exit crypto_kw_exit(void) 309 { 377 { 310 crypto_unregister_template(&crypto_kw_ 378 crypto_unregister_template(&crypto_kw_tmpl); 311 } 379 } 312 380 313 subsys_initcall(crypto_kw_init); !! 381 module_init(crypto_kw_init); 314 module_exit(crypto_kw_exit); 382 module_exit(crypto_kw_exit); 315 383 316 MODULE_LICENSE("Dual BSD/GPL"); 384 MODULE_LICENSE("Dual BSD/GPL"); 317 MODULE_AUTHOR("Stephan Mueller <smueller@chron 385 MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>"); 318 MODULE_DESCRIPTION("Key Wrapping (RFC3394 / NI 386 MODULE_DESCRIPTION("Key Wrapping (RFC3394 / NIST SP800-38F)"); 319 MODULE_ALIAS_CRYPTO("kw"); 387 MODULE_ALIAS_CRYPTO("kw"); 320 MODULE_IMPORT_NS(CRYPTO_INTERNAL); << 321 388
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.