wolfssl_adapter.c 1.3 KB

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