예제 #1
0
파일: ecc.py 프로젝트: w13b3/do_not_use-py
def __assure_public_key(public_key: ec) -> None:
    """
    Check if a public key is a public key
    :param public_key: ec  the public key to check
    :raises InvalidKey: if given key is invalid
    :return: None
    """
    public_keys = (ec.EllipticCurvePublicKey, ec.EllipticCurvePublicNumbers,
                   ec.EllipticCurvePublicKeyWithSerialization)
    if not isinstance(public_key, public_keys):
        raise InvalidKey("Given key is not a public key")
예제 #2
0
def __assure_public_key(public_key: rsa) -> None:
    """
    Check if a public key is a public key
    :param public_key: rsa  the public key to check
    :raises InvalidKey: if given key is invalid
    :return: None
    """
    public_keys = (rsa.RSAPublicKey, rsa.RSAPublicNumbers,
                   rsa.RSAPublicKeyWithSerialization)
    if not isinstance(public_key, public_keys):
        raise InvalidKey("Given key is not a public key")
예제 #3
0
파일: ecc.py 프로젝트: w13b3/do_not_use-py
def __assure_private_key(private_key: ec) -> None:
    """
    Check if a private key is a private key
    :param private_key: ec  the private key to check
    :raises InvalidKey: if given key is invalid
    :return: None
    """
    private_keys = (ec.EllipticCurvePrivateKey, ec.EllipticCurvePrivateNumbers,
                    ec.EllipticCurvePrivateNumbers)
    if not isinstance(private_key, private_keys):
        raise InvalidKey("Given key is not a private key")
예제 #4
0
def __assure_private_key(private_key: rsa) -> None:
    """
    Check if a private key is a private key
    :param private_key: rsa  the private key to check
    :raises InvalidKey: if given key is invalid
    :return: None
    """
    private_keys = (rsa.RSAPrivateKey, rsa.RSAPrivateNumbers,
                    rsa.RSAPrivateKeyWithSerialization)
    if not isinstance(private_key, private_keys):
        raise InvalidKey("Given key is not a private key")
예제 #5
0
 def verify(self, key_material, expected_key):
     derived_key = self.derive(key_material)
     if not constant_time.bytes_eq(derived_key, expected_key):
         raise InvalidKey("Keys do not match.")