From f2597b8ac5cc59a08ffc762f087dd01f51f1d37f Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 14 Dec 2021 06:27:48 +0000 Subject: [PATCH] MINIMUM() because of no sys/param.h --- regress/sys/crypto/chachapoly/chachapoly_test.c | 8 +++++--- regress/sys/crypto/gmac/gmac_test.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/regress/sys/crypto/chachapoly/chachapoly_test.c b/regress/sys/crypto/chachapoly/chachapoly_test.c index 004e58d48d6..a179d9da3bd 100644 --- a/regress/sys/crypto/chachapoly/chachapoly_test.c +++ b/regress/sys/crypto/chachapoly/chachapoly_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chachapoly_test.c,v 1.2 2021/12/13 16:56:49 deraadt Exp $ */ +/* $OpenBSD: chachapoly_test.c,v 1.3 2021/12/14 06:27:48 deraadt Exp $ */ /* * Copyright (c) 2010,2015 Mike Belopuhov @@ -25,6 +25,8 @@ #include #include +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + int debug = 0; enum { TST_KEY, TST_IV, TST_AAD, TST_PLAIN, TST_CIPHER, TST_TAG, TST_NUM }; @@ -328,12 +330,12 @@ dopoly(const unsigned char *key, size_t klen, for (i = 0; i < aadlen; i += POLY1305_BLOCK_LEN) { memset(blk, 0, POLY1305_BLOCK_LEN); - memcpy(blk, aad + i, MIN(aadlen - i, POLY1305_BLOCK_LEN)); + memcpy(blk, aad + i, MINIMUM(aadlen - i, POLY1305_BLOCK_LEN)); Chacha20_Poly1305_Update(&ctx, blk, POLY1305_BLOCK_LEN); } for (i = 0; i < len; i += CHACHA20_BLOCK_LEN) { - int dlen = MIN(len - i, CHACHA20_BLOCK_LEN); + int dlen = MINIMUM(len - i, CHACHA20_BLOCK_LEN); Chacha20_Poly1305_Update(&ctx, in + i, dlen); } diff --git a/regress/sys/crypto/gmac/gmac_test.c b/regress/sys/crypto/gmac/gmac_test.c index bb72a6d2fef..2e236cf1b9d 100644 --- a/regress/sys/crypto/gmac/gmac_test.c +++ b/regress/sys/crypto/gmac/gmac_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gmac_test.c,v 1.6 2021/12/13 16:56:49 deraadt Exp $ */ +/* $OpenBSD: gmac_test.c,v 1.7 2021/12/14 06:27:48 deraadt Exp $ */ /* * Copyright (c) 2010 Mike Belopuhov @@ -26,6 +26,8 @@ #include #include +#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) + int debug = 0; enum { TST_KEY, TST_IV, TST_AAD, TST_CIPHER, TST_TAG, TST_NUM }; @@ -650,12 +652,12 @@ dogmac(const unsigned char *key, size_t klen, for (i = 0; i < aadlen; i += GMAC_BLOCK_LEN) { memset(blk, 0, GMAC_BLOCK_LEN); - memcpy(blk, aad + i, MIN(aadlen - i, GMAC_BLOCK_LEN)); + memcpy(blk, aad + i, MINIMUM(aadlen - i, GMAC_BLOCK_LEN)); AES_GMAC_Update(&ctx, blk, GMAC_BLOCK_LEN); } for (i = 0; i < len; i += GMAC_BLOCK_LEN) { - int dlen = MIN(len - i, GMAC_BLOCK_LEN); + int dlen = MINIMUM(len - i, GMAC_BLOCK_LEN); AES_GMAC_Update(&ctx, in + i, dlen); } -- 2.20.1