|
|
|
@ -648,7 +648,7 @@ class EndToEndKeyStore(EndToEndKeyWorkerStore, SQLBaseStore): |
|
|
|
|
"delete_e2e_keys_by_device", delete_e2e_keys_by_device_txn |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
def _set_e2e_cross_signing_key_txn(self, txn, user_id, key_type, key): |
|
|
|
|
def _set_e2e_cross_signing_key_txn(self, txn, user_id, key_type, key, stream_id): |
|
|
|
|
"""Set a user's cross-signing key. |
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
@ -658,6 +658,7 @@ class EndToEndKeyStore(EndToEndKeyWorkerStore, SQLBaseStore): |
|
|
|
|
for a master key, 'self_signing' for a self-signing key, or |
|
|
|
|
'user_signing' for a user-signing key |
|
|
|
|
key (dict): the key data |
|
|
|
|
stream_id (int) |
|
|
|
|
""" |
|
|
|
|
# the 'key' dict will look something like: |
|
|
|
|
# { |
|
|
|
@ -695,23 +696,22 @@ class EndToEndKeyStore(EndToEndKeyWorkerStore, SQLBaseStore): |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# and finally, store the key itself |
|
|
|
|
with self._cross_signing_id_gen.get_next() as stream_id: |
|
|
|
|
self.db_pool.simple_insert_txn( |
|
|
|
|
txn, |
|
|
|
|
"e2e_cross_signing_keys", |
|
|
|
|
values={ |
|
|
|
|
"user_id": user_id, |
|
|
|
|
"keytype": key_type, |
|
|
|
|
"keydata": json_encoder.encode(key), |
|
|
|
|
"stream_id": stream_id, |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
self.db_pool.simple_insert_txn( |
|
|
|
|
txn, |
|
|
|
|
"e2e_cross_signing_keys", |
|
|
|
|
values={ |
|
|
|
|
"user_id": user_id, |
|
|
|
|
"keytype": key_type, |
|
|
|
|
"keydata": json_encoder.encode(key), |
|
|
|
|
"stream_id": stream_id, |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
self._invalidate_cache_and_stream( |
|
|
|
|
txn, self._get_bare_e2e_cross_signing_keys, (user_id,) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
def set_e2e_cross_signing_key(self, user_id, key_type, key): |
|
|
|
|
async def set_e2e_cross_signing_key(self, user_id, key_type, key): |
|
|
|
|
"""Set a user's cross-signing key. |
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
@ -719,13 +719,16 @@ class EndToEndKeyStore(EndToEndKeyWorkerStore, SQLBaseStore): |
|
|
|
|
key_type (str): the type of cross-signing key to set |
|
|
|
|
key (dict): the key data |
|
|
|
|
""" |
|
|
|
|
return self.db_pool.runInteraction( |
|
|
|
|
"add_e2e_cross_signing_key", |
|
|
|
|
self._set_e2e_cross_signing_key_txn, |
|
|
|
|
user_id, |
|
|
|
|
key_type, |
|
|
|
|
key, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
with await self._cross_signing_id_gen.get_next() as stream_id: |
|
|
|
|
return await self.db_pool.runInteraction( |
|
|
|
|
"add_e2e_cross_signing_key", |
|
|
|
|
self._set_e2e_cross_signing_key_txn, |
|
|
|
|
user_id, |
|
|
|
|
key_type, |
|
|
|
|
key, |
|
|
|
|
stream_id, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
def store_e2e_cross_signing_signatures(self, user_id, signatures): |
|
|
|
|
"""Stores cross-signing signatures. |
|
|
|
|