summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 03:07:56 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 04:25:24 +0200
commit94ad20f2978e7234579593ac284f9c6cd1426785 (patch)
treeb048aa7b4b0cd246b481eeddc6403250eddb73fe
parent32e0115f32c75f0bffdea599734774376cdf097b (diff)
downloadcryptodev-linux-94ad20f2978e7234579593ac284f9c6cd1426785.tar.gz
cryptodev-linux-94ad20f2978e7234579593ac284f9c6cd1426785.tar.xz
cryptodev-linux-94ad20f2978e7234579593ac284f9c6cd1426785.zip
Replace _ncr_algo_digest_size by direct accesses
-rw-r--r--libtomcrypt/hashes/hash_memory.c8
-rw-r--r--libtomcrypt/hashes/hash_memory_multi.c8
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c2
-rw-r--r--libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c2
-rw-r--r--ncr-sessions.c14
-rw-r--r--ncr_int.h1
9 files changed, 11 insertions, 30 deletions
diff --git a/libtomcrypt/hashes/hash_memory.c b/libtomcrypt/hashes/hash_memory.c
index 267957a..a452525 100644
--- a/libtomcrypt/hashes/hash_memory.c
+++ b/libtomcrypt/hashes/hash_memory.c
@@ -30,7 +30,6 @@ int hash_memory(const struct algo_properties_st *hash, const unsigned char *in,
{
int err;
struct hash_data hdata;
- int digest_size;
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
@@ -40,9 +39,8 @@ int hash_memory(const struct algo_properties_st *hash, const unsigned char *in,
return err;
}
- digest_size = _ncr_algo_digest_size(hash->algo);
- if (*outlen < digest_size) {
- *outlen = digest_size;
+ if (*outlen < hash->digest_size) {
+ *outlen = hash->digest_size;
return CRYPT_BUFFER_OVERFLOW;
}
@@ -59,7 +57,7 @@ int hash_memory(const struct algo_properties_st *hash, const unsigned char *in,
err = cryptodev_hash_final(&hdata, out);
- *outlen = digest_size;
+ *outlen = hash->digest_size;
LBL_ERR:
cryptodev_hash_deinit(&hdata);
diff --git a/libtomcrypt/hashes/hash_memory_multi.c b/libtomcrypt/hashes/hash_memory_multi.c
index 79cfd2b..a10e14c 100644
--- a/libtomcrypt/hashes/hash_memory_multi.c
+++ b/libtomcrypt/hashes/hash_memory_multi.c
@@ -32,7 +32,6 @@ int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out,
const unsigned char *in, unsigned long inlen, ...)
{
struct hash_data hdata;
- int digest_size;
int err;
va_list args;
const unsigned char *curptr;
@@ -46,9 +45,8 @@ int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out,
return err;
}
- digest_size = _ncr_algo_digest_size(hash->algo);
- if (*outlen < digest_size) {
- *outlen = digest_size;
+ if (*outlen < hash->digest_size) {
+ *outlen = hash->digest_size;
return CRYPT_BUFFER_OVERFLOW;
}
@@ -77,7 +75,7 @@ int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out,
err = cryptodev_hash_final(&hdata, out);
- *outlen = digest_size;
+ *outlen = hash->digest_size;
LBL_ERR:
cryptodev_hash_deinit(&hdata);
va_end(args);
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c b/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c
index e7971f7..b09dd11 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_mgf1.c
@@ -45,7 +45,7 @@ int pkcs_1_mgf1(const struct algo_properties_st *hash,
}
/* get hash output size */
- hLen = _ncr_algo_digest_size(hash->algo);
+ hLen = hash->digest_size;
/* allocate memory */
buf = XMALLOC(hLen);
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c
index b44a1ed..60f76a0 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_decode.c
@@ -54,7 +54,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
return err;
}
- hLen = _ncr_algo_digest_size(hash->algo);
+ hLen = hash->digest_size;
modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0);
/* test hash/message size */
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
index 43bd22e..c56e3b1 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_oaep_encode.c
@@ -48,7 +48,7 @@ int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
return err;
}
- hLen = _ncr_algo_digest_size(hash->algo);
+ hLen = hash->digest_size;
modulus_len = (modulus_bitlen >> 3) + (modulus_bitlen & 7 ? 1 : 0);
/* test message size */
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c b/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c
index b8e126a..293d84f 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_pss_decode.c
@@ -50,7 +50,7 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
return err;
}
- hLen = _ncr_algo_digest_size(hash_algo->algo);
+ hLen = hash_algo->digest_size;
modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0);
/* check sizes */
diff --git a/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c b/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c
index 88963de..d747b49 100644
--- a/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c
+++ b/libtomcrypt/pk/pkcs1/pkcs_1_pss_encode.c
@@ -47,7 +47,7 @@ int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
return err;
}
- hLen = _ncr_algo_digest_size(hash_algo->algo);
+ hLen = hash_algo->digest_size;
modulus_len = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0);
/* check sizes */
diff --git a/ncr-sessions.c b/ncr-sessions.c
index e96da56..bbe3ffb 100644
--- a/ncr-sessions.c
+++ b/ncr-sessions.c
@@ -211,20 +211,6 @@ int i = 0;
return NULL;
}
-int _ncr_algo_digest_size(ncr_algorithm_t algo)
-{
-ncr_algorithm_t a;
-int i = 0;
-
- while((a=algo_properties[i].algo)!=NCR_ALG_NONE) {
- if (a == algo)
- return algo_properties[i].digest_size;
- i++;
- }
-
- return 0;
-}
-
static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* session)
{
struct session_item_st* ns = NULL;
diff --git a/ncr_int.h b/ncr_int.h
index fc6e0c6..d10bcb7 100644
--- a/ncr_int.h
+++ b/ncr_int.h
@@ -207,7 +207,6 @@ inline static unsigned int data_flags_to_key(unsigned int data_flags)
const struct algo_properties_st *_ncr_algo_to_properties(ncr_algorithm_t algo);
const char* _ncr_algo_to_str(ncr_algorithm_t algo);
-int _ncr_algo_digest_size(ncr_algorithm_t algo);
const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params);
#endif