diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-24 02:04:11 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-07-24 04:25:17 +0200 |
commit | d11063f50e61ba5880324908ea6cccb0314f0d46 (patch) | |
tree | 4f000394fa0e798a8a4206996ce51ec4919cd909 | |
parent | 442669bac9acde432d01d423a3fd1dd2c7a27fd7 (diff) | |
download | cryptodev-linux-d11063f50e61ba5880324908ea6cccb0314f0d46.tar.gz cryptodev-linux-d11063f50e61ba5880324908ea6cccb0314f0d46.tar.xz cryptodev-linux-d11063f50e61ba5880324908ea6cccb0314f0d46.zip |
Use algo_properties_st in ncr_key_params_get_sign_hash
-rw-r--r-- | ncr-pk.c | 24 | ||||
-rw-r--r-- | ncr-sessions.c | 13 | ||||
-rw-r--r-- | ncr_int.h | 2 |
3 files changed, 20 insertions, 19 deletions
@@ -305,16 +305,21 @@ void ncr_pk_queue_deinit(void) destroy_workqueue(pk_wq); } -int ncr_key_params_get_sign_hash(ncr_algorithm_t algo, struct ncr_key_params_st * params) +const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params) { - switch(algo) { + ncr_algorithm_t id; + + switch(algo->algo) { case NCR_ALG_RSA: - return params->params.rsa.sign_hash; + id = params->params.rsa.sign_hash; + break; case NCR_ALG_DSA: - return params->params.dsa.sign_hash; + id = params->params.dsa.sign_hash; + break; default: - return -EINVAL; + return ERR_PTR(-EINVAL); } + return _ncr_algo_to_properties(id); } /* Encryption/Decryption @@ -332,8 +337,6 @@ int ncr_pk_cipher_init(const struct algo_properties_st *algo, struct ncr_pk_ctx* ctx, struct ncr_key_params_st* params, struct key_item_st *key) { -int ret; - memset(ctx, 0, sizeof(*ctx)); if (key->algorithm != algo) { @@ -343,12 +346,11 @@ int ret; ctx->algorithm = algo; ctx->key = key; - ret = ncr_key_params_get_sign_hash(algo->algo, params); - if (ret < 0) { + ctx->sign_hash = ncr_key_params_get_sign_hash(algo, params); + if (IS_ERR(ctx->sign_hash)) { err(); - return ret; + return PTR_ERR(ctx->sign_hash); } - ctx->sign_hash = _ncr_algo_to_properties(ret); switch(algo->algo) { case NCR_ALG_RSA: diff --git a/ncr-sessions.c b/ncr-sessions.c index 6f26e43..dfc8976 100644 --- a/ncr-sessions.c +++ b/ncr-sessions.c @@ -286,7 +286,7 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses { struct session_item_st* ns = NULL; int ret; - ncr_algorithm_t sign_hash; + const struct algo_properties_st *sign_hash; const char* str = NULL; ns = ncr_session_new(&lists->sessions); @@ -388,19 +388,18 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses } } else if (ns->key->type == NCR_KEY_TYPE_PRIVATE || ns->key->type == NCR_KEY_TYPE_PUBLIC) { - ret = ncr_key_params_get_sign_hash(ns->key->algorithm->algo, &session->params); - if (ret < 0) { + sign_hash = ncr_key_params_get_sign_hash(ns->key->algorithm, &session->params); + if (IS_ERR(sign_hash)) { err(); - return ret; + return PTR_ERR(sign_hash); } - sign_hash = ret; - if (algo_can_digest(sign_hash) == 0) { + if (algo_can_digest(sign_hash->algo) == 0) { err(); ret = -EINVAL; goto fail; } - str = _ncr_algo_to_str(sign_hash); + str = _ncr_algo_to_str(sign_hash->algo); if (str == NULL) { err(); ret = -EINVAL; @@ -208,6 +208,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); -int ncr_key_params_get_sign_hash(ncr_algorithm_t algo, struct ncr_key_params_st * params); +const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params); #endif |