From: Andre Noll Date: Mon, 7 Mar 2011 07:07:37 +0000 (+0100) Subject: stream cipher: Allow in-place encryption. X-Git-Tag: v0.4.8~21^2~10 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=e3272a316d113dd9c0c6f01f3087ab14f945e76b stream cipher: Allow in-place encryption. unlike openssl's RC4(), the RC4 implemenation of libgcrypt can encrypt a buffer in-place. For this the "buf" argument of the various send and receive functions must not be const. --- diff --git a/crypt.c b/crypt.c index 7b602d99..2dc15461 100644 --- a/crypt.c +++ b/crypt.c @@ -365,7 +365,7 @@ void sc_free(struct stream_cipher *sc) * * \sa \ref write_all(), RC4(3). */ -int sc_send_bin_buffer(struct stream_cipher_context *scc, const char *buf, +int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, size_t len) { int ret; diff --git a/crypt.h b/crypt.h index d2c2b320..fc41acf3 100644 --- a/crypt.h +++ b/crypt.h @@ -54,9 +54,9 @@ struct stream_cipher_context { }; struct stream_cipher *sc_new(const unsigned char *data, int len); void sc_free(struct stream_cipher *sc); -int sc_send_bin_buffer(struct stream_cipher_context *scc, const char *buf, +int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, size_t len); -int sc_send_buffer(struct stream_cipher_context *scc, const char *buf); +int sc_send_buffer(struct stream_cipher_context *scc, char *buf); __printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc, const char *fmt, ...); int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf, diff --git a/crypt_common.c b/crypt_common.c index 3bd603c0..a2f68268 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -325,7 +325,7 @@ int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size) * * \return The return value of the underyling call to sc_send_bin_buffer(). */ -int sc_send_buffer(struct stream_cipher_context *scc, const char *buf) +int sc_send_buffer(struct stream_cipher_context *scc, char *buf) { return sc_send_bin_buffer(scc, buf, strlen(buf)); }