identify_algorithm

classmethod KeyManager.identify_algorithm(key: Union[cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKeyWithSerialization, cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PrivateKey, cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey, cryptography.hazmat.primitives.asymmetric.ed25519.Ed25519PublicKey])str[source]

Identifies a cryptography public/private key instance, such as RSAPrivateKey and returns the algorithm name that can be used with other KeyManager methods, e.g. 'rsa' or 'ed25519'

Example:

>>> priv, pub = KeyManager.generate_keypair_raw(alg='ecdsa', curve=ec.SECP521R1)
>>> KeyManager.identify_algorithm(priv)
'ecdsa'
>>> priv, pub = KeyManager.generate_keypair_raw()
>>> KeyManager.identify_algorithm(priv)
'rsa'
>>> KeyManager.identify_algorithm(pub)
'rsa'
Parameters

key (combined_key_types) – A cryptography public/private key instance

Return str algorithm

The name of the algorithm used by this key