Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

chap.h 1.2KB

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 response */
  12. struct chap_response {
  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_response *chap,
  23. struct crypto_algorithm *digest );
  24. extern void chap_update ( struct chap_response *chap, const void *data,
  25. size_t len );
  26. extern void chap_respond ( struct chap_response *chap );
  27. extern void chap_finish ( struct chap_response *chap );
  28. /**
  29. * Add identifier data to the CHAP challenge
  30. *
  31. * @v chap CHAP 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_response *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 */