From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: FreeSec crypt()
Date: Wed, 13 Jun 2012 08:10:32 +0200 [thread overview]
Message-ID: <20120613061032.GH17860@port70.net> (raw)
In-Reply-To: <20120613011842.GA163@brightrain.aerifal.cx>
* Rich Felker <dalias@aerifal.cx> [2012-06-12 21:18:42 -0400]:
> On Wed, Jun 13, 2012 at 03:51:13AM +0400, Solar Designer wrote:
> > Rich -
> >
> > As discussed on IRC, here is a revision of the FreeSec crypt() code with
>
> Thanks. Here's a _really_ quick draft, untested, of the direction I
> wanted to take it with making the tables static-initialized. Note that
my comments:
> #include <sys/types.h>
> #include <string.h>
>
> struct _crypt_extended_local {
> u_int32_t saltbits;
> u_int32_t en_keysl[16], en_keysr[16];
> };
>
-#include <sys/types.h>
+#include <stdint.h>
s/u_int32_t/uint32_t/g
s/u_char/unsigned char/g
> static inline int
> ascii_to_bin(int ch)
> {
> int sch = ch>127 ? -(256-ch) : ch;
> int retval;
>
> retval = sch - '.';
> if (sch >= 'A') {
> retval = sch - ('A' - 12);
> if (sch >= 'a')
> retval = sch - ('a' - 38);
> }
> retval &= 0x3f;
>
> return retval;
> }
>
s/inline//
on [-128,255] the following code gives the same result:
static int ascii_to_bin2(int c)
{
if (c >= 128)
c += -128 + 18;
else if (c >= 97)
c += -97 + 38;
else if (c >= 65)
c += -65 + 12;
else
c += 128 + 18;
return (unsigned)c % 64;
}
> char *
> _crypt_extended_r(const char *key, const char *setting, char *output)
> {
...
> while (q - (u_char *) keybuf < sizeof(keybuf)) {
> *q++ = *key << 1;
implementation-defined signed shift
> for (i = 1, count = 0; i < 5; i++) {
> int value = ascii_to_bin(setting[i]);
> if (ascii64[value] != setting[i])
> return NULL;
> count |= value << (i - 1) * 6;
> }
signed shift (harmless)
> while (q - (u_char *) keybuf < sizeof(keybuf) && *key)
> *q++ ^= *key++ << 1;
signed shift
next prev parent reply other threads:[~2012-06-13 6:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-12 23:51 Solar Designer
2012-06-13 1:18 ` Rich Felker
2012-06-13 6:10 ` Szabolcs Nagy [this message]
2012-06-13 12:43 ` Solar Designer
2012-06-13 12:58 ` Rich Felker
2012-06-13 13:18 ` Solar Designer
2012-06-13 14:56 ` Rich Felker
2012-06-13 16:45 ` Solar Designer
2012-06-13 17:27 ` Rich Felker
2012-06-13 17:32 ` Szabolcs Nagy
2012-06-13 17:36 ` Rich Felker
2012-06-13 12:07 ` Solar Designer
2012-06-13 14:53 ` Rich Felker
2012-06-24 7:21 ` Solar Designer
2012-06-24 7:32 ` Solar Designer
2012-06-25 3:51 ` Rich Felker
2012-06-29 5:25 ` 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=20120613061032.GH17860@port70.net \
--to=nsz@port70.net \
--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).