You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chap.h 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _IPXE_CHAP_H
  2. #define _IPXE_CHAP_H
  3. /** @file
  4. *
  5. * CHAP protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/md5.h>
  11. struct digest_algorithm;
  12. /** A CHAP response */
  13. struct chap_response {
  14. /** Digest algorithm used for the response */
  15. struct digest_algorithm *digest;
  16. /** Context used by the digest algorithm */
  17. uint8_t *digest_context;
  18. /** CHAP response */
  19. uint8_t *response;
  20. /** Length of CHAP response */
  21. size_t response_len;
  22. };
  23. extern int chap_init ( struct chap_response *chap,
  24. struct digest_algorithm *digest );
  25. extern void chap_update ( struct chap_response *chap, const void *data,
  26. size_t len );
  27. extern void chap_respond ( struct chap_response *chap );
  28. extern void chap_finish ( struct chap_response *chap );
  29. /**
  30. * Add identifier data to the CHAP challenge
  31. *
  32. * @v chap CHAP response
  33. * @v identifier CHAP identifier
  34. *
  35. * The CHAP identifier is the first byte of the CHAP challenge. This
  36. * function is a notational convenience for calling chap_update() for
  37. * the identifier byte.
  38. */
  39. static inline void chap_set_identifier ( struct chap_response *chap,
  40. unsigned int identifier ) {
  41. uint8_t ident_byte = identifier;
  42. chap_update ( chap, &ident_byte, sizeof ( ident_byte ) );
  43. }
  44. #endif /* _IPXE_CHAP_H */