Package org.jbls.util

Examples of org.jbls.util.Buffer


            comment = lastComment;
          }

          key = key.replaceAll("-", "");

          Buffer b = org.jbls.Hashing.HashMain.hashKey(0, 0, key);
          b.removeDWord()//length
          int prod = b.removeDWord()//Product

          cdkeys.add(new CDKey(key, prod, comment));
        } else {
          lastComment = key.substring(1).trim();
        }
View Full Code Here


  public static void main(String[] args) {
    SRP srp = new SRP("username", "password");
    byte[] salt = new byte[32];

    System.out.println("v: " + srp.get_v(new byte[32]).toString(16));
    System.out.println("A: " + new Buffer(srp.get_A()));
    System.out.println("u: " + srp.get_u(salt).toString(16));
    System.out.println("S: " + new Buffer(srp.get_S(salt, salt)));
    System.out
        .println("K: " + new Buffer(srp.get_K(srp.get_S(salt, salt))));
    System.out.println("M1: " + new Buffer(srp.getM1(salt, salt)));
  }
View Full Code Here

  }// end of hashKey Method

  private static Buffer hashD2Key(int clientToken, int serverToken, String key)
      throws HashException {
    D2KeyDecode d2 = new D2KeyDecode(key);
    Buffer ret = new Buffer();
    ret.addDWord(key.length());
    ret.addDWord(d2.getProduct());
    ret.addDWord(d2.getVal1());
    ret.addDWord(0);
    int hashedKey[] = d2.getKeyHash(clientToken, serverToken);
    for (int i = 0; i < 5; i++)
      ret.addDWord(hashedKey[i]);
    return ret;
  }
View Full Code Here

   *             If Invalid Key
   */
  public static Buffer hashW2Key(int clientToken, int serverToken, String key)
      throws HashException {
    D2KeyDecode d2 = new D2KeyDecode(key);
    Buffer ret = new Buffer();
    ret.addDWord(key.length());
    ret.addDWord(d2.getProduct());
    ret.addDWord(d2.getVal1());
    ret.addDWord(serverToken);
    ret.addDWord(clientToken);
    int hashedKey[] = d2.getOldKeyHash(clientToken, serverToken);
    for (int i = 0; i < 5; i++)
      ret.addDWord(hashedKey[i]);
    return ret;
  }
View Full Code Here

  private static Buffer hashSCKey(int clientToken, int serverToken, String key)
      throws HashException {

    SCKeyDecode sc = new SCKeyDecode(key);
    Buffer ret = new Buffer();
    ret.addDWord(key.length());
    ret.addDWord(sc.getProduct());
    ret.addDWord(sc.getVal1());
    ret.addDWord(0);
    int hashedKey[] = sc.getKeyHash(clientToken, serverToken);
    for (int i = 0; i < 5; i++)
      ret.addDWord(hashedKey[i]);
    return ret;
  }
View Full Code Here

  }

  private static Buffer hashWAR3Key(int clientToken, int serverToken,
      String key) {
    War3Decode w3 = new War3Decode(key);
    Buffer ret = new Buffer();
    ret.addDWord(key.length());
    ret.addDWord(w3.getProduct());
    ret.addDWord(w3.getVal1());
    ret.addDWord(0);
    int hashedKey[] = w3.getKeyHash(clientToken, serverToken);
    for (int i = 0; i < 5; i++)
      ret.addDWord(hashedKey[i]);
    return ret;
  }
View Full Code Here

   *            The server token to hash it with.
   * @return The 20-byte hash (5 ints).
   */
  public int[] getKeyHash(int clientToken, int serverToken) {

    Buffer hashData = new Buffer();

    hashData.addDWord(clientToken);
    hashData.addDWord(serverToken);
    hashData.addDWord(getProduct());
    hashData.addDWord(getVal1());
    hashData.addDWord(0);
    hashData.addDWord(getVal2());

    return BrokenSHA1.calcHashBuffer(hashData.getBuffer());
  }
View Full Code Here

    return BrokenSHA1.calcHashBuffer(hashData.getBuffer());
  }

  public int[] getOldKeyHash(int clientToken, int serverToken) {

    Buffer hashData = new Buffer();

    hashData.addDWord(clientToken);
    hashData.addDWord(serverToken);
    hashData.addDWord(getProduct());
    hashData.addDWord(getVal1());
    hashData.addDWord(getVal2());

    return BrokenSHA1.calcHashBuffer(hashData.getBuffer());
  }
View Full Code Here

   * @param serverToken
   *            The server token for this session.
   * @return The 5-DWord (20 byte) hash.
   */
  static public int[] doubleHash(String str, int clientToken, int serverToken) {
    Buffer initialHash = new Buffer();
    initialHash.addNTString(str);
    int[] hash1 = BrokenSHA1.calcHashBuffer(initialHash.getBuffer());

    Buffer secondHash = new Buffer();
    secondHash.add(clientToken);
    secondHash.add(serverToken);
    for (int i = 0; i < 5; i++)
      secondHash.add(hash1[i]);

    return BrokenSHA1.calcHashBuffer(secondHash.getBuffer());
  }
View Full Code Here

      throw new IllegalStateException();
  }

  public Buffer handleRequest(Buffer in) throws IOException {
    in.removeByte();
    Buffer ret = new Buffer();
    int checksum = 0;
    while (in.size() >= 7) {
      /*int command =*/ in.removeWord();
      int address = in.removeDWord();
      int length = in.removeByte();
//      if(Out.isDebug())
//        Out.debug(getClass(), "Command: 0x" + PadString.padHex(command, 4)
//            + ", " + "Address: 0x" + PadString.padHex(address, 8)
//            + ", " + "Length: " + length);
      ret.addByte((byte) 0);
      ret.addBytes(getFileData(address - 0x400000, length));
      switch (address) {
      case 0x00497FB0:
        checksum += 1;
        break;
      case 0x0049C33D:
        checksum += 2;
        break;
      case 0x004A2FF7:
        checksum += 3;
        break;
      }
      checksum *= 10;
    }
    ret.addDWord(checksum / 10);
    return ret;
  }
View Full Code Here

TOP

Related Classes of org.jbls.util.Buffer

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.