Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c7a637f2 authored by Vincent Breitmoser's avatar Vincent Breitmoser
Browse files

don't sign in opportunistic mode if sign-only isn't supported

parent 98286fd7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ public class ComposeCryptoStatus {

    private CryptoProviderState cryptoProviderState;
    private CryptoMode cryptoMode;
    private boolean cryptoSupportSignOnly;
    private boolean allKeysAvailable;
    private boolean allKeysVerified;
    private boolean hasRecipients;
@@ -99,6 +100,10 @@ public class ComposeCryptoStatus {
        return cryptoMode == CryptoMode.OPPORTUNISTIC;
    }

    public boolean isOpportunisticSignOnly() {
        return cryptoSupportSignOnly;
    }

    public boolean isSigningEnabled() {
        return cryptoMode != CryptoMode.DISABLE && signingKeyId != null;
    }
@@ -123,6 +128,7 @@ public class ComposeCryptoStatus {
        private Long selfEncryptKeyId;
        private List<Recipient> recipients;
        private Boolean enablePgpInline;
        private Boolean cryptoSupportSignOnly;

        public ComposeCryptoStatusBuilder setCryptoProviderState(CryptoProviderState cryptoProviderState) {
            this.cryptoProviderState = cryptoProviderState;
@@ -134,6 +140,11 @@ public class ComposeCryptoStatus {
            return this;
        }

        public ComposeCryptoStatusBuilder setCryptoSupportSignOnly(boolean cryptoSupportSignOnly) {
            this.cryptoSupportSignOnly = cryptoSupportSignOnly;
            return this;
        }

        public ComposeCryptoStatusBuilder setSigningKeyId(long signingKeyId) {
            this.signingKeyId = signingKeyId;
            return this;
@@ -167,6 +178,9 @@ public class ComposeCryptoStatus {
            if (enablePgpInline == null) {
                throw new AssertionError("enablePgpInline must be set!");
            }
            if (cryptoSupportSignOnly == null) {
                throw new AssertionError("supportSignOnly must be set!");
            }

            ArrayList<String> recipientAddresses = new ArrayList<>();
            boolean allKeysAvailable = true;
@@ -187,6 +201,7 @@ public class ComposeCryptoStatus {
            ComposeCryptoStatus result = new ComposeCryptoStatus();
            result.cryptoProviderState = cryptoProviderState;
            result.cryptoMode = cryptoMode;
            result.cryptoSupportSignOnly = cryptoSupportSignOnly;
            result.recipientAddresses = recipientAddresses.toArray(new String[0]);
            result.allKeysAvailable = allKeysAvailable;
            result.allKeysVerified = allKeysVerified;
+1 −0
Original line number Diff line number Diff line
@@ -354,6 +354,7 @@ public class RecipientPresenter implements PermissionPingCallback {
            ComposeCryptoStatusBuilder builder = new ComposeCryptoStatusBuilder()
                    .setCryptoProviderState(cryptoProviderState)
                    .setCryptoMode(currentCryptoMode)
                    .setCryptoSupportSignOnly(account.getCryptoSupportSignOnly())
                    .setEnablePgpInline(cryptoEnablePgpInline)
                    .setRecipients(getAllRecipients());

+2 −1
Original line number Diff line number Diff line
@@ -128,7 +128,8 @@ public class PgpMessageBuilder extends MessageBuilder {
                return;
            }

            if (opportunisticSkipEncryption && !opportunisticSecondPass) {
            boolean shouldSignOnly = cryptoStatus.isOpportunisticSignOnly();
            if (opportunisticSkipEncryption && shouldSignOnly && !opportunisticSecondPass) {
                opportunisticSecondPass = true;
                startOrContinueBuildMessage(null);
                return;
+2 −1
Original line number Diff line number Diff line
@@ -412,7 +412,8 @@ public class PgpMessageBuilderTest {
                .setSigningKeyId(TEST_SIGN_KEY_ID)
                .setSelfEncryptId(TEST_SELF_ENCRYPT_KEY_ID)
                .setRecipients(new ArrayList<Recipient>())
                .setCryptoProviderState(CryptoProviderState.OK);
                .setCryptoProviderState(CryptoProviderState.OK)
                .setCryptoSupportSignOnly(true);
    }

    private static PgpMessageBuilder createDefaultPgpMessageBuilder(OpenPgpApi openPgpApi) {