summaryrefslogtreecommitdiffstats
path: root/ncr-pk.c
diff options
context:
space:
mode:
Diffstat (limited to 'ncr-pk.c')
-rw-r--r--ncr-pk.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/ncr-pk.c b/ncr-pk.c
index ecac4c777b2..c6055dba1d5 100644
--- a/ncr-pk.c
+++ b/ncr-pk.c
@@ -632,30 +632,27 @@ int ret;
err();
return -EINVAL;
}
- switch(nla_get_u32(nla)) {
- case NCR_DERIVE_DH:
- if (oldkey->type != NCR_KEY_TYPE_PRIVATE &&
- oldkey->algorithm->algo != NCR_ALG_DH) {
- err();
- return -EINVAL;
- }
+ if (nla_strcmp(nla, NCR_DERIVE_DH) == 0) {
+ if (oldkey->type != NCR_KEY_TYPE_PRIVATE &&
+ oldkey->algorithm->algo != NCR_ALG_DH) {
+ err();
+ return -EINVAL;
+ }
- nla = tb[NCR_ATTR_DH_PUBLIC];
- if (nla == NULL) {
- err();
- return -EINVAL;
- }
- ret = dh_derive_gxy(newkey, &oldkey->key.pk.dh,
- nla_data(nla), nla_len(nla));
- if (ret < 0) {
- err();
- return ret;
- }
-
- break;
- default:
+ nla = tb[NCR_ATTR_DH_PUBLIC];
+ if (nla == NULL) {
err();
return -EINVAL;
+ }
+ ret = dh_derive_gxy(newkey, &oldkey->key.pk.dh, nla_data(nla),
+ nla_len(nla));
+ if (ret < 0) {
+ err();
+ return ret;
+ }
+ } else {
+ err();
+ return -EINVAL;
}
return 0;