{"record":{"id":"816be322f5e1a430","repo":"peass-ng/PEASS-ng","slug":"invalid-blocksize-threefish-is-defined-with-bloc","errorCode":null,"errorMessage":"Invalid blocksize - Threefish is defined with block size of 256, 512, or 1024 bits","messagePattern":"Invalid blocksize - Threefish is defined with block size of 256, 512, or 1024 bits","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/ThreefishEngine.cs","lineNumber":145,"sourceCode":"\t\t\t/*\n\t         * Provide room for original key words, extended key word and repeat of key words for modulo\n\t         * free lookup of key schedule words.\n\t         */\n\t\t\tthis.kw = new ulong[2 * blocksizeWords + 1];\n\n\t\t\tswitch (blocksizeBits)\n\t\t\t{\n\t\t\t\tcase BLOCKSIZE_256:\n\t\t\t\t\tcipher = new Threefish256Cipher(kw, t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase BLOCKSIZE_512:\n\t\t\t\t\tcipher = new Threefish512Cipher(kw, t);\n\t\t\t\t\tbreak;\n\t\t\t\tcase BLOCKSIZE_1024:\n\t\t\t\t\tcipher = new Threefish1024Cipher(kw, t);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new ArgumentException(\n\t\t\t\t\t\t\"Invalid blocksize - Threefish is defined with block size of 256, 512, or 1024 bits\");\n\t\t\t}\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Initialise the engine.\n\t\t/// </summary>\n\t\t/// <param name=\"forEncryption\">Initialise for encryption if true, for decryption if false.</param>\n\t\t/// <param name=\"parameters\">an instance of <see cref=\"TweakableBlockCipherParameters\"/> or <see cref=\"KeyParameter\"/> (to\n\t\t///               use a 0 tweak)</param>\n\t\tpublic virtual void Init(bool forEncryption, ICipherParameters parameters)\n\t\t{\n\t\t\tbyte[] keyBytes;\n\t\t\tbyte[] tweakBytes;\n\n\t\t\tif (parameters is TweakableBlockCipherParameters)\n\t\t\t{\n\t\t\t\tTweakableBlockCipherParameters tParams = (TweakableBlockCipherParameters)parameters;","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/BouncyCastle/crypto/engines/ThreefishEngine.cs#L127-L163","documentation":"The ThreefishEngine constructor selects a cipher implementation based on the requested block size; only 256, 512 and 1024 bits are defined by the Threefish algorithm. Any other blocksize value reaches the default case and throws ArgumentException.","triggerScenarios":"Constructing ThreefishEngine with a blocksize argument other than BLOCKSIZE_256 (32), BLOCKSIZE_512 (64) or BLOCKSIZE_1024 (128) bytes — e.g. ThreefishEngine(16) or ThreefishEngine(0).","commonSituations":"Assuming Threefish supports AES-like 128-bit blocks; computing block size from an input key length (e.g. 128-bit key => 16 bytes); passing bits instead of bytes or vice versa.","solutions":["Instantiate with one of the supported sizes: new ThreefishEngine(ThreefishEngine.BLOCKSIZE_256), _512 or _1024","Derive block size from the intended key size (32, 64 or 128 bytes) and validate before constructing","Use the named constants rather than raw integers to avoid unit mistakes"],"exampleFix":"// before\nvar engine = new ThreefishEngine(16);\n// after\nvar engine = new ThreefishEngine(ThreefishEngine.BLOCKSIZE_256);","handlingStrategy":"validation","validationCode":"if (blockSizeBytes != 32 && blockSizeBytes != 64 && blockSizeBytes != 128)\n    throw new ArgumentException(\"Threefish block size must be 32, 64 or 128 bytes\");\nvar engine = new ThreefishEngine(blockSizeBytes);","typeGuard":"bool IsValidThreefishBlocksize(int bytes) => bytes == 32 || bytes == 64 || bytes == 128;","tryCatchPattern":"try { var engine = new ThreefishEngine(size); }\ncatch (ArgumentException ex) { /* map to supported variant or fail fast */ }","preventionTips":["Use the BLOCKSIZE_256/512/1024 constants instead of raw numbers","Derive the variant from the key length you actually have","Document that Threefish has no 128-bit block mode"],"tags":["csharp","cryptography","threefish","block-size"],"backgroundTag":"invalid-cipher-block-size","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}