Skip to content

Commit

Permalink
Remove last few incorrect shakeLen
Browse files Browse the repository at this point in the history
  • Loading branch information
Caligatio committed Apr 15, 2020
1 parent 04602a8 commit 4fe3ddc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/sha3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ declare class jsSHA extends jsSHABase<Int_64[][], VariantType> {
* Returns the the KMAC in the specified format.
*
* @param format The desired output formatting.
* @param options Hashmap of extra outputs options. `shakeLen` must be specified.
* @param options Hashmap of extra outputs options. `outputLen` must be specified.
* @returns The KMAC in the format specified.
*/
protected _getKMAC(options: {
Expand Down
2 changes: 1 addition & 1 deletion src/sha3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ export default class jsSHA extends jsSHABase<Int_64[][], VariantType> {
* Returns the the KMAC in the specified format.
*
* @param format The desired output formatting.
* @param options Hashmap of extra outputs options. `shakeLen` must be specified.
* @param options Hashmap of extra outputs options. `outputLen` must be specified.
* @returns The KMAC in the format specified.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
10 changes: 5 additions & 5 deletions test/src/test_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ describe("Test jsSHABase", () => {
assert.equal(stubbedJsSHA.getter("processedLen"), 64);
});

it("Test getHash Without Needed shakeLen ", () => {
it("Test getHash Without Needed outputLen ", () => {
const stubbedJsSHA = new jsSHAATest("SHA-TEST", "HEX");

stubbedJsSHA.setter("isVariableLen", true);
Expand Down Expand Up @@ -319,7 +319,7 @@ describe("Test jsSHABase", () => {
it("Test getHash for SHAKE", () => {
/*
* Check a few basic things:
* 1. The output of getHash should equal the first shakeLen bits of the output of finalizeFunc
* 1. The output of getHash should equal the first outputLen bits of the output of finalizeFunc
* 2. finalize should be called once with the correct inputs
*/
const stubbedJsSHA = new jsSHAATest("SHA-TEST", "HEX");
Expand All @@ -334,7 +334,7 @@ describe("Test jsSHABase", () => {
stubbedJsSHA.setter("processedLen", 64);

// Check #1
assert.equal(stubbedJsSHA.getHash("HEX", { shakeLen: 32 }), dummyVals[0].toString(16));
assert.equal(stubbedJsSHA.getHash("HEX", { outputLen: 32 }), dummyVals[0].toString(16));

// Check #2
assert.isTrue(stubbedFinalize.calledOnceWith([dummyVals[5]], 32, 64, [dummyVals[2], dummyVals[3]], 32));
Expand Down Expand Up @@ -362,15 +362,15 @@ describe("Test jsSHABase", () => {
* Check a few basic things:
* 1. The output of getHash should equal the output of last finalizeFunc call
* 2. finalizeFunc should be called numRound times
* 3. The last numRound-1 calls of finalizeFunc should have the last 32-shakeLen bits 0ed out
* 3. The last numRound-1 calls of finalizeFunc should have the last 32-outputLen bits 0ed out
*/
const stubbedJsSHA = new jsSHAATest("SHA-TEST", "HEX", { numRounds: 3 });
stubbedJsSHA.setter("isVariableLen", true);
sinon.reset();
stubbedFinalize.returns([dummyVals[0], dummyVals[1]]).onCall(2).returns([dummyVals[2], dummyVals[3]]);

// Check #1
assert.equal(stubbedJsSHA.getHash("HEX", { shakeLen: 24 }), dummyVals[2].toString(16).substr(0, 6));
assert.equal(stubbedJsSHA.getHash("HEX", { outputLen: 24 }), dummyVals[2].toString(16).substr(0, 6));

// Check #2
assert.equal(stubbedFinalize.callCount, 3);
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ describe("Test getOutputConverter", () => {
{ inputValue: "ARRAYBUFFER", funcName: "packed2arraybuffer", needsOptions: false },
{ inputValue: "UINT8ARRAY", funcName: "packed2uint8array", needsOptions: false },
],
options = { outputUpper: false, b64Pad: "", shakeLen: -1 };
options = { outputUpper: false, b64Pad: "", outputLen: -1 };

funcNameToInputValueMappings.forEach((mapping) => {
it(`${mapping.funcName} Mapping`, () => {
Expand Down

0 comments on commit 4fe3ddc

Please sign in to comment.