Ejemplo n.º 1
0
 def test_object_encryption(self):
     """
     test_object_encryption
     """
     self.do_wait_for_tasks = False
     mydict = {"hello": "world"}
     encrypted_obj = msgpack_encrypt_pyobject("kjhfsd98", mydict)
     mydict2, secret = msgpack_decrypt_pyobject("kjhfsd98", encrypted_obj)
     self.assertEqual(mydict, mydict2)
Ejemplo n.º 2
0
def get_encrypted_configs(options, name_stop=None):
    """
    @type options: optparse.Values, instance
    @param name_stop: stop looking if this name is matched
    @type name_stop:bool
    """
    hidden_configs = get_hidden_configs(options)
    encrypted_configs = []

    for config in hidden_configs:
        config_file_path = os.path.join(options.basedir, config[0])
        config_file_path = os.path.join(config_file_path, config[1])
        cryptoboxname = unpickle_object(config_file_path)
        secret = password_derivation(options.password, cryptoboxname["salt"])
        cryptoboxname, secret = msgpack_decrypt_pyobject(secret, obj_string=cryptoboxname["encrypted_name"])
        encrypted_configs.append({"cryptoboxname": cryptoboxname, "secret": secret, "config_file_path": config_file_path})
        if name_stop == cryptoboxname:
            return encrypted_configs
    return encrypted_configs
Ejemplo n.º 3
0
def get_encrypted_configs(options, name_stop=None):
    """
    @type options: optparse.Values, instance
    @param name_stop: stop looking if this name is matched
    @type name_stop:bool
    """
    hidden_configs = get_hidden_configs(options)
    encrypted_configs = []

    for config in hidden_configs:
        config_file_path = os.path.join(options.basedir, config[0])
        config_file_path = os.path.join(config_file_path, config[1])
        cryptoboxname = unpickle_object(config_file_path)
        secret = password_derivation(options.password, cryptoboxname["salt"])
        cryptoboxname, secret = msgpack_decrypt_pyobject(
            secret, obj_string=cryptoboxname["encrypted_name"])
        encrypted_configs.append({
            "cryptoboxname": cryptoboxname,
            "secret": secret,
            "config_file_path": config_file_path
        })
        if name_stop == cryptoboxname:
            return encrypted_configs
    return encrypted_configs