X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt.c;h=5445138d53f6589ebce6645b027531f02b74c860;hp=5c5333a9a15a43d2cecf5d3ed1774141c58b90cf;hb=b3644a3f5de245609dc608a947ed71e2f75b2fd5;hpb=c5e38315901ea63efd169af5d4ba3f3c66db7de9 diff --git a/crypt.c b/crypt.c index 5c5333a9..5445138d 100644 --- a/crypt.c +++ b/crypt.c @@ -147,8 +147,7 @@ static int read_rsa_bignums(const unsigned char *blob, int blen, RSA **result) *result = rsa; return 1; fail: - if (rsa) - RSA_free(rsa); + RSA_free(rsa); return ret; } @@ -283,40 +282,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;