Commit 8c39e269 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Martin K. Petersen

scsi: target: iscsi: Use bin2hex instead of a re-implementation

Signed-off-by: default avatarVincent Pelletier <plr.vincent@gmail.com>
Reviewed-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 18164943
...@@ -26,15 +26,6 @@ ...@@ -26,15 +26,6 @@
#include "iscsi_target_nego.h" #include "iscsi_target_nego.h"
#include "iscsi_target_auth.h" #include "iscsi_target_auth.h"
static void chap_binaryhex_to_asciihex(char *dst, char *src, int src_len)
{
int i;
for (i = 0; i < src_len; i++) {
sprintf(&dst[i*2], "%02x", (int) src[i] & 0xff);
}
}
static int chap_gen_challenge( static int chap_gen_challenge(
struct iscsi_conn *conn, struct iscsi_conn *conn,
int caller, int caller,
...@@ -50,7 +41,7 @@ static int chap_gen_challenge( ...@@ -50,7 +41,7 @@ static int chap_gen_challenge(
ret = get_random_bytes_wait(chap->challenge, CHAP_CHALLENGE_LENGTH); ret = get_random_bytes_wait(chap->challenge, CHAP_CHALLENGE_LENGTH);
if (unlikely(ret)) if (unlikely(ret))
return ret; return ret;
chap_binaryhex_to_asciihex(challenge_asciihex, chap->challenge, bin2hex(challenge_asciihex, chap->challenge,
CHAP_CHALLENGE_LENGTH); CHAP_CHALLENGE_LENGTH);
/* /*
* Set CHAP_C, and copy the generated challenge into c_str. * Set CHAP_C, and copy the generated challenge into c_str.
...@@ -289,7 +280,7 @@ static int chap_server_compute_md5( ...@@ -289,7 +280,7 @@ static int chap_server_compute_md5(
goto out; goto out;
} }
chap_binaryhex_to_asciihex(response, server_digest, MD5_SIGNATURE_SIZE); bin2hex(response, server_digest, MD5_SIGNATURE_SIZE);
pr_debug("[server] MD5 Server Digest: %s\n", response); pr_debug("[server] MD5 Server Digest: %s\n", response);
if (memcmp(server_digest, client_digest, MD5_SIGNATURE_SIZE) != 0) { if (memcmp(server_digest, client_digest, MD5_SIGNATURE_SIZE) != 0) {
...@@ -411,7 +402,7 @@ static int chap_server_compute_md5( ...@@ -411,7 +402,7 @@ static int chap_server_compute_md5(
/* /*
* Convert response from binary hex to ascii hext. * Convert response from binary hex to ascii hext.
*/ */
chap_binaryhex_to_asciihex(response, digest, MD5_SIGNATURE_SIZE); bin2hex(response, digest, MD5_SIGNATURE_SIZE);
*nr_out_len += sprintf(nr_out_ptr + *nr_out_len, "CHAP_R=0x%s", *nr_out_len += sprintf(nr_out_ptr + *nr_out_len, "CHAP_R=0x%s",
response); response);
*nr_out_len += 1; *nr_out_len += 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment