20 Aug, 2020

1 commit

  • The header file algapi.h includes skbuff.h unnecessarily since
    all we need is a forward declaration for struct sk_buff. This
    patch removes that inclusion.

    Unfortunately skbuff.h pulls in a lot of things and drivers over
    the years have come to rely on it so this patch adds a lot of
    missing inclusions that result from this.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

08 Aug, 2020

1 commit

  • As said by Linus:

    A symmetric naming is only helpful if it implies symmetries in use.
    Otherwise it's actively misleading.

    In "kzalloc()", the z is meaningful and an important part of what the
    caller wants.

    In "kzfree()", the z is actively detrimental, because maybe in the
    future we really _might_ want to use that "memfill(0xdeadbeef)" or
    something. The "zero" part of the interface isn't even _relevant_.

    The main reason that kzfree() exists is to clear sensitive information
    that should not be leaked to other future users of the same memory
    objects.

    Rename kzfree() to kfree_sensitive() to follow the example of the recently
    added kvfree_sensitive() and make the intention of the API more explicit.
    In addition, memzero_explicit() is used to clear the memory to make sure
    that it won't get optimized away by the compiler.

    The renaming is done by using the command sequence:

    git grep -w --name-only kzfree |\
    xargs sed -i 's/kzfree/kfree_sensitive/'

    followed by some editing of the kfree_sensitive() kerneldoc and adding
    a kzfree backward compatibility macro in slab.h.

    [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
    [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]

    Suggested-by: Joe Perches
    Signed-off-by: Waiman Long
    Signed-off-by: Andrew Morton
    Acked-by: David Howells
    Acked-by: Michal Hocko
    Acked-by: Johannes Weiner
    Cc: Jarkko Sakkinen
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: Joe Perches
    Cc: Matthew Wilcox
    Cc: David Rientjes
    Cc: Dan Carpenter
    Cc: "Jason A . Donenfeld"
    Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.com
    Signed-off-by: Linus Torvalds

    Waiman Long
     

16 Jul, 2020

1 commit

  • The flag CRYPTO_ALG_ASYNC is "inherited" in the sense that when a
    template is instantiated, the template will have CRYPTO_ALG_ASYNC set if
    any of the algorithms it uses has CRYPTO_ALG_ASYNC set.

    We'd like to add a second flag (CRYPTO_ALG_ALLOCATES_MEMORY) that gets
    "inherited" in the same way. This is difficult because the handling of
    CRYPTO_ALG_ASYNC is hardcoded everywhere. Address this by:

    - Add CRYPTO_ALG_INHERITED_FLAGS, which contains the set of flags that
    have these inheritance semantics.

    - Add crypto_algt_inherited_mask(), for use by template ->create()
    methods. It returns any of these flags that the user asked to be
    unset and thus must be passed in the 'mask' to crypto_grab_*().

    - Also modify crypto_check_attr_type() to handle computing the 'mask'
    so that most templates can just use this.

    - Make crypto_grab_*() propagate these flags to the template instance
    being created so that templates don't have to do this themselves.

    Make crypto/simd.c propagate these flags too, since it "wraps" another
    algorithm, similar to a template.

    Based on a patch by Mikulas Patocka
    (https://lore.kernel.org/r/alpine.LRH.2.02.2006301414580.30526@file01.intranet.prod.int.rdu2.redhat.com).

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

    Eric Biggers
     

06 Mar, 2020

1 commit

  • Simplify the error handling in pkcs1pad_create() by taking advantage of
    crypto_grab_akcipher() now handling an ERR_PTR() name and by taking
    advantage of crypto_drop_akcipher() now accepting (as a no-op) a spawn
    that hasn't been grabbed yet.

    While we're at it, also simplify the way the hash_name optional argument
    is handled. We only need to check whether it's present in one place,
    and we can just assign directly to ctx->digest_info.

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

    Eric Biggers
     

09 Jan, 2020

1 commit

  • Initializing a crypto_akcipher_spawn currently requires:

    1. Set spawn->base.inst to point to the instance.
    2. Call crypto_grab_akcipher().

    But there's no reason for these steps to be separate, and in fact this
    unneeded complication has caused at least one bug, the one fixed by
    commit 6db43410179b ("crypto: adiantum - initialize crypto_spawn::inst")

    So just make crypto_grab_akcipher() take the instance as an argument.

    To keep the function call from getting too unwieldy due to this extra
    argument, also introduce a 'mask' variable into pkcs1pad_create().

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

    Eric Biggers
     

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
     

18 Apr, 2019

2 commits

  • Previous akcipher .verify() just `decrypts' (using RSA encrypt which is
    using public key) signature to uncover message hash, which was then
    compared in upper level public_key_verify_signature() with the expected
    hash value, which itself was never passed into verify().

    This approach was incompatible with EC-DSA family of algorithms,
    because, to verify a signature EC-DSA algorithm also needs a hash value
    as input; then it's used (together with a signature divided into halves
    `r||s') to produce a witness value, which is then compared with `r' to
    determine if the signature is correct. Thus, for EC-DSA, nor
    requirements of .verify() itself, nor its output expectations in
    public_key_verify_signature() wasn't sufficient.

    Make improved .verify() call which gets hash value as input and produce
    complete signature check without any output besides status.

    Now for the top level verification only crypto_akcipher_verify() needs
    to be called and its return value inspected.

    Make sure that `digest' is in kmalloc'd memory (in place of `output`) in
    {public,tpm}_key_verify_signature() as insisted by Herbert Xu, and will
    be changed in the following commit.

    Cc: David Howells
    Cc: keyrings@vger.kernel.org
    Signed-off-by: Vitaly Chikunov
    Reviewed-by: Denis Kenzior
    Signed-off-by: Herbert Xu

    Vitaly Chikunov
     
  • In preparation for new akcipher verify call remove sign/verify callbacks
    from RSA backends and make PKCS1 driver call encrypt/decrypt instead.

    This also complies with the well-known idea that raw RSA should never be
    used for sign/verify. It only should be used with proper padding scheme
    such as PKCS1 driver provides.

    Cc: Giovanni Cabiddu
    Cc: qat-linux@intel.com
    Cc: Tom Lendacky
    Cc: Gary Hook
    Cc: Horia Geantă
    Cc: Aymen Sghaier
    Signed-off-by: Vitaly Chikunov
    Reviewed-by: Horia Geantă
    Acked-by: Gary R Hook
    Signed-off-by: Herbert Xu

    Vitaly Chikunov
     

18 Jan, 2019

1 commit

  • Include internal/rsa.h in rsa-pkcs1pad.c to get the declaration of
    rsa_pkcs1pad_tmpl. This fixes the following sparse warning:

    crypto/rsa-pkcs1pad.c:698:24: warning: symbol 'rsa_pkcs1pad_tmpl' was not declared. Should it be static?

    Cc: Andrzej Zaborowski
    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

26 Oct, 2018

1 commit

  • The original pkcs1pad implementation allowed to pad/unpad raw RSA
    output. However, this has been taken out in commit:
    commit c0d20d22e0ad ("crypto: rsa-pkcs1pad - Require hash to be present")

    This patch restored this ability as it is needed by the asymmetric key
    implementation.

    Signed-off-by: Denis Kenzior
    Signed-off-by: David Howells
    Tested-by: Marcel Holtmann
    Reviewed-by: Marcel Holtmann
    Signed-off-by: James Morris

    Denis Kenzior
     

28 Sep, 2018

1 commit


15 Feb, 2018

1 commit


03 Nov, 2017

1 commit


20 Jun, 2017

1 commit


10 Jun, 2017

1 commit


22 Sep, 2016

1 commit

  • As the software RSA implementation now produces fixed-length
    output, we need to eliminate leading zeros in the calling code
    instead.

    This patch does just that for pkcs1pad decryption while signature
    verification was fixed in an earlier patch.

    Fixes: 9b45b7bba3d2 ("crypto: rsa - Generate fixed-length output")
    Reported-by: Mat Martineau
    Signed-off-by: Herbert Xu

    Herbert Xu
     

19 Jul, 2016

1 commit


03 Jul, 2016

1 commit

  • As the software RSA implementation now produces fixed-length
    output, we need to eliminate leading zeros in the calling code
    instead.

    This patch does just that for pkcs1pad signature verification.

    Fixes: 9b45b7bba3d2 ("crypto: rsa - Generate fixed-length output")
    Reported-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Herbert Xu
     

01 Jul, 2016

5 commits


15 Apr, 2016

1 commit


04 Mar, 2016

1 commit

  • This adds hash param to pkcs1pad.
    The pkcs1pad template can work with or without the hash.
    When hash param is provided then the verify operation will
    also verify the output against the known digest.

    Signed-off-by: Tadeusz Struk
    Signed-off-by: David Howells
    Acked-by: Herbert Xu

    Tadeusz Struk
     

22 Dec, 2015

1 commit


09 Dec, 2015

1 commit

  • This patch adds PKCS#1 v1.5 standard RSA padding as a separate template.
    This way an RSA cipher with padding can be obtained by instantiating
    "pkcs1pad(rsa)". The reason for adding this is that RSA is almost
    never used without this padding (or OAEP) so it will be needed for
    either certificate work in the kernel or the userspace, and I also hear
    that it is likely implemented by hardware RSA in which case hardware
    implementations of the whole of pkcs1pad(rsa) can be provided.

    Signed-off-by: Andrew Zaborowski
    Signed-off-by: Herbert Xu

    Andrzej Zaborowski