aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-08-30 11:11:54 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-08-30 11:11:54 +0200
commit8f4b7686c94c52563c29f100cd25599ac08a7bb2 (patch)
tree8d54f0d0400c2498cee845bf23523ddce3e78250
parent3db70876588ca43687b69a3305a2547270aa0850 (diff)
catch invalid base64 on omemo key decoding
-rw-r--r--src/main/java/eu/siacs/conversations/parser/IqParser.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java
index 44e4bc08..f6446cfd 100644
--- a/src/main/java/eu/siacs/conversations/parser/IqParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java
@@ -149,7 +149,12 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
if(signedPreKeySignature == null) {
return null;
}
- return Base64.decode(signedPreKeySignature.getContent(),Base64.DEFAULT);
+ try {
+ return Base64.decode(signedPreKeySignature.getContent(), Base64.DEFAULT);
+ } catch (IllegalArgumentException e) {
+ Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : Invalid base64 in signedPreKeySignature");
+ return null;
+ }
}
public IdentityKey identityKey(final Element bundle) {
@@ -160,7 +165,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
}
try {
identityKey = new IdentityKey(Base64.decode(identityKeyElement.getContent(), Base64.DEFAULT), 0);
- } catch (InvalidKeyException e) {
+ } catch (InvalidKeyException | IllegalArgumentException e) {
Log.e(Config.LOGTAG,AxolotlService.LOGPREFIX+" : "+"Invalid identityKey in PEP: "+e.getMessage());
}
return identityKey;
@@ -191,7 +196,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived {
try {
ECPublicKey preKeyPublic = Curve.decodePoint(Base64.decode(preKeyPublicElement.getContent(), Base64.DEFAULT), 0);
preKeyRecords.put(preKeyId, preKeyPublic);
- } catch (InvalidKeyException e) {
+ } catch (InvalidKeyException | IllegalArgumentException e) {
Log.e(Config.LOGTAG, AxolotlService.LOGPREFIX+" : "+"Invalid preKeyPublic (ID="+preKeyId+") in PEP: "+ e.getMessage()+", skipping...");
continue;
}