import base64


def decode_key(fname):
    """Convert base64 encoded openssh key to binary"""
    contents = open(fname).read()
    fields = contents.split()

    in_key = False
    for f in fields:
        f = f.strip()
        if f.startswith("ssh-"):
            in_key = True
            continue
        elif in_key:
            return base64.b64decode(f)
        
    return None