From owner-p4-projects@FreeBSD.ORG Fri Jun 11 21:44:13 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 81A8A16A4D1; Fri, 11 Jun 2004 21:44:13 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3B56716A4CE for ; Fri, 11 Jun 2004 21:44:13 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 323BF43D41 for ; Fri, 11 Jun 2004 21:44:13 +0000 (GMT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i5BLhjvY056607 for ; Fri, 11 Jun 2004 21:43:45 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i5BLhilp056604 for perforce@freebsd.org; Fri, 11 Jun 2004 21:43:44 GMT (envelope-from marcel@freebsd.org) Date: Fri, 11 Jun 2004 21:43:44 GMT Message-Id: <200406112143.i5BLhilp056604@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 54657 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2004 21:44:14 -0000 http://perforce.freebsd.org/chv.cgi?CH=54657 Change 54657 by marcel@marcel_nfs on 2004/06/11 21:43:15 IFC @54656 Affected files ... .. //depot/projects/gdb/etc/etc.arm/ttys#1 branch .. //depot/projects/gdb/gnu/usr.bin/binutils/gdb/Makefile#5 integrate .. //depot/projects/gdb/gnu/usr.bin/binutils/gdb/kvm-fbsd-alpha.h#1 branch .. //depot/projects/gdb/gnu/usr.bin/binutils/gdb/kvm-fbsd-i386.h#1 branch .. //depot/projects/gdb/gnu/usr.bin/binutils/gdb/kvm-fbsd-sparc64.h#1 branch .. //depot/projects/gdb/gnu/usr.bin/binutils/gdb/kvm-fbsd.c#4 integrate .. //depot/projects/gdb/sbin/md5/Makefile#3 integrate .. //depot/projects/gdb/sbin/md5/md5.1#3 integrate .. //depot/projects/gdb/sbin/md5/md5.c#2 integrate .. //depot/projects/gdb/sbin/sunlabel/sunlabel.c#4 integrate .. //depot/projects/gdb/sys/alpha/alpha/machdep.c#10 integrate .. //depot/projects/gdb/sys/alpha/alpha/pmap.c#8 integrate .. //depot/projects/gdb/sys/alpha/alpha/uma_machdep.c#1 branch .. //depot/projects/gdb/sys/amd64/amd64/machdep.c#14 integrate .. //depot/projects/gdb/sys/boot/i386/boot0/boot0.S#3 integrate .. //depot/projects/gdb/sys/compat/linux/linux_misc.c#4 integrate .. //depot/projects/gdb/sys/compat/linux/linux_uid16.c#2 integrate .. //depot/projects/gdb/sys/conf/NOTES#23 integrate .. //depot/projects/gdb/sys/conf/files.alpha#6 integrate .. //depot/projects/gdb/sys/conf/options#21 integrate .. //depot/projects/gdb/sys/dev/ata/ata-lowlevel.c#11 integrate .. //depot/projects/gdb/sys/dev/bktr/bktr_mem.c#3 integrate .. //depot/projects/gdb/sys/dev/cy/cy.c#6 integrate .. //depot/projects/gdb/sys/dev/digi/digi.c#6 integrate .. //depot/projects/gdb/sys/dev/esp/esp_sbus.c#2 integrate .. //depot/projects/gdb/sys/dev/esp/ncr53c9x.c#2 integrate .. //depot/projects/gdb/sys/dev/esp/ncr53c9xvar.h#2 integrate .. //depot/projects/gdb/sys/dev/rp/rp.c#5 integrate .. //depot/projects/gdb/sys/dev/si/si.c#5 integrate .. //depot/projects/gdb/sys/dev/sio/sio.c#13 integrate .. //depot/projects/gdb/sys/dev/sx/sx.c#4 integrate .. //depot/projects/gdb/sys/dev/twe/twe.c#5 integrate .. //depot/projects/gdb/sys/dev/twe/twe_freebsd.c#6 integrate .. //depot/projects/gdb/sys/dev/twe/twevar.h#5 integrate .. //depot/projects/gdb/sys/dev/usb/ucom.c#6 integrate .. //depot/projects/gdb/sys/i386/i386/machdep.c#9 integrate .. //depot/projects/gdb/sys/ia64/ia64/machdep.c#8 integrate .. //depot/projects/gdb/sys/ia64/ia64/pmap.c#7 integrate .. //depot/projects/gdb/sys/kern/kern_descrip.c#7 integrate .. //depot/projects/gdb/sys/kern/kern_kse.c#2 integrate .. //depot/projects/gdb/sys/kern/kern_prot.c#4 integrate .. //depot/projects/gdb/sys/kern/kern_resource.c#6 integrate .. //depot/projects/gdb/sys/kern/kern_sig.c#10 integrate .. //depot/projects/gdb/sys/kern/kern_thread.c#13 integrate .. //depot/projects/gdb/sys/kern/kern_xxx.c#3 integrate .. //depot/projects/gdb/sys/kern/tty.c#8 integrate .. //depot/projects/gdb/sys/kern/tty_compat.c#4 integrate .. //depot/projects/gdb/sys/kern/tty_pty.c#8 integrate .. //depot/projects/gdb/sys/kern/uipc_mbuf.c#7 integrate .. //depot/projects/gdb/sys/kern/uipc_syscalls.c#13 integrate .. //depot/projects/gdb/sys/kern/vfs_syscalls.c#12 integrate .. //depot/projects/gdb/sys/pc98/i386/machdep.c#7 integrate .. //depot/projects/gdb/sys/pc98/pc98/sio.c#11 integrate .. //depot/projects/gdb/sys/sys/ioctl.h#4 integrate .. //depot/projects/gdb/sys/sys/signal.h#3 integrate .. //depot/projects/gdb/sys/vm/vm_mmap.c#8 integrate .. //depot/projects/gdb/usr.bin/truss/syscalls.c#3 integrate .. //depot/projects/gdb/usr.bin/xinstall/install.1#2 integrate Differences ... ==== //depot/projects/gdb/gnu/usr.bin/binutils/gdb/Makefile#5 (text+ko) ==== @@ -1,5 +1,5 @@ # ex:ts=8 -# $FreeBSD: src/gnu/usr.bin/binutils/gdb/Makefile,v 1.79 2004/03/17 07:40:42 obrien Exp $ +# $FreeBSD: src/gnu/usr.bin/binutils/gdb/Makefile,v 1.80 2004/06/11 16:09:38 obrien Exp $ .include "../Makefile.inc0" @@ -45,7 +45,7 @@ scm-exp.c scm-lang.c scm-valprint.c \ coffread.c dbxread.c dwarfread.c dwarf2read.c elfread.c \ solib.c solib-svr4.c solib-legacy.c -XSRCS+= freebsd-uthread.c kvm-fbsd.c solib-fbsd-kld.c +XSRCS+= freebsd-uthread.c kvm-fbsd.c kvm-fbsd-machine.h solib-fbsd-kld.c SRCS= init.c ${XSRCS} nm.h tm.h xm.h gdbversion.c xregex.h .include "${.CURDIR}/Makefile.${TARGET_ARCH}" @@ -73,7 +73,7 @@ LDADD+= ${RELTOP}/libiberty/libiberty.a LDADD+= -lreadline -ltermcap -CLEANFILES= init.c init.c-tmp nm.h tm.h xm.h gdbversion.c xregex.h +CLEANFILES= init.c init.c-tmp nm.h tm.h xm.h gdbversion.c xregex.h kvm-fbsd-machine.h # We do this by grepping through sources. If that turns out to be too slow, # maybe we could just require every .o file to have an initialization routine @@ -127,6 +127,9 @@ ln -sf ${GDBDIR}/gdb/config/${GDB_CPU}/${H}.h ${.TARGET} .endfor +kvm-fbsd-machine.h: + ln -sf ${.CURDIR}/kvm-fbsd-${TARGET_ARCH}.h ${.TARGET} + GDB_VERSION= "5.2.1 (FreeBSD)" gdbversion.c: Makefile @echo '#include "version.h"' > ${.TARGET} ==== //depot/projects/gdb/gnu/usr.bin/binutils/gdb/kvm-fbsd.c#4 (text+ko) ==== @@ -19,7 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $FreeBSD: src/gnu/usr.bin/binutils/gdb/kvm-fbsd.c,v 1.48 2004/05/10 17:45:51 obrien Exp $ */ +#include +__FBSDID("$FreeBSD: src/gnu/usr.bin/binutils/gdb/kvm-fbsd.c,v 1.49 2004/06/11 16:09:38 obrien Exp $"); /* * This works like "remote" but, you use it like this: @@ -33,31 +34,27 @@ */ #include -#include -#include #include -#include -#include +#include #include #include #include #include -#include -#include #include "defs.h" +#include #include "gdb_string.h" #include "frame.h" /* required by inferior.h */ #include "inferior.h" -#include "symtab.h" #include "symfile.h" #include "objfiles.h" #include "command.h" #include "bfd.h" -#include "target.h" #include "gdbcore.h" #include "solist.h" +#include "kvm-fbsd-machine.h" + static void kcore_files_info (struct target_ops *); @@ -68,10 +65,6 @@ get_kcore_registers (int); static int -xfer_mem (CORE_ADDR, char *, int, int, struct mem_attrib *, - struct target_ops *); - -static int xfer_umem (CORE_ADDR, char *, int, int); #ifdef SOLIB_ADD @@ -116,7 +109,7 @@ #define KERNOFF (ksym_kernbase ()) #define INKERNEL(x) ((x) >= KERNOFF) -CORE_ADDR +static CORE_ADDR ksym_lookup(const char *name) { struct minimal_symbol *sym; @@ -190,8 +183,6 @@ static int set_context (CORE_ADDR addr) { - CORE_ADDR procaddr = 0; - if (kvread (addr, &cur_pcb)) error ("cannot read pcb at %#x", addr); @@ -349,253 +340,6 @@ printf_filtered ("No kernel core file now.\n"); } -#ifdef __alpha__ - -#include "alpha/tm-alpha.h" -#ifndef S0_REGNUM -#define S0_REGNUM (T7_REGNUM+1) -#endif - -fetch_kcore_registers (struct pcb *pcbp) -{ - - /* First clear out any garbage. */ - memset (registers, '\0', REGISTER_BYTES); - - /* SP */ - *(long *) ®isters[REGISTER_BYTE (SP_REGNUM)] = - pcbp->pcb_hw.apcb_ksp; - - /* S0 through S6 */ - memcpy (®isters[REGISTER_BYTE (S0_REGNUM)], - &pcbp->pcb_context[0], 7 * sizeof (long)); - - /* PC */ - *(long *) ®isters[REGISTER_BYTE (PC_REGNUM)] = - pcbp->pcb_context[7]; - - registers_fetched (); -} - - -CORE_ADDR -fbsd_kern_frame_saved_pc (struct frame_info *fi) -{ - struct minimal_symbol *sym; - CORE_ADDR this_saved_pc; - - this_saved_pc = alpha_frame_saved_pc (fi); - - sym = lookup_minimal_symbol_by_pc (this_saved_pc); - - if (sym != NULL && - (strcmp (SYMBOL_NAME (sym), "XentArith") == 0 || - strcmp (SYMBOL_NAME (sym), "XentIF") == 0 || - strcmp (SYMBOL_NAME (sym), "XentInt") == 0 || - strcmp (SYMBOL_NAME (sym), "XentMM") == 0 || - strcmp (SYMBOL_NAME (sym), "XentSys") == 0 || - strcmp (SYMBOL_NAME (sym), "XentUna") == 0 || - strcmp (SYMBOL_NAME (sym), "XentRestart") == 0)) - { - return (read_memory_integer (fi->frame + 32 * 8, 8)); - } - else - { - return (this_saved_pc); - } -} - -#endif /* __alpha__ */ - -#ifdef __i386__ - -static CORE_ADDR -ksym_maxuseraddr (void) -{ - static CORE_ADDR maxuseraddr; - struct minimal_symbol *sym; - - if (maxuseraddr == 0) - { - sym = lookup_minimal_symbol ("PTmap", NULL, NULL); - if (sym == NULL) { - maxuseraddr = VM_MAXUSER_ADDRESS; - } else { - maxuseraddr = SYMBOL_VALUE_ADDRESS (sym); - } - } - return maxuseraddr; -} - - -/* Symbol names of kernel entry points. Use special frames. */ -#define KSYM_TRAP "calltrap" -#define KSYM_INTR "Xintr" -#define KSYM_FASTINTR "Xfastintr" -#define KSYM_OLDSYSCALL "Xlcall_syscall" -#define KSYM_SYSCALL "Xint0x80_syscall" - -/* The following is FreeBSD-specific hackery to decode special frames - and elide the assembly-language stub. This could be made faster by - defining a frame_type field in the machine-dependent frame information, - but we don't think that's too important right now. */ -enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall }; - -CORE_ADDR -fbsd_kern_frame_saved_pc (struct frame_info *fi) -{ - struct minimal_symbol *sym; - CORE_ADDR this_saved_pc; - enum frametype frametype; - - this_saved_pc = read_memory_integer (fi->frame + 4, 4); - sym = lookup_minimal_symbol_by_pc (this_saved_pc); - frametype = tf_normal; - if (sym != NULL) - { - if (strcmp (SYMBOL_NAME (sym), KSYM_TRAP) == 0) - frametype = tf_trap; - else - if (strncmp (SYMBOL_NAME (sym), KSYM_INTR, - strlen (KSYM_INTR)) == 0 || strncmp (SYMBOL_NAME(sym), - KSYM_FASTINTR, strlen (KSYM_FASTINTR)) == 0) - frametype = tf_interrupt; - else - if (strcmp (SYMBOL_NAME (sym), KSYM_SYSCALL) == 0 || - strcmp (SYMBOL_NAME (sym), KSYM_OLDSYSCALL) == 0) - frametype = tf_syscall; - } - - switch (frametype) - { - case tf_normal: - return (this_saved_pc); -#define oEIP offsetof (struct trapframe, tf_eip) - - case tf_trap: - return (read_memory_integer (fi->frame + 8 + oEIP, 4)); - - case tf_interrupt: - return (read_memory_integer (fi->frame + 12 + oEIP, 4)); - - case tf_syscall: - return (read_memory_integer (fi->frame + 8 + oEIP, 4)); -#undef oEIP - } -} - -static int -fetch_kcore_registers (struct pcb *pcb) -{ - int i; - int noreg; - - /* Get the register values out of the sys pcb and store them where - `read_register' will find them. */ - /* - * XXX many registers aren't available. - * XXX for the non-core case, the registers are stale - they are for - * the last context switch to the debugger. - * XXX gcc's register numbers aren't all #defined in tm-i386.h. - */ - noreg = 0; - for (i = 0; i < 3; ++i) /* eax,ecx,edx */ - supply_register (i, (char *)&noreg); - - supply_register (3, (char *) &pcb->pcb_ebx); - supply_register (SP_REGNUM, (char *) &pcb->pcb_esp); - supply_register (FP_REGNUM, (char *) &pcb->pcb_ebp); - supply_register (6, (char *) &pcb->pcb_esi); - supply_register (7, (char *) &pcb->pcb_edi); - supply_register (PC_REGNUM, (char *) &pcb->pcb_eip); - - for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */ - supply_register (i, (char *) &noreg); - supply_register (15, (char *) &pcb->pcb_gs); - - /* XXX 80387 registers? */ -} - -#endif /* __i386__ */ - -#ifdef __sparc64__ - -#define SPARC_INTREG_SIZE 8 - -static void -fetch_kcore_registers (struct pcb *pcbp) -{ - static struct frame top; - CORE_ADDR f_addr; - int i; - - /* Get the register values out of the sys pcb and store them where - `read_register' will find them. */ - /* - * XXX many registers aren't available. - * XXX for the non-core case, the registers are stale - they are for - * the last context switch to the debugger. - * XXX do something with the floating-point registers? - */ - supply_register (SP_REGNUM, (char *)&pcbp->pcb_ufp); - supply_register (PC_REGNUM, (char *)&pcbp->pcb_pc); - f_addr = extract_address (&pcbp->pcb_ufp, SPARC_INTREG_SIZE); - /* Load the previous frame by hand (XXX) and supply it. */ - read_memory (f_addr + SPOFF, (char *)&top, sizeof (top)); - for (i = 0; i < 8; i++) - supply_register (i + L0_REGNUM, (char *)&top.fr_local[i]); - for (i = 0; i < 8; i++) - supply_register (i + I0_REGNUM, (char *)&top.fr_in[i]); -} - -CORE_ADDR -fbsd_kern_frame_saved_pc (struct frame_info *fi) -{ - struct minimal_symbol *sym; - CORE_ADDR frame, pc_addr, pc; - char *buf; - - buf = alloca (MAX_REGISTER_RAW_SIZE); - /* XXX: duplicates fi->extra_info->bottom. */ - frame = (fi->next != NULL) ? fi->next->frame : read_sp (); - pc_addr = frame + offsetof (struct frame, fr_in[7]); - -#define READ_PC(pc, a, b) do { \ - read_memory (a, b, SPARC_INTREG_SIZE); \ - pc = extract_address (b, SPARC_INTREG_SIZE); \ -} while (0) - - READ_PC (pc, pc_addr, buf); - - sym = lookup_minimal_symbol_by_pc (pc); - if (sym != NULL) - { - if (strncmp (SYMBOL_NAME (sym), "tl0_", 4) == 0 || - strcmp (SYMBOL_NAME (sym), "btext") == 0 || - strcmp (SYMBOL_NAME (sym), "mp_startup") == 0 || - strcmp (SYMBOL_NAME (sym), "fork_trampoline") == 0) - { - /* - * Ugly kluge: user space addresses aren't separated from kernel - * ones by range; if encountering a trap from user space, just - * return a 0 to stop the trace. - * Do the same for entry points of kernel processes to avoid - * printing garbage. - */ - pc = 0; - } - if (strncmp (SYMBOL_NAME (sym), "tl1_", 4) == 0) - { - pc_addr = fi->frame + sizeof (struct frame) + - offsetof (struct trapframe, tf_tpc); - READ_PC (pc, pc_addr, buf); - } - } - return (pc); -} - -#endif /* __sparc64__ */ - /* Get the registers out of a core file. This is the machine- independent part. Fetch_core_registers is the machine-dependent part, typically implemented in the xm-file for each architecture. */ @@ -623,16 +367,7 @@ printf_filtered ("\t`%s'\n", core_file); } -/* If mourn is being called in all the right places, this could be say - `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */ - static int -ignore (CORE_ADDR addr, char *contents) -{ - return 0; -} - -static int xfer_kmem (CORE_ADDR memaddr, char *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target) { @@ -651,7 +386,7 @@ n = kvm_read (core_kd, memaddr, myaddr, len) ; if (n < 0) { fprintf_unfiltered (gdb_stderr, "can not access 0x%x, %s\n", - memaddr, kvm_geterr (core_kd)); + (unsigned)memaddr, kvm_geterr (core_kd)); n = 0; } ==== //depot/projects/gdb/sbin/md5/Makefile#3 (text+ko) ==== @@ -1,9 +1,18 @@ # @(#)Makefile 8.1 (Berkeley) 6/9/93 -# $FreeBSD: src/sbin/md5/Makefile,v 1.8 2004/02/05 22:44:23 ru Exp $ +# $FreeBSD: src/sbin/md5/Makefile,v 1.9 2004/06/11 16:07:02 eik Exp $ PROG= md5 +LINKS= ${BINDIR}/md5 ${BINDIR}/rmd160 \ + ${BINDIR}/md5 ${BINDIR}/sha1 + +MLINKS= md5.1 rmd160.1 \ + md5.1 sha1.1 + +WARNS?= 6 +WFORMAT?= 1 + +DPADD= ${LIBMD} LDADD= -lmd -DPADD= ${LIBMD} .include ==== //depot/projects/gdb/sbin/md5/md5.1#3 (text+ko) ==== @@ -1,20 +1,30 @@ -.\" $FreeBSD: src/sbin/md5/md5.1,v 1.20 2004/05/17 08:35:41 ru Exp $ -.Dd February 14, 1994 +.\" $FreeBSD: src/sbin/md5/md5.1,v 1.21 2004/06/11 16:07:02 eik Exp $ +.Dd June 6, 2004 .Dt MD5 1 .Os .Sh NAME -.Nm md5 +.Nm md5 , sha1 , rmd160 .Nd calculate a message-digest fingerprint (checksum) for a file .Sh SYNOPSIS -.Nm +.Nm md5 +.Op Fl pqrtx +.Op Fl s Ar string +.Op Ar +.Nm sha1 +.Op Fl pqrtx +.Op Fl s Ar string +.Op Ar +.Nm rmd160 .Op Fl pqrtx .Op Fl s Ar string .Op Ar .Sh DESCRIPTION -The -.Nm -utility takes as input a message of arbitrary length and produces -as output a 128-bit +The +.Nm md5 , sha1 +and +.Nm rmd160 +utilities take as input a message of arbitrary length and produce as +output a .Dq fingerprint or .Dq message digest @@ -22,17 +32,23 @@ It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given prespecified target message digest. -The MD5 algorithm is intended for digital signature applications, where a +The +.Tn MD5 , SHA-1 +and +.Tn RIPEMD-160 +algorithms are intended for digital signature applications, where a large file must be .Dq compressed in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as -.Em RSA . +.Tn RSA . .Pp -MD5 has not yet (2001-09-03) been broken, but sufficient attacks have been +.Tn MD5 +has not yet (2001-09-03) been broken, but sufficient attacks have been made that its security is in some doubt. -The attacks on MD5 +The attacks on +.Tn MD5 are in the nature of finding .Dq collisions \(em that is, multiple @@ -41,17 +57,16 @@ .Pp The following options may be used in any combination and must precede any files named on the command line. -The MD5 -sum of each file listed on the command line is printed after the options -are processed. +The hexadecimal checksum of each file listed on the command line is printed +after the options are processed. .Bl -tag -width indent .It Fl s Ar string Print a checksum of the given .Ar string . .It Fl p -Echo stdin to stdout and appends the MD5 sum to stdout. +Echo stdin to stdout and append the checksum to stdout. .It Fl q -Quiet mode - only the MD5 sum is printed out. +Quiet mode - only the checksum is printed out. Overrides the .Fl r option. @@ -69,16 +84,44 @@ .El .Sh DIAGNOSTICS The -.Nm -utility exits 0 on success, +.Nm md5 , sha1 +and +.Nm rmd160 +utilities exit 0 on success, and 1 if at least one of the input files could not be read. .Sh SEE ALSO -.Xr cksum 1 +.Xr cksum 1 , +.Xr md5 3 , +.Xr ripemd 3 , +.Xr sha 3 .Rs .%A R. Rivest .%T The MD5 Message-Digest Algorithm .%O RFC1321 .Re +.Rs +.%A J. Burrows +.%T The Secure Hash Standard +.%O FIPS PUB 180-1 +.Re +.Rs +.%A D. Eastlake and P. Jones +.%T US Secure Hash Algorithm 1 +.%O RFC 3174 +.Re +.Pp +RIPEMD-160 is part of the ISO draft standard +.Qq ISO/IEC DIS 10118-3 +on dedicated hash functions. +.Pp +Secure Hash Standard (SHS): +.Pa http://csrc.nist.gov/cryptval/shs.html . +.Pp +The RIPEMD-160 page: +.Pa http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html . .Sh ACKNOWLEDGMENTS This program is placed in the public domain for free general use by RSA Data Security. +.Pp +Support for SHA-1 and RIPEMD-160 has been added by +.An Oliver Eikemeier Aq eik@FreeBSD.org . ==== //depot/projects/gdb/sbin/md5/md5.c#2 (text+ko) ==== @@ -18,13 +18,15 @@ */ #include -__FBSDID("$FreeBSD: src/sbin/md5/md5.c,v 1.31 2003/11/02 23:12:08 se Exp $"); +__FBSDID("$FreeBSD: src/sbin/md5/md5.c,v 1.32 2004/06/11 16:07:02 eik Exp $"); #include #include #include #include #include +#include +#include #include #include #include @@ -36,16 +38,66 @@ */ #define TEST_BLOCK_LEN 10000 #define TEST_BLOCK_COUNT 100000 +#define MDTESTCOUNT 8 int qflag; int rflag; int sflag; -static void MDString(const char *); -static void MDTimeTrial(void); -static void MDTestSuite(void); -static void MDFilter(int); -static void usage(void); +typedef void (DIGEST_Init)(void *); +typedef void (DIGEST_Update)(void *, const unsigned char *, size_t); +typedef char *(DIGEST_End)(void *, char *); + +extern const char *MD5TestOutput[MDTESTCOUNT]; +extern const char *SHA1_TestOutput[MDTESTCOUNT]; +extern const char *RIPEMD160_TestOutput[MDTESTCOUNT]; + +typedef struct Algorithm_t { + const char *progname; + const char *name; + const char *(*TestOutput)[MDTESTCOUNT]; + DIGEST_Init *Init; + DIGEST_Update *Update; + DIGEST_End *End; + char *(*Data)(const unsigned char *, unsigned int, char *); + char *(*File)(const char *, char *); +} Algorithm_t; + +static void MD5_Update(MD5_CTX *, const unsigned char *, size_t); +static void MDString(Algorithm_t *, const char *); +static void MDTimeTrial(Algorithm_t *); +static void MDTestSuite(Algorithm_t *); +static void MDFilter(Algorithm_t *, int); +static void usage(Algorithm_t *); + +typedef union { + MD5_CTX md5; + SHA1_CTX sha1; + RIPEMD160_CTX ripemd160; +} DIGEST_CTX; + +/* max(MD5_DIGEST_LENGTH, SHA_DIGEST_LENGTH, RIPEMD160_DIGEST_LENGTH)*2+1 */ +#define HEX_DIGEST_LENGTH 41 + +/* algorithm function table */ + +struct Algorithm_t Algorithm[] = { + { "md5", "MD5", &MD5TestOutput, (DIGEST_Init*)&MD5Init, + (DIGEST_Update*)&MD5_Update, (DIGEST_End*)&MD5End, + &MD5Data, &MD5File }, + { "sha1", "SHA1", &SHA1_TestOutput, (DIGEST_Init*)&SHA1_Init, + (DIGEST_Update*)&SHA1_Update, (DIGEST_End*)&SHA1_End, + &SHA1_Data, &SHA1_File }, + { "rmd160", "RMD160", &RIPEMD160_TestOutput, + (DIGEST_Init*)&RIPEMD160_Init, (DIGEST_Update*)&RIPEMD160_Update, + (DIGEST_End*)&RIPEMD160_End, &RIPEMD160_Data, &RIPEMD160_File } +}; + +static void +MD5_Update(MD5_CTX *c, const unsigned char *data, size_t len) +{ + MD5Update(c, data, len); +} /* Main driver. @@ -61,14 +113,28 @@ { int ch; char *p; - char buf[33]; + char buf[HEX_DIGEST_LENGTH]; int failed; + unsigned digest; + const char* progname; + + if ((progname = strrchr(argv[0], '/')) == NULL) + progname = argv[0]; + else + progname++; + + for (digest = 0; digest < sizeof(Algorithm)/sizeof(*Algorithm); digest++) + if (strcasecmp(Algorithm[digest].progname, progname) == 0) + break; + + if (Algorithm[digest].progname == NULL) + digest = 0; failed = 0; while ((ch = getopt(argc, argv, "pqrs:tx")) != -1) switch (ch) { case 'p': - MDFilter(1); + MDFilter(&Algorithm[digest], 1); break; case 'q': qflag = 1; @@ -78,23 +144,23 @@ break; case 's': sflag = 1; - MDString(optarg); + MDString(&Algorithm[digest], optarg); break; case 't': - MDTimeTrial(); + MDTimeTrial(&Algorithm[digest]); break; case 'x': - MDTestSuite(); + MDTestSuite(&Algorithm[digest]); break; default: - usage(); + usage(&Algorithm[digest]); } argc -= optind; argv += optind; if (*argv) { do { - p = MD5File(*argv, buf); + p = Algorithm[digest].File(*argv, buf); if (!p) { warn("%s", *argv); failed++; @@ -104,11 +170,11 @@ else if (rflag) printf("%s %s\n", p, *argv); else - printf("MD5 (%s) = %s\n", *argv, p); + printf("%s (%s) = %s\n", Algorithm[digest].name, *argv, p); } } while (*++argv); } else if (!sflag && (optind == 1 || qflag || rflag)) - MDFilter(0); + MDFilter(&Algorithm[digest], 0); if (failed != 0) return (1); @@ -119,35 +185,35 @@ * Digests a string and prints the result. */ static void -MDString(const char *string) +MDString(Algorithm_t *alg, const char *string) { size_t len = strlen(string); - char buf[33]; + char buf[HEX_DIGEST_LENGTH]; if (qflag) - printf("%s\n", MD5Data(string, len, buf)); + printf("%s\n", alg->Data(string, len, buf)); else if (rflag) - printf("%s \"%s\"\n", MD5Data(string, len, buf), string); + printf("%s \"%s\"\n", alg->Data(string, len, buf), string); else - printf("MD5 (\"%s\") = %s\n", string, MD5Data(string, len, buf)); + printf("%s (\"%s\") = %s\n", alg->name, string, alg->Data(string, len, buf)); } /* * Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte blocks. */ static void -MDTimeTrial(void) +MDTimeTrial(Algorithm_t *alg) { - MD5_CTX context; + DIGEST_CTX context; struct rusage before, after; struct timeval total; float seconds; unsigned char block[TEST_BLOCK_LEN]; unsigned int i; - char *p, buf[33]; + char *p, buf[HEX_DIGEST_LENGTH]; printf - ("MD5 time trial. Digesting %d %d-byte blocks ...", - TEST_BLOCK_COUNT, TEST_BLOCK_LEN); + ("%s time trial. Digesting %d %d-byte blocks ...", + alg->name, TEST_BLOCK_COUNT, TEST_BLOCK_LEN); fflush(stdout); /* Initialize block */ @@ -158,10 +224,10 @@ getrusage(0, &before); /* Digest blocks */ - MD5Init(&context); + alg->Init(&context); for (i = 0; i < TEST_BLOCK_COUNT; i++) - MD5Update(&context, block, TEST_BLOCK_LEN); - p = MD5End(&context,buf); + alg->Update(&context, block, TEST_BLOCK_LEN); + p = alg->End(&context, buf); /* Stop timer */ getrusage(0, &after); @@ -179,9 +245,7 @@ * Digests a reference suite of strings and prints the results. */ -#define MD5TESTCOUNT 8 - -char *MDTestInput[] = { +const char *MDTestInput[MDTESTCOUNT] = { "", "a", "abc", @@ -189,10 +253,11 @@ "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - "MD5 has not yet (2001-09-03) been broken, but sufficient attacks have been made that its security is in some doubt" + "MD5 has not yet (2001-09-03) been broken, but sufficient attacks have been made \ +that its security is in some doubt" }; -char *MDTestOutput[MD5TESTCOUNT] = { +const char *MD5TestOutput[MDTESTCOUNT] = { "d41d8cd98f00b204e9800998ecf8427e", "0cc175b9c0f1b6a831c399e269772661", "900150983cd24fb0d6963f7d28e17f72", @@ -203,17 +268,39 @@ "b50663f41d44d92171cb9976bc118538" }; +const char *SHA1_TestOutput[MDTESTCOUNT] = { + "da39a3ee5e6b4b0d3255bfef95601890afd80709", + "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", + "a9993e364706816aba3e25717850c26c9cd0d89d", + "c12252ceda8be8994d5fa0290a47231c1d16aae3", + "32d10c7b8cf96570ca04ce37f2a19d84240d3a89", + "761c457bf73b14d27e9e9265c46f4b4dda11f940", + "50abf5706a150990a08b2c5ea40fa0e585554732", + "18eca4333979c4181199b7b4fab8786d16cf2846" +}; + +const char *RIPEMD160_TestOutput[MDTESTCOUNT] = { + "9c1185a5c5e9fc54612808977ee8f548b2258d31", + "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", + "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", + "5d0689ef49d2fae572b881b123a85ffa21595f36", + "f71c27109c692c1b56bbdceb5b9d2865b3708dbc", + "b0e20b6e3116640286ed3a87a5713079b21f5189", + "9b752e45573d4b39f4dbd3323cab82bf63326bfb", + "5feb69c6bf7c29d95715ad55f57d8ac5b2b7dd32" +}; + static void -MDTestSuite(void) +MDTestSuite(Algorithm_t *alg) { int i; - char buffer[33]; + char buffer[HEX_DIGEST_LENGTH]; - printf("MD5 test suite:\n"); - for (i = 0; i < MD5TESTCOUNT; i++) { - MD5Data(MDTestInput[i], strlen(MDTestInput[i]), buffer); - printf("MD5 (\"%s\") = %s", MDTestInput[i], buffer); - if (strcmp(buffer, MDTestOutput[i]) == 0) + printf("%s test suite:\n", alg->name); + for (i = 0; i < MDTESTCOUNT; i++) { + (*alg->Data)(MDTestInput[i], strlen(MDTestInput[i]), buffer); + printf("%s (\"%s\") = %s", alg->name, MDTestInput[i], buffer); + if (strcmp(buffer, (*alg->TestOutput)[i]) == 0) printf(" - verified correct\n"); else printf(" - INCORRECT RESULT!\n"); @@ -224,26 +311,26 @@ * Digests the standard input and prints the result. */ static void -MDFilter(int tee) +MDFilter(Algorithm_t *alg, int tee) { - MD5_CTX context; + DIGEST_CTX context; unsigned int len; unsigned char buffer[BUFSIZ]; - char buf[33]; + char buf[HEX_DIGEST_LENGTH]; - MD5Init(&context); + alg->Init(&context); while ((len = fread(buffer, 1, BUFSIZ, stdin))) { if (tee && len != fwrite(buffer, 1, len, stdout)) err(1, "stdout"); - MD5Update(&context, buffer, len); + alg->Update(&context, buffer, len); } - printf("%s\n", MD5End(&context,buf)); + printf("%s\n", alg->End(&context, buf)); } static void -usage(void) +usage(Algorithm_t *alg) { - fprintf(stderr, "usage: md5 [-pqrtx] [-s string] [files ...]\n"); + fprintf(stderr, "usage: %s [-pqrtx] [-s string] [files ...]\n", alg->progname); exit(1); } ==== //depot/projects/gdb/sbin/sunlabel/sunlabel.c#4 (text+ko) ==== @@ -67,7 +67,7 @@ */ #include -__FBSDID("$FreeBSD: src/sbin/sunlabel/sunlabel.c,v 1.9 2004/06/01 20:32:36 joerg Exp $"); +__FBSDID("$FreeBSD: src/sbin/sunlabel/sunlabel.c,v 1.10 2004/06/11 11:41:33 joerg Exp $"); #include #include @@ -805,9 +805,9 @@ if (hflag) { fprintf(out, " %c: %10s", 'a' + i, - make_h_number(sl->sl_part[i].sdkp_nsectors * 512)); + make_h_number((uintmax_t)sl->sl_part[i].sdkp_nsectors * 512)); fprintf(out, " %10s", - make_h_number(sl->sl_part[i].sdkp_cyloffset * + make_h_number((uintmax_t)sl->sl_part[i].sdkp_cyloffset * 512 * secpercyl)); } else { fprintf(out, " %c: %10ju %10u", ==== //depot/projects/gdb/sys/alpha/alpha/machdep.c#10 (text+ko) ==== @@ -88,7 +88,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.219 2004/04/01 20:56:43 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.220 2004/06/11 11:16:17 phk Exp $"); #include "opt_compat.h" #include "opt_ddb.h" @@ -1165,7 +1165,7 @@ SIGISMEMBER(psp->ps_sigonstack, sig)) { sip = (osiginfo_t *)((caddr_t)td->td_sigstk.ss_sp + td->td_sigstk.ss_size - rndfsize); -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) >>> TRUNCATED FOR MAIL (1000 lines) <<<