#include <mLib/base64.h>
#include <mLib/bits.h>
#include <mLib/dstr.h>
+#include <mLib/macros.h>
#include <mLib/mdwopt.h>
#include <mLib/quis.h>
#include <mLib/report.h>
#include <mLib/sub.h>
#include "cc.h"
+#include "ct.h"
#include "key.h"
#include "gmac.h"
#include "getdate.h"
octet *_p = (octet *)(p); \
const cookie *_c = (c); \
STORE32(_p + 0, _c->k); \
- STORE32(_p + 4, ((_c->exp & ~MASK32) >> 16) >> 16); \
+ STORE32(_p + 4, ((_c->exp & ~(unsigned long)MASK32) >> 16) >> 16); \
STORE32(_p + 8, _c->exp); \
} while (0)
cookie *_c = (c); \
const octet *_p = (const octet *)(p); \
_c->k = LOAD32(_p + 0); \
- _c->exp = ((time_t)(((LOAD32(_p + 4) << 16) << 16) & ~MASK32) | \
+ _c->exp = ((time_t)(((LOAD32(_p + 4) << 16) << 16) & \
+ ~(unsigned long)MASK32) | \
(time_t)LOAD32(_p + 8)); \
} while (0)
if ((q = key_getattr(0, k, "mac")) != 0) {
dstr_puts(&d, q);
p = d.buf;
- } else if (strncmp(k->type, app, n) == 0 && k->type[n] == '-') {
+ } else if (STRNCMP(k->type, ==, app, n) && k->type[n] == '-') {
dstr_puts(&d, k->type);
p = d.buf + n + 1;
} else
/* --- Fetch an expiry time --- */
case 'e':
- if (strcmp(optarg, "forever") == 0)
+ if (STRCMP(optarg, ==, "forever"))
c.exp = KEXP_FOREVER;
else if ((c.exp = get_date(optarg, 0)) == -1)
die(EXIT_FAILURE, "bad expiry date: `%s'", optarg);
GH_HASH(h, argv[optind + 1], strlen(argv[optind + 1]));
t = GH_DONE(h, 0);
- if (memcmp(t, d.buf + COOKIE_SZ, cbits / 8) != 0) {
+ if (!ct_memeq(t, d.buf + COOKIE_SZ, cbits / 8)) {
if (v) printf("FAIL bad authentication token\n");
goto fail;
}