Skip to content

Commit 35de409

Browse files
committed
Revert "crypto: testmgr - Add hash export format testing"
This reverts commit 18c438b. The s390 hmac and sha3 algorithms are failing the test. Revert the change until they have been fixed. Reported-by: Ingo Franzki <ifranzki@linux.ibm.com> Link: https://lore.kernel.org/all/623a7fcb-b4cb-48e6-9833-57ad2b32a252@linux.ibm.com/ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 0413bcf commit 35de409

File tree

3 files changed

+9
-94
lines changed

3 files changed

+9
-94
lines changed

crypto/testmgr.c

Lines changed: 9 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,25 @@
1717
*/
1818

1919
#include <crypto/aead.h>
20-
#include <crypto/acompress.h>
21-
#include <crypto/akcipher.h>
22-
#include <crypto/drbg.h>
23-
#include <crypto/internal/cipher.h>
24-
#include <crypto/internal/hash.h>
25-
#include <crypto/internal/simd.h>
26-
#include <crypto/kpp.h>
27-
#include <crypto/rng.h>
28-
#include <crypto/sig.h>
20+
#include <crypto/hash.h>
2921
#include <crypto/skcipher.h>
3022
#include <linux/err.h>
3123
#include <linux/fips.h>
32-
#include <linux/kernel.h>
3324
#include <linux/module.h>
3425
#include <linux/once.h>
3526
#include <linux/prandom.h>
3627
#include <linux/scatterlist.h>
3728
#include <linux/slab.h>
3829
#include <linux/string.h>
3930
#include <linux/uio.h>
31+
#include <crypto/rng.h>
32+
#include <crypto/drbg.h>
33+
#include <crypto/akcipher.h>
34+
#include <crypto/kpp.h>
35+
#include <crypto/acompress.h>
36+
#include <crypto/sig.h>
37+
#include <crypto/internal/cipher.h>
38+
#include <crypto/internal/simd.h>
4039

4140
#include "internal.h"
4241

@@ -1465,49 +1464,6 @@ static int check_nonfinal_ahash_op(const char *op, int err,
14651464
return 0;
14661465
}
14671466

1468-
static int check_ahash_export(struct ahash_request *req,
1469-
const struct hash_testvec *vec,
1470-
const char *vec_name,
1471-
const struct testvec_config *cfg,
1472-
const char *driver, u8 *hashstate)
1473-
{
1474-
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1475-
const unsigned int digestsize = crypto_ahash_digestsize(tfm);
1476-
HASH_FBREQ_ON_STACK(fbreq, req);
1477-
int err;
1478-
1479-
if (!vec->state)
1480-
return 0;
1481-
1482-
err = crypto_ahash_export(req, hashstate);
1483-
if (err) {
1484-
pr_err("alg: ahash: %s mixed export() failed with err %d on test vector %s, cfg=\"%s\"\n",
1485-
driver, err, vec_name, cfg->name);
1486-
return err;
1487-
}
1488-
err = crypto_ahash_import(req, vec->state);
1489-
if (err) {
1490-
pr_err("alg: ahash: %s mixed import() failed with err %d on test vector %s, cfg=\"%s\"\n",
1491-
driver, err, vec_name, cfg->name);
1492-
return err;
1493-
}
1494-
err = crypto_ahash_import(fbreq, hashstate);
1495-
if (err) {
1496-
pr_err("alg: ahash: %s fallback import() failed with err %d on test vector %s, cfg=\"%s\"\n",
1497-
crypto_ahash_driver_name(crypto_ahash_reqtfm(fbreq)), err, vec_name, cfg->name);
1498-
return err;
1499-
}
1500-
ahash_request_set_crypt(fbreq, NULL, hashstate, 0);
1501-
testmgr_poison(hashstate, digestsize + TESTMGR_POISON_LEN);
1502-
err = crypto_ahash_final(fbreq);
1503-
if (err) {
1504-
pr_err("alg: ahash: %s fallback final() failed with err %d on test vector %s, cfg=\"%s\"\n",
1505-
crypto_ahash_driver_name(crypto_ahash_reqtfm(fbreq)), err, vec_name, cfg->name);
1506-
return err;
1507-
}
1508-
return check_hash_result("ahash export", hashstate, digestsize, vec, vec_name, driver, cfg);
1509-
}
1510-
15111467
/* Test one hash test vector in one configuration, using the ahash API */
15121468
static int test_ahash_vec_cfg(const struct hash_testvec *vec,
15131469
const char *vec_name,
@@ -1653,10 +1609,6 @@ static int test_ahash_vec_cfg(const struct hash_testvec *vec,
16531609
driver, vec_name, cfg);
16541610
if (err)
16551611
return err;
1656-
err = check_ahash_export(req, vec, vec_name, cfg,
1657-
driver, hashstate);
1658-
if (err)
1659-
return err;
16601612
err = do_ahash_op(crypto_ahash_final, req, &wait, cfg->nosimd);
16611613
if (err) {
16621614
pr_err("alg: ahash: %s final() failed with err %d on test vector %s, cfg=\"%s\"\n",
@@ -1780,17 +1732,6 @@ static void generate_random_hash_testvec(struct rnd_state *rng,
17801732
vec->digest_error = crypto_hash_digest(
17811733
crypto_ahash_reqtfm(req), vec->plaintext,
17821734
vec->psize, (u8 *)vec->digest);
1783-
1784-
if (vec->digest_error || !vec->state)
1785-
goto done;
1786-
1787-
ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL, NULL);
1788-
ahash_request_set_virt(req, vec->plaintext, (u8 *)vec->digest,
1789-
vec->psize);
1790-
crypto_ahash_init(req);
1791-
crypto_ahash_update(req);
1792-
crypto_ahash_export(req, (u8 *)vec->state);
1793-
17941735
done:
17951736
snprintf(name, max_namelen, "\"random: psize=%u ksize=%u\"",
17961737
vec->psize, vec->ksize);
@@ -1809,7 +1750,6 @@ static int test_hash_vs_generic_impl(const char *generic_driver,
18091750
{
18101751
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
18111752
const unsigned int digestsize = crypto_ahash_digestsize(tfm);
1812-
const unsigned int statesize = crypto_ahash_statesize(tfm);
18131753
const unsigned int blocksize = crypto_ahash_blocksize(tfm);
18141754
const unsigned int maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN;
18151755
const char *algname = crypto_hash_alg_common(tfm)->base.cra_name;
@@ -1882,22 +1822,6 @@ static int test_hash_vs_generic_impl(const char *generic_driver,
18821822
goto out;
18831823
}
18841824

1885-
if (crypto_hash_no_export_core(tfm) ||
1886-
crypto_hash_no_export_core(generic_tfm))
1887-
;
1888-
else if (statesize != crypto_ahash_statesize(generic_tfm)) {
1889-
pr_err("alg: hash: statesize for %s (%u) doesn't match generic impl (%u)\n",
1890-
driver, statesize,
1891-
crypto_ahash_statesize(generic_tfm));
1892-
err = -EINVAL;
1893-
goto out;
1894-
} else {
1895-
vec.state = kmalloc(statesize, GFP_KERNEL);
1896-
err = -ENOMEM;
1897-
if (!vec.state)
1898-
goto out;
1899-
}
1900-
19011825
/*
19021826
* Now generate test vectors using the generic implementation, and test
19031827
* the other implementation against them.
@@ -1930,7 +1854,6 @@ static int test_hash_vs_generic_impl(const char *generic_driver,
19301854
kfree(vec.key);
19311855
kfree(vec.plaintext);
19321856
kfree(vec.digest);
1933-
kfree(vec.state);
19341857
ahash_request_free(generic_req);
19351858
crypto_free_ahash(generic_tfm);
19361859
return err;

crypto/testmgr.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
* hash_testvec: structure to describe a hash (message digest) test
3030
* @key: Pointer to key (NULL if none)
3131
* @plaintext: Pointer to source data
32-
* @state: Pointer to expected state
3332
* @digest: Pointer to expected digest
3433
* @psize: Length of source data in bytes
3534
* @ksize: Length of @key in bytes (0 if no key)
@@ -40,7 +39,6 @@
4039
struct hash_testvec {
4140
const char *key;
4241
const char *plaintext;
43-
const char *state;
4442
const char *digest;
4543
unsigned int psize;
4644
unsigned short ksize;

include/crypto/internal/hash.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ static inline bool crypto_hash_alg_needs_key(struct hash_alg_common *alg)
9191
!(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY);
9292
}
9393

94-
static inline bool crypto_hash_no_export_core(struct crypto_ahash *tfm)
95-
{
96-
return crypto_hash_alg_common(tfm)->base.cra_flags &
97-
CRYPTO_AHASH_ALG_NO_EXPORT_CORE;
98-
}
99-
10094
int crypto_grab_ahash(struct crypto_ahash_spawn *spawn,
10195
struct crypto_instance *inst,
10296
const char *name, u32 type, u32 mask);

0 commit comments

Comments
 (0)