chash.c 776 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * cifra - embedded cryptography library
  3. * Written in 2014 by Joseph Birr-Pixton <jpixton@gmail.com>
  4. *
  5. * To the extent possible under law, the author(s) have dedicated all
  6. * copyright and related and neighboring rights to this software to the
  7. * public domain worldwide. This software is distributed without any
  8. * warranty.
  9. *
  10. * You should have received a copy of the CC0 Public Domain Dedication
  11. * along with this software. If not, see
  12. * <http://creativecommons.org/publicdomain/zero/1.0/>.
  13. */
  14. #include "chash.h"
  15. #include "handy.h"
  16. #include "tassert.h"
  17. void cf_hash(const cf_chash *h, const void *m, size_t nm, uint8_t *out)
  18. {
  19. cf_chash_ctx ctx;
  20. assert(h);
  21. h->init(&ctx);
  22. h->update(&ctx, m, nm);
  23. h->digest(&ctx, out);
  24. mem_clean(&ctx, sizeof ctx);
  25. }