コード例 #1
0
ファイル: test_crypto.py プロジェクト: unoffices/netsukuku
    def testMessageInvalidity(self):
        # host 1
        self.keys_host1 = crypto.KeyPair(self.temp_dir + "/key1")
        # host 2
        self.keys_host2 = crypto.KeyPair(self.temp_dir + "/key2")
        # host 3
        self.keys_host3 = crypto.KeyPair(self.temp_dir + "/key3")

        # host 1 sign the message and send it to host 2,
        # with the attached signature and public key
        signature = self.keys_host1.sign(self.msg)
        host1_pub_key = self.keys_host2.get_pub_key()  # pass the wrong key

        # host 2 receive the message with signature and public key of host 1,
        # and verify the authenticity of the sender
        result = host1_pub_key.verify(self.msg, signature)
        result = crypto.verify(self.msg, signature, host1_pub_key)
        self.failUnlessEqual(result, False)
        result = crypto.verify(self.msg, signature,
                               self.keys_host1.get_pub_key())
        self.failUnlessEqual(result, True)
コード例 #2
0
ファイル: test_crypto.py プロジェクト: AlexVanGluk/netsukuku
    def testMessageInvalidity(self):
        # host 1
        self.keys_host1 = crypto.KeyPair(self.temp_dir + "/key1")
        # host 2
        self.keys_host2 = crypto.KeyPair(self.temp_dir + "/key2")
        # host 3
        self.keys_host3 = crypto.KeyPair(self.temp_dir + "/key3")

        # host 1 sign the message and send it to host 2,
        # with the attached signature and public key
        signature = self.keys_host1.sign(self.msg)
        host1_pub_key = self.keys_host2.get_pub_key() # pass the wrong key

        # host 2 receive the message with signature and public key of host 1,
        # and verify the authenticity of the sender
        result = host1_pub_key.verify(self.msg, signature)
        result = crypto.verify(self.msg, signature, host1_pub_key)
        self.failUnlessEqual(result, False)
        result = crypto.verify(self.msg, signature,
                               self.keys_host1.get_pub_key())
        self.failUnlessEqual(result, True)
コード例 #3
0
ファイル: test_crypto.py プロジェクト: unoffices/netsukuku
 def testPublicKeySerialization(self):
     keys = crypto.KeyPair(self.temp_dir + "/temp_key")
     signature = keys.sign("Message")
     pub_key = keys.get_pub_key()
     classname, pem_string = pub_key._pack()
     pub_key = crypto.PublicKey(pem_string=pem_string)
     self.failUnlessEqual(crypto.verify("Message", signature, pub_key),
                          True)
     self.failUnlessEqual(rencode.loads(rencode.dumps(pub_key)),
                          str(pub_key))
     print rencode.dumps(pub_key)
     print rencode.loads(rencode.dumps(pub_key))
     print pub_key.rsa.as_pem()
コード例 #4
0
ファイル: test_crypto.py プロジェクト: AlexVanGluk/netsukuku
 def testPublicKeySerialization(self):
     keys = crypto.KeyPair(self.temp_dir + "/temp_key")
     signature = keys.sign("Message")
     pub_key = keys.get_pub_key()
     classname, pem_string = pub_key._pack()
     pub_key = crypto.PublicKey(pem_string=pem_string)
     self.failUnlessEqual(crypto.verify("Message", signature, pub_key),
                          True)
     self.failUnlessEqual(rencode.loads(rencode.dumps(pub_key)),
                          str(pub_key))
     print rencode.dumps(pub_key)
     print rencode.loads(rencode.dumps(pub_key))
     print pub_key.rsa.as_pem()
コード例 #5
0
ファイル: test_crypto.py プロジェクト: unoffices/netsukuku
    def testMessageValidity(self):
        # host 1
        self.keys_host1 = crypto.KeyPair(self.temp_dir + "/keypair1")
        # host 2
        self.keys_host2 = crypto.KeyPair(self.temp_dir + "/keypair2")

        # host 1 sign the message and send it to host 2, with
        # the attached signature and public key
        signature = self.keys_host1.sign(self.msg)
        host1_pub_key = self.keys_host1.get_pub_key()

        # host 2 receive the message with signature and public
        # key of host 1, and verify the authenticity of the sender
        result = crypto.verify(self.msg, signature, host1_pub_key)
        self.failUnlessEqual(result, True)
コード例 #6
0
ファイル: test_crypto.py プロジェクト: AlexVanGluk/netsukuku
    def testMessageValidity(self):
        # host 1
        self.keys_host1 = crypto.KeyPair(self.temp_dir + "/keypair1")
        # host 2
        self.keys_host2 = crypto.KeyPair(self.temp_dir + "/keypair2")

        # host 1 sign the message and send it to host 2, with
        # the attached signature and public key
        signature = self.keys_host1.sign(self.msg)
        host1_pub_key = self.keys_host1.get_pub_key()

        # host 2 receive the message with signature and public
        # key of host 1, and verify the authenticity of the sender
        result = crypto.verify(self.msg, signature, host1_pub_key)
        self.failUnlessEqual(result, True)