summaryrefslogtreecommitdiffstats
path: root/libtomcrypt/pk
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:36:48 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commit6962f9b991bd1c47d1e501e19875372d0301ca53 (patch)
tree13d68a3b8554d2c62d9ca69ebb90c7cacbd65291 /libtomcrypt/pk
parent82c206a8e9d16e439c64d9afbf5afabd9ed1f0ce (diff)
Use algo_properties_st in pkcs_1_oaep_encode
Diffstat (limited to 'libtomcrypt/pk')
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c16
-rw-r--r--libtomcrypt/pk/rsa/rsa_encrypt_key.c4
2 files changed, 10 insertions, 10 deletions
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
index ccee5cf..46dc91e 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
@@ -25,14 +25,14 @@
@param lparam A session or system parameter (can be NULL)
@param lparamlen The length of the lparam data
@param modulus_bitlen The bit length of the RSA modulus
- @param hash_idx The index of the hash desired
+ @param hash The desired hash
@param out [out] The destination for the encoded data
@param outlen [in/out] The max size and resulting size of the encoded data
@return CRYPT_OK if successful
*/
int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
const unsigned char *lparam, unsigned long lparamlen,
- unsigned long modulus_bitlen, int hash_idx,
+ unsigned long modulus_bitlen, const struct algo_properties_st *hash,
unsigned char *out, unsigned long *outlen)
{
unsigned char *DB, *seed, *mask;
@@ -44,11 +44,11 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
LTC_ARGCHK(outlen != NULL);
/* test valid hash */
- if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
+ if ((err = hash_is_valid(hash->algo)) != CRYPT_OK) {
return err;
}
- hLen = _ncr_algo_digest_size(hash_idx);
+ hLen = _ncr_algo_digest_size(hash->algo);
modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0);
/* test message size */
@@ -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_idx, lparam, lparamlen, DB, &x)) != CRYPT_OK) {
+ if ((err = hash_memory(hash->algo, 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_idx, DB, 0, DB, &x)) != CRYPT_OK) {
+ if ((err = hash_memory(hash->algo, DB, 0, DB, &x)) != CRYPT_OK) {
goto LBL_ERR;
}
}
@@ -104,7 +104,7 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
get_random_bytes(seed, hLen);
/* compute MGF1 of seed (k - hlen - 1) */
- if ((err = pkcs_1_mgf1(hash_idx, seed, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) {
+ if ((err = pkcs_1_mgf1(hash->algo, seed, hLen, mask, modulus_len - hLen - 1)) != CRYPT_OK) {
goto LBL_ERR;
}
@@ -114,7 +114,7 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
}
/* compute MGF1 of maskedDB (hLen) */
- if ((err = pkcs_1_mgf1(hash_idx, DB, modulus_len - hLen - 1, mask, hLen)) != CRYPT_OK) {
+ if ((err = pkcs_1_mgf1(hash->algo, DB, modulus_len - hLen - 1, mask, hLen)) != CRYPT_OK) {
goto LBL_ERR;
}
diff --git a/libtomcrypt/pk/rsa/rsa_encrypt_key.c b/libtomcrypt/pk/rsa/rsa_encrypt_key.c
index 9e4573b..9fea75a 100644
--- a/libtomcrypt/pk/rsa/rsa_encrypt_key.c
+++ b/libtomcrypt/pk/rsa/rsa_encrypt_key.c
@@ -71,8 +71,8 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
/* OAEP pad the key */
x = *outlen;
if ((err = pkcs_1_oaep_encode(in, inlen, lparam,
- lparamlen, modulus_bitlen, hash->algo,
- out, &x)) != CRYPT_OK) {
+ lparamlen, modulus_bitlen, hash,
+ out, &x)) != CRYPT_OK) {
return err;
}
} else {