summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-24 01:41:00 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-07-24 02:06:22 +0200
commit785cc374c65b2e206db4e38d686dfede50fdb9f5 (patch)
treeba98676f8b2b51638854d5d4dda0cdaf38882eaa
parent9ea8ffaa934b50ced391817ce2e11527f5426f22 (diff)
downloadcryptodev-linux-785cc374c65b2e206db4e38d686dfede50fdb9f5.tar.gz
cryptodev-linux-785cc374c65b2e206db4e38d686dfede50fdb9f5.tar.xz
cryptodev-linux-785cc374c65b2e206db4e38d686dfede50fdb9f5.zip
Use algo_properties_st in ncr_pk_ctx.algorithm
-rw-r--r--ncr-pk.c16
-rw-r--r--ncr-pk.h4
-rw-r--r--ncr-sessions.c4
3 files changed, 12 insertions, 12 deletions
diff --git a/ncr-pk.c b/ncr-pk.c
index e911c23..0f9ca53 100644
--- a/ncr-pk.c
+++ b/ncr-pk.c
@@ -329,7 +329,7 @@ void ncr_pk_cipher_deinit(struct ncr_pk_ctx* ctx)
}
}
-int ncr_pk_cipher_init(ncr_algorithm_t algo,
+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)
{
@@ -337,21 +337,21 @@ int ret;
memset(ctx, 0, sizeof(*ctx));
- if (key->algorithm->algo != algo) {
+ if (key->algorithm != algo) {
err();
return -EINVAL;
}
ctx->algorithm = algo;
ctx->key = key;
- ret = ncr_key_params_get_sign_hash(algo, params);
+ ret = ncr_key_params_get_sign_hash(algo->algo, params);
if (ret < 0) {
err();
return ret;
}
ctx->sign_hash = ret;
- switch(algo) {
+ switch(algo->algo) {
case NCR_ALG_RSA:
if (params->params.rsa.type == RSA_PKCS1_V1_5)
ctx->type = LTC_LTC_PKCS_1_V1_5;
@@ -382,7 +382,7 @@ int ncr_pk_cipher_encrypt(const struct ncr_pk_ctx* ctx,
int cret;
unsigned long osize = *output_size;
- switch(ctx->algorithm) {
+ switch(ctx->algorithm->algo) {
case NCR_ALG_RSA:
cret = rsa_encrypt_key_ex( input, input_size, output, &osize,
NULL, 0, ctx->oaep_hash, ctx->type, &ctx->key->key.pk.rsa);
@@ -412,7 +412,7 @@ int cret;
unsigned long osize = *output_size;
int stat;
- switch(ctx->algorithm) {
+ switch(ctx->algorithm->algo) {
case NCR_ALG_RSA:
cret = rsa_decrypt_key_ex( input, input_size, output, &osize,
NULL, 0, ctx->oaep_hash, ctx->type, &stat, &ctx->key->key.pk.rsa);
@@ -446,7 +446,7 @@ int ncr_pk_cipher_sign(const struct ncr_pk_ctx* ctx,
int cret;
unsigned long osize = *output_size;
- switch(ctx->algorithm) {
+ switch(ctx->algorithm->algo) {
case NCR_ALG_RSA:
cret = rsa_sign_hash_ex( input, input_size, output, &osize,
ctx->type, ctx->sign_hash, ctx->salt_len, &ctx->key->key.pk.rsa);
@@ -482,7 +482,7 @@ int ncr_pk_cipher_verify(const struct ncr_pk_ctx* ctx,
int cret;
int stat;
- switch(ctx->algorithm) {
+ switch(ctx->algorithm->algo) {
case NCR_ALG_RSA:
cret = rsa_verify_hash_ex( signature, signature_size,
hash, hash_size, ctx->type, ctx->sign_hash,
diff --git a/ncr-pk.h b/ncr-pk.h
index 1180017..0bf2745 100644
--- a/ncr-pk.h
+++ b/ncr-pk.h
@@ -4,7 +4,7 @@
#include <tomcrypt.h>
struct ncr_pk_ctx {
- ncr_algorithm_t algorithm; /* algorithm */
+ const struct algo_properties_st *algorithm; /* algorithm */
ncr_algorithm_t sign_hash; /* for verification */
@@ -30,7 +30,7 @@ int ncr_pk_queue_init(void);
void ncr_pk_queue_deinit(void);
/* encryption/decryption */
-int ncr_pk_cipher_init(ncr_algorithm_t algo,
+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);
void ncr_pk_cipher_deinit(struct ncr_pk_ctx* ctx);
diff --git a/ncr-sessions.c b/ncr-sessions.c
index c2cb7c3..6f26e43 100644
--- a/ncr-sessions.c
+++ b/ncr-sessions.c
@@ -345,7 +345,7 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses
cryptodev_cipher_set_iv(&ns->cipher, session->params.params.cipher.iv, session->params.params.cipher.iv_size);
}
} else if (ns->key->type == NCR_KEY_TYPE_PRIVATE || ns->key->type == NCR_KEY_TYPE_PUBLIC) {
- ret = ncr_pk_cipher_init(ns->algorithm->algo, &ns->pk,
+ ret = ncr_pk_cipher_init(ns->algorithm, &ns->pk,
&session->params, ns->key);
if (ret < 0) {
err();
@@ -407,7 +407,7 @@ static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* ses
goto fail;
}
- ret = ncr_pk_cipher_init(ns->algorithm->algo, &ns->pk,
+ ret = ncr_pk_cipher_init(ns->algorithm, &ns->pk,
&session->params, ns->key);
if (ret < 0) {
err();