Skip to content

Commit

Permalink
Throw error when trying to cache keys in the wrong format
Browse files Browse the repository at this point in the history
  • Loading branch information
jryans committed Apr 7, 2020
1 parent 66417e6 commit dc56f05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/crypto/CrossSigning.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,11 @@ export function createCryptoStoreCacheCallbacks(store) {
});
},
storeCrossSigningKeyCache: function(type, key) {
if (!(key instanceof Uint8Array)) {
throw new Error(
`storeCrossSigningKeyCache expects Uint8Array, got ${key}`,
);
}
return store.doTxn(
'readwrite',
[IndexedDBCryptoStore.STORE_ACCOUNT],
Expand Down
3 changes: 3 additions & 0 deletions src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,9 @@ Crypto.prototype.getSessionBackupPrivateKey = async function() {
* @returns {Promise} so you can catch failures
*/
Crypto.prototype.storeSessionBackupPrivateKey = async function(key) {
if (!(key instanceof Uint8Array)) {
throw new Error(`storeSessionBackupPrivateKey expects Uint8Array, got ${key}`);
}
return this._cryptoStore.doTxn(
'readwrite',
[IndexedDBCryptoStore.STORE_ACCOUNT],
Expand Down

0 comments on commit dc56f05

Please sign in to comment.