diff --git a/src/bench.c b/src/bench.c index 86eb0e9..6693be2 100644 --- a/src/bench.c +++ b/src/bench.c @@ -50,7 +50,7 @@ gt_bench(int argc, char **argv) randombytes_buf(key, sizeof(key)); if (term) { - printf("cipher: %s\n\n", chacha ? "chacha20poly1305" : "aegis256"); + printf("cipher: %s\n\n", GT_CIPHER(chacha)); printf(" size min mean max \n"); printf("----------------------------------------------------\n"); } @@ -108,8 +108,7 @@ gt_bench(int argc, char **argv) printf("\n"); } else { printf("bench %s %"PRIi64" %"PRIi64" %"PRIi64" %"PRIi64"\n", - chacha ? "chacha20poly1305" : "aegis256", - size, mbps.min, mbps.mean, mbps.max); + GT_CIPHER(chacha), size, mbps.min, mbps.mean, mbps.max); } size += 2 * 5 * 13; diff --git a/src/common.h b/src/common.h index 25b4b33..b375ccd 100644 --- a/src/common.h +++ b/src/common.h @@ -54,6 +54,8 @@ #undef MIN #define MIN(x,y) ({ __typeof__(x) X=(x); __typeof__(y) Y=(y); X < Y ? X : Y; }) +#define GT_CIPHER(x) ((x) ? "chacha20poly1305" : "aegis256") + extern volatile sig_atomic_t gt_alarm; extern volatile sig_atomic_t gt_reload; extern volatile sig_atomic_t gt_quit; diff --git a/src/show.c b/src/show.c index 076f179..234c48e 100644 --- a/src/show.c +++ b/src/show.c @@ -47,7 +47,7 @@ gt_show_status(int fd) bindstr[0] ? bindstr : "-", gt_get_port((struct sockaddr *)&res.status.bind), res.status.mtu, - res.status.chacha ? "chacha20poly1305" : "aes256gcm"); + GT_CIPHER(res.status.chacha)); } else { printf(term ? "client %s:\n" " pid: %li\n" @@ -69,7 +69,7 @@ gt_show_status(int fd) peerstr[0] ? peerstr : "-", gt_get_port((struct sockaddr *)&res.status.peer), res.status.mtu, - res.status.chacha ? "chacha20poly1305" : "aes256gcm"); + GT_CIPHER(res.status.chacha)); } return 0;