説明なし

sha1.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. ---------------------------------------------------------------------------
  3. Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved.
  4. LICENSE TERMS
  5. The free distribution and use of this software in both source and binary
  6. form is allowed (with or without changes) provided that:
  7. 1. distributions of this source code include the above copyright
  8. notice, this list of conditions and the following disclaimer;
  9. 2. distributions in binary form include the above copyright
  10. notice, this list of conditions and the following disclaimer
  11. in the documentation and/or other associated materials;
  12. 3. the copyright holder's name is not used to endorse products
  13. built using this software without specific written permission.
  14. ALTERNATIVELY, provided that this notice is retained in full, this product
  15. may be distributed under the terms of the GNU General Public License (GPL),
  16. in which case the provisions of the GPL apply INSTEAD OF those given above.
  17. DISCLAIMER
  18. This software is provided 'as is' with no explicit or implied warranties
  19. in respect of its properties, including, but not limited to, correctness
  20. and/or fitness for purpose.
  21. ---------------------------------------------------------------------------
  22. Issue Date: 01/08/2005
  23. */
  24. #ifndef _SHA1_H
  25. #define _SHA1_H
  26. #include <stdlib.h>
  27. #include "brg_types.h"
  28. #define SHA1_BLOCK_SIZE 64
  29. #define SHA1_DIGEST_SIZE 20
  30. #if defined(__cplusplus)
  31. extern "C"
  32. {
  33. #endif
  34. /* type to hold the SHA256 context */
  35. typedef struct
  36. { uint_32t count[2];
  37. uint_32t hash[5];
  38. uint_32t wbuf[16];
  39. } sha1_ctx;
  40. /* Note that these prototypes are the same for both bit and */
  41. /* byte oriented implementations. However the length fields */
  42. /* are in bytes or bits as appropriate for the version used */
  43. /* and bit sequences are input as arrays of bytes in which */
  44. /* bit sequences run from the most to the least significant */
  45. /* end of each byte */
  46. VOID_RETURN sha1_compile(sha1_ctx ctx[1]);
  47. VOID_RETURN sha1_begin(sha1_ctx ctx[1]);
  48. VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]);
  49. VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
  50. VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
  51. #if defined(__cplusplus)
  52. }
  53. #endif
  54. #endif