2
0

sha1.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * sha1.h
  3. *
  4. * interface to the Secure Hash Algorithm v.1 (SHA-1), specified in
  5. * FIPS 180-1
  6. *
  7. * David A. McGrew
  8. * Cisco Systems, Inc.
  9. */
  10. /*
  11. *
  12. * Copyright (c) 2001-2017, Cisco Systems, Inc.
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions
  17. * are met:
  18. *
  19. * Redistributions of source code must retain the above copyright
  20. * notice, this list of conditions and the following disclaimer.
  21. *
  22. * Redistributions in binary form must reproduce the above
  23. * copyright notice, this list of conditions and the following
  24. * disclaimer in the documentation and/or other materials provided
  25. * with the distribution.
  26. *
  27. * Neither the name of the Cisco Systems, Inc. nor the names of its
  28. * contributors may be used to endorse or promote products derived
  29. * from this software without specific prior written permission.
  30. *
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  34. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  35. * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  36. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  37. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  38. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  42. * OF THE POSSIBILITY OF SUCH DAMAGE.
  43. *
  44. */
  45. #ifndef SHA1_H
  46. #define SHA1_H
  47. #ifdef HAVE_CONFIG_H
  48. #include <config.h>
  49. #endif
  50. #include "err.h"
  51. #include "datatypes.h"
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. typedef struct {
  56. uint32_t H[5]; /* state vector */
  57. uint32_t M[16]; /* message buffer */
  58. int octets_in_buffer; /* octets of message in buffer */
  59. uint32_t num_bits_in_msg; /* total number of bits in message */
  60. } srtp_sha1_ctx_t;
  61. /*
  62. * srtp_sha1_init(&ctx) initializes the SHA1 context ctx
  63. *
  64. * srtp_sha1_update(&ctx, msg, len) hashes the len octets starting at msg
  65. * into the SHA1 context
  66. *
  67. * srtp_sha1_final(&ctx, output) performs the final processing of the SHA1
  68. * context and writes the result to the 20 octets at output
  69. *
  70. */
  71. void srtp_sha1_init(srtp_sha1_ctx_t *ctx);
  72. void srtp_sha1_update(srtp_sha1_ctx_t *ctx,
  73. const uint8_t *M,
  74. int octets_in_msg);
  75. void srtp_sha1_final(srtp_sha1_ctx_t *ctx, uint32_t output[5]);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif /* SHA1_H */