iPXE
|
00001 #ifndef _IPXE_CHAP_H 00002 #define _IPXE_CHAP_H 00003 00004 /** @file 00005 * 00006 * CHAP protocol 00007 * 00008 */ 00009 00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 00011 00012 #include <stdint.h> 00013 #include <ipxe/md5.h> 00014 00015 struct digest_algorithm; 00016 00017 /** A CHAP response */ 00018 struct chap_response { 00019 /** Digest algorithm used for the response */ 00020 struct digest_algorithm *digest; 00021 /** Context used by the digest algorithm */ 00022 uint8_t *digest_context; 00023 /** CHAP response */ 00024 uint8_t *response; 00025 /** Length of CHAP response */ 00026 size_t response_len; 00027 }; 00028 00029 extern int chap_init ( struct chap_response *chap, 00030 struct digest_algorithm *digest ); 00031 extern void chap_update ( struct chap_response *chap, const void *data, 00032 size_t len ); 00033 extern void chap_respond ( struct chap_response *chap ); 00034 extern void chap_finish ( struct chap_response *chap ); 00035 00036 /** 00037 * Add identifier data to the CHAP challenge 00038 * 00039 * @v chap CHAP response 00040 * @v identifier CHAP identifier 00041 * 00042 * The CHAP identifier is the first byte of the CHAP challenge. This 00043 * function is a notational convenience for calling chap_update() for 00044 * the identifier byte. 00045 */ 00046 static inline void chap_set_identifier ( struct chap_response *chap, 00047 unsigned int identifier ) { 00048 uint8_t ident_byte = identifier; 00049 00050 chap_update ( chap, &ident_byte, sizeof ( ident_byte ) ); 00051 } 00052 00053 #endif /* _IPXE_CHAP_H */