-/*++\r
-\r
-Copyright (c) 2004 - 2007, Intel Corporation\r
+/** @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
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- IScsiCHAP.c\r
-\r
-Abstract:\r
-\r
---*/\r
+**/\r
\r
#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
+ @param[out] ChapResponse The calculation of the expected hash value.\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
+ length of the hash value for the hashing algorithm chosen.\r
+ @retval Others Some unexpected error happened. \r
+**/\r
EFI_STATUS\r
IScsiCHAPCalculateResponse (\r
IN UINT32 ChapIdentifier,\r
return Status;\r
}\r
\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
+\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
+**/\r
EFI_STATUS\r
IScsiCHAPAuthTarget (\r
IN ISCSI_CHAP_AUTH_DATA *AuthData,\r
VerifyRsp\r
);\r
\r
- if (NetCompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN)) {\r
+ if (CompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN)) {\r
Status = EFI_SECURITY_VIOLATION;\r
}\r
\r
return Status;\r
}\r
\r
+/**\r
+ This function checks the received iSCSI Login Response during the security\r
+ negotiation stage.\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
+**/\r
EFI_STATUS\r
IScsiCHAPOnRspReceived (\r
IN ISCSI_CONNECTION *Conn,\r
IN BOOLEAN Transit\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function checks the received iSCSI Login Response during the security\r
- negotiation stage.\r
- \r
-Arguments:\r
-\r
- Conn - The iSCSI connection.\r
- Transit - The transit flag of the latest iSCSI Login Response.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - The Login Response passed the CHAP validation.\r
- EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
- EFI_PROTOCOL_ERROR - Some kind of protocol error happend.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
ISCSI_SESSION *Session;\r
CHAR8 *Value;\r
UINT8 *Data;\r
UINT32 Len;\r
- NET_LIST_ENTRY *KeyValueList;\r
+ LIST_ENTRY *KeyValueList;\r
UINTN Algorithm;\r
CHAR8 *Identifier;\r
CHAR8 *Challenge;\r
AuthData = &Session->AuthData;\r
\r
Len = Conn->RspQue.BufSize;\r
- Data = NetAllocatePool (Len);\r
+ Data = AllocatePool (Len);\r
if (Data == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
IScsiHexToBin (TargetRsp, &RspLen, Response);\r
\r
//\r
- // Check the CHAP Name and Response replied by Target.\r
+ // Check the CHAP Response replied by Target.\r
//\r
Status = IScsiCHAPAuthTarget (AuthData, TargetRsp);\r
break;\r
\r
IScsiFreeKeyValueList (KeyValueList);\r
\r
- NetFreePool (Data);\r
+ gBS->FreePool (Data);\r
\r
return Status;\r
}\r
\r
+/**\r
+ 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
+\r
+ @retval EFI_SUCCESS All check passed and the phase-related CHAP\r
+ authentication info is filled into the iSCSI PDU.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval EFI_PROTOCOL_ERROR Some kind of protocol error happend.\r
+**/\r
EFI_STATUS\r
IScsiCHAPToSendReq (\r
IN ISCSI_CONNECTION *Conn,\r
IN NET_BUF *Pdu\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- This function fills the CHAP authentication information into the login PDU\r
- during the security negotiation stage in the iSCSI connection login.\r
- \r
-Arguments:\r
-\r
- Conn - The iSCSI connection.\r
- Pdu - The PDU to send out.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - All check passed and the phase-related CHAP authentication\r
- info is filled into the iSCSI PDU.\r
- EFI_OUT_OF_RESOURCES - Failed to allocate memory.\r
- EFI_PROTOCOL_ERROR - Some kind of protocol error happend.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
ISCSI_SESSION *Session;\r
Status = EFI_SUCCESS;\r
\r
RspLen = 2 * ISCSI_CHAP_RSP_LEN + 3;\r
- Response = NetAllocatePool (RspLen);\r
+ Response = AllocatePool (RspLen);\r
if (Response == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
ChallengeLen = 2 * ISCSI_CHAP_RSP_LEN + 3;\r
- Challenge = NetAllocatePool (ChallengeLen);\r
+ Challenge = AllocatePool (ChallengeLen);\r
if (Challenge == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
break;\r
}\r
\r
- NetFreePool (Response);\r
- NetFreePool (Challenge);\r
+ gBS->FreePool (Response);\r
+ gBS->FreePool (Challenge);\r
\r
return Status;\r
}\r