Beispiel #1
0
    def test(self):
        vaulttext_envelope = u'''$ANSIBLE_VAULT;1.1;AES256
33363965326261303234626463623963633531343539616138316433353830356566396130353436
3562643163366231316662386565383735653432386435610a306664636137376132643732393835
63383038383730306639353234326630666539346233376330303938323639306661313032396437
6233623062366136310a633866373936313238333730653739323461656662303864663666653563
3138'''

        b_vaulttext_envelope = to_bytes(vaulttext_envelope, errors='strict', encoding='utf-8')
        b_vaulttext, b_version, cipher_name, vault_id = vault.parse_vaulttext_envelope(b_vaulttext_envelope)
        res = vault.parse_vaulttext(b_vaulttext)
        self.assertIsInstance(res[0], bytes)
        self.assertIsInstance(res[1], bytes)
        self.assertIsInstance(res[2], bytes)
Beispiel #2
0
    def test(self):
        vaulttext_envelope = u'''$ANSIBLE_VAULT;1.1;AES256
33363965326261303234626463623963633531343539616138316433353830356566396130353436
3562643163366231316662386565383735653432386435610a306664636137376132643732393835
63383038383730306639353234326630666539346233376330303938323639306661313032396437
6233623062366136310a633866373936313238333730653739323461656662303864663666653563
3138'''

        b_vaulttext_envelope = to_bytes(vaulttext_envelope, errors='strict', encoding='utf-8')
        b_vaulttext, b_version, cipher_name, vault_id = vault.parse_vaulttext_envelope(b_vaulttext_envelope)
        res = vault.parse_vaulttext(b_vaulttext)
        self.assertIsInstance(res[0], bytes)
        self.assertIsInstance(res[1], bytes)
        self.assertIsInstance(res[2], bytes)
                                                    algorithms, modes)

dir = os.path.dirname(__file__)
filename = dir + '/files/OnePointOneStringNoTag.txt'
vault_text = open(filename, 'r').read()

lib = VaultLib(secrets=[['default', VaultSecret("daniel-ness/ansible-vault")]])
print lib.decrypt(vault_text)

plaintext, vault_id, vault_secret = lib.decrypt_and_get_vault_id(vault_text)
print plaintext
print vault_text
b_vaulttext, dummy, cipher_name, vault_id = parse_vaulttext_envelope(
    vault_text)
print b_vaulttext
cipher_text, salt, crypted_hmac = parse_vaulttext(b_vaulttext)

print("Cipher Text: " + hexlify(cipher_text))
print("Salt: " + hexlify(salt))
print("HMAC: " + crypted_hmac)

aes = VaultAES256()
key1, key2, iv = aes._gen_key_initctr("daniel-ness/ansible-vault", salt)

print("Key1: " + hexlify(key1))
print("Key2: " + hexlify(key2))
print("IV: " + hexlify(iv))

print("pre decrypt:")
print(unhexlify(hexlify(cipher_text)))
cipher = C_Cipher(algorithms.AES(key1), modes.CTR(iv), default_backend())