diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-01-27 09:22:25 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-01-27 09:22:25 -0500 |
commit | 514c73013b4b99e50201fdfe5df672f6f81c76e2 (patch) | |
tree | 55a0e2df9ae47d6f695fffc9911659e9efa6f742 /docs/hazmat/primitives | |
parent | efec065b905a404887fa9c55c2276f3b47ed140b (diff) | |
download | cryptography-514c73013b4b99e50201fdfe5df672f6f81c76e2.tar.gz cryptography-514c73013b4b99e50201fdfe5df672f6f81c76e2.tar.bz2 cryptography-514c73013b4b99e50201fdfe5df672f6f81c76e2.zip |
Include an example of loading a public key
Diffstat (limited to 'docs/hazmat/primitives')
-rw-r--r-- | docs/hazmat/primitives/asymmetric/serialization.rst | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/hazmat/primitives/asymmetric/serialization.rst b/docs/hazmat/primitives/asymmetric/serialization.rst index f63455e4..d5da24da 100644 --- a/docs/hazmat/primitives/asymmetric/serialization.rst +++ b/docs/hazmat/primitives/asymmetric/serialization.rst @@ -24,6 +24,14 @@ Key Serialization 7SGRS1DTUGX4Y70m9dQpguy6Zg+gpHC+o+ERZR06uEQr+w== -----END RSA PRIVATE KEY----- """.strip() + public_pem_data = b""" + -----BEGIN PUBLIC KEY----- + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDn09PV9KPE7Q+N5K5UtNLT1DLl + 8z/pKM2pP5tXqWx2OsEw00lCkDHdHESwzS050s/8rtkERKKyusCzCm9+vC1pQzUl + mtibfF4PQAQc1pJL6KHqlidgHw49atYmnC25CaeXt65pAYXoIacOZ8k5X7FW3Eag + ex8nG0iMw4ObOtg6CwIDAQAB + -----END PUBLIC KEY----- + """.strip() message = b"" def sign_with_rsa_key(key, message): @@ -99,6 +107,13 @@ all begin with ``-----BEGIN {format}-----`` and end with ``-----END Deserialize a public key from PEM encoded data to one of the supported asymmetric public key types. + .. doctest:: + + >>> from cryptography.hazmat.primitives.serialization import load_pem_public_key + >>> key = load_pem_public_key(public_pem_data, backend=default_backend()) + >>> isinstance(key, rsa.RSAPublicKey) + True + :param bytes data: The PEM encoded key data. :param backend: A |