mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
How with some assembly support
This commit is contained in:
parent
a0196dfb18
commit
9479cf7e24
@ -1,6 +1,6 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = util mpi cipher tools g10
|
||||
SUBDIRS = scripts include util mpi cipher tools g10
|
||||
EXTRA_DIST =
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
SUBDIRS = util mpi cipher tools g10
|
||||
SUBDIRS = scripts include util mpi cipher tools g10
|
||||
EXTRA_DIST =
|
||||
ACCONFIG = acconfig.h
|
||||
CONFIG_HEADER_IN = config.h.in
|
||||
|
@ -5,6 +5,7 @@ INCLUDES = -I$(top_srcdir)/include
|
||||
noinst_LIBRARIES = cipher
|
||||
|
||||
|
||||
# please add "rsa.c" and "rsa.h" manually in Makefile.am
|
||||
cipher_SOURCES = blowfish.c \
|
||||
blowfish.h \
|
||||
elgamal.c \
|
||||
@ -15,12 +16,10 @@ cipher_SOURCES = blowfish.c \
|
||||
md5.h \
|
||||
primegen.c \
|
||||
random.c \
|
||||
ripemd.h \
|
||||
rmd.h \
|
||||
rmd160.c \
|
||||
rsa.c \
|
||||
rsa.h \
|
||||
smallprime.c
|
||||
|
||||
cipher_LIBADD = rsa.o
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@ INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
noinst_LIBRARIES = cipher
|
||||
|
||||
# please add "rsa.c" and "rsa.h" manually in Makefile.am
|
||||
cipher_SOURCES = blowfish.c \
|
||||
blowfish.h \
|
||||
elgamal.c \
|
||||
@ -52,12 +53,11 @@ cipher_SOURCES = blowfish.c \
|
||||
md5.h \
|
||||
primegen.c \
|
||||
random.c \
|
||||
ripemd.h \
|
||||
rmd.h \
|
||||
rmd160.c \
|
||||
rsa.c \
|
||||
rsa.h \
|
||||
smallprime.c
|
||||
|
||||
cipher_LIBADD = rsa.o
|
||||
mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
@ -76,9 +76,8 @@ LIBS = @LIBS@
|
||||
|
||||
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(CC) $(LDFLAGS) -o $@
|
||||
cipher_LIBADD =
|
||||
cipher_OBJECTS = blowfish.o elgamal.o gost.o md5.o primegen.o random.o \
|
||||
rmd160.o rsa.o smallprime.o
|
||||
rmd160.o smallprime.o
|
||||
EXTRA_cipher_SOURCES =
|
||||
LIBFILES = libcipher.a
|
||||
AR = ar
|
||||
@ -97,7 +96,7 @@ DEP_DISTFILES = $(DIST_COMMON) $(SOURCES) $(BUILT_SOURCES) $(HEADERS) \
|
||||
TAR = tar
|
||||
DEP_FILES = $(srcdir)/.deps/blowfish.P $(srcdir)/.deps/elgamal.P \
|
||||
$(srcdir)/.deps/gost.P $(srcdir)/.deps/md5.P $(srcdir)/.deps/primegen.P \
|
||||
$(srcdir)/.deps/random.P $(srcdir)/.deps/rmd160.P $(srcdir)/.deps/rsa.P \
|
||||
$(srcdir)/.deps/random.P $(srcdir)/.deps/rmd160.P \
|
||||
$(srcdir)/.deps/smallprime.P
|
||||
SOURCES = $(cipher_SOURCES)
|
||||
OBJECTS = $(cipher_OBJECTS)
|
||||
|
@ -43,6 +43,7 @@ randomize_buffer( byte *buffer, size_t length, int level )
|
||||
|
||||
if( level == 2 )
|
||||
level = 1; /* 2 is much too slow */
|
||||
/* FIXME: do a stat and check that we have the correct device numbers*/
|
||||
fp = fopen(level < 2? "/dev/urandom":"/dev/random", "r");
|
||||
if( !fp )
|
||||
log_fatal("can't open random device: %s\n", strerror(errno) );
|
||||
|
43
configure.in
43
configure.in
@ -21,6 +21,22 @@ if test "$enableval" = y || test "$enableval" = yes; then
|
||||
CFLAGS="-g"
|
||||
fi
|
||||
|
||||
dnl
|
||||
AC_CANONICAL_HOST
|
||||
AC_MSG_CHECKING(cached information)
|
||||
hostcheck="$host"
|
||||
AC_CACHE_VAL(ac_cv_mpi_hostcheck, [ ac_cv_mpi_hostcheck="$hostcheck" ])
|
||||
if test "$ac_cv_mpi_hostcheck" != "$hostcheck"; then
|
||||
AC_MSG_RESULT(changed)
|
||||
AC_MSG_WARN(config.cache exists!)
|
||||
AC_MSG_ERROR(you must do 'make distclean' first to compile for
|
||||
different host or different parameters.)
|
||||
else
|
||||
AC_MSG_RESULT(ok)
|
||||
fi
|
||||
|
||||
|
||||
|
||||
dnl Checks for programs.
|
||||
|
||||
AC_PROG_MAKE_SET
|
||||
@ -37,7 +53,11 @@ dnl Checks for libraries.
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(unistd.h)
|
||||
AC_CHECK_HEADERS(zlib.h)
|
||||
AC_CHECK_HEADERS(zlib.h,
|
||||
[LIBS="$LIBS -lz"],
|
||||
AC_MSG_WARN([zlib missing - creating without ZLIB support!])
|
||||
)
|
||||
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@ -48,7 +68,19 @@ dnl Checks for library functions.
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS(strerror strtol strtoul)
|
||||
|
||||
dnl
|
||||
|
||||
|
||||
dnl setup assembler stuff
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl checking wether we have the RSA source
|
||||
dnl fixme: I found no way (aside of using Makefile.am.in)
|
||||
dnl to add the requeired source int Makefile.am
|
||||
dnl I used: add_cipher_SOURCES="rsa.c rsa.h"
|
||||
dnl but of cource it can't work
|
||||
AC_MSG_CHECKING(wether we have the rsa source)
|
||||
if test -f cipher/rsa.c && test -f cipher/rsa.h; then
|
||||
AC_DEFINE(HAVE_RSA_CIPHER)
|
||||
@ -56,9 +88,12 @@ if test -f cipher/rsa.c && test -f cipher/rsa.h; then
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
AC_SUBST(add_cipher_SOURCES)
|
||||
|
||||
AC_OUTPUT([ Makefile util/Makefile mpi/Makefile cipher/Makefile \
|
||||
AC_OUTPUT([ Makefile scripts/Makefile util/Makefile mpi/Makefile \
|
||||
cipher/Makefile \
|
||||
include/Makefile \
|
||||
g10/Makefile tools/Makefile ],
|
||||
[echo timestamp > stamp-h ])
|
||||
[echo timestamp > stamp-h ] )
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ g10_SOURCES = g10.c \
|
||||
sig-check.c
|
||||
|
||||
|
||||
LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil -lz
|
||||
LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil
|
||||
|
||||
|
||||
$(PROGRAMS): ../cipher/libcipher.a ../mpi/libmpi.a
|
||||
|
@ -71,7 +71,7 @@ g10_SOURCES = g10.c \
|
||||
comment.c \
|
||||
sig-check.c
|
||||
|
||||
LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil -lz
|
||||
LDADD = -L ../cipher -L ../mpi -L ../util -lcipher -lmpi -lutil
|
||||
mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_ZLIB_H
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#error You need ZLIB to compile this module
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
@ -38,6 +36,7 @@
|
||||
#include "options.h"
|
||||
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
static void
|
||||
init_compress( compress_filter_context_t *zfx, z_stream *zs )
|
||||
{
|
||||
@ -163,7 +162,6 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs,
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
compress_filter( void *opaque, int control,
|
||||
IOBUF a, byte *buf, size_t *ret_len)
|
||||
@ -228,6 +226,35 @@ compress_filter( void *opaque, int control,
|
||||
*(char**)buf = "compress_filter";
|
||||
return rc;
|
||||
}
|
||||
#else /* No ZLIB */
|
||||
int
|
||||
compress_filter( void *opaque, int control,
|
||||
IOBUF a, byte *buf, size_t *ret_len)
|
||||
{
|
||||
size_t size = *ret_len;
|
||||
compress_filter_context_t *zfx = opaque;
|
||||
int c, rc=0;
|
||||
size_t n;
|
||||
|
||||
if( control == IOBUFCTRL_UNDERFLOW ) {
|
||||
for( n=0; n < size; n++ ) {
|
||||
if( (c=iobuf_get(a)) == -1 )
|
||||
break;
|
||||
buf[n] = c & 0xff;
|
||||
}
|
||||
if( !n )
|
||||
rc = -1;
|
||||
*ret_len = n;
|
||||
}
|
||||
else if( control == IOBUFCTRL_FLUSH ) {
|
||||
if( iobuf_write( a, buf, size ) )
|
||||
rc = G10ERR_WRITE_FILE;
|
||||
}
|
||||
else if( control == IOBUFCTRL_DESC )
|
||||
*(char**)buf = "dummy compress_filter";
|
||||
return rc;
|
||||
}
|
||||
#endif /*no ZLIB*/
|
||||
|
||||
/****************
|
||||
* Handle a compressed packet
|
||||
|
@ -251,6 +251,7 @@ encode_crypt( const char *filename, STRLIST remusr )
|
||||
m_free(ustr);
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_RSA_CIPHER
|
||||
else if( enc->pubkey_algo == PUBKEY_ALGO_RSA ) {
|
||||
RSA_public_key pkey;
|
||||
|
||||
@ -270,6 +271,7 @@ encode_crypt( const char *filename, STRLIST remusr )
|
||||
m_free(ustr);
|
||||
}
|
||||
}
|
||||
#endif/*HAVE_RSA_CIPHER*/
|
||||
else {
|
||||
last_rc = rc = G10ERR_PUBKEY_ALGO;
|
||||
log_error("skipped '%s': %s\n", remusr->d, g10_errstr(rc) );
|
||||
|
71
g10/g10.c
71
g10/g10.c
@ -33,6 +33,7 @@
|
||||
#include "cipher.h"
|
||||
#include "filter.h"
|
||||
|
||||
static void do_test(void);
|
||||
|
||||
const char *
|
||||
strusage( int level )
|
||||
@ -41,7 +42,7 @@ strusage( int level )
|
||||
switch( level ) {
|
||||
case 10:
|
||||
case 0: p = "g10 - v" VERSION "; "
|
||||
"Copyright 1997 Werner Koch (dd9jn)" ; break;
|
||||
"Copyright 1997 Werner Koch (dd9jn)\n" ; break;
|
||||
case 13: p = "g10"; break;
|
||||
case 14: p = VERSION; break;
|
||||
case 1:
|
||||
@ -49,18 +50,25 @@ strusage( int level )
|
||||
break;
|
||||
case 2:
|
||||
case 12: p =
|
||||
"\nSyntax: g10 [options] [files]\n"
|
||||
"Syntax: g10 [options] [files]\n"
|
||||
"sign, check, encrypt or decrypt\n"
|
||||
"default operation depends on the input data\n"
|
||||
"default operation depends on the input data\n"; break;
|
||||
|
||||
case 26:
|
||||
p = "Please report bugs to <g10-bugs@isil.d.shuttle.de>.\n";
|
||||
break;
|
||||
|
||||
case 30: p = ""
|
||||
#ifndef HAVE_ZLIB_H
|
||||
" NOTE: This version is compiled without ZLIB support;\n"
|
||||
" you are not able to process compresssed data!\n"
|
||||
#endif
|
||||
#ifdef HAVE_RSA_CIPHER
|
||||
"WARNING: This version has RSA support! Your are not allowed to\n"
|
||||
" use it inside the Unites States until Sep 30, 2000!\n"
|
||||
#endif
|
||||
;
|
||||
break;
|
||||
case 26:
|
||||
p = "Please report bugs to <g10-bugs@isil.d.shuttle.de>.\n";
|
||||
break;
|
||||
default: p = default_strusage(level);
|
||||
}
|
||||
return p;
|
||||
@ -96,7 +104,7 @@ main( int argc, char **argv )
|
||||
{ 'o', "output", 2, "use as output file" },
|
||||
{ 501, "yes", 0, "assume yes on most questions"},
|
||||
{ 502, "no", 0, "assume no on most questions"},
|
||||
{ 503, "make-key", 0, "generate a new key pair" },
|
||||
{ 503, "gen-key", 0, "generate a new key pair" },
|
||||
{ 504, "add-key", 0, "add key to the public keyring" },
|
||||
{ 505, "delete-key",0, "remove key from public keyring" },
|
||||
{ 506, "sign-key" ,0, "make a signature on a key in the keyring" },
|
||||
@ -112,18 +120,20 @@ main( int argc, char **argv )
|
||||
{ 510, "debug" ,4|16, "set debugging flags" },
|
||||
{ 511, "debug-all" ,0, "enable full debugging"},
|
||||
{ 512, "cache-all" ,0, "hold everything in memory"},
|
||||
{ 513, "gen-prime" , 1, "generate a prime of length n" },
|
||||
{ 514, "gen-key" , 0, "generate a key pair" },
|
||||
{ 513, "gen-prime" , 1, "\rgenerate a prime of length n" },
|
||||
{ 514, "test" , 0, "\rdevelopment usage" },
|
||||
{0} };
|
||||
ARGPARSE_ARGS pargs = { &argc, &argv, 0 };
|
||||
IOBUF a;
|
||||
int rc;
|
||||
enum { aNull, aSym, aStore, aEncr, aPrimegen, aKeygen, aSign, aSignEncr,
|
||||
aTest,
|
||||
} action = aNull;
|
||||
const char *fname, *fname_print;
|
||||
STRLIST sl, remusr= NULL, locusr=NULL;
|
||||
int nrings=0;
|
||||
armor_filter_context_t afx;
|
||||
const char *s;
|
||||
|
||||
opt.compress = -1; /* defaults to default compression level */
|
||||
while( arg_parse( &pargs, opts) ) {
|
||||
@ -155,6 +165,7 @@ main( int argc, char **argv )
|
||||
break;
|
||||
case 501: opt.answer_yes = 1; break;
|
||||
case 502: opt.answer_no = 1; break;
|
||||
case 503: action = aKeygen; break;
|
||||
case 507: action = aStore; break;
|
||||
case 508: opt.check_sigs = 1; break;
|
||||
case 509: add_keyring(pargs.r.ret_str); nrings++; break;
|
||||
@ -162,13 +173,18 @@ main( int argc, char **argv )
|
||||
case 511: opt.debug = ~0; break;
|
||||
case 512: opt.cache_all = 1; break;
|
||||
case 513: action = aPrimegen; break;
|
||||
case 514: action = aKeygen; break;
|
||||
case 514: action = aTest; break;
|
||||
default : pargs.err = 2; break;
|
||||
}
|
||||
}
|
||||
set_debug();
|
||||
if( opt.verbose > 1 )
|
||||
set_packet_list_mode(1);
|
||||
if( !opt.batch && *(s=strusage(10)) )
|
||||
fputs(s, stderr);
|
||||
if( !opt.batch && *(s=strusage(30)) )
|
||||
fputs(s, stderr);
|
||||
|
||||
|
||||
if( !nrings ) { /* add default rings */
|
||||
add_keyring("../keys/ring.pgp");
|
||||
@ -230,6 +246,8 @@ main( int argc, char **argv )
|
||||
generate_keypair();
|
||||
break;
|
||||
|
||||
case aTest: do_test(); break;
|
||||
|
||||
default:
|
||||
if( argc > 1 )
|
||||
usage(1);
|
||||
@ -250,3 +268,36 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
do_test()
|
||||
{
|
||||
MPI t = mpi_alloc( 50 );
|
||||
MPI m = mpi_alloc( 50 );
|
||||
MPI a = mpi_alloc( 50 );
|
||||
MPI b = mpi_alloc( 50 );
|
||||
MPI p = mpi_alloc( 50 );
|
||||
MPI x = mpi_alloc( 50 );
|
||||
mpi_fromstr(a, "0xef45678343589854354a4545545454554545455"
|
||||
"aaaaaaaaaaaaa44444fffdecb33434343443331" );
|
||||
mpi_fromstr(b, "0x8765765589854354a4545545454554545455"
|
||||
"aaaaaaa466577778decb36666343443331" );
|
||||
mpi_fromstr(p, "0xcccddd456700000012222222222222254545455"
|
||||
"aaaaaaaaaaaaa44444fffdecb33434343443337" );
|
||||
mpi_fromstr(x, "0x100004545543656456656545545454554545455"
|
||||
"aaa33aaaa465456544fffdecb33434bbbac3331" );
|
||||
|
||||
/* output = b/(a^x) mod p */
|
||||
log_debug("powm ..\n");
|
||||
mpi_powm( t, a, x, p );
|
||||
log_debug("invm ..\n");
|
||||
mpi_invm( t, t, p );
|
||||
log_debug("mulm ..\n");
|
||||
mpi_mulm( m, b, t, p );
|
||||
|
||||
|
||||
m_check(NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
326
g10/mainproc.c
326
g10/mainproc.c
@ -33,7 +33,331 @@
|
||||
#include "main.h"
|
||||
|
||||
static int opt_list=1; /* and list the data packets to stdout */
|
||||
#if 0
|
||||
static void
|
||||
do_free_last_user_id( CTX c )
|
||||
{
|
||||
if( c->last_user_id ) {
|
||||
free_user_id( c->last_user_id );
|
||||
c->last_user_id = NULL;
|
||||
}
|
||||
}
|
||||
static void
|
||||
do_free_last_pubkey( CTX c )
|
||||
{
|
||||
if( c->last_pubkey ) {
|
||||
free_pubkey_cert( c->last_pubkey );
|
||||
c->last_pubkey = NULL;
|
||||
}
|
||||
}
|
||||
static void
|
||||
do_free_last_seckey( CTX c )
|
||||
{
|
||||
if( c->last_seckey ) {
|
||||
free_seckey_cert( c->last_seckey );
|
||||
c->last_seckey = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
proc_pubkey_cert( CTX c, PACKET *pkt )
|
||||
{
|
||||
do_free_last_user_id( c );
|
||||
do_free_last_seckey( c );
|
||||
if( opt.check_sigs ) {
|
||||
char *ustr = get_user_id_string(sig->keyid); /* sig ???? */
|
||||
printstr(lvl0, "pub: %s\n", ustr );
|
||||
m_free(ustr);
|
||||
}
|
||||
else
|
||||
fputs( "pub: [Public Key Cerificate]\n", stdout );
|
||||
c->last_pubkey = pkt->pkt.pubkey_cert;
|
||||
pkt->pkt.pubkey_cert = NULL;
|
||||
free_packet(pkt);
|
||||
pkt->pkc_parent = c->last_pubkey; /* set this as parent */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
proc_seckey_cert( CTX c, PACKET *pkt )
|
||||
{
|
||||
int rc;
|
||||
|
||||
do_free_last_user_id( c );
|
||||
do_free_last_pubkey( c );
|
||||
if( opt_list )
|
||||
fputs( "sec: (secret key certificate)\n", stdout );
|
||||
rc = check_secret_key( pkt->pkt.seckey_cert );
|
||||
if( opt_list ) {
|
||||
if( !rc )
|
||||
fputs( " Secret key is good", stdout );
|
||||
else
|
||||
fputs( g10_errstr(rc), stdout);
|
||||
putchar('\n');
|
||||
}
|
||||
else if( rc )
|
||||
log_error("secret key certificate error: %s\n", g10_errstr(rc));
|
||||
c->last_seckey = pkt->pkt.seckey_cert;
|
||||
pkt->pkt.seckey_cert = NULL;
|
||||
free_packet(pkt);
|
||||
pkt->skc_parent = c->last_seckey; /* set this as parent */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
proc_packets( IOBUF a )
|
||||
{
|
||||
PACKET *pkt;
|
||||
PKT_pubkey_cert *last_pubkey = NULL;
|
||||
PKT_seckey_cert *last_seckey = NULL;
|
||||
PKT_user_id *last_user_id = NULL;
|
||||
DEK *dek = NULL;
|
||||
PKT_signature *sig; /* CHECK: "might be used uninitialied" */
|
||||
int rc, result;
|
||||
MD_HANDLE md_handle; /* union to pass handles */
|
||||
char *ustr;
|
||||
int lvl0, lvl1;
|
||||
int last_was_pubkey_enc = 0;
|
||||
u32 keyid[2];
|
||||
md_filter_context_t mfx;
|
||||
|
||||
memset( &mfx, 0, sizeof mfx );
|
||||
lvl0 = opt.check_sigs? 1:0; /* stdout or /dev/null */
|
||||
lvl1 = opt.check_sigs? 1:3; /* stdout or error */
|
||||
pkt = m_alloc( sizeof *pkt );
|
||||
init_packet(pkt);
|
||||
while( (rc=parse_packet(a, pkt)) != -1 ) {
|
||||
/* cleanup if we have an illegal data structure */
|
||||
if( dek && pkt->pkttype != PKT_ENCR_DATA ) {
|
||||
log_error("oops: valid pubkey enc packet not followed by data\n");
|
||||
m_free(dek); dek = NULL; /* burn it */
|
||||
}
|
||||
|
||||
if( rc ) {
|
||||
free_packet(pkt);
|
||||
continue;
|
||||
}
|
||||
switch( pkt->pkttype ) {
|
||||
case PKT_PUBKEY_CERT: proc_pubkey_cert( c, pkt ); break;
|
||||
case PKT_SECKEY_CERT: proc_seckey_cert( c, pkt ); break;
|
||||
case PKT_USER_ID:
|
||||
if( last_user_id ) {
|
||||
free_user_id( last_user_id );
|
||||
last_user_id = NULL;
|
||||
}
|
||||
if( opt_list ) {
|
||||
printf("uid: '%.*s'\n", pkt->pkt.user_id->len,
|
||||
pkt->pkt.user_id->name );
|
||||
if( !pkt->pkc_parent && !pkt->skc_parent )
|
||||
puts(" (orphaned)");
|
||||
}
|
||||
if( pkt->pkc_parent ) {
|
||||
if( pkt->pkc_parent->pubkey_algo == PUBKEY_ALGO_ELGAMAL
|
||||
|| pkt->pkc_parent->pubkey_algo == PUBKEY_ALGO_RSA ) {
|
||||
keyid_from_pkc( pkt->pkc_parent, keyid );
|
||||
cache_user_id( pkt->pkt.user_id, keyid );
|
||||
}
|
||||
}
|
||||
|
||||
last_user_id = pkt->pkt.user_id; /* save */
|
||||
pkt->pkt.user_id = NULL;
|
||||
free_packet(pkt); /* fixme: free_packet is not a good name */
|
||||
pkt->user_parent = last_user_id; /* and set this as user */
|
||||
break;
|
||||
|
||||
case PKT_SIGNATURE:
|
||||
sig = pkt->pkt.signature;
|
||||
ustr = get_user_id_string(sig->keyid);
|
||||
result = -1;
|
||||
if( sig->sig_class == 0x00 ) {
|
||||
if( mfx.rmd160 )
|
||||
result = 0;
|
||||
else
|
||||
printstr(lvl1,"sig?: %s: no plaintext for signature\n",
|
||||
ustr);
|
||||
}
|
||||
else if( sig->sig_class != 0x10 )
|
||||
printstr(lvl1,"sig?: %s: unknown signature class %02x\n",
|
||||
ustr, sig->sig_class);
|
||||
else if( !pkt->pkc_parent || !pkt->user_parent )
|
||||
printstr(lvl1,"sig?: %s: orphaned encoded packet\n", ustr);
|
||||
else
|
||||
result = 0;
|
||||
|
||||
if( result )
|
||||
;
|
||||
else if( !opt.check_sigs && sig->sig_class != 0x00 ) {
|
||||
result = -1;
|
||||
printstr(lvl0, "sig: from %s\n", ustr );
|
||||
}
|
||||
else if(sig->pubkey_algo == PUBKEY_ALGO_ELGAMAL ) {
|
||||
md_handle.algo = sig->d.elg.digest_algo;
|
||||
if( sig->d.elg.digest_algo == DIGEST_ALGO_RMD160 ) {
|
||||
if( sig->sig_class == 0x00 )
|
||||
md_handle.u.rmd = rmd160_copy( mfx.rmd160 );
|
||||
else {
|
||||
md_handle.u.rmd = rmd160_copy(pkt->pkc_parent->mfx.rmd160);
|
||||
rmd160_write(md_handle.u.rmd, pkt->user_parent->name,
|
||||
pkt->user_parent->len);
|
||||
}
|
||||
result = signature_check( sig, md_handle );
|
||||
rmd160_close(md_handle.u.rmd);
|
||||
}
|
||||
else if( sig->d.elg.digest_algo == DIGEST_ALGO_MD5
|
||||
&& sig->sig_class != 0x00 ) {
|
||||
md_handle.u.md5 = md5_copy(pkt->pkc_parent->mfx.md5);
|
||||
md5_write(md_handle.u.md5, pkt->user_parent->name,
|
||||
pkt->user_parent->len);
|
||||
result = signature_check( sig, md_handle );
|
||||
md5_close(md_handle.u.md5);
|
||||
}
|
||||
else
|
||||
result = G10ERR_DIGEST_ALGO;
|
||||
}
|
||||
else if(sig->pubkey_algo == PUBKEY_ALGO_RSA ) {
|
||||
md_handle.algo = sig->d.rsa.digest_algo;
|
||||
if( sig->d.rsa.digest_algo == DIGEST_ALGO_RMD160 ) {
|
||||
if( sig->sig_class == 0x00 )
|
||||
md_handle.u.rmd = rmd160_copy( mfx.rmd160 );
|
||||
else {
|
||||
md_handle.u.rmd = rmd160_copy(pkt->pkc_parent->mfx.rmd160);
|
||||
rmd160_write(md_handle.u.rmd, pkt->user_parent->name,
|
||||
pkt->user_parent->len);
|
||||
}
|
||||
result = signature_check( sig, md_handle );
|
||||
rmd160_close(md_handle.u.rmd);
|
||||
}
|
||||
else if( sig->d.rsa.digest_algo == DIGEST_ALGO_MD5
|
||||
&& sig->sig_class != 0x00 ) {
|
||||
md_handle.u.md5 = md5_copy(pkt->pkc_parent->mfx.md5);
|
||||
md5_write(md_handle.u.md5, pkt->user_parent->name,
|
||||
pkt->user_parent->len);
|
||||
result = signature_check( sig, md_handle );
|
||||
md5_close(md_handle.u.md5);
|
||||
}
|
||||
else
|
||||
result = G10ERR_DIGEST_ALGO;
|
||||
}
|
||||
else
|
||||
result = G10ERR_PUBKEY_ALGO;
|
||||
|
||||
if( result == -1 )
|
||||
;
|
||||
else if( !result && sig->sig_class == 0x00 )
|
||||
printstr(1, "sig: good signature from %s\n", ustr );
|
||||
else if( !result )
|
||||
printstr(lvl0, "sig: good signature from %s\n", ustr );
|
||||
else
|
||||
printstr(lvl1, "sig? %s: %s\n", ustr, g10_errstr(result));
|
||||
free_packet(pkt);
|
||||
m_free(ustr);
|
||||
break;
|
||||
|
||||
case PKT_PUBKEY_ENC:
|
||||
PKT_pubkey_enc *enc;
|
||||
|
||||
last_was_pubkey_enc = 1;
|
||||
result = 0;
|
||||
enc = pkt->pkt.pubkey_enc;
|
||||
printf("enc: encrypted by a pubkey with keyid %08lX\n",
|
||||
enc->keyid[1] );
|
||||
if( enc->pubkey_algo == PUBKEY_ALGO_ELGAMAL
|
||||
|| enc->pubkey_algo == PUBKEY_ALGO_RSA ) {
|
||||
m_free(dek ); /* paranoid: delete a pending DEK */
|
||||
dek = m_alloc_secure( sizeof *dek );
|
||||
if( (result = get_session_key( enc, dek )) ) {
|
||||
/* error: delete the DEK */
|
||||
m_free(dek); dek = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
result = G10ERR_PUBKEY_ALGO;
|
||||
|
||||
if( result == -1 )
|
||||
;
|
||||
else if( !result )
|
||||
fputs( " DEK is good", stdout );
|
||||
else
|
||||
printf( " %s", g10_errstr(result));
|
||||
putchar('\n');
|
||||
free_packet(pkt);
|
||||
break;
|
||||
|
||||
case PKT_ENCR_DATA:
|
||||
result = 0;
|
||||
printf("dat: %sencrypted data\n", dek?"":"conventional ");
|
||||
if( !dek && !last_was_pubkey_enc ) {
|
||||
/* assume this is conventional encrypted data */
|
||||
dek = m_alloc_secure( sizeof *dek );
|
||||
dek->algo = DEFAULT_CIPHER_ALGO;
|
||||
result = make_dek_from_passphrase( dek, 0 );
|
||||
}
|
||||
else if( !dek )
|
||||
result = G10ERR_NO_SECKEY;
|
||||
if( !result )
|
||||
result = decrypt_data( pkt->pkt.encr_data, dek );
|
||||
m_free(dek); dek = NULL;
|
||||
if( result == -1 )
|
||||
;
|
||||
else if( !result )
|
||||
fputs( " encryption okay",stdout);
|
||||
else
|
||||
printf( " %s", g10_errstr(result));
|
||||
putchar('\n');
|
||||
free_packet(pkt);
|
||||
last_was_pubkey_enc = 0;
|
||||
break;
|
||||
|
||||
case PKT_PLAINTEXT:
|
||||
PKT_plaintext *pt = pkt->pkt.plaintext;
|
||||
printf("txt: plain text data name='%.*s'\n", pt->namelen, pt->name);
|
||||
free_md_filter_context( &mfx );
|
||||
mfx.rmd160 = rmd160_open(0);
|
||||
result = handle_plaintext( pt, &mfx );
|
||||
if( !result )
|
||||
fputs( " okay",stdout);
|
||||
else
|
||||
printf( " %s", g10_errstr(result));
|
||||
putchar('\n');
|
||||
free_packet(pkt);
|
||||
last_was_pubkey_enc = 0;
|
||||
break;
|
||||
|
||||
case PKT_COMPR_DATA:
|
||||
PKT_compressed *zd = pkt->pkt.compressed;
|
||||
printf("zip: compressed data packet\n");
|
||||
result = handle_compressed( zd );
|
||||
if( !result )
|
||||
fputs( " okay",stdout);
|
||||
else
|
||||
printf( " %s", g10_errstr(result));
|
||||
putchar('\n');
|
||||
free_packet(pkt);
|
||||
last_was_pubkey_enc = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
free_packet(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
if( last_user_id )
|
||||
free_user_id( last_user_id );
|
||||
if( last_seckey )
|
||||
free_seckey_cert( last_seckey );
|
||||
if( last_pubkey )
|
||||
free_pubkey_cert( last_pubkey );
|
||||
m_free(dek);
|
||||
free_packet( pkt );
|
||||
m_free( pkt );
|
||||
free_md_filter_context( &mfx );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* old */
|
||||
int
|
||||
proc_packets( IOBUF a )
|
||||
{
|
||||
@ -317,5 +641,5 @@ proc_packets( IOBUF a )
|
||||
free_md_filter_context( &mfx );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -61,6 +61,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
|
||||
elg_decipher( dek_frame, k->d.elg.a, k->d.elg.b, &skey );
|
||||
memset( &skey, 0, sizeof skey );
|
||||
}
|
||||
#ifdef HAVE_RSA_CIPHER
|
||||
else if( k->pubkey_algo == PUBKEY_ALGO_RSA ) {
|
||||
RSA_secret_key skey;
|
||||
|
||||
@ -76,6 +77,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
|
||||
rsa_secret( dek_frame, k->d.rsa.rsa_integer, &skey );
|
||||
memset( &skey, 0, sizeof skey );
|
||||
}
|
||||
#endif/*HAVE_RSA_CIPHER*/
|
||||
else {
|
||||
rc = G10ERR_PUBKEY_ALGO; /* unsupported algorithm */
|
||||
goto leave;
|
||||
|
@ -66,7 +66,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
|
||||
dp = rmd160_final( digest.u.rmd );
|
||||
result = encode_rmd160_value( dp, 20, mpi_get_nbits(pkc->d.elg.p));
|
||||
}
|
||||
else if( sig->d.rsa.digest_algo == DIGEST_ALGO_MD5 ) {
|
||||
else if( sig->d.elg.digest_algo == DIGEST_ALGO_MD5 ) {
|
||||
md5_putchar( digest.u.md5, sig->sig_class );
|
||||
{ u32 a = sig->timestamp;
|
||||
md5_putchar( digest.u.md5, (a >> 24) & 0xff );
|
||||
@ -89,6 +89,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
|
||||
if( !elg_verify( sig->d.elg.a, sig->d.elg.b, result, &pkey ) )
|
||||
rc = G10ERR_BAD_SIGN;
|
||||
}
|
||||
#ifdef HAVE_RSA_CIPHER
|
||||
else if( pkc->pubkey_algo == PUBKEY_ALGO_RSA ) {
|
||||
RSA_public_key pkey;
|
||||
|
||||
@ -214,6 +215,7 @@ signature_check( PKT_signature *sig, MD_HANDLE digest )
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
#endif/*HAVE_RSA_CIPHER*/
|
||||
else {
|
||||
log_debug("signature_check: unsupported pubkey algo %d\n",
|
||||
pkc->pubkey_algo );
|
||||
|
5
include/Makefile.am
Normal file
5
include/Makefile.am
Normal file
@ -0,0 +1,5 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = cipher.h errors.h iobuf.h memory.h mpi.h ttyio.h types.h \
|
||||
util.h
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* mpi.h - Multi Precision Integers
|
||||
* Copyright (c) 1997 by Werner Koch (dd9jn)
|
||||
* Copyright (C) 1994, 1996 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of G10.
|
||||
*
|
||||
@ -16,6 +17,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* Note: This code is heavily based on the GNU MP Library.
|
||||
* Actually it's the same code with only minor changes in the
|
||||
* way the data is stored; this is to support the abstraction
|
||||
* of an optional secure memory allocation which may be used
|
||||
* to avoid revealing of sensitive data due to paging etc.
|
||||
* The GNU MP Library itself is published under the LGPL;
|
||||
* however I decided to publish this code under the plain GPL.
|
||||
*/
|
||||
|
||||
#ifndef G10_MPI_H
|
||||
|
@ -3,8 +3,10 @@
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
CFLAGS += -O2
|
||||
|
||||
noinst_LIBRARIES = mpi
|
||||
SUFFIXES = .S .s
|
||||
|
||||
noinst_LIBRARIES = mpi
|
||||
noinst_HEADERS = sysdep.h
|
||||
|
||||
mpi_SOURCES = longlong.h \
|
||||
mpi-add.c \
|
||||
@ -19,18 +21,28 @@ mpi_SOURCES = longlong.h \
|
||||
mpi-pow.c \
|
||||
mpi-scan.c \
|
||||
mpicoder.c \
|
||||
mpih-add.c \
|
||||
mpih-cmp.c \
|
||||
mpih-add.c \
|
||||
mpih-sub.c \
|
||||
mpih-div.c \
|
||||
mpih-mul.c \
|
||||
mpih-shift.c \
|
||||
mpih-sub.c \
|
||||
mpih-mul1.S \
|
||||
mpih-mul2.S \
|
||||
mpih-add1.S \
|
||||
mpih-mul3.S \
|
||||
mpih-sub1.S \
|
||||
mpih-shift.S \
|
||||
mpih-add.S \
|
||||
mpiutil.c
|
||||
|
||||
mpi_LIBADD = mpih-mul1.o \
|
||||
mpih-mul2.o \
|
||||
mpih-mul3.o \
|
||||
mpih-add1.o \
|
||||
mpih-sub1.o \
|
||||
mpih-shift.o
|
||||
|
||||
#mpi_DEPENDENCIES = mpih-mul1.S \
|
||||
# mpih-mul2.S \
|
||||
# mpih-mul3.S \
|
||||
# mpih-add1.S \
|
||||
# mpih-sub1.S \
|
||||
# mpih-shift.S
|
||||
#
|
||||
|
||||
##DISTCLEANFILES = @MPI_DISTCLEANFILES@
|
||||
|
||||
|
||||
|
@ -40,27 +40,37 @@ transform = @program_transform_name@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
noinst_LIBRARIES = mpi
|
||||
SUFFIXES = .S .s
|
||||
|
||||
mpi_SOURCES = longlong.h \
|
||||
mpi-add.c \
|
||||
mpi-bit.c \
|
||||
mpi-cmp.c \
|
||||
mpi-div.c \
|
||||
mpi-gcd.c \
|
||||
mpi-internal.h \
|
||||
mpi-inv.c \
|
||||
mpi-mul.c \
|
||||
mpi-pow.c \
|
||||
mpi-scan.c \
|
||||
mpicoder.c \
|
||||
mpihelp-add.c \
|
||||
mpihelp-cmp.c \
|
||||
mpihelp-div.c \
|
||||
mpihelp-mul.c \
|
||||
mpihelp-shift.c \
|
||||
mpihelp-sub.c \
|
||||
noinst_LIBRARIES = mpi
|
||||
noinst_HEADERS = sysdep.h
|
||||
|
||||
mpi_SOURCES = longlong.h \
|
||||
mpi-add.c \
|
||||
mpi-bit.c \
|
||||
mpi-cmp.c \
|
||||
mpi-div.c \
|
||||
mpi-gcd.c \
|
||||
mpi-internal.h \
|
||||
mpi-inline.h \
|
||||
mpi-inv.c \
|
||||
mpi-mul.c \
|
||||
mpi-pow.c \
|
||||
mpi-scan.c \
|
||||
mpicoder.c \
|
||||
mpih-cmp.c \
|
||||
mpih-add.c \
|
||||
mpih-sub.c \
|
||||
mpih-div.c \
|
||||
mpih-mul.c \
|
||||
mpiutil.c
|
||||
|
||||
mpi_LIBADD = mpih-mul1.o \
|
||||
mpih-mul2.o \
|
||||
mpih-mul3.o \
|
||||
mpih-add1.o \
|
||||
mpih-sub1.o \
|
||||
mpih-shift.o
|
||||
mkinstalldirs = $(top_srcdir)/scripts/mkinstalldirs
|
||||
CONFIG_HEADER = ../config.h
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
@ -79,15 +89,15 @@ LIBS = @LIBS@
|
||||
|
||||
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
|
||||
LINK = $(CC) $(LDFLAGS) -o $@
|
||||
mpi_LIBADD =
|
||||
mpi_OBJECTS = mpi-add.o mpi-bit.o mpi-cmp.o mpi-div.o mpi-gcd.o \
|
||||
mpi-inv.o mpi-mul.o mpi-pow.o mpi-scan.o mpicoder.o mpihelp-add.o \
|
||||
mpihelp-cmp.o mpihelp-div.o mpihelp-mul.o mpihelp-shift.o mpihelp-sub.o \
|
||||
mpiutil.o
|
||||
mpi-inv.o mpi-mul.o mpi-pow.o mpi-scan.o mpicoder.o mpih-cmp.o \
|
||||
mpih-add.o mpih-sub.o mpih-div.o mpih-mul.o mpiutil.o
|
||||
EXTRA_mpi_SOURCES =
|
||||
LIBFILES = libmpi.a
|
||||
AR = ar
|
||||
RANLIB = @RANLIB@
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
|
||||
@ -105,10 +115,9 @@ $(srcdir)/.deps/mpi-cmp.P $(srcdir)/.deps/mpi-div.P \
|
||||
$(srcdir)/.deps/mpi-gcd.P $(srcdir)/.deps/mpi-inv.P \
|
||||
$(srcdir)/.deps/mpi-mul.P $(srcdir)/.deps/mpi-pow.P \
|
||||
$(srcdir)/.deps/mpi-scan.P $(srcdir)/.deps/mpicoder.P \
|
||||
$(srcdir)/.deps/mpihelp-add.P $(srcdir)/.deps/mpihelp-cmp.P \
|
||||
$(srcdir)/.deps/mpihelp-div.P $(srcdir)/.deps/mpihelp-mul.P \
|
||||
$(srcdir)/.deps/mpihelp-shift.P $(srcdir)/.deps/mpihelp-sub.P \
|
||||
$(srcdir)/.deps/mpiutil.P
|
||||
$(srcdir)/.deps/mpih-add.P $(srcdir)/.deps/mpih-cmp.P \
|
||||
$(srcdir)/.deps/mpih-div.P $(srcdir)/.deps/mpih-mul.P \
|
||||
$(srcdir)/.deps/mpih-sub.P $(srcdir)/.deps/mpiutil.P
|
||||
SOURCES = $(mpi_SOURCES)
|
||||
OBJECTS = $(mpi_OBJECTS)
|
||||
|
||||
@ -218,7 +227,7 @@ install: install-exec install-data all
|
||||
|
||||
uninstall:
|
||||
|
||||
all: $(LIBFILES) Makefile
|
||||
all: $(LIBFILES) $(HEADERS) Makefile
|
||||
|
||||
install-strip:
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
@ -263,8 +272,17 @@ install-exec install-data install uninstall all installdirs \
|
||||
mostlyclean-generic distclean-generic clean-generic \
|
||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
||||
|
||||
CFLAGS += -O2
|
||||
|
||||
#mpi_DEPENDENCIES = mpih-mul1.S \
|
||||
# mpih-mul2.S \
|
||||
# mpih-mul3.S \
|
||||
# mpih-add1.S \
|
||||
# mpih-sub1.S \
|
||||
# mpih-shift.S
|
||||
#
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o
|
||||
.SUFFIXES: .c .o $(SUFFIXES)
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
@ -1,94 +0,0 @@
|
||||
/* mpihelp-shift.c - MPI helper functions
|
||||
* Copyright (c) 1997 by Werner Koch (dd9jn)
|
||||
*
|
||||
* This file is part of G10.
|
||||
*
|
||||
* G10 is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* G10 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "mpi-internal.h"
|
||||
|
||||
/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
|
||||
* and store the USIZE least significant digits of the result at WP.
|
||||
* Return the bits shifted out from the most significant digit.
|
||||
*
|
||||
* Argument constraints:
|
||||
* 1. 0 < CNT < BITS_PER_MP_LIMB
|
||||
* 2. If the result is to be written over the input, WP must be >= UP.
|
||||
*/
|
||||
|
||||
mpi_limb_t
|
||||
mpihelp_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
|
||||
unsigned int cnt)
|
||||
{
|
||||
mpi_limb_t high_limb, low_limb;
|
||||
unsigned sh_1, sh_2;
|
||||
mpi_size_t i;
|
||||
mpi_limb_t retval;
|
||||
|
||||
sh_1 = cnt;
|
||||
wp += 1;
|
||||
sh_2 = BITS_PER_MPI_LIMB - sh_1;
|
||||
i = usize - 1;
|
||||
low_limb = up[i];
|
||||
retval = low_limb >> sh_2;
|
||||
high_limb = low_limb;
|
||||
while( --i >= 0 ) {
|
||||
low_limb = up[i];
|
||||
wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
|
||||
high_limb = low_limb;
|
||||
}
|
||||
wp[i] = high_limb << sh_1;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right
|
||||
* and store the USIZE least significant limbs of the result at WP.
|
||||
* The bits shifted out to the right are returned.
|
||||
*
|
||||
* Argument constraints:
|
||||
* 1. 0 < CNT < BITS_PER_MP_LIMB
|
||||
* 2. If the result is to be written over the input, WP must be <= UP.
|
||||
*/
|
||||
|
||||
mpi_limb_t
|
||||
mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt)
|
||||
{
|
||||
mpi_limb_t high_limb, low_limb;
|
||||
unsigned sh_1, sh_2;
|
||||
mpi_size_t i;
|
||||
mpi_limb_t retval;
|
||||
|
||||
sh_1 = cnt;
|
||||
wp -= 1;
|
||||
sh_2 = BITS_PER_MPI_LIMB - sh_1;
|
||||
high_limb = up[0];
|
||||
retval = high_limb << sh_2;
|
||||
low_limb = high_limb;
|
||||
for( i=1; i < usize; i++) {
|
||||
high_limb = up[i];
|
||||
wp[i] = (low_limb >> sh_1) | (high_limb << sh_2);
|
||||
low_limb = high_limb;
|
||||
}
|
||||
wp[i] = low_limb >> sh_1;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
737
scripts/config.guess
vendored
Executable file
737
scripts/config.guess
vendored
Executable file
@ -0,0 +1,737 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Written by Per Bothner <bothner@cygnus.com>.
|
||||
# The master version of this file is at the FSF in /home/gd/gnu/lib.
|
||||
#
|
||||
# This script attempts to guess a canonical system name similar to
|
||||
# config.sub. If it succeeds, it prints the system name on stdout, and
|
||||
# exits with 0. Otherwise, it exits with 1.
|
||||
#
|
||||
# The plan is that this can be called by configure scripts if you
|
||||
# don't specify an explicit system type (host/target name).
|
||||
#
|
||||
# Only a few systems have been added to this list; please add others
|
||||
# (but try to keep the structure clean).
|
||||
#
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 8/24/94.)
|
||||
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
|
||||
PATH=$PATH:/.attbin ; export PATH
|
||||
fi
|
||||
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
||||
|
||||
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
||||
|
||||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
alpha:OSF1:*:*)
|
||||
# A Vn.n version is a released version.
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
|
||||
exit 0 ;;
|
||||
21064:Windows_NT:50:3)
|
||||
echo alpha-dec-winnt3.5
|
||||
exit 0 ;;
|
||||
Amiga*:UNIX_System_V:4.0:*)
|
||||
echo m68k-cbm-sysv4
|
||||
exit 0;;
|
||||
amiga:NetBSD:*:*)
|
||||
echo m68k-cbm-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc64:OpenBSD:*:*)
|
||||
echo mips64el-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hkmips:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
SR2?01:HI-UX/MPP:*:*)
|
||||
echo hppa1.1-hitachi-hiuxmpp
|
||||
exit 0;;
|
||||
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
echo pyramid-pyramid-sysv3
|
||||
else
|
||||
echo pyramid-pyramid-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
NILE:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
|
||||
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
i86pc:SunOS:5.*:*)
|
||||
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:6*:*)
|
||||
# According to config.sub, this is the proper way to canonicalize
|
||||
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
|
||||
# it's likely to be more like Solaris than SunOS4.
|
||||
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sun4*:SunOS:*:*)
|
||||
case "`/usr/bin/arch -k`" in
|
||||
Series*|S4*)
|
||||
UNAME_RELEASE=`uname -v`
|
||||
;;
|
||||
esac
|
||||
# Japanese Language versions have a version number like `4.1.3-JL'.
|
||||
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
|
||||
exit 0 ;;
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
aushp:SunOS:*:*)
|
||||
echo sparc-auspex-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:NetBSD:*:*)
|
||||
echo m68k-atari-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:NetBSD:*:*)
|
||||
echo m68k-sun-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:NetBSD:*:*)
|
||||
echo m68k-apple-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme88k:OpenBSD:*:*)
|
||||
echo m88k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RISC*:Mach:*:*)
|
||||
echo mips-dec-mach_bsd4.3
|
||||
exit 0 ;;
|
||||
RISC*:ULTRIX:*:*)
|
||||
echo mips-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
VAX*:ULTRIX*:*:*)
|
||||
echo vax-dec-ultrix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:*:*:UMIPS | mips:*:*:RISCos)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
int main (argc, argv) int argc; char **argv; {
|
||||
#if defined (host_mips) && defined (MIPSEB)
|
||||
#if defined (SYSTYPE_SYSV)
|
||||
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_SVR4)
|
||||
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
|
||||
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy \
|
||||
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
m88k:CX/UX:7*:*)
|
||||
echo m88k-harris-cxux7
|
||||
exit 0 ;;
|
||||
m88k:*:4*:R4*)
|
||||
echo m88k-motorola-sysv4
|
||||
exit 0 ;;
|
||||
m88k:*:3*:R3*)
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
AViiON:dgux:*:*)
|
||||
# DG/UX returns AViiON for all architectures
|
||||
UNAME_PROCESSOR=`/usr/bin/uname -p`
|
||||
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
|
||||
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
|
||||
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
|
||||
echo m88k-dg-dgux${UNAME_RELEASE}
|
||||
else
|
||||
echo m88k-dg-dguxbcs${UNAME_RELEASE}
|
||||
fi
|
||||
else echo i586-dg-dgux${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
|
||||
echo m88k-dolphin-sysv3
|
||||
exit 0 ;;
|
||||
M88*:*:R3*:*)
|
||||
# Delta 88k system running SVR3
|
||||
echo m88k-motorola-sysv3
|
||||
exit 0 ;;
|
||||
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
|
||||
echo m88k-tektronix-sysv3
|
||||
exit 0 ;;
|
||||
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
|
||||
echo m68k-tektronix-bsd
|
||||
exit 0 ;;
|
||||
*:IRIX*:*:*)
|
||||
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
|
||||
exit 0 ;;
|
||||
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
|
||||
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
|
||||
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
|
||||
i?86:AIX:*:*)
|
||||
echo i386-ibm-aix
|
||||
exit 0 ;;
|
||||
*:AIX:2:3)
|
||||
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
main()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
puts("powerpc-ibm-aix3.2.5");
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
else
|
||||
echo rs6000-ibm-aix3.2
|
||||
fi
|
||||
exit 0 ;;
|
||||
*:AIX:*:4)
|
||||
if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
|
||||
IBM_ARCH=rs6000
|
||||
else
|
||||
IBM_ARCH=powerpc
|
||||
fi
|
||||
if [ -x /usr/bin/oslevel ] ; then
|
||||
IBM_REV=`/usr/bin/oslevel`
|
||||
else
|
||||
IBM_REV=4.${UNAME_RELEASE}
|
||||
fi
|
||||
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
|
||||
exit 0 ;;
|
||||
*:AIX:*:*)
|
||||
echo rs6000-ibm-aix
|
||||
exit 0 ;;
|
||||
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
|
||||
echo romp-ibm-bsd4.4
|
||||
exit 0 ;;
|
||||
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
|
||||
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
|
||||
exit 0 ;; # report: romp-ibm BSD 4.3
|
||||
*:BOSX:*:*)
|
||||
echo rs6000-bull-bosx
|
||||
exit 0 ;;
|
||||
DPX/2?00:B.O.S.:*:*)
|
||||
echo m68k-bull-sysv3
|
||||
exit 0 ;;
|
||||
9000/[34]??:4.3bsd:1.*:*)
|
||||
echo m68k-hp-bsd
|
||||
exit 0 ;;
|
||||
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
|
||||
echo m68k-hp-bsd4.4
|
||||
exit 0 ;;
|
||||
9000/[3478]??:HP-UX:*:*)
|
||||
case "${UNAME_MACHINE}" in
|
||||
9000/31? ) HP_ARCH=m68000 ;;
|
||||
9000/[34]?? ) HP_ARCH=m68k ;;
|
||||
9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;;
|
||||
9000/8?? ) HP_ARCH=hppa1.0 ;;
|
||||
esac
|
||||
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
exit 0 ;;
|
||||
3050*:HI-UX:*:*)
|
||||
sed 's/^ //' << EOF >dummy.c
|
||||
#include <unistd.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
long cpu = sysconf (_SC_CPU_VERSION);
|
||||
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
|
||||
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
|
||||
results, however. */
|
||||
if (CPU_IS_PA_RISC (cpu))
|
||||
{
|
||||
switch (cpu)
|
||||
{
|
||||
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
|
||||
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
|
||||
default: puts ("hppa-hitachi-hiuxwe2"); break;
|
||||
}
|
||||
}
|
||||
else if (CPU_IS_HP_MC68K (cpu))
|
||||
puts ("m68k-hitachi-hiuxwe2");
|
||||
else puts ("unknown-hitachi-hiuxwe2");
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
echo hppa1.1-hp-bsd
|
||||
exit 0 ;;
|
||||
9000/8??:4.3bsd:*:*)
|
||||
echo hppa1.0-hp-bsd
|
||||
exit 0 ;;
|
||||
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
|
||||
echo hppa1.1-hp-osf
|
||||
exit 0 ;;
|
||||
hp8??:OSF1:*:*)
|
||||
echo hppa1.0-hp-osf
|
||||
exit 0 ;;
|
||||
i?86:OSF1:*:*)
|
||||
if [ -x /usr/sbin/sysversion ] ; then
|
||||
echo ${UNAME_MACHINE}-unknown-osf1mk
|
||||
else
|
||||
echo ${UNAME_MACHINE}-unknown-osf1
|
||||
fi
|
||||
exit 0 ;;
|
||||
parisc*:Lites*:*:*)
|
||||
echo hppa1.1-hp-lites
|
||||
exit 0 ;;
|
||||
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
CRAY*X-MP:*:*:*)
|
||||
echo xmp-cray-unicos
|
||||
exit 0 ;;
|
||||
CRAY*Y-MP:*:*:*)
|
||||
echo ymp-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY*[A-Z]90:*:*:*)
|
||||
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
|
||||
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
|
||||
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
|
||||
exit 0 ;;
|
||||
CRAY*TS:*:*:*)
|
||||
echo t90-cray-unicos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
CRAY-2:*:*:*)
|
||||
echo cray2-cray-unicos
|
||||
exit 0 ;;
|
||||
F300:UNIX_System_V:*:*)
|
||||
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
F301:UNIX_System_V:*:*)
|
||||
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
|
||||
exit 0 ;;
|
||||
hp3[0-9][05]:NetBSD:*:*)
|
||||
echo m68k-hp-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp300:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i?86:BSD/386:*:* | *:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
*:NetBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo i386-pc-cygwin32
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin32
|
||||
exit 0 ;;
|
||||
prep*:SunOS:5.*:*)
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,-.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:Linux:*:*)
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us.
|
||||
ld_help_string=`ld --help 2>&1`
|
||||
if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
|
||||
echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
|
||||
echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then
|
||||
echo "powerpc-unknown-linux-gnu" ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
echo alpha-unknown-linux-gnu ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "sparc" ; then
|
||||
echo sparc-unknown-linux-gnu ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "mips" ; then
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __MIPSEB__
|
||||
printf ("%s-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
#ifdef __MIPSEL__
|
||||
printf ("%sel-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
else
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us
|
||||
# useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout.
|
||||
test ! -d /usr/lib/ldscripts/. \
|
||||
&& echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __ELF__
|
||||
printf ("%s-pc-linux-gnu\n", argv[1]);
|
||||
#else
|
||||
printf ("%s-pc-linux-gnuaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
fi ;;
|
||||
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
|
||||
# are messed up and put the nodename in both sysname and nodename.
|
||||
i?86:DYNIX/ptx:4*:*)
|
||||
echo i386-sequent-sysv4
|
||||
exit 0 ;;
|
||||
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
i?86:*:3.2:*)
|
||||
if test -f /usr/options/cb.name; then
|
||||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit 0 ;;
|
||||
paragon:*:*:*)
|
||||
echo i860-intel-osf1
|
||||
exit 0 ;;
|
||||
i860:*:4.*:*) # i860-SVR4
|
||||
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
|
||||
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
|
||||
else # Add other i860-SVR4 vendors below as they are discovered.
|
||||
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
|
||||
fi
|
||||
exit 0 ;;
|
||||
mini*:CTIX:SYS*5:*)
|
||||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
|
||||
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
|
||||
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
|
||||
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
|
||||
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
|
||||
&& echo i486-ncr-sysv4 && exit 0 ;;
|
||||
m68*:LynxOS:2.*:*)
|
||||
echo m68k-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mc68030:UNIX_System_V:4.*:*)
|
||||
echo m68k-atari-sysv4
|
||||
exit 0 ;;
|
||||
i?86:LynxOS:2.*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
TSUNAMI:LynxOS:2.*:*)
|
||||
echo sparc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
|
||||
echo rs6000-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SM[BE]S:UNIX_SV:*:*)
|
||||
echo mips-dde-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
RM*:SINIX-*:*:*)
|
||||
echo mips-sni-sysv4
|
||||
exit 0 ;;
|
||||
*:SINIX-*:*:*)
|
||||
if uname -p 2>/dev/null >/dev/null ; then
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
echo ${UNAME_MACHINE}-sni-sysv4
|
||||
else
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
echo hppa1.1-stratus-sysv4
|
||||
exit 0 ;;
|
||||
*:*:*:FTX*)
|
||||
# From seanf@swdc.stratus.com.
|
||||
echo i860-stratus-sysv4
|
||||
exit 0 ;;
|
||||
mc68*:A/UX:*:*)
|
||||
echo m68k-apple-aux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
else
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
|
||||
|
||||
cat >dummy.c <<EOF
|
||||
#ifdef _SEQUENT_
|
||||
# include <sys/types.h>
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
#if defined (MIPSEB)
|
||||
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
|
||||
I don't know.... */
|
||||
printf ("mips-sony-bsd\n"); exit (0);
|
||||
#else
|
||||
#include <sys/param.h>
|
||||
printf ("m68k-sony-newsos%s\n",
|
||||
#ifdef NEWSOS4
|
||||
"4"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__arm) && defined (__acorn) && defined (__unix)
|
||||
printf ("arm-acorn-riscix"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (hp300) && !defined (hpux)
|
||||
printf ("m68k-hp-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (NeXT)
|
||||
#if !defined (__ARCHITECTURE__)
|
||||
#define __ARCHITECTURE__ "m68k"
|
||||
#endif
|
||||
int version;
|
||||
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
|
||||
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
|
||||
exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (MULTIMAX) || defined (n16)
|
||||
#if defined (UMAXV)
|
||||
printf ("ns32k-encore-sysv\n"); exit (0);
|
||||
#else
|
||||
#if defined (CMU)
|
||||
printf ("ns32k-encore-mach\n"); exit (0);
|
||||
#else
|
||||
printf ("ns32k-encore-bsd\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__386BSD__)
|
||||
printf ("i386-pc-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
#if defined (sequent)
|
||||
#if defined (i386)
|
||||
printf ("i386-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#if defined (ns32000)
|
||||
printf ("ns32k-sequent-dynix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (_SEQUENT_)
|
||||
struct utsname un;
|
||||
|
||||
uname(&un);
|
||||
|
||||
if (strncmp(un.version, "V2", 2) == 0) {
|
||||
printf ("i386-sequent-ptx2\n"); exit (0);
|
||||
}
|
||||
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
|
||||
printf ("i386-sequent-ptx1\n"); exit (0);
|
||||
}
|
||||
printf ("i386-sequent-ptx\n"); exit (0);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (vax)
|
||||
#if !defined (ultrix)
|
||||
printf ("vax-dec-bsd\n"); exit (0);
|
||||
#else
|
||||
printf ("vax-dec-ultrix\n"); exit (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (alliant) && defined (i860)
|
||||
printf ("i860-alliant-bsd\n"); exit (0);
|
||||
#endif
|
||||
|
||||
exit (1);
|
||||
}
|
||||
EOF
|
||||
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
|
||||
|
||||
# Convex versions that predate uname can use getsysinfo(1)
|
||||
|
||||
if [ -x /usr/convex/getsysinfo ]
|
||||
then
|
||||
case `getsysinfo -f cpu_type` in
|
||||
c1*)
|
||||
echo c1-convex-bsd
|
||||
exit 0 ;;
|
||||
c2*)
|
||||
if getsysinfo -f scalar_acc
|
||||
then echo c32-convex-bsd
|
||||
else echo c2-convex-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
c34*)
|
||||
echo c34-convex-bsd
|
||||
exit 0 ;;
|
||||
c38*)
|
||||
echo c38-convex-bsd
|
||||
exit 0 ;;
|
||||
c4*)
|
||||
echo c4-convex-bsd
|
||||
exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#echo '(Unable to guess system type)' 1>&2
|
||||
|
||||
exit 1
|
1181
scripts/config.sub
vendored
Executable file
1181
scripts/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
@ -349,7 +349,10 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
|
||||
{
|
||||
const char *s;
|
||||
|
||||
puts( strusage(10) );
|
||||
s = strusage(10);
|
||||
fputs( s, stdout );
|
||||
if( *s && s[strlen(s)-1] != '\n' )
|
||||
putchar( '\n' );
|
||||
s = strusage(12);
|
||||
if( *s == '\n' )
|
||||
s++;
|
||||
@ -366,6 +369,9 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
|
||||
indent += 10;
|
||||
puts("Options:");
|
||||
for(i=0; opts[i].short_opt; i++ ) {
|
||||
s = opts[i].description;
|
||||
if( s && *s== '\r' ) /* hide this line */
|
||||
continue;
|
||||
if( opts[i].short_opt < 256 )
|
||||
printf(" -%c", opts[i].short_opt );
|
||||
else
|
||||
@ -376,7 +382,7 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
|
||||
opts[i].long_opt );
|
||||
for(;j < indent; j++ )
|
||||
putchar(' ');
|
||||
if( (s = opts[i].description) ) {
|
||||
if( s ) {
|
||||
for(; *s; s++ ) {
|
||||
if( *s == '\n' ) {
|
||||
if( s[1] ) {
|
||||
@ -398,6 +404,10 @@ show_help( ARGPARSE_OPTS *opts, unsigned flags )
|
||||
putchar('\n');
|
||||
fputs(s, stdout);
|
||||
}
|
||||
if( *(s=strusage(30)) ) { /* special notes */
|
||||
putchar('\n');
|
||||
fputs(s, stdout);
|
||||
}
|
||||
fflush(stdout);
|
||||
exit(0);
|
||||
}
|
||||
@ -497,7 +507,7 @@ default_strusage( int level )
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation; either version 2 of the License, or\n"
|
||||
"(at your option) any later version.\n\n"
|
||||
"WkLib is distributed in the hope that it will be useful,\n"
|
||||
"It is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n\n"
|
||||
@ -537,6 +547,7 @@ default_strusage( int level )
|
||||
p = "UnknownOS";
|
||||
#endif
|
||||
break;
|
||||
case 30: p = ""; break;
|
||||
case 31: p =
|
||||
"This program comes with ABSOLUTELY NO WARRANTY.\n"
|
||||
"This is free software, and you are welcome to redistribute it\n"
|
||||
|
@ -63,10 +63,10 @@ const void membug( const char *fmt, ... );
|
||||
#define FNAME(a) m_ ##a
|
||||
#define FNAMEPRT
|
||||
#define FNAMEARG
|
||||
#define store_len(p,n,m) do { ((byte*))p[0] = n; \
|
||||
((byte*))p[2] = n >> 8 ; \
|
||||
((byte*))p[3] = n >> 16 ; \
|
||||
((byte*))p[4] = m? MAGIC_SEC_BYTE \
|
||||
#define store_len(p,n,m) do { ((byte*)p)[0] = n; \
|
||||
((byte*)p)[1] = n >> 8 ; \
|
||||
((byte*)p)[2] = n >> 16 ; \
|
||||
((byte*)p)[3] = m? MAGIC_SEC_BYTE \
|
||||
: MAGIC_NOR_BYTE; \
|
||||
} while(0)
|
||||
#endif
|
||||
@ -213,8 +213,6 @@ check_mem( const byte *p, const char *info )
|
||||
membug("memory at %p corrupted: underflow=%02x (%s)\n", p+4, p[3], info );
|
||||
if( p[4+e->user_n] != MAGIC_END_BYTE )
|
||||
membug("memory at %p corrupted: overflow=%02x (%s)\n", p+4, p[4+e->user_n], info );
|
||||
if( e->info->count > 20000 )
|
||||
membug("memory at %p corrupted: count too high (%s)\n", p+4, info );
|
||||
return e;
|
||||
}
|
||||
|
||||
@ -444,9 +442,9 @@ m_size( const void *a )
|
||||
#ifdef M_DEBUG
|
||||
n = check_mem(p-4, "m_size")->user_n;
|
||||
#else
|
||||
n = ((byte*)p[-4];
|
||||
n |= ((byte*)p[-3] << 8;
|
||||
n |= ((byte*)p[-2] << 16;
|
||||
n = ((byte*)p)[-4];
|
||||
n |= ((byte*)p)[-3] << 8;
|
||||
n |= ((byte*)p)[-2] << 16;
|
||||
#endif
|
||||
return n;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user