summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:24:51 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commitfad50a3c690dc2d52b0f568b714a0cfcf072c938 (patch)
treec6467186aa2e97dcbcb687c08a57c7e06f21dba3
parentb92da3d22f38bfbc9187032d273a8de39f9bb423 (diff)
downloadcryptodev-linux-fad50a3c690dc2d52b0f568b714a0cfcf072c938.tar.gz
cryptodev-linux-fad50a3c690dc2d52b0f568b714a0cfcf072c938.tar.xz
cryptodev-linux-fad50a3c690dc2d52b0f568b714a0cfcf072c938.zip
Use algo_properties_st in rsa_verify_hash_ex
-rw-r--r--libtomcrypt/headers/tomcrypt_pk.h6
-rw-r--r--libtomcrypt/pk/rsa/rsa_verify_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 1e0b62a..145165e 100644
--- a/libtomcrypt/headers/tomcrypt_pk.h
+++ b/libtomcrypt/headers/tomcrypt_pk.h
@@ -68,8 +68,8 @@ void rsa_free(rsa_key *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)
+#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_algo, _saltlen, _stat, _key) \
+ rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_LTC_PKCS_1_PSS, _hash_algo, _saltlen, _stat, _key)
/* These can be switched between LTC_PKCS #1 v2.x and LTC_PKCS #1 v1.5 paddings */
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
@@ -92,7 +92,7 @@ int rsa_sign_hash_ex(const unsigned char *in, unsigned long inlen,
int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
const unsigned char *hash, unsigned long hashlen,
int padding,
- int hash_idx, unsigned long saltlen,
+ const struct algo_properties_st *hash_algo, unsigned long saltlen,
int *stat, rsa_key *key);
/* LTC_PKCS #1 import/export */
diff --git a/libtomcrypt/pk/rsa/rsa_verify_hash.c b/libtomcrypt/pk/rsa/rsa_verify_hash.c
index 773ea7d..c563391 100644
--- a/libtomcrypt/pk/rsa/rsa_verify_hash.c
+++ b/libtomcrypt/pk/rsa/rsa_verify_hash.c
@@ -9,6 +9,7 @@
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
+#include "ncr_int.h"
/**
@file rsa_verify_hash.c
@@ -24,7 +25,7 @@
@param hash The hash of the message that was signed
@param hashlen The length of the hash of the message that was signed (octets)
@param padding Type of padding (LTC_LTC_PKCS_1_PSS or LTC_LTC_PKCS_1_V1_5)
- @param hash_idx The index of the desired hash
+ @param hash_algo The desired hash
@param saltlen The length of the salt used during signature
@param stat [out] The result of the signature comparison, 1==valid, 0==invalid
@param key The public RSA key corresponding to the key that performed the signature
@@ -33,7 +34,7 @@
int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
const unsigned char *hash, unsigned long hashlen,
int padding,
- int hash_idx, unsigned long saltlen,
+ const struct algo_properties_st *hash_algo, unsigned long saltlen,
int *stat, rsa_key *key)
{
unsigned long modulus_bitlen, modulus_bytelen, x;
@@ -57,7 +58,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
if (padding == LTC_LTC_PKCS_1_PSS) {
/* valid hash ? */
- if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
+ if ((err = hash_is_valid(hash_algo->algo)) != CRYPT_OK) {
return err;
}
}
@@ -92,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_idx, modulus_bitlen, stat);
+ err = pkcs_1_pss_decode(hash, hashlen, tmpbuf, x, saltlen, hash_algo->algo, modulus_bitlen, stat);
} else {
/* LTC_PKCS #1 v1.5 decode it */
unsigned char *out;
@@ -102,7 +103,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
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->algo, &st) != CRYPT_OK) {
err = CRYPT_INVALID_ARG;
goto bail_2;
}
diff --git a/ncr-pk.c b/ncr-pk.c
index 505dd6f..8386b2b 100644
--- a/ncr-pk.c
+++ b/ncr-pk.c
@@ -498,7 +498,7 @@ int stat;
return -EINVAL;
}
cret = rsa_verify_hash_ex( signature, signature_size,
- hash, hash_size, ctx->type, ctx->sign_hash->algo,
+ hash, hash_size, ctx->type, ctx->sign_hash,
ctx->salt_len, &stat, &ctx->key->key.pk.rsa);
if (cret != CRYPT_OK) {