summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ncr-key.c12
-rw-r--r--ncr.c4
-rw-r--r--ncr_int.h2
3 files changed, 12 insertions, 6 deletions
diff --git a/ncr-key.c b/ncr-key.c
index fcdda09..4aa6a06 100644
--- a/ncr-key.c
+++ b/ncr-key.c
@@ -419,6 +419,7 @@ int ncr_key_generate(struct list_sem_st* lst, void __user* arg)
{
struct ncr_key_generate_st gen;
struct key_item_st* item = NULL;
+const struct algo_properties_st *algo;
int ret;
size_t size;
@@ -437,7 +438,12 @@ size_t size;
/* we generate only secret keys */
item->flags = gen.params.keyflags;
- item->type = ncr_algorithm_to_key_type(gen.params.algorithm);
+ algo = _ncr_algo_to_properties(gen.params.algorithm);
+ if (algo == NULL) {
+ err();
+ return ret;
+ }
+ item->type = ncr_algorithm_to_key_type(algo);
if (item->type == NCR_KEY_TYPE_SECRET) {
/* arbitrary */
item->algorithm = _ncr_algo_to_properties(NCR_ALG_AES_CBC);
@@ -527,14 +533,14 @@ int ret;
/* we generate only secret keys */
private->flags = public->flags = gen.params.keyflags;
- public->type = ncr_algorithm_to_key_type(gen.params.algorithm);
- private->type = NCR_KEY_TYPE_PRIVATE;
private->algorithm = public->algorithm = _ncr_algo_to_properties(gen.params.algorithm);
if (private->algorithm == NULL) {
err();
ret = -EINVAL;
goto fail;
}
+ public->type = ncr_algorithm_to_key_type(public->algorithm);
+ private->type = NCR_KEY_TYPE_PRIVATE;
public->flags |= (NCR_KEY_FLAG_EXPORTABLE|NCR_KEY_FLAG_WRAPPABLE);
if (public->type == NCR_KEY_TYPE_PUBLIC) {
diff --git a/ncr.c b/ncr.c
index 5740580..f68a1d8 100644
--- a/ncr.c
+++ b/ncr.c
@@ -177,9 +177,9 @@ ncr_ioctl(struct ncr_lists* lst, struct file *filp,
/* Returns NCR_KEY_TYPE_SECRET if a secret key algorithm or MAC is given,
* and NCR_KEY_TYPE_PUBLIC if a public key algorithm is given.
*/
-ncr_key_type_t ncr_algorithm_to_key_type(ncr_algorithm_t algo)
+ncr_key_type_t ncr_algorithm_to_key_type(const struct algo_properties_st *algo)
{
- switch(algo) {
+ switch(algo->algo) {
case NCR_ALG_3DES_CBC:
case NCR_ALG_AES_CBC:
case NCR_ALG_CAMELLIA_CBC:
diff --git a/ncr_int.h b/ncr_int.h
index 47eb419..93936ca 100644
--- a/ncr_int.h
+++ b/ncr_int.h
@@ -154,7 +154,7 @@ int ncr_limits_add_and_check(uid_t uid, pid_t pid, limits_type_t type);
void ncr_limits_init(void);
void ncr_limits_deinit(void);
-ncr_key_type_t ncr_algorithm_to_key_type(ncr_algorithm_t algo);
+ncr_key_type_t ncr_algorithm_to_key_type(const struct algo_properties_st *algo);
int ncr_key_wrap(struct list_sem_st* keys, struct list_sem_st* data, void __user* arg);
int ncr_key_unwrap(struct list_sem_st*, struct list_sem_st* data, void __user* arg);