summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-08-27 08:40:05 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-08-27 08:40:05 +0200
commitc9c3bf34c8f7c12c0d961bf7c0beb13ad5b24950 (patch)
tree919229afcf2578335d826648f676fca791a2b86b
parent9f0a6ce7f41043dad38b272cd6ad165f98827b8b (diff)
parent114f42fe23152f6726144fe82eb62f400cfe1dba (diff)
downloadkernel-crypto-c9c3bf34c8f7c12c0d961bf7c0beb13ad5b24950.tar.gz
kernel-crypto-c9c3bf34c8f7c12c0d961bf7c0beb13ad5b24950.tar.xz
kernel-crypto-c9c3bf34c8f7c12c0d961bf7c0beb13ad5b24950.zip
Merge branch 'session_update-iv'
-rw-r--r--crypto.44
-rw-r--r--ncr-sessions.c19
2 files changed, 23 insertions, 0 deletions
diff --git a/crypto.4 b/crypto.4
index 23c4c2ba47a..a1339339841 100644
--- a/crypto.4
+++ b/crypto.4
@@ -576,6 +576,10 @@ member.
The following input attributes are recognized:
.RS
+.IP \fBNCR_ATTR_IV\fP
+Only used for some operations and algorithms.
+Optional,
+IV from session initialization or left from last update is used if not present.
.IP \fBNCR_ATTR_UPDATE_INPUT_DATA\fP
A
.B struct ncr_session_input_data
diff --git a/ncr-sessions.c b/ncr-sessions.c
index 0e48865c599..3691127a757 100644
--- a/ncr-sessions.c
+++ b/ncr-sessions.c
@@ -817,6 +817,7 @@ static int get_userbuf2(struct session_item_st *ses, struct nlattr *tb[],
static int _ncr_session_update(struct session_item_st *sess,
struct nlattr *tb[], int compat)
{
+ const struct nlattr *nla;
int ret;
struct scatterlist *isg = NULL;
struct scatterlist *osg = NULL;
@@ -846,6 +847,15 @@ static int _ncr_session_update(struct session_item_st *sess,
goto fail;
}
+ if (sess->algorithm->is_symmetric
+ && sess->algorithm->needs_iv) {
+ nla = tb[NCR_ATTR_IV];
+ if (nla != NULL)
+ cryptodev_cipher_set_iv(&sess->cipher,
+ nla_data(nla),
+ nla_len(nla));
+ }
+
ret = _ncr_session_encrypt(sess, isg, isg_cnt, isg_size,
osg, osg_cnt, &osg_size);
if (ret < 0) {
@@ -874,6 +884,15 @@ static int _ncr_session_update(struct session_item_st *sess,
goto fail;
}
+ if (sess->algorithm->is_symmetric
+ && sess->algorithm->needs_iv) {
+ nla = tb[NCR_ATTR_IV];
+ if (nla != NULL)
+ cryptodev_cipher_set_iv(&sess->cipher,
+ nla_data(nla),
+ nla_len(nla));
+ }
+
ret = _ncr_session_decrypt(sess, isg, isg_cnt, isg_size,
osg, osg_cnt, &osg_size);
if (ret < 0) {