def encrypt(_, rt, key): start = time.time() print "Started at %f." % start aes = AES(rt, options.keylength, use_exponentiation=options.exponentiation) ciphertext = [] for i in range(options.count): ciphertext += aes.encrypt("a" * 16, key, True, prepare_at_once=options.at_once) opened_ciphertext = [rt.open(c) for c in ciphertext] def fin(ciphertext): print "Finished after %f sec." % (time.time() - start) print "Ciphertext:", [hex(c.value) for c in ciphertext] if rt._needed_data and options.preproc: print "Missing pre-processed data:" for (func, args), pcs in rt._needed_data.iteritems(): print "* %s%s:" % (func, args) print " " + pformat(pcs).replace("\n", "\n ") if rt._pool: print "Unused pre-processed data:" pcs = rt._pool.keys() pcs.sort() print " " + pformat(pcs).replace("\n", "\n ") rt.shutdown() g = gather_shares(opened_ciphertext) rt.schedule_complex_callback(g, fin)
def test_encrypt(self, runtime): cleartext = "Encrypt this!!!!" key = "Supposed to be secret!?!" aes = AES(runtime, 192, quiet=True) r = rijndael(key) result = aes.encrypt(cleartext, key) expected = [ord(c) for c in r.encrypt(cleartext)] return self.verify(runtime, [result], [expected])