import java.io.*;
import java.net.*;
import java.util.Arrays;
+import javax.crypto.*;
class CloudComm {
String baseurl;
- CloudComm(String _baseurl) {
+ Cipher encryptcipher;
+ Cipher decryptcipher;
+
+ CloudComm(String _baseurl, Cipher _encrypt, Cipher _decrypt) {
this.baseurl=_baseurl;
+ this.encryptcipher = _encrypt;
+ this.decryptcipher = _decrypt;
}
private URL buildRequest(boolean isput, long sequencenumber, long maxentries) throws IOException {
int numslots;
HashMap table=new HashMap();
CloudComm cloud;
- private Cipher encryptCipher;
- private Cipher decryptCipher;
private Mac hmac;
public Table(String baseurl, String password) {
- cloud=new CloudComm(baseurl);
- initCiphers(password);
+ initCloud(baseurl, password);
}
-
- private void initCiphers(String password) {
+
+ private void initCloud(String baseurl, String password) {
try {
SecretKeySpec secret=getKey(password);
- encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ Cipher encryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
encryptCipher.init(Cipher.ENCRYPT_MODE, secret);
- decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ Cipher decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
decryptCipher.init(Cipher.DECRYPT_MODE, secret);
hmac = Mac.getInstance("HmacSHA256");
hmac.init(secret);
+ cloud=new CloudComm(baseurl, encryptCipher, decryptCipher);
} catch (Exception e) {
throw new Error("Failed To Initialize Ciphers");
}