Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3368897
D11112.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11112.diff
View Options
diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js
--- a/lib/types/crypto-types.js
+++ b/lib/types/crypto-types.js
@@ -126,4 +126,8 @@
+initializeCryptoAccount: () => Promise<void>,
+encrypt: (content: string, deviceID: string) => Promise<string>,
+decrypt: (encryptedContent: string, deviceID: string) => Promise<string>,
+ +contentInboundSessionCreator: (
+ contentIdentityKeys: OLMIdentityKeys,
+ initialEncryptedContent: string,
+ ) => Promise<string>,
};
diff --git a/native/crypto/olm-api.js b/native/crypto/olm-api.js
--- a/native/crypto/olm-api.js
+++ b/native/crypto/olm-api.js
@@ -1,6 +1,6 @@
// @flow
-import type { OlmAPI } from 'lib/types/crypto-types';
+import type { OlmAPI, OLMIdentityKeys } from 'lib/types/crypto-types';
import { commCoreModule } from '../native-modules.js';
@@ -10,6 +10,20 @@
},
encrypt: commCoreModule.encrypt,
decrypt: commCoreModule.decrypt,
+ async contentInboundSessionCreator(
+ contentIdentityKeys: OLMIdentityKeys,
+ initialEncryptedContent: string,
+ ): Promise<string> {
+ const identityKeys = JSON.stringify({
+ curve25519: contentIdentityKeys.curve25519,
+ ed25519: contentIdentityKeys.ed25519,
+ });
+ return commCoreModule.initializeContentInboundSession(
+ identityKeys,
+ initialEncryptedContent,
+ contentIdentityKeys.ed25519,
+ );
+ },
};
export { olmAPI };
diff --git a/web/crypto/olm-api.js b/web/crypto/olm-api.js
--- a/web/crypto/olm-api.js
+++ b/web/crypto/olm-api.js
@@ -6,11 +6,12 @@
import {
type OlmAPI,
olmEncryptedMessageTypes,
+ type OLMIdentityKeys,
} from 'lib/types/crypto-types.js';
// methods below are just mocks to SQLite API
// implement proper methods tracked in ENG-6462
-// eslint-disable-next-line no-unused-vars
+
function getOlmAccount(): Account {
return new olm.Account();
}
@@ -42,6 +43,27 @@
storeOlmSession(session);
return result;
},
+ async contentInboundSessionCreator(
+ contentIdentityKeys: OLMIdentityKeys,
+ initialEncryptedContent: string,
+ ): Promise<string> {
+ const account = getOlmAccount();
+ const session = new olm.Session();
+ session.create_inbound_from(
+ account,
+ contentIdentityKeys.curve25519,
+ initialEncryptedContent,
+ );
+
+ account.remove_one_time_keys(session);
+ const initialEncryptedMessage = session.decrypt(
+ olmEncryptedMessageTypes.PREKEY,
+ initialEncryptedContent,
+ );
+ storeOlmAccount(account);
+ storeOlmSession(session);
+ return initialEncryptedMessage;
+ },
};
export { olmAPI };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 9:01 PM (21 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2586277
Default Alt Text
D11112.diff (2 KB)
Attached To
Mode
D11112: [crypto] implement creating `olm` inbound session
Attached
Detach File
Event Timeline
Log In to Comment