Esempio n. 1
0
 def setUp(self):
     shared_secret = 'secretsecretsecretsecret'
     name_alice = 'alice'
     name_bob = 'bob'
     self.alice = MutualAuth(shared_secret, name_alice)
     self.bob = MutualAuth(shared_secret, name_bob)
     self.alice_dh = 17
     self.bob_dh = 3
Esempio n. 2
0
	def setUp(self):
		shared_secret = 'secretsecretsecretsecret'
		name_alice = 'alice'
		name_bob = 'bob'
		self.alice = MutualAuth(shared_secret, name_alice)
		self.bob = MutualAuth(shared_secret, name_bob)
		self.alice_dh = 17
		self.bob_dh = 3
Esempio n. 3
0
File: main.py Progetto: iim/442VPN
    def useSharedSecret(self, obj):

        # validate shared secret input
        if (self.shared_secret_value.text != ''):
            self.shared_secret_value.disabled = True

            # use hashed shared secret as key for mutual authentication
            self.shared_secret_hash = md5.new(
                self.shared_secret_value.text).digest()
            self.mutual_auth = MutualAuth(self.shared_secret_hash, self.mode)
        else:
            self.console.text = self.console.text + "\nERROR: Please enter a shared secret."
            print "ERROR: Please enter a shared secret."
            return

        # on success
        if (self.mutualAuthentication()):
            self.key_estabilshment_inprogress = False
            self.send_data_button.disabled = False
            self.send_secret_button.disabled = True

            # initialize the CBC cipher
            key = md5.new(str(self.total_session_key)).digest()
            self.cipher = CBC.generateCBC(key)

            # start up thread for receiving incoming messages
            threading.Thread(target=self.messageReceivingService).start()

            # in server, start up thread to periodically refresh session key
            if (self.mode == 'server'):
                threading.Thread(target=self.updateSessionKeyService).start()
Esempio n. 4
0
class MutualAuthTest(unittest.TestCase):
    def setUp(self):
        shared_secret = 'secretsecretsecretsecret'
        name_alice = 'alice'
        name_bob = 'bob'
        self.alice = MutualAuth(shared_secret, name_alice)
        self.bob = MutualAuth(shared_secret, name_bob)
        self.alice_dh = 17
        self.bob_dh = 3

    def test(self):

        bits = 100
        # alice send ra
        ra = self.alice.generate_nonce(bits)

        # bob use ra to encrypt eb and send rb
        eb = self.bob.encrypt_nonce(ra, self.bob_dh)
        rb = self.bob.generate_nonce(bits)

        # alice validate eb encrypted by bob
        plaintext = self.alice.decrypt_ciphertext(eb)
        # alice's own name not in plaintext
        self.assertFalse(self.alice.check_name(plaintext))
        # alice's nonce is in plaintext
        self.assertTrue(self.alice.check_nonce(plaintext))
        # get bob's dh
        self.assertEquals(str(self.bob_dh),
                          str(self.alice.get_partner_dh_value(plaintext)))

        # alice use rb to encrypt ea encryted by alice
        ea = self.alice.encrypt_nonce(rb, self.alice_dh)

        # bob validates ea
        plaintext = self.bob.decrypt_ciphertext(ea)
        # bob's own name not in plaintext
        self.assertFalse(self.bob.check_name(plaintext))
        # bob's nonce is in plaintext
        self.assertTrue(self.bob.check_nonce(plaintext))
        # get alice's dh
        self.assertEquals(str(self.alice_dh),
                          str(self.bob.get_partner_dh_value(plaintext)))
Esempio n. 5
0
class MutualAuthTest(unittest.TestCase):

	def setUp(self):
		shared_secret = 'secretsecretsecretsecret'
		name_alice = 'alice'
		name_bob = 'bob'
		self.alice = MutualAuth(shared_secret, name_alice)
		self.bob = MutualAuth(shared_secret, name_bob)
		self.alice_dh = 17
		self.bob_dh = 3

	def test(self):

		bits = 100
		# alice send ra
		ra = self.alice.generate_nonce(bits)
		
		# bob use ra to encrypt eb and send rb
		eb = self.bob.encrypt_nonce(ra, self.bob_dh)
		rb = self.bob.generate_nonce(bits)

		# alice validate eb encrypted by bob
		plaintext = self.alice.decrypt_ciphertext(eb)
		# alice's own name not in plaintext
		self.assertFalse(self.alice.check_name(plaintext))
		# alice's nonce is in plaintext
		self.assertTrue(self.alice.check_nonce(plaintext))
		# get bob's dh
		self.assertEquals(str(self.bob_dh), str(self.alice.get_partner_dh_value(plaintext)))

		# alice use rb to encrypt ea encryted by alice
		ea = self.alice.encrypt_nonce(rb, self.alice_dh)

		# bob validates ea
		plaintext = self.bob.decrypt_ciphertext(ea)
		# bob's own name not in plaintext
		self.assertFalse(self.bob.check_name(plaintext))
		# bob's nonce is in plaintext
		self.assertTrue(self.bob.check_nonce(plaintext))
		# get alice's dh
		self.assertEquals(str(self.alice_dh), str(self.bob.get_partner_dh_value(plaintext)))