X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/e7eb3a2744aa45179daea235800753d3d1955338..0c1d42ad03f7e49b23755209f5b1f295cbe21f6b:/lib/authhash.c diff --git a/lib/authhash.c b/lib/authhash.c index 9d36fef..c06c233 100644 --- a/lib/authhash.c +++ b/lib/authhash.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2004, 2006, 2007 Richard Kettlewell + * Copyright (C) 2004, 2006, 2007, 2009 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,10 @@ /** @brief Structure of algorithm lookup table */ struct algorithm { + /** @brief DisOrder algorithm name */ const char *name; + + /** @brief gcrypt algorithm ID */ int id; }; @@ -56,14 +59,15 @@ static const struct algorithm algorithms[] = { * @param nchallenge Size of challenge * @param password Password * @param algo Algorithm to use + * @return Hex string or NULL on error * * Computes H(challenge|password) and returns it as a newly allocated hex * string, or returns NULL on error. */ -const char *authhash(const void *challenge, size_t nchallenge, - const char *password, const char *algo) { +char *authhash(const void *challenge, size_t nchallenge, + const char *password, const char *algo) { gcrypt_hash_handle h; - const char *res; + char *res; size_t n; int id; @@ -81,7 +85,7 @@ const char *authhash(const void *challenge, size_t nchallenge, gcry_error_t e; if((e = gcry_md_open(&h, id, 0))) { - error(0, "gcry_md_open: %s", gcry_strerror(e)); + disorder_error(0, "gcry_md_open: %s", gcry_strerror(e)); return 0; } }