- 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);
+ size_t len = src->iov_len, l1, l2;
+ RC4_KEY *key = &sc->key;
+
+ assert(len > 0);
+ assert(len < ((typeof(src->iov_len))-1) / 2);
+ l1 = ROUND_DOWN(len, RC4_ALIGN);
+ l2 = ROUND_UP(len, RC4_ALIGN);
+
+ *dst = (typeof(*dst)) {
+ /* Add one for the terminating zero byte. */
+ .iov_base = para_malloc(l2 + 1),
+ .iov_len = len
+ };
+ RC4(key, l1, src->iov_base, dst->iov_base);