pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/security/multigest Update multigest and libmultigest t...
details: https://anonhg.NetBSD.org/pkgsrc/rev/d0a95673689a
branches: trunk
changeset: 646588:d0a95673689a
user: agc <agc%pkgsrc.org@localhost>
date: Thu Feb 12 01:57:57 2015 +0000
description:
Update multigest and libmultigest to version 20150211
+ bring over lint fixes from the version in othersrc
+ document the concat, comb4p, xor and hash combiner functions
diffstat:
security/multigest/Makefile | 4 +-
security/multigest/files/blake2.c | 4 +-
security/multigest/files/crc32c.c | 6 +-
security/multigest/files/keccak.c | 18 +-
security/multigest/files/libmultigest.3 | 63 +++-
security/multigest/files/main.c | 10 +-
security/multigest/files/multigest.c | 563 +++++++++++++++++++++----------
security/multigest/files/multigest.h | 12 +-
security/multigest/files/rmd160.c | 10 +-
security/multigest/files/sha1.c | 6 +-
security/multigest/files/tiger.c | 2 +-
security/multigest/files/whirlpool.c | 30 +-
12 files changed, 487 insertions(+), 241 deletions(-)
diffs (truncated from 1268 to 300 lines):
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/Makefile
--- a/security/multigest/Makefile Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/Makefile Thu Feb 12 01:57:57 2015 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.1.1.1 2014/03/05 05:09:44 agc Exp $
+# $NetBSD: Makefile,v 1.2 2015/02/12 01:57:57 agc Exp $
-DISTNAME= multigest-20140303
+DISTNAME= multigest-20150211
CATEGORIES= security
MASTER_SITES= # not used
DISTFILES= # not used
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/files/blake2.c
--- a/security/multigest/files/blake2.c Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/files/blake2.c Thu Feb 12 01:57:57 2015 +0000
@@ -311,7 +311,7 @@
int i;
for (i = 0; i < 16; ++i) {
- m[i] = load64(block + i * sizeof(m[i]));
+ m[i] = load64(block + (sizeof(m[i]) * (uint64_t)i));
}
for (i = 0; i < 8; ++i) {
v[i] = S->h[i];
@@ -412,7 +412,7 @@
blake2b_compress(S, S->buf);
for (i = 0; i < 8; ++i) {
/* Output full hash to temp buffer */
- store64(buffer + sizeof(S->h[i]) * i, S->h[i]);
+ store64(buffer + (sizeof(S->h[i]) * (uint64_t)i), S->h[i]);
}
memcpy(out, buffer, outlen);
return 0;
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/files/crc32c.c
--- a/security/multigest/files/crc32c.c Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/files/crc32c.c Thu Feb 12 01:57:57 2015 +0000
@@ -540,9 +540,9 @@
p_buf += 4;
} else {
crc ^= *p_buf++;
- crc ^= (*p_buf++) << 8;
- crc ^= (*p_buf++) << 16;
- crc ^= (*p_buf++) << 24;
+ crc ^= (uint32_t)(*p_buf++) << 8;
+ crc ^= (uint32_t)(*p_buf++) << 16;
+ crc ^= (uint32_t)(*p_buf++) << 24;
}
term1 = crc_tableil8_o88[crc & 0x000000FF] ^
crc_tableil8_o80[(crc >> 8) & 0x000000FF];
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/files/keccak.c
--- a/security/multigest/files/keccak.c Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/files/keccak.c Thu Feb 12 01:57:57 2015 +0000
@@ -192,9 +192,9 @@
if (((*LFSR) & 0x80) != 0) {
/* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
- (*LFSR) = ((*LFSR) << 1) ^ 0x71;
+ (*LFSR) = (uint8_t)((*LFSR) << 1) ^ 0x71;
} else {
- (*LFSR) = (*LFSR) << 1;
+ (*LFSR) = (uint8_t)((*LFSR) << 1);
}
return result;
}
@@ -208,7 +208,7 @@
for (i = 0; i < KECCAK_NUM_ROUNDS; i++) {
ctx->RoundConstants[i] = 0;
for (j = 0; j < 7; j++) {
- bitPosition = (1<<j)-1; /*2^j-1 */
+ bitPosition = (unsigned)(1<<j)-1; /*2^j-1 */
if (LFSR86540(&LFSRstate)) {
ctx->RoundConstants[i] ^= (uint64_t)1<<bitPosition;
}
@@ -298,7 +298,7 @@
absorb_queue(ctx);
}
if (partialByte > 0) {
- uint8_t mask = (1 << partialByte)-1;
+ uint8_t mask = (uint8_t)((1 << partialByte)-1);
ctx->dataQueue[ctx->bitsInQueue/8] = data[(unsigned long)i/8] & mask;
ctx->bitsInQueue += partialByte;
i += partialByte;
@@ -313,14 +313,14 @@
{
/* Note: the bits are numbered from 0=LSB to 7=MSB */
if (ctx->bitsInQueue + 1 == ctx->rate) {
- ctx->dataQueue[ctx->bitsInQueue/8 ] |= 1 << (ctx->bitsInQueue % 8);
+ ctx->dataQueue[ctx->bitsInQueue/8 ] |= (uint8_t)(1 << (ctx->bitsInQueue % 8));
absorb_queue(ctx);
memset(ctx->dataQueue, 0, ctx->rate/8);
} else {
memset(ctx->dataQueue + (ctx->bitsInQueue+7)/8, 0, ctx->rate/8 - (ctx->bitsInQueue+7)/8);
- ctx->dataQueue[ctx->bitsInQueue/8 ] |= 1 << (ctx->bitsInQueue % 8);
+ ctx->dataQueue[ctx->bitsInQueue/8 ] |= (uint8_t)(1 << (ctx->bitsInQueue % 8));
}
- ctx->dataQueue[(ctx->rate-1)/8] |= 1 << ((ctx->rate-1) % 8);
+ ctx->dataQueue[(ctx->rate-1)/8] |= (uint8_t)(1 << ((ctx->rate-1) % 8));
absorb_queue(ctx);
memcpy(ctx->dataQueue, ctx->state, ctx->rate/8);
ctx->bitsAvailableForSqueezing = ctx->rate;
@@ -381,7 +381,7 @@
default:
return BAD_HASHLEN;
}
- ctx->fixedOutputLength = hashbitlen;
+ ctx->fixedOutputLength = (uint32_t)hashbitlen;
return SUCCESS;
}
@@ -398,7 +398,7 @@
uint8_t lastByte;
/* Align the last partial byte to the least significant bits */
- lastByte = data[(unsigned long)databitlen/8] >> (8 - (databitlen % 8));
+ lastByte = (uint8_t)(data[(unsigned long)databitlen/8] >> (8 - (databitlen % 8)));
return absorb((KECCAK_CTX*)ctx, &lastByte, databitlen % 8);
}
return ret;
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/files/libmultigest.3
--- a/security/multigest/files/libmultigest.3 Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/files/libmultigest.3 Thu Feb 12 01:57:57 2015 +0000
@@ -1,6 +1,6 @@
-.\" $NetBSD: libmultigest.3,v 1.1.1.1 2014/03/05 05:09:44 agc Exp $
+.\" $NetBSD: libmultigest.3,v 1.2 2015/02/12 01:57:57 agc Exp $
.\"
-.\" Copyright (c) 2013,2014 Alistair Crooks <agc%NetBSD.org@localhost>
+.\" Copyright (c) 2013,2014,2015 Alistair Crooks <agc%NetBSD.org@localhost>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -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 March 3, 2014
+.Dd February 11, 2015
.Dt LIBMULTIGEST 3
.Os
.Sh NAME
@@ -47,7 +47,7 @@
.Fc
.Ft void
.Fo multigest_update
-.Fa "multigest_t *mg" "const char *data" "size_t length"
+.Fa "multigest_t *mg" "const void *data" "size_t length"
.Fc
.Ft void
.Fo multigest_final
@@ -55,7 +55,7 @@
.Fc
.Ft "uint8_t *"
.Fo multigest_data
-.Fa "const char *algorithms" "const char *data" "size_t length"
+.Fa "const char *algorithms" "const void *data" "size_t length"
.Fa "const unsigned char *rawoutput" "const char *substregex"
.Fa "const char *replacement"
.Fc
@@ -123,6 +123,14 @@
WHIRLPOOL
.Ed
.Pp
+In addition, a number of hash combiner functions are defined:
+.Bd -literal -offset indent
+CONCAT
+HASH
+XOR
+COMB4P
+.Ed
+.Pp
The
.Dv crc32c
checksum is a simple, lightweight checksum, as found in SCTP and iSCSI.
@@ -154,6 +162,49 @@
Digest names are provided to the initialisation function in a comma-separated
list of names.
.Pp
+The combiner functions define how the individual digests will be combined
+in the finalisation stage.
+They have different qualities, and different uses.
+.Pp
+The
+.Dq CONCAT
+algorithm, the default, simply concatenates the digests in the output.
+It is useful when collision resistance is needed, but not pre-image resistance,
+second pre-image resistance or PRF functionality.
+.Pp
+The
+.Dq Comb4P
+combiner should be used when collision resistance is needed,
+or as a PRF, where target-collision resistance is needed, or
+as a MAC.
+However, this combiner is not as efficient as the other combiner algorithms,
+requiring more CPU cycles.
+.Pp
+The
+.Dq XOR
+combiner xors the first two digests together.
+This is useful as a PRF, but not where
+collision resistance is needed.
+.Pp
+Finally, the
+.Dq HASH
+combiner takes the output of the second digest's
+finalisation routine, and passes that as an update to the current state of
+the first digest, and then finalises the multigest.
+This is useful where pre-image resistance is needed,
+but should not be used if collision resistance is needed.
+.Pp
+If less than two digest algorithms are provided in conjunction
+with a combiner function, a zero multigest will result.
+In addition, if the
+.Dq XOR
+combiner is given the same digest function as input, a zero
+multigest will result.
+The
+.Dq Comb4P
+combiner should be given two digests of the same size,
+or a zero multigest will result.
+.Pp
There are two interfaces to the
.Nm
library, one using the lower-level functions
@@ -197,6 +248,6 @@
The
.Nm
library first appeared in
-.Nx 7.0 .
+.Nx 8.0 .
.Sh AUTHORS
.An Alistair Crooks Aq Mt agc%NetBSD.org@localhost .
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/files/main.c
--- a/security/multigest/files/main.c Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/files/main.c Thu Feb 12 01:57:57 2015 +0000
@@ -41,12 +41,12 @@
static int
do_input(const char *alg, uint8_t *raw, const char *pat, const char *repl)
{
+ ssize_t rc;
size_t cc;
- size_t rc;
char *data;
if ((data = calloc(1, MB(4))) != NULL) {
- for (cc = 0 ; cc < MB(4) ; cc += rc) {
+ for (cc = 0 ; cc < MB(4) ; cc += (size_t)rc) {
if ((rc = read(fileno(stdin), &data[cc], MB(4) - cc)) <= 0) {
break;
}
@@ -110,11 +110,11 @@
return 0;
}
fstat(fileno(fp), &st);
- if ((in = calloc(1, st.st_size + 1)) == NULL) {
+ if ((in = calloc(1, (size_t)(st.st_size + 1))) == NULL) {
fclose(fp);
return 0;
}
- read(fileno(fp), in, st.st_size);
+ read(fileno(fp), in, (size_t)(st.st_size));
in[st.st_size] = 0x0;
fclose(fp);
if (regexec(&r, in, 10, match, 0) != 0) {
@@ -129,7 +129,7 @@
getsubst(subs, from, sizeof(from), to, sizeof(to));
multigest_file(alg, file, raw, from, to);
multigest_format_hex(raw, alg, calc, sizeof(calc));
- if ((ret = memcmp(calc, provided, match[4].rm_eo - match[4].rm_so)) != 0) {
+ if ((ret = memcmp(calc, provided, (size_t)(match[4].rm_eo - match[4].rm_so))) != 0) {
fprintf(stderr, "multigest: provided digest: '%s', calculated digest: '%s'\n", provided, calc);
}
regfree(&r);
diff -r d2eee3d68d26 -r d0a95673689a security/multigest/files/multigest.c
--- a/security/multigest/files/multigest.c Wed Feb 11 23:39:35 2015 +0000
+++ b/security/multigest/files/multigest.c Thu Feb 12 01:57:57 2015 +0000
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2013 Alistair Crooks <agc%NetBSD.org@localhost>
+ * Copyright (c) 2013,2015 Alistair Crooks <agc%NetBSD.org@localhost>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -86,42 +86,126 @@
/*****/
static void
+wrap_md5_init(void *v)
+{
+ MD5Init(v);
+}
+
+static void
+wrap_md5_update(void *v, const void *data, unsigned len)
+{
+ MD5Update(v, (const uint8_t *)data, len);
+}
+
+static void
+wrap_md5_final(uint8_t *raw, void *v)
+{
+ MD5Final(raw, v);
Home |
Main Index |
Thread Index |
Old Index