def from_string(key_pem, is_x509_cert):
"""Construct a Verified instance from a string.
Args:
key_pem: string, public key in PEM format.
is_x509_cert: bool, True if key_pem is an X509 cert, otherwise it is
expected to be an RSA key in PEM format.
Returns:
Verifier instance.
Raises:
NotImplementedError if is_x509_cert is true.
"""
if is_x509_cert:
# raise NotImplementedError(
# 'X509 certs are not supported by the PyCrypto library. '
# 'Try using PyOpenSSL if native code is an option.')
key_pem = x509.get_pubkey(key_pem)
pubkey = RSA.importKey(key_pem)
return PyCryptoVerifier(pubkey)
评论列表
文章目录