summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMat Martineau <mathew.j.martineau@linux.intel.com>2017-06-07 10:31:35 -0700
committerDavid Howells <dhowells@redhat.com>2017-06-08 13:32:16 +0100
commit62f223825386402db9f92ff4c148b1ab2a65f1b8 (patch)
tree5ea331417b6bb8da71a518c86d7fca168634c994
parentbadd34263aff2c53749774589310d232c31b8f4b (diff)
downloadkeyutils-62f223825386402db9f92ff4c148b1ab2a65f1b8.tar.gz
TEST: Add KDF leading zero test
Diffie-Hellman results used as input to a KDF algorithm can have leading zero bytes, and the current kernel DH implementation truncates leading zero bytes. This test confirms that the KDF code correctly handles DH results with leading zeros. Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--tests/keyctl/dh_compute/valid/runtest.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/keyctl/dh_compute/valid/runtest.sh b/tests/keyctl/dh_compute/valid/runtest.sh
index 6498eef..5ad1d14 100644
--- a/tests/keyctl/dh_compute/valid/runtest.sh
+++ b/tests/keyctl/dh_compute/valid/runtest.sh
@@ -171,6 +171,16 @@ marker "COMPUTE DERIVED KEY FROM DH SHARED SECRET (SHA-256)"
echo -e -n $otherinfo | dh_compute_kdf_oi $privateid $primeid $xaid 16 "sha256"
expect_multiline payload "$derived"
+pcreate_key "-e \x01" user dh:leadingzero @s
+expect_keyid lzid
+
+read -d '' derived2 <<"EOF"
+0066207b cdab1d64 bbf489b3 d6a0dadc
+EOF
+
+marker "COMPUTE DERIVED KEY WITH LEADING ZEROS"
+echo -e -n $otherinfo | dh_compute_kdf_oi $privateid $primeid $lzid 16 "sha256"
+expect_multiline payload "$derived2"
# SHA-224