From: Ari Johnson Date: Tue, 20 Feb 2007 16:54:38 +0000 (+0000) Subject: SHS encryption should now work on 64-bit architectures that define uint32_t X-Git-Tag: 0.73~191 X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=037c40e1a19191211fbaf7d7d7f9fca0acb290df;p=cobramush.git SHS encryption should now work on 64-bit architectures that define uint32_t --- diff --git a/Configure b/Configure index 99b5497..651d05c 100644 --- a/Configure +++ b/Configure @@ -355,6 +355,7 @@ i_tcl='' d_textdomain='' d_timelocal='' d_toupper='' +d_uint32_t='' d_uptime='' d_urandom='' d_uwait3='' @@ -382,6 +383,7 @@ i_sysin='' i_nitcp='' i_setjmp='' i_stddef='' +i_stdint='' i_stdlib='' i_string='' strings='' @@ -5331,65 +5333,6 @@ EOM fi $rm -f test_toupper* core -: uptime -echo " " -if $test -x $uptime ; then - val="$define" -else - val="$undef" -fi -set d_uptime; eval $setvar - -: see if /dev/urandom is present -echo " " -if $test -c /dev/urandom ; then - val="$define" -else - val="$undef" -fi -set d_urandom; eval $setvar - -: see if union wait is available -echo " " -set X $cppflags -shift -flags='' -also='' -for f in $*; do - case "$f" in - *NO_PROTO*) ;; - *) flags="$flags $f";; - esac -done -xxx="`./findhdr sys/wait.h`" -case "x$xxx" in -x) xxx=/dev/null -esac -$cat "$xxx" | $cppstdin $flags $cppminus >wait.out 2>/dev/null -if $contains 'union.*wait.*{' wait.out >/dev/null 2>&1 ; then - echo "Looks like your knows about 'union wait'..." >&4 - val="$define" - also='also ' - if $contains 'extern.*wait[ ]*([ ]*int' wait.out >/dev/null 2>&1 - then - echo "But wait() seems to expect an 'int' pointer (POSIX way)." >&4 - val="$undef" - also='' - elif $contains 'extern.*wait[ ]*([ ]*union' wait.out >/dev/null 2>&1 - then - echo "And indeed wait() expects an 'union wait' pointer (BSD way)." >&4 - else - echo "So we'll use that for wait()." >&4 - fi -else - echo "No trace of 'union wait' in ..." >&4 - val="$undef" - echo "Your wait() should be happy with a plain 'int' pointer." >&4 -fi -set d_uwait -eval $setvar -$rm -f wait.out - : get C preprocessor symbols handy echo " " $echo $n "Hmm... $c" @@ -5497,6 +5440,117 @@ else fi $rm -f ccsym* +: see if this is a stdint system +val="$undef" +if $test "`./findhdr stdint.h`"; then + val="$define" + echo " found." >&4 +fi +echo " " +set i_stdint; eval $setvar +: see if we have uint32_t +echo "Let's try to figure out a really big double." >&4 +echo " " + $cat >d_uint32.c < +#$i_stdint I_STDINT +#ifdef I_STDINT +#include +#endif + +int main() +{ + uint32_t a; + a = 2*2*2*2; + a *= a; /* 2^8 */ + a *= a; /* 2^16 */ + a *= a; /* 2^32 */ + a += 1; /* 2^32 + 1 */ + if (a == 1) + printf("ok\n"); + else + printf("not ok\n"); +} +EOCP + +if $cc $ccflags $ldflags d_uint32.c -o d_uint32 $libs >/dev/null 2>&1; then + val=`./d_uint32` + if test $val = "ok" ; then + val="$define" + set d_uint32_t; eval $setvar + echo "You have uint32_t." >&4 + else + val="$undef" + set d_uint32_t; eval $setvar + echo "You don't have uint32_t, hope you're a 32 bit machine." >&4 + fi +else + val="$undef" + set d_uint32_t; eval $setvar + echo "I can't tell if you have uint32_t, hope you're a 32 bit machine." >&4 +fi + +$rm -f d_uint32* + +: uptime +echo " " +if $test -x $uptime ; then + val="$define" +else + val="$undef" +fi +set d_uptime; eval $setvar + +: see if /dev/urandom is present +echo " " +if $test -c /dev/urandom ; then + val="$define" +else + val="$undef" +fi +set d_urandom; eval $setvar + +: see if union wait is available +echo " " +set X $cppflags +shift +flags='' +also='' +for f in $*; do + case "$f" in + *NO_PROTO*) ;; + *) flags="$flags $f";; + esac +done +xxx="`./findhdr sys/wait.h`" +case "x$xxx" in +x) xxx=/dev/null +esac +$cat "$xxx" | $cppstdin $flags $cppminus >wait.out 2>/dev/null +if $contains 'union.*wait.*{' wait.out >/dev/null 2>&1 ; then + echo "Looks like your knows about 'union wait'..." >&4 + val="$define" + also='also ' + if $contains 'extern.*wait[ ]*([ ]*int' wait.out >/dev/null 2>&1 + then + echo "But wait() seems to expect an 'int' pointer (POSIX way)." >&4 + val="$undef" + also='' + elif $contains 'extern.*wait[ ]*([ ]*union' wait.out >/dev/null 2>&1 + then + echo "And indeed wait() expects an 'union wait' pointer (BSD way)." >&4 + else + echo "So we'll use that for wait()." >&4 + fi +else + echo "No trace of 'union wait' in ..." >&4 + val="$undef" + echo "Your wait() should be happy with a plain 'int' pointer." >&4 +fi +set d_uwait +eval $setvar +$rm -f wait.out + : see if this is a termio system val="$undef" val2="$undef" @@ -7018,6 +7072,7 @@ d_tcl='$d_tcl' d_textdomain='$d_textdomain' d_timelocal='$d_timelocal' d_toupper='$d_toupper' +d_uint32_t='$d_uint32_t' d_uptime='$d_uptime' d_urandom='$d_urandom' d_usgnames='$d_usgnames' @@ -7069,6 +7124,7 @@ i_setjmp='$i_setjmp' i_sgtty='$i_sgtty' i_stdarg='$i_stdarg' i_stddef='$i_stddef' +i_stdint='$i_stdint' i_stdlib='$i_stdlib' i_string='$i_string' i_syserrno='$i_syserrno' diff --git a/config_h.SH b/config_h.SH index 842a4db..203a07a 100644 --- a/config_h.SH +++ b/config_h.SH @@ -729,6 +729,11 @@ sed <config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$d_toupper HAS_SAFE_TOUPPER /**/ +/* HAS_UINT32_T: + * If defined, this system has the uint32_t type. + */ +#$d_uint32_t HAS_UINT32_T /**/ + /* UPTIME_PATH: * This symbol gives the full path to the uptime(1) program if * it exists on the system. If not, this symbol is undefined. @@ -807,6 +812,12 @@ sed <config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$i_setjmp I_SETJMP /**/ +/* I_STDINT: + * This symbol, if defined, indicates that the program should include + * . + */ +#$i_stdint I_STDINT /**/ + /* USE_TIOCNOTTY: * This symbol, if defined indicate to the C program that the ioctl() * call with TIOCNOTTY should be used to void tty association. diff --git a/hdrs/shs.h b/hdrs/shs.h index e9d3953..b350ff7 100644 --- a/hdrs/shs.h +++ b/hdrs/shs.h @@ -2,6 +2,9 @@ #define _SHS_H #include "config.h" +#ifdef I_STDINT +#include +#endif #include "confmagic.h" /* -------------- SHS.H --------------------------- */ @@ -15,8 +18,12 @@ typedef unsigned char BYTE; typedef long LONG; #else typedef unsigned char BYTE; +#ifdef HAS_UINT32_T +typedef uint32_t LONG; +#else typedef unsigned long LONG; #endif +#endif #define SHS_BLOCKSIZE 64