mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: FreeSec DES-based crypt(3)
Date: Mon, 2 May 2011 09:49:52 -0400	[thread overview]
Message-ID: <20110502134952.GK277@brightrain.aerifal.cx> (raw)
In-Reply-To: <20110502134333.GB18325@openwall.com>

On Mon, May 02, 2011 at 05:43:33PM +0400, Solar Designer wrote:
> Another issue is that somehow the speed of your FreeSec code in musl is
> extremely poor - it runs about 50 times slower than expected (e.g., than
> it does in glibc on Owl).  This is as tested with "john --test
> --format=crypt" with JtR 1.7.7 on x86_64.  I suggest that you run this
> test too, both before and after you replace the FreeSec code.

You are right, and the reason, as suspected, is that the state is
reinitialized on each call to crypt (crypt is just a wrapper for
crypt_r with state on the stack). I tried eliminating the des_init
function and instead just using memcpy from a static const
initial_state object, but as this structure is very large, it
increased the object size by ~35k. Using a non-const static object
would be even worse, as it would increase the non-sharable data size
of any process by this amount. I could consider using malloc to obtain
a permanent des state, allocated and initialized on first use, with
fallback to the stack if malloc fails. But I'm wondering if it's
really desirable for crypt to be fast anyway. Surely JtR wants a fast
crypt, but my impression was always that slow crypt was a cheap way to
get some added defense against brute force login attempts and such...

Thoughts?

Rich

P.S. crypt is in no way integrated with other parts of libc, so
linking with -lfastcrypt (separate library) is a potentially viable
option for situations where you want a fast one.


  reply	other threads:[~2011-05-02 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 13:43 Solar Designer
2011-05-02 13:49 ` Rich Felker [this message]
2011-05-02 18:03   ` Solar Designer
2011-05-02 19:01     ` Rich Felker
2011-05-23 12:50       ` Solar Designer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110502134952.GK277@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).