X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt.c;h=f3bfed3be755ccce6ba9ec1d89c40934babedc35;hp=99804470783c04e3758e8800f87f083c4e54f623;hb=e7593d7c153bfca2131b18621fb24ae18c1c0cb3;hpb=a5ec1a6f44b149c0b018c1da8c1703109c5bdc8c diff --git a/crypt.c b/crypt.c index 99804470..f3bfed3b 100644 --- a/crypt.c +++ b/crypt.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "para.h" #include "error.h" @@ -364,3 +365,22 @@ int sc_recv_buffer(struct stream_cipher_context *scc, char *buf, size_t size) *buf = '\0'; return n; } + +/** + * Compute the hash of the given input data. + * + * \param data Pointer to the data to compute the hash value from. + * \param len The length of \a data in bytes. + * \param hash Result pointer. + * + * \a hash must point to an area at least \p HASH_SIZE bytes large. + * + * \sa sha(3), openssl(1). + * */ +void hash_function(const char *data, unsigned long len, unsigned char *hash) +{ + SHA_CTX c; + SHA1_Init(&c); + SHA1_Update(&c, data, len); + SHA1_Final(hash, &c); +}