0005-Skeleton-Introduce-WAL-encryption-for-cluster-encyrp.patch

application/octet-stream

Filename: 0005-Skeleton-Introduce-WAL-encryption-for-cluster-encyrp.patch
Type: application/octet-stream
Part: 2
Message: Re: [Proposal] Table-level Transparent Data Encryption (TDE) and Key Management Service (KMS)

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0005
Subject: Skeleton: Introduce WAL encryption for cluster encyrption
File+
src/backend/storage/encryption/walenc.c 42 0
From e039128fcb089b5b6064d8b39763a9bc8ddd4a72 Mon Sep 17 00:00:00 2001
From: Masahiko Sawada <sawada.mshk@gmail.com>
Date: Thu, 15 Aug 2019 13:23:30 +0900
Subject: [PATCH 5/5] Skeleton: Introduce WAL encryption for cluster encyrption

---
 src/backend/storage/encryption/walenc.c | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 src/backend/storage/encryption/walenc.c

diff --git a/src/backend/storage/encryption/walenc.c b/src/backend/storage/encryption/walenc.c
new file mode 100644
index 0000000..2a30319
--- /dev/null
+++ b/src/backend/storage/encryption/walenc.c
@@ -0,0 +1,42 @@
+/*-------------------------------------------------------------------------
+ *
+ * walenc.c
+ *
+ * Copyright (c) 2019, PostgreSQL Global Development Group
+ *
+ *
+ * IDENTIFICATION
+ *	  src/backend/storage/encryption/walenc.c
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#include "access/xlog.h"
+#include "storage/encryption.h"
+
+#ifdef NOT_USED
+static char wal_encryption_iv[ENC_IV_SIZE];
+
+static void
+set_wal_encryption_iv(char *iv, XLogSegNo segment, uint32 offset)
+{
+	char *p = iv;
+	uint32 pageno = offset / XLOG_BLCKSZ;
+
+	Assert(iv != NULL);
+
+	/* Space for counter (4 byte) */
+	memset(p, 0, ENC_WAL_AES_COUNTER_SIZE);
+	p += ENC_WAL_AES_COUNTER_SIZE;
+
+	/* Segment number (8 byte) */
+	memcpy(p, &segment, sizeof(XLogSegNo));
+	p += sizeof(XLogSegNo);
+
+	/* Page number within a WAL segment (4 byte) */
+	memcpy(p, &pageno, sizeof(uint32));
+}
+#endif
+
-- 
2.10.5