md5.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* md5.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /*
  17. * File: md5.h
  18. * Author: Daniel Otte
  19. * Date: 31.07.2006
  20. * License: GPL
  21. * Description: Implementation of the MD5 hash algorithm as described in RFC 1321
  22. *
  23. */
  24. #ifndef MD5_H_
  25. #define MD5_H_
  26. #include <stdint.h>
  27. #define MD5_HASH_BITS 128
  28. #define MD5_HASH_BYTES (MD5_HASH_BITS/8)
  29. #define MD5_BLOCK_BITS 512
  30. #define MD5_BLOCK_BYTES (MD5_BLOCK_BITS/8)
  31. typedef struct md5_ctx_st {
  32. uint32_t a[4];
  33. uint32_t counter;
  34. } md5_ctx_t;
  35. typedef uint8_t md5_hash_t[MD5_HASH_BYTES];
  36. void md5_init(md5_ctx_t *s);
  37. void md5_nextBlock(md5_ctx_t *state, const void* block);
  38. void md5_lastBlock(md5_ctx_t *state, const void* block, uint16_t length);
  39. void md5_ctx2hash(md5_hash_t* dest, const md5_ctx_t* state);
  40. void md5(md5_hash_t* dest, const void* msg, uint32_t length_b);
  41. #endif /*MD5_H_*/