1. 28 5月, 2021 2 次提交
  2. 26 3月, 2021 2 次提交
  3. 12 3月, 2021 1 次提交
  4. 07 3月, 2021 1 次提交
  5. 10 2月, 2021 1 次提交
  6. 29 1月, 2021 5 次提交
  7. 03 1月, 2021 1 次提交
  8. 06 11月, 2020 4 次提交
    • E
      crypto: testmgr - WARN on test failure · 09a5ef96
      Eric Biggers 提交于
      Currently, by default crypto self-test failures only result in a
      pr_warn() message and an "unknown" status in /proc/crypto.  Both of
      these are easy to miss.  There is also an option to panic the kernel
      when a test fails, but that can't be the default behavior.
      
      A crypto self-test failure always indicates a kernel bug, however, and
      there's already a standard way to report (recoverable) kernel bugs --
      the WARN() family of macros.  WARNs are noisier and harder to miss, and
      existing test systems already know to look for them in dmesg or via
      /proc/sys/kernel/tainted.
      
      Therefore, call WARN() when an algorithm fails its self-tests.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      09a5ef96
    • E
      crypto: testmgr - always print the actual skcipher driver name · 6e5972fa
      Eric Biggers 提交于
      When alg_test() is called from tcrypt.ko rather than from the algorithm
      registration code, "driver" is actually the algorithm name, not the
      driver name.  So it shouldn't be used in places where a driver name is
      wanted, e.g. when reporting a test failure or when checking whether the
      driver is the generic driver or not.
      
      Fix this for the skcipher algorithm tests by getting the driver name
      from the crypto_skcipher that actually got allocated.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      6e5972fa
    • E
      crypto: testmgr - always print the actual AEAD driver name · 2257f471
      Eric Biggers 提交于
      When alg_test() is called from tcrypt.ko rather than from the algorithm
      registration code, "driver" is actually the algorithm name, not the
      driver name.  So it shouldn't be used in places where a driver name is
      wanted, e.g. when reporting a test failure or when checking whether the
      driver is the generic driver or not.
      
      Fix this for the AEAD algorithm tests by getting the driver name from
      the crypto_aead that actually got allocated.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      2257f471
    • E
      crypto: testmgr - always print the actual hash driver name · 79cafe9a
      Eric Biggers 提交于
      When alg_test() is called from tcrypt.ko rather than from the algorithm
      registration code, "driver" is actually the algorithm name, not the
      driver name.  So it shouldn't be used in places where a driver name is
      wanted, e.g. when reporting a test failure or when checking whether the
      driver is the generic driver or not.
      
      Fix this for the hash algorithm tests by getting the driver name from
      the crypto_ahash or crypto_shash that actually got allocated.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      79cafe9a
  9. 25 9月, 2020 3 次提交
  10. 20 8月, 2020 1 次提交
    • H
      crypto: algapi - Remove skbuff.h inclusion · 0c3dc787
      Herbert Xu 提交于
      The header file algapi.h includes skbuff.h unnecessarily since
      all we need is a forward declaration for struct sk_buff.  This
      patch removes that inclusion.
      
      Unfortunately skbuff.h pulls in a lot of things and drivers over
      the years have come to rely on it so this patch adds a lot of
      missing inclusions that result from this.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      0c3dc787
  11. 08 8月, 2020 1 次提交
    • W
      mm, treewide: rename kzfree() to kfree_sensitive() · 453431a5
      Waiman Long 提交于
      As said by Linus:
      
        A symmetric naming is only helpful if it implies symmetries in use.
        Otherwise it's actively misleading.
      
        In "kzalloc()", the z is meaningful and an important part of what the
        caller wants.
      
        In "kzfree()", the z is actively detrimental, because maybe in the
        future we really _might_ want to use that "memfill(0xdeadbeef)" or
        something. The "zero" part of the interface isn't even _relevant_.
      
      The main reason that kzfree() exists is to clear sensitive information
      that should not be leaked to other future users of the same memory
      objects.
      
      Rename kzfree() to kfree_sensitive() to follow the example of the recently
      added kvfree_sensitive() and make the intention of the API more explicit.
      In addition, memzero_explicit() is used to clear the memory to make sure
      that it won't get optimized away by the compiler.
      
      The renaming is done by using the command sequence:
      
        git grep -w --name-only kzfree |\
        xargs sed -i 's/kzfree/kfree_sensitive/'
      
      followed by some editing of the kfree_sensitive() kerneldoc and adding
      a kzfree backward compatibility macro in slab.h.
      
      [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
      [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]
      Suggested-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NWaiman Long <longman@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>
      Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      453431a5
  12. 12 3月, 2020 2 次提交
  13. 14 2月, 2020 1 次提交
    • H
      crypto/testmgr: enable selftests for paes-s390 ciphers · c7ff8573
      Harald Freudenberger 提交于
      This patch enables the selftests for the s390 specific protected key
      AES (PAES) cipher implementations:
        * cbc-paes-s390
        * ctr-paes-s390
        * ecb-paes-s390
        * xts-paes-s390
      PAES is an AES cipher but with encrypted ('protected') key
      material. However, the paes ciphers are able to derive an protected
      key from clear key material with the help of the pkey kernel module.
      
      So this patch now enables the generic AES tests for the paes
      ciphers. Under the hood the setkey() functions rearrange the clear key
      values as clear key token and so the pkey kernel module is able to
      provide protected key blobs from the given clear key values. The
      derived protected key blobs are then used within the paes cipers and
      should produce the very same results as the generic AES implementation
      with the clear key values.
      
      The s390-paes cipher testlist entries are surrounded
      by #if IS_ENABLED(CONFIG_CRYPTO_PAES_S390) because they don't
      make any sense on non s390 platforms or without the PAES
      cipher implementation.
      
      Link: http://lkml.kernel.org/r/20200213083946.zicarnnt3wizl5ty@gondor.apana.org.auAcked-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      c7ff8573
  14. 11 12月, 2019 6 次提交
    • E
      crypto: testmgr - generate inauthentic AEAD test vectors · 49763fc6
      Eric Biggers 提交于
      The whole point of using an AEAD over length-preserving encryption is
      that the data is authenticated.  However currently the fuzz tests don't
      test any inauthentic inputs to verify that the data is actually being
      authenticated.  And only two algorithms ("rfc4543(gcm(aes))" and
      "ccm(aes)") even have any inauthentic test vectors at all.
      
      Therefore, update the AEAD fuzz tests to sometimes generate inauthentic
      test vectors, either by generating a (ciphertext, AAD) pair without
      using the key, or by mutating an authentic pair that was generated.
      
      To avoid flakiness, only assume this works reliably if the auth tag is
      at least 8 bytes.  Also account for the rfc4106, rfc4309, and rfc7539esp
      algorithms intentionally ignoring the last 8 AAD bytes, and for some
      algorithms doing extra checks that result in EINVAL rather than EBADMSG.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      49763fc6
    • E
      crypto: testmgr - create struct aead_extra_tests_ctx · 2ea91505
      Eric Biggers 提交于
      In preparation for adding inauthentic input fuzz tests, which don't
      require that a generic implementation of the algorithm be available,
      refactor test_aead_vs_generic_impl() so that instead there's a
      higher-level function test_aead_extra() which initializes a struct
      aead_extra_tests_ctx and then calls test_aead_vs_generic_impl() with a
      pointer to that struct.
      
      As a bonus, this reduces stack usage.
      
      Also switch from crypto_aead_alg(tfm)->maxauthsize to
      crypto_aead_maxauthsize(), now that the latter is available in
      <crypto/aead.h>.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      2ea91505
    • E
      crypto: testmgr - test setting misaligned keys · fd8c37c7
      Eric Biggers 提交于
      The alignment bug in ghash_setkey() fixed by commit 5c6bc4df
      ("crypto: ghash - fix unaligned memory access in ghash_setkey()")
      wasn't reliably detected by the crypto self-tests on ARM because the
      tests only set the keys directly from the test vectors.
      
      To improve test coverage, update the tests to sometimes pass misaligned
      keys to setkey().  This applies to shash, ahash, skcipher, and aead.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      fd8c37c7
    • E
      crypto: testmgr - check skcipher min_keysize · fd60f727
      Eric Biggers 提交于
      When checking two implementations of the same skcipher algorithm for
      consistency, require that the minimum key size be the same, not just the
      maximum key size.  There's no good reason to allow different minimum key
      sizes.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      fd60f727
    • E
      crypto: testmgr - don't try to decrypt uninitialized buffers · eb455dbd
      Eric Biggers 提交于
      Currently if the comparison fuzz tests encounter an encryption error
      when generating an skcipher or AEAD test vector, they will still test
      the decryption side (passing it the uninitialized ciphertext buffer)
      and expect it to fail with the same error.
      
      This is sort of broken because it's not well-defined usage of the API to
      pass an uninitialized buffer, and furthermore in the AEAD case it's
      acceptable for the decryption error to be EBADMSG (meaning "inauthentic
      input") even if the encryption error was something else like EINVAL.
      
      Fix this for skcipher by explicitly initializing the ciphertext buffer
      on error, and for AEAD by skipping the decryption test on error.
      Reported-by: NPascal Van Leeuwen <pvanleeuwen@verimatrix.com>
      Fixes: d435e10e ("crypto: testmgr - fuzz skciphers against their generic implementation")
      Fixes: 40153b10 ("crypto: testmgr - fuzz AEADs against their generic implementation")
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      eb455dbd
    • E
      crypto: skcipher - remove crypto_skcipher::keysize · 9ac0d136
      Eric Biggers 提交于
      Due to the removal of the blkcipher and ablkcipher algorithm types,
      crypto_skcipher::keysize is now redundant since it always equals
      crypto_skcipher_alg(tfm)->max_keysize.
      
      Remove it and update crypto_skcipher_default_keysize() accordingly.
      
      Also rename crypto_skcipher_default_keysize() to
      crypto_skcipher_max_keysize() to clarify that it specifically returns
      the maximum key size, not some unspecified "default".
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      9ac0d136
  15. 17 11月, 2019 2 次提交
  16. 01 11月, 2019 1 次提交
    • D
      crypto: testmgr - add test vectors for blake2b · a1afe274
      David Sterba 提交于
      Test vectors for blake2b with various digest sizes. As the algorithm is
      the same up to the digest calculation, the key and input data length is
      distributed in a way that tests all combinanions of the two over the
      digest sizes.
      
      Based on the suggestion from Eric, the following input sizes are tested
      [0, 1, 7, 15, 64, 247, 256], where blake2b blocksize is 128, so the
      padded and the non-padded input buffers are tested.
      
                blake2b-160  blake2b-256  blake2b-384  blake2b-512
               ---------------------------------------------------
      len=0   | klen=0       klen=1       klen=32      klen=64
      len=1   | klen=32      klen=64      klen=0       klen=1
      len=7   | klen=64      klen=0       klen=1       klen=32
      len=15  | klen=1       klen=32      klen=64      klen=0
      len=64  | klen=0       klen=1       klen=32      klen=64
      len=247 | klen=32      klen=64      klen=0       klen=1
      len=256 | klen=64      klen=0       klen=1       klen=32
      
      Where key:
      
      - klen=0: empty key
      - klen=1: 1 byte value 0x42, 'B'
      - klen=32: first 32 bytes of the default key, sequence 00..1f
      - klen=64: default key, sequence 00..3f
      
      The unkeyed vectors are ordered before keyed, as this is required by
      testmgr.
      
      CC: Eric Biggers <ebiggers@kernel.org>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      a1afe274
  17. 04 10月, 2019 3 次提交
  18. 30 8月, 2019 1 次提交
  19. 26 7月, 2019 2 次提交