mirror of
https://github.com/ipxe/ipxe
synced 2025-12-29 11:03:15 +03:00
Added generic CHAP layer, independent of iSCSI
This commit is contained in:
51
src/include/gpxe/chap.h
Normal file
51
src/include/gpxe/chap.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _GPXE_CHAP_H
|
||||
#define _GPXE_CHAP_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* CHAP protocol
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gpxe/md5.h>
|
||||
|
||||
struct digest_algorithm;
|
||||
|
||||
/** A CHAP challenge/response */
|
||||
struct chap_challenge {
|
||||
/** Digest algorithm used for the response */
|
||||
struct digest_algorithm *digest;
|
||||
/** Context used by the digest algorithm */
|
||||
uint8_t *digest_context;
|
||||
/** CHAP response */
|
||||
uint8_t *response;
|
||||
/** Length of CHAP response */
|
||||
size_t response_len;
|
||||
};
|
||||
|
||||
extern int chap_init ( struct chap_challenge *chap,
|
||||
struct digest_algorithm *digest );
|
||||
extern void chap_update ( struct chap_challenge *chap, const void *data,
|
||||
size_t len );
|
||||
extern void chap_respond ( struct chap_challenge *chap );
|
||||
extern void chap_finish ( struct chap_challenge *chap );
|
||||
|
||||
/**
|
||||
* Add identifier data to the CHAP challenge
|
||||
*
|
||||
* @v chap CHAP challenge/response
|
||||
* @v identifier CHAP identifier
|
||||
*
|
||||
* The CHAP identifier is the first byte of the CHAP challenge. This
|
||||
* function is a notational convenience for calling chap_update() for
|
||||
* the identifier byte.
|
||||
*/
|
||||
static inline void chap_set_identifier ( struct chap_challenge *chap,
|
||||
unsigned int identifier ) {
|
||||
uint8_t ident_byte = identifier;
|
||||
|
||||
chap_update ( chap, &ident_byte, sizeof ( ident_byte ) );
|
||||
}
|
||||
|
||||
#endif /* _GPXE_CHAP_H */
|
||||
Reference in New Issue
Block a user