fixed size limit on server to include crypto overhead

This commit is contained in:
Danny Coates 2019-03-06 10:31:50 -08:00
parent dce8b6e525
commit 7f9674f494
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
7 changed files with 24 additions and 11 deletions

View file

@ -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
};