diff --git a/src/crypto/CrossSigning.js b/src/crypto/CrossSigning.js index 9e877dcfc0d..c0633e958af 100644 --- a/src/crypto/CrossSigning.js +++ b/src/crypto/CrossSigning.js @@ -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], diff --git a/src/crypto/index.js b/src/crypto/index.js index 7ee23161616..96ddc218c02 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -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],