How to use the pykeepass.kdbx_parsing.common.compute_key_composite function in pykeepass

To help you get started, we’ve selected a few pykeepass examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libkeepass / pykeepass / pykeepass / kdbx_parsing / kdbx4.py View on Github external
if context._._.transformed_key is not None:
        transformed_key = context._._.transformed_key
    elif kdf_parameters['$UUID'].value == kdf_uuids['argon2']:
        transformed_key = argon2.low_level.hash_secret_raw(
            secret=key_composite,
            salt=kdf_parameters['S'].value,
            hash_len=32,
            type=argon2.low_level.Type.D,
            time_cost=kdf_parameters['I'].value,
            memory_cost=kdf_parameters['M'].value // 1024,
            parallelism=kdf_parameters['P'].value,
            version=kdf_parameters['V'].value
        )
    elif kdf_parameters['$UUID'].value == kdf_uuids['aeskdf']:
        key_composite = compute_key_composite(
            password=context._._.password,
            keyfile=context._._.keyfile
        )
        transformed_key = aes_kdf(
            kdf_parameters['S'].value,
            kdf_parameters['R'].value,
            key_composite
        )
    else:
        raise Exception('Unsupported key derivation method')

    return transformed_key
github libkeepass / pykeepass / pykeepass / kdbx_parsing / kdbx4.py View on Github external
def compute_transformed(context):
    """Compute transformed key for opening database"""

    key_composite = compute_key_composite(
        password=context._._.password,
        keyfile=context._._.keyfile
    )
    kdf_parameters = context._.header.value.dynamic_header.kdf_parameters.data.dict

    if context._._.transformed_key is not None:
        transformed_key = context._._.transformed_key
    elif kdf_parameters['$UUID'].value == kdf_uuids['argon2']:
        transformed_key = argon2.low_level.hash_secret_raw(
            secret=key_composite,
            salt=kdf_parameters['S'].value,
            hash_len=32,
            type=argon2.low_level.Type.D,
            time_cost=kdf_parameters['I'].value,
            memory_cost=kdf_parameters['M'].value // 1024,
            parallelism=kdf_parameters['P'].value,
github libkeepass / pykeepass / pykeepass / kdbx_parsing / kdbx3.py View on Github external
def compute_transformed(context):
    """Compute transformed key for opening database"""

    if context._._.transformed_key is not None:
        transformed_key = context._._.transformed_key
    else:
        key_composite = compute_key_composite(
            password=context._._.password,
            keyfile=context._._.keyfile
        )
        transformed_key = aes_kdf(
            context._.header.value.dynamic_header.transform_seed.data,
            context._.header.value.dynamic_header.transform_rounds.data,
            key_composite
        )

    return transformed_key