From b314172618586e500fc362a49ca08bf497b8e878 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 21 Dec 2007 13:40:22 +0000 Subject: [PATCH] server always mentions algorithm in client greeting Organization: Straylight/Edgeware From: Richard Kettlewell --- doc/disorder_protocol.5.in | 5 ++--- python/disorder.py.in | 4 +++- scripts/completion.bash | 4 ++-- server/server.c | 12 +++--------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/doc/disorder_protocol.5.in b/doc/disorder_protocol.5.in index 7fdb819..8cbbde7 100644 --- a/doc/disorder_protocol.5.in +++ b/doc/disorder_protocol.5.in @@ -344,9 +344,8 @@ When a connection is made the server sends a \fB231\fR response before any command is received. This contains an algorithm name and a challenge encoded in hex. .PP -Currently the algorithm name is omitted if it is \fBsha1\fR (but this will -probably change in a future version). The other options are \fBsha256\fR, -\fBsha384\fR and \fBsha512\fR. \fBSHA1\fR etc work as synonyms. +The possible algorithms are (currently) \fBsha1\fR, \fBsha256\fR, \fBsha384\fR +and \fBsha512\fR. \fBSHA1\fR etc work as synonyms. .PP The \fBuser\fR response consists of the selected hash of the user's password concatenated with the challenge, encoded in hex. diff --git a/python/disorder.py.in b/python/disorder.py.in index 4e9b8cd..b18c724 100644 --- a/python/disorder.py.in +++ b/python/disorder.py.in @@ -375,7 +375,8 @@ class client: s.connect(self.who) self.w = s.makefile("wb") self.r = s.makefile("rb") - (res, challenge) = self._simple() + (res, challenge_and_algo) = self._simple() + (algo, challenge) = _split(challenge_and_algo) if cookie is None: if self.user is None: user = self.config['username'] @@ -385,6 +386,7 @@ class client: password = self.config['password'] else: password = self.password + # TODO support algorithms other than SHA-1 h = sha.sha() h.update(password) h.update(binascii.unhexlify(challenge)) diff --git a/scripts/completion.bash b/scripts/completion.bash index 41da55a..3239366 100644 --- a/scripts/completion.bash +++ b/scripts/completion.bash @@ -25,13 +25,13 @@ complete -r disobedience 2>/dev/null || true complete -o default \ -A file \ - -W "allfiles authorize become dirs disable disable-random + -W "allfiles authorize dirs disable disable-random enable enable-random files get get-volume length log move play playing prefs quack queue random-disable random-enable recent reconfigure remove rescan scratch search set set-volume shutdown stats unset version resolve part pause resume scratch-id get-global set-global unset-global - tags new rtp-address adduser users edituser deluser + tags new rtp-address adduser users edituser deluser userinfo -h --help -H --help-commands --version -V --config -c --length --debug -d" \ disorder diff --git a/server/server.c b/server/server.c index ef32151..b204513 100644 --- a/server/server.c +++ b/server/server.c @@ -1352,15 +1352,9 @@ static int listen_callback(ev_source *ev, c->l = l; c->rights = 0; gcry_randomize(c->nonce, sizeof c->nonce, GCRY_STRONG_RANDOM); - if(!strcmp(config->authorization_algorithm, "sha1") - || !strcmp(config->authorization_algorithm, "SHA1")) { - sink_printf(ev_writer_sink(c->w), "231 %s\n", - hex(c->nonce, sizeof c->nonce)); - } else { - sink_printf(ev_writer_sink(c->w), "231 %s %s\n", - config->authorization_algorithm, - hex(c->nonce, sizeof c->nonce)); - } + sink_printf(ev_writer_sink(c->w), "231 %s %s\n", + config->authorization_algorithm, + hex(c->nonce, sizeof c->nonce)); return 0; } -- [mdw]