summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:56:38 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commit51f5a84d2999239d305de3404e804273984d01e0 (patch)
treee2a0e5e0455654cb93f3ac597a0ba4db4ace7493
parentcfdfa8c889b944322f1af84f7447041fd44f7e5f (diff)
downloadcryptodev-linux-51f5a84d2999239d305de3404e804273984d01e0.tar.gz
cryptodev-linux-51f5a84d2999239d305de3404e804273984d01e0.tar.xz
cryptodev-linux-51f5a84d2999239d305de3404e804273984d01e0.zip
Use algo_properties_st in hash_memory
-rw-r--r--libtomcrypt/hashes/hash_memory.c10
-rw-r--r--libtomcrypt/headers/tomcrypt_hash.h2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c4
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c4
-rw-r--r--ncr-pk.c2
5 files changed, 11 insertions, 11 deletions
diff --git a/libtomcrypt/hashes/hash_memory.c b/libtomcrypt/hashes/hash_memory.c
index 274c208..13e7d36 100644
--- a/libtomcrypt/hashes/hash_memory.c
+++ b/libtomcrypt/hashes/hash_memory.c
@@ -19,14 +19,14 @@
/**
Hash a block of memory and store the digest.
- @param hash The index of the hash you wish to use
+ @param hash The hash you wish to use
@param in The data you wish to hash
@param inlen The length of the data to hash (octets)
@param out [out] Where to store the digest
@param outlen [in/out] Max size and resulting size of the digest
@return CRYPT_OK if successful
*/
-int hash_memory(int hash, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
+int hash_memory(const struct algo_properties_st *hash, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
{
int err;
struct hash_data hdata;
@@ -36,17 +36,17 @@ int hash_memory(int hash, const unsigned char *in, unsigned long inlen, unsigned
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
- if ((err = hash_is_valid(hash)) != CRYPT_OK) {
+ if ((err = hash_is_valid(hash->algo)) != CRYPT_OK) {
return err;
}
- digest_size = _ncr_algo_digest_size(hash);
+ digest_size = _ncr_algo_digest_size(hash->algo);
if (*outlen < digest_size) {
*outlen = digest_size;
return CRYPT_BUFFER_OVERFLOW;
}
- err = cryptodev_hash_init( &hdata, _ncr_algo_to_str(hash), 0, NULL, 0);
+ err = cryptodev_hash_init( &hdata, _ncr_algo_to_str(hash->algo), 0, NULL, 0);
if (err < 0) {
err = CRYPT_INVALID_HASH;
goto LBL_ERR;
diff --git a/libtomcrypt/headers/tomcrypt_hash.h b/libtomcrypt/headers/tomcrypt_hash.h
index 1a2934b..93cc6c7 100644
--- a/libtomcrypt/headers/tomcrypt_hash.h
+++ b/libtomcrypt/headers/tomcrypt_hash.h
@@ -4,7 +4,7 @@ struct algo_properties_st;
int hash_is_valid(int idx);
-int hash_memory(int hash,
+int hash_memory(const struct algo_properties_st *hash,
const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c
index 37ca7a2..4ca4e19 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c
@@ -127,12 +127,12 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
/* compute lhash and store it in seed [reuse temps!] */
x = modulus_len;
if (lparam != NULL) {
- if ((err = hash_memory(hash->algo, lparam, lparamlen, seed, &x)) != CRYPT_OK) {
+ if ((err = hash_memory(hash, lparam, lparamlen, seed, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
} else {
/* can't pass hash_memory a NULL so use DB with zero length */
- if ((err = hash_memory(hash->algo, DB, 0, seed, &x)) != CRYPT_OK) {
+ if ((err = hash_memory(hash, DB, 0, seed, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
}
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
index 4e8d05c..18a464f 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
@@ -77,12 +77,12 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
/* DB == lhash || PS || 0x01 || M, PS == k - mlen - 2hlen - 2 zeroes */
x = modulus_len;
if (lparam != NULL) {
- if ((err = hash_memory(hash->algo, lparam, lparamlen, DB, &x)) != CRYPT_OK) {
+ if ((err = hash_memory(hash, lparam, lparamlen, DB, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
} else {
/* can't pass hash_memory a NULL so use DB with zero length */
- if ((err = hash_memory(hash->algo, DB, 0, DB, &x)) != CRYPT_OK) {
+ if ((err = hash_memory(hash, DB, 0, DB, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
}
diff --git a/ncr-pk.c b/ncr-pk.c
index 8386b2b..0837d4c 100644
--- a/ncr-pk.c
+++ b/ncr-pk.c
@@ -111,7 +111,7 @@ static int ncr_pk_make_public_and_id( struct key_item_st * private, struct key_i
}
key_id_size = MAX_KEY_ID_SIZE;
- cret = hash_memory(NCR_ALG_SHA1, tmp, max_size, private->key_id, &key_id_size);
+ cret = hash_memory(_ncr_algo_to_properties(NCR_ALG_SHA1), tmp, max_size, private->key_id, &key_id_size);
if (cret != CRYPT_OK) {
err();
ret = tomerr(cret);