1. 28 5月, 2020 1 次提交
  2. 15 5月, 2020 1 次提交
  3. 10 5月, 2020 1 次提交
    • L
      gcc-10: avoid shadowing standard library 'free()' in crypto · 1a263ae6
      Linus Torvalds 提交于
      gcc-10 has started warning about conflicting types for a few new
      built-in functions, particularly 'free()'.
      
      This results in warnings like:
      
         crypto/xts.c:325:13: warning: conflicting types for built-in function ‘free’; expected ‘void(void *)’ [-Wbuiltin-declaration-mismatch]
      
      because the crypto layer had its local freeing functions called
      'free()'.
      
      Gcc-10 is in the wrong here, since that function is marked 'static', and
      thus there is no chance of confusion with any standard library function
      namespace.
      
      But the simplest thing to do is to just use a different name here, and
      avoid this gcc mis-feature.
      
      [ Side note: gcc knowing about 'free()' is in itself not the
        mis-feature: the semantics of 'free()' are special enough that a
        compiler can validly do special things when seeing it.
      
        So the mis-feature here is that gcc thinks that 'free()' is some
        restricted name, and you can't shadow it as a local static function.
      
        Making the special 'free()' semantics be a function attribute rather
        than tied to the name would be the much better model ]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1a263ae6
  4. 08 5月, 2020 10 次提交
    • E
      crypto: lib/sha1 - fold linux/cryptohash.h into crypto/sha.h · 228c4f26
      Eric Biggers 提交于
      <linux/cryptohash.h> 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.
      
      Remove this header and fold it into <crypto/sha.h> which already
      contains constants and functions for SHA-1 (along with SHA-2).
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      228c4f26
    • E
      crypto: lib/sha1 - rename "sha" to "sha1" · 6b0b0fa2
      Eric Biggers 提交于
      The library implementation of the SHA-1 compression function is
      confusingly called just "sha_transform()".  Alongside it are some "SHA_"
      constants and "sha_init()".  Presumably these are left over from a time
      when SHA just meant SHA-1.  But now there are also SHA-2 and SHA-3, and
      moreover SHA-1 is now considered insecure and thus shouldn't be used.
      
      Therefore, rename these functions and constants to make it very clear
      that they are for SHA-1.  Also add a comment to make it clear that these
      shouldn't be used.
      
      For the extra-misleadingly named "SHA_MESSAGE_BYTES", rename it to
      SHA1_BLOCK_SIZE and define it to just '64' rather than '(512/8)' so that
      it matches the same definition in <crypto/sha.h>.  This prepares for
      merging <linux/cryptohash.h> into <crypto/sha.h>.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      6b0b0fa2
    • E
      crypto: essiv - use crypto_shash_tfm_digest() · 1306664f
      Eric Biggers 提交于
      Instead of manually allocating a 'struct shash_desc' on the stack and
      calling crypto_shash_digest(), switch to using the new helper function
      crypto_shash_tfm_digest() which does this for us.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      1306664f
    • E
      crypto: hash - introduce crypto_shash_tfm_digest() · 822a98b8
      Eric Biggers 提交于
      Currently the simplest use of the shash API is to use
      crypto_shash_digest() to digest a whole buffer.  However, this still
      requires allocating a hash descriptor (struct shash_desc).  Many users
      don't really want to preallocate one and instead just use a one-off
      descriptor on the stack like the following:
      
      	{
      		SHASH_DESC_ON_STACK(desc, tfm);
      		int err;
      
      		desc->tfm = tfm;
      
      		err = crypto_shash_digest(desc, data, len, out);
      
      		shash_desc_zero(desc);
      	}
      
      Wrap this in a new helper function crypto_shash_tfm_digest() that can be
      used instead of the above.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      822a98b8
    • E
      crypto: lib/sha256 - return void · 13855fd8
      Eric Biggers 提交于
      The SHA-256 / SHA-224 library functions can't fail, so remove the
      useless return value.
      
      Also long as the declarations are being changed anyway, also fix some
      parameter names in the declarations to match the definitions.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      13855fd8
    • A
      crypto - Avoid free() namespace collision · d099ea6e
      Arnd Bergmann 提交于
      gcc-10 complains about using the name of a standard library
      function in the kernel, as we are not building with -ffreestanding:
      
      crypto/xts.c:325:13: error: conflicting types for built-in function 'free'; expected 'void(void *)' [-Werror=builtin-declaration-mismatch]
        325 | static void free(struct skcipher_instance *inst)
            |             ^~~~
      crypto/lrw.c:290:13: error: conflicting types for built-in function 'free'; expected 'void(void *)' [-Werror=builtin-declaration-mismatch]
        290 | static void free(struct skcipher_instance *inst)
            |             ^~~~
      crypto/lrw.c:27:1: note: 'free' is declared in header '<stdlib.h>'
      
      The xts and lrw cipher implementations run into this because they do
      not use the conventional namespaced function names.
      
      It might be better to rename all local functions in those files to
      help with things like 'ctags' and 'grep', but just renaming these two
      avoids the build issue. I picked the more verbose crypto_xts_free()
      and crypto_lrw_free() names for consistency with several other drivers
      that do use namespaced function names.
      
      Fixes: f1c131b4 ("crypto: xts - Convert to skcipher")
      Fixes: 700cb3f5 ("crypto: lrw - Convert to skcipher")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      d099ea6e
    • W
      crypto: drbg - fix error return code in drbg_alloc_state() · e0664ebc
      Wei Yongjun 提交于
      Fix to return negative error code -ENOMEM from the kzalloc error handling
      case instead of 0, as done elsewhere in this function.
      Reported-by: NXiumei Mu <xmu@redhat.com>
      Fixes: db07cd26 ("crypto: drbg - add FIPS 140-2 CTRNG for noise source")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
      Reviewed-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      e0664ebc
    • I
      crypto: engine - support for batch requests · 8d908226
      Iuliana Prodan 提交于
      Added support for batch requests, per crypto engine.
      A new callback is added, do_batch_requests, which executes a
      batch of requests. This has the crypto_engine structure as argument
      (for cases when more than one crypto-engine is used).
      The crypto_engine_alloc_init_and_set function, initializes
      crypto-engine, but also, sets the do_batch_requests callback.
      On crypto_pump_requests, if do_batch_requests callback is
      implemented in a driver, this will be executed. The link between
      the requests will be done in driver, if possible.
      do_batch_requests is available only if the hardware has support
      for multiple request.
      Signed-off-by: NIuliana Prodan <iuliana.prodan@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      8d908226
    • I
      crypto: engine - support for parallel requests based on retry mechanism · 6a89f492
      Iuliana Prodan 提交于
      Added support for executing multiple requests, in parallel,
      for crypto engine based on a retry mechanism.
      If hardware was unable to execute a backlog request, enqueue it
      back in front of crypto-engine queue, to keep the order
      of requests.
      
      A new variable is added, retry_support (this is to keep the
      backward compatibility of crypto-engine) , which keeps track
      whether the hardware has support for retry mechanism and,
      also, if can run multiple requests.
      
      If do_one_request() returns:
      >= 0: hardware executed the request successfully;
      < 0: this is the old error path. If hardware has support for retry
      mechanism, the request is put back in front of crypto-engine queue.
      For backwards compatibility, if the retry support is not available,
      the crypto-engine will work as before.
      If hardware queue is full (-ENOSPC), requeue request regardless
      of MAY_BACKLOG flag.
      If hardware throws any other error code (like -EIO, -EINVAL,
      -ENOMEM, etc.) only MAY_BACKLOG requests are enqueued back into
      crypto-engine's queue, since the others can be dropped.
      
      The new crypto_engine_alloc_init_and_set function, initializes
      crypto-engine, sets the maximum size for crypto-engine software
      queue (not hardcoded anymore) and the retry_support variable
      is set, by default, to false.
      On crypto_pump_requests(), if do_one_request() returns >= 0,
      a new request is send to hardware, until there is no space in
      hardware and do_one_request() returns < 0.
      
      By default, retry_support is false and crypto-engine will
      work as before - will send requests to hardware,
      one-by-one, on crypto_pump_requests(), and complete it, on
      crypto_finalize_request(), and so on.
      
      To support multiple requests, in each driver, retry_support
      must be set on true, and if do_one_request() returns an error
      the request must not be freed, since it will be enqueued back
      into crypto-engine's queue.
      
      When all drivers, that use crypto-engine now, will be updated for
      retry mechanism, the retry_support variable can be removed.
      Signed-off-by: NIuliana Prodan <iuliana.prodan@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      6a89f492
    • I
      crypto: algapi - create function to add request in front of queue · ec6e2bf3
      Iuliana Prodan 提交于
      Add crypto_enqueue_request_head function that enqueues a
      request in front of queue.
      This will be used in crypto-engine, on error path. In case a request
      was not executed by hardware, enqueue it back in front of queue (to
      keep the order of requests).
      Signed-off-by: NIuliana Prodan <iuliana.prodan@nxp.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      ec6e2bf3
  5. 30 4月, 2020 2 次提交
  6. 24 4月, 2020 3 次提交
    • S
      crypto: drbg - always seeded with SP800-90B compliant noise source · 97f2650e
      Stephan Müller 提交于
      As the Jitter RNG provides an SP800-90B compliant noise source, use this
      noise source always for the (re)seeding of the DRBG.
      
      To make sure the DRBG is always properly seeded, the reseed threshold
      is reduced to 1<<20 generate operations.
      
      The Jitter RNG may report health test failures. Such health test
      failures are treated as transient as follows. The DRBG will not reseed
      from the Jitter RNG (but from get_random_bytes) in case of a health
      test failure. Though, it produces the requested random number.
      
      The Jitter RNG has a failure counter where at most 1024 consecutive
      resets due to a health test failure are considered as a transient error.
      If more consecutive resets are required, the Jitter RNG will return
      a permanent error which is returned to the caller by the DRBG. With this
      approach, the worst case reseed threshold is significantly lower than
      mandated by SP800-90A in order to seed with an SP800-90B noise source:
      the DRBG has a reseed threshold of 2^20 * 1024 = 2^30 generate requests.
      
      Yet, in case of a transient Jitter RNG health test failure, the DRBG is
      seeded with the data obtained from get_random_bytes.
      
      However, if the Jitter RNG fails during the initial seeding operation
      even due to a health test error, the DRBG will send an error to the
      caller because at that time, the DRBG has received no seed that is
      SP800-90B compliant.
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      97f2650e
    • S
      crypto: jitter - SP800-90B compliance · 764428fe
      Stephan Müller 提交于
      SP800-90B specifies various requirements for the noise source(s) that
      may seed any DRNG including SP800-90A DRBGs. In November 2020,
      SP800-90B will be mandated for all noise sources that provide entropy
      to DRBGs as part of a FIPS 140-[2|3] validation or other evaluation
      types. Without SP800-90B compliance, a noise source is defined to always
      deliver zero bits of entropy.
      
      This patch ports the SP800-90B compliance from the user space Jitter RNG
      version 2.2.0.
      
      The following changes are applied:
      
      - addition of (an enhanced version of) the repetitive count test (RCT)
        from SP800-90B section 4.4.1 - the enhancement is due to the fact of
        using the stuck test as input to the RCT.
      
      - addition of the adaptive proportion test (APT) from SP800-90B section
        4.4.2
      
      - update of the power-on self test to perform a test measurement of 1024
        noise samples compliant to SP800-90B section 4.3
      
      - remove of the continuous random number generator test which is
        replaced by APT and RCT
      
      Health test failures due to the SP800-90B operation are only enforced in
      FIPS mode. If a runtime health test failure is detected, the Jitter RNG
      is reset. If more than 1024 resets in a row are performed, a permanent
      error is returned to the caller.
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      764428fe
    • C
      crypto: algif_rng - remove redundant assignment to variable err · 63e05f32
      Colin Ian King 提交于
      The variable err is being initialized with a value that is never read
      and it is being updated later with a new value.  The initialization is
      redundant and can be removed.
      
      Addresses-Coverity: ("Unused value")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      63e05f32
  7. 16 4月, 2020 3 次提交
  8. 08 4月, 2020 2 次提交
  9. 30 3月, 2020 1 次提交
  10. 12 3月, 2020 2 次提交
  11. 06 3月, 2020 12 次提交
  12. 28 2月, 2020 1 次提交
  13. 18 2月, 2020 1 次提交