Package com.subgraph.orchid

Examples of com.subgraph.orchid.TorException


    case RelayCell.RELAY_BEGIN_DIR:
    case RelayCell.RELAY_EXTEND:
    case RelayCell.RELAY_RESOLVE:
    case RelayCell.RELAY_TRUNCATE:
      destroyCircuit();
      throw new TorException("Unexpected 'forward' direction relay cell type: "+ relayCell.getRelayCommand());
    }
  }
View Full Code Here


  private final byte[] digestBytes;
  private final boolean isDigest256;

  private HexDigest(byte[] data) {
    if(data.length != TorMessageDigest.TOR_DIGEST_SIZE && data.length != TorMessageDigest.TOR_DIGEST256_SIZE) {
      throw new TorException("Digest data is not the correct length "+ data.length +" != (" + TorMessageDigest.TOR_DIGEST_SIZE + " or "+ TorMessageDigest.TOR_DIGEST256_SIZE +")");
    }
    digestBytes = new byte[data.length];
    isDigest256 = digestBytes.length == TorMessageDigest.TOR_DIGEST256_SIZE;
    System.arraycopy(data, 0, digestBytes, 0, data.length);
  }
View Full Code Here

  }
 
  private CircuitNode receiveAndProcessCreateFastResponse(Router targetRouter, TorKeyAgreement kex) {
    final Cell cell = circuit.receiveControlCellResponse();
    if(cell == null) {
      throw new TorException("Timeout building circuit waiting for CREATE_FAST response from "+ targetRouter);
    }

    return processCreatedFastCell(targetRouter, cell, kex);
  }
View Full Code Here

    return node;
  }
 
  CircuitNode extendTo(Router targetRouter) {
    if(circuit.getCircuitLength() == 0) {
      throw new TorException("Cannot EXTEND an empty circuit");
    }
   
    if(useNtor(targetRouter)) {
      final NTorCircuitExtender nce = new NTorCircuitExtender(this, targetRouter);
      return nce.extendTo();
View Full Code Here


  public RelayCell receiveRelayResponse(int expectedCommand, Router extendTarget) {
    final RelayCell cell = circuit.receiveRelayCell();
    if(cell == null) {
      throw new TorException("Timeout building circuit");
    }
    final int command = cell.getRelayCommand();
    if(command == RelayCell.RELAY_TRUNCATED) {
      final int code = cell.getByte() & 0xFF;
      final String msg = CellImpl.errorToDescription(code);
      final String source = nodeToName(cell.getCircuitNode());
      if(code == Cell.ERROR_PROTOCOL) {
        logProtocolViolation(source, extendTarget);
      }
      throw new TorException("Error from ("+ source +") while extending to ("+ extendTarget.getNickname() + "): "+ msg);
    } else if(command != expectedCommand) {
      final String expected = RelayCellImpl.commandToDescription(expectedCommand);
      final String received = RelayCellImpl.commandToDescription(command);
      throw new TorException("Received incorrect extend response, expecting "+ expected + " but received "+ received);
    } else {
      return cell;
    }
  }
View Full Code Here

    try {
      final SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(null, NULL_TRUST, null);
      return sslContext;
    } catch (NoSuchAlgorithmException e) {
      throw new TorException(e);
    } catch (KeyManagementException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

      final SSLSocket socket = (SSLSocket) socketFactory.createSocket();
      socket.setEnabledCipherSuites(MANDATORY_CIPHERS);
      socket.setUseClientMode(true);
      return socket;
    } catch (IOException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

    this(portValue, portValue);
  }
 
  PortRange(int start, int end) {
    if(!isValidRange(start, end))
      throw new TorException("Invalid port range: "+ start +"-"+ end);
    portStart = start;
    portEnd = end;
  }
View Full Code Here

    final Cipher cipher = createCipherInstance();
    try {
      byte[] decrypted = cipher.doFinal(signature.getSignatureBytes());
      return Utils.constantTimeArrayEquals(decrypted, digestBytes);
    } catch (IllegalBlockSizeException e) {
      throw new TorException(e);
    } catch (BadPaddingException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

    try {
      Cipher cipher = getCipherInstance();
      cipher.init(Cipher.DECRYPT_MODE, getKey());
      return cipher;
    } catch (InvalidKeyException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

TOP

Related Classes of com.subgraph.orchid.TorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.