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 
12 #include <stdint.h>
13 #include <ipxe/md5.h>
14 
15 struct digest_algorithm;
16 
17 /** A CHAP response */
18 struct chap_response {
19  /** Digest algorithm used for the response */
21  /** Context used by the digest algorithm */
23  /** CHAP response */
25  /** Length of CHAP response */
26  size_t response_len;
27 };
28 
29 extern int chap_init ( struct chap_response *chap,
30  struct digest_algorithm *digest );
31 extern void chap_update ( struct chap_response *chap, const void *data,
32  size_t len );
33 extern void chap_respond ( struct chap_response *chap );
34 extern void chap_finish ( struct chap_response *chap );
35 
36 /**
37  * Add identifier data to the CHAP challenge
38  *
39  * @v chap CHAP response
40  * @v identifier CHAP identifier
41  *
42  * The CHAP identifier is the first byte of the CHAP challenge. This
43  * function is a notational convenience for calling chap_update() for
44  * the identifier byte.
45  */
46 static inline void chap_set_identifier ( struct chap_response *chap,
47  unsigned int identifier ) {
48  uint8_t ident_byte = identifier;
49 
50  chap_update ( chap, &ident_byte, sizeof ( ident_byte ) );
51 }
52 
53 #endif /* _IPXE_CHAP_H */
int chap_init(struct chap_response *chap, struct digest_algorithm *digest)
Initialise CHAP challenge/response.
Definition: chap.c:51
A CHAP response.
Definition: chap.h:18
void chap_respond(struct chap_response *chap)
Respond to the CHAP challenge.
Definition: chap.c:104
uint8_t * response
CHAP response.
Definition: chap.h:24
uint8_t * digest_context
Context used by the digest algorithm.
Definition: chap.h:22
struct md4_digest digest
Digest of data already processed.
Definition: md4.h:12
void chap_finish(struct chap_response *chap)
Free resources used by a CHAP response.
Definition: chap.c:122
struct digest_algorithm * digest
Digest algorithm used for the response.
Definition: chap.h:20
void chap_update(struct chap_response *chap, const void *data, size_t len)
Add data to the CHAP challenge.
Definition: chap.c:85
unsigned char uint8_t
Definition: stdint.h:10
size_t response_len
Length of CHAP response.
Definition: chap.h:26
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:46
uint32_t len
Length.
Definition: ena.h:14
A message digest algorithm.
Definition: crypto.h:16
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
MD5 algorithm.