sha1.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * sha1.h
  3. * Copyright (C) The Internet Society (2001). All Rights Reserved.
  4. * This document and translations of it may be copied and furnished to others,
  5. * and derivative works that comment on or otherwise explain it or assist in its
  6. * implementation may be prepared, copied, published and distributed, in whole or in part,
  7. * without restriction of any kind, provided that the above copyright notice and this paragraph
  8. * are included on all such copies and derivative works. However, this document itself may not
  9. * be modified in any way, such as by removing the copyright notice or references to the Internet Society
  10. * or other Internet organizations, except as needed for the purpose of developing Internet standards in
  11. * which case the procedures for copyrights defined in the Internet Standards process must be followed,
  12. * or as required to translate it into languages other than English.
  13. *
  14. * The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
  15. *
  16. * This document and the information contained herein is provided on an "AS IS" basis and
  17. * THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  18. * INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS
  19. * OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  20. *
  21. *
  22. * Description:
  23. * This is the header file for code which implements the Secure
  24. * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
  25. * April 17, 1995.
  26. *
  27. * Many of the variable names in this code, especially the
  28. * single character names, were used because those were the names
  29. * used in the publication.
  30. *
  31. * Please read the file sha1.c for more information.
  32. *
  33. */
  34. #ifndef _SHA1_H_
  35. #define _SHA1_H_
  36. #include <stdint.h>
  37. /*
  38. * If you do not have the ISO standard stdint.h header file, then you
  39. * must typdef the following:
  40. * name meaning
  41. * uint32_t unsigned 32 bit integer
  42. * uint8_t unsigned 8 bit integer (i.e., unsigned char)
  43. * int_least16_t integer of >= 16 bits
  44. *
  45. */
  46. #ifndef _SHA_enum_
  47. #define _SHA_enum_
  48. enum
  49. {
  50. shaSuccess = 0,
  51. shaNull, /* Null pointer parameter */
  52. shaInputTooLong, /* input data too long */
  53. shaStateError /* called Input after Result */
  54. };
  55. #endif
  56. #define SHA1HashSize 20
  57. /*
  58. * This structure will hold context information for the SHA-1
  59. * hashing operation
  60. */
  61. typedef struct SHA1Context
  62. {
  63. uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
  64. uint32_t Length_Low; /* Message length in bits */
  65. uint32_t Length_High; /* Message length in bits */
  66. /* Index into message block array */
  67. int_least16_t Message_Block_Index;
  68. uint8_t Message_Block[64]; /* 512-bit message blocks */
  69. int Computed; /* Is the digest computed? */
  70. int Corrupted; /* Is the message digest corrupted? */
  71. } SHA1Context;
  72. /*
  73. * Function Prototypes
  74. */
  75. int SHA1Reset( SHA1Context *);
  76. int SHA1Input( SHA1Context *,
  77. const uint8_t *,
  78. unsigned int);
  79. int SHA1Result( SHA1Context *,
  80. uint8_t Message_Digest[SHA1HashSize]);
  81. void SHA1ConvertMessageToString(uint8_t *hash_binary, char* hash_string);
  82. #endif