summaryrefslogtreecommitdiff
path: root/crypto/cipher.c
AgeCommit message (Collapse)Author
2005-03-22[CRYPTO]: Remap when walk_out crosses page in crypt()Herbert Xu
This is needed so that we can keep the in_place assignment outside the inner loop. Without this in pathalogical situations we can start out having walk_out being different from walk_in, but when walk_out crosses a page it may converge with walk_in. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Split cbc_process into encrypt/decryptHerbert Xu
Rather than taking a branch on the fast path, we might as well split cbc_process into encrypt and decrypt since they don't share anything in common. We can get rid of the cryptfn argument too. I'll do that next. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Kill obsolete iv check in cbc_process()Herbert Xu
Here's some more optimisations plus a bug fix for a pathological case where in_place might not be set correctly which can't happen with any of the current users. Here is the first one: We have long since stopped using a null cit_iv as a means of doing null encryption. In fact it doesn't work here anyway since we need to copy src into dst to achieve null encryption. No user of cbc_encrypt_iv/cbc_decrypt_iv does this either so let's just get rid of this check which is sitting in the fast path. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Optimise kmap calls in crypt()Herbert Xu
Perform kmap once (or twice if the buffer is not aligned correctly) per page in crypt() instead of the current code which does it once per block. Consequently it will yield once per page instead of once per block. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Eliminate most calls to scatterwalk_copychunks from crypt()Herbert Xu
Only call scatterwalk_copychunks when the block straddles a page boundary. This allows crypt() to skip the out-of-line call most of the time. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Split src/dst handling out from crypt()Herbert Xu
Move src/dst handling from crypt() into the helpers prepare_src, prepare_dst, complete_src and complete_dst. complete_src doesn't actually do anything at the moment but is included for completeness. This sets the stage for further optimisations down the track without polluting crypt() itself. These helpers don't belong in scatterwalk.[ch] since they only help the particular way that crypt() is walking the scatter lists. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Handle in_place flag in crypt()Herbert Xu
Move the handling of in_place into crypt() itself. This means that we only need two temporary buffers instead of three. It also allows us to simplify the check in scatterwalk_samebuf. Signed-off-by: David S. Miller <davem@davemloft.net>
2005-03-22[CRYPTO]: Do scatterwalk_whichbuf inline.Herbert Xu
scatterwalk_whichbuf is called once for each block which could be as small as 8/16 bytes. So it makes sense to do that work inline. It's also a bit inflexible since we may want to use the temporary buffer even if the block doesn't cross page boundaries. In particular, we want to do that when the source and destination are the same. So let's replace it with scatterwalk_across_pages. I've also simplified the check in scatterwalk_across_pages. It is sufficient to only check len_this_page. Signed-off-by: David S. Miller <davem@davemloft.net>
2004-07-21[CRYPTO]: Fix stack overrun in crypt().Herbert Xu
The stack allocation in crypt() is bogus as whether tmp_src/tmp_dst is used is determined by factors unrelated to nbytes and src->length/dst->length. Since the condition for whether tmp_src/tmp_dst are used is very complex, let's allocate them always instead of guessing. This fixes a number of weird crashes including those AES crashes that people have been seeing with the 2.4 backport + ipt_conntrack. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: James Morris <jmorris@redhat.com> Signed-off-by: David S. Miller <davem@redhat.com>
2004-05-25[CRYPTO]: Fix two scatterwalk problems.Christophe Saout
- After calling scatterwalk_copychunks walk_in might point to the next page which will break scatterwalk_samebuf (in this case src_p should point to tmp_src anyway and scatterwalk_samembuf returns 0). - scatterwalk_samebuf should also check for equal offsets inside the page (just bad for performance in some cases).
2004-03-01[PATCH] fix in-place de/encryption bug with highmemAndrew Morton
From: Christophe Saout <christophe@saout.de> This patch fixes the bug where in-place encryption was not detected when the same highmem pages is mapped twice to different virtual addresses. This adds a parameter to xxx_process to indicate whether this is an in-place encryption and moves the responsability to the caller using a helper function scatterwalk.h.
2004-03-01[PATCH] move scatterwalk functions to own fileAndrew Morton
From: Christophe Saout <christophe@saout.de> I've cleaned up the latest patches and adjusted the header files. This patch moves the scatterwalk functions from cipher.c to scatterwalk.c and adds a header file.
2003-08-17[IPSEC]: Fix oops using null ciper in CBC mode.Mikael Ylikoski
2003-03-07[CRYPTO]: Eliminate crypto_tfm.crt_ctx, from Adam Richter.James Morris
2003-03-07[CRYPTO]: Add encrypt_iv() and decrypt_iv() methods.James Morris
2003-03-07[CRYPTO]: Move km_types out of header.James Morris
2003-02-02[CRYPTO]: in/out scatterlist support for ciphers.James Morris
- Merge scatterwalk patch from Adam J. Richter <adam@yggdrasil.com> API change: cipher methods now take in/out scatterlists and nbytes params. - Merge gss_krb5_crypto update from Adam J. Richter <adam@yggdrasil.com> - Add KM_SOFTIRQn (instead of KM_CRYPTO_IN etc). - Add asm/kmap_types.h to crypto/internal.h - Update cipher.c credits. - Update cipher.c documentation.
2002-11-25[CRYPTO]: Add twofish algorithm.James Morris
2002-11-14[CRYPTO] kstack cleanup (v0.28)James Morris
2002-11-06[CRYPTO]: Add blowfish algorithm.James Morris
2002-10-29[CRYPTO]: Cleanups based upon suggestions by Jeff Garzik.James Morris
- Changed unsigned to unsigned int in algos. - Consistent use of u32 for flags throughout api. - Use of unsigned int rather than int for counting things which must be positive, also replaced size_ts to keep code simpler and lessen bloat on some archs. - got rid of some unneeded returns. - const correctness.
2002-10-28[CRYPTO]: Clean up header file usage.David S. Miller
2002-10-28[CRYPTO]: Cleanups and more consistency checks.James Morris
- Removed local_bh_disable() from kmap wrapper, not needed now with two atomic kmaps. - Nuked atomic flag, use in_softirq() instead. - Converted crypto_kmap() and crypto_yield() to check in_softirq(). - Check CRYPTO_MAX_CIPHER_BLOCK_SIZE during alg init. - Try to initialize as much at compile time as possible (feedback from Christoph Hellwig). - Clean up list handling a bit (feedback from Christoph Hellwig).
2002-10-27[CRYPTO]: Algorithm lookup API change plus bug fixes.James Morris
- API change: implemented simplest version of algorithm lookup by name (feedback from Rusty Russell and Herbert Valerio Riedel). - Now need to add the following line to to /etc/modules.conf for dynamic module loading: alias des3_ede des
2002-10-26[CRYPTO]: Bug fixes and cleanups.James Morris
- try_inc_mod_count() already does what crypto_alg_get() was trying to do. (feedback from Andrew Morton). - Moved the BUG_ON() in crypto_unregister_alg() further up, no need to bother iterating over the list. - Always use kmap_atomic (feedback from Andrew Morton). Implemented two atomic kmaps, KM_USER for user context and KM_SOFTIRQ for softirq context. - Fixup KM_CRYPTO_ placement so Dave does not go crazy.
2002-10-24[CRYPTO]: Cleanups based upon feedback from Rusty and jgarzikJames Morris
- s/__u/u/ - s/char/u8/ - Fixed bug in cipher.c, page remapped was off by one block
2002-10-23[CRYPTO]: Add initial crypto api subsystem.James Morris