diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-07-06 16:51:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-07-06 16:51:52 -0400 |
commit | 40725181b74be6b0e3bdc8c05bd1e0b9873ec5cc (patch) | |
tree | abbc1057a5e0bd77385d17cfc6146617151e93bc /include | |
parent | c774e93e2152d0be2612739418689e6e6400f4eb (diff) |
[CRYPTO] Add support for low-level multi-block operations
This patch adds hooks for cipher algorithms to implement multi-block
ECB/CBC operations directly. This is expected to provide significant
performance boots to the VIA Padlock.
It could also be used for improving software implementations such as
AES where operating on multiple blocks at a time may enable certain
optimisations.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/crypto.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 387da6a3e58c..26ce01c25745 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -61,6 +61,15 @@ | |||
61 | #define CRYPTO_DIR_DECRYPT 0 | 61 | #define CRYPTO_DIR_DECRYPT 0 |
62 | 62 | ||
63 | struct scatterlist; | 63 | struct scatterlist; |
64 | struct crypto_tfm; | ||
65 | |||
66 | struct cipher_desc { | ||
67 | struct crypto_tfm *tfm; | ||
68 | void (*crfn)(void *ctx, u8 *dst, const u8 *src); | ||
69 | unsigned int (*prfn)(const struct cipher_desc *desc, u8 *dst, | ||
70 | const u8 *src, unsigned int nbytes); | ||
71 | void *info; | ||
72 | }; | ||
64 | 73 | ||
65 | /* | 74 | /* |
66 | * Algorithms: modular crypto algorithm implementations, managed | 75 | * Algorithms: modular crypto algorithm implementations, managed |
@@ -73,6 +82,19 @@ struct cipher_alg { | |||
73 | unsigned int keylen, u32 *flags); | 82 | unsigned int keylen, u32 *flags); |
74 | void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); | 83 | void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src); |
75 | void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); | 84 | void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src); |
85 | |||
86 | unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc, | ||
87 | u8 *dst, const u8 *src, | ||
88 | unsigned int nbytes); | ||
89 | unsigned int (*cia_decrypt_ecb)(const struct cipher_desc *desc, | ||
90 | u8 *dst, const u8 *src, | ||
91 | unsigned int nbytes); | ||
92 | unsigned int (*cia_encrypt_cbc)(const struct cipher_desc *desc, | ||
93 | u8 *dst, const u8 *src, | ||
94 | unsigned int nbytes); | ||
95 | unsigned int (*cia_decrypt_cbc)(const struct cipher_desc *desc, | ||
96 | u8 *dst, const u8 *src, | ||
97 | unsigned int nbytes); | ||
76 | }; | 98 | }; |
77 | 99 | ||
78 | struct digest_alg { | 100 | struct digest_alg { |
@@ -136,7 +158,6 @@ static inline int crypto_alg_available(const char *name, u32 flags) | |||
136 | * and core processing logic. Managed via crypto_alloc_tfm() and | 158 | * and core processing logic. Managed via crypto_alloc_tfm() and |
137 | * crypto_free_tfm(), as well as the various helpers below. | 159 | * crypto_free_tfm(), as well as the various helpers below. |
138 | */ | 160 | */ |
139 | struct crypto_tfm; | ||
140 | 161 | ||
141 | struct cipher_tfm { | 162 | struct cipher_tfm { |
142 | void *cit_iv; | 163 | void *cit_iv; |
@@ -266,6 +287,11 @@ static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm) | |||
266 | return tfm->__crt_alg->cra_digest.dia_digestsize; | 287 | return tfm->__crt_alg->cra_digest.dia_digestsize; |
267 | } | 288 | } |
268 | 289 | ||
290 | static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm) | ||
291 | { | ||
292 | return (void *)&tfm[1]; | ||
293 | } | ||
294 | |||
269 | /* | 295 | /* |
270 | * API wrappers. | 296 | * API wrappers. |
271 | */ | 297 | */ |