1 #ifndef _GPXE_CHAP_H 2 #define _GPXE_CHAP_H 3 4 /** @file 5 * 6 * CHAP protocol 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER ); 11 12 #include <stdint.h> 13 #include <gpxe/md5.h> 14 15 struct digest_algorithm; 16 17 /** A CHAP response */ 18 struct chap_response { 19 /** Digest algorithm used for the response */ 20 struct digest_algorithm *digest; 21 /** Context used by the digest algorithm */ 22 uint8_t *digest_context; 23 /** CHAP response */ 24 uint8_t *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 */ chap_set_identifier(struct chap_response * chap,unsigned int identifier)46static 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 /* _GPXE_CHAP_H */ 54