HACK debug encryption
authorStefan Metzmacher <metze@samba.org>
Fri, 17 Aug 2012 06:33:11 +0000 (08:33 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 18 Sep 2012 03:10:19 +0000 (05:10 +0200)
source3/smbd/smb2_server.c

index be7997febfb919b9bacfd3705f4d10765bbafa2f..2511c578e46d123eb7910a74e2c1b1fe8f914033 100644 (file)
@@ -173,11 +173,13 @@ static void print_req_vectors(const struct smbd_smb2_request *req)
                dbgtext("\treq->in.vector[%u].iov_len = %u\n",
                        (unsigned int)i,
                        (unsigned int)req->in.vector[i].iov_len);
+               dump_data(0, req->in.vector[i].iov_base, req->in.vector[i].iov_len);
        }
        for (i = 0; i < req->out.vector_count; i++) {
                dbgtext("\treq->out.vector[%u].iov_len = %u\n",
                        (unsigned int)i,
                        (unsigned int)req->out.vector[i].iov_len);
+               dump_data(0, req->out.vector[i].iov_base, req->out.vector[i].iov_len);
        }
 }
 
@@ -404,6 +406,9 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
                                TALLOC_FREE(iov);
                                return status;
                        }
+                       DEBUG(0, ("%s: DECRYPT buflen[%u] taken[%u], len[%u]\n", __location__,
+                               (unsigned)buflen, (unsigned)taken, (unsigned)len));
+                       dump_data(0,buf, buflen);
 
                        verified_buflen = taken + enc_len;
                        len = enc_len;
@@ -426,6 +431,7 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
                if (SVAL(hdr, 4) != SMB2_HDR_BODY) {
                        DEBUG(10, ("Got HDR len %d, expected %d\n",
                                   SVAL(hdr, 4), SMB2_HDR_BODY));
+                       DEBUG(10,(":%s: HERE INVALID\n", __location__));
                        goto inval;
                }
 
@@ -435,14 +441,27 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
 
                if (next_command_ofs != 0) {
                        if (next_command_ofs < (SMB2_HDR_BODY + 2)) {
+                       DEBUG(10,(":%s: HERE INVALID\n", __location__));
                                goto inval;
                        }
                        if (next_command_ofs > full_size) {
+                       DEBUG(10,(":%s: HERE INVALID\n", __location__));
                                goto inval;
                        }
+                       if (tf && next_command_ofs < len) {
+                       DEBUG(0,(":%s: HERE INVALID: next_command_ofs[%u] len[%u] buflen[%u] taken[%u]\n",
+                               __location__,
+                               (unsigned)next_command_ofs,
+                               (unsigned)len,
+                               (unsigned)buflen,
+                               (unsigned)taken));
+               //      dump_data(0,buf, buflen);
+               //              goto inval;
+                       }
                        full_size = next_command_ofs;
                }
                if (body_size < 2) {
+                       DEBUG(10,(":%s: HERE INVALID\n", __location__));
                        goto inval;
                }
                body_size &= 0xfffe;
@@ -484,6 +503,7 @@ static NTSTATUS smbd_smb2_inbuf_parse_compound(struct smbXsrv_connection *conn,
        return NT_STATUS_OK;
 
 inval:
+                       DEBUG(10,(":%s: HERE INVALID\n", __location__));
        TALLOC_FREE(iov);
        return NT_STATUS_INVALID_PARAMETER;
 }
@@ -1188,6 +1208,18 @@ static struct smbd_smb2_request *dup_smb2_req(const struct smbd_smb2_request *re
        smb2_setup_nbt_length(newreq->out.vector,
                newreq->out.vector_count);
 
+       if (DEBUGLEVEL >= 10) {
+               dbgtext("dup_smb2_req: req->current_idx = %u\n",
+                       (unsigned int)req->current_idx );
+               dbgtext("dup_smb2_req: returning %u vectors\n",
+                       (unsigned int)req->out.vector_count );
+               print_req_vectors(req);
+               dbgtext("dup_smb2_req: newreq->current_idx = %u\n",
+                       (unsigned int)newreq->current_idx );
+               dbgtext("dup_smb2_req: returning %u vectors\n",
+                       (unsigned int)newreq->out.vector_count );
+               print_req_vectors(newreq);
+       }
        return newreq;
 }
 
@@ -1258,6 +1290,13 @@ static NTSTATUS smb2_send_async_interim_response(const struct smbd_smb2_request
                }
        }
 
+       if (DEBUGLEVEL >= 10) {
+               dbgtext("smb2_send_async_interim_response out: nreq->current_idx = %u\n",
+                       (unsigned int)nreq->current_idx );
+               dbgtext("smb2_send_async_interim_response out: returning %u vectors\n",
+                       (unsigned int)nreq->out.vector_count );
+               print_req_vectors(nreq);
+       }
        nreq->subreq = tstream_writev_queue_send(nreq,
                                        nreq->sconn->ev_ctx,
                                        nreq->sconn->smb2.stream,
@@ -2305,6 +2344,18 @@ static NTSTATUS smbd_smb2_request_reply(struct smbd_smb2_request *req)
        req->subreq = NULL;
        TALLOC_FREE(req->async_te);
 
+       if (DEBUGLEVEL >= 10) {
+               dbgtext("%s: smbd_smb2_request_reply[%p/%d]: "
+                       "enc[%u] tf[%u] fk[%u] s[%p] ek[%u]\n",
+                       __location__, req, req->current_idx,
+                       req->do_encryption,
+                       (unsigned)firsttf->iov_len,
+                       (unsigned)req->first_key.length,
+                       req->session,
+                       (unsigned)(req->session?req->session->global->encryption_key.length:0));
+               print_req_vectors(req);
+       }
+
        if (req->do_encryption &&
            (firsttf->iov_len == 0) &&
            (req->first_key.length == 0) &&
@@ -2358,6 +2409,11 @@ static NTSTATUS smbd_smb2_request_reply(struct smbd_smb2_request *req)
                firsttf->iov_len = SMB2_TF_HDR_SIZE;
        }
 
+       if (DEBUGLEVEL >= 10) {
+               dbgtext("%s: smbd_smb2_request_reply[%p/%d]: sending...\n",
+                       __location__, req, req->current_idx);
+               print_req_vectors(req);
+       }
        if ((req->current_idx > SMBD_SMB2_NUM_IOV_PER_REQ) &&
            (req->last_key.length > 0) &&
            (firsttf->iov_len == 0))
@@ -2435,6 +2491,10 @@ static NTSTATUS smbd_smb2_request_reply(struct smbd_smb2_request *req)
         */
        if (firsttf->iov_len == SMB2_TF_HDR_SIZE) {
                NTSTATUS status;
+       if (DEBUGLEVEL >= 10) {
+               dbgtext("smbd_smb2_request_reply: sending...\n");
+               print_req_vectors(req);
+       }
 
                status = smb2_signing_encrypt_pdu(req->first_key,
                                        conn->protocol,