diff --git a/docs/ciphers/jest-html-reporters-attach/test-report/result.js b/docs/ciphers/jest-html-reporters-attach/test-report/result.js
index cc57bca..922ea22 100644
--- a/docs/ciphers/jest-html-reporters-attach/test-report/result.js
+++ b/docs/ciphers/jest-html-reporters-attach/test-report/result.js
@@ -1 +1 @@
-window.jest_html_reporters_callback__({"numFailedTestSuites":1,"numFailedTests":1,"numPassedTestSuites":2,"numPassedTests":29,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":3,"numTotalTests":30,"startTime":1707948544728,"success":false,"testResults":[{"numFailingTests":0,"numPassingTests":5,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1707948557281,"runtime":11443,"slow":true,"start":1707948545838},"testFilePath":"/encrypted-uri/packages/ciphers/aes.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["success flow aes"],"duration":325,"failureMessages":[],"fullName":"success flow aes cbc","status":"passed","title":"cbc"},{"ancestorTitles":["success flow aes"],"duration":31,"failureMessages":[],"fullName":"success flow aes ctr","status":"passed","title":"ctr"},{"ancestorTitles":["success flow aes"],"duration":15,"failureMessages":[],"fullName":"success flow aes ecb","status":"passed","title":"ecb"},{"ancestorTitles":["success flow aes"],"duration":19,"failureMessages":[],"fullName":"success flow aes gcm","status":"passed","title":"gcm"},{"ancestorTitles":["success flow aes"],"duration":29,"failureMessages":[],"fullName":"success flow aes siv","status":"passed","title":"siv"}]},{"numFailingTests":0,"numPassingTests":12,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1707948557797,"runtime":11959,"slow":true,"start":1707948545838},"testFilePath":"/encrypted-uri/packages/ciphers/kdf.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["kdf success flow"],"duration":317,"failureMessages":[],"fullName":"kdf success flow [2] kdf include all parameters including default","status":"passed","title":"[2] kdf include all parameters including default"},{"ancestorTitles":["kdf success flow"],"duration":76,"failureMessages":[],"fullName":"kdf success flow [3] kdf with hasher sha512","status":"passed","title":"[3] kdf with hasher sha512"},{"ancestorTitles":["kdf success flow"],"duration":120,"failureMessages":[],"fullName":"kdf success flow [4] kdf with hasher sha512_256","status":"passed","title":"[4] kdf with hasher sha512_256"},{"ancestorTitles":["kdf success flow"],"duration":97,"failureMessages":[],"fullName":"kdf success flow [5] kdf with hasher sha384","status":"passed","title":"[5] kdf with hasher sha384"},{"ancestorTitles":["kdf success flow"],"duration":80,"failureMessages":[],"fullName":"kdf success flow [6] kdf with hasher sha3_512","status":"passed","title":"[6] kdf with hasher sha3_512"},{"ancestorTitles":["kdf success flow"],"duration":33,"failureMessages":[],"fullName":"kdf success flow [7] kdf with hasher sha3_384","status":"passed","title":"[7] kdf with hasher sha3_384"},{"ancestorTitles":["kdf success flow"],"duration":37,"failureMessages":[],"fullName":"kdf success flow [8] kdf with hasher sha3_256","status":"passed","title":"[8] kdf with hasher sha3_256"},{"ancestorTitles":["kdf success flow"],"duration":50,"failureMessages":[],"fullName":"kdf success flow [9] kdf with hasher sha3_224","status":"passed","title":"[9] kdf with hasher sha3_224"},{"ancestorTitles":["kdf success flow"],"duration":36,"failureMessages":[],"fullName":"kdf success flow [10] kdf with hasher keccak_512","status":"passed","title":"[10] kdf with hasher keccak_512"},{"ancestorTitles":["kdf success flow"],"duration":35,"failureMessages":[],"fullName":"kdf success flow [11] kdf with hasher keccak_384","status":"passed","title":"[11] kdf with hasher keccak_384"},{"ancestorTitles":["kdf success flow"],"duration":21,"failureMessages":[],"fullName":"kdf success flow [12] kdf with hasher keccak_256","status":"passed","title":"[12] kdf with hasher keccak_256"},{"ancestorTitles":["kdf success flow"],"duration":31,"failureMessages":[],"fullName":"kdf success flow [13] kdf with hasher keccak_224","status":"passed","title":"[13] kdf with hasher keccak_224"}]},{"numFailingTests":1,"numPassingTests":12,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1707948562545,"runtime":16707,"slow":true,"start":1707948545838},"testFilePath":"/encrypted-uri/packages/ciphers/params.test.ts","failureMessage":"\u001b[1m\u001b[31m \u001b[1m● \u001b[22m\u001b[1mhashing customization › [12] kdf with hasher keccak_256\u001b[39m\u001b[22m\n\n \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoEqual\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // deep equality\u001b[22m\n\n Expected: \u001b[32mundefined\u001b[39m\n Received: \u001b[31m\"aes/cbc\"\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 228 |\u001b[39m \u001b[36mconst\u001b[39m parser \u001b[33m=\u001b[39m \u001b[36mnew\u001b[39m \u001b[33mEncryptedURIParser\u001b[39m(encoded)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 229 |\u001b[39m expect(parser\u001b[33m.\u001b[39mdecoded\u001b[33m.\u001b[39mparams\u001b[33m?\u001b[39m\u001b[33m.\u001b[39mkdf)\u001b[33m.\u001b[39mtoEqual(undefined)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 230 |\u001b[39m expect(parser\u001b[33m.\u001b[39mdecoded\u001b[33m.\u001b[39malgorithm)\u001b[33m.\u001b[39mtoEqual(undefined)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 231 |\u001b[39m expect(parser\u001b[33m.\u001b[39mdecoded\u001b[33m.\u001b[39mparams\u001b[33m?\u001b[39m\u001b[33m.\u001b[39mc)\u001b[33m.\u001b[39mtoEqual(undefined)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 232 |\u001b[39m expect(parser\u001b[33m.\u001b[39mdecoded\u001b[33m.\u001b[39mparams\u001b[33m?\u001b[39m\u001b[33m.\u001b[39mdklen)\u001b[33m.\u001b[39mtoEqual(undefined)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 233 |\u001b[39m expect(parser\u001b[33m.\u001b[39mdecoded\u001b[33m.\u001b[39mparams\u001b[33m?\u001b[39m\u001b[33m.\u001b[39mh)\u001b[33m.\u001b[39mtoEqual(\u001b[32m'keccak_256'\u001b[39m)\u001b[33m;\u001b[39m\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[2mat Object. (\u001b[22m\u001b[2m\u001b[0m\u001b[36mparams.test.ts\u001b[39m\u001b[0m\u001b[2m:230:38)\u001b[22m\u001b[2m\u001b[22m\n","testResults":[{"ancestorTitles":["hashing customization"],"duration":342,"failureMessages":[],"fullName":"hashing customization [3] kdf with hasher sha512","status":"passed","title":"[3] kdf with hasher sha512"},{"ancestorTitles":["hashing customization"],"duration":49,"failureMessages":[],"fullName":"hashing customization [4] kdf with hasher sha512_256","status":"passed","title":"[4] kdf with hasher sha512_256"},{"ancestorTitles":["hashing customization"],"duration":61,"failureMessages":[],"fullName":"hashing customization [5] kdf with hasher sha384","status":"passed","title":"[5] kdf with hasher sha384"},{"ancestorTitles":["hashing customization"],"duration":63,"failureMessages":[],"fullName":"hashing customization [6] kdf with hasher sha3_512","status":"passed","title":"[6] kdf with hasher sha3_512"},{"ancestorTitles":["hashing customization"],"duration":23,"failureMessages":[],"fullName":"hashing customization [7] kdf with hasher sha3_384","status":"passed","title":"[7] kdf with hasher sha3_384"},{"ancestorTitles":["hashing customization"],"duration":23,"failureMessages":[],"fullName":"hashing customization [8] kdf with hasher sha3_256","status":"passed","title":"[8] kdf with hasher sha3_256"},{"ancestorTitles":["hashing customization"],"duration":28,"failureMessages":[],"fullName":"hashing customization [9] kdf with hasher sha3_224","status":"passed","title":"[9] kdf with hasher sha3_224"},{"ancestorTitles":["hashing customization"],"duration":25,"failureMessages":[],"fullName":"hashing customization [10] kdf with hasher keccak_512","status":"passed","title":"[10] kdf with hasher keccak_512"},{"ancestorTitles":["hashing customization"],"duration":22,"failureMessages":[],"fullName":"hashing customization [11] kdf with hasher keccak_384","status":"passed","title":"[11] kdf with hasher keccak_384"},{"ancestorTitles":["hashing customization"],"duration":28,"failureMessages":["Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoEqual\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // deep equality\u001b[22m\n\nExpected: \u001b[32mundefined\u001b[39m\nReceived: \u001b[31m\"aes/cbc\"\u001b[39m\n at Object. (/encrypted-uri/packages/ciphers/params.test.ts:230:38)"],"fullName":"hashing customization [12] kdf with hasher keccak_256","status":"failed","title":"[12] kdf with hasher keccak_256"},{"ancestorTitles":["checking if params are correctly encoded"],"duration":4856,"failureMessages":[],"fullName":"checking if params are correctly encoded [1] overriding default values in decrypt","status":"passed","title":"[1] overriding default values in decrypt"},{"ancestorTitles":["checking if params are correctly encoded"],"duration":10,"failureMessages":[],"fullName":"checking if params are correctly encoded [2] kdf include all parameters including default","status":"passed","title":"[2] kdf include all parameters including default"},{"ancestorTitles":["checking if params are correctly encoded"],"duration":8,"failureMessages":[],"fullName":"checking if params are correctly encoded [3] kdf with algorithm not set","status":"passed","title":"[3] kdf with algorithm not set"}]}],"config":{"bail":0,"changedFilesWithAncestor":false,"ci":false,"collectCoverage":false,"collectCoverageFrom":[],"coverageDirectory":"/encrypted-uri/packages/ciphers/coverage","coverageProvider":"babel","coverageReporters":["json","text","lcov","clover"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"openHandlesTimeout":1000,"passWithNoTests":false,"projects":[],"reporters":[["default",{}],["/encrypted-uri/packages/ciphers/node_modules/jest-html-reporters/index.js",{"publicPath":"../../docs/ciphers","filename":"test-report.html","expand":true}]],"rootDir":"/encrypted-uri/packages/ciphers","runTestsByPath":false,"seed":-2103888769,"skipFilter":false,"snapshotFormat":{"escapeString":false,"printBasicPrototype":false},"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/encrypted-uri/packages/ciphers/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"watch":false,"watchAll":false,"watchman":true,"workerThreads":false},"endTime":1707948562670,"_reporterOptions":{"publicPath":"../../docs/ciphers","filename":"test-report.html","expand":true,"pageTitle":"","hideIcon":false,"testCommand":"","openReport":false,"failureMessageOnly":0,"enableMergeData":false,"dataMergeLevel":1,"inlineSource":false,"urlForTestFiles":"","darkTheme":false,"includeConsoleLog":false,"stripSkippedTest":false},"logInfoMapping":{},"attachInfos":{}})
\ No newline at end of file
+window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":3,"numPassedTests":38,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":3,"numTotalTests":38,"startTime":1708028887715,"success":false,"testResults":[{"numFailingTests":0,"numPassingTests":5,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1708028889698,"runtime":1816,"slow":false,"start":1708028887882},"testFilePath":"/encrypted-uri/packages/ciphers/aes.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["success flow aes"],"duration":12,"failureMessages":[],"fullName":"success flow aes cbc","status":"passed","title":"cbc"},{"ancestorTitles":["success flow aes"],"duration":3,"failureMessages":[],"fullName":"success flow aes ctr","status":"passed","title":"ctr"},{"ancestorTitles":["success flow aes"],"duration":5,"failureMessages":[],"fullName":"success flow aes ecb","status":"passed","title":"ecb"},{"ancestorTitles":["success flow aes"],"duration":4,"failureMessages":[],"fullName":"success flow aes gcm","status":"passed","title":"gcm"},{"ancestorTitles":["success flow aes"],"duration":4,"failureMessages":[],"fullName":"success flow aes siv","status":"passed","title":"siv"}]},{"numFailingTests":0,"numPassingTests":12,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1708028889836,"runtime":1955,"slow":false,"start":1708028887881},"testFilePath":"/encrypted-uri/packages/ciphers/kdf.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["kdf success flow"],"duration":15,"failureMessages":[],"fullName":"kdf success flow [2] kdf include all parameters including default","status":"passed","title":"[2] kdf include all parameters including default"},{"ancestorTitles":["kdf success flow"],"duration":18,"failureMessages":[],"fullName":"kdf success flow [3] kdf with hasher sha512","status":"passed","title":"[3] kdf with hasher sha512"},{"ancestorTitles":["kdf success flow"],"duration":17,"failureMessages":[],"fullName":"kdf success flow [4] kdf with hasher sha512_256","status":"passed","title":"[4] kdf with hasher sha512_256"},{"ancestorTitles":["kdf success flow"],"duration":15,"failureMessages":[],"fullName":"kdf success flow [5] kdf with hasher sha384","status":"passed","title":"[5] kdf with hasher sha384"},{"ancestorTitles":["kdf success flow"],"duration":15,"failureMessages":[],"fullName":"kdf success flow [6] kdf with hasher sha3_512","status":"passed","title":"[6] kdf with hasher sha3_512"},{"ancestorTitles":["kdf success flow"],"duration":4,"failureMessages":[],"fullName":"kdf success flow [7] kdf with hasher sha3_384","status":"passed","title":"[7] kdf with hasher sha3_384"},{"ancestorTitles":["kdf success flow"],"duration":4,"failureMessages":[],"fullName":"kdf success flow [8] kdf with hasher sha3_256","status":"passed","title":"[8] kdf with hasher sha3_256"},{"ancestorTitles":["kdf success flow"],"duration":7,"failureMessages":[],"fullName":"kdf success flow [9] kdf with hasher sha3_224","status":"passed","title":"[9] kdf with hasher sha3_224"},{"ancestorTitles":["kdf success flow"],"duration":4,"failureMessages":[],"fullName":"kdf success flow [10] kdf with hasher keccak_512","status":"passed","title":"[10] kdf with hasher keccak_512"},{"ancestorTitles":["kdf success flow"],"duration":4,"failureMessages":[],"fullName":"kdf success flow [11] kdf with hasher keccak_384","status":"passed","title":"[11] kdf with hasher keccak_384"},{"ancestorTitles":["kdf success flow"],"duration":4,"failureMessages":[],"fullName":"kdf success flow [12] kdf with hasher keccak_256","status":"passed","title":"[12] kdf with hasher keccak_256"},{"ancestorTitles":["kdf success flow"],"duration":7,"failureMessages":[],"fullName":"kdf success flow [13] kdf with hasher keccak_224","status":"passed","title":"[13] kdf with hasher keccak_224"}]},{"numFailingTests":0,"numPassingTests":21,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1708028890985,"runtime":3097,"slow":false,"start":1708028887888},"testFilePath":"/encrypted-uri/packages/ciphers/params.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["hashing customization"],"duration":23,"failureMessages":[],"fullName":"hashing customization [1] kdf with hasher sha512","status":"passed","title":"[1] kdf with hasher sha512"},{"ancestorTitles":["hashing customization"],"duration":7,"failureMessages":[],"fullName":"hashing customization [2] kdf with hasher sha512_256","status":"passed","title":"[2] kdf with hasher sha512_256"},{"ancestorTitles":["hashing customization"],"duration":11,"failureMessages":[],"fullName":"hashing customization [3] kdf with hasher sha384","status":"passed","title":"[3] kdf with hasher sha384"},{"ancestorTitles":["hashing customization"],"duration":16,"failureMessages":[],"fullName":"hashing customization [4] kdf with hasher sha3_512","status":"passed","title":"[4] kdf with hasher sha3_512"},{"ancestorTitles":["hashing customization"],"duration":3,"failureMessages":[],"fullName":"hashing customization [5] kdf with hasher sha3_384","status":"passed","title":"[5] kdf with hasher sha3_384"},{"ancestorTitles":["hashing customization"],"duration":5,"failureMessages":[],"fullName":"hashing customization [6] kdf with hasher sha3_256","status":"passed","title":"[6] kdf with hasher sha3_256"},{"ancestorTitles":["hashing customization"],"duration":21,"failureMessages":[],"fullName":"hashing customization [7] kdf with hasher sha3_224","status":"passed","title":"[7] kdf with hasher sha3_224"},{"ancestorTitles":["hashing customization"],"duration":4,"failureMessages":[],"fullName":"hashing customization [8] kdf with hasher keccak_512","status":"passed","title":"[8] kdf with hasher keccak_512"},{"ancestorTitles":["hashing customization"],"duration":4,"failureMessages":[],"fullName":"hashing customization [9] kdf with hasher keccak_384","status":"passed","title":"[9] kdf with hasher keccak_384"},{"ancestorTitles":["hashing customization"],"duration":3,"failureMessages":[],"fullName":"hashing customization [10] kdf with hasher keccak_256","status":"passed","title":"[10] kdf with hasher keccak_256"},{"ancestorTitles":["checking if params are correctly encoded"],"duration":1166,"failureMessages":[],"fullName":"checking if params are correctly encoded [1] overriding default values in decrypt","status":"passed","title":"[1] overriding default values in decrypt"},{"ancestorTitles":["checking if params are correctly encoded"],"duration":2,"failureMessages":[],"fullName":"checking if params are correctly encoded [2] kdf include all parameters including default","status":"passed","title":"[2] kdf include all parameters including default"},{"ancestorTitles":["checking if params are correctly encoded"],"duration":1,"failureMessages":[],"fullName":"checking if params are correctly encoded [3] kdf with algorithm not set","status":"passed","title":"[3] kdf with algorithm not set"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [1] ignoreDefaults as true","status":"passed","title":"[1] ignoreDefaults as true"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [2] ignoreDefaults as false","status":"passed","title":"[2] ignoreDefaults as false"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [3] ignoreDefaultAlgorithm as true","status":"passed","title":"[3] ignoreDefaultAlgorithm as true"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [4] ignoreDefaultValues as true","status":"passed","title":"[4] ignoreDefaultValues as true"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [5] ignoreMandatoryParamName as true","status":"passed","title":"[5] ignoreMandatoryParamName as true"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [6] ignoreDefaultAlgorithm and ignoreMandatoryParamName as true","status":"passed","title":"[6] ignoreDefaultAlgorithm and ignoreMandatoryParamName as true"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [7] ignoreDefaultAlgorithm and ignoreDefaultValues as true","status":"passed","title":"[7] ignoreDefaultAlgorithm and ignoreDefaultValues as true"},{"ancestorTitles":["configs of defaults"],"duration":1,"failureMessages":[],"fullName":"configs of defaults [8] ignoreDefaultValues and ignoreMandatoryParamName as true","status":"passed","title":"[8] ignoreDefaultValues and ignoreMandatoryParamName as true"}]}],"config":{"bail":0,"changedFilesWithAncestor":false,"ci":false,"collectCoverage":false,"collectCoverageFrom":[],"coverageDirectory":"/encrypted-uri/packages/ciphers/coverage","coverageProvider":"babel","coverageReporters":["json","text","lcov","clover"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"openHandlesTimeout":1000,"passWithNoTests":false,"projects":[],"reporters":[["default",{}],["/encrypted-uri/packages/ciphers/node_modules/jest-html-reporters/index.js",{"publicPath":"../../docs/ciphers","filename":"test-report.html","expand":true}]],"rootDir":"/encrypted-uri/packages/ciphers","runTestsByPath":false,"seed":-1423653765,"skipFilter":false,"snapshotFormat":{"escapeString":false,"printBasicPrototype":false},"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/encrypted-uri/packages/ciphers/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"watch":false,"watchAll":false,"watchman":true,"workerThreads":false},"endTime":1708028891017,"_reporterOptions":{"publicPath":"../../docs/ciphers","filename":"test-report.html","expand":true,"pageTitle":"","hideIcon":false,"testCommand":"","openReport":false,"failureMessageOnly":0,"enableMergeData":false,"dataMergeLevel":1,"inlineSource":false,"urlForTestFiles":"","darkTheme":false,"includeConsoleLog":false,"stripSkippedTest":false},"logInfoMapping":{},"attachInfos":{}})
\ No newline at end of file
diff --git a/docs/core/jest-html-reporters-attach/test-report/result.js b/docs/core/jest-html-reporters-attach/test-report/result.js
index 0e8de27..2dfa0a9 100644
--- a/docs/core/jest-html-reporters-attach/test-report/result.js
+++ b/docs/core/jest-html-reporters-attach/test-report/result.js
@@ -1 +1 @@
-window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":38,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":38,"startTime":1707948528799,"success":false,"testResults":[{"numFailingTests":0,"numPassingTests":38,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1707948538921,"runtime":9484,"slow":true,"start":1707948529437},"testFilePath":"/encrypted-uri/packages/core/index.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["decode uri with default values"],"duration":12,"failureMessages":[],"fullName":"decode uri with default values [1] decode uri with default values not include","status":"passed","title":"[1] decode uri with default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":2,"failureMessages":[],"fullName":"decode uri with default values [2] decode uri with some default values not include","status":"passed","title":"[2] decode uri with some default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":1,"failureMessages":[],"fullName":"decode uri with default values [3] decode uri with some default values not include","status":"passed","title":"[3] decode uri with some default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":3,"failureMessages":[],"fullName":"decode uri with default values [4] decode uri with default values not include","status":"passed","title":"[4] decode uri with default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":4,"failureMessages":[],"fullName":"decode uri with default values [5] decode uri with some default values not include","status":"passed","title":"[5] decode uri with some default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":2,"failureMessages":[],"fullName":"decode uri with default values [6] decode uri with some default values not include","status":"passed","title":"[6] decode uri with some default values not include"},{"ancestorTitles":["decode uri with customized values"],"duration":1,"failureMessages":[],"fullName":"decode uri with customized values [1] decode aes/gcm with customized values","status":"passed","title":"[1] decode aes/gcm with customized values"},{"ancestorTitles":["decode uri with customized values"],"duration":2,"failureMessages":[],"fullName":"decode uri with customized values [2] decode salsa20 with customized values","status":"passed","title":"[2] decode salsa20 with customized values"},{"ancestorTitles":["decode uri with customized values"],"duration":2,"failureMessages":[],"fullName":"decode uri with customized values [3] decode xchacha with customized values","status":"passed","title":"[3] decode xchacha with customized values"},{"ancestorTitles":["decode uri with customized values"],"duration":2,"failureMessages":[],"fullName":"decode uri with customized values [4] decode chacha12 with customized values","status":"passed","title":"[4] decode chacha12 with customized values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":2,"failureMessages":[],"fullName":"encode uri with configs using default values [1] encode with default config with default values","status":"passed","title":"[1] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":2,"failureMessages":[],"fullName":"encode uri with configs using default values [2] encode with default config with default values","status":"passed","title":"[2] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [3] encode with default config with default values","status":"passed","title":"[3] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [4] encode with default config with default values","status":"passed","title":"[4] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [5] encode with default config with default values","status":"passed","title":"[5] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [6] encode with default config with default values","status":"passed","title":"[6] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [7] encode with default config with default values","status":"passed","title":"[7] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [8] encode with default config with default values","status":"passed","title":"[8] encode with default config with default values"},{"ancestorTitles":["encode uri with customized values"],"duration":1,"failureMessages":[],"fullName":"encode uri with customized values [1] encode aes/gcm with customized values","status":"passed","title":"[1] encode aes/gcm with customized values"},{"ancestorTitles":["encode uri with customized values"],"duration":1,"failureMessages":[],"fullName":"encode uri with customized values [2] encode salsa20 with customized values","status":"passed","title":"[2] encode salsa20 with customized values"},{"ancestorTitles":["encode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"encode uri with customized values [3] encode xchacha with customized values","status":"passed","title":"[3] encode xchacha with customized values"},{"ancestorTitles":["encode uri with customized values"],"duration":1,"failureMessages":[],"fullName":"encode uri with customized values [4] encode chacha12 with customized values","status":"passed","title":"[4] encode chacha12 with customized values"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [1] match valid encrypted uri","status":"passed","title":"[1] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [2] match valid encrypted uri","status":"passed","title":"[2] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":2,"failureMessages":[],"fullName":"uri matcher [3] match valid encrypted uri","status":"passed","title":"[3] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [4] match valid encrypted uri","status":"passed","title":"[4] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [5] match valid encrypted uri","status":"passed","title":"[5] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [6] match valid encrypted uri","status":"passed","title":"[6] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [7] match valid encrypted uri","status":"passed","title":"[7] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [8] match valid encrypted uri","status":"passed","title":"[8] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [9] match valid encrypted uri","status":"passed","title":"[9] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [10] match valid encrypted uri","status":"passed","title":"[10] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [11] match valid encrypted uri","status":"passed","title":"[11] match valid encrypted uri"},{"ancestorTitles":["EncryptedURI object"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI object [1] match valid encrypted uri","status":"passed","title":"[1] match valid encrypted uri"},{"ancestorTitles":["EncryptedURI object"],"duration":2,"failureMessages":[],"fullName":"EncryptedURI object [2] EncryptedURI must run decrypt for custom algorithm","status":"passed","title":"[2] EncryptedURI must run decrypt for custom algorithm"},{"ancestorTitles":["EncryptedURI object"],"duration":2,"failureMessages":[],"fullName":"EncryptedURI object [3] EncryptedURI must run encrypt for custom algorithm","status":"passed","title":"[3] EncryptedURI must run encrypt for custom algorithm"},{"ancestorTitles":["EncryptedURI getKDFConfig"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI getKDFConfig [1] EncryptedURI get KDF config from KDF config","status":"passed","title":"[1] EncryptedURI get KDF config from KDF config"},{"ancestorTitles":["EncryptedURI getKDFConfig"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI getKDFConfig [2] EncryptedURI get KDF config from decoded URI","status":"passed","title":"[2] EncryptedURI get KDF config from decoded URI"}]}],"config":{"bail":0,"changedFilesWithAncestor":false,"ci":false,"collectCoverage":false,"collectCoverageFrom":[],"coverageDirectory":"/encrypted-uri/packages/core/coverage","coverageProvider":"babel","coverageReporters":["json","text","lcov","clover"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"openHandlesTimeout":1000,"passWithNoTests":false,"projects":[],"reporters":[["default",{}],["/encrypted-uri/packages/core/node_modules/jest-html-reporters/index.js",{"publicPath":"../../docs/core","filename":"test-report.html","expand":true}]],"rootDir":"/encrypted-uri/packages/core","runTestsByPath":false,"seed":-1428097188,"skipFilter":false,"snapshotFormat":{"escapeString":false,"printBasicPrototype":false},"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/encrypted-uri/packages/core/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"verbose":true,"watch":false,"watchAll":false,"watchman":true,"workerThreads":false},"endTime":1707948538943,"_reporterOptions":{"publicPath":"../../docs/core","filename":"test-report.html","expand":true,"pageTitle":"","hideIcon":false,"testCommand":"","openReport":false,"failureMessageOnly":0,"enableMergeData":false,"dataMergeLevel":1,"inlineSource":false,"urlForTestFiles":"","darkTheme":false,"includeConsoleLog":false,"stripSkippedTest":false},"logInfoMapping":{},"attachInfos":{}})
\ No newline at end of file
+window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":46,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":46,"startTime":1708028885811,"success":false,"testResults":[{"numFailingTests":0,"numPassingTests":46,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1708028886972,"runtime":1119,"slow":false,"start":1708028885853},"testFilePath":"/encrypted-uri/packages/core/index.test.ts","failureMessage":null,"testResults":[{"ancestorTitles":["decode uri with default values"],"duration":3,"failureMessages":[],"fullName":"decode uri with default values [1] decode uri with default values not include","status":"passed","title":"[1] decode uri with default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":0,"failureMessages":[],"fullName":"decode uri with default values [2] decode uri with some default values not include","status":"passed","title":"[2] decode uri with some default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":0,"failureMessages":[],"fullName":"decode uri with default values [3] decode uri with some default values not include","status":"passed","title":"[3] decode uri with some default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":1,"failureMessages":[],"fullName":"decode uri with default values [4] decode uri with default values not include","status":"passed","title":"[4] decode uri with default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":1,"failureMessages":[],"fullName":"decode uri with default values [5] decode uri with some default values not include","status":"passed","title":"[5] decode uri with some default values not include"},{"ancestorTitles":["decode uri with default values"],"duration":1,"failureMessages":[],"fullName":"decode uri with default values [6] decode uri with some default values not include","status":"passed","title":"[6] decode uri with some default values not include"},{"ancestorTitles":["decode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"decode uri with customized values [1] decode aes/gcm with customized values","status":"passed","title":"[1] decode aes/gcm with customized values"},{"ancestorTitles":["decode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"decode uri with customized values [2] decode salsa20 with customized values","status":"passed","title":"[2] decode salsa20 with customized values"},{"ancestorTitles":["decode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"decode uri with customized values [3] decode xchacha with customized values","status":"passed","title":"[3] decode xchacha with customized values"},{"ancestorTitles":["decode uri with customized values"],"duration":1,"failureMessages":[],"fullName":"decode uri with customized values [4] decode chacha12 with customized values","status":"passed","title":"[4] decode chacha12 with customized values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [1] encode with default config with default values","status":"passed","title":"[1] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":0,"failureMessages":[],"fullName":"encode uri with configs using default values [2] encode with default config with default values","status":"passed","title":"[2] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":0,"failureMessages":[],"fullName":"encode uri with configs using default values [3] encode with default config with default values","status":"passed","title":"[3] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":0,"failureMessages":[],"fullName":"encode uri with configs using default values [4] encode with default config with default values","status":"passed","title":"[4] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":0,"failureMessages":[],"fullName":"encode uri with configs using default values [5] encode with default config with default values","status":"passed","title":"[5] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":0,"failureMessages":[],"fullName":"encode uri with configs using default values [6] encode with default config with default values","status":"passed","title":"[6] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":1,"failureMessages":[],"fullName":"encode uri with configs using default values [7] encode with default config with default values","status":"passed","title":"[7] encode with default config with default values"},{"ancestorTitles":["encode uri with configs using default values"],"duration":0,"failureMessages":[],"fullName":"encode uri with configs using default values [8] encode with default config with default values","status":"passed","title":"[8] encode with default config with default values"},{"ancestorTitles":["encode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"encode uri with customized values [1] encode aes/gcm with customized values","status":"passed","title":"[1] encode aes/gcm with customized values"},{"ancestorTitles":["encode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"encode uri with customized values [2] encode salsa20 with customized values","status":"passed","title":"[2] encode salsa20 with customized values"},{"ancestorTitles":["encode uri with customized values"],"duration":0,"failureMessages":[],"fullName":"encode uri with customized values [3] encode xchacha with customized values","status":"passed","title":"[3] encode xchacha with customized values"},{"ancestorTitles":["encode uri with customized values"],"duration":1,"failureMessages":[],"fullName":"encode uri with customized values [4] encode chacha12 with customized values","status":"passed","title":"[4] encode chacha12 with customized values"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [1] match valid encrypted uri","status":"passed","title":"[1] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [2] match valid encrypted uri","status":"passed","title":"[2] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [3] match valid encrypted uri","status":"passed","title":"[3] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [4] match valid encrypted uri","status":"passed","title":"[4] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [5] match valid encrypted uri","status":"passed","title":"[5] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [6] match valid encrypted uri","status":"passed","title":"[6] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [7] match valid encrypted uri","status":"passed","title":"[7] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [8] match valid encrypted uri","status":"passed","title":"[8] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [9] match valid encrypted uri","status":"passed","title":"[9] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":1,"failureMessages":[],"fullName":"uri matcher [10] match valid encrypted uri","status":"passed","title":"[10] match valid encrypted uri"},{"ancestorTitles":["uri matcher"],"duration":0,"failureMessages":[],"fullName":"uri matcher [11] match valid encrypted uri","status":"passed","title":"[11] match valid encrypted uri"},{"ancestorTitles":["EncryptedURI object"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI object [1] match valid encrypted uri","status":"passed","title":"[1] match valid encrypted uri"},{"ancestorTitles":["EncryptedURI object"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI object [2] EncryptedURI must run decrypt for custom algorithm","status":"passed","title":"[2] EncryptedURI must run decrypt for custom algorithm"},{"ancestorTitles":["EncryptedURI object"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI object [3] EncryptedURI must run encrypt for custom algorithm","status":"passed","title":"[3] EncryptedURI must run encrypt for custom algorithm"},{"ancestorTitles":["EncryptedURI kdf customization"],"duration":0,"failureMessages":[],"fullName":"EncryptedURI kdf customization [1] EncryptedURI get KDF config from KDF config","status":"passed","title":"[1] EncryptedURI get KDF config from KDF config"},{"ancestorTitles":["EncryptedURI kdf customization"],"duration":0,"failureMessages":[],"fullName":"EncryptedURI kdf customization [2] EncryptedURI get KDF config from decoded URI","status":"passed","title":"[2] EncryptedURI get KDF config from decoded URI"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [1] EncryptedURI ignoreDefaults as false","status":"passed","title":"[1] EncryptedURI ignoreDefaults as false"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [2] EncryptedURI ignoreDefaults as true","status":"passed","title":"[2] EncryptedURI ignoreDefaults as true"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":0,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [3] EncryptedURI ignoreDefaultAlgorithm as true","status":"passed","title":"[3] EncryptedURI ignoreDefaultAlgorithm as true"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":0,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [4] EncryptedURI ignoreDefaultValues as true","status":"passed","title":"[4] EncryptedURI ignoreDefaultValues as true"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [5] EncryptedURI ignoreMandatoryParamName as true","status":"passed","title":"[5] EncryptedURI ignoreMandatoryParamName as true"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [6] EncryptedURI ignoreDefaultAlgorithm and ignoreDefaultValues as true","status":"passed","title":"[6] EncryptedURI ignoreDefaultAlgorithm and ignoreDefaultValues as true"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":0,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [7] EncryptedURI ignoreDefaultAlgorithm and ignoreMandatoryParamName as true","status":"passed","title":"[7] EncryptedURI ignoreDefaultAlgorithm and ignoreMandatoryParamName as true"},{"ancestorTitles":["EncryptedURI configs of defaults"],"duration":1,"failureMessages":[],"fullName":"EncryptedURI configs of defaults [8] EncryptedURI ignoreDefaultValues and ignoreMandatoryParamName as true","status":"passed","title":"[8] EncryptedURI ignoreDefaultValues and ignoreMandatoryParamName as true"}]}],"config":{"bail":0,"changedFilesWithAncestor":false,"ci":false,"collectCoverage":false,"collectCoverageFrom":[],"coverageDirectory":"/encrypted-uri/packages/core/coverage","coverageProvider":"babel","coverageReporters":["json","text","lcov","clover"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"openHandlesTimeout":1000,"passWithNoTests":false,"projects":[],"reporters":[["default",{}],["/encrypted-uri/packages/core/node_modules/jest-html-reporters/index.js",{"publicPath":"../../docs/core","filename":"test-report.html","expand":true}]],"rootDir":"/encrypted-uri/packages/core","runTestsByPath":false,"seed":-1798787030,"skipFilter":false,"snapshotFormat":{"escapeString":false,"printBasicPrototype":false},"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/encrypted-uri/packages/core/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"verbose":true,"watch":false,"watchAll":false,"watchman":true,"workerThreads":false},"endTime":1708028886983,"_reporterOptions":{"publicPath":"../../docs/core","filename":"test-report.html","expand":true,"pageTitle":"","hideIcon":false,"testCommand":"","openReport":false,"failureMessageOnly":0,"enableMergeData":false,"dataMergeLevel":1,"inlineSource":false,"urlForTestFiles":"","darkTheme":false,"includeConsoleLog":false,"stripSkippedTest":false},"logInfoMapping":{},"attachInfos":{}})
\ No newline at end of file
diff --git a/packages/ciphers/aes/cbc/index.ts b/packages/ciphers/aes/cbc/index.ts
index 2ee942a..cba6bb1 100755
--- a/packages/ciphers/aes/cbc/index.ts
+++ b/packages/ciphers/aes/cbc/index.ts
@@ -20,9 +20,7 @@ class EncryptedURIAESCBCDecrypter extends EncryptedURIDecrypter extends Enc
async decrypt(): Promise {
const cipher = base64.decode(this.decoded.cipher || '');
const params = getSalt(cipher, this.decoded?.params);
- const result = await ecb(kdf(this.password, params.salt, this.decoded))
+ const derivatedKey = kdf(this.password, params.salt, this.decoded);
+ const result = await ecb(derivatedKey)
.decrypt(params.cipher);
return bytesToUtf8(result);
@@ -42,7 +43,8 @@ class EncryptedURIAESECBEncrypter extends Enc
const content = utf8ToBytes(this.params.content);
const saltLength = 8;
const salt = randomBytes(saltLength);
- const rawCipher = await ecb(kdf(this.params.password, salt, this.params)).encrypt(content);
+ const derivatedKey = kdf(this.params.password, salt, this.params);
+ const rawCipher = await ecb(derivatedKey).encrypt(content);
const cipher = base64.encode(OpenSSLSerializer.encode(rawCipher, salt));
return Promise.resolve({ cipher });
diff --git a/packages/ciphers/aes/gcm/index.ts b/packages/ciphers/aes/gcm/index.ts
index b7ebc64..c64838f 100755
--- a/packages/ciphers/aes/gcm/index.ts
+++ b/packages/ciphers/aes/gcm/index.ts
@@ -20,7 +20,8 @@ class EncryptedURIAESGCMDecrypter extends EncryptedURIDecrypter(
salt: Uint8Array,
kdfConfig?: TEncryptedURI | TEncryptedURIResultset
): Uint8Array {
- const cfg = EncryptedURI.getKDFConfig(kdfConfig);
+ const cfg = EncryptedURI.getKDFParams(kdfConfig);
const saltLength = 8;
if (salt.length !== saltLength) {
throw new Error(`salt length must be ${saltLength} bytes, ${salt.length} bytes was given`);
diff --git a/packages/ciphers/aes/siv/index.ts b/packages/ciphers/aes/siv/index.ts
index 76d3eda..82e439c 100755
--- a/packages/ciphers/aes/siv/index.ts
+++ b/packages/ciphers/aes/siv/index.ts
@@ -1,12 +1,12 @@
-import { EncryptedURIAlgorithm, EncryptedURIDecrypter, EncryptedURIEncrypter, TEncryptedURI, TEncryptedURIResultset } from "@encrypted-uri/core";
+import { EncryptedURIAlgorithm, EncryptedURIDecrypter, EncryptedURIEncrypter, TEncryptedURI, TEncryptedURIResultset } from '@encrypted-uri/core';
import { siv } from '@noble/ciphers/aes';
import { bytesToUtf8, hexToBytes, utf8ToBytes } from '@noble/ciphers/utils';
-import { randomBytes } from "@noble/hashes/utils";
+import { randomBytes } from '@noble/hashes/utils';
import { base64 } from '@scure/base';
-import { kdf } from "../kdf";
+import { kdf } from '../kdf';
import { TNumberOnceParams, getNumberOnce } from '../number-once';
-import { OpenSSLSerializer } from "../openssl-serializer";
-import { getSalt } from "../salt";
+import { OpenSSLSerializer } from '../openssl-serializer';
+import { getSalt } from '../salt';
class EncryptedURIAESSIVDecrypter extends EncryptedURIDecrypter {
constructor(
@@ -20,7 +20,8 @@ class EncryptedURIAESSIVDecrypter extends EncryptedURIDecrypter {
it('[2] kdf include all parameters including default', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
kdf: 'pbkdf2',
- ignoreDefaults: false,
hasher: 'sha256',
rounds: 10,
derivateKeyLength: 32
@@ -20,6 +19,9 @@ describe('kdf success flow', () => {
algorithm: 'aes/cbc',
content: originalMessage,
password,
+ config: {
+ ignoreDefaults: false
+ },
kdf
});
@@ -28,7 +30,7 @@ describe('kdf success flow', () => {
});
it('[3] kdf with hasher sha512', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha512'
};
@@ -47,7 +49,7 @@ describe('kdf success flow', () => {
});
it('[4] kdf with hasher sha512_256', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha512_256'
};
@@ -66,7 +68,7 @@ describe('kdf success flow', () => {
});
it('[5] kdf with hasher sha384', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha384'
};
@@ -85,7 +87,7 @@ describe('kdf success flow', () => {
});
it('[6] kdf with hasher sha3_512', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_512'
};
@@ -104,7 +106,7 @@ describe('kdf success flow', () => {
});
it('[7] kdf with hasher sha3_384', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_384'
};
@@ -123,7 +125,7 @@ describe('kdf success flow', () => {
});
it('[8] kdf with hasher sha3_256', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_256'
};
@@ -142,7 +144,7 @@ describe('kdf success flow', () => {
});
it('[9] kdf with hasher sha3_224', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_224'
};
@@ -161,7 +163,7 @@ describe('kdf success flow', () => {
});
it('[10] kdf with hasher keccak_512', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_512'
};
@@ -180,7 +182,7 @@ describe('kdf success flow', () => {
});
it('[11] kdf with hasher keccak_384', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_384'
};
@@ -199,7 +201,7 @@ describe('kdf success flow', () => {
});
it('[12] kdf with hasher keccak_256', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_256'
};
@@ -218,7 +220,7 @@ describe('kdf success flow', () => {
});
it('[13] kdf with hasher keccak_224', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_224'
};
diff --git a/packages/ciphers/params.test.ts b/packages/ciphers/params.test.ts
index b8a5ed2..174200b 100755
--- a/packages/ciphers/params.test.ts
+++ b/packages/ciphers/params.test.ts
@@ -1,10 +1,10 @@
-import { EncryptedURI, EncryptedURIParser, TEncryptedURIKDFConfig } from '@encrypted-uri/core';
+import { EncryptedURI, EncryptedURIParser, TEncryptedDefaultsConfig, TEncryptedURIKDFParams } from '@encrypted-uri/core';
import './aes';
import './hashes';
describe('hashing customization', () => {
- it('[3] kdf with hasher sha512', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[1] kdf with hasher sha512', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha512'
};
@@ -26,8 +26,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha512');
});
- it('[4] kdf with hasher sha512_256', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[2] kdf with hasher sha512_256', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha512_256'
};
@@ -49,8 +49,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha512_256');
});
- it('[5] kdf with hasher sha384', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[3] kdf with hasher sha384', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha384'
};
@@ -72,8 +72,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha384');
});
- it('[6] kdf with hasher sha3_512', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[4] kdf with hasher sha3_512', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_512'
};
@@ -95,8 +95,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha3_512');
});
- it('[7] kdf with hasher sha3_384', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[5] kdf with hasher sha3_384', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_384'
};
@@ -118,8 +118,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha3_384');
});
- it('[8] kdf with hasher sha3_256', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[6] kdf with hasher sha3_256', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_256'
};
@@ -141,8 +141,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha3_256');
});
- it('[9] kdf with hasher sha3_224', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[7] kdf with hasher sha3_224', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'sha3_224'
};
@@ -164,8 +164,8 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.h).toEqual('sha3_224');
});
- it('[10] kdf with hasher keccak_512', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[8] kdf with hasher keccak_512', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_512'
};
@@ -181,14 +181,14 @@ describe('hashing customization', () => {
const parser = new EncryptedURIParser(encoded);
expect(parser.decoded.params?.kdf).toEqual(undefined);
- expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.algorithm).toEqual(undefined);
expect(parser.decoded.params?.c).toEqual(undefined);
expect(parser.decoded.params?.dklen).toEqual(undefined);
expect(parser.decoded.params?.h).toEqual('keccak_512');
});
- it('[11] kdf with hasher keccak_384', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[9] kdf with hasher keccak_384', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_384'
};
@@ -204,14 +204,14 @@ describe('hashing customization', () => {
const parser = new EncryptedURIParser(encoded);
expect(parser.decoded.params?.kdf).toEqual(undefined);
- expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.algorithm).toEqual(undefined);
expect(parser.decoded.params?.c).toEqual(undefined);
expect(parser.decoded.params?.dklen).toEqual(undefined);
expect(parser.decoded.params?.h).toEqual('keccak_384');
});
- it('[12] kdf with hasher keccak_256', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ it('[10] kdf with hasher keccak_256', async () => {
+ const kdf: TEncryptedURIKDFParams = {
hasher: 'keccak_256'
};
@@ -232,11 +232,11 @@ describe('hashing customization', () => {
expect(parser.decoded.params?.dklen).toEqual(undefined);
expect(parser.decoded.params?.h).toEqual('keccak_256');
});
-})
+});
describe('checking if params are correctly encoded', () => {
it('[1] overriding default values in decrypt', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
kdf: 'pbkdf2',
hasher: 'sha256',
rounds: 250_000,
@@ -262,9 +262,8 @@ describe('checking if params are correctly encoded', () => {
});
it('[2] kdf include all parameters including default', async () => {
- const kdf: TEncryptedURIKDFConfig = {
+ const kdf: TEncryptedURIKDFParams = {
kdf: 'pbkdf2',
- ignoreDefaults: false,
hasher: 'sha256',
rounds: 100,
derivateKeyLength: 32
@@ -277,6 +276,9 @@ describe('checking if params are correctly encoded', () => {
algorithm: 'aes/cbc',
content: originalMessage,
password,
+ config: {
+ ignoreDefaults: false
+ },
kdf
});
@@ -299,9 +301,271 @@ describe('checking if params are correctly encoded', () => {
const parser = new EncryptedURIParser(encoded);
expect(parser.decoded.params?.kdf).toEqual(undefined);
- expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.algorithm).toEqual(undefined);
expect(parser.decoded.params?.c).toEqual(undefined);
expect(parser.decoded.params?.dklen).toEqual(undefined);
expect(parser.decoded.params?.h).toEqual(undefined);
});
});
+
+describe('configs of defaults', () => {
+ it('[1] ignoreDefaults as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaults: true
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual(undefined);
+ expect(parser.decoded.params?.kdf).toEqual(undefined);
+ expect(parser.decoded.params?.c).toEqual(undefined);
+ expect(parser.decoded.params?.dklen).toEqual(undefined);
+ expect(parser.decoded.params?.h).toEqual(undefined);
+ });
+
+ it('[2] ignoreDefaults as false', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaults: false
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.params?.kdf).toEqual('pbkdf2');
+ expect(parser.decoded.params?.c).toEqual('32');
+ expect(parser.decoded.params?.dklen).toEqual('32');
+ expect(parser.decoded.params?.h).toEqual('sha256');
+ });
+
+ it('[3] ignoreDefaultAlgorithm as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: false,
+ ignoreMandatoryParamName: false
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual(undefined);
+ expect(parser.decoded.params?.kdf).toEqual('pbkdf2');
+ expect(parser.decoded.params?.c).toEqual('32');
+ expect(parser.decoded.params?.dklen).toEqual('32');
+ expect(parser.decoded.params?.h).toEqual('sha256');
+ });
+
+ it('[4] ignoreDefaultValues as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaultAlgorithm: false,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: false
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.params?.kdf).toEqual(undefined);
+ expect(parser.decoded.params?.c).toEqual(undefined);
+ expect(parser.decoded.params?.dklen).toEqual(undefined);
+ expect(parser.decoded.params?.h).toEqual(undefined);
+ });
+
+ it('[5] ignoreMandatoryParamName as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaultAlgorithm: false,
+ ignoreDefaultValues: false,
+ ignoreMandatoryParamName: true
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.params?.kdf).toEqual('pbkdf2');
+ expect(parser.decoded.params?.c).toEqual('32');
+ expect(parser.decoded.params?.dklen).toEqual('32');
+ expect(parser.decoded.params?.h).toEqual('sha256');
+ });
+
+ it('[6] ignoreDefaultAlgorithm and ignoreMandatoryParamName as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: false,
+ ignoreMandatoryParamName: true
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual(undefined);
+ expect(parser.decoded.params?.kdf).toEqual('pbkdf2');
+ expect(parser.decoded.params?.c).toEqual('32');
+ expect(parser.decoded.params?.dklen).toEqual('32');
+ expect(parser.decoded.params?.h).toEqual('sha256');
+ });
+
+ it('[7] ignoreDefaultAlgorithm and ignoreDefaultValues as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: false
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual(undefined);
+ expect(parser.decoded.params?.kdf).toEqual(undefined);
+ expect(parser.decoded.params?.c).toEqual(undefined);
+ expect(parser.decoded.params?.dklen).toEqual(undefined);
+ expect(parser.decoded.params?.h).toEqual(undefined);
+ });
+
+ it('[8] ignoreDefaultValues and ignoreMandatoryParamName as true', async () => {
+ const config: TEncryptedDefaultsConfig = {
+ ignoreDefaultAlgorithm: false,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: true
+ };
+
+ const kdf: TEncryptedURIKDFParams = {
+ kdf: 'pbkdf2',
+ hasher: 'sha256',
+ rounds: 32,
+ derivateKeyLength: 32
+ };
+
+ const originalMessage = 'mensagem secreta, favor não ler em voz alta';
+ const password = 'senha123';
+
+ const encoded = await EncryptedURI.encrypt({
+ algorithm: 'aes/cbc',
+ content: originalMessage,
+ password,
+ config,
+ kdf
+ });
+
+ const parser = new EncryptedURIParser(encoded);
+ expect(parser.decoded.algorithm).toEqual('aes/cbc');
+ expect(parser.decoded.params?.kdf).toEqual(undefined);
+ expect(parser.decoded.params?.c).toEqual(undefined);
+ expect(parser.decoded.params?.dklen).toEqual(undefined);
+ expect(parser.decoded.params?.h).toEqual(undefined);
+ });
+});
\ No newline at end of file
diff --git a/packages/core/index.test.ts b/packages/core/index.test.ts
index ea9db52..041842a 100755
--- a/packages/core/index.test.ts
+++ b/packages/core/index.test.ts
@@ -1,4 +1,4 @@
-import { EncryptedURI, EncryptedURIDecrypter, EncryptedURIEncrypter, EncryptedURIParser, TEncryptedURI, TEncryptedURIEncryptableDefaultParams, TEncryptedURIKDFConfig, TURIParams } from ".";
+import { EncryptedURI, EncryptedURIDecrypter, EncryptedURIEncrypter, EncryptedURIParser, TEncryptedURI, TEncryptedURIEncryptableDefaultParams, TEncryptedURIKDFParams, TURIParams } from ".";
describe('decode uri with default values', () => {
it('[1] decode uri with default values not include', () => {
@@ -19,9 +19,8 @@ describe('decode uri with default values', () => {
});
it('[3] decode uri with some default values not include', () => {
- expect(new EncryptedURIParser('encrypted:aes/cbc?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata').decoded)
+ expect(new EncryptedURIParser('encrypted:?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata').decoded)
.toEqual({
- algorithm: 'aes/cbc',
cipher: 'en1e3kj3e31jn2algoritmgenerateddata',
queryString: '2345678wertyui'
});
@@ -52,9 +51,8 @@ describe('decode uri with default values', () => {
});
it('[6] decode uri with some default values not include', () => {
- expect(new EncryptedURIParser('encrypted:aes/cbc?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata').decoded)
+ expect(new EncryptedURIParser('encrypted:?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata').decoded)
.toEqual({
- algorithm: 'aes/cbc',
cipher: 'en1e3kj3e31jn2algoritmgenerateddata',
queryString: 'iv=2345678wertyui&pad=pkcs%237',
params: {
@@ -126,7 +124,7 @@ describe('encode uri with configs using default values', () => {
params: {
iv: '2345678wertyui'
}
- }).encoded).toEqual('encrypted:aes/cbc?iv=2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[3] encode with default config with default values', () => {
@@ -142,7 +140,7 @@ describe('encode uri with configs using default values', () => {
algorithm: 'aes/cbc',
cipher: 'en1e3kj3e31jn2algoritmgenerateddata',
queryString: '2345678wertyui'
- }).encoded).toEqual('encrypted:aes/cbc?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[5] encode with default config with default values', () => {
@@ -153,7 +151,7 @@ describe('encode uri with configs using default values', () => {
iv: '2345678wertyui',
pad: 'pkcs#7'
}
- }).encoded).toEqual('encrypted:aes/cbc?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[6] encode with default config with default values', () => {
@@ -163,7 +161,7 @@ describe('encode uri with configs using default values', () => {
params: {
iv: '2345678wertyui'
}
- }).encoded).toEqual('encrypted:aes?iv=2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:aes?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[7] encode with default config with default values', () => {
@@ -171,7 +169,7 @@ describe('encode uri with configs using default values', () => {
algorithm: 'aes/cbc',
cipher: 'en1e3kj3e31jn2algoritmgenerateddata',
queryString: 'iv=2345678wertyui'
- }).encoded).toEqual('encrypted:aes/cbc?iv=2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:?iv=2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[8] encode with default config with default values', () => {
@@ -182,7 +180,7 @@ describe('encode uri with configs using default values', () => {
iv: '2345678wertyui',
pad: 'pkcs#7'
}
- }).encoded).toEqual('encrypted:aes/cbc?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata')
});
});
@@ -206,7 +204,7 @@ describe('encode uri with customized values', () => {
// nonce
no: '871232183987132082713'
}
- }).encoded).toEqual('encrypted:salsa20?no=871232183987132082713;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:salsa20?871232183987132082713;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[3] encode xchacha with customized values', () => {
@@ -217,7 +215,7 @@ describe('encode uri with customized values', () => {
// nonce
no: '871232183987132082713'
}
- }).encoded).toEqual('encrypted:xchacha?no=871232183987132082713;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:xchacha?871232183987132082713;en1e3kj3e31jn2algoritmgenerateddata')
});
it('[4] encode chacha12 with customized values', () => {
@@ -228,7 +226,7 @@ describe('encode uri with customized values', () => {
// nonce
no: '871232183987132082713'
}
- }).encoded).toEqual('encrypted:chacha12?no=871232183987132082713;en1e3kj3e31jn2algoritmgenerateddata')
+ }).encoded).toEqual('encrypted:chacha12?871232183987132082713;en1e3kj3e31jn2algoritmgenerateddata')
});
});
@@ -244,7 +242,7 @@ describe('uri matcher', () => {
});
it('[3] match valid encrypted uri', () => {
- expect(EncryptedURIParser.matcher('encrypted:aes/cbc?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata'))
+ expect(EncryptedURIParser.matcher('encrypted:?2345678wertyui;en1e3kj3e31jn2algoritmgenerateddata'))
.toEqual(true);
});
@@ -259,7 +257,7 @@ describe('uri matcher', () => {
});
it('[6] match valid encrypted uri', () => {
- expect(EncryptedURIParser.matcher('encrypted:aes/cbc?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata'))
+ expect(EncryptedURIParser.matcher('encrypted:?iv=2345678wertyui&pad=pkcs%237;en1e3kj3e31jn2algoritmgenerateddata'))
.toEqual(true);
});
@@ -345,15 +343,17 @@ describe('EncryptedURI object', () => {
});
});
-describe('EncryptedURI getKDFConfig', () => {
+describe('EncryptedURI kdf customization', () => {
it('[1] EncryptedURI get KDF config from KDF config', () => {
- const configs = EncryptedURI.getKDFConfig({
+ const configs = EncryptedURI.getKDFParams({
algorithm: 'aes/cbc',
content: 'mensagem secreta, favor não ler em voz alta',
password: 'senha123',
+ config: {
+ ignoreDefaults: false
+ },
kdf: {
kdf: 'pbkdf2',
- ignoreDefaults: false,
hasher: 'sha256',
rounds: 10,
derivateKeyLength: 32
@@ -362,7 +362,6 @@ describe('EncryptedURI getKDFConfig', () => {
expect(configs).toEqual({
kdf: 'pbkdf2',
- ignoreDefaults: false,
hasher: 'sha256',
rounds: 10,
derivateKeyLength: 32
@@ -370,9 +369,8 @@ describe('EncryptedURI getKDFConfig', () => {
});
-
it('[2] EncryptedURI get KDF config from decoded URI', () => {
- const configs = EncryptedURI.getKDFConfig({
+ const configs = EncryptedURI.getKDFParams({
algorithm: 'aes/cbc',
cipher: 'U2FsdGVkX18WeA03azX1tWETWsG/oSiQYzgI0en6RPgQ7Z2i9YbxCL3VcfzL6nsFo5Sdf0xF/UVatnJEehkcHQ==',
queryString: 'iv=44b9c510f05a8461c0ad153ba915d9dc&h=keccak_224',
@@ -384,12 +382,127 @@ describe('EncryptedURI getKDFConfig', () => {
expect(configs).toEqual({
kdf: 'pbkdf2',
- ignoreDefaults: true,
hasher: 'keccak_224',
rounds: 32,
derivateKeyLength: 32
});
-
+ });
+});
+
+describe('EncryptedURI configs of defaults', () => {
+ it('[1] EncryptedURI ignoreDefaults as false', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaults: false
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:aes/cbc?iv=2345678wertyui;cipherexample')
+ });
+
+ it('[2] EncryptedURI ignoreDefaults as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaults: true
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:?2345678wertyui;cipherexample')
+ });
+
+ it('[3] EncryptedURI ignoreDefaultAlgorithm as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: false,
+ ignoreMandatoryParamName: false
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:?iv=2345678wertyui;cipherexample')
});
+ it('[4] EncryptedURI ignoreDefaultValues as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaultAlgorithm: false,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: false
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:aes/cbc?iv=2345678wertyui;cipherexample')
+ });
+
+ it('[5] EncryptedURI ignoreMandatoryParamName as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaultAlgorithm: false,
+ ignoreDefaultValues: false,
+ ignoreMandatoryParamName: true
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:aes/cbc?2345678wertyui;cipherexample')
+ });
+
+ it('[6] EncryptedURI ignoreDefaultAlgorithm and ignoreDefaultValues as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: false
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:?iv=2345678wertyui;cipherexample')
+ });
+
+ it('[7] EncryptedURI ignoreDefaultAlgorithm and ignoreMandatoryParamName as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: false,
+ ignoreMandatoryParamName: true
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:?2345678wertyui;cipherexample')
+ });
+
+ it('[8] EncryptedURI ignoreDefaultValues and ignoreMandatoryParamName as true', () => {
+ expect(new EncryptedURIParser({
+ algorithm: 'aes/cbc',
+ cipher: 'cipherexample',
+ config: {
+ ignoreDefaultAlgorithm: false,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: true
+ },
+ params: {
+ iv: '2345678wertyui'
+ }
+ }).encoded).toEqual('encrypted:aes/cbc?2345678wertyui;cipherexample')
+ });
});
\ No newline at end of file
diff --git a/packages/core/index.ts b/packages/core/index.ts
index e694b23..1c7bf5a 100755
--- a/packages/core/index.ts
+++ b/packages/core/index.ts
@@ -11,28 +11,59 @@ export type TURIParams = {
[param: string]: string
};
-export type TEncryptedURIKDFConfig = {
-
+export type TEncryptedFullDefaultsConfig = {
/**
- * Only pbkdf2 supported, just if someone see purpose in alternative KDF,
- * if you need this come to me, open an issue
+ * If set as `true` and the choosen algorithm is aes/cbc,
+ * the algorithm name will be not included.
*
- * @default pbkdf2
+ * If set as `false` the algorithm will be always included.
+ *
+ * @default true
*/
- kdf?: 'pbkdf2',
+ ignoreDefaultAlgorithm?: boolean;
/**
- * Enableable just if `includeURIParams` is set as `true`.
+ * If set as `true` and there is only one mandatory param include
+ * in URI params, the attribute name will be not included, only
+ * the value.
*
- * If set as `true` ignore the param if the value is the default
- * value, include only non default params.
+ * If set as `false` the mandatory param name will be always included.
+ *
+ * @default true
+ */
+ ignoreMandatoryParamName?: boolean;
+
+ /**
+ * If set as `true` will not include params with default value set.
+ *
+ * If set as `false` will aways include all params, even if it is
+ * a default value.
+ *
+ * @default true
+ */
+ ignoreDefaultValues?: boolean;
+};
+
+export type TEncryptedDefaultsConfig = {
+ /**
+ * The value set will be replicated in the following configs:
+ * `ignoreDefaultAlgorithm`, `ignoreMandatoryParamName` and
+ * `ignoreDefaultValues`.
*
- * If set as `false` all included param in kdf object will be
- * include in URI with his reserved name.
- *
* @default true
*/
- ignoreDefaults?: boolean;
+ ignoreDefaults: boolean;
+} | TEncryptedFullDefaultsConfig;
+
+export type TEncryptedURIKDFParams = {
+
+ /**
+ * Only pbkdf2 supported, just if someone see purpose in alternative KDF,
+ * if you need this come to me, open an issue
+ *
+ * @default pbkdf2
+ */
+ kdf?: 'pbkdf2',
/**
* Hashing algorithm supported by pbkdf2
@@ -81,69 +112,6 @@ export type TEncryptedURI = {
class EncryptedURIDecoder {
- static getKDFConfig(
- /**
- * if you're decoding pass TEncryptedURI,
- * if you're encoding pass TEncryptedURIResultset
- *
- * @optional
- */
- kdfConfig?: TEncryptedURI | TEncryptedURIResultset
- ): Required {
- let config: TEncryptedURIKDFConfig = EncryptedURI.defaultConfigs;
- if (kdfConfig) {
- if ('kdf' in kdfConfig && kdfConfig.kdf) {
- config = kdfConfig.kdf;
- } else if (kdfConfig.params) {
- config = this.castParamsToConfig(kdfConfig.params);
- }
- }
-
- const configWithDefaults: Required = {
- ...EncryptedURI.defaultConfigs,
- ...config
- };
-
- return configWithDefaults;
- }
-
- private static castParamsToConfig(
- params?: TEncryptedURIParams
- ): TEncryptedURIKDFConfig {
- const config: TEncryptedURIKDFConfig = {};
-
- if (!params) {
- return config;
- }
-
- if (params.kdf === 'string') {
- config.kdf = params.kdf as 'pbkdf2';
- }
-
- if (typeof params.h === 'string') {
- config.hasher = params.h;
- }
-
- if (typeof params.dklen === 'string') {
- const derivateKeyLength = Number(params.dklen);
- if (Number.isSafeInteger(derivateKeyLength)) {
- // remove any quando issue for resolvido
- // https://github.com/antonioconselheiro/encrypted-uri/issues/31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- config.derivateKeyLength = derivateKeyLength as any;
- }
- }
-
- if (typeof params.c === 'string') {
- const rounds = Number(params.c);
- if (Number.isSafeInteger(rounds)) {
- config.rounds = rounds;
- }
- }
-
- return config;
- }
-
private readonly ENCRYPTED_URI_MATCHER = /^encrypted:/;
private readonly QUERY_STRING_MATCHER = /^\?[^;]*;/;
@@ -199,18 +167,22 @@ class EncryptedURIDecoder {
class EncryptedURIEncoder {
private static propertyShouldBeIgnored(
- configs: TEncryptedURIKDFConfig,
- configName: keyof TEncryptedURIKDFConfig
+ params: TEncryptedURIKDFParams,
+ paramName: keyof TEncryptedURIKDFParams,
+ config?: TEncryptedDefaultsConfig
): boolean {
- const configWithDefaults: Required = {
- ...EncryptedURI.defaultConfigs,
- ...configs
+ const paramWithDefaults: Required = {
+ ...EncryptedURI.defaultParams,
+ ...params
};
+ const configWithDefaults = EncryptedURI.getConfigsOfDefaults(config);
+
if (
- !configWithDefaults[configName] ||
- EncryptedURI.defaultConfigs[configName] === configWithDefaults[configName] &&
- configWithDefaults.ignoreDefaults
+ !paramWithDefaults[paramName] ||
+ configWithDefaults.ignoreDefaultValues &&
+ EncryptedURI.defaultParams[paramName] === paramWithDefaults[paramName]
+
) {
return true;
}
@@ -219,31 +191,34 @@ class EncryptedURIEncoder {
}
static castKDFConfigToParams(
- content: { kdf?: TEncryptedURIKDFConfig }
+ content: {
+ kdf?: TEncryptedURIKDFParams,
+ config?: TEncryptedDefaultsConfig
+ }
): TEncryptedURIParams {
const params: TEncryptedURIParams = {};
if (content.kdf) {
if (!this.propertyShouldBeIgnored(
- content.kdf, 'kdf'
+ content.kdf, 'kdf', content.config
)) {
params.kdf = content.kdf.kdf;
}
if (!this.propertyShouldBeIgnored(
- content.kdf, 'hasher'
+ content.kdf, 'hasher', content.config
)) {
params.h = content.kdf.hasher;
}
if (!this.propertyShouldBeIgnored(
- content.kdf, 'derivateKeyLength'
+ content.kdf, 'derivateKeyLength', content.config
)) {
params.dklen = String(content.kdf.derivateKeyLength);
}
if (!this.propertyShouldBeIgnored(
- content.kdf, 'rounds'
+ content.kdf, 'rounds', content.config
)) {
params.c = String(content.kdf.rounds);
}
@@ -252,7 +227,7 @@ class EncryptedURIEncoder {
return params;
}
- encode(content: TEncryptedURI & { kdf?: TEncryptedURIKDFConfig }): string {
+ encode(content: TEncryptedURI & { kdf?: TEncryptedURIKDFParams, config?: TEncryptedDefaultsConfig }): string {
const algorithm = this.encodeAlgorithm(content);
const parameters = this.encodeParameters(content);
@@ -264,13 +239,24 @@ class EncryptedURIEncoder {
}
private encodeParameters(
- content: TEncryptedURI & { kdf?: TEncryptedURIKDFConfig }
+ content: TEncryptedURI & {
+ kdf?: TEncryptedURIKDFParams,
+ config?: TEncryptedDefaultsConfig
+ }
): string {
const params: TURIParams = {};
const kdfParams = EncryptedURIEncoder.castKDFConfigToParams(content);
const contentParams: TURIParams = { ...content.params, ...kdfParams };
+ const config = EncryptedURI.getConfigsOfDefaults(content.config);
const paramsKeys = Object.keys(contentParams);
- if (paramsKeys.length) {
+
+ if (
+ config.ignoreMandatoryParamName &&
+ (paramsKeys[0] === 'iv' || paramsKeys[0] === 'no') &&
+ paramsKeys.length === 1
+ ) {
+ return contentParams[paramsKeys[0]];
+ } else if (paramsKeys.length) {
paramsKeys.forEach(key => params[key] = contentParams[key]);
} else {
return content.queryString || '';
@@ -283,8 +269,19 @@ class EncryptedURIEncoder {
}
private encodeAlgorithm(
- content: TEncryptedURI
+ content: TEncryptedURI & {
+ config?: TEncryptedDefaultsConfig
+ }
): string {
+ const config = EncryptedURI.getConfigsOfDefaults(content.config);
+
+ if (
+ config.ignoreDefaultAlgorithm &&
+ content.algorithm === EncryptedURI.defaultAlgotithm
+ ) {
+ return '';
+ }
+
return content.algorithm || '';
}
}
@@ -300,10 +297,12 @@ export class EncryptedURIParser {
constructor(content: string);
constructor(content: TEncryptedURI & {
- kdf?: TEncryptedURIKDFConfig | undefined;
+ kdf?: TEncryptedURIKDFParams;
+ config?: TEncryptedDefaultsConfig;
});
constructor(content: string | TEncryptedURI & {
- kdf?: TEncryptedURIKDFConfig | undefined;
+ kdf?: TEncryptedURIKDFParams;
+ config?: TEncryptedDefaultsConfig;
}) {
if (typeof content === 'string') {
const decoder = new EncryptedURIDecoder();
@@ -331,21 +330,21 @@ export abstract class EncryptedURIEncrypter<
export abstract class EncryptedURIDecrypter {
- protected kdf: Required;
+ protected kdf: Required;
constructor(
protected decoded: TEncryptedURI,
protected password: string
) {
- this.kdf = this.getKDFConfig(this.decoded);
+ this.kdf = this.getKDFParams(this.decoded);
}
abstract decrypt(): Promise;
- private getKDFConfig(
+ private getKDFParams(
kdfConfig: TEncryptedURI
- ): Required {
- return EncryptedURIDecoder.getKDFConfig(kdfConfig);
+ ): Required {
+ return EncryptedURI.getKDFParams(kdfConfig);
}
}
@@ -408,7 +407,7 @@ export type TEncryptedURIDefaultParams = {
* Customize the key derivation function params to open and to encrypt,
* you can configure in this object to include the kdf as URI params
*/
- kdf?: TEncryptedURIKDFConfig;
+ kdf?: TEncryptedURIKDFParams;
params?: TEncryptedURIParams;
};
@@ -416,10 +415,11 @@ export type TEncryptedURIDefaultParams = {
export type TEncryptedURIEncryptableDefaultParams = {
content: string;
password: string;
+ config?: TEncryptedDefaultsConfig;
} & TEncryptedURIDefaultParams;
export type TEncrypterClass = { new (resultset: TEncryptedURIResultset, ...args: any[]): EncryptedURIEncrypter } & { algorithm?: string };
-export type TDecrypterClass = { new (decoded: TEncryptedURI, password: string, kdf: Required, ...args: any[]): EncryptedURIDecrypter };
+export type TDecrypterClass = { new (decoded: TEncryptedURI, password: string, kdf: Required, ...args: any[]): EncryptedURIDecrypter };
export type TEncryptedURIResultset = TEncryptedURIEncryptableDefaultParams;
export function EncryptedURIAlgorithm(args: {
@@ -436,15 +436,14 @@ export function EncryptedURIAlgorithm(args: {
export class EncryptedURI {
- static readonly defaultConfigs: Required = {
+ static readonly defaultParams: Required = {
kdf: 'pbkdf2',
hasher: 'sha256',
- ignoreDefaults: true,
derivateKeyLength: 32,
rounds: 32
};
- static readonly defaultAlgotithm = 'aes';
+ static readonly defaultAlgotithm = 'aes/cbc';
static readonly supportedAlgorithm: {
[algorithm: string]: [
@@ -453,14 +452,94 @@ export class EncryptedURI {
]
} = { };
- static getKDFConfig(
- decoded?: TEncryptedURI | TEncryptedURIResultset
- ): Required {
- return EncryptedURIDecoder.getKDFConfig(decoded);
+ static getConfigsOfDefaults(config?: TEncryptedDefaultsConfig): Required {
+ const defaultConfigs: Required = {
+ ignoreDefaultAlgorithm: true,
+ ignoreDefaultValues: true,
+ ignoreMandatoryParamName: true
+ };
+
+ if (!config) {
+ return defaultConfigs;
+ } else if ('ignoreDefaults' in config) {
+ return {
+ ignoreDefaultAlgorithm: config.ignoreDefaults,
+ ignoreDefaultValues: config.ignoreDefaults,
+ ignoreMandatoryParamName: config.ignoreDefaults
+ };
+ } else {
+ return {
+ ...defaultConfigs,
+ ...config
+ };
+ }
+ }
+
+ static getKDFParams(
+ /**
+ * if you're decoding pass TEncryptedURI,
+ * if you're encoding pass TEncryptedURIResultset
+ *
+ * @optional
+ */
+ kdfParams?: TEncryptedURI | TEncryptedURIResultset
+ ): Required {
+ let params: TEncryptedURIKDFParams = EncryptedURI.defaultParams;
+ if (kdfParams) {
+ if ('kdf' in kdfParams && kdfParams.kdf) {
+ params = kdfParams.kdf;
+ } else if (kdfParams.params) {
+ params = EncryptedURI.castParamsToConfig(kdfParams.params);
+ }
+ }
+
+ const configWithDefaults: Required = {
+ ...EncryptedURI.defaultParams,
+ ...params
+ };
+
+ return configWithDefaults;
+ }
+
+ private static castParamsToConfig(
+ params?: TEncryptedURIParams
+ ): TEncryptedURIKDFParams {
+ const config: TEncryptedURIKDFParams = {};
+
+ if (!params) {
+ return config;
+ }
+
+ if (params.kdf === 'string') {
+ config.kdf = params.kdf as 'pbkdf2';
+ }
+
+ if (typeof params.h === 'string') {
+ config.hasher = params.h;
+ }
+
+ if (typeof params.dklen === 'string') {
+ const derivateKeyLength = Number(params.dklen);
+ if (Number.isSafeInteger(derivateKeyLength)) {
+ // remove any quando issue for resolvido
+ // https://github.com/antonioconselheiro/encrypted-uri/issues/31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ config.derivateKeyLength = derivateKeyLength as any;
+ }
+ }
+
+ if (typeof params.c === 'string') {
+ const rounds = Number(params.c);
+ if (Number.isSafeInteger(rounds)) {
+ config.rounds = rounds;
+ }
+ }
+
+ return config;
}
static castKDFConfigToParams(
- content: { kdf?: TEncryptedURIKDFConfig }
+ content: { kdf?: TEncryptedURIKDFParams }
): TEncryptedURIParams {
return EncryptedURIEncoder.castKDFConfigToParams(content);
}
@@ -470,7 +549,8 @@ export class EncryptedURI {
}
static encode(params: TEncryptedURI & {
- kdf?: TEncryptedURIKDFConfig | undefined;
+ kdf?: TEncryptedURIKDFParams;
+ config?: TEncryptedDefaultsConfig;
}): string {
return new EncryptedURIParser(params).encoded;
}
@@ -482,7 +562,11 @@ export class EncryptedURI {
const ciphred = await new encrypter(params, ...args).encrypt();
ciphred.algorithm = encrypter.algorithm || params.algorithm;
- return Promise.resolve(this.encode({ ...ciphred, kdf: params.kdf }));
+ return Promise.resolve(this.encode({
+ ...ciphred,
+ kdf: params.kdf,
+ config: params.config
+ }));
}
static decrypt(
@@ -492,8 +576,8 @@ export class EncryptedURI {
): Promise {
const uriDecoded = new EncryptedURIParser(uri).decoded;
const [ , decryptor ] = this.getAlgorithm(uriDecoded.algorithm);
- const kdfConfigs: Required = {
- ...EncryptedURI.defaultConfigs
+ const kdfConfigs: Required = {
+ ...EncryptedURI.defaultParams
};
return new decryptor(uriDecoded, password, kdfConfigs, ...args).decrypt();
}