Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 25 Jun 2015 16:59:28 +0300
From: Aleksey Cherepanov <lyosha@...nwall.com>
To: john-dev@...ts.openwall.com
Subject: Re: light way to make extensions to format interface

On Thu, Jun 25, 2015 at 03:24:02PM +0300, Aleksey Cherepanov wrote:
> In addition to current structure, there may be an optional array with
> pairs: string literal for method name and pointer to method
> implementation. The array is of variable length and finished by NULL,
> just like test vector. So it would be possible for a format to
> announce only implemented methods.

Alexander Cherepanov suggested to make macros that place methods into
structure. I think a method is needed to be called with a pointer to
structure then in method.

> For example, something like the following can be added only in formats
> that support rainbow tables:
> 
> struct fmt_extensions raw_md5_format_extensions = {
>   { "get_hash_for_rainbow_tables", raw_md5_get_hash_for_rainbow_tables },
>   NULL
> };

Example of macros approach:

void md5_register_extensions(struct fmt_extensions *exts)
{
#define R(s, name, method) EXT_REGISTER((s), (name), (method))
        R(GET_HASH_FOR_RAINBOW_TABLES, raw_md5_get_hash_for_rainbow_tables);
#undef R
}


X-Macro can be used for that:

#define GET_HASH_FOR_RAINBOW_TABLES raw_md5_get_hash_for_rainbow_tables
#include "make_register_extension.h"

where make_register_extension.h contains something like the following:

void md5_register_extensions(struct fmt_extensions *exts)
{

#ifdef GET_HASH_FOR_RAINBOW_TABLES
        EXT_REGISTER(exts, EXT_GET_HASH_FOR_RAINBOW_TABLES, GET_HASH_FOR_RAINBOW_TABLES);
#endif

#ifdef SOME_OTHER_EXTENSION_METHOD
        EXT_REGISTER(exts, EXT_SOEM, SOME_OTHER_EXTENSION_METHOD);
#endif

}

Well, EXT_REGISTER() abstraction is not really needed here.


Thanks!

-- 
Regards,
Aleksey Cherepanov

Powered by blists - more mailing lists

Your e-mail address:

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