mirror of
https://github.com/etesync/android
synced 2025-01-25 15:10:55 +00:00
Encryption helpers: deal with FIXMEs.
This commit is contained in:
parent
88322f341a
commit
81b927e7fb
@ -22,6 +22,8 @@ import java.security.MessageDigest;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import at.bitfire.davdroid.App;
|
||||||
|
|
||||||
public class Helpers {
|
public class Helpers {
|
||||||
// FIXME: This should be somewhere else
|
// FIXME: This should be somewhere else
|
||||||
public static String deriveKey(String salt, String password) {
|
public static String deriveKey(String salt, String password) {
|
||||||
@ -79,8 +81,9 @@ public class Helpers {
|
|||||||
try {
|
try {
|
||||||
len += cipher.doFinal(buf, len);
|
len += cipher.doFinal(buf, len);
|
||||||
} catch (InvalidCipherTextException e) {
|
} catch (InvalidCipherTextException e) {
|
||||||
// FIXME: Fail!
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
App.log.severe("Invalid ciphertext: " + Base64.encodeToString(_data, Base64.NO_WRAP));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove padding
|
// remove padding
|
||||||
@ -102,20 +105,19 @@ public class Helpers {
|
|||||||
try {
|
try {
|
||||||
cipher.doFinal(buf, len);
|
cipher.doFinal(buf, len);
|
||||||
} catch (InvalidCipherTextException e) {
|
} catch (InvalidCipherTextException e) {
|
||||||
// FIXME: Fail!
|
App.log.severe("Invalid ciphertext: " + Base64.encodeToString(data, Base64.NO_WRAP));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Replace with bouncy-castle once available. */
|
|
||||||
static String sha256(String base) {
|
static String sha256(String base) {
|
||||||
return sha256(base.getBytes(Charsets.UTF_8));
|
return sha256(base.getBytes(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Replace with bouncy-castle once available. */
|
|
||||||
static String sha256(byte[] base) {
|
static String sha256(byte[] base) {
|
||||||
try {
|
try {
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
|
Loading…
Reference in New Issue
Block a user