standardize on "sha256" as the hash name, like fdroidserver uses
fdroidserver has always written "sha256" to the index.xml file, so client should use the same. The Java hashers will correctly respond to both "sha256" and "SHA-256", and the only place that the hashType is read from the DB and used is in the swap repo index.xml generation, where it should also use "sha256".
This commit is contained in:
parent
20c93c64d8
commit
20a1b4c83d
@ -22,7 +22,6 @@ package org.fdroid.fdroid;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.fdroid.fdroid.data.Apk;
|
||||
import org.fdroid.fdroid.data.App;
|
||||
import org.fdroid.fdroid.data.Repo;
|
||||
@ -129,11 +128,11 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
if (currentApkHashType == null || "md5".equals(currentApkHashType)) {
|
||||
if (curapk.hash == null) {
|
||||
curapk.hash = str;
|
||||
curapk.hashType = "SHA-256";
|
||||
curapk.hashType = "sha256";
|
||||
}
|
||||
} else if ("sha256".equals(currentApkHashType)) {
|
||||
curapk.hash = str;
|
||||
curapk.hashType = "SHA-256";
|
||||
curapk.hashType = "sha256";
|
||||
}
|
||||
break;
|
||||
case ApkTable.Cols.SIGNATURE:
|
||||
|
@ -362,7 +362,7 @@ public final class Utils {
|
||||
String ret = null;
|
||||
try {
|
||||
// keytool -list -v gives you the SHA-256 fingerprint
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
MessageDigest digest = MessageDigest.getInstance("sha256");
|
||||
digest.update(key);
|
||||
byte[] fingerprint = digest.digest();
|
||||
Formatter formatter = new Formatter(new StringBuilder());
|
||||
|
@ -240,7 +240,7 @@ public class InstallManagerService extends Service {
|
||||
* @see <a href="https://developer.android.com/google/play/expansion-files.html">APK Expansion Files</a>
|
||||
*/
|
||||
private void getObb(final String urlString, String obbUrlString,
|
||||
final File obbDestFile, final String sha256) {
|
||||
final File obbDestFile, final String hash) {
|
||||
if (obbDestFile == null || obbDestFile.exists() || TextUtils.isEmpty(obbUrlString)) {
|
||||
return;
|
||||
}
|
||||
@ -267,7 +267,7 @@ public class InstallManagerService extends Service {
|
||||
+ " to " + localApkUri);
|
||||
|
||||
try {
|
||||
if (Hasher.isFileMatchingHash(localFile, sha256, "SHA-256")) {
|
||||
if (Hasher.isFileMatchingHash(localFile, hash, "sha256")) {
|
||||
Utils.debugLog(TAG, "Installing OBB " + localFile + " to " + obbDestFile);
|
||||
FileUtils.forceMkdirParent(obbDestFile);
|
||||
FileUtils.copyFile(localFile, obbDestFile);
|
||||
@ -280,7 +280,7 @@ public class InstallManagerService extends Service {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Utils.debugLog(TAG, localFile + " deleted, did not match hash: " + sha256);
|
||||
Utils.debugLog(TAG, localFile + " deleted, did not match hash: " + hash);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
x
Reference in New Issue
Block a user