Exemplo n.º 1
0
def decrypt_entry(entry, key, iv):
    for k, v in entry.items():
        if k is not 'StringFields':
            entry[k] = ch.decrypt(base64.b64decode(v), key, iv)

    if 'StringFields' in entry:
        fields = []
        for field in entry['StringFields']:
            field['Key'] = ch.decrypt(field['Key'], key, iv, True)
            field['Value'] = ch.decrypt(field['Value'], key, iv, True)
            fields = fields + [field]
        entry['StringFields'] = fields
Exemplo n.º 2
0
def verify_response(response, key, identifier=None):
    if not response['Success']:
        return False

    iv = base64.b64decode(response['Nonce'].encode('utf-8'))
    crypted = base64.b64decode(response['Verifier'])
    value = ch.decrypt(crypted, key, iv)
    valid = value == response['Nonce']
    if identifier is not None:
        valid = valid and identifier == response['Id']
    return valid