X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/1020001ce9f8c0f2e9119d92b0b7f680a6be79b9..7489d3af05a4394e9621e14a196a9f6c4f788a26:/lib/authhash.c
diff --git a/lib/authhash.c b/lib/authhash.c
index 24c40f0..c06c233 100644
--- a/lib/authhash.c
+++ b/lib/authhash.c
@@ -1,30 +1,26 @@
/*
* 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
+ * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * along with this program. If not, see .
*/
/** @file lib/authhash.c @brief The authorization hash */
-#include
-#include "types.h"
+#include "common.h"
#include
#include
-#include
#include "hex.h"
#include "log.h"
@@ -32,7 +28,10 @@
/** @brief Structure of algorithm lookup table */
struct algorithm {
+ /** @brief DisOrder algorithm name */
const char *name;
+
+ /** @brief gcrypt algorithm ID */
int id;
};
@@ -60,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;
@@ -85,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;
}
}