Example #1
0
def parse_private_key(encoded_key, encoding="PEM"):
    """
    Parses a private 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 = private_key_pem_decode(encoded_key)
    else:
        raise NotImplementedError("Key encoding not supported.")
    key = PrivateKey(key_info, encoded_key, encoding)
    return key
Example #2
0
def parse_private_key(encoded_key, encoding="PEM"):
    """
  Parses a private 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.private_key_pem_decode(encoded_key)
    else:
        raise NotImplementedError("Key encoding not supported.")
    key = PrivateKey(key_info, encoded_key, encoding)
    return key
Example #3
0
 def test_decode(self):
     self.assertDictEqual(codec.private_key_pem_decode(PRIVATE_KEY),
                          PRIVATE_KEY_DECODED)
 def test_decode(self):
   self.assertDictEqual(codec.private_key_pem_decode(PRIVATE_KEY),
                        PRIVATE_KEY_DECODED)