2727#include <asm/switch_to.h>
2828#include <crypto/aes.h>
2929#include <crypto/scatterwalk.h>
30+ #include <crypto/skcipher.h>
3031
3132#include "aesp8-ppc.h"
3233
3334struct p8_aes_cbc_ctx {
34- struct crypto_blkcipher * fallback ;
35+ struct crypto_skcipher * fallback ;
3536 struct aes_key enc_key ;
3637 struct aes_key dec_key ;
3738};
3839
3940static int p8_aes_cbc_init (struct crypto_tfm * tfm )
4041{
4142 const char * alg ;
42- struct crypto_blkcipher * fallback ;
43+ struct crypto_skcipher * fallback ;
4344 struct p8_aes_cbc_ctx * ctx = crypto_tfm_ctx (tfm );
4445
4546 if (!(alg = crypto_tfm_alg_name (tfm ))) {
4647 printk (KERN_ERR "Failed to get algorithm name.\n" );
4748 return - ENOENT ;
4849 }
4950
50- fallback =
51- crypto_alloc_blkcipher (alg , 0 , CRYPTO_ALG_NEED_FALLBACK );
51+ fallback = crypto_alloc_skcipher (alg , 0 ,
52+ CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK );
53+
5254 if (IS_ERR (fallback )) {
5355 printk (KERN_ERR
5456 "Failed to allocate transformation for '%s': %ld\n" ,
5557 alg , PTR_ERR (fallback ));
5658 return PTR_ERR (fallback );
5759 }
5860 printk (KERN_INFO "Using '%s' as fallback implementation.\n" ,
59- crypto_tfm_alg_driver_name ((struct crypto_tfm * ) fallback ));
61+ crypto_skcipher_driver_name (fallback ));
62+
6063
61- crypto_blkcipher_set_flags (
64+ crypto_skcipher_set_flags (
6265 fallback ,
63- crypto_blkcipher_get_flags ((struct crypto_blkcipher * )tfm ));
66+ crypto_skcipher_get_flags ((struct crypto_skcipher * )tfm ));
6467 ctx -> fallback = fallback ;
6568
6669 return 0 ;
@@ -71,7 +74,7 @@ static void p8_aes_cbc_exit(struct crypto_tfm *tfm)
7174 struct p8_aes_cbc_ctx * ctx = crypto_tfm_ctx (tfm );
7275
7376 if (ctx -> fallback ) {
74- crypto_free_blkcipher (ctx -> fallback );
77+ crypto_free_skcipher (ctx -> fallback );
7578 ctx -> fallback = NULL ;
7679 }
7780}
@@ -91,7 +94,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
9194 pagefault_enable ();
9295 preempt_enable ();
9396
94- ret += crypto_blkcipher_setkey (ctx -> fallback , key , keylen );
97+ ret += crypto_skcipher_setkey (ctx -> fallback , key , keylen );
9598 return ret ;
9699}
97100
@@ -103,15 +106,14 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
103106 struct blkcipher_walk walk ;
104107 struct p8_aes_cbc_ctx * ctx =
105108 crypto_tfm_ctx (crypto_blkcipher_tfm (desc -> tfm ));
106- struct blkcipher_desc fallback_desc = {
107- .tfm = ctx -> fallback ,
108- .info = desc -> info ,
109- .flags = desc -> flags
110- };
111109
112110 if (in_interrupt ()) {
113- ret = crypto_blkcipher_encrypt (& fallback_desc , dst , src ,
114- nbytes );
111+ SKCIPHER_REQUEST_ON_STACK (req , ctx -> fallback );
112+ skcipher_request_set_tfm (req , ctx -> fallback );
113+ skcipher_request_set_callback (req , desc -> flags , NULL , NULL );
114+ skcipher_request_set_crypt (req , src , dst , nbytes , desc -> info );
115+ ret = crypto_skcipher_encrypt (req );
116+ skcipher_request_zero (req );
115117 } else {
116118 preempt_disable ();
117119 pagefault_disable ();
@@ -144,15 +146,14 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
144146 struct blkcipher_walk walk ;
145147 struct p8_aes_cbc_ctx * ctx =
146148 crypto_tfm_ctx (crypto_blkcipher_tfm (desc -> tfm ));
147- struct blkcipher_desc fallback_desc = {
148- .tfm = ctx -> fallback ,
149- .info = desc -> info ,
150- .flags = desc -> flags
151- };
152149
153150 if (in_interrupt ()) {
154- ret = crypto_blkcipher_decrypt (& fallback_desc , dst , src ,
155- nbytes );
151+ SKCIPHER_REQUEST_ON_STACK (req , ctx -> fallback );
152+ skcipher_request_set_tfm (req , ctx -> fallback );
153+ skcipher_request_set_callback (req , desc -> flags , NULL , NULL );
154+ skcipher_request_set_crypt (req , src , dst , nbytes , desc -> info );
155+ ret = crypto_skcipher_decrypt (req );
156+ skcipher_request_zero (req );
156157 } else {
157158 preempt_disable ();
158159 pagefault_disable ();
0 commit comments