summaryrefslogtreecommitdiffstats
path: root/libtomcrypt/hashes/hash_memory_multi.c
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 11:54:02 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-07-24 11:54:02 +0200
commit951eda087f418c2a5ced189fa9d64c8616634dd0 (patch)
tree72050e803bfce0e4c8454011078f10435bb66f04 /libtomcrypt/hashes/hash_memory_multi.c
parentc13723d4a2a9627f4cd85d47954ab1fd3a115dbd (diff)
downloadcryptodev-linux-951eda087f418c2a5ced189fa9d64c8616634dd0.tar.gz
cryptodev-linux-951eda087f418c2a5ced189fa9d64c8616634dd0.tar.xz
cryptodev-linux-951eda087f418c2a5ced189fa9d64c8616634dd0.zip
Use of algo_properties to avoid linear search on a table for each property.
Diffstat (limited to 'libtomcrypt/hashes/hash_memory_multi.c')
-rw-r--r--libtomcrypt/hashes/hash_memory_multi.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libtomcrypt/hashes/hash_memory_multi.c b/libtomcrypt/hashes/hash_memory_multi.c
index 6a85f65..d772492 100644
--- a/libtomcrypt/hashes/hash_memory_multi.c
+++ b/libtomcrypt/hashes/hash_memory_multi.c
@@ -20,7 +20,7 @@
/**
Hash multiple (non-adjacent) blocks of memory at once.
- @param hash The index of the hash you wish to use
+ @param hash The hash you wish to use
@param out [out] Where to store the digest
@param outlen [in/out] Max size and resulting size of the digest
@param in The data you wish to hash
@@ -28,11 +28,10 @@
@param ... tuples of (data,len) pairs to hash, terminated with a (NULL,x) (x=don't care)
@return CRYPT_OK if successful
*/
-int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
+int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out, unsigned long *outlen,
const unsigned char *in, unsigned long inlen, ...)
{
struct hash_data hdata;
- int digest_size;
int err;
va_list args;
const unsigned char *curptr;
@@ -46,13 +45,12 @@ int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
return err;
}
- digest_size = _ncr_algo_digest_size(hash);
- if (*outlen < digest_size) {
- *outlen = digest_size;
+ if (*outlen < hash->digest_size) {
+ *outlen = hash->digest_size;
return CRYPT_BUFFER_OVERFLOW;
}
- err = cryptodev_hash_init( &hdata, _ncr_algo_to_str(hash), 0, NULL, 0);
+ err = cryptodev_hash_init( &hdata, hash->kstr, 0, NULL, 0);
if (err < 0) {
err = CRYPT_INVALID_HASH;
goto LBL_ERR;
@@ -77,7 +75,7 @@ int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
err = cryptodev_hash_final(&hdata, out);
- *outlen = digest_size;
+ *outlen = hash->digest_size;
LBL_ERR:
cryptodev_hash_deinit(&hdata);
va_end(args);