1. 25 3月, 2020 1 次提交
  2. 09 1月, 2020 1 次提交
    • E
      crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN · 674f368a
      Eric Biggers 提交于
      The CRYPTO_TFM_RES_BAD_KEY_LEN flag was apparently meant as a way to
      make the ->setkey() functions provide more information about errors.
      
      However, no one actually checks for this flag, which makes it pointless.
      
      Also, many algorithms fail to set this flag when given a bad length key.
      Reviewing just the generic implementations, this is the case for
      aes-fixed-time, cbcmac, echainiv, nhpoly1305, pcrypt, rfc3686, rfc4309,
      rfc7539, rfc7539esp, salsa20, seqiv, and xcbc.  But there are probably
      many more in arch/*/crypto/ and drivers/crypto/.
      
      Some algorithms can even set this flag when the key is the correct
      length.  For example, authenc and authencesn set it when the key payload
      is malformed in any way (not just a bad length), the atmel-sha and ccree
      drivers can set it if a memory allocation fails, and the chelsio driver
      sets it for bad auth tag lengths, not just bad key lengths.
      
      So even if someone actually wanted to start checking this flag (which
      seems unlikely, since it's been unused for a long time), there would be
      a lot of work needed to get it working correctly.  But it would probably
      be much better to go back to the drawing board and just define different
      return values, like -EINVAL if the key is invalid for the algorithm vs.
      -EKEYREJECTED if the key was rejected by a policy like "no weak keys".
      That would be much simpler, less error-prone, and easier to test.
      
      So just remove this flag.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      674f368a
  3. 11 12月, 2019 1 次提交
  4. 09 9月, 2019 1 次提交
  5. 22 8月, 2019 1 次提交
  6. 26 7月, 2019 2 次提交
  7. 13 6月, 2019 1 次提交
  8. 31 5月, 2019 1 次提交
  9. 22 3月, 2019 3 次提交
  10. 08 2月, 2019 1 次提交
    • E
      crypto: x86/aesni-gcm - fix crash on empty plaintext · 3af34963
      Eric Biggers 提交于
      gcmaes_crypt_by_sg() dereferences the NULL pointer returned by
      scatterwalk_ffwd() when encrypting an empty plaintext and the source
      scatterlist ends immediately after the associated data.
      
      Fix it by only fast-forwarding to the src/dst data scatterlists if the
      data length is nonzero.
      
      This bug is reproduced by the "rfc4543(gcm(aes))" test vectors when run
      with the new AEAD test manager.
      
      Fixes: e8455207 ("crypto: aesni - Update aesni-intel_glue to use scatter/gather")
      Cc: <stable@vger.kernel.org> # v4.17+
      Cc: Dave Watson <davejwatson@fb.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      3af34963
  11. 18 1月, 2019 1 次提交
    • E
      crypto: x86/aesni-gcm - make 'struct aesni_gcm_tfm_s' static const · 793ff5ff
      Eric Biggers 提交于
      Add missing static keywords to fix the following sparse warnings:
      
          arch/x86/crypto/aesni-intel_glue.c:197:24: warning: symbol 'aesni_gcm_tfm_sse' was not declared. Should it be static?
          arch/x86/crypto/aesni-intel_glue.c:246:24: warning: symbol 'aesni_gcm_tfm_avx_gen2' was not declared. Should it be static?
          arch/x86/crypto/aesni-intel_glue.c:291:24: warning: symbol 'aesni_gcm_tfm_avx_gen4' was not declared. Should it be static?
      
      I also made the affected structures 'const', and adjusted the
      indentation in the struct definition to not be insane.
      
      Cc: Dave Watson <davejwatson@fb.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      793ff5ff
  12. 23 12月, 2018 4 次提交
  13. 08 10月, 2018 1 次提交
  14. 05 10月, 2018 1 次提交
  15. 14 9月, 2018 1 次提交
  16. 22 2月, 2018 3 次提交
  17. 25 1月, 2018 1 次提交
    • S
      crypto: aesni - handle zero length dst buffer · 9c674e1e
      Stephan Mueller 提交于
      GCM can be invoked with a zero destination buffer. This is possible if
      the AAD and the ciphertext have zero lengths and only the tag exists in
      the source buffer (i.e. a source buffer cannot be zero). In this case,
      the GCM cipher only performs the authentication and no decryption
      operation.
      
      When the destination buffer has zero length, it is possible that no page
      is mapped to the SG pointing to the destination. In this case,
      sg_page(req->dst) is an invalid access. Therefore, page accesses should
      only be allowed if the req->dst->length is non-zero which is the
      indicator that a page must exist.
      
      This fixes a crash that can be triggered by user space via AF_ALG.
      
      CC: <stable@vger.kernel.org>
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      9c674e1e
  18. 22 12月, 2017 2 次提交
  19. 22 9月, 2017 2 次提交
  20. 04 8月, 2017 1 次提交
    • A
      crypto: algapi - make crypto_xor() take separate dst and src arguments · 45fe93df
      Ard Biesheuvel 提交于
      There are quite a number of occurrences in the kernel of the pattern
      
        if (dst != src)
                memcpy(dst, src, walk.total % AES_BLOCK_SIZE);
        crypto_xor(dst, final, walk.total % AES_BLOCK_SIZE);
      
      or
      
        crypto_xor(keystream, src, nbytes);
        memcpy(dst, keystream, nbytes);
      
      where crypto_xor() is preceded or followed by a memcpy() invocation
      that is only there because crypto_xor() uses its output parameter as
      one of the inputs. To avoid having to add new instances of this pattern
      in the arm64 code, which will be refactored to implement non-SIMD
      fallbacks, add an alternative implementation called crypto_xor_cpy(),
      taking separate input and output arguments. This removes the need for
      the separate memcpy().
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      45fe93df
  21. 18 5月, 2017 1 次提交
  22. 03 2月, 2017 1 次提交
  23. 30 12月, 2016 1 次提交
  24. 27 12月, 2016 1 次提交
  25. 28 11月, 2016 1 次提交
  26. 12 11月, 2016 1 次提交
    • A
      crypto: aesni: shut up -Wmaybe-uninitialized warning · beae2c9e
      Arnd Bergmann 提交于
      The rfc4106 encrypy/decrypt helper functions cause an annoying
      false-positive warning in allmodconfig if we turn on
      -Wmaybe-uninitialized warnings again:
      
        arch/x86/crypto/aesni-intel_glue.c: In function ‘helper_rfc4106_decrypt’:
        include/linux/scatterlist.h:67:31: warning: ‘dst_sg_walk.sg’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      
      The problem seems to be that the compiler doesn't track the state of the
      'one_entry_in_sg' variable across the kernel_fpu_begin/kernel_fpu_end
      section.
      
      This takes the easy way out by adding a bogus initialization, which
      should be harmless enough to get the patch into v4.9 so we can turn on
      this warning again by default without producing useless output.  A
      follow-up patch for v4.10 rearranges the code to make the warning go
      away.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      beae2c9e
  27. 01 7月, 2016 1 次提交
    • H
      crypto: aesni - Use crypto_cipher to derive rfc4106 subkey · 02fa472a
      Herbert Xu 提交于
      Currently aesni uses an async ctr(aes) to derive the rfc4106
      subkey, which was presumably copied over from the generic rfc4106
      code.  Over there it's done that way because we already have a
      ctr(aes) spawn.  But it is simply overkill for aesni since we
      have to go get a ctr(aes) from scratch anyway.
      
      This patch simplifies the subkey derivation by using a straight
      aes cipher instead.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      02fa472a
  28. 23 6月, 2016 1 次提交
  29. 13 4月, 2016 1 次提交
  30. 17 2月, 2016 1 次提交
    • S
      crypto: xts - consolidate sanity check for keys · 28856a9e
      Stephan Mueller 提交于
      The patch centralizes the XTS key check logic into the service function
      xts_check_key which is invoked from the different XTS implementations.
      With this, the XTS implementations in ARM, ARM64, PPC and S390 have now
      a sanity check for the XTS keys similar to the other arches.
      
      In addition, this service function received a check to ensure that the
      key != the tweak key which is mandated by FIPS 140-2 IG A.9. As the
      check is not present in the standards defining XTS, it is only enforced
      in FIPS mode of the kernel.
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      28856a9e