summaryrefslogtreecommitdiff
path: root/verify.py
blob: e3f3bc8a7a1bafd900e7fc273f93b340a74ae7c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/python

import binascii
import codecs
import hashlib
import hmac
import random
import string
import subprocess
import sys

with open('.shared_secret', 'r') as file:
    ssh = file.read().strip()

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)