X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt.c;h=b754c0919e6fbccca77c0d662bddf59c6351fca6;hp=f33f769f6f035c18946c21fea064b37052802583;hb=2830b9f881898aaec073d5ba19e33482e30190bd;hpb=f0e41e36c3f1a3a5bb6ff66d92d2814391d8f908 diff --git a/crypt.c b/crypt.c index f33f769f..b754c091 100644 --- a/crypt.c +++ b/crypt.c @@ -317,6 +317,23 @@ int sc_recv_bin_buffer(struct stream_cipher_context *scc, char *buf, 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;