use aesgcm:// uri scheme for omemo encrypted http upload

This commit is contained in:
Daniel Gultsch 2017-04-05 18:46:56 +02:00
parent f75eb6bc43
commit 401329caaa
2 changed files with 14 additions and 1 deletions

View File

@ -191,7 +191,7 @@ public class HttpUploadConnection implements Transferable {
if (code == 200 || code == 201) { if (code == 200 || code == 201) {
Log.d(Config.LOGTAG, "finished uploading file"); Log.d(Config.LOGTAG, "finished uploading file");
if (key != null) { if (key != null) {
mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key)); mGetUrl = CryptoHelper.toAesGcmUrl(new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key)));
} }
mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl); mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl);
mXmppConnectionService.getFileBackend().updateMediaScanner(file); mXmppConnectionService.getFileBackend().updateMediaScanner(file);

View File

@ -8,6 +8,8 @@ import org.bouncycastle.asn1.x500.style.BCStyle;
import org.bouncycastle.asn1.x500.style.IETFUtils; import org.bouncycastle.asn1.x500.style.IETFUtils;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateEncodingException;
@ -230,4 +232,15 @@ public final class CryptoHelper {
return R.string.encryption_choice_pgp; return R.string.encryption_choice_pgp;
} }
} }
public static URL toAesGcmUrl(URL url) {
if (!url.getProtocol().equalsIgnoreCase("https")) {
return url;
}
try {
return new URL("aesgcm"+url.toString().substring(url.getProtocol().length()));
} catch (MalformedURLException e) {
return url;
}
}
} }