]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
crypto: FIPS - allow tests to be disabled in FIPS mode
authorStephan Mueller <smueller@chronox.de>
Thu, 25 Aug 2016 13:15:01 +0000 (15:15 +0200)
committerJack Vogel <jack.vogel@oracle.com>
Thu, 5 Apr 2018 20:11:43 +0000 (13:11 -0700)
In FIPS mode, additional restrictions may apply. If these restrictions
are violated, the kernel will panic(). This patch allows test vectors
for symmetric ciphers to be marked as to be skipped in FIPS mode.

Together with the patch, the XTS test vectors where the AES key is
identical to the tweak key is disabled in FIPS mode. This test vector
violates the FIPS requirement that both keys must be different.

Reported-by: Tapas Sarangi <TSarangi@trustwave.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 10faa8c0d6c3b22466f97713a9533824a2ea1c57)

Orabug: 27809271

Signed-off-by: John Haxby <john.haxby@oracle.com>
Reviewed-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
Conflicts:
crypto/testmgr.h

crypto/testmgr.c
crypto/testmgr.h

index af65aecd2c925276dac7b7bc9fe3132907d1b724..5284cbb7c502461e7300a9c4324400db5c450596 100644 (file)
@@ -854,6 +854,9 @@ static int test_cipher(struct crypto_cipher *tfm, int enc,
                if (template[i].np)
                        continue;
 
+               if (fips_enabled && template[i].fips_skip)
+                       continue;
+
                j++;
 
                ret = -EINVAL;
@@ -958,6 +961,9 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
                if (template[i].np && !template[i].also_non_np)
                        continue;
 
+               if (fips_enabled && template[i].fips_skip)
+                       continue;
+
                if (template[i].iv)
                        memcpy(iv, template[i].iv, ivsize);
                else
@@ -1033,6 +1039,9 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
                if (!template[i].np)
                        continue;
 
+               if (fips_enabled && template[i].fips_skip)
+                       continue;
+
                if (template[i].iv)
                        memcpy(iv, template[i].iv, ivsize);
                else
index 4ae2de50a9e18086920c9bcedc0b245cbab6cc28..af35d98c9bd1c93df6285bfed0f3c671bc721350 100644 (file)
@@ -46,6 +46,25 @@ struct hash_testvec {
        unsigned char ksize;
 };
 
+/*
+ * cipher_testvec:     structure to describe a cipher test
+ * @key:       A pointer to a key used by the test
+ * @klen:      The length of @key
+ * @iv:                A pointer to the IV used by the test
+ * @input:     A pointer to data used as input
+ * @ilen       The length of data in @input
+ * @result:    A pointer to what the test need to produce
+ * @rlen:      The length of data in @result
+ * @fail:      If set to one, the test need to fail
+ * @wk:                Does the test need CRYPTO_TFM_REQ_WEAK_KEY
+ *             ( e.g. test needs to fail due to a weak key )
+ * @np:        numbers of SG to distribute data in (from 1 to MAX_TAP)
+ * @tap:       How to distribute data in @np SGs
+ * @also_non_np:       if set to 1, the test will be also done without
+ *                     splitting data in @np SGs
+ * @fips_skip: Skip the test vector in FIPS mode
+ */
+
 struct cipher_testvec {
        char *key;
        char *iv;
@@ -59,6 +78,7 @@ struct cipher_testvec {
        unsigned char klen;
        unsigned short ilen;
        unsigned short rlen;
+       bool fips_skip;
 };
 
 struct aead_testvec {
@@ -16588,6 +16608,7 @@ static struct cipher_testvec aes_xts_enc_tv_template[] = {
                          "\x00\x00\x00\x00\x00\x00\x00\x00"
                          "\x00\x00\x00\x00\x00\x00\x00\x00",
                .klen   = 32,
+               .fips_skip = 1,
                .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
                          "\x00\x00\x00\x00\x00\x00\x00\x00",
                .input  = "\x00\x00\x00\x00\x00\x00\x00\x00"
@@ -16930,6 +16951,7 @@ static struct cipher_testvec aes_xts_dec_tv_template[] = {
                          "\x00\x00\x00\x00\x00\x00\x00\x00"
                          "\x00\x00\x00\x00\x00\x00\x00\x00",
                .klen   = 32,
+               .fips_skip = 1,
                .iv     = "\x00\x00\x00\x00\x00\x00\x00\x00"
                          "\x00\x00\x00\x00\x00\x00\x00\x00",
                .input = "\x91\x7c\xf6\x9e\xbd\x68\xb2\xec"