sha256.h 1008 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #ifndef SHA256_H
  17. #define SHA256_H
  18. #include <stddef.h>
  19. #include <stdint.h>
  20. #define SHA256_BLOCK_SIZE 32
  21. typedef struct {
  22. uint8_t data[64];
  23. uint32_t datalen;
  24. unsigned long long bitlen;
  25. uint32_t state[8];
  26. } SHA256_CTX;
  27. void sha256_init(SHA256_CTX *ctx);
  28. void sha256_update(SHA256_CTX *ctx, const uint8_t data[], size_t len);
  29. void sha256_final(SHA256_CTX *ctx, uint8_t hash[]);
  30. #endif