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

Add or modify encryption related codes #13364

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

zhujt20
Copy link

@zhujt20 zhujt20 commented Aug 31, 2024

Add or modify encryption related codes for encryption module realization.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.

Comment on lines 123 to 126
public static void setUp() throws Exception {
TSFileDescriptor.getInstance().getConfig().setEncryptFlag("true");
TSFileDescriptor.getInstance().getConfig().setEncryptType("AES128");
TSFileDescriptor.getInstance().getConfig().setEncryptKey("mkmkmkmkmkmkmkmk");
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not be effective for the testing environment because the servers are started in another process.
Refer to EnvFactory.getEnv().getConfig() to see how to change the config in IT.

Copy link
Contributor

Choose a reason for hiding this comment

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

The loading TsFiles cases should be tested. Either loading a TsFile with consistent encryption, or with unrecognized encryption.

Comment on lines 113 to 135
public static ByteBuffer decryptAndUncompressPageData(
PageHeader pageHeader,
IUnCompressor unCompressor,
ByteBuffer compressedPageData,
IDecryptor decryptor)
throws IOException {
int compressedPageBodyLength = pageHeader.getCompressedSize();
byte[] uncompressedPageData = new byte[pageHeader.getUncompressedSize()];
try {
byte[] decryptedPageData =
decryptor.decrypt(compressedPageData.array(), 0, compressedPageBodyLength);
unCompressor.uncompress(
decryptedPageData, 0, compressedPageBodyLength, uncompressedPageData, 0);
} catch (Exception e) {
throw new IOException(
"Decrypt and Uncompress error! uncompress size: "
+ pageHeader.getUncompressedSize()
+ "compressed size: "
+ pageHeader.getCompressedSize()
+ "page header: "
+ pageHeader
+ e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid coying when not encrypted or compressed like those in TsFile.

Comment on lines 127 to 134
throw new IOException(
"Decrypt and Uncompress error! uncompress size: "
+ pageHeader.getUncompressedSize()
+ "compressed size: "
+ pageHeader.getCompressedSize()
+ "page header: "
+ pageHeader
+ e.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

Include e as the cause.

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.

2 participants