diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-24 03:15:46 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-07-24 04:25:24 +0200 |
commit | 6c29ce243f2d106648d93bc3cf44060db38fdf9a (patch) | |
tree | 6788479b86f24bbc119c1c38c9cb42b9a97a56d2 | |
parent | 94ad20f2978e7234579593ac284f9c6cd1426785 (diff) | |
download | cryptodev-linux-6c29ce243f2d106648d93bc3cf44060db38fdf9a.tar.gz cryptodev-linux-6c29ce243f2d106648d93bc3cf44060db38fdf9a.tar.xz cryptodev-linux-6c29ce243f2d106648d93bc3cf44060db38fdf9a.zip |
Replace _ncr_algo_to_str by direct accesses
-rw-r--r-- | libtomcrypt/hashes/hash_memory.c | 2 | ||||
-rw-r--r-- | libtomcrypt/hashes/hash_memory_multi.c | 2 | ||||
-rw-r--r-- | ncr-sessions.c | 35 | ||||
-rw-r--r-- | ncr_int.h | 1 |
4 files changed, 10 insertions, 30 deletions
diff --git a/libtomcrypt/hashes/hash_memory.c b/libtomcrypt/hashes/hash_memory.c index a452525..5ba3bc6 100644 --- a/libtomcrypt/hashes/hash_memory.c +++ b/libtomcrypt/hashes/hash_memory.c @@ -44,7 +44,7 @@ int hash_memory(const struct algo_properties_st *hash, const unsigned char *in, return CRYPT_BUFFER_OVERFLOW; } - err = cryptodev_hash_init( &hdata, _ncr_algo_to_str(hash->algo), 0, NULL, 0); + err = cryptodev_hash_init( &hdata, hash->kstr, 0, NULL, 0); if (err < 0) { err = CRYPT_INVALID_HASH; goto LBL_ERR; diff --git a/libtomcrypt/hashes/hash_memory_multi.c b/libtomcrypt/hashes/hash_memory_multi.c index a10e14c..d772492 100644 --- a/libtomcrypt/hashes/hash_memory_multi.c +++ b/libtomcrypt/hashes/hash_memory_multi.c @@ -50,7 +50,7 @@ int hash_memory_multi(const struct algo_properties_st *hash, unsigned char *out, return CRYPT_BUFFER_OVERFLOW; } - err = cryptodev_hash_init( &hdata, _ncr_algo_to_str(hash->algo), 0, NULL, 0); + err = cryptodev_hash_init( &hdata, hash->kstr, 0, NULL, 0); if (err < 0) { err = CRYPT_INVALID_HASH; goto LBL_ERR; diff --git a/ncr-sessions.c b/ncr-sessions.c index bbe3ffb..6ecafb9 100644 --- a/ncr-sessions.c +++ b/ncr-sessions.c @@ -197,26 +197,11 @@ const struct algo_properties_st *_ncr_algo_to_properties(ncr_algorithm_t algo) return NULL; } -const char* _ncr_algo_to_str(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].kstr; - i++; - } - - return NULL; -} - static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* session) { struct session_item_st* ns = NULL; int ret; const struct algo_properties_st *sign_hash; - const char* str = NULL; ns = ncr_session_new(&lists->sessions); if (ns == NULL) { @@ -252,13 +237,12 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses if (session->algorithm == NCR_ALG_NULL) keysize = 0; - str = _ncr_algo_to_str(session->algorithm); - if (str == NULL) { + if (ns->algorithm->kstr == NULL) { err(); return -EINVAL; } - ret = cryptodev_cipher_init(&ns->cipher, str, + ret = cryptodev_cipher_init(&ns->cipher, ns->algorithm->kstr, ns->key->key.secret.data, keysize); if (ret < 0) { err(); @@ -303,13 +287,12 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses } if (ns->key->type == NCR_KEY_TYPE_SECRET) { - str = _ncr_algo_to_str(session->algorithm); - if (str == NULL) { + if (ns->algorithm->kstr == NULL) { err(); return -EINVAL; } - ret = cryptodev_hash_init(&ns->hash, str, 1, + ret = cryptodev_hash_init(&ns->hash, ns->algorithm->kstr, 1, ns->key->key.secret.data, ns->key->key.secret.size); if (ret < 0) { err(); @@ -328,8 +311,7 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses ret = -EINVAL; goto fail; } - str = _ncr_algo_to_str(sign_hash->algo); - if (str == NULL) { + if (sign_hash->kstr == NULL) { err(); ret = -EINVAL; goto fail; @@ -342,7 +324,7 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses goto fail; } - ret = cryptodev_hash_init(&ns->hash, str, 0, NULL, 0); + ret = cryptodev_hash_init(&ns->hash, sign_hash->kstr, 0, NULL, 0); if (ret < 0) { err(); goto fail; @@ -360,14 +342,13 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses ret = -EINVAL; goto fail; } - str = _ncr_algo_to_str(session->algorithm); - if (str == NULL) { + if (ns->algorithm->kstr == NULL) { err(); ret = -EINVAL; goto fail; } - ret = cryptodev_hash_init(&ns->hash, str, 0, NULL, 0); + ret = cryptodev_hash_init(&ns->hash, ns->algorithm->kstr, 0, NULL, 0); if (ret < 0) { err(); goto fail; @@ -206,7 +206,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); const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params); #endif |