def calculate_keys(p, q, nbits):
 phi_n = ((p - 1) * (q - 1))
 e = 65537
 try:
  d = rsa.common.inverse(e, phi_n)
 except ValueError:
  raise ValueError(('e (%d) and phi_n (%d) are not relatively prime' % (e, phi_n)))
 if (((e * d) % phi_n) != 1):
  raise ValueError(('e (%d) and d (%d) are not mult. inv. modulo phi_n (%d)' % (e, d, phi_n)))
 return (e, d)

def calculate_keys ( p , q , nbits ) : phi_n = ( ( p - 1 ) * ( q - 1 ) ) e = 65537 try : d = rsa . common . inverse ( e , phi_n ) except ValueError : raise ValueError ( ( 'e (%d) and phi_n (%d) are not relatively prime' % ( e , phi_n ) ) ) if ( ( ( e * d ) % phi_n ) != 1 ) : raise ValueError ( ( 'e (%d) and d (%d) are not mult. inv. modulo phi_n (%d)' % ( e , d , phi_n ) ) ) return ( e , d )
calculates an encryption and a decryption key for p and q .