Module jcifs

Class NtlmUtil

java.lang.Object
org.codelibs.jcifs.smb.impl.NtlmUtil

public final class NtlmUtil extends Object
Internal use only
Author:
mbechler

This class is intended for internal use.

  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    getLMv2Response(byte[] responseKeyLM, byte[] serverChallenge, byte[] clientChallenge)
    Creates the LMv2 response for the supplied keys and challenges.
    static byte[]
    getLMv2Response(String domain, String user, byte[] passwordHash, byte[] challenge, byte[] clientChallenge)
    Creates the LMv2 response for the supplied information.
    static byte[]
    getLMv2Response(String domain, String user, String password, byte[] challenge, byte[] clientChallenge)
    Creates the LMv2 response for the supplied information.
    static byte[]
    getNTHash(String password)
    Generates the NT password hash for the given password.
    static byte[]
    getNTLM2Response(byte[] passwordHash, byte[] serverChallenge, byte[] clientChallenge)
    Creates the NTLM2 session response for the supplied information.
    static byte[]
    getNTLMResponse(byte[] passwordHash, byte[] challenge)
    Generate the Unicode MD4 hash for the password associated with these credentials.
    static byte[]
    getNTLMResponse(String password, byte[] challenge)
    Generate the Unicode MD4 hash for the password associated with these credentials.
    static byte[]
    getNTLMv2Response(byte[] responseKeyNT, byte[] serverChallenge, byte[] clientChallenge, long nanos1601, byte[] avPairs)
    Creates the NTLMv2 response for the supplied information.
    static byte[]
    getPreNTLMResponse(CIFSContext tc, String password, byte[] challenge)
    Generate the ANSI DES hash for the password associated with these credentials.
    static byte[]
    nTOWFv1(String password)
    Generates the NTOWFv1 hash for the given password.
    static byte[]
    nTOWFv2(String domain, String username, byte[] passwordHash)
    Generates the NTOWFv2 hash for the given domain, username, and password hash.
    static byte[]
    nTOWFv2(String domain, String username, String password)
    Generates the NTOWFv2 hash for the given domain, username, and password.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getNTLMv2Response

      public static byte[] getNTLMv2Response(byte[] responseKeyNT, byte[] serverChallenge, byte[] clientChallenge, long nanos1601, byte[] avPairs)
      Creates the NTLMv2 response for the supplied information.
      Parameters:
      responseKeyNT - the NT response key
      serverChallenge - the server challenge bytes
      clientChallenge - the client challenge bytes
      nanos1601 - the timestamp in nanoseconds since 1601
      avPairs - the AV pairs from the Type 2 message
      Returns:
      the calculated response
    • getLMv2Response

      public static byte[] getLMv2Response(byte[] responseKeyLM, byte[] serverChallenge, byte[] clientChallenge)
      Creates the LMv2 response for the supplied keys and challenges.
      Parameters:
      responseKeyLM - the LM response key
      serverChallenge - the server challenge bytes
      clientChallenge - the client challenge bytes
      Returns:
      the calculated response
    • nTOWFv2

      public static byte[] nTOWFv2(String domain, String username, String password)
      Generates the NTOWFv2 hash for the given domain, username, and password.
      Parameters:
      domain - the authentication domain
      username - the username
      password - the password
      Returns:
      the calculated mac
    • nTOWFv2

      public static byte[] nTOWFv2(String domain, String username, byte[] passwordHash)
      Generates the NTOWFv2 hash for the given domain, username, and password hash.
      Parameters:
      domain - the authentication domain
      username - the username
      passwordHash - NT password hash
      Returns:
      the calculated mac
    • getNTHash

      public static byte[] getNTHash(String password)
      Generates the NT password hash for the given password.
      Parameters:
      password - the password to hash
      Returns:
      nt password hash
    • nTOWFv1

      public static byte[] nTOWFv1(String password)
      Generates the NTOWFv1 hash for the given password.
      Parameters:
      password - the password to hash
      Returns:
      the calculated hash
    • getNTLM2Response

      public static byte[] getNTLM2Response(byte[] passwordHash, byte[] serverChallenge, byte[] clientChallenge) throws GeneralSecurityException
      Creates the NTLM2 session response for the supplied information.
      Parameters:
      passwordHash - the password hash to use
      serverChallenge - the server challenge bytes
      clientChallenge - the client challenge bytes
      Returns:
      the calculated response
      Throws:
      GeneralSecurityException - if a cryptographic error occurs
    • getLMv2Response

      public static byte[] getLMv2Response(String domain, String user, String password, byte[] challenge, byte[] clientChallenge) throws GeneralSecurityException
      Creates the LMv2 response for the supplied information.
      Parameters:
      domain - The domain in which the username exists.
      user - The username.
      password - The user's password.
      challenge - The server challenge.
      clientChallenge - The client challenge (nonce).
      Returns:
      the calculated response
      Throws:
      GeneralSecurityException - if a cryptographic error occurs
    • getLMv2Response

      public static byte[] getLMv2Response(String domain, String user, byte[] passwordHash, byte[] challenge, byte[] clientChallenge) throws GeneralSecurityException
      Creates the LMv2 response for the supplied information.
      Parameters:
      domain - The domain in which the username exists.
      user - The username.
      passwordHash - The user's NT hash.
      challenge - The server challenge.
      clientChallenge - The client challenge (nonce).
      Returns:
      the calculated response
      Throws:
      GeneralSecurityException - if a cryptographic error occurs
    • getNTLMResponse

      public static byte[] getNTLMResponse(String password, byte[] challenge) throws GeneralSecurityException
      Generate the Unicode MD4 hash for the password associated with these credentials.
      Parameters:
      password - the password to hash
      challenge - the server challenge bytes
      Returns:
      the calculated response
      Throws:
      GeneralSecurityException - if a cryptographic error occurs
    • getNTLMResponse

      public static byte[] getNTLMResponse(byte[] passwordHash, byte[] challenge) throws GeneralSecurityException
      Generate the Unicode MD4 hash for the password associated with these credentials.
      Parameters:
      passwordHash - NT Hash
      challenge - the server challenge bytes
      Returns:
      the calculated response
      Throws:
      GeneralSecurityException - if a cryptographic error occurs
    • getPreNTLMResponse

      public static byte[] getPreNTLMResponse(CIFSContext tc, String password, byte[] challenge) throws GeneralSecurityException
      Generate the ANSI DES hash for the password associated with these credentials.
      Parameters:
      tc - the CIFS context to use for configuration
      password - the password to hash
      challenge - the server challenge bytes
      Returns:
      the calculated response
      Throws:
      GeneralSecurityException - if a cryptographic error occurs