From ca48e7fb7a2636f545f188ceaa22e9a57662fd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85strand?= Date: Thu, 28 Aug 2025 13:54:08 +0200 Subject: [PATCH] PG-1892 Move InternalKey to common file This structure seems generally useful and doesn't belong with the relation key code. --- contrib/pg_tde/src/include/access/pg_tde_keys_common.h | 3 --- contrib/pg_tde/src/include/access/pg_tde_tdemap.h | 7 +------ contrib/pg_tde/src/include/access/pg_tde_xlog_keys.h | 1 + contrib/pg_tde/src/include/encryption/enc_tde.h | 9 ++++++++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/pg_tde/src/include/access/pg_tde_keys_common.h b/contrib/pg_tde/src/include/access/pg_tde_keys_common.h index 91554f84474..69d7b76484a 100644 --- a/contrib/pg_tde/src/include/access/pg_tde_keys_common.h +++ b/contrib/pg_tde/src/include/access/pg_tde_keys_common.h @@ -3,9 +3,6 @@ #include "catalog/tde_principal_key.h" -#define INTERNAL_KEY_LEN 16 -#define INTERNAL_KEY_IV_LEN 16 - #define MAP_ENTRY_IV_SIZE 16 #define MAP_ENTRY_AEAD_TAG_SIZE 16 diff --git a/contrib/pg_tde/src/include/access/pg_tde_tdemap.h b/contrib/pg_tde/src/include/access/pg_tde_tdemap.h index 241d0e7f732..40ee9eb9cbc 100644 --- a/contrib/pg_tde/src/include/access/pg_tde_tdemap.h +++ b/contrib/pg_tde/src/include/access/pg_tde_tdemap.h @@ -4,12 +4,7 @@ #include "storage/relfilelocator.h" #include "access/pg_tde_keys_common.h" - -typedef struct InternalKey -{ - uint8 key[INTERNAL_KEY_LEN]; - uint8 base_iv[INTERNAL_KEY_IV_LEN]; -} InternalKey; +#include "encryption/enc_tde.h" extern void pg_tde_save_smgr_key(RelFileLocator rel, const InternalKey *key); extern bool pg_tde_has_smgr_key(RelFileLocator rel); diff --git a/contrib/pg_tde/src/include/access/pg_tde_xlog_keys.h b/contrib/pg_tde/src/include/access/pg_tde_xlog_keys.h index 0ee39585339..63c2e202151 100644 --- a/contrib/pg_tde/src/include/access/pg_tde_xlog_keys.h +++ b/contrib/pg_tde/src/include/access/pg_tde_xlog_keys.h @@ -4,6 +4,7 @@ #include "access/xlog_internal.h" #include "access/pg_tde_keys_common.h" +#include "access/pg_tde_tdemap.h" typedef enum { diff --git a/contrib/pg_tde/src/include/encryption/enc_tde.h b/contrib/pg_tde/src/include/encryption/enc_tde.h index 7873606d61d..64299c85e33 100644 --- a/contrib/pg_tde/src/include/encryption/enc_tde.h +++ b/contrib/pg_tde/src/include/encryption/enc_tde.h @@ -5,7 +5,14 @@ #ifndef ENC_TDE_H #define ENC_TDE_H -#include "access/pg_tde_tdemap.h" +#define INTERNAL_KEY_LEN 16 +#define INTERNAL_KEY_IV_LEN 16 + +typedef struct InternalKey +{ + uint8 key[INTERNAL_KEY_LEN]; + uint8 base_iv[INTERNAL_KEY_IV_LEN]; +} InternalKey; extern void pg_tde_generate_internal_key(InternalKey *int_key); extern void pg_tde_stream_crypt(const char *iv_prefix,