aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/xcbc.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-12-23 17:59:42 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2007-02-06 17:21:01 -0500
commit6b701dde8e0584f3bf0b6857d0e92f7ed15ed6f9 (patch)
tree581af967a3da50d916ab5a5cdf1f6cc8ff4a80cc /crypto/xcbc.c
parent27d2a3300755387d2fec231d37944907ff992ce8 (diff)
[CRYPTO] xcbc: Use new cipher interface
This patch changes xcbc to use the new cipher encryt_one interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/xcbc.c')
-rw-r--r--crypto/xcbc.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index d7b4be0a057d..53e8ccbf0f5f 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -48,7 +48,7 @@ static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101,
48 * +------------------------ 48 * +------------------------
49 */ 49 */
50struct crypto_xcbc_ctx { 50struct crypto_xcbc_ctx {
51 struct crypto_tfm *child; 51 struct crypto_cipher *child;
52 u8 *odds; 52 u8 *odds;
53 u8 *prev; 53 u8 *prev;
54 u8 *key; 54 u8 *key;
@@ -76,8 +76,7 @@ static int _crypto_xcbc_digest_setkey(struct crypto_hash *parent,
76 if ((err = crypto_cipher_setkey(ctx->child, ctx->key, ctx->keylen))) 76 if ((err = crypto_cipher_setkey(ctx->child, ctx->key, ctx->keylen)))
77 return err; 77 return err;
78 78
79 ctx->child->__crt_alg->cra_cipher.cia_encrypt(ctx->child, key1, 79 crypto_cipher_encrypt_one(ctx->child, key1, ctx->consts);
80 ctx->consts);
81 80
82 return crypto_cipher_setkey(ctx->child, key1, bs); 81 return crypto_cipher_setkey(ctx->child, key1, bs);
83} 82}
@@ -87,7 +86,7 @@ static int crypto_xcbc_digest_setkey(struct crypto_hash *parent,
87{ 86{
88 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent); 87 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
89 88
90 if (keylen != crypto_tfm_alg_blocksize(ctx->child)) 89 if (keylen != crypto_cipher_blocksize(ctx->child))
91 return -EINVAL; 90 return -EINVAL;
92 91
93 ctx->keylen = keylen; 92 ctx->keylen = keylen;
@@ -115,7 +114,7 @@ static int crypto_xcbc_digest_update2(struct hash_desc *pdesc,
115{ 114{
116 struct crypto_hash *parent = pdesc->tfm; 115 struct crypto_hash *parent = pdesc->tfm;
117 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent); 116 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
118 struct crypto_tfm *tfm = ctx->child; 117 struct crypto_cipher *tfm = ctx->child;
119 int bs = crypto_hash_blocksize(parent); 118 int bs = crypto_hash_blocksize(parent);
120 unsigned int i = 0; 119 unsigned int i = 0;
121 120
@@ -143,7 +142,7 @@ static int crypto_xcbc_digest_update2(struct hash_desc *pdesc,
143 offset += len; 142 offset += len;
144 143
145 crypto_kunmap(p, 0); 144 crypto_kunmap(p, 0);
146 crypto_yield(tfm->crt_flags); 145 crypto_yield(pdesc->flags);
147 continue; 146 continue;
148 } 147 }
149 148
@@ -153,7 +152,7 @@ static int crypto_xcbc_digest_update2(struct hash_desc *pdesc,
153 p += bs - ctx->len; 152 p += bs - ctx->len;
154 153
155 ctx->xor(ctx->prev, ctx->odds, bs); 154 ctx->xor(ctx->prev, ctx->odds, bs);
156 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev); 155 crypto_cipher_encrypt_one(tfm, ctx->prev, ctx->prev);
157 156
158 /* clearing the length */ 157 /* clearing the length */
159 ctx->len = 0; 158 ctx->len = 0;
@@ -161,7 +160,8 @@ static int crypto_xcbc_digest_update2(struct hash_desc *pdesc,
161 /* encrypting the rest of data */ 160 /* encrypting the rest of data */
162 while (len > bs) { 161 while (len > bs) {
163 ctx->xor(ctx->prev, p, bs); 162 ctx->xor(ctx->prev, p, bs);
164 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev); 163 crypto_cipher_encrypt_one(tfm, ctx->prev,
164 ctx->prev);
165 p += bs; 165 p += bs;
166 len -= bs; 166 len -= bs;
167 } 167 }
@@ -172,7 +172,7 @@ static int crypto_xcbc_digest_update2(struct hash_desc *pdesc,
172 ctx->len = len; 172 ctx->len = len;
173 } 173 }
174 crypto_kunmap(p, 0); 174 crypto_kunmap(p, 0);
175 crypto_yield(tfm->crt_flags); 175 crypto_yield(pdesc->flags);
176 slen -= min(slen, ((unsigned int)(PAGE_SIZE)) - offset); 176 slen -= min(slen, ((unsigned int)(PAGE_SIZE)) - offset);
177 offset = 0; 177 offset = 0;
178 pg++; 178 pg++;
@@ -197,7 +197,7 @@ static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
197{ 197{
198 struct crypto_hash *parent = pdesc->tfm; 198 struct crypto_hash *parent = pdesc->tfm;
199 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent); 199 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
200 struct crypto_tfm *tfm = ctx->child; 200 struct crypto_cipher *tfm = ctx->child;
201 int bs = crypto_hash_blocksize(parent); 201 int bs = crypto_hash_blocksize(parent);
202 int err = 0; 202 int err = 0;
203 203
@@ -207,13 +207,14 @@ static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
207 if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0) 207 if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
208 return err; 208 return err;
209 209
210 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key2, (const u8*)(ctx->consts+bs)); 210 crypto_cipher_encrypt_one(tfm, key2,
211 (u8 *)(ctx->consts + bs));
211 212
212 ctx->xor(ctx->prev, ctx->odds, bs); 213 ctx->xor(ctx->prev, ctx->odds, bs);
213 ctx->xor(ctx->prev, key2, bs); 214 ctx->xor(ctx->prev, key2, bs);
214 _crypto_xcbc_digest_setkey(parent, ctx); 215 _crypto_xcbc_digest_setkey(parent, ctx);
215 216
216 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev); 217 crypto_cipher_encrypt_one(tfm, out, ctx->prev);
217 } else { 218 } else {
218 u8 key3[bs]; 219 u8 key3[bs];
219 unsigned int rlen; 220 unsigned int rlen;
@@ -228,14 +229,15 @@ static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
228 if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0) 229 if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
229 return err; 230 return err;
230 231
231 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key3, (const u8*)(ctx->consts+bs*2)); 232 crypto_cipher_encrypt_one(tfm, key3,
233 (u8 *)(ctx->consts + bs * 2));
232 234
233 ctx->xor(ctx->prev, ctx->odds, bs); 235 ctx->xor(ctx->prev, ctx->odds, bs);
234 ctx->xor(ctx->prev, key3, bs); 236 ctx->xor(ctx->prev, key3, bs);
235 237
236 _crypto_xcbc_digest_setkey(parent, ctx); 238 _crypto_xcbc_digest_setkey(parent, ctx);
237 239
238 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev); 240 crypto_cipher_encrypt_one(tfm, out, ctx->prev);
239 } 241 }
240 242
241 return 0; 243 return 0;