Exemple #1
0
 def _default_seal(self):
     """
     Helper method to build a Seal
     :return: a Seal instance
     """
     sig = 'A' * 128
     vk = 'A' * 68
     return Seal.create(signature=sig, verifying_key=vk)
Exemple #2
0
    def test_validate_bad_metadata(self):
        meta = b'lol'
        message = self._default_msg()
        sk, vk = wallet.new()
        sk2, vk2 = wallet.new()

        signature = EnvelopeAuth.seal(signing_key=sk,
                                      meta=meta,
                                      message=message)

        seal = Seal.create(signature=signature, verifying_key=vk2)

        self.assertRaises(Exception, Envelope._create_from_objects, seal, meta,
                          message.serialize())
Exemple #3
0
    def test_validate_bad_seal(self):
        meta = self._default_meta()
        message = self._default_msg()
        sk, vk = wallet.new()
        sk2, vk2 = wallet.new()

        signature = EnvelopeAuth.seal(signing_key=sk,
                                      meta=meta,
                                      message=message)

        seal = Seal.create(signature=signature, verifying_key=vk2)

        env = Envelope._create_from_objects(seal=seal,
                                            meta=meta,
                                            message=message.serialize())

        self.assertFalse(env.verify_seal())
Exemple #4
0
    def test_verify_seal(self):
        """
        Tests verify seal with a valid signature
        """
        meta = self._default_meta()
        message = self._default_msg()
        sk, vk = wallet.new()

        signature = EnvelopeAuth.seal(signing_key=sk,
                                      meta=meta,
                                      message=message)
        seal = Seal.create(signature=signature, verifying_key=vk)

        env = Envelope.create_from_message(message=message,
                                           signing_key=sk,
                                           verifying_key=vk)

        self.assertTrue(env.verify_seal())
Exemple #5
0
    def test_validate_envelope(self):
        """
        Tests validate envelope function
        """
        meta = self._default_meta()
        message = self._default_msg()
        sk, vk = wallet.new()

        signature = EnvelopeAuth.seal(signing_key=sk,
                                      meta=meta,
                                      message=message)
        seal = Seal.create(signature=signature, verifying_key=vk)

        env = Envelope._create_from_objects(seal=seal,
                                            meta=meta,
                                            message=message.serialize())

        env.validate()
Exemple #6
0
    def test_verify_seal_invalid(self):
        """
        Tests verifying a seal with an invalid signature
        """
        meta = self._default_meta()
        message = self._default_msg()
        sk, vk = wallet.new()
        sk_prime = 'A' * 64

        signature = EnvelopeAuth.seal(signing_key=sk_prime,
                                      meta=meta,
                                      message=message)
        seal = Seal.create(signature=signature, verifying_key=vk)

        env = Envelope._create_from_objects(seal=seal,
                                            meta=meta,
                                            message=message.serialize())

        env.verify_seal()