Beispiel #1
0
def parse_public_key(encoded_key, encoding="PEM"):
    """
    Parses a public key in the given format.

    :param encoded_key:
        The encoded key.
    :param encoding:
        The encoding used to encode the key. Default "PEM".
    """
    encoding = encoding.upper()
    if encoding == "PEM":
        key_info = public_key_pem_decode(encoded_key)
    else:
        raise NotImplementedError("Key encoding not supported.")
    key = PublicKey(key_info, encoded_key, encoding)
    return key
Beispiel #2
0
def parse_public_key(encoded_key, encoding="PEM"):
    """
  Parses a public key in the given format.

  :param encoded_key:
      The encoded key.
  :param encoding:
      The encoding used to encode the key. Default "PEM".
  """
    encoding = encoding.upper()
    if encoding == "PEM":
        key_info = codec.public_key_pem_decode(encoded_key)
    else:
        raise NotImplementedError("Key encoding not supported.")
    key = PublicKey(key_info, encoded_key, encoding)
    return key
Beispiel #3
0
 def test_decode(self):
     self.assertDictEqual(codec.public_key_pem_decode(PUBLIC_KEY),
                          PUBLIC_KEY_DECODED)
     self.assertDictEqual(codec.public_key_pem_decode(CERTIFICATE),
                          PUBLIC_KEY_DECODED)
 def test_decode(self):
   self.assertDictEqual(codec.public_key_pem_decode(PUBLIC_KEY),
                        PUBLIC_KEY_DECODED)
   self.assertDictEqual(codec.public_key_pem_decode(CERTIFICATE),
                        PUBLIC_KEY_DECODED)