[Git][NTPsec/ntpsec][master] Bool-ify mac_authdecrypt
Matt Selsky
gitlab at mg.gitlab.com
Tue Apr 11 03:55:06 UTC 2017
Matt Selsky pushed to branch master at NTPsec / ntpsec
Commits:
a737b1f1 by Matt Selsky at 2017-04-10T23:53:45-04:00
Bool-ify mac_authdecrypt
And removed unneeded casts
- - - - -
2 changed files:
- include/ntp_stdlib.h
- libntp/macencrypt.c
Changes:
=====================================
include/ntp_stdlib.h
=====================================
--- a/include/ntp_stdlib.h
+++ b/include/ntp_stdlib.h
@@ -77,7 +77,7 @@ int ntp_getopt_long(int argc, char* const argv[], const char *optstring,
const struct option *longopts, int *longindex);
/* a_md5encrypt.c */
-extern int mac_authdecrypt (int, uint8_t *, uint32_t *, int, int);
+extern bool mac_authdecrypt (int, uint8_t *, uint32_t *, int, int);
extern int mac_authencrypt (int, uint8_t *, uint32_t *, int);
extern void mac_setkey (keyid_t, int, const uint8_t *, size_t);
extern uint32_t addr2refid (sockaddr_u *);
=====================================
libntp/macencrypt.c
=====================================
--- a/libntp/macencrypt.c
+++ b/libntp/macencrypt.c
@@ -78,9 +78,9 @@ mac_authencrypt(
/*
* mac_authdecrypt - verify MD5 message authenticator
*
- * Returns one if digest valid, zero if invalid.
+ * Returns true if digest valid, false if invalid.
*/
-int
+bool
mac_authdecrypt(
int type, /* hash algorithm */
uint8_t *key, /* key pointer */
@@ -103,7 +103,7 @@ mac_authdecrypt(
if (!EVP_DigestInit_ex(ctx, EVP_get_digestbynid(type), NULL)) {
msyslog(LOG_ERR,
"MAC decrypt: digest init failed");
- return (0);
+ return false;
}
EVP_DigestUpdate(ctx, key, cache_secretsize);
EVP_DigestUpdate(ctx, (uint8_t *)pkt, (u_int)length);
@@ -112,9 +112,9 @@ mac_authdecrypt(
if ((u_int)size != len + 4) {
msyslog(LOG_ERR,
"MAC decrypt: MAC length error");
- return (0);
+ return false;
}
- return (int)ctmemeq(digest, (char *)pkt + length + 4, len);
+ return ctmemeq(digest, (char *)pkt + length + 4, len);
}
/*
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a737b1f19c200ea64f9d3f3c568fac3f925deee9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170411/d08b41cb/attachment.html>
More information about the vc
mailing list