Esempio n. 1
0
 def test_x509_keys(self):
   for key, cert in KEY_FILE_PAIRS:
     x509_dict = self.dicts[cert]
     x509_t = x509_pem.dict_to_tuple(x509_dict)
     x509_key = RSA.construct(x509_t)
     self.assertTrue(x509_key)
     self.assertEqual(x509_key.e, 65537)
Esempio n. 2
0
 def test_x509_keys(self):
   for key, cert in KEY_FILE_PAIRS:
     x509_dict = self.dicts[cert]
     x509_t = x509_pem.dict_to_tuple(x509_dict)
     x509_key = RSA.construct(x509_t)
     self.assertTrue(x509_key)
     self.assertEqual(x509_key.e, 65537)
Esempio n. 3
0
  def setUp(self):
    self.keys = {}

    for key, cert in KEY_FILE_PAIRS:
      with open(key, "r") as f:
        data = f.read()
        dict = rsa_pem.parse(data)
        t = rsa_pem.dict_to_tuple(dict)
        self.keys[key] = RSA.construct(t)
      with open(cert, "r") as f:
        data = f.read()
        dict = x509_pem.parse(data)
        t = x509_pem.dict_to_tuple(dict)
        self.keys[cert] = RSA.construct(t)
Esempio n. 4
0
  def setUp(self):
    self.keys = {}

    for key, cert in KEY_FILE_PAIRS:
      with open(key, "r") as f:
        data = f.read()
        dict = rsa_pem.parse(data)
        t = rsa_pem.dict_to_tuple(dict)
        self.keys[key] = RSA.construct(t)
      with open(cert, "r") as f:
        data = f.read()
        dict = x509_pem.parse(data)
        t = x509_pem.dict_to_tuple(dict)
        self.keys[cert] = RSA.construct(t)
Esempio n. 5
0
def get_key(parse_dict):
  """Return RSA object from parsed PEM key file dictionary.

  Args:
    parse_dict: {str:str} as returned by `parse`
  Returns:
    `RSAKey` RSA key object as specified by `parse_dict`
  """
  if parse_dict['type'] == "RSA PRIVATE":
    key_tuple = rsa_pem.dict_to_tuple(parse_dict)
  elif parse_dict['type'] == "X509 CERTIFICATE":
    key_tuple = x509_pem.dict_to_tuple(parse_dict)
  else:
    raise Exception("parse_dict type '%s' not supported." % parse_dict['type'])
  key = RSA.construct(key_tuple)
  return key
Esempio n. 6
0
def get_key(parse_dict):
    """Return RSA object from parsed PEM key file dictionary.

  Args:
    parse_dict: {str:str} as returned by `parse`
  Returns:
    `RSAKey` RSA key object as specified by `parse_dict`
  """
    if parse_dict['type'] == "RSA PRIVATE":
        key_tuple = rsa_pem.dict_to_tuple(parse_dict)
    elif parse_dict['type'] == "X509 CERTIFICATE":
        key_tuple = x509_pem.dict_to_tuple(parse_dict)
    else:
        raise Exception("parse_dict type '%s' not supported." %
                        parse_dict['type'])
    key = RSA.construct(key_tuple)
    return key
Esempio n. 7
0
 def test_x509_tuple_generation(self):
   for key, cert in KEY_FILE_PAIRS:
     x509_dict = self.dicts[cert]
     t = x509_pem.dict_to_tuple(x509_dict)
     self.assertTrue(t)
     self.assertEqual(len(t), 2)
Esempio n. 8
0
 def test_x509_tuple_generation(self):
   for key, cert in KEY_FILE_PAIRS:
     x509_dict = self.dicts[cert]
     t = x509_pem.dict_to_tuple(x509_dict)
     self.assertTrue(t)
     self.assertEqual(len(t), 2)