# Path: DPAPI/Core/masterkey.py
# class MasterKey(eater.DataStruct):
# class CredHist(eater.DataStruct):
# class DomainKey(eater.DataStruct):
# class MasterKeyFile(eater.DataStruct):
# class MasterKeyPool(object):
#     def __init__(self, raw=None):
#     def __getstate__(self):
#     def __setstate__(self, d):
#     def parse(self, data):
#     def decryptWithHash(self, userSID, pwdhash):
#     def decryptWithPassword(self, userSID, pwd):
#     def setKeyHash(self, h):
#     def setDecryptedKey(self, data):
#     def decryptWithKey(self, pwdhash):
#     def __repr__(self):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def __repr__(self):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def __repr__(self):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def decryptWithHash(self, userSID, h):
#     def decryptWithPassword(self, userSID, pwd):
#     def decryptWithKey(self, pwdhash):
#     def addKeyHash(self, guid, h):
#     def addDecryptedKey(self, guid, data):
#     def get_key(self):
#     def __repr__(self):
#     def __init__(self):
#     def addMasterKey(self, mkey):
#     def addMasterKeyHash(self, guid, h):
#     def getMasterKeys(self, guid):
#     def addSystemCredential(self, blob):
#     def addCredhist(self, sid, cred):
#     def addCredhistFile(self, sid, credfile):
#     def loadDirectory(self, directory):
#     def pickle(self, filename=None):
#     def __getstate__(self):
#     def __setstate__(self, d):
#     def unpickle(data=None, filename=None):
#     def try_credential_hash(self, userSID, pwdhash):
#     def try_credential(self, userSID, password):
#     def __repr__(self):
# 
# Path: DPAPI/Core/crypto.py
# class CryptoAlgo(object):
#     class Algo(object):
#         def __init__(self, data):
#         def __getattr__(self, attr):
#     def add_algo(cls, algnum, **kargs):
#     def get_algo(cls, algnum):
#     def __init__(self, i):
#     def do_fixup_key(self, key):
#     def __repr__(self):
# def des_set_odd_parity(key):
# def CryptSessionKeyXP(masterkey, nonce, hashAlgo, entropy=None, strongPassword=None, verifBlob=None):
# def CryptSessionKeyWin7(masterkey, nonce, hashAlgo, entropy=None, strongPassword=None, verifBlob=None):
# def CryptDeriveKey(h, cipherAlgo, hashAlgo):
# def decrypt_lsa_key_nt5(lsakey, syskey):
# def decrypt_lsa_key_nt6(lsakey, syskey):
# def SystemFunction005(secret, key):
# def decrypt_lsa_secret(secret, lsa_keys):
# def pbkdf2(passphrase, salt, keylen, iterations, digest='sha1'):
# def derivePwdHash(pwdhash, userSID, digest='sha1'):
# def dataDecrypt(cipherAlgo, hashAlgo, raw, encKey, iv, rounds):
# def DPAPIHmac(hashAlgo, pwdhash, hmacSalt, value):
#         U = salt + struct.pack("!L", i)
# 
# Path: DPAPI/Core/blob.py
# class DPAPIBlob(eater.DataStruct):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def decrypt(self, masterkey, entropy=None, strongPassword=None):
#     def __repr__(self):


import unittest
from DPAPI.Core import masterkey
from DPAPI.Core import crypto
from DPAPI.Core import blob
    def test_decrypt_good_key_bad_entropy(self):
        self.blob.decrypt(self.mkey, None, None)

        self.assertFalse(self.blob.decrypted)

    def test_decrypt_good_key_good_entropy(self):
        self.blob.decrypt(self.mkey, self.entropy, None)

        self.assertTrue(self.blob.decrypted)
        self.assertEqual(self.blob.sign, self.blob.signComputed)
        self.assertEqual(self.blob.cleartext, "This entropy was not faked")


class BlobWin8SimpleTest(unittest.TestCase):
    def setUp(self):
        self.raw = ("01000000d08c9ddf0115d1118c7a00c0"
                    "4fc297eb010000003fb376ba974b974e"
                    "96037865fb972cec0000000002000000"
                    "00001066000000010000200000009798"
                    "683005ff678f507036b44bcbbcfe1501"
                    "15346bf67bd75ad73b42ce6331bf0000"
                    "00000e800000000200002000000040da"
                    "71bec41e2cf971d270977099e1d34030"
                    "f0875de802967769f7b4906cbc951000"
                    "00005ccee1467028df028177bda3c9c3"
                    "40574000000045fb9275a0e852ed4b9f"
                    "2e34ec6100bb2d3bd5225da37bccb73b"
                    "fb89b4073dc215840c8beeb728201ab6"
                    "9a41945c944cf6ae645d2e69d00b752c"
                    "a1552b42ed3d").decode("hex")

# Path: DPAPI/Core/masterkey.py
# class MasterKey(eater.DataStruct):
# class CredHist(eater.DataStruct):
# class DomainKey(eater.DataStruct):
# class MasterKeyFile(eater.DataStruct):
# class MasterKeyPool(object):
#     def __init__(self, raw=None):
#     def __getstate__(self):
#     def __setstate__(self, d):
#     def parse(self, data):
#     def decryptWithHash(self, userSID, pwdhash):
#     def decryptWithPassword(self, userSID, pwd):
#     def setKeyHash(self, h):
#     def setDecryptedKey(self, data):
#     def decryptWithKey(self, pwdhash):
#     def __repr__(self):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def __repr__(self):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def __repr__(self):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def decryptWithHash(self, userSID, h):
#     def decryptWithPassword(self, userSID, pwd):
#     def decryptWithKey(self, pwdhash):
#     def addKeyHash(self, guid, h):
#     def addDecryptedKey(self, guid, data):
#     def get_key(self):
#     def __repr__(self):
#     def __init__(self):
#     def addMasterKey(self, mkey):
#     def addMasterKeyHash(self, guid, h):
#     def getMasterKeys(self, guid):
#     def addSystemCredential(self, blob):
#     def addCredhist(self, sid, cred):
#     def addCredhistFile(self, sid, credfile):
#     def loadDirectory(self, directory):
#     def pickle(self, filename=None):
#     def __getstate__(self):
#     def __setstate__(self, d):
#     def unpickle(data=None, filename=None):
#     def try_credential_hash(self, userSID, pwdhash):
#     def try_credential(self, userSID, password):
#     def __repr__(self):
# 
# Path: DPAPI/Core/crypto.py
# class CryptoAlgo(object):
#     class Algo(object):
#         def __init__(self, data):
#         def __getattr__(self, attr):
#     def add_algo(cls, algnum, **kargs):
#     def get_algo(cls, algnum):
#     def __init__(self, i):
#     def do_fixup_key(self, key):
#     def __repr__(self):
# def des_set_odd_parity(key):
# def CryptSessionKeyXP(masterkey, nonce, hashAlgo, entropy=None, strongPassword=None, verifBlob=None):
# def CryptSessionKeyWin7(masterkey, nonce, hashAlgo, entropy=None, strongPassword=None, verifBlob=None):
# def CryptDeriveKey(h, cipherAlgo, hashAlgo):
# def decrypt_lsa_key_nt5(lsakey, syskey):
# def decrypt_lsa_key_nt6(lsakey, syskey):
# def SystemFunction005(secret, key):
# def decrypt_lsa_secret(secret, lsa_keys):
# def pbkdf2(passphrase, salt, keylen, iterations, digest='sha1'):
# def derivePwdHash(pwdhash, userSID, digest='sha1'):
# def dataDecrypt(cipherAlgo, hashAlgo, raw, encKey, iv, rounds):
# def DPAPIHmac(hashAlgo, pwdhash, hmacSalt, value):
#         U = salt + struct.pack("!L", i)
# 
# Path: DPAPI/Core/blob.py
# class DPAPIBlob(eater.DataStruct):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def decrypt(self, masterkey, entropy=None, strongPassword=None):
#     def __repr__(self):


# Path: tests/blob.py
import unittest
from DPAPI.Core import masterkey
from DPAPI.Core import crypto
from DPAPI.Core import blob

    def test_decrypt_good_key_bad_entropy(self):
        self.blob.decrypt(self.mkey, None, None)

        self.assertFalse(self.blob.decrypted)

    def test_decrypt_good_key_good_entropy(self):
        self.blob.decrypt(self.mkey, self.entropy, None)

        self.assertTrue(self.blob.decrypted)
        self.assertEqual(self.blob.sign, self.blob.signComputed)
        self.assertEqual(self.blob.cleartext, "This entropy was not faked")


class BlobWin8SimpleTest(unittest.TestCase):
    def setUp(self):
        self.raw = ("01000000d08c9ddf0115d1118c7a00c0"
                    "4fc297eb010000003fb376ba974b974e"
                    "96037865fb972cec0000000002000000"
                    "00001066000000010000200000009798"
                    "683005ff678f507036b44bcbbcfe1501"
                    "15346bf67bd75ad73b42ce6331bf0000"
                    "00000e800000000200002000000040da"
                    "71bec41e2cf971d270977099e1d34030"
                    "f0875de802967769f7b4906cbc951000"
                    "00005ccee1467028df028177bda3c9c3"
                    "40574000000045fb9275a0e852ed4b9f"
                    "2e34ec6100bb2d3bd5225da37bccb73b"
                    "fb89b4073dc215840c8beeb728201ab6"
                    "9a41945c944cf6ae645d2e69d00b752c"
                    "a1552b42ed3d").decode("hex")

        self.mkey = ("c942b584a88a36f3ce8abe61a62d4036"