当前位置: 首页>>代码示例>>Python>>正文


Python AnonCrypto.decrypt_with_rsa方法代码示例

本文整理汇总了Python中anon_crypto.AnonCrypto.decrypt_with_rsa方法的典型用法代码示例。如果您正苦于以下问题:Python AnonCrypto.decrypt_with_rsa方法的具体用法?Python AnonCrypto.decrypt_with_rsa怎么用?Python AnonCrypto.decrypt_with_rsa使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在anon_crypto.AnonCrypto的用法示例。


在下文中一共展示了AnonCrypto.decrypt_with_rsa方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: shuffle_and_decrypt

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import decrypt_with_rsa [as 别名]
	def shuffle_and_decrypt(self):
		random.shuffle(self.data_in)
		self.debug("Shuffling len = %d" % len(self.data_in))
		self.data_out = []
		for ctuple in self.data_in:
			(rem_round, ctext) = marshal.loads(ctuple)
			if rem_round != self.round_id:
				raise RuntimeError, "Mismatched round numbers (mine:%d, other:%d)" % (self.round_id, rem_round)

			new_ctext = AnonCrypto.decrypt_with_rsa(self.key1, ctext)	
			pickled = marshal.dumps((self.round_id, new_ctext))
			self.data_out.append(pickled)
开发者ID:ASchurman,项目名称:Dissent,代码行数:14,代码来源:shuffle_node.py

示例2: decrypt_ciphers

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import decrypt_with_rsa [as 别名]
	def decrypt_ciphers(self, keyset):
		priv_keys = {}
		for item in keyset:
			""" Verify signature on each key """
			item_str = AnonCrypto.verify(self.pub_keys, item)
			(r_id, r_roundid, r_keystr) = marshal.loads(item_str)
			if r_roundid != self.round_id:
				raise RuntimeError, 'Mismatched round numbers'
			priv_keys[r_id] = AnonCrypto.priv_key_from_str(r_keystr)

		plaintexts = []
		for cipher in self.final_ciphers:
			(r_round, cipher_prime) = marshal.loads(cipher)
			if r_round != self.round_id:
				raise RuntimeError, 'Mismatched round ids'
			for i in xrange(0, self.n_nodes):
				cipher_prime = AnonCrypto.decrypt_with_rsa(priv_keys[i], cipher_prime)
			plaintexts.append(self.unpackage_msg(cipher_prime))
		
		self.anon_data = plaintexts
开发者ID:ASchurman,项目名称:Dissent,代码行数:22,代码来源:shuffle_node.py

示例3: run_phase3

# 需要导入模块: from anon_crypto import AnonCrypto [as 别名]
# 或者: from anon_crypto.AnonCrypto import decrypt_with_rsa [as 别名]
    def run_phase3(self):
        self.advance_phase()
        self.info("Starting data transmission phase")

        self.responses = []
        self.go_flag = False

        """
		We put all of the pseudo-random strings in a tar file
		for transmission.
		"""
        handle, self.tar_filename = tempfile.mkstemp()
        tar = tarfile.open(name=self.tar_filename, mode="w")  # Create new archive
        # dereference = True)

        """ For each transmission slot... """
        for i in xrange(0, self.n_nodes):
            debug("Processing data for msg slot %d" % i)
            slot_data = self.msg_data[i]
            msg_len = slot_data[0]
            enc_seeds = slot_data[1]
            hashes = slot_data[2]

            if enc_seeds[self.id] == self.my_seed:
                """ If this is my seed, use the cheating message. """
                self.go_flag = True
                self.responses.append(self.dfilename)
                tar.add(self.cip_file, "%d" % (self.id))
            else:
                """ If this is not my msg slot, decrypt seed assigned to me. """
                seed = AnonCrypto.decrypt_with_rsa(self.key1, enc_seeds[self.id])
                h_val, fname = self.generate_prng_file(seed, msg_len)

                if h_val != hashes[self.id]:
                    for q in xrange(0, len(hashes)):
                        self.debug("> %d - %s" % (q, hashes[q]))
                    raise RuntimeError, "Mismatched hash values"

                """
				Label each file in the tar with this node's id so that nodes can
				match the files to the message hashes.
				"""
                tar.add(fname, "%d" % (self.id))
        tar.close()

        if not self.go_flag:
            raise RuntimeError, "My ciphertext is missing"

        if self.am_leader():
            fnames = AnonNet.recv_file_from_n(self.sockets)
            fnames.append(self.tar_filename)
            self.message_tar = self.generate_msg_tar(fnames)

            """ Broadcast final messages """
            self.debug("Broadcasting msg tar")
            self.broadcast_file_to_all_nodes(self.message_tar)
            self.debug("Sent msg tar")
        else:
            AnonNet.send_file_to_sock(self.leader_socket, self.tar_filename)
            self.debug("Waiting for msg tar")
            self.message_tar = AnonNet.recv_file_from_sock(self.leader_socket)
            self.debug("Got for msg tar")
开发者ID:ecrypto,项目名称:dissent,代码行数:64,代码来源:bulk_node.py


注:本文中的anon_crypto.AnonCrypto.decrypt_with_rsa方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。