Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3331736
D13757.id45289.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13757.id45289.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 9:09 PM (1 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2558550
Default Alt Text
D13757.id45289.diff (3 KB)
Attached To
Mode
D13757: [lib] Restart session when any Olm error is thrown
Attached
Detach File
Event Timeline
Log In to Comment