logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git

sha1.h (685B)


  1. // SPDX-FileCopyrightText: public domain sha1 implementation based on rfc3174 and libtomcrypt
  2. // SPDX-License-Identifier: 0BSD
  3. #include <stdint.h>
  4. struct sha1
  5. {
  6. uint64_t len; /* processed message length */
  7. uint32_t h[5]; /* hash state */
  8. uint8_t buf[64]; /* message block buffer */
  9. };
  10. #define SHA1_DIGEST_LENGTH 20
  11. /* reset state */
  12. void sha1_init(void *ctx);
  13. /* process message */
  14. void sha1_update(void *ctx, const void *m, unsigned long len);
  15. /* get message digest */
  16. /* state is ruined after sum, keep a copy if multiple sum is needed */
  17. /* part of the message might be left in s, zero it if secrecy is needed */
  18. void sha1_sum(void *ctx, uint8_t md[SHA1_DIGEST_LENGTH]);