1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-27 22:14:50 +02:00

Clean up CachingBcPublicKeyDataDecryptorFactory

This commit is contained in:
Paul Schaub 2022-11-23 20:07:03 +01:00
parent b495e602e5
commit be7349f0b5

View file

@ -59,16 +59,20 @@ public class CachingBcPublicKeyDataDecryptorFactory
} }
private byte[] lookupSessionKeyData(byte[][] secKeyData) { private byte[] lookupSessionKeyData(byte[][] secKeyData) {
byte[] sk = secKeyData[0]; String key = toKey(secKeyData);
String key = Base64.toBase64String(sk);
byte[] sessionKey = cachedSessionKeys.get(key); byte[] sessionKey = cachedSessionKeys.get(key);
return copy(sessionKey); return copy(sessionKey);
} }
private void cacheSessionKeyData(byte[][] secKeyData, byte[] sessionKey) { private void cacheSessionKeyData(byte[][] secKeyData, byte[] sessionKey) {
String key = toKey(secKeyData);
cachedSessionKeys.put(key, copy(sessionKey));
}
private static String toKey(byte[][] secKeyData) {
byte[] sk = secKeyData[0]; byte[] sk = secKeyData[0];
String key = Base64.toBase64String(sk); String key = Base64.toBase64String(sk);
cachedSessionKeys.put(key, copy(sessionKey)); return key;
} }
private static byte[] copy(byte[] bytes) { private static byte[] copy(byte[] bytes) {