IScsiCHAP.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /** @file
  2. The header file of CHAP configuration.
  3. Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _ISCSI_CHAP_H_
  7. #define _ISCSI_CHAP_H_
  8. #define ISCSI_AUTH_METHOD_CHAP "CHAP"
  9. #define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"
  10. #define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
  11. #define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"
  12. #define ISCSI_KEY_CHAP_NAME "CHAP_N"
  13. #define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"
  14. #define ISCSI_CHAP_ALGORITHM_MD5 5
  15. #define ISCSI_CHAP_AUTH_MAX_LEN 1024
  16. ///
  17. /// MD5_HASHSIZE
  18. ///
  19. #define ISCSI_CHAP_RSP_LEN 16
  20. #define ISCSI_CHAP_STEP_ONE 1
  21. #define ISCSI_CHAP_STEP_TWO 2
  22. #define ISCSI_CHAP_STEP_THREE 3
  23. #define ISCSI_CHAP_STEP_FOUR 4
  24. #pragma pack(1)
  25. typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
  26. UINT8 CHAPType;
  27. CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
  28. CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
  29. CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
  30. CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
  31. } ISCSI_CHAP_AUTH_CONFIG_NVDATA;
  32. #pragma pack()
  33. ///
  34. /// ISCSI CHAP Authentication Data
  35. ///
  36. typedef struct _ISCSI_CHAP_AUTH_DATA {
  37. ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
  38. UINT32 InIdentifier;
  39. UINT8 InChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
  40. UINT32 InChallengeLength;
  41. //
  42. // Calculated CHAP Response (CHAP_R) value.
  43. //
  44. UINT8 CHAPResponse[ISCSI_CHAP_RSP_LEN];
  45. //
  46. // Auth-data to be sent out for mutual authentication.
  47. //
  48. UINT32 OutIdentifier;
  49. UINT8 OutChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
  50. UINT32 OutChallengeLength;
  51. } ISCSI_CHAP_AUTH_DATA;
  52. /**
  53. This function checks the received iSCSI Login Response during the security
  54. negotiation stage.
  55. @param[in] Conn The iSCSI connection.
  56. @retval EFI_SUCCESS The Login Response passed the CHAP validation.
  57. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  58. @retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.
  59. @retval Others Other errors as indicated.
  60. **/
  61. EFI_STATUS
  62. IScsiCHAPOnRspReceived (
  63. IN ISCSI_CONNECTION *Conn
  64. );
  65. /**
  66. This function fills the CHAP authentication information into the login PDU
  67. during the security negotiation stage in the iSCSI connection login.
  68. @param[in] Conn The iSCSI connection.
  69. @param[in, out] Pdu The PDU to send out.
  70. @retval EFI_SUCCESS All check passed and the phase-related CHAP
  71. authentication info is filled into the iSCSI PDU.
  72. @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
  73. @retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.
  74. **/
  75. EFI_STATUS
  76. IScsiCHAPToSendReq (
  77. IN ISCSI_CONNECTION *Conn,
  78. IN OUT NET_BUF *Pdu
  79. );
  80. #endif