void cred_hash3(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw) { unsigned char key2[8]; memset(key2,'\0',8); des_crypt56(out, in, key, forw); key2[0] = key[7]; des_crypt56(out + 8, in + 8, key2, forw); }
void SMBsesskeygen_lm_sess_key(const uint8_t lm_hash[16], const uint8_t lm_resp[24], /* only uses 8 */ uint8_t sess_key[16]) { /* Calculate the LM session key (effective length 40 bits, but changes with each session) */ uint8_t p24[24]; uint8_t partial_lm_hash[14]; memcpy(partial_lm_hash, lm_hash, 8); memset(partial_lm_hash + 8, 0xbd, 6); des_crypt56(p24, lm_resp, partial_lm_hash, 1); des_crypt56(p24+8, lm_resp, partial_lm_hash + 7, 1); memcpy(sess_key, p24, 16); #ifdef DEBUG_PASSWORD DEBUG(100, ("SMBsesskeygen_lm_sess_key: \n")); dump_data(100, sess_key, 16); #endif }
void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key, int forward) { int i, k; for (i=0,k=0; i<in->length; i += 8, k += 7) { uint8 bin[8], bout[8], key[7]; memset(bin, 0, 8); memcpy(bin, &in->data[i], MIN(8, in->length-i)); if (k + 7 > session_key->length) { k = (session_key->length - k); } memcpy(key, &session_key->data[k], 7); des_crypt56(bout, bin, key, forward?1:0); memcpy(&out->data[i], bout, MIN(8, in->length-i)); } }
/* DES decrypt a 8 byte LMSessionKey buffer using the Netlogon session key */ void netlogon_creds_des_decrypt_LMKey(struct netlogon_creds_CredentialState *creds, struct netr_LMSessionKey *key) { struct netr_LMSessionKey tmp; des_crypt56(tmp.key, key->key, creds->session_key, 0); *key = tmp; }