Skip to content

Commit fce8b8d

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: remove obsolete 'comp' compression API
The 'comp' compression API has been superseded by the acomp API, which is a bit more cumbersome to use, but ultimately more flexible when it comes to hardware implementations. Now that all the users and implementations have been removed, let's remove the core plumbing of the 'comp' API as well. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent be457e4 commit fce8b8d

File tree

8 files changed

+15
-272
lines changed

8 files changed

+15
-272
lines changed

Documentation/crypto/architecture.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ the aforementioned cipher types:
196196

197197
- CRYPTO_ALG_TYPE_CIPHER Single block cipher
198198

199-
- CRYPTO_ALG_TYPE_COMPRESS Compression
200-
201199
- CRYPTO_ALG_TYPE_AEAD Authenticated Encryption with Associated Data
202200
(MAC)
203201

crypto/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
obj-$(CONFIG_CRYPTO) += crypto.o
7-
crypto-y := api.o cipher.o compress.o
7+
crypto-y := api.o cipher.o
88

99
obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o
1010
obj-$(CONFIG_CRYPTO_FIPS) += fips.o

crypto/api.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,6 @@ static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask)
383383
case CRYPTO_ALG_TYPE_CIPHER:
384384
len += crypto_cipher_ctxsize(alg);
385385
break;
386-
387-
case CRYPTO_ALG_TYPE_COMPRESS:
388-
len += crypto_compress_ctxsize(alg);
389-
break;
390386
}
391387

392388
return len;

crypto/compress.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

crypto/crypto_user.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
8484
sizeof(rcipher), &rcipher);
8585
}
8686

87-
static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
88-
{
89-
struct crypto_report_comp rcomp;
90-
91-
memset(&rcomp, 0, sizeof(rcomp));
92-
93-
strscpy(rcomp.type, "compression", sizeof(rcomp.type));
94-
95-
return nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, sizeof(rcomp), &rcomp);
96-
}
97-
9887
static int crypto_report_one(struct crypto_alg *alg,
9988
struct crypto_user_alg *ualg, struct sk_buff *skb)
10089
{
@@ -135,11 +124,6 @@ static int crypto_report_one(struct crypto_alg *alg,
135124
if (crypto_report_cipher(skb, alg))
136125
goto nla_put_failure;
137126

138-
break;
139-
case CRYPTO_ALG_TYPE_COMPRESS:
140-
if (crypto_report_comp(skb, alg))
141-
goto nla_put_failure;
142-
143127
break;
144128
}
145129

crypto/proc.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ static int c_show(struct seq_file *m, void *p)
7272
seq_printf(m, "max keysize : %u\n",
7373
alg->cra_cipher.cia_max_keysize);
7474
break;
75-
case CRYPTO_ALG_TYPE_COMPRESS:
76-
seq_printf(m, "type : compression\n");
77-
break;
7875
default:
7976
seq_printf(m, "type : unknown\n");
8077
break;

crypto/testmgr.c

Lines changed: 13 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,112 +3320,6 @@ static int alg_test_skcipher(const struct alg_test_desc *desc,
33203320
return err;
33213321
}
33223322

3323-
static int test_comp(struct crypto_comp *tfm,
3324-
const struct comp_testvec *ctemplate,
3325-
const struct comp_testvec *dtemplate,
3326-
int ctcount, int dtcount)
3327-
{
3328-
const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm));
3329-
char *output, *decomp_output;
3330-
unsigned int i;
3331-
int ret;
3332-
3333-
output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
3334-
if (!output)
3335-
return -ENOMEM;
3336-
3337-
decomp_output = kmalloc(COMP_BUF_SIZE, GFP_KERNEL);
3338-
if (!decomp_output) {
3339-
kfree(output);
3340-
return -ENOMEM;
3341-
}
3342-
3343-
for (i = 0; i < ctcount; i++) {
3344-
int ilen;
3345-
unsigned int dlen = COMP_BUF_SIZE;
3346-
3347-
memset(output, 0, COMP_BUF_SIZE);
3348-
memset(decomp_output, 0, COMP_BUF_SIZE);
3349-
3350-
ilen = ctemplate[i].inlen;
3351-
ret = crypto_comp_compress(tfm, ctemplate[i].input,
3352-
ilen, output, &dlen);
3353-
if (ret) {
3354-
printk(KERN_ERR "alg: comp: compression failed "
3355-
"on test %d for %s: ret=%d\n", i + 1, algo,
3356-
-ret);
3357-
goto out;
3358-
}
3359-
3360-
ilen = dlen;
3361-
dlen = COMP_BUF_SIZE;
3362-
ret = crypto_comp_decompress(tfm, output,
3363-
ilen, decomp_output, &dlen);
3364-
if (ret) {
3365-
pr_err("alg: comp: compression failed: decompress: on test %d for %s failed: ret=%d\n",
3366-
i + 1, algo, -ret);
3367-
goto out;
3368-
}
3369-
3370-
if (dlen != ctemplate[i].inlen) {
3371-
printk(KERN_ERR "alg: comp: Compression test %d "
3372-
"failed for %s: output len = %d\n", i + 1, algo,
3373-
dlen);
3374-
ret = -EINVAL;
3375-
goto out;
3376-
}
3377-
3378-
if (memcmp(decomp_output, ctemplate[i].input,
3379-
ctemplate[i].inlen)) {
3380-
pr_err("alg: comp: compression failed: output differs: on test %d for %s\n",
3381-
i + 1, algo);
3382-
hexdump(decomp_output, dlen);
3383-
ret = -EINVAL;
3384-
goto out;
3385-
}
3386-
}
3387-
3388-
for (i = 0; i < dtcount; i++) {
3389-
int ilen;
3390-
unsigned int dlen = COMP_BUF_SIZE;
3391-
3392-
memset(decomp_output, 0, COMP_BUF_SIZE);
3393-
3394-
ilen = dtemplate[i].inlen;
3395-
ret = crypto_comp_decompress(tfm, dtemplate[i].input,
3396-
ilen, decomp_output, &dlen);
3397-
if (ret) {
3398-
printk(KERN_ERR "alg: comp: decompression failed "
3399-
"on test %d for %s: ret=%d\n", i + 1, algo,
3400-
-ret);
3401-
goto out;
3402-
}
3403-
3404-
if (dlen != dtemplate[i].outlen) {
3405-
printk(KERN_ERR "alg: comp: Decompression test %d "
3406-
"failed for %s: output len = %d\n", i + 1, algo,
3407-
dlen);
3408-
ret = -EINVAL;
3409-
goto out;
3410-
}
3411-
3412-
if (memcmp(decomp_output, dtemplate[i].output, dlen)) {
3413-
printk(KERN_ERR "alg: comp: Decompression test %d "
3414-
"failed for %s\n", i + 1, algo);
3415-
hexdump(decomp_output, dlen);
3416-
ret = -EINVAL;
3417-
goto out;
3418-
}
3419-
}
3420-
3421-
ret = 0;
3422-
3423-
out:
3424-
kfree(decomp_output);
3425-
kfree(output);
3426-
return ret;
3427-
}
3428-
34293323
static int test_acomp(struct crypto_acomp *tfm,
34303324
const struct comp_testvec *ctemplate,
34313325
const struct comp_testvec *dtemplate,
@@ -3684,42 +3578,22 @@ static int alg_test_cipher(const struct alg_test_desc *desc,
36843578
static int alg_test_comp(const struct alg_test_desc *desc, const char *driver,
36853579
u32 type, u32 mask)
36863580
{
3687-
struct crypto_comp *comp;
36883581
struct crypto_acomp *acomp;
36893582
int err;
3690-
u32 algo_type = type & CRYPTO_ALG_TYPE_ACOMPRESS_MASK;
36913583

3692-
if (algo_type == CRYPTO_ALG_TYPE_ACOMPRESS) {
3693-
acomp = crypto_alloc_acomp(driver, type, mask);
3694-
if (IS_ERR(acomp)) {
3695-
if (PTR_ERR(acomp) == -ENOENT)
3696-
return 0;
3697-
pr_err("alg: acomp: Failed to load transform for %s: %ld\n",
3698-
driver, PTR_ERR(acomp));
3699-
return PTR_ERR(acomp);
3700-
}
3701-
err = test_acomp(acomp, desc->suite.comp.comp.vecs,
3702-
desc->suite.comp.decomp.vecs,
3703-
desc->suite.comp.comp.count,
3704-
desc->suite.comp.decomp.count);
3705-
crypto_free_acomp(acomp);
3706-
} else {
3707-
comp = crypto_alloc_comp(driver, type, mask);
3708-
if (IS_ERR(comp)) {
3709-
if (PTR_ERR(comp) == -ENOENT)
3710-
return 0;
3711-
pr_err("alg: comp: Failed to load transform for %s: %ld\n",
3712-
driver, PTR_ERR(comp));
3713-
return PTR_ERR(comp);
3714-
}
3715-
3716-
err = test_comp(comp, desc->suite.comp.comp.vecs,
3717-
desc->suite.comp.decomp.vecs,
3718-
desc->suite.comp.comp.count,
3719-
desc->suite.comp.decomp.count);
3720-
3721-
crypto_free_comp(comp);
3722-
}
3584+
acomp = crypto_alloc_acomp(driver, type, mask);
3585+
if (IS_ERR(acomp)) {
3586+
if (PTR_ERR(acomp) == -ENOENT)
3587+
return 0;
3588+
pr_err("alg: acomp: Failed to load transform for %s: %ld\n",
3589+
driver, PTR_ERR(acomp));
3590+
return PTR_ERR(acomp);
3591+
}
3592+
err = test_acomp(acomp, desc->suite.comp.comp.vecs,
3593+
desc->suite.comp.decomp.vecs,
3594+
desc->suite.comp.comp.count,
3595+
desc->suite.comp.decomp.count);
3596+
crypto_free_acomp(acomp);
37233597
return err;
37243598
}
37253599

include/linux/crypto.h

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
#define CRYPTO_ALG_TYPE_MASK 0x0000000f
2626
#define CRYPTO_ALG_TYPE_CIPHER 0x00000001
27-
#define CRYPTO_ALG_TYPE_COMPRESS 0x00000002
2827
#define CRYPTO_ALG_TYPE_AEAD 0x00000003
2928
#define CRYPTO_ALG_TYPE_LSKCIPHER 0x00000004
3029
#define CRYPTO_ALG_TYPE_SKCIPHER 0x00000005
@@ -246,26 +245,7 @@ struct cipher_alg {
246245
void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
247246
};
248247

249-
/**
250-
* struct compress_alg - compression/decompression algorithm
251-
* @coa_compress: Compress a buffer of specified length, storing the resulting
252-
* data in the specified buffer. Return the length of the
253-
* compressed data in dlen.
254-
* @coa_decompress: Decompress the source buffer, storing the uncompressed
255-
* data in the specified buffer. The length of the data is
256-
* returned in dlen.
257-
*
258-
* All fields are mandatory.
259-
*/
260-
struct compress_alg {
261-
int (*coa_compress)(struct crypto_tfm *tfm, const u8 *src,
262-
unsigned int slen, u8 *dst, unsigned int *dlen);
263-
int (*coa_decompress)(struct crypto_tfm *tfm, const u8 *src,
264-
unsigned int slen, u8 *dst, unsigned int *dlen);
265-
};
266-
267248
#define cra_cipher cra_u.cipher
268-
#define cra_compress cra_u.compress
269249

270250
/**
271251
* struct crypto_alg - definition of a cryptograpic cipher algorithm
@@ -316,7 +296,7 @@ struct compress_alg {
316296
* transformation types. There are multiple options, such as
317297
* &crypto_skcipher_type, &crypto_ahash_type, &crypto_rng_type.
318298
* This field might be empty. In that case, there are no common
319-
* callbacks. This is the case for: cipher, compress, shash.
299+
* callbacks. This is the case for: cipher.
320300
* @cra_u: Callbacks implementing the transformation. This is a union of
321301
* multiple structures. Depending on the type of transformation selected
322302
* by @cra_type and @cra_flags above, the associated structure must be
@@ -335,8 +315,6 @@ struct compress_alg {
335315
* @cra_init.
336316
* @cra_u.cipher: Union member which contains a single-block symmetric cipher
337317
* definition. See @struct @cipher_alg.
338-
* @cra_u.compress: Union member which contains a (de)compression algorithm.
339-
* See @struct @compress_alg.
340318
* @cra_module: Owner of this transformation implementation. Set to THIS_MODULE
341319
* @cra_list: internally used
342320
* @cra_users: internally used
@@ -366,7 +344,6 @@ struct crypto_alg {
366344

367345
union {
368346
struct cipher_alg cipher;
369-
struct compress_alg compress;
370347
} cra_u;
371348

372349
int (*cra_init)(struct crypto_tfm *tfm);
@@ -440,10 +417,6 @@ struct crypto_tfm {
440417
void *__crt_ctx[] CRYPTO_MINALIGN_ATTR;
441418
};
442419

443-
struct crypto_comp {
444-
struct crypto_tfm base;
445-
};
446-
447420
/*
448421
* Transform user interface.
449422
*/
@@ -500,53 +473,6 @@ static inline unsigned int crypto_tfm_ctx_alignment(void)
500473
return __alignof__(tfm->__crt_ctx);
501474
}
502475

503-
static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
504-
{
505-
return (struct crypto_comp *)tfm;
506-
}
507-
508-
static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
509-
u32 type, u32 mask)
510-
{
511-
type &= ~CRYPTO_ALG_TYPE_MASK;
512-
type |= CRYPTO_ALG_TYPE_COMPRESS;
513-
mask |= CRYPTO_ALG_TYPE_MASK;
514-
515-
return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask));
516-
}
517-
518-
static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm)
519-
{
520-
return &tfm->base;
521-
}
522-
523-
static inline void crypto_free_comp(struct crypto_comp *tfm)
524-
{
525-
crypto_free_tfm(crypto_comp_tfm(tfm));
526-
}
527-
528-
static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask)
529-
{
530-
type &= ~CRYPTO_ALG_TYPE_MASK;
531-
type |= CRYPTO_ALG_TYPE_COMPRESS;
532-
mask |= CRYPTO_ALG_TYPE_MASK;
533-
534-
return crypto_has_alg(alg_name, type, mask);
535-
}
536-
537-
static inline const char *crypto_comp_name(struct crypto_comp *tfm)
538-
{
539-
return crypto_tfm_alg_name(crypto_comp_tfm(tfm));
540-
}
541-
542-
int crypto_comp_compress(struct crypto_comp *tfm,
543-
const u8 *src, unsigned int slen,
544-
u8 *dst, unsigned int *dlen);
545-
546-
int crypto_comp_decompress(struct crypto_comp *tfm,
547-
const u8 *src, unsigned int slen,
548-
u8 *dst, unsigned int *dlen);
549-
550476
static inline void crypto_reqchain_init(struct crypto_async_request *req)
551477
{
552478
req->err = -EINPROGRESS;

0 commit comments

Comments
 (0)