hmac-md5.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* hmac-md5.h -- HMAC_MD5 functions
  2. */
  3. #ifndef HMAC_MD5_H
  4. #define HMAC_MD5_H 1
  5. #define HMAC_MD5_SIZE 16
  6. /* intermediate MD5 context */
  7. typedef struct HMAC_MD5_CTX_s {
  8. MD5_CTX ictx, octx;
  9. } HMAC_MD5_CTX;
  10. /* intermediate HMAC state
  11. * values stored in network byte order (Big Endian)
  12. */
  13. typedef struct HMAC_MD5_STATE_s {
  14. SASL_UINT4 istate[4];
  15. SASL_UINT4 ostate[4];
  16. } HMAC_MD5_STATE;
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /* One step hmac computation
  21. *
  22. * digest may be same as text or key
  23. */
  24. void _sasl_hmac_md5(const unsigned char *text, int text_len,
  25. const unsigned char *key, int key_len,
  26. unsigned char digest[HMAC_MD5_SIZE]);
  27. /* create context from key
  28. */
  29. void _sasl_hmac_md5_init(HMAC_MD5_CTX *hmac,
  30. const unsigned char *key, int key_len);
  31. /* precalculate intermediate state from key
  32. */
  33. void _sasl_hmac_md5_precalc(HMAC_MD5_STATE *hmac,
  34. const unsigned char *key, int key_len);
  35. /* initialize context from intermediate state
  36. */
  37. void _sasl_hmac_md5_import(HMAC_MD5_CTX *hmac, HMAC_MD5_STATE *state);
  38. #define _sasl_hmac_md5_update(hmac, text, text_len) _sasl_MD5Update(&(hmac)->ictx, (text), (text_len))
  39. /* finish hmac from intermediate result. Intermediate result is zeroed.
  40. */
  41. void _sasl_hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
  42. HMAC_MD5_CTX *hmac);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif /* HMAC_MD5_H */