From owner-svn-src-stable-7@FreeBSD.ORG Mon Jun 11 07:11:35 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB9B7106566C; Mon, 11 Jun 2012 07:11:35 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8BE458FC12; Mon, 11 Jun 2012 07:11:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5B7BZS6049466; Mon, 11 Jun 2012 07:11:35 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5B7BZOs049463; Mon, 11 Jun 2012 07:11:35 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201206110711.q5B7BZOs049463@svn.freebsd.org> From: Xin LI Date: Mon, 11 Jun 2012 07:11:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236875 - in stable: 7/usr.sbin/inetd 8/usr.sbin/inetd 9/usr.sbin/inetd X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 07:11:35 -0000 Author: delphij Date: Mon Jun 11 07:11:34 2012 New Revision: 236875 URL: http://svn.freebsd.org/changeset/base/236875 Log: MFC r236572: Replace the use of wall clock time with monotonically increasing clock. In general, gettimeofday() is not appropriate interface when accounting for elasped time because it can go backward, in which case the policy code could errornously consider the limit as exceeded. Reported by: Mahesh Arumugam Submitted by: Dorr H. Clark via gnn Sponsored by: Citrix / NetScaler Modified: stable/7/usr.sbin/inetd/inetd.c stable/7/usr.sbin/inetd/inetd.h Directory Properties: stable/7/usr.sbin/inetd/ (props changed) Changes in other areas also in this revision: Modified: stable/8/usr.sbin/inetd/inetd.c stable/8/usr.sbin/inetd/inetd.h stable/9/usr.sbin/inetd/inetd.c stable/9/usr.sbin/inetd/inetd.h Directory Properties: stable/8/usr.sbin/inetd/ (props changed) stable/9/usr.sbin/inetd/ (props changed) Modified: stable/7/usr.sbin/inetd/inetd.c ============================================================================== --- stable/7/usr.sbin/inetd/inetd.c Mon Jun 11 07:08:40 2012 (r236874) +++ stable/7/usr.sbin/inetd/inetd.c Mon Jun 11 07:11:34 2012 (r236875) @@ -684,11 +684,11 @@ main(int argc, char **argv) */ if (dofork) { if (sep->se_count++ == 0) - (void)gettimeofday(&sep->se_time, (struct timezone *)NULL); + (void)clock_gettime(CLOCK_MONOTONIC_FAST, &sep->se_time); else if (toomany > 0 && sep->se_count >= toomany) { - struct timeval now; + struct timespec now; - (void)gettimeofday(&now, (struct timezone *)NULL); + (void)clock_gettime(CLOCK_MONOTONIC_FAST, &now); if (now.tv_sec - sep->se_time.tv_sec > CNT_INTVL) { sep->se_time = now; Modified: stable/7/usr.sbin/inetd/inetd.h ============================================================================== --- stable/7/usr.sbin/inetd/inetd.h Mon Jun 11 07:08:40 2012 (r236874) +++ stable/7/usr.sbin/inetd/inetd.h Mon Jun 11 07:11:34 2012 (r236875) @@ -109,7 +109,7 @@ struct servtab { u_int se_rpc_lowvers; /* RPC low version */ u_int se_rpc_highvers; /* RPC high version */ int se_count; /* number started since se_time */ - struct timeval se_time; /* start of se_count */ + struct timespec se_time; /* start of se_count */ struct servtab *se_next; struct se_flags { u_int se_nomapped : 1; From owner-svn-src-stable-7@FreeBSD.ORG Mon Jun 11 19:05:11 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6B0DB1065670; Mon, 11 Jun 2012 19:05:11 +0000 (UTC) (envelope-from issyl0@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 54E1E8FC12; Mon, 11 Jun 2012 19:05:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BJ5Bg6004322; Mon, 11 Jun 2012 19:05:11 GMT (envelope-from issyl0@svn.freebsd.org) Received: (from issyl0@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BJ5BTs004320; Mon, 11 Jun 2012 19:05:11 GMT (envelope-from issyl0@svn.freebsd.org) Message-Id: <201206111905.q5BJ5BTs004320@svn.freebsd.org> From: Isabell Long Date: Mon, 11 Jun 2012 19:05:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236907 - stable/7/gnu/usr.bin/man/man X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2012 19:05:11 -0000 Author: issyl0 (doc committer) Date: Mon Jun 11 19:05:10 2012 New Revision: 236907 URL: http://svn.freebsd.org/changeset/base/236907 Log: Partial merge of r213507 from head: In r178993, the ability to view a man page by giving a path to the man page itself was added, but never documented. Subsequently, the GNU-licensed man(1) and its man page were replaced by BSD licensed implementations, and later on this undocumented functionality was also added to the new BSD-licensed man(1), together with documentation. This is a merge of the documentation part of that commit (r213507) into the GNU-licensed man(1) man page in stable/7, in order to document the available functionality. PR: docs/158973 Merge help: bz Approved by: gabor (mentor) Modified: stable/7/gnu/usr.bin/man/man/man.man Directory Properties: stable/7/gnu/usr.bin/man/ (props changed) Modified: stable/7/gnu/usr.bin/man/man/man.man ============================================================================== --- stable/7/gnu/usr.bin/man/man/man.man Mon Jun 11 18:47:26 2012 (r236906) +++ stable/7/gnu/usr.bin/man/man/man.man Mon Jun 11 19:05:10 2012 (r236907) @@ -14,7 +14,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 3, 2005 +.Dd October 7, 2010 .Dt MAN 1 .Os .Sh NAME @@ -233,6 +233,13 @@ printed. Do not actually display the man pages, but do print the location(s) of the files that would be formatted or displayed. .El +.Ss Displaying Specific Manual Files +The +.Nm +utility also supports displaying a specific manual page if passed a path +to the file as long as it contains a +.Sq / +character. .Sh ENVIRONMENT .Bl -tag -width ".Ev MACHINE_ARCH" .It Ev LC_ALL , LC_CTYPE , LANG From owner-svn-src-stable-7@FreeBSD.ORG Tue Jun 12 12:10:12 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EF161106567A; Tue, 12 Jun 2012 12:10:11 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9DE98FC0A; Tue, 12 Jun 2012 12:10:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5CCAB41052390; Tue, 12 Jun 2012 12:10:11 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5CCABtB052386; Tue, 12 Jun 2012 12:10:11 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201206121210.q5CCABtB052386@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Tue, 12 Jun 2012 12:10:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236953 - head/sys/amd64/amd64 releng/7.4 releng/7.4/contrib/bind9/lib/dns releng/7.4/sys/amd64/amd64 releng/7.4/sys/conf releng/8.1 releng/8.1/contrib/bind9/lib/dns releng/8.1/sys/amd6... X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 12:10:12 -0000 Author: bz Date: Tue Jun 12 12:10:10 2012 New Revision: 236953 URL: http://svn.freebsd.org/changeset/base/236953 Log: Fix a problem where zero-length RDATA fields can cause named(8) to crash. [12:03] Correct a privilege escalation when returning from kernel if running FreeBSD/amd64 on non-AMD processors. [12:04] Fix reference count errors in IPv6 code. [EN-12:02] Security: CVE-2012-1667 Security: FreeBSD-SA-12:03.bind Security: CVE-2012-0217 Security: FreeBSD-SA-12:04.sysret Security: FreeBSD-EN-12:02.ipv6refcount Approved by: so (simon, bz) Modified: stable/7/contrib/bind9/lib/dns/rdata.c stable/7/contrib/bind9/lib/dns/rdataslab.c stable/7/sys/amd64/amd64/trap.c Changes in other areas also in this revision: Modified: head/sys/amd64/amd64/trap.c releng/7.4/UPDATING releng/7.4/contrib/bind9/lib/dns/rdata.c releng/7.4/contrib/bind9/lib/dns/rdataslab.c releng/7.4/sys/amd64/amd64/trap.c releng/7.4/sys/conf/newvers.sh releng/8.1/UPDATING releng/8.1/contrib/bind9/lib/dns/rdata.c releng/8.1/contrib/bind9/lib/dns/rdataslab.c releng/8.1/sys/amd64/amd64/trap.c releng/8.1/sys/conf/newvers.sh releng/8.1/sys/netinet/tcp_input.c releng/8.1/sys/netinet6/in6.c releng/8.1/sys/netinet6/ip6_input.c releng/8.2/UPDATING releng/8.2/contrib/bind9/lib/dns/rdata.c releng/8.2/contrib/bind9/lib/dns/rdataslab.c releng/8.2/sys/amd64/amd64/trap.c releng/8.2/sys/conf/newvers.sh releng/8.2/sys/netinet/tcp_input.c releng/8.2/sys/netinet6/in6.c releng/8.2/sys/netinet6/ip6_input.c releng/8.3/UPDATING releng/8.3/contrib/bind9/lib/dns/rdata.c releng/8.3/contrib/bind9/lib/dns/rdataslab.c releng/8.3/sys/amd64/amd64/trap.c releng/8.3/sys/conf/newvers.sh releng/8.3/sys/netinet/tcp_input.c releng/8.3/sys/netinet6/in6.c releng/8.3/sys/netinet6/ip6_input.c releng/9.0/UPDATING releng/9.0/contrib/bind9/lib/dns/rdata.c releng/9.0/contrib/bind9/lib/dns/rdataslab.c releng/9.0/sys/amd64/amd64/trap.c releng/9.0/sys/conf/newvers.sh releng/9.0/sys/netinet/tcp_input.c releng/9.0/sys/netinet6/in6.c releng/9.0/sys/netinet6/ip6_input.c stable/8/sys/amd64/amd64/trap.c stable/9/sys/amd64/amd64/trap.c Modified: stable/7/contrib/bind9/lib/dns/rdata.c ============================================================================== --- stable/7/contrib/bind9/lib/dns/rdata.c Tue Jun 12 11:08:51 2012 (r236952) +++ stable/7/contrib/bind9/lib/dns/rdata.c Tue Jun 12 12:10:10 2012 (r236953) @@ -334,8 +334,8 @@ dns_rdata_compare(const dns_rdata_t *rda REQUIRE(rdata1 != NULL); REQUIRE(rdata2 != NULL); - REQUIRE(rdata1->data != NULL); - REQUIRE(rdata2->data != NULL); + REQUIRE(rdata1->length == 0 || rdata1->data != NULL); + REQUIRE(rdata2->length == 0 || rdata2->data != NULL); REQUIRE(DNS_RDATA_VALIDFLAGS(rdata1)); REQUIRE(DNS_RDATA_VALIDFLAGS(rdata2)); Modified: stable/7/contrib/bind9/lib/dns/rdataslab.c ============================================================================== --- stable/7/contrib/bind9/lib/dns/rdataslab.c Tue Jun 12 11:08:51 2012 (r236952) +++ stable/7/contrib/bind9/lib/dns/rdataslab.c Tue Jun 12 12:10:10 2012 (r236953) @@ -128,6 +128,11 @@ isc_result_t dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, isc_region_t *region, unsigned int reservelen) { + /* + * Use &removed as a sentinal pointer for duplicate + * rdata as rdata.data == NULL is valid. + */ + static unsigned char removed; struct xrdata *x; unsigned char *rawbuf; #if DNS_RDATASET_FIXED @@ -166,6 +171,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_ INSIST(result == ISC_R_SUCCESS); dns_rdata_init(&x[i].rdata); dns_rdataset_current(rdataset, &x[i].rdata); + INSIST(x[i].rdata.data != &removed); #if DNS_RDATASET_FIXED x[i].order = i; #endif @@ -198,8 +204,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_ */ for (i = 1; i < nalloc; i++) { if (compare_rdata(&x[i-1].rdata, &x[i].rdata) == 0) { - x[i-1].rdata.data = NULL; - x[i-1].rdata.length = 0; + x[i-1].rdata.data = &removed; #if DNS_RDATASET_FIXED /* * Preserve the least order so A, B, A -> A, B @@ -275,7 +280,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_ #endif for (i = 0; i < nalloc; i++) { - if (x[i].rdata.data == NULL) + if (x[i].rdata.data == &removed) continue; #if DNS_RDATASET_FIXED offsettable[x[i].order] = rawbuf - offsetbase; Modified: stable/7/sys/amd64/amd64/trap.c ============================================================================== --- stable/7/sys/amd64/amd64/trap.c Tue Jun 12 11:08:51 2012 (r236952) +++ stable/7/sys/amd64/amd64/trap.c Tue Jun 12 12:10:10 2012 (r236953) @@ -972,6 +972,23 @@ syscall(struct trapframe *frame) /* * Traced syscall. */ + + /* + * If the user-supplied value of %rip is not a canonical + * address, then some CPUs will trigger a ring 0 #GP during + * the sysret instruction. However, the fault handler would + * execute with the user's %gs and %rsp in ring 0 which would + * not be safe. Instead, preemptively kill the thread with a + * SIGBUS. + */ + if (td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)td->td_frame->tf_rip; + trapsignal(td, &ksi); + } if (orig_tf_rflags & PSL_T) { frame->tf_rflags &= ~PSL_T; ksiginfo_init_trap(&ksi); From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 13 03:29:57 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E40F6106566B; Wed, 13 Jun 2012 03:29:57 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CF58D8FC12; Wed, 13 Jun 2012 03:29:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D3TvUp092620; Wed, 13 Jun 2012 03:29:57 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D3Tv8O092618; Wed, 13 Jun 2012 03:29:57 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206130329.q5D3Tv8O092618@svn.freebsd.org> From: Eitan Adler Date: Wed, 13 Jun 2012 03:29:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236981 - stable/7/lib/libc/stdio X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 03:29:58 -0000 Author: eadler Date: Wed Jun 13 03:29:57 2012 New Revision: 236981 URL: http://svn.freebsd.org/changeset/base/236981 Log: MFC r236288: Only set _w to 0 when the file stream is not currently reading. Without this fflush may fail to write data in the buffer. PR: kern/137819 Approved by: cperciva (implicit) Modified: stable/7/lib/libc/stdio/fpurge.c Directory Properties: stable/7/lib/libc/ (props changed) Modified: stable/7/lib/libc/stdio/fpurge.c ============================================================================== --- stable/7/lib/libc/stdio/fpurge.c Wed Jun 13 03:19:11 2012 (r236980) +++ stable/7/lib/libc/stdio/fpurge.c Wed Jun 13 03:29:57 2012 (r236981) @@ -62,7 +62,7 @@ fpurge(fp) FREEUB(fp); fp->_p = fp->_bf._base; fp->_r = 0; - fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size; + fp->_w = fp->_flags & (__SLBF|__SNBF|__SRD) ? 0 : fp->_bf._size; retval = 0; } FUNLOCKFILE(fp); From owner-svn-src-stable-7@FreeBSD.ORG Wed Jun 13 03:41:42 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9961B1065674; Wed, 13 Jun 2012 03:41:42 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 841AB8FC0A; Wed, 13 Jun 2012 03:41:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5D3fgjG093338; Wed, 13 Jun 2012 03:41:42 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5D3fgIB093336; Wed, 13 Jun 2012 03:41:42 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206130341.q5D3fgIB093336@svn.freebsd.org> From: Eitan Adler Date: Wed, 13 Jun 2012 03:41:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236986 - stable/7/usr.bin/mail X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 03:41:42 -0000 Author: eadler Date: Wed Jun 13 03:41:42 2012 New Revision: 236986 URL: http://svn.freebsd.org/changeset/base/236986 Log: MFC r236286: Fix likely race condition if wait_child() is interrupted by sigchild() PR: bin/102834 Approved by: cperciva (implicit) Modified: stable/7/usr.bin/mail/popen.c Directory Properties: stable/7/usr.bin/mail/ (props changed) Modified: stable/7/usr.bin/mail/popen.c ============================================================================== --- stable/7/usr.bin/mail/popen.c Wed Jun 13 03:41:22 2012 (r236985) +++ stable/7/usr.bin/mail/popen.c Wed Jun 13 03:41:42 2012 (r236986) @@ -364,12 +364,14 @@ wait_child(pid) int pid; { sigset_t nset, oset; - struct child *cp = findchild(pid); + struct child *cp; (void)sigemptyset(&nset); (void)sigaddset(&nset, SIGCHLD); (void)sigprocmask(SIG_BLOCK, &nset, &oset); + cp = findchild(pid); + while (!cp->done) (void)sigsuspend(&oset); wait_status = cp->status; From owner-svn-src-stable-7@FreeBSD.ORG Thu Jun 14 06:55:41 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1E665106585C; Thu, 14 Jun 2012 06:55:41 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 086498FC0C; Thu, 14 Jun 2012 06:55:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E6tebF076786; Thu, 14 Jun 2012 06:55:40 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5E6teb0076783; Thu, 14 Jun 2012 06:55:40 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201206140655.q5E6teb0076783@svn.freebsd.org> From: Eitan Adler Date: Thu, 14 Jun 2012 06:55:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237051 - stable/7/usr.sbin/mptutil X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 06:55:41 -0000 Author: eadler Date: Thu Jun 14 06:55:40 2012 New Revision: 237051 URL: http://svn.freebsd.org/changeset/base/237051 Log: MFC r236287: add missing variable declaration when DEBUG is defined forgotten in r215046 PR: bin/166404 Approved by: cperciva (implicit) Modified: stable/7/usr.sbin/mptutil/mpt_show.c Directory Properties: stable/7/usr.sbin/mptutil/ (props changed) Modified: stable/7/usr.sbin/mptutil/mpt_show.c ============================================================================== --- stable/7/usr.sbin/mptutil/mpt_show.c Thu Jun 14 06:55:16 2012 (r237050) +++ stable/7/usr.sbin/mptutil/mpt_show.c Thu Jun 14 06:55:40 2012 (r237051) @@ -538,7 +538,7 @@ show_physdisks(int ac, char **av) { CONFIG_PAGE_RAID_PHYS_DISK_0 *pinfo; U16 IOCStatus; - int fd, i; + int error, fd, i; if (ac != 1) { warnx("show drives: extra arguments"); From owner-svn-src-stable-7@FreeBSD.ORG Thu Jun 14 11:39:43 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7AF7106566B; Thu, 14 Jun 2012 11:39:43 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id B27688FC0C; Thu, 14 Jun 2012 11:39:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EBdhgp091836; Thu, 14 Jun 2012 11:39:43 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EBdhdd091833; Thu, 14 Jun 2012 11:39:43 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201206141139.q5EBdhdd091833@svn.freebsd.org> From: Sergey Kandaurov Date: Thu, 14 Jun 2012 11:39:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237060 - stable/7/share/man/man9 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 11:39:43 -0000 Author: pluknet Date: Thu Jun 14 11:39:43 2012 New Revision: 237060 URL: http://svn.freebsd.org/changeset/base/237060 Log: MFC r234188, r234463, r234465 (partially, except softclock_ih): - Update the swi_add prototype after struct ithd was split up into struct intr_event and struct intr_thread. [1] - Update the rest of struct ithd references. - net_ih cookie has gone away. - Document swi_remove(9). PR: docs/166864 [1] Modified: stable/7/share/man/man9/Makefile stable/7/share/man/man9/swi.9 Directory Properties: stable/7/share/man/man9/ (props changed) Modified: stable/7/share/man/man9/Makefile ============================================================================== --- stable/7/share/man/man9/Makefile Thu Jun 14 11:21:21 2012 (r237059) +++ stable/7/share/man/man9/Makefile Thu Jun 14 11:39:43 2012 (r237060) @@ -1096,6 +1096,7 @@ MLINKS+=store.9 subyte.9 \ store.9 suword.9 MLINKS+=suser.9 suser_cred.9 MLINKS+=swi.9 swi_add.9 \ + swi.9 swi_remove.9 \ swi.9 swi_sched.9 MLINKS+=sx.9 sx_assert.9 \ sx.9 sx_destroy.9 \ Modified: stable/7/share/man/man9/swi.9 ============================================================================== --- stable/7/share/man/man9/swi.9 Thu Jun 14 11:21:21 2012 (r237059) +++ stable/7/share/man/man9/swi.9 Thu Jun 14 11:39:43 2012 (r237060) @@ -24,25 +24,25 @@ .\" .\" $FreeBSD$ .\" -.Dd October 30, 2000 +.Dd April 19, 2012 .Dt SWI 9 .Os .Sh NAME .Nm swi_add , +.Nm swi_remove , .Nm swi_sched .Nd register and schedule software interrupt handlers .Sh SYNOPSIS .In sys/param.h .In sys/bus.h .In sys/interrupt.h -.Vt "extern struct ithd *tty_ithd" ; -.Vt "extern struct ithd *clk_ithd" ; -.Vt "extern void *net_ih" ; +.Vt "extern struct intr_event *tty_intr_event" ; +.Vt "extern struct intr_event *clk_intr_event" ; .Vt "extern void *softclock_ih" ; .Vt "extern void *vm_ih" ; .Ft int .Fo swi_add -.Fa "struct ithd **ithdp" +.Fa "struct intr_event **eventp" .Fa "const char *name" .Fa "driver_intr_t handler" .Fa "void *arg" @@ -50,6 +50,8 @@ .Fa "enum intr_type flags" .Fa "void **cookiep" .Fc +.Ft int +.Fn swi_remove "void *cookie" .Ft void .Fn swi_sched "void *cookie" "int flags" .Sh DESCRIPTION @@ -67,20 +69,21 @@ time, and that they can be run via a lig .Pp The .Fn swi_add -function is used to register a new software interrupt handler. +function is used to add a new software interrupt handler to a specified +interrupt event. The -.Fa ithdp +.Fa eventp argument is an optional pointer to a -.Vt struct ithd +.Vt struct intr_event pointer. -If this argument points to an existing software interrupt thread, then this -handler will be attached to that thread. -Otherwise a new thread will be created, and if -.Fa ithdp +If this argument points to an existing event that holds a list of +interrupt handlers, then this handler will be attached to that event. +Otherwise a new event will be created, and if +.Fa eventp is not .Dv NULL , then the pointer at that address to will be modified to point to the -newly created thread. +newly created event. The .Fa name argument is used to associate a name with a specific handler. @@ -99,7 +102,7 @@ The .Fa pri value specifies the priority of this interrupt handler relative to other software interrupt handlers. -If an interrupt thread is created, then this value is used as the vector, +If an interrupt event is created, then this value is used as the vector, and the .Fa flags argument is used to specify the attributes of a handler such as @@ -113,6 +116,14 @@ This cookie will be set to a value that and is used to schedule the handler for execution later on. .Pp The +.Fn swi_remove +function is used to teardown an interrupt handler pointed to by the +.Fa cookie +argument. +It detaches the interrupt handler from the associated interrupt event +and frees its memory. +.Pp +The .Fn swi_sched function is used to schedule an interrupt handler and its associated thread to run. @@ -140,30 +151,31 @@ in earlier versions of .El .Pp The -.Va tty_ithd +.Va tty_intr_event and -.Va clk_ithd -variables contain pointers to the software interrupt threads for the tty and +.Va clk_intr_event +variables contain pointers to the software interrupt handlers for the tty and clock software interrupts, respectively. -.Va tty_ithd +.Va tty_intr_event is used to hang tty software interrupt handlers off of the same thread. -.Va clk_ithd +.Va clk_intr_event is used to hang delayed handlers off of the clock software interrupt thread so that the functionality of .Fn setdelayed can be obtained in conjunction with .Dv SWI_DELAY . The -.Va net_ih , -.Va softclock_ih , +.Va softclock_ih and .Va vm_ih handler cookies are used to schedule software interrupt threads to run for the -networking stack, clock interrupt, and VM subsystem respectively. +clock interrupt and VM subsystem respectively. .Sh RETURN VALUES The .Fn swi_add -function returns zero on success and non-zero on failure. +and +.Fn swi_remove +functions return zero on success and non-zero on failure. .Sh ERRORS The .Fn swi_add @@ -185,7 +197,7 @@ or .Dv INTR_FAST . .It Bq Er EINVAL The -.Fa ithdp +.Fa eventp argument points to a hardware interrupt thread. .It Bq Er EINVAL Either of the @@ -197,11 +209,22 @@ arguments are .It Bq Er EINVAL The .Dv INTR_EXCL -flag is specified and the interrupt thread pointed to by -.Fa ithdp -already has at least one handler, or the interrupt thread already has an +flag is specified and the interrupt event pointed to by +.Fa eventp +already has at least one handler, or the interrupt event already has an exclusive handler. .El +.Pp +The +.Fn swi_remove +function will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +A software interrupt handler pointed to by +.Fa cookie +is +.Dv NULL . +.El .Sh SEE ALSO .Xr ithread 9 , .Xr taskqueue 9 @@ -222,6 +245,10 @@ and .Fn schedsoft* functions which date back to at least .Bx 4.4 . +The +.Fn swi_remove +function first appeared in +.Fx 6.1 . .Sh BUGS Most of the global variables described in this manual page should not be global, or at the very least should not be declared in From owner-svn-src-stable-7@FreeBSD.ORG Sat Jun 16 09:17:22 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6C79106564A; Sat, 16 Jun 2012 09:17:22 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EE108FC0C; Sat, 16 Jun 2012 09:17:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5G9HM2s034128; Sat, 16 Jun 2012 09:17:22 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5G9HMIo034112; Sat, 16 Jun 2012 09:17:22 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201206160917.q5G9HMIo034112@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Sat, 16 Jun 2012 09:17:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237157 - in stable/7/lib: libcrypt libmd X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jun 2012 09:17:22 -0000 Author: des Date: Sat Jun 16 09:17:21 2012 New Revision: 237157 URL: http://svn.freebsd.org/changeset/base/237157 Log: Backport sha512 support. Added: stable/7/lib/libcrypt/crypt-sha256.c - copied, changed from r220498, head/lib/libcrypt/crypt-sha256.c stable/7/lib/libcrypt/crypt-sha512.c - copied, changed from r220498, head/lib/libcrypt/crypt-sha512.c stable/7/lib/libmd/sha512.3 - copied, changed from r220496, head/lib/libmd/sha512.3 stable/7/lib/libmd/sha512.h - copied unchanged from r220496, head/lib/libmd/sha512.h stable/7/lib/libmd/sha512c.c - copied unchanged from r220496, head/lib/libmd/sha512c.c Modified: stable/7/lib/libcrypt/Makefile stable/7/lib/libcrypt/crypt.3 stable/7/lib/libcrypt/crypt.c stable/7/lib/libcrypt/crypt.h stable/7/lib/libcrypt/misc.c stable/7/lib/libmd/Makefile stable/7/lib/libmd/mddriver.c stable/7/lib/libmd/rmddriver.c stable/7/lib/libmd/sha256.3 stable/7/lib/libmd/shadriver.c Directory Properties: stable/7/lib/libcrypt/ (props changed) stable/7/lib/libmd/ (props changed) Modified: stable/7/lib/libcrypt/Makefile ============================================================================== --- stable/7/lib/libcrypt/Makefile Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libcrypt/Makefile Sat Jun 16 09:17:21 2012 (r237157) @@ -12,7 +12,9 @@ LIB= crypt .PATH: ${.CURDIR}/../libmd SRCS= crypt.c misc.c \ crypt-md5.c md5c.c \ - crypt-nthash.c md4c.c + crypt-nthash.c md4c.c \ + crypt-sha256.c sha256c.c \ + crypt-sha512.c sha512c.c MAN= crypt.3 MLINKS= crypt.3 crypt_get_format.3 crypt.3 crypt_set_format.3 CFLAGS+= -I${.CURDIR}/../libmd -I${.CURDIR}/../libutil @@ -29,7 +31,9 @@ CFLAGS+= -I${.CURDIR} -DHAS_DES -DHAS_BL SRCS+= auth.c property.c .for sym in auth_getval property_find properties_read properties_free \ MD4Init MD4Final MD4Update MD4Pad \ - MD5Init MD5Final MD5Update MD5Pad + MD5Init MD5Final MD5Update MD5Pad \ + SHA256_Init SHA256_Final SHA256_Update \ + SHA512_Init SHA512_Final SHA512_Update CFLAGS+= -D${sym}=__${sym} .endfor Copied and modified: stable/7/lib/libcrypt/crypt-sha256.c (from r220498, head/lib/libcrypt/crypt-sha256.c) ============================================================================== --- head/lib/libcrypt/crypt-sha256.c Sat Apr 9 14:09:46 2011 (r220498, copy source) +++ stable/7/lib/libcrypt/crypt-sha256.c Sat Jun 16 09:17:21 2012 (r237157) @@ -60,7 +60,7 @@ static const char sha256_rounds_prefix[] #define ROUNDS_MAX 999999999 static char * -sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen) +crypt_sha256_r(const char *key, const char *salt, char *buffer, int buflen) { u_long srounds; int n; @@ -210,7 +210,9 @@ sha256_crypt_r(const char *key, const ch /* Now we can construct the result string. It consists of three * parts. */ - cp = stpncpy(buffer, sha256_salt_prefix, MAX(0, buflen)); + cp = buffer; + strncpy(buffer, sha256_salt_prefix, MAX(0, buflen)); + cp += sizeof(sha256_salt_prefix) - 1; buflen -= sizeof(sha256_salt_prefix) - 1; if (rounds_custom) { @@ -221,7 +223,8 @@ sha256_crypt_r(const char *key, const ch buflen -= n; } - cp = stpncpy(cp, salt, MIN((size_t)MAX(0, buflen), salt_len)); + strncpy(cp, salt, MIN((size_t)MAX(0, buflen), salt_len)); + cp += MIN((size_t)MAX(0, buflen), salt_len); buflen -= MIN((size_t)MAX(0, buflen), salt_len); if (buflen > 0) { @@ -268,12 +271,12 @@ sha256_crypt_r(const char *key, const ch /* This entry point is equivalent to crypt(3). */ char * -sha256_crypt(const char *key, const char *salt) +crypt_sha256(const char *key, const char *salt) { /* We don't want to have an arbitrary limit in the size of the * password. We can compute an upper bound for the size of the * result in advance and so we can prepare the buffer we pass to - * `sha256_crypt_r'. */ + * `crypt_sha256_r'. */ static char *buffer; static int buflen; int needed; @@ -293,7 +296,7 @@ sha256_crypt(const char *key, const char buflen = needed; } - return sha256_crypt_r(key, salt, buffer, buflen); + return crypt_sha256_r(key, salt, buffer, buflen); } #ifdef TEST @@ -459,7 +462,7 @@ main(void) } for (cnt = 0; cnt < ntests2; ++cnt) { - char *cp = sha256_crypt(tests2[cnt].input, tests2[cnt].salt); + char *cp = crypt_sha256(tests2[cnt].input, tests2[cnt].salt); if (strcmp(cp, tests2[cnt].expected) != 0) { printf("test %d: expected \"%s\", got \"%s\"\n", Copied and modified: stable/7/lib/libcrypt/crypt-sha512.c (from r220498, head/lib/libcrypt/crypt-sha512.c) ============================================================================== --- head/lib/libcrypt/crypt-sha512.c Sat Apr 9 14:09:46 2011 (r220498, copy source) +++ stable/7/lib/libcrypt/crypt-sha512.c Sat Jun 16 09:17:21 2012 (r237157) @@ -60,7 +60,7 @@ static const char sha512_rounds_prefix[] #define ROUNDS_MAX 999999999 static char * -sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) +crypt_sha512_r(const char *key, const char *salt, char *buffer, int buflen) { u_long srounds; int n; @@ -210,7 +210,9 @@ sha512_crypt_r(const char *key, const ch /* Now we can construct the result string. It consists of three * parts. */ - cp = stpncpy(buffer, sha512_salt_prefix, MAX(0, buflen)); + cp = buffer; + strncpy(buffer, sha512_salt_prefix, MAX(0, buflen)); + cp += sizeof(sha512_salt_prefix) - 1; buflen -= sizeof(sha512_salt_prefix) - 1; if (rounds_custom) { @@ -221,7 +223,8 @@ sha512_crypt_r(const char *key, const ch buflen -= n; } - cp = stpncpy(cp, salt, MIN((size_t)MAX(0, buflen), salt_len)); + strncpy(cp, salt, MIN((size_t)MAX(0, buflen), salt_len)); + cp += MIN((size_t)MAX(0, buflen), salt_len); buflen -= MIN((size_t)MAX(0, buflen), salt_len); if (buflen > 0) { @@ -280,12 +283,12 @@ sha512_crypt_r(const char *key, const ch /* This entry point is equivalent to crypt(3). */ char * -sha512_crypt(const char *key, const char *salt) +crypt_sha512(const char *key, const char *salt) { /* We don't want to have an arbitrary limit in the size of the * password. We can compute an upper bound for the size of the * result in advance and so we can prepare the buffer we pass to - * `sha512_crypt_r'. */ + * `crypt_sha512_r'. */ static char *buffer; static int buflen; int needed; @@ -305,7 +308,7 @@ sha512_crypt(const char *key, const char buflen = needed; } - return sha512_crypt_r(key, salt, buffer, buflen); + return crypt_sha512_r(key, salt, buffer, buflen); } #ifdef TEST @@ -482,7 +485,7 @@ main(void) } for (cnt = 0; cnt < ntests2; ++cnt) { - char *cp = sha512_crypt(tests2[cnt].input, tests2[cnt].salt); + char *cp = crypt_sha512(tests2[cnt].input, tests2[cnt].salt); if (strcmp(cp, tests2[cnt].expected) != 0) { printf("test %d: expected \"%s\", got \"%s\"\n", Modified: stable/7/lib/libcrypt/crypt.3 ============================================================================== --- stable/7/lib/libcrypt/crypt.3 Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libcrypt/crypt.3 Sat Jun 16 09:17:21 2012 (r237157) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 19, 1997 +.Dd April 9, 2011 .Dt CRYPT 3 .Os .Sh NAME @@ -188,6 +188,12 @@ MD5 Blowfish .It NT-Hash +.It +(unused) +.It +SHA-256 +.It +SHA-512 .El .Pp Other crypt formats may be easily added. @@ -226,7 +232,9 @@ Valid values are .\" .Ql des , .Ql blf , -.Ql md5 +.Ql md5 , +.Ql sha256 , +.Ql sha512 and .Ql nth . .Pp Modified: stable/7/lib/libcrypt/crypt.c ============================================================================== --- stable/7/lib/libcrypt/crypt.c Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libcrypt/crypt.c Sat Jun 16 09:17:21 2012 (r237157) @@ -63,6 +63,16 @@ static const struct { "$3$" }, { + "sha256", + crypt_sha256, + "$5$" + }, + { + "sha512", + crypt_sha512, + "$6$" + }, + { NULL, NULL, NULL Modified: stable/7/lib/libcrypt/crypt.h ============================================================================== --- stable/7/lib/libcrypt/crypt.h Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libcrypt/crypt.h Sat Jun 16 09:17:21 2012 (r237157) @@ -36,5 +36,8 @@ char *crypt_des(const char *pw, const ch char *crypt_md5(const char *pw, const char *salt); char *crypt_nthash(const char *pw, const char *salt); char *crypt_blowfish(const char *pw, const char *salt); +char *crypt_sha256 (const char *pw, const char *salt); +char *crypt_sha512 (const char *pw, const char *salt); extern void _crypt_to64(char *s, u_long v, int n); +extern void b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, int *buflen, char **cp); Modified: stable/7/lib/libcrypt/misc.c ============================================================================== --- stable/7/lib/libcrypt/misc.c Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libcrypt/misc.c Sat Jun 16 09:17:21 2012 (r237157) @@ -45,3 +45,19 @@ _crypt_to64(char *s, u_long v, int n) v >>= 6; } } + +void +b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, int *buflen, char **cp) +{ + uint32_t w; + int i; + + w = (B2 << 16) | (B1 << 8) | B0; + for (i = 0; i < n; i++) { + **cp = itoa64[w&0x3f]; + (*cp)++; + if ((*buflen)-- < 0) + break; + w >>= 6; + } +} Modified: stable/7/lib/libmd/Makefile ============================================================================== --- stable/7/lib/libmd/Makefile Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libmd/Makefile Sat Jun 16 09:17:21 2012 (r237157) @@ -5,10 +5,11 @@ SHLIBDIR?= /lib SRCS= md2c.c md4c.c md5c.c md2hl.c md4hl.c md5hl.c \ rmd160c.c rmd160hl.c \ sha0c.c sha0hl.c sha1c.c sha1hl.c \ - sha256c.c sha256hl.c -INCS= md2.h md4.h md5.h ripemd.h sha.h sha256.h + sha256c.c sha256hl.c \ + sha512c.c sha512hl.c +INCS= md2.h md4.h md5.h ripemd.h sha.h sha256.h sha512.h -MAN+= md2.3 md4.3 md5.3 ripemd.3 sha.3 sha256.3 +MAN+= md2.3 md4.3 md5.3 ripemd.3 sha.3 sha256.3 sha512.3 MLINKS+=md2.3 MD2Init.3 md2.3 MD2Update.3 md2.3 MD2Final.3 MLINKS+=md2.3 MD2End.3 md2.3 MD2File.3 md2.3 MD2FileChunk.3 MLINKS+=md2.3 MD2Data.3 @@ -32,10 +33,15 @@ MLINKS+=sha256.3 SHA256_Init.3 sha256.3 MLINKS+=sha256.3 SHA256_Final.3 sha256.3 SHA256_End.3 MLINKS+=sha256.3 SHA256_File.3 sha256.3 SHA256_FileChunk.3 MLINKS+=sha256.3 SHA256_Data.3 +MLINKS+=sha512.3 SHA512_Init.3 sha512.3 SHA512_Update.3 +MLINKS+=sha512.3 SHA512_Final.3 sha512.3 SHA512_End.3 +MLINKS+=sha512.3 SHA512_File.3 sha512.3 SHA512_FileChunk.3 +MLINKS+=sha512.3 SHA512_Data.3 CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \ rmd160.ref rmd160hl.c rmddriver \ sha0.ref sha0hl.c sha1.ref sha1hl.c shadriver \ - sha256.ref sha256hl.c + sha256.ref sha256hl.c sha512.ref sha512hl.c + CFLAGS+= -I${.CURDIR} .PATH: ${.CURDIR}/${MACHINE_ARCH} @@ -76,6 +82,12 @@ sha256hl.c: mdXhl.c -e 's/SHA256__/SHA256_/g' \ ${.ALLSRC}) > ${.TARGET} +sha512hl.c: mdXhl.c + (echo '#define LENGTH 64'; \ + sed -e 's/mdX/sha512/g' -e 's/MDX/SHA512_/g' \ + -e 's/SHA512__/SHA512_/g' \ + ${.ALLSRC}) > ${.TARGET} + rmd160hl.c: mdXhl.c (echo '#define LENGTH 20'; \ sed -e 's/mdX/ripemd/g' -e 's/MDX/RIPEMD160_/g' \ @@ -105,8 +117,10 @@ md4.ref: @echo 'MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d' >> ${.TARGET} @echo 'MD4 ("message digest") = d9130a8164549fe818874806e1c7014b' >> ${.TARGET} @echo 'MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9' >> ${.TARGET} - @echo 'MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = 043f8582f241db351ce627e153e7f0e4' >> ${.TARGET} - @echo 'MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536' >> ${.TARGET} + @echo 'MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + '043f8582f241db351ce627e153e7f0e4' >> ${.TARGET} + @echo 'MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + 'e33b4ddc9c38f2199c3e7b164fcc0536' >> ${.TARGET} md5.ref: echo 'MD5 test suite:' > ${.TARGET} @@ -119,54 +133,74 @@ md5.ref: @echo 'MD5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a' >> ${.TARGET} sha0.ref: - (echo 'SHA-0 test suite:'; \ - echo 'SHA-0 ("") = f96cea198ad1dd5617ac084a3d92c6107708c0ef'; \ - echo 'SHA-0 ("abc") = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880'; \ - echo 'SHA-0 ("message digest") =' \ - 'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14'; \ - echo 'SHA-0 ("abcdefghijklmnopqrstuvwxyz") =' \ - 'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd'; \ - echo 'SHA-0 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ - '79e966f7a3a990df33e40e3d7f8f18d2caebadfa'; \ - echo 'SHA-0 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ - '4aa29d14d171522ece47bee8957e35a41f3e9cff' ) > ${.TARGET} + echo 'SHA-0 test suite:' > ${.TARGET} + @echo 'SHA-0 ("") = f96cea198ad1dd5617ac084a3d92c6107708c0ef' >> ${.TARGET} + @echo 'SHA-0 ("abc") = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880' >> ${.TARGET} + @echo 'SHA-0 ("message digest") =' \ + 'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14' >> ${.TARGET} + @echo 'SHA-0 ("abcdefghijklmnopqrstuvwxyz") =' \ + 'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd' >> ${.TARGET} + @echo 'SHA-0 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + '79e966f7a3a990df33e40e3d7f8f18d2caebadfa' >> ${.TARGET} + @echo 'SHA-0 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + '4aa29d14d171522ece47bee8957e35a41f3e9cff' >> ${.TARGET} sha1.ref: - (echo 'SHA-1 test suite:'; \ - echo 'SHA-1 ("") = da39a3ee5e6b4b0d3255bfef95601890afd80709'; \ - echo 'SHA-1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d'; \ - echo 'SHA-1 ("message digest") =' \ - 'c12252ceda8be8994d5fa0290a47231c1d16aae3'; \ - echo 'SHA-1 ("abcdefghijklmnopqrstuvwxyz") =' \ - '32d10c7b8cf96570ca04ce37f2a19d84240d3a89'; \ - echo 'SHA-1 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ - '761c457bf73b14d27e9e9265c46f4b4dda11f940'; \ - echo 'SHA-1 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ - '50abf5706a150990a08b2c5ea40fa0e585554732' ) > ${.TARGET} + echo 'SHA-1 test suite:' > ${.TARGET} + @echo 'SHA-1 ("") = da39a3ee5e6b4b0d3255bfef95601890afd80709' >> ${.TARGET} + @echo 'SHA-1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d' >> ${.TARGET} + @echo 'SHA-1 ("message digest") =' \ + 'c12252ceda8be8994d5fa0290a47231c1d16aae3' >> ${.TARGET} + @echo 'SHA-1 ("abcdefghijklmnopqrstuvwxyz") =' \ + '32d10c7b8cf96570ca04ce37f2a19d84240d3a89' >> ${.TARGET} + @echo 'SHA-1 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + '761c457bf73b14d27e9e9265c46f4b4dda11f940' >> ${.TARGET} + @echo 'SHA-1 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + '50abf5706a150990a08b2c5ea40fa0e585554732' >> ${.TARGET} sha256.ref: echo 'SHA-256 test suite:' > ${.TARGET} @echo 'SHA-256 ("") = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' >> ${.TARGET} - @echo 'SHA-256 ("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' >> ${.TARGET} - @echo 'SHA-256 ("message digest") = f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650' >> ${.TARGET} - @echo 'SHA-256 ("abcdefghijklmnopqrstuvwxyz") = 71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73' >> ${.TARGET} - @echo 'SHA-256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0' >> ${.TARGET} - @echo 'SHA-256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e' >> ${.TARGET} + @echo 'SHA-256 ("abc") =' \ + 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' >> ${.TARGET} + @echo 'SHA-256 ("message digest") =' \ + 'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650' >> ${.TARGET} + @echo 'SHA-256 ("abcdefghijklmnopqrstuvwxyz") =' \ + '71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73' >> ${.TARGET} + @echo 'SHA-256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + 'db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0' >> ${.TARGET} + @echo 'SHA-256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + 'f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e' >> ${.TARGET} + +sha512.ref: + echo 'SHA-512 test suite:' > ${.TARGET} + @echo 'SHA-512 ("") =' \ + 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e' >> ${.TARGET} + @echo 'SHA-512 ("abc") =' \ + 'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f' >> ${.TARGET} + @echo 'SHA-512 ("message digest") =' \ + '107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c' >> ${.TARGET} + @echo 'SHA-512 ("abcdefghijklmnopqrstuvwxyz") =' \ + '4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1' >> ${.TARGET} + @echo 'SHA-512 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + '1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894' >> ${.TARGET} + @echo 'SHA-512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + '72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843' >> ${.TARGET} rmd160.ref: - (echo 'RIPEMD160 test suite:'; \ - echo 'RIPEMD160 ("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31'; \ - echo 'RIPEMD160 ("abc") = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc'; \ - echo 'RIPEMD160 ("message digest") =' \ - '5d0689ef49d2fae572b881b123a85ffa21595f36'; \ - echo 'RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") =' \ - 'f71c27109c692c1b56bbdceb5b9d2865b3708dbc'; \ - echo 'RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ - 'b0e20b6e3116640286ed3a87a5713079b21f5189'; \ - echo 'RIPEMD160 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ - '9b752e45573d4b39f4dbd3323cab82bf63326bfb' ) > ${.TARGET} + echo 'RIPEMD160 test suite:' > ${.TARGET} + @echo 'RIPEMD160 ("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31' >> ${.TARGET} + @echo 'RIPEMD160 ("abc") = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc' >> ${.TARGET} + @echo 'RIPEMD160 ("message digest") =' \ + '5d0689ef49d2fae572b881b123a85ffa21595f36' >> ${.TARGET} + @echo 'RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") =' \ + 'f71c27109c692c1b56bbdceb5b9d2865b3708dbc' >> ${.TARGET} + @echo 'RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \ + 'b0e20b6e3116640286ed3a87a5713079b21f5189' >> ${.TARGET} + @echo 'RIPEMD160 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \ + '9b752e45573d4b39f4dbd3323cab82bf63326bfb' >> ${.TARGET} -test: md2.ref md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha256.ref +test: md2.ref md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha256.ref sha512.ref @${ECHO} if any of these test fail, the code produces wrong results @${ECHO} and should NOT be used. ${CC} ${CFLAGS} ${LDFLAGS} -DMD=2 -o mddriver ${.CURDIR}/mddriver.c -L. -lmd @@ -192,6 +226,9 @@ test: md2.ref md4.ref md5.ref sha0.ref r ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=256 -o shadriver ${.CURDIR}/shadriver.c -L. -lmd ./shadriver | cmp sha256.ref - @${ECHO} SHA-256 passed test + ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512 -o shadriver ${.CURDIR}/shadriver.c libmd.a + ./shadriver | cmp sha512.ref - + @${ECHO} SHA-512 passed test -rm -f shadriver .include Modified: stable/7/lib/libmd/mddriver.c ============================================================================== --- stable/7/lib/libmd/mddriver.c Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libmd/mddriver.c Sat Jun 16 09:17:21 2012 (r237157) @@ -1,33 +1,31 @@ -/* MDDRIVER.C - test driver for MD2, MD4 and MD5 - */ +/* MDDRIVER.C - test driver for MD2, MD4 and MD5 */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights + * reserved. + * + * RSA Data Security, Inc. makes no representations concerning either the + * merchantability of this software or the suitability of this software for + * any particular purpose. It is provided "as is" without express or implied + * warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. */ #include __FBSDID("$FreeBSD$"); -/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All - rights reserved. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. - */ - -/* The following makes MD default to MD5 if it has not already been - defined with C compiler flags. - */ -#ifndef MD -#define MD 5 -#endif - #include #include #include #include + +/* The following makes MD default to MD5 if it has not already been defined + * with C compiler flags. */ +#ifndef MD +#define MD 5 +#endif + #if MD == 2 #include "md2.h" #define MDData MD2Data @@ -41,32 +39,31 @@ __FBSDID("$FreeBSD$"); #define MDData MD5Data #endif -/* Digests a string and prints the result. - */ -static void MDString (string) -char *string; +/* Digests a string and prints the result. */ +static void +MDString(char *string) { - char buf[33]; + char buf[33]; - printf ("MD%d (\"%s\") = %s\n", - MD, string, MDData(string,strlen(string),buf)); + printf("MD%d (\"%s\") = %s\n", + MD, string, MDData(string, strlen(string), buf)); } -/* Digests a reference suite of strings and prints the results. - */ -main() +/* Digests a reference suite of strings and prints the results. */ +int +main(void) { - printf ("MD%d test suite:\n", MD); + printf("MD%d test suite:\n", MD); + + MDString(""); + MDString("a"); + MDString("abc"); + MDString("message digest"); + MDString("abcdefghijklmnopqrstuvwxyz"); + MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz0123456789"); + MDString("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890"); - MDString (""); - MDString ("a"); - MDString ("abc"); - MDString ("message digest"); - MDString ("abcdefghijklmnopqrstuvwxyz"); - MDString - ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - MDString - ("1234567890123456789012345678901234567890\ -1234567890123456789012345678901234567890"); - return 0; + return 0; } Modified: stable/7/lib/libmd/rmddriver.c ============================================================================== --- stable/7/lib/libmd/rmddriver.c Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libmd/rmddriver.c Sat Jun 16 09:17:21 2012 (r237157) @@ -1,53 +1,51 @@ -/* RIPEMD160DRIVER.C - test driver for RIPEMD160 - */ +/* RIPEMD160DRIVER.C - test driver for RIPEMD160 */ + +/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights + * reserved. + * + * RSA Data Security, Inc. makes no representations concerning either the + * merchantability of this software or the suitability of this software for + * any particular purpose. It is provided "as is" without express or implied + * warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. */ #include __FBSDID("$FreeBSD$"); -/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All - rights reserved. - - RSA Data Security, Inc. makes no representations concerning either - the merchantability of this software or the suitability of this - software for any particular purpose. It is provided "as is" - without express or implied warranty of any kind. - - These notices must be retained in any copies of any part of this - documentation and/or software. - */ - #include #include #include #include + #include "ripemd.h" -/* Digests a string and prints the result. - */ -static void RIPEMD160String (string) -char *string; +/* Digests a string and prints the result. */ +static void +RIPEMD160String(char *string) { - char buf[2*20+1]; + char buf[2*20 + 1]; - printf ("RIPEMD160 (\"%s\") = %s\n", - string, RIPEMD160_Data(string,strlen(string),buf)); + printf("RIPEMD160 (\"%s\") = %s\n", + string, RIPEMD160_Data(string, strlen(string), buf)); } -/* Digests a reference suite of strings and prints the results. - */ -main() +/* Digests a reference suite of strings and prints the results. */ +int +main(void) { - printf ("RIPEMD160 test suite:\n"); + printf("RIPEMD160 test suite:\n"); + + RIPEMD160String(""); + RIPEMD160String("abc"); + RIPEMD160String("message digest"); + RIPEMD160String("abcdefghijklmnopqrstuvwxyz"); + RIPEMD160String("ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz0123456789"); + RIPEMD160String("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890"); - RIPEMD160String (""); - RIPEMD160String ("abc"); - RIPEMD160String ("message digest"); - RIPEMD160String ("abcdefghijklmnopqrstuvwxyz"); - RIPEMD160String - ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - RIPEMD160String - ("1234567890123456789012345678901234567890\ -1234567890123456789012345678901234567890"); - return 0; + return 0; } Modified: stable/7/lib/libmd/sha256.3 ============================================================================== --- stable/7/lib/libmd/sha256.3 Sat Jun 16 06:38:11 2012 (r237156) +++ stable/7/lib/libmd/sha256.3 Sat Jun 16 09:17:21 2012 (r237157) @@ -127,7 +127,7 @@ argument is non-null it must point to at .Xr sha 3 .Sh HISTORY These functions appeared in -.Fx 4.0 . +.Fx 6.0 . .Sh AUTHORS The core hash routines were implemented by Colin Percival based on the published Copied and modified: stable/7/lib/libmd/sha512.3 (from r220496, head/lib/libmd/sha512.3) ============================================================================== --- head/lib/libmd/sha512.3 Sat Apr 9 13:56:29 2011 (r220496, copy source) +++ stable/7/lib/libmd/sha512.3 Sat Jun 16 09:17:21 2012 (r237157) @@ -127,7 +127,7 @@ argument is non-null it must point to at .Xr sha 3 .Sh HISTORY These functions appeared in -.Fx 4.0 . +.Fx 9.0 . .Sh AUTHORS The core hash routines were implemented by Colin Percival based on the published Copied: stable/7/lib/libmd/sha512.h (from r220496, head/lib/libmd/sha512.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libmd/sha512.h Sat Jun 16 09:17:21 2012 (r237157, copy of r220496, head/lib/libmd/sha512.h) @@ -0,0 +1,50 @@ +/*- + * Copyright 2005 Colin Percival + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SHA512_H_ +#define _SHA512_H_ + +#include + +typedef struct SHA512Context { + uint64_t state[8]; + uint64_t count[2]; + unsigned char buf[128]; +} SHA512_CTX; + +__BEGIN_DECLS +void SHA512_Init(SHA512_CTX *); +void SHA512_Update(SHA512_CTX *, const void *, size_t); +void SHA512_Final(unsigned char [64], SHA512_CTX *); +char *SHA512_End(SHA512_CTX *, char *); +char *SHA512_File(const char *, char *); +char *SHA512_FileChunk(const char *, char *, off_t, off_t); +char *SHA512_Data(const void *, unsigned int, char *); +__END_DECLS + +#endif /* !_SHA512_H_ */ Copied: stable/7/lib/libmd/sha512c.c (from r220496, head/lib/libmd/sha512c.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libmd/sha512c.c Sat Jun 16 09:17:21 2012 (r237157, copy of r220496, head/lib/libmd/sha512c.c) @@ -0,0 +1,320 @@ +/*- + * Copyright 2005 Colin Percival + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include + +#include "sha512.h" + +#if BYTE_ORDER == BIG_ENDIAN + +/* Copy a vector of big-endian uint64_t into a vector of bytes */ +#define be64enc_vect(dst, src, len) \ + memcpy((void *)dst, (const void *)src, (size_t)len) + +/* Copy a vector of bytes into a vector of big-endian uint64_t */ +#define be64dec_vect(dst, src, len) \ + memcpy((void *)dst, (const void *)src, (size_t)len) + +#else /* BYTE_ORDER != BIG_ENDIAN */ + +/* + * Encode a length len/4 vector of (uint64_t) into a length len vector of + * (unsigned char) in big-endian form. Assumes len is a multiple of 8. + */ +static void +be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len) +{ + size_t i; + + for (i = 0; i < len / 8; i++) + be64enc(dst + i * 8, src[i]); +} + +/* + * Decode a big-endian length len vector of (unsigned char) into a length + * len/4 vector of (uint64_t). Assumes len is a multiple of 8. + */ +static void +be64dec_vect(uint64_t *dst, const unsigned char *src, size_t len) +{ + size_t i; + + for (i = 0; i < len / 8; i++) + dst[i] = be64dec(src + i * 8); +} + +#endif /* BYTE_ORDER != BIG_ENDIAN */ + +/* Elementary functions used by SHA512 */ +#define Ch(x, y, z) ((x & (y ^ z)) ^ z) +#define Maj(x, y, z) ((x & (y | z)) | (y & z)) +#define SHR(x, n) (x >> n) +#define ROTR(x, n) ((x >> n) | (x << (64 - n))) +#define S0(x) (ROTR(x, 28) ^ ROTR(x, 34) ^ ROTR(x, 39)) +#define S1(x) (ROTR(x, 14) ^ ROTR(x, 18) ^ ROTR(x, 41)) +#define s0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7)) +#define s1(x) (ROTR(x, 19) ^ ROTR(x, 61) ^ SHR(x, 6)) + +/* SHA512 round function */ +#define RND(a, b, c, d, e, f, g, h, k) \ + t0 = h + S1(e) + Ch(e, f, g) + k; \ + t1 = S0(a) + Maj(a, b, c); \ + d += t0; \ + h = t0 + t1; + +/* Adjusted round function for rotating state */ +#define RNDr(S, W, i, k) \ + RND(S[(80 - i) % 8], S[(81 - i) % 8], \ + S[(82 - i) % 8], S[(83 - i) % 8], \ + S[(84 - i) % 8], S[(85 - i) % 8], \ + S[(86 - i) % 8], S[(87 - i) % 8], \ + W[i] + k) + +/* + * SHA512 block compression function. The 512-bit state is transformed via + * the 512-bit input block to produce a new state. + */ +static void +SHA512_Transform(uint64_t * state, const unsigned char block[128]) +{ + uint64_t W[80]; + uint64_t S[8]; + uint64_t t0, t1; + int i; + + /* 1. Prepare message schedule W. */ + be64dec_vect(W, block, 128); + for (i = 16; i < 80; i++) + W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16]; + + /* 2. Initialize working variables. */ + memcpy(S, state, 64); + + /* 3. Mix. */ + RNDr(S, W, 0, 0x428a2f98d728ae22ULL); + RNDr(S, W, 1, 0x7137449123ef65cdULL); + RNDr(S, W, 2, 0xb5c0fbcfec4d3b2fULL); + RNDr(S, W, 3, 0xe9b5dba58189dbbcULL); + RNDr(S, W, 4, 0x3956c25bf348b538ULL); + RNDr(S, W, 5, 0x59f111f1b605d019ULL); + RNDr(S, W, 6, 0x923f82a4af194f9bULL); + RNDr(S, W, 7, 0xab1c5ed5da6d8118ULL); + RNDr(S, W, 8, 0xd807aa98a3030242ULL); + RNDr(S, W, 9, 0x12835b0145706fbeULL); + RNDr(S, W, 10, 0x243185be4ee4b28cULL); + RNDr(S, W, 11, 0x550c7dc3d5ffb4e2ULL); + RNDr(S, W, 12, 0x72be5d74f27b896fULL); + RNDr(S, W, 13, 0x80deb1fe3b1696b1ULL); + RNDr(S, W, 14, 0x9bdc06a725c71235ULL); + RNDr(S, W, 15, 0xc19bf174cf692694ULL); + RNDr(S, W, 16, 0xe49b69c19ef14ad2ULL); + RNDr(S, W, 17, 0xefbe4786384f25e3ULL); + RNDr(S, W, 18, 0x0fc19dc68b8cd5b5ULL); + RNDr(S, W, 19, 0x240ca1cc77ac9c65ULL); + RNDr(S, W, 20, 0x2de92c6f592b0275ULL); + RNDr(S, W, 21, 0x4a7484aa6ea6e483ULL); + RNDr(S, W, 22, 0x5cb0a9dcbd41fbd4ULL); + RNDr(S, W, 23, 0x76f988da831153b5ULL); + RNDr(S, W, 24, 0x983e5152ee66dfabULL); + RNDr(S, W, 25, 0xa831c66d2db43210ULL); + RNDr(S, W, 26, 0xb00327c898fb213fULL); + RNDr(S, W, 27, 0xbf597fc7beef0ee4ULL); + RNDr(S, W, 28, 0xc6e00bf33da88fc2ULL); + RNDr(S, W, 29, 0xd5a79147930aa725ULL); + RNDr(S, W, 30, 0x06ca6351e003826fULL); + RNDr(S, W, 31, 0x142929670a0e6e70ULL); + RNDr(S, W, 32, 0x27b70a8546d22ffcULL); + RNDr(S, W, 33, 0x2e1b21385c26c926ULL); + RNDr(S, W, 34, 0x4d2c6dfc5ac42aedULL); + RNDr(S, W, 35, 0x53380d139d95b3dfULL); + RNDr(S, W, 36, 0x650a73548baf63deULL); + RNDr(S, W, 37, 0x766a0abb3c77b2a8ULL); + RNDr(S, W, 38, 0x81c2c92e47edaee6ULL); + RNDr(S, W, 39, 0x92722c851482353bULL); + RNDr(S, W, 40, 0xa2bfe8a14cf10364ULL); + RNDr(S, W, 41, 0xa81a664bbc423001ULL); + RNDr(S, W, 42, 0xc24b8b70d0f89791ULL); + RNDr(S, W, 43, 0xc76c51a30654be30ULL); + RNDr(S, W, 44, 0xd192e819d6ef5218ULL); + RNDr(S, W, 45, 0xd69906245565a910ULL); + RNDr(S, W, 46, 0xf40e35855771202aULL); + RNDr(S, W, 47, 0x106aa07032bbd1b8ULL); + RNDr(S, W, 48, 0x19a4c116b8d2d0c8ULL); + RNDr(S, W, 49, 0x1e376c085141ab53ULL); + RNDr(S, W, 50, 0x2748774cdf8eeb99ULL); + RNDr(S, W, 51, 0x34b0bcb5e19b48a8ULL); + RNDr(S, W, 52, 0x391c0cb3c5c95a63ULL); + RNDr(S, W, 53, 0x4ed8aa4ae3418acbULL); + RNDr(S, W, 54, 0x5b9cca4f7763e373ULL); + RNDr(S, W, 55, 0x682e6ff3d6b2b8a3ULL); + RNDr(S, W, 56, 0x748f82ee5defb2fcULL); + RNDr(S, W, 57, 0x78a5636f43172f60ULL); + RNDr(S, W, 58, 0x84c87814a1f0ab72ULL); + RNDr(S, W, 59, 0x8cc702081a6439ecULL); + RNDr(S, W, 60, 0x90befffa23631e28ULL); + RNDr(S, W, 61, 0xa4506cebde82bde9ULL); + RNDr(S, W, 62, 0xbef9a3f7b2c67915ULL); + RNDr(S, W, 63, 0xc67178f2e372532bULL); + RNDr(S, W, 64, 0xca273eceea26619cULL); + RNDr(S, W, 65, 0xd186b8c721c0c207ULL); + RNDr(S, W, 66, 0xeada7dd6cde0eb1eULL); + RNDr(S, W, 67, 0xf57d4f7fee6ed178ULL); + RNDr(S, W, 68, 0x06f067aa72176fbaULL); + RNDr(S, W, 69, 0x0a637dc5a2c898a6ULL); + RNDr(S, W, 70, 0x113f9804bef90daeULL); + RNDr(S, W, 71, 0x1b710b35131c471bULL); + RNDr(S, W, 72, 0x28db77f523047d84ULL); + RNDr(S, W, 73, 0x32caab7b40c72493ULL); + RNDr(S, W, 74, 0x3c9ebe0a15c9bebcULL); + RNDr(S, W, 75, 0x431d67c49c100d4cULL); + RNDr(S, W, 76, 0x4cc5d4becb3e42b6ULL); + RNDr(S, W, 77, 0x597f299cfc657e2aULL); + RNDr(S, W, 78, 0x5fcb6fab3ad6faecULL); + RNDr(S, W, 79, 0x6c44198c4a475817ULL); + + /* 4. Mix local working variables into global state */ + for (i = 0; i < 8; i++) + state[i] += S[i]; +} + +static unsigned char PAD[128] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* Add padding and terminating bit-count. */ +static void +SHA512_Pad(SHA512_CTX * ctx) +{ + unsigned char len[16]; + uint64_t r, plen; + + /* + * Convert length to a vector of bytes -- we do this now rather + * than later because the length will change after we pad. + */ + be64enc_vect(len, ctx->count, 16); + + /* Add 1--128 bytes so that the resulting length is 112 mod 128 */ + r = (ctx->count[1] >> 3) & 0x7f; + plen = (r < 112) ? (112 - r) : (240 - r); + SHA512_Update(ctx, PAD, (size_t)plen); + + /* Add the terminating bit-count */ + SHA512_Update(ctx, len, 16); +} + +/* SHA-512 initialization. Begins a SHA-512 operation. */ +void +SHA512_Init(SHA512_CTX * ctx) +{ + + /* Zero bits processed so far */ + ctx->count[0] = ctx->count[1] = 0; + + /* Magic initialization constants */ + ctx->state[0] = 0x6a09e667f3bcc908ULL; + ctx->state[1] = 0xbb67ae8584caa73bULL; + ctx->state[2] = 0x3c6ef372fe94f82bULL; + ctx->state[3] = 0xa54ff53a5f1d36f1ULL; + ctx->state[4] = 0x510e527fade682d1ULL; + ctx->state[5] = 0x9b05688c2b3e6c1fULL; + ctx->state[6] = 0x1f83d9abfb41bd6bULL; + ctx->state[7] = 0x5be0cd19137e2179ULL; +} + +/* Add bytes into the hash */ +void +SHA512_Update(SHA512_CTX * ctx, const void *in, size_t len) +{ + uint64_t bitlen[2]; + uint64_t r; + const unsigned char *src = in; + + /* Number of bytes left in the buffer from previous updates */ + r = (ctx->count[1] >> 3) & 0x7f; + + /* Convert the length into a number of bits */ + bitlen[1] = ((uint64_t)len) << 3; + bitlen[0] = ((uint64_t)len) >> 61; + + /* Update number of bits */ + if ((ctx->count[1] += bitlen[1]) < bitlen[1]) + ctx->count[0]++; + ctx->count[0] += bitlen[0]; + + /* Handle the case where we don't need to perform any transforms */ + if (len < 128 - r) { + memcpy(&ctx->buf[r], src, len); + return; + } + + /* Finish the current block */ + memcpy(&ctx->buf[r], src, 128 - r); + SHA512_Transform(ctx->state, ctx->buf); + src += 128 - r; + len -= 128 - r; + + /* Perform complete blocks */ + while (len >= 128) { + SHA512_Transform(ctx->state, src); + src += 128; + len -= 128; + } + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-7@FreeBSD.ORG Sat Jun 16 18:37:55 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B88F106566C; Sat, 16 Jun 2012 18:37:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 751CA8FC08; Sat, 16 Jun 2012 18:37:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5GIbt5E059666; Sat, 16 Jun 2012 18:37:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5GIbtWo059664; Sat, 16 Jun 2012 18:37:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201206161837.q5GIbtWo059664@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 16 Jun 2012 18:37:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237167 - stable/7/sys/amd64/amd64 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jun 2012 18:37:55 -0000 Author: kib Date: Sat Jun 16 18:37:54 2012 New Revision: 237167 URL: http://svn.freebsd.org/changeset/base/237167 Log: Move misplaced comment. Discussed with: bz Modified: stable/7/sys/amd64/amd64/trap.c Modified: stable/7/sys/amd64/amd64/trap.c ============================================================================== --- stable/7/sys/amd64/amd64/trap.c Sat Jun 16 17:05:09 2012 (r237166) +++ stable/7/sys/amd64/amd64/trap.c Sat Jun 16 18:37:54 2012 (r237167) @@ -970,10 +970,6 @@ syscall(struct trapframe *frame) } /* - * Traced syscall. - */ - - /* * If the user-supplied value of %rip is not a canonical * address, then some CPUs will trigger a ring 0 #GP during * the sysret instruction. However, the fault handler would @@ -989,6 +985,10 @@ syscall(struct trapframe *frame) ksi.ksi_addr = (void *)td->td_frame->tf_rip; trapsignal(td, &ksi); } + + /* + * Traced syscall. + */ if (orig_tf_rflags & PSL_T) { frame->tf_rflags &= ~PSL_T; ksiginfo_init_trap(&ksi);