lib/substitute.o lib/fsusage.o \
lib/ms_fnmatch.o lib/select.o lib/messages.o \
lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \
- lib/md5.o lib/hmacmd5.o lib/arc4.o lib/iconv.o \
+ libsmb/smb_seal.o lib/md5.o lib/hmacmd5.o lib/arc4.o lib/iconv.o \
nsswitch/wb_client.o $(WBCOMMON_OBJ) \
lib/pam_errors.o intl/lang_tdb.o \
lib/adt_tree.o lib/gencache.o $(TDB_OBJ) \
#define WRITE_ERROR 4 /* This error code can go into the client smb_rw_error. */
#define READ_BAD_SIG 5
#define DO_NOT_DO_TDIS 6 /* cli_close_connection() check for this when smbfs wants to keep tree connected */
+#define READ_BAD_DECRYPT 7
#define DIR_STRUCT_SIZE 43
(chflags) and lsattr */
#define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x10 /* Use POSIX pathnames on the wire. */
#define CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20 /* We can cope with POSIX open/mkdir/unlink etc. */
-
+#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x40 /* We can do SPNEGO negotiations for encryption. */
#define SMB_QUERY_POSIX_FS_INFO 0x201
DOM_SID[] - list of SIDs (may be empty)
*/
+/*
+ * The following trans2 is done between client and server
+ * as a FSINFO call to set up the encryption state for transport
+ * encryption.
+ *
+ * The request looks like :
+ *
+ * [data block] -> SPNEGO framed GSSAPI request.
+ *
+ * The reply looks like :
+ *
+ * [data block] -> SPNEGO framed GSSAPI reply - if error
+ * is NT_STATUS_OK then we're done, if it's
+ * NT_STATUS_MORE_PROCESSING_REQUIRED then the
+ * client needs to keep going. If it's an
+ * error it can be any NT_STATUS error.
+ *
+ */
+
+#define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
+
/* The query/set info levels for POSIX ACLs. */
#define SMB_QUERY_POSIX_ACL 0x204
#define SMB_SET_POSIX_ACL 0x204
BOOL receive_smb(int fd, char *buffer, unsigned int timeout)
{
+ NTSTATUS status;
+
if (!receive_smb_raw(fd, buffer, timeout)) {
return False;
}
+ status = srv_decrypt_buffer(buffer);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("receive_smb: SMB decryption failed on incoming packet! Error %s\n",
+ nt_errstr(status) ));
+ if (smb_read_error == 0) {
+ smb_read_error = READ_BAD_DECRYPT;
+ }
+ return False;
+ }
+
/* Check the incoming SMB signature. */
if (!srv_check_sign_mac(buffer, True)) {
DEBUG(0, ("receive_smb: SMB Signature verification failed on incoming packet!\n"));
- if (smb_read_error == 0)
+ if (smb_read_error == 0) {
smb_read_error = READ_BAD_SIG;
+ }
return False;
};
BOOL send_smb(int fd, char *buffer)
{
+ NTSTATUS status;
size_t len;
size_t nwritten=0;
ssize_t ret;
/* Sign the outgoing packet if required. */
srv_calculate_sign_mac(buffer);
+ status = srv_encrypt_buffer(buffer);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("send_smb: SMB encryption failed on outgoing packet! Error %s\n",
+ nt_errstr(status) ));
+ return False;
+ }
+
len = smb_len(buffer) + 4;
while (nwritten < len) {
should never go into a blocking read.
****************************************************************************/
-static BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout)
+static BOOL client_receive_smb(struct cli_state *cli)
{
BOOL ret;
+ NTSTATUS status;
+ int fd = cli->fd;
+ char *buffer = cli->inbuf;
+ unsigned int timeout = cli->timeout;
for(;;) {
ret = receive_smb_raw(fd, buffer, timeout);
if(CVAL(buffer,0) != SMBkeepalive)
break;
}
+ status = cli_decrypt_message(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("SMB decryption failed on incoming packet! Error %s\n",
+ nt_errstr(status)));
+ cli->smb_rw_error = READ_BAD_DECRYPT;
+ close(cli->fd);
+ cli->fd = -1;
+ return False;
+ }
show_msg(buffer);
return ret;
}
return False;
again:
- ret = client_receive_smb(cli->fd,cli->inbuf,cli->timeout);
+ ret = client_receive_smb(cli);
if (ret) {
/* it might be an oplock break request */
DEBUG(6,("write_socket(%d,%d)\n",fd,(int)len));
ret = write_data(fd,buf,len);
-
+
DEBUG(6,("write_socket(%d,%d) wrote %d\n",fd,(int)len,(int)ret));
if(ret <= 0)
DEBUG(0,("write_socket: Error writing %d bytes to socket %d: ERRNO = %s\n",
BOOL cli_send_smb(struct cli_state *cli)
{
+ NTSTATUS status;
size_t len;
size_t nwritten=0;
ssize_t ret;
/* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
- if (cli->fd == -1)
+ if (cli->fd == -1) {
return False;
+ }
cli_calculate_sign_mac(cli);
+ status = cli_encrypt_message(cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ close(cli->fd);
+ cli->fd = -1;
+ cli->smb_rw_error = WRITE_ERROR;
+ DEBUG(0,("Error in encrypting client message. Error %s\n",
+ nt_errstr(status) ));
+ return False;
+ }
+
len = smb_len(cli->outbuf) + 4;
while (nwritten < len) {
}
/* Increment the mid so we can tell between responses. */
cli->mid++;
- if (!cli->mid)
+ if (!cli->mid) {
cli->mid++;
+ }
return True;
}
case WRITE_ERROR:
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
case READ_BAD_SIG:
+ case READ_BAD_DECRYPT:
return NT_STATUS_INVALID_PARAMETER;
default:
break;
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
"Server packet had invalid SMB signature!");
break;
+ case READ_BAD_DECRYPT:
+ slprintf(cli_error_message, sizeof(cli_error_message) - 1,
+ "Server packet could not be decrypted !");
+ break;
default:
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
"Unknown error code %d\n", cli->smb_rw_error );
--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+ SMB Transport encryption (sealing) code.
+ Copyright (C) Jeremy Allison 2007.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+NTSTATUS cli_decrypt_message(struct cli_state *cli)
+{
+ return NT_STATUS_OK;
+}
+
+NTSTATUS cli_encrypt_message(struct cli_state *cli)
+{
+ return NT_STATUS_OK;
+}
+
+NTSTATUS srv_decrypt_buffer(char *buffer)
+{
+ return NT_STATUS_OK;
+}
+
+NTSTATUS srv_encrypt_buffer(char *buffer)
+{
+ return NT_STATUS_OK;
+}