From 09729861646bbcf842e830789e3a0173b6cdb7c2 Mon Sep 17 00:00:00 2001 From: Karol Babioch Date: Thu, 17 May 2018 16:03:21 +0200 Subject: [PATCH] util.c: Check whether generate_random() was invoked successfully This evaluates the return code from generate_random() within write_chalresp_state() and returns immediately in case of an error. This fixes #161. --- util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index a9a6fe6..2e52651 100644 --- a/util.c +++ b/util.c @@ -508,7 +508,10 @@ write_chalresp_state(FILE *f, CR_STATE *state) iterations = state->iterations; } - generate_random(salt, CR_SALT_SIZE); + if (generate_random(salt, CR_CHALLENGE_SIZE)) { + goto out; + } + yk_pbkdf2(response_hex, salt, CR_SALT_SIZE, iterations, hash, CR_RESPONSE_SIZE, &prf_method);