{"record":{"id":"68e4fd1e6abae97d","repo":"peass-ng/PEASS-ng","slug":"basedigest-68e4fd","errorCode":null,"errorMessage":"baseDigest","messagePattern":"baseDigest","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/ShortenedDigest.cs","lineNumber":28,"sourceCode":"\t\t: IDigest\n\t{\n\t\tprivate IDigest\tbaseDigest;\n\t\tprivate int\t\tlength;\n\n\t\t/**\n\t\t* Base constructor.\n\t\t*\n\t\t* @param baseDigest underlying digest to use.\n\t\t* @param length length in bytes of the output of doFinal.\n\t\t* @exception ArgumentException if baseDigest is null, or length is greater than baseDigest.GetDigestSize().\n\t\t*/\n\t\tpublic ShortenedDigest(\n\t\t\tIDigest\tbaseDigest,\n\t\t\tint\t\tlength)\n\t\t{\n\t\t\tif (baseDigest == null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentNullException(\"baseDigest\");\n\t\t\t}\n\n\t\t\tif (length > baseDigest.GetDigestSize())\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"baseDigest output not large enough to support length\");\n\t\t\t}\n\n\t\t\tthis.baseDigest = baseDigest;\n\t\t\tthis.length = length;\n\t\t}\n\n\t\tpublic string AlgorithmName\n\t\t{\n\t\t\tget { return baseDigest.AlgorithmName + \"(\" + length * 8 + \")\"; }\n\t\t}\n\n\t\tpublic int GetDigestSize()\n\t\t{","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/digests/ShortenedDigest.cs#L10-L46","documentation":"Standard ArgumentNullException sentinel raised from the ShortenedDigest constructor when the baseDigest argument is null; the underlying digest is a required dependency, so construction cannot proceed.","triggerScenarios":"new ShortenedDigest(null, length), typically when the base digest is resolved from a lookup that returned null.","commonSituations":"Algorithm-name lookup (e.g. DigestUtilities.GetDigest failing or a dictionary miss) silently yielding null before wrapping.","solutions":["Pass a non-null IDigest instance.","Resolve the base digest via DigestUtilities.GetDigest and check for null/exceptions first.","Validate the algorithm name is supported before constructing."],"exampleFix":"// before\nvar d = new ShortenedDigest(registry[name], 16);\n// after\nIDigest baseDigest = registry[name] ?? new Sha256Digest();\nvar d = new ShortenedDigest(baseDigest, 16);","handlingStrategy":"type-guard","validationCode":"if (baseDigest is null) throw new ArgumentNullException(nameof(baseDigest));","typeGuard":"bool TryCreateShortened(IDigest baseDigest, int length, out ShortenedDigest shortened) { shortened = baseDigest is null ? null : new ShortenedDigest(baseDigest, length); return baseDigest != null; }","tryCatchPattern":"try { d = new ShortenedDigest(baseDigest, len); }\ncatch (ArgumentNullException) { d = new ShortenedDigest(new Sha256Digest(), len); }","preventionTips":["Check lookup results for null before wrapping.","Use pattern matching (baseDigest is IDigest d) to narrow.","Fail fast at config load when an algorithm name is unknown."],"tags":["csharp","null-argument","bouncycastle","hash"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}