def test_get_asym_key_all(): # When not marked for a special usage this key can be use for everything rsakey = RSAKey( priv_key=import_private_rsa_key_from_file(full_path("rsa.key"))) assert rsakey.appropriate_for("sign") assert rsakey.appropriate_for("verify") assert rsakey.appropriate_for("encrypt") assert rsakey.appropriate_for("decrypt") rsakey.use = "sig" # Now it can only be used for signing and signature verification assert rsakey.appropriate_for("sign") assert rsakey.appropriate_for("verify") for usage in ["encrypt", "decrypt"]: assert rsakey.appropriate_for(usage) is None rsakey.use = "enc" # Now it can only be used for encrypting and decrypting assert rsakey.appropriate_for("encrypt") assert rsakey.appropriate_for("decrypt") for usage in ["sign", "verify"]: assert rsakey.appropriate_for(usage) is None
def test_get_asym_key_all(): # When not marked for a special usage this key can be use for everything rsakey = RSAKey( priv_key=import_private_rsa_key_from_file(full_path("rsa.key"))) assert rsakey.appropriate_for('sign') assert rsakey.appropriate_for('verify') assert rsakey.appropriate_for('encrypt') assert rsakey.appropriate_for('decrypt') rsakey.use = 'sig' # Now it can only be used for signing and signature verification assert rsakey.appropriate_for('sign') assert rsakey.appropriate_for('verify') for usage in ['encrypt', 'decrypt']: assert rsakey.appropriate_for(usage) is None rsakey.use = 'enc' # Now it can only be used for encrypting and decrypting assert rsakey.appropriate_for('encrypt') assert rsakey.appropriate_for('decrypt') for usage in ['sign', 'verify']: assert rsakey.appropriate_for(usage) is None