예제 #1
0
    def _deriveCreate2CellSecrets(self, response, path_node):
        if isinstance(response, DestroyCell):
            msg = "DestroyCell received from {}.".format(path_node.router_status_entry.fingerprint)
            raise ValueError(msg)
        if not isinstance(response, Created2Cell):
            msg = "Unexpected cell {} received from {}.".format(response, path_node.router_status_entry.fingerprint)
            destroy = DestroyCell.make(self.circuit_id)
            self._conn.send(destroy)
            raise ValueError(msg)

        self._crypt_path.append(ntor.deriveRelayCrypto(self._hs_state, response))
        # TODO: implement this
        # self._hs_state.memwipe()
        self._hs_state = None
예제 #2
0
    def _deriveCreate2CellSecrets(self, response, path_node):
        if isinstance(response, DestroyCell):
            msg = ("DestroyCell received from {}.".format(
                path_node.router_status_entry.fingerprint))
            raise ValueError(msg)
        if not isinstance(response, Created2Cell):
            msg = ("Unexpected cell {} received from {}.".format(
                response, path_node.router_status_entry.fingerprint))
            destroy = DestroyCell.make(self.circuit_id)
            self._conn.send(destroy)
            raise ValueError(msg)

        self._crypt_path.append(
            ntor.deriveRelayCrypto(self._hs_state, response))
        # TODO: implement this
        #self._hs_state.memwipe()
        self._hs_state = None
예제 #3
0
파일: test_ntor.py 프로젝트: nskinkel/oppy
    def test_deriveRelayCrypto_ok(self, mock_mrc, mock_cse, mock_bai, mock_mhs,
        mock_bsi):
        mock_nts = mock.Mock()
        mock_nts.relay_identity = 'ident'
        mock_nts.relay_ntor_onion_key = 'ntork'
        mock_nts.public_key = 'pk'
        mock_cell = mock.Mock()
        mock_cell.hdata = [chr(i) for i in range(96)]
        hdata = mock_cell.hdata

        ret = ntor.deriveRelayCrypto(mock_nts, mock_cell)

        mock_bsi.assert_called_once_with(mock_nts, hdata[:32])
        self.assertEqual(mock_mhs.call_count, 2)
        self.assertEqual(mock_mhs.call_args_list,
            [mock.call(msg='secret', key='ntor-curve25519-sha256-1:verify'),
             mock.call(msg='auth', key='ntor-curve25519-sha256-1:mac')])
        mock_cse.assert_called_once_with(hdata[32:32+20], 'hmac')
        mock_mrc.assert_called_once_with('secret')
        self.assertEqual(ret, 'ret')
예제 #4
0
    def _deriveExtend2CellSecrets(self, response, path_node):
        if isinstance(response, DestroyCell):
            msg = "Destroy cell received from {} on pending circuit {}.".format(
                path_node.router_status_entry.fingerprint, self.circuit_id
            )
            raise ValueError(msg)

        cell, _ = crypto.decryptCell(response, self._crypt_path)

        if not isinstance(cell, RelayExtended2Cell):
            msg = "CircuitBuildTask {} received an unexpected cell: {}. " "Destroying the circuit.".format(
                self.circuit_id, type(cell)
            )
            destroy = DestroyCell.make(self.circuit_id)
            self._conn.send(destroy)
            raise ValueError(msg)

        self._crypt_path.append(ntor.deriveRelayCrypto(self._hs_state, cell))
        # TODO: implement this
        # self._hs_state.memwipe()
        self._hs = None
예제 #5
0
    def test_deriveRelayCrypto_ok(self, mock_mrc, mock_cse, mock_bai, mock_mhs,
                                  mock_bsi):
        mock_nts = mock.Mock()
        mock_nts.relay_identity = 'ident'
        mock_nts.relay_ntor_onion_key = 'ntork'
        mock_nts.public_key = 'pk'
        mock_cell = mock.Mock()
        mock_cell.hdata = [chr(i) for i in range(96)]
        hdata = mock_cell.hdata

        ret = ntor.deriveRelayCrypto(mock_nts, mock_cell)

        mock_bsi.assert_called_once_with(mock_nts, hdata[:32])
        self.assertEqual(mock_mhs.call_count, 2)
        self.assertEqual(mock_mhs.call_args_list, [
            mock.call(msg='secret', key='ntor-curve25519-sha256-1:verify'),
            mock.call(msg='auth', key='ntor-curve25519-sha256-1:mac')
        ])
        mock_cse.assert_called_once_with(hdata[32:32 + 20], 'hmac')
        mock_mrc.assert_called_once_with('secret')
        self.assertEqual(ret, 'ret')
예제 #6
0
    def _deriveExtend2CellSecrets(self, response, path_node):
        if isinstance(response, DestroyCell):
            msg = (
                "Destroy cell received from {} on pending circuit {}.".format(
                    path_node.router_status_entry.fingerprint,
                    self.circuit_id))
            raise ValueError(msg)

        cell, _ = crypto.decryptCell(response, self._crypt_path)

        if not isinstance(cell, RelayExtended2Cell):
            msg = ("CircuitBuildTask {} received an unexpected cell: {}. "
                   "Destroying the circuit.".format(self.circuit_id,
                                                    type(cell)))
            destroy = DestroyCell.make(self.circuit_id)
            self._conn.send(destroy)
            raise ValueError(msg)

        self._crypt_path.append(ntor.deriveRelayCrypto(self._hs_state, cell))
        # TODO: implement this
        #self._hs_state.memwipe()
        self._hs = None