27
27
#include <asm/switch_to.h>
28
28
#include <crypto/aes.h>
29
29
#include <crypto/scatterwalk.h>
30
+ #include <crypto/skcipher.h>
30
31
31
32
#include "aesp8-ppc.h"
32
33
33
34
struct p8_aes_cbc_ctx {
34
- struct crypto_blkcipher * fallback ;
35
+ struct crypto_skcipher * fallback ;
35
36
struct aes_key enc_key ;
36
37
struct aes_key dec_key ;
37
38
};
38
39
39
40
static int p8_aes_cbc_init (struct crypto_tfm * tfm )
40
41
{
41
42
const char * alg ;
42
- struct crypto_blkcipher * fallback ;
43
+ struct crypto_skcipher * fallback ;
43
44
struct p8_aes_cbc_ctx * ctx = crypto_tfm_ctx (tfm );
44
45
45
46
if (!(alg = crypto_tfm_alg_name (tfm ))) {
46
47
printk (KERN_ERR "Failed to get algorithm name.\n" );
47
48
return - ENOENT ;
48
49
}
49
50
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
+
52
54
if (IS_ERR (fallback )) {
53
55
printk (KERN_ERR
54
56
"Failed to allocate transformation for '%s': %ld\n" ,
55
57
alg , PTR_ERR (fallback ));
56
58
return PTR_ERR (fallback );
57
59
}
58
60
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
+
60
63
61
- crypto_blkcipher_set_flags (
64
+ crypto_skcipher_set_flags (
62
65
fallback ,
63
- crypto_blkcipher_get_flags ((struct crypto_blkcipher * )tfm ));
66
+ crypto_skcipher_get_flags ((struct crypto_skcipher * )tfm ));
64
67
ctx -> fallback = fallback ;
65
68
66
69
return 0 ;
@@ -71,7 +74,7 @@ static void p8_aes_cbc_exit(struct crypto_tfm *tfm)
71
74
struct p8_aes_cbc_ctx * ctx = crypto_tfm_ctx (tfm );
72
75
73
76
if (ctx -> fallback ) {
74
- crypto_free_blkcipher (ctx -> fallback );
77
+ crypto_free_skcipher (ctx -> fallback );
75
78
ctx -> fallback = NULL ;
76
79
}
77
80
}
@@ -91,7 +94,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key,
91
94
pagefault_enable ();
92
95
preempt_enable ();
93
96
94
- ret += crypto_blkcipher_setkey (ctx -> fallback , key , keylen );
97
+ ret += crypto_skcipher_setkey (ctx -> fallback , key , keylen );
95
98
return ret ;
96
99
}
97
100
@@ -103,15 +106,14 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc,
103
106
struct blkcipher_walk walk ;
104
107
struct p8_aes_cbc_ctx * ctx =
105
108
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
- };
111
109
112
110
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 );
115
117
} else {
116
118
preempt_disable ();
117
119
pagefault_disable ();
@@ -144,15 +146,14 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc,
144
146
struct blkcipher_walk walk ;
145
147
struct p8_aes_cbc_ctx * ctx =
146
148
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
- };
152
149
153
150
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 );
156
157
} else {
157
158
preempt_disable ();
158
159
pagefault_disable ();
0 commit comments