01 Jul, 2016

1 commit


05 May, 2016

1 commit


06 Feb, 2016

1 commit


25 Jan, 2016

1 commit


18 Jan, 2016

1 commit


13 Oct, 2015

1 commit

  • Unlike shash algorithms, ahash drivers must implement export
    and import as their descriptors may contain hardware state and
    cannot be exported as is. Unfortunately some ahash drivers did
    not provide them and end up causing crashes with algif_hash.

    This patch adds a check to prevent these drivers from registering
    ahash algorithms until they are fixed.

    Cc: stable@vger.kernel.org
    Signed-off-by: Russell King
    Signed-off-by: Herbert Xu

    Russell King
     

26 Jan, 2015

1 commit


22 Dec, 2014

1 commit


25 Aug, 2014

1 commit


21 May, 2014

1 commit

  • Although the existing hash walk interface has already been used
    by a number of ahash crypto drivers, it turns out that none of
    them were really asynchronous. They were all essentially polling
    for completion.

    That's why nobody has noticed until now that the walk interface
    couldn't work with a real asynchronous driver since the memory
    is mapped using kmap_atomic.

    As we now have a use-case for a real ahash implementation on x86,
    this patch creates a minimal ahash walk interface. Basically it
    just calls kmap instead of kmap_atomic and does away with the
    crypto_yield call. Real ahash crypto drivers don't need to yield
    since by definition they won't be hogging the CPU.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

21 Mar, 2014

3 commits

  • The ahash_def_finup() can make use of the request save/restore functions,
    thus make it so. This simplifies the code a little and unifies the code
    paths.

    Note that the same remark about free()ing the req->priv applies here, the
    req->priv can only be free()'d after the original request was restored.

    Finally, squash a bug in the invocation of completion in the ASYNC path.
    In both ahash_def_finup_done{1,2}, the function areq->base.complete(X, err);
    was called with X=areq->base.data . This is incorrect , as X=&areq->base
    is the correct value. By analysis of the data structures, we see the areq is
    of type 'struct ahash_request' , areq->base is of type 'struct crypto_async_request'
    and areq->base.completion is of type crypto_completion_t, which is defined in
    include/linux/crypto.h as:

    typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);

    This is one lead that the X should be &areq->base . Next up, we can inspect
    other code which calls the completion callback to give us kind-of statistical
    idea of how this callback is used. We can try:

    $ git grep base\.complete\( drivers/crypto/

    Finally, by inspecting ahash_request_set_callback() implementation defined
    in include/crypto/hash.h , we observe that the .data entry of 'struct
    crypto_async_request' is intended for arbitrary data, not for completion
    argument.

    Signed-off-by: Marek Vasut
    Cc: David S. Miller
    Cc: Fabio Estevam
    Cc: Herbert Xu
    Cc: Shawn Guo
    Cc: Tom Lendacky
    Signed-off-by: Herbert Xu

    Marek Vasut
     
  • The functions to save original request within a newly adjusted request
    and it's counterpart to restore the original request can be re-used by
    more code in the crypto/ahash.c file. Pull these functions out from the
    code so they're available.

    Signed-off-by: Marek Vasut
    Cc: David S. Miller
    Cc: Fabio Estevam
    Cc: Herbert Xu
    Cc: Shawn Guo
    Cc: Tom Lendacky
    Signed-off-by: Herbert Xu

    Marek Vasut
     
  • Add documentation for the pointer voodoo that is happening in crypto/ahash.c
    in ahash_op_unaligned(). This code is quite confusing, so add a beefy chunk
    of documentation.

    Moreover, make sure the mangled request is completely restored after finishing
    this unaligned operation. This means restoring all of .result, .base.data
    and .base.complete .

    Also, remove the crypto_completion_t complete = ... line present in the
    ahash_op_unaligned_done() function. This type actually declares a function
    pointer, which is very confusing.

    Finally, yet very important nonetheless, make sure the req->priv is free()'d
    only after the original request is restored in ahash_op_unaligned_done().
    The req->priv data must not be free()'d before that in ahash_op_unaligned_finish(),
    since we would be accessing previously free()'d data in ahash_op_unaligned_done()
    and cause corruption.

    Signed-off-by: Marek Vasut
    Cc: David S. Miller
    Cc: Fabio Estevam
    Cc: Herbert Xu
    Cc: Shawn Guo
    Cc: Tom Lendacky
    Signed-off-by: Herbert Xu

    Marek Vasut
     

05 Jan, 2014

1 commit

  • When finishing the ahash request, the ahash_op_unaligned_done() will
    call complete() on the request. Yet, this will not call the correct
    complete callback. The correct complete callback was previously stored
    in the requests' private data, as seen in ahash_op_unaligned(). This
    patch restores the correct complete callback and .data field of the
    request before calling complete() on it.

    Signed-off-by: Marek Vasut
    Cc: David S. Miller
    Cc: Fabio Estevam
    Cc: Shawn Guo
    Signed-off-by: Herbert Xu

    Marek Vasut
     

19 Feb, 2013

1 commit

  • Three errors resulting in kernel memory disclosure:

    1/ The structures used for the netlink based crypto algorithm report API
    are located on the stack. As snprintf() does not fill the remainder of
    the buffer with null bytes, those stack bytes will be disclosed to users
    of the API. Switch to strncpy() to fix this.

    2/ crypto_report_one() does not initialize all field of struct
    crypto_user_alg. Fix this to fix the heap info leak.

    3/ For the module name we should copy only as many bytes as
    module_name() returns -- not as much as the destination buffer could
    hold. But the current code does not and therefore copies random data
    from behind the end of the module name, as the module name is always
    shorter than CRYPTO_MAX_ALG_NAME.

    Also switch to use strncpy() to copy the algorithm's name and
    driver_name. They are strings, after all.

    Signed-off-by: Mathias Krause
    Cc: Steffen Klassert
    Signed-off-by: Herbert Xu

    Mathias Krause
     

02 Apr, 2012

1 commit


20 Mar, 2012

1 commit


11 Nov, 2011

1 commit


21 Oct, 2011

1 commit


06 Aug, 2010

1 commit

  • If a scatterwalk chain contains an entry with an unaligned offset then
    hash_walk_next() will cut off the next step at the next alignment point.

    However, if the entry ends before the next alignment point then we a loop,
    which leads to a kernel oops.

    Fix this by checking whether the next aligment point is before the end of the
    current entry.

    Signed-off-by: Szilveszter Ördög
    Acked-by: David S. Miller
    Signed-off-by: Herbert Xu

    Szilveszter Ördög
     

03 Mar, 2010

1 commit

  • The correct way to calculate the start of the aligned part of an
    unaligned buffer is:

    offset = ALIGN(offset, alignmask + 1);

    However, crypto_hash_walk_done() has:

    offset += alignmask - 1;
    offset = ALIGN(offset, alignmask + 1);

    which actually skips a whole block unless offset % (alignmask + 1) == 1.

    This patch fixes the problem.

    Signed-off-by: Szilveszter Ördög
    Signed-off-by: Herbert Xu

    Szilveszter Ördög
     

24 Jul, 2009

1 commit


15 Jul, 2009

2 commits


14 Jul, 2009

5 commits


31 May, 2009

1 commit

  • A quirk that we've always supported is having an sg entry that's
    bigger than a page, or more generally an sg entry that crosses
    page boundaries. Even though it would be better to explicitly have
    to sg entries for this, we need to support it for the existing users,
    in particular, IPsec.

    The new ahash sg walking code did try to handle this, but there was
    a bug where we didn't increment the page so kept on walking on the
    first page over an dover again.

    This patch fixes it.

    Tested-by: Martin Willi
    Signed-off-by: Herbert Xu

    Herbert Xu
     

19 Feb, 2009

1 commit


25 Dec, 2008

3 commits

  • Since most cryptographic hash algorithms have no keys, this patch
    makes the setkey function optional for ahash and shash.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch allows shash algorithms to be used through the old hash
    interface. This is a transitional measure so we can convert the
    underlying algorithms to shash before converting the users across.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • It is often useful to save the partial state of a hash function
    so that it can be used as a base for two or more computations.

    The most prominent example is HMAC where all hashes start from
    a base determined by the key. Having an import/export interface
    means that we only have to compute that base once rather than
    for each message.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

10 Jul, 2008

4 commits

  • This patch adds the walking helpers for hash algorithms akin to
    those of block ciphers. This is a necessary step before we can
    reimplement existing hash algorithms using the new ahash interface.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The base field in ahash_tfm appears to have been cut-n-pasted from
    ablkcipher. It isn't needed here at all. Similarly, the info field
    in ahash_request also appears to have originated from its cipher
    counter-part and is vestigial.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • The digest size check on hash algorithms is incorrect. It's
    perfectly valid for hash algorithms to have a digest length
    longer than their block size. For example crc32c has a block
    size of 1 and a digest size of 4. Rather than having it lie
    about its block size, this patch fixes the checks to do what
    they really should which is to bound the digest size so that
    code placing the digest on the stack continue to work.

    HMAC however still needs to check this as it's only defined
    for such algorithms.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • This patch adds asynchronous hash and digest support.

    Signed-off-by: Loc Ho
    Signed-off-by: Herbert Xu

    Loc Ho