Skip to content

Commit

Permalink
Use full MD4 len for archaic protocol auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne Davison committed Oct 30, 2017
1 parent 8a82fee commit bc112b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 4 additions & 6 deletions authenticate.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "itypes.h"

extern int read_only;
extern int protocol_version;
extern char *password_file;

/***************************************************************************
Expand Down Expand Up @@ -75,6 +74,8 @@ static void gen_challenge(const char *addr, char *challenge)
sum_init(-1, 0);
sum_update(input, sizeof input);
len = sum_end(digest);
if (len == 2) /* The archaic checksum is 2 bytes, but sum_end() filled in the full MD4 checksum for us. */
len = MD4_DIGEST_LEN;

base64_encode(digest, len, challenge, 0);
}
Expand All @@ -90,6 +91,8 @@ static void generate_hash(const char *in, const char *challenge, char *out)
sum_update(in, strlen(in));
sum_update(challenge, strlen(challenge));
len = sum_end(buf);
if (len == 2) /* The archaic checksum is 2 bytes, but sum_end() filled in the full MD4 checksum for us. */
len = MD4_DIGEST_LEN;

base64_encode(buf, len, out, 0);
}
Expand Down Expand Up @@ -238,11 +241,6 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";

if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
rprintf(FERROR, "ERROR: protocol version is too old!\n");
exit_cleanup(RERR_PROTOCOL);
}

gen_challenge(addr, challenge);

io_printf(f_out, "%s%s\n", leader, challenge);
Expand Down
10 changes: 10 additions & 0 deletions checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ int csum_len_for_type(int cst)
return MD4_DIGEST_LEN;
case CSUM_MD5:
return MD5_DIGEST_LEN;
default: /* paranoia to prevent missing case values */
exit_cleanup(RERR_UNSUPPORTED);
}
return 0;
}
Expand Down Expand Up @@ -181,6 +183,8 @@ void get_checksum2(char *buf, int32 len, char *sum)
mdfour_result(&m, (uchar *)sum);
break;
}
default: /* paranoia to prevent missing case values */
exit_cleanup(RERR_UNSUPPORTED);
}
}

Expand Down Expand Up @@ -275,6 +279,8 @@ void sum_init(int csum_type, int seed)
break;
case CSUM_NONE:
break;
default: /* paranoia to prevent missing case values */
exit_cleanup(RERR_UNSUPPORTED);
}
}

Expand Down Expand Up @@ -322,6 +328,8 @@ void sum_update(const char *p, int32 len)
break;
case CSUM_NONE:
break;
default: /* paranoia to prevent missing case values */
exit_cleanup(RERR_UNSUPPORTED);
}
}

Expand Down Expand Up @@ -349,6 +357,8 @@ int sum_end(char *sum)
case CSUM_NONE:
*sum = '\0';
break;
default: /* paranoia to prevent missing case values */
exit_cleanup(RERR_UNSUPPORTED);
}

return csum_len_for_type(cursum_type);
Expand Down

0 comments on commit bc112b0

Please sign in to comment.