Skip to content
  1. Aug 04, 2017
    • Ard Biesheuvel's avatar
      crypto: arm/aes - avoid expanded lookup tables in the final round · 0d149ce6
      Ard Biesheuvel authored
      
      
      For the final round, avoid the expanded and padded lookup tables
      exported by the generic AES driver. Instead, for encryption, we can
      perform byte loads from the same table we used for the inner rounds,
      which will still be hot in the caches. For decryption, use the inverse
      AES Sbox directly, which is 4x smaller than the inverse lookup table
      exported by the generic driver.
      
      This should significantly reduce the Dcache footprint of our code,
      which makes the code more robust against timing attacks. It does not
      introduce any additional module dependencies, given that we already
      rely on the core AES module for the shared key expansion routines.
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      0d149ce6
    • Ard Biesheuvel's avatar
      crypto: arm/ghash - add NEON accelerated fallback for vmull.p64 · 3759ee05
      Ard Biesheuvel authored
      Implement a NEON fallback for systems that do support NEON but have
      no support for the optional 64x64->128 polynomial multiplication
      instruction that is part of the ARMv8 Crypto Extensions. It is based
      on the paper "Fast Software Polynomial Multiplication on ARM Processors
      Using the NEON Engine" by Danilo Camara, Conrado Gouvea, Julio Lopez and
      Ricardo Dahab (https://hal.inria.fr/hal-01506572
      
      )
      
      On a 32-bit guest executing under KVM on a Cortex-A57, the new code is
      not only 4x faster than the generic table based GHASH driver, it is also
      time invariant. (Note that the existing vmull.p64 code is 16x faster on
      this core).
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      3759ee05
    • Ard Biesheuvel's avatar
      crypto: algapi - make crypto_xor() take separate dst and src arguments · 45fe93df
      Ard Biesheuvel authored
      
      
      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: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      45fe93df
  2. Jun 01, 2017
  3. Mar 09, 2017
    • Ard Biesheuvel's avatar
      crypto: arm/aes-neonbs - resolve fallback cipher at runtime · b56f5cbc
      Ard Biesheuvel authored
      
      
      Currently, the bit sliced NEON AES code for ARM has a link time
      dependency on the scalar ARM asm implementation, which it uses as a
      fallback to perform CBC encryption and the encryption of the initial
      XTS tweak.
      
      The bit sliced NEON code is both fast and time invariant, which makes
      it a reasonable default on hardware that supports it. However, the
      ARM asm code it pulls in is not time invariant, and due to the way it
      is linked in, cannot be overridden by the new generic time invariant
      driver. In fact, it will not be used at all, given that the ARM asm
      code registers itself as a cipher with a priority that exceeds the
      priority of the fixed time cipher.
      
      So remove the link time dependency, and allocate the fallback cipher
      via the crypto API. Note that this requires this driver's module_init
      call to be replaced with late_initcall, so that the (possibly generic)
      fallback cipher is guaranteed to be available when the builtin test
      is performed at registration time.
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      b56f5cbc
  4. Mar 01, 2017
  5. Feb 03, 2017
  6. Jan 23, 2017
    • Ard Biesheuvel's avatar
      crypto: arm/aes-neonbs - fix issue with v2.22 and older assembler · 13954e78
      Ard Biesheuvel authored
      
      
      The GNU assembler for ARM version 2.22 or older fails to infer the
      element size from the vmov instructions, and aborts the build in
      the following way;
      
      .../aes-neonbs-core.S: Assembler messages:
      .../aes-neonbs-core.S:817: Error: bad type for scalar -- `vmov q1h[1],r10'
      .../aes-neonbs-core.S:817: Error: bad type for scalar -- `vmov q1h[0],r9'
      .../aes-neonbs-core.S:817: Error: bad type for scalar -- `vmov q1l[1],r8'
      .../aes-neonbs-core.S:817: Error: bad type for scalar -- `vmov q1l[0],r7'
      .../aes-neonbs-core.S:818: Error: bad type for scalar -- `vmov q2h[1],r10'
      .../aes-neonbs-core.S:818: Error: bad type for scalar -- `vmov q2h[0],r9'
      .../aes-neonbs-core.S:818: Error: bad type for scalar -- `vmov q2l[1],r8'
      .../aes-neonbs-core.S:818: Error: bad type for scalar -- `vmov q2l[0],r7'
      
      Fix this by setting the element size explicitly, by replacing vmov with
      vmov.32.
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      13954e78
  7. Jan 13, 2017
    • Ard Biesheuvel's avatar
      crypto: arm/aes - avoid reserved 'tt' mnemonic in asm code · 658fa754
      Ard Biesheuvel authored
      
      
      The ARMv8-M architecture introduces 'tt' and 'ttt' instructions,
      which means we can no longer use 'tt' as a register alias on recent
      versions of binutils for ARM. So replace the alias with 'ttab'.
      
      Fixes: 81edb426 ("crypto: arm/aes - replace scalar AES cipher")
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      658fa754
    • Ard Biesheuvel's avatar
      crypto: arm/aes - replace bit-sliced OpenSSL NEON code · cc477bf6
      Ard Biesheuvel authored
      
      
      This replaces the unwieldy generated implementation of bit-sliced AES
      in CBC/CTR/XTS modes that originated in the OpenSSL project with a
      new version that is heavily based on the OpenSSL implementation, but
      has a number of advantages over the old version:
      - it does not rely on the scalar AES cipher that also originated in the
        OpenSSL project and contains redundant lookup tables and key schedule
        generation routines (which we already have in crypto/aes_generic.)
      - it uses the same expanded key schedule for encryption and decryption,
        reducing the size of the per-key data structure by 1696 bytes
      - it adds an implementation of AES in ECB mode, which can be wrapped by
        other generic chaining mode implementations
      - it moves the handling of corner cases that are non critical to performance
        to the glue layer written in C
      - it was written directly in assembler rather than generated from a Perl
        script
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      cc477bf6
  8. Jan 12, 2017
  9. Dec 28, 2016
  10. Dec 27, 2016
  11. Dec 07, 2016
  12. Dec 01, 2016
  13. Nov 30, 2016
  14. Nov 29, 2016
  15. Nov 28, 2016
  16. Oct 21, 2016
  17. Sep 13, 2016
    • Ard Biesheuvel's avatar
      crypto: arm/aes-ctr - fix NULL dereference in tail processing · f82e90b2
      Ard Biesheuvel authored
      
      
      The AES-CTR glue code avoids calling into the blkcipher API for the
      tail portion of the walk, by comparing the remainder of walk.nbytes
      modulo AES_BLOCK_SIZE with the residual nbytes, and jumping straight
      into the tail processing block if they are equal. This tail processing
      block checks whether nbytes != 0, and does nothing otherwise.
      
      However, in case of an allocation failure in the blkcipher layer, we
      may enter this code with walk.nbytes == 0, while nbytes > 0. In this
      case, we should not dereference the source and destination pointers,
      since they may be NULL. So instead of checking for nbytes != 0, check
      for (walk.nbytes % AES_BLOCK_SIZE) != 0, which implies the former in
      non-error conditions.
      
      Fixes: 86464859 ("crypto: arm - AES in ECB/CBC/CTR/XTS modes using ARMv8 Crypto Extensions")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarxiakaixu <xiakaixu@huawei.com>
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      f82e90b2
  18. Sep 07, 2016
  19. Jun 23, 2016
    • Herbert Xu's avatar
      crypto: ghash-ce - Fix cryptd reordering · 820573eb
      Herbert Xu authored
      
      
      This patch fixes an old bug where requests can be reordered because
      some are processed by cryptd while others are processed directly
      in softirq context.
      
      The fix is to always postpone to cryptd if there are currently
      requests outstanding from the same tfm.
      
      This patch also removes the redundant use of cryptd in the async
      init function as init never touches the FPU.
      
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      820573eb
  20. Feb 17, 2016
  21. Feb 16, 2016
    • Stephan Mueller's avatar
      crypto: xts - consolidate sanity check for keys · 28856a9e
      Stephan Mueller authored
      
      
      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: default avatarStephan Mueller <smueller@chronox.de>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      28856a9e
  22. Feb 15, 2016
  23. Jul 06, 2015
  24. May 11, 2015
Loading