diff --git a/AesCbcPadding.java b/AesCbcWithIntegrity.java similarity index 99% rename from AesCbcPadding.java rename to AesCbcWithIntegrity.java index 8554a9d..79f3773 100644 --- a/AesCbcPadding.java +++ b/AesCbcWithIntegrity.java @@ -22,7 +22,7 @@ * Created by Isaac Potoczny-Jones on 11/12/14. */ -package com.tozny.crypto.basicaescbc; +package com.tozny.crypto.android; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; @@ -58,7 +58,6 @@ import android.util.Base64; import android.util.Log; -import static java.util.Arrays.copyOf; import static java.util.Arrays.copyOfRange; /** @@ -66,7 +65,7 @@ * and decryption using 128-bit AES, CBC, PKCS5 padding, and a random 16-byte IV * with SHA1PRNG. Integrity with HmacSHA256. */ -public class AesCbcPadding { +public class AesCbcWithIntegrity { private static final String CIPHER_TRANSFORMATION = "AES/CBC/PKCS5Padding"; private static final String CIPHER = "AES"; private static final String RANDOM_ALGORITHM = "SHA1PRNG"; diff --git a/AesCbcPaddingTests.java b/AesCbcWithIntegrityTests.java similarity index 100% rename from AesCbcPaddingTests.java rename to AesCbcWithIntegrityTests.java diff --git a/MyActivity.java b/MyActivity.java index f071ce3..85fbf97 100644 --- a/MyActivity.java +++ b/MyActivity.java @@ -1,4 +1,4 @@ -package com.tozny.crypto.basicaescbc; +package com.tozny.crypto.android; import android.app.Activity; import android.os.Bundle; @@ -9,14 +9,14 @@ import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.generateKeyFromPassword; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.generateSalt; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.keyString; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.decryptString; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.encrypt; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.generateKey; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.keys; -import static com.tozny.crypto.basicaescbc.AesCbcPadding.saltString; +import static com.tozny.crypto.android.AesCbcWithIntegrity.generateKeyFromPassword; +import static com.tozny.crypto.android.AesCbcWithIntegrity.generateSalt; +import static com.tozny.crypto.android.AesCbcWithIntegrity.keyString; +import static com.tozny.crypto.android.AesCbcWithIntegrity.decryptString; +import static com.tozny.crypto.android.AesCbcWithIntegrity.encrypt; +import static com.tozny.crypto.android.AesCbcWithIntegrity.generateKey; +import static com.tozny.crypto.android.AesCbcWithIntegrity.keys; +import static com.tozny.crypto.android.AesCbcWithIntegrity.saltString; public class MyActivity extends Activity { @@ -29,7 +29,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_my); try { - AesCbcPadding.SecretKeys key; + AesCbcWithIntegrity.SecretKeys key; if (PASSWORD_BASED_KEY) {//example for password based keys String salt = saltString(generateSalt()); //If you generated the key from a password, you can store the salt and not the key. @@ -53,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) { // Read from storage & decrypt key = keys(keyStr); // alternately, regenerate the key from password/salt. - AesCbcPadding.CipherTextIvMac civ = encrypt(textToEncrypt, key); + AesCbcWithIntegrity.CipherTextIvMac civ = encrypt(textToEncrypt, key); Log.i("Tozny", "Encrypted: " + civ.toString()); String decryptedText = decryptString(civ, key);