cryptohash.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*-------------------------------------------------------------------------
  2. *
  3. * cryptohash.h
  4. * Generic headers for cryptographic hash functions.
  5. *
  6. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994, Regents of the University of California
  8. *
  9. * IDENTIFICATION
  10. * src/include/common/cryptohash.h
  11. *
  12. *-------------------------------------------------------------------------
  13. */
  14. #ifndef PG_CRYPTOHASH_H
  15. #define PG_CRYPTOHASH_H
  16. /* Context Structures for each hash function */
  17. typedef enum
  18. {
  19. PG_MD5 = 0,
  20. PG_SHA1,
  21. PG_SHA224,
  22. PG_SHA256,
  23. PG_SHA384,
  24. PG_SHA512
  25. } pg_cryptohash_type;
  26. /* opaque context, private to each cryptohash implementation */
  27. typedef struct pg_cryptohash_ctx pg_cryptohash_ctx;
  28. extern pg_cryptohash_ctx *pg_cryptohash_create(pg_cryptohash_type type);
  29. extern int pg_cryptohash_init(pg_cryptohash_ctx *ctx);
  30. extern int pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len);
  31. extern int pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len);
  32. extern void pg_cryptohash_free(pg_cryptohash_ctx *ctx);
  33. extern const char *pg_cryptohash_error(pg_cryptohash_ctx *ctx);
  34. #endif /* PG_CRYPTOHASH_H */