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

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