# 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_good_entropy(self):
        self.blob.decrypt(self.mkey, None, None)

        self.assertTrue(self.blob.decrypted)
        self.assertEqual(self.blob.sign, self.blob.signComputed)
        self.assertEqual(self.blob.cleartext, "This is for real !")


class BlobXPEntropyTest(unittest.TestCase):
    def setUp(self):
        self.raw = ("01000000d08c9ddf0115d1118c7a00c0"
                    "4fc297eb0100000018fa1d263223e549"
                    "93d9388d2f271486000000003c000000"
                    "4400500041005000490063006b002000"
                    "730069006d0070006c00650020006200"
                    "6c006f0062002000670065006e006500"
                    "7200610074006f007200000003660000"
                    "a8000000100000000c1e54f10d3ac713"
                    "ef4c19dbc440e4a70000000004800000"
                    "a000000010000000bde7c0f3b1d5def7"
                    "cbb6669c2c2b361c2000000062658248"
                    "66ed719fe25046d193bf6fd8252be099"
                    "ac10609b50677b57ea61bbbf14000000"
                    "5906ca660b04e0c1bce743ebe5b21aa9"
                    "e79acc1f").decode("hex")
        self.mkey = ("d0c624a61e4080ac28ec07f33466581ec"
                     "04980f26953aa940258dc4ced7fd5452"
                     "51208d88d6bac5c64b5cd69b4e214009"
                     "3174f51ab07f0f5fb7a45462a2c00e4").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_good_entropy(self):
        self.blob.decrypt(self.mkey, None, None)

        self.assertTrue(self.blob.decrypted)
        self.assertEqual(self.blob.sign, self.blob.signComputed)
        self.assertEqual(self.blob.cleartext, "This is for real !")


class BlobXPEntropyTest(unittest.TestCase):
    def setUp(self):
        self.raw = ("01000000d08c9ddf0115d1118c7a00c0"
                    "4fc297eb0100000018fa1d263223e549"
                    "93d9388d2f271486000000003c000000"
                    "4400500041005000490063006b002000"
                    "730069006d0070006c00650020006200"
                    "6c006f0062002000670065006e006500"
                    "7200610074006f007200000003660000"
                    "a8000000100000000c1e54f10d3ac713"
                    "ef4c19dbc440e4a70000000004800000"
                    "a000000010000000bde7c0f3b1d5def7"
                    "cbb6669c2c2b361c2000000062658248"
                    "66ed719fe25046d193bf6fd8252be099"
                    "ac10609b50677b57ea61bbbf14000000"
                    "5906ca660b04e0c1bce743ebe5b21aa9"
                    "e79acc1f").decode("hex")
        self.mkey = ("d0c624a61e4080ac28ec07f33466581ec"
                     "04980f26953aa940258dc4ced7fd5452"
                     "51208d88d6bac5c64b5cd69b4e214009"
                     "3174f51ab07f0f5fb7a45462a2c00e4").decode("hex")

        self.blob = blob.DPAPIBlob(self.raw)