* pg_cryptohash_create * * Allocate a hash context. Returns NULL on failure for an OOM. The * backend issues an error, without returning. */
| 64 | * backend issues an error, without returning. |
| 65 | */ |
| 66 | pg_cryptohash_ctx * |
| 67 | pg_cryptohash_create(pg_cryptohash_type type) |
| 68 | { |
| 69 | pg_cryptohash_ctx *ctx; |
| 70 | |
| 71 | /* |
| 72 | * Note that this always allocates enough space for the largest hash. A |
| 73 | * smaller allocation would be enough for md5, sha224 and sha256, but the |
| 74 | * small extra amount of memory does not make it worth complicating this |
| 75 | * code. |
| 76 | */ |
| 77 | ctx = ALLOC(sizeof(pg_cryptohash_ctx)); |
| 78 | if (ctx == NULL) |
| 79 | return NULL; |
| 80 | memset(ctx, 0, sizeof(pg_cryptohash_ctx)); |
| 81 | ctx->type = type; |
| 82 | |
| 83 | return ctx; |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * pg_cryptohash_init |
no outgoing calls
no test coverage detected