-
Notifications
You must be signed in to change notification settings - Fork 1k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
public static void setUp() throws Exception { | ||
TSFileDescriptor.getInstance().getConfig().setEncryptFlag("true"); | ||
TSFileDescriptor.getInstance().getConfig().setEncryptType("AES128"); | ||
TSFileDescriptor.getInstance().getConfig().setEncryptKey("mkmkmkmkmkmkmkmk"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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()); | ||
} |
There was a problem hiding this comment.
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.
throw new IOException( | ||
"Decrypt and Uncompress error! uncompress size: " | ||
+ pageHeader.getUncompressedSize() | ||
+ "compressed size: " | ||
+ pageHeader.getCompressedSize() | ||
+ "page header: " | ||
+ pageHeader | ||
+ e.getMessage()); |
There was a problem hiding this comment.
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.
Add or modify encryption related codes for encryption module realization.