From 1e6fc5a9cbb43706cb6f1daffd912c4b78f6199b Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 29 Mar 2017 12:35:44 +0100 Subject: [PATCH] Crypto: rename Cipher to CryptoManager. --- .../syncadapter/journalmanager/BaseManager.java | 12 ++++++------ .../etesync/syncadapter/journalmanager/Crypto.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/journalmanager/BaseManager.java b/app/src/main/java/com/etesync/syncadapter/journalmanager/BaseManager.java index 1b6acfc2..8e7179d3 100644 --- a/app/src/main/java/com/etesync/syncadapter/journalmanager/BaseManager.java +++ b/app/src/main/java/com/etesync/syncadapter/journalmanager/BaseManager.java @@ -75,14 +75,14 @@ abstract class BaseManager { public String getContent(String keyBase64) { // FIXME: probably cache encryption object - Crypto.Cipher cipher = new Crypto.Cipher(keyBase64, null); - return new String(cipher.decrypt(content), Charsets.UTF_8); + Crypto.CryptoManager cryptoManager = new Crypto.CryptoManager(keyBase64, null); + return new String(cryptoManager.decrypt(content), Charsets.UTF_8); } void setContent(String keyBase64, String content) { // FIXME: probably cache encryption object - Crypto.Cipher cipher = new Crypto.Cipher(keyBase64, null); - this.content = cipher.encrypt(content.getBytes(Charsets.UTF_8)); + Crypto.CryptoManager cryptoManager = new Crypto.CryptoManager(keyBase64, null); + this.content = cryptoManager.encrypt(content.getBytes(Charsets.UTF_8)); } byte[] calculateHmac(String keyBase64, String uuid) { @@ -100,8 +100,8 @@ abstract class BaseManager { } // FIXME: probably cache encryption object - Crypto.Cipher cipher = new Crypto.Cipher(keyBase64, null); - return cipher.hmac(hashContent.toByteArray()); + Crypto.CryptoManager cryptoManager = new Crypto.CryptoManager(keyBase64, null); + return cryptoManager.hmac(hashContent.toByteArray()); } protected Base() { diff --git a/app/src/main/java/com/etesync/syncadapter/journalmanager/Crypto.java b/app/src/main/java/com/etesync/syncadapter/journalmanager/Crypto.java index 0a152d3e..fc3bf0b6 100644 --- a/app/src/main/java/com/etesync/syncadapter/journalmanager/Crypto.java +++ b/app/src/main/java/com/etesync/syncadapter/journalmanager/Crypto.java @@ -31,12 +31,12 @@ public class Crypto { return Base64.encodeToString(SCrypt.generate(password.getBytes(Charsets.UTF_8), salt.getBytes(Charsets.UTF_8), 16384, 8, 1, keySize), Base64.NO_WRAP); } - static class Cipher { + static class CryptoManager { private SecureRandom _random = null; private final byte[] cipherKey; private final byte[] hmacKey; - Cipher(String keyBase64, String salt) { + CryptoManager(String keyBase64, String salt) { byte[] derivedKey; // FIXME use salt = hmac256(salt.getBytes(Charsets.UTF_8), Base64.decode(keyBase64, Base64.NO_WRAP)); derivedKey = Base64.decode(keyBase64, Base64.NO_WRAP); cipherKey = hmac256("aes".getBytes(Charsets.UTF_8), derivedKey);