MD5_128.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. *****************************************************************
  14. *
  15. * Md5_128.c
  16. * This Code is taken from RFC 1321(RFC1321)
  17. *
  18. *
  19. *****************************************************************/
  20. #include "md5.h"
  21. /******************************************************************************
  22. *
  23. * Name
  24. * MD5_128
  25. *
  26. * Abstract:
  27. * Function to compute the digest using MD5.
  28. *
  29. * Context/Scope:
  30. * Called from anywhere.
  31. *
  32. * Side Effects:
  33. *
  34. * Return Value:
  35. * None
  36. *
  37. * Assumptions:
  38. * None
  39. *
  40. ******************************************************************************/
  41. void MD5_128(char* k, /* secret key */
  42. int lk, /* length of the key in bytes */
  43. char* d, /* data */
  44. int ld, /* length of data in bytes */
  45. char* out, /* output buffer, at least "t" bytes */
  46. int t )
  47. {
  48. MD5_CTX ctx;
  49. MD5_Init(&ctx) ;
  50. MD5_Update(&ctx, (unsigned char *) k, lk) ;
  51. MD5_Update(&ctx, (unsigned char *) d, ld) ;
  52. // Added this to match the MD5 for user password integrity
  53. MD5_Update(&ctx, (unsigned char *) k, lk) ;
  54. MD5_Final((unsigned char *) out,&ctx ) ;
  55. }