summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:39:40 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commit1df0eac499355e025d75dd1aa8e033aa5cf7fd70 (patch)
tree9e10049c5b55569aa0cd7c2c2811b3825494c4ca
parent6962f9b991bd1c47d1e501e19875372d0301ca53 (diff)
downloadkernel-crypto-1df0eac499355e025d75dd1aa8e033aa5cf7fd70.tar.gz
kernel-crypto-1df0eac499355e025d75dd1aa8e033aa5cf7fd70.tar.xz
kernel-crypto-1df0eac499355e025d75dd1aa8e033aa5cf7fd70.zip
Use algo_properties_st in pkcs_1_pss_encode
-rw-r--r--libtomcrypt/headers/tomcrypt_pkcs.h2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c12
-rw-r--r--libtomcrypt/pk/rsa/rsa_sign_hash.c2
3 files changed, 8 insertions, 8 deletions
diff --git a/libtomcrypt/headers/tomcrypt_pkcs.h b/libtomcrypt/headers/tomcrypt_pkcs.h
index 9cfa81dac15..4ca2d9d31c1 100644
--- a/libtomcrypt/headers/tomcrypt_pkcs.h
+++ b/libtomcrypt/headers/tomcrypt_pkcs.h
@@ -54,7 +54,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
int *res);
int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
- unsigned long saltlen, int hash_idx,
+ unsigned long saltlen, const struct algo_properties_st *hash,
unsigned long modulus_bitlen,
unsigned char *out, unsigned long *outlen);
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c
index 382820d8bc2..86909325640 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c
@@ -23,14 +23,14 @@
@param msghash The hash to encode
@param msghashlen The length of the hash (octets)
@param saltlen The length of the salt desired (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 out [out] The destination of the encoding
@param outlen [in/out] The max size and resulting size of the encoded data
@return CRYPT_OK if successful
*/
int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
- unsigned long saltlen, int hash_idx,
+ unsigned long saltlen, const struct algo_properties_st *hash_algo,
unsigned long modulus_bitlen,
unsigned char *out, unsigned long *outlen)
{
@@ -43,11 +43,11 @@ int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
LTC_ARGCHK(outlen != NULL);
/* ensure hash and PRNG are 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 */
@@ -83,7 +83,7 @@ int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
}
/* M = (eight) 0x00 || msghash || salt, hash = H(M) */
- err = hash_memory_multi(hash_idx, hash, &hLen, DB, 8, msghash, (unsigned long)msghashlen, salt, (unsigned long)saltlen, NULL, 0);
+ err = hash_memory_multi(hash_algo->algo, hash, &hLen, DB, 8, msghash, (unsigned long)msghashlen, salt, (unsigned long)saltlen, NULL, 0);
if (err != CRYPT_OK) {
goto LBL_ERR;
}
@@ -97,7 +97,7 @@ int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
x += saltlen;
/* 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;
}
diff --git a/libtomcrypt/pk/rsa/rsa_sign_hash.c b/libtomcrypt/pk/rsa/rsa_sign_hash.c
index 30577a129b1..8c6c9d9b52c 100644
--- a/libtomcrypt/pk/rsa/rsa_sign_hash.c
+++ b/libtomcrypt/pk/rsa/rsa_sign_hash.c
@@ -69,7 +69,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
/* PSS pad the key */
x = *outlen;
if ((err = pkcs_1_pss_encode(in, inlen, saltlen,
- hash->algo, modulus_bitlen, out, &x)) != CRYPT_OK) {
+ hash, modulus_bitlen, out, &x)) != CRYPT_OK) {
return err;
}
} else {