# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/util/scram.py
# def get_nonce():
# def get_nonce_16():
# def _hash_sha256(client_key, algorithm):
# def salted_password(salt, iterations, algorithm_name, password):
# def salted_password_2(salt, iterations, algorithm_name, password):
# def base64_no_padding(s):
# def regex_after_equal(s):
# def _xor(s1, s2):
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)
# 
# Path: pyhaystack/client/http/exceptions.py
# class HTTPStatusError(HTTPBaseError):
#     """
#     Error class to represent a returned failed status from the host.
#     """
# 
#     def __init__(self, message, status, headers=None, body=None):
#         self.headers = headers
#         self.body = body
#         self.status = status
#         super(HTTPStatusError, self).__init__(message, status)


import fysom
import hmac
import re
from hashlib import sha256
from binascii import unhexlify, b2a_base64, hexlify
from ....util import state, scram
from ....util.asyncexc import AsynchronousException
from ...http.exceptions import HTTPStatusError
    def _do_done(self, event):
        """
        Return the result from the state machine.
        """
        self._done(event.result)


def binary_encoding(string, encoding="utf-8"):
    """
    This helper function will allow compatibility with Python 2 and 3
    """
    try:
        return bytes(string, encoding)
    except TypeError:  # We are in Python 2
        return str(string)


def get_jession(arg_header):
    set_cookie = arg_header.split(",")
    for key in set_cookie:
        if "JSESSIONID=" in key:
            jsession = scram.regex_after_equal(key)
            jsession = jsession.split(";")[0]
            return jsession


def _createClientProof(salted_password, auth_msg, algorithm):
    client_key = hmac.new(
        unhexlify(salted_password), "Client Key".encode("UTF-8"), algorithm
    ).hexdigest()

# Path: pyhaystack/util/state.py
# @property
# def state(self):
#     """
#     Return the current state machine's state.
#     """
#     return self._state_machine.current
# 
# Path: pyhaystack/util/scram.py
# def get_nonce():
# def get_nonce_16():
# def _hash_sha256(client_key, algorithm):
# def salted_password(salt, iterations, algorithm_name, password):
# def salted_password_2(salt, iterations, algorithm_name, password):
# def base64_no_padding(s):
# def regex_after_equal(s):
# def _xor(s1, s2):
# 
# Path: pyhaystack/util/asyncexc.py
# class AsynchronousException(object):
#     def __init__(self):
#         self._exc_info = exc_info()
# 
#     def reraise(self):
#         reraise(*self._exc_info)
# 
# Path: pyhaystack/client/http/exceptions.py
# class HTTPStatusError(HTTPBaseError):
#     """
#     Error class to represent a returned failed status from the host.
#     """
# 
#     def __init__(self, message, status, headers=None, body=None):
#         self.headers = headers
#         self.body = body
#         self.status = status
#         super(HTTPStatusError, self).__init__(message, status)


# Path: pyhaystack/client/ops/vendor/niagara_scram.py
import fysom
import hmac
import re
from hashlib import sha256
from binascii import unhexlify, b2a_base64, hexlify
from ....util import state, scram
from ....util.asyncexc import AsynchronousException
from ...http.exceptions import HTTPStatusError

    def _do_done(self, event):
        """
        Return the result from the state machine.
        """
        self._done(event.result)


def binary_encoding(string, encoding="utf-8"):
    """
    This helper function will allow compatibility with Python 2 and 3
    """
    try:
        return bytes(string, encoding)
    except TypeError:  # We are in Python 2
        return str(string)


def get_jession(arg_header):
    set_cookie = arg_header.split(",")
    for key in set_cookie:
        if "JSESSIONID=" in key:
            jsession = scram.regex_after_equal(key)
            jsession = jsession.split(";")[0]
            return jsession


def _createClientProof(salted_password, auth_msg, algorithm):
    client_key = hmac.new(
        unhexlify(salted_password), "Client Key".encode("UTF-8"), algorithm
    ).hexdigest()

    stored_key = scram._hash_sha256(unhexlify(client_key), algorithm)