make authentications work with null password

This commit is contained in:
Daniel Gultsch 2023-01-22 16:26:42 +01:00
parent f982885d2e
commit f16603742f
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
3 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package im.conversations.android.xmpp.sasl; package im.conversations.android.xmpp.sasl;
import android.util.Base64; import android.util.Base64;
import com.google.common.base.Strings;
import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.CryptoHelper;
import im.conversations.android.database.model.Account; import im.conversations.android.database.model.Account;
import im.conversations.android.database.model.Credential; import im.conversations.android.database.model.Credential;
@ -54,7 +55,7 @@ public class DigestMd5 extends SaslMechanism {
+ ":" + ":"
+ account.address.getDomain() + account.address.getDomain()
+ ":" + ":"
+ credential.password; + Strings.nullToEmpty(credential.password);
final MessageDigest md = MessageDigest.getInstance("MD5"); final MessageDigest md = MessageDigest.getInstance("MD5");
final byte[] y = md.digest(x.getBytes(Charset.defaultCharset())); final byte[] y = md.digest(x.getBytes(Charset.defaultCharset()));
final String cNonce = CryptoHelper.random(100); final String cNonce = CryptoHelper.random(100);

View file

@ -1,6 +1,7 @@
package im.conversations.android.xmpp.sasl; package im.conversations.android.xmpp.sasl;
import android.util.Base64; import android.util.Base64;
import com.google.common.base.Strings;
import im.conversations.android.database.model.Account; import im.conversations.android.database.model.Account;
import im.conversations.android.database.model.Credential; import im.conversations.android.database.model.Credential;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -31,6 +32,7 @@ public class Plain extends SaslMechanism {
@Override @Override
public String getClientFirstMessage(final SSLSocket sslSocket) { public String getClientFirstMessage(final SSLSocket sslSocket) {
return getMessage(account.address.getEscapedLocal(), credential.password); return getMessage(
account.address.getEscapedLocal(), Strings.nullToEmpty(credential.password));
} }
} }

View file

@ -3,6 +3,7 @@ package im.conversations.android.xmpp.sasl;
import android.util.Base64; import android.util.Base64;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.hash.HashFunction; import com.google.common.hash.HashFunction;
@ -215,7 +216,7 @@ abstract class ScramMechanism extends SaslMechanism {
try { try {
keys = keys =
getKeyPair( getKeyPair(
CryptoHelper.saslPrep(credential.password), CryptoHelper.saslPrep(Strings.nullToEmpty(credential.password)),
salt, salt,
iterationCount); iterationCount);
} catch (ExecutionException e) { } catch (ExecutionException e) {