Esempio n. 1
0
 def test_encrypt(self):
     msg = b'My private message'
     pw = b'my private key'
     pk = str(seccure.passphrase_to_pubkey(pw))
     self.assertEqual(seccure.decrypt(seccure.encrypt(msg, pk), pw), msg)
     for c in seccure.curves:
         self.assertEqual(
             seccure.decrypt(
                 seccure.encrypt(
                     msg,
                     str(seccure.passphrase_to_pubkey(pw, curve=c)),
                     curve=c),
                 pw, curve=c),
             msg)
Esempio n. 2
0
 def test_encrypt(self):
     msg = b'My private message'
     pw = b'my private key'
     pk = str(seccure.passphrase_to_pubkey(pw))
     self.assertEqual(seccure.decrypt(seccure.encrypt(msg, pk), pw), msg)
     for c in seccure.curves:
         self.assertEqual(
             seccure.decrypt(
                 seccure.encrypt(
                     msg,
                     str(seccure.passphrase_to_pubkey(pw, curve=c)),
                     curve=c),
                 pw, curve=c),
             msg)
Esempio n. 3
0
 def __init__(self, parent = None, id = 0, passString = None):
     super(passwordList, self).__init__(parent)
     self.passStringLocal = passString
     self.table = QtGui.QTableWidget()
     self.tableItem = QtGui.QTableWidgetItem()
     self.table.setWindowTitle("List of Accounts")
     self.table.resize(800, 600)
     self.table.setColumnWidth(100,100)
     self.conn = sqlite3.connect("Data.db")
     self.c = self.conn.cursor()
     data = self.c.execute("SELECT * FROM PASSES WHERE ID = ?;",[(id)])
     self.counter = 0
     extData = []
     for i in data:
         self.counter += 1
         extData.append(i)
     self.table.setRowCount(self.counter)
     self.table.setColumnCount(3)
     self.table.setColumnWidth(0, 200)
     self.table.setColumnWidth(1, 200)
     self.table.setColumnWidth(2, 200)
     self.table.setHorizontalHeaderLabels(["Company", "Email/Username", "Password"])
     for i in range(self.counter):
         print(extData[i][3])
         self.table.setItem(i, 0, QtGui.QTableWidgetItem(extData[i][1]))
         self.table.setItem(i, 1, QtGui.QTableWidgetItem(extData[i][2]))
         self.table.setItem(i, 2, QtGui.QTableWidgetItem(seccure.decrypt(extData[i][3], passString.encode()).decode()))
     self.table.show()
Esempio n. 4
0
 def test_encrypt(self):
     msg = b'My private message'
     pw = b'my private key'
     self.assertEqual(
         seccure.decrypt(
             seccure.encrypt(msg, str(seccure.passphrase_to_pubkey(pw))),
             b'my private key'), msg)
Esempio n. 5
0
def decryptMiniProdFile(key):
    # List files in the export folder
    export_file_names = [
        f for f in listdir("export/") if isfile(join("export/", f))
    ]

    # Ask for Mooltipass ID
    mooltipass_ids = raw_input("Enter Mooltipass ID: ")

    # Generate a list with Mooltipass IDs
    mooltipass_ids_list = mooltipass_ids.split(' ')

    # Find Mooltipass ID in files
    for mooltipass_id in mooltipass_ids_list:
        for file_name in export_file_names:
            if "Mooltipass-" + mooltipass_id + ".txt" in file_name:
                print "Found export file:", file_name
                data = pickle_read(join("export/", file_name))
                decrypted_data = seccure.decrypt(data,
                                                 key,
                                                 curve='secp521r1/nistp521')
                items = decrypted_data.split('|')
                #print decrypted_data
                # Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write

                if True:
                    # Print Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID (might get quite big)
                    data_qr = pyqrcode.create(decrypted_data, error="L")
                    print(data_qr.terminal(quiet_zone=1))
                    raw_input("Press enter:")
                else:
                    # This is just here in case you need it....
                    # key1
                    key1 = items[1]
                    key1_qr = pyqrcode.create(key1)
                    print ""
                    print "AES key 1:", key1
                    print(key1_qr.terminal(quiet_zone=1))

                    # key2
                    key2 = items[2]
                    key2_qr = pyqrcode.create(key2)
                    print ""
                    print "AES key 2:", key2
                    print(key2_qr.terminal(quiet_zone=1))

                    # Request UID
                    request = items[3]
                    request_qr = pyqrcode.create(request)
                    print "Request UID key:", request
                    print(request_qr.terminal(quiet_zone=1))

                    # UID
                    request = items[4]
                    request_qr = pyqrcode.create(request)
                    print "UID :", request
                    print(request_qr.terminal(quiet_zone=1))
Esempio n. 6
0
 def decrypt(message, key):
     args = (message, key)
     if not args in Private.decrypt_cache:
         try:
             result = seccure.decrypt(message, key, "secp256r1/nistp256")
         except:  #decryption failure
             result = None
         Private.decrypt_cache[args] = result
     return Private.decrypt_cache[args]
Esempio n. 7
0
 def CalBAL(self):
     self.conn = sqlite3.connect('BankDB.db')
     self.c = self.conn.cursor()
     self.data = self.c.execute('SELECT TRANSACTION_AMOUNT FROM SAMPE WHERE RECEIVER_ID = ?;', [(self.accID)])
     self.pos = 0
     for i in self.data:
         # self.pos += int(i[0])
         self.pos += float(seccure.decrypt(i[0], b'my private key').decode())
         # print(seccure.decrypt(str(i[0]).encode(), b'my private key'))
         self.data = self.c.execute('SELECT TRANSACTION_AMOUNT FROM SAMPE WHERE SENDER_ID = ?;', [(self.accID)])
         self.neg = 0
     for i in self.data:
         pass
         self.neg += float(seccure.decrypt(i[0], b'my private key').decode())
         # print(seccure.decrypt(str(i[0]).encode(), b'my private key'))
         # self.bald = self.c.execute('SELECT NETBALANCE FROM USERS WHERE ACCOUNT_ID = ?;',[(self.accID)])
         print(self.accID)
         self.NETBAL = self.pos - self.neg
Esempio n. 8
0
def asym_decrypt(encoded_ciphertext, private_key):
    ''' decryption with ECIES '''
    ciphertext = b64decode(encoded_ciphertext)
    plaintext = seccure.decrypt(ciphertext, private_key)
    liste = split_words(plaintext)
    if len(liste) > 1:
        return liste
    else:
        return plaintext
def decryptMiniProdFile(key):	
	# List files in the export folder
	export_file_names = [f for f in listdir("export/") if isfile(join("export/", f))]
		
	# Ask for Mooltipass ID
	mooltipass_ids = raw_input("Enter Mooltipass ID: ")
	
	# Generate a list with Mooltipass IDs
	mooltipass_ids_list = mooltipass_ids.split(' ')
	
	# Find Mooltipass ID in files
	for mooltipass_id in mooltipass_ids_list:
		for file_name in export_file_names:
			if "Mooltipass-" + mooltipass_id + ".txt" in file_name:
				print "Found export file:", file_name
				data = pickle_read(join("export/",file_name))			
				decrypted_data = seccure.decrypt(data, key, curve='secp521r1/nistp521')
				items = decrypted_data.split('|')
				#print decrypted_data
				# Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write
				
				if True:
					# Print Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID (might get quite big)
					data_qr = pyqrcode.create(decrypted_data, error="L")
					print(data_qr.terminal(quiet_zone=1))
					raw_input("Press enter:")
				else:
					# This is just here in case you need it....
					# key1
					key1 = items[1]
					key1_qr = pyqrcode.create(key1)
					print ""
					print "AES key 1:", key1
					print(key1_qr.terminal(quiet_zone=1))
					
					# key2
					key2 = items[2]
					key2_qr = pyqrcode.create(key2)
					print ""
					print "AES key 2:", key2
					print(key2_qr.terminal(quiet_zone=1))
					
					# Request UID
					request = items[3]
					request_qr = pyqrcode.create(request)
					print "Request UID key:", request
					print(request_qr.terminal(quiet_zone=1))
					
					# UID
					request = items[4]
					request_qr = pyqrcode.create(request)
					print "UID :", request
					print(request_qr.terminal(quiet_zone=1))
Esempio n. 10
0
 def decrypt(self, cipher, private_key):
     """Decrypts a message with the provide private key.
     
        @param cipher The encrypted message.
        @param private_key The key to use for decryption.
        @return The decrypted message.
     """
     assert type(cipher) is bytes
     # TODO: This should probably raise some type of exception when decryption fails ...
     message = seccure.decrypt(cipher, private_key)
     self.logger.debug("Decrypted " + str(len(message)) + " bytes")
     return message
Esempio n. 11
0
    def decrypt(self, eccpgp_struct, passphrase=''):
        struct = self.make_eccpgp_structure()

        header = seccure.decrypt(b64dec(eccpgp_struct['header']), passphrase.encode())
        struct['header'] = json.loads(header.decode())

        sc = SymCiph()
        self._skey = b64dec(struct['header']['key'])
        self._iv = b64dec(struct['header']['iv'])
        crypto = sc.create_crypto(self._skey, self._iv)

        payload = sc.decrypt(crypto, b64dec(eccpgp_struct['payload']))
        struct['payload'] = payload

        return struct
Esempio n. 12
0
    def decrypt(self, eccpgp_struct, passphrase=''):
        struct = self.make_eccpgp_structure()

        header = seccure.decrypt(b64dec(eccpgp_struct['header']),
                                 passphrase.encode())
        struct['header'] = json.loads(header.decode())

        sc = SymCiph()
        self._skey = b64dec(struct['header']['key'])
        self._iv = b64dec(struct['header']['iv'])
        crypto = sc.create_crypto(self._skey, self._iv)

        payload = sc.decrypt(crypto, b64dec(eccpgp_struct['payload']))
        struct['payload'] = payload

        return struct
Esempio n. 13
0
def decryptMiniProdFile(key):
    # List files in the export folder
    export_file_names = [
        f for f in listdir("export/") if isfile(join("export/", f))
    ]

    # Ask for Mooltipass ID
    mooltipass_id = raw_input("Enter Mooltipass ID: ")

    # Find Mooltipass ID in files
    for file_name in export_file_names:
        if mooltipass_id in file_name:
            print "Found export file:", file_name
            data = pickle_read(join("export/", file_name))
            decrypted_data = seccure.decrypt(data,
                                             key,
                                             curve='secp521r1/nistp521')
            items = decrypted_data.split('|')
            #print decrypted_data
            # Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write

            # key1
            key1 = items[1]
            key1_qr = pyqrcode.create(key1)
            print ""
            print "AES key 1:", key1
            print(key1_qr.terminal(quiet_zone=1))

            # key2
            key2 = items[2]
            key2_qr = pyqrcode.create(key2)
            print ""
            print "AES key 2:", key2
            print(key2_qr.terminal(quiet_zone=1))

            # Request UID
            request = items[3]
            request_qr = pyqrcode.create(request)
            print "Request UID key:", request
            print(request_qr.terminal(quiet_zone=1))

            # UID
            request = items[4]
            request_qr = pyqrcode.create(request)
            print "UID :", request
            print(request_qr.terminal(quiet_zone=1))
Esempio n. 14
0
 def fetch(self):
     self.conn = sqlite3.connect('BankDB.db')
     self.c = self.conn.cursor()
     self.data = self.c.execute(
         'SELECT SENDER_ID, RECEIVER_ID, TRANSACTION_AMOUNT, DOT, TOT, TRANSACTION_ID from SAMPE where ACCOUNT_ID = ? or RECEIVER_ID = ?;',
         [(self.accID), (self.accID)])
     j = 0
     for i in self.data:
         self.setItem(j, 0, QtWidgets.QTableWidgetItem(str(i[0])))
         self.setItem(j, 1, QtWidgets.QTableWidgetItem(str(i[1])))
         self.setItem(
             j, 2,
             QtWidgets.QTableWidgetItem(
                 str(s.decrypt(i[2], b'my private key'))))
         self.setItem(j, 3, QtWidgets.QTableWidgetItem(str(i[3])))
         self.setItem(j, 4, QtWidgets.QTableWidgetItem(str(i[4])))
         self.setItem(j, 5, QtWidgets.QTableWidgetItem(str(i[5])))
         j += 1
Esempio n. 15
0
def decryptMiniProdFile(key):	
	# List files in the export folder
	export_file_names = [f for f in listdir("export/") if isfile(join("export/", f))]
		
	# Ask for Mooltipass ID
	mooltipass_id = raw_input("Enter Mooltipass ID: ")
	
	# Find Mooltipass ID in files
	for file_name in export_file_names:
		if mooltipass_id in file_name:
			print "Found export file:", file_name
			data = pickle_read(join("export/",file_name))			
			decrypted_data = seccure.decrypt(data, key, curve='secp521r1/nistp521')
			items = decrypted_data.split('|')
			#print decrypted_data
			# Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write
			
			# key1
			key1 = items[1]
			key1_qr = pyqrcode.create(key1)
			print ""
			print "AES key 1:", key1
			print(key1_qr.terminal(quiet_zone=1))
			
			# key2
			key2 = items[2]
			key2_qr = pyqrcode.create(key2)
			print ""
			print "AES key 2:", key2
			print(key2_qr.terminal(quiet_zone=1))
			
			# Request UID
			request = items[3]
			request_qr = pyqrcode.create(request)
			print "Request UID key:", request
			print(request_qr.terminal(quiet_zone=1))
			
			# UID
			request = items[4]
			request_qr = pyqrcode.create(request)
			print "UID :", request
			print(request_qr.terminal(quiet_zone=1))
Esempio n. 16
0
def determine_escalation():
    global enc_data
    global counter
    decTime = 0
    decrypted_bytestring = ''
    decryptedTextString = ''
    strdec = ''
    decrypted = []
    private_key = '77'
    jsondata = request.get_data()
    enc_data.update({jsondata[-3:]: jsondata[:-3]})
    #stuff happens here that involves data to obtain a result
    result = {'status': 'data received'}
    if counter > 0:
        counter -= 1
    if counter == 0:
        ciphertext = []
        temp = {}
        for el in enc_data:
            temp.update({int(el, 2): enc_data[el]})
        for key in sorted(temp.iterkeys()):
            ciphertext.append(temp[key])
        for k in range(7):
            t1 = time.time()
            decrypted.append(seccure.decrypt(ciphertext[k], private_key))
            t2 = time.time()
            decTime = decTime + (t2 - t1)
            #print decrypted[k]
            decrypted_bytestring += decrypted[k]
        for l in range(len(decrypted_bytestring) / 7):
            strdec += chr(int(decrypted_bytestring[l * 7:(l + 1) * 7], 2))
        decryptedTextString = strdec
        print "\nFinal Decrypted String: {}".format(decryptedTextString)
        enc_data = {}
        counter = 7
    return json.dumps(result)
def doEccDecrypt(data_cipher, privatekey):
    return seccure.decrypt(data_cipher, privatekey)
Esempio n. 18
0
def seccure_get_decrypted_content(cipher_text , private_key):
    cipher_text = base64.decodestring(cipher_text)
    plain_text = seccure.decrypt(cipher_text, private_key)
    return plain_text
Esempio n. 19
0
    #RECEIVE packet data from CLOUD 2
    #RECEIVE packet data from CLOUD 3
    #RECEIVE packet data from CLOUD 4
    #RECEIVE packet data from CLOUD 5
    #RECEIVE packet data from CLOUD 6
    #RECEIVE packet data from CLOUD 7
    #RECEIVE packet data from CLOUD 8
    #Combine packets and store in the list cyphertext in the order that they appeared
    
    print 'Encryption Time for the iteration',t2-t1
    enc_times_data.append(t2-t1)
    
    decrypted_bytestring = ''
    t1 = time.time()
    for k in range(7):
        decrypted.append(seccure.decrypt(ciphertext[k], private_key))
        #print decrypted[k]
        decrypted_bytestring += decrypted[k]

    #print decrypted_bytestring == byteString
    #print len(decrypted_bytestring)

    strdec = ''
    for l in range(len(decrypted_bytestring)/7):
        strdec += chr(int(decrypted_bytestring[l*7:(l+1)*7],2))
    
    #print strdec
    decryptedTextString += strdec

    t2 = time.time()
    tot2 = t2
    def _packet_in_handler(self, ev):
        # If you hit this you might want to increase
        # the "miss_send_length" of your switch
        if ev.msg.msg_len < ev.msg.total_len:
            self.logger.debug("packet truncated: only %s of %s bytes",
                              ev.msg.msg_len, ev.msg.total_len)
        msg = ev.msg                               
        datapath = msg.datapath
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        in_port = msg.match['in_port']

        #Parsing various headers
        pkt = packet.Packet(msg.data)
        eth = pkt.get_protocols(ethernet.ethernet)[0]
        ipv = pkt.get_protocols(ipv4.ipv4)
	pkt_icmp = pkt.get_protocols(icmp.icmp)

	if pkt_icmp:
	    encicmpdata = str(pkt.protocols[-1].data.data)
	    srcip = pkt.protocols[1].src

	    # Try to decrypt the ICMP payload, and check if it is a Decoy routing request
	    try:
            	icmpData = seccure.decrypt(encicmpdata, b'my private key')
            except AssertionError:
            	#self.logger.info('Send ICMP echo reply to [%s].', srcip, extra=self.sw_id)
		print "ICMP not of concern"
            	return

            if "Siege" in icmpData:
		print "Got a Decoy Routing PING"
            	timeout = 0 #in case client doesn't supply one, we will use OVS default
            	timeoutString = icmpData[icmpData.find('Siege')+5: icmpData.find('@')]
            	dstip = ip_addr_ntoa(icmpData[icmpData.find('@')+1: icmpData.find('#')])
		#dstip="192.168.2.4"
            	srcport = icmpData[icmpData.find('#')+1: icmpData.find('$')]
            	if timeoutString is not '':
                	timeout = int(timeoutString)
                	#self.logger.info("Timeout value received: %s", timeout, extra=self.sw_id)
		print timeout
		# If all the fields are extracted add redirection rules
	    	self.add_redirection_flows(datapath, msg.buffer_id,srcport,dstip,timeout,srcip)

        if ipv:
            ipv = ipv[0]
            src = ipv.src
            dst = ipv.dst
            print src, dst

        if eth.ethertype == ether_types.ETH_TYPE_LLDP:
            # ignore lldp packet
            return

        dst = eth.dst
        src = eth.src

        dpid = datapath.id
        self.mac_to_port.setdefault(dpid, {})

        self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)

        # learn a mac address to avoid FLOOD next time.
        self.mac_to_port[dpid][src] = in_port
        if dst in self.mac_to_port[dpid]:
            out_port = self.mac_to_port[dpid][dst]
        else:
            out_port = ofproto.OFPP_FLOOD

        actions = [parser.OFPActionOutput(ofproto.OFPP_NORMAL, 0)]
 
        #install decoy routing flows if not already done
        if self.flag is False:
                #self.add_redirection_flows(datapath, msg.buffer_id)
                self.add_table_100_redirection(datapath, msg.buffer_id)
		self.add_icmp_redirection(datapath, msg.buffer_id)
                self.flag = True

        # install a flow to avoid packet_in next time
        if out_port != ofproto.OFPP_FLOOD:
            match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
            # verify if we have a valid buffer_id, if yes avoid to send both
            # flow_mod & packet_out
            if msg.buffer_id != ofproto.OFP_NO_BUFFER:
                self.add_flow(datapath, 2, match, actions, msg.buffer_id, table_id=200, redirect_table=False)
                if ipv is not None:
                        #print "Adding IP flow for this"
                        self.add_flow(datapath, 2, match, actions, msg.buffer_id, table_id=200, redirect_table=True, src_ip = ipv.src_ip, dst_ip=ipv.dst_ip)
            else:
                #print "adding flow2"
                self.add_flow(datapath, 2, match, actions, table_id=200, redirect_table=False)#,  src_ip = ipv.src_ip, dst_ip=ipv.dst_ip)
        if msg.buffer_id == ofproto.OFP_NO_BUFFER:
            data = msg.data

        out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
                                  in_port=in_port, actions=actions, data=data)
        datapath.send_msg(out)
Esempio n. 21
0
def test_ec_crypto():
    q,p = seccure.generate_keypair()
    c = seccure.encrypt(b'ABC' ,  p)
    print seccure.decrypt(c , q)
Esempio n. 22
0
 def raw_dec(self, data, prvkey=''):
     return seccure.decrypt(data, prvkey)
Esempio n. 23
0
def decriptText(cipherText):
    private_key = 'prueba1'
    text = seccure.decrypt(cipherText, private_key.encode())
    print(text)                                                                      
    return text
Esempio n. 24
0
 def raw_dec(self, data, prvkey=''):
     return seccure.decrypt(data, prvkey)
Esempio n. 25
0
def decryptMiniProdFile(key):	
	# List files in the export folder
	export_file_names = [f for f in listdir("export/") if isfile(join("export/", f))]
		
	# Ask for Mooltipass ID
	mooltipass_ids = raw_input("Enter Mooltipass ID: ")
	
	# If "uid_export" is entered, generate a csv export
	if mooltipass_ids == "uid_export":
		csvexport = csv.writer(open("uid_export.tsv", "wb"), delimiter='	', quoting=csv.QUOTE_NONNUMERIC)
		csvexport.writerow(["Serial Number", "UID Req Code", "UID"])
		for file_name in export_file_names:
			print "Trackling export file:", file_name
			data = pickle_read(join("export/",file_name))			
			decrypted_data = seccure.decrypt(data, key, curve='secp521r1/nistp521')
			items = decrypted_data.split('|')
			#print decrypted_data
			# Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write
			csvexport.writerow([items[0],items[3],items[4]])
			
	else:	
		# Generate a list with Mooltipass IDs
		mooltipass_ids_list = mooltipass_ids.split(' ')
		
		# Find Mooltipass ID in files
		for mooltipass_id in mooltipass_ids_list:
			for file_name in export_file_names:
				if "Mooltipass-" + mooltipass_id + ".txt" in file_name:
					print "Found export file:", file_name
					data = pickle_read(join("export/",file_name))			
					decrypted_data = seccure.decrypt(data, key, curve='secp521r1/nistp521')
					items = decrypted_data.split('|')
					#print decrypted_data
					# Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write
					
					if True:
						# Print Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID (might get quite big)
						data_qr = pyqrcode.create(decrypted_data, error="L")
						print(data_qr.terminal(quiet_zone=1))
						raw_input("Press enter:")
					else:
						# This is just here in case you need it....
						# key1
						key1 = items[1]
						key1_qr = pyqrcode.create(key1)
						print ""
						print "AES key 1:", key1
						print(key1_qr.terminal(quiet_zone=1))
						
						# key2
						key2 = items[2]
						key2_qr = pyqrcode.create(key2)
						print ""
						print "AES key 2:", key2
						print(key2_qr.terminal(quiet_zone=1))
						
						# Request UID
						request = items[3]
						request_qr = pyqrcode.create(request)
						print "Request UID key:", request
						print(request_qr.terminal(quiet_zone=1))
						
						# UID
						request = items[4]
						request_qr = pyqrcode.create(request)
						print "UID :", request
						print(request_qr.terminal(quiet_zone=1))
def decryptMiniProdFile(key):
    # List files in the export folder
    export_file_names = [
        f for f in listdir("export/") if isfile(join("export/", f))
    ]

    # Ask for Mooltipass ID
    mooltipass_ids = raw_input("Enter Mooltipass ID: ")

    # If "uid_export" is entered, generate a csv export
    if mooltipass_ids == "uid_export":
        csvexport = csv.writer(open("uid_export.tsv", "wb"),
                               delimiter='	',
                               quoting=csv.QUOTE_NONNUMERIC)
        csvexport.writerow(["Serial Number", "UID Req Code", "UID"])
        for file_name in export_file_names:
            print "Trackling export file:", file_name
            data = pickle_read(join("export/", file_name))
            decrypted_data = seccure.decrypt(data,
                                             key,
                                             curve='secp521r1/nistp521')
            items = decrypted_data.split('|')
            #print decrypted_data
            # Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write
            csvexport.writerow([items[0], items[3], items[4]])

    else:
        # Generate a list with Mooltipass IDs
        mooltipass_ids_list = mooltipass_ids.split(' ')

        # Find Mooltipass ID in files
        for mooltipass_id in mooltipass_ids_list:
            for file_name in export_file_names:
                if "Mooltipass-" + mooltipass_id + ".txt" in file_name:
                    print "Found export file:", file_name
                    data = pickle_read(join("export/", file_name))
                    decrypted_data = seccure.decrypt(
                        data, key, curve='secp521r1/nistp521')
                    items = decrypted_data.split('|')
                    #print decrypted_data
                    # Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID, flush write

                    if True:
                        # Print Mooltipass ID | aes key 1 | aes key 2 | request ID key | UID (might get quite big)
                        data_qr = pyqrcode.create(decrypted_data, error="L")
                        print(data_qr.terminal(quiet_zone=1))
                        raw_input("Press enter:")
                    else:
                        # This is just here in case you need it....
                        # key1
                        key1 = items[1]
                        key1_qr = pyqrcode.create(key1)
                        print ""
                        print "AES key 1:", key1
                        print(key1_qr.terminal(quiet_zone=1))

                        # key2
                        key2 = items[2]
                        key2_qr = pyqrcode.create(key2)
                        print ""
                        print "AES key 2:", key2
                        print(key2_qr.terminal(quiet_zone=1))

                        # Request UID
                        request = items[3]
                        request_qr = pyqrcode.create(request)
                        print "Request UID key:", request
                        print(request_qr.terminal(quiet_zone=1))

                        # UID
                        request = items[4]
                        request_qr = pyqrcode.create(request)
                        print "UID :", request
                        print(request_qr.terminal(quiet_zone=1))
Esempio n. 27
0
 def test_encrypt(self):
     msg = b'My private message'
     pw = b'my private key'
     self.assertEqual(seccure.decrypt(seccure.encrypt(msg,
                     str(seccure.passphrase_to_pubkey(pw))),
                         b'my private key'), msg)
#
#
# using elliptic curve cryptography to encrypt messages. 
#
# use with seccure: https://github.com/MeeSeongIm/py-seccure
#
#



import seccure

str(seccure.passphrase_to_pubkey(b'my private key'))  # devive the public key 

ciphertext = seccure.encrypt(b'This is a secret message.\n', b'8W;>i^H0qi|J&$coR5MFpR*Vn')

print(ciphertext)

seccure.decrypt(ciphertext, b'my private key')

seccure.sign(b'This will be a signed message.\n', b'my private key') 

seccure.verify(b'This will be a signed message.\n', b'', b'8W;>i^H0qi|J&$coR5MFpR*Vn')  # to verify the signature