sha1.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Yet another SHA-1 implementation.
  2. *
  3. * Copyright (c) 2003 Red Hat, Inc.
  4. * Written by Nalin Dahyabhai <nalin@redhat.com>
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, and the entire permission notice in its entirety,
  11. * including the disclaimer of warranties.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. The name of the author may not be used to endorse or promote
  16. * products derived from this software without specific prior
  17. * written permission.
  18. *
  19. * ALTERNATIVELY, this product may be distributed under the terms of
  20. * the GNU Public License, in which case the provisions of the GPL are
  21. * required INSTEAD OF the above restrictions. (This clause is
  22. * necessary due to a potential bad interaction between the GPL and
  23. * the restrictions contained in a BSD-style copyright.)
  24. *
  25. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  26. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  29. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  33. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  35. * OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. */
  38. #ifndef pam_timestamp_sha1_h
  39. #define pam_timestamp_sha1_h
  40. #include <stdint.h>
  41. #include <sys/types.h>
  42. #include "pam_cc_compat.h"
  43. #define SHA1_BLOCK_SIZE 64
  44. struct sha1_context {
  45. size_t count;
  46. union {
  47. unsigned char c[SHA1_BLOCK_SIZE];
  48. uint32_t i[SHA1_BLOCK_SIZE / sizeof(uint32_t)];
  49. } pending;
  50. uint32_t counts[2];
  51. size_t pending_count;
  52. uint32_t a, b, c, d, e;
  53. };
  54. #define SHA1_OUTPUT_SIZE 20
  55. void sha1_init(struct sha1_context *ctx);
  56. void sha1_update(struct sha1_context *ctx,
  57. const unsigned char *data, size_t length);
  58. size_t sha1_output(struct sha1_context *ctx, unsigned char *out);
  59. #endif