def gen_params(curve): """ Factory function that generates EC parameters and instantiates a EC object from the output. @param curve: This is the OpenSSL nid of the curve to use. """ assert curve in [x['NID'] for x in m2.ec_get_builtin_curves()], \ 'Elliptic curve %s is not available on this system.' % \ m2.obj_nid2sn(curve) return EC(m2.ec_key_new_by_curve_name(curve), 1)
def gen_params(curve): # type: (int) -> EC """ Factory function that generates EC parameters and instantiates a EC object from the output. :param curve: This is the OpenSSL nid of the curve to use. """ assert curve in [x['NID'] for x in m2.ec_get_builtin_curves()], \ 'Elliptic curve %s is not available on this system.' % \ m2.obj_nid2sn(curve) return EC(m2.ec_key_new_by_curve_name(curve), 1)
def genkey(self, curve): try: curve_name = m2.obj_nid2sn(curve[0]) except TypeError: # we have to throw different exception for compatibility raise AttributeError('Unknown cipher %s', curve[0]) ec = EC.gen_params(curve[0]) self.assertEqual(len(ec), curve[1]) ec.gen_key() self.assertTrue(ec.check_key(), 'check_key() failure for "%s"' % curve_name) return ec
def genkey(self, curve): try: curve_name = m2.obj_nid2sn(curve[0]) except TypeError: # we have to throw different exception for compatibility raise AttributeError('Unknown cipher %s', curve[0]) ec = EC.gen_params(curve[0]) self.assertEqual(len(ec), curve[1]) ec.gen_key() self.assertTrue(ec.check_key(), 'check_key() failure for "%s"' % curve_name) return ec
def is_legacy_proxy(cert): for i in xrange(cert.get_ext_count()): ext = cert.get_ext_at(i) if ext.get_name().lower() == "proxycertinfo": return False for entry in cert.get_subject(): # M2Crypto 0.16 не имеет нужного python api obj = m2.x509_name_entry_get_object(entry._ptr()) objname = m2.obj_nid2sn(m2.obj_obj2nid(obj)) val = entry.get_data().as_text() if objname == 'CN' and val in ('proxy', 'limited proxy'): return True return False
def is_legacy_proxy(cert): for i in xrange(cert.get_ext_count()): ext = cert.get_ext_at(i) if ext.get_name().lower() == "proxycertinfo": return False for entry in cert.get_subject(): # M2Crypto 0.16 не имеет нужного python api obj = m2.x509_name_entry_get_object(entry._ptr()) objname = m2.obj_nid2sn(m2.obj_obj2nid(obj)) val = entry.get_data().as_text() if objname == 'CN' and val in ('proxy', 'limited proxy'): return True return False
def is_legacy_proxy(cert): """Check if certificate is a legacy proxy certificate""" for i in xrange(cert.get_ext_count()): ext = cert.get_ext_at(i) if ext.get_name().lower() == "proxycertinfo": return False for entry in cert.get_subject(): # M2Crypto 0.16 does not implement the corresponding python api :( obj = m2.x509_name_entry_get_object(entry._ptr()) objname = m2.obj_nid2sn(m2.obj_obj2nid(obj)) val = entry.get_data().as_text() if objname == 'CN' and val in ('proxy', 'limited proxy'): return True return False
def asn1_object_get_sn(self): return m2.obj_nid2sn(m2.obj_obj2nid(self._ptr()))