Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <024a01cd552c$e9ac7d50$bd0577f0$@net>
Date: Thu, 28 Jun 2012 07:52:44 -0500
From: "jfoug" <jfoug@....net>
To: <john-dev@...ts.openwall.com>
Subject: RE: Is saving 2 bytes per salt worth the effort?

>From: Frank Dittrich [mailto:frank_dittrich@...mail.com]
>
>
>You actually snipped the quoting with my idea:
>
> snip [again ;) ]

Frank,

I do not believe you were the only one tossing out the 'change the int into
a char' line of thought ;)

I posted that to the full list, to try to keep people from making that form
of problematic and needless change.

Actually, if there are several 'flags', and some smallish sizes, AND they do
not get accessing in a hot section, you are best off using a bit union, of
the narrowest aligned int size that will carry all of the flags.  So if you
need a couple off flags and a small size that are only needed at init time,
and then later at final time, but are not used in the main grinding loop,
doing something like

union {
  unsigned short flag1 : 1;
  unsigned short flag2 : 1;
  unsigned short flag3 : 1;
  unsigned short len : 9;
}

Gives a pretty good memory savings overall, with little/no performace hit.
Uses 2 bytes, has 3 flags, and a number from 0 to 511, and there still are 4
'flag' bytes, or a number from 0 to 15 left.   NOTE, if these WERE used in a
hot area, it would (could) change the runtime speed of the function.

Jim.

PS, not sure my syntax is correct, I wrote that off the cuff.


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.