19 Dec, 2019

1 commit

  • Pull tpm fixes from Jarkko Sakkinen:
    "Bunch of fixes for rc3"

    * tag 'tpmdd-next-20191219' of git://git.infradead.org/users/jjs/linux-tpmdd:
    tpm/tpm_ftpm_tee: add shutdown call back
    tpm: selftest: cleanup after unseal with wrong auth/policy test
    tpm: selftest: add test covering async mode
    tpm: fix invalid locking in NONBLOCKING mode
    security: keys: trusted: fix lost handle flush
    tpm_tis: reserve chip for duration of tpm_tis_core_init
    KEYS: asymmetric: return ENOMEM if akcipher_request_alloc() fails
    KEYS: remove CONFIG_KEYS_COMPAT

    Linus Torvalds
     

13 Dec, 2019

1 commit

  • No error code was being set on this error path.

    Cc: stable@vger.kernel.org
    Fixes: ad4b1eb5fb33 ("KEYS: asym_tpm: Implement encryption operation [ver #2]")
    Fixes: c08fed737126 ("KEYS: Implement encrypt, decrypt and sign for software asymmetric key [ver #2]")
    Reviewed-by: James Morris
    Signed-off-by: Eric Biggers
    Reviewed-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen

    Eric Biggers
     

10 Dec, 2019

1 commit

  • Replace all the occurrences of FIELD_SIZEOF() with sizeof_field() except
    at places where these are defined. Later patches will remove the unused
    definition of FIELD_SIZEOF().

    This patch is generated using following script:

    EXCLUDE_FILES="include/linux/stddef.h|include/linux/kernel.h"

    git grep -l -e "\bFIELD_SIZEOF\b" | while read file;
    do

    if [[ "$file" =~ $EXCLUDE_FILES ]]; then
    continue
    fi
    sed -i -e 's/\bFIELD_SIZEOF\b/sizeof_field/g' $file;
    done

    Signed-off-by: Pankaj Bharadiya
    Link: https://lore.kernel.org/r/20190924105839.110713-3-pankaj.laxminarayan.bharadiya@intel.com
    Co-developed-by: Kees Cook
    Signed-off-by: Kees Cook
    Acked-by: David Miller # for net

    Pankaj Bharadiya
     

26 Nov, 2019

1 commit

  • Pull crypto updates from Herbert Xu:
    "API:
    - Add library interfaces of certain crypto algorithms for WireGuard
    - Remove the obsolete ablkcipher and blkcipher interfaces
    - Move add_early_randomness() out of rng_mutex

    Algorithms:
    - Add blake2b shash algorithm
    - Add blake2s shash algorithm
    - Add curve25519 kpp algorithm
    - Implement 4 way interleave in arm64/gcm-ce
    - Implement ciphertext stealing in powerpc/spe-xts
    - Add Eric Biggers's scalar accelerated ChaCha code for ARM
    - Add accelerated 32r2 code from Zinc for MIPS
    - Add OpenSSL/CRYPTOGRAMS poly1305 implementation for ARM and MIPS

    Drivers:
    - Fix entropy reading failures in ks-sa
    - Add support for sam9x60 in atmel
    - Add crypto accelerator for amlogic GXL
    - Add sun8i-ce Crypto Engine
    - Add sun8i-ss cryptographic offloader
    - Add a host of algorithms to inside-secure
    - Add NPCM RNG driver
    - add HiSilicon HPRE accelerator
    - Add HiSilicon TRNG driver"

    * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (285 commits)
    crypto: vmx - Avoid weird build failures
    crypto: lib/chacha20poly1305 - use chacha20_crypt()
    crypto: x86/chacha - only unregister algorithms if registered
    crypto: chacha_generic - remove unnecessary setkey() functions
    crypto: amlogic - enable working on big endian kernel
    crypto: sun8i-ce - enable working on big endian
    crypto: mips/chacha - select CRYPTO_SKCIPHER, not CRYPTO_BLKCIPHER
    hwrng: ks-sa - Enable COMPILE_TEST
    crypto: essiv - remove redundant null pointer check before kfree
    crypto: atmel-aes - Change data type for "lastc" buffer
    crypto: atmel-tdes - Set the IV after {en,de}crypt
    crypto: sun4i-ss - fix big endian issues
    crypto: sun4i-ss - hide the Invalid keylen message
    crypto: sun4i-ss - use crypto_ahash_digestsize
    crypto: sun4i-ss - remove dependency on not 64BIT
    crypto: sun4i-ss - Fix 64-bit size_t warnings on sun4i-ss-hash.c
    MAINTAINERS: Add maintainer for HiSilicon SEC V2 driver
    crypto: hisilicon - add DebugFS for HiSilicon SEC
    Documentation: add DebugFS doc for HiSilicon SEC
    crypto: hisilicon - add SRIOV for HiSilicon SEC
    ...

    Linus Torvalds
     

22 Nov, 2019

10 commits


17 Nov, 2019

23 commits

  • Now that all users of the deprecated ablkcipher interface have been
    moved to the skcipher interface, ablkcipher is no longer used and
    can be removed.

    Reviewed-by: Eric Biggers
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • this patchs constify the alg list because this list is never modified.

    Signed-off-by: Corentin Labbe
    Signed-off-by: Herbert Xu

    Corentin Labbe
     
  • This implementation is the fastest available x86_64 implementation, and
    unlike Sandy2x, it doesn't requie use of the floating point registers at
    all. Instead it makes use of BMI2 and ADX, available on recent
    microarchitectures. The implementation was written by Armando
    Faz-Hernández with contributions (upstream) from Samuel Neves and me,
    in addition to further changes in the kernel implementation from us.

    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Samuel Neves
    Co-developed-by: Samuel Neves
    [ardb: - move to arch/x86/crypto
    - wire into lib/crypto framework
    - implement crypto API KPP hooks ]
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Jason A. Donenfeld
     
  • Expose the generic Curve25519 library via the crypto API KPP interface.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • In preparation of introducing KPP implementations of Curve25519, import
    the set of test cases proposed by the Zinc patch set, but converted to
    the KPP format.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • These implementations from Samuel Neves support AVX and AVX-512VL.
    Originally this used AVX-512F, but Skylake thermal throttling made
    AVX-512VL more attractive and possible to do with negligable difference.

    Signed-off-by: Jason A. Donenfeld
    Signed-off-by: Samuel Neves
    Co-developed-by: Samuel Neves
    [ardb: move to arch/x86/crypto, wire into lib/crypto framework]
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Jason A. Donenfeld
     
  • Wire up our newly added Blake2s implementation via the shash API.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • As suggested by Eric for the Blake2b implementation contributed by
    David, introduce a set of test vectors for Blake2s covering different
    digest and key sizes.

    blake2s-128 blake2s-160 blake2s-224 blake2s-256
    ---------------------------------------------------
    len=0 | klen=0 klen=1 klen=16 klen=32
    len=1 | klen=16 klen=32 klen=0 klen=1
    len=7 | klen=32 klen=0 klen=1 klen=16
    len=15 | klen=1 klen=16 klen=32 klen=0
    len=64 | klen=0 klen=1 klen=16 klen=32
    len=247 | klen=16 klen=32 klen=0 klen=1
    len=256 | klen=32 klen=0 klen=1 klen=16

    Cc: David Sterba
    Cc: Eric Biggers
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • In order to use 128-bit integer arithmetic in C code, the architecture
    needs to have declared support for it by setting ARCH_SUPPORTS_INT128,
    and it requires a version of the toolchain that supports this at build
    time. This is why all existing tests for ARCH_SUPPORTS_INT128 also test
    whether __SIZEOF_INT128__ is defined, since this is only the case for
    compilers that can support 128-bit integers.

    Let's fold this additional test into the Kconfig declaration of
    ARCH_SUPPORTS_INT128 so that we can also use the symbol in Makefiles,
    e.g., to decide whether a certain object needs to be included in the
    first place.

    Cc: Masahiro Yamada
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • This is a straight import of the OpenSSL/CRYPTOGAMS Poly1305 implementation for
    MIPS authored by Andy Polyakov, a prior 64-bit only version of which has been
    contributed by him to the OpenSSL project. The file 'poly1305-mips.pl' is taken
    straight from this upstream GitHub repository [0] at commit
    d22ade312a7af958ec955620b0d241cf42c37feb, and already contains all the changes
    required to build it as part of a Linux kernel module.

    [0] https://github.com/dot-asm/cryptogams

    Co-developed-by: Andy Polyakov
    Signed-off-by: Andy Polyakov
    Co-developed-by: René van Dorst
    Signed-off-by: René van Dorst
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Implement the arch init/update/final Poly1305 library routines in the
    accelerated SIMD driver for x86 so they are accessible to users of
    the Poly1305 library interface as well.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Remove the dependency on the generic Poly1305 driver. Instead, depend
    on the generic library so that we only reuse code without pulling in
    the generic skcipher implementation as well.

    While at it, remove the logic that prefers the non-SIMD path for short
    inputs - this is no longer necessary after recent FPU handling changes
    on x86.

    Since this removes the last remaining user of the routines exported
    by the generic shash driver, unexport them and make them static.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Expose the existing generic Poly1305 code via a init/update/final
    library interface so that callers are not required to go through
    the crypto API's shash abstraction to access it. At the same time,
    make some preparations so that the library implementation can be
    superseded by an accelerated arch-specific version in the future.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • In preparation of exposing a Poly1305 library interface directly from
    the accelerated x86 driver, align the state descriptor of the x86 code
    with the one used by the generic driver. This is needed to make the
    library interface unified between all implementations.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Move the core Poly1305 routines shared between the generic Poly1305
    shash driver and the Adiantum and NHPoly1305 drivers into a separate
    library so that using just this pieces does not pull in the crypto
    API pieces of the generic Poly1305 routine.

    In a subsequent patch, we will augment this generic library with
    init/update/final routines so that Poyl1305 algorithm can be used
    directly without the need for using the crypto API's shash abstraction.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Now that all users of generic ChaCha code have moved to the core library,
    there is no longer a need for the generic ChaCha skcpiher driver to
    export parts of it implementation for reuse by other drivers. So drop
    the exports, and make the symbols static.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • This integrates the accelerated MIPS 32r2 implementation of ChaCha
    into both the API and library interfaces of the kernel crypto stack.

    The significance of this is that, in addition to becoming available
    as an accelerated library implementation, it can also be used by
    existing crypto API code such as Adiantum (for block encryption on
    ultra low performance cores) or IPsec using chacha20poly1305. These
    are use cases that have already opted into using the abstract crypto
    API. In order to support Adiantum, the core assembler routine has
    been adapted to take the round count as a function argument rather
    than hardcoding it to 20.

    Co-developed-by: René van Dorst
    Signed-off-by: René van Dorst
    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Wire the existing x86 SIMD ChaCha code into the new ChaCha library
    interface, so that users of the library interface will get the
    accelerated version when available.

    Given that calls into the library API will always go through the
    routines in this module if it is enabled, switch to static keys
    to select the optimal implementation available (which may be none
    at all, in which case we defer to the generic implementation for
    all invocations).

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • In preparation of extending the x86 ChaCha driver to also expose the ChaCha
    library interface, drop the dependency on the chacha_generic crypto driver
    as a non-SIMD fallback, and depend on the generic ChaCha library directly.
    This way, we only pull in the code we actually need, without registering
    a set of ChaCha skciphers that we will never use.

    Since turning the FPU on and off is cheap these days, simplify the SIMD
    routine by dropping the per-page yield, which makes for a cleaner switch
    to the library API as well. This also allows use to invoke the skcipher
    walk routines in non-atomic mode.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • Currently, our generic ChaCha implementation consists of a permute
    function in lib/chacha.c that operates on the 64-byte ChaCha state
    directly [and which is always included into the core kernel since it
    is used by the /dev/random driver], and the crypto API plumbing to
    expose it as a skcipher.

    In order to support in-kernel users that need the ChaCha streamcipher
    but have no need [or tolerance] for going through the abstractions of
    the crypto API, let's expose the streamcipher bits via a library API
    as well, in a way that permits the implementation to be superseded by
    an architecture specific one if provided.

    So move the streamcipher code into a separate module in lib/crypto,
    and expose the init() and crypt() routines to users of the library.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • In preparation of introducing a set of crypto library interfaces, tidy
    up the Makefile and split off the Kconfig symbols into a separate file.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu

    Ard Biesheuvel
     
  • If aead is built as a module along with cryptomgr, it creates a
    dependency loop due to the dependency chain aead => crypto_null =>
    cryptomgr => aead.

    This is due to the presence of the AEAD geniv code. This code is
    not really part of the AEAD API but simply support code for IV
    generators such as seqiv. This patch moves the geniv code into
    its own module thus breaking the dependency loop.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The crypto API requires cryptomgr to be present for probing to work
    so we need a softdep to ensure that cryptomgr is added to the
    initramfs.

    This was usually not a problem because until very recently it was
    not practical to build crypto API as module but with the recent
    work to eliminate direct AES users this is now possible.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

15 Nov, 2019

1 commit


13 Nov, 2019

2 commits

  • Move existing code to trusted keys subsystem. Also, rename files with
    "tpm" as suffix which provides the underlying implementation.

    Suggested-by: Jarkko Sakkinen
    Signed-off-by: Sumit Garg
    Reviewed-by: Jarkko Sakkinen
    Tested-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen

    Sumit Garg
     
  • Switch to utilize common heap based tpm_buf code for TPM based trusted
    and asymmetric keys rather than using stack based tpm1_buf code. Also,
    remove tpm1_buf code.

    Suggested-by: Jarkko Sakkinen
    Signed-off-by: Sumit Garg
    Reviewed-by: Jerry Snitselaar
    Reviewed-by: Jarkko Sakkinen
    Tested-by: Jarkko Sakkinen
    Signed-off-by: Jarkko Sakkinen

    Sumit Garg