{"record":{"id":"95f3dcf4c3152828","repo":"peass-ng/PEASS-ng","slug":"not-supported-for-sha-3","errorCode":null,"errorMessage":" not supported for SHA-3","messagePattern":" not supported for SHA-3","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/SHA3Digest.cs","lineNumber":26,"sourceCode":"    /// Implementation of SHA-3 based on following KeccakNISTInterface.c from http://keccak.noekeon.org/\n    /// </summary>\n    /// <remarks>\n    /// Following the naming conventions used in the C source code to enable easy review of the implementation.\n    /// </remarks>\n    public class Sha3Digest\n        : KeccakDigest\n    {\n        private static int CheckBitLength(int bitLength)\n        {\n            switch (bitLength)\n            {\n            case 224:\n            case 256:\n            case 384:\n            case 512:\n                return bitLength;\n            default:\n                throw new ArgumentException(bitLength + \" not supported for SHA-3\", \"bitLength\");\n            }\n        }\n\n        public Sha3Digest()\n            : this(256)\n        {\n        }\n\n        public Sha3Digest(int bitLength)\n            : base(CheckBitLength(bitLength))\n        {\n        }\n\n        public Sha3Digest(Sha3Digest source)\n            : base(source)\n        {\n        }\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/SHA3Digest.cs#L8-L44","documentation":"Sha3Digest.CheckBitLength throws ArgumentException when the constructor's bitLength is not one of the SHA-3 approved sizes: 224, 256, 384, or 512. The check validates the fixed output-size variants of SHA-3; other Keccak rates must use KeccakDigest directly. Raised from the Sha3Digest constructor.","triggerScenarios":"Calling `new Sha3Digest(bitLength)` with values like 128, 288, or a raw Keccak rate (e.g. 576, 1024).","commonSituations":"Confusing SHA-3 sizes with original Keccak sizes (Keccak supports 224/256/288/384/512 and arbitrary rates); deriving bit length from config without validation.","solutions":["Use one of the supported values: 224, 256, 384, or 512.","For non-standard rates, instantiate KeccakDigest directly instead of Sha3Digest.","Validate/normalize configured bit length before constructing the digest."],"exampleFix":"// before\nvar digest = new Sha3Digest(288); // throws\n// after\nvar digest = new Sha3Digest(256); // valid SHA-3 size\n// or for non-standard rates:\nvar keccak = new KeccakDigest(288);","handlingStrategy":"validation","validationCode":"static readonly int[] ValidSha3Sizes = { 224, 256, 384, 512 };\nif (!ValidSha3Sizes.Contains(bitLength))\n    throw new ArgumentOutOfRangeException(nameof(bitLength), $\"{bitLength} not supported for SHA-3; use 224/256/384/512\");\nvar digest = new Sha3Digest(bitLength);","typeGuard":"bool IsSha3Size(int bitLength) => bitLength is 224 or 256 or 384 or 512;","tryCatchPattern":"try { digest = new Sha3Digest(bitLength); } catch (ArgumentException ex) when (ex.ParamName == \"bitLength\") { digest = new Sha3Digest(256); // safe default }","preventionTips":["Map algorithm names to digest instances via a whitelist of {224,256,384,512}.","Use Sha3Digest only for standard SHA-3 sizes; use KeccakDigest for other rates.","Validate configured bit lengths at startup with a unit test over all config values."],"tags":["csharp","bouncycastle","sha3","argument-validation"],"backgroundTag":"unsupported-parameter-value","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}