Skip to content

Commit b60f653

Browse files
authored
fix: framLength is not passed to the CMM (#190)
resolves: #161 The CMM accepts `plaintextLength` but not `frameLenth`.
1 parent 7f7228b commit b60f653

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

modules/cache-material/src/caching_cryptographic_materials_decorators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function getEncryptionMaterials<S extends SupportedAlgorithmSuites> (
7070
this: CachingMaterialsManager<S>,
7171
request: EncryptionRequest<S>
7272
): Promise<EncryptionMaterial<S>> {
73-
const { suite, encryptionContext, frameLength, plaintextLength } = request
73+
const { suite, encryptionContext, plaintextLength } = request
7474
/* Check for early return (Postcondition): If I can not cache the EncryptionMaterial, do not even look. */
7575
if ((suite && !suite.cacheSafe) || typeof plaintextLength !== 'number' || plaintextLength < 0) {
7676
return this
@@ -92,7 +92,7 @@ export function getEncryptionMaterials<S extends SupportedAlgorithmSuites> (
9292
/* Strip any information about the plaintext from the backing request,
9393
* because the resulting response may be used to encrypt multiple plaintexts.
9494
*/
95-
.getEncryptionMaterials({ suite, encryptionContext, frameLength })
95+
.getEncryptionMaterials({ suite, encryptionContext, plaintextLength })
9696

9797
/* Check for early return (Postcondition): If I can not cache the EncryptionMaterial, just return it. */
9898
if (!material.suite.cacheSafe) return material

modules/encrypt-browser/src/encrypt.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export async function encrypt (
8080
const encryptionRequest: WebCryptoEncryptionRequest = {
8181
suite,
8282
encryptionContext,
83-
frameLength,
8483
plaintextLength
8584
}
8685

modules/encrypt-node/src/encrypt_stream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function encryptStream (
5656
cmm: KeyringNode|NodeMaterialsManager,
5757
op: EncryptStreamInput = {}
5858
): Duplex {
59-
const { suiteId, encryptionContext = {}, frameLength = FRAME_LENGTH } = op
59+
const { suiteId, encryptionContext = {}, frameLength = FRAME_LENGTH, plaintextLength } = op
6060

6161
/* Precondition: The frameLength must be less than the maximum frame size Node.js stream. */
6262
needs(frameLength > 0 && Maximum.FRAME_SIZE >= frameLength, `frameLength out of bounds: 0 > frameLength >= ${Maximum.FRAME_SIZE}`)
@@ -70,7 +70,7 @@ export function encryptStream (
7070

7171
const wrappingStream = new Duplexify()
7272

73-
cmm.getEncryptionMaterials({ suite, encryptionContext, frameLength })
73+
cmm.getEncryptionMaterials({ suite, encryptionContext, plaintextLength })
7474
.then(async (material) => {
7575
const { dispose, getSigner } = getEncryptHelper(material)
7676

modules/material-management/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export type MixedBackendCryptoKey = {
4545
export interface EncryptionRequest<S extends NodeAlgorithmSuite|WebCryptoAlgorithmSuite> {
4646
readonly suite?: S
4747
readonly encryptionContext: EncryptionContext
48-
readonly frameLength?: number
4948
readonly plaintextLength?: number
5049
}
5150

0 commit comments

Comments
 (0)