From 35207a2265187213bb03819959db03af875f6ab9 Mon Sep 17 00:00:00 2001 From: ovk Date: Tue, 5 Jan 2021 09:58:25 -0500 Subject: [PATCH] Allow changing salt length for EncryptedContentInfo #300 --- src/AuthenticatedSafe.js | 3 +++ src/CryptoEngine.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AuthenticatedSafe.js b/src/AuthenticatedSafe.js index cc71565bb..9e904b36d 100644 --- a/src/AuthenticatedSafe.js +++ b/src/AuthenticatedSafe.js @@ -408,6 +408,9 @@ export default class AuthenticatedSafe const currentParameters = parameters.safeContents[index]; currentParameters.contentToEncrypt = content.value.toSchema().toBER(false); + + if ('saltLength' in parameters) + currentParameters.saltLength = parameters.saltLength; //endregion //region Encrypt CMS EncryptedData using password diff --git a/src/CryptoEngine.js b/src/CryptoEngine.js index bb4740cb7..cd67ca796 100644 --- a/src/CryptoEngine.js +++ b/src/CryptoEngine.js @@ -1839,7 +1839,8 @@ export default class CryptoEngine const ivView = new Uint8Array(ivBuffer); this.getRandomValues(ivView); - const saltBuffer = new ArrayBuffer(64); + const saltLength = 'saltLength' in parameters ? parameters.saltLength : 64; + const saltBuffer = new ArrayBuffer(saltLength); const saltView = new Uint8Array(saltBuffer); this.getRandomValues(saltView);