| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Scatterlist Cryptographic API. | 
|  | 3 | * | 
|  | 4 | * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> | 
|  | 5 | * Copyright (c) 2002 David S. Miller (davem@redhat.com) | 
| Herbert Xu | 5cb1454 | 2005-11-05 16:58:14 +1100 | [diff] [blame] | 6 | * Copyright (c) 2005 Herbert Xu <herbert@gondor.apana.org.au> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * | 
|  | 8 | * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no> | 
| John Anthony Kazos Jr | 18735dd | 2007-10-19 23:07:36 +0200 | [diff] [blame] | 9 | * and Nettle, by Niels Möller. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * | 
|  | 11 | * This program is free software; you can redistribute it and/or modify it | 
|  | 12 | * under the terms of the GNU General Public License as published by the Free | 
|  | 13 | * Software Foundation; either version 2 of the License, or (at your option) | 
|  | 14 | * any later version. | 
|  | 15 | * | 
|  | 16 | */ | 
|  | 17 | #ifndef _LINUX_CRYPTO_H | 
|  | 18 | #define _LINUX_CRYPTO_H | 
|  | 19 |  | 
| Arun Sharma | 6006349 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 20 | #include <linux/atomic.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/kernel.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/list.h> | 
| Paul Gortmaker | 187f188 | 2011-11-23 20:12:59 -0500 | [diff] [blame] | 23 | #include <linux/bug.h> | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 24 | #include <linux/slab.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/string.h> | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 26 | #include <linux/uaccess.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 |  | 
|  | 28 | /* | 
|  | 29 | * Algorithm masks and types. | 
|  | 30 | */ | 
| Herbert Xu | 2825982 | 2006-08-06 21:23:26 +1000 | [diff] [blame] | 31 | #define CRYPTO_ALG_TYPE_MASK		0x0000000f | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #define CRYPTO_ALG_TYPE_CIPHER		0x00000001 | 
| Loc Ho | 004a403 | 2008-05-14 20:41:47 +0800 | [diff] [blame] | 33 | #define CRYPTO_ALG_TYPE_COMPRESS	0x00000002 | 
|  | 34 | #define CRYPTO_ALG_TYPE_AEAD		0x00000003 | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 35 | #define CRYPTO_ALG_TYPE_BLKCIPHER	0x00000004 | 
| Herbert Xu | 332f884 | 2007-11-15 22:36:07 +0800 | [diff] [blame] | 36 | #define CRYPTO_ALG_TYPE_ABLKCIPHER	0x00000005 | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 37 | #define CRYPTO_ALG_TYPE_GIVCIPHER	0x00000006 | 
| Loc Ho | 004a403 | 2008-05-14 20:41:47 +0800 | [diff] [blame] | 38 | #define CRYPTO_ALG_TYPE_DIGEST		0x00000008 | 
| Herbert Xu | 5f7082e | 2008-08-31 22:21:09 +1000 | [diff] [blame] | 39 | #define CRYPTO_ALG_TYPE_HASH		0x00000008 | 
|  | 40 | #define CRYPTO_ALG_TYPE_SHASH		0x00000009 | 
| Loc Ho | 004a403 | 2008-05-14 20:41:47 +0800 | [diff] [blame] | 41 | #define CRYPTO_ALG_TYPE_AHASH		0x0000000a | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 42 | #define CRYPTO_ALG_TYPE_RNG		0x0000000c | 
| Geert Uytterhoeven | a1d2f09 | 2009-03-04 15:05:33 +0800 | [diff] [blame] | 43 | #define CRYPTO_ALG_TYPE_PCOMPRESS	0x0000000f | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 44 |  | 
|  | 45 | #define CRYPTO_ALG_TYPE_HASH_MASK	0x0000000e | 
| Loc Ho | 004a403 | 2008-05-14 20:41:47 +0800 | [diff] [blame] | 46 | #define CRYPTO_ALG_TYPE_AHASH_MASK	0x0000000c | 
| Herbert Xu | 332f884 | 2007-11-15 22:36:07 +0800 | [diff] [blame] | 47 | #define CRYPTO_ALG_TYPE_BLKCIPHER_MASK	0x0000000c | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 |  | 
| Herbert Xu | 2825982 | 2006-08-06 21:23:26 +1000 | [diff] [blame] | 49 | #define CRYPTO_ALG_LARVAL		0x00000010 | 
| Herbert Xu | 6bfd480 | 2006-09-21 11:39:29 +1000 | [diff] [blame] | 50 | #define CRYPTO_ALG_DEAD			0x00000020 | 
|  | 51 | #define CRYPTO_ALG_DYING		0x00000040 | 
| Herbert Xu | f3f632d | 2006-08-06 23:12:59 +1000 | [diff] [blame] | 52 | #define CRYPTO_ALG_ASYNC		0x00000080 | 
| Herbert Xu | 2825982 | 2006-08-06 21:23:26 +1000 | [diff] [blame] | 53 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /* | 
| Herbert Xu | 6010439 | 2006-08-26 18:34:10 +1000 | [diff] [blame] | 55 | * Set this bit if and only if the algorithm requires another algorithm of | 
|  | 56 | * the same type to handle corner cases. | 
|  | 57 | */ | 
|  | 58 | #define CRYPTO_ALG_NEED_FALLBACK	0x00000100 | 
|  | 59 |  | 
|  | 60 | /* | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 61 | * This bit is set for symmetric key ciphers that have already been wrapped | 
|  | 62 | * with a generic IV generator to prevent them from being wrapped again. | 
|  | 63 | */ | 
|  | 64 | #define CRYPTO_ALG_GENIV		0x00000200 | 
|  | 65 |  | 
|  | 66 | /* | 
| Herbert Xu | 73d3864 | 2008-08-03 21:15:23 +0800 | [diff] [blame] | 67 | * Set if the algorithm has passed automated run-time testing.  Note that | 
|  | 68 | * if there is no run-time testing for a given algorithm it is considered | 
|  | 69 | * to have passed. | 
|  | 70 | */ | 
|  | 71 |  | 
|  | 72 | #define CRYPTO_ALG_TESTED		0x00000400 | 
|  | 73 |  | 
|  | 74 | /* | 
| Steffen Klassert | 64a947b | 2011-09-27 07:21:26 +0200 | [diff] [blame] | 75 | * Set if the algorithm is an instance that is build from templates. | 
|  | 76 | */ | 
|  | 77 | #define CRYPTO_ALG_INSTANCE		0x00000800 | 
|  | 78 |  | 
| Nikos Mavrogiannopoulos | d912bb7 | 2011-11-01 13:39:56 +0100 | [diff] [blame] | 79 | /* Set this bit if the algorithm provided is hardware accelerated but | 
|  | 80 | * not available to userspace via instruction set or so. | 
|  | 81 | */ | 
|  | 82 | #define CRYPTO_ALG_KERN_DRIVER_ONLY	0x00001000 | 
|  | 83 |  | 
| Steffen Klassert | 64a947b | 2011-09-27 07:21:26 +0200 | [diff] [blame] | 84 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | * Transform masks and values (for crt_flags). | 
|  | 86 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | #define CRYPTO_TFM_REQ_MASK		0x000fff00 | 
|  | 88 | #define CRYPTO_TFM_RES_MASK		0xfff00000 | 
|  | 89 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #define CRYPTO_TFM_REQ_WEAK_KEY		0x00000100 | 
| Herbert Xu | 64baf3c | 2005-09-01 17:43:05 -0700 | [diff] [blame] | 91 | #define CRYPTO_TFM_REQ_MAY_SLEEP	0x00000200 | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 92 | #define CRYPTO_TFM_REQ_MAY_BACKLOG	0x00000400 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | #define CRYPTO_TFM_RES_WEAK_KEY		0x00100000 | 
|  | 94 | #define CRYPTO_TFM_RES_BAD_KEY_LEN   	0x00200000 | 
|  | 95 | #define CRYPTO_TFM_RES_BAD_KEY_SCHED 	0x00400000 | 
|  | 96 | #define CRYPTO_TFM_RES_BAD_BLOCK_LEN 	0x00800000 | 
|  | 97 | #define CRYPTO_TFM_RES_BAD_FLAGS 	0x01000000 | 
|  | 98 |  | 
|  | 99 | /* | 
|  | 100 | * Miscellaneous stuff. | 
|  | 101 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #define CRYPTO_MAX_ALG_NAME		64 | 
|  | 103 |  | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 104 | /* | 
|  | 105 | * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual | 
|  | 106 | * declaration) is used to ensure that the crypto_tfm context structure is | 
|  | 107 | * aligned correctly for the given architecture so that there are no alignment | 
|  | 108 | * faults for C data types.  In particular, this is required on platforms such | 
|  | 109 | * as arm where pointers are 32-bit aligned but there are data types such as | 
|  | 110 | * u64 which require 64-bit alignment. | 
|  | 111 | */ | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 112 | #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 113 |  | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 114 | #define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN))) | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 115 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | struct scatterlist; | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 117 | struct crypto_ablkcipher; | 
|  | 118 | struct crypto_async_request; | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 119 | struct crypto_aead; | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 120 | struct crypto_blkcipher; | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 121 | struct crypto_hash; | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 122 | struct crypto_rng; | 
| Herbert Xu | 4072518 | 2005-07-06 13:51:52 -0700 | [diff] [blame] | 123 | struct crypto_tfm; | 
| Herbert Xu | e853c3c | 2006-08-22 00:06:54 +1000 | [diff] [blame] | 124 | struct crypto_type; | 
| Herbert Xu | 743edf5 | 2007-12-10 16:18:01 +0800 | [diff] [blame] | 125 | struct aead_givcrypt_request; | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 126 | struct skcipher_givcrypt_request; | 
| Herbert Xu | 4072518 | 2005-07-06 13:51:52 -0700 | [diff] [blame] | 127 |  | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 128 | typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); | 
|  | 129 |  | 
|  | 130 | struct crypto_async_request { | 
|  | 131 | struct list_head list; | 
|  | 132 | crypto_completion_t complete; | 
|  | 133 | void *data; | 
|  | 134 | struct crypto_tfm *tfm; | 
|  | 135 |  | 
|  | 136 | u32 flags; | 
|  | 137 | }; | 
|  | 138 |  | 
|  | 139 | struct ablkcipher_request { | 
|  | 140 | struct crypto_async_request base; | 
|  | 141 |  | 
|  | 142 | unsigned int nbytes; | 
|  | 143 |  | 
|  | 144 | void *info; | 
|  | 145 |  | 
|  | 146 | struct scatterlist *src; | 
|  | 147 | struct scatterlist *dst; | 
|  | 148 |  | 
|  | 149 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | 
|  | 150 | }; | 
|  | 151 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 152 | /** | 
|  | 153 | *	struct aead_request - AEAD request | 
|  | 154 | *	@base: Common attributes for async crypto requests | 
|  | 155 | *	@assoclen: Length in bytes of associated data for authentication | 
|  | 156 | *	@cryptlen: Length of data to be encrypted or decrypted | 
|  | 157 | *	@iv: Initialisation vector | 
|  | 158 | *	@assoc: Associated data | 
|  | 159 | *	@src: Source data | 
|  | 160 | *	@dst: Destination data | 
|  | 161 | *	@__ctx: Start of private context data | 
|  | 162 | */ | 
|  | 163 | struct aead_request { | 
|  | 164 | struct crypto_async_request base; | 
|  | 165 |  | 
|  | 166 | unsigned int assoclen; | 
|  | 167 | unsigned int cryptlen; | 
|  | 168 |  | 
|  | 169 | u8 *iv; | 
|  | 170 |  | 
|  | 171 | struct scatterlist *assoc; | 
|  | 172 | struct scatterlist *src; | 
|  | 173 | struct scatterlist *dst; | 
|  | 174 |  | 
|  | 175 | void *__ctx[] CRYPTO_MINALIGN_ATTR; | 
|  | 176 | }; | 
|  | 177 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 178 | struct blkcipher_desc { | 
|  | 179 | struct crypto_blkcipher *tfm; | 
|  | 180 | void *info; | 
|  | 181 | u32 flags; | 
|  | 182 | }; | 
|  | 183 |  | 
| Herbert Xu | 4072518 | 2005-07-06 13:51:52 -0700 | [diff] [blame] | 184 | struct cipher_desc { | 
|  | 185 | struct crypto_tfm *tfm; | 
| Herbert Xu | 6c2bb98 | 2006-05-16 22:09:29 +1000 | [diff] [blame] | 186 | void (*crfn)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | 
| Herbert Xu | 4072518 | 2005-07-06 13:51:52 -0700 | [diff] [blame] | 187 | unsigned int (*prfn)(const struct cipher_desc *desc, u8 *dst, | 
|  | 188 | const u8 *src, unsigned int nbytes); | 
|  | 189 | void *info; | 
|  | 190 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 192 | struct hash_desc { | 
|  | 193 | struct crypto_hash *tfm; | 
|  | 194 | u32 flags; | 
|  | 195 | }; | 
|  | 196 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | /* | 
|  | 198 | * Algorithms: modular crypto algorithm implementations, managed | 
|  | 199 | * via crypto_register_alg() and crypto_unregister_alg(). | 
|  | 200 | */ | 
| Herbert Xu | b5b7f08 | 2007-04-16 20:48:54 +1000 | [diff] [blame] | 201 | struct ablkcipher_alg { | 
|  | 202 | int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key, | 
|  | 203 | unsigned int keylen); | 
|  | 204 | int (*encrypt)(struct ablkcipher_request *req); | 
|  | 205 | int (*decrypt)(struct ablkcipher_request *req); | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 206 | int (*givencrypt)(struct skcipher_givcrypt_request *req); | 
|  | 207 | int (*givdecrypt)(struct skcipher_givcrypt_request *req); | 
| Herbert Xu | b5b7f08 | 2007-04-16 20:48:54 +1000 | [diff] [blame] | 208 |  | 
| Herbert Xu | 23508e1 | 2007-11-27 21:33:24 +0800 | [diff] [blame] | 209 | const char *geniv; | 
|  | 210 |  | 
| Herbert Xu | b5b7f08 | 2007-04-16 20:48:54 +1000 | [diff] [blame] | 211 | unsigned int min_keysize; | 
|  | 212 | unsigned int max_keysize; | 
|  | 213 | unsigned int ivsize; | 
|  | 214 | }; | 
|  | 215 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 216 | struct aead_alg { | 
|  | 217 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, | 
|  | 218 | unsigned int keylen); | 
| Herbert Xu | 7ba683a | 2007-12-02 18:49:21 +1100 | [diff] [blame] | 219 | int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize); | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 220 | int (*encrypt)(struct aead_request *req); | 
|  | 221 | int (*decrypt)(struct aead_request *req); | 
| Herbert Xu | 743edf5 | 2007-12-10 16:18:01 +0800 | [diff] [blame] | 222 | int (*givencrypt)(struct aead_givcrypt_request *req); | 
|  | 223 | int (*givdecrypt)(struct aead_givcrypt_request *req); | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 224 |  | 
| Herbert Xu | 5b6d2d7 | 2007-12-12 19:23:36 +0800 | [diff] [blame] | 225 | const char *geniv; | 
|  | 226 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 227 | unsigned int ivsize; | 
| Herbert Xu | 7ba683a | 2007-12-02 18:49:21 +1100 | [diff] [blame] | 228 | unsigned int maxauthsize; | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 229 | }; | 
|  | 230 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 231 | struct blkcipher_alg { | 
|  | 232 | int (*setkey)(struct crypto_tfm *tfm, const u8 *key, | 
|  | 233 | unsigned int keylen); | 
|  | 234 | int (*encrypt)(struct blkcipher_desc *desc, | 
|  | 235 | struct scatterlist *dst, struct scatterlist *src, | 
|  | 236 | unsigned int nbytes); | 
|  | 237 | int (*decrypt)(struct blkcipher_desc *desc, | 
|  | 238 | struct scatterlist *dst, struct scatterlist *src, | 
|  | 239 | unsigned int nbytes); | 
|  | 240 |  | 
| Herbert Xu | 23508e1 | 2007-11-27 21:33:24 +0800 | [diff] [blame] | 241 | const char *geniv; | 
|  | 242 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 243 | unsigned int min_keysize; | 
|  | 244 | unsigned int max_keysize; | 
|  | 245 | unsigned int ivsize; | 
|  | 246 | }; | 
|  | 247 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | struct cipher_alg { | 
|  | 249 | unsigned int cia_min_keysize; | 
|  | 250 | unsigned int cia_max_keysize; | 
| Herbert Xu | 6c2bb98 | 2006-05-16 22:09:29 +1000 | [diff] [blame] | 251 | int (*cia_setkey)(struct crypto_tfm *tfm, const u8 *key, | 
| Herbert Xu | 560c06a | 2006-08-13 14:16:39 +1000 | [diff] [blame] | 252 | unsigned int keylen); | 
| Herbert Xu | 6c2bb98 | 2006-05-16 22:09:29 +1000 | [diff] [blame] | 253 | void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | 
|  | 254 | void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | }; | 
|  | 256 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | struct compress_alg { | 
| Herbert Xu | 6c2bb98 | 2006-05-16 22:09:29 +1000 | [diff] [blame] | 258 | int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src, | 
|  | 259 | unsigned int slen, u8 *dst, unsigned int *dlen); | 
|  | 260 | int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src, | 
|  | 261 | unsigned int slen, u8 *dst, unsigned int *dlen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | }; | 
|  | 263 |  | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 264 | struct rng_alg { | 
|  | 265 | int (*rng_make_random)(struct crypto_rng *tfm, u8 *rdata, | 
|  | 266 | unsigned int dlen); | 
|  | 267 | int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen); | 
|  | 268 |  | 
|  | 269 | unsigned int seedsize; | 
|  | 270 | }; | 
|  | 271 |  | 
|  | 272 |  | 
| Herbert Xu | b5b7f08 | 2007-04-16 20:48:54 +1000 | [diff] [blame] | 273 | #define cra_ablkcipher	cra_u.ablkcipher | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 274 | #define cra_aead	cra_u.aead | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 275 | #define cra_blkcipher	cra_u.blkcipher | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | #define cra_cipher	cra_u.cipher | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | #define cra_compress	cra_u.compress | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 278 | #define cra_rng		cra_u.rng | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 |  | 
|  | 280 | struct crypto_alg { | 
|  | 281 | struct list_head cra_list; | 
| Herbert Xu | 6bfd480 | 2006-09-21 11:39:29 +1000 | [diff] [blame] | 282 | struct list_head cra_users; | 
|  | 283 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | u32 cra_flags; | 
|  | 285 | unsigned int cra_blocksize; | 
|  | 286 | unsigned int cra_ctxsize; | 
| Herbert Xu | 9547737 | 2005-07-06 13:52:09 -0700 | [diff] [blame] | 287 | unsigned int cra_alignmask; | 
| Herbert Xu | 5cb1454 | 2005-11-05 16:58:14 +1100 | [diff] [blame] | 288 |  | 
|  | 289 | int cra_priority; | 
| Herbert Xu | 6521f30 | 2006-08-06 20:28:44 +1000 | [diff] [blame] | 290 | atomic_t cra_refcnt; | 
| Herbert Xu | 5cb1454 | 2005-11-05 16:58:14 +1100 | [diff] [blame] | 291 |  | 
| Herbert Xu | d913ea0 | 2006-05-21 08:45:26 +1000 | [diff] [blame] | 292 | char cra_name[CRYPTO_MAX_ALG_NAME]; | 
|  | 293 | char cra_driver_name[CRYPTO_MAX_ALG_NAME]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 |  | 
| Herbert Xu | e853c3c | 2006-08-22 00:06:54 +1000 | [diff] [blame] | 295 | const struct crypto_type *cra_type; | 
|  | 296 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | union { | 
| Herbert Xu | b5b7f08 | 2007-04-16 20:48:54 +1000 | [diff] [blame] | 298 | struct ablkcipher_alg ablkcipher; | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 299 | struct aead_alg aead; | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 300 | struct blkcipher_alg blkcipher; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | struct cipher_alg cipher; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | struct compress_alg compress; | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 303 | struct rng_alg rng; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | } cra_u; | 
| Herbert Xu | c7fc059 | 2006-05-24 13:02:26 +1000 | [diff] [blame] | 305 |  | 
|  | 306 | int (*cra_init)(struct crypto_tfm *tfm); | 
|  | 307 | void (*cra_exit)(struct crypto_tfm *tfm); | 
| Herbert Xu | 6521f30 | 2006-08-06 20:28:44 +1000 | [diff] [blame] | 308 | void (*cra_destroy)(struct crypto_alg *alg); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 |  | 
|  | 310 | struct module *cra_module; | 
|  | 311 | }; | 
|  | 312 |  | 
|  | 313 | /* | 
|  | 314 | * Algorithm registration interface. | 
|  | 315 | */ | 
|  | 316 | int crypto_register_alg(struct crypto_alg *alg); | 
|  | 317 | int crypto_unregister_alg(struct crypto_alg *alg); | 
| Mark Brown | 4b00434 | 2012-01-17 23:34:26 +0000 | [diff] [blame] | 318 | int crypto_register_algs(struct crypto_alg *algs, int count); | 
|  | 319 | int crypto_unregister_algs(struct crypto_alg *algs, int count); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 |  | 
|  | 321 | /* | 
|  | 322 | * Algorithm query interface. | 
|  | 323 | */ | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 324 | int crypto_has_alg(const char *name, u32 type, u32 mask); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 |  | 
|  | 326 | /* | 
|  | 327 | * Transforms: user-instantiated objects which encapsulate algorithms | 
| Herbert Xu | 6d7d684 | 2006-07-30 11:53:01 +1000 | [diff] [blame] | 328 | * and core processing logic.  Managed via crypto_alloc_*() and | 
|  | 329 | * crypto_free_*(), as well as the various helpers below. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 |  | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 332 | struct ablkcipher_tfm { | 
|  | 333 | int (*setkey)(struct crypto_ablkcipher *tfm, const u8 *key, | 
|  | 334 | unsigned int keylen); | 
|  | 335 | int (*encrypt)(struct ablkcipher_request *req); | 
|  | 336 | int (*decrypt)(struct ablkcipher_request *req); | 
| Herbert Xu | 61da88e | 2007-12-17 21:51:27 +0800 | [diff] [blame] | 337 | int (*givencrypt)(struct skcipher_givcrypt_request *req); | 
|  | 338 | int (*givdecrypt)(struct skcipher_givcrypt_request *req); | 
|  | 339 |  | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 340 | struct crypto_ablkcipher *base; | 
|  | 341 |  | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 342 | unsigned int ivsize; | 
|  | 343 | unsigned int reqsize; | 
|  | 344 | }; | 
|  | 345 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 346 | struct aead_tfm { | 
|  | 347 | int (*setkey)(struct crypto_aead *tfm, const u8 *key, | 
|  | 348 | unsigned int keylen); | 
|  | 349 | int (*encrypt)(struct aead_request *req); | 
|  | 350 | int (*decrypt)(struct aead_request *req); | 
| Herbert Xu | 743edf5 | 2007-12-10 16:18:01 +0800 | [diff] [blame] | 351 | int (*givencrypt)(struct aead_givcrypt_request *req); | 
|  | 352 | int (*givdecrypt)(struct aead_givcrypt_request *req); | 
| Herbert Xu | 5b6d2d7 | 2007-12-12 19:23:36 +0800 | [diff] [blame] | 353 |  | 
|  | 354 | struct crypto_aead *base; | 
|  | 355 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 356 | unsigned int ivsize; | 
|  | 357 | unsigned int authsize; | 
|  | 358 | unsigned int reqsize; | 
|  | 359 | }; | 
|  | 360 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 361 | struct blkcipher_tfm { | 
|  | 362 | void *iv; | 
|  | 363 | int (*setkey)(struct crypto_tfm *tfm, const u8 *key, | 
|  | 364 | unsigned int keylen); | 
|  | 365 | int (*encrypt)(struct blkcipher_desc *desc, struct scatterlist *dst, | 
|  | 366 | struct scatterlist *src, unsigned int nbytes); | 
|  | 367 | int (*decrypt)(struct blkcipher_desc *desc, struct scatterlist *dst, | 
|  | 368 | struct scatterlist *src, unsigned int nbytes); | 
|  | 369 | }; | 
|  | 370 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | struct cipher_tfm { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | int (*cit_setkey)(struct crypto_tfm *tfm, | 
|  | 373 | const u8 *key, unsigned int keylen); | 
| Herbert Xu | f28776a | 2006-08-13 20:58:18 +1000 | [diff] [blame] | 374 | void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | 
|  | 375 | void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | }; | 
|  | 377 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 378 | struct hash_tfm { | 
|  | 379 | int (*init)(struct hash_desc *desc); | 
|  | 380 | int (*update)(struct hash_desc *desc, | 
|  | 381 | struct scatterlist *sg, unsigned int nsg); | 
|  | 382 | int (*final)(struct hash_desc *desc, u8 *out); | 
|  | 383 | int (*digest)(struct hash_desc *desc, struct scatterlist *sg, | 
|  | 384 | unsigned int nsg, u8 *out); | 
|  | 385 | int (*setkey)(struct crypto_hash *tfm, const u8 *key, | 
|  | 386 | unsigned int keylen); | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 387 | unsigned int digestsize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | }; | 
|  | 389 |  | 
|  | 390 | struct compress_tfm { | 
|  | 391 | int (*cot_compress)(struct crypto_tfm *tfm, | 
|  | 392 | const u8 *src, unsigned int slen, | 
|  | 393 | u8 *dst, unsigned int *dlen); | 
|  | 394 | int (*cot_decompress)(struct crypto_tfm *tfm, | 
|  | 395 | const u8 *src, unsigned int slen, | 
|  | 396 | u8 *dst, unsigned int *dlen); | 
|  | 397 | }; | 
|  | 398 |  | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 399 | struct rng_tfm { | 
|  | 400 | int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata, | 
|  | 401 | unsigned int dlen); | 
|  | 402 | int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen); | 
|  | 403 | }; | 
|  | 404 |  | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 405 | #define crt_ablkcipher	crt_u.ablkcipher | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 406 | #define crt_aead	crt_u.aead | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 407 | #define crt_blkcipher	crt_u.blkcipher | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | #define crt_cipher	crt_u.cipher | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 409 | #define crt_hash	crt_u.hash | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | #define crt_compress	crt_u.compress | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 411 | #define crt_rng		crt_u.rng | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 |  | 
|  | 413 | struct crypto_tfm { | 
|  | 414 |  | 
|  | 415 | u32 crt_flags; | 
|  | 416 |  | 
|  | 417 | union { | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 418 | struct ablkcipher_tfm ablkcipher; | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 419 | struct aead_tfm aead; | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 420 | struct blkcipher_tfm blkcipher; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | struct cipher_tfm cipher; | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 422 | struct hash_tfm hash; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | struct compress_tfm compress; | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 424 | struct rng_tfm rng; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | } crt_u; | 
| Herbert Xu | 4a77948 | 2008-09-13 18:19:03 -0700 | [diff] [blame] | 426 |  | 
|  | 427 | void (*exit)(struct crypto_tfm *tfm); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 |  | 
|  | 429 | struct crypto_alg *__crt_alg; | 
| Herbert Xu | f10b789 | 2006-01-25 22:34:01 +1100 | [diff] [blame] | 430 |  | 
| Herbert Xu | 7991110 | 2006-08-21 21:03:52 +1000 | [diff] [blame] | 431 | void *__crt_ctx[] CRYPTO_MINALIGN_ATTR; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | }; | 
|  | 433 |  | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 434 | struct crypto_ablkcipher { | 
|  | 435 | struct crypto_tfm base; | 
|  | 436 | }; | 
|  | 437 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 438 | struct crypto_aead { | 
|  | 439 | struct crypto_tfm base; | 
|  | 440 | }; | 
|  | 441 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 442 | struct crypto_blkcipher { | 
|  | 443 | struct crypto_tfm base; | 
|  | 444 | }; | 
|  | 445 |  | 
| Herbert Xu | 78a1fe4 | 2006-12-24 10:02:00 +1100 | [diff] [blame] | 446 | struct crypto_cipher { | 
|  | 447 | struct crypto_tfm base; | 
|  | 448 | }; | 
|  | 449 |  | 
|  | 450 | struct crypto_comp { | 
|  | 451 | struct crypto_tfm base; | 
|  | 452 | }; | 
|  | 453 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 454 | struct crypto_hash { | 
|  | 455 | struct crypto_tfm base; | 
|  | 456 | }; | 
|  | 457 |  | 
| Neil Horman | 17f0f4a | 2008-08-14 22:15:52 +1000 | [diff] [blame] | 458 | struct crypto_rng { | 
|  | 459 | struct crypto_tfm base; | 
|  | 460 | }; | 
|  | 461 |  | 
| Herbert Xu | 2b8c19d | 2006-09-21 11:31:44 +1000 | [diff] [blame] | 462 | enum { | 
|  | 463 | CRYPTOA_UNSPEC, | 
|  | 464 | CRYPTOA_ALG, | 
| Herbert Xu | ebc610e | 2007-01-01 18:37:02 +1100 | [diff] [blame] | 465 | CRYPTOA_TYPE, | 
| Herbert Xu | 39e1ee0 | 2007-08-29 19:27:26 +0800 | [diff] [blame] | 466 | CRYPTOA_U32, | 
| Herbert Xu | ebc610e | 2007-01-01 18:37:02 +1100 | [diff] [blame] | 467 | __CRYPTOA_MAX, | 
| Herbert Xu | 2b8c19d | 2006-09-21 11:31:44 +1000 | [diff] [blame] | 468 | }; | 
|  | 469 |  | 
| Herbert Xu | ebc610e | 2007-01-01 18:37:02 +1100 | [diff] [blame] | 470 | #define CRYPTOA_MAX (__CRYPTOA_MAX - 1) | 
|  | 471 |  | 
| Herbert Xu | 39e1ee0 | 2007-08-29 19:27:26 +0800 | [diff] [blame] | 472 | /* Maximum number of (rtattr) parameters for each template. */ | 
|  | 473 | #define CRYPTO_MAX_ATTRS 32 | 
|  | 474 |  | 
| Herbert Xu | 2b8c19d | 2006-09-21 11:31:44 +1000 | [diff] [blame] | 475 | struct crypto_attr_alg { | 
|  | 476 | char name[CRYPTO_MAX_ALG_NAME]; | 
|  | 477 | }; | 
|  | 478 |  | 
| Herbert Xu | ebc610e | 2007-01-01 18:37:02 +1100 | [diff] [blame] | 479 | struct crypto_attr_type { | 
|  | 480 | u32 type; | 
|  | 481 | u32 mask; | 
|  | 482 | }; | 
|  | 483 |  | 
| Herbert Xu | 39e1ee0 | 2007-08-29 19:27:26 +0800 | [diff] [blame] | 484 | struct crypto_attr_u32 { | 
|  | 485 | u32 num; | 
|  | 486 | }; | 
|  | 487 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | /* | 
|  | 489 | * Transform user interface. | 
|  | 490 | */ | 
|  | 491 |  | 
| Herbert Xu | 6d7d684 | 2006-07-30 11:53:01 +1000 | [diff] [blame] | 492 | struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask); | 
| Herbert Xu | 7b2cd92 | 2009-02-05 16:48:24 +1100 | [diff] [blame] | 493 | void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm); | 
|  | 494 |  | 
|  | 495 | static inline void crypto_free_tfm(struct crypto_tfm *tfm) | 
|  | 496 | { | 
|  | 497 | return crypto_destroy_tfm(tfm, tfm); | 
|  | 498 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 |  | 
| Herbert Xu | da7f033 | 2008-07-31 17:08:25 +0800 | [diff] [blame] | 500 | int alg_test(const char *driver, const char *alg, u32 type, u32 mask); | 
|  | 501 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | /* | 
|  | 503 | * Transform helpers which query the underlying algorithm. | 
|  | 504 | */ | 
|  | 505 | static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm) | 
|  | 506 | { | 
|  | 507 | return tfm->__crt_alg->cra_name; | 
|  | 508 | } | 
|  | 509 |  | 
| Michal Ludvig | b14cdd6 | 2006-07-09 09:02:24 +1000 | [diff] [blame] | 510 | static inline const char *crypto_tfm_alg_driver_name(struct crypto_tfm *tfm) | 
|  | 511 | { | 
|  | 512 | return tfm->__crt_alg->cra_driver_name; | 
|  | 513 | } | 
|  | 514 |  | 
|  | 515 | static inline int crypto_tfm_alg_priority(struct crypto_tfm *tfm) | 
|  | 516 | { | 
|  | 517 | return tfm->__crt_alg->cra_priority; | 
|  | 518 | } | 
|  | 519 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm) | 
|  | 521 | { | 
|  | 522 | return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK; | 
|  | 523 | } | 
|  | 524 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm) | 
|  | 526 | { | 
|  | 527 | return tfm->__crt_alg->cra_blocksize; | 
|  | 528 | } | 
|  | 529 |  | 
| Herbert Xu | fbdae9f | 2005-07-06 13:53:29 -0700 | [diff] [blame] | 530 | static inline unsigned int crypto_tfm_alg_alignmask(struct crypto_tfm *tfm) | 
|  | 531 | { | 
|  | 532 | return tfm->__crt_alg->cra_alignmask; | 
|  | 533 | } | 
|  | 534 |  | 
| Herbert Xu | f28776a | 2006-08-13 20:58:18 +1000 | [diff] [blame] | 535 | static inline u32 crypto_tfm_get_flags(struct crypto_tfm *tfm) | 
|  | 536 | { | 
|  | 537 | return tfm->crt_flags; | 
|  | 538 | } | 
|  | 539 |  | 
|  | 540 | static inline void crypto_tfm_set_flags(struct crypto_tfm *tfm, u32 flags) | 
|  | 541 | { | 
|  | 542 | tfm->crt_flags |= flags; | 
|  | 543 | } | 
|  | 544 |  | 
|  | 545 | static inline void crypto_tfm_clear_flags(struct crypto_tfm *tfm, u32 flags) | 
|  | 546 | { | 
|  | 547 | tfm->crt_flags &= ~flags; | 
|  | 548 | } | 
|  | 549 |  | 
| Herbert Xu | 4072518 | 2005-07-06 13:51:52 -0700 | [diff] [blame] | 550 | static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm) | 
|  | 551 | { | 
| Herbert Xu | f10b789 | 2006-01-25 22:34:01 +1100 | [diff] [blame] | 552 | return tfm->__crt_ctx; | 
|  | 553 | } | 
|  | 554 |  | 
|  | 555 | static inline unsigned int crypto_tfm_ctx_alignment(void) | 
|  | 556 | { | 
|  | 557 | struct crypto_tfm *tfm; | 
|  | 558 | return __alignof__(tfm->__crt_ctx); | 
| Herbert Xu | 4072518 | 2005-07-06 13:51:52 -0700 | [diff] [blame] | 559 | } | 
|  | 560 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | /* | 
|  | 562 | * API wrappers. | 
|  | 563 | */ | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 564 | static inline struct crypto_ablkcipher *__crypto_ablkcipher_cast( | 
|  | 565 | struct crypto_tfm *tfm) | 
|  | 566 | { | 
|  | 567 | return (struct crypto_ablkcipher *)tfm; | 
|  | 568 | } | 
|  | 569 |  | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 570 | static inline u32 crypto_skcipher_type(u32 type) | 
|  | 571 | { | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 572 | type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV); | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 573 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 
|  | 574 | return type; | 
|  | 575 | } | 
|  | 576 |  | 
|  | 577 | static inline u32 crypto_skcipher_mask(u32 mask) | 
|  | 578 | { | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 579 | mask &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV); | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 580 | mask |= CRYPTO_ALG_TYPE_BLKCIPHER_MASK; | 
|  | 581 | return mask; | 
|  | 582 | } | 
|  | 583 |  | 
| Herbert Xu | b9c55aa | 2007-12-04 12:46:48 +1100 | [diff] [blame] | 584 | struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name, | 
|  | 585 | u32 type, u32 mask); | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 586 |  | 
|  | 587 | static inline struct crypto_tfm *crypto_ablkcipher_tfm( | 
|  | 588 | struct crypto_ablkcipher *tfm) | 
|  | 589 | { | 
|  | 590 | return &tfm->base; | 
|  | 591 | } | 
|  | 592 |  | 
|  | 593 | static inline void crypto_free_ablkcipher(struct crypto_ablkcipher *tfm) | 
|  | 594 | { | 
|  | 595 | crypto_free_tfm(crypto_ablkcipher_tfm(tfm)); | 
|  | 596 | } | 
|  | 597 |  | 
|  | 598 | static inline int crypto_has_ablkcipher(const char *alg_name, u32 type, | 
|  | 599 | u32 mask) | 
|  | 600 | { | 
| Herbert Xu | 378f4f5 | 2007-12-17 20:07:31 +0800 | [diff] [blame] | 601 | return crypto_has_alg(alg_name, crypto_skcipher_type(type), | 
|  | 602 | crypto_skcipher_mask(mask)); | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 603 | } | 
|  | 604 |  | 
|  | 605 | static inline struct ablkcipher_tfm *crypto_ablkcipher_crt( | 
|  | 606 | struct crypto_ablkcipher *tfm) | 
|  | 607 | { | 
|  | 608 | return &crypto_ablkcipher_tfm(tfm)->crt_ablkcipher; | 
|  | 609 | } | 
|  | 610 |  | 
|  | 611 | static inline unsigned int crypto_ablkcipher_ivsize( | 
|  | 612 | struct crypto_ablkcipher *tfm) | 
|  | 613 | { | 
|  | 614 | return crypto_ablkcipher_crt(tfm)->ivsize; | 
|  | 615 | } | 
|  | 616 |  | 
|  | 617 | static inline unsigned int crypto_ablkcipher_blocksize( | 
|  | 618 | struct crypto_ablkcipher *tfm) | 
|  | 619 | { | 
|  | 620 | return crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(tfm)); | 
|  | 621 | } | 
|  | 622 |  | 
|  | 623 | static inline unsigned int crypto_ablkcipher_alignmask( | 
|  | 624 | struct crypto_ablkcipher *tfm) | 
|  | 625 | { | 
|  | 626 | return crypto_tfm_alg_alignmask(crypto_ablkcipher_tfm(tfm)); | 
|  | 627 | } | 
|  | 628 |  | 
|  | 629 | static inline u32 crypto_ablkcipher_get_flags(struct crypto_ablkcipher *tfm) | 
|  | 630 | { | 
|  | 631 | return crypto_tfm_get_flags(crypto_ablkcipher_tfm(tfm)); | 
|  | 632 | } | 
|  | 633 |  | 
|  | 634 | static inline void crypto_ablkcipher_set_flags(struct crypto_ablkcipher *tfm, | 
|  | 635 | u32 flags) | 
|  | 636 | { | 
|  | 637 | crypto_tfm_set_flags(crypto_ablkcipher_tfm(tfm), flags); | 
|  | 638 | } | 
|  | 639 |  | 
|  | 640 | static inline void crypto_ablkcipher_clear_flags(struct crypto_ablkcipher *tfm, | 
|  | 641 | u32 flags) | 
|  | 642 | { | 
|  | 643 | crypto_tfm_clear_flags(crypto_ablkcipher_tfm(tfm), flags); | 
|  | 644 | } | 
|  | 645 |  | 
|  | 646 | static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm, | 
|  | 647 | const u8 *key, unsigned int keylen) | 
|  | 648 | { | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 649 | struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(tfm); | 
|  | 650 |  | 
|  | 651 | return crt->setkey(crt->base, key, keylen); | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 652 | } | 
|  | 653 |  | 
|  | 654 | static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm( | 
|  | 655 | struct ablkcipher_request *req) | 
|  | 656 | { | 
|  | 657 | return __crypto_ablkcipher_cast(req->base.tfm); | 
|  | 658 | } | 
|  | 659 |  | 
|  | 660 | static inline int crypto_ablkcipher_encrypt(struct ablkcipher_request *req) | 
|  | 661 | { | 
|  | 662 | struct ablkcipher_tfm *crt = | 
|  | 663 | crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req)); | 
|  | 664 | return crt->encrypt(req); | 
|  | 665 | } | 
|  | 666 |  | 
|  | 667 | static inline int crypto_ablkcipher_decrypt(struct ablkcipher_request *req) | 
|  | 668 | { | 
|  | 669 | struct ablkcipher_tfm *crt = | 
|  | 670 | crypto_ablkcipher_crt(crypto_ablkcipher_reqtfm(req)); | 
|  | 671 | return crt->decrypt(req); | 
|  | 672 | } | 
|  | 673 |  | 
| Herbert Xu | b16c3a2 | 2007-08-29 19:02:04 +0800 | [diff] [blame] | 674 | static inline unsigned int crypto_ablkcipher_reqsize( | 
|  | 675 | struct crypto_ablkcipher *tfm) | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 676 | { | 
|  | 677 | return crypto_ablkcipher_crt(tfm)->reqsize; | 
|  | 678 | } | 
|  | 679 |  | 
| Herbert Xu | e196d62 | 2007-04-14 16:09:14 +1000 | [diff] [blame] | 680 | static inline void ablkcipher_request_set_tfm( | 
|  | 681 | struct ablkcipher_request *req, struct crypto_ablkcipher *tfm) | 
|  | 682 | { | 
| Herbert Xu | ecfc432 | 2007-12-05 21:08:36 +1100 | [diff] [blame] | 683 | req->base.tfm = crypto_ablkcipher_tfm(crypto_ablkcipher_crt(tfm)->base); | 
| Herbert Xu | e196d62 | 2007-04-14 16:09:14 +1000 | [diff] [blame] | 684 | } | 
|  | 685 |  | 
| Herbert Xu | b5b7f08 | 2007-04-16 20:48:54 +1000 | [diff] [blame] | 686 | static inline struct ablkcipher_request *ablkcipher_request_cast( | 
|  | 687 | struct crypto_async_request *req) | 
|  | 688 | { | 
|  | 689 | return container_of(req, struct ablkcipher_request, base); | 
|  | 690 | } | 
|  | 691 |  | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 692 | static inline struct ablkcipher_request *ablkcipher_request_alloc( | 
|  | 693 | struct crypto_ablkcipher *tfm, gfp_t gfp) | 
|  | 694 | { | 
|  | 695 | struct ablkcipher_request *req; | 
|  | 696 |  | 
|  | 697 | req = kmalloc(sizeof(struct ablkcipher_request) + | 
|  | 698 | crypto_ablkcipher_reqsize(tfm), gfp); | 
|  | 699 |  | 
|  | 700 | if (likely(req)) | 
| Herbert Xu | e196d62 | 2007-04-14 16:09:14 +1000 | [diff] [blame] | 701 | ablkcipher_request_set_tfm(req, tfm); | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 702 |  | 
|  | 703 | return req; | 
|  | 704 | } | 
|  | 705 |  | 
|  | 706 | static inline void ablkcipher_request_free(struct ablkcipher_request *req) | 
|  | 707 | { | 
| Herbert Xu | aef73cf | 2009-07-11 22:22:14 +0800 | [diff] [blame] | 708 | kzfree(req); | 
| Herbert Xu | 32e3983 | 2007-03-24 14:35:34 +1100 | [diff] [blame] | 709 | } | 
|  | 710 |  | 
|  | 711 | static inline void ablkcipher_request_set_callback( | 
|  | 712 | struct ablkcipher_request *req, | 
|  | 713 | u32 flags, crypto_completion_t complete, void *data) | 
|  | 714 | { | 
|  | 715 | req->base.complete = complete; | 
|  | 716 | req->base.data = data; | 
|  | 717 | req->base.flags = flags; | 
|  | 718 | } | 
|  | 719 |  | 
|  | 720 | static inline void ablkcipher_request_set_crypt( | 
|  | 721 | struct ablkcipher_request *req, | 
|  | 722 | struct scatterlist *src, struct scatterlist *dst, | 
|  | 723 | unsigned int nbytes, void *iv) | 
|  | 724 | { | 
|  | 725 | req->src = src; | 
|  | 726 | req->dst = dst; | 
|  | 727 | req->nbytes = nbytes; | 
|  | 728 | req->info = iv; | 
|  | 729 | } | 
|  | 730 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 731 | static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm) | 
|  | 732 | { | 
|  | 733 | return (struct crypto_aead *)tfm; | 
|  | 734 | } | 
|  | 735 |  | 
| Herbert Xu | d29ce98 | 2007-12-12 19:24:27 +0800 | [diff] [blame] | 736 | struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask); | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 737 |  | 
|  | 738 | static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm) | 
|  | 739 | { | 
|  | 740 | return &tfm->base; | 
|  | 741 | } | 
|  | 742 |  | 
|  | 743 | static inline void crypto_free_aead(struct crypto_aead *tfm) | 
|  | 744 | { | 
|  | 745 | crypto_free_tfm(crypto_aead_tfm(tfm)); | 
|  | 746 | } | 
|  | 747 |  | 
|  | 748 | static inline struct aead_tfm *crypto_aead_crt(struct crypto_aead *tfm) | 
|  | 749 | { | 
|  | 750 | return &crypto_aead_tfm(tfm)->crt_aead; | 
|  | 751 | } | 
|  | 752 |  | 
|  | 753 | static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm) | 
|  | 754 | { | 
|  | 755 | return crypto_aead_crt(tfm)->ivsize; | 
|  | 756 | } | 
|  | 757 |  | 
|  | 758 | static inline unsigned int crypto_aead_authsize(struct crypto_aead *tfm) | 
|  | 759 | { | 
|  | 760 | return crypto_aead_crt(tfm)->authsize; | 
|  | 761 | } | 
|  | 762 |  | 
|  | 763 | static inline unsigned int crypto_aead_blocksize(struct crypto_aead *tfm) | 
|  | 764 | { | 
|  | 765 | return crypto_tfm_alg_blocksize(crypto_aead_tfm(tfm)); | 
|  | 766 | } | 
|  | 767 |  | 
|  | 768 | static inline unsigned int crypto_aead_alignmask(struct crypto_aead *tfm) | 
|  | 769 | { | 
|  | 770 | return crypto_tfm_alg_alignmask(crypto_aead_tfm(tfm)); | 
|  | 771 | } | 
|  | 772 |  | 
|  | 773 | static inline u32 crypto_aead_get_flags(struct crypto_aead *tfm) | 
|  | 774 | { | 
|  | 775 | return crypto_tfm_get_flags(crypto_aead_tfm(tfm)); | 
|  | 776 | } | 
|  | 777 |  | 
|  | 778 | static inline void crypto_aead_set_flags(struct crypto_aead *tfm, u32 flags) | 
|  | 779 | { | 
|  | 780 | crypto_tfm_set_flags(crypto_aead_tfm(tfm), flags); | 
|  | 781 | } | 
|  | 782 |  | 
|  | 783 | static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags) | 
|  | 784 | { | 
|  | 785 | crypto_tfm_clear_flags(crypto_aead_tfm(tfm), flags); | 
|  | 786 | } | 
|  | 787 |  | 
|  | 788 | static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key, | 
|  | 789 | unsigned int keylen) | 
|  | 790 | { | 
| Herbert Xu | 5b6d2d7 | 2007-12-12 19:23:36 +0800 | [diff] [blame] | 791 | struct aead_tfm *crt = crypto_aead_crt(tfm); | 
|  | 792 |  | 
|  | 793 | return crt->setkey(crt->base, key, keylen); | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 794 | } | 
|  | 795 |  | 
| Herbert Xu | 7ba683a | 2007-12-02 18:49:21 +1100 | [diff] [blame] | 796 | int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize); | 
|  | 797 |  | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 798 | static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req) | 
|  | 799 | { | 
|  | 800 | return __crypto_aead_cast(req->base.tfm); | 
|  | 801 | } | 
|  | 802 |  | 
|  | 803 | static inline int crypto_aead_encrypt(struct aead_request *req) | 
|  | 804 | { | 
|  | 805 | return crypto_aead_crt(crypto_aead_reqtfm(req))->encrypt(req); | 
|  | 806 | } | 
|  | 807 |  | 
|  | 808 | static inline int crypto_aead_decrypt(struct aead_request *req) | 
|  | 809 | { | 
|  | 810 | return crypto_aead_crt(crypto_aead_reqtfm(req))->decrypt(req); | 
|  | 811 | } | 
|  | 812 |  | 
| Herbert Xu | b16c3a2 | 2007-08-29 19:02:04 +0800 | [diff] [blame] | 813 | static inline unsigned int crypto_aead_reqsize(struct crypto_aead *tfm) | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 814 | { | 
|  | 815 | return crypto_aead_crt(tfm)->reqsize; | 
|  | 816 | } | 
|  | 817 |  | 
|  | 818 | static inline void aead_request_set_tfm(struct aead_request *req, | 
|  | 819 | struct crypto_aead *tfm) | 
|  | 820 | { | 
| Herbert Xu | 5b6d2d7 | 2007-12-12 19:23:36 +0800 | [diff] [blame] | 821 | req->base.tfm = crypto_aead_tfm(crypto_aead_crt(tfm)->base); | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 822 | } | 
|  | 823 |  | 
|  | 824 | static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, | 
|  | 825 | gfp_t gfp) | 
|  | 826 | { | 
|  | 827 | struct aead_request *req; | 
|  | 828 |  | 
|  | 829 | req = kmalloc(sizeof(*req) + crypto_aead_reqsize(tfm), gfp); | 
|  | 830 |  | 
|  | 831 | if (likely(req)) | 
|  | 832 | aead_request_set_tfm(req, tfm); | 
|  | 833 |  | 
|  | 834 | return req; | 
|  | 835 | } | 
|  | 836 |  | 
|  | 837 | static inline void aead_request_free(struct aead_request *req) | 
|  | 838 | { | 
| Herbert Xu | aef73cf | 2009-07-11 22:22:14 +0800 | [diff] [blame] | 839 | kzfree(req); | 
| Herbert Xu | 1ae9782 | 2007-08-30 15:36:14 +0800 | [diff] [blame] | 840 | } | 
|  | 841 |  | 
|  | 842 | static inline void aead_request_set_callback(struct aead_request *req, | 
|  | 843 | u32 flags, | 
|  | 844 | crypto_completion_t complete, | 
|  | 845 | void *data) | 
|  | 846 | { | 
|  | 847 | req->base.complete = complete; | 
|  | 848 | req->base.data = data; | 
|  | 849 | req->base.flags = flags; | 
|  | 850 | } | 
|  | 851 |  | 
|  | 852 | static inline void aead_request_set_crypt(struct aead_request *req, | 
|  | 853 | struct scatterlist *src, | 
|  | 854 | struct scatterlist *dst, | 
|  | 855 | unsigned int cryptlen, u8 *iv) | 
|  | 856 | { | 
|  | 857 | req->src = src; | 
|  | 858 | req->dst = dst; | 
|  | 859 | req->cryptlen = cryptlen; | 
|  | 860 | req->iv = iv; | 
|  | 861 | } | 
|  | 862 |  | 
|  | 863 | static inline void aead_request_set_assoc(struct aead_request *req, | 
|  | 864 | struct scatterlist *assoc, | 
|  | 865 | unsigned int assoclen) | 
|  | 866 | { | 
|  | 867 | req->assoc = assoc; | 
|  | 868 | req->assoclen = assoclen; | 
|  | 869 | } | 
|  | 870 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 871 | static inline struct crypto_blkcipher *__crypto_blkcipher_cast( | 
|  | 872 | struct crypto_tfm *tfm) | 
|  | 873 | { | 
|  | 874 | return (struct crypto_blkcipher *)tfm; | 
|  | 875 | } | 
|  | 876 |  | 
|  | 877 | static inline struct crypto_blkcipher *crypto_blkcipher_cast( | 
|  | 878 | struct crypto_tfm *tfm) | 
|  | 879 | { | 
|  | 880 | BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_BLKCIPHER); | 
|  | 881 | return __crypto_blkcipher_cast(tfm); | 
|  | 882 | } | 
|  | 883 |  | 
|  | 884 | static inline struct crypto_blkcipher *crypto_alloc_blkcipher( | 
|  | 885 | const char *alg_name, u32 type, u32 mask) | 
|  | 886 | { | 
| Herbert Xu | 332f884 | 2007-11-15 22:36:07 +0800 | [diff] [blame] | 887 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 888 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 
| Herbert Xu | 332f884 | 2007-11-15 22:36:07 +0800 | [diff] [blame] | 889 | mask |= CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 890 |  | 
|  | 891 | return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask)); | 
|  | 892 | } | 
|  | 893 |  | 
|  | 894 | static inline struct crypto_tfm *crypto_blkcipher_tfm( | 
|  | 895 | struct crypto_blkcipher *tfm) | 
|  | 896 | { | 
|  | 897 | return &tfm->base; | 
|  | 898 | } | 
|  | 899 |  | 
|  | 900 | static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm) | 
|  | 901 | { | 
|  | 902 | crypto_free_tfm(crypto_blkcipher_tfm(tfm)); | 
|  | 903 | } | 
|  | 904 |  | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 905 | static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask) | 
|  | 906 | { | 
| Herbert Xu | 332f884 | 2007-11-15 22:36:07 +0800 | [diff] [blame] | 907 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 908 | type |= CRYPTO_ALG_TYPE_BLKCIPHER; | 
| Herbert Xu | 332f884 | 2007-11-15 22:36:07 +0800 | [diff] [blame] | 909 | mask |= CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 910 |  | 
|  | 911 | return crypto_has_alg(alg_name, type, mask); | 
|  | 912 | } | 
|  | 913 |  | 
| Herbert Xu | 5cde0af | 2006-08-22 00:07:53 +1000 | [diff] [blame] | 914 | static inline const char *crypto_blkcipher_name(struct crypto_blkcipher *tfm) | 
|  | 915 | { | 
|  | 916 | return crypto_tfm_alg_name(crypto_blkcipher_tfm(tfm)); | 
|  | 917 | } | 
|  | 918 |  | 
|  | 919 | static inline struct blkcipher_tfm *crypto_blkcipher_crt( | 
|  | 920 | struct crypto_blkcipher *tfm) | 
|  | 921 | { | 
|  | 922 | return &crypto_blkcipher_tfm(tfm)->crt_blkcipher; | 
|  | 923 | } | 
|  | 924 |  | 
|  | 925 | static inline struct blkcipher_alg *crypto_blkcipher_alg( | 
|  | 926 | struct crypto_blkcipher *tfm) | 
|  | 927 | { | 
|  | 928 | return &crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher; | 
|  | 929 | } | 
|  | 930 |  | 
|  | 931 | static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm) | 
|  | 932 | { | 
|  | 933 | return crypto_blkcipher_alg(tfm)->ivsize; | 
|  | 934 | } | 
|  | 935 |  | 
|  | 936 | static inline unsigned int crypto_blkcipher_blocksize( | 
|  | 937 | struct crypto_blkcipher *tfm) | 
|  | 938 | { | 
|  | 939 | return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm)); | 
|  | 940 | } | 
|  | 941 |  | 
|  | 942 | static inline unsigned int crypto_blkcipher_alignmask( | 
|  | 943 | struct crypto_blkcipher *tfm) | 
|  | 944 | { | 
|  | 945 | return crypto_tfm_alg_alignmask(crypto_blkcipher_tfm(tfm)); | 
|  | 946 | } | 
|  | 947 |  | 
|  | 948 | static inline u32 crypto_blkcipher_get_flags(struct crypto_blkcipher *tfm) | 
|  | 949 | { | 
|  | 950 | return crypto_tfm_get_flags(crypto_blkcipher_tfm(tfm)); | 
|  | 951 | } | 
|  | 952 |  | 
|  | 953 | static inline void crypto_blkcipher_set_flags(struct crypto_blkcipher *tfm, | 
|  | 954 | u32 flags) | 
|  | 955 | { | 
|  | 956 | crypto_tfm_set_flags(crypto_blkcipher_tfm(tfm), flags); | 
|  | 957 | } | 
|  | 958 |  | 
|  | 959 | static inline void crypto_blkcipher_clear_flags(struct crypto_blkcipher *tfm, | 
|  | 960 | u32 flags) | 
|  | 961 | { | 
|  | 962 | crypto_tfm_clear_flags(crypto_blkcipher_tfm(tfm), flags); | 
|  | 963 | } | 
|  | 964 |  | 
|  | 965 | static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm, | 
|  | 966 | const u8 *key, unsigned int keylen) | 
|  | 967 | { | 
|  | 968 | return crypto_blkcipher_crt(tfm)->setkey(crypto_blkcipher_tfm(tfm), | 
|  | 969 | key, keylen); | 
|  | 970 | } | 
|  | 971 |  | 
|  | 972 | static inline int crypto_blkcipher_encrypt(struct blkcipher_desc *desc, | 
|  | 973 | struct scatterlist *dst, | 
|  | 974 | struct scatterlist *src, | 
|  | 975 | unsigned int nbytes) | 
|  | 976 | { | 
|  | 977 | desc->info = crypto_blkcipher_crt(desc->tfm)->iv; | 
|  | 978 | return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes); | 
|  | 979 | } | 
|  | 980 |  | 
|  | 981 | static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc, | 
|  | 982 | struct scatterlist *dst, | 
|  | 983 | struct scatterlist *src, | 
|  | 984 | unsigned int nbytes) | 
|  | 985 | { | 
|  | 986 | return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes); | 
|  | 987 | } | 
|  | 988 |  | 
|  | 989 | static inline int crypto_blkcipher_decrypt(struct blkcipher_desc *desc, | 
|  | 990 | struct scatterlist *dst, | 
|  | 991 | struct scatterlist *src, | 
|  | 992 | unsigned int nbytes) | 
|  | 993 | { | 
|  | 994 | desc->info = crypto_blkcipher_crt(desc->tfm)->iv; | 
|  | 995 | return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes); | 
|  | 996 | } | 
|  | 997 |  | 
|  | 998 | static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc, | 
|  | 999 | struct scatterlist *dst, | 
|  | 1000 | struct scatterlist *src, | 
|  | 1001 | unsigned int nbytes) | 
|  | 1002 | { | 
|  | 1003 | return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes); | 
|  | 1004 | } | 
|  | 1005 |  | 
|  | 1006 | static inline void crypto_blkcipher_set_iv(struct crypto_blkcipher *tfm, | 
|  | 1007 | const u8 *src, unsigned int len) | 
|  | 1008 | { | 
|  | 1009 | memcpy(crypto_blkcipher_crt(tfm)->iv, src, len); | 
|  | 1010 | } | 
|  | 1011 |  | 
|  | 1012 | static inline void crypto_blkcipher_get_iv(struct crypto_blkcipher *tfm, | 
|  | 1013 | u8 *dst, unsigned int len) | 
|  | 1014 | { | 
|  | 1015 | memcpy(dst, crypto_blkcipher_crt(tfm)->iv, len); | 
|  | 1016 | } | 
|  | 1017 |  | 
| Herbert Xu | f28776a | 2006-08-13 20:58:18 +1000 | [diff] [blame] | 1018 | static inline struct crypto_cipher *__crypto_cipher_cast(struct crypto_tfm *tfm) | 
|  | 1019 | { | 
|  | 1020 | return (struct crypto_cipher *)tfm; | 
|  | 1021 | } | 
|  | 1022 |  | 
|  | 1023 | static inline struct crypto_cipher *crypto_cipher_cast(struct crypto_tfm *tfm) | 
|  | 1024 | { | 
|  | 1025 | BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); | 
|  | 1026 | return __crypto_cipher_cast(tfm); | 
|  | 1027 | } | 
|  | 1028 |  | 
|  | 1029 | static inline struct crypto_cipher *crypto_alloc_cipher(const char *alg_name, | 
|  | 1030 | u32 type, u32 mask) | 
|  | 1031 | { | 
|  | 1032 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
|  | 1033 | type |= CRYPTO_ALG_TYPE_CIPHER; | 
|  | 1034 | mask |= CRYPTO_ALG_TYPE_MASK; | 
|  | 1035 |  | 
|  | 1036 | return __crypto_cipher_cast(crypto_alloc_base(alg_name, type, mask)); | 
|  | 1037 | } | 
|  | 1038 |  | 
|  | 1039 | static inline struct crypto_tfm *crypto_cipher_tfm(struct crypto_cipher *tfm) | 
|  | 1040 | { | 
| Herbert Xu | 78a1fe4 | 2006-12-24 10:02:00 +1100 | [diff] [blame] | 1041 | return &tfm->base; | 
| Herbert Xu | f28776a | 2006-08-13 20:58:18 +1000 | [diff] [blame] | 1042 | } | 
|  | 1043 |  | 
|  | 1044 | static inline void crypto_free_cipher(struct crypto_cipher *tfm) | 
|  | 1045 | { | 
|  | 1046 | crypto_free_tfm(crypto_cipher_tfm(tfm)); | 
|  | 1047 | } | 
|  | 1048 |  | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1049 | static inline int crypto_has_cipher(const char *alg_name, u32 type, u32 mask) | 
|  | 1050 | { | 
|  | 1051 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
|  | 1052 | type |= CRYPTO_ALG_TYPE_CIPHER; | 
|  | 1053 | mask |= CRYPTO_ALG_TYPE_MASK; | 
|  | 1054 |  | 
|  | 1055 | return crypto_has_alg(alg_name, type, mask); | 
|  | 1056 | } | 
|  | 1057 |  | 
| Herbert Xu | f28776a | 2006-08-13 20:58:18 +1000 | [diff] [blame] | 1058 | static inline struct cipher_tfm *crypto_cipher_crt(struct crypto_cipher *tfm) | 
|  | 1059 | { | 
|  | 1060 | return &crypto_cipher_tfm(tfm)->crt_cipher; | 
|  | 1061 | } | 
|  | 1062 |  | 
|  | 1063 | static inline unsigned int crypto_cipher_blocksize(struct crypto_cipher *tfm) | 
|  | 1064 | { | 
|  | 1065 | return crypto_tfm_alg_blocksize(crypto_cipher_tfm(tfm)); | 
|  | 1066 | } | 
|  | 1067 |  | 
|  | 1068 | static inline unsigned int crypto_cipher_alignmask(struct crypto_cipher *tfm) | 
|  | 1069 | { | 
|  | 1070 | return crypto_tfm_alg_alignmask(crypto_cipher_tfm(tfm)); | 
|  | 1071 | } | 
|  | 1072 |  | 
|  | 1073 | static inline u32 crypto_cipher_get_flags(struct crypto_cipher *tfm) | 
|  | 1074 | { | 
|  | 1075 | return crypto_tfm_get_flags(crypto_cipher_tfm(tfm)); | 
|  | 1076 | } | 
|  | 1077 |  | 
|  | 1078 | static inline void crypto_cipher_set_flags(struct crypto_cipher *tfm, | 
|  | 1079 | u32 flags) | 
|  | 1080 | { | 
|  | 1081 | crypto_tfm_set_flags(crypto_cipher_tfm(tfm), flags); | 
|  | 1082 | } | 
|  | 1083 |  | 
|  | 1084 | static inline void crypto_cipher_clear_flags(struct crypto_cipher *tfm, | 
|  | 1085 | u32 flags) | 
|  | 1086 | { | 
|  | 1087 | crypto_tfm_clear_flags(crypto_cipher_tfm(tfm), flags); | 
|  | 1088 | } | 
|  | 1089 |  | 
| Herbert Xu | 7226bc8 | 2006-08-21 21:40:49 +1000 | [diff] [blame] | 1090 | static inline int crypto_cipher_setkey(struct crypto_cipher *tfm, | 
|  | 1091 | const u8 *key, unsigned int keylen) | 
|  | 1092 | { | 
|  | 1093 | return crypto_cipher_crt(tfm)->cit_setkey(crypto_cipher_tfm(tfm), | 
|  | 1094 | key, keylen); | 
|  | 1095 | } | 
|  | 1096 |  | 
| Herbert Xu | f28776a | 2006-08-13 20:58:18 +1000 | [diff] [blame] | 1097 | static inline void crypto_cipher_encrypt_one(struct crypto_cipher *tfm, | 
|  | 1098 | u8 *dst, const u8 *src) | 
|  | 1099 | { | 
|  | 1100 | crypto_cipher_crt(tfm)->cit_encrypt_one(crypto_cipher_tfm(tfm), | 
|  | 1101 | dst, src); | 
|  | 1102 | } | 
|  | 1103 |  | 
|  | 1104 | static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm, | 
|  | 1105 | u8 *dst, const u8 *src) | 
|  | 1106 | { | 
|  | 1107 | crypto_cipher_crt(tfm)->cit_decrypt_one(crypto_cipher_tfm(tfm), | 
|  | 1108 | dst, src); | 
|  | 1109 | } | 
|  | 1110 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1111 | static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | { | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1113 | return (struct crypto_hash *)tfm; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | } | 
|  | 1115 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1116 | static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | { | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1118 | BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_HASH) & | 
|  | 1119 | CRYPTO_ALG_TYPE_HASH_MASK); | 
|  | 1120 | return __crypto_hash_cast(tfm); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | } | 
|  | 1122 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1123 | static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name, | 
|  | 1124 | u32 type, u32 mask) | 
|  | 1125 | { | 
|  | 1126 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | 551a09a | 2007-12-01 21:47:07 +1100 | [diff] [blame] | 1127 | mask &= ~CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1128 | type |= CRYPTO_ALG_TYPE_HASH; | 
|  | 1129 | mask |= CRYPTO_ALG_TYPE_HASH_MASK; | 
|  | 1130 |  | 
|  | 1131 | return __crypto_hash_cast(crypto_alloc_base(alg_name, type, mask)); | 
|  | 1132 | } | 
|  | 1133 |  | 
|  | 1134 | static inline struct crypto_tfm *crypto_hash_tfm(struct crypto_hash *tfm) | 
|  | 1135 | { | 
|  | 1136 | return &tfm->base; | 
|  | 1137 | } | 
|  | 1138 |  | 
|  | 1139 | static inline void crypto_free_hash(struct crypto_hash *tfm) | 
|  | 1140 | { | 
|  | 1141 | crypto_free_tfm(crypto_hash_tfm(tfm)); | 
|  | 1142 | } | 
|  | 1143 |  | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1144 | static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask) | 
|  | 1145 | { | 
|  | 1146 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | 551a09a | 2007-12-01 21:47:07 +1100 | [diff] [blame] | 1147 | mask &= ~CRYPTO_ALG_TYPE_MASK; | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1148 | type |= CRYPTO_ALG_TYPE_HASH; | 
|  | 1149 | mask |= CRYPTO_ALG_TYPE_HASH_MASK; | 
|  | 1150 |  | 
|  | 1151 | return crypto_has_alg(alg_name, type, mask); | 
|  | 1152 | } | 
|  | 1153 |  | 
| Herbert Xu | 055bcee | 2006-08-19 22:24:23 +1000 | [diff] [blame] | 1154 | static inline struct hash_tfm *crypto_hash_crt(struct crypto_hash *tfm) | 
|  | 1155 | { | 
|  | 1156 | return &crypto_hash_tfm(tfm)->crt_hash; | 
|  | 1157 | } | 
|  | 1158 |  | 
|  | 1159 | static inline unsigned int crypto_hash_blocksize(struct crypto_hash *tfm) | 
|  | 1160 | { | 
|  | 1161 | return crypto_tfm_alg_blocksize(crypto_hash_tfm(tfm)); | 
|  | 1162 | } | 
|  | 1163 |  | 
|  | 1164 | static inline unsigned int crypto_hash_alignmask(struct crypto_hash *tfm) | 
|  | 1165 | { | 
|  | 1166 | return crypto_tfm_alg_alignmask(crypto_hash_tfm(tfm)); | 
|  | 1167 | } | 
|  | 1168 |  | 
|  | 1169 | static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm) | 
|  | 1170 | { | 
|  | 1171 | return crypto_hash_crt(tfm)->digestsize; | 
|  | 1172 | } | 
|  | 1173 |  | 
|  | 1174 | static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm) | 
|  | 1175 | { | 
|  | 1176 | return crypto_tfm_get_flags(crypto_hash_tfm(tfm)); | 
|  | 1177 | } | 
|  | 1178 |  | 
|  | 1179 | static inline void crypto_hash_set_flags(struct crypto_hash *tfm, u32 flags) | 
|  | 1180 | { | 
|  | 1181 | crypto_tfm_set_flags(crypto_hash_tfm(tfm), flags); | 
|  | 1182 | } | 
|  | 1183 |  | 
|  | 1184 | static inline void crypto_hash_clear_flags(struct crypto_hash *tfm, u32 flags) | 
|  | 1185 | { | 
|  | 1186 | crypto_tfm_clear_flags(crypto_hash_tfm(tfm), flags); | 
|  | 1187 | } | 
|  | 1188 |  | 
|  | 1189 | static inline int crypto_hash_init(struct hash_desc *desc) | 
|  | 1190 | { | 
|  | 1191 | return crypto_hash_crt(desc->tfm)->init(desc); | 
|  | 1192 | } | 
|  | 1193 |  | 
|  | 1194 | static inline int crypto_hash_update(struct hash_desc *desc, | 
|  | 1195 | struct scatterlist *sg, | 
|  | 1196 | unsigned int nbytes) | 
|  | 1197 | { | 
|  | 1198 | return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes); | 
|  | 1199 | } | 
|  | 1200 |  | 
|  | 1201 | static inline int crypto_hash_final(struct hash_desc *desc, u8 *out) | 
|  | 1202 | { | 
|  | 1203 | return crypto_hash_crt(desc->tfm)->final(desc, out); | 
|  | 1204 | } | 
|  | 1205 |  | 
|  | 1206 | static inline int crypto_hash_digest(struct hash_desc *desc, | 
|  | 1207 | struct scatterlist *sg, | 
|  | 1208 | unsigned int nbytes, u8 *out) | 
|  | 1209 | { | 
|  | 1210 | return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out); | 
|  | 1211 | } | 
|  | 1212 |  | 
|  | 1213 | static inline int crypto_hash_setkey(struct crypto_hash *hash, | 
|  | 1214 | const u8 *key, unsigned int keylen) | 
|  | 1215 | { | 
|  | 1216 | return crypto_hash_crt(hash)->setkey(hash, key, keylen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | } | 
|  | 1218 |  | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1219 | static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm) | 
|  | 1220 | { | 
|  | 1221 | return (struct crypto_comp *)tfm; | 
|  | 1222 | } | 
|  | 1223 |  | 
|  | 1224 | static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm) | 
|  | 1225 | { | 
|  | 1226 | BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) & | 
|  | 1227 | CRYPTO_ALG_TYPE_MASK); | 
|  | 1228 | return __crypto_comp_cast(tfm); | 
|  | 1229 | } | 
|  | 1230 |  | 
|  | 1231 | static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name, | 
|  | 1232 | u32 type, u32 mask) | 
|  | 1233 | { | 
|  | 1234 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
|  | 1235 | type |= CRYPTO_ALG_TYPE_COMPRESS; | 
|  | 1236 | mask |= CRYPTO_ALG_TYPE_MASK; | 
|  | 1237 |  | 
|  | 1238 | return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask)); | 
|  | 1239 | } | 
|  | 1240 |  | 
|  | 1241 | static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm) | 
|  | 1242 | { | 
| Herbert Xu | 78a1fe4 | 2006-12-24 10:02:00 +1100 | [diff] [blame] | 1243 | return &tfm->base; | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1244 | } | 
|  | 1245 |  | 
|  | 1246 | static inline void crypto_free_comp(struct crypto_comp *tfm) | 
|  | 1247 | { | 
|  | 1248 | crypto_free_tfm(crypto_comp_tfm(tfm)); | 
|  | 1249 | } | 
|  | 1250 |  | 
|  | 1251 | static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask) | 
|  | 1252 | { | 
|  | 1253 | type &= ~CRYPTO_ALG_TYPE_MASK; | 
|  | 1254 | type |= CRYPTO_ALG_TYPE_COMPRESS; | 
|  | 1255 | mask |= CRYPTO_ALG_TYPE_MASK; | 
|  | 1256 |  | 
|  | 1257 | return crypto_has_alg(alg_name, type, mask); | 
|  | 1258 | } | 
|  | 1259 |  | 
| Herbert Xu | e4d5b79 | 2006-08-26 18:12:40 +1000 | [diff] [blame] | 1260 | static inline const char *crypto_comp_name(struct crypto_comp *tfm) | 
|  | 1261 | { | 
|  | 1262 | return crypto_tfm_alg_name(crypto_comp_tfm(tfm)); | 
|  | 1263 | } | 
|  | 1264 |  | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1265 | static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm) | 
|  | 1266 | { | 
|  | 1267 | return &crypto_comp_tfm(tfm)->crt_compress; | 
|  | 1268 | } | 
|  | 1269 |  | 
|  | 1270 | static inline int crypto_comp_compress(struct crypto_comp *tfm, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | const u8 *src, unsigned int slen, | 
|  | 1272 | u8 *dst, unsigned int *dlen) | 
|  | 1273 | { | 
| Herbert Xu | 78a1fe4 | 2006-12-24 10:02:00 +1100 | [diff] [blame] | 1274 | return crypto_comp_crt(tfm)->cot_compress(crypto_comp_tfm(tfm), | 
|  | 1275 | src, slen, dst, dlen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | } | 
|  | 1277 |  | 
| Herbert Xu | fce32d7 | 2006-08-26 17:35:45 +1000 | [diff] [blame] | 1278 | static inline int crypto_comp_decompress(struct crypto_comp *tfm, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1279 | const u8 *src, unsigned int slen, | 
|  | 1280 | u8 *dst, unsigned int *dlen) | 
|  | 1281 | { | 
| Herbert Xu | 78a1fe4 | 2006-12-24 10:02:00 +1100 | [diff] [blame] | 1282 | return crypto_comp_crt(tfm)->cot_decompress(crypto_comp_tfm(tfm), | 
|  | 1283 | src, slen, dst, dlen); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | } | 
|  | 1285 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | #endif	/* _LINUX_CRYPTO_H */ | 
|  | 1287 |  |