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

Changed logging logic in AE and improved performance #773

Merged
merged 4 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ byte[] encryptData(byte[] plainText) throws SQLServerException {
* @throws SQLServerException
*/
protected byte[] encryptData(byte[] plainText, boolean hasAuthenticationTag) throws SQLServerException {
aeLogger.entering(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(),
Thread.currentThread().getStackTrace()[1].getMethodName(), "Encrypting data.");
aeLogger.entering(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(), "encryptData", "Encrypting data.");
// we will generate this initialization vector based whether
// this encryption type is deterministic
assert (plainText != null);
Expand Down Expand Up @@ -181,16 +180,14 @@ protected byte[] encryptData(byte[] plainText, boolean hasAuthenticationTag) thr
throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
}

aeLogger.exiting(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(),
Thread.currentThread().getStackTrace()[1].getMethodName(), "Data encrypted.");
aeLogger.exiting(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(), "encryptData", "Data encrypted.");
return outBuffer;

}

@Override
byte[] decryptData(byte[] cipherText) throws SQLServerException {
return decryptData(cipherText, true);

}

/**
Expand Down Expand Up @@ -289,8 +286,7 @@ private byte[] decryptData(byte[] cipherText, boolean hasAuthenticationTag) thro
* @throws SQLServerException
*/
private byte[] decryptData(byte[] iv, byte[] cipherText, int offset, int count) throws SQLServerException {
aeLogger.entering(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(),
Thread.currentThread().getStackTrace()[1].getMethodName(), "Decrypting data.");
aeLogger.entering(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(), "decryptData", "Decrypting data.");
assert (cipherText != null);
assert (iv != null);
byte[] plainText = null;
Expand All @@ -299,7 +295,6 @@ private byte[] decryptData(byte[] iv, byte[] cipherText, int offset, int count)
IvParameterSpec ivector = new IvParameterSpec(iv);
Cipher decryptCipher;
try {
// AES encryption CBC mode and PKCS5 padding
decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
decryptCipher.init(Cipher.DECRYPT_MODE, skeySpec, ivector);
plainText = decryptCipher.doFinal(cipherText, offset, count);
Expand All @@ -311,8 +306,7 @@ private byte[] decryptData(byte[] iv, byte[] cipherText, int offset, int count)
throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
}

aeLogger.exiting(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(),
Thread.currentThread().getStackTrace()[1].getMethodName(), "Data decrypted.");
aeLogger.exiting(SQLServerAeadAes256CbcHmac256Algorithm.class.getName(), "decryptData", "Data decrypted.");
return plainText;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private CertificateDetails getCertificateDetailsByAlias(KeyStore keyStore, Strin
public byte[] encryptColumnEncryptionKey(String masterKeyPath, String encryptionAlgorithm,
byte[] plainTextColumnEncryptionKey) throws SQLServerException {
javaKeyStoreLogger.entering(SQLServerColumnEncryptionJavaKeyStoreProvider.class.getName(),
Thread.currentThread().getStackTrace()[1].getMethodName(), "Encrypting Column Encryption Key.");
"encryptColumnEncryptionKey", "Encrypting Column Encryption Key.");

byte[] version = KeyStoreProviderCommon.version;
KeyStoreProviderCommon.validateNonEmptyMasterKeyPath(masterKeyPath);
Expand Down Expand Up @@ -257,7 +257,7 @@ public byte[] encryptColumnEncryptionKey(String masterKeyPath, String encryption
System.arraycopy(signedHash, 0, encryptedColumnEncryptionKey, currentIndex, signedHash.length);

javaKeyStoreLogger.exiting(SQLServerColumnEncryptionJavaKeyStoreProvider.class.getName(),
Thread.currentThread().getStackTrace()[1].getMethodName(),
"encryptColumnEncryptionKey",
"Finished encrypting Column Encryption Key.");
return encryptedColumnEncryptionKey;

Expand Down