diff options
author | David Howells <dhowells@redhat.com> | 2019-08-16 16:04:52 +0100 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-08-19 15:42:10 +0100 |
commit | af573e51f2abae3da702204c068043a11018e9a4 (patch) | |
tree | 8ea0280b4ab1af737e12de0bc406fa432375b202 /tests | |
parent | 9a99f28afbabb48d2164ab7819b3fd981c978d46 (diff) | |
download | keyutils-af573e51f2abae3da702204c068043a11018e9a4.tar.gz |
keyctl: Allow add, padd and suchlike to take hex-encoded data
Allow add, padd, update, pupdate, instantiate, pinstantiate and
dh_compute_kdf_oi to take hex-encoded data which is then converted into
binary before being passed to the kernel, e.g.:
$ keyctl add -x user foo 686578 @s
$ echo 686578 | keyctl padd -x user foo @s
This makes it easier to stash data in scripts.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/keyctl/add/useradd/runtest.sh | 10 | ||||
-rw-r--r-- | tests/keyctl/padd/useradd/runtest.sh | 10 | ||||
-rw-r--r-- | tests/keyctl/pupdate/bad-args/runtest.sh | 6 | ||||
-rw-r--r-- | tests/keyctl/pupdate/userupdate/runtest.sh | 2 | ||||
-rw-r--r-- | tests/keyctl/update/userupdate/runtest.sh | 9 | ||||
-rw-r--r-- | tests/toolbox.inc.sh | 8 |
6 files changed, 37 insertions, 8 deletions
diff --git a/tests/keyctl/add/useradd/runtest.sh b/tests/keyctl/add/useradd/runtest.sh index 031241c..e421a89 100644 --- a/tests/keyctl/add/useradd/runtest.sh +++ b/tests/keyctl/add/useradd/runtest.sh @@ -19,6 +19,16 @@ marker "PRINT PAYLOAD" print_key $keyid expect_payload payload "stuff" +# check that we can add a hex-encoded user key to the session keyring +marker "ADD HEX USER KEY" +create_key -x user wibble "73 7475 66 66 " @s +expect_keyid keyid + +# read back what we put in it +marker "PRINT PAYLOAD" +print_key $keyid +expect_payload payload "stuff" + # check that we can update a user key marker "UPDATE USER KEY" create_key user wibble lizard @s diff --git a/tests/keyctl/padd/useradd/runtest.sh b/tests/keyctl/padd/useradd/runtest.sh index 206a163..6bd3c09 100644 --- a/tests/keyctl/padd/useradd/runtest.sh +++ b/tests/keyctl/padd/useradd/runtest.sh @@ -19,6 +19,16 @@ marker "PRINT PAYLOAD" print_key $keyid expect_payload payload "stuff" +# check that we can add a hex-encoded user key to the session keyring +marker "ADD HEX USER KEY" +pcreate_key "73 7475 66 66 " -x user wibble @s +expect_keyid keyid + +# read back what we put in it +marker "PRINT PAYLOAD" +print_key $keyid +expect_payload payload "stuff" + # check that we can update a user key marker "UPDATE USER KEY" pcreate_key lizard user wibble @s diff --git a/tests/keyctl/pupdate/bad-args/runtest.sh b/tests/keyctl/pupdate/bad-args/runtest.sh index bced352..e8bc28f 100644 --- a/tests/keyctl/pupdate/bad-args/runtest.sh +++ b/tests/keyctl/pupdate/bad-args/runtest.sh @@ -11,12 +11,12 @@ echo "++++ BEGINNING TEST" >$OUTPUTFILE # attempt to update the session keyring marker "CHECK UPDATE SESSION KEYRING" -pupdate_key --fail @s a +echo -n "a" | pupdate_key --fail @s expect_error EOPNOTSUPP # attempt to update an invalid key marker "CHECK UPDATE INVALID KEY" -pupdate_key --fail 0 a +echo -n "a" | pupdate_key --fail 0 expect_error EINVAL # add a user key to the session keyring for us to play with @@ -30,7 +30,7 @@ unlink_key --wait $keyid @s # it should fail when we attempt to update it marker "UPDATE UNLINKED KEY" -pupdate_key --fail $keyid @s +echo -n "a" | pupdate_key --fail $keyid expect_error ENOKEY echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE diff --git a/tests/keyctl/pupdate/userupdate/runtest.sh b/tests/keyctl/pupdate/userupdate/runtest.sh index 05a77c1..eada6ff 100644 --- a/tests/keyctl/pupdate/userupdate/runtest.sh +++ b/tests/keyctl/pupdate/userupdate/runtest.sh @@ -21,7 +21,7 @@ expect_payload payload "stuff" # check that we can update a user key marker "PUPDATE USER KEY" -pupdate_key $keyid "lizard" +echo -n "lizard" | pupdate_key $keyid # read back what we changed it to marker "PRINT UPDATED PAYLOAD" diff --git a/tests/keyctl/update/userupdate/runtest.sh b/tests/keyctl/update/userupdate/runtest.sh index ddc7cd4..4a86eb3 100644 --- a/tests/keyctl/update/userupdate/runtest.sh +++ b/tests/keyctl/update/userupdate/runtest.sh @@ -28,6 +28,15 @@ marker "PRINT UPDATED PAYLOAD" print_key $keyid expect_payload payload "lizard" +# check that we can update a user key with hex-encoded data +marker "UPDATE USER KEY HEX" +update_key -x $keyid " 6c 697a 6172 64 78 " + +# read back what we changed it to +marker "PRINT UPDATED PAYLOAD" +print_key $keyid +expect_payload payload "lizardx" + # remove the key we added marker "UNLINK KEY" unlink_key $keyid @s diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh index 2b432a8..7ee5d92 100644 --- a/tests/toolbox.inc.sh +++ b/tests/toolbox.inc.sh @@ -820,8 +820,8 @@ function update_key () shift fi - echo keyctl update $1 $2 >>$OUTPUTFILE - keyctl update $1 $2 >>$OUTPUTFILE 2>&1 + echo keyctl update "$@" >>$OUTPUTFILE + keyctl update "$@" >>$OUTPUTFILE 2>&1 if [ $? != $my_exitval ] then failed @@ -842,8 +842,8 @@ function pupdate_key () shift fi - echo echo -n $2 \| keyctl pupdate $1 >>$OUTPUTFILE - echo -n $2 | keyctl pupdate $1 >>$OUTPUTFILE 2>&1 + echo keyctl pupdate "$@" >>$OUTPUTFILE + keyctl pupdate "$@" >>$OUTPUTFILE 2>&1 if [ $? != $my_exitval ] then failed |