def main(config):
    config_all(config)
    build_openvpn()
    build_ddk(config, 'tap', 'all')
    build_ddk(config, 'tapinstall', 'all')
    sign(config, 'all')
    make_dist(config)
def main(config):
    config_all(config)
    build_openvpn()
    build_ddk(config, 'tap', 'all')
    build_ddk(config, 'tapinstall', 'all')
    sign(config, 'all')
    make_dist(config)
Esempio n. 3
0
    def _send(self, message: str) -> None:
        """
        Effectively encodes and sends a message
        :param message:
        :return:
        """

        logger.debug("Send: {}".format(message))

        message_b = (json.dumps(message) + '\r\n').encode()
        if self.state == STATE_OPEN and self.chall == True:
            if self.cifra == "AES":
                message_b = aes.generate(message_b, self.bloco, self.hah,
                                         self.chave)
            if self.cifra == "CHACHA20":
                message_b = chacha20.generate(message_b, self.hah, self.chave)
            if self.aut == "CC":
                message_b += sign.sign(message_b)
            self.state = STATE_DATA

        elif self.state == STATE_OPEN and self.chall == False:
            pass

        elif self.state == STATE_DATA:
            if self.cifra == "AES":
                message_b = aes.generate(message_b, self.bloco, self.hah,
                                         self.chave)
            if self.cifra == "CHACHA20":
                message_b = chacha20.generate(message_b, self.hah, self.chave)

        self.transport.write(message_b)
Esempio n. 4
0
def main():
    """Main."""
    test = Transaction(123, "Dane", "Someone else", "memes", "memez")
    print(test.sign_transaction)
    text = b"Meow Meow Meow"
    sign.verify(text, sign.sign(text))
    print("Unix Epoch: " + str(time.time()))
    data1 = ["314", "123", "987", "000", "555"]
    # 0x20000f00
    difficulty = int(hex(0x000f00 * int((math.pow(2, 8 * (0x20 - 3))))), 16)
    chain1 = Chain()
    block1 = Block(1, 2, "Richard Nixon :P", difficulty, time.time(),
                   chain1.blocks[-1], data1)
    block1.mine()
    chain1.add_block(block1)
    chain1.write()
    print("Header:\n" + block1.header)
    print("Data:\n" + str(block1.data))
    Transactions = []
    for i in range(64):
        Transactions.append(
            Transaction("token1", "John" + str(i), "John" + str(i + 1),
                        "Block Talk", "Blah Blah Blah " + str(i)).transaction)
    block2 = Block(1, 2, "Al Gore :P", difficulty, time.time(),
                   chain1.blocks[-1], Transactions)
    block2.mine()
Esempio n. 5
0
def cell(mnc, lac, cell):
	mnc = str(mnc)
	lac = str(lac)
	cell = str(cell)

	timestamp = str(int(time.time()))

	#build param string
	#collect all params: lac cell timestamp access_id
	paramTupleList = []

	paramTupleList.append(('mnc', mnc));
	paramTupleList.append(('lac', lac))
	paramTupleList.append(('cell', cell))
	paramTupleList.append(('access_id', access_id))
	paramTupleList.append(('timestamp', timestamp))

	#sign
	signature = sign.sign(url, paramTupleList, access_key)

	#paramString
	paramString = ''

	for tupleItem in paramTupleList:
		paramString += tupleItem[0] + '=' + tupleItem[1] + '&'

	#compose valid request url
	requestURL = 'http://' + url + '?' + paramString + 'signature=' + urllib.quote_plus(signature)

	print requestURL

	result = urllib2.urlopen(requestURL).read()

	return result
Esempio n. 6
0
def test_sign():
    key = RSA.importKey(PRIVATE_KEY)
    tmp_dir = tempfile.mkdtemp()
    data_path = join(tmp_dir, 'data')
    write_message(data_path)
    assert sign.sign(data_path, key) == SIGNATURE
    shutil.rmtree(tmp_dir)
Esempio n. 7
0
def cell(mnc, lac, cell):
    mnc = str(mnc)
    lac = str(lac)
    cell = str(cell)

    timestamp = str(int(time.time()))

    #build param string
    #collect all params: lac cell timestamp access_id
    paramTupleList = []

    paramTupleList.append(('mnc', mnc))
    paramTupleList.append(('lac', lac))
    paramTupleList.append(('cell', cell))
    paramTupleList.append(('access_id', access_id))
    paramTupleList.append(('timestamp', timestamp))

    #sign
    signature = sign.sign(url, paramTupleList, access_key)

    #paramString
    paramString = ''

    for tupleItem in paramTupleList:
        paramString += tupleItem[0] + '=' + tupleItem[1] + '&'

    #compose valid request url
    requestURL = 'http://' + url + '?' + paramString + 'signature=' + urllib.quote_plus(
        signature)

    print requestURL

    result = urllib2.urlopen(requestURL).read()

    return result
Esempio n. 8
0
def pay_to(coin, next_pubk, owner_pubk, owner_prik):
    msg = '{}${}'.format(coin, next_pubk)
    new_coin = msg + '$' + sign(owner_prik, ADDRESS_DICT[owner_pubk], msg)
    url = THIS_NODE + r'/input/' + new_coin
    res = urllib2.urlopen(url)
    ret = res.read()
    return ret + ' : ' + new_coin
Esempio n. 9
0
    def append(self, node):

        new_head = 1
        if self.empty:
            self.empty = False
        else:
            new_head = self.head + 1

        self.data[new_head] = {}
        self.data[new_head]['pointer'] = self.head
        self.data[new_head]['node'] = node

        if new_head == 1:
            self.data[new_head]['hash'] = None
        else:
            self.data[new_head]['hash'] = hash(
                int(dict_to_binary(self.data[self.head])), self.generator,
                self.prime, self.length)

        node_to_sign = dict_to_text(self.data[new_head])
        z, c, t = sign(node_to_sign, self.pri_key, self.length, self.generator,
                       self.prime)
        self.data[new_head]['sign'] = (z, c, t)

        self.head = new_head
Esempio n. 10
0
    def dataReceived(self, data):
        """
        Invoked when data arrives from the server. We just print it.
        """
        sys.stdout.buffer.write(data)
        sys.stdout.flush()

        if (data[:10] == b'Challenge:'):
            print("\"" + data[23:].decode().rstrip() + "\"")
            s = sign(data[23:].decode().rstrip())
            print("________________________")
            signature = binascii.hexlify(s).decode()
            self.transport.write(bytes(signature + '\n', "utf-8"))

        if (data == b'Press any key.\r\r\n'):
            self.transport.write(b'\n')

        if (data == b'Successful login. Press any key.\r\r\n' and False):
            self.transport.write(b'\n')
            self.transport.write(b'3\n')
            self.transport.write(b'3\n')
            self.transport.write(b'\n')
            self.transport.write(b'Q\n')
            self.transport.write(b'prendre documentation\n')
            self.transport.write(b'prendre downloader\n')
            self.transport.write(b'prendre chargeur\n')
            self.transport.write(b'prendre uploader\n')
            self.transport.write(b'prendre SD\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'ascenseur\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'26\n')
            self.transport.write(b'monter\n')
            self.transport.write(b'monter\n')
            self.transport.write(b'est\n')
            self.transport.write(b'dist\n')
            self.transport.write(b'12\n')
            self.transport.write(b'\n')
            self.transport.write(b'prendre cable\n')
            self.transport.write(b'brancher chargeur\n')
            self.transport.write(b'utiliser SD\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'descendre\n')
            self.transport.write(b'descendre\n')
            self.transport.write(b'24\n')
            self.transport.write(b'25\n')
            self.transport.write(b'monter\n')
            self.transport.write(b'monter\n')
            self.transport.write(b'monter\n')
            self.transport.write(b'14\n')
            self.transport.write(b'15\n')
            self.transport.write(b'entrer bureau\n')
            self.transport.write(b'prendre prog\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'entrer serveur\n')
            self.transport.write(b'prendre ecran\n')
            self.transport.write(b'brancher ecran\n')
Esempio n. 11
0
def api_sign_and_deploy(username, csrfilename, email = None):
    signing = sign(csrfilename, username)
    signing.revoke() # revoke old certificate
    signing.sign() # sign certificate
    signing.pack() # create certificate zip and configuration samples
    if email:
        signing.send(email) # send zip via email
    return signing
Esempio n. 12
0
def api_sign_and_deploy(username, csrfilename, email=None):
    signing = sign(csrfilename, username)
    signing.revoke()  # revoke old certificate
    signing.sign()  # sign certificate
    signing.pack()  # create certificate zip and configuration samples
    if email:
        signing.send(email)  # send zip via email
    return signing
Esempio n. 13
0
def g(R, K, d, b, pOrbital='p'):

    #calculates  phase term for the LCAO bandstructure hamiltonian
    #requires:
    #R= translation vectors for neighboring atoms
    #K= momentum wavevector kx,ky,kz
    #d=unit nearest neighbor vectors
    #orbital bond vector (only pass in a single direction)

    if pOrbital == 'p':
        g = (1 + s.sign(d[1], b) * np.exp(1j * np.dot(K, R[0])) +
             s.sign(d[2], b) * np.exp(1j * np.dot(K, R[1])) +
             s.sign(d[3], b) * np.exp(1j * np.dot(K, R[2])))
    elif pOrbital == 's':
        g = (1 + np.exp(1j * np.dot(K, R[0])) + np.exp(1j * np.dot(K, R[1])) +
             np.exp(1j * np.dot(K, R[2])))

    return g
Esempio n. 14
0
def floating(string):
    s = sign(string)
    exp = bin(expo(string))
    exp = exp[2:]
    man = mantisse(string)[::-1]
    remove_zeros = man.index('1')
    man = man[remove_zeros:][::-1]

    return f'{s}1,{man}x2^{exp}'
Esempio n. 15
0
def test_randomdata():
    key = RSA.importKey(PRIVATE_KEY)
    tmp_dir = tempfile.mkdtemp()
    data_path = join(tmp_dir, 'data')
    for x in range(100):
        with open(data_path, 'wb') as fo:
            fo.write(Random.new().read(100))
        assert sign.verify(data_path, key,
                           sign.sign(data_path, key))
    shutil.rmtree(tmp_dir)
Esempio n. 16
0
def init_coin():
    coins = []
    for sn in range(10):
        msg = '{}${}${}'.format(randint(1, 10), sn, first_owner_pubkh)
        coin = msg + '$' + sign(gold_prik, gold_pubk, msg)
        coins.append(coin)

    for c in coins:
        print c
        process(c)
Esempio n. 17
0
def test_roundabout():
    tmp_dir = tempfile.mkdtemp()
    key_path = join(tmp_dir, 'key')
    data_path = join(tmp_dir, 'data')
    write_message(data_path)
    sign.keygen(key_path)
    key = RSA.importKey(open('%s.priv' % key_path).read())
    sig = sign.sign(data_path, key)
    assert sign.verify(data_path, key, sig)
    shutil.rmtree(tmp_dir)
Esempio n. 18
0
    def encode(self, message):
        poly_coeffs = strencode(message, self.k)

        polynomial = Polynomial(poly_coeffs)

        shares = [(x, int(polyval(x, polynomial.coef))) for x in range(1, (self.k+self.e+1))]
        
        signed_shares = [(i, sign(str(i[1]), self.pri_key, self.bitlen, self.generator, self.prime)) for i in shares]

        return signed_shares
Esempio n. 19
0
def write_source_file(filename, text, is_sign=True):
  # always end a file with a newline
  if not text.endswith("\n\n"):
    text += "\n\n"
  # remove trailing white spaces
  text = remove_trailing_white_space(text)
  # sign the source file, in case it was requested:
  if is_sign:
    text = sign.sign(None, text)[0]
  log("writing, %s" % filename)
  open(filename, "w").write(text)
Esempio n. 20
0
def post(app_key, app_secret, uri, method, ip, port, body, https=True):
    url = "https://" if https else "http://"
    url += ip + ":" + port + uri

    headers = sign(app_key, app_secret, body, uri, method)

    r = requests.post(url,
                      headers=headers,
                      data=json.dumps(body),
                      verify=False)

    return r.content
Esempio n. 21
0
def send(isSitting, start_time):
    email = ""
    key = ""
    config_file = os.path.dirname(
        os.path.realpath(__file__)) + '/../config.json'

    with open(config_file, "r") as f:
        data = json.load(f)
        email = data['email']
        key = data['key']

    send_data = {}
    send_data['isSitting'] = isSitting
    send_data['datetime'] = start_time.isoformat()
    send_data['email'] = email

    plaintext = str(email + start_time.strftime('%Y%m%d%H%M'))
    send_data['sign'] = sign(plaintext, key)
    #print(send_data)

    resp = requests.post(siteurl, json=send_data)

    # Only for test data:
    email = '*****@*****.**'
    send_data['email'] = email
    plaintext = str(email + start_time.strftime('%Y%m%d%H%M'))
    send_data['sign'] = sign(plaintext,
                             'Bh7N/4B5vlRixMEcl0Af7le3+9OGfsKPVdjjmqWIDec=')
    requests.post(siteurl, json=send_data)

    # Only for test data:
    email = '*****@*****.**'
    send_data['email'] = email
    plaintext = str(email + start_time.strftime('%Y%m%d%H%M'))
    send_data['sign'] = sign(plaintext,
                             'VK+1P2lRacTW402b6NThdEDQrjkBsOdp5Cqw7pjBExo=')
    requests.post(siteurl, json=send_data)

    return resp
Esempio n. 22
0
    def on_frame(self, frame: str) -> None:
        """
        Processes a frame (JSON Object)

        :param frame: The JSON Object to process
        :return:
        """

        #logger.debug("Frame: {}".format(frame))
        try:
            message = json.loads(frame)
        except:
            logger.exception("Could not decode the JSON message")
            self.transport.close()
            return

        mtype = message.get('type', None)

        if mtype == 'OK':  # Server replied OK. We can advance the state
            if self.state == STATE_OPEN:
                logger.info("Channel open")
                self.chave = message["pk"].encode()
                server_pub = serialization.load_pem_public_key(
                    self.chave, backend=default_backend())
                self.chave = server_pub
                #print(self.chave)
                self.send_file(self.file_name)
            elif self.state == STATE_DATA:  # Got an OK during a message transfer.
                # Reserved for future use
                pass
            else:
                logger.warning("Ignoring message from server")
            return
        elif mtype == "challenge":

            t = message["random"]
            t = sign.sign(t)
            c = cert.accessCert()
            self._send({
                "type": "challenge",
                'challengeAss': base64.b64encode(t).decode(),
                "certificado": base64.b64encode(c).decode()
            })
            self.chall = True
        elif mtype == 'Challenge OK':
            self.chall = True
        elif mtype == 'ERROR':
            logger.warning("Got error from server: {}".format(
                message.get('data', None)))
        else:
            logger.warning("Invalid message type")
Esempio n. 23
0
def token_gen(pub, priv):
	if priv == None:
		priv = ''
	if len(priv) > 0:
		pub['o'] = len(priv)
	else:
		try:
			del pub['o']
		except:
			pass
	jss = minify_json.json_minify(json.dumps(pub))
	td = jss[1:-1]
	sig = sign.sign(td + priv)
	tok = "%s%s%s%s" %(len(td), td, priv, sig)
	return tok.encode('base64').replace('\n', '').replace('=', '')
Esempio n. 24
0
def token_gen(pub, priv):
    if priv == None:
        priv = ''
    if len(priv) > 0:
        pub['o'] = len(priv)
    else:
        try:
            del pub['o']
        except:
            pass
    jss = minify_json.json_minify(json.dumps(pub))
    td = jss[1:-1]
    sig = sign.sign(td + priv)
    tok = "%s%s%s%s" % (len(td), td, priv, sig)
    return tok.encode('base64').replace('\n', '').replace('=', '')
Esempio n. 25
0
def log():
    global user, newpass
    choice = sign.sign()
    if (choice == "1"):
        user = sign.login(user)
        encrypt = input("Do you want to encrypt your password? (Y/N)")
        if encrypt == "Y":
            print("Your information has been encrypted")
            affine = crypt.Affine()
            user["password"] = affine.encrypt(user["password"])
            s.send(bytes("login", "utf-8"))
            msg = pickle.dumps(user)
            s.send(msg)
            user["password"] = affine.decrypt(user["password"])
        else:
            print("You choose not to encrypt your password.")
            s.send(bytes("login", "utf-8"))
            msg = pickle.dumps(user)
            s.send(msg)

    elif (choice == "2"):
        encrypt = input("Do you want to encrypt your password? (Y/N)")
        if (encrypt == "N"):
            user = sign.regis(user)
            s.send(bytes("regis", "utf-8"))
        elif (encrypt == "Y"):
            user = sign.regisAndEncrypt(user)
            s.send(bytes("regis_encrypt", "utf-8"))

        msg = pickle.dumps(user)
        s.send(msg)
    elif (choice == "3"):
        user = sign.unlogin_changePassword(user)
        newpass = getpass("New password >> ")
        encrypt = input("Do you want to encrypt your password? (Y/N)")
        if encrypt == "Y":
            affine = crypt.Affine()
            newpass = affine.encrypt(newpass)
            s.send(bytes("unlogin_cpass_encrypt", "utf-8"))
        else:
            s.send(bytes("unlogin_cpass", "utf-8"))
        msg = pickle.dumps(user)
        s.send(msg)
    else:
        s.send(bytes("quit", "utf-8"))
Esempio n. 26
0
def wybor_3():
    p, q, g = read_file_parameters()
    if p == -1:
        fail = "a"
        while fail != "n" and fail != "T":
            fail = input(
                "nie udalo sie otworzyc pliku z parametrami funkcji, czy chcesz teraz wygenerowac? [T,n] \n"
            )
            if fail != "n" and fail != "T":
                print("prosze podać T lub n")
        if fail == "n":
            return
        elif fail == "T":
            wybor_1()
            p, q, g = read_file_parameters()
            if p == -1:
                print("nie udalo sie wygenerowac parametrow")
                return
    x = read_file_private_key()
    if x == -1:
        return
    choice = "a"
    while choice != "P" and choice != "k":
        choice = input(
            "czy chcesz wygenerowac podpis z pliku czy z konsoli? [P,k] \n")
        if choice != "P" and choice != "k":
            print("prosze podać P lub k")
    message = ""
    if choice == "k":
        while message == "":
            message = input("podaj wybrana wiadomosc \n")
            if message == "":
                print("nie udalo sie odczytac wiadomosci lub wiadomosc "
                      "jest pusta, prosze wprowadzic wiadomosc przez konsole")
    elif choice == "P":
        message = ""
        file = input("podaj nazwe pliku \n")
        message = read_file_message(file)
        while message == -1:
            print("nie udalo sie odczytac wiadomosci lub wiadomosc "
                  "jest pusta, prosze wprowadzic wiadomosc przez konsole")
            message = input("podaj wybrana wiadomosc \n")
    r, s = sign(p, q, g, x, message)
    write_to_file_sign(r, s)
Esempio n. 27
0
    def connectionMade(self):
        self.DH = False
        print("Connexion initialized, implement diffie Hellman key exchange")
        self.g = int(
            "3f:b3:2c:9b:73:13:4d:0b:2e:77:50:66:60:ed:bd:48:4c:a7:b1:8f:21:ef:20:54:07:f4:79:3a:1a:0b:a1:25:10:db:c1:50:77:be:46:3f:ff:4f:ed:4a:ac:0b:b5:55:be:3a:6c:1b:0c:6b:47:b1:bc:37:73:bf:7e:8c:6f:62:90:12:28:f8:c2:8c:bb:18:a5:5a:e3:13:41:00:0a:65:01:96:f9:31:c7:7a:57:f2:dd:f4:63:e5:e9:ec:14:4b:77:7d:e6:2a:aa:b8:a8:62:8a:c3:76:d2:82:d6:ed:38:64:e6:79:82:42:8e:bc:83:1d:14:34:8f:6f:2f:91:93:b5:04:5a:f2:76:71:64:e1:df:c9:67:c1:fb:3f:2e:55:a4:bd:1b:ff:e8:3b:9c:80:d0:52:b9:85:d1:82:ea:0a:db:2a:3b:73:13:d3:fe:14:c8:48:4b:1e:05:25:88:b9:b7:d2:bb:d2:df:01:61:99:ec:d0:6e:15:57:cd:09:15:b3:35:3b:bb:64:e0:ec:37:7f:d0:28:37:0d:f9:2b:52:c7:89:14:28:cd:c6:7e:b6:18:4b:52:3d:1d:b2:46:c3:2f:63:07:84:90:f0:0e:f8:d6:47:d1:48:d4:79:54:51:5e:23:27:cf:ef:98:c5:82:66:4b:4c:0f:6c:c4:16:59"
            .replace(':', ''),
            base=16)
        self.p = int(
            "00:87:a8:e6:1d:b4:b6:66:3c:ff:bb:d1:9c:65:19:59:99:8c:ee:f6:08:66:0d:d0:f2:5d:2c:ee:d4:43:5e:3b:00:e0:0d:f8:f1:d6:19:57:d4:fa:f7:df:45:61:b2:aa:30:16:c3:d9:11:34:09:6f:aa:3b:f4:29:6d:83:0e:9a:7c:20:9e:0c:64:97:51:7a:bd:5a:8a:9d:30:6b:cf:67:ed:91:f9:e6:72:5b:47:58:c0:22:e0:b1:ef:42:75:bf:7b:6c:5b:fc:11:d4:5f:90:88:b9:41:f5:4e:b1:e5:9b:b8:bc:39:a0:bf:12:30:7f:5c:4f:db:70:c5:81:b2:3f:76:b6:3a:ca:e1:ca:a6:b7:90:2d:52:52:67:35:48:8a:0e:f1:3c:6d:9a:51:bf:a4:ab:3a:d8:34:77:96:52:4d:8e:f6:a1:67:b5:a4:18:25:d9:67:e1:44:e5:14:05:64:25:1c:ca:cb:83:e6:b4:86:f6:b3:ca:3f:79:71:50:60:26:c0:b8:57:f6:89:96:28:56:de:d4:01:0a:bd:0b:e6:21:c3:a3:96:0a:54:e7:10:c3:75:f2:63:75:d7:01:41:03:a4:b5:43:30:c1:98:af:12:61:16:d2:27:6e:11:71:5f:69:38:77:fa:d7:ef:09:ca:db:09:4a:e9:1e:1a:15:97"
            .replace(':', ''),
            base=16)
        self.q = int(
            "00:8c:f8:36:42:a7:09:a0:97:b4:47:99:76:40:12:9d:a2:99:b1:a4:7d:1e:b3:75:0b:a3:08:b0:fe:64:f5:fb:d3"
            .replace(':', ''),
            base=16)

        self.x = random.randint(1, self.q)
        self.A = pow(self.g, self.x, self.p)
        s = sign(str(self.A))
        jdict = json.dumps({
            'username': "******",
            'A': self.A,
            "signature": s.hex()
        })

        # self.Kiv = 0x00000000000000000000000000000000
        # self.Kaes = (0x00000000000000000000000000000000).to_bytes(16,'big')
        # self.Kmac = (0x00000000000000000000000000000000).to_bytes(16,'big')

        # self.Kiv2 = 0x00000000000000000000000000000000
        # self.Kaes2 = (0x00000000000000000000000000000000).to_bytes(16,'big')
        # self.Kmac2 = (0x00000000000000000000000000000000).to_bytes(16,'big')

        # self.CTR1 = self.Kiv
        # self.CTR2 = self.Kiv

        self.stream_encrypt = b""
        self.stream_decrypt = b""
        self.transport.write(jdict.encode())
Esempio n. 28
0
def send(isSitting, start_time):
    email = ""
    key = ""
    config_file = os.path.dirname(
        os.path.realpath(__file__)) + '/../config.json'

    with open(config_file, "r") as f:
        data = json.load(f)
        email = data['email']
        key = data['key']

    send_data = {}
    send_data['isSitting'] = isSitting
    send_data['datetime'] = start_time.isoformat()
    send_data['email'] = email

    plaintext = str(email + start_time.strftime('%Y%m%d%H%M'))
    send_data['sign'] = sign(plaintext, key)
    print(send_data)

    resp = requests.post(siteurl, json=send_data)
    return resp
Esempio n. 29
0
import random
from generate import generate
from sign import sign
from verify import verify

length = int(input("Enter number of bits: "))
generator, prime = generate(length)
print(generator, prime)

# Key generation
pri_key = random.randint(1, prime - 1)  #private key
print("Private Key =", pri_key)
pub_key = pow(generator, pri_key, prime)  #public key
print("Public Key =", pub_key)

message = input("Enter message text: ")

z, c, t = sign(message, pri_key, length, generator, prime)
print(verify(message, z, c, t, length, generator, prime, pub_key))
Esempio n. 30
0
def do_sign(changesfile):
    sign.sign(changesfile)
Esempio n. 31
0
#!/usr/bin/env python
# coding=utf-8
import time

from sign import sign


if __name__ == '__main__':
    SLEEPTIME = 60 * 60 * 24

    while True:
        print ("Start : %s" % time.ctime())
        sign()
        time.sleep(SLEEPTIME)
        print ("End : %s" % time.ctime())
Esempio n. 32
0
 def signup(self):
     self.root.destroy()
     sign()
     logmein()
Esempio n. 33
0
    def dataReceived(self, data):
        """
            Invoked when data arrives from the server. We just print it.
            """
        sys.stdout.buffer.write(data)
        sys.stdout.flush()
        n = self.n

        if (data[:10] == b'Challenge:'):
            print("\"" + data[23:].decode().rstrip() + "\"")
            s = sign(data[23:].decode().rstrip())
            print("________________________")
            signature = binascii.hexlify(s).decode()
            self.transport.write(bytes(signature + '\n', "utf-8"))
            self.transport.write(b'\n')

        if (data == b'Successful login. Press any key.\r\r\n'):
            self.transport.write(b'\n')
            self.transport.write(b'\n')
            self.transport.write(b'3\n')
            self.transport.write(b'\n')
            self.transport.write(b'Q\n')
            self.transport.write(b'prendre downloader\n')
            self.transport.write(b'prendre carte SD\n')
            self.transport.write(b'prendre chargeur\n')
            self.transport.write(b'prendre uploader\n')
            self.transport.write(b'prendre lecteur\n')
            self.transport.write(b'prendre azote\n')
            self.transport.write(b'prendre suspecte\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'ascenseur\n')
            self.transport.write(b'\n')
            self.transport.write(b'sortir\n')
            self.transport.write(b'sortir\n')

            self.transport.write(b'use suspecte\n')
            self.transport.write(b'batch\n')
            self.transport.write(b'encryption\n')
            self.transport.write(
                bytes(
                    format(int(self.plain1, 2), 'x').zfill(32) + "\n",
                    "utf-8"))
            self.transport.write(
                bytes(
                    format(int(self.plain2, 2), 'x').zfill(32) + "\n",
                    "utf-8"))
            self.transport.write(b'\n')

        # initialisation
        if data[:6] == b"-----E" and self.flag_init:
            with open("../feistel.txt", "r") as f:
                content = f.read().splitlines()
                self.cypher1 = format(int(content[0], 16), 'b').zfill(128)
                self.cypher2 = format(int(content[2], 16), "b").zfill(128)
            with open("../feistel.txt", "w") as f:
                f.write("")
            self.flag = False
            self.flag_init = False
            self.flag_batch = True

            self.i = 0

        if data[:6] == b"-----E" and self.flag_batch:
            with open("../feistel.txt", "r") as f:
                content = f.read().splitlines()

                for k in range(
                        len(content) // 2
                ):  # content est vide au 1er tour (donc passe au 1er tour)
                    k3 = format(self.i - 1024 + k, "b").zfill(
                        16)  # ca decale les i d'ou le - 1024
                    #print(int(k3, 2))
                    cypher1prime = antifeistel(self.cypher1, k3, n, 1)
                    cypher2prime = antifeistel(self.cypher2, k3, n, 1)
                    cypher3prime = cypher2prime[0:n//2] \
                             + format( int(cypher2prime[n//2:n], 2) \
                                     ^ int(self.plain1[0:n//2], 2) \
                                     ^ int(self.plain2[0:n//2], 2), "b" ).zfill(n//2)
                    if self.i - 1024 + k == 1022:
                        print(format(int(cypher1prime, 2), 'x'))
                        print(format(int(cypher2prime, 2), 'x'))
                        print(format(int(cypher3prime, 2), 'x'))
                    plain3 = format(int(content[2 * k], 16), "b").zfill(128)
                    if distingueur_3tr(self.plain1, self.plain2, plain3,
                                       cypher1prime, cypher2prime,
                                       cypher3prime, n):
                        print("TROUVE LA FETE LA FETE")
                        time.sleep(5)

                        self.K3 = k3
                        with open("../k.txt", "w") as ggg:
                            ggg.write(self.K3)

                        self.transport.write(
                            bytes(format(k3, 'x').zfill(4), "utf-8"))

                        self.flag_batch = False
                        self.flag_remontee = True
                        break

            if not self.flag_remontee:
                print("_" * 30 + "\n\n i = ", self.i / 1024, "\n\n")
                self.transport.write(b"use suspecte\n")
                self.transport.write(b"batch\n")
                self.transport.write(b"decryption\n")
                for j in range(1024):
                    time.sleep(0.005)
                    k3 = format(self.i + j, "b").zfill(16)
                    #print(int(k3, 2))
                    cypher1prime = antifeistel(self.cypher1, k3, n, 1)
                    cypher2prime = antifeistel(self.cypher2, k3, n, 1)
                    cypher3prime = cypher2prime[0:n//2] \
                             + format( int(cypher2prime[n//2:n], 2) \
                                     ^ int(self.plain1[0:n//2], 2) \
                                     ^ int(self.plain2[0:n//2], 2), "b" ).zfill(n//2)
                    if self.i + j == 1022:
                        print(format(int(cypher1prime, 2), 'x'))
                        print(format(int(cypher2prime, 2), 'x'))
                        print(format(int(cypher3prime, 2), 'x'))
                    cypher3 = feistel(cypher3prime, k3, n, 1)
                    time.sleep(0.005)
                    self.transport.write(
                        bytes(
                            format(int(cypher3, 2), 'x').zfill(32) + "\n",
                            "utf-8"))
                    time.sleep(0.005)
                self.transport.write(b"\n")

            with open("../feistel.txt", "w") as f:
                f.write("")
            self.flag = False
            if self.i < 2**16:
                self.i += 1024
            else:
                self.flag_batch = False

        if self.flag:
            with open("../feistel.txt", "a") as f:
                f.write(data.decode())

        if data[:6] == b"-----B":
            self.flag = True

        if self.flag_remontee:
            self.transport.write(b"lala")
Esempio n. 34
0
def gen_xsrf(actions):
    xsrf = {}
    for action in actions:
        xsrf[action] = sign.sign(action + flask.session["g"])
    return {"xsrf": xsrf}
Esempio n. 35
0
import sign
from time import sleep

result = sign.sign()
result.noMaskErrorOn()
sleep(1)
result.noMaskErrorOff()
result.imMaskErrorOn()
sleep(1)
result.imMaskErrorOff()
result.okayOn()
sleep(1)
result.okayOff()
result.highErrorOn()
sleep(1)
result.highErrorOff()
result.fullErrorOn()
sleep(1)
result.fullErrorOff()
Esempio n. 36
0
 def sign(self, key, msg):
     if not isinstance(key, bytes) or not isinstance(msg, bytes):
         raise TypeError
     else:
         return s.sign(msg, s.importKey(key), self.__hash_alg)
Esempio n. 37
0
    HAND_APPROVED = 1
    HAND_DENIED = 0
    NOT_HAND = 2
    MAX_PEOPLE = 2

    restart_button = 40
    gpio.setmode(gpio.BOARD)
    gpio.setup(restart_button, gpio.IN, pull_up_down=gpio.PUD_UP)
    gpio.add_event_detect(restart_button,
                          gpio.RISING,
                          callback=restart,
                          bouncetime=200)

    ExitHR = ExitHandReader.ExitHandReader(32, 31)
    print("Exit Hand Reader Initialized!")

    door = Door()
    print("Door Initialized!")
    B = Buzzer(33)
    print("Buzzer Initialized!")
    PC = PeopleCounter.PeopleCounter(23, 24, 21, 22, func=door.close)
    print("People Counter Initialized!")
    EntryHR = OuterHandReader.OHandReader(12, 18, 1, _get_state=PC._get_state)
    print("Entry Hand Reader Initialized!")
    MD = MaskDetector.MaskDetector(headless=False)
    print("Mask Detector Initialized!")
    opsign = sign.sign()

    main()
Esempio n. 38
0
    # Verify the ECDSA signature of a signed transaction
    # 4674da699de44c9c5d182870207ba89e5ccf395e5101dab6b0900bbf2f3b16cb
    #
    tx_inputs = inputs[0:1]
    tx_outputs = [TxOut(address='1JDZRGf5fPjGTpqLNwjHFFZnagcZbwDsxw', satoshi=800)]
    tx_digest = transaction_digest(tx_inputs, tx_outputs)[0]
    serialized_sig = unhexlify('304402207e2c6eb8c4b20e251a71c580373a2836e209c50726e5f8b0f4f59f8af00eee1a022019ae1690e2eb4455add6ca5b86695d65d3261d914bc1d7abb40b188c7f46c9a5')
    sig = deserialize_signature(serialized_sig)
    print(verify_signature(pub_key, tx_digest, sig))
    #
    # Sign an unsigned transaction then broadcast
    # c04bbd007ad3987f9b2ea8534175b5e436e43d64471bf32139b5851adf9f477e
    #
    serialized_pub_key = serialize_public_key(pub_key)
    tx_inputs = inputs[1:]
    tx_outputs = [TxOut(address='18CgRLx9hFZqDZv75J5kED7ANnDriwvpi1', satoshi=1700)]
    tx_digests = transaction_digest(tx_inputs, tx_outputs)
    for i in range(len(tx_digests)):
        tx_digest = tx_digests[i]
        sig = sign(priv_key, tx_digest)
        serialized_sig = serialize_signature(sig)
        # unlocking_script = LEN + der + sighash + LEN + public_key
        tx_inputs[i].unlocking_script = bytes([len(serialized_sig) + 1]) + serialized_sig + bytes([SIGHASH_ALL, len(serialized_pub_key)]) + serialized_pub_key
        print(hexlify(tx_inputs[i].unlocking_script))
        tx_inputs[i].unlocking_script_len = int_to_varint(len(tx_inputs[i].unlocking_script))
        print(hexlify(tx_inputs[i].unlocking_script_len))
    raw = serialize_transaction(tx_inputs, tx_outputs)
    print(hexlify(raw))
    tx_id = double_sha256(raw)[::-1]
    print(hexlify(tx_id))
Esempio n. 39
0
 def __init__(self):
     self.board = board()
     self.datalist = datalist()
     self.sign = sign()
     self.get_alba = get_alba()
Esempio n. 40
0
def do_sign(changesfile):
    sign.sign(changesfile)