@@ -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-
34293323static 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,
36843578static 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
0 commit comments