Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

md5.h 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _IPXE_MD5_H
  2. #define _IPXE_MD5_H
  3. /** @file
  4. *
  5. * MD5 algorithm
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/crypto.h>
  11. /** An MD5 digest */
  12. struct md5_digest {
  13. /** Hash output */
  14. uint32_t h[4];
  15. };
  16. /** An MD5 data block */
  17. union md5_block {
  18. /** Raw bytes */
  19. uint8_t byte[64];
  20. /** Raw dwords */
  21. uint32_t dword[16];
  22. /** Final block structure */
  23. struct {
  24. /** Padding */
  25. uint8_t pad[56];
  26. /** Length in bits */
  27. uint64_t len;
  28. } final;
  29. };
  30. /** MD5 digest and data block
  31. *
  32. * The order of fields within this structure is designed to minimise
  33. * code size.
  34. */
  35. struct md5_digest_data {
  36. /** Digest of data already processed */
  37. struct md5_digest digest;
  38. /** Accumulated data */
  39. union md5_block data;
  40. } __attribute__ (( packed ));
  41. /** MD5 digest and data block */
  42. union md5_digest_data_dwords {
  43. /** Digest and data block */
  44. struct md5_digest_data dd;
  45. /** Raw dwords */
  46. uint32_t dword[ sizeof ( struct md5_digest_data ) /
  47. sizeof ( uint32_t ) ];
  48. };
  49. /** An MD5 context */
  50. struct md5_context {
  51. /** Amount of accumulated data */
  52. size_t len;
  53. /** Digest and accumulated data */
  54. union md5_digest_data_dwords ddd;
  55. } __attribute__ (( packed ));
  56. /** MD5 context size */
  57. #define MD5_CTX_SIZE sizeof ( struct md5_context )
  58. /** MD5 digest size */
  59. #define MD5_DIGEST_SIZE sizeof ( struct md5_digest )
  60. extern struct digest_algorithm md5_algorithm;
  61. #endif /* _IPXE_MD5_H */