From f16603742f8c0477f2be38f2c66d19ec6c7c5b7d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 22 Jan 2023 16:26:42 +0100 Subject: [PATCH] make authentications work with null password --- .../java/im/conversations/android/xmpp/sasl/DigestMd5.java | 3 ++- src/main/java/im/conversations/android/xmpp/sasl/Plain.java | 4 +++- .../im/conversations/android/xmpp/sasl/ScramMechanism.java | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/im/conversations/android/xmpp/sasl/DigestMd5.java b/src/main/java/im/conversations/android/xmpp/sasl/DigestMd5.java index d1e2b914b..dc4135d1d 100644 --- a/src/main/java/im/conversations/android/xmpp/sasl/DigestMd5.java +++ b/src/main/java/im/conversations/android/xmpp/sasl/DigestMd5.java @@ -1,6 +1,7 @@ package im.conversations.android.xmpp.sasl; import android.util.Base64; +import com.google.common.base.Strings; import eu.siacs.conversations.utils.CryptoHelper; import im.conversations.android.database.model.Account; import im.conversations.android.database.model.Credential; @@ -54,7 +55,7 @@ public class DigestMd5 extends SaslMechanism { + ":" + account.address.getDomain() + ":" - + credential.password; + + Strings.nullToEmpty(credential.password); final MessageDigest md = MessageDigest.getInstance("MD5"); final byte[] y = md.digest(x.getBytes(Charset.defaultCharset())); final String cNonce = CryptoHelper.random(100); diff --git a/src/main/java/im/conversations/android/xmpp/sasl/Plain.java b/src/main/java/im/conversations/android/xmpp/sasl/Plain.java index d41c07629..3da877e1e 100644 --- a/src/main/java/im/conversations/android/xmpp/sasl/Plain.java +++ b/src/main/java/im/conversations/android/xmpp/sasl/Plain.java @@ -1,6 +1,7 @@ package im.conversations.android.xmpp.sasl; import android.util.Base64; +import com.google.common.base.Strings; import im.conversations.android.database.model.Account; import im.conversations.android.database.model.Credential; import java.nio.charset.Charset; @@ -31,6 +32,7 @@ public class Plain extends SaslMechanism { @Override public String getClientFirstMessage(final SSLSocket sslSocket) { - return getMessage(account.address.getEscapedLocal(), credential.password); + return getMessage( + account.address.getEscapedLocal(), Strings.nullToEmpty(credential.password)); } } diff --git a/src/main/java/im/conversations/android/xmpp/sasl/ScramMechanism.java b/src/main/java/im/conversations/android/xmpp/sasl/ScramMechanism.java index 99f500d75..a1790cc28 100644 --- a/src/main/java/im/conversations/android/xmpp/sasl/ScramMechanism.java +++ b/src/main/java/im/conversations/android/xmpp/sasl/ScramMechanism.java @@ -3,6 +3,7 @@ package im.conversations.android.xmpp.sasl; import android.util.Base64; import com.google.common.base.CaseFormat; import com.google.common.base.Objects; +import com.google.common.base.Strings; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.hash.HashFunction; @@ -215,7 +216,7 @@ abstract class ScramMechanism extends SaslMechanism { try { keys = getKeyPair( - CryptoHelper.saslPrep(credential.password), + CryptoHelper.saslPrep(Strings.nullToEmpty(credential.password)), salt, iterationCount); } catch (ExecutionException e) {