re: pwhash - added -x option

matthew green <[email protected]> Thu, 29 Nov 2018 07:34:28 +1100
Newsgroups gmane.os.netbsd.devel.crypto
Message-ID <[email protected]>
hi JP.

can you use "cvs diff -up"?  (unified diff and likely function
name options.)  you can put "diff -up" in ~/.cvsrc.

i think i'd rather this didn't try to be tricky and re-use 2
lines, but have the case 'x' be its own chunk, and perhaps it
should grow a "DO_CHECK" that is set instead of DO_SED, and
that print_passwd() considers the same as DO_SED.  this should
only total less than 10 extra lines without conflating options.

thanks!


.mrg.

> I have the need to check against hashes generated by pwhash (I have a CG=
I
> script doing logins).  I'd like an option in pwhash to explicitly specif=
y
> the setting for crypt() (rather than create a whole separate binary).  T=
he
> -s option almost does this except that it verifies that there is no $ in
> the optarg (to ensure DES), so the changes to the source are minimal (5
> lines).  I added a -x, the option argument explicitly specifies the cryp=
t()
> setting.
> =

> Anyway, just thought someone else might be interested.
> =

> JP
> =

> P.S.  I'm not sure how to submit patches, but I ran `cvs diff` in
> /usr/src/usr.bin/pwhash and this is the output
> =

> Index: pwhash.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/src/usr.bin/pwhash/pwhash.c,v
> retrieving revision 1.15
> diff -r1.15 pwhash.c
> 56a57
> > #define DO_CRYPT   5
> 63c64
> < 	    "Usage: %s [-km] [-b rounds] [-S rounds] [-s salt] [-p | string]\=
n",
> ---
> > 	    "Usage: %s [-km] [-b rounds] [-S rounds] [-s salt] [-x setting] [=
-p | string]\n",
> 118a120
> > 	case DO_CRYPT:
> 149c151
> < 	while ((opt =3D getopt(argc, argv, "kmpS:s:b:")) !=3D -1) {
> ---
> > 	while ((opt =3D getopt(argc, argv, "kmpS:s:b:x:")) !=3D -1) {
> 179a182
> > 		case 'x':
> =

> --0000000000008971a4057b9321c2
> Content-Type: text/html; charset=3D"UTF-8"
> Content-Transfer-Encoding: quoted-printable
> =

> <div dir=3D3D"ltr"><div>I have the need to check against hashes generate=
d by =3D
> pwhash (I have a CGI script doing logins).=3DC2=3DA0 I&#39;d like an opt=
ion in =3D
> pwhash to explicitly specify the setting for crypt() (rather than create=
 a =3D
> whole separate binary).=3DC2=3DA0 The -s option almost does this except =
that it=3D
>  verifies that there is no $ in the optarg (to ensure DES), so the chang=
es =3D
> to the source are minimal (5 lines).=3DC2=3DA0 I added a -x, the option =
argumen=3D
> t explicitly specifies the crypt() setting.<br></div><div><br></div><div=
>An=3D
> yway, just thought someone else might be interested.</div><div><br></div=
><d=3D
> iv>JP<br></div><div><br></div><div>P.S.=3DC2=3DA0 I&#39;m not sure how t=
o submi=3D
> t patches, but I ran `cvs diff` in /usr/src/usr.bin/pwhash and this is t=
he =3D
> output</div><div><br></div><div>
> <pre>Index: pwhash.c
> =3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D=
3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D
> =3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D=
3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D
> =3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D3D=3D=
3D=3D3D=3D3D
> RCS file: /cvsroot/src/usr.bin/pwhash/pwhash.c,v
> retrieving revision 1.15
> diff -r1.15 pwhash.c
> 56a57
> &gt; #define DO_CRYPT   5
> 63c64
> &lt; 	    &quot;Usage: %s [-km] [-b rounds] [-S rounds] [-s salt] [-p | =
str=3D
> ing]\n&quot;,
> ---
> &gt; 	    &quot;Usage: %s [-km] [-b rounds] [-S rounds] [-s salt] [-x se=
tti=3D
> ng] [-p | string]\n&quot;,
> 118a120
> &gt; 	case DO_CRYPT:
> 149c151
> &lt; 	while ((opt =3D3D getopt(argc, argv, &quot;kmpS:s:b:&quot;)) !=3D3=
D -1) {
> ---
> &gt; 	while ((opt =3D3D getopt(argc, argv, &quot;kmpS:s:b:x:&quot;)) !=3D=
3D -1)=3D
>  {
> 179a182
> &gt; 		case &#39;x&#39;:</pre>
> =

> </div></div>
> =

> --0000000000008971a4057b9321c2--
> =