]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Remove old stream cipher API.
authorAndre Noll <maan@systemlinux.org>
Tue, 24 Jul 2012 06:38:53 +0000 (08:38 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 3 Apr 2013 22:37:26 +0000 (22:37 +0000)
No users remained after the sideband compatibility code has been
removed.

crypt.c
crypt.h
crypt_common.c
gcrypt.c

diff --git a/crypt.c b/crypt.c
index 5c5333a9a15a43d2cecf5d3ed1774141c58b90cf..b8577dfc5ab164a5f0b382273aab1c8083a05ef1 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -283,40 +283,6 @@ void sc_free(struct stream_cipher *sc)
  */
 #define RC4_ALIGN 8
 
-int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t len)
-{
-       int ret;
-       unsigned char *tmp;
-       static unsigned char remainder[RC4_ALIGN];
-       size_t l1 = ROUND_DOWN(len, RC4_ALIGN), l2 = ROUND_UP(len, RC4_ALIGN);
-
-       assert(len);
-       tmp = para_malloc(l2);
-       RC4(&scc->send->key, l1, (const unsigned char *)buf, tmp);
-       if (len > l1) {
-               memcpy(remainder, buf + l1, len - l1);
-               RC4(&scc->send->key, len - l1, remainder, tmp + l1);
-       }
-       ret = xwrite(scc->fd, (char *)tmp, len);
-       free(tmp);
-       return ret;
-}
-
-int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t size)
-{
-       unsigned char *tmp = para_malloc(ROUND_UP(size, RC4_ALIGN));
-       ssize_t ret = recv(scc->fd, tmp, size, 0);
-
-       if (ret > 0)
-               RC4(&scc->recv->key, ret, tmp, (unsigned char *)buf);
-       else if (ret < 0)
-               ret = -ERRNO_TO_PARA_ERROR(errno);
-       free(tmp);
-       return ret;
-}
-
 void sc_crypt(struct stream_cipher *sc, struct iovec *src, struct iovec *dst)
 {
        size_t len = src->iov_len, l1, l2;
diff --git a/crypt.h b/crypt.h
index 77806af6983895c13f3120f4f65c1c1d46b9b11d..1406197d0c6cd64c14cf1b30d8ef281417903638 100644 (file)
--- a/crypt.h
+++ b/crypt.h
@@ -165,75 +165,9 @@ _static_inline_ void sc_trafo(struct iovec *src, struct iovec *dst,
  */
 void sc_free(struct stream_cipher *sc);
 
-/**
- * Encrypt and send a buffer.
- *
- * \param scc The context.
- * \param buf The buffer to send.
- * \param len The size of \a buf in bytes.
- *
- * \return The return value of the underyling call to write_all().
- *
- * \sa \ref write_all(), RC4(3).
- */
-int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t len);
-
-/**
- * Encrypt and send a \p NULL-terminated buffer.
- *
- * \param scc The context.
- * \param buf The buffer to send.
- *
- * \return The return value of the underyling call to sc_send_bin_buffer().
- */
-int sc_send_buffer(struct stream_cipher_context *scc, char *buf);
-
-/**
- * Format, encrypt and send a buffer.
- *
- * \param scc The context.
- * \param fmt A format string.
- *
- * \return The return value of the underyling call to sc_send_buffer().
- */
-__printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc,
-               const char *fmt, ...);
-
-/**
- * Receive a buffer and decrypt it.
- *
- * \param scc The context.
- * \param buf The buffer to write the decrypted data to.
- * \param size The size of \a buf.
- *
- * \return The number of bytes received on success, negative on errors, zero if
- * the peer has performed an orderly shutdown.
- *
- * \sa recv(2), RC4(3).
- */
-int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t size);
-
-/**
- * Receive a buffer, decrypt it and write terminating NULL byte.
- *
- * \param scc The context.
- * \param buf The buffer to write the decrypted data to.
- * \param size The size of \a buf.
- *
- * Read at most \a size - 1 bytes from file descriptor given by \a scc, decrypt
- * the received data and write a NULL byte at the end of the decrypted data.
- *
- * \return The return value of the underlying call to \ref
- * sc_recv_bin_buffer().
- */
-int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size);
-
 /** Size of the hash value in bytes. */
 #define HASH_SIZE 20
 
-
 /**
  * Compute the hash of the given input data.
  *
index cd9500ab39f3a89cd4ee70da64d0d7e72ff7c84f..6c71d7e3716829d90485894bc261ee867589d7bf 100644 (file)
@@ -321,41 +321,3 @@ int hash_compare(unsigned char *h1, unsigned char *h2)
        }
        return 0;
 }
-
-int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size)
-{
-       int n;
-
-       assert(size);
-       n = sc_recv_bin_buffer(scc, buf, size - 1);
-       if (n >= 0)
-               buf[n] = '\0';
-       else
-               *buf = '\0';
-       return n;
-}
-
-int sc_send_buffer(struct stream_cipher_context *scc, char *buf)
-{
-       size_t len = strlen(buf);
-       int ret = sc_send_bin_buffer(scc, buf, len);
-
-       if (ret < 0 || ret == len)
-               return ret;
-       return -E_SHORT_WRITE;
-}
-
-__printf_2_3 int sc_send_va_buffer(struct stream_cipher_context *scc,
-               const char *fmt, ...)
-{
-       char *msg;
-       int ret;
-       va_list ap;
-
-       va_start(ap, fmt);
-       ret = xvasprintf(&msg, fmt, ap);
-       va_end(ap);
-       ret = sc_send_bin_buffer(scc, msg, ret);
-       free(msg);
-       return ret;
-}
index 115529cb6b7f67ecdf60754c3c23f461aea4a6bf..a96db362278b1dae70e7aec87a920aac1c402e54 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -937,39 +937,6 @@ void sc_free(struct stream_cipher *sc)
        free(sc);
 }
 
-int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf,
-               size_t size)
-{
-       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,
-               NULL, 0);
-       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;