From f63ca381cb35baf10ec45ba0a4c0d81cc89f28ce Mon Sep 17 00:00:00 2001 From: Emery Date: Tue, 6 Aug 2019 12:55:36 -0700 Subject: [PATCH] fix: framLength is not passed to the CMM resolves: #161 The CMM accepts `plaintextLength` but not `frameLenth`. --- .../src/caching_cryptographic_materials_decorators.ts | 4 ++-- modules/encrypt-browser/src/encrypt.ts | 1 - modules/encrypt-node/src/encrypt_stream.ts | 4 ++-- modules/material-management/src/types.ts | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/cache-material/src/caching_cryptographic_materials_decorators.ts b/modules/cache-material/src/caching_cryptographic_materials_decorators.ts index 501cb6a7a..b5d0549b2 100644 --- a/modules/cache-material/src/caching_cryptographic_materials_decorators.ts +++ b/modules/cache-material/src/caching_cryptographic_materials_decorators.ts @@ -70,7 +70,7 @@ export function getEncryptionMaterials ( this: CachingMaterialsManager, request: EncryptionRequest ): Promise> { - const { suite, encryptionContext, frameLength, plaintextLength } = request + const { suite, encryptionContext, plaintextLength } = request /* Check for early return (Postcondition): If I can not cache the EncryptionMaterial, do not even look. */ if ((suite && !suite.cacheSafe) || typeof plaintextLength !== 'number' || plaintextLength < 0) { return this @@ -92,7 +92,7 @@ export function getEncryptionMaterials ( /* Strip any information about the plaintext from the backing request, * because the resulting response may be used to encrypt multiple plaintexts. */ - .getEncryptionMaterials({ suite, encryptionContext, frameLength }) + .getEncryptionMaterials({ suite, encryptionContext, plaintextLength }) /* Check for early return (Postcondition): If I can not cache the EncryptionMaterial, just return it. */ if (!material.suite.cacheSafe) return material diff --git a/modules/encrypt-browser/src/encrypt.ts b/modules/encrypt-browser/src/encrypt.ts index facb37f44..332a7aba4 100644 --- a/modules/encrypt-browser/src/encrypt.ts +++ b/modules/encrypt-browser/src/encrypt.ts @@ -80,7 +80,6 @@ export async function encrypt ( const encryptionRequest: WebCryptoEncryptionRequest = { suite, encryptionContext, - frameLength, plaintextLength } diff --git a/modules/encrypt-node/src/encrypt_stream.ts b/modules/encrypt-node/src/encrypt_stream.ts index aadb83523..967e92e3c 100644 --- a/modules/encrypt-node/src/encrypt_stream.ts +++ b/modules/encrypt-node/src/encrypt_stream.ts @@ -56,7 +56,7 @@ export function encryptStream ( cmm: KeyringNode|NodeMaterialsManager, op: EncryptStreamInput = {} ): Duplex { - const { suiteId, encryptionContext = {}, frameLength = FRAME_LENGTH } = op + const { suiteId, encryptionContext = {}, frameLength = FRAME_LENGTH, plaintextLength } = op /* Precondition: The frameLength must be less than the maximum frame size Node.js stream. */ needs(frameLength > 0 && Maximum.FRAME_SIZE >= frameLength, `frameLength out of bounds: 0 > frameLength >= ${Maximum.FRAME_SIZE}`) @@ -70,7 +70,7 @@ export function encryptStream ( const wrappingStream = new Duplexify() - cmm.getEncryptionMaterials({ suite, encryptionContext, frameLength }) + cmm.getEncryptionMaterials({ suite, encryptionContext, plaintextLength }) .then(async (material) => { const { dispose, getSigner } = getEncryptHelper(material) diff --git a/modules/material-management/src/types.ts b/modules/material-management/src/types.ts index db58db1e8..3f4e3be37 100644 --- a/modules/material-management/src/types.ts +++ b/modules/material-management/src/types.ts @@ -45,7 +45,6 @@ export type MixedBackendCryptoKey = { export interface EncryptionRequest { readonly suite?: S readonly encryptionContext: EncryptionContext - readonly frameLength?: number readonly plaintextLength?: number }