26 test failures to go :D
This commit is contained in:
parent
6ad31fe023
commit
0041dae664
7 changed files with 70 additions and 10 deletions
|
@ -16,7 +16,27 @@ limitations under the License.
|
|||
|
||||
"use strict";
|
||||
|
||||
import SubtleCrypto from 'subtle';
|
||||
import webcrypto from "node-webcrypto-shim";
|
||||
import {TextEncoder} from "util";
|
||||
import crypto from "crypto";
|
||||
|
||||
function getRandomValues(buf) {
|
||||
if (!(buf instanceof Uint8Array)) {
|
||||
throw new TypeError('expected Uint8Array');
|
||||
}
|
||||
if (buf.length > 65536) {
|
||||
const e = new Error();
|
||||
e.code = 22;
|
||||
e.message = 'Failed to execute \'getRandomValues\' on \'Crypto\': The ' +
|
||||
'ArrayBufferView\'s byte length (' + buf.length + ') exceeds the ' +
|
||||
'number of bytes of entropy available via this API (65536).';
|
||||
e.name = 'QuotaExceededError';
|
||||
throw e;
|
||||
}
|
||||
const bytes = crypto.randomBytes(buf.length);
|
||||
buf.set(bytes);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const TEST_VECTORS=[
|
||||
[
|
||||
|
@ -66,7 +86,7 @@ describe('MegolmExportEncryption', function() {
|
|||
let MegolmExportEncryption;
|
||||
|
||||
beforeAll(() => {
|
||||
window.crypto = { subtle: SubtleCrypto };
|
||||
window.crypto = { ...webcrypto, getRandomValues };
|
||||
MegolmExportEncryption = require("../../src/utils/MegolmExportEncryption");
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue