summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 02:14:38 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commit52e90afd006bec2a072c00cae8945e606f43da66 (patch)
tree9c5720d01c2f779319931e31603e3e953bf9f8a0
parentd11063f50e61ba5880324908ea6cccb0314f0d46 (diff)
downloadcryptodev-linux-52e90afd006bec2a072c00cae8945e606f43da66.tar.gz
cryptodev-linux-52e90afd006bec2a072c00cae8945e606f43da66.tar.xz
cryptodev-linux-52e90afd006bec2a072c00cae8945e606f43da66.zip
Use algo_properties_st in rsa_encrypt_key_ex
-rw-r--r--libtomcrypt/headers/tomcrypt_pk.h8
-rw-r--r--libtomcrypt/pk/rsa/rsa_encrypt_key.c9
-rw-r--r--ncr-pk.c2
3 files changed, 11 insertions, 8 deletions
diff --git a/libtomcrypt/headers/tomcrypt_pk.h b/libtomcrypt/headers/tomcrypt_pk.h
index fa6030e..3d2de50 100644
--- a/libtomcrypt/headers/tomcrypt_pk.h
+++ b/libtomcrypt/headers/tomcrypt_pk.h
@@ -1,5 +1,7 @@
/* ---- NUMBER THEORY ---- */
+struct algo_properties_st;
+
enum {
PK_PUBLIC=0,
PK_PRIVATE=1
@@ -57,8 +59,8 @@ int rsa_exptmod(const unsigned char *in, unsigned long inlen,
void rsa_free(rsa_key *key);
/* These use LTC_PKCS #1 v2.0 padding */
-#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _key) \
- rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_LTC_PKCS_1_OAEP, _key)
+#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash, _key) \
+ rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash, LTC_LTC_PKCS_1_OAEP, _key)
#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _stat, _key) \
rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_LTC_PKCS_1_OAEP, _stat, _key)
@@ -73,7 +75,7 @@ void rsa_free(rsa_key *key);
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
const unsigned char *lparam, unsigned long lparamlen,
- int hash_idx, int padding, rsa_key *key);
+ const struct algo_properties_st *hash, int padding, rsa_key *key);
int rsa_decrypt_key_ex(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
diff --git a/libtomcrypt/pk/rsa/rsa_encrypt_key.c b/libtomcrypt/pk/rsa/rsa_encrypt_key.c
index d59699c..9e4573b 100644
--- a/libtomcrypt/pk/rsa/rsa_encrypt_key.c
+++ b/libtomcrypt/pk/rsa/rsa_encrypt_key.c
@@ -9,6 +9,7 @@
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
+#include "ncr_int.h"
/**
@file rsa_encrypt_key.c
@@ -25,7 +26,7 @@
@param outlen [in/out] The max size and resulting size of the ciphertext
@param lparam The system "lparam" for the encryption
@param lparamlen The length of lparam (octets)
- @param hash_idx The index of the desired hash
+ @param hash The desired hash
@param padding Type of padding (LTC_LTC_PKCS_1_OAEP or LTC_LTC_PKCS_1_V1_5)
@param key The RSA key to encrypt to
@return CRYPT_OK if successful
@@ -33,7 +34,7 @@
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
const unsigned char *lparam, unsigned long lparamlen,
- int hash_idx, int padding, rsa_key *key)
+ const struct algo_properties_st *hash, int padding, rsa_key *key)
{
unsigned long modulus_bitlen, modulus_bytelen, x;
int err;
@@ -51,7 +52,7 @@ int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
if (padding == LTC_LTC_PKCS_1_OAEP) {
/* valid hash? */
- if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
+ if ((err = hash_is_valid(hash->algo)) != CRYPT_OK) {
return err;
}
}
@@ -70,7 +71,7 @@ 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_idx,
+ lparamlen, modulus_bitlen, hash->algo,
out, &x)) != CRYPT_OK) {
return err;
}
diff --git a/ncr-pk.c b/ncr-pk.c
index 09dd242..bd041b1 100644
--- a/ncr-pk.c
+++ b/ncr-pk.c
@@ -390,7 +390,7 @@ unsigned long osize = *output_size;
switch(ctx->algorithm->algo) {
case NCR_ALG_RSA:
cret = rsa_encrypt_key_ex( input, input_size, output, &osize,
- NULL, 0, ctx->oaep_hash->algo, ctx->type, &ctx->key->key.pk.rsa);
+ NULL, 0, ctx->oaep_hash, ctx->type, &ctx->key->key.pk.rsa);
if (cret != CRYPT_OK) {
printk("cret: %d type: %d\n", cret, ctx->type);