bool smb_signing_activate(struct smb_signing_state *si, const DATA_BLOB user_session_key, const DATA_BLOB response) { size_t len; off_t ofs; if (!user_session_key.length) { return false; } if (!si->negotiated) { return false; } if (si->active) { return false; } if (si->mac_key.length > 0) { return false; } smb_signing_reset_info(si); len = response.length + user_session_key.length; si->mac_key = data_blob_talloc(si, NULL, len); ofs = 0; memcpy(&si->mac_key.data[ofs], user_session_key.data, user_session_key.length); DEBUG(10, ("smb_signing_activate: user_session_key\n")); dump_data(10, user_session_key.data, user_session_key.length); if (response.length) { ofs = user_session_key.length; memcpy(&si->mac_key.data[ofs], response.data, response.length); DEBUG(10, ("smb_signing_activate: response_data\n")); dump_data(10, response.data, response.length); } else { DEBUG(10, ("smb_signing_activate: NULL response_data\n")); } dump_data_pw("smb_signing_activate: mac key is:\n", si->mac_key.data, si->mac_key.length); /* Initialise the sequence number */ si->seqnum = 2; return true; }
static bool smb_signing_good(struct smb_signing_state *si, bool good, uint32_t seq) { if (good) { if (!si->active) { si->active = true; } return true; } if (!si->mandatory && !si->active) { /* Non-mandatory signing - just turn off if this is the first bad packet.. */ DEBUG(5, ("smb_signing_good: signing negotiated but not required and peer\n" "isn't sending correct signatures. Turning off.\n")); smb_signing_reset_info(si); return true; } /* Mandatory signing or bad packet after signing started - fail and disconnect. */ DEBUG(0, ("smb_signing_good: BAD SIG: seq %u\n", (unsigned int)seq)); return false; }