Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3287047
D9420.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
D9420.diff
View Options
diff --git a/keyserver/src/user/login.js b/keyserver/src/user/login.js
--- a/keyserver/src/user/login.js
+++ b/keyserver/src/user/login.js
@@ -6,7 +6,6 @@
import { getOneTimeKeyValuesFromBlob } from 'lib/shared/crypto-utils.js';
import { getCommConfig } from 'lib/utils/comm-config.js';
import { ServerError } from 'lib/utils/errors.js';
-import { values } from 'lib/utils/objects.js';
import {
saveIdentityInfo,
@@ -15,7 +14,10 @@
} from './identity.js';
import { getMessageForException } from '../responders/utils.js';
import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';
-import { validateAccountPrekey } from '../utils/olm-utils.js';
+import {
+ getAccountPrekeysSet,
+ validateAccountPrekey,
+} from '../utils/olm-utils.js';
type UserCredentials = { +username: string, +password: string };
@@ -30,9 +32,7 @@
const identityKeys = account.identity_keys();
validateAccountPrekey(account);
- const prekeyMap = JSON.parse(account.prekey()).curve25519;
- const [prekey] = values(prekeyMap);
- const prekeySignature = account.prekey_signature();
+ const { prekey, prekeySignature } = getAccountPrekeysSet(account);
if (!prekeySignature || !prekey) {
throw new ServerError('invalid_prekey');
diff --git a/keyserver/src/utils/olm-utils.js b/keyserver/src/utils/olm-utils.js
--- a/keyserver/src/utils/olm-utils.js
+++ b/keyserver/src/utils/olm-utils.js
@@ -12,6 +12,7 @@
import { getOneTimeKeyValuesFromBlob } from 'lib/shared/crypto-utils.js';
import { olmEncryptedMessageTypes } from 'lib/types/crypto-types.js';
import { ServerError } from 'lib/utils/errors.js';
+import { values } from 'lib/utils/objects.js';
import {
fetchCallUpdateOlmAccount,
@@ -186,6 +187,16 @@
return JSON.parse(accountInfo.account.identity_keys()).ed25519;
}
+function getAccountPrekeysSet(account: OlmAccount): {
+ +prekey: string,
+ +prekeySignature: ?string,
+} {
+ const prekeyMap = JSON.parse(account.prekey()).curve25519;
+ const [prekey] = values(prekeyMap);
+ const prekeySignature = account.prekey_signature();
+ return { prekey, prekeySignature };
+}
+
export {
createPickledOlmAccount,
createPickledOlmSession,
@@ -195,4 +206,5 @@
validateAccountPrekey,
uploadNewOneTimeKeys,
getContentSigningKey,
+ getAccountPrekeysSet,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 1:40 PM (18 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2526041
Default Alt Text
D9420.diff (2 KB)
Attached To
Mode
D9420: [keyserver] implement function to get account prekey and prekey signature
Attached
Detach File
Event Timeline
Log In to Comment