summaryrefslogtreecommitdiffstats
path: root/crypto/shash.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* crypto: Stop using NLA_PUT*().David S. Miller2012-04-021-3/+3
| | | | | | | These macros contain a hidden goto, and are thus extremely error prone and make code hard to audit. Signed-off-by: David S. Miller <davem@davemloft.net>
* crypto: remove the second argument of k[un]map_atomic()Cong Wang2012-03-201-4/+4
| | | | Signed-off-by: Cong Wang <amwang@redhat.com>
* crypto: algapi - Fix build problem with NET disabledHerbert Xu2011-11-101-0/+7
| | | | | | | | The report functions use NLA_PUT so we need to ensure that NET is enabled. Reported-by: Luis Henriques <henrix@camandro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: Add userspace report for shash type algorithmsSteffen Klassert2011-10-211-0/+21
| | | | | Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: hash - Fix async import on shash algorithmHerbert Xu2010-11-041-1/+7
| | | | | | | | | | The function shash_async_import did not initialise the descriptor correctly prior to calling the underlying shash import function. This patch adds the required initialisation. Reported-by: Miloslav Trmac <mitr@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Remove usage of CRYPTO_MINALIGNHerbert Xu2010-05-191-1/+1
| | | | | | | The macro CRYPTO_MINALIGN is not meant to be used directly. This patch replaces it with crypto_tfm_ctx_alignment. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Test for the algorithms import function before exporting itSteffen Klassert2009-07-241-1/+1
| | | | | | | | | crypto_init_shash_ops_async() tests for setkey and not for import before exporting the algorithms import function to ahash. This patch fixes this. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Require all algorithms to support export/importHerbert Xu2009-07-221-8/+11
| | | | | | | | | | | | | | | | | This patch provides a default export/import function for all shash algorithms. It simply copies the descriptor context as is done by sha1_generic. This in essence means that all existing shash algorithms now support export/import. This is something that will be depended upon in implementations such as hmac. Therefore all new shash and ahash implementations must support export/import. For those that cannot obtain a partial result, padlock-sha's fallback model should be used so that a partial result is always available. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Fix async finup handling of null digestHerbert Xu2009-07-151-2/+7
| | | | | | | When shash_ahash_finup encounters a null request, we end up not calling the underlying final function. This patch fixes that. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: ahash - Add unaligned handling and default operationsHerbert Xu2009-07-151-4/+48
| | | | | | | | | | This patch exports the finup operation where available and adds a default finup operation for ahash. The operations final, finup and digest also will now deal with unaligned result pointers by copying it. Finally export/import operations are will now be exported too. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Fix alignment in unaligned operationsHerbert Xu2009-07-141-2/+4
| | | | | | | | When we encounter an unaligned pointer we are supposed to copy it to a temporary aligned location. However the temporary buffer isn't aligned properly. This patch fixes that. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: hash - Zap unaligned buffersHerbert Xu2009-07-141-3/+11
| | | | | | | | | | | | Some unaligned buffers on the stack weren't zapped properly which may cause secret data to be leaked. This patch fixes them by doing a zero memset. It is also possible for us to place random kernel stack contents in the digest buffer if a digest operation fails. This is fixed by only copying if the operation succeeded. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: ahash - Remove old_ahash_algHerbert Xu2009-07-141-2/+0
| | | | | | | Now that all ahash implementations have been converted to the new ahash type, we can remove old_ahash_alg and its associated support. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: ahash - Convert to new style algorithmsHerbert Xu2009-07-141-6/+2
| | | | | | | | | This patch converts crypto_ahash to the new style. The old ahash algorithm type is retained until the existing ahash implementations are also converted. All ahash users will automatically get the new crypto_ahash type. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: api - Remove frontend argument from extsize/init_tfmHerbert Xu2009-07-141-4/+2
| | | | | | | As the extsize and init_tfm functions belong to the frontend the frontend argument is superfluous. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Export async functionsHerbert Xu2009-07-141-20/+22
| | | | | | | This patch exports the async functions so that they can be reused by cryptd when it switches over to using shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Make descsize a run-time attributeHerbert Xu2009-07-141-11/+28
| | | | | | | This patch changes descsize to a run-time attribute so that implementations can change it in their init functions. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Move null setkey check to registration timeHerbert Xu2009-07-121-3/+8
| | | | | | | This patch moves the run-time null setkey check to shash_prepare_alg just like we did for finup/digest. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Move finup/digest null checks to registration timeHerbert Xu2009-07-111-4/+6
| | | | | | | This patch moves the run-time null finup/digest checks to the shash_prepare_alg function which is run at registration time. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Export/import hash state onlyHerbert Xu2009-07-111-11/+14
| | | | | | | | | | | | | This patch replaces the full descriptor export with an export of the partial hash state. This allows the use of a consistent export format across all implementations of a given algorithm. This is useful because a number of cases require the use of the partial hash state, e.g., PadLock can use the SHA1 hash state to get around the fact that it can only hash contiguous data chunks. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Propagate reinit return valueHerbert Xu2009-07-081-1/+1
| | | | | | | This patch fixes crypto_shash_import to propagate the value returned by reinit. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Use finup in default digestHerbert Xu2009-07-081-2/+1
| | | | | | This patch simplifies the default digest function by using finup. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Add shash_register_instanceHerbert Xu2009-07-081-1/+25
| | | | | | | | This patch adds shash_register_instance so that shash instances can be registered without bypassing the shash checks applied to normal algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Add shash_attr_alg2 helperHerbert Xu2009-07-081-0/+10
| | | | | | | This patch adds the helper shash_attr_alg2 which locates a shash algorithm based on the information in the given attribute. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Add spawn supportHerbert Xu2009-07-081-0/+9
| | | | | | | This patch adds the functions needed to create and use shash spawns, i.e., to use shash algorithms in a template. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Add shash_instanceHerbert Xu2009-07-081-0/+7
| | | | | | | | | This patch adds shash_instance and the associated alloc/free functions. This is meant to be an instance that with a shash algorithm under it. Note that the instance itself doesn't have to be shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Fix unaligned calculation with short lengthYehuda Sadeh2009-03-271-0/+3
| | | | | | | When the total length is shorter than the calculated number of unaligned bytes, the call to shash->update breaks. For example, calling crc32c on unaligned buffer with length of 1 can result in a system crash. Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: api - Fix crypto_alloc_tfm/create_create_tfm return conventionHerbert Xu2009-02-181-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | This is based on a report and patch by Geert Uytterhoeven. The functions crypto_alloc_tfm and create_create_tfm return a pointer that needs to be adjusted by the caller when successful and otherwise an error value. This means that the caller has to check for the error and only perform the adjustment if the pointer returned is valid. Since all callers want to make the adjustment and we know how to adjust it ourselves, it's much easier to just return adjusted pointer directly. The only caveat is that we have to return a void * instead of struct crypto_tfm *. However, this isn't that bad because both of these functions are for internal use only (by types code like shash.c, not even algorithms code). This patch also moves crypto_alloc_tfm into crypto/internal.h (crypto_create_tfm is already there) to reflect this. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Remove superfluous check in init_tfmHerbert Xu2009-02-181-2/+0
| | | | | | | | We're currently checking the frontend type in init_tfm. This is completely pointless because the fact that we're called at all means that the frontend is ours so the type must match as well. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: shash - Fix module refcountAdrian-Ken Rueegsegger2009-02-051-1/+6
| | | | | | | | | Module reference counting for shash is incorrect: when a new shash transformation is created the refcount is not increased as it should. Signed-off-by: Adrian-Ken Rueegsegger <rueegsegger@swiss-it.ch> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: hash - Make setkey optionalHerbert Xu2008-12-251-0/+3
| | | | | | | 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@gondor.apana.org.au>
* crypto: hash - Export shash through hashHerbert Xu2008-12-251-0/+109
| | | | | | | | 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@gondor.apana.org.au>
* crypto: hash - Add import/export interfaceHerbert Xu2008-12-251-0/+14
| | | | | | | | | | | | 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@gondor.apana.org.au>
* crypto: hash - Export shash through ahashHerbert Xu2008-12-251-0/+143
| | | | | | | | This patch allows shash algorithms to be used through the ahash interface. This is required before we can convert digest algorithms over to shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
* crypto: hash - Add shash interfaceHerbert Xu2008-12-251-0/+239
The shash interface replaces the current synchronous hash interface. It improves over hash in two ways. Firstly shash is reentrant, meaning that the same tfm may be used by two threads simultaneously as all hashing state is stored in a local descriptor. The other enhancement is that shash no longer takes scatter list entries. This is because shash is specifically designed for synchronous algorithms and as such scatter lists are unnecessary. All existing hash users will be converted to shash once the algorithms have been completely converted. There is also a new finup function that combines update with final. This will be extended to ahash once the algorithm conversion is done. This is also the first time that an algorithm type has their own registration function. Existing algorithm types will be converted to this way in due course. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>