title: HMAC-MD5 using openSSL
body: <p>I'm trying to study NTLMv2 response, <a href="http://davenport.sourceforge.net/ntlm.html#theNtlmv2Response" rel="nofollow noreferrer">Eric Glass's work</a>.<br>
  but stuck at HMAC-MD5 section. (using function like <a href="https://stackoverflow.com/questions/13555962/md5-hmac-with-openssl">this</a>)</p>
  
  <p>I got the right NTLM hash, and unicode username &amp; domain.<br>
  (he only emphasize the "USERDOMAIN" but no username, so I suppose it's "USER")  </p>
  
  <pre><code>unsigned char v1hash[16];  // "0xcd06ca7c7e10c99b1d33b7485a2ed808"
  unsigned short udata[14];
  // concated unicode USER+USERDOMAIN "0x550053004500520044004f004d00410049004e00"
  unsigned char v2hash[16];
  int iLen;
  
  HMAC(EVP_md5(), v1hash, 16, udata, sizeof(udata), v2hash, &amp;iLen);
  </code></pre>
  
  <p>but the result is:  </p>
  
  <pre><code>v2hash(16): 23 d2 3c a4 dd 1a 20 81 35 cf 3a 42 1c e1 5a 17
  </code></pre>
  
  <p>which should be "0x04b8e0ba74289cc540826bab1dee63ae"</p>
  
  <p>am I doing something wrong here?</p>