aboutsummaryrefslogtreecommitdiff
path: root/src/challenge.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-07-13 17:59:42 +0200
committerToni Uhlig <matzeton@googlemail.com>2019-07-13 18:02:16 +0200
commitcb8c15a231a9a8e49d6654a7d599fe9152159ae8 (patch)
tree28315af0b9af935ea5a46becec85c0ff596522d5 /src/challenge.c
parentd42cd7795a44d5e5c32432eb536ef525bdb359a8 (diff)
SHA512 challenge response authentication
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/challenge.c')
-rw-r--r--src/challenge.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/challenge.c b/src/challenge.c
index f0b02ad..d12beea 100644
--- a/src/challenge.c
+++ b/src/challenge.c
@@ -109,13 +109,27 @@ int validate_challenge_md5(challenge_t *local, challenge_digest_t *remote) {
}
#ifdef ENABLE_SHA512
-void generate_response_sha512(challenge_t *challenge)
+void generate_response_sha512(challenge_plain_t *plain, challenge_digest_t *digest)
{
- /* TODO: Implement me! */
+ unsigned char buf[sizeof(*plain) + kSHA512_digest_size];
+
+ digest->hash_type = HT_SHA512;
+ memcpy(buf, plain, sizeof(*plain));
+ memcpy(&buf[sizeof(*plain)], opts.sha512_password_digest, kSHA512_digest_size);
+ memset(plain, 0, sizeof(*plain));
+
+ SHA512(buf, sizeof(*plain) + kSHA512_digest_size, &digest->sha512[0]);
}
-int validate_challenge_sha512(challenge_t *local, challenge_t *remote)
+int validate_challenge_sha512(challenge_t *local, challenge_digest_t *remote)
{
- /* TODO: Implement me! */
+ generate_response_sha512(&local->plain, &local->digest);
+
+ if (remote->hash_type == HT_SHA512 &&
+ memcmp(&local->digest.sha512[0], &remote->sha512[0], sizeof(local->digest.sha512)) == 0)
+ {
+ return 1;
+ }
+ return 0;
}
#endif /* ENABLE_SHA512 */