#!/bin/python import binascii import codecs import hashlib import hmac import random import string import subprocess import sys ssh = b'840fedcacdb9e86f1ae1e6a0060de471d4f5fb35' ss = codecs.decode(ssh, 'hex') chh = ''.join(random.choice('0123456789abcdef') for i in range(126)) ch = codecs.decode(chh, 'hex') actual = subprocess.check_output(['ykchalresp', '-2', '-x', chh]).strip().decode() expected = hmac.new(ss, ch, hashlib.sha1).hexdigest() if actual == expected: sys.exit(0) else sys.exit(1)