-/* $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>
#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 };
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);
}
-/* $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>
#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 };
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);
}