DISQUS

Daemonic Dispatches: scrypt version 1.1 released

  • Ricardo Martins · 7 months ago
    Arch Linux -- kernel 2.6.29.3, gcc 4.4.0
    Intel Core2Duo 2.4 GHz (Macbook Pro 4,1)

    scrypt failed to build with the following compiler errors:

    scrypt-nosse.c: In function ‘scrypt’:
    scrypt-nosse.c:298: error: ‘MAP_NOCORE’ undeclared (first use in this function)
    scrypt-nosse.c:298: error: (Each undeclared identifier is reported only once
    scrypt-nosse.c:298: error: for each function it appears in.)
    make[1]: *** [scrypt-nosse.o] Error 1
    make[1]: Leaving directory `/home/meqif/tmp/scrypt-1.1'
    make: *** [all] Error 2
  • cperciva · 7 months ago
    Oops. I coded the test for MAP_NOCORE backwards -- please try again with version 1.1.1.
  • Ricardo Martins · 7 months ago
    Ah, now it compiled successfully. It also works fine with both a plain text file and a PDF (encryption and decryption). Thanks for fixing it!
  • Rory Arms · 7 months ago
    Hi Colin. It fails to build on OSX 10.4.11/powerpc & 10.5.6/powerpc

    First on 10.4, configure looks clean as far as I can tell, but the make step fails:

    osse.Tpo -c -o scrypt-nosse.o scrypt-nosse.c
    scrypt-nosse.c: In function ‘scrypt’:
    scrypt-nosse.c:298: error: ‘MAP_NOCORE’ undeclared (first use in this function)
    scrypt-nosse.c:298: error: (Each undeclared identifier is reported only once
    scrypt-nosse.c:298: error: for each function it appears in.)
    make[1]: *** [scrypt-nosse.o] Error 1
    make: *** [all] Error 2

    On 10.5.6/powerpc

    I do see some errors in the configure output that you might find useful:

    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... config.aux/install-sh -c -d
    checking for gawk... no
    checking for mawk... no
    checking for nawk... no
    checking for awk... awk
    checking whether make sets $(MAKE)... yes
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking for style of include used by make... GNU
    checking dependency style of gcc... gcc3
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for ANSI C header files... rm: conftest.dSYM/Contents/Resources/DWARF: Operation not permitted
    rm: conftest.dSYM/Contents/Resources: Directory not empty
    rm: conftest.dSYM/Contents: Directory not empty
    rm: conftest.dSYM: Directory not empty
    yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking err.h usability... yes
    checking err.h presence... yes
    checking for err.h... yes
    checking sys/endian.h usability... no
    checking sys/endian.h presence... no
    checking for sys/endian.h... no
    checking sys/sysinfo.h usability... no
    checking sys/sysinfo.h presence... no
    checking for sys/sysinfo.h... no
    checking for clock_gettime in -lrt... no
    checking for clock_gettime... no
    checking for sysinfo... no
    checking for posix_memalign... no
    checking for struct sysinfo... no
    checking for struct sysinfo.mem_unit... no
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating config.h
    config.status: executing depfiles commands

    And the make failure:

    scrypt-nosse.c: In function ‘scrypt’:
    scrypt-nosse.c:298: error: ‘MAP_NOCORE’ undeclared (first use in this function)
    scrypt-nosse.c:298: error: (Each undeclared identifier is reported only once
    scrypt-nosse.c:298: error: for each function it appears in.)
    make[1]: *** [scrypt-nosse.o] Error 1
    make: *** [all] Error 2
  • ekarulf · 7 months ago
    The same failure occurs on OS X 10.5.6 / Intel
  • cperciva · 7 months ago
    I coded the test for MAP_NOCORE backwards -- please try again with version 1.1.1 (where I think I've fixed this).
  • Antonio Touriño · 7 months ago
    Hi Colin,

    I couldn't verify your scrypt-sigs-1.1.asc file. gpg complained it could not find the key ID 3DD61E72 on the public servers. Is there another place I should be looking for it?

    Cheers,
    Antonio
  • cperciva · 7 months ago
    This is the tarsnap code signing GPG key, as mentioned at http://www.daemonology.net/blog/2009-01-17-tars...
  • Antonio Touriño · 7 months ago
    Thanks for the pointer. scrypt has compiled and is working on MacOS 10.5.7 on an Intel iMac. I have only done light tests and it has worked correctly. I will report back if I find any bugs. Cheers.
  • da44en · 7 months ago
    $ uname -a; make
    SunOS keithmoon 5.10 Generic_127127-11 sun4v sparc SUNW,Sun-Fire-T200 Solaris
    make all-am
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
    mv -f .deps/main.Tpo .deps/main.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT scryptenc.o -MD -MP -MF .deps/scryptenc.Tpo -c -o scryptenc.o scryptenc.c
    mv -f .deps/scryptenc.Tpo .deps/scryptenc.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT crypto_aesctr.o -MD -MP -MF .deps/crypto_aesctr.Tpo -c -o crypto_aesctr.o crypto_aesctr.c
    mv -f .deps/crypto_aesctr.Tpo .deps/crypto_aesctr.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT sha256.o -MD -MP -MF .deps/sha256.Tpo -c -o sha256.o sha256.c
    mv -f .deps/sha256.Tpo .deps/sha256.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT memlimit.o -MD -MP -MF .deps/memlimit.Tpo -c -o memlimit.o memlimit.c
    memlimit.c: In function `memlimit_sysinfo':
    memlimit.c:106: error: structure has no member named `totalram'
    *** Error code 1
    make: Fatal error: Command failed for target `memlimit.o'
    Current working directory /home/darren/tmp/scrypt-1.1.1
    *** Error code 1
    make: Fatal error: Command failed for target `all'
  • cperciva · 7 months ago
    Thanks! I should have added a check to make sure that the build was running on linux before assuming that any sysinfo function I detected was linux's sysinfo. If you edit config.h and delete the HAVE_SYSINFO line, does that fix the build?
  • da44en · 7 months ago
    With that change, it compiles, but I get a runtime error:

    $ ./scrypt enc config.h.in config.h.in.enc
    Please enter passphrase:
    Please confirm passphrase:
    scrypt: Error reading clocks: Invalid argument

    (Passphrase is foo.)

    I get the same error when trying to decrypt a file encrypted by scrypt compiled on linux. I see that error is from main.c:230.
  • cperciva · 7 months ago
    Thanks! Could you send your config.log and config.h files to me at cperciva@tarsnap.com so that I can look at them?
  • royce · 7 months ago
    Your target demographic may not be running on a NetBSD 2.x system running on Alpha, but just in case ...

    tycho@sdf$ uname -a
    NetBSD sdf 2.1.0_STABLE NetBSD 2.1.0_STABLE (sdf) #0: Fri Mar 30 02:24:32 UTC 2007 root@ol:/var/sys/arch/alpha/compile/sdf alpha

    tycho@sdf$ ./configure
    checking for a BSD-compatible install... /usr/pkg/bin/ginstall -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /usr/pkg/bin/gmkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking for style of include used by make... GNU
    checking dependency style of gcc... gcc3
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking err.h usability... yes
    checking err.h presence... yes
    checking for err.h... yes
    checking sys/endian.h usability... yes
    checking sys/endian.h presence... yes
    checking for sys/endian.h... yes
    checking sys/sysinfo.h usability... no
    checking sys/sysinfo.h presence... no
    checking for sys/sysinfo.h... no
    checking for clock_gettime in -lrt... yes
    checking for clock_gettime... yes
    checking for sysinfo... no
    checking for posix_memalign... no
    checking for struct sysinfo... no
    checking for struct sysinfo.mem_unit... no
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating config.h
    config.status: executing depfiles commands

    tycho@sdf$ make
    make all-am
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
    mv -f .deps/main.Tpo .deps/main.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT scryptenc.o -MD -MP -MF .deps/scryptenc.Tpo -c -o scryptenc.o scryptenc.c
    mv -f .deps/scryptenc.Tpo .deps/scryptenc.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT crypto_aesctr.o -MD -MP -MF .deps/crypto_aesctr.Tpo -c -o crypto_aesctr.o crypto_aesctr.c
    mv -f .deps/crypto_aesctr.Tpo .deps/crypto_aesctr.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT sha256.o -MD -MP -MF .deps/sha256.Tpo -c -o sha256.o sha256.c
    mv -f .deps/sha256.Tpo .deps/sha256.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT memlimit.o -MD -MP -MF .deps/memlimit.Tpo -c -o memlimit.o memlimit.c
    memlimit.c: In function `memlimit_rlimit':
    memlimit.c:138: error: `RLIMIT_AS' undeclared (first use in this function)
    memlimit.c:138: error: (Each undeclared identifier is reported only once
    memlimit.c:138: error: for each function it appears in.)
    *** Error code 1

    Stop.
    make: stopped in /arpa/tz/t/tycho/src/scrypt-1.1.1
    *** Error code 1

    Stop.
    make: stopped in /arpa/tz/t/tycho/src/scrypt-1.1.1
  • cperciva · 7 months ago
    Thanks! It looks like NetBSD only added RLIMIT_AS recently, in spite of it being required by POSIX. Could you try wrapping the RLIMIT_AS check in memlimit.c with #ifdef RLIMIT_AS ... #endif and let me know if that fixes the build?
  • royce · 7 months ago
    Another stop - some semi-duplicate lines removed for brevity:

    gcc -g -O2 -o scrypt main.o scryptenc.o crypto_aesctr.o sha256.o memlimit.o warn.o scrypt_cpuperf.o scrypt-nosse.o -lcrypto -lrt

    scryptenc.o(.text+0x718): In function `scryptenc_setup':
    /arpa/tz/t/tycho/src/scrypt-1.1.1/scryptenc.c:207: undefined reference to `be32enc'

    crypto_aesctr.o(.text+0x144): In function `crypto_aesctr_stream':
    /arpa/tz/t/tycho/src/scrypt-1.1.1/crypto_aesctr.c:95: undefined reference to `be64enc'

    sha256.o(.text+0x10c):/arpa/tz/t/tycho/src/scrypt-1.1.1/sha256.c:58: undefined reference to `be32dec'
    sha256.o(.text+0x3228): In function `PBKDF2_SHA256':

    scrypt-nosse.o(.text+0x8c8): In function `smix':
    /arpa/tz/t/tycho/src/scrypt-1.1.1/scrypt-nosse.c:220: undefined reference to `le32enc'
  • cperciva · 7 months ago
    If you edit config.h and take out the HAVE_SYS_ENDIAN_H line, does that unbreak the build?
  • royce · 7 months ago
    Yes, it now builds. Now getting the same error as da44en's Solaris 10 test:

    scrypt: Error reading clocks: Invalid argument
  • royce · 7 months ago
    Compiles and verifies fine on CentOS 4.7 i686:

    $ uname -a
    Linux vps.alpca.org 2.6.18-028stab060.8 #1 SMP Mon Feb 9 20:25:36 MSK 2009 i686 i686 i386 GNU/Linux
    $ cat /proc/version
    Linux version 2.6.18-028stab060.8 (root@rhel5-64-build) (gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)) #1 SMP Mon Feb 9 20:25:36 MSK 2009
    $ cat /etc/redhat-release
    CentOS release 4.7 (Final)
  • s0xxx · 7 months ago
    nbsd$ uname -rms
    NetBSD 5.0_STABLE i386

    nbsd$ ./configure
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... config.aux/install-sh -c -d
    checking for gawk... no
    checking for mawk... no
    checking for nawk... no
    checking for awk... awk
    checking whether make sets $(MAKE)... yes
    checking whether to enable maintainer-specific portions of Makefiles... no
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking for style of include used by make... GNU
    checking dependency style of gcc... gcc3
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking err.h usability... yes
    checking err.h presence... yes
    checking for err.h... yes
    checking sys/endian.h usability... yes
    checking sys/endian.h presence... yes
    checking for sys/endian.h... yes
    checking sys/sysinfo.h usability... no
    checking sys/sysinfo.h presence... no
    checking for sys/sysinfo.h... no
    checking for clock_gettime in -lrt... yes
    checking for clock_gettime... yes
    checking for sysinfo... no
    checking for posix_memalign... yes
    checking for struct sysinfo... no
    checking for struct sysinfo.mem_unit... no
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating config.h
    config.status: executing depfiles commands


    nbsd$ make
    make all-am
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
    mv -f .deps/main.Tpo .deps/main.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT scryptenc.o -MD -MP -MF .deps/scryptenc.Tpo -c -o scryptenc.o scryptenc.c
    mv -f .deps/scryptenc.Tpo .deps/scryptenc.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT crypto_aesctr.o -MD -MP -MF .deps/crypto_aesctr.Tpo -c -o crypto_aesctr.o crypto_aesctr.c
    mv -f .deps/crypto_aesctr.Tpo .deps/crypto_aesctr.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT sha256.o -MD -MP -MF .deps/sha256.Tpo -c -o sha256.o sha256.c
    mv -f .deps/sha256.Tpo .deps/sha256.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT memlimit.o -MD -MP -MF .deps/memlimit.Tpo -c -o memlimit.o memlimit.c
    mv -f .deps/memlimit.Tpo .deps/memlimit.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT warn.o -MD -MP -MF .deps/warn.Tpo -c -o warn.o warn.c
    mv -f .deps/warn.Tpo .deps/warn.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT scrypt_cpuperf.o -MD -MP -MF .deps/scrypt_cpuperf.Tpo -c -o scrypt_cpuperf.o scrypt_cpuperf.c
    mv -f .deps/scrypt_cpuperf.Tpo .deps/scrypt_cpuperf.Po
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT scrypt-nosse.o -MD -MP -MF .deps/scrypt-nosse.Tpo -c -o scrypt-nosse.o scrypt-nosse.c
    mv -f .deps/scrypt-nosse.Tpo .deps/scrypt-nosse.Po
    gcc -g -O2 -o scrypt main.o scryptenc.o crypto_aesctr.o sha256.o memlimit.o warn.o scrypt_cpuperf.o scrypt-nosse.o -lcrypto -lrt


    nbsd$ ./scrypt enc ./Toaster_NetBSD.jpg ./Toaster_NetBSD.jpg.enc
    Please enter passphrase:
    Please confirm passphrase:
    scrypt: Error reading clocks: Invalid argument
  • cperciva · 7 months ago
    Thanks! This looks like a rather difficult bug to figure out via the commenting system here -- could you send an email to me (cperciva@tarsnap.com)?
  • Marshall Pierce · 7 months ago
    Gentoo linux 2.6.27, gcc 4.3.2, glibc 2.8. Works succesfully.
  • akira · 7 months ago
    % set OS
    OS=Windows_NT

    % scrypt.exe
    usage: scrypt {enc | dec} [...] infile [outfile]

    i have sent colin the patch, lets see what goes into scrypt :)
  • Kenji Rikitake · 7 months ago
    Ubuntu 9.04, gcc 4.3.3. The scrypt was built and worked OK.

    uname -a
    Linux bluemax-ubuntu 2.6.28-12-server #43-Ubuntu SMP Fri May 1 20:28:32 UTC 2009 i686 GNU/Linux
    Intel(R) Core2 DuO CPU E6300 @ 1.86GHz stepping 06
  • royce · 7 months ago
    $ uname -a
    CYGWIN_NT-5.1 mycroft 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin

    $ ./scrypt enc scrypt.h scrypt.h.enc
    Please enter passphrase: Please confirm passphrase: scrypt: Error reading salt: No error

    I threw some fprintfs into getsalt(), and neither successes nor failures seem to be triggered, which makes me think that something other than getsalt() is returning 4 to scryptenc_file. Take that with a giant grain of salt, though; I know about two weeks' worth of C. :-)
  • cperciva · 7 months ago
    Does /dev/urandom exist on your Cygwin machine?
  • royce · 7 months ago
    Yep - I should have said as much.

    $ cat /dev/urandom | strings | head -1
    h>E73
  • akira · 7 months ago
    i will look into that issue asap. i had to rewrite several parts of the code to work on native win32/64, /dev/urandom was one "issue".

    colin, have my mails reached your spam folder?
  • cperciva · 7 months ago
    Yes, I received your emails -- sorry for not replying. I wanted to get the "easy" unix portability issues out of the way before I tackled the Windows issues.
  • Tim · 7 months ago
    Solaris 9: SunOS myrtle 5.9 Generic_122300-35 sun4u sparc SUNW,Sun-Fire-480R
    (whether you care about older versions of Solaris like this one is up to you :-)

    make[1]: Entering directory `/tmp/scrypt-1.1.2'
    gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
    main.c:27:20: error: stdint.h: No such file or directory
    make[1]: *** [main.o] Error 1
    make[1]: Leaving directory `/tmp/scrypt-1.1.2'
    make: *** [all] Error 2
  • cperciva · 7 months ago
    Yes, I'm aware of this problem, and at the moment I don't think I want to fix it. Solaris 9 is pretty old, and stdint.h is a required C99 header, so odds are that if Solaris 9 is missing that it will also miss lots of other important bits.

    That said, it's possible that if you install a newer (C99) compiler, it will bring a stdint.h implementation with it; so you might want to try that.