Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt relation's Internal Key in XLog #97

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

dAdAbird
Copy link
Member

XLog record with its Internal Key for replication purposes. This commit makes this Key encrypted with the master key. Therefore we have to add also a master key name to XLog. That also means that standbys should have access to the very same master key as the primary.

Fix #56

Copy link
Collaborator

@dutow dutow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I only added a few formatting related comments

}
if(master_key_info == NULL)
{
ereport(ERROR,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation - it's already there in the original, but now that we move it, it's a good time to fix it

@@ -394,6 +398,9 @@ pg_tde_xlog_create_fork(XLogReaderState *record)
char *rec = XLogRecGetData(record);
RelFileLocator rlocator;
InternalKey int_key = {0};
InternalKey int_key_enc = {0};
uint8 mkey_len;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like another indentation issue?

@@ -347,6 +330,27 @@ pg_tde_get_key_file_path(const RelFileLocator *newrlocator)
return key_file_path;
}

void
pg_tde_decrypt_internal_key(const InternalKey *in, InternalKey *out, const char *MasterKeyName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MasterKeyName also seems inconsistent with the other variable/argument names

@dAdAbird
Copy link
Member Author

I reckoned it make sense to run pgindent on the file

@dAdAbird dAdAbird requested a review from dutow January 11, 2024 10:32
@dutow
Copy link
Collaborator

dutow commented Jan 11, 2024

@dAdAbird pgIndent is a good idea, but could we do it in a separate PR instead? Maybe even on the entire code?

With this now, if you squash and merge, we'll end up with lots of formatting changes and some logic changes in a single commit.

XLog record with its Internal Key for replication purposes. This commit
makes this Key encrypted with the master key. Therefore we have to add
also a master key name to XLog. That also means that standbys should
have access to the very same master key as the primary.

Fix percona#56
@dAdAbird
Copy link
Member Author

@dutow I rearranged commits so there are two now - changes and formatting - so we can merge this PR instead of squashing

Copy link
Contributor

@hqakhtar hqakhtar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hqakhtar hqakhtar merged commit fbd79d0 into percona:main Jan 24, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XLog: tde internal keys should be encrypted
3 participants