mirror of https://github.com/acidanthera/audk.git
NetworkPkg/IScsiDxe: wrap IScsiCHAP source files to 80 characters
Working with overlong lines is difficult for me; rewrap the CHAP-related source files in IScsiDxe to 80 characters width. No functional changes. Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Cc: Siyuan Fu <siyuan.fu@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3356 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210608121259.32451-2-lersek@redhat.com>
This commit is contained in:
parent
702ba436ed
commit
83761337ec
|
@ -1,5 +1,6 @@
|
||||||
/** @file
|
/** @file
|
||||||
This file is for Challenge-Handshake Authentication Protocol (CHAP) Configuration.
|
This file is for Challenge-Handshake Authentication Protocol (CHAP)
|
||||||
|
Configuration.
|
||||||
|
|
||||||
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
@ -18,9 +19,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
@param[in] ChallengeLength The length of iSCSI CHAP challenge message.
|
@param[in] ChallengeLength The length of iSCSI CHAP challenge message.
|
||||||
@param[out] ChapResponse The calculation of the expected hash value.
|
@param[out] ChapResponse The calculation of the expected hash value.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The expected hash value was calculatedly successfully.
|
@retval EFI_SUCCESS The expected hash value was calculatedly
|
||||||
@retval EFI_PROTOCOL_ERROR The length of the secret should be at least the
|
successfully.
|
||||||
length of the hash value for the hashing algorithm chosen.
|
@retval EFI_PROTOCOL_ERROR The length of the secret should be at least
|
||||||
|
the length of the hash value for the hashing
|
||||||
|
algorithm chosen.
|
||||||
@retval EFI_PROTOCOL_ERROR MD5 hash operation fail.
|
@retval EFI_PROTOCOL_ERROR MD5 hash operation fail.
|
||||||
@retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete MD5.
|
@retval EFI_OUT_OF_RESOURCES Fail to allocate resource to complete MD5.
|
||||||
|
|
||||||
|
@ -94,8 +97,10 @@ Exit:
|
||||||
@param[in] AuthData iSCSI CHAP authentication data.
|
@param[in] AuthData iSCSI CHAP authentication data.
|
||||||
@param[in] TargetResponse The response from target.
|
@param[in] TargetResponse The response from target.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The response from target passed authentication.
|
@retval EFI_SUCCESS The response from target passed
|
||||||
@retval EFI_SECURITY_VIOLATION The response from target was not expected value.
|
authentication.
|
||||||
|
@retval EFI_SECURITY_VIOLATION The response from target was not expected
|
||||||
|
value.
|
||||||
@retval Others Other errors as indicated.
|
@retval Others Other errors as indicated.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
@ -193,7 +198,10 @@ IScsiCHAPOnRspReceived (
|
||||||
//
|
//
|
||||||
// The first Login Response.
|
// The first Login Response.
|
||||||
//
|
//
|
||||||
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_TARGET_PORTAL_GROUP_TAG);
|
Value = IScsiGetValueByKeyFromList (
|
||||||
|
KeyValueList,
|
||||||
|
ISCSI_KEY_TARGET_PORTAL_GROUP_TAG
|
||||||
|
);
|
||||||
if (Value == NULL) {
|
if (Value == NULL) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
@ -205,13 +213,17 @@ IScsiCHAPOnRspReceived (
|
||||||
|
|
||||||
Session->TargetPortalGroupTag = (UINT16) Result;
|
Session->TargetPortalGroupTag = (UINT16) Result;
|
||||||
|
|
||||||
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_AUTH_METHOD);
|
Value = IScsiGetValueByKeyFromList (
|
||||||
|
KeyValueList,
|
||||||
|
ISCSI_KEY_AUTH_METHOD
|
||||||
|
);
|
||||||
if (Value == NULL) {
|
if (Value == NULL) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Initiator mandates CHAP authentication but target replies without "CHAP", or
|
// Initiator mandates CHAP authentication but target replies without
|
||||||
// initiator suggets "None" but target replies with some kind of auth method.
|
// "CHAP", or initiator suggets "None" but target replies with some kind of
|
||||||
|
// auth method.
|
||||||
//
|
//
|
||||||
if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
|
if (Session->AuthType == ISCSI_AUTH_TYPE_NONE) {
|
||||||
if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) {
|
if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) != 0) {
|
||||||
|
@ -236,7 +248,10 @@ IScsiCHAPOnRspReceived (
|
||||||
//
|
//
|
||||||
// The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
|
// The Target replies with CHAP_A=<A> CHAP_I=<I> CHAP_C=<C>
|
||||||
//
|
//
|
||||||
Value = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_ALGORITHM);
|
Value = IScsiGetValueByKeyFromList (
|
||||||
|
KeyValueList,
|
||||||
|
ISCSI_KEY_CHAP_ALGORITHM
|
||||||
|
);
|
||||||
if (Value == NULL) {
|
if (Value == NULL) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
@ -249,12 +264,18 @@ IScsiCHAPOnRspReceived (
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_IDENTIFIER);
|
Identifier = IScsiGetValueByKeyFromList (
|
||||||
|
KeyValueList,
|
||||||
|
ISCSI_KEY_CHAP_IDENTIFIER
|
||||||
|
);
|
||||||
if (Identifier == NULL) {
|
if (Identifier == NULL) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Challenge = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_CHALLENGE);
|
Challenge = IScsiGetValueByKeyFromList (
|
||||||
|
KeyValueList,
|
||||||
|
ISCSI_KEY_CHAP_CHALLENGE
|
||||||
|
);
|
||||||
if (Challenge == NULL) {
|
if (Challenge == NULL) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +290,11 @@ IScsiCHAPOnRspReceived (
|
||||||
|
|
||||||
AuthData->InIdentifier = (UINT32) Result;
|
AuthData->InIdentifier = (UINT32) Result;
|
||||||
AuthData->InChallengeLength = ISCSI_CHAP_AUTH_MAX_LEN;
|
AuthData->InChallengeLength = ISCSI_CHAP_AUTH_MAX_LEN;
|
||||||
IScsiHexToBin ((UINT8 *) AuthData->InChallenge, &AuthData->InChallengeLength, Challenge);
|
IScsiHexToBin (
|
||||||
|
(UINT8 *) AuthData->InChallenge,
|
||||||
|
&AuthData->InChallengeLength,
|
||||||
|
Challenge
|
||||||
|
);
|
||||||
Status = IScsiCHAPCalculateResponse (
|
Status = IScsiCHAPCalculateResponse (
|
||||||
AuthData->InIdentifier,
|
AuthData->InIdentifier,
|
||||||
AuthData->AuthConfig->CHAPSecret,
|
AuthData->AuthConfig->CHAPSecret,
|
||||||
|
@ -303,7 +328,10 @@ IScsiCHAPOnRspReceived (
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
Response = IScsiGetValueByKeyFromList (KeyValueList, ISCSI_KEY_CHAP_RESPONSE);
|
Response = IScsiGetValueByKeyFromList (
|
||||||
|
KeyValueList,
|
||||||
|
ISCSI_KEY_CHAP_RESPONSE
|
||||||
|
);
|
||||||
if (Response == NULL) {
|
if (Response == NULL) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +369,8 @@ ON_EXIT:
|
||||||
@param[in, out] Pdu The PDU to send out.
|
@param[in, out] Pdu The PDU to send out.
|
||||||
|
|
||||||
@retval EFI_SUCCESS All check passed and the phase-related CHAP
|
@retval EFI_SUCCESS All check passed and the phase-related CHAP
|
||||||
authentication info is filled into the iSCSI PDU.
|
authentication info is filled into the iSCSI
|
||||||
|
PDU.
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||||
@retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.
|
@retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.
|
||||||
|
|
||||||
|
@ -392,7 +421,11 @@ IScsiCHAPToSendReq (
|
||||||
// It's the initial Login Request. Fill in the key=value pairs mandatory
|
// It's the initial Login Request. Fill in the key=value pairs mandatory
|
||||||
// for the initial Login Request.
|
// for the initial Login Request.
|
||||||
//
|
//
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_INITIATOR_NAME, mPrivate->InitiatorName);
|
IScsiAddKeyValuePair (
|
||||||
|
Pdu,
|
||||||
|
ISCSI_KEY_INITIATOR_NAME,
|
||||||
|
mPrivate->InitiatorName
|
||||||
|
);
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
|
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_SESSION_TYPE, "Normal");
|
||||||
IScsiAddKeyValuePair (
|
IScsiAddKeyValuePair (
|
||||||
Pdu,
|
Pdu,
|
||||||
|
@ -413,7 +446,8 @@ IScsiCHAPToSendReq (
|
||||||
|
|
||||||
case ISCSI_CHAP_STEP_ONE:
|
case ISCSI_CHAP_STEP_ONE:
|
||||||
//
|
//
|
||||||
// First step, send the Login Request with CHAP_A=<A1,A2...> key-value pair.
|
// First step, send the Login Request with CHAP_A=<A1,A2...> key-value
|
||||||
|
// pair.
|
||||||
//
|
//
|
||||||
AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", ISCSI_CHAP_ALGORITHM_MD5);
|
AsciiSPrint (ValueStr, sizeof (ValueStr), "%d", ISCSI_CHAP_ALGORITHM_MD5);
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, ValueStr);
|
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_ALGORITHM, ValueStr);
|
||||||
|
@ -429,11 +463,20 @@ IScsiCHAPToSendReq (
|
||||||
//
|
//
|
||||||
// CHAP_N=<N>
|
// CHAP_N=<N>
|
||||||
//
|
//
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_NAME, (CHAR8 *) &AuthData->AuthConfig->CHAPName);
|
IScsiAddKeyValuePair (
|
||||||
|
Pdu,
|
||||||
|
ISCSI_KEY_CHAP_NAME,
|
||||||
|
(CHAR8 *) &AuthData->AuthConfig->CHAPName
|
||||||
|
);
|
||||||
//
|
//
|
||||||
// CHAP_R=<R>
|
// CHAP_R=<R>
|
||||||
//
|
//
|
||||||
IScsiBinToHex ((UINT8 *) AuthData->CHAPResponse, ISCSI_CHAP_RSP_LEN, Response, &RspLen);
|
IScsiBinToHex (
|
||||||
|
(UINT8 *) AuthData->CHAPResponse,
|
||||||
|
ISCSI_CHAP_RSP_LEN,
|
||||||
|
Response,
|
||||||
|
&RspLen
|
||||||
|
);
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
|
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_RESPONSE, Response);
|
||||||
|
|
||||||
if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
|
if (AuthData->AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
|
||||||
|
@ -448,7 +491,12 @@ IScsiCHAPToSendReq (
|
||||||
//
|
//
|
||||||
IScsiGenRandom ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN);
|
IScsiGenRandom ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN);
|
||||||
AuthData->OutChallengeLength = ISCSI_CHAP_RSP_LEN;
|
AuthData->OutChallengeLength = ISCSI_CHAP_RSP_LEN;
|
||||||
IScsiBinToHex ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN, Challenge, &ChallengeLen);
|
IScsiBinToHex (
|
||||||
|
(UINT8 *) AuthData->OutChallenge,
|
||||||
|
ISCSI_CHAP_RSP_LEN,
|
||||||
|
Challenge,
|
||||||
|
&ChallengeLen
|
||||||
|
);
|
||||||
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
|
IScsiAddKeyValuePair (Pdu, ISCSI_KEY_CHAP_CHALLENGE, Challenge);
|
||||||
|
|
||||||
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
|
Conn->AuthStep = ISCSI_CHAP_STEP_FOUR;
|
||||||
|
|
|
@ -88,7 +88,8 @@ IScsiCHAPOnRspReceived (
|
||||||
@param[in, out] Pdu The PDU to send out.
|
@param[in, out] Pdu The PDU to send out.
|
||||||
|
|
||||||
@retval EFI_SUCCESS All check passed and the phase-related CHAP
|
@retval EFI_SUCCESS All check passed and the phase-related CHAP
|
||||||
authentication info is filled into the iSCSI PDU.
|
authentication info is filled into the iSCSI
|
||||||
|
PDU.
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
|
||||||
@retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.
|
@retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue