diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2021-12-14 06:27:49 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2021-12-14 06:27:49 +0000 |
commit | f8b792a32062564ce575dbd153e7dfa9ef4c38b9 (patch) | |
tree | d9c77b3eb85851efd81efbf1d7514e2e1972b963 /regress/sys | |
parent | 8f98a374c717bd499867893027405cd7984ddfb5 (diff) |
MINIMUM() because of no sys/param.h
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/crypto/chachapoly/chachapoly_test.c | 8 | ||||
-rw-r--r-- | 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 <mikeb@openbsd.org> @@ -25,6 +25,8 @@ #include <stdlib.h> #include <stdio.h> +#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 <mikeb@openbsd.org> @@ -26,6 +26,8 @@ #include <stdlib.h> #include <stdio.h> +#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); } |