X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIScsiDxe%2FIScsiCHAP.c;h=be5ad88f1553de9df60567ed3180af2d90e470d0;hb=c8ad2d7a296c851c2a91519f80dab479df0fdf46;hp=ad68cd9d4c7436772f4837401df5917ebacfa605;hpb=11e0ec6b3c4abeaaa53fcfb582a3ab980106a9f6;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c index ad68cd9d4c..be5ad88f15 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c @@ -1,8 +1,8 @@ /** @file This file is for Challenge-Handshake Authentication Protocol (CHAP) Configuration. - -Copyright (c) 2004 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials + +Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -15,22 +15,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "IScsiImpl.h" #include "Md5.h" -EFI_GUID mIScsiCHAPAuthInfoGuid = ISCSI_CHAP_AUTH_INFO_GUID; - /** - Initator caculates its own expected hash value. - - @param[in] ChapIdentifier ISCSI CHAP identifier sent by authenticator. - @param[in] ChapSecret ISCSI CHAP secret of the authenticator. - @param[in] SecretLength The length of ISCSI CHAP secret. - @param[in] ChapChallenge The challenge message sent by authenticator. - @param[in] ChallengeLength The length of ISCSI CHAP challenge message. + Initator caculates its own expected hash value. + + @param[in] ChapIdentifier iSCSI CHAP identifier sent by authenticator. + @param[in] ChapSecret iSCSI CHAP secret of the authenticator. + @param[in] SecretLength The length of iSCSI CHAP secret. + @param[in] ChapChallenge The challenge message sent by authenticator. + @param[in] ChallengeLength The length of iSCSI CHAP challenge message. @param[out] ChapResponse The calculation of the expected hash value. - + @retval EFI_SUCCESS The expected hash value was caculatedly successfully. - @retval EFI_PROTOCOL_ERROR The length of the secret should be at least the + @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 Others Some unexpected error happened. + @retval Others Other errors as indicated. **/ EFI_STATUS IScsiCHAPCalculateResponse ( @@ -75,14 +73,14 @@ IScsiCHAPCalculateResponse ( /** The initator checks the CHAP response replied by target against its own - calculation of the expected hash value. - - @param[in] AuthData ISCSI CHAP authentication data. - @param[in] TargetResponse The response from target. + calculation of the expected hash value. + + @param[in] AuthData iSCSI CHAP authentication data. + @param[in] TargetResponse The response from target. @retval EFI_SUCCESS The response from target passed authentication. @retval EFI_SECURITY_VIOLATION The response from target was not expected value. - @retval Others Some unexpected error happened. + @retval Others Other errors as indicated. **/ EFI_STATUS IScsiCHAPAuthTarget ( @@ -106,7 +104,7 @@ IScsiCHAPAuthTarget ( VerifyRsp ); - if (CompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN)) { + if (CompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN) != 0) { Status = EFI_SECURITY_VIOLATION; } @@ -116,19 +114,17 @@ IScsiCHAPAuthTarget ( /** This function checks the received iSCSI Login Response during the security negotiation stage. - + @param[in] Conn The iSCSI connection. - @param[in] Transit The transit flag of the latest iSCSI Login Response. @retval EFI_SUCCESS The Login Response passed the CHAP validation. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. @retval EFI_PROTOCOL_ERROR Some kind of protocol error happend. - @retval Others Some unexpected error happend. + @retval Others Other errors as indicated. **/ EFI_STATUS IScsiCHAPOnRspReceived ( - IN ISCSI_CONNECTION *Conn, - IN BOOLEAN Transit + IN ISCSI_CONNECTION *Conn ) { EFI_STATUS Status; @@ -167,8 +163,8 @@ IScsiCHAPOnRspReceived ( // KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len); if (KeyValueList == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto ON_EXIT; + FreePool (Data); + return EFI_OUT_OF_RESOURCES; } Status = EFI_PROTOCOL_ERROR; @@ -297,7 +293,7 @@ ON_EXIT: IScsiFreeKeyValueList (KeyValueList); - gBS->FreePool (Data); + FreePool (Data); return Status; } @@ -306,8 +302,8 @@ ON_EXIT: This function fills the CHAP authentication information into the login PDU during the security negotiation stage in the iSCSI connection login. - @param[in] Conn The iSCSI connection. - @param[in] Pdu The PDU to send out. + @param[in] Conn The iSCSI connection. + @param[in, out] Pdu The PDU to send out. @retval EFI_SUCCESS All check passed and the phase-related CHAP authentication info is filled into the iSCSI PDU. @@ -316,8 +312,8 @@ ON_EXIT: **/ EFI_STATUS IScsiCHAPToSendReq ( - IN ISCSI_CONNECTION *Conn, - IN NET_BUF *Pdu + IN ISCSI_CONNECTION *Conn, + IN OUT NET_BUF *Pdu ) { EFI_STATUS Status; @@ -424,8 +420,8 @@ IScsiCHAPToSendReq ( break; } - gBS->FreePool (Response); - gBS->FreePool (Challenge); + FreePool (Response); + FreePool (Challenge); return Status; }