1. 18 4月, 2019 2 次提交
  2. 22 2月, 2019 6 次提交
  3. 08 2月, 2019 3 次提交
    • 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
    • E
      crypto: testmgr - convert skcipher testing to use testvec_configs · 4e7babba
      Eric Biggers 提交于
      Convert alg_test_skcipher() 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 skcipher 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, different IV alignments, and buffers
      that cross pages.
      
      This has already found a bug in the arm64 ctr-aes-neonbs algorithm.
      It would have easily found many past bugs.
      
      I removed the skcipher 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>
      4e7babba
  4. 25 1月, 2019 1 次提交
    • E
      crypto: clarify name of WEAK_KEY request flag · 231baecd
      Eric Biggers 提交于
      CRYPTO_TFM_REQ_WEAK_KEY confuses newcomers to the crypto API because it
      sounds like it is requesting a weak key.  Actually, it is requesting
      that weak keys be forbidden (for algorithms that have the notion of
      "weak keys"; currently only DES and XTS do).
      
      Also it is only one letter away from CRYPTO_TFM_RES_WEAK_KEY, with which
      it can be easily confused.  (This in fact happened in the UX500 driver,
      though just in some debugging messages.)
      
      Therefore, make the intent clear by renaming it to
      CRYPTO_TFM_REQ_FORBID_WEAK_KEYS.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      231baecd
  5. 18 1月, 2019 4 次提交
    • E
      crypto: testmgr - unify the AEAD encryption and decryption test vectors · a0d608ee
      Eric Biggers 提交于
      Currently testmgr has separate encryption and decryption test vectors
      for AEADs.  That's massively redundant, since usually the decryption
      tests are identical to the encryption tests, just with the input/result
      swapped.  And for some algorithms it was forgotten to add decryption
      test vectors, so for them currently only encryption is being tested.
      
      Therefore, eliminate the redundancy by removing the AEAD decryption test
      vectors and updating testmgr to test both AEAD encryption and decryption
      using what used to be the encryption test vectors.  Naming is adjusted
      accordingly: each aead_testvec now has a 'ptext' (plaintext), 'plen'
      (plaintext length), 'ctext' (ciphertext), and 'clen' (ciphertext length)
      instead of an 'input', 'ilen', 'result', and 'rlen'.  "Ciphertext" here
      refers to the full ciphertext, including the authentication tag.
      
      For now the scatterlist divisions are just given for the plaintext
      length, not also the ciphertext length.  For decryption, the last
      scatterlist element is just extended by the authentication tag length.
      
      In total, this removes over 5000 lines from testmgr.h, with no reduction
      in test coverage since prior patches already copied the few unique
      decryption test vectors into the encryption test vectors.
      
      The testmgr.h portion of this patch was automatically generated using
      the following awk script, except that I also manually updated the
      definition of 'struct aead_testvec' and fixed the location of the
      comment describing the AEGIS-128 test vectors.
      
          BEGIN { OTHER = 0; ENCVEC = 1; DECVEC = 2; DECVEC_TAIL = 3; mode = OTHER }
      
          /^static const struct aead_testvec.*_enc_/ { sub("_enc", ""); mode = ENCVEC }
          /^static const struct aead_testvec.*_dec_/ { mode = DECVEC }
          mode == ENCVEC {
              sub(/\.input[[:space:]]*=/,     ".ptext\t=")
              sub(/\.result[[:space:]]*=/,    ".ctext\t=")
              sub(/\.ilen[[:space:]]*=/,      ".plen\t=")
              sub(/\.rlen[[:space:]]*=/,      ".clen\t=")
              print
          }
          mode == DECVEC_TAIL && /[^[:space:]]/ { mode = OTHER }
          mode == OTHER                         { print }
          mode == ENCVEC && /^};/               { mode = OTHER }
          mode == DECVEC && /^};/               { mode = DECVEC_TAIL }
      
      Note that git's default diff algorithm gets confused by the testmgr.h
      portion of this patch, and reports too many lines added and removed.
      It's better viewed with 'git diff --minimal' (or 'git show --minimal'),
      which reports "2 files changed, 1235 insertions(+), 6491 deletions(-)".
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      a0d608ee
    • E
      crypto: testmgr - add rfc4543(gcm(aes)) decryption test to encryption tests · d7250b41
      Eric Biggers 提交于
      One "rfc4543(gcm(aes))" decryption test vector doesn't exactly match any of the
      encryption test vectors with input and result swapped.  In preparation
      for removing the AEAD decryption test vectors and testing AEAD
      decryption using the encryption test vectors, add this to the encryption
      test vectors, so we don't lose any test coverage.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      d7250b41
    • E
      crypto: testmgr - add gcm(aes) decryption tests to encryption tests · f38e8885
      Eric Biggers 提交于
      Some "gcm(aes)" decryption test vectors don't exactly match any of the
      encryption test vectors with input and result swapped.  In preparation
      for removing the AEAD decryption test vectors and testing AEAD
      decryption using the encryption test vectors, add these to the
      encryption test vectors, so we don't lose any test coverage.
      
      In the case of the chunked test vector, I truncated the last scatterlist
      element to the end of the plaintext.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      f38e8885
    • E
      crypto: testmgr - add ccm(aes) decryption tests to encryption tests · de845da9
      Eric Biggers 提交于
      Some "ccm(aes)" decryption test vectors don't exactly match any of the
      encryption test vectors with input and result swapped.  In preparation
      for removing the AEAD decryption test vectors and testing AEAD
      decryption using the encryption test vectors, add these to the
      encryption test vectors, so we don't lose any test coverage.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      de845da9
  6. 11 1月, 2019 2 次提交
    • E
      crypto: ofb - fix handling partial blocks and make thread-safe · b3e3e2db
      Eric Biggers 提交于
      Fix multiple bugs in the OFB implementation:
      
      1. It stored the per-request state 'cnt' in the tfm context, which can be
         used by multiple threads concurrently (e.g. via AF_ALG).
      2. It didn't support messages not a multiple of the block cipher size,
         despite being a stream cipher.
      3. It didn't set cra_blocksize to 1 to indicate it is a stream cipher.
      
      To fix these, set the 'chunksize' property to the cipher block size to
      guarantee that when walking through the scatterlist, a partial block can
      only occur at the end.  Then change the implementation to XOR a block at
      a time at first, then XOR the partial block at the end if needed.  This
      is the same way CTR and CFB are implemented.  As a bonus, this also
      improves performance in most cases over the current approach.
      
      Fixes: e497c518 ("crypto: ofb - add output feedback mode")
      Cc: <stable@vger.kernel.org> # v4.20+
      Cc: Gilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NGilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      b3e3e2db
    • E
      crypto: cfb - add missing 'chunksize' property · 394a9e04
      Eric Biggers 提交于
      Like some other block cipher mode implementations, the CFB
      implementation assumes that while walking through the scatterlist, a
      partial block does not occur until the end.  But the walk is incorrectly
      being done with a blocksize of 1, as 'cra_blocksize' is set to 1 (since
      CFB is a stream cipher) but no 'chunksize' is set.  This bug causes
      incorrect encryption/decryption for some scatterlist layouts.
      
      Fix it by setting the 'chunksize'.  Also extend the CFB test vectors to
      cover this bug as well as cases where the message length is not a
      multiple of the block size.
      
      Fixes: a7d85e06 ("crypto: cfb - add support for Cipher FeedBack mode")
      Cc: <stable@vger.kernel.org> # v4.17+
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      394a9e04
  7. 13 12月, 2018 2 次提交
  8. 20 11月, 2018 4 次提交
    • E
      crypto: adiantum - add Adiantum support · 059c2a4d
      Eric Biggers 提交于
      Add support for the Adiantum encryption mode.  Adiantum was designed by
      Paul Crowley and is specified by our paper:
      
          Adiantum: length-preserving encryption for entry-level processors
          (https://eprint.iacr.org/2018/720.pdf)
      
      See our paper for full details; this patch only provides an overview.
      
      Adiantum is a tweakable, length-preserving encryption mode designed for
      fast and secure disk encryption, especially on CPUs without dedicated
      crypto instructions.  Adiantum encrypts each sector using the XChaCha12
      stream cipher, two passes of an ε-almost-∆-universal (εA∆U) hash
      function, and an invocation of the AES-256 block cipher on a single
      16-byte block.  On CPUs without AES instructions, Adiantum is much
      faster than AES-XTS; for example, on ARM Cortex-A7, on 4096-byte sectors
      Adiantum encryption is about 4 times faster than AES-256-XTS encryption,
      and decryption about 5 times faster.
      
      Adiantum is a specialization of the more general HBSH construction.  Our
      earlier proposal, HPolyC, was also a HBSH specialization, but it used a
      different εA∆U hash function, one based on Poly1305 only.  Adiantum's
      εA∆U hash function, which is based primarily on the "NH" hash function
      like that used in UMAC (RFC4418), is about twice as fast as HPolyC's;
      consequently, Adiantum is about 20% faster than HPolyC.
      
      This speed comes with no loss of security: Adiantum is provably just as
      secure as HPolyC, in fact slightly *more* secure.  Like HPolyC,
      Adiantum's security is reducible to that of XChaCha12 and AES-256,
      subject to a security bound.  XChaCha12 itself has a security reduction
      to ChaCha12.  Therefore, one need not "trust" Adiantum; one need only
      trust ChaCha12 and AES-256.  Note that the εA∆U hash function is only
      used for its proven combinatorical properties so cannot be "broken".
      
      Adiantum is also a true wide-block encryption mode, so flipping any
      plaintext bit in the sector scrambles the entire ciphertext, and vice
      versa.  No other such mode is available in the kernel currently; doing
      the same with XTS scrambles only 16 bytes.  Adiantum also supports
      arbitrary-length tweaks and naturally supports any length input >= 16
      bytes without needing "ciphertext stealing".
      
      For the stream cipher, Adiantum uses XChaCha12 rather than XChaCha20 in
      order to make encryption feasible on the widest range of devices.
      Although the 20-round variant is quite popular, the best known attacks
      on ChaCha are on only 7 rounds, so ChaCha12 still has a substantial
      security margin; in fact, larger than AES-256's.  12-round Salsa20 is
      also the eSTREAM recommendation.  For the block cipher, Adiantum uses
      AES-256, despite it having a lower security margin than XChaCha12 and
      needing table lookups, due to AES's extensive adoption and analysis
      making it the obvious first choice.  Nevertheless, for flexibility this
      patch also permits the "adiantum" template to be instantiated with
      XChaCha20 and/or with an alternate block cipher.
      
      We need Adiantum support in the kernel for use in dm-crypt and fscrypt,
      where currently the only other suitable options are block cipher modes
      such as AES-XTS.  A big problem with this is that many low-end mobile
      devices (e.g. Android Go phones sold primarily in developing countries,
      as well as some smartwatches) still have CPUs that lack AES
      instructions, e.g. ARM Cortex-A7.  Sadly, AES-XTS encryption is much too
      slow to be viable on these devices.  We did find that some "lightweight"
      block ciphers are fast enough, but these suffer from problems such as
      not having much cryptanalysis or being too controversial.
      
      The ChaCha stream cipher has excellent performance but is insecure to
      use directly for disk encryption, since each sector's IV is reused each
      time it is overwritten.  Even restricting the threat model to offline
      attacks only isn't enough, since modern flash storage devices don't
      guarantee that "overwrites" are really overwrites, due to wear-leveling.
      Adiantum avoids this problem by constructing a
      "tweakable super-pseudorandom permutation"; this is the strongest
      possible security model for length-preserving encryption.
      
      Of course, storing random nonces along with the ciphertext would be the
      ideal solution.  But doing that with existing hardware and filesystems
      runs into major practical problems; in most cases it would require data
      journaling (like dm-integrity) which severely degrades performance.
      Thus, for now length-preserving encryption is still needed.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      059c2a4d
    • E
      crypto: nhpoly1305 - add NHPoly1305 support · 26609a21
      Eric Biggers 提交于
      Add a generic implementation of NHPoly1305, an ε-almost-∆-universal hash
      function used in the Adiantum encryption mode.
      
      CONFIG_NHPOLY1305 is not selectable by itself since there won't be any
      real reason to enable it without also enabling Adiantum support.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      26609a21
    • E
      crypto: chacha - add XChaCha12 support · aa762409
      Eric Biggers 提交于
      Now that the generic implementation of ChaCha20 has been refactored to
      allow varying the number of rounds, add support for XChaCha12, which is
      the XSalsa construction applied to ChaCha12.  ChaCha12 is one of the
      three ciphers specified by the original ChaCha paper
      (https://cr.yp.to/chacha/chacha-20080128.pdf: "ChaCha, a variant of
      Salsa20"), alongside ChaCha8 and ChaCha20.  ChaCha12 is faster than
      ChaCha20 but has a lower, but still large, security margin.
      
      We need XChaCha12 support so that it can be used in the Adiantum
      encryption mode, which enables disk/file encryption on low-end mobile
      devices where AES-XTS is too slow as the CPUs lack AES instructions.
      
      We'd prefer XChaCha20 (the more popular variant), but it's too slow on
      some of our target devices, so at least in some cases we do need the
      XChaCha12-based version.  In more detail, the problem is that Adiantum
      is still much slower than we're happy with, and encryption still has a
      quite noticeable effect on the feel of low-end devices.  Users and
      vendors push back hard against encryption that degrades the user
      experience, which always risks encryption being disabled entirely.  So
      we need to choose the fastest option that gives us a solid margin of
      security, and here that's XChaCha12.  The best known attack on ChaCha
      breaks only 7 rounds and has 2^235 time complexity, so ChaCha12's
      security margin is still better than AES-256's.  Much has been learned
      about cryptanalysis of ARX ciphers since Salsa20 was originally designed
      in 2005, and it now seems we can be comfortable with a smaller number of
      rounds.  The eSTREAM project also suggests the 12-round version of
      Salsa20 as providing the best balance among the different variants:
      combining very good performance with a "comfortable margin of security".
      
      Note that it would be trivial to add vanilla ChaCha12 in addition to
      XChaCha12.  However, it's unneeded for now and therefore is omitted.
      
      As discussed in the patch that introduced XChaCha20 support, I
      considered splitting the code into separate chacha-common, chacha20,
      xchacha20, and xchacha12 modules, so that these algorithms could be
      enabled/disabled independently.  However, since nearly all the code is
      shared anyway, I ultimately decided there would have been little benefit
      to the added complexity.
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      aa762409
    • E
      crypto: chacha20-generic - add XChaCha20 support · de61d7ae
      Eric Biggers 提交于
      Add support for the XChaCha20 stream cipher.  XChaCha20 is the
      application of the XSalsa20 construction
      (https://cr.yp.to/snuffle/xsalsa-20081128.pdf) to ChaCha20 rather than
      to Salsa20.  XChaCha20 extends ChaCha20's nonce length from 64 bits (or
      96 bits, depending on convention) to 192 bits, while provably retaining
      ChaCha20's security.  XChaCha20 uses the ChaCha20 permutation to map the
      key and first 128 nonce bits to a 256-bit subkey.  Then, it does the
      ChaCha20 stream cipher with the subkey and remaining 64 bits of nonce.
      
      We need XChaCha support in order to add support for the Adiantum
      encryption mode.  Note that to meet our performance requirements, we
      actually plan to primarily use the variant XChaCha12.  But we believe
      it's wise to first add XChaCha20 as a baseline with a higher security
      margin, in case there are any situations where it can be used.
      Supporting both variants is straightforward.
      
      Since XChaCha20's subkey differs for each request, XChaCha20 can't be a
      template that wraps ChaCha20; that would require re-keying the
      underlying ChaCha20 for every request, which wouldn't be thread-safe.
      Instead, we make XChaCha20 its own top-level algorithm which calls the
      ChaCha20 streaming implementation internally.
      
      Similar to the existing ChaCha20 implementation, we define the IV to be
      the nonce and stream position concatenated together.  This allows users
      to seek to any position in the stream.
      
      I considered splitting the code into separate chacha20-common, chacha20,
      and xchacha20 modules, so that chacha20 and xchacha20 could be
      enabled/disabled independently.  However, since nearly all the code is
      shared anyway, I ultimately decided there would have been little benefit
      to the added complexity of separate modules.
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NMartin Willi <martin@strongswan.org>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      de61d7ae
  9. 16 11月, 2018 1 次提交
  10. 09 11月, 2018 1 次提交
  11. 28 9月, 2018 2 次提交
  12. 21 9月, 2018 1 次提交
  13. 04 9月, 2018 1 次提交
  14. 03 8月, 2018 1 次提交
  15. 20 7月, 2018 1 次提交
  16. 01 7月, 2018 2 次提交
    • E
      crypto: vmac - remove insecure version with hardcoded nonce · 0917b873
      Eric Biggers 提交于
      Remove the original version of the VMAC template that had the nonce
      hardcoded to 0 and produced a digest with the wrong endianness.  I'm
      unsure whether this had users or not (there are no explicit in-kernel
      references to it), but given that the hardcoded nonce made it wildly
      insecure unless a unique key was used for each message, let's try
      removing it and see if anyone complains.
      
      Leave the new "vmac64" template that requires the nonce to be explicitly
      specified as the first 16 bytes of data and uses the correct endianness
      for the digest.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      0917b873
    • E
      crypto: vmac - add nonced version with big endian digest · ed331ada
      Eric Biggers 提交于
      Currently the VMAC template uses a "nonce" hardcoded to 0, which makes
      it insecure unless a unique key is set for every message.  Also, the
      endianness of the final digest is wrong: the implementation uses little
      endian, but the VMAC specification has it as big endian, as do other
      VMAC implementations such as the one in Crypto++.
      
      Add a new VMAC template where the nonce is passed as the first 16 bytes
      of data (similar to what is done for Poly1305's nonce), and the digest
      is big endian.  Call it "vmac64", since the old name of simply "vmac"
      didn't clarify whether the implementation is of VMAC-64 or of VMAC-128
      (which produce 64-bit and 128-bit digests respectively); so we fix the
      naming ambiguity too.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      ed331ada
  17. 31 5月, 2018 5 次提交
    • E
      crypto: testmgr - eliminate redundant decryption test vectors · 92a4c9fe
      Eric Biggers 提交于
      Currently testmgr has separate encryption and decryption test vectors
      for symmetric ciphers.  That's massively redundant, since with few
      exceptions (mostly mistakes, apparently), all decryption tests are
      identical to the encryption tests, just with the input/result flipped.
      
      Therefore, eliminate the redundancy by removing the decryption test
      vectors and updating testmgr to test both encryption and decryption
      using what used to be the encryption test vectors.  Naming is adjusted
      accordingly: each cipher_testvec now has a 'ptext' (plaintext), 'ctext'
      (ciphertext), and 'len' instead of an 'input', 'result', 'ilen', and
      'rlen'.  Note that it was always the case that 'ilen == rlen'.
      
      AES keywrap ("kw(aes)") is special because its IV is generated by the
      encryption.  Previously this was handled by specifying 'iv_out' for
      encryption and 'iv' for decryption.  To make it work cleanly with only
      one set of test vectors, put the IV in 'iv', remove 'iv_out', and add a
      boolean that indicates that the IV is generated by the encryption.
      
      In total, this removes over 10000 lines from testmgr.h, with no
      reduction in test coverage since prior patches already copied the few
      unique decryption test vectors into the encryption test vectors.
      
      This covers all algorithms that used 'struct cipher_testvec', e.g. any
      block cipher in the ECB, CBC, CTR, XTS, LRW, CTS-CBC, PCBC, OFB, or
      keywrap modes, and Salsa20 and ChaCha20.  No change is made to AEAD
      tests, though we probably can eliminate a similar redundancy there too.
      
      The testmgr.h portion of this patch was automatically generated using
      the following awk script, with some slight manual fixups on top (updated
      'struct cipher_testvec' definition, updated a few comments, and fixed up
      the AES keywrap test vectors):
      
          BEGIN { OTHER = 0; ENCVEC = 1; DECVEC = 2; DECVEC_TAIL = 3; mode = OTHER }
      
          /^static const struct cipher_testvec.*_enc_/ { sub("_enc", ""); mode = ENCVEC }
          /^static const struct cipher_testvec.*_dec_/ { mode = DECVEC }
          mode == ENCVEC && !/\.ilen[[:space:]]*=/ {
          	sub(/\.input[[:space:]]*=$/,    ".ptext =")
          	sub(/\.input[[:space:]]*=/,     ".ptext\t=")
          	sub(/\.result[[:space:]]*=$/,   ".ctext =")
          	sub(/\.result[[:space:]]*=/,    ".ctext\t=")
          	sub(/\.rlen[[:space:]]*=/,      ".len\t=")
          	print
          }
          mode == DECVEC_TAIL && /[^[:space:]]/ { mode = OTHER }
          mode == OTHER                         { print }
          mode == ENCVEC && /^};/               { mode = OTHER }
          mode == DECVEC && /^};/               { mode = DECVEC_TAIL }
      
      Note that git's default diff algorithm gets confused by the testmgr.h
      portion of this patch, and reports too many lines added and removed.
      It's better viewed with 'git diff --minimal' (or 'git show --minimal'),
      which reports "2 files changed, 919 insertions(+), 11723 deletions(-)".
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      92a4c9fe
    • E
      crypto: testmgr - add extra kw(aes) encryption test vector · 4074a77d
      Eric Biggers 提交于
      One "kw(aes)" decryption test vector doesn't exactly match an encryption
      test vector with input and result swapped.  In preparation for removing
      the decryption test vectors, add this test vector to the encryption test
      vectors, so we don't lose any test coverage.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      4074a77d
    • E
      crypto: testmgr - add extra ecb(tnepres) encryption test vectors · a0e20b9b
      Eric Biggers 提交于
      None of the four "ecb(tnepres)" decryption test vectors exactly match an
      encryption test vector with input and result swapped.  In preparation
      for removing the decryption test vectors, add these to the encryption
      test vectors, so we don't lose any test coverage.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      a0e20b9b
    • E
      crypto: testmgr - make an cbc(des) encryption test vector chunked · 17880f11
      Eric Biggers 提交于
      One "cbc(des)" decryption test vector doesn't exactly match an
      encryption test vector with input and result swapped.  It's *almost* the
      same as one, but the decryption version is "chunked" while the
      encryption version is "unchunked".  In preparation for removing the
      decryption test vectors, make the encryption one both chunked and
      unchunked, so we don't lose any test coverage.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      17880f11
    • E
      crypto: testmgr - add extra ecb(des) encryption test vectors · 097012e8
      Eric Biggers 提交于
      Two "ecb(des)" decryption test vectors don't exactly match any of the
      encryption test vectors with input and result swapped.  In preparation
      for removing the decryption test vectors, add these to the encryption
      test vectors, so we don't lose any test coverage.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      097012e8
  18. 27 5月, 2018 1 次提交