File diff 66115b023ec7 → c3e3f7ebf69d
gimmecert/crypto.py
Show inline comments
 
@@ -460,12 +460,14 @@ def key_specification_from_public_key(public_key):
 
    :type public_key: cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey
 

	
 
    :returns: Key algorithm and parameter(s) for generating same type of keys as the passed-in public key.
 
    :rtype: tuple(str, int)
 
    :rtype: tuple(str, int or cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve)
 

	
 
    :raises ValueError: If algorithm/parameters could not be derived from the passed-in public key.
 
    """
 

	
 
    if isinstance(public_key, cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey):
 
        return "rsa", public_key.key_size
 
    elif isinstance(public_key, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey):
 
        return "ecdsa", type(public_key.curve)
 

	
 
    raise ValueError("Unsupported public key instance passed-in: \"%s\" (%s)" % (str(public_key), type(public_key)))