Comparing version 0.6.3 to 0.6.4
26
ece.js
@@ -261,6 +261,9 @@ 'use strict'; | ||
} | ||
if (header.rs <= PAD_SIZE[header.version]) { | ||
throw new Error('The rs parameter has to be greater than ' + | ||
PAD_SIZE[header.version]); | ||
var overhead = PAD_SIZE[header.version]; | ||
if (header.version === 'aes128gcm') { | ||
overhead += TAG_LENGTH; | ||
} | ||
if (header.rs <= overhead) { | ||
throw new Error('The rs parameter has to be greater than ' + overhead); | ||
} | ||
@@ -369,4 +372,9 @@ if (params.salt) { | ||
var chunkSize = header.rs; | ||
if (header.version !== 'aes128gcm') { | ||
chunkSize += TAG_LENGTH; | ||
} | ||
for (var i = 0; start < buffer.length; ++i) { | ||
var end = start + header.rs + TAG_LENGTH; | ||
var end = start + chunkSize; | ||
if (end === buffer.length) { | ||
@@ -462,2 +470,6 @@ throw new Error('Truncated payload'); | ||
var padSize = PAD_SIZE[header.version]; | ||
var overhead = padSize; | ||
if (header.version === 'aes128gcm') { | ||
overhead += TAG_LENGTH; | ||
} | ||
var pad = isNaN(parseInt(params.pad, 10)) ? 0 : parseInt(params.pad, 10); | ||
@@ -470,10 +482,10 @@ | ||
var recordPad = Math.min((1 << (padSize * 8)) - 1, // maximum padding | ||
Math.min(header.rs - padSize - 1, pad)); | ||
Math.min(header.rs - overhead - 1, pad)); | ||
pad -= recordPad; | ||
var end = Math.min(start + header.rs - padSize - recordPad, buffer.length); | ||
var end = Math.min(start + header.rs - overhead - recordPad, buffer.length); | ||
var block = encryptRecord(key, i, buffer.slice(start, end), | ||
recordPad, padSize); | ||
result = Buffer.concat([result, block]); | ||
start += header.rs - padSize - recordPad; | ||
start += header.rs - overhead - recordPad; | ||
} | ||
@@ -480,0 +492,0 @@ if (pad) { |
{ | ||
"name": "http_ece", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "Encrypted Content-Encoding for HTTP", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/martinthomson/encrypted-content-encoding", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29955
813