[hashcash] hashcash BSD vs GNU getopt bug (Re: documentation bug?)

  • From: Adam Back <adam@xxxxxxxxxxxxxxx>
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Sat, 28 Aug 2004 14:49:45 -0400

Hi

The issue Atom identified below seems to occur on BSD only.

Looking at code the following getopt option is relied on by hashcash:

        By default, getopt() permutes the contents of argv as it
        scans, so that eventually all the non-options are at the end.
        [...] [but]

        If the first character of optstring is ‘-’, then each non-option
        argv-element is handled as if it were the argument of an
        option with character code 1.

)

BSD getopt does not support this:

        http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=getopt

(it's unclear if the first optstring char '-' option is a GNU
extension, or if BSD is not quite POSIX2 compatible).


Anyway I don't see an obvious way to use the BSD getopt to do what
hashcash is expecting.  But there is another solution, the hashcash
package already include the source for the GNU getopt (for win32
building as it does not have a suitable function), so one should just
link with that on BSD.

Any ideas on how to modify Makefile, source or whatever to
automatically use the GNU getopt source included in the distribution
on BSD?

Adam

On Wed, Aug 25, 2004 at 07:47:22PM -0400, Atom 'Smasher' wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> i just upgraded from 0.28 to 1.02. built on freeBSD from source and it 
> went _smooth_.
> 
> line 25 of the man page says:
>       Count collision bits:
>       hashcash -w [ options ] [ stamp ... ]
> 
> and line 503 of the man page says:
>       "hashcash -w 1:24:040806:foo::511801694b4cd6b0:1e7297a"
>                       Report the value of the stamp...
> 
> this syntax appears to not work, at least form the command line...
> 
>       $ hashcash -w 1:24:040806:foo::511801694b4cd6b0:1e7297a
>       enter stamps to check one per line:
> 
> also, it seems that "-w" doesn't work with "-c"...?
> 
> this version also seems to have problems checking the width of v0 stamps.
> 
> 
>       ...atom
> 
>  _________________________________________
>  PGP key - http://atom.smasher.org/pgp.txt
>  762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
>  -------------------------------------------------
> 
>       "IDEA's key length is 128 bits - over twice as long as DES.
>        Assuming that a brute force attack is the most efficient,
>        it would require 2^128 (10^38) encryptions to recover the
>        key. Design a chip that can test a billion keys per
>        second an throw a billion of the them at the problem,
>        and it will still take 10^13 years - that's longer than
>        the age of the universe. An array of 10^24 such chips can
>        find the key in a day, but there aren't enough silicon
>        atoms in the universe to build such a machine. Now we're
>        getting somewhere - although I'd keep my eye on the dark
>        matter debate."
>               -- Bruce Schneier, Applied Cryptography
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.3.6 (FreeBSD)
> Comment: What is this gibberish?
> Comment: http://atom.smasher.org/links/#digital_signatures
> 
> iQEcBAEBCAAGBQJBLSUQAAoJEAx/d+cTpVciXsoH/1bvb5zJqbhL8Tx2o7kp2EIz
> Q2WqwrSX59B7ZJy4Ft1AUnaEk5TqsLWd4VjtTLs7+EQcpzxcOuz7emnHj98W5f/r
> z7idkHEHU+skSngP1gn9ubGmLBN12tslWARvfIlLhJiNnGv/l9olSGY4Hy2m/ZfU
> 4z790PKIxW9znBSqSnUDj5EaA5D4z69j4a0CWnJp41SNoOX1Q2hoVPlQ7WvldQeY
> Xzvwpq8ejaXeisxRORKhRVDIymimpFv3SuwmHP6XjrsHbmvFpwcunhZMBuBaNOHg
> +Zklpm7redMjQS90Bq23K/1SfRt5iKk4OB7UKcHdAjLpQCbX/1wLMLH/tluEt08=
> =bc6M
> -----END PGP SIGNATURE-----

Other related posts: