final class NTLMEngineImpl extends Object implements NTLMEngine
Modifier and Type | Class and Description |
---|---|
protected static class |
NTLMEngineImpl.CipherGen |
(package private) static class |
NTLMEngineImpl.HMACMD5
Cryptography support - HMACMD5 - algorithmically based on various web
resources by Karl Wright
|
(package private) static class |
NTLMEngineImpl.MD4
Cryptography support - MD4.
|
(package private) static class |
NTLMEngineImpl.NTLMMessage
NTLM message generation, base class
|
(package private) static class |
NTLMEngineImpl.Type1Message
Type 1 message assembly class
|
(package private) static class |
NTLMEngineImpl.Type2Message
Type 2 message class
|
(package private) static class |
NTLMEngineImpl.Type3Message
Type 3 message assembly class
|
Modifier and Type | Field and Description |
---|---|
private static Charset |
DEFAULT_CHARSET
Character encoding
|
protected static int |
FLAG_DOMAIN_PRESENT |
protected static int |
FLAG_REQUEST_128BIT_KEY_EXCH |
protected static int |
FLAG_REQUEST_56BIT_ENCRYPTION |
protected static int |
FLAG_REQUEST_ALWAYS_SIGN |
protected static int |
FLAG_REQUEST_EXPLICIT_KEY_EXCH |
protected static int |
FLAG_REQUEST_LAN_MANAGER_KEY |
protected static int |
FLAG_REQUEST_NTLM2_SESSION |
protected static int |
FLAG_REQUEST_NTLMv1 |
protected static int |
FLAG_REQUEST_SEAL |
protected static int |
FLAG_REQUEST_SIGN |
protected static int |
FLAG_REQUEST_TARGET |
protected static int |
FLAG_REQUEST_UNICODE_ENCODING |
protected static int |
FLAG_REQUEST_VERSION |
protected static int |
FLAG_TARGETINFO_PRESENT |
protected static int |
FLAG_WORKSTATION_PRESENT |
private static SecureRandom |
RND_GEN
Secure random generator
|
private static byte[] |
SIGNATURE
The signature string as bytes in the default encoding
|
private static String |
TYPE_1_MESSAGE |
private static Charset |
UNICODE_LITTLE_UNMARKED
Unicode encoding
|
Constructor and Description |
---|
NTLMEngineImpl() |
Modifier and Type | Method and Description |
---|---|
private static String |
convertDomain(String domain)
Convert domain to standard form
|
private static String |
convertHost(String host)
Convert host to standard form
|
private static byte[] |
createBlob(byte[] clientChallenge,
byte[] targetInformation,
byte[] timestamp)
Creates the NTLMv2 blob from the given target information block and
client challenge.
|
private static Key |
createDESKey(byte[] bytes,
int offset)
Creates a DES encryption key from the given key material.
|
(package private) static int |
F(int x,
int y,
int z) |
(package private) static int |
G(int x,
int y,
int z) |
String |
generateType1Msg(String domain,
String workstation)
Generates a Type1 message given the domain and workstation.
|
String |
generateType3Msg(String username,
String password,
String domain,
String workstation,
String challenge)
Generates a Type3 message given the user credentials and the
authentication challenge.
|
(package private) static String |
getResponseFor(String message,
String username,
String password,
String host,
String domain)
Returns the response for the given message.
|
(package private) static String |
getType1Message(String host,
String domain)
Creates the first message (type 1 message) in the NTLM authentication
sequence.
|
(package private) static String |
getType3Message(String user,
String password,
String host,
String domain,
byte[] nonce,
int type2Flags,
String target,
byte[] targetInformation)
Creates the type 3 message using the given server nonce.
|
(package private) static int |
H(int x,
int y,
int z) |
(package private) static byte[] |
hmacMD5(byte[] value,
byte[] key)
Calculates HMAC-MD5
|
private static byte[] |
lmHash(String password)
Creates the LM Hash of the user's password.
|
private static byte[] |
lmResponse(byte[] hash,
byte[] challenge)
Creates the LM Response from the given hash and Type 2 challenge.
|
private static byte[] |
lmv2Hash(String domain,
String user,
byte[] ntlmHash)
Creates the LMv2 Hash of the user's password.
|
private static byte[] |
lmv2Response(byte[] hash,
byte[] challenge,
byte[] clientData)
Creates the LMv2 Response from the given hash, client data, and Type 2
challenge.
|
private static byte[] |
makeRandomChallenge()
Calculate a challenge block
|
private static byte[] |
makeSecondaryKey()
Calculate a 16-byte secondary key
|
(package private) static byte[] |
ntlm2SessionResponse(byte[] ntlmHash,
byte[] challenge,
byte[] clientChallenge)
Calculates the NTLM2 Session Response for the given challenge, using the
specified password and client challenge.
|
private static byte[] |
ntlmHash(String password)
Creates the NTLM Hash of the user's password.
|
private static byte[] |
ntlmv2Hash(String domain,
String user,
byte[] ntlmHash)
Creates the NTLMv2 Hash of the user's password.
|
private static void |
oddParity(byte[] bytes)
Applies odd parity to the given byte array.
|
(package private) static byte[] |
RC4(byte[] value,
byte[] key)
Calculates RC4
|
private static byte[] |
readSecurityBuffer(byte[] src,
int index) |
private static int |
readULong(byte[] src,
int index) |
private static int |
readUShort(byte[] src,
int index) |
(package private) static int |
rotintlft(int val,
int numbits) |
private static String |
stripDotSuffix(String value)
Strip dot suffix from a name
|
(package private) static void |
writeULong(byte[] buffer,
int value,
int offset) |
private static final Charset UNICODE_LITTLE_UNMARKED
private static final Charset DEFAULT_CHARSET
protected static final int FLAG_REQUEST_UNICODE_ENCODING
protected static final int FLAG_REQUEST_TARGET
protected static final int FLAG_REQUEST_SIGN
protected static final int FLAG_REQUEST_SEAL
protected static final int FLAG_REQUEST_LAN_MANAGER_KEY
protected static final int FLAG_REQUEST_NTLMv1
protected static final int FLAG_DOMAIN_PRESENT
protected static final int FLAG_WORKSTATION_PRESENT
protected static final int FLAG_REQUEST_ALWAYS_SIGN
protected static final int FLAG_REQUEST_NTLM2_SESSION
protected static final int FLAG_REQUEST_VERSION
protected static final int FLAG_TARGETINFO_PRESENT
protected static final int FLAG_REQUEST_128BIT_KEY_EXCH
protected static final int FLAG_REQUEST_EXPLICIT_KEY_EXCH
protected static final int FLAG_REQUEST_56BIT_ENCRYPTION
private static final SecureRandom RND_GEN
private static final byte[] SIGNATURE
private static final String TYPE_1_MESSAGE
NTLMEngineImpl()
static String getResponseFor(String message, String username, String password, String host, String domain) throws NTLMEngineException
message
- the message that was received from the server.username
- the username to authenticate with.password
- the password to authenticate with.host
- The host.domain
- the NT domain to authenticate in.HttpException
- If the messages cannot be retrieved.NTLMEngineException
static String getType1Message(String host, String domain) throws NTLMEngineException
host
- the computer name of the host requesting authentication.domain
- The domain to authenticate with.NTLMEngineException
static String getType3Message(String user, String password, String host, String domain, byte[] nonce, int type2Flags, String target, byte[] targetInformation) throws NTLMEngineException
user
- The user name. This should not include the domain name.password
- The password.host
- The host that is originating the authentication request.domain
- The domain to authenticate within.nonce
- the 8 byte array the server sent.NTLMEngineException
- If fails.private static String stripDotSuffix(String value)
private static String convertHost(String host)
private static String convertDomain(String domain)
private static int readULong(byte[] src, int index) throws NTLMEngineException
NTLMEngineException
private static int readUShort(byte[] src, int index) throws NTLMEngineException
NTLMEngineException
private static byte[] readSecurityBuffer(byte[] src, int index) throws NTLMEngineException
NTLMEngineException
private static byte[] makeRandomChallenge() throws NTLMEngineException
NTLMEngineException
private static byte[] makeSecondaryKey() throws NTLMEngineException
NTLMEngineException
static byte[] hmacMD5(byte[] value, byte[] key) throws NTLMEngineException
NTLMEngineException
static byte[] RC4(byte[] value, byte[] key) throws NTLMEngineException
NTLMEngineException
static byte[] ntlm2SessionResponse(byte[] ntlmHash, byte[] challenge, byte[] clientChallenge) throws NTLMEngineException
NTLMEngineException
private static byte[] lmHash(String password) throws NTLMEngineException
password
- The password.NTLMEngineException
private static byte[] ntlmHash(String password) throws NTLMEngineException
password
- The password.NTLMEngineException
private static byte[] lmv2Hash(String domain, String user, byte[] ntlmHash) throws NTLMEngineException
NTLMEngineException
private static byte[] ntlmv2Hash(String domain, String user, byte[] ntlmHash) throws NTLMEngineException
NTLMEngineException
private static byte[] lmResponse(byte[] hash, byte[] challenge) throws NTLMEngineException
hash
- The LM or NTLM Hash.challenge
- The server challenge from the Type 2 message.NTLMEngineException
private static byte[] lmv2Response(byte[] hash, byte[] challenge, byte[] clientData) throws NTLMEngineException
hash
- The NTLMv2 Hash.clientData
- The client data (blob or client challenge).challenge
- The server challenge from the Type 2 message.NTLMEngineException
private static byte[] createBlob(byte[] clientChallenge, byte[] targetInformation, byte[] timestamp)
targetInformation
- The target information block from the Type 2 message.clientChallenge
- The random 8-byte client challenge.private static Key createDESKey(byte[] bytes, int offset)
bytes
- A byte array containing the DES key material.offset
- The offset in the given byte array at which the 7-byte key
material starts.private static void oddParity(byte[] bytes)
bytes
- The data whose parity bits are to be adjusted for odd parity.static void writeULong(byte[] buffer, int value, int offset)
static int F(int x, int y, int z)
static int G(int x, int y, int z)
static int H(int x, int y, int z)
static int rotintlft(int val, int numbits)
public String generateType1Msg(String domain, String workstation) throws NTLMEngineException
NTLMEngine
generateType1Msg
in interface NTLMEngine
domain
- Optional Windows domain name. Can be null
.workstation
- Optional Windows workstation name. Can be
null
.NTLMEngineException
public String generateType3Msg(String username, String password, String domain, String workstation, String challenge) throws NTLMEngineException
NTLMEngine
generateType3Msg
in interface NTLMEngine
username
- Windows user namepassword
- Passworddomain
- Windows domain nameworkstation
- Windows workstation namechallenge
- Type2 challenge.NTLMEngineException
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses