Skip to content

Commit 9d33d7b

Browse files
authored
Merge pull request #1583 from ably/1557-fix-browser-crypto-test-fails
[SDK-4003] Fix `multiple_send_binary_2_200` is failing intermittently in browser on v2 branch
2 parents 86daa44 + c94cbf1 commit 9d33d7b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/platform/web/lib/util/crypto.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ var createCryptoClass = function (config: IPlatformConfig, bufferUtils: typeof B
3333
if (config.getRandomArrayBuffer) {
3434
generateRandom = config.getRandomArrayBuffer;
3535
} else if (typeof Uint32Array !== 'undefined' && config.getRandomValues) {
36-
var blockRandomArray = new Uint32Array(DEFAULT_BLOCKLENGTH_WORDS);
3736
generateRandom = function (bytes, callback) {
37+
var blockRandomArray = new Uint32Array(DEFAULT_BLOCKLENGTH_WORDS);
3838
var words = bytes / 4,
3939
nativeArray = words == DEFAULT_BLOCKLENGTH_WORDS ? blockRandomArray : new Uint32Array(words);
4040
config.getRandomValues!(nativeArray, function (err) {
@@ -300,9 +300,6 @@ var createCryptoClass = function (config: IPlatformConfig, bufferUtils: typeof B
300300
return;
301301
}
302302

303-
/* Since the iv for a new block is the ciphertext of the last, this
304-
* sets a new iv (= aes(randomBlock XOR lastCipherText)) as well as
305-
* returning it */
306303
generateRandom(DEFAULT_BLOCKLENGTH, function (err, randomBlock) {
307304
if (err) {
308305
callback(err, null);

test/realtime/crypto.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,14 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
505505
_multiple_send(done, true, 20, 100);
506506
});
507507

508+
it('multiple_send_binary_10_10', function (done) {
509+
_multiple_send(done, false, 10, 10);
510+
});
511+
512+
it('multiple_send_text_10_10', function (done) {
513+
_multiple_send(done, true, 10, 10);
514+
});
515+
508516
function _single_send_separate_realtimes(done, txOpts, rxOpts) {
509517
if (!Crypto) {
510518
done(new Error('Encryption not supported'));

0 commit comments

Comments
 (0)