Page MenuHomePhabricator

D13757.id45289.diff
No OneTemporary

D13757.id45289.diff

diff --git a/lib/tunnelbroker/use-peer-to-peer-message-handler.js b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
--- a/lib/tunnelbroker/use-peer-to-peer-message-handler.js
+++ b/lib/tunnelbroker/use-peer-to-peer-message-handler.js
@@ -41,7 +41,7 @@
import { getMessageForException } from '../utils/errors.js';
import {
hasHigherDeviceID,
- OLM_SESSION_ERROR_PREFIX,
+ OLM_ERROR_FLAG,
olmSessionErrors,
} from '../utils/olm-utils.js';
import { getClientMessageIDFromTunnelbrokerMessageID } from '../utils/peer-to-peer-communication-utils.js';
@@ -304,10 +304,7 @@
`${message.senderInfo.deviceID}: ${e.message}`,
);
- if (
- !e.message?.includes(OLM_SESSION_ERROR_PREFIX) &&
- !e.message?.includes(olmSessionErrors.sessionDoesNotExist)
- ) {
+ if (!e.message?.includes(OLM_ERROR_FLAG)) {
throw e;
}
diff --git a/lib/utils/olm-utils.js b/lib/utils/olm-utils.js
--- a/lib/utils/olm-utils.js
+++ b/lib/utils/olm-utils.js
@@ -104,6 +104,7 @@
}
export const OLM_SESSION_ERROR_PREFIX = 'OLM_';
+export const OLM_ERROR_FLAG = 'OLM_ERROR';
const olmSessionErrors = Object.freeze({
// Two clients send the session request to each other at the same time,
// we choose which session to keep based on `deviceID`.
diff --git a/native/cpp/CommonCpp/CryptoTools/Session.cpp b/native/cpp/CommonCpp/CryptoTools/Session.cpp
--- a/native/cpp/CommonCpp/CryptoTools/Session.cpp
+++ b/native/cpp/CommonCpp/CryptoTools/Session.cpp
@@ -174,8 +174,8 @@
decryptedMessage.size());
if (decryptedSize == -1) {
throw std::runtime_error{
- "error decrypt => " + std::string{::olm_session_last_error(session)} +
- ". Hash: " +
+ "error decrypt => OLM_ERROR " +
+ std::string{::olm_session_last_error(session)} + ". Hash: " +
std::string{messageHashBuffer.begin(), messageHashBuffer.end()}};
}
return std::string{(char *)decryptedMessage.data(), decryptedSize};
diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -31,6 +31,7 @@
shouldForgetPrekey,
shouldRotatePrekey,
olmSessionErrors,
+ OLM_ERROR_FLAG,
} from 'lib/utils/olm-utils.js';
import { getIdentityClient } from './identity-client.js';
@@ -611,10 +612,15 @@
throw new Error(olmSessionErrors.invalidSessionVersion);
}
- const result = olmSession.session.decrypt(
- encryptedData.messageType,
- encryptedData.message,
- );
+ let result;
+ try {
+ result = olmSession.session.decrypt(
+ encryptedData.messageType,
+ encryptedData.message,
+ );
+ } catch (e) {
+ throw new Error(`error decrypt => ${OLM_ERROR_FLAG} ` + e.message);
+ }
await persistCryptoStore();
@@ -642,10 +648,15 @@
throw new Error(olmSessionErrors.invalidSessionVersion);
}
- const result = olmSession.session.decrypt(
- encryptedData.messageType,
- encryptedData.message,
- );
+ let result;
+ try {
+ result = olmSession.session.decrypt(
+ encryptedData.messageType,
+ encryptedData.message,
+ );
+ } catch (e) {
+ throw new Error(`error decrypt => ${OLM_ERROR_FLAG} ` + e.message);
+ }
const sqliteQueryExecutor = getSQLiteQueryExecutor();
const dbModule = getDBModule();
@@ -703,10 +714,15 @@
);
contentAccount.remove_one_time_keys(session);
- const initialEncryptedMessage = session.decrypt(
- initialEncryptedData.messageType,
- initialEncryptedData.message,
- );
+ let initialEncryptedMessage;
+ try {
+ initialEncryptedMessage = session.decrypt(
+ initialEncryptedData.messageType,
+ initialEncryptedData.message,
+ );
+ } catch (e) {
+ throw new Error(`error decrypt => ${OLM_ERROR_FLAG} ` + e.message);
+ }
contentSessions[contentIdentityKeys.ed25519] = {
session,

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 22, 7:41 AM (8 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2340685
Default Alt Text
D13757.id45289.diff (3 KB)

Event Timeline