string: Clean up for_each_line() and related functions.
[paraslash.git] / gcrypt.c
index ea1e7710d01c53f5fd300444970806715ad14241..115529cb6b7f67ecdf60754c3c23f461aea4a6bf 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2011-2013 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -969,3 +969,15 @@ int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf,
        assert(gret == 0);
        return ret;
 }
+
+void sc_crypt(struct stream_cipher *sc, struct iovec *src, struct iovec *dst)
+{
+       gcry_cipher_hd_t handle = sc->handle;
+       gcry_error_t gret;
+
+       /* perform in-place encryption */
+       *dst = *src;
+       gret = gcry_cipher_encrypt(handle, src->iov_base, src->iov_len,
+               NULL, 0);
+       assert(gret == 0);
+}