{"record":{"id":"05a7ffeb572f9086","repo":"peass-ng/PEASS-ng","slug":"must-be-in-the-range-0-7-05a7ff","errorCode":null,"errorMessage":"must be in the range [0,7]","messagePattern":"must be in the range \\[0,7\\]","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/ShakeDigest.cs","lineNumber":88,"sourceCode":"\n            return outLen;\n        }\n\n        /*\n         * TODO Possible API change to support partial-byte suffixes.\n         */\n        protected override int DoFinal(byte[] output, int outOff, byte partialByte, int partialBits)\n        {\n            return DoFinal(output, outOff, GetDigestSize(), partialByte, partialBits);\n        }\n\n        /*\n         * TODO Possible API change to support partial-byte suffixes.\n         */\n        protected virtual int DoFinal(byte[] output, int outOff, int outLen, byte partialByte, int partialBits)\n        {\n            if (partialBits < 0 || partialBits > 7)\n                throw new ArgumentException(\"must be in the range [0,7]\", \"partialBits\");\n\n            int finalInput = (partialByte & ((1 << partialBits) - 1)) | (0x0F << partialBits);\n            Debug.Assert(finalInput >= 0);\n            int finalBits = partialBits + 4;\n\n            if (finalBits >= 8)\n            {\n                Absorb((byte)finalInput);\n                finalBits -= 8;\n                finalInput >>= 8;\n            }\n\n            if (finalBits > 0)\n            {\n                AbsorbBits(finalInput, finalBits);\n            }\n\n            Squeeze(output, outOff, (long)outLen << 3);","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/ShakeDigest.cs#L70-L106","documentation":"The extended DoFinal(output, outOff, outLen, partialByte, partialBits) supports appending a partial-byte suffix bits; partialBits must be 0-7 because only one partial byte can be encoded. The library throws ArgumentException('must be in the range [0,7]') otherwise.","triggerScenarios":"Calling the protected DoFinal overload (e.g. from a subclass or via TupleHash/ParallelHash) with partialBits < 0 or > 7, e.g. 8 or a negative leftover counter.","commonSituations":"Implementing a custom cSHAKE-style wrapper and mis-tracking how many leftover bits remain in the final byte.","solutions":["Pass partialBits in [0,7]; mask/normalize the bit count before the call.","Ensure partialByte only contains the low partialBits bits.","Use the simple DoFinal(output, outOff) overload if you have no partial-byte suffix."],"exampleFix":"// before\nDoFinal(output, outOff, outLen, partialByte, 8);\n// after\nDoFinal(output, outOff, outLen, partialByte & 0xFF, partialBits % 8);","handlingStrategy":"validation","validationCode":"if (partialBits < 0 || partialBits > 7) throw new ArgumentOutOfRangeException(nameof(partialBits));","typeGuard":"bool IsValidPartialBits(int partialBits) => (uint)partialBits <= 7;","tryCatchPattern":"try { DoFinal(output, outOff, outLen, partialByte, partialBits); }\ncatch (ArgumentException ex) when (ex.ParamName == \"partialBits\") { DoFinal(output, outOff, outLen, 0, 0); }","preventionTips":["Compute partialBits as (totalSuffixBits % 8) and keep the partial byte buffered separately.","Use the two-argument DoFinal when no partial-byte suffix is needed.","Unit-test custom XOF subclasses with 0..7 and out-of-range values."],"tags":["csharp","argument-validation","bouncycastle","shake","xof"],"backgroundTag":"invalid-hash-parameter","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}