#NEWLINE# def gen_keys( nbits ) : #NEWLINE# #INDENT# 'Generate RSA keys of nbits bits. Returns (p, q, e, d).\n\n    Note: this can take a long time, depending on the key size.\n    ' #NEWLINE# while True : #NEWLINE# #INDENT# ( p , q ) = find_p_q ( nbits ) #NEWLINE# ( e , d ) = calculate_keys ( p , q , nbits ) #NEWLINE# if ( d > 0 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return ( p , q , e , d )