summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-08-18 03:29:12 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-08-24 22:51:00 +0200
commitdbb2f11a32cdde060798c14cdac33f95e22f39bb (patch)
treedd8ba40445effe4451769a957213e4f8a158a913
parentf1382e005ed777e286c4c88fd8320ba133f8c0c6 (diff)
downloadcryptodev-linux-dbb2f11a32cdde060798c14cdac33f95e22f39bb.tar.gz
cryptodev-linux-dbb2f11a32cdde060798c14cdac33f95e22f39bb.tar.xz
cryptodev-linux-dbb2f11a32cdde060798c14cdac33f95e22f39bb.zip
Simplify algorithm lookup by nla
-rw-r--r--ncr-int.h3
-rw-r--r--ncr-sessions.c8
2 files changed, 11 insertions, 0 deletions
diff --git a/ncr-int.h b/ncr-int.h
index b7c6ed4..2a45907 100644
--- a/ncr-int.h
+++ b/ncr-int.h
@@ -14,6 +14,8 @@
#define err() printk(KERN_DEBUG"ncr: %s: %s: %d\n", __FILE__, __func__, __LINE__)
+struct nlattr;
+
struct algo_properties_st {
ncr_algorithm_t algo;
const char *kstr;
@@ -172,6 +174,7 @@ int key_to_storage_data( uint8_t** data, size_t * data_size, const struct key_it
/* misc helper macros */
const struct algo_properties_st *_ncr_algo_to_properties(ncr_algorithm_t algo);
+const struct algo_properties_st *_ncr_nla_to_properties(const struct nlattr *nla);
const struct algo_properties_st *ncr_key_params_get_sign_hash(const struct algo_properties_st *algo, struct ncr_key_params_st * params);
int _ncr_key_get_sec_level(struct key_item_st* item);
diff --git a/ncr-sessions.c b/ncr-sessions.c
index 711963b..320a061 100644
--- a/ncr-sessions.c
+++ b/ncr-sessions.c
@@ -29,6 +29,7 @@
#include "ncr-int.h"
#include <linux/mm_types.h>
#include <linux/scatterlist.h>
+#include <net/netlink.h>
static int _ncr_session_update_key(struct ncr_lists* lists, struct ncr_session_op_st* op);
static void _ncr_session_remove(struct ncr_lists *lst, ncr_session_t desc);
@@ -214,6 +215,13 @@ const struct algo_properties_st *_ncr_algo_to_properties(ncr_algorithm_t algo)
return NULL;
}
+const struct algo_properties_st *_ncr_nla_to_properties(const struct nlattr *nla)
+{
+ if (nla == NULL)
+ return NULL;
+ return _ncr_algo_to_properties(nla_get_u32(nla));
+}
+
static int _ncr_session_init(struct ncr_lists* lists, struct ncr_session_st* session)
{
struct session_item_st* ns = NULL;