def boneh_durfee(self): # use boneh durfee method, should return a d value, else returns 0 # only works if the sageworks() function returned True # many of these problems will be solved by the wiener attack module but perhaps some will fall through to here # TODO: get an example public key solvable by boneh_durfee but not wiener try: sageresult = int( subprocess.check_output([ 'sage', 'boneh_durfee.sage', str(self.pub_key.n), str(self.pub_key.e) ])) except subprocess.CalledProcessError: return if sageresult > 0: # use PyCrypto _slowmath rsa_construct to resolve p and q from d from Crypto.PublicKey import _slowmath tmp_priv = _slowmath.rsa_construct(int(self.pub_key.n), int(self.pub_key.e), d=int(sageresult)) self.pub_key.p = tmp_priv.p self.pub_key.q = tmp_priv.q self.priv_key = PrivateKey(int(self.pub_key.p), int(self.pub_key.q), int(self.pub_key.e), int(self.pub_key.n)) return
def boneh_durfee(N, e): log.debug('factor N: try Boneh and Durfee attack') # use boneh durfee method, should return a d value, else returns 0 # only works if the sageworks() function returned True # many of these problems will be solved by the wiener attack module but perhaps some will fall through to here # TODO: get an example public key solvable by boneh_durfee but not wiener sageresult = int(subprocess.check_output( ['sage', os.path.dirname(__file__) + '/boneh_durfee.sage', str(N), str(e)])) if sageresult > 0: # use PyCrypto _slowmath rsa_construct to resolve p and q from d from Crypto.PublicKey import _slowmath tmp_priv = _slowmath.rsa_construct( int(N), int(e), d=int(sageresult)) p = tmp_priv.p q = tmp_priv.q # d = sageresult return p, q
def boneh_durfee(self): # use boneh durfee method, should return a d value, else returns 0 # only works if the sageworks() function returned True # many of these problems will be solved by the wiener attack module but perhaps some will fall through to here # TODO: get an example public key solvable by boneh_durfee but not wiener sageresult = int(subprocess.check_output(['sage','boneh_durfee.sage',str(self.pub_key.n),str(self.pub_key.e)])) if sageresult > 0: # use PyCrypto _slowmath rsa_construct to resolve p and q from d from Crypto.PublicKey import _slowmath tmp_priv = _slowmath.rsa_construct(long(self.pub_key.n), long(self.pub_key.e), d=long(sageresult)) self.pub_key.p = tmp_priv.p self.pub_key.q = tmp_priv.q self.priv_key = PrivateKey(long(self.pub_key.p), long(self.pub_key.q), long(self.pub_key.e), long(self.pub_key.n)) return
def nde_2_pq(N, d, e): tmp_priv = _slowmath.rsa_construct(long(N), long(e), d=long(d)) p = tmp_priv.p q = tmp_priv.q return p, q
def nde_2_pq(N, d, e): tmp_priv = _slowmath.rsa_construct(int(N), int(e), d=int(d)) p = tmp_priv.p q = tmp_priv.q return p, q