Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 8 Mar 2011 11:40:15 -0600
From: "jfoug" <>
To: <>
Subject: RE: --utf8 option, proof of concept

>-----Original Message-----
>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;

If you put the init() function at the bottom of the file, then you would
need no declaration statements at all.  If the init function is before any
of the definitions, then you will have to put declarations there.  Nothing
more than having to pacify the compiler.

>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

The order of operations:

methods.valid() and methods.split(), may be called prior to methods.init().
No other function will be called prior to methods.init().  methods.init() is
called one time only, or none, but if it is not called, nothing else in the
format will be called.  Thus, methods.setkey() can NOT be called, prior to
methods.init() being called.

This is how I do the 'thin' formats, for MD5.  I only set pointers to valid
and init.  Then within init, the rest of the function pointers get set to
md5-generic functions, by calling a function that lives INSIDE the
md5_gen_fmt.c, so it can access all of the static function pointers, and a
couple get the thin methods.init() sets a few functions to thin wrapper

One other tiny item.  The name of a function is (can be) a pointer.  Thus,
fnptr = &set_key_utf8; can be simplified to fnptr = &set_key_utf8;   The &
operator is not needed.

Also, within the format, within the fmt_main structure setup, you might
simply initialize the set_key function pointer to the set_key_ansi function.
Then within init, only have the 'if' side of it, and do not worry about the
else, since by default, the format is already setup to use the set_key_ansi.

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

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


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.