sha256.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* sha256.h
  4. *
  5. * Copyright (C) 2006-2014 wolfSSL Inc.
  6. *
  7. * This file is part of CyaSSL.
  8. *
  9. * CyaSSL is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * CyaSSL is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef CTAO_CRYPT_SHA256_H
  24. #define CTAO_CRYPT_SHA256_H
  25. #include "crypto/integer.h"
  26. /* in bytes */
  27. enum {
  28. SHA256_BLOCK_SIZE = 64,
  29. SHA256_DIGEST_SIZE = 32,
  30. SHA256_PAD_SIZE = 56
  31. };
  32. /* SHA256 digest */
  33. typedef struct SHA256 {
  34. word32 buffLen; /* in bytes */
  35. word32 loLen; /* length in bytes */
  36. word32 hiLen; /* length in bytes */
  37. word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)];
  38. word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)];
  39. } SHA256;
  40. int SHA256Init(SHA256 *);
  41. int SHA256Update(SHA256 *, const byte *, word32);
  42. int SHA256Final(SHA256 *, byte *);
  43. int SHA256Hash(const byte *, word32, byte *);
  44. #endif /* CTAO_CRYPT_SHA256_H */