def testLeaks2(): print "Trying to leak (rsa)" s20 = "a"*20 p = pk_generate(512) n,e = p.get_public_key() if not os.path.exists("/dev/null"): print "No /dev/null found; dying" return f = open("/dev/null", 'w') while 1: if 0: p = pk_generate(512) if 1: pk_decrypt(pk_encrypt(s20,p),p) for public in (0,1): x = p.encode_key(public) _ml.rsa_decode_key(x,public) p.get_public_key() _ml.rsa_make_public_key(n,e) p.get_modulus_bytes() p.get_exponent() if 1: p.PEM_write_key(f, 1) p.PEM_write_key(f, 0) p.PEM_write_key(f, 0, "Z") if 1: x = p.crypt("A"*64, 1, 1) p.crypt(x, 0, 0)
def pk_from_modulus(n, e=65537L): """Given a modulus and exponent, creates an RSA public key.""" return _ml.rsa_make_public_key(long(n), long(e))