summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:46:15 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commit257c3d8b7cf9a877b05234ff4d9a58a0562ae855 (patch)
tree19b84a02f4fe58ba3294285601f913773dab6d71
parent2b9b8fbdb32eb0636a22c81c1727fbf115a14d69 (diff)
downloadcryptodev-linux-257c3d8b7cf9a877b05234ff4d9a58a0562ae855.tar.gz
cryptodev-linux-257c3d8b7cf9a877b05234ff4d9a58a0562ae855.tar.xz
cryptodev-linux-257c3d8b7cf9a877b05234ff4d9a58a0562ae855.zip
Use algo_properties_st in pkcs_1_pss_decode
-rw-r--r--libtomcrypt/headers/tomcrypt_pkcs.h2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c12
-rw-r--r--libtomcrypt/pk/rsa/rsa_verify_hash.c2
3 files changed, 8 insertions, 8 deletions
diff --git a/libtomcrypt/headers/tomcrypt_pkcs.h b/libtomcrypt/headers/tomcrypt_pkcs.h
index 6dcde5e..142f196 100644
--- a/libtomcrypt/headers/tomcrypt_pkcs.h
+++ b/libtomcrypt/headers/tomcrypt_pkcs.h
@@ -60,7 +60,7 @@ int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
const unsigned char *sig, unsigned long siglen,
- unsigned long saltlen, int hash_idx,
+ unsigned long saltlen, const struct algo_properties_st *hash,
unsigned long modulus_bitlen, int *res);
#endif /* LTC_PKCS_1 */
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c b/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c
index 5a26654..029f654 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c
@@ -25,14 +25,14 @@
@param sig The signature data (encoded data)
@param siglen The length of the signature data (octets)
@param saltlen The length of the salt used (octets)
- @param hash_idx The index of the hash desired
+ @param hash_algo The desired hash
@param modulus_bitlen The bit length of the RSA modulus
@param res [out] The result of the comparison, 1==valid, 0==invalid
@return CRYPT_OK if successful (even if the comparison failed)
*/
int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
const unsigned char *sig, unsigned long siglen,
- unsigned long saltlen, int hash_idx,
+ unsigned long saltlen, const struct algo_properties_st *hash_algo,
unsigned long modulus_bitlen, int *res)
{
unsigned char *DB, *mask, *salt, *hash;
@@ -46,11 +46,11 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
*res = 0;
/* ensure hash is valid */
- if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
+ if ((err = hash_is_valid(hash_algo->algo)) != CRYPT_OK) {
return err;
}
- hLen = _ncr_algo_digest_size(hash_idx);
+ hLen = _ncr_algo_digest_size(hash_algo->algo);
modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0);
/* check sizes */
@@ -102,7 +102,7 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
}
/* generate mask of length modulus_len - hLen - 1 from hash */
- if ((err = pkcs_1_mgf1(hash_idx, hash, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) {
+ if ((err = pkcs_1_mgf1(hash_algo->algo, hash, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) {
goto LBL_ERR;
}
@@ -131,7 +131,7 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
}
/* M = (eight) 0x00 || msghash || salt, mask = H(M) */
- err = hash_memory_multi(hash_idx, mask, &hLen, mask, 8, msghash, (unsigned long)msghashlen, DB+x, (unsigned long)saltlen, NULL, 0);
+ err = hash_memory_multi(hash_algo->algo, mask, &hLen, mask, 8, msghash, (unsigned long)msghashlen, DB+x, (unsigned long)saltlen, NULL, 0);
if (err != CRYPT_OK) {
goto LBL_ERR;
}
diff --git a/libtomcrypt/pk/rsa/rsa_verify_hash.c b/libtomcrypt/pk/rsa/rsa_verify_hash.c
index eff2f3e..4036a09 100644
--- a/libtomcrypt/pk/rsa/rsa_verify_hash.c
+++ b/libtomcrypt/pk/rsa/rsa_verify_hash.c
@@ -93,7 +93,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
if (padding == LTC_LTC_PKCS_1_PSS) {
/* PSS decode and verify it */
- err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_algo->algo, modulus_bitlen, stat);
+ err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_algo, modulus_bitlen, stat);
} else {
/* LTC_PKCS #1 v1.5 decode it */
unsigned char *out;