Skip to content

Commit 8c39e26

Browse files
vpelletiermartinkpetersen
authored andcommitted
scsi: target: iscsi: Use bin2hex instead of a re-implementation
Signed-off-by: Vincent Pelletier <[email protected]> Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 1816494 commit 8c39e26

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

drivers/target/iscsi/iscsi_target_auth.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@
2626
#include "iscsi_target_nego.h"
2727
#include "iscsi_target_auth.h"
2828

29-
static void chap_binaryhex_to_asciihex(char *dst, char *src, int src_len)
30-
{
31-
int i;
32-
33-
for (i = 0; i < src_len; i++) {
34-
sprintf(&dst[i*2], "%02x", (int) src[i] & 0xff);
35-
}
36-
}
37-
3829
static int chap_gen_challenge(
3930
struct iscsi_conn *conn,
4031
int caller,
@@ -50,7 +41,7 @@ static int chap_gen_challenge(
5041
ret = get_random_bytes_wait(chap->challenge, CHAP_CHALLENGE_LENGTH);
5142
if (unlikely(ret))
5243
return ret;
53-
chap_binaryhex_to_asciihex(challenge_asciihex, chap->challenge,
44+
bin2hex(challenge_asciihex, chap->challenge,
5445
CHAP_CHALLENGE_LENGTH);
5546
/*
5647
* Set CHAP_C, and copy the generated challenge into c_str.
@@ -289,7 +280,7 @@ static int chap_server_compute_md5(
289280
goto out;
290281
}
291282

292-
chap_binaryhex_to_asciihex(response, server_digest, MD5_SIGNATURE_SIZE);
283+
bin2hex(response, server_digest, MD5_SIGNATURE_SIZE);
293284
pr_debug("[server] MD5 Server Digest: %s\n", response);
294285

295286
if (memcmp(server_digest, client_digest, MD5_SIGNATURE_SIZE) != 0) {
@@ -411,7 +402,7 @@ static int chap_server_compute_md5(
411402
/*
412403
* Convert response from binary hex to ascii hext.
413404
*/
414-
chap_binaryhex_to_asciihex(response, digest, MD5_SIGNATURE_SIZE);
405+
bin2hex(response, digest, MD5_SIGNATURE_SIZE);
415406
*nr_out_len += sprintf(nr_out_ptr + *nr_out_len, "CHAP_R=0x%s",
416407
response);
417408
*nr_out_len += 1;

0 commit comments

Comments
 (0)