]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - gcrypt.c
Remove old stream cipher API.
[paraslash.git] / gcrypt.c
index 1e997fb45c0bd6a753a79bfcff1db5ede4546782..a96db362278b1dae70e7aec87a920aac1c402e54 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.
  */
@@ -695,7 +695,6 @@ int get_asymmetric_key(const char *key_file, int private,
        key->num_bytes = ret;
        key->sexp = sexp;
        *result = key;
-       ret = key->num_bytes;
 unmap:
        ret2 = para_munmap(map, map_size);
        if (ret >= 0 && ret2 < 0)
@@ -938,35 +937,14 @@ void sc_free(struct stream_cipher *sc)
        free(sc);
 }
 
-int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t size)
+void sc_crypt(struct stream_cipher *sc, struct iovec *src, struct iovec *dst)
 {
+       gcry_cipher_hd_t handle = sc->handle;
        gcry_error_t gret;
-       int ret;
-       unsigned char *tmp = para_malloc(size);
-
-       assert(size);
-       gret = gcry_cipher_encrypt(scc->send->handle, tmp, size,
-               (unsigned char *)buf, size);
-       assert(gret == 0);
-       ret = xwrite(scc->fd, (char *)tmp, size);
-       free(tmp);
-       return ret;
-}
 
-int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t size)
-{
-       gcry_error_t gret;
-       ssize_t ret = recv(scc->fd, buf, size, 0);
-
-       if (ret < 0)
-               ret = -ERRNO_TO_PARA_ERROR(errno);
-       if (ret <= 0)
-               return ret;
        /* perform in-place encryption */
-       gret = gcry_cipher_encrypt(scc->recv->handle, (unsigned char *)buf, ret,
+       *dst = *src;
+       gret = gcry_cipher_encrypt(handle, src->iov_base, src->iov_len,
                NULL, 0);
        assert(gret == 0);
-       return ret;
 }