2019-05-25 10:17:52 +00:00
|
|
|
import six
|
|
|
|
|
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
|
from cryptography.hazmat.primitives import serialization
|
|
|
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
|
|
|
|
|
|
|
|
|
|
def rsa_check_private_key(private_key_material):
|
|
|
|
assert isinstance(private_key_material, six.string_types)
|
|
|
|
|
|
|
|
private_key = serialization.load_pem_private_key(
|
2019-10-31 15:44:26 +00:00
|
|
|
data=private_key_material.encode("ascii"),
|
2019-05-25 10:17:52 +00:00
|
|
|
backend=default_backend(),
|
2019-10-31 15:44:26 +00:00
|
|
|
password=None,
|
|
|
|
)
|
2019-05-25 10:17:52 +00:00
|
|
|
assert isinstance(private_key, rsa.RSAPrivateKey)
|