Mercurial > dropbear
comparison hash_memory.c @ 3:7faae8f46238 libtomcrypt-orig
Branch renaming
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 31 May 2004 18:25:41 +0000 |
parents | |
children | 5d99163f7e32 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 3:7faae8f46238 |
---|---|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
2 * | |
3 * LibTomCrypt is a library that provides various cryptographic | |
4 * algorithms in a highly modular and flexible manner. | |
5 * | |
6 * The library is free for all purposes without any express | |
7 * guarantee it works. | |
8 * | |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | |
10 */ | |
11 #include "mycrypt.h" | |
12 | |
13 int hash_memory(int hash, const unsigned char *data, unsigned long len, unsigned char *dst, unsigned long *outlen) | |
14 { | |
15 hash_state md; | |
16 int err; | |
17 | |
18 _ARGCHK(data != NULL); | |
19 _ARGCHK(dst != NULL); | |
20 _ARGCHK(outlen != NULL); | |
21 | |
22 if ((err = hash_is_valid(hash)) != CRYPT_OK) { | |
23 return err; | |
24 } | |
25 | |
26 if (*outlen < hash_descriptor[hash].hashsize) { | |
27 return CRYPT_BUFFER_OVERFLOW; | |
28 } | |
29 *outlen = hash_descriptor[hash].hashsize; | |
30 | |
31 hash_descriptor[hash].init(&md); | |
32 hash_descriptor[hash].process(&md, data, len); | |
33 hash_descriptor[hash].done(&md, dst); | |
34 return CRYPT_OK; | |
35 } |