memcpy(remainder, buf + l1, len - l1);
RC4(&scc->send->key, len - l1, remainder, tmp + l1);
}
- ret = write_nonblock(scc->fd, (char *)tmp, len);
+ ret = xwrite(scc->fd, (char *)tmp, len);
free(tmp);
return ret;
}
return ret;
}
+void sc_crypt(struct stream_cipher *sc, struct iovec *src, struct iovec *dst)
+{
+ RC4_KEY *key = &sc->key;
+
+ *dst = (typeof(*dst)) {
+ /*
+ * Add one for the terminating zero byte. Integer overflow is
+ * no problem here as para_malloc() aborts when given a zero
+ * size argument.
+ */
+ .iov_base = para_malloc(src->iov_len + 1),
+ .iov_len = src->iov_len
+ };
+ RC4(key, src->iov_len, src->iov_base, dst->iov_base);
+ ((char *)dst->iov_base)[dst->iov_len] = '\0';
+}
+
void hash_function(const char *data, unsigned long len, unsigned char *hash)
{
SHA_CTX c;