iPXE
chap.h
Go to the documentation of this file.
1 #ifndef _IPXE_CHAP_H
2 #define _IPXE_CHAP_H
3 
4 /** @file
5  *
6  * CHAP protocol
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stdint.h>
14 #include <ipxe/md5.h>
15 
16 struct digest_algorithm;
17 
18 /** A CHAP response */
19 struct chap_response {
20  /** Digest algorithm used for the response */
22  /** Context used by the digest algorithm */
24  /** CHAP response */
26  /** Length of CHAP response */
27  size_t response_len;
28 };
29 
30 extern int chap_init ( struct chap_response *chap,
31  struct digest_algorithm *digest );
32 extern void chap_update ( struct chap_response *chap, const void *data,
33  size_t len );
34 extern void chap_respond ( struct chap_response *chap );
35 extern void chap_finish ( struct chap_response *chap );
36 
37 /**
38  * Add identifier data to the CHAP challenge
39  *
40  * @v chap CHAP response
41  * @v identifier CHAP identifier
42  *
43  * The CHAP identifier is the first byte of the CHAP challenge. This
44  * function is a notational convenience for calling chap_update() for
45  * the identifier byte.
46  */
47 static inline void chap_set_identifier ( struct chap_response *chap,
48  unsigned int identifier ) {
49  uint8_t ident_byte = identifier;
50 
51  chap_update ( chap, &ident_byte, sizeof ( ident_byte ) );
52 }
53 
54 #endif /* _IPXE_CHAP_H */
int chap_init(struct chap_response *chap, struct digest_algorithm *digest)
Initialise CHAP challenge/response.
Definition: chap.c:52
A CHAP response.
Definition: chap.h:19
void chap_respond(struct chap_response *chap)
Respond to the CHAP challenge.
Definition: chap.c:105
uint8_t * response
CHAP response.
Definition: chap.h:25
uint8_t * digest_context
Context used by the digest algorithm.
Definition: chap.h:23
void chap_finish(struct chap_response *chap)
Free resources used by a CHAP response.
Definition: chap.c:123
ring len
Length.
Definition: dwmac.h:231
struct digest_algorithm * digest
Digest algorithm used for the response.
Definition: chap.h:21
void chap_update(struct chap_response *chap, const void *data, size_t len)
Add data to the CHAP challenge.
Definition: chap.c:86
unsigned char uint8_t
Definition: stdint.h:10
size_t response_len
Length of CHAP response.
Definition: chap.h:27
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void chap_set_identifier(struct chap_response *chap, unsigned int identifier)
Add identifier data to the CHAP challenge.
Definition: chap.h:47
FILE_SECBOOT(PERMITTED)
A message digest algorithm.
Definition: crypto.h:19
uint8_t data[48]
Additional event data.
Definition: ena.h:22
MD5 algorithm.