TianoCore EDK2 master
Loading...
Searching...
No Matches
IScsiCHAP.h
Go to the documentation of this file.
1
9#ifndef _ISCSI_CHAP_H_
10#define _ISCSI_CHAP_H_
11
12#define ISCSI_AUTH_METHOD_CHAP "CHAP"
13
14#define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"
15#define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
16#define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"
17#define ISCSI_KEY_CHAP_NAME "CHAP_N"
18#define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"
19
20//
21// Identifiers of supported CHAP hash algorithms:
22// https://www.iana.org/assignments/ppp-numbers/ppp-numbers.xhtml#ppp-numbers-9
23//
24#define ISCSI_CHAP_ALGORITHM_MD5 5
25#define ISCSI_CHAP_ALGORITHM_SHA256 7
26
27//
28// Byte count of the largest digest over the above-listed
29// ISCSI_CHAP_ALGORITHM_* hash algorithms.
30//
31#define ISCSI_CHAP_MAX_DIGEST_SIZE SHA256_DIGEST_SIZE
32
33#define ISCSI_CHAP_STEP_ONE 1
34#define ISCSI_CHAP_STEP_TWO 2
35#define ISCSI_CHAP_STEP_THREE 3
36#define ISCSI_CHAP_STEP_FOUR 4
37
38#pragma pack(1)
39
41 UINT8 CHAPType;
42 CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
43 CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
44 CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
45 CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
47
48#pragma pack()
49
50//
51// Typedefs for collecting sets of hash APIs from BaseCryptLib.
52//
53typedef
55(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE)(
56 VOID
57 );
58
59typedef
60BOOLEAN
61(EFIAPI *CHAP_HASH_INIT)(
62 OUT VOID *Context
63 );
64
65typedef
66BOOLEAN
67(EFIAPI *CHAP_HASH_UPDATE)(
68 IN OUT VOID *Context,
69 IN CONST VOID *Data,
70 IN UINTN DataSize
71 );
72
73typedef
74BOOLEAN
75(EFIAPI *CHAP_HASH_FINAL)(
76 IN OUT VOID *Context,
77 OUT UINT8 *HashValue
78 );
79
80typedef struct {
81 UINT8 Algorithm; // ISCSI_CHAP_ALGORITHM_*, CHAP_A
82 UINT32 DigestSize;
83 CHAP_HASH_GET_CONTEXT_SIZE GetContextSize;
84 CHAP_HASH_INIT Init;
85 CHAP_HASH_UPDATE Update;
86 CHAP_HASH_FINAL Final;
87} CHAP_HASH;
88
92typedef struct _ISCSI_CHAP_AUTH_DATA {
94 UINT32 InIdentifier;
95 UINT8 InChallenge[1024];
96 UINT32 InChallengeLength;
97 //
98 // The hash algorithm (CHAP_A) that the target selects in
99 // ISCSI_CHAP_STEP_TWO.
100 //
101 CONST CHAP_HASH *Hash;
102 //
103 // Calculated CHAP Response (CHAP_R) value.
104 //
105 UINT8 CHAPResponse[ISCSI_CHAP_MAX_DIGEST_SIZE];
106
107 //
108 // Auth-data to be sent out for mutual authentication.
109 //
110 // While the challenge size is technically independent of the hashing
111 // algorithm, it is good practice to avoid hashing *fewer bytes* than the
112 // digest size. In other words, it's good practice to feed *at least as many
113 // bytes* to the hashing algorithm as the hashing algorithm will output.
114 //
115 UINT32 OutIdentifier;
116 UINT8 OutChallenge[ISCSI_CHAP_MAX_DIGEST_SIZE];
118
133 IN ISCSI_CONNECTION *Conn
134 );
135
152 IN ISCSI_CONNECTION *Conn,
153 IN OUT NET_BUF *Pdu
154 );
155
163VOID
165 VOID
166 );
167
168#endif
UINT64 UINTN
struct _ISCSI_CHAP_AUTH_DATA ISCSI_CHAP_AUTH_DATA
EFI_STATUS IScsiCHAPToSendReq(IN ISCSI_CONNECTION *Conn, IN OUT NET_BUF *Pdu)
Definition: IScsiCHAP.c:470
VOID IScsiCHAPInitHashList(VOID)
Definition: IScsiCHAP.c:635
EFI_STATUS IScsiCHAPOnRspReceived(IN ISCSI_CONNECTION *Conn)
Definition: IScsiCHAP.c:215
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29