summaryrefslogtreecommitdiff
path: root/src/common/cipher.c
blob: 393b062bc39149cac0031089bc4964f3fc97c85b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*-------------------------------------------------------------------------
 *
 * cipher.c
 *	  Shared frontend/backend for cryptographic functions
 *
 * Copyright (c) 2020, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *	  src/common/cipher.c
 *
 *-------------------------------------------------------------------------
 */

#ifndef FRONTEND
#include "postgres.h"
#else
#include "postgres_fe.h"
#endif

#include "common/cipher.h"

static void cipher_failure(void) pg_attribute_noreturn();

PgCipherCtx *
pg_cipher_ctx_create(int cipher, uint8 *key, int klen, bool enc)
{
	cipher_failure();
}

void
pg_cipher_ctx_free(PgCipherCtx *ctx)
{
	cipher_failure();
}

bool
pg_cipher_encrypt(PgCipherCtx *ctx, const unsigned char *plaintext,
				  const int inlen, unsigned char *ciphertext, int *outlen,
				  const unsigned char *iv, const int ivlen,
				  unsigned char *outtag, const int taglen)
{
	cipher_failure();
}

bool
pg_cipher_decrypt(PgCipherCtx *ctx, const unsigned char *ciphertext,
				  const int inlen, unsigned char *plaintext, int *outlen,
				  const unsigned char *iv, const int ivlen,
				  unsigned char *intag, const int taglen)
{
	cipher_failure();
}

static void
cipher_failure(void)
{
#ifndef FRONTEND
	ereport(ERROR,
		   (errcode(ERRCODE_CONFIG_FILE_ERROR),
			(errmsg("cluster file encryption is not supported because OpenSSL is not supported by this build"),
			 errhint("Compile with --with-openssl to use this feature."))));
#else
	fprintf(stderr, _("cluster file encryption is not supported because OpenSSL is not supported by this build"));
	exit(1);
#endif
}