Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 08 Mar 2011 17:46:45 +0100
From: magnum <rawsmooth@...dband.net>
To: john-dev@...ts.openwall.com
Subject: Re: --utf8 option, proof of concept

On 03/08/2011 12:31 AM, jfoug wrote:
>> -----Original Message-----
>> From: magnum   Sent - Monday, March 07, 2011 4:03 PM
>> * In a couple of formats (eg. NT) I have doubled the set_salt function
>> and call it via a pointer, in order to mitigate the performance hit for
>> non-utf8. I'm not sure how to do it better, but I'm not particularly
>> satisfied. It's a hack.
>
> Here is an example for the changes in rawmd5.
>
> extern struct fmt_main fmt_rawMD5unicode
>
> static void rawmd5_init(void)
> {
> 	if (options.flags&  FLG_UTF8)
> 		rawMD5unicode.set_key = set_key_utf8;
> 	else
> 		rawMD5unicode.set_key = set_key_ansi;
> }
>
>
> Simply sets the function pointer to the proper set_key into the format's
> function pointer for set_key.  The only reason for the extern, is since the
> declaration/definition of the actual object is at the end of the source
> file.

Thanks. I had tried something similar but it did not work. Now with some 
more courage I managed to do it:

static void set_key_utf8(char *_key, int index);
static void set_key_ansi(char *_key, int index);
extern struct fmt_main fmt_rawMD5unicode;

static void rawmd5_init(void)
{
        if (options.flags & FLG_UTF8)
               fmt_rawMD5unicode.methods.set_key = &set_key_utf8;
        else
               fmt_rawMD5unicode.methods.set_key = &set_key_ansi;
}

...and this last detail, which was what I missed before:

@@ -403,7 +398,7 @@ struct fmt_main fmt_rawMD5unicode =
                 rawmd5_set_salt,
-               set_key,
+               NULL,


So, is this a sane way of doing this? Is init() always called, and only 
once?

magnum

Powered by blists - more mailing lists

Your e-mail address:

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