Module Name: othersrc
Committed By: agc
Date: Wed Mar 26 22:13:44 UTC 2014
Modified Files:
othersrc/external/bsd/multigest/bin: Makefile
othersrc/external/bsd/multigest/dist: multigest.c multigest.h
Added Files:
othersrc/external/bsd/multigest/bin: 28.expected
Log Message:
update multigest to version 20140326
+ allow the digest combiners to be specified anywhere in the list
of digest algorithms
+ add tests for comb4p
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/multigest/bin/28.expected
cvs rdiff -u -r1.6 -r1.7 othersrc/external/bsd/multigest/bin/Makefile
cvs rdiff -u -r1.13 -r1.14 othersrc/external/bsd/multigest/dist/multigest.c
cvs rdiff -u -r1.10 -r1.11 othersrc/external/bsd/multigest/dist/multigest.h
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/multigest/bin/Makefile
diff -u othersrc/external/bsd/multigest/bin/Makefile:1.6 othersrc/external/bsd/multigest/bin/Makefile:1.7
--- othersrc/external/bsd/multigest/bin/Makefile:1.6 Wed Mar 26 06:43:01 2014
+++ othersrc/external/bsd/multigest/bin/Makefile Wed Mar 26 22:13:44 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2014/03/26 06:43:01 agc Exp $
+# $NetBSD: Makefile,v 1.7 2014/03/26 22:13:44 agc Exp $
.include <bsd.own.mk>
@@ -106,3 +106,12 @@ t: ${PROG}
env LD_LIBRARY_PATH=${LIB_MULTIGEST_DIR} ./${PROG} -o 27.out -a rmd160,hash,sha1 2.in
diff 27.expected 27.out
rm -f 27.out
+ env LD_LIBRARY_PATH=${LIB_MULTIGEST_DIR} ./${PROG} -o 28.out -a comb4p,sha1,rmd160 < 2.in
+ diff 28.expected 28.out
+ rm -f 28.out
+ env LD_LIBRARY_PATH=${LIB_MULTIGEST_DIR} ./${PROG} -o 29.out -a sha1,comb4p,rmd160 < 2.in
+ diff 28.expected 29.out
+ rm -f 29.out
+ env LD_LIBRARY_PATH=${LIB_MULTIGEST_DIR} ./${PROG} -o 30.out -a sha1,rmd160,comb4p < 2.in
+ diff 28.expected 30.out
+ rm -f 30.out
Index: othersrc/external/bsd/multigest/dist/multigest.c
diff -u othersrc/external/bsd/multigest/dist/multigest.c:1.13 othersrc/external/bsd/multigest/dist/multigest.c:1.14
--- othersrc/external/bsd/multigest/dist/multigest.c:1.13 Wed Mar 26 06:43:01 2014
+++ othersrc/external/bsd/multigest/dist/multigest.c Wed Mar 26 22:13:44 2014
@@ -450,11 +450,13 @@ normalise(multigest_t *multigest, const
break;
}
for (d = multigest->digs, i = 0 ; i < multigest->digc ; i++, d++) {
- (*d->update)(&multigest->ctx[d->ctxoff], &data[*from],
- (unsigned)(match[0].rm_so - *from));
- if (multigest->repllen) {
- (*d->update)(&multigest->ctx[d->ctxoff], multigest->repl,
- multigest->repllen);
+ if (d->rawsize) {
+ (*d->update)(&multigest->ctx[d->ctxoff], &data[*from],
+ (unsigned)(match[0].rm_so - *from));
+ if (multigest->repllen) {
+ (*d->update)(&multigest->ctx[d->ctxoff], multigest->repl,
+ multigest->repllen);
+ }
}
}
*from = match[0].rm_eo;
@@ -478,13 +480,11 @@ xorbuf(uint8_t *out, uint8_t *in1, uint8
/* a round of comb4p combination */
static int
-comb4p_round(multigest_t *m, uint8_t *out, uint8_t *in, size_t insize, uint32_t r)
+comb4p_round(multigest_t *m, uint8_t *out, uint8_t *in, multigest_dig_t *d1, multigest_dig_t *d2, uint32_t r)
{
- multigest_dig_t *d;
const int indian = 1;
uint32_t b2;
uint32_t b4;
- uint32_t i;
uint8_t h1[4096];
uint8_t h2[4096];
@@ -494,16 +494,14 @@ comb4p_round(multigest_t *m, uint8_t *ou
b4 = (r & 0x000000ff);
r = (r & 0xff00ff00) | (b2 >> 16) | (b4 << 16);
}
- for (d = &m->digs[1], i = 1 ; i < m->digc ; i++, d++) {
- (*d->update)(&m->ctx[d->ctxoff], (const char *)&r, sizeof(r));
- (*d->update)(&m->ctx[d->ctxoff], (const char *)in, insize);
- }
- d = &m->digs[1];
- (*d->final)(h1, &m->ctx[d->ctxoff]);
- xorbuf(out, out, h1, d->rawsize);
- d = &m->digs[2];
- (*d->final)(h2, &m->ctx[d->ctxoff]);
- xorbuf(out, out, h2, d->rawsize);
+ (*d1->update)(&m->ctx[d1->ctxoff], (const char *)&r, sizeof(r));
+ (*d2->update)(&m->ctx[d2->ctxoff], (const char *)&r, sizeof(r));
+ (*d1->update)(&m->ctx[d1->ctxoff], (const char *)in, d1->rawsize);
+ (*d2->update)(&m->ctx[d2->ctxoff], (const char *)in, d2->rawsize);
+ (*d1->final)(h1, &m->ctx[d1->ctxoff]);
+ xorbuf(out, out, h1, d1->rawsize);
+ (*d2->final)(h2, &m->ctx[d2->ctxoff]);
+ xorbuf(out, out, h2, d2->rawsize);
return 1;
}
@@ -647,7 +645,9 @@ multigest_update(multigest_t *multigest,
if (multigest && data) {
normalise(multigest, data, len, &from);
for (d = multigest->digs, i = 0 ; i < multigest->digc ; i++, d++) {
- (*d->update)(&multigest->ctx[d->ctxoff], &data[from], (unsigned)(len - from));
+ if (d->rawsize) {
+ (*d->update)(&multigest->ctx[d->ctxoff], &data[from], (unsigned)(len - from));
+ }
}
}
}
@@ -669,12 +669,14 @@ multigest_final(multigest_t *m, uint8_t
if (!find_digests(m, &d1, &d2)) {
return;
}
+ memset(h1, 0x0, sizeof(h1));
+ memset(h2, 0x0, sizeof(h2));
(*d1->final)(h1, &m->ctx[d1->ctxoff]);
(*d2->final)(h2, &m->ctx[d2->ctxoff]);
xorbuf(h1, h1, h2, d2->rawsize);
- comb4p_round(m, h2, h1, d1->rawsize, 1);
- comb4p_round(m, h1, h2, d2->rawsize, 2);
- memcpy(raw, h1, d2->rawsize);
+ comb4p_round(m, h2, h1, d1, d2, 1);
+ comb4p_round(m, h1, h2, d1, d2, 2);
+ memcpy(raw, h1, d1->rawsize);
memcpy(&raw[d1->rawsize], h2, d2->rawsize);
break;
case COMBINE_CONCAT:
Index: othersrc/external/bsd/multigest/dist/multigest.h
diff -u othersrc/external/bsd/multigest/dist/multigest.h:1.10 othersrc/external/bsd/multigest/dist/multigest.h:1.11
--- othersrc/external/bsd/multigest/dist/multigest.h:1.10 Wed Mar 26 06:22:16 2014
+++ othersrc/external/bsd/multigest/dist/multigest.h Wed Mar 26 22:13:44 2014
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MULTIGEST_H_
-#define MULTIGEST_H_ 20140325
+#define MULTIGEST_H_ 20140326
#include <sys/types.h>
Added files:
Index: othersrc/external/bsd/multigest/bin/28.expected
diff -u /dev/null othersrc/external/bsd/multigest/bin/28.expected:1.1
--- /dev/null Wed Mar 26 22:13:44 2014
+++ othersrc/external/bsd/multigest/bin/28.expected Wed Mar 26 22:13:44 2014
@@ -0,0 +1 @@
+deef78986ff2e27d759a83bf2c7a4bf1fc90e52f5a768ab252fd22ea6704b98f6ebc2646fbbef3a7