fixed size limit on server to include crypto overhead
This commit is contained in:
parent
dce8b6e525
commit
7f9674f494
7 changed files with 24 additions and 11 deletions
|
@ -281,11 +281,6 @@ class StreamSlicer {
|
|||
}
|
||||
}
|
||||
|
||||
export function encryptedSize(size, rs = ECE_RECORD_SIZE) {
|
||||
const chunk_meta = TAG_LENGTH + 1; // Chunk metadata, tag and delimiter
|
||||
return 21 + size + chunk_meta * Math.ceil(size / (rs - chunk_meta));
|
||||
}
|
||||
|
||||
/*
|
||||
input: a ReadableStream containing data to be transformed
|
||||
key: Uint8Array containing key of size KEY_LENGTH
|
||||
|
|
|
@ -3,7 +3,7 @@ import OwnedFile from './ownedFile';
|
|||
import Keychain from './keychain';
|
||||
import { arrayToB64, bytes } from './utils';
|
||||
import { uploadWs } from './api';
|
||||
import { encryptedSize } from './ece';
|
||||
import { encryptedSize } from './utils';
|
||||
|
||||
export default class FileSender extends Nanobus {
|
||||
constructor() {
|
||||
|
|
10
app/utils.js
10
app/utils.js
|
@ -249,6 +249,13 @@ function platform() {
|
|||
return 'web';
|
||||
}
|
||||
|
||||
const ECE_RECORD_SIZE = 1024 * 64;
|
||||
const TAG_LENGTH = 16;
|
||||
function encryptedSize(size, rs = ECE_RECORD_SIZE, tagLength = TAG_LENGTH) {
|
||||
const chunk_meta = tagLength + 1; // Chunk metadata, tag and delimiter
|
||||
return 21 + size + chunk_meta * Math.ceil(size / (rs - chunk_meta));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fadeOut,
|
||||
delay,
|
||||
|
@ -267,5 +274,6 @@ module.exports = {
|
|||
list,
|
||||
secondsToL10nId,
|
||||
timeLeft,
|
||||
platform
|
||||
platform,
|
||||
encryptedSize
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue