summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:20:45 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commitb92da3d22f38bfbc9187032d273a8de39f9bb423 (patch)
treea29ccb26d2df5cab5ee05c3707769d278a95d721
parent5a0f78d7300975afc64f51ad217e69f71aa0aa55 (diff)
downloadkernel-crypto-b92da3d22f38bfbc9187032d273a8de39f9bb423.tar.gz
kernel-crypto-b92da3d22f38bfbc9187032d273a8de39f9bb423.tar.xz
kernel-crypto-b92da3d22f38bfbc9187032d273a8de39f9bb423.zip
Use algo_properties_st in rsa_sign_hash_ex
-rw-r--r--libtomcrypt/headers/tomcrypt_pk.h6
-rw-r--r--libtomcrypt/pk/rsa/rsa_sign_hash.c11
-rw-r--r--ncr-pk.c2
3 files changed, 10 insertions, 9 deletions
diff --git a/libtomcrypt/headers/tomcrypt_pk.h b/libtomcrypt/headers/tomcrypt_pk.h
index cc5e6c2d5b1..1e0b62aca30 100644
--- a/libtomcrypt/headers/tomcrypt_pk.h
+++ b/libtomcrypt/headers/tomcrypt_pk.h
@@ -65,8 +65,8 @@ void rsa_free(rsa_key *key);
#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash, _stat, _key) \
rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash, LTC_LTC_PKCS_1_OAEP, _stat, _key)
-#define rsa_sign_hash(_in, _inlen, _out, _outlen, _hash_idx, _saltlen, _key) \
- rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_LTC_PKCS_1_PSS, _hash_idx, _saltlen, _key)
+#define rsa_sign_hash(_in, _inlen, _out, _outlen, _hash, _saltlen, _key) \
+ rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_LTC_PKCS_1_PSS, _hash, _saltlen, _key)
#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \
rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key)
@@ -86,7 +86,7 @@ int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen,
int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
int padding,
- int hash_idx, unsigned long saltlen,
+ const struct algo_properties_st *hash, unsigned long saltlen,
rsa_key *key);
int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
diff --git a/libtomcrypt/pk/rsa/rsa_sign_hash.c b/libtomcrypt/pk/rsa/rsa_sign_hash.c
index 1298d46c896..2d87c47f2bc 100644
--- a/libtomcrypt/pk/rsa/rsa_sign_hash.c
+++ b/libtomcrypt/pk/rsa/rsa_sign_hash.c
@@ -9,6 +9,7 @@
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
+#include "ncr_int.h"
/**
@file rsa_sign_hash.c
@@ -24,7 +25,7 @@
@param out [out] The signature
@param outlen [in/out] The max size and resulting size of the signature
@param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5)
- @param hash_idx The index of the hash desired
+ @param hash The desired hash
@param saltlen The length of the salt desired (octets)
@param key The private RSA key to use
@return CRYPT_OK if successful
@@ -32,7 +33,7 @@
int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
int padding,
- int hash_idx, unsigned long saltlen,
+ const struct algo_properties_st *hash, unsigned long saltlen,
rsa_key *key)
{
unsigned long modulus_bitlen, modulus_bytelen, x, y;
@@ -49,7 +50,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
}
if (padding == LTC_LTC_PKCS_1_PSS) {
- if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
+ if ((err = hash_is_valid(hash->algo)) != CRYPT_OK) {
return err;
}
}
@@ -68,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_idx, modulus_bitlen, out, &x)) != CRYPT_OK) {
+ hash->algo, modulus_bitlen, out, &x)) != CRYPT_OK) {
return err;
}
} else {
@@ -78,7 +79,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
oid_st st;
/* not all hashes have OIDs... so sad */
- if (hash_get_oid(hash_idx, &st) != CRYPT_OK) {
+ if (hash_get_oid(hash->algo, &st) != CRYPT_OK) {
return CRYPT_INVALID_ARG;
}
diff --git a/ncr-pk.c b/ncr-pk.c
index 9a9e98a9860..505dd6fb2d5 100644
--- a/ncr-pk.c
+++ b/ncr-pk.c
@@ -458,7 +458,7 @@ unsigned long osize = *output_size;
return -EINVAL;
}
cret = rsa_sign_hash_ex( input, input_size, output, &osize,
- ctx->type, ctx->sign_hash->algo, ctx->salt_len, &ctx->key->key.pk.rsa);
+ ctx->type, ctx->sign_hash, ctx->salt_len, &ctx->key->key.pk.rsa);
if (cret != CRYPT_OK) {
err();