diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-08-25 00:28:25 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-08-25 00:28:25 +0200 |
commit | d9c91873ac6dee10aeb7e165dee3aefc5f79bba8 (patch) | |
tree | 55cd455c5b6b8cc3a532a36bcd21b135425afda5 /ncr-key-wrap.c | |
parent | cc60983067194a6e7bdc12c7771aeaff6762a253 (diff) | |
parent | 1ba66cab0563708d551e3462c249f1da21695882 (diff) | |
download | cryptodev-linux-d9c91873ac6dee10aeb7e165dee3aefc5f79bba8.tar.gz cryptodev-linux-d9c91873ac6dee10aeb7e165dee3aefc5f79bba8.tar.xz cryptodev-linux-d9c91873ac6dee10aeb7e165dee3aefc5f79bba8.zip |
Merge branch 'bugfixes' into nlattr
Conflicts:
cryptodev_main.c
examples/ncr.c
examples/pk.c
ncr-int.h
ncr-key-wrap.c
ncr-key.c
ncr.c
ncr.h
Diffstat (limited to 'ncr-key-wrap.c')
-rw-r--r-- | ncr-key-wrap.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/ncr-key-wrap.c b/ncr-key-wrap.c index 4111ab1..c409bb9 100644 --- a/ncr-key-wrap.c +++ b/ncr-key-wrap.c @@ -471,14 +471,20 @@ const uint8_t *iv; goto cleanup; } + nla = tb[NCR_ATTR_KEY_FLAGS]; + if (nla != NULL) { + ret = ncr_key_assign_flags(output, nla_get_u32(nla)); + if (ret != 0) { + err(); + goto cleanup; + } + } + memset(&output->key, 0, sizeof(output->key)); for (i=0;i<n;i++) { memcpy(&output->key.secret.data[i*8], R[i], sizeof(R[i])); } output->key.secret.size = n*8; - nla = tb[NCR_ATTR_KEY_FLAGS]; - if (nla != NULL) - ncr_key_assign_flags(output, nla_get_u32(nla)); output->type = NCR_KEY_TYPE_SECRET; ret = 0; @@ -876,10 +882,21 @@ static int key_from_packed_data(struct nlattr *tb[], struct key_item_st *key, return -EINVAL; } - key->type = key->algorithm->key_type; + nla = tb[NCR_ATTR_KEY_TYPE]; + if (tb == NULL) { + err(); + return -EINVAL; + } + key->type = nla_get_u32(nla); + nla = tb[NCR_ATTR_KEY_FLAGS]; - if (nla != NULL) - ncr_key_assign_flags(key, nla_get_u32(nla)); + if (nla != NULL) { + ret = ncr_key_assign_flags(key, nla_get_u32(nla)); + if (ret != 0) { + err(); + return ret; + } + } if (key->type == NCR_KEY_TYPE_SECRET) { if (data_size > NCR_CIPHER_MAX_KEY_LEN) { |