1. 21 5月, 2021 1 次提交
  2. 26 3月, 2021 2 次提交
  3. 12 3月, 2021 1 次提交
  4. 10 2月, 2021 1 次提交
  5. 29 1月, 2021 5 次提交
  6. 25 9月, 2020 1 次提交
  7. 23 7月, 2020 1 次提交
  8. 11 12月, 2019 1 次提交
    • 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
  9. 17 11月, 2019 2 次提交
  10. 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
  11. 04 10月, 2019 4 次提交
  12. 30 8月, 2019 1 次提交
  13. 26 7月, 2019 3 次提交
  14. 06 6月, 2019 1 次提交
    • N
      crypto: xxhash - Implement xxhash support · 67882e76
      Nikolay Borisov 提交于
      xxhash is currently implemented as a self-contained module in /lib.
      This patch enables that module to be used as part of the generic kernel
      crypto framework. It adds a simple wrapper to the 64bit version.
      
      I've also added test vectors (with help from Nick Terrell). The upstream
      xxhash code is tested by running hashing operation on random 222 byte
      data with seed values of 0 and a prime number. The upstream test
      suite can be found at https://github.com/Cyan4973/xxHash/blob/cf46e0c/xxhsum.c#L664
      
      Essentially hashing is run on data of length 0,1,14,222 with the
      aforementioned seed values 0 and prime 2654435761. The particular random
      222 byte string was provided to me by Nick Terrell by reading
      /dev/random and the checksums were calculated by the upstream xxsum
      utility with the following bash script:
      
      dd if=/dev/random of=TEST_VECTOR bs=1 count=222
      
      for a in 0 1; do
      	for l in 0 1 14 222; do
      		for s in 0 2654435761; do
      			echo algo $a length $l seed $s;
      			head -c $l TEST_VECTOR | ~/projects/kernel/xxHash/xxhsum -H$a -s$s
      		done
      	done
      done
      
      This produces output as follows:
      
      algo 0 length 0 seed 0
      02cc5d05  stdin
      algo 0 length 0 seed 2654435761
      02cc5d05  stdin
      algo 0 length 1 seed 0
      25201171  stdin
      algo 0 length 1 seed 2654435761
      25201171  stdin
      algo 0 length 14 seed 0
      c1d95975  stdin
      algo 0 length 14 seed 2654435761
      c1d95975  stdin
      algo 0 length 222 seed 0
      b38662a6  stdin
      algo 0 length 222 seed 2654435761
      b38662a6  stdin
      algo 1 length 0 seed 0
      ef46db3751d8e999  stdin
      algo 1 length 0 seed 2654435761
      ac75fda2929b17ef  stdin
      algo 1 length 1 seed 0
      27c3f04c2881203a  stdin
      algo 1 length 1 seed 2654435761
      4a15ed26415dfe4d  stdin
      algo 1 length 14 seed 0
      3d33dc700231dfad  stdin
      algo 1 length 14 seed 2654435761
      ea5f7ddef9a64f80  stdin
      algo 1 length 222 seed 0
      5f3d3c08ec2bef34  stdin
      algo 1 length 222 seed 2654435761
      6a9df59664c7ed62  stdin
      
      algo 1 is xx64 variant, algo 0 is the 32 bit variant which is currently
      not hooked up.
      Signed-off-by: NNikolay Borisov <nborisov@suse.com>
      Reviewed-by: NEric Biggers <ebiggers@kernel.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      67882e76
  15. 31 5月, 2019 1 次提交
  16. 30 5月, 2019 1 次提交
  17. 18 4月, 2019 4 次提交
    • E
      crypto: testmgr - fuzz skciphers against their generic implementation · d435e10e
      Eric Biggers 提交于
      When the extra crypto self-tests are enabled, test each skcipher
      algorithm against its generic implementation when one is available.
      This involves: checking the algorithm properties for consistency, then
      randomly generating test vectors using the generic implementation and
      running them against the implementation under test.  Both good and bad
      inputs are tested.
      
      This has already detected a bug in the skcipher_walk API, a bug in the
      LRW template, and an inconsistency in the cts implementations.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      d435e10e
    • E
      crypto: testmgr - expand ability to test for errors · 5283a8ee
      Eric Biggers 提交于
      Update testmgr to support testing for specific errors from setkey() and
      digest() for hashes; setkey() and encrypt()/decrypt() for skciphers and
      ciphers; and setkey(), setauthsize(), and encrypt()/decrypt() for AEADs.
      This is useful because algorithms usually restrict the lengths or format
      of the message, key, and/or authentication tag in some way.  And bad
      inputs should be tested too, not just good inputs.
      
      As part of this change, remove the ambiguously-named 'fail' flag and
      replace it with 'setkey_error = -EINVAL' for the only test vector that
      used it -- the DES weak key test vector.  Note that this tightens the
      test to require -EINVAL rather than any error code, but AFAICS this
      won't cause any test failure.
      
      Other than that, these new fields aren't set on any test vectors yet.
      Later patches will do so.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      5283a8ee
    • V
      crypto: ecrdsa - add EC-RDSA test vectors to testmgr · 32fbdbd3
      Vitaly Chikunov 提交于
      Add testmgr test vectors for EC-RDSA algorithm for every of five
      supported parameters (curves). Because there are no officially published
      test vectors for the curves, the vectors are generated by gost-engine.
      Signed-off-by: NVitaly Chikunov <vt@altlinux.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      32fbdbd3
    • V
      X.509: parse public key parameters from x509 for akcipher · f1774cb8
      Vitaly Chikunov 提交于
      Some public key algorithms (like EC-DSA) keep in parameters field
      important data such as digest and curve OIDs (possibly more for
      different EC-DSA variants). Thus, just setting a public key (as
      for RSA) is not enough.
      
      Append parameters into the key stream for akcipher_set_{pub,priv}_key.
      Appended data is: (u32) algo OID, (u32) parameters length, parameters
      data.
      
      This does not affect current akcipher API nor RSA ciphers (they could
      ignore it). Idea of appending parameters to the key stream is by Herbert
      Xu.
      
      Cc: David Howells <dhowells@redhat.com>
      Cc: Denis Kenzior <denkenz@gmail.com>
      Cc: keyrings@vger.kernel.org
      Signed-off-by: NVitaly Chikunov <vt@altlinux.org>
      Reviewed-by: NDenis Kenzior <denkenz@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      f1774cb8
  18. 08 4月, 2019 1 次提交
    • E
      crypto: x86/poly1305 - fix overflow during partial reduction · 678cce40
      Eric Biggers 提交于
      The x86_64 implementation of Poly1305 produces the wrong result on some
      inputs because poly1305_4block_avx2() incorrectly assumes that when
      partially reducing the accumulator, the bits carried from limb 'd4' to
      limb 'h0' fit in a 32-bit integer.  This is true for poly1305-generic
      which processes only one block at a time.  However, it's not true for
      the AVX2 implementation, which processes 4 blocks at a time and
      therefore can produce intermediate limbs about 4x larger.
      
      Fix it by making the relevant calculations use 64-bit arithmetic rather
      than 32-bit.  Note that most of the carries already used 64-bit
      arithmetic, but the d4 -> h0 carry was different for some reason.
      
      To be safe I also made the same change to the corresponding SSE2 code,
      though that only operates on 1 or 2 blocks at a time.  I don't think
      it's really needed for poly1305_block_sse2(), but it doesn't hurt
      because it's already x86_64 code.  It *might* be needed for
      poly1305_2block_sse2(), but overflows aren't easy to reproduce there.
      
      This bug was originally detected by my patches that improve testmgr to
      fuzz algorithms against their generic implementation.  But also add a
      test vector which reproduces it directly (in the AVX2 case).
      
      Fixes: b1ccc8f4 ("crypto: poly1305 - Add a four block AVX2 variant for x86_64")
      Fixes: c70f4abe ("crypto: poly1305 - Add a SSE2 SIMD variant for x86_64")
      Cc: <stable@vger.kernel.org> # v4.3+
      Cc: Martin Willi <martin@strongswan.org>
      Cc: Jason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      678cce40
  19. 22 2月, 2019 6 次提交
  20. 08 2月, 2019 2 次提交
    • E
      crypto: testmgr - convert hash testing to use testvec_configs · 4cc2dcf9
      Eric Biggers 提交于
      Convert alg_test_hash() to use the new test framework, adding a list of
      testvec_configs to test by default.  When the extra self-tests are
      enabled, randomly generated testvec_configs are tested as well.
      
      This improves hash test coverage mainly because now all algorithms have
      a variety of data layouts tested, whereas before each algorithm was
      responsible for declaring its own chunked test cases which were often
      missing or provided poor test coverage.  The new code also tests both
      the MAY_SLEEP and !MAY_SLEEP cases and buffers that cross pages.
      
      This already found bugs in the hash walk code and in the arm32 and arm64
      implementations of crct10dif.
      
      I removed the hash chunked test vectors that were the same as
      non-chunked ones, but left the ones that were unique.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      4cc2dcf9
    • E
      crypto: testmgr - convert aead testing to use testvec_configs · ed96804f
      Eric Biggers 提交于
      Convert alg_test_aead() to use the new test framework, using the same
      list of testvec_configs that skcipher testing uses.
      
      This significantly improves AEAD test coverage mainly because previously
      there was only very limited test coverage of the possible data layouts.
      Now the data layouts to test are listed in one place for all algorithms
      and optionally are also randomly generated.  In fact, only one AEAD
      algorithm (AES-GCM) even had a chunked test case before.
      
      This already found bugs in all the AEGIS and MORUS implementations, the
      x86 AES-GCM implementation, and the arm64 AES-CCM implementation.
      
      I removed the AEAD chunked test vectors that were the same as
      non-chunked ones, but left the ones that were unique.
      
      Note: the rewritten test code allocates an aead_request just once per
      algorithm rather than once per encryption/decryption, but some AEAD
      algorithms incorrectly change the tfm pointer in the request.  It's
      nontrivial to fix these, so to move forward I'm temporarily working
      around it by resetting the tfm pointer.  But they'll need to be fixed.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      ed96804f