Skip to content

Commit 06f559c

Browse files
committed
comment and constant name
1 parent b7a8c1e commit 06f559c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

modules/encrypt-node/src/framed_encrypt_stream.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export function getFramedEncryptStream (getCipher: GetCipher, messageHeader: Mes
5555
let pathologicalDrain: Function = noop
5656
const { frameLength } = messageHeader
5757

58-
/* Precondition: plaintextLength must be withing bounds.
59-
* The Maximum.BYTES_PER_CACHED_KEY_LIMIT is set to be within Number.MAX_SAFE_INTEGER
58+
/* Precondition: plaintextLength must be within bounds.
59+
* The Maximum.BYTES_PER_MESSAGE is set to be within Number.MAX_SAFE_INTEGER
6060
* See serialize/identifiers.ts enum Maximum for more details.
6161
*/
62-
needs(!plaintextLength || (plaintextLength >= 0 && Maximum.BYTES_PER_CACHED_KEY_LIMIT >= plaintextLength), 'plaintextLength out of bounds.')
62+
needs(!plaintextLength || (plaintextLength >= 0 && Maximum.BYTES_PER_MESSAGE >= plaintextLength), 'plaintextLength out of bounds.')
6363

6464
/* Keeping the messageHeader, accumulatingFrame and pathologicalDrain private is the intention here.
6565
* It is already unlikely that these values could be touched in the current composition of streams,

modules/encrypt-node/test/framed_encrypt_stream.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('getFramedEncryptStream', () => {
3030
expect(test._transform).is.a('function')
3131
})
3232

33-
it('Precondition: plaintextLength must be withing bounds.', () => {
33+
it('Precondition: plaintextLength must be within bounds.', () => {
3434
const getCipher: any = () => {}
3535
expect(() => getFramedEncryptStream(getCipher, {} as any, () => {}, -1)).to.throw(Error, 'plaintextLength out of bounds.')
3636
expect(() => getFramedEncryptStream(getCipher, {} as any, () => {}, Number.MAX_SAFE_INTEGER + 1)).to.throw(Error, 'plaintextLength out of bounds.')

modules/serialize/src/identifiers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export enum Maximum {
8080
* or some value larger 2 ** 63.
8181
*/
8282
BYTES_PER_CACHED_KEY_LIMIT = 2 ** 53 - 1, // eslint-disable-line no-unused-vars
83+
/* This value should be Maximum.FRAME_COUNT * Maximum.FRAME_SIZE.
84+
* However this would be ~ 2 ** 64, much larger than Number.MAX_SAFE_INTEGER.
85+
* For the same reasons outlined above in BYTES_PER_CACHED_KEY_LIMIT
86+
* this value is set to 2 ** 53 - 1.
87+
*/
88+
BYTES_PER_MESSAGE = 2 ** 53 - 1, // eslint-disable-line no-unused-vars
8389
// Maximum number of frames allowed in one message as defined in specification
8490
FRAME_COUNT = 2 ** 32 - 1, // eslint-disable-line no-unused-vars
8591
// Maximum bytes allowed in a single frame as defined in specification

0 commit comments

Comments
 (0)