# Path: yubioath/yubicommon/compat.py
# def int2byte(i):
#     if _PY2:
#         return chr(i)
#     return bytes((i,))
# 
# def byte2int(i):
#     if _PY2:
#         return ord(i)
#     return i


from yubioath.yubicommon.compat import int2byte, byte2int
from Crypto.Hash import HMAC, SHA
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Random import get_random_bytes
    from urlparse import urlparse, parse_qs
    from urllib import unquote
    from urllib.parse import unquote, urlparse, parse_qs
        from win32com.client import GetObject
        from win32api import OpenProcess, CloseHandle, TerminateProcess
import subprocess
import struct
import time
import sys
import re
# non-source form of such a combination shall include the source code
# for the parts of OpenSSL used as well as that of the covered work.

from __future__ import print_function

try:
except ImportError:

__all__ = [
    'hmac_sha1',
    'derive_key',
    'der_pack',
    'der_read',
    'get_random_bytes'
]


#
# OATH related
#

def hmac_sha1(secret, message):
    return HMAC.new(secret, message, digestmod=SHA).digest()


def time_challenge(t=None):
    return struct.pack('>q', int((t or time.time())/30))


def parse_full(resp):

# Path: yubioath/yubicommon/compat.py
# def int2byte(i):
#     if _PY2:
#         return chr(i)
#     return bytes((i,))
# 
# def byte2int(i):
#     if _PY2:
#         return ord(i)
#     return i


# Path: yubioath/core/utils.py
from yubioath.yubicommon.compat import int2byte, byte2int
from Crypto.Hash import HMAC, SHA
from Crypto.Protocol.KDF import PBKDF2
from Crypto.Random import get_random_bytes
    from urlparse import urlparse, parse_qs
    from urllib import unquote
    from urllib.parse import unquote, urlparse, parse_qs
        from win32com.client import GetObject
        from win32api import OpenProcess, CloseHandle, TerminateProcess
import subprocess
import struct
import time
import sys
import re

# non-source form of such a combination shall include the source code
# for the parts of OpenSSL used as well as that of the covered work.

from __future__ import print_function

try:
except ImportError:

__all__ = [
    'hmac_sha1',
    'derive_key',
    'der_pack',
    'der_read',
    'get_random_bytes'
]


#
# OATH related
#

def hmac_sha1(secret, message):
    return HMAC.new(secret, message, digestmod=SHA).digest()


def time_challenge(t=None):
    return struct.pack('>q', int((t or time.time())/30))


def parse_full(resp):

    offs = byte2int(resp[-1]) & 0xf