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