Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
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
Exemple #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
Exemple #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)
Exemple #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)