svn commit: samba r7030 - in trunk/source/libsmb: .

jra at samba.org jra at samba.org
Fri May 27 16:15:40 GMT 2005


Author: jra
Date: 2005-05-27 16:15:39 +0000 (Fri, 27 May 2005)
New Revision: 7030

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7030

Log:
Added encrypt/decrypt function for LSA secrets and trusted
domain passwords on the wire.
Jeremy.

Modified:
   trunk/source/libsmb/smbdes.c
   trunk/source/libsmb/smbencrypt.c


Changeset:
Modified: trunk/source/libsmb/smbdes.c
===================================================================
--- trunk/source/libsmb/smbdes.c	2005-05-27 15:49:15 UTC (rev 7029)
+++ trunk/source/libsmb/smbdes.c	2005-05-27 16:15:39 UTC (rev 7030)
@@ -276,7 +276,7 @@
 }
 
 
-static void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw)
+void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw)
 {
 	int i;
 	char outb[64];

Modified: trunk/source/libsmb/smbencrypt.c
===================================================================
--- trunk/source/libsmb/smbencrypt.c	2005-05-27 15:49:15 UTC (rev 7029)
+++ trunk/source/libsmb/smbencrypt.c	2005-05-27 16:15:39 UTC (rev 7030)
@@ -513,6 +513,7 @@
  *new_pw_len is the length in bytes of the possibly mulitbyte
  returned password including termination.
 ************************************************************/
+
 BOOL decode_pw_buffer(uint8 in_buffer[516], char *new_pwrd,
 		      int new_pwrd_size, uint32 *new_pw_len,
 		      int string_flags)
@@ -554,3 +555,31 @@
 	
 	return True;
 }
+
+/***********************************************************
+ Encrypt/Decrypt used for LSA secrets and trusted domain
+ passwords.
+************************************************************/
+
+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_t 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);
+
+		smbhash(bout, bin, key, forward?1:0);
+
+		memcpy(&out->data[i], bout, MIN(8, in->length-i));
+        }
+}



More information about the samba-cvs mailing list