Examples of MD4


Examples of com.knowgate.jcifs.util.MD4

            uni = password.getBytes( "UnicodeLittleUnmarked" );
        } catch( UnsupportedEncodingException uee ) {
            if( DebugFile.trace )
                new ErrorHandler(uee);
        }
        MD4 md4 = new MD4();
        md4.update( uni );
        try {
            md4.digest(p21, 0, 16);
        } catch (Exception ex) {
            if( DebugFile.trace )
                new ErrorHandler(ex);
        }
        E( p21, challenge, p24 );
View Full Code Here

Examples of com.knowgate.jcifs.util.MD4

    public static byte[] getLMv2Response(String domain, String user,
            String password, byte[] challenge, byte[] clientChallenge) {
        try {
            byte[] hash = new byte[16];
            byte[] response = new byte[24];
            MD4 md4 = new MD4();
            md4.update(password.getBytes("UnicodeLittleUnmarked"));
            HMACT64 hmac = new HMACT64(md4.digest());
            hmac.update(user.toUpperCase().getBytes("UnicodeLittleUnmarked"));
            hmac.update(domain.toUpperCase().getBytes("UnicodeLittleUnmarked"));
            hmac = new HMACT64(hmac.digest());
            hmac.update(challenge);
            hmac.update(clientChallenge);
View Full Code Here

Examples of com.knowgate.jcifs.util.MD4

     * session key will start.
     */
    void getUserSessionKey(byte[] challenge, byte[] dest, int offset)
            throws Exception {
        if (hashesExternal) return;
        MD4 md4 = new MD4();
        md4.update(password.getBytes("UnicodeLittleUnmarked"));
        switch (LM_COMPATIBILITY) {
        case 0:
        case 1:
        case 2:
            md4.update(md4.digest());
            md4.digest(dest, offset, 16);
            break;
        case 3:
        case 4:
        case 5:
            if( clientChallenge == null ) {
                clientChallenge = new byte[8];
                RANDOM.nextBytes( clientChallenge );
            }

            HMACT64 hmac = new HMACT64(md4.digest());
            hmac.update(username.toUpperCase().getBytes(
                    "UnicodeLittleUnmarked"));
            hmac.update(domain.toUpperCase().getBytes(
                    "UnicodeLittleUnmarked"));
            byte[] ntlmv2Hash = hmac.digest();
            hmac = new HMACT64(ntlmv2Hash);
            hmac.update(challenge);
            hmac.update(clientChallenge);
            HMACT64 userKey = new HMACT64(ntlmv2Hash);
            userKey.update(hmac.digest());
            userKey.digest(dest, offset, 16);
            break;
        default:
            md4.update(md4.digest());
            md4.digest(dest, offset, 16);
            break;
        }
    }
View Full Code Here

Examples of gnu.java.security.hash.MD4

  public void test(TestHarness harness)
  {
    harness.checkPoint("TestOfMD4");
    try
      {
        algorithm = new MD4();
        harness.check(algorithm.selfTest(), "selfTest");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.selfTest");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update("a".getBytes(), 0, 1);
        byte[] md = algorithm.digest();
        String exp = "BDE52CB31DE33E46245E05FBDBD6FB24";
        harness.check(exp.equals(Util.toString(md)), "testA");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.testA");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update("abc".getBytes(), 0, 3);
        byte[] md = algorithm.digest();
        String exp = "A448017AAF21D8525FC10AE87AA6729D";
        harness.check(exp.equals(Util.toString(md)), "testABC");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.testABC");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update("message digest".getBytes(), 0, 14);
        byte[] md = algorithm.digest();
        String exp = "D9130A8164549FE818874806E1C7014B";
        harness.check(exp.equals(Util.toString(md)), "testMessageDigest");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.testMessageDigest");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update("abcdefghijklmnopqrstuvwxyz".getBytes(), 0, 26);
        byte[] md = algorithm.digest();
        String exp = "D79E1C308AA5BBCDEEA8ED63DF412DA9";
        harness.check(exp.equals(Util.toString(md)), "testAlphabet");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.testAlphabet");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update(
            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
                .getBytes(),
            0, 62);
        byte[] md = algorithm.digest();
        String exp = "043F8582F241DB351CE627E153E7F0E4";
        harness.check(exp.equals(Util.toString(md)), "testAsciiSubset");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.testAsciiSubset");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update(
            "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
                .getBytes(),
            0, 80);
        byte[] md = algorithm.digest();
        String exp = "E33B4DDC9C38F2199C3E7B164FCC0536";
        harness.check(exp.equals(Util.toString(md)), "testEightyNumerics");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfMD4.testEightyNumerics");
      }

    try
      {
        algorithm = new MD4();
        algorithm.update("a".getBytes(), 0, 1);
        clone = (IMessageDigest) algorithm.clone();
        byte[] md = algorithm.digest();
        String exp = "BDE52CB31DE33E46245E05FBDBD6FB24";
        harness.check(exp.equals(Util.toString(md)), "testCloning #1");
View Full Code Here

Examples of jcifs.util.MD4

                if ((getFlags() & NTLMSSP_NEGOTIATE_SIGN) == NTLMSSP_NEGOTIATE_SIGN) {
                    byte[] sessionNonce = new byte[16];
                    System.arraycopy(type2.getChallenge(), 0, sessionNonce, 0, 8);
                    System.arraycopy(clientChallenge, 0, sessionNonce, 8, 8);

                    MD4 md4 = new MD4();
                    md4.update(responseKeyNT);
                    HMACT64 hmac = new HMACT64(md4.digest());
                    hmac.update(sessionNonce);
                    byte[] userSessionKey = hmac.digest(); // NTLM2 session key

                    if ((getFlags() & NTLMSSP_NEGOTIATE_KEY_EXCH) != 0) {
                        masterKey = new byte[16];
View Full Code Here

Examples of jcifs.util.MD4

                if ((getFlags() & NTLMSSP_NEGOTIATE_SIGN) == NTLMSSP_NEGOTIATE_SIGN) {
                    byte[] sessionNonce = new byte[16];
                    System.arraycopy(type2.getChallenge(), 0, sessionNonce, 0, 8);
                    System.arraycopy(clientChallenge, 0, sessionNonce, 8, 8);

                    MD4 md4 = new MD4();
                    md4.update(responseKeyNT);
                    byte[] userSessionKey = md4.digest();

                    HMACT64 hmac = new HMACT64(userSessionKey);
                    hmac.update(sessionNonce);
                    byte[] ntlm2SessionKey = hmac.digest();
View Full Code Here

Examples of jcifs.util.MD4

        domainControllerName, ntlmServiceAccount.getComputerName(),
        clientChallenge, new byte[8]);

    dcerpcHandle.sendrecv(netrServerReqChallenge);

    MD4 md4 = new MD4();

    md4.update(ntlmServiceAccount.getPassword().getBytes("UTF-16LE"));

    byte[] sessionKey = computeSessionKey(
      md4.digest(), clientChallenge,
      netrServerReqChallenge.getServerChallenge());

    byte[] clientCredential = computeNetlogonCredential(
      clientChallenge, sessionKey);
View Full Code Here

Examples of org.jmule.core.utils.MD4

           
            int c;
           
            ByteBuffer hashset;
           
            MD4 msgDigest = new MD4();
           
            ByteBuffer bb = ByteBuffer.allocateDirect(8192).order(ByteOrder.LITTLE_ENDIAN);
           
            ByteBuffer di = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN);
           
            c = (int) ((fileChannel.size() + PARTSIZE - 1) / PARTSIZE);
           
            // we will need space for c Parts
            hashset = ByteBuffer.allocate(16 * (c>0?c:1)).order(ByteOrder.LITTLE_ENDIAN);
           
            for (i = 1; i < c; i++) {
             
                while (position <= (i * PARTSIZE - bb.capacity())) {
                 
                  if( stop ) return;
                 
                    position+=fileChannel.read(bb, position);
                   
                    bb.flip();
                   
                    msgDigest.update(bb);
                   
                    bb.rewind();
                   
                }
           
                if (position < (i * PARTSIZE)) {
                 
                    bb.limit((int) ((i * PARTSIZE) - position));
                   
                    position+=fileChannel.read(bb, position);
                   
                    bb.flip();
                   
                    msgDigest.update(bb);
                   
                    bb.rewind();
                   
                }
               
                 hashset.limit(16 * i);
                
                 //update hashset - add a hash
                 msgDigest.finalDigest(hashset);
                
            }
           
            if (c > 0) {
             
                while (position < (fileChannel.size())) {
                 
                  if(stop) return;
                 
                    position+=fileChannel.read(bb, position);
                   
                    bb.flip();
                   
                    msgDigest.update(bb);
                   
                    bb.rewind();
                   
                }
               
                hashset.limit(16 * i);
               
            }
           
            msgDigest.finalDigest(hashset);
          
            hashset.flip();
           
            if (c > 1) {
             
                msgDigest.update(hashset);
               
                msgDigest.finalDigest(di);
               
            } else {
             
                di.put(hashset);
               
View Full Code Here

Examples of org.jmule.core.utils.MD4

 
  private boolean checkPartIntegrity(int partID) {
   
    long start = PARTSIZE*partID;
   
    MD4 msgDigest = new MD4();
   
    ByteBuffer partData = Misc.getByteBuffer(PARTSIZE);
    msgDigest.reset();
    try {
     
      readChannel.position(start);
     
      int count = readChannel.read(partData);
      partData.limit(count);
      msgDigest.update(partData);
     
      ByteBuffer hashset = Misc.getByteBuffer(16);
     
      msgDigest.finalDigest(hashset);
     
      if (!Arrays.equals(hashSet.get(partID),hashset.array())) {
        return false;
      }
      return true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.