15 Aug, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

07 May, 2019

1 commit

  • Pull crypto update from Herbert Xu:
    "API:
    - Add support for AEAD in simd
    - Add fuzz testing to testmgr
    - Add panic_on_fail module parameter to testmgr
    - Use per-CPU struct instead multiple variables in scompress
    - Change verify API for akcipher

    Algorithms:
    - Convert x86 AEAD algorithms over to simd
    - Forbid 2-key 3DES in FIPS mode
    - Add EC-RDSA (GOST 34.10) algorithm

    Drivers:
    - Set output IV with ctr-aes in crypto4xx
    - Set output IV in rockchip
    - Fix potential length overflow with hashing in sun4i-ss
    - Fix computation error with ctr in vmx
    - Add SM4 protected keys support in ccree
    - Remove long-broken mxc-scc driver
    - Add rfc4106(gcm(aes)) cipher support in cavium/nitrox"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (179 commits)
    crypto: ccree - use a proper le32 type for le32 val
    crypto: ccree - remove set but not used variable 'du_size'
    crypto: ccree - Make cc_sec_disable static
    crypto: ccree - fix spelling mistake "protedcted" -> "protected"
    crypto: caam/qi2 - generate hash keys in-place
    crypto: caam/qi2 - fix DMA mapping of stack memory
    crypto: caam/qi2 - fix zero-length buffer DMA mapping
    crypto: stm32/cryp - update to return iv_out
    crypto: stm32/cryp - remove request mutex protection
    crypto: stm32/cryp - add weak key check for DES
    crypto: atmel - remove set but not used variable 'alg_name'
    crypto: picoxcell - Use dev_get_drvdata()
    crypto: crypto4xx - get rid of redundant using_sd variable
    crypto: crypto4xx - use sync skcipher for fallback
    crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues
    crypto: crypto4xx - fix ctr-aes missing output IV
    crypto: ecrdsa - select ASN1 and OID_REGISTRY for EC-RDSA
    crypto: ux500 - use ccflags-y instead of CFLAGS_.o
    crypto: ccree - handle tee fips error during power management resume
    crypto: ccree - add function to handle cryptocell tee fips error
    ...

    Linus Torvalds
     

18 Apr, 2019

2 commits

  • Use subsys_initcall for registration of all templates and generic
    algorithm implementations, rather than module_init. Then change
    cryptomgr to use arch_initcall, to place it before the subsys_initcalls.

    This is needed so that when both a generic and optimized implementation
    of an algorithm are built into the kernel (not loadable modules), the
    generic implementation is registered before the optimized one.
    Otherwise, the self-tests for the optimized implementation are unable to
    allocate the generic implementation for the new comparison fuzz tests.

    Note that on arm, a side effect of this change is that self-tests for
    generic implementations may run before the unaligned access handler has
    been installed. So, unaligned accesses will crash the kernel. This is
    arguably a good thing as it makes it easier to detect that type of bug.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • When we perform a walk in the completion function, we need to ensure
    that it is atomic.

    Reported-by: syzbot+6f72c20560060c98b566@syzkaller.appspotmail.com
    Fixes: 78105c7e769b ("crypto: xts - Drop use of auxiliary buffer")
    Cc:
    Signed-off-by: Herbert Xu
    Acked-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Herbert Xu
     

21 Sep, 2018

1 commit

  • Since commit acb9b159c784 ("crypto: gf128mul - define gf128mul_x_* in
    gf128mul.h"), the gf128mul_x_*() functions are very fast and therefore
    caching the computed XTS tweaks has only negligible advantage over
    computing them twice.

    In fact, since the current caching implementation limits the size of
    the calls to the child ecb(...) algorithm to PAGE_SIZE (usually 4096 B),
    it is often actually slower than the simple recomputing implementation.

    This patch simplifies the XTS template to recompute the XTS tweaks from
    scratch in the second pass and thus also removes the need to allocate a
    dynamic buffer using kmalloc().

    As discussed at [1], the use of kmalloc causes deadlocks with dm-crypt.

    PERFORMANCE RESULTS
    I measured time to encrypt/decrypt a memory buffer of varying sizes with
    xts(ecb-aes-aesni) using a tool I wrote ([2]) and the results suggest
    that after this patch the performance is either better or comparable for
    both small and large buffers. Note that there is a lot of noise in the
    measurements, but the overall difference is easy to see.

    Old code:
    ALGORITHM KEY (b) DATA (B) TIME ENC (ns) TIME DEC (ns)
    xts(aes) 256 64 331 328
    xts(aes) 384 64 332 333
    xts(aes) 512 64 338 348
    xts(aes) 256 512 889 920
    xts(aes) 384 512 1019 993
    xts(aes) 512 512 1032 990
    xts(aes) 256 4096 2152 2292
    xts(aes) 384 4096 2453 2597
    xts(aes) 512 4096 3041 2641
    xts(aes) 256 16384 9443 8027
    xts(aes) 384 16384 8536 8925
    xts(aes) 512 16384 9232 9417
    xts(aes) 256 32768 16383 14897
    xts(aes) 384 32768 17527 16102
    xts(aes) 512 32768 18483 17322

    New code:
    ALGORITHM KEY (b) DATA (B) TIME ENC (ns) TIME DEC (ns)
    xts(aes) 256 64 328 324
    xts(aes) 384 64 324 319
    xts(aes) 512 64 320 322
    xts(aes) 256 512 476 473
    xts(aes) 384 512 509 492
    xts(aes) 512 512 531 514
    xts(aes) 256 4096 2132 1829
    xts(aes) 384 4096 2357 2055
    xts(aes) 512 4096 2178 2027
    xts(aes) 256 16384 6920 6983
    xts(aes) 384 16384 8597 7505
    xts(aes) 512 16384 7841 8164
    xts(aes) 256 32768 13468 12307
    xts(aes) 384 32768 14808 13402
    xts(aes) 512 32768 15753 14636

    [1] https://lkml.org/lkml/2018/8/23/1315
    [2] https://gitlab.com/omos/linux-crypto-bench

    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Herbert Xu

    Ondrej Mosnacek
     

03 Aug, 2018

1 commit


03 Mar, 2018

1 commit


15 Nov, 2017

1 commit

  • Pull crypto updates from Herbert Xu:
    "Here is the crypto update for 4.15:

    API:

    - Disambiguate EBUSY when queueing crypto request by adding ENOSPC.
    This change touches code outside the crypto API.
    - Reset settings when empty string is written to rng_current.

    Algorithms:

    - Add OSCCA SM3 secure hash.

    Drivers:

    - Remove old mv_cesa driver (replaced by marvell/cesa).
    - Enable rfc3686/ecb/cfb/ofb AES in crypto4xx.
    - Add ccm/gcm AES in crypto4xx.
    - Add support for BCM7278 in iproc-rng200.
    - Add hash support on Exynos in s5p-sss.
    - Fix fallback-induced error in vmx.
    - Fix output IV in atmel-aes.
    - Fix empty GCM hash in mediatek.

    Others:

    - Fix DoS potential in lib/mpi.
    - Fix potential out-of-order issues with padata"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (162 commits)
    lib/mpi: call cond_resched() from mpi_powm() loop
    crypto: stm32/hash - Fix return issue on update
    crypto: dh - Remove pointless checks for NULL 'p' and 'g'
    crypto: qat - Clean up error handling in qat_dh_set_secret()
    crypto: dh - Don't permit 'key' or 'g' size longer than 'p'
    crypto: dh - Don't permit 'p' to be 0
    crypto: dh - Fix double free of ctx->p
    hwrng: iproc-rng200 - Add support for BCM7278
    dt-bindings: rng: Document BCM7278 RNG200 compatible
    crypto: chcr - Replace _manual_ swap with swap macro
    crypto: marvell - Add a NULL entry at the end of mv_cesa_plat_id_table[]
    hwrng: virtio - Virtio RNG devices need to be re-registered after suspend/resume
    crypto: atmel - remove empty functions
    crypto: ecdh - remove empty exit()
    MAINTAINERS: update maintainer for qat
    crypto: caam - remove unused param of ctx_map_to_sec4_sg()
    crypto: caam - remove unneeded edesc zeroization
    crypto: atmel-aes - Reset the controller before each use
    crypto: atmel-aes - properly set IV after {en,de}crypt
    hwrng: core - Reset user selected rng by writing "" to rng_current
    ...

    Linus Torvalds
     

03 Nov, 2017

1 commit


07 Oct, 2017

1 commit


03 May, 2017

1 commit

  • Pull crypto updates from Herbert Xu:
    "Here is the crypto update for 4.12:

    API:
    - Add batch registration for acomp/scomp
    - Change acomp testing to non-unique compressed result
    - Extend algorithm name limit to 128 bytes
    - Require setkey before accept(2) in algif_aead

    Algorithms:
    - Add support for deflate rfc1950 (zlib)

    Drivers:
    - Add accelerated crct10dif for powerpc
    - Add crc32 in stm32
    - Add sha384/sha512 in ccp
    - Add 3des/gcm(aes) for v5 devices in ccp
    - Add Queue Interface (QI) backend support in caam
    - Add new Exynos RNG driver
    - Add ThunderX ZIP driver
    - Add driver for hardware random generator on MT7623 SoC"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (101 commits)
    crypto: stm32 - Fix OF module alias information
    crypto: algif_aead - Require setkey before accept(2)
    crypto: scomp - add support for deflate rfc1950 (zlib)
    crypto: scomp - allow registration of multiple scomps
    crypto: ccp - Change ISR handler method for a v5 CCP
    crypto: ccp - Change ISR handler method for a v3 CCP
    crypto: crypto4xx - rename ce_ring_contol to ce_ring_control
    crypto: testmgr - Allow ecb(cipher_null) in FIPS mode
    Revert "crypto: arm64/sha - Add constant operand modifier to ASM_EXPORT"
    crypto: ccp - Disable interrupts early on unload
    crypto: ccp - Use only the relevant interrupt bits
    hwrng: mtk - Add driver for hardware random generator on MT7623 SoC
    dt-bindings: hwrng: Add Mediatek hardware random generator bindings
    crypto: crct10dif-vpmsum - Fix missing preempt_disable()
    crypto: testmgr - replace compression known answer test
    crypto: acomp - allow registration of multiple acomps
    hwrng: n2 - Use devm_kcalloc() in n2rng_probe()
    crypto: chcr - Fix error handling related to 'chcr_alloc_shash'
    padata: get_next is never NULL
    crypto: exynos - Add new Exynos RNG driver
    ...

    Linus Torvalds
     

10 Apr, 2017

1 commit

  • When we get an EINPROGRESS completion in xts, we will end up marking
    the request as done and freeing it. This then blows up when the
    request is really completed as we've already freed the memory.

    Fixes: f1c131b45410 ("crypto: xts - Convert to skcipher")
    Cc:
    Reported-by: Nathan Royce
    Reported-by: Krzysztof Kozlowski
    Signed-off-by: Herbert Xu
    Tested-by: Krzysztof Kozlowski

    Herbert Xu
     

05 Apr, 2017

1 commit

  • Currently, gf128mul_x_ble works with pointers to be128, even though it
    actually interprets the words as little-endian. Consequently, it uses
    cpu_to_le64/le64_to_cpu on fields of type __be64, which is incorrect.

    This patch fixes that by changing the function to accept pointers to
    le128 and updating all users accordingly.

    Signed-off-by: Ondrej Mosnacek
    Reviewd-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Ondrej Mosnáček
     

24 Mar, 2017

1 commit

  • In the generic XTS and LRW algorithms, for input data > 128 bytes, a
    temporary buffer is allocated to hold the values to be XOR'ed with the
    data before and after encryption or decryption. If the allocation
    fails, the fixed-size buffer embedded in the request buffer is meant to
    be used as a fallback --- resulting in more calls to the ECB algorithm,
    but still producing the correct result. However, we weren't correctly
    limiting subreq->cryptlen in this case, resulting in pre_crypt()
    overrunning the embedded buffer. Fix this by setting subreq->cryptlen
    correctly.

    Fixes: f1c131b45410 ("crypto: xts - Convert to skcipher")
    Fixes: 700cb3f5fe75 ("crypto: lrw - Convert to skcipher")
    Cc: stable@vger.kernel.org # v4.10+
    Reported-by: Dmitry Vyukov
    Signed-off-by: Eric Biggers
    Acked-by: David S. Miller
    Signed-off-by: Herbert Xu

    Eric Biggers
     

27 Feb, 2017

1 commit

  • When we're used as a fallback algorithm, we should propagate
    the NEED_FALLBACK bit when searching for the underlying ECB mode.

    This just happens to fix a hang too because otherwise the search
    may end up loading the same module that triggered this XTS creation.

    Cc: stable@vger.kernel.org #4.10
    Fixes: f1c131b45410 ("crypto: xts - Convert to skcipher")
    Reported-by: Harald Freudenberger
    Signed-off-by: Herbert Xu

    Herbert Xu
     

28 Nov, 2016

1 commit

  • This patch converts xts over to the skcipher interface. It also
    optimises the implementation to be based on ECB instead of the
    underlying cipher. For compatibility the existing naming scheme
    of xts(aes) is maintained as opposed to the more obvious one of
    xts(ecb(aes)).

    Signed-off-by: Herbert Xu

    Herbert Xu
     

16 Aug, 2016

1 commit


17 Feb, 2016

1 commit

  • 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: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

26 Nov, 2014

1 commit

  • This adds the module loading prefix "crypto-" to the template lookup
    as well.

    For example, attempting to load 'vfat(blowfish)' via AF_ALG now correctly
    includes the "crypto-" prefix at every level, correctly rejecting "vfat":

    net-pf-38
    algif-hash
    crypto-vfat(blowfish)
    crypto-vfat(blowfish)-all
    crypto-vfat

    Reported-by: Mathias Krause
    Signed-off-by: Kees Cook
    Acked-by: Mathias Krause
    Signed-off-by: Herbert Xu

    Kees Cook
     

09 Nov, 2011

2 commits


31 Mar, 2011

1 commit


26 May, 2010

1 commit

  • Use ERR_CAST(x) rather than ERR_PTR(PTR_ERR(x)). The former makes more
    clear what is the purpose of the operation, which otherwise looks like a
    no-op.

    The semantic patch that makes this change is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    type T;
    T x;
    identifier f;
    @@

    T f (...) { }

    @@
    expression x;
    @@

    - ERR_PTR(PTR_ERR(x))
    + ERR_CAST(x)
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Herbert Xu

    Julia Lawall
     

06 Mar, 2008

1 commit

  • The XTS blockmode uses a copy of the IV which is saved on the stack
    and may or may not be properly aligned. If it is not, it will break
    hardware cipher like the geode or padlock.
    This patch encrypts the IV in place so we don't have to worry about
    alignment.

    Signed-off-by: Sebastian Siewior
    Tested-by: Stefan Hellermann
    Signed-off-by: Herbert Xu

    Sebastian Siewior
     

11 Oct, 2007

1 commit

  • XTS currently considered to be the successor of the LRW mode by the IEEE1619
    workgroup. LRW was discarded, because it was not secure if the encyption key
    itself is encrypted with LRW.

    XTS does not have this problem. The implementation is pretty straightforward,
    a new function was added to gf128mul to handle GF(128) elements in ble format.
    Four testvectors from the specification
    http://grouper.ieee.org/groups/1619/email/pdf00086.pdf
    were added, and they verify on my system.

    Signed-off-by: Rik Snel
    Signed-off-by: Herbert Xu

    Rik Snel