CVS commit: othersrc/external/bsd/threshold/dist/src/libthreshold
Module Name:othersrc Committed By: agc Date: Tue Jun 24 07:04:00 UTC 2014 Modified Files: othersrc/external/bsd/threshold/dist/src/libthreshold: raid.c Log Message: only include the codecs.h header if the main program is being used to test - in normal operations, this won't be needed. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c diff -u othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c:1.2 othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c:1.3 --- othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c:1.2 Tue Dec 4 07:39:19 2012 +++ othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c Tue Jun 24 07:04:00 2014 @@ -26,7 +26,6 @@ #include sys/stat.h #include sys/mman.h -#include codecs.h #include inttypes.h #include stdio.h #include stdlib.h @@ -424,6 +423,9 @@ raid_read_header(const char *mem, uint8_ } #ifdef RAID5_MAIN + +#include codecs.h + int main(int argc, char **argv) {
CVS commit: othersrc/external/bsd/threshold/dist/src/libthreshold
Module Name:othersrc Committed By: agc Date: Tue Dec 4 07:39:19 UTC 2012 Modified Files: othersrc/external/bsd/threshold/dist/src/libthreshold: ida.c raid.c threshold.c Log Message: feedback from fuzz testing - check arguments on entry to functions To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ othersrc/external/bsd/threshold/dist/src/libthreshold/ida.c \ othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c \ othersrc/external/bsd/threshold/dist/src/libthreshold/threshold.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/threshold/dist/src/libthreshold/ida.c diff -u othersrc/external/bsd/threshold/dist/src/libthreshold/ida.c:1.1.1.1 othersrc/external/bsd/threshold/dist/src/libthreshold/ida.c:1.2 --- othersrc/external/bsd/threshold/dist/src/libthreshold/ida.c:1.1.1.1 Sat Mar 12 08:13:08 2011 +++ othersrc/external/bsd/threshold/dist/src/libthreshold/ida.c Tue Dec 4 07:39:19 2012 @@ -194,6 +194,9 @@ ida_split(threshold_t *thresh) size_t insize; ida_t *ida; + if (thresh == NULL) { + return 0; + } ida = (ida_t *)thresh-handle; mem = thresh-shares[THRESH_MAX_SHARES]; thresh_fmt_header(head, IDA_MAGIC, thresh-threshold, thresh-sharesc, mem-io.size); @@ -240,6 +243,9 @@ ida_combine(threshold_t *thresh) ida_t *ida; int cc; + if (thresh == NULL) { + return 0; + } ida = (ida_t *)thresh-handle; (void) memset(coeff, 0x0, sizeof(coeff)); for (i = 0 ; i thresh-availc ; i++) { @@ -274,7 +280,7 @@ ida_combine(threshold_t *thresh) arr[i] = gfadd(arr[i], gfmuls[ida-matrix[SUBSCRIPT(i, j, thresh-threshold)]][ch]); } } - cc = MIN(thresh-threshold, (heads[0].size - out-c)); + cc = MIN((int)thresh-threshold, (int)(heads[0].size - out-c)); (void) memcpy(out-io.base[out-c], arr, cc); out-c += cc; } @@ -293,6 +299,9 @@ ida_init(threshold_t *threshold, unsigne unsigned j; ida_t *ida; + if (threshold == NULL) { + return 0; + } if ((ida = calloc(1, sizeof(ida_t))) == NULL) { (void) fprintf(stderr, can't allocate ida\n); return 0; @@ -320,6 +329,9 @@ ida_end(threshold_t *threshold) { ida_t *ida; + if (threshold == NULL) { + return 0; + } if ((ida = threshold-handle) != NULL) { if (ida-matrix) { free(ida-matrix); Index: othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c diff -u othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c:1.1.1.1 othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c:1.2 --- othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c:1.1.1.1 Sat Mar 12 08:13:08 2011 +++ othersrc/external/bsd/threshold/dist/src/libthreshold/raid.c Tue Dec 4 07:39:19 2012 @@ -154,6 +154,9 @@ raid_init(threshold_t *thresh, unsigned { raid_t *raid; + if (thresh == NULL) { + return 0; + } if ((raid = calloc(1, sizeof(*raid))) == NULL) { fprintf(stderr, raid_init: unable to allocate space\n); return 0; @@ -179,6 +182,9 @@ raid_split_memory(threshold_t *thresh, c uint8_t *parity; raid_t *raid; + if (thresh == NULL || input == NULL) { + return 0; + } in = (const uint8_t *)input; raid = thresh-handle; blocksize = threshold; /* overloaded here */ @@ -223,8 +229,11 @@ raid_split(threshold_t *thresh) { thresh_str_t *mem; + if (thresh == NULL) { + return 0; + } mem = thresh-shares[THRESH_MAX_SHARES]; - return raid_split_memory(thresh, mem-io.base, mem-io.size, thresh-threshold, thresh-sharesc); + return raid_split_memory(thresh, mem-io.base, (unsigned)mem-io.size, thresh-threshold, thresh-sharesc); } /* split the file into shares */ @@ -237,6 +246,9 @@ raid_split_file(threshold_t *thresh, con FILE *fp; int ret; + if (thresh == NULL || f == NULL) { + return 0; + } if (!check_values(blocksize, disks)) { return 0; } @@ -252,7 +264,7 @@ raid_split_file(threshold_t *thresh, con return 0; } /* Do the work */ - ret = raid_split_memory(thresh, mem, bytes, blocksize, disks); + ret = raid_split_memory(thresh, mem, (unsigned)bytes, blocksize, disks); (void) fclose(fp); (void) munmap(mem, bytes); return ret; @@ -271,6 +283,9 @@ raid_join_file(threshold_t *thresh, char int good; int ret; + if (thresh == NULL || files == NULL || str == NULL) { + return 0; + } raid = thresh-handle; if (raid-blocksize == 0) { raid-blocksize = DEFAULT_BLOCKSIZE; @@ -337,6 +352,9 @@ raid_join_memory(threshold_t *thresh, th raid_t *raid; int repair; + if (thresh == NULL || inputv == NULL) { + return 0; + } raid = thresh-handle; if (raid-blocksize == 0) { raid-blocksize = DEFAULT_BLOCKSIZE; @@ -362,7 +380,7 @@ raid_join_memory(threshold_t *thresh, th int raid_end(threshold_t *thresh) { - if (thresh-handle) { + if (thresh thresh-handle) { free(thresh-handle); } return 1; @@ -375,6 +393,9 @@ raid_end(threshold_t *thresh) int raid_read_header(const char *mem,
CVS commit: othersrc/external/bsd/threshold/dist/src/threshold
Module Name:othersrc Committed By: agc Date: Sun Sep 18 19:01:16 UTC 2011 Modified Files: othersrc/external/bsd/threshold/dist/src/threshold: threshold.1 Log Message: sync manual page with reality To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 \ othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 diff -u othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.2 othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.3 --- othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.2 Sat Mar 12 13:22:24 2011 +++ othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 Sun Sep 18 19:01:16 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: threshold.1,v 1.2 2011/03/12 13:22:24 wiz Exp $ +.\ $NetBSD: threshold.1,v 1.3 2011/09/18 19:01:16 agc Exp $ .\ .\ Copyright (c) 2010 Alistair Crooks a...@netbsd.org .\ All rights reserved. @@ -23,7 +23,7 @@ .\ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\ -.Dd April 13, 2010 +.Dd September 18, 2011 .Dt THRESHOLD 1 .Os .Sh NAME @@ -35,8 +35,7 @@ .Op Fl a algorithm .Op Fl m memory-size .Op Fl o filename -.Op Fl s total-shares|threshold/shares -.Op Fl t threshold-shares|threshold/shares +.Op Fl t threshold/shares .Ar file .Sh DESCRIPTION The @@ -60,8 +59,17 @@ .Bl -tag -width Ar .It Fl a Specify the algorithm to be used in the threshold scheme. -The default algorithm is -.Dq . +The possible algorithms are +.Dq ida +for Rabin's IDA (this is the default), +.Dq RAID4 +and +.Dq RAID5 +while the +.Xr 1 +command also uses the +.Xr libthreshold 3 +framework. .It Fl i Operate in an interactive manner by prompting the user for a secret to be typed in response to a prompt, and read by @@ -113,26 +121,78 @@ .Dv secretfile into 10 separate shares, of which 3 are needed to reconstruct the original file. .Bd -literal -% threshold -a s4 -t 3/5 secretfile -Splitting file secretfile to: -secretfile.001 secretfile.002 secretfile.003 secretfile.004 secretfile.005 -% ls -al secretfile.0* --rw-r--r-- 1 agc agc 21327 May 2 21:44 secretfile.001 --rw-r--r-- 1 agc agc 21327 May 2 21:44 secretfile.002 --rw-r--r-- 1 agc agc 21327 May 2 21:44 secretfile.003 --rw-r--r-- 1 agc agc 21327 May 2 21:44 secretfile.004 --rw-r--r-- 1 agc agc 21327 May 2 21:44 secretfile.005 -% threshold -j -o secretfile.out secretfile.003 secretfile.001 secretfile.002 -Creating file secretfile.out from files: -% diff secretfile secretfile.out +% cp /etc/group origfile +% threshold -t 3/10 origfile +% ls -al /etc/group origfile.split* +-rw-r--r-- 1 root wheel 526 Jun 26 01:34 /etc/group +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split0 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split1 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split2 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split3 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split4 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split5 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split6 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split7 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split8 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 origfile.split9 +% threshold -j -o origfile.recons origfile.split4 origfile.split2 origfile.split3 +% diff origfile origfile.recons +% rm origfile.* % .Ed +.Pp +The following example uses shell redirection to split the +data on standard input: +.Bd -literal +% threshold -t 3/10 origfile +% ls -al threshold.split* +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split0 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split1 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split2 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split3 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split4 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split5 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split6 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split7 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split8 +-rw-r--r-- 1 agc agc 192 Sep 17 13:59 threshold.split9 +% threshold -j -o origfile.mem threshold.split1 threshold.split2 threshold.split3 +% diff origfile origfile.mem +% rm threshold.* +.Ed +.Pp +The following example prompts for input using +.Xr getpass 3 +.Bd -literal +% threshold -t 3/10 -i +Data to share: +% ls -al threshold.split* +-rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split0 +-rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split1 +-rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split2 +-rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split3 +-rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split4 +-rw-r--r-- 1 agc
CVS commit: othersrc/external/bsd/threshold/dist/src/threshold
Module Name:othersrc Committed By: wiz Date: Sun Sep 18 22:35:54 UTC 2011 Modified Files: othersrc/external/bsd/threshold/dist/src/threshold: threshold.1 Log Message: Remove trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 \ othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 diff -u othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.3 othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.4 --- othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.3 Sun Sep 18 19:01:16 2011 +++ othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 Sun Sep 18 22:35:53 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: threshold.1,v 1.3 2011/09/18 19:01:16 agc Exp $ +.\ $NetBSD: threshold.1,v 1.4 2011/09/18 22:35:53 wiz Exp $ .\ .\ Copyright (c) 2010 Alistair Crooks a...@netbsd.org .\ All rights reserved. @@ -165,7 +165,7 @@ .Xr getpass 3 .Bd -literal % threshold -t 3/10 -i -Data to share: +Data to share: % ls -al threshold.split* -rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split0 -rw-r--r-- 1 agc agc 20 Sep 17 13:59 threshold.split1
CVS commit: othersrc/external/bsd/threshold/dist/src
Module Name:othersrc Committed By: wiz Date: Sat Mar 12 13:22:24 UTC 2011 Modified Files: othersrc/external/bsd/threshold/dist/src/libthreshold: libthreshold.3 othersrc/external/bsd/threshold/dist/src/threshold: threshold.1 Log Message: Whitespace nits. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ othersrc/external/bsd/threshold/dist/src/libthreshold/libthreshold.3 cvs rdiff -u -r1.1.1.1 -r1.2 \ othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/external/bsd/threshold/dist/src/libthreshold/libthreshold.3 diff -u othersrc/external/bsd/threshold/dist/src/libthreshold/libthreshold.3:1.1.1.1 othersrc/external/bsd/threshold/dist/src/libthreshold/libthreshold.3:1.2 --- othersrc/external/bsd/threshold/dist/src/libthreshold/libthreshold.3:1.1.1.1 Sat Mar 12 08:13:08 2011 +++ othersrc/external/bsd/threshold/dist/src/libthreshold/libthreshold.3 Sat Mar 12 13:22:24 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: libthreshold.3,v 1.1.1.1 2011/03/12 08:13:08 agc Exp $ +.\ $NetBSD: libthreshold.3,v 1.2 2011/03/12 13:22:24 wiz Exp $ .\ .\ Copyright (c) 2010 Alistair Crooks a...@netbsd.org .\ All rights reserved. @@ -28,7 +28,7 @@ .Os .Sh NAME .Nm libthreshold -.Nd secret sharing library +.Nd secret sharing library .Sh LIBRARY .Lb libthreshold .Sh SYNOPSIS @@ -100,7 +100,7 @@ The information may still be used to recover parts of the original secret - there is no expectation of secrecy withion the shares, and -.It RAID5 +.It RAID5 Use a standard XOR-parity based scheme, with the parity in rotation, to provide the resilience to be able to recover the data with a threshold of shares being one less than the total number of shares. Index: othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 diff -u othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.1.1.1 othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.2 --- othersrc/external/bsd/threshold/dist/src/threshold/threshold.1:1.1.1.1 Sat Mar 12 08:13:09 2011 +++ othersrc/external/bsd/threshold/dist/src/threshold/threshold.1 Sat Mar 12 13:22:24 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: threshold.1,v 1.1.1.1 2011/03/12 08:13:09 agc Exp $ +.\ $NetBSD: threshold.1,v 1.2 2011/03/12 13:22:24 wiz Exp $ .\ .\ Copyright (c) 2010 Alistair Crooks a...@netbsd.org .\ All rights reserved. @@ -55,13 +55,13 @@ .Xr libthreshold 3 library. .Pp -The secret is first split up into +The secret is first split up into a number of shares. .Bl -tag -width Ar .It Fl a Specify the algorithm to be used in the threshold scheme. The default algorithm is -.Dq +.Dq . .It Fl i Operate in an interactive manner by prompting the user for a secret to be typed in response to a prompt, and read by @@ -71,7 +71,7 @@ routine. Please note the maximum limit on the length of the secret that can be given using -.Xr getpass 3. +.Xr getpass 3 . .It Fl j is used to reconstruct (or join) the original secret from the threshold number of shares which were provided on the command line. @@ -92,7 +92,8 @@ .Dv k and .Dv n -are integers representing the threshold and total number of shares, respectively. +are integers representing the threshold and total number of shares, +respectively. .It Fl t Specify the threshold number of shares, from which the original secret can be reconstructed. @@ -102,7 +103,8 @@ .Dv k and .Dv n -are integers representing the threshold and total number of shares, respectively. +are integers representing the threshold and total number of shares, +respectively. .It Fl o used to provide the output file name .El