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
This commit is contained in:
Dmitry Shachnev 2017-10-09 01:25:08 +07:00 committed by Stef Walter
parent 3e5c18bcc2
commit d3ac1c1834

View File

@ -84,6 +84,8 @@ class AesAlgorithm():
# print "mock publi: ", hex(publi) # print "mock publi: ", hex(publi)
# print " mock peer: ", hex(peer) # print " mock peer: ", hex(peer)
ikm = dh.derive_key(privat, 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) # print " mock ikm: ", hex_encode(ikm)
key = hkdf.hkdf(ikm, 16) key = hkdf.hkdf(ikm, 16)
# print " mock key: ", hex_encode(key) # print " mock key: ", hex_encode(key)