Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 17 Jan 2013 18:01:20 +0100
From: Frank Dittrich <frank_dittrich@...mail.com>
To: john-dev@...ts.openwall.com
Subject: Unused functions in mozilla_des.c (was: NSS not needed)

On 01/17/2013 03:48 PM, Dhiru Kholia wrote:
> On Thu, Jan 17, 2013 at 7:52 PM, Frank Dittrich
> <frank_dittrich@...mail.com> wrote:
>> On 01/17/2013 01:22 PM, magnum wrote:
>>> On 16 Jan, 2013, at 4:14 , Dhiru Kholia <dhiru.kholia@...il.com> wrote:
>>>> Yes,  the format can be built without NSS.
>>>>
>>>> I suspected this earlier and now you have confirmed it.

May be I should have questioned this statement earlier.
I just assumed *you* had a look and found out that you can build mozilla
without NSS.

>>>> I will take a look at it soon. Thanks Frank.
>>>
>>> This would be nice for Jumbo-8, please commit to unstable if you fix it. Remove all references to HAVE_NSS in Makefile too.
> 
> I took a quick look but it doesn't seem to be that trivial (to me).
> 
> I am planning to re-write mozilla format at some point (like pdf
> format got re-written).
> 
>> Before we finally get rid of HAVE_NSS, we would need to make sure the
>> format works for different architectures (e.g., we don't have endianness
>> or other issues).
> 
> I removed the unused functions (and cleaned up includes, removed
> HAVE_NSS from format) but then unstable-jumbo doesn't build if
> HAVE_NSS is not defined.
> 
> Doing the same worked for Frank because maybe the NSS header files
> were in standard enough location on his system.
> 
> Frank,
> 
> Do you have a working patch I can test?

Obviously, there was some misunderstanding here.

What I meant with

| Removing DES_Encrypt() from mozilla_des.c and mozilla_des.h still
| allows building john, with or without -DHAVE_NSS.
|
| DES_Decrypt, DES_DestroyContext and possibly other functions seem
| to be unused as well.

was not that I got --format=mozilla working without HAVE_NSS.

Instead I meant that I removed DES_Encrypt(), then I built john (with
HAVE_NSS) and made sure
$ ./john --test --format=mozilla
still works.
Afterwards, I just disabled HAVE_NSS and built a new john version, to
make sure it still works (but this time without mozilla format.


So, I suggest to follow magnum's suggestion and just remove unused
functions. (We might need DES_DestroyContext in future versions, though.
Just in case we have proper cleanup functions in the format definition.)

The attached has #if 0 ... #endif around unused functions in
mozilla_des.c, and unused functions in mozilla_des.h commented out using
//, even for DES_DestroyContext, which we might need in future.

BTW:
Should the mozilla_des.[ch] and lowpbe.[ch] comments include a pointer
to the web address where source came from before it has been integrated
into john?

Frank

diff --git a/src/mozilla_des.c b/src/mozilla_des.c
index 6d679af..eb51f9a 100644
--- a/src/mozilla_des.c
+++ b/src/mozilla_des.c
@@ -718,7 +718,7 @@ void DES_Do1Block(HALF * ks, const BYTE * inbuf, BYTE * outbuf)
 #define COPY8BTOHALF(to, from) COPY8B(to, from, from)
 #define COPY8BFROMHALF(to, from) COPY8B(to, from, to)
 
-
+#if 0
 void DES_ECB(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len)
 {
     while (len) {
@@ -775,7 +775,7 @@ void DES_CBCDe(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int le
 	out += 8;
     }
 }
-
+#endif
 void DES_EDE3CBCEn(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len)
 {
     const BYTE * bufend = in + len;
@@ -820,7 +820,7 @@ struct DESContext *DES_CreateContext(struct DESContext *cx, const BYTE * key, co
 	DES_MakeSchedule(cx->ks0, key + 16, DES_DECRYPT);
 	return cx;
 }
-
+#if 0
 void DES_DestroyContext(struct DESContext *cx, PRBool freeit)
 {
 	if (cx)
@@ -843,5 +843,5 @@ int DES_Decrypt(struct DESContext *cx, BYTE *out, unsigned int *outLen,unsigned
 {
 	return DES_EDE3CBCDe(cx, in);
 }
-
+#endif
 #endif
diff --git a/src/mozilla_des.h b/src/mozilla_des.h
index b71ab19..1218954 100644
--- a/src/mozilla_des.h
+++ b/src/mozilla_des.h
@@ -78,19 +78,19 @@ struct DESContext
 
 typedef void DESFunc(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
 
-void DES_MakeSchedule( HALF * ks, const BYTE * key,   DESDirection direction);
-void DES_Do1Block(     HALF * ks, const BYTE * inbuf, BYTE * outbuf);
+//void DES_MakeSchedule( HALF * ks, const BYTE * key,   DESDirection direction);
+//void DES_Do1Block(     HALF * ks, const BYTE * inbuf, BYTE * outbuf);
 struct DESContext *DES_CreateContext(struct DESContext *cx, const BYTE * key, const BYTE *iv); //, int mode);
-void DES_DestroyContext(struct DESContext *cx, PRBool freeit);
-SECStatus DES_Encrypt(struct DESContext *cx, BYTE *out, unsigned int *outLen, unsigned int maxOutLen, const BYTE *in, unsigned int inLen);
-int DES_Decrypt(struct DESContext *cx, BYTE *out, unsigned int *outLen,unsigned int maxOutLen, const BYTE *in, unsigned int inLen);
+//void DES_DestroyContext(struct DESContext *cx, PRBool freeit);
+//SECStatus DES_Encrypt(struct DESContext *cx, BYTE *out, unsigned int *outLen, unsigned int maxOutLen, const BYTE *in, unsigned int inLen);
+//int DES_Decrypt(struct DESContext *cx, BYTE *out, unsigned int *outLen,unsigned int maxOutLen, const BYTE *in, unsigned int inLen);
 int DES_EDE3CBCDe(struct DESContext *cx, const BYTE *in);
 
 //not used...
-void DES_EDE3CBCEn(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
-void DES_CBCEn(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
-void DES_EDE3_ECB(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
-void DES_ECB(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
+//void DES_EDE3CBCEn(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
+//void DES_CBCEn(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
+//void DES_EDE3_ECB(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
+//void DES_ECB(struct DESContext *cx, BYTE *out, const BYTE *in, unsigned int len);
 
 
 

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ