Re: Randomization from the bootblocks

2014-01-03 Thread Alexey E. Suslikov
Theo de Raadt deraadt at cvs.openbsd.org writes:

 Having no interrupt (and such) entropy means less entropy.
 
 From other hand, there are lot of speculations about some
 hardware entropy sources are suspected (proven?) bad (or
 intentionally hijacked?).
 
 So question here is, does moving random generation closer
 to hardware paves a way to more predictable numbers?
 
 It is clear you don't understand the code that was commited.

You're right. Now I see: the code in question tries to XOR
*over* hardware randomness.



Re: Add Intel Centrino Wireless-N 2230 support in iwn(4)

2014-01-03 Thread Fabian Raetz
Hi tech@,

here is an updated patch.

it seems like Intel Centrino Wireless-N 2030 and
Intel Centrino Wireless-N 2230 have the same pciids...

this makes patch apply again with newest pcidevs changes.


Index: if_iwn.c
===
RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.127
diff -u -p -r1.127 if_iwn.c
--- if_iwn.c6 Dec 2013 21:03:04 -   1.127
+++ if_iwn.c3 Jan 2014 13:18:54 -
@@ -94,6 +94,8 @@ static const struct pci_matchid iwn_devi
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_130_2 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_6235_1 },
{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_6235_2 },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_2x30_1 },
+   { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_WL_2x30_2 },
 };
 
 intiwn_match(struct device *, void *, void *);
@@ -244,6 +246,7 @@ int iwn5000_send_calibration(struct iwn
 intiwn5000_send_wimax_coex(struct iwn_softc *);
 intiwn5000_crystal_calib(struct iwn_softc *);
 intiwn5000_temp_offset_calib(struct iwn_softc *);
+intiwn5000_temp_offset_calibv2(struct iwn_softc *);
 intiwn4965_post_alive(struct iwn_softc *);
 intiwn5000_post_alive(struct iwn_softc *);
 intiwn4965_load_bootcode(struct iwn_softc *, const uint8_t *,
@@ -651,6 +654,11 @@ iwn5000_attach(struct iwn_softc *sc, pci
} else
sc-fwname = iwn-6005;
break;
+   case IWN_HW_REV_TYPE_2030:
+   sc-limits = iwn2030_sensitivity_limits;
+   sc-fwname = iwn-2030;
+sc-sc_flags |= IWN_FLAG_ADV_BT_COEX;
+break;
default:
printf(: adapter type %d not supported\n, sc-hw_type);
return ENOTSUP;
@@ -1529,6 +1537,14 @@ iwn5000_read_eeprom(struct iwn_softc *sc
hdr.version, hdr.pa_type, letoh16(hdr.volt)));
sc-calib_ver = hdr.version;
 
+   if (sc-hw_type == IWN_HW_REV_TYPE_2030) {
+sc-eeprom_voltage = letoh16(hdr.volt);
+iwn_read_prom_data(sc, base + IWN5000_EEPROM_TEMP, val, 2);
+sc-eeprom_temp_high = letoh16(val);
+iwn_read_prom_data(sc, base + IWN5000_EEPROM_VOLT, val, 2);
+sc-eeprom_temp = letoh16(val);
+}
+
if (sc-hw_type == IWN_HW_REV_TYPE_5150) {
/* Compute temperature offset. */
iwn_read_prom_data(sc, base + IWN5000_EEPROM_TEMP, val, 2);
@@ -2095,7 +2111,8 @@ iwn5000_rx_calib_results(struct iwn_soft
 
switch (calib-code) {
case IWN5000_PHY_CALIB_DC:
-   if (sc-hw_type == IWN_HW_REV_TYPE_5150)
+   if (sc-hw_type == IWN_HW_REV_TYPE_5150 ||
+sc-hw_type == IWN_HW_REV_TYPE_2030)
idx = 0;
break;
case IWN5000_PHY_CALIB_LO:
@@ -4161,28 +4178,51 @@ iwn_send_advanced_btcoex(struct iwn_soft
0xc0004000, 0x4000, 0xf0005000, 0xf0005000,
};
struct iwn6000_btcoex_config btconfig;
+struct iwn2000_btcoex_config btconfig2k;
struct iwn_btcoex_priotable btprio;
struct iwn_btcoex_prot btprot;
int error, i;
 
memset(btconfig, 0, sizeof btconfig);
-   btconfig.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION |
-   (IWN_BT_FLAG_COEX6000_MODE_3W  IWN_BT_FLAG_COEX6000_MODE_SHIFT) |
-   IWN_BT_FLAG_SYNC_2_BT_DISABLE;
-   btconfig.max_kill = 5;
-   btconfig.bt3_t7_timer = 1;
-   btconfig.kill_ack = htole32(0x);
-   btconfig.kill_cts = htole32(0x);
-   btconfig.sample_time = 2;
-   btconfig.bt3_t2_timer = 0xc;
-   for (i = 0; i  12; i++)
-   btconfig.lookup_table[i] = htole32(btcoex_3wire[i]);
-   btconfig.valid = htole16(0xff);
-   btconfig.prio_boost = 0xf0;
-   DPRINTF((configuring advanced bluetooth coexistence\n));
-   error = iwn_cmd(sc, IWN_CMD_BT_COEX, btconfig, sizeof(btconfig), 1);
-   if (error != 0)
-   return (error);
+memset(btconfig2k, 0, sizeof btconfig2k);
+
+if (sc-hw_type == IWN_HW_REV_TYPE_2030) {
+btconfig2k.flags = IWN_BT_FLAG_COEX6000_CHAN_INHIBITION |
+(IWN_BT_FLAG_COEX6000_MODE_3W  IWN_BT_FLAG_COEX6000_MODE_SHIFT) |
+IWN_BT_FLAG_SYNC_2_BT_DISABLE;
+btconfig2k.max_kill = 5;
+btconfig2k.bt3_t7_timer = 1;
+btconfig2k.kill_ack = htole32(0x);
+btconfig2k.kill_cts = htole32(0x);
+btconfig2k.sample_time = 2;
+btconfig2k.bt3_t2_timer = 0xc;
+for (i = 0; i  12; i++)
+btconfig2k.lookup_table[i] = htole32(btcoex_3wire[i]);
+btconfig2k.valid = htole16(0xff);
+btconfig2k.prio_boost = htole32(0xf0);
+DPRINTF((configuring advanced bluetooth coexistence\n));
+error = iwn_cmd(sc, IWN_CMD_BT_COEX, btconfig2k, sizeof(btconfig2k), 
1);
+if (error 

signify API change and manpage

2014-01-03 Thread Marc Espie
I really, really want to have an actual parameter for sign and verify,
this makes more sense.

Also, the set of modes of signify means it's much clearer to have separate
synopsis in the manpage...

Also fix some .Ar which should be .Fl while we're at it.

To *keep things simple*, let's only sign a single file... ;)
(note that this actually fixes the code logic, again, since you could
specify an input file option, and generate a sigfile name, and even error
out in cases things were too long if -G got used)...

Note  that I haven't changed the option order in the synopsis, though I
would tend to put -G/-S/-V first, personally...

Index: signify.1
===
RCS file: /build/data/openbsd/cvs/src/usr.bin/signify/signify.1,v
retrieving revision 1.6
diff -u -p -r1.6 signify.1
--- signify.1   1 Jan 2014 17:50:33 -   1.6
+++ signify.1   3 Jan 2014 13:47:54 -
@@ -23,15 +23,25 @@
 .Sh SYNOPSIS
 .Nm signify
 .Op Fl n
-.Op Fl i Ar input
+.Fl p Ar pubkey
+.Fl s Ar seckey
+.Fl G
+.Nm signify
 .Op Fl o Ar output
-.Op Fl p Ar pubkey
-.Op Fl s Ar seckey
-.Fl G | S | V
+.Fl s Ar seckey
+.Fl S
+.Ar input
+.Nm signify
+.Op Fl o Ar output
+.Fl p Ar pubkey
+.Fl V
+.Ar input
 .Sh DESCRIPTION
 The
 .Nm
-utility creates and verifies cryptographic signatures.
+utility creates and verifies cryptographic signatures for
+an input file
+.Ar input .
 The mode of operation is selected by the
 .Fl G ,
 .Fl S ,
@@ -43,8 +53,6 @@ The options are as follows:
 .Bl -tag -width Ds
 .It Fl G
 Generate a new keypair.
-.It Fl i Ar input
-Input file to sign or verify.
 .It Fl n
 Do not ask for a passphrase during key generation.
 Otherwise,
@@ -56,17 +64,17 @@ The default is
 .Ar input Ns .sig .
 .It Fl p Ar pubkey
 Public key produced by
-.Ar G ,
+.Fl G ,
 and used by
-.Ar V
+.Fl V
 to check a signature.
 .It Fl S
 Sign the input file.
 .It Fl s Ar seckey
 Secret (private) key produced by
-.Ar G ,
+.Fl G ,
 and used by
-.Ar S
+.Fl S
 to sign a message.
 .It Fl V
 Verify the input file and signature match.
@@ -94,13 +102,13 @@ The message file is too large.
 .El
 .Sh EXAMPLES
 Create a new keypair:
-.Dl $ signify -p newkey.pub -s newkey.sec -G
+.Dl $ signify -G -p newkey.pub -s newkey.sec
 .Pp
 Sign a file, specifying a signature name:
-.Dl $ signify -s key.sec -i message.txt -o msg.sig -S
+.Dl $ signify -S -s key.sec -o msg.sig message.txt
 .Pp
 Verify a signature, using the default signature name:
-.Dl $ signify -p key.pub -i generalsorders.txt -V
+.Dl $ signify -V -p key.pub generalsorders.txt
 .Sh SEE ALSO
 .Xr cmp 1 ,
 .Xr sha256 1 ,
@@ -109,4 +117,4 @@ Verify a signature, using the default si
 The
 .Nm
 command first appeared in
-.Ox 5.5
+.Ox 5.5 .
Index: signify.c
===
RCS file: /build/data/openbsd/cvs/src/usr.bin/signify/signify.c,v
retrieving revision 1.7
diff -u -p -r1.7 signify.c
--- signify.c   2 Jan 2014 16:34:02 -   1.7
+++ signify.c   3 Jan 2014 13:57:23 -
@@ -64,8 +64,8 @@ extern char *__progname;
 static void
 usage(void)
 {
-   fprintf(stderr, usage: %s [-n] [-i input] [-o output] [-p pubkey] [-s 
seckey] 
-   -G | -S | -V\n, __progname);
+   fprintf(stderr, usage: %s [-n] [-o output] [-p pubkey] [-s seckey] 
+   -G | -S | -V [input]\n, __progname);
exit(1);
 }
 
@@ -338,7 +338,7 @@ main(int argc, char **argv)
 
rounds = 42;
 
-   while ((ch = getopt(argc, argv, GSVi:no:p:s:)) != -1) {
+   while ((ch = getopt(argc, argv, GSVno:p:s:)) != -1) {
switch (ch) {
case 'G':
if (verb)
@@ -355,9 +355,6 @@ main(int argc, char **argv)
usage();
verb = VERIFY;
break;
-   case 'i':
-   inputfile = optarg;
-   break;
case 'n':
rounds = 0;
break;
@@ -376,21 +373,29 @@ main(int argc, char **argv)
}
}
argc -= optind;
-   if (argc != 0)
+   argv += optind;
+
+   if (verb == GENERATE) {
+   if (!pubkeyfile || !seckeyfile || argc != 0)
+   usage();
+   generate(pubkeyfile, seckeyfile, rounds);
+   } else if (verb == NONE) {
+   usage();
+   }
+
+   if (argc != 1)
usage();
 
-   if (inputfile  !sigfile) {
+   inputfile = argv[0];
+
+   if (!sigfile) {
if (snprintf(sigfilebuf, sizeof(sigfilebuf), %s.sig,
inputfile) = sizeof(sigfilebuf))
errx(1, path too long);
sigfile = sigfilebuf;
}
 
-   if (verb == GENERATE) {
-   if (!pubkeyfile || !seckeyfile)
-   usage();
-   generate(pubkeyfile, seckeyfile, rounds);
-   } else if (verb == SIGN) {
+   if 

whois close fd patch

2014-01-03 Thread Loganaden Velvindron
Hi All,

From NetBSD:
Coverity CID 1736

Close fd sfo  sfi before returning from whois(). 

whois() is called from within a loop before exiting.

for (name = *argv; (name = *argv) != NULL; argv++)
rval += whois(name, host ? host : choose_server(name, country),
port_whois, flags);
exit(rval);



Index: src/usr.bin/whois/whois.c
===
RCS file: /cvs/src/usr.bin/whois/whois.c,v
retrieving revision 1.45
diff -u -p -r1.45 whois.c
--- src/usr.bin/whois/whois.c   25 Nov 2013 18:06:32 -  1.45
+++ src/usr.bin/whois/whois.c   1 Jan 2014 10:59:12 -
@@ -260,6 +260,8 @@ whois(const char *query, const char *ser
free(nhost);
}
freeaddrinfo(res);
+   (void)fclose(sfi);
+   (void)fclose(sfo);
return (error);
 }



Re: redux: signify diff

2014-01-03 Thread Ted Unangst
On Fri, Jan 03, 2014 at 16:39, Marc Espie wrote:
 Rechecked that -G was working (broken) and jmc wants identical
 SYNOPSIS/usage.
 Together with the \n for base64...



 + } else if (verb == NONE) {
 usage();

this is weird, mixing that into the middle.



redux: signify diff

2014-01-03 Thread Marc Espie
Rechecked that -G was working (broken) and jmc wants identical SYNOPSIS/usage.
Together with the \n for base64...

Index: signify.1
===
RCS file: /build/data/openbsd/cvs/src/usr.bin/signify/signify.1,v
retrieving revision 1.6
diff -u -p -r1.6 signify.1
--- signify.1   1 Jan 2014 17:50:33 -   1.6
+++ signify.1   3 Jan 2014 13:47:54 -
@@ -23,15 +23,25 @@
 .Sh SYNOPSIS
 .Nm signify
 .Op Fl n
-.Op Fl i Ar input
+.Fl p Ar pubkey
+.Fl s Ar seckey
+.Fl G
+.Nm signify
 .Op Fl o Ar output
-.Op Fl p Ar pubkey
-.Op Fl s Ar seckey
-.Fl G | S | V
+.Fl s Ar seckey
+.Fl S
+.Ar input
+.Nm signify
+.Op Fl o Ar output
+.Fl p Ar pubkey
+.Fl V
+.Ar input
 .Sh DESCRIPTION
 The
 .Nm
-utility creates and verifies cryptographic signatures.
+utility creates and verifies cryptographic signatures for
+an input file
+.Ar input .
 The mode of operation is selected by the
 .Fl G ,
 .Fl S ,
@@ -43,8 +53,6 @@ The options are as follows:
 .Bl -tag -width Ds
 .It Fl G
 Generate a new keypair.
-.It Fl i Ar input
-Input file to sign or verify.
 .It Fl n
 Do not ask for a passphrase during key generation.
 Otherwise,
@@ -56,17 +64,17 @@ The default is
 .Ar input Ns .sig .
 .It Fl p Ar pubkey
 Public key produced by
-.Ar G ,
+.Fl G ,
 and used by
-.Ar V
+.Fl V
 to check a signature.
 .It Fl S
 Sign the input file.
 .It Fl s Ar seckey
 Secret (private) key produced by
-.Ar G ,
+.Fl G ,
 and used by
-.Ar S
+.Fl S
 to sign a message.
 .It Fl V
 Verify the input file and signature match.
@@ -94,13 +102,13 @@ The message file is too large.
 .El
 .Sh EXAMPLES
 Create a new keypair:
-.Dl $ signify -p newkey.pub -s newkey.sec -G
+.Dl $ signify -G -p newkey.pub -s newkey.sec
 .Pp
 Sign a file, specifying a signature name:
-.Dl $ signify -s key.sec -i message.txt -o msg.sig -S
+.Dl $ signify -S -s key.sec -o msg.sig message.txt
 .Pp
 Verify a signature, using the default signature name:
-.Dl $ signify -p key.pub -i generalsorders.txt -V
+.Dl $ signify -V -p key.pub generalsorders.txt
 .Sh SEE ALSO
 .Xr cmp 1 ,
 .Xr sha256 1 ,
@@ -109,4 +117,4 @@ Verify a signature, using the default si
 The
 .Nm
 command first appeared in
-.Ox 5.5
+.Ox 5.5 .
Index: signify.c
===
RCS file: /build/data/openbsd/cvs/src/usr.bin/signify/signify.c,v
retrieving revision 1.7
diff -u -p -r1.7 signify.c
--- signify.c   2 Jan 2014 16:34:02 -   1.7
+++ signify.c   3 Jan 2014 15:37:57 -
@@ -64,8 +64,11 @@ extern char *__progname;
 static void
 usage(void)
 {
-   fprintf(stderr, usage: %s [-n] [-i input] [-o output] [-p pubkey] [-s 
seckey] 
-   -G | -S | -V\n, __progname);
+   fprintf(stderr, usage:
+   \t%s [-n] -p pubkey -s seckey -G\n
+   \t%s [-o output] -s seckey -S input\n
+   \t%s [-o output] -p pubkey -V input\n,
+   __progname, __progname, __progname);
exit(1);
 }
 
@@ -170,8 +173,9 @@ writeb64file(const char *filename, const
fd = xopen(filename, O_CREAT|O_EXCL|O_NOFOLLOW|O_RDWR, mode);
snprintf(header, sizeof(header), signify -- %s\n, comment);
writeall(fd, header, strlen(header), filename);
-   if ((rv = b64_ntop(buf, len, b64, sizeof(b64))) == -1)
+   if ((rv = b64_ntop(buf, len, b64, sizeof(b64)-1)) == -1)
errx(1, b64 encode failed);
+   b64[rv++] = '\n';
writeall(fd, b64, rv, filename);
memset(b64, 0, sizeof(b64));
close(fd);
@@ -338,7 +342,7 @@ main(int argc, char **argv)
 
rounds = 42;
 
-   while ((ch = getopt(argc, argv, GSVi:no:p:s:)) != -1) {
+   while ((ch = getopt(argc, argv, GSVno:p:s:)) != -1) {
switch (ch) {
case 'G':
if (verb)
@@ -355,9 +359,6 @@ main(int argc, char **argv)
usage();
verb = VERIFY;
break;
-   case 'i':
-   inputfile = optarg;
-   break;
case 'n':
rounds = 0;
break;
@@ -376,30 +377,37 @@ main(int argc, char **argv)
}
}
argc -= optind;
-   if (argc != 0)
-   usage();
-
-   if (inputfile  !sigfile) {
-   if (snprintf(sigfilebuf, sizeof(sigfilebuf), %s.sig,
-   inputfile) = sizeof(sigfilebuf))
-   errx(1, path too long);
-   sigfile = sigfilebuf;
-   }
+   argv += optind;
 
if (verb == GENERATE) {
-   if (!pubkeyfile || !seckeyfile)
+   if (!pubkeyfile || !seckeyfile || argc != 0)
usage();
generate(pubkeyfile, seckeyfile, rounds);
-   } else if (verb == SIGN) {
-   if (!seckeyfile || !inputfile)
-   usage();
-   sign(seckeyfile, inputfile, sigfile);
-   } else if 

Re: redux: signify diff

2014-01-03 Thread Marc Espie
On Fri, Jan 03, 2014 at 10:46:45AM -0500, Ted Unangst wrote:
 On Fri, Jan 03, 2014 at 16:39, Marc Espie wrote:
  Rechecked that -G was working (broken) and jmc wants identical
  SYNOPSIS/usage.
  Together with the \n for base64...
 
 
 
  +   } else if (verb == NONE) {
  usage();
 
 this is weird, mixing that into the middle.
Well, do you prefer that ?
Index: signify.1
===
RCS file: /cvs/src/usr.bin/signify/signify.1,v
retrieving revision 1.6
diff -u -p -r1.6 signify.1
--- signify.1   1 Jan 2014 17:50:33 -   1.6
+++ signify.1   3 Jan 2014 15:53:58 -
@@ -23,15 +23,25 @@
 .Sh SYNOPSIS
 .Nm signify
 .Op Fl n
-.Op Fl i Ar input
+.Fl p Ar pubkey
+.Fl s Ar seckey
+.Fl G
+.Nm signify
 .Op Fl o Ar output
-.Op Fl p Ar pubkey
-.Op Fl s Ar seckey
-.Fl G | S | V
+.Fl s Ar seckey
+.Fl S
+.Ar input
+.Nm signify
+.Op Fl o Ar output
+.Fl p Ar pubkey
+.Fl V
+.Ar input
 .Sh DESCRIPTION
 The
 .Nm
-utility creates and verifies cryptographic signatures.
+utility creates and verifies cryptographic signatures for
+an input file
+.Ar input .
 The mode of operation is selected by the
 .Fl G ,
 .Fl S ,
@@ -40,11 +50,9 @@ or
 options.
 .Pp
 The options are as follows:
-.Bl -tag -width Ds
+.Bl -tag -width Dssoutput
 .It Fl G
 Generate a new keypair.
-.It Fl i Ar input
-Input file to sign or verify.
 .It Fl n
 Do not ask for a passphrase during key generation.
 Otherwise,
@@ -56,17 +64,17 @@ The default is
 .Ar input Ns .sig .
 .It Fl p Ar pubkey
 Public key produced by
-.Ar G ,
+.Fl G ,
 and used by
-.Ar V
+.Fl V
 to check a signature.
 .It Fl S
 Sign the input file.
 .It Fl s Ar seckey
 Secret (private) key produced by
-.Ar G ,
+.Fl G ,
 and used by
-.Ar S
+.Fl S
 to sign a message.
 .It Fl V
 Verify the input file and signature match.
@@ -94,13 +102,13 @@ The message file is too large.
 .El
 .Sh EXAMPLES
 Create a new keypair:
-.Dl $ signify -p newkey.pub -s newkey.sec -G
+.Dl $ signify -G -p newkey.pub -s newkey.sec
 .Pp
 Sign a file, specifying a signature name:
-.Dl $ signify -s key.sec -i message.txt -o msg.sig -S
+.Dl $ signify -S -s key.sec -o msg.sig message.txt
 .Pp
 Verify a signature, using the default signature name:
-.Dl $ signify -p key.pub -i generalsorders.txt -V
+.Dl $ signify -V -p key.pub generalsorders.txt
 .Sh SEE ALSO
 .Xr cmp 1 ,
 .Xr sha256 1 ,
@@ -109,4 +117,4 @@ Verify a signature, using the default si
 The
 .Nm
 command first appeared in
-.Ox 5.5
+.Ox 5.5 .
Index: signify.c
===
RCS file: /cvs/src/usr.bin/signify/signify.c,v
retrieving revision 1.8
diff -u -p -r1.8 signify.c
--- signify.c   3 Jan 2014 15:42:22 -   1.8
+++ signify.c   3 Jan 2014 15:53:58 -
@@ -64,8 +64,11 @@ extern char *__progname;
 static void
 usage(void)
 {
-   fprintf(stderr, usage: %s [-n] [-i input] [-o output] [-p pubkey] [-s 
seckey] 
-   -G | -S | -V\n, __progname);
+   fprintf(stderr, usage:
+   \t%s [-n] -p pubkey -s seckey -G\n
+   \t%s [-o output] -s seckey -S input\n
+   \t%s [-o output] -p pubkey -V input\n,
+   __progname, __progname, __progname);
exit(1);
 }
 
@@ -339,7 +342,7 @@ main(int argc, char **argv)
 
rounds = 42;
 
-   while ((ch = getopt(argc, argv, GSVi:no:p:s:)) != -1) {
+   while ((ch = getopt(argc, argv, GSVno:p:s:)) != -1) {
switch (ch) {
case 'G':
if (verb)
@@ -356,9 +359,6 @@ main(int argc, char **argv)
usage();
verb = VERIFY;
break;
-   case 'i':
-   inputfile = optarg;
-   break;
case 'n':
rounds = 0;
break;
@@ -377,30 +377,37 @@ main(int argc, char **argv)
}
}
argc -= optind;
-   if (argc != 0)
-   usage();
-
-   if (inputfile  !sigfile) {
-   if (snprintf(sigfilebuf, sizeof(sigfilebuf), %s.sig,
-   inputfile) = sizeof(sigfilebuf))
-   errx(1, path too long);
-   sigfile = sigfilebuf;
-   }
+   argv += optind;
 
if (verb == GENERATE) {
-   if (!pubkeyfile || !seckeyfile)
+   if (!pubkeyfile || !seckeyfile || argc != 0)
usage();
generate(pubkeyfile, seckeyfile, rounds);
-   } else if (verb == SIGN) {
-   if (!seckeyfile || !inputfile)
+   } else if (verb == SIGN || verb == VERIFY) {
+   if (argc != 1)
usage();
-   sign(seckeyfile, inputfile, sigfile);
-   } else if (verb == VERIFY) {
-   if (!pubkeyfile || !inputfile)
-   usage();
-   verify(pubkeyfile, inputfile, sigfile);
+
+   inputfile = argv[0];
+
+   if 

properly terminate lines in signify

2014-01-03 Thread Marc Espie
Looking more closely at the generated files, they don't have terminating
newlines...

The base64 routines will properly ignore newlines, since they match isspace().

okay ?

Index: signify.c
===
RCS file: /build/data/openbsd/cvs/src/usr.bin/signify/signify.c,v
retrieving revision 1.7
diff -u -p -r1.7 signify.c
--- signify.c   2 Jan 2014 16:34:02 -   1.7
+++ signify.c   3 Jan 2014 15:27:16 -
@@ -170,8 +170,9 @@ writeb64file(const char *filename, const
fd = xopen(filename, O_CREAT|O_EXCL|O_NOFOLLOW|O_RDWR, mode);
snprintf(header, sizeof(header), signify -- %s\n, comment);
writeall(fd, header, strlen(header), filename);
-   if ((rv = b64_ntop(buf, len, b64, sizeof(b64))) == -1)
+   if ((rv = b64_ntop(buf, len, b64, sizeof(b64)-1)) == -1)
errx(1, b64 encode failed);
+   b64[rv++] = '\n';
writeall(fd, b64, rv, filename);
memset(b64, 0, sizeof(b64));
close(fd);



Re: redux: signify diff

2014-01-03 Thread Ted Unangst
On Fri, Jan 03, 2014 at 16:55, Marc Espie wrote:

 @@ -377,30 +377,37 @@ main(int argc, char **argv)
 }
 }
 argc -= optind;
 - if (argc != 0)
 - usage();
 -
 - if (inputfile  !sigfile) {
 - if (snprintf(sigfilebuf, sizeof(sigfilebuf), %s.sig,
 - inputfile) = sizeof(sigfilebuf))
 - errx(1, path too long);
 - sigfile = sigfilebuf;
 - }
 + argv += optind;

You can haul the none check up to here now. (which is where it was
long ago, when verb was in argv). The check at the end used to be for
an unrecognized verb, but that can't happen now.

 
 if (verb == GENERATE) {
 - if (!pubkeyfile || !seckeyfile)
 + if (!pubkeyfile || !seckeyfile || argc != 0)
 usage();
 generate(pubkeyfile, seckeyfile, rounds);
 - } else if (verb == SIGN) {
 - if (!seckeyfile || !inputfile)
 + } else if (verb == SIGN || verb == VERIFY) {
 + if (argc != 1)
 usage();
 - sign(seckeyfile, inputfile, sigfile);
 - } else if (verb == VERIFY) {
 - if (!pubkeyfile || !inputfile)
 - usage();
 - verify(pubkeyfile, inputfile, sigfile);
 +
 + inputfile = argv[0];
 +
 + if (!sigfile) {
 + if (snprintf(sigfilebuf, sizeof(sigfilebuf), %s.sig,
 + inputfile) = sizeof(sigfilebuf))
 + errx(1, path too long);
 + sigfile = sigfilebuf;
 + }
 +
 + if (verb == SIGN) {
 + if (!seckeyfile)
 + usage();
 + sign(seckeyfile, inputfile, sigfile);
 + } else if (verb == VERIFY) {
 + if (!pubkeyfile)
 + usage();
 + verify(pubkeyfile, inputfile, sigfile);
 + }
 } else {
 usage();
 }
 +
 return 0;
 }



Re: whois close fd patch

2014-01-03 Thread Todd C. Miller
Since both sfi and sfo refer to the same underlying descriptor it
is a bad idea to fclose() both of them.  In this case, it is not a
big deal as sfo has already been flushed.  There's really no need
for two streams so I committed a change to use a single one, opened
with r+, and added the fclose().

 - todd



Re: Add Intel Centrino Wireless-N 2230 support in iwn(4)

2014-01-03 Thread Dawe
On Jan 03, 2014 14:24, Fabian Raetz wrote:
 Hi tech@,
 
 here is an updated patch.
 
 it seems like Intel Centrino Wireless-N 2030 and
 Intel Centrino Wireless-N 2230 have the same pciids...
 
 this makes patch apply again with newest pcidevs changes.
 

No regressions with my Intel WiFi Link 1000 running amd64.

iwn0 at pci2 dev 0 function 0 Intel WiFi Link 1000 rev 0x00: msi, MIMO 1T2R, 
BGS