summaryrefslogtreecommitdiff
path: root/cipher/cipher.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2013-11-03 22:07:19 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2013-11-06 19:23:00 +0200
commitb8515aa70b00baba3fba8121ed305edcd029c8c7 (patch)
treece33ef0fc6fd7de512a9cf8772f0f57c78597676 /cipher/cipher.c
parenta48d07ccadee4cb8b666a9a4ba2f00129bad5b2f (diff)
downloadlibgcrypt-b8515aa70b00baba3fba8121ed305edcd029c8c7.tar.gz
Modify encrypt/decrypt arguments for in-place
* cipher/cipher.c (gcry_cipher_encrypt, gcry_cipher_decrypt): Modify local arguments if in-place operation. -- Modify encrypt/decrypt argument variables instead of calling subfunction with different arguments. This allows compiler to inline the subfunction for small speedup. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/cipher.c')
-rw-r--r--cipher/cipher.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 73a97b11..705696c2 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -758,9 +758,12 @@ gcry_cipher_encrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
gcry_err_code_t err;
if (!in) /* Caller requested in-place encryption. */
- err = cipher_encrypt (h, out, outsize, out, outsize);
- else
- err = cipher_encrypt (h, out, outsize, in, inlen);
+ {
+ in = out;
+ inlen = outsize;
+ }
+
+ err = cipher_encrypt (h, out, outsize, in, inlen);
/* Failsafe: Make sure that the plaintext will never make it into
OUT if the encryption returned an error. */
@@ -851,9 +854,12 @@ gcry_cipher_decrypt (gcry_cipher_hd_t h, void *out, size_t outsize,
gcry_err_code_t err;
if (!in) /* Caller requested in-place encryption. */
- err = cipher_decrypt (h, out, outsize, out, outsize);
- else
- err = cipher_decrypt (h, out, outsize, in, inlen);
+ {
+ in = out;
+ inlen = outsize;
+ }
+
+ err = cipher_decrypt (h, out, outsize, in, inlen);
return gcry_error (err);
}