Use full MD4 len for archaic protocol auth.

This commit is contained in:
Wayne Davison
2017-10-30 09:11:16 -07:00
parent 8a82feeb7c
commit bc112b0e7f
2 changed files with 14 additions and 6 deletions

View File

@@ -22,7 +22,6 @@
#include "itypes.h"
extern int read_only;
extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -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);
}
@@ -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);
}
@@ -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);

View File

@@ -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;
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);