Package com.subgraph.orchid

Examples of com.subgraph.orchid.TorException


  }
 
  public static String base32Encode(byte[] source, int offset, int length) {
    final int nbits = length * 8;
    if(nbits % 5 != 0)
      throw new TorException("Base32 input length must be a multiple of 5 bits");
   
    final int outlen = nbits / 5;
    final StringBuffer outbuffer = new StringBuffer();
    int bit = 0;
    for(int i = 0; i < outlen; i++) {
View Full Code Here


  public static byte[] base32Decode(String source) {
    int[] v = stringToIntVector(source);
   
    int nbits = source.length() * 5;
    if(nbits % 8 != 0)
      throw new TorException("Base32 decoded array must be a muliple of 8 bits");
   
    int outlen = nbits / 8;
    byte[] outbytes = new byte[outlen];
   
    int bit = 0;
View Full Code Here

    case 24:
      return ls(b0, 7) + ls(b1, 2) + rs(b2, 3);
    case 32:
      return ls(b0, 5) + (b1 & 0xFF);
    }
    throw new TorException("Illegal bit offset");
  }
View Full Code Here

      else if(b > 0x31 && b < 0x38)
        ints[i] = b - 0x18;
      else if(b > 0x40 && b < 0x5B)
        ints[i] = b - 0x41;
      else
        throw new TorException("Illegal character in base32 encoded string: "+ s.charAt(i));
    }
    return ints;
  }
View Full Code Here

      DHPublicKeySpec pub = new DHPublicKeySpec(otherPublic, P1024, G);
      PublicKey key = factory.generatePublic(pub);
      dh.doPhase(key, true);
      return dh.generateSecret();
    } catch (GeneralSecurityException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

    try {
      KeyAgreement dh = KeyAgreement.getInstance("DH");
      dh.init(keyPair.getPrivate());
      return dh;
    } catch (GeneralSecurityException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

    try {
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
      keyGen.initialize(DH_PARAMETER_SPEC);
      return keyGen.generateKeyPair()
    } catch (GeneralSecurityException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

    return deriveKeysFromDHPublicAndHash(peerPublic, keyHash, keyMaterialOut, verifyHashOut);
  }
 
  public boolean deriveKeysFromDHPublicAndHash(BigInteger peerPublic, byte[] keyHash, byte[] keyMaterialOut, byte[] verifyHashOut) {
    if(!isValidPublicValue(peerPublic)) {
      throw new TorException("Illegal DH public value");
    }
    final byte[] sharedSecret = getSharedSecret(peerPublic);
    final TorKeyDerivation kdf = new TorKeyDerivation(sharedSecret);
    kdf.deriveKeys(keyMaterialOut, verifyHashOut);
    return Arrays.equals(verifyHashOut, keyHash);
View Full Code Here

 
  public InetAddress toInetAddress() {
    try {
      return InetAddress.getByAddress(getAddressDataBytes());
    } catch (UnknownHostException e) {
      throw new TorException(e);
    }
  }
View Full Code Here

      if(node.decryptBackwardCell(cell)) {
        return RelayCellImpl.createFromCell(node, cell);
      }
    }
    destroyCircuit();
    throw new TorException("Could not decrypt relay cell");
  }
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.