diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-24 04:30:14 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-07-24 04:30:14 +0200 |
commit | d750b60952619af570ac4d91cd650ffa6bbe311d (patch) | |
tree | 894b9abfd9eaaa8e241994136c06700a38fcd991 | |
parent | 6c29ce243f2d106648d93bc3cf44060db38fdf9a (diff) | |
download | cryptodev-linux-d750b60952619af570ac4d91cd650ffa6bbe311d.tar.gz cryptodev-linux-d750b60952619af570ac4d91cd650ffa6bbe311d.tar.xz cryptodev-linux-d750b60952619af570ac4d91cd650ffa6bbe311d.zip |
Only look up the sign_hash algorithm once
-rw-r--r-- | ncr-pk.c | 8 | ||||
-rw-r--r-- | ncr-pk.h | 2 | ||||
-rw-r--r-- | ncr-sessions.c | 4 |
3 files changed, 5 insertions, 9 deletions
@@ -335,7 +335,7 @@ void ncr_pk_cipher_deinit(struct ncr_pk_ctx* ctx) 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) + struct key_item_st *key, const struct algo_properties_st *sign_hash) { memset(ctx, 0, sizeof(*ctx)); @@ -346,11 +346,7 @@ int ncr_pk_cipher_init(const struct algo_properties_st *algo, ctx->algorithm = algo; ctx->key = key; - ctx->sign_hash = ncr_key_params_get_sign_hash(algo, params); - if (IS_ERR(ctx->sign_hash)) { - err(); - return PTR_ERR(ctx->sign_hash); - } + ctx->sign_hash = sign_hash; switch(algo->algo) { case NCR_ALG_RSA: @@ -32,7 +32,7 @@ void ncr_pk_queue_deinit(void); /* encryption/decryption */ 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); + struct key_item_st *key, const struct algo_properties_st *sign_hash); void ncr_pk_cipher_deinit(struct ncr_pk_ctx* ctx); int ncr_pk_cipher_encrypt(const struct ncr_pk_ctx* ctx, const void* input, size_t input_size, void* output, size_t *output_size); diff --git a/ncr-sessions.c b/ncr-sessions.c index 6ecafb9..f768cb3 100644 --- a/ncr-sessions.c +++ b/ncr-sessions.c @@ -259,7 +259,7 @@ 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_pk_cipher_init(ns->algorithm, &ns->pk, - &session->params, ns->key); + &session->params, ns->key, NULL); if (ret < 0) { err(); goto fail; @@ -318,7 +318,7 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses } ret = ncr_pk_cipher_init(ns->algorithm, &ns->pk, - &session->params, ns->key); + &session->params, ns->key, sign_hash); if (ret < 0) { err(); goto fail; |