iscsi: Support Base64 constants for iSCSI certification CHAP test
A major iSCSI initiator requires iSCSI targets to handle base64 constants for CHAP packets from the initiator. This patch enables the SPDK iSCSI target to handle base64 constants for CHAP packets from the initiator. Change-Id: I276eb73113c40baa322904fe562d5b6016cccf33 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/431086 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
ec257c5f08
commit
4e54b1a082
@ -34,6 +34,7 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include "spdk/base64.h"
|
||||
#include "spdk/crc32.h"
|
||||
#include "spdk/endian.h"
|
||||
#include "spdk/env.h"
|
||||
@ -795,6 +796,7 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
|
||||
uint8_t resmd5[SPDK_MD5DIGEST_LEN];
|
||||
uint8_t tgtmd5[SPDK_MD5DIGEST_LEN];
|
||||
struct spdk_md5ctx md5ctx;
|
||||
size_t decoded_len = 0;
|
||||
|
||||
if (conn->auth.chap_phase != ISCSI_CHAP_PHASE_WAIT_NR) {
|
||||
SPDK_ERRLOG("CHAP sequence error\n");
|
||||
@ -806,8 +808,22 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
|
||||
SPDK_ERRLOG("no response\n");
|
||||
goto error_return;
|
||||
}
|
||||
rc = spdk_hex2bin(resmd5, SPDK_MD5DIGEST_LEN, response);
|
||||
if (rc < 0 || rc != SPDK_MD5DIGEST_LEN) {
|
||||
if (response[0] == '0' &&
|
||||
(response[1] == 'x' || response[1] == 'X')) {
|
||||
rc = spdk_hex2bin(resmd5, SPDK_MD5DIGEST_LEN, response);
|
||||
if (rc < 0 || rc != SPDK_MD5DIGEST_LEN) {
|
||||
SPDK_ERRLOG("response format error\n");
|
||||
goto error_return;
|
||||
}
|
||||
} else if (response[0] == '0' &&
|
||||
(response[1] == 'b' || response[1] == 'B')) {
|
||||
response += 2;
|
||||
rc = spdk_base64_decode(resmd5, &decoded_len, response);
|
||||
if (rc < 0 || decoded_len != SPDK_MD5DIGEST_LEN) {
|
||||
SPDK_ERRLOG("response format error\n");
|
||||
goto error_return;
|
||||
}
|
||||
} else {
|
||||
SPDK_ERRLOG("response format error\n");
|
||||
goto error_return;
|
||||
}
|
||||
@ -865,14 +881,30 @@ spdk_iscsi_auth_params(struct spdk_iscsi_conn *conn,
|
||||
SPDK_ERRLOG("CHAP sequence error\n");
|
||||
goto error_return;
|
||||
}
|
||||
rc = spdk_hex2bin(conn->auth.chap_mchallenge,
|
||||
ISCSI_CHAP_CHALLENGE_LEN,
|
||||
challenge);
|
||||
if (rc < 0) {
|
||||
if (challenge[0] == '0' &&
|
||||
(challenge[1] == 'x' || challenge[1] == 'X')) {
|
||||
rc = spdk_hex2bin(conn->auth.chap_mchallenge,
|
||||
ISCSI_CHAP_CHALLENGE_LEN,
|
||||
challenge);
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("challenge format error\n");
|
||||
goto error_return;
|
||||
}
|
||||
conn->auth.chap_mchallenge_len = rc;
|
||||
} else if (challenge[0] == '0' &&
|
||||
(challenge[1] == 'b' || challenge[1] == 'B')) {
|
||||
challenge += 2;
|
||||
rc = spdk_base64_decode(conn->auth.chap_mchallenge,
|
||||
&decoded_len, challenge);
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("challenge format error\n");
|
||||
goto error_return;
|
||||
}
|
||||
conn->auth.chap_mchallenge_len = decoded_len;
|
||||
} else {
|
||||
SPDK_ERRLOG("challenge format error\n");
|
||||
goto error_return;
|
||||
}
|
||||
conn->auth.chap_mchallenge_len = rc;
|
||||
#if 0
|
||||
spdk_dump("MChallenge", conn->auth.chap_mchallenge,
|
||||
conn->auth.chap_mchallenge_len);
|
||||
|
Loading…
Reference in New Issue
Block a user