Ejemplo n.º 1
0
 def test_valid_signature(self):
     signing_key = SigObj.generate_signing_key()
     pub_key = signing.generate_pubkey(signing_key)
     temp = SignedObject({"PublicKey": pub_key})
     # test valid signature
     temp.sign_object(signing_key)
     self.assertTrue(temp.is_valid("valid"))
Ejemplo n.º 2
0
 def test_is_valid_no_public_key(self):
     # Verify that is_valid only returns true if working with a valid
     # SignedObject
     # test a valid signature
     temp = SignedObject({"TestSignatureDictKey": "test"},
                         "TestSignatureDictKey")
     self.assertFalse(temp.is_valid("invalid"))
Ejemplo n.º 3
0
    def test_is_valid(self):
        # Verify that is_valid only returns true if working with a valid
        # Signed Object
        # test a valid signature
        temp = SignedObject({"TestSignatureDictKey": "test"}, "TestSignatureDictKey")
        self.assertTrue(temp.is_valid("unused"))

        # test OriginatorID
        ogid = temp.OriginatorID
        self.assertTrue(temp.verify_signature(ogid))

        # test invalid OriginatorID
        self.assertFalse(temp.verify_signature("invalid"))
    def test_is_valid(self):
        # Verify that is_valid only returns true if working with a valid
        # Signed Object
        # test a valid signature
        signkey = SigObj.generate_signing_key()
        temp = SignedObject({signkey: "test"}, signkey)
        self.assertTrue(temp.is_valid("unused"))

        # test OriginatorID
        ogid = temp.OriginatorID
        self.assertTrue(temp.verify_signature(ogid))

        # test invalid OriginatorID
        self.assertFalse(temp.verify_signature("invalid"))
Ejemplo n.º 5
0
    def test_is_valid(self):
        # Verify that is_valid only returns true if working with a valid
        # Signed Object
        # test a valid signature
        signkey = SigObj.generate_signing_key()
        temp = SignedObject({signkey: "test"}, signkey)
        self.assertTrue(temp.is_valid("unused"))

        # test OriginatorID
        ogid = temp.OriginatorID
        self.assertTrue(temp.verify_signature(ogid))

        # test invalid OriginatorID
        self.assertFalse(temp.verify_signature("invalid"))
Ejemplo n.º 6
0
    def test_signed_node(self):
        # Verify that signed_node and sign_object does not invalidate the
        # signed object and can be returned to original
        # create initial signed object
        temp = SignedObject({"TestSignatureDictKey": "test"}, "TestSignatureDictKey")
        # save origanl OriginatorID before creating node
        idBeforeNode = temp.OriginatorID

        # create a node instance
        key = generate_private_key()
        sigkey = SigObj.generate_signing_key(wifstr=key)
        nodeid = SigObj.generate_identifier(sigkey)
        testNode = Node(name="testNode", signingkey=sigkey, identifier=nodeid)

        temp.sign_from_node(testNode)
        # save new OriginatorID after the
        idAfterNode = temp.OriginatorID

        self.assertNotEqual(idAfterNode, idBeforeNode)
        # check that the signed_object signature is still valid and reset
        # OrignatorId back to original
        self.assertTrue(temp.is_valid("unused parameter"))
        self.assertNotEqual(temp.OriginatorID, idBeforeNode)
    def test_signed_node(self):
        # Verify that signed_node and sign_object does not invalidate the
        # signed object and can be returned to original
        # create initial signed object
        signkey = SigObj.generate_signing_key()
        temp = SignedObject({signkey: "test"}, signkey)
        # save origanl OriginatorID before creating node
        idBeforeNode = temp.OriginatorID

        # create a node instance
        key = generate_private_key()
        sigkey = SigObj.generate_signing_key(wifstr=key)
        nodeid = SigObj.generate_identifier(sigkey)
        testNode = Node(name="testNode", signingkey=sigkey, identifier=nodeid)

        temp.sign_from_node(testNode)
        # save new OriginatorID after the
        idAfterNode = temp.OriginatorID

        self.assertNotEqual(idAfterNode, idBeforeNode)
        # check that the signed_object signature is still valid and reset
        # OrignatorId back to original
        self.assertTrue(temp.is_valid("unused parameter"))
        self.assertNotEqual(temp.OriginatorID, idBeforeNode)