22
22
#include <linux/cryptouser.h>
23
23
#include <net/netlink.h>
24
24
#include <crypto/internal/acompress.h>
25
+ #include <crypto/internal/scompress.h>
25
26
#include "internal.h"
26
27
28
+ static const struct crypto_type crypto_acomp_type ;
29
+
27
30
#ifdef CONFIG_NET
28
31
static int crypto_acomp_report (struct sk_buff * skb , struct crypto_alg * alg )
29
32
{
@@ -67,6 +70,14 @@ static int crypto_acomp_init_tfm(struct crypto_tfm *tfm)
67
70
struct crypto_acomp * acomp = __crypto_acomp_tfm (tfm );
68
71
struct acomp_alg * alg = crypto_acomp_alg (acomp );
69
72
73
+ if (tfm -> __crt_alg -> cra_type != & crypto_acomp_type )
74
+ return crypto_init_scomp_ops_async (tfm );
75
+
76
+ acomp -> compress = alg -> compress ;
77
+ acomp -> decompress = alg -> decompress ;
78
+ acomp -> dst_free = alg -> dst_free ;
79
+ acomp -> reqsize = alg -> reqsize ;
80
+
70
81
if (alg -> exit )
71
82
acomp -> base .exit = crypto_acomp_exit_tfm ;
72
83
@@ -76,15 +87,25 @@ static int crypto_acomp_init_tfm(struct crypto_tfm *tfm)
76
87
return 0 ;
77
88
}
78
89
90
+ static unsigned int crypto_acomp_extsize (struct crypto_alg * alg )
91
+ {
92
+ int extsize = crypto_alg_extsize (alg );
93
+
94
+ if (alg -> cra_type != & crypto_acomp_type )
95
+ extsize += sizeof (struct crypto_scomp * );
96
+
97
+ return extsize ;
98
+ }
99
+
79
100
static const struct crypto_type crypto_acomp_type = {
80
- .extsize = crypto_alg_extsize ,
101
+ .extsize = crypto_acomp_extsize ,
81
102
.init_tfm = crypto_acomp_init_tfm ,
82
103
#ifdef CONFIG_PROC_FS
83
104
.show = crypto_acomp_show ,
84
105
#endif
85
106
.report = crypto_acomp_report ,
86
107
.maskclear = ~CRYPTO_ALG_TYPE_MASK ,
87
- .maskset = CRYPTO_ALG_TYPE_MASK ,
108
+ .maskset = CRYPTO_ALG_TYPE_ACOMPRESS_MASK ,
88
109
.type = CRYPTO_ALG_TYPE_ACOMPRESS ,
89
110
.tfmsize = offsetof(struct crypto_acomp , base ),
90
111
};
@@ -96,6 +117,36 @@ struct crypto_acomp *crypto_alloc_acomp(const char *alg_name, u32 type,
96
117
}
97
118
EXPORT_SYMBOL_GPL (crypto_alloc_acomp );
98
119
120
+ struct acomp_req * acomp_request_alloc (struct crypto_acomp * acomp )
121
+ {
122
+ struct crypto_tfm * tfm = crypto_acomp_tfm (acomp );
123
+ struct acomp_req * req ;
124
+
125
+ req = __acomp_request_alloc (acomp );
126
+ if (req && (tfm -> __crt_alg -> cra_type != & crypto_acomp_type ))
127
+ return crypto_acomp_scomp_alloc_ctx (req );
128
+
129
+ return req ;
130
+ }
131
+ EXPORT_SYMBOL_GPL (acomp_request_alloc );
132
+
133
+ void acomp_request_free (struct acomp_req * req )
134
+ {
135
+ struct crypto_acomp * acomp = crypto_acomp_reqtfm (req );
136
+ struct crypto_tfm * tfm = crypto_acomp_tfm (acomp );
137
+
138
+ if (tfm -> __crt_alg -> cra_type != & crypto_acomp_type )
139
+ crypto_acomp_scomp_free_ctx (req );
140
+
141
+ if (req -> flags & CRYPTO_ACOMP_ALLOC_OUTPUT ) {
142
+ acomp -> dst_free (req -> dst );
143
+ req -> dst = NULL ;
144
+ }
145
+
146
+ __acomp_request_free (req );
147
+ }
148
+ EXPORT_SYMBOL_GPL (acomp_request_free );
149
+
99
150
int crypto_register_acomp (struct acomp_alg * alg )
100
151
{
101
152
struct crypto_alg * base = & alg -> base ;
0 commit comments