summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/usr.bin/calendar/calendars/calendar.ushistory4
-rw-r--r--src/usr.bin/calendar/io.c17
-rw-r--r--src/usr.bin/signify/Makefile4
-rw-r--r--src/usr.bin/signify/signify.18
-rw-r--r--src/usr.bin/signify/signify.c24
-rw-r--r--src/usr.bin/signify/smult_curve25519_ref.c265
-rw-r--r--src/usr.bin/signify/zsig.c4
7 files changed, 38 insertions, 288 deletions
diff --git a/src/usr.bin/calendar/calendars/calendar.ushistory b/src/usr.bin/calendar/calendars/calendar.ushistory
index 684dc25..a46a542 100644
--- a/src/usr.bin/calendar/calendars/calendar.ushistory
+++ b/src/usr.bin/calendar/calendars/calendar.ushistory
@@ -1,7 +1,7 @@
 /*
  * USA history
  *
- * $OpenBSD: calendar.ushistory,v 1.6 2016/11/19 12:41:22 otto Exp $
+ * $OpenBSD: calendar.ushistory,v 1.7 2017/06/29 07:01:49 jmc Exp $
  */
 
 #ifndef _calendar_ushistory_
@@ -93,7 +93,7 @@
 06/26	Battle of Gettysburg, 1863
 06/27	100 degrees F, Fort Yukon, 1915
 06/27	Bill Graham closes the Fillmore East, 1971
-06/28	Supreme Court decides in favor of Alan Bakke, 1978
+06/28	Supreme Court decides in favor of Allan Bakke, 1978
 07/01	Battle of Gettysburg begins, 1863
 07/04	Cloudy, 76 degrees F, Philadelphia PA, 1776
 07/04	New York abstains on Declaration of Independence vote, 1776
diff --git a/src/usr.bin/calendar/io.c b/src/usr.bin/calendar/io.c
index e4cb689..8abe799 100644
--- a/src/usr.bin/calendar/io.c
+++ b/src/usr.bin/calendar/io.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: io.c,v 1.44 2016/08/31 09:38:47 jsg Exp $	*/
+/*	$OpenBSD: io.c,v 1.46 2017/08/21 21:41:13 deraadt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -89,13 +89,9 @@ cal(void)
 		if (strncmp(buf, "LANG=", 5) == 0) {
 			(void) setlocale(LC_ALL, buf + 5);
 			setnnames();
-			/* XXX remove KOI8 lines after 5.9 is out */
 			if (!strcmp(buf + 5, "ru_RU.UTF-8") ||
 			    !strcmp(buf + 5, "uk_UA.UTF-8") ||
-			    !strcmp(buf + 5, "by_BY.UTF-8") ||
-			    !strcmp(buf + 5, "ru_RU.KOI8-R") ||
-			    !strcmp(buf + 5, "uk_UA.KOI8-U") ||
-			    !strcmp(buf + 5, "by_BY.KOI8-B")) {
+			    !strcmp(buf + 5, "by_BY.UTF-8")) {
 				bodun_maybe++;
 				bodun = 0;
 				free(prefix);
@@ -389,6 +385,7 @@ closecal(FILE *fp)
 	struct stat sbuf;
 	int nread, pdes[2], status;
 	char buf[1024];
+	pid_t pid;
 
 	if (!doall)
 		return;
@@ -398,7 +395,7 @@ closecal(FILE *fp)
 		goto done;
 	if (pipe(pdes) < 0)
 		goto done;
-	switch (vfork()) {
+	switch ((pid = vfork())) {
 	case -1:			/* error */
 		(void)close(pdes[0]);
 		(void)close(pdes[1]);
@@ -425,8 +422,10 @@ closecal(FILE *fp)
 		(void)write(pdes[1], buf, nread);
 	(void)close(pdes[1]);
 done:	(void)fclose(fp);
-	while (wait(&status) >= 0)
-		;
+	while (waitpid(pid, &status, 0) == -1) {
+		if (errno != EINTR)
+			break;
+	}
 }
 
 
diff --git a/src/usr.bin/signify/Makefile b/src/usr.bin/signify/Makefile
index 161c43d..de94571 100644
--- a/src/usr.bin/signify/Makefile
+++ b/src/usr.bin/signify/Makefile
@@ -1,8 +1,8 @@
-#	$OpenBSD: Makefile,v 1.11 2016/09/02 16:10:56 espie Exp $
+#	$OpenBSD: Makefile,v 1.12 2017/05/28 21:59:56 tedu Exp $
 
 SRCS=	signify.c
 SRCS+=	zsig.c
-SRCS+=	fe25519.c sc25519.c smult_curve25519_ref.c
+SRCS+=	fe25519.c sc25519.c
 SRCS+=	mod_ed25519.c mod_ge25519.c
 SRCS+=	crypto_api.c
 
diff --git a/src/usr.bin/signify/signify.1 b/src/usr.bin/signify/signify.1
index 569c14e..d3cc781 100644
--- a/src/usr.bin/signify/signify.1
+++ b/src/usr.bin/signify/signify.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: signify.1,v 1.41 2017/03/09 19:42:05 benno Exp $
+.\" $OpenBSD: signify.1,v 1.42 2017/08/20 22:36:10 deraadt Exp $
 .\"
 .\"Copyright (c) 2013 Marc Espie <espie@openbsd.org>
 .\"Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
@@ -14,7 +14,7 @@
 .\"WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 .\"ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\"OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.Dd $Mdocdate: March 9 2017 $
+.Dd $Mdocdate: August 20 2017 $
 .Dt SIGNIFY 1
 .Os
 .Sh NAME
@@ -165,12 +165,12 @@ Verify a release directory containing
 .Pa SHA256.sig
 and a full set of release files:
 .Bd -literal -offset indent -compact
-$ signify -C -p /etc/signify/openbsd-62-base.pub -x SHA256.sig
+$ signify -C -p /etc/signify/openbsd-63-base.pub -x SHA256.sig
 .Ed
 .Pp
 Verify a bsd.rd before an upgrade:
 .Bd -literal -offset indent -compact
-$ signify -C -p /etc/signify/openbsd-62-base.pub -x SHA256.sig bsd.rd
+$ signify -C -p /etc/signify/openbsd-63-base.pub -x SHA256.sig bsd.rd
 .Ed
 .Pp
 Sign a gzip archive:
diff --git a/src/usr.bin/signify/signify.c b/src/usr.bin/signify/signify.c
index e7af943..3607e2f 100644
--- a/src/usr.bin/signify/signify.c
+++ b/src/usr.bin/signify/signify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signify.c,v 1.127 2017/04/18 02:20:50 deraadt Exp $ */
+/* $OpenBSD: signify.c,v 1.128 2017/07/11 23:27:13 tedu Exp $ */
 /*
  * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
  *
@@ -347,11 +347,15 @@ generate(const char *pubkeyfile, const char *seckeyfile, int rounds,
 static void
 check_keyname_compliance(const char *pubkeyfile, const char *seckeyfile)
 {
+	const char *pos;
 	size_t len;
 
-	len = strlen(pubkeyfile);
-	if (strlen(seckeyfile) != len)
-		goto bad;
+	/* basename may or may not modify input */
+	pos = strrchr(seckeyfile, '/');
+	if (pos != NULL)
+		seckeyfile = pos + 1;
+
+	len = strlen(seckeyfile);
 	if (len < 5) /* ?.key */
 		goto bad;
 	if (strcmp(pubkeyfile + len - 4, ".pub") != 0 ||
@@ -359,6 +363,18 @@ check_keyname_compliance(const char *pubkeyfile, const char *seckeyfile)
 		goto bad;
 	if (strncmp(pubkeyfile, seckeyfile, len - 4) != 0)
 		goto bad;
+	if (pubkeyfile != NULL) {
+		pos = strrchr(pubkeyfile, '/');
+		if (pos != NULL)
+			pubkeyfile = pos + 1;
+
+		if (strlen(pubkeyfile) != len)
+			goto bad;
+		if (strcmp(pubkeyfile + len - 4, ".pub") != 0)
+			goto bad;
+		if (strncmp(pubkeyfile, seckeyfile, len - 4) != 0)
+			goto bad;
+	}
 
 	return;
 bad:
diff --git a/src/usr.bin/signify/smult_curve25519_ref.c b/src/usr.bin/signify/smult_curve25519_ref.c
deleted file mode 100644
index 0c6a62b..0000000
--- a/src/usr.bin/signify/smult_curve25519_ref.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* $OpenBSD: smult_curve25519_ref.c,v 1.1 2014/07/22 00:41:19 deraadt Exp $ */
-/*
-version 20081011
-Matthew Dempsky
-Public domain.
-Derived from public domain code by D. J. Bernstein.
-*/
-
-int crypto_scalarmult_curve25519(unsigned char *, const unsigned char *, const unsigned char *);
-
-static void add(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
-{
-  unsigned int j;
-  unsigned int u;
-  u = 0;
-  for (j = 0;j < 31;++j) { u += a[j] + b[j]; out[j] = u & 255; u >>= 8; }
-  u += a[31] + b[31]; out[31] = u;
-}
-
-static void sub(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
-{
-  unsigned int j;
-  unsigned int u;
-  u = 218;
-  for (j = 0;j < 31;++j) {
-    u += a[j] + 65280 - b[j];
-    out[j] = u & 255;
-    u >>= 8;
-  }
-  u += a[31] - b[31];
-  out[31] = u;
-}
-
-static void squeeze(unsigned int a[32])
-{
-  unsigned int j;
-  unsigned int u;
-  u = 0;
-  for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
-  u += a[31]; a[31] = u & 127;
-  u = 19 * (u >> 7);
-  for (j = 0;j < 31;++j) { u += a[j]; a[j] = u & 255; u >>= 8; }
-  u += a[31]; a[31] = u;
-}
-
-static const unsigned int minusp[32] = {
- 19, 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, 128
-} ;
-
-static void freeze(unsigned int a[32])
-{
-  unsigned int aorig[32];
-  unsigned int j;
-  unsigned int negative;
-
-  for (j = 0;j < 32;++j) aorig[j] = a[j];
-  add(a,a,minusp);
-  negative = -((a[31] >> 7) & 1);
-  for (j = 0;j < 32;++j) a[j] ^= negative & (aorig[j] ^ a[j]);
-}
-
-static void mult(unsigned int out[32],const unsigned int a[32],const unsigned int b[32])
-{
-  unsigned int i;
-  unsigned int j;
-  unsigned int u;
-
-  for (i = 0;i < 32;++i) {
-    u = 0;
-    for (j = 0;j <= i;++j) u += a[j] * b[i - j];
-    for (j = i + 1;j < 32;++j) u += 38 * a[j] * b[i + 32 - j];
-    out[i] = u;
-  }
-  squeeze(out);
-}
-
-static void mult121665(unsigned int out[32],const unsigned int a[32])
-{
-  unsigned int j;
-  unsigned int u;
-
-  u = 0;
-  for (j = 0;j < 31;++j) { u += 121665 * a[j]; out[j] = u & 255; u >>= 8; }
-  u += 121665 * a[31]; out[31] = u & 127;
-  u = 19 * (u >> 7);
-  for (j = 0;j < 31;++j) { u += out[j]; out[j] = u & 255; u >>= 8; }
-  u += out[j]; out[j] = u;
-}
-
-static void square(unsigned int out[32],const unsigned int a[32])
-{
-  unsigned int i;
-  unsigned int j;
-  unsigned int u;
-
-  for (i = 0;i < 32;++i) {
-    u = 0;
-    for (j = 0;j < i - j;++j) u += a[j] * a[i - j];
-    for (j = i + 1;j < i + 32 - j;++j) u += 38 * a[j] * a[i + 32 - j];
-    u *= 2;
-    if ((i & 1) == 0) {
-      u += a[i / 2] * a[i / 2];
-      u += 38 * a[i / 2 + 16] * a[i / 2 + 16];
-    }
-    out[i] = u;
-  }
-  squeeze(out);
-}
-
-static void select_(unsigned int p[64],unsigned int q[64],const unsigned int r[64],const unsigned int s[64],unsigned int b)
-{
-  unsigned int j;
-  unsigned int t;
-  unsigned int bminus1;
-
-  bminus1 = b - 1;
-  for (j = 0;j < 64;++j) {
-    t = bminus1 & (r[j] ^ s[j]);
-    p[j] = s[j] ^ t;
-    q[j] = r[j] ^ t;
-  }
-}
-
-static void mainloop(unsigned int work[64],const unsigned char e[32])
-{
-  unsigned int xzm1[64];
-  unsigned int xzm[64];
-  unsigned int xzmb[64];
-  unsigned int xzm1b[64];
-  unsigned int xznb[64];
-  unsigned int xzn1b[64];
-  unsigned int a0[64];
-  unsigned int a1[64];
-  unsigned int b0[64];
-  unsigned int b1[64];
-  unsigned int c1[64];
-  unsigned int r[32];
-  unsigned int s[32];
-  unsigned int t[32];
-  unsigned int u[32];
-  unsigned int j;
-  unsigned int b;
-  int pos;
-
-  for (j = 0;j < 32;++j) xzm1[j] = work[j];
-  xzm1[32] = 1;
-  for (j = 33;j < 64;++j) xzm1[j] = 0;
-
-  xzm[0] = 1;
-  for (j = 1;j < 64;++j) xzm[j] = 0;
-
-  for (pos = 254;pos >= 0;--pos) {
-    b = e[pos / 8] >> (pos & 7);
-    b &= 1;
-    select_(xzmb,xzm1b,xzm,xzm1,b);
-    add(a0,xzmb,xzmb + 32);
-    sub(a0 + 32,xzmb,xzmb + 32);
-    add(a1,xzm1b,xzm1b + 32);
-    sub(a1 + 32,xzm1b,xzm1b + 32);
-    square(b0,a0);
-    square(b0 + 32,a0 + 32);
-    mult(b1,a1,a0 + 32);
-    mult(b1 + 32,a1 + 32,a0);
-    add(c1,b1,b1 + 32);
-    sub(c1 + 32,b1,b1 + 32);
-    square(r,c1 + 32);
-    sub(s,b0,b0 + 32);
-    mult121665(t,s);
-    add(u,t,b0);
-    mult(xznb,b0,b0 + 32);
-    mult(xznb + 32,s,u);
-    square(xzn1b,c1);
-    mult(xzn1b + 32,r,work);
-    select_(xzm,xzm1,xznb,xzn1b,b);
-  }
-
-  for (j = 0;j < 64;++j) work[j] = xzm[j];
-}
-
-static void recip(unsigned int out[32],const unsigned int z[32])
-{
-  unsigned int z2[32];
-  unsigned int z9[32];
-  unsigned int z11[32];
-  unsigned int z2_5_0[32];
-  unsigned int z2_10_0[32];
-  unsigned int z2_20_0[32];
-  unsigned int z2_50_0[32];
-  unsigned int z2_100_0[32];
-  unsigned int t0[32];
-  unsigned int t1[32];
-  int i;
-
-  /* 2 */ square(z2,z);
-  /* 4 */ square(t1,z2);
-  /* 8 */ square(t0,t1);
-  /* 9 */ mult(z9,t0,z);
-  /* 11 */ mult(z11,z9,z2);
-  /* 22 */ square(t0,z11);
-  /* 2^5 - 2^0 = 31 */ mult(z2_5_0,t0,z9);
-
-  /* 2^6 - 2^1 */ square(t0,z2_5_0);
-  /* 2^7 - 2^2 */ square(t1,t0);
-  /* 2^8 - 2^3 */ square(t0,t1);
-  /* 2^9 - 2^4 */ square(t1,t0);
-  /* 2^10 - 2^5 */ square(t0,t1);
-  /* 2^10 - 2^0 */ mult(z2_10_0,t0,z2_5_0);
-
-  /* 2^11 - 2^1 */ square(t0,z2_10_0);
-  /* 2^12 - 2^2 */ square(t1,t0);
-  /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t0,t1); square(t1,t0); }
-  /* 2^20 - 2^0 */ mult(z2_20_0,t1,z2_10_0);
-
-  /* 2^21 - 2^1 */ square(t0,z2_20_0);
-  /* 2^22 - 2^2 */ square(t1,t0);
-  /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { square(t0,t1); square(t1,t0); }
-  /* 2^40 - 2^0 */ mult(t0,t1,z2_20_0);
-
-  /* 2^41 - 2^1 */ square(t1,t0);
-  /* 2^42 - 2^2 */ square(t0,t1);
-  /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { square(t1,t0); square(t0,t1); }
-  /* 2^50 - 2^0 */ mult(z2_50_0,t0,z2_10_0);
-
-  /* 2^51 - 2^1 */ square(t0,z2_50_0);
-  /* 2^52 - 2^2 */ square(t1,t0);
-  /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
-  /* 2^100 - 2^0 */ mult(z2_100_0,t1,z2_50_0);
-
-  /* 2^101 - 2^1 */ square(t1,z2_100_0);
-  /* 2^102 - 2^2 */ square(t0,t1);
-  /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { square(t1,t0); square(t0,t1); }
-  /* 2^200 - 2^0 */ mult(t1,t0,z2_100_0);
-
-  /* 2^201 - 2^1 */ square(t0,t1);
-  /* 2^202 - 2^2 */ square(t1,t0);
-  /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { square(t0,t1); square(t1,t0); }
-  /* 2^250 - 2^0 */ mult(t0,t1,z2_50_0);
-
-  /* 2^251 - 2^1 */ square(t1,t0);
-  /* 2^252 - 2^2 */ square(t0,t1);
-  /* 2^253 - 2^3 */ square(t1,t0);
-  /* 2^254 - 2^4 */ square(t0,t1);
-  /* 2^255 - 2^5 */ square(t1,t0);
-  /* 2^255 - 21 */ mult(out,t1,z11);
-}
-
-int crypto_scalarmult_curve25519(unsigned char *q,
-  const unsigned char *n,
-  const unsigned char *p)
-{
-  unsigned int work[96];
-  unsigned char e[32];
-  unsigned int i;
-  for (i = 0;i < 32;++i) e[i] = n[i];
-  e[0] &= 248;
-  e[31] &= 127;
-  e[31] |= 64;
-  for (i = 0;i < 32;++i) work[i] = p[i];
-  mainloop(work,e);
-  recip(work + 32,work + 32);
-  mult(work + 64,work,work + 32);
-  freeze(work + 64);
-  for (i = 0;i < 32;++i) q[i] = work[64 + i];
-  return 0;
-}
diff --git a/src/usr.bin/signify/zsig.c b/src/usr.bin/signify/zsig.c
index 38092be..c60f247 100644
--- a/src/usr.bin/signify/zsig.c
+++ b/src/usr.bin/signify/zsig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zsig.c,v 1.14 2016/10/04 14:40:41 espie Exp $ */
+/* $OpenBSD: zsig.c,v 1.15 2017/07/11 23:52:05 tedu Exp $ */
 /*
  * Copyright (c) 2016 Marc Espie <espie@openbsd.org>
  *
@@ -55,7 +55,7 @@ static uint8_t fake[10] = { 0x1f, 0x8b, 8, FCOMMENT_FLAG, 0, 0, 0, 0, 0, 3 };
 static uint8_t *
 readgz_header(struct gzheader *h, int fd)
 {
-	size_t sz = 1024;
+	size_t sz = 1023;
 	uint8_t *p;
 	size_t pos = 0;
 	size_t len = 0;