@@ -792,6 +792,23 @@ int test_NTResponseV1(struct ntlm_ctx *ctx)
792792 result .data , result .length );
793793}
794794
795+ int test_LM_KeyExchangeKey (struct ntlm_ctx * ctx )
796+ {
797+ struct ntlm_key result = { .length = 16 };
798+ struct ntlm_buffer lm_response = {
799+ .data = T_NTLMv1 .LMv1Response ,
800+ .length = sizeof (T_NTLMv1 .LMv1Response )
801+ };
802+ int ret ;
803+
804+ ret = KXKEY (ctx , false, true, false, T_ServerChallenge ,
805+ & T_NTLMv1 .ResponseKeyLM , & T_NTLMv1 .SessionBaseKey ,
806+ & lm_response , & result );
807+ if (ret ) return ret ;
808+
809+ return test_keys ("results" , & T_NTLMv1 .KeyExchangeKey , & result );
810+ }
811+
795812int test_NTOWFv2 (struct ntlm_ctx * ctx )
796813{
797814 struct ntlm_key nt_hash = { .length = 16 };
@@ -2162,6 +2179,47 @@ do { \
21622179 return 0 ;
21632180}
21642181
2182+ /* test with data from Jordan Borean, the DC apparently has a zero key */
2183+ int test_ZERO_LMKEY (struct ntlm_ctx * ctx )
2184+ {
2185+ struct ntlm_key lmowf = { .data = {0 }, .length = 16 };
2186+ struct ntlm_key ntowf = { .length = 16 };
2187+ struct ntlm_key sessionkey = { .length = 16 };
2188+ struct ntlm_key result = { .length = 16 };
2189+ const char * password = "VagrantPass1" ;
2190+ uint8_t serverChallenge [] = {
2191+ 0x45 , 0x56 , 0xB5 , 0x69 , 0xC9 , 0x53 , 0x6A , 0x31
2192+ };
2193+ struct ntlm_key MS_SessionKey = {
2194+ .data = {
2195+ 0x5F , 0xFA , 0x2B , 0xF7 , 0x27 , 0xAD , 0xD1 , 0x01 ,
2196+ 0xC2 , 0x6C , 0xF2 , 0xE6 , 0xC1 , 0x13 , 0xBD , 0x6D
2197+ },
2198+ .length = 16
2199+ };
2200+ uint8_t LM_Response [] = {
2201+ 0x8B , 0xFC , 0xFE , 0xD5 , 0xA3 , 0x6D , 0x25 , 0x13 ,
2202+ 0x86 , 0xCC , 0x38 , 0xDE , 0x78 , 0xBA , 0xE1 , 0x62 ,
2203+ 0x24 , 0xC5 , 0x2F , 0xD7 , 0x35 , 0x35 , 0x5E , 0x24
2204+ };
2205+ struct ntlm_buffer lm_response = {
2206+ .data = LM_Response ,
2207+ .length = 24
2208+ };
2209+ int ret ;
2210+
2211+ ret = NTOWFv1 (password , & ntowf );
2212+ if (ret ) return ret ;
2213+ ret = ntlm_session_base_key (& ntowf , & sessionkey );
2214+ if (ret ) return ret ;
2215+
2216+ ret = KXKEY (ctx , false, true, false, serverChallenge , & lmowf ,
2217+ & sessionkey , & lm_response , & result );
2218+ if (ret ) return ret ;
2219+
2220+ return test_keys ("results" , & MS_SessionKey , & result );
2221+ }
2222+
21652223int main (int argc , const char * argv [])
21662224{
21672225 struct ntlm_ctx * ctx ;
@@ -2197,6 +2255,10 @@ int main(int argc, const char *argv[])
21972255 ret = test_SessionBaseKeyV1 (ctx );
21982256 fprintf (stdout , "Test: %s\n" , (ret ? "FAIL" :"SUCCESS" ));
21992257
2258+ fprintf (stdout , "Test LM KeyExchangeKey\n" );
2259+ ret = test_LM_KeyExchangeKey (ctx );
2260+ fprintf (stdout , "Test: %s\n" , (ret ? "FAIL" :"SUCCESS" ));
2261+
22002262 fprintf (stdout , "Test EncryptedSessionKey v1 (1)\n" );
22012263 ret = test_EncryptedSessionKey1 (ctx );
22022264 fprintf (stdout , "Test: %s\n" , (ret ? "FAIL" :"SUCCESS" ));
@@ -2333,6 +2395,10 @@ int main(int argc, const char *argv[])
23332395 ret = test_gssapi_rfc5587 ();
23342396 fprintf (stdout , "Test: %s\n" , (ret ? "FAIL" :"SUCCESS" ));
23352397
2398+ fprintf (stdout , "Test ZERO LM_KEY\n" );
2399+ ret = test_ZERO_LMKEY (ctx );
2400+ fprintf (stdout , "Test: %s\n" , (ret ? "FAIL" :"SUCCESS" ));
2401+
23362402done :
23372403 ntlm_free_ctx (& ctx );
23382404 return ret ;
0 commit comments