wolfssl_adapter.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* This file is part of Graphene Library OS.
  2. Graphene Library OS is free software: you can redistribute it and/or
  3. modify it under the terms of the GNU General Public License
  4. as published by the Free Software Foundation, either version 3 of the
  5. License, or (at your option) any later version.
  6. Graphene Library OS is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  12. #include <stdint.h>
  13. #include "pal.h"
  14. #include "pal_crypto.h"
  15. #include "crypto/wolfssl/sha256.h"
  16. int lib_SHA256Init(LIB_SHA256_CONTEXT *context)
  17. {
  18. return SHA256Init(context);
  19. }
  20. int lib_SHA256Update(LIB_SHA256_CONTEXT *context, const uint8_t *data,
  21. uint64_t len)
  22. {
  23. /* uint64_t is a 64-bit value, but SHA256Update takes a 32-bit len. */
  24. if (len > UINT32_MAX) {
  25. return -1;
  26. }
  27. return SHA256Update(context, data, len);
  28. }
  29. int lib_SHA256Final(LIB_SHA256_CONTEXT *context, uint8_t *output)
  30. {
  31. return SHA256Final(context, output);
  32. }