08 May, 2020

1 commit

  • sounds very generic and important, like it's the
    header to include if you're doing cryptographic hashing in the kernel.
    But actually it only includes the library implementation of the SHA-1
    compression function (not even the full SHA-1). This should basically
    never be used anymore; SHA-1 is no longer considered secure, and there
    are much better ways to do cryptographic hashing in the kernel.

    Most files that include this header don't actually need it. So in
    preparation for removing it, remove all these unneeded includes of it.

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

    Eric Biggers
     

22 Jan, 2020

1 commit

  • These drivers no longer need it as they are only probed via DT.
    crypto_platform_data was allocated but unused, so remove it.
    This is a follow up for:
    commit 45a536e3a7e0 ("crypto: atmel-tdes - Retire dma_request_slave_channel_compat()")
    commit db28512f48e2 ("crypto: atmel-sha - Retire dma_request_slave_channel_compat()")
    commit 62f72cbdcf02 ("crypto: atmel-aes - Retire dma_request_slave_channel_compat()")

    Signed-off-by: Tudor Ambarus
    Signed-off-by: Herbert Xu

    Tudor Ambarus
     

09 Jan, 2020

2 commits

  • The CRYPTO_TFM_RES_* flags were apparently meant as a way to make the
    ->setkey() functions provide more information about errors. But these
    flags weren't actually being used or tested, and in many cases they
    weren't being set correctly anyway. So they've now been removed.

    Also, if someone ever actually needs to start better distinguishing
    ->setkey() errors (which is somewhat unlikely, as this has been unneeded
    for a long time), we'd be much better off just defining different return
    values, like -EINVAL if the key is invalid for the algorithm vs.
    -EKEYREJECTED if the key was rejected by a policy like "no weak keys".
    That would be much simpler, less error-prone, and easier to test.

    So just remove CRYPTO_TFM_RES_MASK and all the unneeded logic that
    propagates these flags around.

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

    Eric Biggers
     
  • HMAC keys can be of any length, and atmel_sha_hmac_key_set() can only
    fail due to -ENOMEM. But atmel_sha_hmac_setkey() incorrectly treated
    any error as a "bad key length" error. Fix it to correctly propagate
    the -ENOMEM error code and not set any tfm result flags.

    Fixes: 81d8750b2b59 ("crypto: atmel-sha - add support to hmac(shaX)")
    Cc: Nicolas Ferre
    Cc: Alexandre Belloni
    Cc: Ludovic Desroches
    Signed-off-by: Eric Biggers
    Reviewed-by: Tudor Ambarus
    Signed-off-by: Herbert Xu

    Eric Biggers
     

20 Dec, 2019

4 commits


11 Dec, 2019

8 commits


08 Nov, 2019

2 commits


09 Aug, 2019

1 commit

  • We don't need dev_err() messages when platform_get_irq() fails now that
    platform_get_irq() prints an error message itself when something goes
    wrong. Let's remove these prints with a simple semantic patch.

    //
    @@
    expression ret;
    struct platform_device *E;
    @@

    ret =
    (
    platform_get_irq(E, ...)
    |
    platform_get_irq_byname(E, ...)
    );

    if ( \( ret < 0 \| ret

    While we're here, remove braces on if statements that only have one
    statement (manually).

    Cc: Greg Kroah-Hartman
    Cc: Herbert Xu
    Cc: "David S. Miller"
    Cc:
    Signed-off-by: Stephen Boyd
    Signed-off-by: Herbert Xu

    Stephen Boyd
     

04 Sep, 2018

1 commit


09 Jul, 2018

1 commit

  • Some crypto API users allocating a tfm with crypto_alloc_$FOO() are also
    specifying the type flags for $FOO, e.g. crypto_alloc_shash() with
    CRYPTO_ALG_TYPE_SHASH. But, that's redundant since the crypto API will
    override any specified type flag/mask with the correct ones.

    So, remove the unneeded flags.

    This patch shouldn't change any actual behavior.

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

    Eric Biggers
     

22 Feb, 2018

1 commit


03 Nov, 2017

2 commits


03 Aug, 2017

1 commit

  • Remove unnecessary static on local variable sha_dd. Such variable
    is initialized before being used, on every execution path throughout
    the function. The static has no benefit and, removing it reduces the
    object file size.

    This issue was detected using Coccinelle and the following semantic patch:
    https://github.com/GustavoARSilva/coccinelle/blob/master/static/static_unused.cocci

    In the following log you can see a significant difference in the object
    file size. This log is the output of the size command, before and after
    the code change:

    before:
    text data bss dec hex filename
    30005 10264 128 40397 9dcd drivers/crypto/atmel-sha.o

    after:
    text data bss dec hex filename
    29934 10208 64 40206 9d0e drivers/crypto/atmel-sha.o

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Herbert Xu

    Gustavo A. R. Silva
     

12 Jul, 2017

1 commit


15 Feb, 2017

2 commits

  • This patch clarifies and fixes how errors should be handled by
    atmel_sha_start().

    For update operations, the previous code wrongly assumed that
    (err != -EINPROGRESS) implies (err == 0). It's wrong because that doesn't
    take the error cases (err < 0) into account.

    This patch also adds many comments to detail all the possible returned
    values and what should be done in each case.

    Especially, when an error occurs, since atmel_sha_complete() has already
    been called, hence releasing the hardware, atmel_sha_start() must not call
    atmel_sha_finish_req() later otherwise atmel_sha_complete() would be
    called a second time.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch fixes a previous patch: "crypto: atmel-sha - update request
    queue management to make it more generic".

    Indeed the patch above should have replaced the "return -EINVAL;" lines by
    "return atmel_sha_complete(dd, -EINVAL);" but instead replaced them by a
    simple call of "atmel_sha_complete(dd, -EINVAL);".
    Hence all "return" instructions were missing.

    Reported-by: Dan Carpenter
    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     

11 Feb, 2017

1 commit

  • When we enable COMPILE_TEST building for the Atmel sha and tdes implementations,
    we run into a couple of warnings about incorrect format strings, e.g.

    In file included from include/linux/platform_device.h:14:0,
    from drivers/crypto/atmel-sha.c:24:
    drivers/crypto/atmel-sha.c: In function 'atmel_sha_xmit_cpu':
    drivers/crypto/atmel-sha.c:571:19: error: format '%d' expects argument of type 'int', but argument 6 has type 'size_t {aka long unsigned int}' [-Werror=format=]
    In file included from include/linux/printk.h:6:0,
    from include/linux/kernel.h:13,
    from drivers/crypto/atmel-tdes.c:17:
    drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_crypt_dma_stop':
    include/linux/kern_levels.h:4:18: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'size_t {aka long unsigned int}' [-Werror=format=]

    These are all fixed by using the "%z" modifier for size_t data.

    There are also a few uses of min()/max() with incompatible types:

    drivers/crypto/atmel-tdes.c: In function 'atmel_tdes_crypt_start':
    drivers/crypto/atmel-tdes.c:528:181: error: comparison of distinct pointer types lacks a cast [-Werror]

    Where possible, we should use consistent types here, otherwise we can use
    min_t()/max_t() to get well-defined behavior without a warning.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Herbert Xu

    Arnd Bergmann
     

03 Feb, 2017

10 commits

  • When VERBOSE_DEBUG is defined and SHA_FLAGS_DUMP_REG flag is set in
    dd->flags, this patch prints the register names and values when performing
    IO accesses.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patchs allows to combine the AES and SHA hardware accelerators on
    some Atmel SoCs. Doing so, AES blocks are only written to/read from the
    AES hardware. Those blocks are also transferred from the AES to the SHA
    accelerator internally, without additionnal accesses to the system busses.

    Hence, the AES and SHA accelerators work in parallel to process all the
    data blocks, instead of serializing the process by (de)crypting those
    blocks first then authenticating them after like the generic
    crypto/authenc.c driver does.

    Of course, both the AES and SHA hardware accelerators need to be available
    before we can start to process the data blocks. Hence we use their crypto
    request queue to synchronize both drivers.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch adds support to the hmac(shaX) algorithms.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch adds a simple function to perform data transfer with the DMA
    controller.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch adds a simple function to perform data transfer with PIO, hence
    handled by the CPU.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch simply defines a helper function to test the 'Data Ready' flag
    of the Status Register. It also gives a chance for the crypto request to
    be processed synchronously if this 'Data Ready' flag is already set when
    polling the Status Register. Indeed, running synchronously avoid the
    latency of the 'Data Ready' interrupt.

    When the 'Data Ready' flag has not been set yet, we enable the associated
    interrupt and resume processing the crypto request asynchronously from the
    'done' task just as before.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch modifies the SHA_FLAGS_SHA* flags: those algo flags are now
    organized as values of a single bitfield instead of individual bits.
    This allows to reduce the number of bits needed to encode all possible
    values. Also the new values match the SHA_MR_ALGO_SHA* values hence
    the algorithm bitfield of the SHA_MR register could simply be set with:

    mr = (mr & ~SHA_FLAGS_ALGO_MASK) | (ctx->flags & SHA_FLAGS_ALGO_MASK)

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch is a transitional patch. It updates atmel_sha_done_task() to
    make it more generic. Indeed, it adds a new .resume() member in the
    atmel_sha_dev structure. This hook is called from atmel_sha_done_task()
    to resume processing an asynchronous request.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This patch is a transitional patch. It splits the atmel_sha_handle_queue()
    function. Now atmel_sha_handle_queue() only manages the request queue and
    calls a new .start() hook from the atmel_sha_ctx structure.
    This hook allows to implement different kind of requests still handled by
    a single queue.

    Also when the req parameter of atmel_sha_handle_queue() refers to the very
    same request as the one returned by crypto_dequeue_request(), the queue
    management now gives a chance to this crypto request to be handled
    synchronously, hence reducing latencies. The .start() hook returns 0 if
    the crypto request was handled synchronously and -EINPROGRESS if the
    crypto request still need to be handled asynchronously.

    Besides, the new .is_async member of the atmel_sha_dev structure helps
    tagging this asynchronous state. Indeed, the req->base.complete() callback
    should not be called if the crypto request is handled synchronously.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     
  • This is a transitional patch: it creates the atmel_sha_find_dev() function,
    which will be used in further patches to share the source code responsible
    for finding a Atmel SHA device.

    Signed-off-by: Cyrille Pitchen
    Signed-off-by: Herbert Xu

    Cyrille Pitchen
     

18 Mar, 2016

1 commit

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

    API:
    - Convert remaining crypto_hash users to shash or ahash, also convert
    blkcipher/ablkcipher users to skcipher.
    - Remove crypto_hash interface.
    - Remove crypto_pcomp interface.
    - Add crypto engine for async cipher drivers.
    - Add akcipher documentation.
    - Add skcipher documentation.

    Algorithms:
    - Rename crypto/crc32 to avoid name clash with lib/crc32.
    - Fix bug in keywrap where we zero the wrong pointer.

    Drivers:
    - Support T5/M5, T7/M7 SPARC CPUs in n2 hwrng driver.
    - Add PIC32 hwrng driver.
    - Support BCM6368 in bcm63xx hwrng driver.
    - Pack structs for 32-bit compat users in qat.
    - Use crypto engine in omap-aes.
    - Add support for sama5d2x SoCs in atmel-sha.
    - Make atmel-sha available again.
    - Make sahara hashing available again.
    - Make ccp hashing available again.
    - Make sha1-mb available again.
    - Add support for multiple devices in ccp.
    - Improve DMA performance in caam.
    - Add hashing support to rockchip"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (116 commits)
    crypto: qat - remove redundant arbiter configuration
    crypto: ux500 - fix checks of error code returned by devm_ioremap_resource()
    crypto: atmel - fix checks of error code returned by devm_ioremap_resource()
    crypto: qat - Change the definition of icp_qat_uof_regtype
    hwrng: exynos - use __maybe_unused to hide pm functions
    crypto: ccp - Add abstraction for device-specific calls
    crypto: ccp - CCP versioning support
    crypto: ccp - Support for multiple CCPs
    crypto: ccp - Remove check for x86 family and model
    crypto: ccp - memset request context to zero during import
    lib/mpi: use "static inline" instead of "extern inline"
    lib/mpi: avoid assembler warning
    hwrng: bcm63xx - fix non device tree compatibility
    crypto: testmgr - allow rfc3686 aes-ctr variants in fips mode.
    crypto: qat - The AE id should be less than the maximal AE number
    lib/mpi: Endianness fix
    crypto: rockchip - add hash support for crypto engine in rk3288
    crypto: xts - fix compile errors
    crypto: doc - add skcipher API documentation
    crypto: doc - update AEAD AD handling
    ...

    Linus Torvalds