mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: musl 0.9.5 release and new website
Date: Sat, 15 Sep 2012 23:29:31 -0400	[thread overview]
Message-ID: <20120916032931.GB254@brightrain.aerifal.cx> (raw)
In-Reply-To: <20120915135340.GI9428@port70.net>

On Sat, Sep 15, 2012 at 03:53:41PM +0200, Szabolcs Nagy wrote:
> > Post-release priorities are adding the last of the missing Linux
> > syscalls, md5 crypt, and the long-elusive scheduling priority
> 
> i attached an md5 crypt implementation
> 
> i set the key limit to 30000 but that
> can be lowered
> 
> i'm not sure about the copyright notice in the middle
> as the code was rewritten from scratch so nothing
> was actually copied
> but the old bsd code is the specification itself
> and it is copyrighted:

The license is 2-clause BSD so it doesn't really matter.

> static uint32_t rol(uint32_t n, int k) { return (n << k) | (n >> (32-k)); }
> #define F(x,y,z) (z ^ (x & (y ^ z)))
> #define G(x,y,z) (y ^ (z & (y ^ x)))
> #define H(x,y,z) (x ^ y ^ z)
> #define I(x,y,z) (y ^ (x | ~z))
> #define FF(a,b,c,d,w,s,t) a += F(b,c,d) + w + t; a = rol(a,s) + b
> #define GG(a,b,c,d,w,s,t) a += G(b,c,d) + w + t; a = rol(a,s) + b
> #define HH(a,b,c,d,w,s,t) a += H(b,c,d) + w + t; a = rol(a,s) + b
> #define II(a,b,c,d,w,s,t) a += I(b,c,d) + w + t; a = rol(a,s) + b
> 
> [...]
> static void processblock(struct md5 *s, const uint8_t *buf)
> {
> 	uint32_t i, W[16], a, b, c, d;
> 
> 	for (i = 0; i < 16; i++) {
> 		W[i] = buf[4*i];
> 		W[i] |= (uint32_t)buf[4*i+1]<<8;
> 		W[i] |= (uint32_t)buf[4*i+2]<<16;
> 		W[i] |= (uint32_t)buf[4*i+3]<<24;
> 	}
> 
> 	a = s->h[0];
> 	b = s->h[1];
> 	c = s->h[2];
> 	d = s->h[3];
> 
> 	i = 0;
> 	while (i < 16) {
> 		FF(a,b,c,d, W[i],  7, tab[i]); i++;
> 		FF(d,a,b,c, W[i], 12, tab[i]); i++;
> 		FF(c,d,a,b, W[i], 17, tab[i]); i++;
> 		FF(b,c,d,a, W[i], 22, tab[i]); i++;
> 	}

This is more of the same old ugly manual unrolling. The file is small
as-is, but I think it could be a lot smaller with -Os (and same speed
as now with -O3) if the manual unrolling were removed.

I'm going to commit as-is though so I can include it in 0.9.6 (see the
other message I'm about to post).

Rich


  parent reply	other threads:[~2012-09-16  3:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-15  8:12 Rich Felker
2012-09-15 13:53 ` Szabolcs Nagy
2012-09-15 14:05   ` Luca Barbato
2012-09-16  3:35     ` Rich Felker
2012-09-16  3:48       ` Conrad Pankoff
2012-09-16  4:03         ` Gregor Richards
2012-09-16 11:04       ` Luca Barbato
2012-09-16  3:26   ` Rich Felker
2012-09-16 10:31     ` Szabolcs Nagy
2012-09-16 12:39       ` Rich Felker
2012-09-16  3:29   ` Rich Felker [this message]
2012-09-16 21:42     ` Szabolcs Nagy
2012-09-17  3:02       ` Rich Felker
2012-09-17  7:35         ` Szabolcs Nagy
2012-09-18 13:56           ` Rich Felker
2012-09-15 23:09 ` Isaac Dunham
2012-09-16  3:41 ` Rich Felker

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=20120916032931.GB254@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).