From d3ac1c183465bed5ce906062215734a76ac310c6 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 9 Oct 2017 01:25:08 +0700 Subject: [PATCH] mock: Pad the common secret with zero bytes to make it exactly 128 bytes long This is what the C code does, see egg/egg-dh.c:340. https://bugzilla.gnome.org/show_bug.cgi?id=768112 --- libsecret/mock/service.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsecret/mock/service.py b/libsecret/mock/service.py index 5fe6706..99f2cff 100644 --- a/libsecret/mock/service.py +++ b/libsecret/mock/service.py @@ -84,6 +84,8 @@ class AesAlgorithm(): # print "mock publi: ", hex(publi) # print " mock peer: ", hex(peer) ikm = dh.derive_key(privat, peer) + # Pad the secret with zero bytes to match length of prime in bytes. + ikm = b'\x00' * (128 - len(ikm)) + ikm # print " mock ikm: ", hex_encode(ikm) key = hkdf.hkdf(ikm, 16) # print " mock key: ", hex_encode(key)