def setUp(self): self.ca_A = CA('/CN=A') self.ca_B = CA('/CN=B') self.ca_A_tls = CA('/CN=A_tls', self.ca_A) self.ca_A_enc = CA('/CN=A_enc', self.ca_A) self.srvA = self.__makeServer('/CN=localhost', 'localhost') self.srvB = self.__makeServer('/CN=localhost:5701', 'localhost', 5701)
def main(): wa.pygame.init() # CA density_map = read.read_asc("data/polds00g.asc") cell_auto = CA(density_map, a=2, b=2, cell_size=constants.CELL_SIZE) # screen size screen_width = density_map.shape[1] * constants.CELL_SIZE + 200 screen_height = density_map.shape[0] * constants.CELL_SIZE # buttons import_data_button = Button(screen_width - 175, 100, 150, 30, "Import data") start_simulation_button = Button(screen_width - 175, 200, 150, 30, "Start simulation") stop_simulation_button = Button(screen_width - 175, 300, 150, 30, "Stop simulation") randomize_data_button = Button(screen_width - 175, 400, 150, 30, "Randomize data") buttons = [ import_data_button, start_simulation_button, stop_simulation_button, randomize_data_button ] win = wa.pygame.display.set_mode((screen_width, screen_height)) wa.pygame.display.set_caption('Pandemic simulation') run = True run_simulation = True # main loop while run: for event in wa.pygame.event.get(): if event.type == wa.pygame.QUIT: run = False if event.type == wa.pygame.MOUSEBUTTONDOWN and event.button == 1: run_simulation, import_data, new_density_map = wa.check_button_click( buttons, event.pos) if import_data: cell_auto = CA(new_density_map, a=2, b=2, cell_size=constants.CELL_SIZE) if run_simulation: wa.redraw_window(win, cell_auto, buttons) cell_auto.run(1) wa.pygame.quit()
from ca import CA from certificate import Certificate from keytool import Keytool import os line = "----------------------------------------------" cadir = "./testca" ca = CA(cadir, "/CN=Test CA/") ca.validate_setup() r1 = ca.setup() print "CA present" print line print r1 def createCert(certname, subj, password, isServerCert): print line print "Creating certificate for: {}".format(certname) cert = Certificate(cadir, certname, subj, password, isServerCert) print cert.create_certificate() return cert createCert("test.openampere.com", "/CN=Test/", "abc123!@#$", True) c1 = createCert("client.openampere.com", "/CN=Client/", "asdfaer13", False) createCert("client2.openampere.com",
from utils import generate_safe_prime, generate_hash from elgamal import ElGamalDS import random from ca import CA from datetime import datetime, timedelta from utils import verify_certificate # Global Constants NBYTES = SHA.digest_size + 1 BYTES_TO_BITS = 8 MAX_ID = 30 RSA_KEY_BITS = 512 ######################################################################################################################## # CA Creation ca = CA(NBYTES) # RSA Creation rsa = RSA(RSA_KEY_BITS) # Alice and Bob Parameters q = generate_safe_prime(NBYTES * BYTES_TO_BITS) a = random.randint(2, q - 1) ######################################################################################################################## # Alice Keys x_a = random.randint(2, q - 1) y_a = pow(a, x_a, q) id_a = random.randint(1, MAX_ID)