Exemplo n.º 1
0
    def test1_authentication(self):
        ss = scramblesuit.ScrambleSuitTransport()
        ss.srvState = self.state

        realEpoch = util.getEpoch

        # Try three valid and one invalid epoch value.
        for epoch in util.expandedEpoch() + ["000000"]:

            util.getEpoch = lambda: epoch

            # Prepare ticket message.
            blurb = ticket.issueTicketAndKey(self.state)
            rawTicket = blurb[const.MASTER_KEY_LENGTH:]
            masterKey = blurb[:const.MASTER_KEY_LENGTH]
            ss.deriveSecrets(masterKey)
            ticketMsg = ticket.createTicketMessage(rawTicket, ss.recvHMAC)

            util.getEpoch = realEpoch

            buf = obfs_buf.Buffer()
            buf.write(ticketMsg)

            if epoch == "000000":
                self.assertFalse(ss.receiveTicket(buf))
            else:
                self.assertTrue(ss.receiveTicket(buf))
Exemplo n.º 2
0
    def test1_authentication(self):
        ss = scramblesuit.ScrambleSuitTransport()
        ss.srvState = self.state

        realEpoch = util.getEpoch

        # Try three valid and one invalid epoch value.
        for epoch in util.expandedEpoch() + ["000000"]:

            util.getEpoch = lambda: epoch

            # Prepare ticket message.
            blurb = ticket.issueTicketAndKey(self.state)
            rawTicket = blurb[const.MASTER_KEY_LENGTH :]
            masterKey = blurb[: const.MASTER_KEY_LENGTH]
            ss.deriveSecrets(masterKey)
            ticketMsg = ticket.createTicketMessage(rawTicket, ss.recvHMAC)

            util.getEpoch = realEpoch

            buf = obfs_buf.Buffer()
            buf.write(ticketMsg)

            if epoch == "000000":
                self.assertFalse(ss.receiveTicket(buf))
            else:
                self.assertTrue(ss.receiveTicket(buf))
Exemplo n.º 3
0
    def test4_extractPublicKey(self):

        # Create UniformDH authentication message.
        sharedSecret = "A" * const.SHARED_SECRET_LENGTH

        realEpoch = util.getEpoch

        # Try three valid and one invalid epoch value.
        for epoch in util.expandedEpoch() + ["000000"]:
            udh = uniformdh.new(sharedSecret, True)

            util.getEpoch = lambda: epoch
            authMsg = udh.createHandshake()
            util.getEpoch = realEpoch

            buf = obfs_buf.Buffer()
            buf.write(authMsg)

            if epoch == "000000":
                self.assertFalse(udh.extractPublicKey(buf))
            else:
                self.assertTrue(udh.extractPublicKey(buf))
Exemplo n.º 4
0
    def test4_extractPublicKey(self):

        # Create UniformDH authentication message.
        sharedSecret = "A" * const.SHARED_SECRET_LENGTH

        realEpoch = util.getEpoch

        # Try three valid and one invalid epoch value.
        for epoch in util.expandedEpoch() + ["000000"]:
            udh = uniformdh.new(sharedSecret, True)

            util.getEpoch = lambda: epoch
            authMsg = udh.createHandshake()
            util.getEpoch = realEpoch

            buf = obfs_buf.Buffer()
            buf.write(authMsg)

            if epoch == "000000":
                self.assertFalse(udh.extractPublicKey(buf))
            else:
                self.assertTrue(udh.extractPublicKey(buf))