From dbb2f11a32cdde060798c14cdac33f95e22f39bb Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Wed, 18 Aug 2010 03:29:12 +0200 Subject: Simplify algorithm lookup by nla --- ncr-int.h | 3 +++ ncr-sessions.c | 8 ++++++++ 2 files changed, 11 insertions(+) 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 #include +#include 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; -- cgit