diff --git a/.editorconfig b/.editorconfig index 565326214..29656fecb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,9 +8,12 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true -trim_trailing_whitespace = true indent_style = space indent_size = 2 +trim_trailing_whitespace = true + +[*.{pot,rule}] +trim_trailing_whitespace = false [Makefile] indent_style = tab diff --git a/BUILD.md b/BUILD.md index 333b8ec81..b552f48bc 100644 --- a/BUILD.md +++ b/BUILD.md @@ -3,7 +3,7 @@ hashcat build documentation ### Revision ### -* 1.5 +* 1.6 ### Author ### @@ -61,6 +61,10 @@ Otherwise: - Cached kernels go to: $HOME/.cache/hashcat - Potfiles go to: $HOME/.local/share/hashcat/ +### Building hashcat for Windows (using macOS) ### + +Refer to [BUILD_macOS.md](BUILD_macOS.md) + ### Building hashcat for Windows (using Windows Subsystem for Linux) ### Refer to [BUILD_WSL.md](BUILD_WSL.md) diff --git a/BUILD_macOS.md b/BUILD_macOS.md new file mode 100644 index 000000000..67d09a6bf --- /dev/null +++ b/BUILD_macOS.md @@ -0,0 +1,27 @@ +# Compiling hashcat for Windows with macOS. + +Tested on macOS 12.6.6 M1. + +Make sure to have the HomeBrew upgraded. + +### Installation ### + +``` +brew install mingw-w64 +git clone https://github.com/hashcat/hashcat +git clone https://github.com/win-iconv/win-iconv +cd win-iconv/ +patch < ../hashcat/tools/win-iconv-64.diff +sudo make install +cd ../ +``` + +### Building ### + +You've already cloned the latest master revision of hashcat repository above, so switch to the folder and type "make win" to start compiling hashcat +``` +cd hashcat/ +make win +``` + +The process may take a while, please be patient. diff --git a/OpenCL/inc_bignum_operations.cl b/OpenCL/inc_bignum_operations.cl index 8fedb292a..c10f17c76 100644 --- a/OpenCL/inc_bignum_operations.cl +++ b/OpenCL/inc_bignum_operations.cl @@ -1187,7 +1187,7 @@ DECLSPEC void mul_mod128 (PRIVATE_AS u32 *x, PRIVATE_AS const u32 *y, PRIVATE_AS t[62] += t[61] < p[125]; t[63] += t[62] < p[126]; - // VERY IMPORTANT: if we have an overflow at the highest u32, we need to do the substraction + // VERY IMPORTANT: if we have an overflow at the highest u32, we need to do the subtraction const u32 c = t[63] < p[127]; // carry / overflow diff --git a/OpenCL/inc_cipher_cast.h b/OpenCL/inc_cipher_cast.h new file mode 100644 index 000000000..86e59c07d --- /dev/null +++ b/OpenCL/inc_cipher_cast.h @@ -0,0 +1,732 @@ +/* + * CAST OpenCL + * + * Copyright (c) 2018, magnum. + * This software is hereby released to the general public under + * the following terms: Redistribution and use in source and binary + * forms, with or without modification, are permitted. + * + * Based on version in Truecrypt 7.1a sources + * Based on cast.cpp - written and placed in the public domain by + * Wei Dai and Leonard Janke + * Based on Steve Reid's public domain cast.c + * + * atom - changed S boxes from constant mem to shared mem + */ + +#ifndef _OPENCL_CAST_H +#define _OPENCL_CAST_H + +// #include "opencl_misc.h" +#define GET_UINT32BE(n, b, i) \ + { \ + (n) = ((uint) (b)[(i)] << 24) \ + | ((uint) (b)[(i) + 1] << 16) \ + | ((uint) (b)[(i) + 2] << 8) \ + | ((uint) (b)[(i) + 3] ); \ + } +#define PUT_UINT32BE(n, b, i) \ + { \ + (b)[(i) ] = (u8) ((n) >> 24); \ + (b)[(i) + 1] = (u8) ((n) >> 16); \ + (b)[(i) + 2] = (u8) ((n) >> 8); \ + (b)[(i) + 3] = (u8) ((n) ); \ + } + +typedef struct { + uint K[32]; +} CAST_KEY; + +#define GETBYTE(x, y) (uint)(u8)((x)>>(8*(y))) + +/* Macros to access 8-bit bytes out of a 32-bit word */ +#define U8a(x) GETBYTE(x,3) +#define U8b(x) GETBYTE(x,2) +#define U8c(x) GETBYTE(x,1) +#define U8d(x) GETBYTE(x,0) + +/* CAST S-boxes */ +CONSTANT_AS uint S[8][256] = { + { + 0x30FB40D4UL, 0x9FA0FF0BUL, 0x6BECCD2FUL, 0x3F258C7AUL, + 0x1E213F2FUL, 0x9C004DD3UL, 0x6003E540UL, 0xCF9FC949UL, + 0xBFD4AF27UL, 0x88BBBDB5UL, 0xE2034090UL, 0x98D09675UL, + 0x6E63A0E0UL, 0x15C361D2UL, 0xC2E7661DUL, 0x22D4FF8EUL, + 0x28683B6FUL, 0xC07FD059UL, 0xFF2379C8UL, 0x775F50E2UL, + 0x43C340D3UL, 0xDF2F8656UL, 0x887CA41AUL, 0xA2D2BD2DUL, + 0xA1C9E0D6UL, 0x346C4819UL, 0x61B76D87UL, 0x22540F2FUL, + 0x2ABE32E1UL, 0xAA54166BUL, 0x22568E3AUL, 0xA2D341D0UL, + 0x66DB40C8UL, 0xA784392FUL, 0x004DFF2FUL, 0x2DB9D2DEUL, + 0x97943FACUL, 0x4A97C1D8UL, 0x527644B7UL, 0xB5F437A7UL, + 0xB82CBAEFUL, 0xD751D159UL, 0x6FF7F0EDUL, 0x5A097A1FUL, + 0x827B68D0UL, 0x90ECF52EUL, 0x22B0C054UL, 0xBC8E5935UL, + 0x4B6D2F7FUL, 0x50BB64A2UL, 0xD2664910UL, 0xBEE5812DUL, + 0xB7332290UL, 0xE93B159FUL, 0xB48EE411UL, 0x4BFF345DUL, + 0xFD45C240UL, 0xAD31973FUL, 0xC4F6D02EUL, 0x55FC8165UL, + 0xD5B1CAADUL, 0xA1AC2DAEUL, 0xA2D4B76DUL, 0xC19B0C50UL, + 0x882240F2UL, 0x0C6E4F38UL, 0xA4E4BFD7UL, 0x4F5BA272UL, + 0x564C1D2FUL, 0xC59C5319UL, 0xB949E354UL, 0xB04669FEUL, + 0xB1B6AB8AUL, 0xC71358DDUL, 0x6385C545UL, 0x110F935DUL, + 0x57538AD5UL, 0x6A390493UL, 0xE63D37E0UL, 0x2A54F6B3UL, + 0x3A787D5FUL, 0x6276A0B5UL, 0x19A6FCDFUL, 0x7A42206AUL, + 0x29F9D4D5UL, 0xF61B1891UL, 0xBB72275EUL, 0xAA508167UL, + 0x38901091UL, 0xC6B505EBUL, 0x84C7CB8CUL, 0x2AD75A0FUL, + 0x874A1427UL, 0xA2D1936BUL, 0x2AD286AFUL, 0xAA56D291UL, + 0xD7894360UL, 0x425C750DUL, 0x93B39E26UL, 0x187184C9UL, + 0x6C00B32DUL, 0x73E2BB14UL, 0xA0BEBC3CUL, 0x54623779UL, + 0x64459EABUL, 0x3F328B82UL, 0x7718CF82UL, 0x59A2CEA6UL, + 0x04EE002EUL, 0x89FE78E6UL, 0x3FAB0950UL, 0x325FF6C2UL, + 0x81383F05UL, 0x6963C5C8UL, 0x76CB5AD6UL, 0xD49974C9UL, + 0xCA180DCFUL, 0x380782D5UL, 0xC7FA5CF6UL, 0x8AC31511UL, + 0x35E79E13UL, 0x47DA91D0UL, 0xF40F9086UL, 0xA7E2419EUL, + 0x31366241UL, 0x051EF495UL, 0xAA573B04UL, 0x4A805D8DUL, + 0x548300D0UL, 0x00322A3CUL, 0xBF64CDDFUL, 0xBA57A68EUL, + 0x75C6372BUL, 0x50AFD341UL, 0xA7C13275UL, 0x915A0BF5UL, + 0x6B54BFABUL, 0x2B0B1426UL, 0xAB4CC9D7UL, 0x449CCD82UL, + 0xF7FBF265UL, 0xAB85C5F3UL, 0x1B55DB94UL, 0xAAD4E324UL, + 0xCFA4BD3FUL, 0x2DEAA3E2UL, 0x9E204D02UL, 0xC8BD25ACUL, + 0xEADF55B3UL, 0xD5BD9E98UL, 0xE31231B2UL, 0x2AD5AD6CUL, + 0x954329DEUL, 0xADBE4528UL, 0xD8710F69UL, 0xAA51C90FUL, + 0xAA786BF6UL, 0x22513F1EUL, 0xAA51A79BUL, 0x2AD344CCUL, + 0x7B5A41F0UL, 0xD37CFBADUL, 0x1B069505UL, 0x41ECE491UL, + 0xB4C332E6UL, 0x032268D4UL, 0xC9600ACCUL, 0xCE387E6DUL, + 0xBF6BB16CUL, 0x6A70FB78UL, 0x0D03D9C9UL, 0xD4DF39DEUL, + 0xE01063DAUL, 0x4736F464UL, 0x5AD328D8UL, 0xB347CC96UL, + 0x75BB0FC3UL, 0x98511BFBUL, 0x4FFBCC35UL, 0xB58BCF6AUL, + 0xE11F0ABCUL, 0xBFC5FE4AUL, 0xA70AEC10UL, 0xAC39570AUL, + 0x3F04442FUL, 0x6188B153UL, 0xE0397A2EUL, 0x5727CB79UL, + 0x9CEB418FUL, 0x1CACD68DUL, 0x2AD37C96UL, 0x0175CB9DUL, + 0xC69DFF09UL, 0xC75B65F0UL, 0xD9DB40D8UL, 0xEC0E7779UL, + 0x4744EAD4UL, 0xB11C3274UL, 0xDD24CB9EUL, 0x7E1C54BDUL, + 0xF01144F9UL, 0xD2240EB1UL, 0x9675B3FDUL, 0xA3AC3755UL, + 0xD47C27AFUL, 0x51C85F4DUL, 0x56907596UL, 0xA5BB15E6UL, + 0x580304F0UL, 0xCA042CF1UL, 0x011A37EAUL, 0x8DBFAADBUL, + 0x35BA3E4AUL, 0x3526FFA0UL, 0xC37B4D09UL, 0xBC306ED9UL, + 0x98A52666UL, 0x5648F725UL, 0xFF5E569DUL, 0x0CED63D0UL, + 0x7C63B2CFUL, 0x700B45E1UL, 0xD5EA50F1UL, 0x85A92872UL, + 0xAF1FBDA7UL, 0xD4234870UL, 0xA7870BF3UL, 0x2D3B4D79UL, + 0x42E04198UL, 0x0CD0EDE7UL, 0x26470DB8UL, 0xF881814CUL, + 0x474D6AD7UL, 0x7C0C5E5CUL, 0xD1231959UL, 0x381B7298UL, + 0xF5D2F4DBUL, 0xAB838653UL, 0x6E2F1E23UL, 0x83719C9EUL, + 0xBD91E046UL, 0x9A56456EUL, 0xDC39200CUL, 0x20C8C571UL, + 0x962BDA1CUL, 0xE1E696FFUL, 0xB141AB08UL, 0x7CCA89B9UL, + 0x1A69E783UL, 0x02CC4843UL, 0xA2F7C579UL, 0x429EF47DUL, + 0x427B169CUL, 0x5AC9F049UL, 0xDD8F0F00UL, 0x5C8165BFUL + }, + + { + 0x1F201094UL, 0xEF0BA75BUL, 0x69E3CF7EUL, 0x393F4380UL, + 0xFE61CF7AUL, 0xEEC5207AUL, 0x55889C94UL, 0x72FC0651UL, + 0xADA7EF79UL, 0x4E1D7235UL, 0xD55A63CEUL, 0xDE0436BAUL, + 0x99C430EFUL, 0x5F0C0794UL, 0x18DCDB7DUL, 0xA1D6EFF3UL, + 0xA0B52F7BUL, 0x59E83605UL, 0xEE15B094UL, 0xE9FFD909UL, + 0xDC440086UL, 0xEF944459UL, 0xBA83CCB3UL, 0xE0C3CDFBUL, + 0xD1DA4181UL, 0x3B092AB1UL, 0xF997F1C1UL, 0xA5E6CF7BUL, + 0x01420DDBUL, 0xE4E7EF5BUL, 0x25A1FF41UL, 0xE180F806UL, + 0x1FC41080UL, 0x179BEE7AUL, 0xD37AC6A9UL, 0xFE5830A4UL, + 0x98DE8B7FUL, 0x77E83F4EUL, 0x79929269UL, 0x24FA9F7BUL, + 0xE113C85BUL, 0xACC40083UL, 0xD7503525UL, 0xF7EA615FUL, + 0x62143154UL, 0x0D554B63UL, 0x5D681121UL, 0xC866C359UL, + 0x3D63CF73UL, 0xCEE234C0UL, 0xD4D87E87UL, 0x5C672B21UL, + 0x071F6181UL, 0x39F7627FUL, 0x361E3084UL, 0xE4EB573BUL, + 0x602F64A4UL, 0xD63ACD9CUL, 0x1BBC4635UL, 0x9E81032DUL, + 0x2701F50CUL, 0x99847AB4UL, 0xA0E3DF79UL, 0xBA6CF38CUL, + 0x10843094UL, 0x2537A95EUL, 0xF46F6FFEUL, 0xA1FF3B1FUL, + 0x208CFB6AUL, 0x8F458C74UL, 0xD9E0A227UL, 0x4EC73A34UL, + 0xFC884F69UL, 0x3E4DE8DFUL, 0xEF0E0088UL, 0x3559648DUL, + 0x8A45388CUL, 0x1D804366UL, 0x721D9BFDUL, 0xA58684BBUL, + 0xE8256333UL, 0x844E8212UL, 0x128D8098UL, 0xFED33FB4UL, + 0xCE280AE1UL, 0x27E19BA5UL, 0xD5A6C252UL, 0xE49754BDUL, + 0xC5D655DDUL, 0xEB667064UL, 0x77840B4DUL, 0xA1B6A801UL, + 0x84DB26A9UL, 0xE0B56714UL, 0x21F043B7UL, 0xE5D05860UL, + 0x54F03084UL, 0x066FF472UL, 0xA31AA153UL, 0xDADC4755UL, + 0xB5625DBFUL, 0x68561BE6UL, 0x83CA6B94UL, 0x2D6ED23BUL, + 0xECCF01DBUL, 0xA6D3D0BAUL, 0xB6803D5CUL, 0xAF77A709UL, + 0x33B4A34CUL, 0x397BC8D6UL, 0x5EE22B95UL, 0x5F0E5304UL, + 0x81ED6F61UL, 0x20E74364UL, 0xB45E1378UL, 0xDE18639BUL, + 0x881CA122UL, 0xB96726D1UL, 0x8049A7E8UL, 0x22B7DA7BUL, + 0x5E552D25UL, 0x5272D237UL, 0x79D2951CUL, 0xC60D894CUL, + 0x488CB402UL, 0x1BA4FE5BUL, 0xA4B09F6BUL, 0x1CA815CFUL, + 0xA20C3005UL, 0x8871DF63UL, 0xB9DE2FCBUL, 0x0CC6C9E9UL, + 0x0BEEFF53UL, 0xE3214517UL, 0xB4542835UL, 0x9F63293CUL, + 0xEE41E729UL, 0x6E1D2D7CUL, 0x50045286UL, 0x1E6685F3UL, + 0xF33401C6UL, 0x30A22C95UL, 0x31A70850UL, 0x60930F13UL, + 0x73F98417UL, 0xA1269859UL, 0xEC645C44UL, 0x52C877A9UL, + 0xCDFF33A6UL, 0xA02B1741UL, 0x7CBAD9A2UL, 0x2180036FUL, + 0x50D99C08UL, 0xCB3F4861UL, 0xC26BD765UL, 0x64A3F6ABUL, + 0x80342676UL, 0x25A75E7BUL, 0xE4E6D1FCUL, 0x20C710E6UL, + 0xCDF0B680UL, 0x17844D3BUL, 0x31EEF84DUL, 0x7E0824E4UL, + 0x2CCB49EBUL, 0x846A3BAEUL, 0x8FF77888UL, 0xEE5D60F6UL, + 0x7AF75673UL, 0x2FDD5CDBUL, 0xA11631C1UL, 0x30F66F43UL, + 0xB3FAEC54UL, 0x157FD7FAUL, 0xEF8579CCUL, 0xD152DE58UL, + 0xDB2FFD5EUL, 0x8F32CE19UL, 0x306AF97AUL, 0x02F03EF8UL, + 0x99319AD5UL, 0xC242FA0FUL, 0xA7E3EBB0UL, 0xC68E4906UL, + 0xB8DA230CUL, 0x80823028UL, 0xDCDEF3C8UL, 0xD35FB171UL, + 0x088A1BC8UL, 0xBEC0C560UL, 0x61A3C9E8UL, 0xBCA8F54DUL, + 0xC72FEFFAUL, 0x22822E99UL, 0x82C570B4UL, 0xD8D94E89UL, + 0x8B1C34BCUL, 0x301E16E6UL, 0x273BE979UL, 0xB0FFEAA6UL, + 0x61D9B8C6UL, 0x00B24869UL, 0xB7FFCE3FUL, 0x08DC283BUL, + 0x43DAF65AUL, 0xF7E19798UL, 0x7619B72FUL, 0x8F1C9BA4UL, + 0xDC8637A0UL, 0x16A7D3B1UL, 0x9FC393B7UL, 0xA7136EEBUL, + 0xC6BCC63EUL, 0x1A513742UL, 0xEF6828BCUL, 0x520365D6UL, + 0x2D6A77ABUL, 0x3527ED4BUL, 0x821FD216UL, 0x095C6E2EUL, + 0xDB92F2FBUL, 0x5EEA29CBUL, 0x145892F5UL, 0x91584F7FUL, + 0x5483697BUL, 0x2667A8CCUL, 0x85196048UL, 0x8C4BACEAUL, + 0x833860D4UL, 0x0D23E0F9UL, 0x6C387E8AUL, 0x0AE6D249UL, + 0xB284600CUL, 0xD835731DUL, 0xDCB1C647UL, 0xAC4C56EAUL, + 0x3EBD81B3UL, 0x230EABB0UL, 0x6438BC87UL, 0xF0B5B1FAUL, + 0x8F5EA2B3UL, 0xFC184642UL, 0x0A036B7AUL, 0x4FB089BDUL, + 0x649DA589UL, 0xA345415EUL, 0x5C038323UL, 0x3E5D3BB9UL, + 0x43D79572UL, 0x7E6DD07CUL, 0x06DFDF1EUL, 0x6C6CC4EFUL, + 0x7160A539UL, 0x73BFBE70UL, 0x83877605UL, 0x4523ECF1UL + }, + + { + 0x8DEFC240UL, 0x25FA5D9FUL, 0xEB903DBFUL, 0xE810C907UL, + 0x47607FFFUL, 0x369FE44BUL, 0x8C1FC644UL, 0xAECECA90UL, + 0xBEB1F9BFUL, 0xEEFBCAEAUL, 0xE8CF1950UL, 0x51DF07AEUL, + 0x920E8806UL, 0xF0AD0548UL, 0xE13C8D83UL, 0x927010D5UL, + 0x11107D9FUL, 0x07647DB9UL, 0xB2E3E4D4UL, 0x3D4F285EUL, + 0xB9AFA820UL, 0xFADE82E0UL, 0xA067268BUL, 0x8272792EUL, + 0x553FB2C0UL, 0x489AE22BUL, 0xD4EF9794UL, 0x125E3FBCUL, + 0x21FFFCEEUL, 0x825B1BFDUL, 0x9255C5EDUL, 0x1257A240UL, + 0x4E1A8302UL, 0xBAE07FFFUL, 0x528246E7UL, 0x8E57140EUL, + 0x3373F7BFUL, 0x8C9F8188UL, 0xA6FC4EE8UL, 0xC982B5A5UL, + 0xA8C01DB7UL, 0x579FC264UL, 0x67094F31UL, 0xF2BD3F5FUL, + 0x40FFF7C1UL, 0x1FB78DFCUL, 0x8E6BD2C1UL, 0x437BE59BUL, + 0x99B03DBFUL, 0xB5DBC64BUL, 0x638DC0E6UL, 0x55819D99UL, + 0xA197C81CUL, 0x4A012D6EUL, 0xC5884A28UL, 0xCCC36F71UL, + 0xB843C213UL, 0x6C0743F1UL, 0x8309893CUL, 0x0FEDDD5FUL, + 0x2F7FE850UL, 0xD7C07F7EUL, 0x02507FBFUL, 0x5AFB9A04UL, + 0xA747D2D0UL, 0x1651192EUL, 0xAF70BF3EUL, 0x58C31380UL, + 0x5F98302EUL, 0x727CC3C4UL, 0x0A0FB402UL, 0x0F7FEF82UL, + 0x8C96FDADUL, 0x5D2C2AAEUL, 0x8EE99A49UL, 0x50DA88B8UL, + 0x8427F4A0UL, 0x1EAC5790UL, 0x796FB449UL, 0x8252DC15UL, + 0xEFBD7D9BUL, 0xA672597DUL, 0xADA840D8UL, 0x45F54504UL, + 0xFA5D7403UL, 0xE83EC305UL, 0x4F91751AUL, 0x925669C2UL, + 0x23EFE941UL, 0xA903F12EUL, 0x60270DF2UL, 0x0276E4B6UL, + 0x94FD6574UL, 0x927985B2UL, 0x8276DBCBUL, 0x02778176UL, + 0xF8AF918DUL, 0x4E48F79EUL, 0x8F616DDFUL, 0xE29D840EUL, + 0x842F7D83UL, 0x340CE5C8UL, 0x96BBB682UL, 0x93B4B148UL, + 0xEF303CABUL, 0x984FAF28UL, 0x779FAF9BUL, 0x92DC560DUL, + 0x224D1E20UL, 0x8437AA88UL, 0x7D29DC96UL, 0x2756D3DCUL, + 0x8B907CEEUL, 0xB51FD240UL, 0xE7C07CE3UL, 0xE566B4A1UL, + 0xC3E9615EUL, 0x3CF8209DUL, 0x6094D1E3UL, 0xCD9CA341UL, + 0x5C76460EUL, 0x00EA983BUL, 0xD4D67881UL, 0xFD47572CUL, + 0xF76CEDD9UL, 0xBDA8229CUL, 0x127DADAAUL, 0x438A074EUL, + 0x1F97C090UL, 0x081BDB8AUL, 0x93A07EBEUL, 0xB938CA15UL, + 0x97B03CFFUL, 0x3DC2C0F8UL, 0x8D1AB2ECUL, 0x64380E51UL, + 0x68CC7BFBUL, 0xD90F2788UL, 0x12490181UL, 0x5DE5FFD4UL, + 0xDD7EF86AUL, 0x76A2E214UL, 0xB9A40368UL, 0x925D958FUL, + 0x4B39FFFAUL, 0xBA39AEE9UL, 0xA4FFD30BUL, 0xFAF7933BUL, + 0x6D498623UL, 0x193CBCFAUL, 0x27627545UL, 0x825CF47AUL, + 0x61BD8BA0UL, 0xD11E42D1UL, 0xCEAD04F4UL, 0x127EA392UL, + 0x10428DB7UL, 0x8272A972UL, 0x9270C4A8UL, 0x127DE50BUL, + 0x285BA1C8UL, 0x3C62F44FUL, 0x35C0EAA5UL, 0xE805D231UL, + 0x428929FBUL, 0xB4FCDF82UL, 0x4FB66A53UL, 0x0E7DC15BUL, + 0x1F081FABUL, 0x108618AEUL, 0xFCFD086DUL, 0xF9FF2889UL, + 0x694BCC11UL, 0x236A5CAEUL, 0x12DECA4DUL, 0x2C3F8CC5UL, + 0xD2D02DFEUL, 0xF8EF5896UL, 0xE4CF52DAUL, 0x95155B67UL, + 0x494A488CUL, 0xB9B6A80CUL, 0x5C8F82BCUL, 0x89D36B45UL, + 0x3A609437UL, 0xEC00C9A9UL, 0x44715253UL, 0x0A874B49UL, + 0xD773BC40UL, 0x7C34671CUL, 0x02717EF6UL, 0x4FEB5536UL, + 0xA2D02FFFUL, 0xD2BF60C4UL, 0xD43F03C0UL, 0x50B4EF6DUL, + 0x07478CD1UL, 0x006E1888UL, 0xA2E53F55UL, 0xB9E6D4BCUL, + 0xA2048016UL, 0x97573833UL, 0xD7207D67UL, 0xDE0F8F3DUL, + 0x72F87B33UL, 0xABCC4F33UL, 0x7688C55DUL, 0x7B00A6B0UL, + 0x947B0001UL, 0x570075D2UL, 0xF9BB88F8UL, 0x8942019EUL, + 0x4264A5FFUL, 0x856302E0UL, 0x72DBD92BUL, 0xEE971B69UL, + 0x6EA22FDEUL, 0x5F08AE2BUL, 0xAF7A616DUL, 0xE5C98767UL, + 0xCF1FEBD2UL, 0x61EFC8C2UL, 0xF1AC2571UL, 0xCC8239C2UL, + 0x67214CB8UL, 0xB1E583D1UL, 0xB7DC3E62UL, 0x7F10BDCEUL, + 0xF90A5C38UL, 0x0FF0443DUL, 0x606E6DC6UL, 0x60543A49UL, + 0x5727C148UL, 0x2BE98A1DUL, 0x8AB41738UL, 0x20E1BE24UL, + 0xAF96DA0FUL, 0x68458425UL, 0x99833BE5UL, 0x600D457DUL, + 0x282F9350UL, 0x8334B362UL, 0xD91D1120UL, 0x2B6D8DA0UL, + 0x642B1E31UL, 0x9C305A00UL, 0x52BCE688UL, 0x1B03588AUL, + 0xF7BAEFD5UL, 0x4142ED9CUL, 0xA4315C11UL, 0x83323EC5UL, + 0xDFEF4636UL, 0xA133C501UL, 0xE9D3531CUL, 0xEE353783UL + }, + + { + 0x9DB30420UL, 0x1FB6E9DEUL, 0xA7BE7BEFUL, 0xD273A298UL, + 0x4A4F7BDBUL, 0x64AD8C57UL, 0x85510443UL, 0xFA020ED1UL, + 0x7E287AFFUL, 0xE60FB663UL, 0x095F35A1UL, 0x79EBF120UL, + 0xFD059D43UL, 0x6497B7B1UL, 0xF3641F63UL, 0x241E4ADFUL, + 0x28147F5FUL, 0x4FA2B8CDUL, 0xC9430040UL, 0x0CC32220UL, + 0xFDD30B30UL, 0xC0A5374FUL, 0x1D2D00D9UL, 0x24147B15UL, + 0xEE4D111AUL, 0x0FCA5167UL, 0x71FF904CUL, 0x2D195FFEUL, + 0x1A05645FUL, 0x0C13FEFEUL, 0x081B08CAUL, 0x05170121UL, + 0x80530100UL, 0xE83E5EFEUL, 0xAC9AF4F8UL, 0x7FE72701UL, + 0xD2B8EE5FUL, 0x06DF4261UL, 0xBB9E9B8AUL, 0x7293EA25UL, + 0xCE84FFDFUL, 0xF5718801UL, 0x3DD64B04UL, 0xA26F263BUL, + 0x7ED48400UL, 0x547EEBE6UL, 0x446D4CA0UL, 0x6CF3D6F5UL, + 0x2649ABDFUL, 0xAEA0C7F5UL, 0x36338CC1UL, 0x503F7E93UL, + 0xD3772061UL, 0x11B638E1UL, 0x72500E03UL, 0xF80EB2BBUL, + 0xABE0502EUL, 0xEC8D77DEUL, 0x57971E81UL, 0xE14F6746UL, + 0xC9335400UL, 0x6920318FUL, 0x081DBB99UL, 0xFFC304A5UL, + 0x4D351805UL, 0x7F3D5CE3UL, 0xA6C866C6UL, 0x5D5BCCA9UL, + 0xDAEC6FEAUL, 0x9F926F91UL, 0x9F46222FUL, 0x3991467DUL, + 0xA5BF6D8EUL, 0x1143C44FUL, 0x43958302UL, 0xD0214EEBUL, + 0x022083B8UL, 0x3FB6180CUL, 0x18F8931EUL, 0x281658E6UL, + 0x26486E3EUL, 0x8BD78A70UL, 0x7477E4C1UL, 0xB506E07CUL, + 0xF32D0A25UL, 0x79098B02UL, 0xE4EABB81UL, 0x28123B23UL, + 0x69DEAD38UL, 0x1574CA16UL, 0xDF871B62UL, 0x211C40B7UL, + 0xA51A9EF9UL, 0x0014377BUL, 0x041E8AC8UL, 0x09114003UL, + 0xBD59E4D2UL, 0xE3D156D5UL, 0x4FE876D5UL, 0x2F91A340UL, + 0x557BE8DEUL, 0x00EAE4A7UL, 0x0CE5C2ECUL, 0x4DB4BBA6UL, + 0xE756BDFFUL, 0xDD3369ACUL, 0xEC17B035UL, 0x06572327UL, + 0x99AFC8B0UL, 0x56C8C391UL, 0x6B65811CUL, 0x5E146119UL, + 0x6E85CB75UL, 0xBE07C002UL, 0xC2325577UL, 0x893FF4ECUL, + 0x5BBFC92DUL, 0xD0EC3B25UL, 0xB7801AB7UL, 0x8D6D3B24UL, + 0x20C763EFUL, 0xC366A5FCUL, 0x9C382880UL, 0x0ACE3205UL, + 0xAAC9548AUL, 0xECA1D7C7UL, 0x041AFA32UL, 0x1D16625AUL, + 0x6701902CUL, 0x9B757A54UL, 0x31D477F7UL, 0x9126B031UL, + 0x36CC6FDBUL, 0xC70B8B46UL, 0xD9E66A48UL, 0x56E55A79UL, + 0x026A4CEBUL, 0x52437EFFUL, 0x2F8F76B4UL, 0x0DF980A5UL, + 0x8674CDE3UL, 0xEDDA04EBUL, 0x17A9BE04UL, 0x2C18F4DFUL, + 0xB7747F9DUL, 0xAB2AF7B4UL, 0xEFC34D20UL, 0x2E096B7CUL, + 0x1741A254UL, 0xE5B6A035UL, 0x213D42F6UL, 0x2C1C7C26UL, + 0x61C2F50FUL, 0x6552DAF9UL, 0xD2C231F8UL, 0x25130F69UL, + 0xD8167FA2UL, 0x0418F2C8UL, 0x001A96A6UL, 0x0D1526ABUL, + 0x63315C21UL, 0x5E0A72ECUL, 0x49BAFEFDUL, 0x187908D9UL, + 0x8D0DBD86UL, 0x311170A7UL, 0x3E9B640CUL, 0xCC3E10D7UL, + 0xD5CAD3B6UL, 0x0CAEC388UL, 0xF73001E1UL, 0x6C728AFFUL, + 0x71EAE2A1UL, 0x1F9AF36EUL, 0xCFCBD12FUL, 0xC1DE8417UL, + 0xAC07BE6BUL, 0xCB44A1D8UL, 0x8B9B0F56UL, 0x013988C3UL, + 0xB1C52FCAUL, 0xB4BE31CDUL, 0xD8782806UL, 0x12A3A4E2UL, + 0x6F7DE532UL, 0x58FD7EB6UL, 0xD01EE900UL, 0x24ADFFC2UL, + 0xF4990FC5UL, 0x9711AAC5UL, 0x001D7B95UL, 0x82E5E7D2UL, + 0x109873F6UL, 0x00613096UL, 0xC32D9521UL, 0xADA121FFUL, + 0x29908415UL, 0x7FBB977FUL, 0xAF9EB3DBUL, 0x29C9ED2AUL, + 0x5CE2A465UL, 0xA730F32CUL, 0xD0AA3FE8UL, 0x8A5CC091UL, + 0xD49E2CE7UL, 0x0CE454A9UL, 0xD60ACD86UL, 0x015F1919UL, + 0x77079103UL, 0xDEA03AF6UL, 0x78A8565EUL, 0xDEE356DFUL, + 0x21F05CBEUL, 0x8B75E387UL, 0xB3C50651UL, 0xB8A5C3EFUL, + 0xD8EEB6D2UL, 0xE523BE77UL, 0xC2154529UL, 0x2F69EFDFUL, + 0xAFE67AFBUL, 0xF470C4B2UL, 0xF3E0EB5BUL, 0xD6CC9876UL, + 0x39E4460CUL, 0x1FDA8538UL, 0x1987832FUL, 0xCA007367UL, + 0xA99144F8UL, 0x296B299EUL, 0x492FC295UL, 0x9266BEABUL, + 0xB5676E69UL, 0x9BD3DDDAUL, 0xDF7E052FUL, 0xDB25701CUL, + 0x1B5E51EEUL, 0xF65324E6UL, 0x6AFCE36CUL, 0x0316CC04UL, + 0x8644213EUL, 0xB7DC59D0UL, 0x7965291FUL, 0xCCD6FD43UL, + 0x41823979UL, 0x932BCDF6UL, 0xB657C34DUL, 0x4EDFD282UL, + 0x7AE5290CUL, 0x3CB9536BUL, 0x851E20FEUL, 0x9833557EUL, + 0x13ECF0B0UL, 0xD3FFB372UL, 0x3F85C5C1UL, 0x0AEF7ED2UL + }, + + { + 0x7EC90C04UL, 0x2C6E74B9UL, 0x9B0E66DFUL, 0xA6337911UL, + 0xB86A7FFFUL, 0x1DD358F5UL, 0x44DD9D44UL, 0x1731167FUL, + 0x08FBF1FAUL, 0xE7F511CCUL, 0xD2051B00UL, 0x735ABA00UL, + 0x2AB722D8UL, 0x386381CBUL, 0xACF6243AUL, 0x69BEFD7AUL, + 0xE6A2E77FUL, 0xF0C720CDUL, 0xC4494816UL, 0xCCF5C180UL, + 0x38851640UL, 0x15B0A848UL, 0xE68B18CBUL, 0x4CAADEFFUL, + 0x5F480A01UL, 0x0412B2AAUL, 0x259814FCUL, 0x41D0EFE2UL, + 0x4E40B48DUL, 0x248EB6FBUL, 0x8DBA1CFEUL, 0x41A99B02UL, + 0x1A550A04UL, 0xBA8F65CBUL, 0x7251F4E7UL, 0x95A51725UL, + 0xC106ECD7UL, 0x97A5980AUL, 0xC539B9AAUL, 0x4D79FE6AUL, + 0xF2F3F763UL, 0x68AF8040UL, 0xED0C9E56UL, 0x11B4958BUL, + 0xE1EB5A88UL, 0x8709E6B0UL, 0xD7E07156UL, 0x4E29FEA7UL, + 0x6366E52DUL, 0x02D1C000UL, 0xC4AC8E05UL, 0x9377F571UL, + 0x0C05372AUL, 0x578535F2UL, 0x2261BE02UL, 0xD642A0C9UL, + 0xDF13A280UL, 0x74B55BD2UL, 0x682199C0UL, 0xD421E5ECUL, + 0x53FB3CE8UL, 0xC8ADEDB3UL, 0x28A87FC9UL, 0x3D959981UL, + 0x5C1FF900UL, 0xFE38D399UL, 0x0C4EFF0BUL, 0x062407EAUL, + 0xAA2F4FB1UL, 0x4FB96976UL, 0x90C79505UL, 0xB0A8A774UL, + 0xEF55A1FFUL, 0xE59CA2C2UL, 0xA6B62D27UL, 0xE66A4263UL, + 0xDF65001FUL, 0x0EC50966UL, 0xDFDD55BCUL, 0x29DE0655UL, + 0x911E739AUL, 0x17AF8975UL, 0x32C7911CUL, 0x89F89468UL, + 0x0D01E980UL, 0x524755F4UL, 0x03B63CC9UL, 0x0CC844B2UL, + 0xBCF3F0AAUL, 0x87AC36E9UL, 0xE53A7426UL, 0x01B3D82BUL, + 0x1A9E7449UL, 0x64EE2D7EUL, 0xCDDBB1DAUL, 0x01C94910UL, + 0xB868BF80UL, 0x0D26F3FDUL, 0x9342EDE7UL, 0x04A5C284UL, + 0x636737B6UL, 0x50F5B616UL, 0xF24766E3UL, 0x8ECA36C1UL, + 0x136E05DBUL, 0xFEF18391UL, 0xFB887A37UL, 0xD6E7F7D4UL, + 0xC7FB7DC9UL, 0x3063FCDFUL, 0xB6F589DEUL, 0xEC2941DAUL, + 0x26E46695UL, 0xB7566419UL, 0xF654EFC5UL, 0xD08D58B7UL, + 0x48925401UL, 0xC1BACB7FUL, 0xE5FF550FUL, 0xB6083049UL, + 0x5BB5D0E8UL, 0x87D72E5AUL, 0xAB6A6EE1UL, 0x223A66CEUL, + 0xC62BF3CDUL, 0x9E0885F9UL, 0x68CB3E47UL, 0x086C010FUL, + 0xA21DE820UL, 0xD18B69DEUL, 0xF3F65777UL, 0xFA02C3F6UL, + 0x407EDAC3UL, 0xCBB3D550UL, 0x1793084DUL, 0xB0D70EBAUL, + 0x0AB378D5UL, 0xD951FB0CUL, 0xDED7DA56UL, 0x4124BBE4UL, + 0x94CA0B56UL, 0x0F5755D1UL, 0xE0E1E56EUL, 0x6184B5BEUL, + 0x580A249FUL, 0x94F74BC0UL, 0xE327888EUL, 0x9F7B5561UL, + 0xC3DC0280UL, 0x05687715UL, 0x646C6BD7UL, 0x44904DB3UL, + 0x66B4F0A3UL, 0xC0F1648AUL, 0x697ED5AFUL, 0x49E92FF6UL, + 0x309E374FUL, 0x2CB6356AUL, 0x85808573UL, 0x4991F840UL, + 0x76F0AE02UL, 0x083BE84DUL, 0x28421C9AUL, 0x44489406UL, + 0x736E4CB8UL, 0xC1092910UL, 0x8BC95FC6UL, 0x7D869CF4UL, + 0x134F616FUL, 0x2E77118DUL, 0xB31B2BE1UL, 0xAA90B472UL, + 0x3CA5D717UL, 0x7D161BBAUL, 0x9CAD9010UL, 0xAF462BA2UL, + 0x9FE459D2UL, 0x45D34559UL, 0xD9F2DA13UL, 0xDBC65487UL, + 0xF3E4F94EUL, 0x176D486FUL, 0x097C13EAUL, 0x631DA5C7UL, + 0x445F7382UL, 0x175683F4UL, 0xCDC66A97UL, 0x70BE0288UL, + 0xB3CDCF72UL, 0x6E5DD2F3UL, 0x20936079UL, 0x459B80A5UL, + 0xBE60E2DBUL, 0xA9C23101UL, 0xEBA5315CUL, 0x224E42F2UL, + 0x1C5C1572UL, 0xF6721B2CUL, 0x1AD2FFF3UL, 0x8C25404EUL, + 0x324ED72FUL, 0x4067B7FDUL, 0x0523138EUL, 0x5CA3BC78UL, + 0xDC0FD66EUL, 0x75922283UL, 0x784D6B17UL, 0x58EBB16EUL, + 0x44094F85UL, 0x3F481D87UL, 0xFCFEAE7BUL, 0x77B5FF76UL, + 0x8C2302BFUL, 0xAAF47556UL, 0x5F46B02AUL, 0x2B092801UL, + 0x3D38F5F7UL, 0x0CA81F36UL, 0x52AF4A8AUL, 0x66D5E7C0UL, + 0xDF3B0874UL, 0x95055110UL, 0x1B5AD7A8UL, 0xF61ED5ADUL, + 0x6CF6E479UL, 0x20758184UL, 0xD0CEFA65UL, 0x88F7BE58UL, + 0x4A046826UL, 0x0FF6F8F3UL, 0xA09C7F70UL, 0x5346ABA0UL, + 0x5CE96C28UL, 0xE176EDA3UL, 0x6BAC307FUL, 0x376829D2UL, + 0x85360FA9UL, 0x17E3FE2AUL, 0x24B79767UL, 0xF5A96B20UL, + 0xD6CD2595UL, 0x68FF1EBFUL, 0x7555442CUL, 0xF19F06BEUL, + 0xF9E0659AUL, 0xEEB9491DUL, 0x34010718UL, 0xBB30CAB8UL, + 0xE822FE15UL, 0x88570983UL, 0x750E6249UL, 0xDA627E55UL, + 0x5E76FFA8UL, 0xB1534546UL, 0x6D47DE08UL, 0xEFE9E7D4UL + }, + + { + 0xF6FA8F9DUL, 0x2CAC6CE1UL, 0x4CA34867UL, 0xE2337F7CUL, + 0x95DB08E7UL, 0x016843B4UL, 0xECED5CBCUL, 0x325553ACUL, + 0xBF9F0960UL, 0xDFA1E2EDUL, 0x83F0579DUL, 0x63ED86B9UL, + 0x1AB6A6B8UL, 0xDE5EBE39UL, 0xF38FF732UL, 0x8989B138UL, + 0x33F14961UL, 0xC01937BDUL, 0xF506C6DAUL, 0xE4625E7EUL, + 0xA308EA99UL, 0x4E23E33CUL, 0x79CBD7CCUL, 0x48A14367UL, + 0xA3149619UL, 0xFEC94BD5UL, 0xA114174AUL, 0xEAA01866UL, + 0xA084DB2DUL, 0x09A8486FUL, 0xA888614AUL, 0x2900AF98UL, + 0x01665991UL, 0xE1992863UL, 0xC8F30C60UL, 0x2E78EF3CUL, + 0xD0D51932UL, 0xCF0FEC14UL, 0xF7CA07D2UL, 0xD0A82072UL, + 0xFD41197EUL, 0x9305A6B0UL, 0xE86BE3DAUL, 0x74BED3CDUL, + 0x372DA53CUL, 0x4C7F4448UL, 0xDAB5D440UL, 0x6DBA0EC3UL, + 0x083919A7UL, 0x9FBAEED9UL, 0x49DBCFB0UL, 0x4E670C53UL, + 0x5C3D9C01UL, 0x64BDB941UL, 0x2C0E636AUL, 0xBA7DD9CDUL, + 0xEA6F7388UL, 0xE70BC762UL, 0x35F29ADBUL, 0x5C4CDD8DUL, + 0xF0D48D8CUL, 0xB88153E2UL, 0x08A19866UL, 0x1AE2EAC8UL, + 0x284CAF89UL, 0xAA928223UL, 0x9334BE53UL, 0x3B3A21BFUL, + 0x16434BE3UL, 0x9AEA3906UL, 0xEFE8C36EUL, 0xF890CDD9UL, + 0x80226DAEUL, 0xC340A4A3UL, 0xDF7E9C09UL, 0xA694A807UL, + 0x5B7C5ECCUL, 0x221DB3A6UL, 0x9A69A02FUL, 0x68818A54UL, + 0xCEB2296FUL, 0x53C0843AUL, 0xFE893655UL, 0x25BFE68AUL, + 0xB4628ABCUL, 0xCF222EBFUL, 0x25AC6F48UL, 0xA9A99387UL, + 0x53BDDB65UL, 0xE76FFBE7UL, 0xE967FD78UL, 0x0BA93563UL, + 0x8E342BC1UL, 0xE8A11BE9UL, 0x4980740DUL, 0xC8087DFCUL, + 0x8DE4BF99UL, 0xA11101A0UL, 0x7FD37975UL, 0xDA5A26C0UL, + 0xE81F994FUL, 0x9528CD89UL, 0xFD339FEDUL, 0xB87834BFUL, + 0x5F04456DUL, 0x22258698UL, 0xC9C4C83BUL, 0x2DC156BEUL, + 0x4F628DAAUL, 0x57F55EC5UL, 0xE2220ABEUL, 0xD2916EBFUL, + 0x4EC75B95UL, 0x24F2C3C0UL, 0x42D15D99UL, 0xCD0D7FA0UL, + 0x7B6E27FFUL, 0xA8DC8AF0UL, 0x7345C106UL, 0xF41E232FUL, + 0x35162386UL, 0xE6EA8926UL, 0x3333B094UL, 0x157EC6F2UL, + 0x372B74AFUL, 0x692573E4UL, 0xE9A9D848UL, 0xF3160289UL, + 0x3A62EF1DUL, 0xA787E238UL, 0xF3A5F676UL, 0x74364853UL, + 0x20951063UL, 0x4576698DUL, 0xB6FAD407UL, 0x592AF950UL, + 0x36F73523UL, 0x4CFB6E87UL, 0x7DA4CEC0UL, 0x6C152DAAUL, + 0xCB0396A8UL, 0xC50DFE5DUL, 0xFCD707ABUL, 0x0921C42FUL, + 0x89DFF0BBUL, 0x5FE2BE78UL, 0x448F4F33UL, 0x754613C9UL, + 0x2B05D08DUL, 0x48B9D585UL, 0xDC049441UL, 0xC8098F9BUL, + 0x7DEDE786UL, 0xC39A3373UL, 0x42410005UL, 0x6A091751UL, + 0x0EF3C8A6UL, 0x890072D6UL, 0x28207682UL, 0xA9A9F7BEUL, + 0xBF32679DUL, 0xD45B5B75UL, 0xB353FD00UL, 0xCBB0E358UL, + 0x830F220AUL, 0x1F8FB214UL, 0xD372CF08UL, 0xCC3C4A13UL, + 0x8CF63166UL, 0x061C87BEUL, 0x88C98F88UL, 0x6062E397UL, + 0x47CF8E7AUL, 0xB6C85283UL, 0x3CC2ACFBUL, 0x3FC06976UL, + 0x4E8F0252UL, 0x64D8314DUL, 0xDA3870E3UL, 0x1E665459UL, + 0xC10908F0UL, 0x513021A5UL, 0x6C5B68B7UL, 0x822F8AA0UL, + 0x3007CD3EUL, 0x74719EEFUL, 0xDC872681UL, 0x073340D4UL, + 0x7E432FD9UL, 0x0C5EC241UL, 0x8809286CUL, 0xF592D891UL, + 0x08A930F6UL, 0x957EF305UL, 0xB7FBFFBDUL, 0xC266E96FUL, + 0x6FE4AC98UL, 0xB173ECC0UL, 0xBC60B42AUL, 0x953498DAUL, + 0xFBA1AE12UL, 0x2D4BD736UL, 0x0F25FAABUL, 0xA4F3FCEBUL, + 0xE2969123UL, 0x257F0C3DUL, 0x9348AF49UL, 0x361400BCUL, + 0xE8816F4AUL, 0x3814F200UL, 0xA3F94043UL, 0x9C7A54C2UL, + 0xBC704F57UL, 0xDA41E7F9UL, 0xC25AD33AUL, 0x54F4A084UL, + 0xB17F5505UL, 0x59357CBEUL, 0xEDBD15C8UL, 0x7F97C5ABUL, + 0xBA5AC7B5UL, 0xB6F6DEAFUL, 0x3A479C3AUL, 0x5302DA25UL, + 0x653D7E6AUL, 0x54268D49UL, 0x51A477EAUL, 0x5017D55BUL, + 0xD7D25D88UL, 0x44136C76UL, 0x0404A8C8UL, 0xB8E5A121UL, + 0xB81A928AUL, 0x60ED5869UL, 0x97C55B96UL, 0xEAEC991BUL, + 0x29935913UL, 0x01FDB7F1UL, 0x088E8DFAUL, 0x9AB6F6F5UL, + 0x3B4CBF9FUL, 0x4A5DE3ABUL, 0xE6051D35UL, 0xA0E1D855UL, + 0xD36B4CF1UL, 0xF544EDEBUL, 0xB0E93524UL, 0xBEBB8FBDUL, + 0xA2D762CFUL, 0x49C92F54UL, 0x38B5F331UL, 0x7128A454UL, + 0x48392905UL, 0xA65B1DB8UL, 0x851C97BDUL, 0xD675CF2FUL + }, + + { + 0x85E04019UL, 0x332BF567UL, 0x662DBFFFUL, 0xCFC65693UL, + 0x2A8D7F6FUL, 0xAB9BC912UL, 0xDE6008A1UL, 0x2028DA1FUL, + 0x0227BCE7UL, 0x4D642916UL, 0x18FAC300UL, 0x50F18B82UL, + 0x2CB2CB11UL, 0xB232E75CUL, 0x4B3695F2UL, 0xB28707DEUL, + 0xA05FBCF6UL, 0xCD4181E9UL, 0xE150210CUL, 0xE24EF1BDUL, + 0xB168C381UL, 0xFDE4E789UL, 0x5C79B0D8UL, 0x1E8BFD43UL, + 0x4D495001UL, 0x38BE4341UL, 0x913CEE1DUL, 0x92A79C3FUL, + 0x089766BEUL, 0xBAEEADF4UL, 0x1286BECFUL, 0xB6EACB19UL, + 0x2660C200UL, 0x7565BDE4UL, 0x64241F7AUL, 0x8248DCA9UL, + 0xC3B3AD66UL, 0x28136086UL, 0x0BD8DFA8UL, 0x356D1CF2UL, + 0x107789BEUL, 0xB3B2E9CEUL, 0x0502AA8FUL, 0x0BC0351EUL, + 0x166BF52AUL, 0xEB12FF82UL, 0xE3486911UL, 0xD34D7516UL, + 0x4E7B3AFFUL, 0x5F43671BUL, 0x9CF6E037UL, 0x4981AC83UL, + 0x334266CEUL, 0x8C9341B7UL, 0xD0D854C0UL, 0xCB3A6C88UL, + 0x47BC2829UL, 0x4725BA37UL, 0xA66AD22BUL, 0x7AD61F1EUL, + 0x0C5CBAFAUL, 0x4437F107UL, 0xB6E79962UL, 0x42D2D816UL, + 0x0A961288UL, 0xE1A5C06EUL, 0x13749E67UL, 0x72FC081AUL, + 0xB1D139F7UL, 0xF9583745UL, 0xCF19DF58UL, 0xBEC3F756UL, + 0xC06EBA30UL, 0x07211B24UL, 0x45C28829UL, 0xC95E317FUL, + 0xBC8EC511UL, 0x38BC46E9UL, 0xC6E6FA14UL, 0xBAE8584AUL, + 0xAD4EBC46UL, 0x468F508BUL, 0x7829435FUL, 0xF124183BUL, + 0x821DBA9FUL, 0xAFF60FF4UL, 0xEA2C4E6DUL, 0x16E39264UL, + 0x92544A8BUL, 0x009B4FC3UL, 0xABA68CEDUL, 0x9AC96F78UL, + 0x06A5B79AUL, 0xB2856E6EUL, 0x1AEC3CA9UL, 0xBE838688UL, + 0x0E0804E9UL, 0x55F1BE56UL, 0xE7E5363BUL, 0xB3A1F25DUL, + 0xF7DEBB85UL, 0x61FE033CUL, 0x16746233UL, 0x3C034C28UL, + 0xDA6D0C74UL, 0x79AAC56CUL, 0x3CE4E1ADUL, 0x51F0C802UL, + 0x98F8F35AUL, 0x1626A49FUL, 0xEED82B29UL, 0x1D382FE3UL, + 0x0C4FB99AUL, 0xBB325778UL, 0x3EC6D97BUL, 0x6E77A6A9UL, + 0xCB658B5CUL, 0xD45230C7UL, 0x2BD1408BUL, 0x60C03EB7UL, + 0xB9068D78UL, 0xA33754F4UL, 0xF430C87DUL, 0xC8A71302UL, + 0xB96D8C32UL, 0xEBD4E7BEUL, 0xBE8B9D2DUL, 0x7979FB06UL, + 0xE7225308UL, 0x8B75CF77UL, 0x11EF8DA4UL, 0xE083C858UL, + 0x8D6B786FUL, 0x5A6317A6UL, 0xFA5CF7A0UL, 0x5DDA0033UL, + 0xF28EBFB0UL, 0xF5B9C310UL, 0xA0EAC280UL, 0x08B9767AUL, + 0xA3D9D2B0UL, 0x79D34217UL, 0x021A718DUL, 0x9AC6336AUL, + 0x2711FD60UL, 0x438050E3UL, 0x069908A8UL, 0x3D7FEDC4UL, + 0x826D2BEFUL, 0x4EEB8476UL, 0x488DCF25UL, 0x36C9D566UL, + 0x28E74E41UL, 0xC2610ACAUL, 0x3D49A9CFUL, 0xBAE3B9DFUL, + 0xB65F8DE6UL, 0x92AEAF64UL, 0x3AC7D5E6UL, 0x9EA80509UL, + 0xF22B017DUL, 0xA4173F70UL, 0xDD1E16C3UL, 0x15E0D7F9UL, + 0x50B1B887UL, 0x2B9F4FD5UL, 0x625ABA82UL, 0x6A017962UL, + 0x2EC01B9CUL, 0x15488AA9UL, 0xD716E740UL, 0x40055A2CUL, + 0x93D29A22UL, 0xE32DBF9AUL, 0x058745B9UL, 0x3453DC1EUL, + 0xD699296EUL, 0x496CFF6FUL, 0x1C9F4986UL, 0xDFE2ED07UL, + 0xB87242D1UL, 0x19DE7EAEUL, 0x053E561AUL, 0x15AD6F8CUL, + 0x66626C1CUL, 0x7154C24CUL, 0xEA082B2AUL, 0x93EB2939UL, + 0x17DCB0F0UL, 0x58D4F2AEUL, 0x9EA294FBUL, 0x52CF564CUL, + 0x9883FE66UL, 0x2EC40581UL, 0x763953C3UL, 0x01D6692EUL, + 0xD3A0C108UL, 0xA1E7160EUL, 0xE4F2DFA6UL, 0x693ED285UL, + 0x74904698UL, 0x4C2B0EDDUL, 0x4F757656UL, 0x5D393378UL, + 0xA132234FUL, 0x3D321C5DUL, 0xC3F5E194UL, 0x4B269301UL, + 0xC79F022FUL, 0x3C997E7EUL, 0x5E4F9504UL, 0x3FFAFBBDUL, + 0x76F7AD0EUL, 0x296693F4UL, 0x3D1FCE6FUL, 0xC61E45BEUL, + 0xD3B5AB34UL, 0xF72BF9B7UL, 0x1B0434C0UL, 0x4E72B567UL, + 0x5592A33DUL, 0xB5229301UL, 0xCFD2A87FUL, 0x60AEB767UL, + 0x1814386BUL, 0x30BCC33DUL, 0x38A0C07DUL, 0xFD1606F2UL, + 0xC363519BUL, 0x589DD390UL, 0x5479F8E6UL, 0x1CB8D647UL, + 0x97FD61A9UL, 0xEA7759F4UL, 0x2D57539DUL, 0x569A58CFUL, + 0xE84E63ADUL, 0x462E1B78UL, 0x6580F87EUL, 0xF3817914UL, + 0x91DA55F4UL, 0x40A230F3UL, 0xD1988F35UL, 0xB6E318D2UL, + 0x3FFA50BCUL, 0x3D40F021UL, 0xC3C0BDAEUL, 0x4958C24CUL, + 0x518F36B2UL, 0x84B1D370UL, 0x0FEDCE83UL, 0x878DDADAUL, + 0xF2A279C7UL, 0x94E01BE8UL, 0x90716F4BUL, 0x954B8AA3UL + }, + + { + 0xE216300DUL, 0xBBDDFFFCUL, 0xA7EBDABDUL, 0x35648095UL, + 0x7789F8B7UL, 0xE6C1121BUL, 0x0E241600UL, 0x052CE8B5UL, + 0x11A9CFB0UL, 0xE5952F11UL, 0xECE7990AUL, 0x9386D174UL, + 0x2A42931CUL, 0x76E38111UL, 0xB12DEF3AUL, 0x37DDDDFCUL, + 0xDE9ADEB1UL, 0x0A0CC32CUL, 0xBE197029UL, 0x84A00940UL, + 0xBB243A0FUL, 0xB4D137CFUL, 0xB44E79F0UL, 0x049EEDFDUL, + 0x0B15A15DUL, 0x480D3168UL, 0x8BBBDE5AUL, 0x669DED42UL, + 0xC7ECE831UL, 0x3F8F95E7UL, 0x72DF191BUL, 0x7580330DUL, + 0x94074251UL, 0x5C7DCDFAUL, 0xABBE6D63UL, 0xAA402164UL, + 0xB301D40AUL, 0x02E7D1CAUL, 0x53571DAEUL, 0x7A3182A2UL, + 0x12A8DDECUL, 0xFDAA335DUL, 0x176F43E8UL, 0x71FB46D4UL, + 0x38129022UL, 0xCE949AD4UL, 0xB84769ADUL, 0x965BD862UL, + 0x82F3D055UL, 0x66FB9767UL, 0x15B80B4EUL, 0x1D5B47A0UL, + 0x4CFDE06FUL, 0xC28EC4B8UL, 0x57E8726EUL, 0x647A78FCUL, + 0x99865D44UL, 0x608BD593UL, 0x6C200E03UL, 0x39DC5FF6UL, + 0x5D0B00A3UL, 0xAE63AFF2UL, 0x7E8BD632UL, 0x70108C0CUL, + 0xBBD35049UL, 0x2998DF04UL, 0x980CF42AUL, 0x9B6DF491UL, + 0x9E7EDD53UL, 0x06918548UL, 0x58CB7E07UL, 0x3B74EF2EUL, + 0x522FFFB1UL, 0xD24708CCUL, 0x1C7E27CDUL, 0xA4EB215BUL, + 0x3CF1D2E2UL, 0x19B47A38UL, 0x424F7618UL, 0x35856039UL, + 0x9D17DEE7UL, 0x27EB35E6UL, 0xC9AFF67BUL, 0x36BAF5B8UL, + 0x09C467CDUL, 0xC18910B1UL, 0xE11DBF7BUL, 0x06CD1AF8UL, + 0x7170C608UL, 0x2D5E3354UL, 0xD4DE495AUL, 0x64C6D006UL, + 0xBCC0C62CUL, 0x3DD00DB3UL, 0x708F8F34UL, 0x77D51B42UL, + 0x264F620FUL, 0x24B8D2BFUL, 0x15C1B79EUL, 0x46A52564UL, + 0xF8D7E54EUL, 0x3E378160UL, 0x7895CDA5UL, 0x859C15A5UL, + 0xE6459788UL, 0xC37BC75FUL, 0xDB07BA0CUL, 0x0676A3ABUL, + 0x7F229B1EUL, 0x31842E7BUL, 0x24259FD7UL, 0xF8BEF472UL, + 0x835FFCB8UL, 0x6DF4C1F2UL, 0x96F5B195UL, 0xFD0AF0FCUL, + 0xB0FE134CUL, 0xE2506D3DUL, 0x4F9B12EAUL, 0xF215F225UL, + 0xA223736FUL, 0x9FB4C428UL, 0x25D04979UL, 0x34C713F8UL, + 0xC4618187UL, 0xEA7A6E98UL, 0x7CD16EFCUL, 0x1436876CUL, + 0xF1544107UL, 0xBEDEEE14UL, 0x56E9AF27UL, 0xA04AA441UL, + 0x3CF7C899UL, 0x92ECBAE6UL, 0xDD67016DUL, 0x151682EBUL, + 0xA842EEDFUL, 0xFDBA60B4UL, 0xF1907B75UL, 0x20E3030FUL, + 0x24D8C29EUL, 0xE139673BUL, 0xEFA63FB8UL, 0x71873054UL, + 0xB6F2CF3BUL, 0x9F326442UL, 0xCB15A4CCUL, 0xB01A4504UL, + 0xF1E47D8DUL, 0x844A1BE5UL, 0xBAE7DFDCUL, 0x42CBDA70UL, + 0xCD7DAE0AUL, 0x57E85B7AUL, 0xD53F5AF6UL, 0x20CF4D8CUL, + 0xCEA4D428UL, 0x79D130A4UL, 0x3486EBFBUL, 0x33D3CDDCUL, + 0x77853B53UL, 0x37EFFCB5UL, 0xC5068778UL, 0xE580B3E6UL, + 0x4E68B8F4UL, 0xC5C8B37EUL, 0x0D809EA2UL, 0x398FEB7CUL, + 0x132A4F94UL, 0x43B7950EUL, 0x2FEE7D1CUL, 0x223613BDUL, + 0xDD06CAA2UL, 0x37DF932BUL, 0xC4248289UL, 0xACF3EBC3UL, + 0x5715F6B7UL, 0xEF3478DDUL, 0xF267616FUL, 0xC148CBE4UL, + 0x9052815EUL, 0x5E410FABUL, 0xB48A2465UL, 0x2EDA7FA4UL, + 0xE87B40E4UL, 0xE98EA084UL, 0x5889E9E1UL, 0xEFD390FCUL, + 0xDD07D35BUL, 0xDB485694UL, 0x38D7E5B2UL, 0x57720101UL, + 0x730EDEBCUL, 0x5B643113UL, 0x94917E4FUL, 0x503C2FBAUL, + 0x646F1282UL, 0x7523D24AUL, 0xE0779695UL, 0xF9C17A8FUL, + 0x7A5B2121UL, 0xD187B896UL, 0x29263A4DUL, 0xBA510CDFUL, + 0x81F47C9FUL, 0xAD1163EDUL, 0xEA7B5965UL, 0x1A00726EUL, + 0x11403092UL, 0x00DA6D77UL, 0x4A0CDD61UL, 0xAD1F4603UL, + 0x605BDFB0UL, 0x9EEDC364UL, 0x22EBE6A8UL, 0xCEE7D28AUL, + 0xA0E736A0UL, 0x5564A6B9UL, 0x10853209UL, 0xC7EB8F37UL, + 0x2DE705CAUL, 0x8951570FUL, 0xDF09822BUL, 0xBD691A6CUL, + 0xAA12E4F2UL, 0x87451C0FUL, 0xE0F6A27AUL, 0x3ADA4819UL, + 0x4CF1764FUL, 0x0D771C2BUL, 0x67CDB156UL, 0x350D8384UL, + 0x5938FA0FUL, 0x42399EF3UL, 0x36997B07UL, 0x0E84093DUL, + 0x4AA93E61UL, 0x8360D87BUL, 0x1FA98B0CUL, 0x1149382CUL, + 0xE97625A5UL, 0x0614D1B7UL, 0x0E25244BUL, 0x0C768347UL, + 0x589E8D82UL, 0x0D2059D1UL, 0xA466BB1EUL, 0xF8DA0A82UL, + 0x04F19130UL, 0xBA6E4EC0UL, 0x99265164UL, 0x1EE7230DUL, + 0x50B2AD80UL, 0xEAEE6801UL, 0x8DB2A283UL, 0xEA8BF59EUL + } +}; + +/* CAST uses three different round functions */ +#define _CAST_f1(l, r, km, kr) \ + t = rotl32_S(km + r, kr); \ + l ^= ((s_S[0][U8a(t)] ^ s_S[1][U8b(t)]) - \ + s_S[2][U8c(t)]) + s_S[3][U8d(t)]; +#define _CAST_f2(l, r, km, kr) \ + t = rotl32_S(km ^ r, kr); \ + l ^= ((s_S[0][U8a(t)] - s_S[1][U8b(t)]) + \ + s_S[2][U8c(t)]) ^ s_S[3][U8d(t)]; +#define _CAST_f3(l, r, km, kr) \ + t = rotl32_S(km - r, kr); \ + l ^= ((s_S[0][U8a(t)] + s_S[1][U8b(t)]) ^ \ + s_S[2][U8c(t)]) - s_S[3][U8d(t)]; + +#define _CAST_F1(l, r, i, j) _CAST_f1(l, r, K[i], K[i+j]) +#define _CAST_F2(l, r, i, j) _CAST_f2(l, r, K[i], K[i+j]) +#define _CAST_F3(l, r, i, j) _CAST_f3(l, r, K[i], K[i+j]) + +inline void Cast5Encrypt(PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBlock, PRIVATE_AS CAST_KEY *key, SHM_TYPE u32 (*s_S)[256]) +{ + uint l; GET_UINT32BE(l, inBlock, 0); + uint r; GET_UINT32BE(r, inBlock, 4); + PRIVATE_AS uint *K = key->K; + uint t; + + /* Do the work */ + _CAST_F1(l, r, 0, 16); + _CAST_F2(r, l, 1, 16); + _CAST_F3(l, r, 2, 16); + _CAST_F1(r, l, 3, 16); + _CAST_F2(l, r, 4, 16); + _CAST_F3(r, l, 5, 16); + _CAST_F1(l, r, 6, 16); + _CAST_F2(r, l, 7, 16); + _CAST_F3(l, r, 8, 16); + _CAST_F1(r, l, 9, 16); + _CAST_F2(l, r, 10, 16); + _CAST_F3(r, l, 11, 16); + _CAST_F1(l, r, 12, 16); + _CAST_F2(r, l, 13, 16); + _CAST_F3(l, r, 14, 16); + _CAST_F1(r, l, 15, 16); + + /* Put l,r into outblock */ + PUT_UINT32BE(r, outBlock, 0); + PUT_UINT32BE(l, outBlock, 4); +} + +inline void Cast5Decrypt(PRIVATE_AS const u8 *inBlock, PRIVATE_AS u8 *outBlock, PRIVATE_AS CAST_KEY *key, SHM_TYPE u32 (*s_S)[256]) +{ + uint l; GET_UINT32BE(l, inBlock, 0); + uint r; GET_UINT32BE(r, inBlock, 4); + PRIVATE_AS uint *K = key->K; + uint t; + + /* Only do full 16 rounds if key length > 80 bits */ + _CAST_F1(r, l, 15, 16); + _CAST_F3(l, r, 14, 16); + _CAST_F2(r, l, 13, 16); + _CAST_F1(l, r, 12, 16); + _CAST_F3(r, l, 11, 16); + _CAST_F2(l, r, 10, 16); + _CAST_F1(r, l, 9, 16); + _CAST_F3(l, r, 8, 16); + _CAST_F2(r, l, 7, 16); + _CAST_F1(l, r, 6, 16); + _CAST_F3(r, l, 5, 16); + _CAST_F2(l, r, 4, 16); + _CAST_F1(r, l, 3, 16); + _CAST_F3(l, r, 2, 16); + _CAST_F2(r, l, 1, 16); + _CAST_F1(l, r, 0, 16); + /* Put l,r into outblock */ + PUT_UINT32BE(r, outBlock, 0); + PUT_UINT32BE(l, outBlock, 4); + /* Wipe clean */ + t = l = r = 0; +} + +inline void Cast5SetKey(PRIVATE_AS CAST_KEY *key, uint keylength, PRIVATE_AS const u8 *userKey, SHM_TYPE u32 (*s_S)[256]) +{ + uint i; + PRIVATE_AS uint *K = key->K; + uint X[4], Z[4]; + + GET_UINT32BE(X[0], userKey, 0); + GET_UINT32BE(X[1], userKey, 4); + GET_UINT32BE(X[2], userKey, 8); + GET_UINT32BE(X[3], userKey, 12); + +#define x(i) GETBYTE(X[i/4], 3-i%4) +#define z(i) GETBYTE(Z[i/4], 3-i%4) + + for (i=0; i<=16; i+=16) { + // this part is copied directly from RFC 2144 (with some search and replace) by Wei Dai + Z[0] = X[0] ^ s_S[4][x(0xD)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xE)] ^ s_S[6][x(0x8)]; + Z[1] = X[2] ^ s_S[4][z(0x0)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x3)] ^ s_S[7][x(0xA)]; + Z[2] = X[3] ^ s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[4][x(0x9)]; + Z[3] = X[1] ^ s_S[4][z(0xA)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0xB)] ^ s_S[7][z(0x8)] ^ s_S[5][x(0xB)]; + K[i+0] = s_S[4][z(0x8)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0x7)] ^ s_S[7][z(0x6)] ^ s_S[4][z(0x2)]; + K[i+1] = s_S[4][z(0xA)] ^ s_S[5][z(0xB)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[5][z(0x6)]; + K[i+2] = s_S[4][z(0xC)] ^ s_S[5][z(0xD)] ^ s_S[6][z(0x3)] ^ s_S[7][z(0x2)] ^ s_S[6][z(0x9)]; + K[i+3] = s_S[4][z(0xE)] ^ s_S[5][z(0xF)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x0)] ^ s_S[7][z(0xC)]; + X[0] = Z[2] ^ s_S[4][z(0x5)] ^ s_S[5][z(0x7)] ^ s_S[6][z(0x4)] ^ s_S[7][z(0x6)] ^ s_S[6][z(0x0)]; + X[1] = Z[0] ^ s_S[4][x(0x0)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x3)] ^ s_S[7][z(0x2)]; + X[2] = Z[1] ^ s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[4][z(0x1)]; + X[3] = Z[3] ^ s_S[4][x(0xA)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0xB)] ^ s_S[7][x(0x8)] ^ s_S[5][z(0x3)]; + K[i+4] = s_S[4][x(0x3)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xD)] ^ s_S[4][x(0x8)]; + K[i+5] = s_S[4][x(0x1)] ^ s_S[5][x(0x0)] ^ s_S[6][x(0xE)] ^ s_S[7][x(0xF)] ^ s_S[5][x(0xD)]; + K[i+6] = s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x8)] ^ s_S[7][x(0x9)] ^ s_S[6][x(0x3)]; + K[i+7] = s_S[4][x(0x5)] ^ s_S[5][x(0x4)] ^ s_S[6][x(0xA)] ^ s_S[7][x(0xB)] ^ s_S[7][x(0x7)]; + Z[0] = X[0] ^ s_S[4][x(0xD)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0xC)] ^ s_S[7][x(0xE)] ^ s_S[6][x(0x8)]; + Z[1] = X[2] ^ s_S[4][z(0x0)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0x1)] ^ s_S[7][z(0x3)] ^ s_S[7][x(0xA)]; + Z[2] = X[3] ^ s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x5)] ^ s_S[7][z(0x4)] ^ s_S[4][x(0x9)]; + Z[3] = X[1] ^ s_S[4][z(0xA)] ^ s_S[5][z(0x9)] ^ s_S[6][z(0xB)] ^ s_S[7][z(0x8)] ^ s_S[5][x(0xB)]; + K[i+8] = s_S[4][z(0x3)] ^ s_S[5][z(0x2)] ^ s_S[6][z(0xC)] ^ s_S[7][z(0xD)] ^ s_S[4][z(0x9)]; + K[i+9] = s_S[4][z(0x1)] ^ s_S[5][z(0x0)] ^ s_S[6][z(0xE)] ^ s_S[7][z(0xF)] ^ s_S[5][z(0xC)]; + K[i+10] = s_S[4][z(0x7)] ^ s_S[5][z(0x6)] ^ s_S[6][z(0x8)] ^ s_S[7][z(0x9)] ^ s_S[6][z(0x2)]; + K[i+11] = s_S[4][z(0x5)] ^ s_S[5][z(0x4)] ^ s_S[6][z(0xA)] ^ s_S[7][z(0xB)] ^ s_S[7][z(0x6)]; + X[0] = Z[2] ^ s_S[4][z(0x5)] ^ s_S[5][z(0x7)] ^ s_S[6][z(0x4)] ^ s_S[7][z(0x6)] ^ s_S[6][z(0x0)]; + X[1] = Z[0] ^ s_S[4][x(0x0)] ^ s_S[5][x(0x2)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x3)] ^ s_S[7][z(0x2)]; + X[2] = Z[1] ^ s_S[4][x(0x7)] ^ s_S[5][x(0x6)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[4][z(0x1)]; + X[3] = Z[3] ^ s_S[4][x(0xA)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0xB)] ^ s_S[7][x(0x8)] ^ s_S[5][z(0x3)]; + K[i+12] = s_S[4][x(0x8)] ^ s_S[5][x(0x9)] ^ s_S[6][x(0x7)] ^ s_S[7][x(0x6)] ^ s_S[4][x(0x3)]; + K[i+13] = s_S[4][x(0xA)] ^ s_S[5][x(0xB)] ^ s_S[6][x(0x5)] ^ s_S[7][x(0x4)] ^ s_S[5][x(0x7)]; + K[i+14] = s_S[4][x(0xC)] ^ s_S[5][x(0xD)] ^ s_S[6][x(0x3)] ^ s_S[7][x(0x2)] ^ s_S[6][x(0x8)]; + K[i+15] = s_S[4][x(0xE)] ^ s_S[5][x(0xF)] ^ s_S[6][x(0x1)] ^ s_S[7][x(0x0)] ^ s_S[7][x(0xD)]; + } + + uint data[32]; + for (i = 0; i < 16; i++) { + data[i * 2] = K[i]; + data[i * 2 + 1] = ((K[i + 16]) + 16) & 0x1f; // here only the lowest 5 bits are set.. + } + + for (i=16; i<32; i++) + K[i] &= 0x1f; +} + +/* OpenSSL API compatibility */ +#define CAST_set_key(ckey, len, key) Cast5SetKey(ckey, len, key) +#define CAST_ecb_encrypt(in, out, ckey) Cast5Encrypt(in, out, ckey) +#define CAST_ecb_decrypt(in, out, ckey) Cast5Decrypt(in, out, ckey) + + +#endif /* _OPENCL_CAST_H */ diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index 0de9924ef..8f1eab60a 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -1317,6 +1317,16 @@ DECLSPEC u64x hc_swap64 (const u64x v) asm volatile ("mov.b64 %0, {%1, %2};" : "=l"(r.sf) : "r"(tr.sf), "r"(tl.sf)); #endif + #elif defined IS_METAL + + const u32x a0 = h32_from_64 (v); + const u32x a1 = l32_from_64 (v); + + u32x t0 = hc_swap32 (a0); + u32x t1 = hc_swap32 (a1); + + r = hl32_to_64 (t1, t0); + #else #if defined USE_BITSELECT && defined USE_ROTATE @@ -1380,7 +1390,19 @@ DECLSPEC u64 hc_swap64_S (const u64 v) asm volatile ("prmt.b32 %0, %1, 0, 0x0123;" : "=r"(tr) : "r"(ir)); asm volatile ("mov.b64 %0, {%1, %2};" : "=l"(r) : "r"(tr), "r"(tl)); + + #elif defined IS_METAL + + const u32 v0 = h32_from_64_S (v); + const u32 v1 = l32_from_64_S (v); + + u32 t0 = hc_swap32_S (v0); + u32 t1 = hc_swap32_S (v1); + + r = hl32_to_64_S (t1, t0); + #else + #ifdef USE_SWIZZLE r = as_ulong (as_uchar8 (v).s76543210); #else diff --git a/OpenCL/inc_common.h b/OpenCL/inc_common.h index fd6cfb348..940e3b015 100644 --- a/OpenCL/inc_common.h +++ b/OpenCL/inc_common.h @@ -11,7 +11,7 @@ * * There are four variables where major differences occur: * - * - P2: Adress space of kernel_rules_t struct. + * - P2: Address space of kernel_rules_t struct. * If the kernel uses rules_buf, it will be stored in CONSTANT_AS. * If it does not, cheaper GLOBAL_AS space is used. * diff --git a/OpenCL/inc_ecc_secp256k1.cl b/OpenCL/inc_ecc_secp256k1.cl index d5cf37f56..4c5dd7ea8 100644 --- a/OpenCL/inc_ecc_secp256k1.cl +++ b/OpenCL/inc_ecc_secp256k1.cl @@ -2024,7 +2024,7 @@ DECLSPEC void point_mul (PRIVATE_AS u32 *r, PRIVATE_AS const u32 *k, SECP256K1_T * @param r out: x and y coordinates. * @param x in: x coordinate which should be converted, a pointer to an u32 array with a size of 8. * @param first_byte in: The parity of the y coordinate, a u32. - * @return Returns 0 if successfull, returns 1 if x is greater than the basepoint. + * @return Returns 0 if successful, returns 1 if x is greater than the basepoint. */ DECLSPEC u32 transform_public (PRIVATE_AS secp256k1_t *r, PRIVATE_AS const u32 *x, const u32 first_byte) { @@ -2084,7 +2084,7 @@ DECLSPEC u32 transform_public (PRIVATE_AS secp256k1_t *r, PRIVATE_AS const u32 * * Parse a x coordinate with leading parity to secp256k1_t. * @param r out: x and y coordinates. * @param k in: x coordinate which should be converted with leading parity, a pointer to an u32 array with a size of 9. - * @return Returns 0 if successfull, returns 1 if x is greater than the basepoint or the parity has an unexpected value. + * @return Returns 0 if successful, returns 1 if x is greater than the basepoint or the parity has an unexpected value. */ DECLSPEC u32 parse_public (PRIVATE_AS secp256k1_t *r, PRIVATE_AS const u32 *k) { diff --git a/OpenCL/inc_hash_blake2s.cl b/OpenCL/inc_hash_blake2s.cl index c10006068..5fb60f979 100644 --- a/OpenCL/inc_hash_blake2s.cl +++ b/OpenCL/inc_hash_blake2s.cl @@ -26,7 +26,7 @@ DECLSPEC u32 blake2s_rot16_S (const u32 a) DECLSPEC u32x blake2s_rot16 (const u32x a) { u32x r; - + #if VECT_SIZE == 1 r = blake2s_rot16_S (a); #endif @@ -346,7 +346,7 @@ DECLSPEC void blake2s_update (PRIVATE_AS blake2s_ctx_t *ctx, PRIVATE_AS const u3 w3[1] = w[pos4 + 13]; w3[2] = w[pos4 + 14]; w3[3] = w[pos4 + 15]; - + blake2s_update_64 (ctx, w0, w1, w2, w3, 64); } @@ -447,11 +447,11 @@ DECLSPEC void blake2s_transform_vector (PRIVATE_AS u32x *h, PRIVATE_AS const u32 v[ 9] = BLAKE2S_IV_01; v[10] = BLAKE2S_IV_02; v[11] = BLAKE2S_IV_03; - v[12] = BLAKE2S_IV_04 ^ t0; + v[12] = make_u32x (BLAKE2S_IV_04) ^ t0; v[13] = BLAKE2S_IV_05; // ^ t1; v[14] = BLAKE2S_IV_06 ^ f0; v[15] = BLAKE2S_IV_07; // ^ f1; - + BLAKE2S_ROUND_VECTOR ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); BLAKE2S_ROUND_VECTOR (14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3); BLAKE2S_ROUND_VECTOR (11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4); diff --git a/OpenCL/inc_hash_sm3.cl b/OpenCL/inc_hash_sm3.cl index f2d53dc72..4fb51b9e0 100644 --- a/OpenCL/inc_hash_sm3.cl +++ b/OpenCL/inc_hash_sm3.cl @@ -41,7 +41,7 @@ DECLSPEC void sm3_transform (PRIVATE_AS const u32 *w0, PRIVATE_AS const u32 *w1, u32 wd_t = w3[1]; u32 we_t = w3[2]; u32 wf_t = w3[3]; - + // SM3 main loop, composed of 64 rounds (0 to 63). // The Compression Function (CF) and Message Expansion (ME) are executed step-by-step. // SM3_ROUND1_S use SM3_FF0 and SM3_GG0 functions for index 0 to 15 and SM3_ROUND2_S use SM3_FF1 and SM3_GG1 functions for index 16 to 63. @@ -93,7 +93,7 @@ DECLSPEC void sm3_transform (PRIVATE_AS const u32 *w0, PRIVATE_AS const u32 *w1, wc_t = SM3_EXPAND_S(wc_t, w3_t, w9_t, wf_t, w6_t); SM3_ROUND2_S(a, b, c, d, e, f, g, h, SM3_T40, w8_t, w8_t ^ wc_t); wd_t = SM3_EXPAND_S(wd_t, w4_t, wa_t, w0_t, w7_t); SM3_ROUND2_S(d, a, b, c, h, e, f, g, SM3_T41, w9_t, w9_t ^ wd_t); we_t = SM3_EXPAND_S(we_t, w5_t, wb_t, w1_t, w8_t); SM3_ROUND2_S(c, d, a, b, g, h, e, f, SM3_T42, wa_t, wa_t ^ we_t); - wf_t = SM3_EXPAND_S(wf_t, w6_t, wc_t, w2_t, w9_t); SM3_ROUND2_S(b, c, d, a, f, g, h, e, SM3_T43, wb_t, wb_t ^ wf_t); + wf_t = SM3_EXPAND_S(wf_t, w6_t, wc_t, w2_t, w9_t); SM3_ROUND2_S(b, c, d, a, f, g, h, e, SM3_T43, wb_t, wb_t ^ wf_t); w0_t = SM3_EXPAND_S(w0_t, w7_t, wd_t, w3_t, wa_t); SM3_ROUND2_S(a, b, c, d, e, f, g, h, SM3_T44, wc_t, wc_t ^ w0_t); w1_t = SM3_EXPAND_S(w1_t, w8_t, we_t, w4_t, wb_t); SM3_ROUND2_S(d, a, b, c, h, e, f, g, SM3_T45, wd_t, wd_t ^ w1_t); w2_t = SM3_EXPAND_S(w2_t, w9_t, wf_t, w5_t, wc_t); SM3_ROUND2_S(c, d, a, b, g, h, e, f, SM3_T46, we_t, we_t ^ w2_t); @@ -928,7 +928,7 @@ DECLSPEC void sm3_final (PRIVATE_AS sm3_ctx_t *ctx) const int pos = ctx->len & 63; append_0x80_4x4_S (ctx->w0, ctx->w1, ctx->w2, ctx->w3, pos ^ 3); - + if (pos >= 56) { sm3_transform (ctx->w0, ctx->w1, ctx->w2, ctx->w3, ctx->h); @@ -986,7 +986,7 @@ DECLSPEC void sm3_transform_vector (PRIVATE_AS const u32x *w0, PRIVATE_AS const u32x wd_t = w3[1]; u32x we_t = w3[2]; u32x wf_t = w3[3]; - + // SM3 main loop, composed of 64 rounds (0 to 63). // The Compression Function (CF) and Message Expansion (ME) are executed step-by-step. // SM3_ROUND1 use SM3_FF0 and SM3_GG0 functions for index 0 to 15 and SM3_ROUND2 use SM3_FF1 and SM3_GG1 functions for index 16 to 63. @@ -1038,7 +1038,7 @@ DECLSPEC void sm3_transform_vector (PRIVATE_AS const u32x *w0, PRIVATE_AS const wc_t = SM3_EXPAND(wc_t, w3_t, w9_t, wf_t, w6_t); SM3_ROUND2(a, b, c, d, e, f, g, h, SM3_T40, w8_t, w8_t ^ wc_t); wd_t = SM3_EXPAND(wd_t, w4_t, wa_t, w0_t, w7_t); SM3_ROUND2(d, a, b, c, h, e, f, g, SM3_T41, w9_t, w9_t ^ wd_t); we_t = SM3_EXPAND(we_t, w5_t, wb_t, w1_t, w8_t); SM3_ROUND2(c, d, a, b, g, h, e, f, SM3_T42, wa_t, wa_t ^ we_t); - wf_t = SM3_EXPAND(wf_t, w6_t, wc_t, w2_t, w9_t); SM3_ROUND2(b, c, d, a, f, g, h, e, SM3_T43, wb_t, wb_t ^ wf_t); + wf_t = SM3_EXPAND(wf_t, w6_t, wc_t, w2_t, w9_t); SM3_ROUND2(b, c, d, a, f, g, h, e, SM3_T43, wb_t, wb_t ^ wf_t); w0_t = SM3_EXPAND(w0_t, w7_t, wd_t, w3_t, wa_t); SM3_ROUND2(a, b, c, d, e, f, g, h, SM3_T44, wc_t, wc_t ^ w0_t); w1_t = SM3_EXPAND(w1_t, w8_t, we_t, w4_t, wb_t); SM3_ROUND2(d, a, b, c, h, e, f, g, SM3_T45, wd_t, wd_t ^ w1_t); w2_t = SM3_EXPAND(w2_t, w9_t, wf_t, w5_t, wc_t); SM3_ROUND2(c, d, a, b, g, h, e, f, SM3_T46, we_t, we_t ^ w2_t); diff --git a/OpenCL/inc_types.h b/OpenCL/inc_types.h index 63dc5815d..4d7b937d5 100644 --- a/OpenCL/inc_types.h +++ b/OpenCL/inc_types.h @@ -112,6 +112,15 @@ typedef u64 u64x; #if defined IS_CUDA || defined IS_HIP +#ifndef __device_builtin__ +#define __device_builtin__ +#endif + +#ifndef __builtin_align__ +#define __builtin_align__(x) +#endif + + #if VECT_SIZE == 2 struct __device_builtin__ __builtin_align__(2) u8x diff --git a/OpenCL/m02630_a0-optimized.cl b/OpenCL/m02630_a0-optimized.cl new file mode 100644 index 000000000..ceb71f299 --- /dev/null +++ b/OpenCL/m02630_a0-optimized.cl @@ -0,0 +1,744 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m02630_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + + const u32x pw_salt_len = out_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * md5 + */ + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = pw_salt_len * 8; + u32x wf_t = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w8_t = 0x80; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 32 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m02630_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m02630_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m02630_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + + const u32x pw_salt_len = out_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * md5 + */ + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = pw_salt_len * 8; + u32x wf_t = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w8_t = 0x80; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 32 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m02630_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m02630_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m02630_a0-pure.cl b/OpenCL/m02630_a0-pure.cl new file mode 100644 index 000000000..6c691a526 --- /dev/null +++ b/OpenCL/m02630_a0-pure.cl @@ -0,0 +1,259 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m02630_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_update (&ctx0, s, salt_len); + + md5_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + ctx.w2[0] = 0x80; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 32 * 8; + ctx.w3[3] = 0; + + md5_transform (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m02630_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_update (&ctx0, s, salt_len); + + md5_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + ctx.w2[0] = 0x80; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 32 * 8; + ctx.w3[3] = 0; + + md5_transform (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m02630_a1-optimized.cl b/OpenCL/m02630_a1-optimized.cl new file mode 100644 index 000000000..7f6971c8d --- /dev/null +++ b/OpenCL/m02630_a1-optimized.cl @@ -0,0 +1,862 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m02630_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * md5 + */ + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = pw_salt_len * 8; + u32x wf_t = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w8_t = 0x80; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 32 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m02630_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m02630_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m02630_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * md5 + */ + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = pw_salt_len * 8; + u32x wf_t = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w8_t = 0x80; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 32 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m02630_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m02630_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m02630_a1-pure.cl b/OpenCL/m02630_a1-pure.cl new file mode 100644 index 000000000..1157dd7d7 --- /dev/null +++ b/OpenCL/m02630_a1-pure.cl @@ -0,0 +1,257 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m02630_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx1, s, salt_len); + + md5_final (&ctx1); + + const u32 a = ctx1.h[0]; + const u32 b = ctx1.h[1]; + const u32 c = ctx1.h[2]; + const u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.len = 32; + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + ctx.w2[0] = 0x80; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 32 * 8; + ctx.w3[3] = 0; + + md5_transform (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m02630_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_update (&ctx1, s, salt_len); + + md5_final (&ctx1); + + const u32 a = ctx1.h[0]; + const u32 b = ctx1.h[1]; + const u32 c = ctx1.h[2]; + const u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.len = 32; + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + ctx.w2[0] = 0x80; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 32 * 8; + ctx.w3[3] = 0; + + md5_transform (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m02630_a3-optimized.cl b/OpenCL/m02630_a3-optimized.cl new file mode 100644 index 000000000..aa12d6a94 --- /dev/null +++ b/OpenCL/m02630_a3-optimized.cl @@ -0,0 +1,1063 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +DECLSPEC void m02630m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + /** + * append salt + */ + + u32 salt_buf0_t[4]; + u32 salt_buf1_t[4]; + u32 salt_buf2_t[4]; + u32 salt_buf3_t[4]; + + salt_buf0_t[0] = salt_buf0[0]; + salt_buf0_t[1] = salt_buf0[1]; + salt_buf0_t[2] = salt_buf0[2]; + salt_buf0_t[3] = salt_buf0[3]; + salt_buf1_t[0] = salt_buf1[0]; + salt_buf1_t[1] = salt_buf1[1]; + salt_buf1_t[2] = salt_buf1[2]; + salt_buf1_t[3] = salt_buf1[3]; + salt_buf2_t[0] = salt_buf2[0]; + salt_buf2_t[1] = salt_buf2[1]; + salt_buf2_t[2] = salt_buf2[2]; + salt_buf2_t[3] = salt_buf2[3]; + salt_buf3_t[0] = salt_buf3[0]; + salt_buf3_t[1] = salt_buf3[1]; + salt_buf3_t[2] = salt_buf3[2]; + salt_buf3_t[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_len); + + w0[0] |= salt_buf0_t[0]; + w0[1] |= salt_buf0_t[1]; + w0[2] |= salt_buf0_t[2]; + w0[3] |= salt_buf0_t[3]; + w1[0] |= salt_buf1_t[0]; + w1[1] |= salt_buf1_t[1]; + w1[2] |= salt_buf1_t[2]; + w1[3] |= salt_buf1_t[3]; + w2[0] |= salt_buf2_t[0]; + w2[1] |= salt_buf2_t[1]; + w2[2] |= salt_buf2_t[2]; + w2[3] |= salt_buf2_t[3]; + w3[0] |= salt_buf3_t[0]; + w3[1] |= salt_buf3_t[1]; + w3[2] = pw_salt_len * 8; + w3[3] = 0; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + /** + * md5 + */ + + u32x w0_t = w0lr; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = w3[2]; + u32x wf_t = w3[3]; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w8_t = 0x80; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 32 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +DECLSPEC void m02630s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + /** + * append salt + */ + + u32 salt_buf0_t[4]; + u32 salt_buf1_t[4]; + u32 salt_buf2_t[4]; + u32 salt_buf3_t[4]; + + salt_buf0_t[0] = salt_buf0[0]; + salt_buf0_t[1] = salt_buf0[1]; + salt_buf0_t[2] = salt_buf0[2]; + salt_buf0_t[3] = salt_buf0[3]; + salt_buf1_t[0] = salt_buf1[0]; + salt_buf1_t[1] = salt_buf1[1]; + salt_buf1_t[2] = salt_buf1[2]; + salt_buf1_t[3] = salt_buf1[3]; + salt_buf2_t[0] = salt_buf2[0]; + salt_buf2_t[1] = salt_buf2[1]; + salt_buf2_t[2] = salt_buf2[2]; + salt_buf2_t[3] = salt_buf2[3]; + salt_buf3_t[0] = salt_buf3[0]; + salt_buf3_t[1] = salt_buf3[1]; + salt_buf3_t[2] = salt_buf3[2]; + salt_buf3_t[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_len); + + w0[0] |= salt_buf0_t[0]; + w0[1] |= salt_buf0_t[1]; + w0[2] |= salt_buf0_t[2]; + w0[3] |= salt_buf0_t[3]; + w1[0] |= salt_buf1_t[0]; + w1[1] |= salt_buf1_t[1]; + w1[2] |= salt_buf1_t[2]; + w1[3] |= salt_buf1_t[3]; + w2[0] |= salt_buf2_t[0]; + w2[1] |= salt_buf2_t[1]; + w2[2] |= salt_buf2_t[2]; + w2[3] |= salt_buf2_t[3]; + w3[0] |= salt_buf3_t[0]; + w3[1] |= salt_buf3_t[1]; + w3[2] = pw_salt_len * 8; + w3[3] = 0; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + /** + * md5 + */ + + u32x w0_t = w0lr; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = w3[2]; + u32x wf_t = w3[3]; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w8_t = 0x80; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 32 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m02630_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m02630m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m02630_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m02630m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m02630_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m02630m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m02630_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m02630s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m02630_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m02630s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m02630_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m02630s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} diff --git a/OpenCL/m02630_a3-pure.cl b/OpenCL/m02630_a3-pure.cl new file mode 100644 index 000000000..51c5fb3af --- /dev/null +++ b/OpenCL/m02630_a3-pure.cl @@ -0,0 +1,283 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m02630_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0lr = w0l | w0r; + + w[0] = w0lr; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_update_vector (&ctx0, s, salt_len); + + md5_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.len = 32; + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + ctx.w2[0] = 0x80; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 32 * 8; + ctx.w3[3] = 0; + + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m02630_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0lr = w0l | w0r; + + w[0] = w0lr; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_update_vector (&ctx0, s, salt_len); + + md5_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.len = 32; + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + ctx.w2[0] = 0x80; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 32 * 8; + ctx.w3[3] = 0; + + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m03200-pure.cl b/OpenCL/m03200-pure.cl index 6f522ee8d..2828908d7 100644 --- a/OpenCL/m03200-pure.cl +++ b/OpenCL/m03200-pure.cl @@ -339,7 +339,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val) #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key) diff --git a/OpenCL/m03610_a0-optimized.cl b/OpenCL/m03610_a0-optimized.cl new file mode 100644 index 000000000..7829bf6fd --- /dev/null +++ b/OpenCL/m03610_a0-optimized.cl @@ -0,0 +1,820 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m03610_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[5]; + salt_buf1[2] = 0; + salt_buf1[3] = 0; + salt_buf2[0] = 0; + salt_buf2[1] = 0; + salt_buf2[2] = 0; + salt_buf2[3] = 0; + salt_buf3[0] = 0; + salt_buf3[1] = 0; + salt_buf3[2] = 0; + salt_buf3[3] = 0; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + w3[2] = out_len * 8; + w3[3] = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2[0] = 0x80; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 32 * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2[0] = salt_buf0[0]; + w2[1] = salt_buf0[1]; + w2[2] = salt_buf0[2]; + w2[3] = salt_buf0[3]; + w3[0] = salt_buf1[0]; + w3[1] = salt_buf1[1]; + w3[2] = (32 + salt_len) * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m03610_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m03610_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m03610_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[5]; + salt_buf1[2] = 0; + salt_buf1[3] = 0; + salt_buf2[0] = 0; + salt_buf2[1] = 0; + salt_buf2[2] = 0; + salt_buf2[3] = 0; + salt_buf3[0] = 0; + salt_buf3[1] = 0; + salt_buf3[2] = 0; + salt_buf3[3] = 0; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + w3[2] = out_len * 8; + w3[3] = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2[0] = 0x80; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 32 * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2[0] = salt_buf0[0]; + w2[1] = salt_buf0[1]; + w2[2] = salt_buf0[2]; + w2[3] = salt_buf0[3]; + w3[0] = salt_buf1[0]; + w3[1] = salt_buf1[1]; + w3[2] = (32 + salt_len) * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m03610_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m03610_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m03610_a0-pure.cl b/OpenCL/m03610_a0-pure.cl new file mode 100644 index 000000000..8eec44092 --- /dev/null +++ b/OpenCL/m03610_a0-pure.cl @@ -0,0 +1,307 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m03610_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx1; + + md5_init (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx1.len = 32; + + md5_final (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx2.len = 32; + + md5_update (&ctx2, s, salt_len); + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m03610_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx1; + + md5_init (&ctx1); + + ctx1.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx1.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx1.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx1.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx1.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx1.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx1.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx1.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx1.len = 32; + + md5_final (&ctx1); + + a = ctx1.h[0]; + b = ctx1.h[1]; + c = ctx1.h[2]; + d = ctx1.h[3]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx2.len = 32; + + md5_update (&ctx2, s, salt_len); + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m03610_a1-optimized.cl b/OpenCL/m03610_a1-optimized.cl new file mode 100644 index 000000000..b8ed49a7a --- /dev/null +++ b/OpenCL/m03610_a1-optimized.cl @@ -0,0 +1,934 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m03610_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[5]; + salt_buf1[2] = 0; + salt_buf1[3] = 0; + salt_buf2[0] = 0; + salt_buf2[1] = 0; + salt_buf2[2] = 0; + salt_buf2[3] = 0; + salt_buf3[0] = 0; + salt_buf3[1] = 0; + salt_buf3[2] = 0; + salt_buf3[3] = 0; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = pw_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w2[0] = 0x80; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 32 * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2[0] = salt_buf0[0]; + w2[1] = salt_buf0[1]; + w2[2] = salt_buf0[2]; + w2[3] = salt_buf0[3]; + w3[0] = salt_buf1[0]; + w3[1] = salt_buf1[1]; + w3[2] = (32 + salt_len) * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m03610_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m03610_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m03610_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[5]; + salt_buf1[2] = 0; + salt_buf1[3] = 0; + salt_buf2[0] = 0; + salt_buf2[1] = 0; + salt_buf2[2] = 0; + salt_buf2[3] = 0; + salt_buf3[0] = 0; + salt_buf3[1] = 0; + salt_buf3[2] = 0; + salt_buf3[3] = 0; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = pw_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w2[0] = 0x80; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 32 * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2[0] = salt_buf0[0]; + w2[1] = salt_buf0[1]; + w2[2] = salt_buf0[2]; + w2[3] = salt_buf0[3]; + w3[0] = salt_buf1[0]; + w3[1] = salt_buf1[1]; + w3[2] = (32 + salt_len) * 8; + w3[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m03610_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m03610_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m03610_a1-pure.cl b/OpenCL/m03610_a1-pure.cl new file mode 100644 index 000000000..2e412d0dd --- /dev/null +++ b/OpenCL/m03610_a1-pure.cl @@ -0,0 +1,301 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m03610_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx2.len = 32; + + md5_update (&ctx2, s, salt_len); + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m03610_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_ctx_t ctx2; + + md5_init (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx2.len = 32; + + md5_update (&ctx2, s, salt_len); + + md5_final (&ctx2); + + const u32 r0 = ctx2.h[DGST_R0]; + const u32 r1 = ctx2.h[DGST_R1]; + const u32 r2 = ctx2.h[DGST_R2]; + const u32 r3 = ctx2.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m03610_a3-optimized.cl b/OpenCL/m03610_a3-optimized.cl new file mode 100644 index 000000000..55a6d7bf5 --- /dev/null +++ b/OpenCL/m03610_a3-optimized.cl @@ -0,0 +1,1179 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +DECLSPEC void m03610m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[5]; + salt_buf1[2] = 0; + salt_buf1[3] = 0; + salt_buf2[0] = 0; + salt_buf2[1] = 0; + salt_buf2[2] = 0; + salt_buf2[3] = 0; + salt_buf3[0] = 0; + salt_buf3[1] = 0; + salt_buf3[2] = 0; + salt_buf3[3] = 0; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = w0lr; + w0_t[1] = w0[1]; + w0_t[2] = w0[2]; + w0_t[3] = w0[3]; + w1_t[0] = w1[0]; + w1_t[1] = w1[1]; + w1_t[2] = w1[2]; + w1_t[3] = w1[3]; + w2_t[0] = w2[0]; + w2_t[1] = w2[1]; + w2_t[2] = w2[2]; + w2_t[3] = w2[3]; + w3_t[0] = w3[0]; + w3_t[1] = w3[1]; + w3_t[2] = w3[2]; + w3_t[3] = w3[3]; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w2_t[0] = 0x80; + w2_t[1] = 0; + w2_t[2] = 0; + w2_t[3] = 0; + w3_t[0] = 0; + w3_t[1] = 0; + w3_t[2] = 32 * 8; + w3_t[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2_t[0] = salt_buf0[0]; + w2_t[1] = salt_buf0[1]; + w2_t[2] = salt_buf0[2]; + w2_t[3] = salt_buf0[3]; + w3_t[0] = salt_buf1[0]; + w3_t[1] = salt_buf1[1]; + w3_t[2] = (32 + salt_len) * 8; + w3_t[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +DECLSPEC void m03610s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[5]; + salt_buf1[2] = 0; + salt_buf1[3] = 0; + salt_buf2[0] = 0; + salt_buf2[1] = 0; + salt_buf2[2] = 0; + salt_buf2[3] = 0; + salt_buf3[0] = 0; + salt_buf3[1] = 0; + salt_buf3[2] = 0; + salt_buf3[3] = 0; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = w0lr; + w0_t[1] = w0[1]; + w0_t[2] = w0[2]; + w0_t[3] = w0[3]; + w1_t[0] = w1[0]; + w1_t[1] = w1[1]; + w1_t[2] = w1[2]; + w1_t[3] = w1[3]; + w2_t[0] = w2[0]; + w2_t[1] = w2[1]; + w2_t[2] = w2[2]; + w2_t[3] = w2[3]; + w3_t[0] = w3[0]; + w3_t[1] = w3[1]; + w3_t[2] = w3[2]; + w3_t[3] = w3[3]; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + w2_t[0] = 0x80; + w2_t[1] = 0; + w2_t[2] = 0; + w2_t[3] = 0; + w3_t[0] = 0; + w3_t[1] = 0; + w3_t[2] = 32 * 8; + w3_t[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + w2_t[0] = salt_buf0[0]; + w2_t[1] = salt_buf0[1]; + w2_t[2] = salt_buf0[2]; + w2_t[3] = salt_buf0[3]; + w3_t[0] = salt_buf1[0]; + w3_t[1] = salt_buf1[1]; + w3_t[2] = (32 + salt_len) * 8; + w3_t[3] = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + + } +} + +KERNEL_FQ void m03610_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m03610m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m03610_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m03610m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m03610_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m03610m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m03610_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m03610s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m03610_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m03610s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m03610_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m03610s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} diff --git a/OpenCL/m03610_a3-pure.cl b/OpenCL/m03610_a3-pure.cl new file mode 100644 index 000000000..1e622a413 --- /dev/null +++ b/OpenCL/m03610_a3-pure.cl @@ -0,0 +1,327 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m03610_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_ctx_vector_t ctx2; + + md5_init_vector (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx2.len = 32; + + md5_update_vector (&ctx2, s, salt_len); + + md5_final_vector (&ctx2); + + const u32x r0 = ctx2.h[DGST_R0]; + const u32x r1 = ctx2.h[DGST_R1]; + const u32x r2 = ctx2.h[DGST_R2]; + const u32x r3 = ctx2.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m03610_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = salt_bufs[SALT_POS_HOST].salt_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_ctx_vector_t ctx2; + + md5_init_vector (&ctx2); + + ctx2.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx2.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx2.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx2.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx2.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx2.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx2.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx2.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx2.len = 32; + + md5_update_vector (&ctx2, s, salt_len); + + md5_final_vector (&ctx2); + + const u32x r0 = ctx2.h[DGST_R0]; + const u32x r1 = ctx2.h[DGST_R1]; + const u32x r2 = ctx2.h[DGST_R2]; + const u32x r3 = ctx2.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m03730_a3-pure.cl b/OpenCL/m03730_a3-pure.cl index 58f8b4410..903512e24 100644 --- a/OpenCL/m03730_a3-pure.cl +++ b/OpenCL/m03730_a3-pure.cl @@ -80,7 +80,7 @@ KERNEL_FQ void m03730_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) const u32 salt_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; - u32 s[64] = { 0 }; + u32x s[64] = { 0 }; for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) { @@ -89,7 +89,7 @@ KERNEL_FQ void m03730_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) const u32 salt_len2 = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; - u32 s2[64] = { 0 }; + u32x s2[64] = { 0 }; for (u32 i = 0, idx = 0; i < salt_len2; i += 4, idx += 1) { @@ -232,7 +232,7 @@ KERNEL_FQ void m03730_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) const u32 salt_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; - u32 s[64] = { 0 }; + u32x s[64] = { 0 }; for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) { @@ -241,7 +241,7 @@ KERNEL_FQ void m03730_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) const u32 salt_len2 = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; - u32 s2[64] = { 0 }; + u32x s2[64] = { 0 }; for (u32 i = 0, idx = 0; i < salt_len2; i += 4, idx += 1) { diff --git a/OpenCL/m04410_a0-optimized.cl b/OpenCL/m04410_a0-optimized.cl index c7be39b39..191e1eddf 100644 --- a/OpenCL/m04410_a0-optimized.cl +++ b/OpenCL/m04410_a0-optimized.cl @@ -641,10 +641,10 @@ KERNEL_FQ void m04410_m04 (KERN_ATTR_RULES ()) MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); - a += digest[0] - MD5M_A; - b += digest[1] - MD5M_B; - c += digest[2] - MD5M_C; - d += digest[3] - MD5M_D; + a += digest[0] - make_u32x (MD5M_A); + b += digest[1] - make_u32x (MD5M_B); + c += digest[2] - make_u32x (MD5M_C); + d += digest[3] - make_u32x (MD5M_D); COMPARE_M_SIMD (a, d, c, b); } @@ -1285,10 +1285,10 @@ KERNEL_FQ void m04410_s04 (KERN_ATTR_RULES ()) MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); - a += digest[0] - MD5M_A; - b += digest[1] - MD5M_B; - c += digest[2] - MD5M_C; - d += digest[3] - MD5M_D; + a += digest[0] - make_u32x (MD5M_A); + b += digest[1] - make_u32x (MD5M_B); + c += digest[2] - make_u32x (MD5M_C); + d += digest[3] - make_u32x (MD5M_D); COMPARE_S_SIMD (a, d, c, b); } diff --git a/OpenCL/m04410_a1-optimized.cl b/OpenCL/m04410_a1-optimized.cl index 61a14f34c..813ad365d 100644 --- a/OpenCL/m04410_a1-optimized.cl +++ b/OpenCL/m04410_a1-optimized.cl @@ -697,10 +697,10 @@ KERNEL_FQ void m04410_m04 (KERN_ATTR_BASIC ()) MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); - a += digest[0] - MD5M_A; - b += digest[1] - MD5M_B; - c += digest[2] - MD5M_C; - d += digest[3] - MD5M_D; + a += digest[0] - make_u32x (MD5M_A); + b += digest[1] - make_u32x (MD5M_B); + c += digest[2] - make_u32x (MD5M_C); + d += digest[3] - make_u32x (MD5M_D); COMPARE_M_SIMD (a, d, c, b); } @@ -1399,10 +1399,10 @@ KERNEL_FQ void m04410_s04 (KERN_ATTR_BASIC ()) MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); - a += digest[0] - MD5M_A; - b += digest[1] - MD5M_B; - c += digest[2] - MD5M_C; - d += digest[3] - MD5M_D; + a += digest[0] - make_u32x (MD5M_A); + b += digest[1] - make_u32x (MD5M_B); + c += digest[2] - make_u32x (MD5M_C); + d += digest[3] - make_u32x (MD5M_D); COMPARE_S_SIMD (a, d, c, b); } diff --git a/OpenCL/m04410_a3-optimized.cl b/OpenCL/m04410_a3-optimized.cl index 231fa0f1e..584999c7e 100644 --- a/OpenCL/m04410_a3-optimized.cl +++ b/OpenCL/m04410_a3-optimized.cl @@ -595,10 +595,10 @@ DECLSPEC void m04410m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); - a += digest[0] - MD5M_A; - b += digest[1] - MD5M_B; - c += digest[2] - MD5M_C; - d += digest[3] - MD5M_D; + a += digest[0] - make_u32x (MD5M_A); + b += digest[1] - make_u32x (MD5M_B); + c += digest[2] - make_u32x (MD5M_C); + d += digest[3] - make_u32x (MD5M_D); COMPARE_M_SIMD (a, d, c, b); } @@ -1187,10 +1187,10 @@ DECLSPEC void m04410s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); - a += digest[0] - MD5M_A; - b += digest[1] - MD5M_B; - c += digest[2] - MD5M_C; - d += digest[3] - MD5M_D; + a += digest[0] - make_u32x (MD5M_A); + b += digest[1] - make_u32x (MD5M_B); + c += digest[2] - make_u32x (MD5M_C); + d += digest[3] - make_u32x (MD5M_D); COMPARE_S_SIMD (a, d, c, b); } diff --git a/OpenCL/m04420_a0-optimized.cl b/OpenCL/m04420_a0-optimized.cl new file mode 100644 index 000000000..e071beef3 --- /dev/null +++ b/OpenCL/m04420_a0-optimized.cl @@ -0,0 +1,813 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04420_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + + const u32x pw_salt_len = out_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04420_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m04420_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m04420_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len); + + const u32x pw_salt_len = out_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04420_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m04420_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m04420_a0-pure.cl b/OpenCL/m04420_a0-pure.cl new file mode 100644 index 000000000..a0114a72c --- /dev/null +++ b/OpenCL/m04420_a0-pure.cl @@ -0,0 +1,280 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04420_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha1_update (&ctx0, s, salt_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m04420_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha1_update (&ctx0, s, salt_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m04420_a1-optimized.cl b/OpenCL/m04420_a1-optimized.cl new file mode 100644 index 000000000..2f688826e --- /dev/null +++ b/OpenCL/m04420_a1-optimized.cl @@ -0,0 +1,931 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04420_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04420_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m04420_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m04420_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * append salt + */ + + u32x s0[4]; + u32x s1[4]; + u32x s2[4]; + u32x s3[4]; + + s0[0] = salt_buf0[0]; + s0[1] = salt_buf0[1]; + s0[2] = salt_buf0[2]; + s0[3] = salt_buf0[3]; + s1[0] = salt_buf1[0]; + s1[1] = salt_buf1[1]; + s1[2] = salt_buf1[2]; + s1[3] = salt_buf1[3]; + s2[0] = salt_buf2[0]; + s2[1] = salt_buf2[1]; + s2[2] = salt_buf2[2]; + s2[3] = salt_buf2[3]; + s3[0] = salt_buf3[0]; + s3[1] = salt_buf3[1]; + s3[2] = salt_buf3[2]; + s3[3] = salt_buf3[3]; + + switch_buffer_by_offset_le_VV (s0, s1, s2, s3, pw_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= s0[0]; + w0[1] |= s0[1]; + w0[2] |= s0[2]; + w0[3] |= s0[3]; + w1[0] |= s1[0]; + w1[1] |= s1[1]; + w1[2] |= s1[2]; + w1[3] |= s1[3]; + w2[0] |= s2[0]; + w2[1] |= s2[1]; + w2[2] |= s2[2]; + w2[3] |= s2[3]; + w3[0] |= s3[0]; + w3[1] |= s3[1]; + w3[2] |= s3[2]; + w3[3] |= s3[3]; + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04420_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m04420_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m04420_a1-pure.cl b/OpenCL/m04420_a1-pure.cl new file mode 100644 index 000000000..20b17296c --- /dev/null +++ b/OpenCL/m04420_a1-pure.cl @@ -0,0 +1,274 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04420_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha1_ctx_t ctx1 = ctx0; + + sha1_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha1_update (&ctx1, s, salt_len); + + sha1_final (&ctx1); + + const u32 a = ctx1.h[0]; + const u32 b = ctx1.h[1]; + const u32 c = ctx1.h[2]; + const u32 d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m04420_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha1_ctx_t ctx1 = ctx0; + + sha1_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha1_update (&ctx1, s, salt_len); + + sha1_final (&ctx1); + + const u32 a = ctx1.h[0]; + const u32 b = ctx1.h[1]; + const u32 c = ctx1.h[2]; + const u32 d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m04420_a3-optimized.cl b/OpenCL/m04420_a3-optimized.cl new file mode 100644 index 000000000..baef3c6a7 --- /dev/null +++ b/OpenCL/m04420_a3-optimized.cl @@ -0,0 +1,1127 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +DECLSPEC void m04420m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + u32 salt_buf0_t[4]; + u32 salt_buf1_t[4]; + u32 salt_buf2_t[4]; + u32 salt_buf3_t[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + salt_buf0_t[0] = salt_buf0[0]; + salt_buf0_t[1] = salt_buf0[1]; + salt_buf0_t[2] = salt_buf0[2]; + salt_buf0_t[3] = salt_buf0[3]; + salt_buf1_t[0] = salt_buf1[0]; + salt_buf1_t[1] = salt_buf1[1]; + salt_buf1_t[2] = salt_buf1[2]; + salt_buf1_t[3] = salt_buf1[3]; + salt_buf2_t[0] = salt_buf2[0]; + salt_buf2_t[1] = salt_buf2[1]; + salt_buf2_t[2] = salt_buf2[2]; + salt_buf2_t[3] = salt_buf2[3]; + salt_buf3_t[0] = salt_buf3[0]; + salt_buf3_t[1] = salt_buf3[1]; + salt_buf3_t[2] = salt_buf3[2]; + salt_buf3_t[3] = salt_buf3[3]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + append_0x80_4x4_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, salt_len); + + switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_len); + + w0[ 0] |= hc_swap32_S (salt_buf0_t[0]); + w0[ 1] |= hc_swap32_S (salt_buf0_t[1]); + w0[ 2] |= hc_swap32_S (salt_buf0_t[2]); + w0[ 3] |= hc_swap32_S (salt_buf0_t[3]); + w1[ 0] |= hc_swap32_S (salt_buf1_t[0]); + w1[ 1] |= hc_swap32_S (salt_buf1_t[1]); + w1[ 2] |= hc_swap32_S (salt_buf1_t[2]); + w1[ 3] |= hc_swap32_S (salt_buf1_t[3]); + w2[ 0] |= hc_swap32_S (salt_buf2_t[0]); + w2[ 1] |= hc_swap32_S (salt_buf2_t[1]); + w2[ 2] |= hc_swap32_S (salt_buf2_t[2]); + w2[ 3] |= hc_swap32_S (salt_buf2_t[3]); + w3[ 0] |= hc_swap32_S (salt_buf3_t[0]); + w3[ 1] |= hc_swap32_S (salt_buf3_t[1]); + w3[ 2] |= hc_swap32_S (salt_buf3_t[2]); + w3[ 3] |= hc_swap32_S (salt_buf3_t[3]); + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + /** + * sha1 + */ + + u32x w0_t = w0lr; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +DECLSPEC void m04420s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + u32 salt_buf0_t[4]; + u32 salt_buf1_t[4]; + u32 salt_buf2_t[4]; + u32 salt_buf3_t[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + salt_buf0_t[0] = salt_buf0[0]; + salt_buf0_t[1] = salt_buf0[1]; + salt_buf0_t[2] = salt_buf0[2]; + salt_buf0_t[3] = salt_buf0[3]; + salt_buf1_t[0] = salt_buf1[0]; + salt_buf1_t[1] = salt_buf1[1]; + salt_buf1_t[2] = salt_buf1[2]; + salt_buf1_t[3] = salt_buf1[3]; + salt_buf2_t[0] = salt_buf2[0]; + salt_buf2_t[1] = salt_buf2[1]; + salt_buf2_t[2] = salt_buf2[2]; + salt_buf2_t[3] = salt_buf2[3]; + salt_buf3_t[0] = salt_buf3[0]; + salt_buf3_t[1] = salt_buf3[1]; + salt_buf3_t[2] = salt_buf3[2]; + salt_buf3_t[3] = salt_buf3[3]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + append_0x80_4x4_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, salt_len); + + switch_buffer_by_offset_le_S (salt_buf0_t, salt_buf1_t, salt_buf2_t, salt_buf3_t, pw_len); + + w0[ 0] |= hc_swap32_S (salt_buf0_t[0]); + w0[ 1] |= hc_swap32_S (salt_buf0_t[1]); + w0[ 2] |= hc_swap32_S (salt_buf0_t[2]); + w0[ 3] |= hc_swap32_S (salt_buf0_t[3]); + w1[ 0] |= hc_swap32_S (salt_buf1_t[0]); + w1[ 1] |= hc_swap32_S (salt_buf1_t[1]); + w1[ 2] |= hc_swap32_S (salt_buf1_t[2]); + w1[ 3] |= hc_swap32_S (salt_buf1_t[3]); + w2[ 0] |= hc_swap32_S (salt_buf2_t[0]); + w2[ 1] |= hc_swap32_S (salt_buf2_t[1]); + w2[ 2] |= hc_swap32_S (salt_buf2_t[2]); + w2[ 3] |= hc_swap32_S (salt_buf2_t[3]); + w3[ 0] |= hc_swap32_S (salt_buf3_t[0]); + w3[ 1] |= hc_swap32_S (salt_buf3_t[1]); + w3[ 2] |= hc_swap32_S (salt_buf3_t[2]); + w3[ 3] |= hc_swap32_S (salt_buf3_t[3]); + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + /** + * sha1 + */ + + u32x w0_t = w0lr; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04420_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04420m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04420_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04420m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04420_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04420m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04420_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04420s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04420_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04420s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04420_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04420s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} diff --git a/OpenCL/m04420_a3-pure.cl b/OpenCL/m04420_a3-pure.cl new file mode 100644 index 000000000..37727503e --- /dev/null +++ b/OpenCL/m04420_a3-pure.cl @@ -0,0 +1,300 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04420_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha1_ctx_vector_t ctx0; + + sha1_init_vector (&ctx0); + + sha1_update_vector (&ctx0, w, pw_len); + + sha1_update_vector (&ctx0, s, salt_len); + + sha1_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + _w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + _w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + _w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + _w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + _w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + _w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + _w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + _w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + _w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + _w2[2] = 0; + _w2[3] = 0; + _w3[0] = 0; + _w3[1] = 0; + _w3[2] = 0; + _w3[3] = 0; + + md5_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 40); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m04420_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha1_ctx_vector_t ctx0; + + sha1_init_vector (&ctx0); + + sha1_update_vector (&ctx0, w, pw_len); + + sha1_update_vector (&ctx0, s, salt_len); + + sha1_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + _w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + _w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + _w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + _w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + _w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + _w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + _w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + _w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + _w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + _w2[2] = 0; + _w2[3] = 0; + _w3[0] = 0; + _w3[1] = 0; + _w3[2] = 0; + _w3[3] = 0; + + md5_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 40); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m04430_a0-optimized.cl b/OpenCL/m04430_a0-optimized.cl new file mode 100644 index 000000000..4f809d3ff --- /dev/null +++ b/OpenCL/m04430_a0-optimized.cl @@ -0,0 +1,773 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04430_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * prepend salt + */ + + const u32x out_salt_len = out_len + salt_len; + + switch_buffer_by_offset_le_VV (w0, w1, w2, w3, salt_len); + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + append_0x80_4x4_VV (w0, w1, w2, w3, out_salt_len); + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = out_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04430_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m04430_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m04430_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + /** + * prepend salt + */ + + const u32x out_salt_len = out_len + salt_len; + + switch_buffer_by_offset_le_VV (w0, w1, w2, w3, salt_len); + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + append_0x80_4x4_VV (w0, w1, w2, w3, out_salt_len); + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = out_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04430_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m04430_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m04430_a0-pure.cl b/OpenCL/m04430_a0-pure.cl new file mode 100644 index 000000000..60cfea81b --- /dev/null +++ b/OpenCL/m04430_a0-pure.cl @@ -0,0 +1,266 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04430_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + sha1_update_global_swap (&ctx1, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_ctx_t ctx0 = ctx1; + + sha1_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m04430_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + sha1_update_global_swap (&ctx1, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_ctx_t ctx0 = ctx1; + + sha1_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m04430_a1-optimized.cl b/OpenCL/m04430_a1-optimized.cl new file mode 100644 index 000000000..43b94cf73 --- /dev/null +++ b/OpenCL/m04430_a1-optimized.cl @@ -0,0 +1,886 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04430_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * prepend salt + */ + + switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + w3[3] |= salt_buf3[3]; + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04430_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m04430_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m04430_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 0]; + salt_buf0[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 1]; + salt_buf0[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 2]; + salt_buf0[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 3]; + salt_buf1[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 4]; + salt_buf1[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 5]; + salt_buf1[2] = salt_bufs[SALT_POS_HOST].salt_buf[ 6]; + salt_buf1[3] = salt_bufs[SALT_POS_HOST].salt_buf[ 7]; + salt_buf2[0] = salt_bufs[SALT_POS_HOST].salt_buf[ 8]; + salt_buf2[1] = salt_bufs[SALT_POS_HOST].salt_buf[ 9]; + salt_buf2[2] = salt_bufs[SALT_POS_HOST].salt_buf[10]; + salt_buf2[3] = salt_bufs[SALT_POS_HOST].salt_buf[11]; + salt_buf3[0] = salt_bufs[SALT_POS_HOST].salt_buf[12]; + salt_buf3[1] = salt_bufs[SALT_POS_HOST].salt_buf[13]; + salt_buf3[2] = salt_bufs[SALT_POS_HOST].salt_buf[14]; + salt_buf3[3] = salt_bufs[SALT_POS_HOST].salt_buf[15]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * prepend salt + */ + + switch_buffer_by_offset_le (w0, w1, w2, w3, salt_len); + + const u32x pw_salt_len = pw_len + salt_len; + + w0[0] |= salt_buf0[0]; + w0[1] |= salt_buf0[1]; + w0[2] |= salt_buf0[2]; + w0[3] |= salt_buf0[3]; + w1[0] |= salt_buf1[0]; + w1[1] |= salt_buf1[1]; + w1[2] |= salt_buf1[2]; + w1[3] |= salt_buf1[3]; + w2[0] |= salt_buf2[0]; + w2[1] |= salt_buf2[1]; + w2[2] |= salt_buf2[2]; + w2[3] |= salt_buf2[3]; + w3[0] |= salt_buf3[0]; + w3[1] |= salt_buf3[1]; + w3[2] |= salt_buf3[2]; + + /** + * sha1 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04430_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m04430_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m04430_a1-pure.cl b/OpenCL/m04430_a1-pure.cl new file mode 100644 index 000000000..3a801e1a2 --- /dev/null +++ b/OpenCL/m04430_a1-pure.cl @@ -0,0 +1,265 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04430_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + sha1_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha1_ctx_t ctx1 = ctx0; + + sha1_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha1_final (&ctx1); + + const u32 a = ctx1.h[0]; + const u32 b = ctx1.h[1]; + const u32 c = ctx1.h[2]; + const u32 d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m04430_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha1_ctx_t ctx0; + + sha1_init (&ctx0); + + sha1_update_global_swap (&ctx0, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + sha1_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha1_ctx_t ctx1 = ctx0; + + sha1_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha1_final (&ctx1); + + const u32 a = ctx1.h[0]; + const u32 b = ctx1.h[1]; + const u32 c = ctx1.h[2]; + const u32 d = ctx1.h[3]; + const u32 e = ctx1.h[4]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m04430_a3-optimized.cl b/OpenCL/m04430_a3-optimized.cl new file mode 100644 index 000000000..ccca5001c --- /dev/null +++ b/OpenCL/m04430_a3-optimized.cl @@ -0,0 +1,1123 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +DECLSPEC void m04430m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + t0[0] = w0lr; + t0[1] = w0[1]; + t0[2] = w0[2]; + t0[3] = w0[3]; + t1[0] = w1[0]; + t1[1] = w1[1]; + t1[2] = w1[2]; + t1[3] = w1[3]; + t2[0] = w2[0]; + t2[1] = w2[1]; + t2[2] = w2[2]; + t2[3] = w2[3]; + t3[0] = w3[0]; + t3[1] = w3[1]; + t3[2] = w3[2]; + t3[3] = w3[3]; + + switch_buffer_by_offset_be (t0, t1, t2, t3, salt_len); + + t0[0] |= salt_buf0[0]; + t0[1] |= salt_buf0[1]; + t0[2] |= salt_buf0[2]; + t0[3] |= salt_buf0[3]; + t1[0] |= salt_buf1[0]; + t1[1] |= salt_buf1[1]; + t1[2] |= salt_buf1[2]; + t1[3] |= salt_buf1[3]; + t2[0] |= salt_buf2[0]; + t2[1] |= salt_buf2[1]; + t2[2] |= salt_buf2[2]; + t2[3] |= salt_buf2[3]; + t3[0] |= salt_buf3[0]; + t3[1] |= salt_buf3[1]; + t3[2] = 0; + t3[3] = pw_salt_len * 8; + + /** + * sha1 + */ + + u32x w0_t = t0[0]; + u32x w1_t = t0[1]; + u32x w2_t = t0[2]; + u32x w3_t = t0[3]; + u32x w4_t = t1[0]; + u32x w5_t = t1[1]; + u32x w6_t = t1[2]; + u32x w7_t = t1[3]; + u32x w8_t = t2[0]; + u32x w9_t = t2[1]; + u32x wa_t = t2[2]; + u32x wb_t = t2[3]; + u32x wc_t = t3[0]; + u32x wd_t = t3[1]; + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +DECLSPEC void m04430s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_BASIC (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + const u32 pw_salt_len = pw_len + salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = ix_create_bft (bfs_buf, il_pos); + + const u32x w0lr = w0l | w0r; + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + t0[0] = w0lr; + t0[1] = w0[1]; + t0[2] = w0[2]; + t0[3] = w0[3]; + t1[0] = w1[0]; + t1[1] = w1[1]; + t1[2] = w1[2]; + t1[3] = w1[3]; + t2[0] = w2[0]; + t2[1] = w2[1]; + t2[2] = w2[2]; + t2[3] = w2[3]; + t3[0] = w3[0]; + t3[1] = w3[1]; + t3[2] = w3[2]; + t3[3] = w3[3]; + + switch_buffer_by_offset_be (t0, t1, t2, t3, salt_len); + + t0[0] |= salt_buf0[0]; + t0[1] |= salt_buf0[1]; + t0[2] |= salt_buf0[2]; + t0[3] |= salt_buf0[3]; + t1[0] |= salt_buf1[0]; + t1[1] |= salt_buf1[1]; + t1[2] |= salt_buf1[2]; + t1[3] |= salt_buf1[3]; + t2[0] |= salt_buf2[0]; + t2[1] |= salt_buf2[1]; + t2[2] |= salt_buf2[2]; + t2[3] |= salt_buf2[3]; + t3[0] |= salt_buf3[0]; + t3[1] |= salt_buf3[1]; + t3[2] = 0; + t3[3] = pw_salt_len * 8; + + /** + * sha1 + */ + + u32x w0_t = t0[0]; + u32x w1_t = t0[1]; + u32x w2_t = t0[2]; + u32x w3_t = t0[3]; + u32x w4_t = t1[0]; + u32x w5_t = t1[1]; + u32x w6_t = t1[2]; + u32x w7_t = t1[3]; + u32x w8_t = t2[0]; + u32x w9_t = t2[1]; + u32x wa_t = t2[2]; + u32x wb_t = t2[3]; + u32x wc_t = t3[0]; + u32x wd_t = t3[1]; + u32x we_t = 0; + u32x wf_t = pw_salt_len * 8; + + u32x a = SHA1M_A; + u32x b = SHA1M_B; + u32x c = SHA1M_C; + u32x d = SHA1M_D; + u32x e = SHA1M_E; + + #undef K + #define K SHA1C00 + + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t); + SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t); + SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t); + SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t); + SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t); + SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t); + + #undef K + #define K SHA1C01 + + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t); + + #undef K + #define K SHA1C02 + + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t); + + #undef K + #define K SHA1C03 + + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t); + w0_t = hc_rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t); + w1_t = hc_rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t); + w2_t = hc_rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t); + w3_t = hc_rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t); + w4_t = hc_rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t); + w5_t = hc_rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t); + w6_t = hc_rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t); + w7_t = hc_rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t); + w8_t = hc_rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t); + w9_t = hc_rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t); + wa_t = hc_rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t); + wb_t = hc_rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t); + wc_t = hc_rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t); + wd_t = hc_rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t); + we_t = hc_rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t); + wf_t = hc_rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t); + + a += make_u32x (SHA1M_A); + b += make_u32x (SHA1M_B); + c += make_u32x (SHA1M_C); + d += make_u32x (SHA1M_D); + e += make_u32x (SHA1M_E); + + /** + * md5 + */ + + w0_t = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w1_t = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w2_t = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w3_t = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w4_t = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w5_t = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w6_t = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w7_t = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w8_t = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w9_t = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + wa_t = 0x80; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 40 * 8; + wf_t = 0; + + a = MD5M_A; + b = MD5M_B; + c = MD5M_C; + d = MD5M_D; + e = 0; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30); + + if (MATCHES_NONE_VS (a, search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m04430_m04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04430m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04430_m08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04430m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04430_m16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04430m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04430_s04 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04430s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04430_s08 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04430s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m04430_s16 (KERN_ATTR_BASIC ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m04430s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} diff --git a/OpenCL/m04430_a3-pure.cl b/OpenCL/m04430_a3-pure.cl new file mode 100644 index 000000000..54142aeb3 --- /dev/null +++ b/OpenCL/m04430_a3-pure.cl @@ -0,0 +1,290 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m04430_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + sha1_update_global_swap (&ctx1, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + /** + * loop + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha1_ctx_vector_t ctx0; + + sha1_init_vector_from_scalar (&ctx0, &ctx1); + + sha1_update_vector (&ctx0, w, pw_len); + + sha1_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + _w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + _w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + _w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + _w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + _w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + _w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + _w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + _w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + _w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + _w2[2] = 0; + _w2[3] = 0; + _w3[0] = 0; + _w3[1] = 0; + _w3[2] = 0; + _w3[3] = 0; + + md5_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 40); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m04430_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha1_ctx_t ctx1; + + sha1_init (&ctx1); + + sha1_update_global_swap (&ctx1, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + /** + * loop + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha1_ctx_vector_t ctx0; + + sha1_init_vector_from_scalar (&ctx0, &ctx1); + + sha1_update_vector (&ctx0, w, pw_len); + + sha1_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + _w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + _w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + _w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + _w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + _w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + _w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + _w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + _w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + _w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + _w2[2] = 0; + _w2[3] = 0; + _w3[0] = 0; + _w3[1] = 0; + _w3[2] = 0; + _w3[3] = 0; + + md5_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 40); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m05800-optimized.cl b/OpenCL/m05800-optimized.cl index fd615b7dc..200716a2f 100644 --- a/OpenCL/m05800-optimized.cl +++ b/OpenCL/m05800-optimized.cl @@ -22,2058 +22,170 @@ typedef struct androidpin_tmp CONSTANT_VK u32a c_pc_dec[1024] = { - 0x00000030, - 0x00000031, - 0x00000032, - 0x00000033, - 0x00000034, - 0x00000035, - 0x00000036, - 0x00000037, - 0x00000038, - 0x00000039, - 0x00003031, - 0x00003131, - 0x00003231, - 0x00003331, - 0x00003431, - 0x00003531, - 0x00003631, - 0x00003731, - 0x00003831, - 0x00003931, - 0x00003032, - 0x00003132, - 0x00003232, - 0x00003332, - 0x00003432, - 0x00003532, - 0x00003632, - 0x00003732, - 0x00003832, - 0x00003932, - 0x00003033, - 0x00003133, - 0x00003233, - 0x00003333, - 0x00003433, - 0x00003533, - 0x00003633, - 0x00003733, - 0x00003833, - 0x00003933, - 0x00003034, - 0x00003134, - 0x00003234, - 0x00003334, - 0x00003434, - 0x00003534, - 0x00003634, - 0x00003734, - 0x00003834, - 0x00003934, - 0x00003035, - 0x00003135, - 0x00003235, - 0x00003335, - 0x00003435, - 0x00003535, - 0x00003635, - 0x00003735, - 0x00003835, - 0x00003935, - 0x00003036, - 0x00003136, - 0x00003236, - 0x00003336, - 0x00003436, - 0x00003536, - 0x00003636, - 0x00003736, - 0x00003836, - 0x00003936, - 0x00003037, - 0x00003137, - 0x00003237, - 0x00003337, - 0x00003437, - 0x00003537, - 0x00003637, - 0x00003737, - 0x00003837, - 0x00003937, - 0x00003038, - 0x00003138, - 0x00003238, - 0x00003338, - 0x00003438, - 0x00003538, - 0x00003638, - 0x00003738, - 0x00003838, - 0x00003938, - 0x00003039, - 0x00003139, - 0x00003239, - 0x00003339, - 0x00003439, - 0x00003539, - 0x00003639, - 0x00003739, - 0x00003839, - 0x00003939, - 0x00303031, - 0x00313031, - 0x00323031, - 0x00333031, - 0x00343031, - 0x00353031, - 0x00363031, - 0x00373031, - 0x00383031, - 0x00393031, - 0x00303131, - 0x00313131, - 0x00323131, - 0x00333131, - 0x00343131, - 0x00353131, - 0x00363131, - 0x00373131, - 0x00383131, - 0x00393131, - 0x00303231, - 0x00313231, - 0x00323231, - 0x00333231, - 0x00343231, - 0x00353231, - 0x00363231, - 0x00373231, - 0x00383231, - 0x00393231, - 0x00303331, - 0x00313331, - 0x00323331, - 0x00333331, - 0x00343331, - 0x00353331, - 0x00363331, - 0x00373331, - 0x00383331, - 0x00393331, - 0x00303431, - 0x00313431, - 0x00323431, - 0x00333431, - 0x00343431, - 0x00353431, - 0x00363431, - 0x00373431, - 0x00383431, - 0x00393431, - 0x00303531, - 0x00313531, - 0x00323531, - 0x00333531, - 0x00343531, - 0x00353531, - 0x00363531, - 0x00373531, - 0x00383531, - 0x00393531, - 0x00303631, - 0x00313631, - 0x00323631, - 0x00333631, - 0x00343631, - 0x00353631, - 0x00363631, - 0x00373631, - 0x00383631, - 0x00393631, - 0x00303731, - 0x00313731, - 0x00323731, - 0x00333731, - 0x00343731, - 0x00353731, - 0x00363731, - 0x00373731, - 0x00383731, - 0x00393731, - 0x00303831, - 0x00313831, - 0x00323831, - 0x00333831, - 0x00343831, - 0x00353831, - 0x00363831, - 0x00373831, - 0x00383831, - 0x00393831, - 0x00303931, - 0x00313931, - 0x00323931, - 0x00333931, - 0x00343931, - 0x00353931, - 0x00363931, - 0x00373931, - 0x00383931, - 0x00393931, - 0x00303032, - 0x00313032, - 0x00323032, - 0x00333032, - 0x00343032, - 0x00353032, - 0x00363032, - 0x00373032, - 0x00383032, - 0x00393032, - 0x00303132, - 0x00313132, - 0x00323132, - 0x00333132, - 0x00343132, - 0x00353132, - 0x00363132, - 0x00373132, - 0x00383132, - 0x00393132, - 0x00303232, - 0x00313232, - 0x00323232, - 0x00333232, - 0x00343232, - 0x00353232, - 0x00363232, - 0x00373232, - 0x00383232, - 0x00393232, - 0x00303332, - 0x00313332, - 0x00323332, - 0x00333332, - 0x00343332, - 0x00353332, - 0x00363332, - 0x00373332, - 0x00383332, - 0x00393332, - 0x00303432, - 0x00313432, - 0x00323432, - 0x00333432, - 0x00343432, - 0x00353432, - 0x00363432, - 0x00373432, - 0x00383432, - 0x00393432, - 0x00303532, - 0x00313532, - 0x00323532, - 0x00333532, - 0x00343532, - 0x00353532, - 0x00363532, - 0x00373532, - 0x00383532, - 0x00393532, - 0x00303632, - 0x00313632, - 0x00323632, - 0x00333632, - 0x00343632, - 0x00353632, - 0x00363632, - 0x00373632, - 0x00383632, - 0x00393632, - 0x00303732, - 0x00313732, - 0x00323732, - 0x00333732, - 0x00343732, - 0x00353732, - 0x00363732, - 0x00373732, - 0x00383732, - 0x00393732, - 0x00303832, - 0x00313832, - 0x00323832, - 0x00333832, - 0x00343832, - 0x00353832, - 0x00363832, - 0x00373832, - 0x00383832, - 0x00393832, - 0x00303932, - 0x00313932, - 0x00323932, - 0x00333932, - 0x00343932, - 0x00353932, - 0x00363932, - 0x00373932, - 0x00383932, - 0x00393932, - 0x00303033, - 0x00313033, - 0x00323033, - 0x00333033, - 0x00343033, - 0x00353033, - 0x00363033, - 0x00373033, - 0x00383033, - 0x00393033, - 0x00303133, - 0x00313133, - 0x00323133, - 0x00333133, - 0x00343133, - 0x00353133, - 0x00363133, - 0x00373133, - 0x00383133, - 0x00393133, - 0x00303233, - 0x00313233, - 0x00323233, - 0x00333233, - 0x00343233, - 0x00353233, - 0x00363233, - 0x00373233, - 0x00383233, - 0x00393233, - 0x00303333, - 0x00313333, - 0x00323333, - 0x00333333, - 0x00343333, - 0x00353333, - 0x00363333, - 0x00373333, - 0x00383333, - 0x00393333, - 0x00303433, - 0x00313433, - 0x00323433, - 0x00333433, - 0x00343433, - 0x00353433, - 0x00363433, - 0x00373433, - 0x00383433, - 0x00393433, - 0x00303533, - 0x00313533, - 0x00323533, - 0x00333533, - 0x00343533, - 0x00353533, - 0x00363533, - 0x00373533, - 0x00383533, - 0x00393533, - 0x00303633, - 0x00313633, - 0x00323633, - 0x00333633, - 0x00343633, - 0x00353633, - 0x00363633, - 0x00373633, - 0x00383633, - 0x00393633, - 0x00303733, - 0x00313733, - 0x00323733, - 0x00333733, - 0x00343733, - 0x00353733, - 0x00363733, - 0x00373733, - 0x00383733, - 0x00393733, - 0x00303833, - 0x00313833, - 0x00323833, - 0x00333833, - 0x00343833, - 0x00353833, - 0x00363833, - 0x00373833, - 0x00383833, - 0x00393833, - 0x00303933, - 0x00313933, - 0x00323933, - 0x00333933, - 0x00343933, - 0x00353933, - 0x00363933, - 0x00373933, - 0x00383933, - 0x00393933, - 0x00303034, - 0x00313034, - 0x00323034, - 0x00333034, - 0x00343034, - 0x00353034, - 0x00363034, - 0x00373034, - 0x00383034, - 0x00393034, - 0x00303134, - 0x00313134, - 0x00323134, - 0x00333134, - 0x00343134, - 0x00353134, - 0x00363134, - 0x00373134, - 0x00383134, - 0x00393134, - 0x00303234, - 0x00313234, - 0x00323234, - 0x00333234, - 0x00343234, - 0x00353234, - 0x00363234, - 0x00373234, - 0x00383234, - 0x00393234, - 0x00303334, - 0x00313334, - 0x00323334, - 0x00333334, - 0x00343334, - 0x00353334, - 0x00363334, - 0x00373334, - 0x00383334, - 0x00393334, - 0x00303434, - 0x00313434, - 0x00323434, - 0x00333434, - 0x00343434, - 0x00353434, - 0x00363434, - 0x00373434, - 0x00383434, - 0x00393434, - 0x00303534, - 0x00313534, - 0x00323534, - 0x00333534, - 0x00343534, - 0x00353534, - 0x00363534, - 0x00373534, - 0x00383534, - 0x00393534, - 0x00303634, - 0x00313634, - 0x00323634, - 0x00333634, - 0x00343634, - 0x00353634, - 0x00363634, - 0x00373634, - 0x00383634, - 0x00393634, - 0x00303734, - 0x00313734, - 0x00323734, - 0x00333734, - 0x00343734, - 0x00353734, - 0x00363734, - 0x00373734, - 0x00383734, - 0x00393734, - 0x00303834, - 0x00313834, - 0x00323834, - 0x00333834, - 0x00343834, - 0x00353834, - 0x00363834, - 0x00373834, - 0x00383834, - 0x00393834, - 0x00303934, - 0x00313934, - 0x00323934, - 0x00333934, - 0x00343934, - 0x00353934, - 0x00363934, - 0x00373934, - 0x00383934, - 0x00393934, - 0x00303035, - 0x00313035, - 0x00323035, - 0x00333035, - 0x00343035, - 0x00353035, - 0x00363035, - 0x00373035, - 0x00383035, - 0x00393035, - 0x00303135, - 0x00313135, - 0x00323135, - 0x00333135, - 0x00343135, - 0x00353135, - 0x00363135, - 0x00373135, - 0x00383135, - 0x00393135, - 0x00303235, - 0x00313235, - 0x00323235, - 0x00333235, - 0x00343235, - 0x00353235, - 0x00363235, - 0x00373235, - 0x00383235, - 0x00393235, - 0x00303335, - 0x00313335, - 0x00323335, - 0x00333335, - 0x00343335, - 0x00353335, - 0x00363335, - 0x00373335, - 0x00383335, - 0x00393335, - 0x00303435, - 0x00313435, - 0x00323435, - 0x00333435, - 0x00343435, - 0x00353435, - 0x00363435, - 0x00373435, - 0x00383435, - 0x00393435, - 0x00303535, - 0x00313535, - 0x00323535, - 0x00333535, - 0x00343535, - 0x00353535, - 0x00363535, - 0x00373535, - 0x00383535, - 0x00393535, - 0x00303635, - 0x00313635, - 0x00323635, - 0x00333635, - 0x00343635, - 0x00353635, - 0x00363635, - 0x00373635, - 0x00383635, - 0x00393635, - 0x00303735, - 0x00313735, - 0x00323735, - 0x00333735, - 0x00343735, - 0x00353735, - 0x00363735, - 0x00373735, - 0x00383735, - 0x00393735, - 0x00303835, - 0x00313835, - 0x00323835, - 0x00333835, - 0x00343835, - 0x00353835, - 0x00363835, - 0x00373835, - 0x00383835, - 0x00393835, - 0x00303935, - 0x00313935, - 0x00323935, - 0x00333935, - 0x00343935, - 0x00353935, - 0x00363935, - 0x00373935, - 0x00383935, - 0x00393935, - 0x00303036, - 0x00313036, - 0x00323036, - 0x00333036, - 0x00343036, - 0x00353036, - 0x00363036, - 0x00373036, - 0x00383036, - 0x00393036, - 0x00303136, - 0x00313136, - 0x00323136, - 0x00333136, - 0x00343136, - 0x00353136, - 0x00363136, - 0x00373136, - 0x00383136, - 0x00393136, - 0x00303236, - 0x00313236, - 0x00323236, - 0x00333236, - 0x00343236, - 0x00353236, - 0x00363236, - 0x00373236, - 0x00383236, - 0x00393236, - 0x00303336, - 0x00313336, - 0x00323336, - 0x00333336, - 0x00343336, - 0x00353336, - 0x00363336, - 0x00373336, - 0x00383336, - 0x00393336, - 0x00303436, - 0x00313436, - 0x00323436, - 0x00333436, - 0x00343436, - 0x00353436, - 0x00363436, - 0x00373436, - 0x00383436, - 0x00393436, - 0x00303536, - 0x00313536, - 0x00323536, - 0x00333536, - 0x00343536, - 0x00353536, - 0x00363536, - 0x00373536, - 0x00383536, - 0x00393536, - 0x00303636, - 0x00313636, - 0x00323636, - 0x00333636, - 0x00343636, - 0x00353636, - 0x00363636, - 0x00373636, - 0x00383636, - 0x00393636, - 0x00303736, - 0x00313736, - 0x00323736, - 0x00333736, - 0x00343736, - 0x00353736, - 0x00363736, - 0x00373736, - 0x00383736, - 0x00393736, - 0x00303836, - 0x00313836, - 0x00323836, - 0x00333836, - 0x00343836, - 0x00353836, - 0x00363836, - 0x00373836, - 0x00383836, - 0x00393836, - 0x00303936, - 0x00313936, - 0x00323936, - 0x00333936, - 0x00343936, - 0x00353936, - 0x00363936, - 0x00373936, - 0x00383936, - 0x00393936, - 0x00303037, - 0x00313037, - 0x00323037, - 0x00333037, - 0x00343037, - 0x00353037, - 0x00363037, - 0x00373037, - 0x00383037, - 0x00393037, - 0x00303137, - 0x00313137, - 0x00323137, - 0x00333137, - 0x00343137, - 0x00353137, - 0x00363137, - 0x00373137, - 0x00383137, - 0x00393137, - 0x00303237, - 0x00313237, - 0x00323237, - 0x00333237, - 0x00343237, - 0x00353237, - 0x00363237, - 0x00373237, - 0x00383237, - 0x00393237, - 0x00303337, - 0x00313337, - 0x00323337, - 0x00333337, - 0x00343337, - 0x00353337, - 0x00363337, - 0x00373337, - 0x00383337, - 0x00393337, - 0x00303437, - 0x00313437, - 0x00323437, - 0x00333437, - 0x00343437, - 0x00353437, - 0x00363437, - 0x00373437, - 0x00383437, - 0x00393437, - 0x00303537, - 0x00313537, - 0x00323537, - 0x00333537, - 0x00343537, - 0x00353537, - 0x00363537, - 0x00373537, - 0x00383537, - 0x00393537, - 0x00303637, - 0x00313637, - 0x00323637, - 0x00333637, - 0x00343637, - 0x00353637, - 0x00363637, - 0x00373637, - 0x00383637, - 0x00393637, - 0x00303737, - 0x00313737, - 0x00323737, - 0x00333737, - 0x00343737, - 0x00353737, - 0x00363737, - 0x00373737, - 0x00383737, - 0x00393737, - 0x00303837, - 0x00313837, - 0x00323837, - 0x00333837, - 0x00343837, - 0x00353837, - 0x00363837, - 0x00373837, - 0x00383837, - 0x00393837, - 0x00303937, - 0x00313937, - 0x00323937, - 0x00333937, - 0x00343937, - 0x00353937, - 0x00363937, - 0x00373937, - 0x00383937, - 0x00393937, - 0x00303038, - 0x00313038, - 0x00323038, - 0x00333038, - 0x00343038, - 0x00353038, - 0x00363038, - 0x00373038, - 0x00383038, - 0x00393038, - 0x00303138, - 0x00313138, - 0x00323138, - 0x00333138, - 0x00343138, - 0x00353138, - 0x00363138, - 0x00373138, - 0x00383138, - 0x00393138, - 0x00303238, - 0x00313238, - 0x00323238, - 0x00333238, - 0x00343238, - 0x00353238, - 0x00363238, - 0x00373238, - 0x00383238, - 0x00393238, - 0x00303338, - 0x00313338, - 0x00323338, - 0x00333338, - 0x00343338, - 0x00353338, - 0x00363338, - 0x00373338, - 0x00383338, - 0x00393338, - 0x00303438, - 0x00313438, - 0x00323438, - 0x00333438, - 0x00343438, - 0x00353438, - 0x00363438, - 0x00373438, - 0x00383438, - 0x00393438, - 0x00303538, - 0x00313538, - 0x00323538, - 0x00333538, - 0x00343538, - 0x00353538, - 0x00363538, - 0x00373538, - 0x00383538, - 0x00393538, - 0x00303638, - 0x00313638, - 0x00323638, - 0x00333638, - 0x00343638, - 0x00353638, - 0x00363638, - 0x00373638, - 0x00383638, - 0x00393638, - 0x00303738, - 0x00313738, - 0x00323738, - 0x00333738, - 0x00343738, - 0x00353738, - 0x00363738, - 0x00373738, - 0x00383738, - 0x00393738, - 0x00303838, - 0x00313838, - 0x00323838, - 0x00333838, - 0x00343838, - 0x00353838, - 0x00363838, - 0x00373838, - 0x00383838, - 0x00393838, - 0x00303938, - 0x00313938, - 0x00323938, - 0x00333938, - 0x00343938, - 0x00353938, - 0x00363938, - 0x00373938, - 0x00383938, - 0x00393938, - 0x00303039, - 0x00313039, - 0x00323039, - 0x00333039, - 0x00343039, - 0x00353039, - 0x00363039, - 0x00373039, - 0x00383039, - 0x00393039, - 0x00303139, - 0x00313139, - 0x00323139, - 0x00333139, - 0x00343139, - 0x00353139, - 0x00363139, - 0x00373139, - 0x00383139, - 0x00393139, - 0x00303239, - 0x00313239, - 0x00323239, - 0x00333239, - 0x00343239, - 0x00353239, - 0x00363239, - 0x00373239, - 0x00383239, - 0x00393239, - 0x00303339, - 0x00313339, - 0x00323339, - 0x00333339, - 0x00343339, - 0x00353339, - 0x00363339, - 0x00373339, - 0x00383339, - 0x00393339, - 0x00303439, - 0x00313439, - 0x00323439, - 0x00333439, - 0x00343439, - 0x00353439, - 0x00363439, - 0x00373439, - 0x00383439, - 0x00393439, - 0x00303539, - 0x00313539, - 0x00323539, - 0x00333539, - 0x00343539, - 0x00353539, - 0x00363539, - 0x00373539, - 0x00383539, - 0x00393539, - 0x00303639, - 0x00313639, - 0x00323639, - 0x00333639, - 0x00343639, - 0x00353639, - 0x00363639, - 0x00373639, - 0x00383639, - 0x00393639, - 0x00303739, - 0x00313739, - 0x00323739, - 0x00333739, - 0x00343739, - 0x00353739, - 0x00363739, - 0x00373739, - 0x00383739, - 0x00393739, - 0x00303839, - 0x00313839, - 0x00323839, - 0x00333839, - 0x00343839, - 0x00353839, - 0x00363839, - 0x00373839, - 0x00383839, - 0x00393839, - 0x00303939, - 0x00313939, - 0x00323939, - 0x00333939, - 0x00343939, - 0x00353939, - 0x00363939, - 0x00373939, - 0x00383939, - 0x00393939, - 0x30303031, - 0x31303031, - 0x32303031, - 0x33303031, - 0x34303031, - 0x35303031, - 0x36303031, - 0x37303031, - 0x38303031, - 0x39303031, - 0x30313031, - 0x31313031, - 0x32313031, - 0x33313031, - 0x34313031, - 0x35313031, - 0x36313031, - 0x37313031, - 0x38313031, - 0x39313031, - 0x30323031, - 0x31323031, - 0x32323031, - 0x33323031, + 0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, + 0x00000038, 0x00000039, 0x00003031, 0x00003131, 0x00003231, 0x00003331, 0x00003431, 0x00003531, + 0x00003631, 0x00003731, 0x00003831, 0x00003931, 0x00003032, 0x00003132, 0x00003232, 0x00003332, + 0x00003432, 0x00003532, 0x00003632, 0x00003732, 0x00003832, 0x00003932, 0x00003033, 0x00003133, + 0x00003233, 0x00003333, 0x00003433, 0x00003533, 0x00003633, 0x00003733, 0x00003833, 0x00003933, + 0x00003034, 0x00003134, 0x00003234, 0x00003334, 0x00003434, 0x00003534, 0x00003634, 0x00003734, + 0x00003834, 0x00003934, 0x00003035, 0x00003135, 0x00003235, 0x00003335, 0x00003435, 0x00003535, + 0x00003635, 0x00003735, 0x00003835, 0x00003935, 0x00003036, 0x00003136, 0x00003236, 0x00003336, + 0x00003436, 0x00003536, 0x00003636, 0x00003736, 0x00003836, 0x00003936, 0x00003037, 0x00003137, + 0x00003237, 0x00003337, 0x00003437, 0x00003537, 0x00003637, 0x00003737, 0x00003837, 0x00003937, + 0x00003038, 0x00003138, 0x00003238, 0x00003338, 0x00003438, 0x00003538, 0x00003638, 0x00003738, + 0x00003838, 0x00003938, 0x00003039, 0x00003139, 0x00003239, 0x00003339, 0x00003439, 0x00003539, + 0x00003639, 0x00003739, 0x00003839, 0x00003939, 0x00303031, 0x00313031, 0x00323031, 0x00333031, + 0x00343031, 0x00353031, 0x00363031, 0x00373031, 0x00383031, 0x00393031, 0x00303131, 0x00313131, + 0x00323131, 0x00333131, 0x00343131, 0x00353131, 0x00363131, 0x00373131, 0x00383131, 0x00393131, + 0x00303231, 0x00313231, 0x00323231, 0x00333231, 0x00343231, 0x00353231, 0x00363231, 0x00373231, + 0x00383231, 0x00393231, 0x00303331, 0x00313331, 0x00323331, 0x00333331, 0x00343331, 0x00353331, + 0x00363331, 0x00373331, 0x00383331, 0x00393331, 0x00303431, 0x00313431, 0x00323431, 0x00333431, + 0x00343431, 0x00353431, 0x00363431, 0x00373431, 0x00383431, 0x00393431, 0x00303531, 0x00313531, + 0x00323531, 0x00333531, 0x00343531, 0x00353531, 0x00363531, 0x00373531, 0x00383531, 0x00393531, + 0x00303631, 0x00313631, 0x00323631, 0x00333631, 0x00343631, 0x00353631, 0x00363631, 0x00373631, + 0x00383631, 0x00393631, 0x00303731, 0x00313731, 0x00323731, 0x00333731, 0x00343731, 0x00353731, + 0x00363731, 0x00373731, 0x00383731, 0x00393731, 0x00303831, 0x00313831, 0x00323831, 0x00333831, + 0x00343831, 0x00353831, 0x00363831, 0x00373831, 0x00383831, 0x00393831, 0x00303931, 0x00313931, + 0x00323931, 0x00333931, 0x00343931, 0x00353931, 0x00363931, 0x00373931, 0x00383931, 0x00393931, + 0x00303032, 0x00313032, 0x00323032, 0x00333032, 0x00343032, 0x00353032, 0x00363032, 0x00373032, + 0x00383032, 0x00393032, 0x00303132, 0x00313132, 0x00323132, 0x00333132, 0x00343132, 0x00353132, + 0x00363132, 0x00373132, 0x00383132, 0x00393132, 0x00303232, 0x00313232, 0x00323232, 0x00333232, + 0x00343232, 0x00353232, 0x00363232, 0x00373232, 0x00383232, 0x00393232, 0x00303332, 0x00313332, + 0x00323332, 0x00333332, 0x00343332, 0x00353332, 0x00363332, 0x00373332, 0x00383332, 0x00393332, + 0x00303432, 0x00313432, 0x00323432, 0x00333432, 0x00343432, 0x00353432, 0x00363432, 0x00373432, + 0x00383432, 0x00393432, 0x00303532, 0x00313532, 0x00323532, 0x00333532, 0x00343532, 0x00353532, + 0x00363532, 0x00373532, 0x00383532, 0x00393532, 0x00303632, 0x00313632, 0x00323632, 0x00333632, + 0x00343632, 0x00353632, 0x00363632, 0x00373632, 0x00383632, 0x00393632, 0x00303732, 0x00313732, + 0x00323732, 0x00333732, 0x00343732, 0x00353732, 0x00363732, 0x00373732, 0x00383732, 0x00393732, + 0x00303832, 0x00313832, 0x00323832, 0x00333832, 0x00343832, 0x00353832, 0x00363832, 0x00373832, + 0x00383832, 0x00393832, 0x00303932, 0x00313932, 0x00323932, 0x00333932, 0x00343932, 0x00353932, + 0x00363932, 0x00373932, 0x00383932, 0x00393932, 0x00303033, 0x00313033, 0x00323033, 0x00333033, + 0x00343033, 0x00353033, 0x00363033, 0x00373033, 0x00383033, 0x00393033, 0x00303133, 0x00313133, + 0x00323133, 0x00333133, 0x00343133, 0x00353133, 0x00363133, 0x00373133, 0x00383133, 0x00393133, + 0x00303233, 0x00313233, 0x00323233, 0x00333233, 0x00343233, 0x00353233, 0x00363233, 0x00373233, + 0x00383233, 0x00393233, 0x00303333, 0x00313333, 0x00323333, 0x00333333, 0x00343333, 0x00353333, + 0x00363333, 0x00373333, 0x00383333, 0x00393333, 0x00303433, 0x00313433, 0x00323433, 0x00333433, + 0x00343433, 0x00353433, 0x00363433, 0x00373433, 0x00383433, 0x00393433, 0x00303533, 0x00313533, + 0x00323533, 0x00333533, 0x00343533, 0x00353533, 0x00363533, 0x00373533, 0x00383533, 0x00393533, + 0x00303633, 0x00313633, 0x00323633, 0x00333633, 0x00343633, 0x00353633, 0x00363633, 0x00373633, + 0x00383633, 0x00393633, 0x00303733, 0x00313733, 0x00323733, 0x00333733, 0x00343733, 0x00353733, + 0x00363733, 0x00373733, 0x00383733, 0x00393733, 0x00303833, 0x00313833, 0x00323833, 0x00333833, + 0x00343833, 0x00353833, 0x00363833, 0x00373833, 0x00383833, 0x00393833, 0x00303933, 0x00313933, + 0x00323933, 0x00333933, 0x00343933, 0x00353933, 0x00363933, 0x00373933, 0x00383933, 0x00393933, + 0x00303034, 0x00313034, 0x00323034, 0x00333034, 0x00343034, 0x00353034, 0x00363034, 0x00373034, + 0x00383034, 0x00393034, 0x00303134, 0x00313134, 0x00323134, 0x00333134, 0x00343134, 0x00353134, + 0x00363134, 0x00373134, 0x00383134, 0x00393134, 0x00303234, 0x00313234, 0x00323234, 0x00333234, + 0x00343234, 0x00353234, 0x00363234, 0x00373234, 0x00383234, 0x00393234, 0x00303334, 0x00313334, + 0x00323334, 0x00333334, 0x00343334, 0x00353334, 0x00363334, 0x00373334, 0x00383334, 0x00393334, + 0x00303434, 0x00313434, 0x00323434, 0x00333434, 0x00343434, 0x00353434, 0x00363434, 0x00373434, + 0x00383434, 0x00393434, 0x00303534, 0x00313534, 0x00323534, 0x00333534, 0x00343534, 0x00353534, + 0x00363534, 0x00373534, 0x00383534, 0x00393534, 0x00303634, 0x00313634, 0x00323634, 0x00333634, + 0x00343634, 0x00353634, 0x00363634, 0x00373634, 0x00383634, 0x00393634, 0x00303734, 0x00313734, + 0x00323734, 0x00333734, 0x00343734, 0x00353734, 0x00363734, 0x00373734, 0x00383734, 0x00393734, + 0x00303834, 0x00313834, 0x00323834, 0x00333834, 0x00343834, 0x00353834, 0x00363834, 0x00373834, + 0x00383834, 0x00393834, 0x00303934, 0x00313934, 0x00323934, 0x00333934, 0x00343934, 0x00353934, + 0x00363934, 0x00373934, 0x00383934, 0x00393934, 0x00303035, 0x00313035, 0x00323035, 0x00333035, + 0x00343035, 0x00353035, 0x00363035, 0x00373035, 0x00383035, 0x00393035, 0x00303135, 0x00313135, + 0x00323135, 0x00333135, 0x00343135, 0x00353135, 0x00363135, 0x00373135, 0x00383135, 0x00393135, + 0x00303235, 0x00313235, 0x00323235, 0x00333235, 0x00343235, 0x00353235, 0x00363235, 0x00373235, + 0x00383235, 0x00393235, 0x00303335, 0x00313335, 0x00323335, 0x00333335, 0x00343335, 0x00353335, + 0x00363335, 0x00373335, 0x00383335, 0x00393335, 0x00303435, 0x00313435, 0x00323435, 0x00333435, + 0x00343435, 0x00353435, 0x00363435, 0x00373435, 0x00383435, 0x00393435, 0x00303535, 0x00313535, + 0x00323535, 0x00333535, 0x00343535, 0x00353535, 0x00363535, 0x00373535, 0x00383535, 0x00393535, + 0x00303635, 0x00313635, 0x00323635, 0x00333635, 0x00343635, 0x00353635, 0x00363635, 0x00373635, + 0x00383635, 0x00393635, 0x00303735, 0x00313735, 0x00323735, 0x00333735, 0x00343735, 0x00353735, + 0x00363735, 0x00373735, 0x00383735, 0x00393735, 0x00303835, 0x00313835, 0x00323835, 0x00333835, + 0x00343835, 0x00353835, 0x00363835, 0x00373835, 0x00383835, 0x00393835, 0x00303935, 0x00313935, + 0x00323935, 0x00333935, 0x00343935, 0x00353935, 0x00363935, 0x00373935, 0x00383935, 0x00393935, + 0x00303036, 0x00313036, 0x00323036, 0x00333036, 0x00343036, 0x00353036, 0x00363036, 0x00373036, + 0x00383036, 0x00393036, 0x00303136, 0x00313136, 0x00323136, 0x00333136, 0x00343136, 0x00353136, + 0x00363136, 0x00373136, 0x00383136, 0x00393136, 0x00303236, 0x00313236, 0x00323236, 0x00333236, + 0x00343236, 0x00353236, 0x00363236, 0x00373236, 0x00383236, 0x00393236, 0x00303336, 0x00313336, + 0x00323336, 0x00333336, 0x00343336, 0x00353336, 0x00363336, 0x00373336, 0x00383336, 0x00393336, + 0x00303436, 0x00313436, 0x00323436, 0x00333436, 0x00343436, 0x00353436, 0x00363436, 0x00373436, + 0x00383436, 0x00393436, 0x00303536, 0x00313536, 0x00323536, 0x00333536, 0x00343536, 0x00353536, + 0x00363536, 0x00373536, 0x00383536, 0x00393536, 0x00303636, 0x00313636, 0x00323636, 0x00333636, + 0x00343636, 0x00353636, 0x00363636, 0x00373636, 0x00383636, 0x00393636, 0x00303736, 0x00313736, + 0x00323736, 0x00333736, 0x00343736, 0x00353736, 0x00363736, 0x00373736, 0x00383736, 0x00393736, + 0x00303836, 0x00313836, 0x00323836, 0x00333836, 0x00343836, 0x00353836, 0x00363836, 0x00373836, + 0x00383836, 0x00393836, 0x00303936, 0x00313936, 0x00323936, 0x00333936, 0x00343936, 0x00353936, + 0x00363936, 0x00373936, 0x00383936, 0x00393936, 0x00303037, 0x00313037, 0x00323037, 0x00333037, + 0x00343037, 0x00353037, 0x00363037, 0x00373037, 0x00383037, 0x00393037, 0x00303137, 0x00313137, + 0x00323137, 0x00333137, 0x00343137, 0x00353137, 0x00363137, 0x00373137, 0x00383137, 0x00393137, + 0x00303237, 0x00313237, 0x00323237, 0x00333237, 0x00343237, 0x00353237, 0x00363237, 0x00373237, + 0x00383237, 0x00393237, 0x00303337, 0x00313337, 0x00323337, 0x00333337, 0x00343337, 0x00353337, + 0x00363337, 0x00373337, 0x00383337, 0x00393337, 0x00303437, 0x00313437, 0x00323437, 0x00333437, + 0x00343437, 0x00353437, 0x00363437, 0x00373437, 0x00383437, 0x00393437, 0x00303537, 0x00313537, + 0x00323537, 0x00333537, 0x00343537, 0x00353537, 0x00363537, 0x00373537, 0x00383537, 0x00393537, + 0x00303637, 0x00313637, 0x00323637, 0x00333637, 0x00343637, 0x00353637, 0x00363637, 0x00373637, + 0x00383637, 0x00393637, 0x00303737, 0x00313737, 0x00323737, 0x00333737, 0x00343737, 0x00353737, + 0x00363737, 0x00373737, 0x00383737, 0x00393737, 0x00303837, 0x00313837, 0x00323837, 0x00333837, + 0x00343837, 0x00353837, 0x00363837, 0x00373837, 0x00383837, 0x00393837, 0x00303937, 0x00313937, + 0x00323937, 0x00333937, 0x00343937, 0x00353937, 0x00363937, 0x00373937, 0x00383937, 0x00393937, + 0x00303038, 0x00313038, 0x00323038, 0x00333038, 0x00343038, 0x00353038, 0x00363038, 0x00373038, + 0x00383038, 0x00393038, 0x00303138, 0x00313138, 0x00323138, 0x00333138, 0x00343138, 0x00353138, + 0x00363138, 0x00373138, 0x00383138, 0x00393138, 0x00303238, 0x00313238, 0x00323238, 0x00333238, + 0x00343238, 0x00353238, 0x00363238, 0x00373238, 0x00383238, 0x00393238, 0x00303338, 0x00313338, + 0x00323338, 0x00333338, 0x00343338, 0x00353338, 0x00363338, 0x00373338, 0x00383338, 0x00393338, + 0x00303438, 0x00313438, 0x00323438, 0x00333438, 0x00343438, 0x00353438, 0x00363438, 0x00373438, + 0x00383438, 0x00393438, 0x00303538, 0x00313538, 0x00323538, 0x00333538, 0x00343538, 0x00353538, + 0x00363538, 0x00373538, 0x00383538, 0x00393538, 0x00303638, 0x00313638, 0x00323638, 0x00333638, + 0x00343638, 0x00353638, 0x00363638, 0x00373638, 0x00383638, 0x00393638, 0x00303738, 0x00313738, + 0x00323738, 0x00333738, 0x00343738, 0x00353738, 0x00363738, 0x00373738, 0x00383738, 0x00393738, + 0x00303838, 0x00313838, 0x00323838, 0x00333838, 0x00343838, 0x00353838, 0x00363838, 0x00373838, + 0x00383838, 0x00393838, 0x00303938, 0x00313938, 0x00323938, 0x00333938, 0x00343938, 0x00353938, + 0x00363938, 0x00373938, 0x00383938, 0x00393938, 0x00303039, 0x00313039, 0x00323039, 0x00333039, + 0x00343039, 0x00353039, 0x00363039, 0x00373039, 0x00383039, 0x00393039, 0x00303139, 0x00313139, + 0x00323139, 0x00333139, 0x00343139, 0x00353139, 0x00363139, 0x00373139, 0x00383139, 0x00393139, + 0x00303239, 0x00313239, 0x00323239, 0x00333239, 0x00343239, 0x00353239, 0x00363239, 0x00373239, + 0x00383239, 0x00393239, 0x00303339, 0x00313339, 0x00323339, 0x00333339, 0x00343339, 0x00353339, + 0x00363339, 0x00373339, 0x00383339, 0x00393339, 0x00303439, 0x00313439, 0x00323439, 0x00333439, + 0x00343439, 0x00353439, 0x00363439, 0x00373439, 0x00383439, 0x00393439, 0x00303539, 0x00313539, + 0x00323539, 0x00333539, 0x00343539, 0x00353539, 0x00363539, 0x00373539, 0x00383539, 0x00393539, + 0x00303639, 0x00313639, 0x00323639, 0x00333639, 0x00343639, 0x00353639, 0x00363639, 0x00373639, + 0x00383639, 0x00393639, 0x00303739, 0x00313739, 0x00323739, 0x00333739, 0x00343739, 0x00353739, + 0x00363739, 0x00373739, 0x00383739, 0x00393739, 0x00303839, 0x00313839, 0x00323839, 0x00333839, + 0x00343839, 0x00353839, 0x00363839, 0x00373839, 0x00383839, 0x00393839, 0x00303939, 0x00313939, + 0x00323939, 0x00333939, 0x00343939, 0x00353939, 0x00363939, 0x00373939, 0x00383939, 0x00393939, + 0x30303031, 0x31303031, 0x32303031, 0x33303031, 0x34303031, 0x35303031, 0x36303031, 0x37303031, + 0x38303031, 0x39303031, 0x30313031, 0x31313031, 0x32313031, 0x33313031, 0x34313031, 0x35313031, + 0x36313031, 0x37313031, 0x38313031, 0x39313031, 0x30323031, 0x31323031, 0x32323031, 0x33323031 }; CONSTANT_VK u32a c_pc_len[1024] = { - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; DECLSPEC void append_word (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS const u32 *append, const u32 offset) diff --git a/OpenCL/m05800-pure.cl b/OpenCL/m05800-pure.cl index 4624de63e..313530194 100644 --- a/OpenCL/m05800-pure.cl +++ b/OpenCL/m05800-pure.cl @@ -22,2058 +22,170 @@ typedef struct androidpin_tmp CONSTANT_VK u32a c_pc_dec[1024] = { - 0x00000030, - 0x00000031, - 0x00000032, - 0x00000033, - 0x00000034, - 0x00000035, - 0x00000036, - 0x00000037, - 0x00000038, - 0x00000039, - 0x00003031, - 0x00003131, - 0x00003231, - 0x00003331, - 0x00003431, - 0x00003531, - 0x00003631, - 0x00003731, - 0x00003831, - 0x00003931, - 0x00003032, - 0x00003132, - 0x00003232, - 0x00003332, - 0x00003432, - 0x00003532, - 0x00003632, - 0x00003732, - 0x00003832, - 0x00003932, - 0x00003033, - 0x00003133, - 0x00003233, - 0x00003333, - 0x00003433, - 0x00003533, - 0x00003633, - 0x00003733, - 0x00003833, - 0x00003933, - 0x00003034, - 0x00003134, - 0x00003234, - 0x00003334, - 0x00003434, - 0x00003534, - 0x00003634, - 0x00003734, - 0x00003834, - 0x00003934, - 0x00003035, - 0x00003135, - 0x00003235, - 0x00003335, - 0x00003435, - 0x00003535, - 0x00003635, - 0x00003735, - 0x00003835, - 0x00003935, - 0x00003036, - 0x00003136, - 0x00003236, - 0x00003336, - 0x00003436, - 0x00003536, - 0x00003636, - 0x00003736, - 0x00003836, - 0x00003936, - 0x00003037, - 0x00003137, - 0x00003237, - 0x00003337, - 0x00003437, - 0x00003537, - 0x00003637, - 0x00003737, - 0x00003837, - 0x00003937, - 0x00003038, - 0x00003138, - 0x00003238, - 0x00003338, - 0x00003438, - 0x00003538, - 0x00003638, - 0x00003738, - 0x00003838, - 0x00003938, - 0x00003039, - 0x00003139, - 0x00003239, - 0x00003339, - 0x00003439, - 0x00003539, - 0x00003639, - 0x00003739, - 0x00003839, - 0x00003939, - 0x00303031, - 0x00313031, - 0x00323031, - 0x00333031, - 0x00343031, - 0x00353031, - 0x00363031, - 0x00373031, - 0x00383031, - 0x00393031, - 0x00303131, - 0x00313131, - 0x00323131, - 0x00333131, - 0x00343131, - 0x00353131, - 0x00363131, - 0x00373131, - 0x00383131, - 0x00393131, - 0x00303231, - 0x00313231, - 0x00323231, - 0x00333231, - 0x00343231, - 0x00353231, - 0x00363231, - 0x00373231, - 0x00383231, - 0x00393231, - 0x00303331, - 0x00313331, - 0x00323331, - 0x00333331, - 0x00343331, - 0x00353331, - 0x00363331, - 0x00373331, - 0x00383331, - 0x00393331, - 0x00303431, - 0x00313431, - 0x00323431, - 0x00333431, - 0x00343431, - 0x00353431, - 0x00363431, - 0x00373431, - 0x00383431, - 0x00393431, - 0x00303531, - 0x00313531, - 0x00323531, - 0x00333531, - 0x00343531, - 0x00353531, - 0x00363531, - 0x00373531, - 0x00383531, - 0x00393531, - 0x00303631, - 0x00313631, - 0x00323631, - 0x00333631, - 0x00343631, - 0x00353631, - 0x00363631, - 0x00373631, - 0x00383631, - 0x00393631, - 0x00303731, - 0x00313731, - 0x00323731, - 0x00333731, - 0x00343731, - 0x00353731, - 0x00363731, - 0x00373731, - 0x00383731, - 0x00393731, - 0x00303831, - 0x00313831, - 0x00323831, - 0x00333831, - 0x00343831, - 0x00353831, - 0x00363831, - 0x00373831, - 0x00383831, - 0x00393831, - 0x00303931, - 0x00313931, - 0x00323931, - 0x00333931, - 0x00343931, - 0x00353931, - 0x00363931, - 0x00373931, - 0x00383931, - 0x00393931, - 0x00303032, - 0x00313032, - 0x00323032, - 0x00333032, - 0x00343032, - 0x00353032, - 0x00363032, - 0x00373032, - 0x00383032, - 0x00393032, - 0x00303132, - 0x00313132, - 0x00323132, - 0x00333132, - 0x00343132, - 0x00353132, - 0x00363132, - 0x00373132, - 0x00383132, - 0x00393132, - 0x00303232, - 0x00313232, - 0x00323232, - 0x00333232, - 0x00343232, - 0x00353232, - 0x00363232, - 0x00373232, - 0x00383232, - 0x00393232, - 0x00303332, - 0x00313332, - 0x00323332, - 0x00333332, - 0x00343332, - 0x00353332, - 0x00363332, - 0x00373332, - 0x00383332, - 0x00393332, - 0x00303432, - 0x00313432, - 0x00323432, - 0x00333432, - 0x00343432, - 0x00353432, - 0x00363432, - 0x00373432, - 0x00383432, - 0x00393432, - 0x00303532, - 0x00313532, - 0x00323532, - 0x00333532, - 0x00343532, - 0x00353532, - 0x00363532, - 0x00373532, - 0x00383532, - 0x00393532, - 0x00303632, - 0x00313632, - 0x00323632, - 0x00333632, - 0x00343632, - 0x00353632, - 0x00363632, - 0x00373632, - 0x00383632, - 0x00393632, - 0x00303732, - 0x00313732, - 0x00323732, - 0x00333732, - 0x00343732, - 0x00353732, - 0x00363732, - 0x00373732, - 0x00383732, - 0x00393732, - 0x00303832, - 0x00313832, - 0x00323832, - 0x00333832, - 0x00343832, - 0x00353832, - 0x00363832, - 0x00373832, - 0x00383832, - 0x00393832, - 0x00303932, - 0x00313932, - 0x00323932, - 0x00333932, - 0x00343932, - 0x00353932, - 0x00363932, - 0x00373932, - 0x00383932, - 0x00393932, - 0x00303033, - 0x00313033, - 0x00323033, - 0x00333033, - 0x00343033, - 0x00353033, - 0x00363033, - 0x00373033, - 0x00383033, - 0x00393033, - 0x00303133, - 0x00313133, - 0x00323133, - 0x00333133, - 0x00343133, - 0x00353133, - 0x00363133, - 0x00373133, - 0x00383133, - 0x00393133, - 0x00303233, - 0x00313233, - 0x00323233, - 0x00333233, - 0x00343233, - 0x00353233, - 0x00363233, - 0x00373233, - 0x00383233, - 0x00393233, - 0x00303333, - 0x00313333, - 0x00323333, - 0x00333333, - 0x00343333, - 0x00353333, - 0x00363333, - 0x00373333, - 0x00383333, - 0x00393333, - 0x00303433, - 0x00313433, - 0x00323433, - 0x00333433, - 0x00343433, - 0x00353433, - 0x00363433, - 0x00373433, - 0x00383433, - 0x00393433, - 0x00303533, - 0x00313533, - 0x00323533, - 0x00333533, - 0x00343533, - 0x00353533, - 0x00363533, - 0x00373533, - 0x00383533, - 0x00393533, - 0x00303633, - 0x00313633, - 0x00323633, - 0x00333633, - 0x00343633, - 0x00353633, - 0x00363633, - 0x00373633, - 0x00383633, - 0x00393633, - 0x00303733, - 0x00313733, - 0x00323733, - 0x00333733, - 0x00343733, - 0x00353733, - 0x00363733, - 0x00373733, - 0x00383733, - 0x00393733, - 0x00303833, - 0x00313833, - 0x00323833, - 0x00333833, - 0x00343833, - 0x00353833, - 0x00363833, - 0x00373833, - 0x00383833, - 0x00393833, - 0x00303933, - 0x00313933, - 0x00323933, - 0x00333933, - 0x00343933, - 0x00353933, - 0x00363933, - 0x00373933, - 0x00383933, - 0x00393933, - 0x00303034, - 0x00313034, - 0x00323034, - 0x00333034, - 0x00343034, - 0x00353034, - 0x00363034, - 0x00373034, - 0x00383034, - 0x00393034, - 0x00303134, - 0x00313134, - 0x00323134, - 0x00333134, - 0x00343134, - 0x00353134, - 0x00363134, - 0x00373134, - 0x00383134, - 0x00393134, - 0x00303234, - 0x00313234, - 0x00323234, - 0x00333234, - 0x00343234, - 0x00353234, - 0x00363234, - 0x00373234, - 0x00383234, - 0x00393234, - 0x00303334, - 0x00313334, - 0x00323334, - 0x00333334, - 0x00343334, - 0x00353334, - 0x00363334, - 0x00373334, - 0x00383334, - 0x00393334, - 0x00303434, - 0x00313434, - 0x00323434, - 0x00333434, - 0x00343434, - 0x00353434, - 0x00363434, - 0x00373434, - 0x00383434, - 0x00393434, - 0x00303534, - 0x00313534, - 0x00323534, - 0x00333534, - 0x00343534, - 0x00353534, - 0x00363534, - 0x00373534, - 0x00383534, - 0x00393534, - 0x00303634, - 0x00313634, - 0x00323634, - 0x00333634, - 0x00343634, - 0x00353634, - 0x00363634, - 0x00373634, - 0x00383634, - 0x00393634, - 0x00303734, - 0x00313734, - 0x00323734, - 0x00333734, - 0x00343734, - 0x00353734, - 0x00363734, - 0x00373734, - 0x00383734, - 0x00393734, - 0x00303834, - 0x00313834, - 0x00323834, - 0x00333834, - 0x00343834, - 0x00353834, - 0x00363834, - 0x00373834, - 0x00383834, - 0x00393834, - 0x00303934, - 0x00313934, - 0x00323934, - 0x00333934, - 0x00343934, - 0x00353934, - 0x00363934, - 0x00373934, - 0x00383934, - 0x00393934, - 0x00303035, - 0x00313035, - 0x00323035, - 0x00333035, - 0x00343035, - 0x00353035, - 0x00363035, - 0x00373035, - 0x00383035, - 0x00393035, - 0x00303135, - 0x00313135, - 0x00323135, - 0x00333135, - 0x00343135, - 0x00353135, - 0x00363135, - 0x00373135, - 0x00383135, - 0x00393135, - 0x00303235, - 0x00313235, - 0x00323235, - 0x00333235, - 0x00343235, - 0x00353235, - 0x00363235, - 0x00373235, - 0x00383235, - 0x00393235, - 0x00303335, - 0x00313335, - 0x00323335, - 0x00333335, - 0x00343335, - 0x00353335, - 0x00363335, - 0x00373335, - 0x00383335, - 0x00393335, - 0x00303435, - 0x00313435, - 0x00323435, - 0x00333435, - 0x00343435, - 0x00353435, - 0x00363435, - 0x00373435, - 0x00383435, - 0x00393435, - 0x00303535, - 0x00313535, - 0x00323535, - 0x00333535, - 0x00343535, - 0x00353535, - 0x00363535, - 0x00373535, - 0x00383535, - 0x00393535, - 0x00303635, - 0x00313635, - 0x00323635, - 0x00333635, - 0x00343635, - 0x00353635, - 0x00363635, - 0x00373635, - 0x00383635, - 0x00393635, - 0x00303735, - 0x00313735, - 0x00323735, - 0x00333735, - 0x00343735, - 0x00353735, - 0x00363735, - 0x00373735, - 0x00383735, - 0x00393735, - 0x00303835, - 0x00313835, - 0x00323835, - 0x00333835, - 0x00343835, - 0x00353835, - 0x00363835, - 0x00373835, - 0x00383835, - 0x00393835, - 0x00303935, - 0x00313935, - 0x00323935, - 0x00333935, - 0x00343935, - 0x00353935, - 0x00363935, - 0x00373935, - 0x00383935, - 0x00393935, - 0x00303036, - 0x00313036, - 0x00323036, - 0x00333036, - 0x00343036, - 0x00353036, - 0x00363036, - 0x00373036, - 0x00383036, - 0x00393036, - 0x00303136, - 0x00313136, - 0x00323136, - 0x00333136, - 0x00343136, - 0x00353136, - 0x00363136, - 0x00373136, - 0x00383136, - 0x00393136, - 0x00303236, - 0x00313236, - 0x00323236, - 0x00333236, - 0x00343236, - 0x00353236, - 0x00363236, - 0x00373236, - 0x00383236, - 0x00393236, - 0x00303336, - 0x00313336, - 0x00323336, - 0x00333336, - 0x00343336, - 0x00353336, - 0x00363336, - 0x00373336, - 0x00383336, - 0x00393336, - 0x00303436, - 0x00313436, - 0x00323436, - 0x00333436, - 0x00343436, - 0x00353436, - 0x00363436, - 0x00373436, - 0x00383436, - 0x00393436, - 0x00303536, - 0x00313536, - 0x00323536, - 0x00333536, - 0x00343536, - 0x00353536, - 0x00363536, - 0x00373536, - 0x00383536, - 0x00393536, - 0x00303636, - 0x00313636, - 0x00323636, - 0x00333636, - 0x00343636, - 0x00353636, - 0x00363636, - 0x00373636, - 0x00383636, - 0x00393636, - 0x00303736, - 0x00313736, - 0x00323736, - 0x00333736, - 0x00343736, - 0x00353736, - 0x00363736, - 0x00373736, - 0x00383736, - 0x00393736, - 0x00303836, - 0x00313836, - 0x00323836, - 0x00333836, - 0x00343836, - 0x00353836, - 0x00363836, - 0x00373836, - 0x00383836, - 0x00393836, - 0x00303936, - 0x00313936, - 0x00323936, - 0x00333936, - 0x00343936, - 0x00353936, - 0x00363936, - 0x00373936, - 0x00383936, - 0x00393936, - 0x00303037, - 0x00313037, - 0x00323037, - 0x00333037, - 0x00343037, - 0x00353037, - 0x00363037, - 0x00373037, - 0x00383037, - 0x00393037, - 0x00303137, - 0x00313137, - 0x00323137, - 0x00333137, - 0x00343137, - 0x00353137, - 0x00363137, - 0x00373137, - 0x00383137, - 0x00393137, - 0x00303237, - 0x00313237, - 0x00323237, - 0x00333237, - 0x00343237, - 0x00353237, - 0x00363237, - 0x00373237, - 0x00383237, - 0x00393237, - 0x00303337, - 0x00313337, - 0x00323337, - 0x00333337, - 0x00343337, - 0x00353337, - 0x00363337, - 0x00373337, - 0x00383337, - 0x00393337, - 0x00303437, - 0x00313437, - 0x00323437, - 0x00333437, - 0x00343437, - 0x00353437, - 0x00363437, - 0x00373437, - 0x00383437, - 0x00393437, - 0x00303537, - 0x00313537, - 0x00323537, - 0x00333537, - 0x00343537, - 0x00353537, - 0x00363537, - 0x00373537, - 0x00383537, - 0x00393537, - 0x00303637, - 0x00313637, - 0x00323637, - 0x00333637, - 0x00343637, - 0x00353637, - 0x00363637, - 0x00373637, - 0x00383637, - 0x00393637, - 0x00303737, - 0x00313737, - 0x00323737, - 0x00333737, - 0x00343737, - 0x00353737, - 0x00363737, - 0x00373737, - 0x00383737, - 0x00393737, - 0x00303837, - 0x00313837, - 0x00323837, - 0x00333837, - 0x00343837, - 0x00353837, - 0x00363837, - 0x00373837, - 0x00383837, - 0x00393837, - 0x00303937, - 0x00313937, - 0x00323937, - 0x00333937, - 0x00343937, - 0x00353937, - 0x00363937, - 0x00373937, - 0x00383937, - 0x00393937, - 0x00303038, - 0x00313038, - 0x00323038, - 0x00333038, - 0x00343038, - 0x00353038, - 0x00363038, - 0x00373038, - 0x00383038, - 0x00393038, - 0x00303138, - 0x00313138, - 0x00323138, - 0x00333138, - 0x00343138, - 0x00353138, - 0x00363138, - 0x00373138, - 0x00383138, - 0x00393138, - 0x00303238, - 0x00313238, - 0x00323238, - 0x00333238, - 0x00343238, - 0x00353238, - 0x00363238, - 0x00373238, - 0x00383238, - 0x00393238, - 0x00303338, - 0x00313338, - 0x00323338, - 0x00333338, - 0x00343338, - 0x00353338, - 0x00363338, - 0x00373338, - 0x00383338, - 0x00393338, - 0x00303438, - 0x00313438, - 0x00323438, - 0x00333438, - 0x00343438, - 0x00353438, - 0x00363438, - 0x00373438, - 0x00383438, - 0x00393438, - 0x00303538, - 0x00313538, - 0x00323538, - 0x00333538, - 0x00343538, - 0x00353538, - 0x00363538, - 0x00373538, - 0x00383538, - 0x00393538, - 0x00303638, - 0x00313638, - 0x00323638, - 0x00333638, - 0x00343638, - 0x00353638, - 0x00363638, - 0x00373638, - 0x00383638, - 0x00393638, - 0x00303738, - 0x00313738, - 0x00323738, - 0x00333738, - 0x00343738, - 0x00353738, - 0x00363738, - 0x00373738, - 0x00383738, - 0x00393738, - 0x00303838, - 0x00313838, - 0x00323838, - 0x00333838, - 0x00343838, - 0x00353838, - 0x00363838, - 0x00373838, - 0x00383838, - 0x00393838, - 0x00303938, - 0x00313938, - 0x00323938, - 0x00333938, - 0x00343938, - 0x00353938, - 0x00363938, - 0x00373938, - 0x00383938, - 0x00393938, - 0x00303039, - 0x00313039, - 0x00323039, - 0x00333039, - 0x00343039, - 0x00353039, - 0x00363039, - 0x00373039, - 0x00383039, - 0x00393039, - 0x00303139, - 0x00313139, - 0x00323139, - 0x00333139, - 0x00343139, - 0x00353139, - 0x00363139, - 0x00373139, - 0x00383139, - 0x00393139, - 0x00303239, - 0x00313239, - 0x00323239, - 0x00333239, - 0x00343239, - 0x00353239, - 0x00363239, - 0x00373239, - 0x00383239, - 0x00393239, - 0x00303339, - 0x00313339, - 0x00323339, - 0x00333339, - 0x00343339, - 0x00353339, - 0x00363339, - 0x00373339, - 0x00383339, - 0x00393339, - 0x00303439, - 0x00313439, - 0x00323439, - 0x00333439, - 0x00343439, - 0x00353439, - 0x00363439, - 0x00373439, - 0x00383439, - 0x00393439, - 0x00303539, - 0x00313539, - 0x00323539, - 0x00333539, - 0x00343539, - 0x00353539, - 0x00363539, - 0x00373539, - 0x00383539, - 0x00393539, - 0x00303639, - 0x00313639, - 0x00323639, - 0x00333639, - 0x00343639, - 0x00353639, - 0x00363639, - 0x00373639, - 0x00383639, - 0x00393639, - 0x00303739, - 0x00313739, - 0x00323739, - 0x00333739, - 0x00343739, - 0x00353739, - 0x00363739, - 0x00373739, - 0x00383739, - 0x00393739, - 0x00303839, - 0x00313839, - 0x00323839, - 0x00333839, - 0x00343839, - 0x00353839, - 0x00363839, - 0x00373839, - 0x00383839, - 0x00393839, - 0x00303939, - 0x00313939, - 0x00323939, - 0x00333939, - 0x00343939, - 0x00353939, - 0x00363939, - 0x00373939, - 0x00383939, - 0x00393939, - 0x30303031, - 0x31303031, - 0x32303031, - 0x33303031, - 0x34303031, - 0x35303031, - 0x36303031, - 0x37303031, - 0x38303031, - 0x39303031, - 0x30313031, - 0x31313031, - 0x32313031, - 0x33313031, - 0x34313031, - 0x35313031, - 0x36313031, - 0x37313031, - 0x38313031, - 0x39313031, - 0x30323031, - 0x31323031, - 0x32323031, - 0x33323031, + 0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, + 0x00000038, 0x00000039, 0x00003031, 0x00003131, 0x00003231, 0x00003331, 0x00003431, 0x00003531, + 0x00003631, 0x00003731, 0x00003831, 0x00003931, 0x00003032, 0x00003132, 0x00003232, 0x00003332, + 0x00003432, 0x00003532, 0x00003632, 0x00003732, 0x00003832, 0x00003932, 0x00003033, 0x00003133, + 0x00003233, 0x00003333, 0x00003433, 0x00003533, 0x00003633, 0x00003733, 0x00003833, 0x00003933, + 0x00003034, 0x00003134, 0x00003234, 0x00003334, 0x00003434, 0x00003534, 0x00003634, 0x00003734, + 0x00003834, 0x00003934, 0x00003035, 0x00003135, 0x00003235, 0x00003335, 0x00003435, 0x00003535, + 0x00003635, 0x00003735, 0x00003835, 0x00003935, 0x00003036, 0x00003136, 0x00003236, 0x00003336, + 0x00003436, 0x00003536, 0x00003636, 0x00003736, 0x00003836, 0x00003936, 0x00003037, 0x00003137, + 0x00003237, 0x00003337, 0x00003437, 0x00003537, 0x00003637, 0x00003737, 0x00003837, 0x00003937, + 0x00003038, 0x00003138, 0x00003238, 0x00003338, 0x00003438, 0x00003538, 0x00003638, 0x00003738, + 0x00003838, 0x00003938, 0x00003039, 0x00003139, 0x00003239, 0x00003339, 0x00003439, 0x00003539, + 0x00003639, 0x00003739, 0x00003839, 0x00003939, 0x00303031, 0x00313031, 0x00323031, 0x00333031, + 0x00343031, 0x00353031, 0x00363031, 0x00373031, 0x00383031, 0x00393031, 0x00303131, 0x00313131, + 0x00323131, 0x00333131, 0x00343131, 0x00353131, 0x00363131, 0x00373131, 0x00383131, 0x00393131, + 0x00303231, 0x00313231, 0x00323231, 0x00333231, 0x00343231, 0x00353231, 0x00363231, 0x00373231, + 0x00383231, 0x00393231, 0x00303331, 0x00313331, 0x00323331, 0x00333331, 0x00343331, 0x00353331, + 0x00363331, 0x00373331, 0x00383331, 0x00393331, 0x00303431, 0x00313431, 0x00323431, 0x00333431, + 0x00343431, 0x00353431, 0x00363431, 0x00373431, 0x00383431, 0x00393431, 0x00303531, 0x00313531, + 0x00323531, 0x00333531, 0x00343531, 0x00353531, 0x00363531, 0x00373531, 0x00383531, 0x00393531, + 0x00303631, 0x00313631, 0x00323631, 0x00333631, 0x00343631, 0x00353631, 0x00363631, 0x00373631, + 0x00383631, 0x00393631, 0x00303731, 0x00313731, 0x00323731, 0x00333731, 0x00343731, 0x00353731, + 0x00363731, 0x00373731, 0x00383731, 0x00393731, 0x00303831, 0x00313831, 0x00323831, 0x00333831, + 0x00343831, 0x00353831, 0x00363831, 0x00373831, 0x00383831, 0x00393831, 0x00303931, 0x00313931, + 0x00323931, 0x00333931, 0x00343931, 0x00353931, 0x00363931, 0x00373931, 0x00383931, 0x00393931, + 0x00303032, 0x00313032, 0x00323032, 0x00333032, 0x00343032, 0x00353032, 0x00363032, 0x00373032, + 0x00383032, 0x00393032, 0x00303132, 0x00313132, 0x00323132, 0x00333132, 0x00343132, 0x00353132, + 0x00363132, 0x00373132, 0x00383132, 0x00393132, 0x00303232, 0x00313232, 0x00323232, 0x00333232, + 0x00343232, 0x00353232, 0x00363232, 0x00373232, 0x00383232, 0x00393232, 0x00303332, 0x00313332, + 0x00323332, 0x00333332, 0x00343332, 0x00353332, 0x00363332, 0x00373332, 0x00383332, 0x00393332, + 0x00303432, 0x00313432, 0x00323432, 0x00333432, 0x00343432, 0x00353432, 0x00363432, 0x00373432, + 0x00383432, 0x00393432, 0x00303532, 0x00313532, 0x00323532, 0x00333532, 0x00343532, 0x00353532, + 0x00363532, 0x00373532, 0x00383532, 0x00393532, 0x00303632, 0x00313632, 0x00323632, 0x00333632, + 0x00343632, 0x00353632, 0x00363632, 0x00373632, 0x00383632, 0x00393632, 0x00303732, 0x00313732, + 0x00323732, 0x00333732, 0x00343732, 0x00353732, 0x00363732, 0x00373732, 0x00383732, 0x00393732, + 0x00303832, 0x00313832, 0x00323832, 0x00333832, 0x00343832, 0x00353832, 0x00363832, 0x00373832, + 0x00383832, 0x00393832, 0x00303932, 0x00313932, 0x00323932, 0x00333932, 0x00343932, 0x00353932, + 0x00363932, 0x00373932, 0x00383932, 0x00393932, 0x00303033, 0x00313033, 0x00323033, 0x00333033, + 0x00343033, 0x00353033, 0x00363033, 0x00373033, 0x00383033, 0x00393033, 0x00303133, 0x00313133, + 0x00323133, 0x00333133, 0x00343133, 0x00353133, 0x00363133, 0x00373133, 0x00383133, 0x00393133, + 0x00303233, 0x00313233, 0x00323233, 0x00333233, 0x00343233, 0x00353233, 0x00363233, 0x00373233, + 0x00383233, 0x00393233, 0x00303333, 0x00313333, 0x00323333, 0x00333333, 0x00343333, 0x00353333, + 0x00363333, 0x00373333, 0x00383333, 0x00393333, 0x00303433, 0x00313433, 0x00323433, 0x00333433, + 0x00343433, 0x00353433, 0x00363433, 0x00373433, 0x00383433, 0x00393433, 0x00303533, 0x00313533, + 0x00323533, 0x00333533, 0x00343533, 0x00353533, 0x00363533, 0x00373533, 0x00383533, 0x00393533, + 0x00303633, 0x00313633, 0x00323633, 0x00333633, 0x00343633, 0x00353633, 0x00363633, 0x00373633, + 0x00383633, 0x00393633, 0x00303733, 0x00313733, 0x00323733, 0x00333733, 0x00343733, 0x00353733, + 0x00363733, 0x00373733, 0x00383733, 0x00393733, 0x00303833, 0x00313833, 0x00323833, 0x00333833, + 0x00343833, 0x00353833, 0x00363833, 0x00373833, 0x00383833, 0x00393833, 0x00303933, 0x00313933, + 0x00323933, 0x00333933, 0x00343933, 0x00353933, 0x00363933, 0x00373933, 0x00383933, 0x00393933, + 0x00303034, 0x00313034, 0x00323034, 0x00333034, 0x00343034, 0x00353034, 0x00363034, 0x00373034, + 0x00383034, 0x00393034, 0x00303134, 0x00313134, 0x00323134, 0x00333134, 0x00343134, 0x00353134, + 0x00363134, 0x00373134, 0x00383134, 0x00393134, 0x00303234, 0x00313234, 0x00323234, 0x00333234, + 0x00343234, 0x00353234, 0x00363234, 0x00373234, 0x00383234, 0x00393234, 0x00303334, 0x00313334, + 0x00323334, 0x00333334, 0x00343334, 0x00353334, 0x00363334, 0x00373334, 0x00383334, 0x00393334, + 0x00303434, 0x00313434, 0x00323434, 0x00333434, 0x00343434, 0x00353434, 0x00363434, 0x00373434, + 0x00383434, 0x00393434, 0x00303534, 0x00313534, 0x00323534, 0x00333534, 0x00343534, 0x00353534, + 0x00363534, 0x00373534, 0x00383534, 0x00393534, 0x00303634, 0x00313634, 0x00323634, 0x00333634, + 0x00343634, 0x00353634, 0x00363634, 0x00373634, 0x00383634, 0x00393634, 0x00303734, 0x00313734, + 0x00323734, 0x00333734, 0x00343734, 0x00353734, 0x00363734, 0x00373734, 0x00383734, 0x00393734, + 0x00303834, 0x00313834, 0x00323834, 0x00333834, 0x00343834, 0x00353834, 0x00363834, 0x00373834, + 0x00383834, 0x00393834, 0x00303934, 0x00313934, 0x00323934, 0x00333934, 0x00343934, 0x00353934, + 0x00363934, 0x00373934, 0x00383934, 0x00393934, 0x00303035, 0x00313035, 0x00323035, 0x00333035, + 0x00343035, 0x00353035, 0x00363035, 0x00373035, 0x00383035, 0x00393035, 0x00303135, 0x00313135, + 0x00323135, 0x00333135, 0x00343135, 0x00353135, 0x00363135, 0x00373135, 0x00383135, 0x00393135, + 0x00303235, 0x00313235, 0x00323235, 0x00333235, 0x00343235, 0x00353235, 0x00363235, 0x00373235, + 0x00383235, 0x00393235, 0x00303335, 0x00313335, 0x00323335, 0x00333335, 0x00343335, 0x00353335, + 0x00363335, 0x00373335, 0x00383335, 0x00393335, 0x00303435, 0x00313435, 0x00323435, 0x00333435, + 0x00343435, 0x00353435, 0x00363435, 0x00373435, 0x00383435, 0x00393435, 0x00303535, 0x00313535, + 0x00323535, 0x00333535, 0x00343535, 0x00353535, 0x00363535, 0x00373535, 0x00383535, 0x00393535, + 0x00303635, 0x00313635, 0x00323635, 0x00333635, 0x00343635, 0x00353635, 0x00363635, 0x00373635, + 0x00383635, 0x00393635, 0x00303735, 0x00313735, 0x00323735, 0x00333735, 0x00343735, 0x00353735, + 0x00363735, 0x00373735, 0x00383735, 0x00393735, 0x00303835, 0x00313835, 0x00323835, 0x00333835, + 0x00343835, 0x00353835, 0x00363835, 0x00373835, 0x00383835, 0x00393835, 0x00303935, 0x00313935, + 0x00323935, 0x00333935, 0x00343935, 0x00353935, 0x00363935, 0x00373935, 0x00383935, 0x00393935, + 0x00303036, 0x00313036, 0x00323036, 0x00333036, 0x00343036, 0x00353036, 0x00363036, 0x00373036, + 0x00383036, 0x00393036, 0x00303136, 0x00313136, 0x00323136, 0x00333136, 0x00343136, 0x00353136, + 0x00363136, 0x00373136, 0x00383136, 0x00393136, 0x00303236, 0x00313236, 0x00323236, 0x00333236, + 0x00343236, 0x00353236, 0x00363236, 0x00373236, 0x00383236, 0x00393236, 0x00303336, 0x00313336, + 0x00323336, 0x00333336, 0x00343336, 0x00353336, 0x00363336, 0x00373336, 0x00383336, 0x00393336, + 0x00303436, 0x00313436, 0x00323436, 0x00333436, 0x00343436, 0x00353436, 0x00363436, 0x00373436, + 0x00383436, 0x00393436, 0x00303536, 0x00313536, 0x00323536, 0x00333536, 0x00343536, 0x00353536, + 0x00363536, 0x00373536, 0x00383536, 0x00393536, 0x00303636, 0x00313636, 0x00323636, 0x00333636, + 0x00343636, 0x00353636, 0x00363636, 0x00373636, 0x00383636, 0x00393636, 0x00303736, 0x00313736, + 0x00323736, 0x00333736, 0x00343736, 0x00353736, 0x00363736, 0x00373736, 0x00383736, 0x00393736, + 0x00303836, 0x00313836, 0x00323836, 0x00333836, 0x00343836, 0x00353836, 0x00363836, 0x00373836, + 0x00383836, 0x00393836, 0x00303936, 0x00313936, 0x00323936, 0x00333936, 0x00343936, 0x00353936, + 0x00363936, 0x00373936, 0x00383936, 0x00393936, 0x00303037, 0x00313037, 0x00323037, 0x00333037, + 0x00343037, 0x00353037, 0x00363037, 0x00373037, 0x00383037, 0x00393037, 0x00303137, 0x00313137, + 0x00323137, 0x00333137, 0x00343137, 0x00353137, 0x00363137, 0x00373137, 0x00383137, 0x00393137, + 0x00303237, 0x00313237, 0x00323237, 0x00333237, 0x00343237, 0x00353237, 0x00363237, 0x00373237, + 0x00383237, 0x00393237, 0x00303337, 0x00313337, 0x00323337, 0x00333337, 0x00343337, 0x00353337, + 0x00363337, 0x00373337, 0x00383337, 0x00393337, 0x00303437, 0x00313437, 0x00323437, 0x00333437, + 0x00343437, 0x00353437, 0x00363437, 0x00373437, 0x00383437, 0x00393437, 0x00303537, 0x00313537, + 0x00323537, 0x00333537, 0x00343537, 0x00353537, 0x00363537, 0x00373537, 0x00383537, 0x00393537, + 0x00303637, 0x00313637, 0x00323637, 0x00333637, 0x00343637, 0x00353637, 0x00363637, 0x00373637, + 0x00383637, 0x00393637, 0x00303737, 0x00313737, 0x00323737, 0x00333737, 0x00343737, 0x00353737, + 0x00363737, 0x00373737, 0x00383737, 0x00393737, 0x00303837, 0x00313837, 0x00323837, 0x00333837, + 0x00343837, 0x00353837, 0x00363837, 0x00373837, 0x00383837, 0x00393837, 0x00303937, 0x00313937, + 0x00323937, 0x00333937, 0x00343937, 0x00353937, 0x00363937, 0x00373937, 0x00383937, 0x00393937, + 0x00303038, 0x00313038, 0x00323038, 0x00333038, 0x00343038, 0x00353038, 0x00363038, 0x00373038, + 0x00383038, 0x00393038, 0x00303138, 0x00313138, 0x00323138, 0x00333138, 0x00343138, 0x00353138, + 0x00363138, 0x00373138, 0x00383138, 0x00393138, 0x00303238, 0x00313238, 0x00323238, 0x00333238, + 0x00343238, 0x00353238, 0x00363238, 0x00373238, 0x00383238, 0x00393238, 0x00303338, 0x00313338, + 0x00323338, 0x00333338, 0x00343338, 0x00353338, 0x00363338, 0x00373338, 0x00383338, 0x00393338, + 0x00303438, 0x00313438, 0x00323438, 0x00333438, 0x00343438, 0x00353438, 0x00363438, 0x00373438, + 0x00383438, 0x00393438, 0x00303538, 0x00313538, 0x00323538, 0x00333538, 0x00343538, 0x00353538, + 0x00363538, 0x00373538, 0x00383538, 0x00393538, 0x00303638, 0x00313638, 0x00323638, 0x00333638, + 0x00343638, 0x00353638, 0x00363638, 0x00373638, 0x00383638, 0x00393638, 0x00303738, 0x00313738, + 0x00323738, 0x00333738, 0x00343738, 0x00353738, 0x00363738, 0x00373738, 0x00383738, 0x00393738, + 0x00303838, 0x00313838, 0x00323838, 0x00333838, 0x00343838, 0x00353838, 0x00363838, 0x00373838, + 0x00383838, 0x00393838, 0x00303938, 0x00313938, 0x00323938, 0x00333938, 0x00343938, 0x00353938, + 0x00363938, 0x00373938, 0x00383938, 0x00393938, 0x00303039, 0x00313039, 0x00323039, 0x00333039, + 0x00343039, 0x00353039, 0x00363039, 0x00373039, 0x00383039, 0x00393039, 0x00303139, 0x00313139, + 0x00323139, 0x00333139, 0x00343139, 0x00353139, 0x00363139, 0x00373139, 0x00383139, 0x00393139, + 0x00303239, 0x00313239, 0x00323239, 0x00333239, 0x00343239, 0x00353239, 0x00363239, 0x00373239, + 0x00383239, 0x00393239, 0x00303339, 0x00313339, 0x00323339, 0x00333339, 0x00343339, 0x00353339, + 0x00363339, 0x00373339, 0x00383339, 0x00393339, 0x00303439, 0x00313439, 0x00323439, 0x00333439, + 0x00343439, 0x00353439, 0x00363439, 0x00373439, 0x00383439, 0x00393439, 0x00303539, 0x00313539, + 0x00323539, 0x00333539, 0x00343539, 0x00353539, 0x00363539, 0x00373539, 0x00383539, 0x00393539, + 0x00303639, 0x00313639, 0x00323639, 0x00333639, 0x00343639, 0x00353639, 0x00363639, 0x00373639, + 0x00383639, 0x00393639, 0x00303739, 0x00313739, 0x00323739, 0x00333739, 0x00343739, 0x00353739, + 0x00363739, 0x00373739, 0x00383739, 0x00393739, 0x00303839, 0x00313839, 0x00323839, 0x00333839, + 0x00343839, 0x00353839, 0x00363839, 0x00373839, 0x00383839, 0x00393839, 0x00303939, 0x00313939, + 0x00323939, 0x00333939, 0x00343939, 0x00353939, 0x00363939, 0x00373939, 0x00383939, 0x00393939, + 0x30303031, 0x31303031, 0x32303031, 0x33303031, 0x34303031, 0x35303031, 0x36303031, 0x37303031, + 0x38303031, 0x39303031, 0x30313031, 0x31313031, 0x32313031, 0x33313031, 0x34313031, 0x35313031, + 0x36313031, 0x37313031, 0x38313031, 0x39313031, 0x30323031, 0x31323031, 0x32323031, 0x33323031 }; CONSTANT_VK u32a c_pc_len[1024] = { - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 2, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 3, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4, - 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; KERNEL_FQ void m05800_init (KERN_ATTR_TMPS (androidpin_tmp_t)) diff --git a/OpenCL/m08800-pure.cl b/OpenCL/m08800-pure.cl index a0efce27f..cbd3a250d 100644 --- a/OpenCL/m08800-pure.cl +++ b/OpenCL/m08800-pure.cl @@ -436,7 +436,7 @@ KERNEL_FQ void m08800_comp (KERN_ATTR_TMPS_ESALT (androidfde_tmp_t, androidfde_t u32 r[16]; - // not needed because of cbc mode -- implementation flaw !!. first 16 byte are not interessting + // not needed because of cbc mode -- implementation flaw !!. first 16 bytes are not interesting r[0] = 0; r[1] = 0; diff --git a/OpenCL/m08900-pure.cl b/OpenCL/m08900-pure.cl index 5f96f8ec4..3064263a2 100644 --- a/OpenCL/m08900-pure.cl +++ b/OpenCL/m08900-pure.cl @@ -327,6 +327,9 @@ KERNEL_FQ void m08900_init (KERN_ATTR_TMPS (scrypt_tmp_t)) #if defined IS_CUDA || defined IS_HIP const uint4 tmp0 = make_uint4 (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = make_uint4 (digest[4], digest[5], digest[6], digest[7]); + #elif defined IS_METAL + const uint4 tmp0 = uint4 (digest[0], digest[1], digest[2], digest[3]); + const uint4 tmp1 = uint4 (digest[4], digest[5], digest[6], digest[7]); #else const uint4 tmp0 = (uint4) (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = (uint4) (digest[4], digest[5], digest[6], digest[7]); @@ -357,6 +360,11 @@ KERNEL_FQ void m08900_init (KERN_ATTR_TMPS (scrypt_tmp_t)) X[1] = make_uint4 (T[1].x, T[2].y, T[3].z, T[0].w); X[2] = make_uint4 (T[2].x, T[3].y, T[0].z, T[1].w); X[3] = make_uint4 (T[3].x, T[0].y, T[1].z, T[2].w); + #elif defined IS_METAL + X[0] = uint4 (T[0].x, T[1].y, T[2].z, T[3].w); + X[1] = uint4 (T[1].x, T[2].y, T[3].z, T[0].w); + X[2] = uint4 (T[2].x, T[3].y, T[0].z, T[1].w); + X[3] = uint4 (T[3].x, T[0].y, T[1].z, T[2].w); #else X[0] = (uint4) (T[0].x, T[1].y, T[2].z, T[3].w); X[1] = (uint4) (T[1].x, T[2].y, T[3].z, T[0].w); @@ -467,6 +475,11 @@ KERNEL_FQ void m08900_comp (KERN_ATTR_TMPS (scrypt_tmp_t)) T[1] = make_uint4 (X[1].x, X[0].y, X[3].z, X[2].w); T[2] = make_uint4 (X[2].x, X[1].y, X[0].z, X[3].w); T[3] = make_uint4 (X[3].x, X[2].y, X[1].z, X[0].w); + #elif defined IS_METAL + T[0] = uint4 (X[0].x, X[3].y, X[2].z, X[1].w); + T[1] = uint4 (X[1].x, X[0].y, X[3].z, X[2].w); + T[2] = uint4 (X[2].x, X[1].y, X[0].z, X[3].w); + T[3] = uint4 (X[3].x, X[2].y, X[1].z, X[0].w); #else T[0] = (uint4) (X[0].x, X[3].y, X[2].z, X[1].w); T[1] = (uint4) (X[1].x, X[0].y, X[3].z, X[2].w); diff --git a/OpenCL/m09000-pure.cl b/OpenCL/m09000-pure.cl index 7e9c7298a..999f57bfe 100644 --- a/OpenCL/m09000-pure.cl +++ b/OpenCL/m09000-pure.cl @@ -340,7 +340,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val) #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key) diff --git a/OpenCL/m10400_a0-optimized.cl b/OpenCL/m10400_a0-optimized.cl index afdd6ac1c..e442a7e8b 100644 --- a/OpenCL/m10400_a0-optimized.cl +++ b/OpenCL/m10400_a0-optimized.cl @@ -20,22 +20,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10400_a1-optimized.cl b/OpenCL/m10400_a1-optimized.cl index 4247d2cc0..3c0165749 100644 --- a/OpenCL/m10400_a1-optimized.cl +++ b/OpenCL/m10400_a1-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10400_a3-optimized.cl b/OpenCL/m10400_a3-optimized.cl index 096d2e172..8687ae809 100644 --- a/OpenCL/m10400_a3-optimized.cl +++ b/OpenCL/m10400_a3-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10410_a0-optimized.cl b/OpenCL/m10410_a0-optimized.cl index cdf6145ce..aa1acad0b 100644 --- a/OpenCL/m10410_a0-optimized.cl +++ b/OpenCL/m10410_a0-optimized.cl @@ -20,22 +20,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10410_a1-optimized.cl b/OpenCL/m10410_a1-optimized.cl index 6e2467a78..b37624c5b 100644 --- a/OpenCL/m10410_a1-optimized.cl +++ b/OpenCL/m10410_a1-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10410_a3-optimized.cl b/OpenCL/m10410_a3-optimized.cl index 44a4f8789..5e789cca8 100644 --- a/OpenCL/m10410_a3-optimized.cl +++ b/OpenCL/m10410_a3-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10420_a0-optimized.cl b/OpenCL/m10420_a0-optimized.cl index ab069e9a1..32b1df8c1 100644 --- a/OpenCL/m10420_a0-optimized.cl +++ b/OpenCL/m10420_a0-optimized.cl @@ -30,22 +30,24 @@ CONSTANT_VK u32a padding[8] = typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10420_a1-optimized.cl b/OpenCL/m10420_a1-optimized.cl index 25dad86a7..5c2ef872d 100644 --- a/OpenCL/m10420_a1-optimized.cl +++ b/OpenCL/m10420_a1-optimized.cl @@ -28,22 +28,24 @@ CONSTANT_VK u32a padding[8] = typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10420_a3-optimized.cl b/OpenCL/m10420_a3-optimized.cl index 06e0ac3b0..797c7d16b 100644 --- a/OpenCL/m10420_a3-optimized.cl +++ b/OpenCL/m10420_a3-optimized.cl @@ -28,22 +28,24 @@ CONSTANT_VK u32a padding[8] = typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10500-pure.cl b/OpenCL/m10500-pure.cl index 905b88f5a..f45c40d42 100644 --- a/OpenCL/m10500-pure.cl +++ b/OpenCL/m10500-pure.cl @@ -17,22 +17,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10700-optimized.cl b/OpenCL/m10700-optimized.cl index 488ddf58e..10ebfcac8 100644 --- a/OpenCL/m10700-optimized.cl +++ b/OpenCL/m10700-optimized.cl @@ -19,22 +19,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -321,7 +323,7 @@ DECLSPEC u32 do_round (LOCAL_AS u32 *sc, PRIVATE_AS const u32 *pw, const u32 pw_ make_sc (sc, pw, pw_len, ctx->dgst32, ctx->dgst_len); - // make sure pwbl_len is calculcated before it gets changed + // make sure pwbl_len is calculated before it gets changed const u32 pwbl_len = pw_len + ctx->dgst_len; diff --git a/OpenCL/m10700-pure.cl b/OpenCL/m10700-pure.cl index 81e67da1e..327c76e71 100644 --- a/OpenCL/m10700-pure.cl +++ b/OpenCL/m10700-pure.cl @@ -25,22 +25,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index f1fce4e9a..c4b870208 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -357,54 +357,98 @@ KERNEL_FQ void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); - for (u32 i = 0, j = 1; i < 16; i += 8, j += 1) - { - streebog512_hmac_ctx_t streebog512_hmac_ctx2 = streebog512_hmac_ctx; - - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - - w0[0] = j; - w0[1] = 0; - w0[2] = 0; - w0[3] = 0; - w1[0] = 0; - w1[1] = 0; - w1[2] = 0; - w1[3] = 0; - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - - streebog512_hmac_update_64 (&streebog512_hmac_ctx2, w0, w1, w2, w3, 4); - - streebog512_hmac_final (&streebog512_hmac_ctx2); - - tmps[gid].dgst[i + 0] = streebog512_hmac_ctx2.opad.h[0]; - tmps[gid].dgst[i + 1] = streebog512_hmac_ctx2.opad.h[1]; - tmps[gid].dgst[i + 2] = streebog512_hmac_ctx2.opad.h[2]; - tmps[gid].dgst[i + 3] = streebog512_hmac_ctx2.opad.h[3]; - tmps[gid].dgst[i + 4] = streebog512_hmac_ctx2.opad.h[4]; - tmps[gid].dgst[i + 5] = streebog512_hmac_ctx2.opad.h[5]; - tmps[gid].dgst[i + 6] = streebog512_hmac_ctx2.opad.h[6]; - tmps[gid].dgst[i + 7] = streebog512_hmac_ctx2.opad.h[7]; - - tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; - tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; - tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; - tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; - tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; - tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; - tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; - tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; - } + u32 i = 0; + u32 j = 1; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + streebog512_hmac_ctx_t streebog512_hmac_ctx_v1 = streebog512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + streebog512_hmac_update_64 (&streebog512_hmac_ctx_v1, w0, w1, w2, w3, 4); + + streebog512_hmac_final (&streebog512_hmac_ctx_v1); + + tmps[gid].dgst[i + 0] = streebog512_hmac_ctx_v1.opad.h[0]; + tmps[gid].dgst[i + 1] = streebog512_hmac_ctx_v1.opad.h[1]; + tmps[gid].dgst[i + 2] = streebog512_hmac_ctx_v1.opad.h[2]; + tmps[gid].dgst[i + 3] = streebog512_hmac_ctx_v1.opad.h[3]; + tmps[gid].dgst[i + 4] = streebog512_hmac_ctx_v1.opad.h[4]; + tmps[gid].dgst[i + 5] = streebog512_hmac_ctx_v1.opad.h[5]; + tmps[gid].dgst[i + 6] = streebog512_hmac_ctx_v1.opad.h[6]; + tmps[gid].dgst[i + 7] = streebog512_hmac_ctx_v1.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + + i=8; + j=2; + + streebog512_hmac_ctx_t streebog512_hmac_ctx_v2 = streebog512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + streebog512_hmac_update_64 (&streebog512_hmac_ctx_v2, w0, w1, w2, w3, 4); + + streebog512_hmac_final (&streebog512_hmac_ctx_v2); + + tmps[gid].dgst[i + 0] = streebog512_hmac_ctx_v2.opad.h[0]; + tmps[gid].dgst[i + 1] = streebog512_hmac_ctx_v2.opad.h[1]; + tmps[gid].dgst[i + 2] = streebog512_hmac_ctx_v2.opad.h[2]; + tmps[gid].dgst[i + 3] = streebog512_hmac_ctx_v2.opad.h[3]; + tmps[gid].dgst[i + 4] = streebog512_hmac_ctx_v2.opad.h[4]; + tmps[gid].dgst[i + 5] = streebog512_hmac_ctx_v2.opad.h[5]; + tmps[gid].dgst[i + 6] = streebog512_hmac_ctx_v2.opad.h[6]; + tmps[gid].dgst[i + 7] = streebog512_hmac_ctx_v2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; } KERNEL_FQ void m13772_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index 3551d5560..55f14890c 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -422,54 +422,142 @@ KERNEL_FQ void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64); - for (u32 i = 0, j = 1; i < 24; i += 8, j += 1) - { - streebog512_hmac_ctx_t streebog512_hmac_ctx2 = streebog512_hmac_ctx; - - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - - w0[0] = j; - w0[1] = 0; - w0[2] = 0; - w0[3] = 0; - w1[0] = 0; - w1[1] = 0; - w1[2] = 0; - w1[3] = 0; - w2[0] = 0; - w2[1] = 0; - w2[2] = 0; - w2[3] = 0; - w3[0] = 0; - w3[1] = 0; - w3[2] = 0; - w3[3] = 0; - - streebog512_hmac_update_64 (&streebog512_hmac_ctx2, w0, w1, w2, w3, 4); - - streebog512_hmac_final (&streebog512_hmac_ctx2); - - tmps[gid].dgst[i + 0] = streebog512_hmac_ctx2.opad.h[0]; - tmps[gid].dgst[i + 1] = streebog512_hmac_ctx2.opad.h[1]; - tmps[gid].dgst[i + 2] = streebog512_hmac_ctx2.opad.h[2]; - tmps[gid].dgst[i + 3] = streebog512_hmac_ctx2.opad.h[3]; - tmps[gid].dgst[i + 4] = streebog512_hmac_ctx2.opad.h[4]; - tmps[gid].dgst[i + 5] = streebog512_hmac_ctx2.opad.h[5]; - tmps[gid].dgst[i + 6] = streebog512_hmac_ctx2.opad.h[6]; - tmps[gid].dgst[i + 7] = streebog512_hmac_ctx2.opad.h[7]; - - tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; - tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; - tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; - tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; - tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; - tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; - tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; - tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; - } + u32 i = 0; + u32 j = 1; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + streebog512_hmac_ctx_t streebog512_hmac_ctx_v1 = streebog512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + streebog512_hmac_update_64 (&streebog512_hmac_ctx_v1, w0, w1, w2, w3, 4); + + streebog512_hmac_final (&streebog512_hmac_ctx_v1); + + tmps[gid].dgst[i + 0] = streebog512_hmac_ctx_v1.opad.h[0]; + tmps[gid].dgst[i + 1] = streebog512_hmac_ctx_v1.opad.h[1]; + tmps[gid].dgst[i + 2] = streebog512_hmac_ctx_v1.opad.h[2]; + tmps[gid].dgst[i + 3] = streebog512_hmac_ctx_v1.opad.h[3]; + tmps[gid].dgst[i + 4] = streebog512_hmac_ctx_v1.opad.h[4]; + tmps[gid].dgst[i + 5] = streebog512_hmac_ctx_v1.opad.h[5]; + tmps[gid].dgst[i + 6] = streebog512_hmac_ctx_v1.opad.h[6]; + tmps[gid].dgst[i + 7] = streebog512_hmac_ctx_v1.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + + i = 8; + j = 2; + + streebog512_hmac_ctx_t streebog512_hmac_ctx_v2 = streebog512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + streebog512_hmac_update_64 (&streebog512_hmac_ctx_v2, w0, w1, w2, w3, 4); + + streebog512_hmac_final (&streebog512_hmac_ctx_v2); + + tmps[gid].dgst[i + 0] = streebog512_hmac_ctx_v2.opad.h[0]; + tmps[gid].dgst[i + 1] = streebog512_hmac_ctx_v2.opad.h[1]; + tmps[gid].dgst[i + 2] = streebog512_hmac_ctx_v2.opad.h[2]; + tmps[gid].dgst[i + 3] = streebog512_hmac_ctx_v2.opad.h[3]; + tmps[gid].dgst[i + 4] = streebog512_hmac_ctx_v2.opad.h[4]; + tmps[gid].dgst[i + 5] = streebog512_hmac_ctx_v2.opad.h[5]; + tmps[gid].dgst[i + 6] = streebog512_hmac_ctx_v2.opad.h[6]; + tmps[gid].dgst[i + 7] = streebog512_hmac_ctx_v2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + + i = 16; + j = 3; + + streebog512_hmac_ctx_t streebog512_hmac_ctx_v3 = streebog512_hmac_ctx; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + streebog512_hmac_update_64 (&streebog512_hmac_ctx_v3, w0, w1, w2, w3, 4); + + streebog512_hmac_final (&streebog512_hmac_ctx_v3); + + tmps[gid].dgst[i + 0] = streebog512_hmac_ctx_v3.opad.h[0]; + tmps[gid].dgst[i + 1] = streebog512_hmac_ctx_v3.opad.h[1]; + tmps[gid].dgst[i + 2] = streebog512_hmac_ctx_v3.opad.h[2]; + tmps[gid].dgst[i + 3] = streebog512_hmac_ctx_v3.opad.h[3]; + tmps[gid].dgst[i + 4] = streebog512_hmac_ctx_v3.opad.h[4]; + tmps[gid].dgst[i + 5] = streebog512_hmac_ctx_v3.opad.h[5]; + tmps[gid].dgst[i + 6] = streebog512_hmac_ctx_v3.opad.h[6]; + tmps[gid].dgst[i + 7] = streebog512_hmac_ctx_v3.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; } KERNEL_FQ void m13773_loop (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) diff --git a/OpenCL/m15300-pure.cl b/OpenCL/m15300-pure.cl index faba9ce24..64869baa7 100644 --- a/OpenCL/m15300-pure.cl +++ b/OpenCL/m15300-pure.cl @@ -39,7 +39,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; diff --git a/OpenCL/m15310-pure.cl b/OpenCL/m15310-pure.cl index 2c394ea13..bf8c53947 100644 --- a/OpenCL/m15310-pure.cl +++ b/OpenCL/m15310-pure.cl @@ -41,7 +41,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; diff --git a/OpenCL/m15700-pure.cl b/OpenCL/m15700-pure.cl index 20cab27d1..e500b4f70 100644 --- a/OpenCL/m15700-pure.cl +++ b/OpenCL/m15700-pure.cl @@ -463,6 +463,9 @@ KERNEL_FQ void m15700_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_ #if defined IS_CUDA || defined IS_HIP const uint4 tmp0 = make_uint4 (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = make_uint4 (digest[4], digest[5], digest[6], digest[7]); + #elif defined IS_METAL + const uint4 tmp0 = uint4 (digest[0], digest[1], digest[2], digest[3]); + const uint4 tmp1 = uint4 (digest[4], digest[5], digest[6], digest[7]); #else const uint4 tmp0 = (uint4) (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = (uint4) (digest[4], digest[5], digest[6], digest[7]); @@ -493,6 +496,11 @@ KERNEL_FQ void m15700_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_ X[1] = make_uint4 (T[1].x, T[2].y, T[3].z, T[0].w); X[2] = make_uint4 (T[2].x, T[3].y, T[0].z, T[1].w); X[3] = make_uint4 (T[3].x, T[0].y, T[1].z, T[2].w); + #elif defined IS_METAL + X[0] = uint4 (T[0].x, T[1].y, T[2].z, T[3].w); + X[1] = uint4 (T[1].x, T[2].y, T[3].z, T[0].w); + X[2] = uint4 (T[2].x, T[3].y, T[0].z, T[1].w); + X[3] = uint4 (T[3].x, T[0].y, T[1].z, T[2].w); #else X[0] = (uint4) (T[0].x, T[1].y, T[2].z, T[3].w); X[1] = (uint4) (T[1].x, T[2].y, T[3].z, T[0].w); @@ -603,6 +611,11 @@ KERNEL_FQ void m15700_comp (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, ethereum_scrypt_ T[1] = make_uint4 (X[1].x, X[0].y, X[3].z, X[2].w); T[2] = make_uint4 (X[2].x, X[1].y, X[0].z, X[3].w); T[3] = make_uint4 (X[3].x, X[2].y, X[1].z, X[0].w); + #elif defined IS_METAL + T[0] = uint4 (X[0].x, X[3].y, X[2].z, X[1].w); + T[1] = uint4 (X[1].x, X[0].y, X[3].z, X[2].w); + T[2] = uint4 (X[2].x, X[1].y, X[0].z, X[3].w); + T[3] = uint4 (X[3].x, X[2].y, X[1].z, X[0].w); #else T[0] = (uint4) (X[0].x, X[3].y, X[2].z, X[1].w); T[1] = (uint4) (X[1].x, X[0].y, X[3].z, X[2].w); diff --git a/OpenCL/m15900-pure.cl b/OpenCL/m15900-pure.cl index 9cff5d883..025c50f0d 100644 --- a/OpenCL/m15900-pure.cl +++ b/OpenCL/m15900-pure.cl @@ -40,7 +40,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; diff --git a/OpenCL/m15910-pure.cl b/OpenCL/m15910-pure.cl index d73d748ea..d9c781911 100644 --- a/OpenCL/m15910-pure.cl +++ b/OpenCL/m15910-pure.cl @@ -48,7 +48,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; diff --git a/OpenCL/m17040-pure.cl b/OpenCL/m17040-pure.cl new file mode 100644 index 000000000..0326ba716 --- /dev/null +++ b/OpenCL/m17040-pure.cl @@ -0,0 +1,404 @@ +/** + * Author......: Netherlands Forensic Institute + * based upon 17010 + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_cast.h) +#endif + +typedef struct gpg +{ + u32 cipher_algo; + u32 iv[4]; // make this dynamic based on the input hash.. iv_size can be 8 bytes or 16 bytes + u32 modulus_size; + u32 encrypted_data[384]; + u32 encrypted_data_size; + +} gpg_t; + +typedef struct gpg_tmp +{ + // buffer for a maximum of 256 + 8 characters, we extend it to 320 characters so it's always 64 byte aligned + u32 salted_pw_block[80]; + // actual number of bytes in 'salted_pwd' that are used since salt and password are copied multiple times into the buffer + u32 salted_pw_block_len; + + u32 h[10]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 len; + +} gpg_tmp_t; + + +DECLSPEC u32 hc_bytealign_le_S (const u32 a, const u32 b, const int c) +{ + const int c_mod_4 = c & 3; + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 0) || defined IS_GENERIC + const u32 r = l32_from_64_S ((v64_from_v32ab_S (b, a) >> (c_mod_4 * 8))); + #endif + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 1) || defined IS_NV + + #if defined IS_NV + const int selector = (0x76543210 >> (c_mod_4 * 4)) & 0xffff; + #endif + + #if (defined IS_AMD || defined IS_HIP) + const int selector = l32_from_64_S (0x0706050403020100UL >> (c_mod_4 * 8)); + #endif + + const u32 r = hc_byte_perm (b, a, selector); + #endif + + return r; +} + +DECLSPEC void memcat_le_S (PRIVATE_AS u32 *block, const u32 offset, PRIVATE_AS const u32 *append, u32 len) +{ + const u32 start_index = (offset - 1) >> 2; + const u32 count = ((offset + len + 3) >> 2) - start_index; + const int off_mod_4 = offset & 3; + const int off_minus_4 = 4 - off_mod_4; + + block[start_index] |= hc_bytealign_le_S (append[0], 0, off_minus_4); + + for (u32 idx = 1; idx < count; idx++) + { + block[start_index + idx] = hc_bytealign_le_S (append[idx], append[idx - 1], off_minus_4); + } +} + +DECLSPEC void memzero_le_S (PRIVATE_AS u32 *block, const u32 start_offset, const u32 end_offset) +{ + const u32 start_idx = start_offset / 4; + + // zero out bytes in the first u32 starting from 'start_offset' + // math is a bit complex to avoid shifting by 32 bits, which is not possible on some architectures + block[start_idx] &= ~(0xffffffff << ((start_offset & 3) * 8)); + + const u32 end_idx = (end_offset + 3) / 4; + + // zero out bytes in u32 units -- note that the last u32 is completely zeroed! + for (u32 i = start_idx + 1; i < end_idx; i++) + { + block[i] = 0; + } +} + +DECLSPEC void memzero_be_S (PRIVATE_AS u32 *block, const u32 start_offset, const u32 end_offset) +{ + const u32 start_idx = start_offset / 4; + + // zero out bytes in the first u32 starting from 'start_offset' + // math is a bit complex to avoid shifting by 32 bits, which is not possible on some architectures + block[start_idx] &= ~(0xffffffff >> ((start_offset & 3) * 8)); + + const u32 end_idx = (end_offset + 3) / 4; + + // zero out bytes in u32 units -- note that the last u32 is completely zeroed! + for (u32 i = start_idx + 1; i < end_idx; i++) + { + block[i] = 0; + } +} + +DECLSPEC void cast128_decrypt_cfb (GLOBAL_AS const u32 *encrypted_data, int data_len, PRIVATE_AS const u32 *iv, PRIVATE_AS const u32 *key, PRIVATE_AS u32 *decrypted_data, SHM_TYPE u32 (*s_S)[256]) +{ + u8 essiv[8]; + for (int j=0; j<8; j++) { essiv[j] = 0; } + + // TODO remove this casting, would speedup the attack + // We need to do this casting to get values in local memory and have them not be constant. + u32 lencrypted_data[384]; // I'd prefer not to hardcode to 384, but rest of kernel uses the same value + for (u32 i = 0; i < (data_len + 3) / 4; i += 4) + { + lencrypted_data[i + 0] = encrypted_data[i + 0]; + lencrypted_data[i + 1] = encrypted_data[i + 1]; + lencrypted_data[i + 2] = encrypted_data[i + 2]; + lencrypted_data[i + 3] = encrypted_data[i + 3]; + } + PRIVATE_AS u8 *lencrypted_data8 = (PRIVATE_AS u8*)lencrypted_data; + PRIVATE_AS u8 *decrypted_data8 = (PRIVATE_AS u8*)decrypted_data; + PRIVATE_AS u8 *key8 = (PRIVATE_AS u8*)key; + + + // Copy the IV, since this will be modified + // essiv[0] = iv[0]; // IV is zero for our example, but we load it dynamically.. + // essiv[1] = iv[1]; // IV is zero for our example, but we load it dynamically.. + // essiv[2] = 0; + // essiv[3] = 0; //TODO load IV dynamically, code doesn't make any sense currently as essiv is now a u8 + + CAST_KEY ck; + Cast5SetKey(&ck, 16, key8, s_S); + + // Decrypt an CAST5 encrypted block + for (u32 i = 0; i < (data_len + 3) ; i += 8) + { + Cast5Encrypt(essiv, &decrypted_data8[i], &ck, s_S); + + for (int j=0; j<8; j++) { decrypted_data8[i+j] ^= lencrypted_data8[i + j]; } + + // Note: Not necessary if you are only decrypting a single block! + for (int j=0; j<8; j++) { + essiv[j] = lencrypted_data8[i + j]; + } + } +} + +DECLSPEC int check_decoded_data (PRIVATE_AS u32 *decoded_data, const u32 decoded_data_size) +{ + // Check the SHA-1 of the decrypted data which is stored at the end of the decrypted data + const u32 sha1_byte_off = (decoded_data_size - 20); + const u32 sha1_u32_off = sha1_byte_off / 4; + + u32 expected_sha1[5]; + + expected_sha1[0] = hc_bytealign_le_S (decoded_data[sha1_u32_off + 1], decoded_data[sha1_u32_off + 0], sha1_byte_off); + expected_sha1[1] = hc_bytealign_le_S (decoded_data[sha1_u32_off + 2], decoded_data[sha1_u32_off + 1], sha1_byte_off); + expected_sha1[2] = hc_bytealign_le_S (decoded_data[sha1_u32_off + 3], decoded_data[sha1_u32_off + 2], sha1_byte_off); + expected_sha1[3] = hc_bytealign_le_S (decoded_data[sha1_u32_off + 4], decoded_data[sha1_u32_off + 3], sha1_byte_off); + expected_sha1[4] = hc_bytealign_le_S (decoded_data[sha1_u32_off + 5], decoded_data[sha1_u32_off + 4], sha1_byte_off); + + + + memzero_le_S (decoded_data, sha1_byte_off, 384 * sizeof(u32)); + + sha1_ctx_t ctx; + + sha1_init (&ctx); + + sha1_update_swap (&ctx, decoded_data, sha1_byte_off); + + sha1_final (&ctx); + + return (expected_sha1[0] == hc_swap32_S (ctx.h[0])) + && (expected_sha1[1] == hc_swap32_S (ctx.h[1])) + && (expected_sha1[2] == hc_swap32_S (ctx.h[2])) + && (expected_sha1[3] == hc_swap32_S (ctx.h[3])) + && (expected_sha1[4] == hc_swap32_S (ctx.h[4])); +} + +KERNEL_FQ void m17040_init (KERN_ATTR_TMPS_ESALT (gpg_tmp_t, gpg_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + const u32 pw_len = pws[gid].pw_len; + const u32 salted_pw_len = (salt_bufs[SALT_POS_HOST].salt_len + pw_len); + + u32 salted_pw_block[80]; + + // concatenate salt and password -- the salt is always 8 bytes + salted_pw_block[0] = salt_bufs[SALT_POS_HOST].salt_buf[0]; + salted_pw_block[1] = salt_bufs[SALT_POS_HOST].salt_buf[1]; + + for (u32 idx = 0; idx < 64; idx++) salted_pw_block[idx + 2] = pws[gid].i[idx]; + + // zero remainder of buffer + for (u32 idx = 66; idx < 80; idx++) salted_pw_block[idx] = 0; + + // create a number of copies for efficiency + const u32 copies = 80 * sizeof(u32) / salted_pw_len; + + for (u32 idx = 1; idx < copies; idx++) + { + memcat_le_S (salted_pw_block, idx * salted_pw_len, salted_pw_block, salted_pw_len); + } + + for (u32 idx = 0; idx < 80; idx++) + { + tmps[gid].salted_pw_block[idx] = hc_swap32_S (salted_pw_block[idx]); + } + + tmps[gid].salted_pw_block_len = (copies * salted_pw_len); + + tmps[gid].h[0] = SHA1M_A; + tmps[gid].h[1] = SHA1M_B; + tmps[gid].h[2] = SHA1M_C; + tmps[gid].h[3] = SHA1M_D; + tmps[gid].h[4] = SHA1M_E; + tmps[gid].h[5] = SHA1M_A; + tmps[gid].h[6] = SHA1M_B; + tmps[gid].h[7] = SHA1M_C; + tmps[gid].h[8] = SHA1M_D; + tmps[gid].h[9] = SHA1M_E; + + tmps[gid].len = 0; +} + +KERNEL_FQ void m17040_loop_prepare (KERN_ATTR_TMPS_ESALT (gpg_tmp_t, gpg_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + tmps[gid].h[0] = SHA1M_A; + tmps[gid].h[1] = SHA1M_B; + tmps[gid].h[2] = SHA1M_C; + tmps[gid].h[3] = SHA1M_D; + tmps[gid].h[4] = SHA1M_E; + tmps[gid].h[5] = SHA1M_A; + tmps[gid].h[6] = SHA1M_B; + tmps[gid].h[7] = SHA1M_C; + tmps[gid].h[8] = SHA1M_D; + tmps[gid].h[9] = SHA1M_E; + + tmps[gid].w0[0] = 0; + tmps[gid].w0[1] = 0; + tmps[gid].w0[2] = 0; + tmps[gid].w0[3] = 0; + tmps[gid].w1[0] = 0; + tmps[gid].w1[1] = 0; + tmps[gid].w1[2] = 0; + tmps[gid].w1[3] = 0; + tmps[gid].w2[0] = 0; + tmps[gid].w2[1] = 0; + tmps[gid].w2[2] = 0; + tmps[gid].w2[3] = 0; + tmps[gid].w3[0] = 0; + tmps[gid].w3[1] = 0; + tmps[gid].w3[2] = 0; + tmps[gid].w3[3] = 0; + + tmps[gid].len = 0; +} + +KERNEL_FQ void m17040_loop (KERN_ATTR_TMPS_ESALT (gpg_tmp_t, gpg_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + if (gid >= GID_CNT) return; + + // get the prepared buffer from the gpg_tmp_t struct into a local buffer + u32 salted_pw_block[80]; + for (int i = 0; i < 80; i++) salted_pw_block[i] = tmps[gid].salted_pw_block[i]; + + + const u32 salted_pw_block_len = tmps[gid].salted_pw_block_len; + + // do we really need this, since the salt is always length 8? + if (salted_pw_block_len == 0) return; + + /** + * context load + */ + + sha1_ctx_t ctx; + + for (int i = 0; i < 5; i++) ctx.h[i] = tmps[gid].h[i]; + + for (int i = 0; i < 4; i++) ctx.w0[i] = tmps[gid].w0[i]; + for (int i = 0; i < 4; i++) ctx.w1[i] = tmps[gid].w1[i]; + for (int i = 0; i < 4; i++) ctx.w2[i] = tmps[gid].w2[i]; + for (int i = 0; i < 4; i++) ctx.w3[i] = tmps[gid].w3[i]; + + const u32 pw_len = pws[gid].pw_len; + const u32 salted_pw_len = (salt_bufs[SALT_POS_HOST].salt_len + pw_len); + const u32 remaining_bytes = salted_pw_len % 4; + + ctx.len = tmps[gid].len; + + memzero_be_S (salted_pw_block, salted_pw_len, salted_pw_block_len); + // zero out last bytes of password if not a multiple of 4 + // TODO do we need this wo don't feed the remainder to the hashing algorithm anyway..?? + sha1_update (&ctx, salted_pw_block, salted_pw_len); + sha1_final (&ctx); + + /** + * context save + */ + + for (int i = 0; i < 5; i++) tmps[gid].h[i] = ctx.h[i]; + // this is the sha1 hash of the salt+password: + + for (int i = 0; i < 4; i++) tmps[gid].w0[i] = ctx.w0[i]; + for (int i = 0; i < 4; i++) tmps[gid].w1[i] = ctx.w1[i]; + for (int i = 0; i < 4; i++) tmps[gid].w2[i] = ctx.w2[i]; + for (int i = 0; i < 4; i++) tmps[gid].w3[i] = ctx.w3[i]; + + tmps[gid].len = ctx.len; +} + +KERNEL_FQ void m17040_comp (KERN_ATTR_TMPS_ESALT (gpg_tmp_t, gpg_t)) +{ + // not in use here, special case... +} + +KERNEL_FQ void m17040_aux1 (KERN_ATTR_TMPS_ESALT (gpg_tmp_t, gpg_t)) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_S[8][256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_S[0][i] = S[0][i]; + s_S[1][i] = S[1][i]; + s_S[2][i] = S[2][i]; + s_S[3][i] = S[3][i]; + s_S[4][i] = S[4][i]; + s_S[5][i] = S[5][i]; + s_S[6][i] = S[6][i]; + s_S[7][i] = S[7][i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a (*s_S)[256] = S; + + #endif + + if (gid >= GID_CNT) return; + + // retrieve and use the SHA-1 as the key for CAST5 + u32 cast_key[5]; + for (int i = 0; i < 5; i++) cast_key[i] = hc_swap32_S (tmps[gid].h[i]); + + u32 iv[4] = {0}; + for (int idx = 0; idx < 4; idx++) iv[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].iv[idx]; + + u32 decoded_data[384]; + + const u32 enc_data_size = esalt_bufs[DIGESTS_OFFSET_HOST].encrypted_data_size; + + cast128_decrypt_cfb (esalt_bufs[DIGESTS_OFFSET_HOST].encrypted_data, enc_data_size, iv, cast_key, decoded_data, s_S); + + if (check_decoded_data (decoded_data, enc_data_size)) + { + if (hc_atomic_inc (&hashes_shown[DIGESTS_OFFSET_HOST]) == 0) + { + mark_hash (plains_buf, d_return_buf, SALT_POS_HOST, DIGESTS_CNT, 0, DIGESTS_OFFSET_HOST + 0, gid, 0, 0, 0); + } + } +} diff --git a/OpenCL/m18400-pure.cl b/OpenCL/m18400-pure.cl index 6d0a5857b..36c1411f1 100644 --- a/OpenCL/m18400-pure.cl +++ b/OpenCL/m18400-pure.cl @@ -35,6 +35,7 @@ typedef struct odf12 u32 iv[4]; u32 checksum[8]; u32 encrypted_data[256]; + int encrypted_len; } odf12_t; @@ -352,111 +353,49 @@ KERNEL_FQ void m18400_comp (KERN_ATTR_TMPS_ESALT (odf12_tmp_t, odf12_t)) iv[2] = es->iv[2]; iv[3] = es->iv[3]; - u32 ct[4]; + u32 pt[256]; - u32 pt1[4]; - u32 pt2[4]; - u32 pt3[4]; - u32 pt4[4]; - - sha256_ctx_t sha256_ctx; - - sha256_init (&sha256_ctx); - - // decrypt aes-cbc and calculate plaintext checksum at the same time - for (int i = 0; i < 16; i++) + for (int i = 0, j = 0; i < es->encrypted_len; i += 16, j += 4) { - const int i16 = i * 16; + u32 ct[4]; - ct[0] = es->encrypted_data[i16 + 0]; - ct[1] = es->encrypted_data[i16 + 1]; - ct[2] = es->encrypted_data[i16 + 2]; - ct[3] = es->encrypted_data[i16 + 3]; + ct[0] = es->encrypted_data[j + 0]; + ct[1] = es->encrypted_data[j + 1]; + ct[2] = es->encrypted_data[j + 2]; + ct[3] = es->encrypted_data[j + 3]; - aes256_decrypt (ks, ct, pt1, s_td0, s_td1, s_td2, s_td3, s_td4); + aes256_decrypt (ks, ct, pt + j, s_td0, s_td1, s_td2, s_td3, s_td4); - pt1[0] ^= iv[0]; - pt1[1] ^= iv[1]; - pt1[2] ^= iv[2]; - pt1[3] ^= iv[3]; - - iv[0] = ct[0]; - iv[1] = ct[1]; - iv[2] = ct[2]; - iv[3] = ct[3]; - - ct[0] = es->encrypted_data[i16 + 4]; - ct[1] = es->encrypted_data[i16 + 5]; - ct[2] = es->encrypted_data[i16 + 6]; - ct[3] = es->encrypted_data[i16 + 7]; - - aes256_decrypt (ks, ct, pt2, s_td0, s_td1, s_td2, s_td3, s_td4); - - pt2[0] ^= iv[0]; - pt2[1] ^= iv[1]; - pt2[2] ^= iv[2]; - pt2[3] ^= iv[3]; - - iv[0] = ct[0]; - iv[1] = ct[1]; - iv[2] = ct[2]; - iv[3] = ct[3]; - - ct[0] = es->encrypted_data[i16 + 8]; - ct[1] = es->encrypted_data[i16 + 9]; - ct[2] = es->encrypted_data[i16 + 10]; - ct[3] = es->encrypted_data[i16 + 11]; - - aes256_decrypt (ks, ct, pt3, s_td0, s_td1, s_td2, s_td3, s_td4); - - pt3[0] ^= iv[0]; - pt3[1] ^= iv[1]; - pt3[2] ^= iv[2]; - pt3[3] ^= iv[3]; + pt[j + 0] ^= iv[0]; + pt[j + 1] ^= iv[1]; + pt[j + 2] ^= iv[2]; + pt[j + 3] ^= iv[3]; iv[0] = ct[0]; iv[1] = ct[1]; iv[2] = ct[2]; iv[3] = ct[3]; + } - ct[0] = es->encrypted_data[i16 + 12]; - ct[1] = es->encrypted_data[i16 + 13]; - ct[2] = es->encrypted_data[i16 + 14]; - ct[3] = es->encrypted_data[i16 + 15]; + const int full64 = es->encrypted_len / 64; - aes256_decrypt (ks, ct, pt4, s_td0, s_td1, s_td2, s_td3, s_td4); + const int encrypted_len64 = full64 * 64; - pt4[0] ^= iv[0]; - pt4[1] ^= iv[1]; - pt4[2] ^= iv[2]; - pt4[3] ^= iv[3]; + sha256_ctx_t sha256_ctx; - iv[0] = ct[0]; - iv[1] = ct[1]; - iv[2] = ct[2]; - iv[3] = ct[3]; + sha256_init (&sha256_ctx); - pt1[0] = hc_swap32_S (pt1[0]); - pt1[1] = hc_swap32_S (pt1[1]); - pt1[2] = hc_swap32_S (pt1[2]); - pt1[3] = hc_swap32_S (pt1[3]); + sha256_update_swap (&sha256_ctx, pt, encrypted_len64); - pt2[0] = hc_swap32_S (pt2[0]); - pt2[1] = hc_swap32_S (pt2[1]); - pt2[2] = hc_swap32_S (pt2[2]); - pt2[3] = hc_swap32_S (pt2[3]); + const int remaining64 = es->encrypted_len - encrypted_len64; - pt3[0] = hc_swap32_S (pt3[0]); - pt3[1] = hc_swap32_S (pt3[1]); - pt3[2] = hc_swap32_S (pt3[2]); - pt3[3] = hc_swap32_S (pt3[3]); + if (remaining64) + { + PRIVATE_AS u32 *pt_remaining = pt + (encrypted_len64 / 4); - pt4[0] = hc_swap32_S (pt4[0]); - pt4[1] = hc_swap32_S (pt4[1]); - pt4[2] = hc_swap32_S (pt4[2]); - pt4[3] = hc_swap32_S (pt4[3]); + truncate_block_16x4_be_S (pt_remaining + 0, pt_remaining + 4, pt_remaining + 8, pt_remaining + 12, remaining64); - sha256_update_64 (&sha256_ctx, pt1, pt2, pt3, pt4, 64); + sha256_update_swap (&sha256_ctx, pt_remaining, remaining64); } sha256_final (&sha256_ctx); diff --git a/OpenCL/m18600-pure.cl b/OpenCL/m18600-pure.cl index e674228e1..1e00f6628 100644 --- a/OpenCL/m18600-pure.cl +++ b/OpenCL/m18600-pure.cl @@ -33,6 +33,7 @@ typedef struct odf11 u32 iv[2]; u32 checksum[5]; u32 encrypted_data[256]; + int encrypted_len; } odf11_t; @@ -349,7 +350,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val) #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key) @@ -759,116 +760,48 @@ KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE_COMP) m18600_comp (KERN_ATTR_ GLOBAL_AS const odf11_t *es = &esalt_bufs[DIGESTS_OFFSET_HOST]; - u32 ct[2]; - - u32 pt0[4]; - u32 pt1[4]; - u32 pt2[4]; - u32 pt3[4]; - - u32 buf[2]; - - buf[0] = es->iv[0]; - buf[1] = es->iv[1]; + u32 iv[2]; - sha1_ctx_t sha1_ctx; + iv[0] = es->iv[0]; + iv[1] = es->iv[1]; - sha1_init (&sha1_ctx); + u32 pt[256]; - // decrypt blowfish-cfb and calculate plaintext checksum at the same time - for (int i = 0; i < 16; i++) + for (int i = 0, j = 0; i < es->encrypted_len; i += 8, j += 2) { - const int i16 = i * 16; - - ct[0] = es->encrypted_data[i16 + 0]; - ct[1] = es->encrypted_data[i16 + 1]; - - BF_ENCRYPT (buf[0], buf[1]); - - pt0[0] = ct[0] ^ buf[0]; - pt0[1] = ct[1] ^ buf[1]; - - buf[0] = ct[0]; - buf[1] = ct[1]; - - ct[0] = es->encrypted_data[i16 + 2]; - ct[1] = es->encrypted_data[i16 + 3]; - - BF_ENCRYPT (buf[0], buf[1]); - - pt0[2] = ct[0] ^ buf[0]; - pt0[3] = ct[1] ^ buf[1]; - - buf[0] = ct[0]; - buf[1] = ct[1]; - - ct[0] = es->encrypted_data[i16 + 4]; - ct[1] = es->encrypted_data[i16 + 5]; + u32 ct[2]; - BF_ENCRYPT (buf[0], buf[1]); + ct[0] = es->encrypted_data[j + 0]; + ct[1] = es->encrypted_data[j + 1]; - pt1[0] = ct[0] ^ buf[0]; - pt1[1] = ct[1] ^ buf[1]; + BF_ENCRYPT (iv[0], iv[1]); - buf[0] = ct[0]; - buf[1] = ct[1]; + pt[j + 0] = ct[0] ^ iv[0]; + pt[j + 1] = ct[1] ^ iv[1]; - ct[0] = es->encrypted_data[i16 + 6]; - ct[1] = es->encrypted_data[i16 + 7]; - - BF_ENCRYPT (buf[0], buf[1]); - - pt1[2] = ct[0] ^ buf[0]; - pt1[3] = ct[1] ^ buf[1]; - - buf[0] = ct[0]; - buf[1] = ct[1]; - - ct[0] = es->encrypted_data[i16 + 8]; - ct[1] = es->encrypted_data[i16 + 9]; - - BF_ENCRYPT (buf[0], buf[1]); - - pt2[0] = ct[0] ^ buf[0]; - pt2[1] = ct[1] ^ buf[1]; - - buf[0] = ct[0]; - buf[1] = ct[1]; - - ct[0] = es->encrypted_data[i16 + 10]; - ct[1] = es->encrypted_data[i16 + 11]; - - BF_ENCRYPT (buf[0], buf[1]); - - pt2[2] = ct[0] ^ buf[0]; - pt2[3] = ct[1] ^ buf[1]; - - buf[0] = ct[0]; - buf[1] = ct[1]; + iv[0] = ct[0]; + iv[1] = ct[1]; + } - ct[0] = es->encrypted_data[i16 + 12]; - ct[1] = es->encrypted_data[i16 + 13]; + const int full64 = es->encrypted_len / 64; - BF_ENCRYPT (buf[0], buf[1]); + const int encrypted_len64 = full64 * 64; - pt3[0] = ct[0] ^ buf[0]; - pt3[1] = ct[1] ^ buf[1]; + sha1_ctx_t sha1_ctx; - buf[0] = ct[0]; - buf[1] = ct[1]; + sha1_init (&sha1_ctx); - ct[0] = es->encrypted_data[i16 + 14]; - ct[1] = es->encrypted_data[i16 + 15]; + sha1_update (&sha1_ctx, pt, encrypted_len64); - BF_ENCRYPT (buf[0], buf[1]); + const int remaining64 = es->encrypted_len - encrypted_len64; - pt3[2] = ct[0] ^ buf[0]; - pt3[3] = ct[1] ^ buf[1]; + if (remaining64) + { + PRIVATE_AS u32 *pt_remaining = pt + (encrypted_len64 / 4); - buf[0] = ct[0]; - buf[1] = ct[1]; + truncate_block_16x4_be_S (pt_remaining + 0, pt_remaining + 4, pt_remaining + 8, pt_remaining + 12, remaining64); - sha1_update_64 (&sha1_ctx, pt0, pt1, pt2, pt3, 64); + sha1_update (&sha1_ctx, pt_remaining, remaining64); } sha1_final (&sha1_ctx); diff --git a/OpenCL/m20712_a0-optimized.cl b/OpenCL/m20712_a0-optimized.cl new file mode 100644 index 000000000..48f5e9463 --- /dev/null +++ b/OpenCL/m20712_a0-optimized.cl @@ -0,0 +1,1233 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +#define SHA256_STEP_REV(a,b,c,d,e,f,g,h) \ +{ \ + u32 t2 = SHA256_S2_S(b) + SHA256_F0o(b,c,d); \ + u32 t1 = a - t2; \ + a = b; \ + b = c; \ + c = d; \ + d = e - t1; \ + e = f; \ + f = g; \ + g = h; \ + h = 0; \ +} + +KERNEL_FQ void m20712_m04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + /** + * sha256(pass) + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = out_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + a += make_u32x (SHA256M_A); + b += make_u32x (SHA256M_B); + c += make_u32x (SHA256M_C); + d += make_u32x (SHA256M_D); + e += make_u32x (SHA256M_E); + f += make_u32x (SHA256M_F); + g += make_u32x (SHA256M_G); + h += make_u32x (SHA256M_H); + + // final sha256 + + // sha256_update_64, len 64, pos 0 + + w0_t = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w8_t = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w9_t = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + wa_t = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + wb_t = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + wc_t = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + wd_t = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + we_t = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + wf_t = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + // sha256 transform + + a = SHA256M_A; + b = SHA256M_B; + c = SHA256M_C; + d = SHA256M_D; + e = SHA256M_E; + f = SHA256M_F; + g = SHA256M_G; + h = SHA256M_H; + + u32x digest[8]; + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + // append salt + + // sha256_update: ctx_len 64, pos 0, len = salt_len + + w0_t = salt_buf0[0]; + w1_t = salt_buf0[1]; + w2_t = salt_buf0[2]; + w3_t = salt_buf0[3]; + w4_t = salt_buf1[0]; + w5_t = salt_buf1[1]; + w6_t = salt_buf1[2]; + w7_t = salt_buf1[3]; + w8_t = salt_buf2[0]; + w9_t = salt_buf2[1]; + wa_t = salt_buf2[2]; + wb_t = salt_buf2[3]; + wc_t = salt_buf3[0]; + wd_t = salt_buf3[1]; + we_t = salt_buf3[2]; + wf_t = salt_buf3[3]; + + // sha256_update_64: pos 0 + + const int ctx_len = 64 + salt_len; + + const int pos = ctx_len & 63; + + // append_0x80_4x4, offset = pos ^ 3 + + const u32 off = pos ^ 3; + + const u32 c0 = (off & 15) / 4; + + const u32 r0 = 0xff << ((off & 3) * 8); + + const u32 m0[4] = { ((c0 == 0) ? r0 : 0), ((c0 == 1) ? r0 : 0), ((c0 == 2) ? r0 : 0), ((c0 == 3) ? r0 : 0) }; + + const u32 off16 = off / 16; + + const u32 v0[4] = { ((off16 == 0) ? 0x80808080 : 0), ((off16 == 1) ? 0x80808080 : 0), ((off16 == 2) ? 0x80808080 : 0), ((off16 == 3) ? 0x80808080 : 0) }; + + w0_t |= v0[0] & m0[0]; + w1_t |= v0[0] & m0[1]; + w2_t |= v0[0] & m0[2]; + w3_t |= v0[0] & m0[3]; + w4_t |= v0[1] & m0[0]; + w5_t |= v0[1] & m0[1]; + w6_t |= v0[1] & m0[2]; + w7_t |= v0[1] & m0[3]; + w8_t |= v0[2] & m0[0]; + w9_t |= v0[2] & m0[1]; + wa_t |= v0[2] & m0[2]; + wb_t |= v0[2] & m0[3]; + wc_t |= v0[3] & m0[0]; + wd_t |= v0[3] & m0[1]; + we_t |= v0[3] & m0[2]; + wf_t |= v0[3] & m0[3]; + + if (pos >= 56) + { + // sha256 transform + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + w0_t = 0; + w1_t = 0; + w2_t = 0; + w3_t = 0; + w4_t = 0; + w5_t = 0; + w6_t = 0; + w7_t = 0; + w8_t = 0; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 0; + } + + // last sha256 transform + + we_t = 0; + wf_t = ctx_len * 8; + + a = digest[0]; + b = digest[1]; + c = digest[2]; + d = digest[3]; + e = digest[4]; + f = digest[5]; + g = digest[6]; + h = digest[7]; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + +// a += digest[0] - SHA256M_A; +// b += digest[1] - SHA256M_B; + c += digest[2] - make_u32x (SHA256M_C); + d += digest[3] - make_u32x (SHA256M_D); +// e += digest[4] - SHA256M_E; +// f += digest[5] - SHA256M_F; + g += digest[6] - make_u32x (SHA256M_G); + h += digest[7] - make_u32x (SHA256M_H); + + COMPARE_M_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m20712_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m20712_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m20712_s04 (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + /** + * sha256(pass) + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = out_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + a += make_u32x (SHA256M_A); + b += make_u32x (SHA256M_B); + c += make_u32x (SHA256M_C); + d += make_u32x (SHA256M_D); + e += make_u32x (SHA256M_E); + f += make_u32x (SHA256M_F); + g += make_u32x (SHA256M_G); + h += make_u32x (SHA256M_H); + + // final sha256 + + // sha256_update_64, len 64, pos 0 + + w0_t = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w8_t = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w9_t = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + wa_t = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + wb_t = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + wc_t = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + wd_t = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + we_t = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + wf_t = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + // sha256 transform + + a = SHA256M_A; + b = SHA256M_B; + c = SHA256M_C; + d = SHA256M_D; + e = SHA256M_E; + f = SHA256M_F; + g = SHA256M_G; + h = SHA256M_H; + + u32x digest[8]; + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + // append salt + + // sha256_update: ctx_len 64, pos 0, len = salt_len + + w0_t = salt_buf0[0]; + w1_t = salt_buf0[1]; + w2_t = salt_buf0[2]; + w3_t = salt_buf0[3]; + w4_t = salt_buf1[0]; + w5_t = salt_buf1[1]; + w6_t = salt_buf1[2]; + w7_t = salt_buf1[3]; + w8_t = salt_buf2[0]; + w9_t = salt_buf2[1]; + wa_t = salt_buf2[2]; + wb_t = salt_buf2[3]; + wc_t = salt_buf3[0]; + wd_t = salt_buf3[1]; + we_t = salt_buf3[2]; + wf_t = salt_buf3[3]; + + // sha256_update_64: pos 0 + + const int ctx_len = 64 + salt_len; + + const int pos = ctx_len & 63; + + // append_0x80_4x4, offset = pos ^ 3 + + const u32 off = pos ^ 3; + + const u32 c0 = (off & 15) / 4; + + const u32 r0 = 0xff << ((off & 3) * 8); + + const u32 m0[4] = { ((c0 == 0) ? r0 : 0), ((c0 == 1) ? r0 : 0), ((c0 == 2) ? r0 : 0), ((c0 == 3) ? r0 : 0) }; + + const u32 off16 = off / 16; + + const u32 v0[4] = { ((off16 == 0) ? 0x80808080 : 0), ((off16 == 1) ? 0x80808080 : 0), ((off16 == 2) ? 0x80808080 : 0), ((off16 == 3) ? 0x80808080 : 0) }; + + w0_t |= v0[0] & m0[0]; + w1_t |= v0[0] & m0[1]; + w2_t |= v0[0] & m0[2]; + w3_t |= v0[0] & m0[3]; + w4_t |= v0[1] & m0[0]; + w5_t |= v0[1] & m0[1]; + w6_t |= v0[1] & m0[2]; + w7_t |= v0[1] & m0[3]; + w8_t |= v0[2] & m0[0]; + w9_t |= v0[2] & m0[1]; + wa_t |= v0[2] & m0[2]; + wb_t |= v0[2] & m0[3]; + wc_t |= v0[3] & m0[0]; + wd_t |= v0[3] & m0[1]; + we_t |= v0[3] & m0[2]; + wf_t |= v0[3] & m0[3]; + + if (pos >= 56) + { + // sha256 transform + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + w0_t = 0; + w1_t = 0; + w2_t = 0; + w3_t = 0; + w4_t = 0; + w5_t = 0; + w6_t = 0; + w7_t = 0; + w8_t = 0; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 0; + } + + // last sha256 transform + + we_t = 0; + wf_t = ctx_len * 8; + + a = digest[0]; + b = digest[1]; + c = digest[2]; + d = digest[3]; + e = digest[4]; + f = digest[5]; + g = digest[6]; + h = digest[7]; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + + // if (MATCHES_NONE_VS ((h + digest[7] - make_u32x (SHA256M_H)), d_rev)) continue; + + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + + if (MATCHES_NONE_VS ((h + digest[7] - make_u32x (SHA256M_H)), search[1])) continue; + + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + +// a += digest[0] - SHA256M_A; +// b += digest[1] - SHA256M_B; + c += digest[2] - make_u32x (SHA256M_C); + d += digest[3] - make_u32x (SHA256M_D); +// e += digest[4] - SHA256M_E; +// f += digest[5] - SHA256M_F; + g += digest[6] - make_u32x (SHA256M_G); + h += digest[7] - make_u32x (SHA256M_H); + + COMPARE_S_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m20712_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m20712_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m20712_a0-pure.cl b/OpenCL/m20712_a0-pure.cl new file mode 100644 index 000000000..4ec9014e3 --- /dev/null +++ b/OpenCL/m20712_a0-pure.cl @@ -0,0 +1,265 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m20712_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m20712_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m20712_a1-optimized.cl b/OpenCL/m20712_a1-optimized.cl new file mode 100644 index 000000000..b1088a630 --- /dev/null +++ b/OpenCL/m20712_a1-optimized.cl @@ -0,0 +1,1347 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +#define SHA256_STEP_REV(a,b,c,d,e,f,g,h) \ +{ \ + u32 t2 = SHA256_S2_S(b) + SHA256_F0o(b,c,d); \ + u32 t1 = a - t2; \ + a = b; \ + b = c; \ + c = d; \ + d = e - t1; \ + e = f; \ + f = g; \ + g = h; \ + h = 0; \ +} + +KERNEL_FQ void m20712_m04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * sha256(pass) + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + a += make_u32x (SHA256M_A); + b += make_u32x (SHA256M_B); + c += make_u32x (SHA256M_C); + d += make_u32x (SHA256M_D); + e += make_u32x (SHA256M_E); + f += make_u32x (SHA256M_F); + g += make_u32x (SHA256M_G); + h += make_u32x (SHA256M_H); + + // final sha256 + + // sha256_update_64, len 64, pos 0 + + w0_t = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w8_t = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w9_t = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + wa_t = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + wb_t = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + wc_t = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + wd_t = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + we_t = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + wf_t = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + // sha256 transform + + a = SHA256M_A; + b = SHA256M_B; + c = SHA256M_C; + d = SHA256M_D; + e = SHA256M_E; + f = SHA256M_F; + g = SHA256M_G; + h = SHA256M_H; + + u32x digest[8]; + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + // append salt + + // sha256_update: ctx_len 64, pos 0, len = salt_len + + w0_t = salt_buf0[0]; + w1_t = salt_buf0[1]; + w2_t = salt_buf0[2]; + w3_t = salt_buf0[3]; + w4_t = salt_buf1[0]; + w5_t = salt_buf1[1]; + w6_t = salt_buf1[2]; + w7_t = salt_buf1[3]; + w8_t = salt_buf2[0]; + w9_t = salt_buf2[1]; + wa_t = salt_buf2[2]; + wb_t = salt_buf2[3]; + wc_t = salt_buf3[0]; + wd_t = salt_buf3[1]; + we_t = salt_buf3[2]; + wf_t = salt_buf3[3]; + + // sha256_update_64: pos 0 + + const int ctx_len = 64 + salt_len; + + const int pos = ctx_len & 63; + + // append_0x80_4x4, offset = pos ^ 3 + + const u32 off = pos ^ 3; + + const u32 c0 = (off & 15) / 4; + + const u32 r0 = 0xff << ((off & 3) * 8); + + const u32 m0[4] = { ((c0 == 0) ? r0 : 0), ((c0 == 1) ? r0 : 0), ((c0 == 2) ? r0 : 0), ((c0 == 3) ? r0 : 0) }; + + const u32 off16 = off / 16; + + const u32 v0[4] = { ((off16 == 0) ? 0x80808080 : 0), ((off16 == 1) ? 0x80808080 : 0), ((off16 == 2) ? 0x80808080 : 0), ((off16 == 3) ? 0x80808080 : 0) }; + + w0_t |= v0[0] & m0[0]; + w1_t |= v0[0] & m0[1]; + w2_t |= v0[0] & m0[2]; + w3_t |= v0[0] & m0[3]; + w4_t |= v0[1] & m0[0]; + w5_t |= v0[1] & m0[1]; + w6_t |= v0[1] & m0[2]; + w7_t |= v0[1] & m0[3]; + w8_t |= v0[2] & m0[0]; + w9_t |= v0[2] & m0[1]; + wa_t |= v0[2] & m0[2]; + wb_t |= v0[2] & m0[3]; + wc_t |= v0[3] & m0[0]; + wd_t |= v0[3] & m0[1]; + we_t |= v0[3] & m0[2]; + wf_t |= v0[3] & m0[3]; + + if (pos >= 56) + { + // sha256 transform + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + w0_t = 0; + w1_t = 0; + w2_t = 0; + w3_t = 0; + w4_t = 0; + w5_t = 0; + w6_t = 0; + w7_t = 0; + w8_t = 0; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 0; + } + + // last sha256 transform + + we_t = 0; + wf_t = ctx_len * 8; + + a = digest[0]; + b = digest[1]; + c = digest[2]; + d = digest[3]; + e = digest[4]; + f = digest[5]; + g = digest[6]; + h = digest[7]; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + +// a += digest[0] - SHA256M_A; +// b += digest[1] - SHA256M_B; + c += digest[2] - make_u32x (SHA256M_C); + d += digest[3] - make_u32x (SHA256M_D); +// e += digest[4] - SHA256M_E; +// f += digest[5] - SHA256M_F; + g += digest[6] - make_u32x (SHA256M_G); + h += digest[7] - make_u32x (SHA256M_H); + + COMPARE_M_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m20712_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m20712_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m20712_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + /** + * sha256(pass) + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = pw_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + a += make_u32x (SHA256M_A); + b += make_u32x (SHA256M_B); + c += make_u32x (SHA256M_C); + d += make_u32x (SHA256M_D); + e += make_u32x (SHA256M_E); + f += make_u32x (SHA256M_F); + g += make_u32x (SHA256M_G); + h += make_u32x (SHA256M_H); + + // final sha256 + + // sha256_update_64, len 64, pos 0 + + w0_t = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w8_t = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w9_t = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + wa_t = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + wb_t = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + wc_t = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + wd_t = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + we_t = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + wf_t = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + // sha256 transform + + a = SHA256M_A; + b = SHA256M_B; + c = SHA256M_C; + d = SHA256M_D; + e = SHA256M_E; + f = SHA256M_F; + g = SHA256M_G; + h = SHA256M_H; + + u32x digest[8]; + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + // append salt + + // sha256_update: ctx_len 64, pos 0, len = salt_len + + w0_t = salt_buf0[0]; + w1_t = salt_buf0[1]; + w2_t = salt_buf0[2]; + w3_t = salt_buf0[3]; + w4_t = salt_buf1[0]; + w5_t = salt_buf1[1]; + w6_t = salt_buf1[2]; + w7_t = salt_buf1[3]; + w8_t = salt_buf2[0]; + w9_t = salt_buf2[1]; + wa_t = salt_buf2[2]; + wb_t = salt_buf2[3]; + wc_t = salt_buf3[0]; + wd_t = salt_buf3[1]; + we_t = salt_buf3[2]; + wf_t = salt_buf3[3]; + + // sha256_update_64: pos 0 + + const int ctx_len = 64 + salt_len; + + const int pos = ctx_len & 63; + + // append_0x80_4x4, offset = pos ^ 3 + + const u32 off = pos ^ 3; + + const u32 c0 = (off & 15) / 4; + + const u32 r0 = 0xff << ((off & 3) * 8); + + const u32 m0[4] = { ((c0 == 0) ? r0 : 0), ((c0 == 1) ? r0 : 0), ((c0 == 2) ? r0 : 0), ((c0 == 3) ? r0 : 0) }; + + const u32 off16 = off / 16; + + const u32 v0[4] = { ((off16 == 0) ? 0x80808080 : 0), ((off16 == 1) ? 0x80808080 : 0), ((off16 == 2) ? 0x80808080 : 0), ((off16 == 3) ? 0x80808080 : 0) }; + + w0_t |= v0[0] & m0[0]; + w1_t |= v0[0] & m0[1]; + w2_t |= v0[0] & m0[2]; + w3_t |= v0[0] & m0[3]; + w4_t |= v0[1] & m0[0]; + w5_t |= v0[1] & m0[1]; + w6_t |= v0[1] & m0[2]; + w7_t |= v0[1] & m0[3]; + w8_t |= v0[2] & m0[0]; + w9_t |= v0[2] & m0[1]; + wa_t |= v0[2] & m0[2]; + wb_t |= v0[2] & m0[3]; + wc_t |= v0[3] & m0[0]; + wd_t |= v0[3] & m0[1]; + we_t |= v0[3] & m0[2]; + wf_t |= v0[3] & m0[3]; + + if (pos >= 56) + { + // sha256 transform + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + w0_t = 0; + w1_t = 0; + w2_t = 0; + w3_t = 0; + w4_t = 0; + w5_t = 0; + w6_t = 0; + w7_t = 0; + w8_t = 0; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 0; + } + + // last sha256 transform + + we_t = 0; + wf_t = ctx_len * 8; + + a = digest[0]; + b = digest[1]; + c = digest[2]; + d = digest[3]; + e = digest[4]; + f = digest[5]; + g = digest[6]; + h = digest[7]; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + + // if (MATCHES_NONE_VS ((h + digest[7] - make_u32x (SHA256M_H)), d_rev)) continue; + + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + + if (MATCHES_NONE_VS ((h + digest[7] - make_u32x (SHA256M_H)), search[1])) continue; + + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + +// a += digest[0] - SHA256M_A; +// b += digest[1] - SHA256M_B; + c += digest[2] - make_u32x (SHA256M_C); + d += digest[3] - make_u32x (SHA256M_D); +// e += digest[4] - SHA256M_E; +// f += digest[5] - SHA256M_F; + g += digest[6] - make_u32x (SHA256M_G); + h += digest[7] - make_u32x (SHA256M_H); + + COMPARE_S_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m20712_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m20712_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m20712_a1-pure.cl b/OpenCL/m20712_a1-pure.cl new file mode 100644 index 000000000..b713e2eca --- /dev/null +++ b/OpenCL/m20712_a1-pure.cl @@ -0,0 +1,259 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m20712_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 s[64] = { 0 }; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha256_ctx_t ctx1; + + sha256_init (&ctx1); + + sha256_update_global_swap (&ctx1, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha256_ctx_t ctx0 = ctx1; + + sha256_update_global_swap (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m20712_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha256_ctx_t ctx1; + + sha256_init (&ctx1); + + sha256_update_global_swap (&ctx1, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha256_ctx_t ctx0 = ctx1; + + sha256_update_global_swap (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha256_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + const u32 f = ctx0.h[5]; + const u32 g = ctx0.h[6]; + const u32 h = ctx0.h[7]; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_64 (&ctx, w0, w1, w2, w3, 64); + + sha256_update (&ctx, s, salt_len); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m20712_a3-optimized.cl b/OpenCL/m20712_a3-optimized.cl new file mode 100644 index 000000000..2814cbe69 --- /dev/null +++ b/OpenCL/m20712_a3-optimized.cl @@ -0,0 +1,1490 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +#define SHA256_STEP_REV(a,b,c,d,e,f,g,h) \ +{ \ + u32 t2 = SHA256_S2_S(b) + SHA256_F0o(b,c,d); \ + u32 t1 = a - t2; \ + a = b; \ + b = c; \ + c = d; \ + d = e - t1; \ + e = f; \ + f = g; \ + g = h; \ + h = 0; \ +} + +DECLSPEC void m20712m (PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTOR (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + /** + * sha256(pass) + */ + + u32x w0_t = w0; + u32x w1_t = w[ 1]; + u32x w2_t = w[ 2]; + u32x w3_t = w[ 3]; + u32x w4_t = w[ 4]; + u32x w5_t = w[ 5]; + u32x w6_t = w[ 6]; + u32x w7_t = w[ 7]; + u32x w8_t = w[ 8]; + u32x w9_t = w[ 9]; + u32x wa_t = w[10]; + u32x wb_t = w[11]; + u32x wc_t = w[12]; + u32x wd_t = w[13]; + u32x we_t = w[14]; + u32x wf_t = w[15]; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + a += make_u32x (SHA256M_A); + b += make_u32x (SHA256M_B); + c += make_u32x (SHA256M_C); + d += make_u32x (SHA256M_D); + e += make_u32x (SHA256M_E); + f += make_u32x (SHA256M_F); + g += make_u32x (SHA256M_G); + h += make_u32x (SHA256M_H); + + // final sha256 + + // sha256_update_64, len 64, pos 0 + + w0_t = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w8_t = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w9_t = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + wa_t = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + wb_t = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + wc_t = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + wd_t = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + we_t = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + wf_t = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + // sha256 transform + + a = SHA256M_A; + b = SHA256M_B; + c = SHA256M_C; + d = SHA256M_D; + e = SHA256M_E; + f = SHA256M_F; + g = SHA256M_G; + h = SHA256M_H; + + u32x digest[8]; + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + // append salt + + // sha256_update: ctx_len 64, pos 0, len = salt_len + + w0_t = salt_buf0[0]; + w1_t = salt_buf0[1]; + w2_t = salt_buf0[2]; + w3_t = salt_buf0[3]; + w4_t = salt_buf1[0]; + w5_t = salt_buf1[1]; + w6_t = salt_buf1[2]; + w7_t = salt_buf1[3]; + w8_t = salt_buf2[0]; + w9_t = salt_buf2[1]; + wa_t = salt_buf2[2]; + wb_t = salt_buf2[3]; + wc_t = salt_buf3[0]; + wd_t = salt_buf3[1]; + we_t = salt_buf3[2]; + wf_t = salt_buf3[3]; + + // sha256_update_64: pos 0 + + const int ctx_len = 64 + salt_len; + + const int pos = ctx_len & 63; + + // append_0x80_4x4, offset = pos ^ 3 + + const u32 off = pos ^ 3; + + const u32 c0 = (off & 15) / 4; + + const u32 r0 = 0xff << ((off & 3) * 8); + + const u32 m0[4] = { ((c0 == 0) ? r0 : 0), ((c0 == 1) ? r0 : 0), ((c0 == 2) ? r0 : 0), ((c0 == 3) ? r0 : 0) }; + + const u32 off16 = off / 16; + + const u32 v0[4] = { ((off16 == 0) ? 0x80808080 : 0), ((off16 == 1) ? 0x80808080 : 0), ((off16 == 2) ? 0x80808080 : 0), ((off16 == 3) ? 0x80808080 : 0) }; + + w0_t |= v0[0] & m0[0]; + w1_t |= v0[0] & m0[1]; + w2_t |= v0[0] & m0[2]; + w3_t |= v0[0] & m0[3]; + w4_t |= v0[1] & m0[0]; + w5_t |= v0[1] & m0[1]; + w6_t |= v0[1] & m0[2]; + w7_t |= v0[1] & m0[3]; + w8_t |= v0[2] & m0[0]; + w9_t |= v0[2] & m0[1]; + wa_t |= v0[2] & m0[2]; + wb_t |= v0[2] & m0[3]; + wc_t |= v0[3] & m0[0]; + wd_t |= v0[3] & m0[1]; + we_t |= v0[3] & m0[2]; + wf_t |= v0[3] & m0[3]; + + if (pos >= 56) + { + // sha256 transform + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + w0_t = 0; + w1_t = 0; + w2_t = 0; + w3_t = 0; + w4_t = 0; + w5_t = 0; + w6_t = 0; + w7_t = 0; + w8_t = 0; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 0; + } + + // last sha256 transform + + we_t = 0; + wf_t = ctx_len * 8; + + a = digest[0]; + b = digest[1]; + c = digest[2]; + d = digest[3]; + e = digest[4]; + f = digest[5]; + g = digest[6]; + h = digest[7]; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + +// a += digest[0] - SHA256M_A; +// b += digest[1] - SHA256M_B; + c += digest[2] - make_u32x (SHA256M_C); + d += digest[3] - make_u32x (SHA256M_D); +// e += digest[4] - SHA256M_E; +// f += digest[5] - SHA256M_F; + g += digest[6] - make_u32x (SHA256M_G); + h += digest[7] - make_u32x (SHA256M_H); + + COMPARE_M_SIMD (d, h, c, g); + } +} + +DECLSPEC void m20712s (PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTOR (), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * salt + */ + + u32 salt_buf0[4]; + u32 salt_buf1[4]; + u32 salt_buf2[4]; + u32 salt_buf3[4]; + + salt_buf0[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 0]); + salt_buf0[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 1]); + salt_buf0[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 2]); + salt_buf0[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 3]); + salt_buf1[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 4]); + salt_buf1[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 5]); + salt_buf1[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 6]); + salt_buf1[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 7]); + salt_buf2[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 8]); + salt_buf2[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[ 9]); + salt_buf2[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[10]); + salt_buf2[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[11]); + salt_buf3[0] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[12]); + salt_buf3[1] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[13]); + salt_buf3[2] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[14]); + salt_buf3[3] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[15]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + /** + * loop + */ + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + /** + * sha256(pass) + */ + + u32x w0_t = w0; + u32x w1_t = w[ 1]; + u32x w2_t = w[ 2]; + u32x w3_t = w[ 3]; + u32x w4_t = w[ 4]; + u32x w5_t = w[ 5]; + u32x w6_t = w[ 6]; + u32x w7_t = w[ 7]; + u32x w8_t = w[ 8]; + u32x w9_t = w[ 9]; + u32x wa_t = w[10]; + u32x wb_t = w[11]; + u32x wc_t = w[12]; + u32x wd_t = w[13]; + u32x we_t = w[14]; + u32x wf_t = w[15]; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + a += make_u32x (SHA256M_A); + b += make_u32x (SHA256M_B); + c += make_u32x (SHA256M_C); + d += make_u32x (SHA256M_D); + e += make_u32x (SHA256M_E); + f += make_u32x (SHA256M_F); + g += make_u32x (SHA256M_G); + h += make_u32x (SHA256M_H); + + // final sha256 + + // sha256_update_64, len 64, pos 0 + + w0_t = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + w1_t = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + w2_t = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + w3_t = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + w4_t = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + w5_t = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + w6_t = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + w7_t = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + w8_t = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + w9_t = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + wa_t = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + wb_t = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + wc_t = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + wd_t = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + we_t = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + wf_t = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + // sha256 transform + + a = SHA256M_A; + b = SHA256M_B; + c = SHA256M_C; + d = SHA256M_D; + e = SHA256M_E; + f = SHA256M_F; + g = SHA256M_G; + h = SHA256M_H; + + u32x digest[8]; + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + // append salt + + // sha256_update: ctx_len 64, pos 0, len = salt_len + + w0_t = salt_buf0[0]; + w1_t = salt_buf0[1]; + w2_t = salt_buf0[2]; + w3_t = salt_buf0[3]; + w4_t = salt_buf1[0]; + w5_t = salt_buf1[1]; + w6_t = salt_buf1[2]; + w7_t = salt_buf1[3]; + w8_t = salt_buf2[0]; + w9_t = salt_buf2[1]; + wa_t = salt_buf2[2]; + wb_t = salt_buf2[3]; + wc_t = salt_buf3[0]; + wd_t = salt_buf3[1]; + we_t = salt_buf3[2]; + wf_t = salt_buf3[3]; + + // sha256_update_64: pos 0 + + const int ctx_len = 64 + salt_len; + + const int pos = ctx_len & 63; + + // append_0x80_4x4, offset = pos ^ 3 + + const u32 off = pos ^ 3; + + const u32 c0 = (off & 15) / 4; + + const u32 r0 = 0xff << ((off & 3) * 8); + + const u32 m0[4] = { ((c0 == 0) ? r0 : 0), ((c0 == 1) ? r0 : 0), ((c0 == 2) ? r0 : 0), ((c0 == 3) ? r0 : 0) }; + + const u32 off16 = off / 16; + + const u32 v0[4] = { ((off16 == 0) ? 0x80808080 : 0), ((off16 == 1) ? 0x80808080 : 0), ((off16 == 2) ? 0x80808080 : 0), ((off16 == 3) ? 0x80808080 : 0) }; + + w0_t |= v0[0] & m0[0]; + w1_t |= v0[0] & m0[1]; + w2_t |= v0[0] & m0[2]; + w3_t |= v0[0] & m0[3]; + w4_t |= v0[1] & m0[0]; + w5_t |= v0[1] & m0[1]; + w6_t |= v0[1] & m0[2]; + w7_t |= v0[1] & m0[3]; + w8_t |= v0[2] & m0[0]; + w9_t |= v0[2] & m0[1]; + wa_t |= v0[2] & m0[2]; + wb_t |= v0[2] & m0[3]; + wc_t |= v0[3] & m0[0]; + wd_t |= v0[3] & m0[1]; + we_t |= v0[3] & m0[2]; + wf_t |= v0[3] & m0[3]; + + if (pos >= 56) + { + // sha256 transform + + digest[0] = a; + digest[1] = b; + digest[2] = c; + digest[3] = d; + digest[4] = e; + digest[5] = f; + digest[6] = g; + digest[7] = h; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + digest[0] += a; + digest[1] += b; + digest[2] += c; + digest[3] += d; + digest[4] += e; + digest[5] += f; + digest[6] += g; + digest[7] += h; + + w0_t = 0; + w1_t = 0; + w2_t = 0; + w3_t = 0; + w4_t = 0; + w5_t = 0; + w6_t = 0; + w7_t = 0; + w8_t = 0; + w9_t = 0; + wa_t = 0; + wb_t = 0; + wc_t = 0; + wd_t = 0; + we_t = 0; + wf_t = 0; + } + + // last sha256 transform + + we_t = 0; + wf_t = ctx_len * 8; + + a = digest[0]; + b = digest[1]; + c = digest[2]; + d = digest[3]; + e = digest[4]; + f = digest[5]; + g = digest[6]; + h = digest[7]; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + + if (MATCHES_NONE_VS ((h + digest[7] - make_u32x (SHA256M_H)), search[1])) continue; + + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + +// a += digest[0] - SHA256M_A; +// b += digest[1] - SHA256M_B; + c += digest[2] - make_u32x (SHA256M_C); + d += digest[3] - make_u32x (SHA256M_D); +// e += digest[4] - SHA256M_E; +// f += digest[5] - SHA256M_F; + g += digest[6] - make_u32x (SHA256M_G); + h += digest[7] - make_u32x (SHA256M_H); + + COMPARE_S_SIMD (d, h, c, g); + } +} + +KERNEL_FQ void m20712_m04 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m20712m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m20712_m08 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m20712m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m20712_m16 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m20712m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m20712_s04 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m20712s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m20712_s08 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m20712s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m20712_s16 (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m20712s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} diff --git a/OpenCL/m20712_a3-pure.cl b/OpenCL/m20712_a3-pure.cl new file mode 100644 index 000000000..908b8ca2d --- /dev/null +++ b/OpenCL/m20712_a3-pure.cl @@ -0,0 +1,285 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8_le(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m20712_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx0; + + sha256_init_vector (&ctx0); + + sha256_update_vector (&ctx0, w, pw_len); + + sha256_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + const u32x f = ctx0.h[5]; + const u32x g = ctx0.h[6]; + const u32x h = ctx0.h[7]; + + sha256_ctx_vector_t ctx; + + sha256_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + _w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + _w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + _w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + _w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + _w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + _w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + _w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + _w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + _w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + _w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + _w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + _w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + _w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + _w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + _w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 64); + + sha256_update_vector (&ctx, s, salt_len); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m20712_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'A' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'A' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (int i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx0; + + sha256_init_vector (&ctx0); + + sha256_update_vector (&ctx0, w, pw_len); + + sha256_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + const u32x f = ctx0.h[5]; + const u32x g = ctx0.h[6]; + const u32x h = ctx0.h[7]; + + sha256_ctx_vector_t ctx; + + sha256_init_vector (&ctx); + + _w0[0] = uint_to_hex_lower8_le ((a >> 16) & 255) << 0 | uint_to_hex_lower8_le ((a >> 24) & 255) << 16; + _w0[1] = uint_to_hex_lower8_le ((a >> 0) & 255) << 0 | uint_to_hex_lower8_le ((a >> 8) & 255) << 16; + _w0[2] = uint_to_hex_lower8_le ((b >> 16) & 255) << 0 | uint_to_hex_lower8_le ((b >> 24) & 255) << 16; + _w0[3] = uint_to_hex_lower8_le ((b >> 0) & 255) << 0 | uint_to_hex_lower8_le ((b >> 8) & 255) << 16; + _w1[0] = uint_to_hex_lower8_le ((c >> 16) & 255) << 0 | uint_to_hex_lower8_le ((c >> 24) & 255) << 16; + _w1[1] = uint_to_hex_lower8_le ((c >> 0) & 255) << 0 | uint_to_hex_lower8_le ((c >> 8) & 255) << 16; + _w1[2] = uint_to_hex_lower8_le ((d >> 16) & 255) << 0 | uint_to_hex_lower8_le ((d >> 24) & 255) << 16; + _w1[3] = uint_to_hex_lower8_le ((d >> 0) & 255) << 0 | uint_to_hex_lower8_le ((d >> 8) & 255) << 16; + _w2[0] = uint_to_hex_lower8_le ((e >> 16) & 255) << 0 | uint_to_hex_lower8_le ((e >> 24) & 255) << 16; + _w2[1] = uint_to_hex_lower8_le ((e >> 0) & 255) << 0 | uint_to_hex_lower8_le ((e >> 8) & 255) << 16; + _w2[2] = uint_to_hex_lower8_le ((f >> 16) & 255) << 0 | uint_to_hex_lower8_le ((f >> 24) & 255) << 16; + _w2[3] = uint_to_hex_lower8_le ((f >> 0) & 255) << 0 | uint_to_hex_lower8_le ((f >> 8) & 255) << 16; + _w3[0] = uint_to_hex_lower8_le ((g >> 16) & 255) << 0 | uint_to_hex_lower8_le ((g >> 24) & 255) << 16; + _w3[1] = uint_to_hex_lower8_le ((g >> 0) & 255) << 0 | uint_to_hex_lower8_le ((g >> 8) & 255) << 16; + _w3[2] = uint_to_hex_lower8_le ((h >> 16) & 255) << 0 | uint_to_hex_lower8_le ((h >> 24) & 255) << 16; + _w3[3] = uint_to_hex_lower8_le ((h >> 0) & 255) << 0 | uint_to_hex_lower8_le ((h >> 8) & 255) << 16; + + sha256_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 64); + + sha256_update_vector (&ctx, s, salt_len); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m21310_a0-pure.cl b/OpenCL/m21310_a0-pure.cl new file mode 100644 index 000000000..dba86ea7d --- /dev/null +++ b/OpenCL/m21310_a0-pure.cl @@ -0,0 +1,282 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m21310_mxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + sha1_ctx_t ctx00; + + sha1_init(&ctx00); + + sha1_update_global (&ctx00, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len); + + md5_ctx_t ctx11; + + md5_init (&ctx11); + + md5_update_global (&ctx11, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + sha1_ctx_t ctx0 = ctx00; + + sha1_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx = ctx11; + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m21310_sxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + sha1_ctx_t ctx00; + + sha1_init(&ctx00); + + sha1_update_global (&ctx00, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len); + + md5_ctx_t ctx11; + + md5_init (&ctx11); + + md5_update_global (&ctx11, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_ctx_t ctx0 = ctx00; + + sha1_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx = ctx11; + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m21310_a1-pure.cl b/OpenCL/m21310_a1-pure.cl new file mode 100644 index 000000000..be8285e50 --- /dev/null +++ b/OpenCL/m21310_a1-pure.cl @@ -0,0 +1,275 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m21310_mxx (KERN_ATTR_ESALT (md5_double_salt)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + sha1_ctx_t ctx00; + + sha1_init (&ctx00); + + sha1_update_global (&ctx00, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len); + + sha1_update_global_swap (&ctx00, pws[gid].i, pws[gid].pw_len); + + md5_ctx_t ctx11; + + md5_init (&ctx11); + + md5_update_global (&ctx11, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha1_ctx_t ctx0 = ctx00; + + sha1_update_global_swap (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx = ctx11; + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m21310_sxx (KERN_ATTR_ESALT (md5_double_salt)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + sha1_ctx_t ctx00; + + sha1_init (&ctx00); + + sha1_update_global (&ctx00, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len); + + sha1_update_global_swap (&ctx00, pws[gid].i, pws[gid].pw_len); + + md5_ctx_t ctx11; + + md5_init (&ctx11); + + md5_update_global (&ctx11, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len); + + /** + * loop + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha1_ctx_t ctx0 = ctx00; + + sha1_update_global_swap (&ctx0, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha1_final (&ctx0); + + const u32 a = ctx0.h[0]; + const u32 b = ctx0.h[1]; + const u32 c = ctx0.h[2]; + const u32 d = ctx0.h[3]; + const u32 e = ctx0.h[4]; + + md5_ctx_t ctx = ctx11; + + w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + md5_update_64 (&ctx, w0, w1, w2, w3, 40); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m21310_a3-pure.cl b/OpenCL/m21310_a3-pure.cl new file mode 100644 index 000000000..546e7defb --- /dev/null +++ b/OpenCL/m21310_a3-pure.cl @@ -0,0 +1,312 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m21310_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha1_ctx_t ctx00; + + sha1_init (&ctx00); + + sha1_update_global (&ctx00, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len); + + md5_ctx_t ctx11; + + md5_init (&ctx11); + + md5_update_global (&ctx11, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len); + + /** + * loop + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha1_ctx_vector_t ctx0; + + sha1_init_vector_from_scalar (&ctx0, &ctx00); + + sha1_update_vector_swap (&ctx0, w, pw_len); + + sha1_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + + md5_ctx_vector_t ctx; + + md5_init_vector_from_scalar (&ctx, &ctx11); + + _w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + _w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + _w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + _w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + _w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + _w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + _w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + _w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + _w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + _w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + _w2[2] = 0; + _w2[3] = 0; + _w3[0] = 0; + _w3[1] = 0; + _w3[2] = 0; + _w3[3] = 0; + + md5_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 40); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m21310_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha1_ctx_t ctx00; + + sha1_init (&ctx00); + + sha1_update_global (&ctx00, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len); + + md5_ctx_t ctx11; + + md5_init (&ctx11); + + md5_update_global (&ctx11, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len); + + /** + * loop + */ + + u32x _w0[4]; + u32x _w1[4]; + u32x _w2[4]; + u32x _w3[4]; + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha1_ctx_vector_t ctx0; + + sha1_init_vector_from_scalar (&ctx0, &ctx00); + + sha1_update_vector_swap (&ctx0, w, pw_len); + + sha1_final_vector (&ctx0); + + const u32x a = ctx0.h[0]; + const u32x b = ctx0.h[1]; + const u32x c = ctx0.h[2]; + const u32x d = ctx0.h[3]; + const u32x e = ctx0.h[4]; + + md5_ctx_vector_t ctx; + + md5_init_vector_from_scalar (&ctx, &ctx11); + + _w0[0] = uint_to_hex_lower8 ((a >> 24) & 255) << 0 + | uint_to_hex_lower8 ((a >> 16) & 255) << 16; + _w0[1] = uint_to_hex_lower8 ((a >> 8) & 255) << 0 + | uint_to_hex_lower8 ((a >> 0) & 255) << 16; + _w0[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 0 + | uint_to_hex_lower8 ((b >> 16) & 255) << 16; + _w0[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 0 + | uint_to_hex_lower8 ((b >> 0) & 255) << 16; + _w1[0] = uint_to_hex_lower8 ((c >> 24) & 255) << 0 + | uint_to_hex_lower8 ((c >> 16) & 255) << 16; + _w1[1] = uint_to_hex_lower8 ((c >> 8) & 255) << 0 + | uint_to_hex_lower8 ((c >> 0) & 255) << 16; + _w1[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 0 + | uint_to_hex_lower8 ((d >> 16) & 255) << 16; + _w1[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 0 + | uint_to_hex_lower8 ((d >> 0) & 255) << 16; + _w2[0] = uint_to_hex_lower8 ((e >> 24) & 255) << 0 + | uint_to_hex_lower8 ((e >> 16) & 255) << 16; + _w2[1] = uint_to_hex_lower8 ((e >> 8) & 255) << 0 + | uint_to_hex_lower8 ((e >> 0) & 255) << 16; + _w2[2] = 0; + _w2[3] = 0; + _w3[0] = 0; + _w3[1] = 0; + _w3[2] = 0; + _w3[3] = 0; + + md5_update_vector_64 (&ctx, _w0, _w1, _w2, _w3, 40); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m22700-pure.cl b/OpenCL/m22700-pure.cl index 7d65fd52e..a29df1c03 100644 --- a/OpenCL/m22700-pure.cl +++ b/OpenCL/m22700-pure.cl @@ -400,6 +400,9 @@ KERNEL_FQ void m22700_init (KERN_ATTR_TMPS (scrypt_tmp_t)) #if defined IS_CUDA || defined IS_HIP const uint4 tmp0 = make_uint4 (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = make_uint4 (digest[4], digest[5], digest[6], digest[7]); + #elif defined IS_METAL + const uint4 tmp0 = uint4 (digest[0], digest[1], digest[2], digest[3]); + const uint4 tmp1 = uint4 (digest[4], digest[5], digest[6], digest[7]); #else const uint4 tmp0 = (uint4) (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = (uint4) (digest[4], digest[5], digest[6], digest[7]); @@ -430,6 +433,11 @@ KERNEL_FQ void m22700_init (KERN_ATTR_TMPS (scrypt_tmp_t)) X[1] = make_uint4 (T[1].x, T[2].y, T[3].z, T[0].w); X[2] = make_uint4 (T[2].x, T[3].y, T[0].z, T[1].w); X[3] = make_uint4 (T[3].x, T[0].y, T[1].z, T[2].w); + #elif defined IS_METAL + X[0] = uint4 (T[0].x, T[1].y, T[2].z, T[3].w); + X[1] = uint4 (T[1].x, T[2].y, T[3].z, T[0].w); + X[2] = uint4 (T[2].x, T[3].y, T[0].z, T[1].w); + X[3] = uint4 (T[3].x, T[0].y, T[1].z, T[2].w); #else X[0] = (uint4) (T[0].x, T[1].y, T[2].z, T[3].w); X[1] = (uint4) (T[1].x, T[2].y, T[3].z, T[0].w); @@ -605,6 +613,11 @@ KERNEL_FQ void m22700_comp (KERN_ATTR_TMPS (scrypt_tmp_t)) T[1] = make_uint4 (X[1].x, X[0].y, X[3].z, X[2].w); T[2] = make_uint4 (X[2].x, X[1].y, X[0].z, X[3].w); T[3] = make_uint4 (X[3].x, X[2].y, X[1].z, X[0].w); + #elif defined IS_METAL + T[0] = uint4 (X[0].x, X[3].y, X[2].z, X[1].w); + T[1] = uint4 (X[1].x, X[0].y, X[3].z, X[2].w); + T[2] = uint4 (X[2].x, X[1].y, X[0].z, X[3].w); + T[3] = uint4 (X[3].x, X[2].y, X[1].z, X[0].w); #else T[0] = (uint4) (X[0].x, X[3].y, X[2].z, X[1].w); T[1] = (uint4) (X[1].x, X[0].y, X[3].z, X[2].w); diff --git a/OpenCL/m25400-pure.cl b/OpenCL/m25400-pure.cl index 8ab75831c..6ad2d1034 100644 --- a/OpenCL/m25400-pure.cl +++ b/OpenCL/m25400-pure.cl @@ -38,6 +38,8 @@ typedef struct pdf u32 rc4key[2]; u32 rc4data[2]; + int P_minus; + } pdf_t; typedef struct pdf14_tmp diff --git a/OpenCL/m25500-pure.cl b/OpenCL/m25500-pure.cl index 05dbd8b48..f5c72c3de 100644 --- a/OpenCL/m25500-pure.cl +++ b/OpenCL/m25500-pure.cl @@ -371,7 +371,7 @@ KERNEL_FQ void m25500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh */ /* - // decrypt buffer is not usefull here, skip + // decrypt buffer is not useful here, skip u32 dec[14] = { 0 }; AES_GCM_GCTR (key, J0, enc, enc_len, dec, s_te0, s_te1, s_te2, s_te3, s_te4); diff --git a/OpenCL/m25600-pure.cl b/OpenCL/m25600-pure.cl index d53a828db..98151b7bf 100644 --- a/OpenCL/m25600-pure.cl +++ b/OpenCL/m25600-pure.cl @@ -352,7 +352,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val) #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key) diff --git a/OpenCL/m25800-pure.cl b/OpenCL/m25800-pure.cl index 8658e17c8..2c3d581ec 100644 --- a/OpenCL/m25800-pure.cl +++ b/OpenCL/m25800-pure.cl @@ -348,7 +348,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val, const u6 #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key, MAYBE_UNUSED const u64 lid) diff --git a/OpenCL/m26610-pure.cl b/OpenCL/m26610-pure.cl index 9c51ea572..abd476395 100644 --- a/OpenCL/m26610-pure.cl +++ b/OpenCL/m26610-pure.cl @@ -21,11 +21,11 @@ typedef struct pbkdf2_sha256_tmp { - u32 ipad[8]; - u32 opad[8]; + u32 ipad[8]; + u32 opad[8]; - u32 dgst[32]; - u32 out[32]; + u32 dgst[32]; + u32 out[32]; } pbkdf2_sha256_tmp_t; @@ -34,7 +34,7 @@ typedef struct pbkdf2_sha256_aes_gcm u32 salt_buf[64]; u32 iv_buf[4]; u32 iv_len; - u32 ct_buf[784]; // TODO this can be smaller and would speedup the attack, only 64 bytes of ciphertext are allowed + u32 ct_buf[16]; u32 ct_len; } pbkdf2_sha256_aes_gcm_t; @@ -368,7 +368,6 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh AES_GCM_decrypt (key, J0, ct, 32, pt, s_te0, s_te1, s_te2, s_te3, s_te4); - const int correct = is_valid_printable_32 (pt[0]) + is_valid_printable_32 (pt[1]) + is_valid_printable_32 (pt[2]) @@ -382,7 +381,7 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh /* const int pt_len = 28; // not using 32 byte but 28 because our UTF8 allows up to 4 byte per character and since we decrypt 32 byte - // only we can't garantee it is not in the middle of a UTF8 byte stream at that point + // only we can't guarantee it is not in the middle of a UTF8 byte stream at that point if (hc_enc_scan (pt, pt_len)) { diff --git a/OpenCL/m27700-pure.cl b/OpenCL/m27700-pure.cl index feaca11de..c62dc90d6 100644 --- a/OpenCL/m27700-pure.cl +++ b/OpenCL/m27700-pure.cl @@ -351,6 +351,9 @@ KERNEL_FQ void m27700_init (KERN_ATTR_TMPS (scrypt_tmp_t)) #if defined IS_CUDA || defined IS_HIP const uint4 tmp0 = make_uint4 (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = make_uint4 (digest[4], digest[5], digest[6], digest[7]); + #elif defined IS_METAL + const uint4 tmp0 = uint4 (digest[0], digest[1], digest[2], digest[3]); + const uint4 tmp1 = uint4 (digest[4], digest[5], digest[6], digest[7]); #else const uint4 tmp0 = (uint4) (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = (uint4) (digest[4], digest[5], digest[6], digest[7]); @@ -381,6 +384,11 @@ KERNEL_FQ void m27700_init (KERN_ATTR_TMPS (scrypt_tmp_t)) X[1] = make_uint4 (T[1].x, T[2].y, T[3].z, T[0].w); X[2] = make_uint4 (T[2].x, T[3].y, T[0].z, T[1].w); X[3] = make_uint4 (T[3].x, T[0].y, T[1].z, T[2].w); + #elif defined IS_METAL + X[0] = uint4 (T[0].x, T[1].y, T[2].z, T[3].w); + X[1] = uint4 (T[1].x, T[2].y, T[3].z, T[0].w); + X[2] = uint4 (T[2].x, T[3].y, T[0].z, T[1].w); + X[3] = uint4 (T[3].x, T[0].y, T[1].z, T[2].w); #else X[0] = (uint4) (T[0].x, T[1].y, T[2].z, T[3].w); X[1] = (uint4) (T[1].x, T[2].y, T[3].z, T[0].w); @@ -557,6 +565,11 @@ KERNEL_FQ void m27700_comp (KERN_ATTR_TMPS (scrypt_tmp_t)) T[1] = make_uint4 (X[1].x, X[0].y, X[3].z, X[2].w); T[2] = make_uint4 (X[2].x, X[1].y, X[0].z, X[3].w); T[3] = make_uint4 (X[3].x, X[2].y, X[1].z, X[0].w); + #elif defined IS_METAL + T[0] = uint4 (X[0].x, X[3].y, X[2].z, X[1].w); + T[1] = uint4 (X[1].x, X[0].y, X[3].z, X[2].w); + T[2] = uint4 (X[2].x, X[1].y, X[0].z, X[3].w); + T[3] = uint4 (X[3].x, X[2].y, X[1].z, X[0].w); #else T[0] = (uint4) (X[0].x, X[3].y, X[2].z, X[1].w); T[1] = (uint4) (X[1].x, X[0].y, X[3].z, X[2].w); diff --git a/OpenCL/m28200-pure.cl b/OpenCL/m28200-pure.cl index 2ead5b4bc..2260e931b 100644 --- a/OpenCL/m28200-pure.cl +++ b/OpenCL/m28200-pure.cl @@ -337,6 +337,9 @@ KERNEL_FQ void m28200_init (KERN_ATTR_TMPS_ESALT (exodus_tmp_t, exodus_t)) #if defined IS_CUDA || defined IS_HIP const uint4 tmp0 = make_uint4 (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = make_uint4 (digest[4], digest[5], digest[6], digest[7]); + #elif defined IS_METAL + const uint4 tmp0 = uint4 (digest[0], digest[1], digest[2], digest[3]); + const uint4 tmp1 = uint4 (digest[4], digest[5], digest[6], digest[7]); #else const uint4 tmp0 = (uint4) (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = (uint4) (digest[4], digest[5], digest[6], digest[7]); @@ -367,6 +370,11 @@ KERNEL_FQ void m28200_init (KERN_ATTR_TMPS_ESALT (exodus_tmp_t, exodus_t)) X[1] = make_uint4 (T[1].x, T[2].y, T[3].z, T[0].w); X[2] = make_uint4 (T[2].x, T[3].y, T[0].z, T[1].w); X[3] = make_uint4 (T[3].x, T[0].y, T[1].z, T[2].w); + #elif defined IS_METAL + X[0] = uint4 (T[0].x, T[1].y, T[2].z, T[3].w); + X[1] = uint4 (T[1].x, T[2].y, T[3].z, T[0].w); + X[2] = uint4 (T[2].x, T[3].y, T[0].z, T[1].w); + X[3] = uint4 (T[3].x, T[0].y, T[1].z, T[2].w); #else X[0] = (uint4) (T[0].x, T[1].y, T[2].z, T[3].w); X[1] = (uint4) (T[1].x, T[2].y, T[3].z, T[0].w); @@ -525,6 +533,11 @@ KERNEL_FQ void m28200_comp (KERN_ATTR_TMPS_ESALT (exodus_tmp_t, exodus_t)) T[1] = make_uint4 (X[1].x, X[0].y, X[3].z, X[2].w); T[2] = make_uint4 (X[2].x, X[1].y, X[0].z, X[3].w); T[3] = make_uint4 (X[3].x, X[2].y, X[1].z, X[0].w); + #elif defined IS_METAL + T[0] = uint4 (X[0].x, X[3].y, X[2].z, X[1].w); + T[1] = uint4 (X[1].x, X[0].y, X[3].z, X[2].w); + T[2] = uint4 (X[2].x, X[1].y, X[0].z, X[3].w); + T[3] = uint4 (X[3].x, X[2].y, X[1].z, X[0].w); #else T[0] = (uint4) (X[0].x, X[3].y, X[2].z, X[1].w); T[1] = (uint4) (X[1].x, X[0].y, X[3].z, X[2].w); diff --git a/OpenCL/m28400-pure.cl b/OpenCL/m28400-pure.cl index 0fb0d45ad..2fec71c5b 100644 --- a/OpenCL/m28400-pure.cl +++ b/OpenCL/m28400-pure.cl @@ -348,7 +348,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val, const u6 #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key, MAYBE_UNUSED const u64 lid) diff --git a/OpenCL/m29800-pure.cl b/OpenCL/m29800-pure.cl index de4260279..c72f5c267 100644 --- a/OpenCL/m29800-pure.cl +++ b/OpenCL/m29800-pure.cl @@ -351,6 +351,9 @@ KERNEL_FQ void m29800_init (KERN_ATTR_TMPS (scrypt_tmp_t)) #if defined IS_CUDA || defined IS_HIP const uint4 tmp0 = make_uint4 (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = make_uint4 (digest[4], digest[5], digest[6], digest[7]); + #elif defined IS_METAL + const uint4 tmp0 = uint4 (digest[0], digest[1], digest[2], digest[3]); + const uint4 tmp1 = uint4 (digest[4], digest[5], digest[6], digest[7]); #else const uint4 tmp0 = (uint4) (digest[0], digest[1], digest[2], digest[3]); const uint4 tmp1 = (uint4) (digest[4], digest[5], digest[6], digest[7]); @@ -381,6 +384,11 @@ KERNEL_FQ void m29800_init (KERN_ATTR_TMPS (scrypt_tmp_t)) X[1] = make_uint4 (T[1].x, T[2].y, T[3].z, T[0].w); X[2] = make_uint4 (T[2].x, T[3].y, T[0].z, T[1].w); X[3] = make_uint4 (T[3].x, T[0].y, T[1].z, T[2].w); + #elif defined IS_METAL + X[0] = uint4 (T[0].x, T[1].y, T[2].z, T[3].w); + X[1] = uint4 (T[1].x, T[2].y, T[3].z, T[0].w); + X[2] = uint4 (T[2].x, T[3].y, T[0].z, T[1].w); + X[3] = uint4 (T[3].x, T[0].y, T[1].z, T[2].w); #else X[0] = (uint4) (T[0].x, T[1].y, T[2].z, T[3].w); X[1] = (uint4) (T[1].x, T[2].y, T[3].z, T[0].w); @@ -557,6 +565,11 @@ KERNEL_FQ void m29800_comp (KERN_ATTR_TMPS (scrypt_tmp_t)) T[1] = make_uint4 (X[1].x, X[0].y, X[3].z, X[2].w); T[2] = make_uint4 (X[2].x, X[1].y, X[0].z, X[3].w); T[3] = make_uint4 (X[3].x, X[2].y, X[1].z, X[0].w); + #elif defined IS_METAL + T[0] = uint4 (X[0].x, X[3].y, X[2].z, X[1].w); + T[1] = uint4 (X[1].x, X[0].y, X[3].z, X[2].w); + T[2] = uint4 (X[2].x, X[1].y, X[0].z, X[3].w); + T[3] = uint4 (X[3].x, X[2].y, X[1].z, X[0].w); #else T[0] = (uint4) (X[0].x, X[3].y, X[2].z, X[1].w); T[1] = (uint4) (X[1].x, X[0].y, X[3].z, X[2].w); diff --git a/OpenCL/m30600-pure.cl b/OpenCL/m30600-pure.cl index 5aebee3d9..140514465 100644 --- a/OpenCL/m30600-pure.cl +++ b/OpenCL/m30600-pure.cl @@ -349,7 +349,7 @@ DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u64 key, const u32 val, const u6 #else -// access pattern: linear access with S offset already set to right offset based on thread ID saving it from compuation +// access pattern: linear access with S offset already set to right offset based on thread ID saving it from computation // makes sense if there are not thread ID's (for instance on CPU) DECLSPEC inline u32 GET_KEY32 (LOCAL_AS u32 *S, const u64 key, MAYBE_UNUSED const u64 lid) diff --git a/OpenCL/m31000_a0-optimized.cl b/OpenCL/m31000_a0-optimized.cl index fbebe24f4..52d4d7852 100644 --- a/OpenCL/m31000_a0-optimized.cl +++ b/OpenCL/m31000_a0-optimized.cl @@ -48,8 +48,6 @@ KERNEL_FQ void m31000_m04 (KERN_ATTR_RULES ()) { u32x w0[4] = { 0 }; u32x w1[4] = { 0 }; - u32x w2[4] = { 0 }; - u32x w3[4] = { 0 }; const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); @@ -185,7 +183,7 @@ KERNEL_FQ void m31000_s04 (KERN_ATTR_RULES ()) const u32x r1 = h[DGST_R1]; const u32x r2 = h[DGST_R2]; const u32x r3 = h[DGST_R3]; - + COMPARE_S_SIMD (r0, r1, r2, r3); } } diff --git a/OpenCL/m31000_a0-pure.cl b/OpenCL/m31000_a0-pure.cl index d6fdb0a51..81919e0ff 100644 --- a/OpenCL/m31000_a0-pure.cl +++ b/OpenCL/m31000_a0-pure.cl @@ -47,7 +47,7 @@ KERNEL_FQ void m31000_mxx (KERN_ATTR_RULES ()) blake2s_init (&ctx); blake2s_update (&ctx, tmp.i, tmp.pw_len); blake2s_final (&ctx); - + const u32 r0 = ctx.h[DGST_R0]; const u32 r1 = ctx.h[DGST_R1]; const u32 r2 = ctx.h[DGST_R2]; diff --git a/OpenCL/m31300_a0-optimized.cl b/OpenCL/m31300_a0-optimized.cl index 453eba46b..11b3061c5 100644 --- a/OpenCL/m31300_a0-optimized.cl +++ b/OpenCL/m31300_a0-optimized.cl @@ -145,10 +145,10 @@ KERNEL_FQ void m31300_m04 (KERN_ATTR_RULES ()) MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23); - w0[0] = a + MD4M_A; - w0[1] = b + MD4M_B; - w0[2] = c + MD4M_C; - w0[3] = d + MD4M_D; + w0[0] = a + make_u32x (MD4M_A); + w0[1] = b + make_u32x (MD4M_B); + w0[2] = c + make_u32x (MD4M_C); + w0[3] = d + make_u32x (MD4M_D); w1[0] = salt_buf[ 0]; w1[1] = salt_buf[ 1]; w1[2] = salt_buf[ 2]; @@ -237,10 +237,10 @@ KERNEL_FQ void m31300_m04 (KERN_ATTR_RULES ()) MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); - a = a + MD5M_A; - b = b + MD5M_B; - c = c + MD5M_C; - d = d + MD5M_D; + a = a + make_u32x (MD5M_A); + b = b + make_u32x (MD5M_B); + c = c + make_u32x (MD5M_C); + d = d + make_u32x (MD5M_D); const u32x a1 = a; const u32x b1 = b; @@ -491,10 +491,10 @@ KERNEL_FQ void m31300_s04 (KERN_ATTR_RULES ()) MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23); - w0[0] = a + MD4M_A; - w0[1] = b + MD4M_B; - w0[2] = c + MD4M_C; - w0[3] = d + MD4M_D; + w0[0] = a + make_u32x (MD4M_A); + w0[1] = b + make_u32x (MD4M_B); + w0[2] = c + make_u32x (MD4M_C); + w0[3] = d + make_u32x (MD4M_D); w1[0] = salt_buf[ 0]; w1[1] = salt_buf[ 1]; w1[2] = salt_buf[ 2]; @@ -583,10 +583,10 @@ KERNEL_FQ void m31300_s04 (KERN_ATTR_RULES ()) MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); - a = a + MD5M_A; - b = b + MD5M_B; - c = c + MD5M_C; - d = d + MD5M_D; + a = a + make_u32x (MD5M_A); + b = b + make_u32x (MD5M_B); + c = c + make_u32x (MD5M_C); + d = d + make_u32x (MD5M_D); const u32x a1 = a; const u32x b1 = b; diff --git a/OpenCL/m31300_a1-optimized.cl b/OpenCL/m31300_a1-optimized.cl index ec6ba05d3..604554925 100644 --- a/OpenCL/m31300_a1-optimized.cl +++ b/OpenCL/m31300_a1-optimized.cl @@ -205,11 +205,10 @@ KERNEL_FQ void m31300_m04 (KERN_ATTR_BASIC ()) MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22); MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23); - - w0[0] = a + MD4M_A; - w0[1] = b + MD4M_B; - w0[2] = c + MD4M_C; - w0[3] = d + MD4M_D; + w0[0] = a + make_u32x (MD4M_A); + w0[1] = b + make_u32x (MD4M_B); + w0[2] = c + make_u32x (MD4M_C); + w0[3] = d + make_u32x (MD4M_D); w1[0] = salt_buf[ 0]; w1[1] = salt_buf[ 1]; w1[2] = salt_buf[ 2]; @@ -298,10 +297,10 @@ KERNEL_FQ void m31300_m04 (KERN_ATTR_BASIC ()) MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); - a = a + MD5M_A; - b = b + MD5M_B; - c = c + MD5M_C; - d = d + MD5M_D; + a = a + make_u32x (MD5M_A); + b = b + make_u32x (MD5M_B); + c = c + make_u32x (MD5M_C); + d = d + make_u32x (MD5M_D); const u32x a1 = a; const u32x b1 = b; @@ -615,10 +614,10 @@ KERNEL_FQ void m31300_s04 (KERN_ATTR_BASIC ()) MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23); - w0[0] = a + MD4M_A; - w0[1] = b + MD4M_B; - w0[2] = c + MD4M_C; - w0[3] = d + MD4M_D; + w0[0] = a + make_u32x (MD4M_A); + w0[1] = b + make_u32x (MD4M_B); + w0[2] = c + make_u32x (MD4M_C); + w0[3] = d + make_u32x (MD4M_D); w1[0] = salt_buf[ 0]; w1[1] = salt_buf[ 1]; w1[2] = salt_buf[ 2]; @@ -707,10 +706,10 @@ KERNEL_FQ void m31300_s04 (KERN_ATTR_BASIC ()) MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); - a = a + MD5M_A; - b = b + MD5M_B; - c = c + MD5M_C; - d = d + MD5M_D; + a = a + make_u32x (MD5M_A); + b = b + make_u32x (MD5M_B); + c = c + make_u32x (MD5M_C); + d = d + make_u32x (MD5M_D); const u32x a1 = a; const u32x b1 = b; diff --git a/OpenCL/m31300_a3-optimized.cl b/OpenCL/m31300_a3-optimized.cl index 6b2153211..e305df2c5 100644 --- a/OpenCL/m31300_a3-optimized.cl +++ b/OpenCL/m31300_a3-optimized.cl @@ -166,10 +166,10 @@ DECLSPEC void m31300m (PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTO u32x w2[4]; u32x w3[4]; - w0[0] = a + MD4M_A; - w0[1] = b + MD4M_B; - w0[2] = c + MD4M_C; - w0[3] = d + MD4M_D; + w0[0] = a + make_u32x (MD4M_A); + w0[1] = b + make_u32x (MD4M_B); + w0[2] = c + make_u32x (MD4M_C); + w0[3] = d + make_u32x (MD4M_D); w1[0] = salt_buf[ 0]; w1[1] = salt_buf[ 1]; w1[2] = salt_buf[ 2]; @@ -258,10 +258,10 @@ DECLSPEC void m31300m (PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTO MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); - a = a + MD5M_A; - b = b + MD5M_B; - c = c + MD5M_C; - d = d + MD5M_D; + a = a + make_u32x (MD5M_A); + b = b + make_u32x (MD5M_B); + c = c + make_u32x (MD5M_C); + d = d + make_u32x (MD5M_D); const u32x a1 = a; const u32x b1 = b; @@ -527,10 +527,10 @@ DECLSPEC void m31300s (PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTO u32x w2[4]; u32x w3[4]; - w0[0] = a + MD4M_A; - w0[1] = b + MD4M_B; - w0[2] = c + MD4M_C; - w0[3] = d + MD4M_D; + w0[0] = a + make_u32x (MD4M_A); + w0[1] = b + make_u32x (MD4M_B); + w0[2] = c + make_u32x (MD4M_C); + w0[3] = d + make_u32x (MD4M_D); w1[0] = salt_buf[ 0]; w1[1] = salt_buf[ 1]; w1[2] = salt_buf[ 2]; @@ -619,10 +619,10 @@ DECLSPEC void m31300s (PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTO MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); - a = a + MD5M_A; - b = b + MD5M_B; - c = c + MD5M_C; - d = d + MD5M_D; + a = a + make_u32x (MD5M_A); + b = b + make_u32x (MD5M_B); + c = c + make_u32x (MD5M_C); + d = d + make_u32x (MD5M_D); const u32x a1 = a; const u32x b1 = b; diff --git a/OpenCL/m31400_a0-optimized.cl b/OpenCL/m31400_a0-optimized.cl new file mode 100644 index 000000000..3ebf076da --- /dev/null +++ b/OpenCL/m31400_a0-optimized.cl @@ -0,0 +1,750 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.h) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +typedef struct scrtv2 +{ + u32 ct_buf[64]; + int ct_len; + +} scrtv2_t; + +DECLSPEC void shift_buffer_by_offset (PRIVATE_AS u32 *w0, const u32 offset) +{ + const int offset_switch = offset / 4; + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 0) || defined IS_GENERIC + switch (offset_switch) + { + case 0: + w0[3] = hc_bytealign_be_S (w0[2], w0[3], offset); + w0[2] = hc_bytealign_be_S (w0[1], w0[2], offset); + w0[1] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[0] = hc_bytealign_be_S ( 0, w0[0], offset); + break; + + case 1: + w0[3] = hc_bytealign_be_S (w0[1], w0[2], offset); + w0[2] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[1] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[0] = 0; + break; + + case 2: + w0[3] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[2] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[1] = 0; + w0[0] = 0; + break; + + case 3: + w0[3] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + + default: + w0[3] = 0; + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + } + #endif + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 1) || defined IS_NV + + #if defined IS_NV + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; + #endif + + #if (defined IS_AMD || defined IS_HIP) + const int selector = l32_from_64_S(0x0706050403020100UL >> ((offset & 3) * 8)); + #endif + + switch (offset_switch) + { + case 0: + w0[3] = hc_byte_perm_S (w0[3], w0[2], selector); + w0[2] = hc_byte_perm_S (w0[2], w0[1], selector); + w0[1] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[0] = hc_byte_perm_S (w0[0], 0, selector); + break; + + case 1: + w0[3] = hc_byte_perm_S (w0[2], w0[1], selector); + w0[2] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[1] = hc_byte_perm_S (w0[0], 0, selector); + w0[0] = 0; + break; + + case 2: + w0[3] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[2] = hc_byte_perm_S (w0[0], 0, selector); + w0[1] = 0; + w0[0] = 0; + break; + + case 3: + w0[3] = hc_byte_perm_S (w0[0], 0, selector); + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + + default: + w0[3] = 0; + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + } + #endif +} + +DECLSPEC void aes256_scrt_format (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32 *pw, const u32 pw_len, PRIVATE_AS u32 *hash, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + AES256_set_encrypt_key (aes_ks, hash, s_te0, s_te1, s_te2, s_te3); + + shift_buffer_by_offset (hash, pw_len + 4); + + hash[0] = hc_swap32_S (pw_len); + hash[1] |= hc_swap32_S (pw[0]); + hash[2] |= hc_swap32_S (pw[1]); + hash[3] |= hc_swap32_S (pw[2]); + + AES256_encrypt (aes_ks, hash, out, s_te0, s_te1, s_te2, s_te3, s_te4); +} + +DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, const u32x pw_len, PRIVATE_AS u32x *h, PRIVATE_AS u32x *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + #if VECT_SIZE == 1 + aes256_scrt_format (aes_ks, w, pw_len, h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + #endif + + #if VECT_SIZE >= 2 + u32 tmp_w[4]; + u32 tmp_h[8]; + u32 tmp_out[4]; + + //s0 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s0; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s0; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s0, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s0 = tmp_out[i]; + + //s1 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s1; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s1; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s1, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s1 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 4 + + //s2 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s2; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s2; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s2, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s2 = tmp_out[i]; + + //s3 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s3; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s3; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s3, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s3 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 8 + + //s4 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s4; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s4; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s4, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s4 = tmp_out[i]; + + //s5 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s5; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s5; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s5, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s5 = tmp_out[i]; + + //s6 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s6; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s6; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s6, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s6 = tmp_out[i]; + + //s7 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s7; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s7; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s7, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s7 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 16 + + //s8 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s8; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s8; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s8, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s8 = tmp_out[i]; + + //s9 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s9; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s9; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s9, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s9 = tmp_out[i]; + + //sa + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sa; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sa; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sa, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sa = tmp_out[i]; + + //sb + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sb; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sb; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sb, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sb = tmp_out[i]; + + //sc + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sc; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sc; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sc, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sc = tmp_out[i]; + + //sd + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sd; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sd; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sd, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sd = tmp_out[i]; + + //se + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].se; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].se; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.se, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].se = tmp_out[i]; + + //sf + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sf; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sf; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sf, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sf = tmp_out[i]; + + #endif +} + +KERNEL_FQ void m31400_m16 (KERN_ATTR_RULES_ESALT (scrtv2_t)) +{ +} + +KERNEL_FQ void m31400_m08 (KERN_ATTR_RULES_ESALT (scrtv2_t)) +{ +} + +KERNEL_FQ void m31400_m04 (KERN_ATTR_RULES_ESALT (scrtv2_t)) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS(); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 ks[60]; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + u32x wt[4]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + wt[0] = w0[0]; + wt[1] = w0[1]; + wt[2] = w0[2]; + wt[3] = w0[3]; + + append_0x80_2x4_VV (w0, w1, out_len); + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = out_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + u32x digest[8]; + + digest[0] = a + make_u32x (SHA256M_A); + digest[1] = b + make_u32x (SHA256M_B); + digest[2] = c + make_u32x (SHA256M_C); + digest[3] = d + make_u32x (SHA256M_D); + digest[4] = e + make_u32x (SHA256M_E); + digest[5] = f + make_u32x (SHA256M_F); + digest[6] = g + make_u32x (SHA256M_G); + digest[7] = h + make_u32x (SHA256M_H); + + u32x out[4] = { 0 }; + + aes256_scrt_format_VV (ks, wt, out_len, digest, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32x r0 = out[DGST_R0]; + const u32x r1 = out[DGST_R1]; + const u32x r2 = out[DGST_R2]; + const u32x r3 = out[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31400_s16 (KERN_ATTR_RULES_ESALT (scrtv2_t)) +{ +} + +KERNEL_FQ void m31400_s08 (KERN_ATTR_RULES_ESALT (scrtv2_t)) +{ +} + +KERNEL_FQ void m31400_s04 (KERN_ATTR_RULES_ESALT (scrtv2_t)) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS(); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 ks[60]; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + u32x wt[4]; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + wt[0] = w0[0]; + wt[1] = w0[1]; + wt[2] = w0[2]; + wt[3] = w0[3]; + + append_0x80_2x4_VV (w0, w1, out_len); + + /** + * sha256 + */ + + u32x w0_t = hc_swap32 (w0[0]); + u32x w1_t = hc_swap32 (w0[1]); + u32x w2_t = hc_swap32 (w0[2]); + u32x w3_t = hc_swap32 (w0[3]); + u32x w4_t = hc_swap32 (w1[0]); + u32x w5_t = hc_swap32 (w1[1]); + u32x w6_t = hc_swap32 (w1[2]); + u32x w7_t = hc_swap32 (w1[3]); + u32x w8_t = hc_swap32 (w2[0]); + u32x w9_t = hc_swap32 (w2[1]); + u32x wa_t = hc_swap32 (w2[2]); + u32x wb_t = hc_swap32 (w2[3]); + u32x wc_t = hc_swap32 (w3[0]); + u32x wd_t = hc_swap32 (w3[1]); + u32x we_t = 0; + u32x wf_t = out_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + u32x digest[8]; + + digest[0] = a + make_u32x (SHA256M_A); + digest[1] = b + make_u32x (SHA256M_B); + digest[2] = c + make_u32x (SHA256M_C); + digest[3] = d + make_u32x (SHA256M_D); + digest[4] = e + make_u32x (SHA256M_E); + digest[5] = f + make_u32x (SHA256M_F); + digest[6] = g + make_u32x (SHA256M_G); + digest[7] = h + make_u32x (SHA256M_H); + + u32x out[4] = { 0 }; + + aes256_scrt_format_VV (ks, wt, out_len, digest, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32x r0 = out[DGST_R0]; + const u32x r1 = out[DGST_R1]; + const u32x r2 = out[DGST_R2]; + const u32x r3 = out[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m31400_a0-pure.cl b/OpenCL/m31400_a0-pure.cl index c75aa1eca..28cd2c51a 100644 --- a/OpenCL/m31400_a0-pure.cl +++ b/OpenCL/m31400_a0-pure.cl @@ -184,10 +184,10 @@ KERNEL_FQ void m31400_mxx (KERN_ATTR_RULES_ESALT (scrtv2_t)) * base */ - COPY_PW (pws[gid]); - u32 ks[60]; + COPY_PW (pws[gid]); + /** * loop */ @@ -208,7 +208,7 @@ KERNEL_FQ void m31400_mxx (KERN_ATTR_RULES_ESALT (scrtv2_t)) u32 out[4] = { 0 }; - aes256_scrt_format (ks, tmp.i, tmp.pw_len, ctx.h, out,s_te0, s_te1, s_te2, s_te3, s_te4); + aes256_scrt_format (ks, tmp.i, tmp.pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); const u32 r0 = out[DGST_R0]; const u32 r1 = out[DGST_R1]; @@ -280,10 +280,10 @@ KERNEL_FQ void m31400_sxx (KERN_ATTR_RULES_ESALT (scrtv2_t)) * base */ - COPY_PW (pws[gid]); - u32 ks[60]; + COPY_PW (pws[gid]); + /** * loop */ @@ -304,7 +304,7 @@ KERNEL_FQ void m31400_sxx (KERN_ATTR_RULES_ESALT (scrtv2_t)) u32 out[4] = { 0 }; - aes256_scrt_format (ks, tmp.i, tmp.pw_len, ctx.h, out,s_te0, s_te1, s_te2, s_te3, s_te4); + aes256_scrt_format (ks, tmp.i, tmp.pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); const u32 r0 = out[DGST_R0]; const u32 r1 = out[DGST_R1]; diff --git a/OpenCL/m31400_a1-optimized.cl b/OpenCL/m31400_a1-optimized.cl new file mode 100644 index 000000000..e6b266a23 --- /dev/null +++ b/OpenCL/m31400_a1-optimized.cl @@ -0,0 +1,901 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +typedef struct scrtv2 +{ + u32 ct_buf[64]; + int ct_len; + +} scrtv2_t; + +DECLSPEC void shift_buffer_by_offset (PRIVATE_AS u32 *w0, const u32 offset) +{ + const int offset_switch = offset / 4; + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 0) || defined IS_GENERIC + switch (offset_switch) + { + case 0: + w0[3] = hc_bytealign_be_S (w0[2], w0[3], offset); + w0[2] = hc_bytealign_be_S (w0[1], w0[2], offset); + w0[1] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[0] = hc_bytealign_be_S ( 0, w0[0], offset); + break; + + case 1: + w0[3] = hc_bytealign_be_S (w0[1], w0[2], offset); + w0[2] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[1] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[0] = 0; + break; + + case 2: + w0[3] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[2] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[1] = 0; + w0[0] = 0; + break; + + case 3: + w0[3] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + + default: + w0[3] = 0; + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + } + #endif + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 1) || defined IS_NV + + #if defined IS_NV + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; + #endif + + #if (defined IS_AMD || defined IS_HIP) + const int selector = l32_from_64_S(0x0706050403020100UL >> ((offset & 3) * 8)); + #endif + + switch (offset_switch) + { + case 0: + w0[3] = hc_byte_perm_S (w0[3], w0[2], selector); + w0[2] = hc_byte_perm_S (w0[2], w0[1], selector); + w0[1] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[0] = hc_byte_perm_S (w0[0], 0, selector); + break; + + case 1: + w0[3] = hc_byte_perm_S (w0[2], w0[1], selector); + w0[2] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[1] = hc_byte_perm_S (w0[0], 0, selector); + w0[0] = 0; + break; + + case 2: + w0[3] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[2] = hc_byte_perm_S (w0[0], 0, selector); + w0[1] = 0; + w0[0] = 0; + break; + + case 3: + w0[3] = hc_byte_perm_S (w0[0], 0, selector); + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + + default: + w0[3] = 0; + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + } + #endif +} + +DECLSPEC void aes256_scrt_format (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32 *pw, const u32 pw_len, PRIVATE_AS u32 *hash, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + AES256_set_encrypt_key (aes_ks, hash, s_te0, s_te1, s_te2, s_te3); + + shift_buffer_by_offset (hash, pw_len + 4); + + hash[0] = hc_swap32_S (pw_len); + hash[1] |= hc_swap32_S (pw[0]); + hash[2] |= hc_swap32_S (pw[1]); + hash[3] |= hc_swap32_S (pw[2]); + + AES256_encrypt (aes_ks, hash, out, s_te0, s_te1, s_te2, s_te3, s_te4); +} + +DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, const u32x pw_len, PRIVATE_AS u32x *h, PRIVATE_AS u32x *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + #if VECT_SIZE == 1 + aes256_scrt_format (aes_ks, w, pw_len, h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + #endif + + #if VECT_SIZE >= 2 + u32 tmp_w[4]; + u32 tmp_h[8]; + u32 tmp_out[4]; + + //s0 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s0; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s0; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s0, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s0 = tmp_out[i]; + + //s1 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s1; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s1; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s1, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s1 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 4 + + //s2 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s2; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s2; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s2, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s2 = tmp_out[i]; + + //s3 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s3; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s3; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s3, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s3 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 8 + + //s4 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s4; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s4; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s4, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s4 = tmp_out[i]; + + //s5 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s5; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s5; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s5, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s5 = tmp_out[i]; + + //s6 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s6; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s6; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s6, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s6 = tmp_out[i]; + + //s7 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s7; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s7; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s7, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s7 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 16 + + //s8 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s8; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s8; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s8, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s8 = tmp_out[i]; + + //s9 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s9; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s9; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.s9, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s9 = tmp_out[i]; + + //sa + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sa; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sa; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sa, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sa = tmp_out[i]; + + //sb + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sb; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sb; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sb, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sb = tmp_out[i]; + + //sc + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sc; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sc; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sc, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sc = tmp_out[i]; + + //sd + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sd; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sd; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sd, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sd = tmp_out[i]; + + //se + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].se; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].se; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.se, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].se = tmp_out[i]; + + //sf + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sf; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sf; + + aes256_scrt_format (aes_ks, tmp_w, pw_len.sf, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sf = tmp_out[i]; + + #endif +} + +KERNEL_FQ void m31400_m04 (KERN_ATTR_ESALT (scrtv2_t)) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS(); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 ks[60]; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + u32x wt[4]; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + wt[0] = w0[0]; + wt[1] = w0[1]; + wt[2] = w0[2]; + wt[3] = w0[3]; + + w0[0] = hc_swap32 (w0[0]); + w0[1] = hc_swap32 (w0[1]); + w0[2] = hc_swap32 (w0[2]); + w0[3] = hc_swap32 (w0[3]); + w1[0] = hc_swap32 (w1[0]); + w1[1] = hc_swap32 (w1[1]); + w1[2] = hc_swap32 (w1[2]); + w1[3] = hc_swap32 (w1[3]); + w2[0] = hc_swap32 (w2[0]); + w2[1] = hc_swap32 (w2[1]); + w2[2] = hc_swap32 (w2[2]); + w2[3] = hc_swap32 (w2[3]); + w3[0] = hc_swap32 (w3[0]); + w3[1] = hc_swap32 (w3[1]); + w3[2] = hc_swap32 (w3[2]); + w3[3] = hc_swap32 (w3[3]); + + append_0x80_4x4_VV (w0, w1, w2, w3, pw_len ^ 3); + + /** + * sha256 + */ + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = 0; + u32x wf_t = pw_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + u32x digest[8]; + + digest[0] = a + make_u32x (SHA256M_A); + digest[1] = b + make_u32x (SHA256M_B); + digest[2] = c + make_u32x (SHA256M_C); + digest[3] = d + make_u32x (SHA256M_D); + digest[4] = e + make_u32x (SHA256M_E); + digest[5] = f + make_u32x (SHA256M_F); + digest[6] = g + make_u32x (SHA256M_G); + digest[7] = h + make_u32x (SHA256M_H); + + u32x out[4] = { 0 }; + + aes256_scrt_format_VV (ks, wt, pw_len, digest, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32x r0 = out[DGST_R0]; + const u32x r1 = out[DGST_R1]; + const u32x r2 = out[DGST_R2]; + const u32x r3 = out[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31400_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m31400_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m31400_s04 (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS(); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 ks[60]; + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + u32x wt[4]; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = wordl3[2] | wordr3[2]; + w3[3] = wordl3[3] | wordr3[3]; + + wt[0] = w0[0]; + wt[1] = w0[1]; + wt[2] = w0[2]; + wt[3] = w0[3]; + + w0[0] = hc_swap32 (w0[0]); + w0[1] = hc_swap32 (w0[1]); + w0[2] = hc_swap32 (w0[2]); + w0[3] = hc_swap32 (w0[3]); + w1[0] = hc_swap32 (w1[0]); + w1[1] = hc_swap32 (w1[1]); + w1[2] = hc_swap32 (w1[2]); + w1[3] = hc_swap32 (w1[3]); + w2[0] = hc_swap32 (w2[0]); + w2[1] = hc_swap32 (w2[1]); + w2[2] = hc_swap32 (w2[2]); + w2[3] = hc_swap32 (w2[3]); + w3[0] = hc_swap32 (w3[0]); + w3[1] = hc_swap32 (w3[1]); + w3[2] = hc_swap32 (w3[2]); + w3[3] = hc_swap32 (w3[3]); + + append_0x80_4x4_VV (w0, w1, w2, w3, pw_len ^ 3); + + /** + * sha256 + */ + + u32x w0_t = w0[0]; + u32x w1_t = w0[1]; + u32x w2_t = w0[2]; + u32x w3_t = w0[3]; + u32x w4_t = w1[0]; + u32x w5_t = w1[1]; + u32x w6_t = w1[2]; + u32x w7_t = w1[3]; + u32x w8_t = w2[0]; + u32x w9_t = w2[1]; + u32x wa_t = w2[2]; + u32x wb_t = w2[3]; + u32x wc_t = w3[0]; + u32x wd_t = w3[1]; + u32x we_t = 0; + u32x wf_t = pw_len * 8; + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + u32x digest[8]; + + digest[0] = a + make_u32x (SHA256M_A); + digest[1] = b + make_u32x (SHA256M_B); + digest[2] = c + make_u32x (SHA256M_C); + digest[3] = d + make_u32x (SHA256M_D); + digest[4] = e + make_u32x (SHA256M_E); + digest[5] = f + make_u32x (SHA256M_F); + digest[6] = g + make_u32x (SHA256M_G); + digest[7] = h + make_u32x (SHA256M_H); + + u32x out[4] = { 0 }; + + aes256_scrt_format_VV (ks, wt, pw_len, digest, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32x r0 = out[DGST_R0]; + const u32x r1 = out[DGST_R1]; + const u32x r2 = out[DGST_R2]; + const u32x r3 = out[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31400_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m31400_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m31400_a1-pure.cl b/OpenCL/m31400_a1-pure.cl index 4c6ea8b33..390bc8bf3 100644 --- a/OpenCL/m31400_a1-pure.cl +++ b/OpenCL/m31400_a1-pure.cl @@ -184,14 +184,16 @@ KERNEL_FQ void m31400_mxx (KERN_ATTR_ESALT (scrtv2_t)) * base */ + u32 wt[3]; + + u32 ks[60]; + sha256_ctx_t ctx0; sha256_init (&ctx0); sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); - u32 ks[60]; - /** * loop */ @@ -202,19 +204,17 @@ KERNEL_FQ void m31400_mxx (KERN_ATTR_ESALT (scrtv2_t)) sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); - u32 pw_candidate[3]; - - pw_candidate[0] = hc_swap32_S (ctx.w0[0]); - pw_candidate[1] = hc_swap32_S (ctx.w0[1]); - pw_candidate[2] = hc_swap32_S (ctx.w0[2]); + wt[0] = hc_swap32_S (ctx.w0[0]); + wt[1] = hc_swap32_S (ctx.w0[1]); + wt[2] = hc_swap32_S (ctx.w0[2]); - u32 pw_len=ctx.len; + u32 pw_len = ctx.len; sha256_final (&ctx); u32 out[4] = { 0 }; - aes256_scrt_format (ks, pw_candidate, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + aes256_scrt_format (ks, wt, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); const u32 r0 = out[DGST_R0]; const u32 r1 = out[DGST_R1]; @@ -286,14 +286,16 @@ KERNEL_FQ void m31400_sxx (KERN_ATTR_ESALT (scrtv2_t)) * base */ + u32 wt[3]; + + u32 ks[60]; + sha256_ctx_t ctx0; sha256_init (&ctx0); sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); - u32 ks[60]; - /** * loop */ @@ -304,19 +306,17 @@ KERNEL_FQ void m31400_sxx (KERN_ATTR_ESALT (scrtv2_t)) sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); - u32 pw_candidate[3]; - - pw_candidate[0] = hc_swap32_S (ctx.w0[0]); - pw_candidate[1] = hc_swap32_S (ctx.w0[1]); - pw_candidate[2] = hc_swap32_S (ctx.w0[2]); + wt[0] = hc_swap32_S (ctx.w0[0]); + wt[1] = hc_swap32_S (ctx.w0[1]); + wt[2] = hc_swap32_S (ctx.w0[2]); - u32 pw_len=ctx.len; + u32 pw_len = ctx.len; sha256_final (&ctx); u32 out[4] = { 0 }; - aes256_scrt_format (ks, pw_candidate, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + aes256_scrt_format (ks, wt, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); const u32 r0 = out[DGST_R0]; const u32 r1 = out[DGST_R1]; diff --git a/OpenCL/m31400_a3-optimized.cl b/OpenCL/m31400_a3-optimized.cl new file mode 100644 index 000000000..a9c43e961 --- /dev/null +++ b/OpenCL/m31400_a3-optimized.cl @@ -0,0 +1,1104 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.h) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.h) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +typedef struct scrtv2 +{ + u32 ct_buf[64]; + int ct_len; + +} scrtv2_t; + +DECLSPEC void shift_buffer_by_offset (PRIVATE_AS u32 *w0, const u32 offset) +{ + const int offset_switch = offset / 4; + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 0) || defined IS_GENERIC + switch (offset_switch) + { + case 0: + w0[3] = hc_bytealign_be_S (w0[2], w0[3], offset); + w0[2] = hc_bytealign_be_S (w0[1], w0[2], offset); + w0[1] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[0] = hc_bytealign_be_S ( 0, w0[0], offset); + break; + + case 1: + w0[3] = hc_bytealign_be_S (w0[1], w0[2], offset); + w0[2] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[1] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[0] = 0; + break; + + case 2: + w0[3] = hc_bytealign_be_S (w0[0], w0[1], offset); + w0[2] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[1] = 0; + w0[0] = 0; + break; + + case 3: + w0[3] = hc_bytealign_be_S ( 0, w0[0], offset); + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + + default: + w0[3] = 0; + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + } + #endif + + #if ((defined IS_AMD || defined IS_HIP) && HAS_VPERM == 1) || defined IS_NV + + #if defined IS_NV + const int selector = (0x76543210 >> ((offset & 3) * 4)) & 0xffff; + #endif + + #if (defined IS_AMD || defined IS_HIP) + const int selector = l32_from_64_S(0x0706050403020100UL >> ((offset & 3) * 8)); + #endif + + switch (offset_switch) + { + case 0: + w0[3] = hc_byte_perm_S (w0[3], w0[2], selector); + w0[2] = hc_byte_perm_S (w0[2], w0[1], selector); + w0[1] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[0] = hc_byte_perm_S (w0[0], 0, selector); + break; + + case 1: + w0[3] = hc_byte_perm_S (w0[2], w0[1], selector); + w0[2] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[1] = hc_byte_perm_S (w0[0], 0, selector); + w0[0] = 0; + break; + + case 2: + w0[3] = hc_byte_perm_S (w0[1], w0[0], selector); + w0[2] = hc_byte_perm_S (w0[0], 0, selector); + w0[1] = 0; + w0[0] = 0; + break; + + case 3: + w0[3] = hc_byte_perm_S (w0[0], 0, selector); + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + + default: + w0[3] = 0; + w0[2] = 0; + w0[1] = 0; + w0[0] = 0; + break; + } + #endif +} + +DECLSPEC void aes256_scrt_format (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32 *pw, const u32 pw_len, PRIVATE_AS u32 *hash, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + AES256_set_encrypt_key (aes_ks, hash, s_te0, s_te1, s_te2, s_te3); + + shift_buffer_by_offset (hash, pw_len + 4); + + hash[0] = hc_swap32_S (pw_len); + hash[1] |= hc_swap32_S (pw[0]); + hash[2] |= hc_swap32_S (pw[1]); + hash[3] |= hc_swap32_S (pw[2]); + + AES256_encrypt (aes_ks, hash, out, s_te0, s_te1, s_te2, s_te3, s_te4); +} + +DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, const u32 pw_len, PRIVATE_AS u32x *h, PRIVATE_AS u32x *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + #if VECT_SIZE == 1 + aes256_scrt_format (aes_ks, w, pw_len, h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + #endif + + #if VECT_SIZE >= 2 + u32 tmp_w[4]; + u32 tmp_h[8]; + u32 tmp_out[4]; + + //s0 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s0; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s0; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s0 = tmp_out[i]; + + //s1 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s1; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s1; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s1 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 4 + + //s2 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s2; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s2; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s2 = tmp_out[i]; + + //s3 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s3; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s3; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s3 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 8 + + //s4 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s4; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s4; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s4 = tmp_out[i]; + + //s5 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s5; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s5; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s5 = tmp_out[i]; + + //s6 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s6; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s6; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s6 = tmp_out[i]; + + //s7 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s7; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s7; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s7 = tmp_out[i]; + + #endif + + #if VECT_SIZE >= 16 + + //s8 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s8; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s8; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s8 = tmp_out[i]; + + //s9 + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s9; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s9; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].s9 = tmp_out[i]; + + //sa + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sa; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sa; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sa = tmp_out[i]; + + //sb + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sb; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sb; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sb = tmp_out[i]; + + //sc + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sc; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sc; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sc = tmp_out[i]; + + //sd + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sd; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sd; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sd = tmp_out[i]; + + //se + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].se; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].se; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].se = tmp_out[i]; + + //sf + + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sf; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sf; + + aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); + + for (u32 i = 0; i < 4; i++) out[i].sf = tmp_out[i]; + + #endif +} + +DECLSPEC void m31400m (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a *s_te2, SHM_TYPE u32a *s_te3, SHM_TYPE u32a *s_te4, PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTOR_ESALT (scrtv2_t)) +{ + /** + * modifiers are taken from args + */ + + /** + * loop + */ + + u32 ks[60]; + + u32x wt[4]; + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + wt[0] = w0; + wt[1] = w[1]; + wt[2] = w[2]; + wt[3] = w[3]; + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = hc_swap32 (w0); + ww0[1] = hc_swap32 (w[1]); + ww0[2] = hc_swap32 (w[2]); + ww0[3] = hc_swap32 (w[3]); + ww1[0] = hc_swap32 (w[4]); + ww1[1] = hc_swap32 (w[5]); + ww1[2] = hc_swap32 (w[6]); + ww1[3] = hc_swap32 (w[7]); + ww2[0] = hc_swap32 (w[8]); + ww2[1] = hc_swap32 (w[9]); + ww2[2] = hc_swap32 (w[10]); + ww2[3] = hc_swap32 (w[11]); + ww3[0] = hc_swap32 (w[12]); + ww3[1] = hc_swap32 (w[13]); + ww3[2] = hc_swap32 (w[14]); + ww3[3] = hc_swap32 (w[15]); + + const int off = pw_len & 63; + + append_0x80_4x4 (ww0, ww1, ww2, ww3, off ^ 3); + + ww3[2] = 0; + ww3[3] = pw_len * 8; + + u32x w0_t = ww0[0]; + u32x w1_t = ww0[1]; + u32x w2_t = ww0[2]; + u32x w3_t = ww0[3]; + u32x w4_t = ww1[0]; + u32x w5_t = ww1[1]; + u32x w6_t = ww1[2]; + u32x w7_t = ww1[3]; + u32x w8_t = ww2[0]; + u32x w9_t = ww2[1]; + u32x wa_t = ww2[2]; + u32x wb_t = ww2[3]; + u32x wc_t = ww3[0]; + u32x wd_t = ww3[1]; + u32x we_t = ww3[2]; + u32x wf_t = ww3[3]; + + // sha256 + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + u32x digest[8]; + + digest[0] = a + make_u32x (SHA256M_A); + digest[1] = b + make_u32x (SHA256M_B); + digest[2] = c + make_u32x (SHA256M_C); + digest[3] = d + make_u32x (SHA256M_D); + digest[4] = e + make_u32x (SHA256M_E); + digest[5] = f + make_u32x (SHA256M_F); + digest[6] = g + make_u32x (SHA256M_G); + digest[7] = h + make_u32x (SHA256M_H); + + u32x out[4] = { 0 }; + + aes256_scrt_format_VV (ks, wt, pw_len, digest, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32x r0 = out[DGST_R0]; + const u32x r1 = out[DGST_R1]; + const u32x r2 = out[DGST_R2]; + const u32x r3 = out[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31400_m04 (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m31400m (s_te0, s_te1, s_te2, s_te3, s_te4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz); +} + +KERNEL_FQ void m31400_m08 (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m31400m (s_te0, s_te1, s_te2, s_te3, s_te4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz); +} + +KERNEL_FQ void m31400_m16 (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m31400m (s_te0, s_te1, s_te2, s_te3, s_te4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz); +} + +DECLSPEC void m31400s (SHM_TYPE u32a *s_te0, SHM_TYPE u32a *s_te1, SHM_TYPE u32a *s_te2, SHM_TYPE u32a *s_te3, SHM_TYPE u32a *s_te4, PRIVATE_AS u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTOR_ESALT (scrtv2_t)) +{ + /** + * modifiers are taken from args + */ + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 ks[60]; + + u32x wt[4]; + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + wt[0] = w0; + wt[1] = w[1]; + wt[2] = w[2]; + wt[3] = w[3]; + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = hc_swap32 (w0); + ww0[1] = hc_swap32 (w[1]); + ww0[2] = hc_swap32 (w[2]); + ww0[3] = hc_swap32 (w[3]); + ww1[0] = hc_swap32 (w[4]); + ww1[1] = hc_swap32 (w[5]); + ww1[2] = hc_swap32 (w[6]); + ww1[3] = hc_swap32 (w[7]); + ww2[0] = hc_swap32 (w[8]); + ww2[1] = hc_swap32 (w[9]); + ww2[2] = hc_swap32 (w[10]); + ww2[3] = hc_swap32 (w[11]); + ww3[0] = hc_swap32 (w[12]); + ww3[1] = hc_swap32 (w[13]); + ww3[2] = hc_swap32 (w[14]); + ww3[3] = hc_swap32 (w[15]); + + const int off = pw_len & 63; + + append_0x80_4x4 (ww0, ww1, ww2, ww3, off ^ 3); + + ww3[2] = 0; + ww3[3] = pw_len * 8; + + u32x w0_t = ww0[0]; + u32x w1_t = ww0[1]; + u32x w2_t = ww0[2]; + u32x w3_t = ww0[3]; + u32x w4_t = ww1[0]; + u32x w5_t = ww1[1]; + u32x w6_t = ww1[2]; + u32x w7_t = ww1[3]; + u32x w8_t = ww2[0]; + u32x w9_t = ww2[1]; + u32x wa_t = ww2[2]; + u32x wb_t = ww2[3]; + u32x wc_t = ww3[0]; + u32x wd_t = ww3[1]; + u32x we_t = ww3[2]; + u32x wf_t = ww3[3]; + + // sha256 + + u32x a = SHA256M_A; + u32x b = SHA256M_B; + u32x c = SHA256M_C; + u32x d = SHA256M_D; + u32x e = SHA256M_E; + u32x f = SHA256M_F; + u32x g = SHA256M_G; + u32x h = SHA256M_H; + + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C00); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C01); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C02); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C03); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C04); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C05); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C06); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C07); + SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C08); + SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C09); + SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C0a); + SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C0b); + SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C0c); + SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C0d); + SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C0e); + SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C0f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C10); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C11); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C12); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C13); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C14); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C15); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C16); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C17); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C18); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C19); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C1a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C1b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C1c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C1d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C1e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C1f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C20); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C21); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C22); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C23); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C24); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C25); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C26); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C27); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C28); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C29); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C2a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C2b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C2c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C2d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C2e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C2f); + + w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, SHA256C30); + w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, SHA256C31); + w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, SHA256C32); + w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, SHA256C33); + w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, SHA256C34); + w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, SHA256C35); + w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, SHA256C36); + w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, SHA256C37); + w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, SHA256C38); + w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, SHA256C39); + wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, SHA256C3a); + wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, SHA256C3b); + wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, SHA256C3c); + wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, SHA256C3d); + we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, SHA256C3e); + wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, SHA256C3f); + + u32x digest[8]; + + digest[0] = a + make_u32x (SHA256M_A); + digest[1] = b + make_u32x (SHA256M_B); + digest[2] = c + make_u32x (SHA256M_C); + digest[3] = d + make_u32x (SHA256M_D); + digest[4] = e + make_u32x (SHA256M_E); + digest[5] = f + make_u32x (SHA256M_F); + digest[6] = g + make_u32x (SHA256M_G); + digest[7] = h + make_u32x (SHA256M_H); + + u32x out[4] = { 0 }; + + aes256_scrt_format_VV (ks, wt, pw_len, digest, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32x r0 = out[DGST_R0]; + const u32x r1 = out[DGST_R1]; + const u32x r2 = out[DGST_R2]; + const u32x r3 = out[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31400_s04 (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 w[16]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = 0; + w[ 5] = 0; + w[ 6] = 0; + w[ 7] = 0; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m31400s (s_te0, s_te1, s_te2, s_te3, s_te4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz); +} + +KERNEL_FQ void m31400_s08 (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = 0; + w[ 9] = 0; + w[10] = 0; + w[11] = 0; + w[12] = 0; + w[13] = 0; + w[14] = 0; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m31400s (s_te0, s_te1, s_te2, s_te3, s_te4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz); +} + +KERNEL_FQ void m31400_s16 (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 w[16]; + + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m31400s (s_te0, s_te1, s_te2, s_te3, s_te4, w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz); +} diff --git a/OpenCL/m31400_a3-pure.cl b/OpenCL/m31400_a3-pure.cl index 70ce410ba..7baacb913 100644 --- a/OpenCL/m31400_a3-pure.cl +++ b/OpenCL/m31400_a3-pure.cl @@ -1,7 +1,7 @@ /** -* Author......: See docs/credits.txt -* License.....: MIT -*/ + * Author......: See docs/credits.txt + * License.....: MIT + */ #define NEW_SIMD_CODE @@ -142,27 +142,27 @@ DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, #endif #if VECT_SIZE >= 2 - u32 tmp_w[64]; + u32 tmp_w[4]; u32 tmp_h[8]; u32 tmp_out[4]; //s0 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s0; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s0; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s0; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s0; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s0 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s0 = tmp_out[i]; //s1 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s1; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s1; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s1; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s1; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s1 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s1 = tmp_out[i]; #endif @@ -170,21 +170,21 @@ DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, //s2 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s2; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s2; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s2; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s2; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s2 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s2 = tmp_out[i]; //s3 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s3; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s3; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s3; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s3; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s3 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s3 = tmp_out[i]; #endif @@ -192,39 +192,39 @@ DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, //s4 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s4; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s4; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s4; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s4; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s4 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s4 = tmp_out[i]; //s5 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s5; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s5; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s5; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s5; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s5 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s5 = tmp_out[i]; //s6 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s6; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s6; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s6; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s6; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s6 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s6 = tmp_out[i]; //s7 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s7; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s7; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s7; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s7; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s7 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s7 = tmp_out[i]; #endif @@ -232,75 +232,75 @@ DECLSPEC void aes256_scrt_format_VV (PRIVATE_AS u32 *aes_ks, PRIVATE_AS u32x *w, //s8 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s8; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s8; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s8; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s8; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s8 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s8 = tmp_out[i]; //s9 - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].s9; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s9; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].s9; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].s9; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].s9 = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].s9 = tmp_out[i]; //sa - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].sa; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sa; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sa; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sa; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].sa = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].sa = tmp_out[i]; //sb - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].sb; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sb; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sb; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sb; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].sb = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].sb = tmp_out[i]; //sc - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].sc; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sc; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sc; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sc; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].sc = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].sc = tmp_out[i]; //sd - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].sd; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sd; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sd; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sd; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].sd = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].sd = tmp_out[i]; //se - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].se; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].se; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].se; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].se; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].se = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].se = tmp_out[i]; //sf - for (u32 i = 0; i < 64; i++) tmp_w[i] = w[i].sf; - for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sf; + for (u32 i = 0; i < 4; i++) tmp_w[i] = w[i].sf; + for (u32 i = 0; i < 8; i++) tmp_h[i] = h[i].sf; aes256_scrt_format (aes_ks, tmp_w, pw_len, tmp_h, tmp_out, s_te0, s_te1, s_te2, s_te3, s_te4); - for (u32 i = 0; i < 4; i++) out[i].sf = tmp_out[i]; + for (u32 i = 0; i < 4; i++) out[i].sf = tmp_out[i]; #endif } @@ -354,10 +354,12 @@ KERNEL_FQ void m31400_mxx (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) * base */ - const u32 pw_len = pws[gid].pw_len; + u32 ks[60]; u32x w[64] = {0}; + const u32 pw_len = pws[gid].pw_len; + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) { w[idx] = pws[gid].i[idx]; @@ -385,11 +387,9 @@ KERNEL_FQ void m31400_mxx (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) sha256_final_vector (&ctx); - u32x out[4] = {0}; + u32x out[4] = { 0 }; - u32 aes_ks[60]; - - aes256_scrt_format_VV (aes_ks, w, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + aes256_scrt_format_VV (ks, w, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); const u32x r0 = out[DGST_R0]; const u32x r1 = out[DGST_R1]; @@ -461,9 +461,11 @@ KERNEL_FQ void m31400_sxx (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) * base */ - const u32 pw_len = pws[gid].pw_len; + u32 ks[60]; - u32x w[64] = {0}; + u32x w[64] = { 0 }; + + const u32 pw_len = pws[gid].pw_len; for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) { @@ -492,11 +494,9 @@ KERNEL_FQ void m31400_sxx (KERN_ATTR_VECTOR_ESALT (scrtv2_t)) sha256_final_vector (&ctx); - u32x out[4] = {0}; - - u32 aes_ks[60]; + u32x out[4] = { 0 }; - aes256_scrt_format_VV (aes_ks, w, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); + aes256_scrt_format_VV (ks, w, pw_len, ctx.h, out, s_te0, s_te1, s_te2, s_te3, s_te4); const u32x r0 = out[DGST_R0]; const u32x r1 = out[DGST_R1]; diff --git a/OpenCL/m31700_a0-pure.cl b/OpenCL/m31700_a0-pure.cl new file mode 100644 index 000000000..f56df6f88 --- /dev/null +++ b/OpenCL/m31700_a0-pure.cl @@ -0,0 +1,335 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m31700_mxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31700_sxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m31700_a1-pure.cl b/OpenCL/m31700_a1-pure.cl new file mode 100644 index 000000000..3b07f7e55 --- /dev/null +++ b/OpenCL/m31700_a1-pure.cl @@ -0,0 +1,329 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m31700_mxx (KERN_ATTR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase array + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * base + */ + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31700_sxx (KERN_ATTR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase array + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * base + */ + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt2_buf, salt2_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m31700_a3-pure.cl b/OpenCL/m31700_a3-pure.cl new file mode 100644 index 000000000..9a9db3047 --- /dev/null +++ b/OpenCL/m31700_a3-pure.cl @@ -0,0 +1,355 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +KERNEL_FQ void m31700_mxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /* + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m31700_sxx (KERN_ATTR_VECTOR_ESALT (md5_double_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /* + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m31800-pure.cl b/OpenCL/m31800-pure.cl new file mode 100644 index 000000000..55ec89ddf --- /dev/null +++ b/OpenCL/m31800-pure.cl @@ -0,0 +1,461 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes-gcm.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct onepassword8 +{ + u32 hkdf_salt_buf[8]; + u32 hkdf_key_buf[8]; + u32 tag_buf[4]; + + u32 iv_buf[4]; + int iv_len; + + u32 email_buf[64]; + int email_len; + + u32 ct_buf[1024]; + int ct_len; + +} onepassword8_t; + +DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m31800_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, onepassword8_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha256_hmac_ctx_t sha256_hmac_ctx; + + sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; + + u32 salt_buf[16]; + + salt_buf[ 0] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[0]; + salt_buf[ 1] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[1]; + salt_buf[ 2] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[2]; + salt_buf[ 3] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[3]; + salt_buf[ 4] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[4]; + salt_buf[ 5] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[5]; + salt_buf[ 6] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[6]; + salt_buf[ 7] = esalt_bufs[DIGESTS_OFFSET_HOST].hkdf_salt_buf[7]; + salt_buf[ 8] = 0; + salt_buf[ 9] = 0; + salt_buf[10] = 0; + salt_buf[11] = 0; + salt_buf[12] = 0; + salt_buf[13] = 0; + salt_buf[14] = 0; + salt_buf[15] = 0; + + sha256_hmac_update (&sha256_hmac_ctx, salt_buf, 32); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); + + sha256_hmac_final (&sha256_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +KERNEL_FQ void m31800_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, onepassword8_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u32x ipad[8]; + u32x opad[8]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + ipad[5] = packv (tmps, ipad, gid, 5); + ipad[6] = packv (tmps, ipad, gid, 6); + ipad[7] = packv (tmps, ipad, gid, 7); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + opad[5] = packv (tmps, opad, gid, 5); + opad[6] = packv (tmps, opad, gid, 6); + opad[7] = packv (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u32x dgst[8]; + u32x out[8]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + dgst[5] = packv (tmps, dgst, gid, i + 5); + dgst[6] = packv (tmps, dgst, gid, i + 6); + dgst[7] = packv (tmps, dgst, gid, i + 7); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + out[5] = packv (tmps, out, gid, i + 5); + out[6] = packv (tmps, out, gid, i + 6); + out[7] = packv (tmps, out, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + unpackv (tmps, dgst, gid, i + 5, dgst[5]); + unpackv (tmps, dgst, gid, i + 6, dgst[6]); + unpackv (tmps, dgst, gid, i + 7, dgst[7]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + unpackv (tmps, out, gid, i + 5, out[5]); + unpackv (tmps, out, gid, i + 6, out[6]); + unpackv (tmps, out, gid, i + 7, out[7]); + } +} + +KERNEL_FQ void m31800_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, onepassword8_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + const u32 digest_pos = LOOP_POS; + + const u32 digest_cur = DIGESTS_OFFSET_HOST + digest_pos; + + GLOBAL_AS const onepassword8_t *onepassword8 = &esalt_bufs[digest_cur]; + + // keys + + u32 hkdf_key[8]; + + hkdf_key[0] = onepassword8->hkdf_key_buf[0]; + hkdf_key[1] = onepassword8->hkdf_key_buf[1]; + hkdf_key[2] = onepassword8->hkdf_key_buf[2]; + hkdf_key[3] = onepassword8->hkdf_key_buf[3]; + hkdf_key[4] = onepassword8->hkdf_key_buf[4]; + hkdf_key[5] = onepassword8->hkdf_key_buf[5]; + hkdf_key[6] = onepassword8->hkdf_key_buf[6]; + hkdf_key[7] = onepassword8->hkdf_key_buf[7]; + + u32 out[8]; + + out[0] = tmps[gid].out[0]; + out[1] = tmps[gid].out[1]; + out[2] = tmps[gid].out[2]; + out[3] = tmps[gid].out[3]; + out[4] = tmps[gid].out[4]; + out[5] = tmps[gid].out[5]; + out[6] = tmps[gid].out[6]; + out[7] = tmps[gid].out[7]; + + u32 muk[8]; + + muk[0] = out[0] ^ hkdf_key[0]; + muk[1] = out[1] ^ hkdf_key[1]; + muk[2] = out[2] ^ hkdf_key[2]; + muk[3] = out[3] ^ hkdf_key[3]; + muk[4] = out[4] ^ hkdf_key[4]; + muk[5] = out[5] ^ hkdf_key[5]; + muk[6] = out[6] ^ hkdf_key[6]; + muk[7] = out[7] ^ hkdf_key[7]; + + u32 key_len = 32 * 8; + + u32 key[60] = { 0 }; + u32 subKey[4] = { 0 }; + + AES_GCM_Init (muk, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); + + // iv + + u32 iv[4]; + + iv[0] = onepassword8->iv_buf[0]; + iv[1] = onepassword8->iv_buf[1]; + iv[2] = onepassword8->iv_buf[2]; + iv[3] = onepassword8->iv_buf[3]; + + const u32 iv_len = onepassword8->iv_len; + + u32 J0[4] = { 0 }; + + AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0); + + u32 ct[8]; + + ct[0] = onepassword8->ct_buf[0]; + ct[1] = onepassword8->ct_buf[1]; + ct[2] = onepassword8->ct_buf[2]; + ct[3] = onepassword8->ct_buf[3]; + ct[4] = onepassword8->ct_buf[4]; + ct[5] = onepassword8->ct_buf[5]; + ct[6] = onepassword8->ct_buf[6]; + ct[7] = onepassword8->ct_buf[7]; + + u32 pt[8] = { 0 }; + + AES_GCM_decrypt (key, J0, ct, 32, pt, s_te0, s_te1, s_te2, s_te3, s_te4); + + const int correct = is_valid_printable_32 (pt[0]) + + is_valid_printable_32 (pt[1]) + + is_valid_printable_32 (pt[2]) + + is_valid_printable_32 (pt[3]) + + is_valid_printable_32 (pt[4]) + + is_valid_printable_32 (pt[5]) + + is_valid_printable_32 (pt[6]) + + is_valid_printable_32 (pt[7]); + + if (correct != 8) return; + + /* + const int pt_len = 28; // not using 32 byte but 28 because our UTF8 allows up to 4 byte per character and since we decrypt 32 byte + // only we can't guarantee it is not in the middle of a UTF8 byte stream at that point + + if (hc_enc_scan (pt, pt_len)) + { + hc_enc_t hc_enc; + + hc_enc_init (&hc_enc); + + while (hc_enc_has_next (&hc_enc, pt_len)) + { + u32 enc_buf[16] = { 0 }; + + const int enc_len = hc_enc_next (&hc_enc, pt, pt_len, 32, enc_buf, sizeof (enc_buf)); + + if (enc_len == -1) return; + } + } + */ + + const u32 r0 = ct[0]; + const u32 r1 = ct[1]; + const u32 r2 = ct[2]; + const u32 r3 = ct[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m31900-pure.cl b/OpenCL/m31900-pure.cl new file mode 100644 index 000000000..24ffb1232 --- /dev/null +++ b/OpenCL/m31900-pure.cl @@ -0,0 +1,451 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct pbkdf2_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + +} pbkdf2_sha512_tmp_t; + +typedef struct pbkdf2_sha512_aes_cbc +{ + u32 salt_buf[64]; + u32 iv_buf[4]; + u32 iv_len; + u32 ct_buf[4]; + u32 ct_len; + +} pbkdf2_sha512_aes_cbc_t; + +DECLSPEC void hmac_sha512_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *w4, PRIVATE_AS u32x *w5, PRIVATE_AS u32x *w6, PRIVATE_AS u32x *w7, PRIVATE_AS u64x *ipad, PRIVATE_AS u64x *opad, PRIVATE_AS u64x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); + + w0[0] = h32_from_64 (digest[0]); + w0[1] = l32_from_64 (digest[0]); + w0[2] = h32_from_64 (digest[1]); + w0[3] = l32_from_64 (digest[1]); + w1[0] = h32_from_64 (digest[2]); + w1[1] = l32_from_64 (digest[2]); + w1[2] = h32_from_64 (digest[3]); + w1[3] = l32_from_64 (digest[3]); + w2[0] = h32_from_64 (digest[4]); + w2[1] = l32_from_64 (digest[4]); + w2[2] = h32_from_64 (digest[5]); + w2[3] = l32_from_64 (digest[5]); + w3[0] = h32_from_64 (digest[6]); + w3[1] = l32_from_64 (digest[6]); + w3[2] = h32_from_64 (digest[7]); + w3[3] = l32_from_64 (digest[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, digest); +} + +KERNEL_FQ void m31900_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha512_tmp_t, pbkdf2_sha512_aes_cbc_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha512_hmac_ctx_t sha512_hmac_ctx; + + sha512_hmac_init_global_swap (&sha512_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha512_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha512_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha512_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha512_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha512_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha512_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha512_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha512_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha512_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha512_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha512_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha512_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7]; + + sha512_hmac_update_global_swap (&sha512_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_hmac_update_128 (&sha512_hmac_ctx2, w0, w1, w2, w3, w4, w5, w6, w7, 4); + + sha512_hmac_final (&sha512_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha512_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha512_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha512_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha512_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha512_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha512_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha512_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha512_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } +} + +KERNEL_FQ void m31900_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha512_tmp_t, pbkdf2_sha512_aes_cbc_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u64x ipad[8]; + u64x opad[8]; + + ipad[0] = pack64v (tmps, ipad, gid, 0); + ipad[1] = pack64v (tmps, ipad, gid, 1); + ipad[2] = pack64v (tmps, ipad, gid, 2); + ipad[3] = pack64v (tmps, ipad, gid, 3); + ipad[4] = pack64v (tmps, ipad, gid, 4); + ipad[5] = pack64v (tmps, ipad, gid, 5); + ipad[6] = pack64v (tmps, ipad, gid, 6); + ipad[7] = pack64v (tmps, ipad, gid, 7); + + opad[0] = pack64v (tmps, opad, gid, 0); + opad[1] = pack64v (tmps, opad, gid, 1); + opad[2] = pack64v (tmps, opad, gid, 2); + opad[3] = pack64v (tmps, opad, gid, 3); + opad[4] = pack64v (tmps, opad, gid, 4); + opad[5] = pack64v (tmps, opad, gid, 5); + opad[6] = pack64v (tmps, opad, gid, 6); + opad[7] = pack64v (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u64x dgst[8]; + u64x out[8]; + + dgst[0] = pack64v (tmps, dgst, gid, i + 0); + dgst[1] = pack64v (tmps, dgst, gid, i + 1); + dgst[2] = pack64v (tmps, dgst, gid, i + 2); + dgst[3] = pack64v (tmps, dgst, gid, i + 3); + dgst[4] = pack64v (tmps, dgst, gid, i + 4); + dgst[5] = pack64v (tmps, dgst, gid, i + 5); + dgst[6] = pack64v (tmps, dgst, gid, i + 6); + dgst[7] = pack64v (tmps, dgst, gid, i + 7); + + out[0] = pack64v (tmps, out, gid, i + 0); + out[1] = pack64v (tmps, out, gid, i + 1); + out[2] = pack64v (tmps, out, gid, i + 2); + out[3] = pack64v (tmps, out, gid, i + 3); + out[4] = pack64v (tmps, out, gid, i + 4); + out[5] = pack64v (tmps, out, gid, i + 5); + out[6] = pack64v (tmps, out, gid, i + 6); + out[7] = pack64v (tmps, out, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = (128 + 64) * 8; + + hmac_sha512_run_V (w0, w1, w2, w3, w4, w5, w6, w7, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpack64v (tmps, dgst, gid, i + 0, dgst[0]); + unpack64v (tmps, dgst, gid, i + 1, dgst[1]); + unpack64v (tmps, dgst, gid, i + 2, dgst[2]); + unpack64v (tmps, dgst, gid, i + 3, dgst[3]); + unpack64v (tmps, dgst, gid, i + 4, dgst[4]); + unpack64v (tmps, dgst, gid, i + 5, dgst[5]); + unpack64v (tmps, dgst, gid, i + 6, dgst[6]); + unpack64v (tmps, dgst, gid, i + 7, dgst[7]); + + unpack64v (tmps, out, gid, i + 0, out[0]); + unpack64v (tmps, out, gid, i + 1, out[1]); + unpack64v (tmps, out, gid, i + 2, out[2]); + unpack64v (tmps, out, gid, i + 3, out[3]); + unpack64v (tmps, out, gid, i + 4, out[4]); + unpack64v (tmps, out, gid, i + 5, out[5]); + unpack64v (tmps, out, gid, i + 6, out[6]); + unpack64v (tmps, out, gid, i + 7, out[7]); + } +} + +KERNEL_FQ void m31900_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha512_tmp_t, pbkdf2_sha512_aes_cbc_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + // keys + + u32 ukey[8]; + + ukey[0] = h32_from_64_S (tmps[gid].out[0]); + ukey[1] = l32_from_64_S (tmps[gid].out[0]); + ukey[2] = h32_from_64_S (tmps[gid].out[1]); + ukey[3] = l32_from_64_S (tmps[gid].out[1]); + ukey[4] = h32_from_64_S (tmps[gid].out[2]); + ukey[5] = l32_from_64_S (tmps[gid].out[2]); + ukey[6] = h32_from_64_S (tmps[gid].out[3]); + ukey[7] = l32_from_64_S (tmps[gid].out[3]); + + u32 ks[60]; + + AES256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + // iv + + u32 iv_buf[4]; + + iv_buf[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0]; + iv_buf[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1]; + iv_buf[2] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2]; + iv_buf[3] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3]; + + // ct + + u32 ct_buf[4]; + + ct_buf[0] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[0]; + ct_buf[1] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[1]; + ct_buf[2] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[2]; + ct_buf[3] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[3]; + + // decrypt first block + + u32 pt_buf[4] = { 0 }; + + AES256_decrypt (ks, ct_buf, pt_buf, s_td0, s_td1, s_td2, s_td3, s_td4); + + pt_buf[0] ^= iv_buf[0]; + pt_buf[1] ^= iv_buf[1]; + pt_buf[2] ^= iv_buf[2]; + pt_buf[3] ^= iv_buf[3]; + + const int correct = is_valid_printable_32 (pt_buf[0]) + + is_valid_printable_32 (pt_buf[1]) + + is_valid_printable_32 (pt_buf[2]) + + is_valid_printable_32 (pt_buf[3]); + + if (correct != 4) return; + + const u32 r0 = ct_buf[0]; + const u32 r1 = ct_buf[1]; + const u32 r2 = ct_buf[2]; + const u32 r3 = ct_buf[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32000-pure.cl b/OpenCL/m32000-pure.cl new file mode 100644 index 000000000..e7d985b52 --- /dev/null +++ b/OpenCL/m32000-pure.cl @@ -0,0 +1,127 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct netiq_sspr_md5_tmp +{ + u32 dgst[4]; + +} netiq_sspr_md5_tmp_t; + +KERNEL_FQ void m32000_init (KERN_ATTR_TMPS (netiq_sspr_md5_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + md5_ctx_t ctx; + + md5_init (&ctx); + + md5_update_global (&ctx, pws[gid].i, pws[gid].pw_len); + + md5_final (&ctx); + + tmps[gid].dgst[0] = ctx.h[0]; + tmps[gid].dgst[1] = ctx.h[1]; + tmps[gid].dgst[2] = ctx.h[2]; + tmps[gid].dgst[3] = ctx.h[3]; +} + +KERNEL_FQ void m32000_loop (KERN_ATTR_TMPS (netiq_sspr_md5_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + for (u32 i = 0; i < 4; i += 4) + { + u32x dgst[4]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x h[4]; + + h[0] = MD5M_A; + h[1] = MD5M_B; + h[2] = MD5M_C; + h[3] = MD5M_D; + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = 0x00000080; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 16 * 8; + w3[3] = 0; + + md5_transform_vector (w0, w1, w2, w3, h); + + dgst[0] = h[0]; + dgst[1] = h[1]; + dgst[2] = h[2]; + dgst[3] = h[3]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + } +} + +KERNEL_FQ void m32000_comp (KERN_ATTR_TMPS (netiq_sspr_md5_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + const u32 r0 = tmps[gid].dgst[0]; + const u32 r1 = tmps[gid].dgst[1]; + const u32 r2 = tmps[gid].dgst[2]; + const u32 r3 = tmps[gid].dgst[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32010-pure.cl b/OpenCL/m32010-pure.cl new file mode 100644 index 000000000..c806dce13 --- /dev/null +++ b/OpenCL/m32010-pure.cl @@ -0,0 +1,132 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct netiq_sspr_sha1_tmp +{ + u32 dgst[5]; + +} netiq_sspr_sha1_tmp_t; + +KERNEL_FQ void m32010_init (KERN_ATTR_TMPS (netiq_sspr_sha1_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha1_ctx_t ctx; + + sha1_init (&ctx); + + sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); + + sha1_final (&ctx); + + tmps[gid].dgst[0] = ctx.h[0]; + tmps[gid].dgst[1] = ctx.h[1]; + tmps[gid].dgst[2] = ctx.h[2]; + tmps[gid].dgst[3] = ctx.h[3]; + tmps[gid].dgst[4] = ctx.h[4]; +} + +KERNEL_FQ void m32010_loop (KERN_ATTR_TMPS (netiq_sspr_sha1_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + for (u32 i = 0; i < 5; i += 5) + { + u32x dgst[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x h[5]; + + h[0] = SHA1M_A; + h[1] = SHA1M_B; + h[2] = SHA1M_C; + h[3] = SHA1M_D; + h[4] = SHA1M_E; + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 20 * 8; + + sha1_transform_vector (w0, w1, w2, w3, h); + + dgst[0] = h[0]; + dgst[1] = h[1]; + dgst[2] = h[2]; + dgst[3] = h[3]; + dgst[4] = h[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + } +} + +KERNEL_FQ void m32010_comp (KERN_ATTR_TMPS (netiq_sspr_sha1_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + const u32 r0 = tmps[gid].dgst[DGST_R0]; + const u32 r1 = tmps[gid].dgst[DGST_R1]; + const u32 r2 = tmps[gid].dgst[DGST_R2]; + const u32 r3 = tmps[gid].dgst[DGST_R3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32020-pure.cl b/OpenCL/m32020-pure.cl new file mode 100644 index 000000000..b779676e2 --- /dev/null +++ b/OpenCL/m32020-pure.cl @@ -0,0 +1,134 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct netiq_sspr_sha1_tmp +{ + u32 dgst[5]; + +} netiq_sspr_sha1_tmp_t; + +KERNEL_FQ void m32020_init (KERN_ATTR_TMPS (netiq_sspr_sha1_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha1_ctx_t ctx; + + sha1_init (&ctx); + + sha1_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + sha1_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); + + sha1_final (&ctx); + + tmps[gid].dgst[0] = ctx.h[0]; + tmps[gid].dgst[1] = ctx.h[1]; + tmps[gid].dgst[2] = ctx.h[2]; + tmps[gid].dgst[3] = ctx.h[3]; + tmps[gid].dgst[4] = ctx.h[4]; +} + +KERNEL_FQ void m32020_loop (KERN_ATTR_TMPS (netiq_sspr_sha1_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + for (u32 i = 0; i < 5; i += 5) + { + u32x dgst[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x h[5]; + + h[0] = SHA1M_A; + h[1] = SHA1M_B; + h[2] = SHA1M_C; + h[3] = SHA1M_D; + h[4] = SHA1M_E; + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 20 * 8; + + sha1_transform_vector (w0, w1, w2, w3, h); + + dgst[0] = h[0]; + dgst[1] = h[1]; + dgst[2] = h[2]; + dgst[3] = h[3]; + dgst[4] = h[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + } +} + +KERNEL_FQ void m32020_comp (KERN_ATTR_TMPS (netiq_sspr_sha1_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + const u32 r0 = tmps[gid].dgst[DGST_R0]; + const u32 r1 = tmps[gid].dgst[DGST_R1]; + const u32 r2 = tmps[gid].dgst[DGST_R2]; + const u32 r3 = tmps[gid].dgst[DGST_R3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32030-pure.cl b/OpenCL/m32030-pure.cl new file mode 100644 index 000000000..78ea30d56 --- /dev/null +++ b/OpenCL/m32030-pure.cl @@ -0,0 +1,149 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct netiq_sspr_sha256_tmp +{ + u32 dgst[8]; + +} netiq_sspr_sha256_tmp_t; + +KERNEL_FQ void m32030_init (KERN_ATTR_TMPS (netiq_sspr_sha256_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + + sha256_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + sha256_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); + + sha256_final (&ctx); + + tmps[gid].dgst[0] = ctx.h[0]; + tmps[gid].dgst[1] = ctx.h[1]; + tmps[gid].dgst[2] = ctx.h[2]; + tmps[gid].dgst[3] = ctx.h[3]; + tmps[gid].dgst[4] = ctx.h[4]; + tmps[gid].dgst[5] = ctx.h[5]; + tmps[gid].dgst[6] = ctx.h[6]; + tmps[gid].dgst[7] = ctx.h[7]; +} + +KERNEL_FQ void m32030_loop (KERN_ATTR_TMPS (netiq_sspr_sha256_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + for (u32 i = 0; i < 8; i += 8) + { + u32x dgst[8]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + dgst[5] = packv (tmps, dgst, gid, i + 5); + dgst[6] = packv (tmps, dgst, gid, i + 6); + dgst[7] = packv (tmps, dgst, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x h[8]; + + h[0] = SHA256M_A; + h[1] = SHA256M_B; + h[2] = SHA256M_C; + h[3] = SHA256M_D; + h[4] = SHA256M_E; + h[5] = SHA256M_F; + h[6] = SHA256M_G; + h[7] = SHA256M_H; + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 32 * 8; + + sha256_transform_vector (w0, w1, w2, w3, h); + + dgst[0] = h[0]; + dgst[1] = h[1]; + dgst[2] = h[2]; + dgst[3] = h[3]; + dgst[4] = h[4]; + dgst[5] = h[5]; + dgst[6] = h[6]; + dgst[7] = h[7]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + unpackv (tmps, dgst, gid, i + 5, dgst[5]); + unpackv (tmps, dgst, gid, i + 6, dgst[6]); + unpackv (tmps, dgst, gid, i + 7, dgst[7]); + } +} + +KERNEL_FQ void m32030_comp (KERN_ATTR_TMPS (netiq_sspr_sha256_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + const u32 r0 = tmps[gid].dgst[DGST_R0]; + const u32 r1 = tmps[gid].dgst[DGST_R1]; + const u32 r2 = tmps[gid].dgst[DGST_R2]; + const u32 r3 = tmps[gid].dgst[DGST_R3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32040-pure.cl b/OpenCL/m32040-pure.cl new file mode 100644 index 000000000..66611bd98 --- /dev/null +++ b/OpenCL/m32040-pure.cl @@ -0,0 +1,173 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct netiq_sspr_sha512_tmp +{ + u64 dgst[8]; + +} netiq_sspr_sha512_tmp_t; + +KERNEL_FQ void m32040_init (KERN_ATTR_TMPS (netiq_sspr_sha512_tmp_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + sha512_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + sha512_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); + + sha512_final (&ctx); + + tmps[gid].dgst[0] = ctx.h[0]; + tmps[gid].dgst[1] = ctx.h[1]; + tmps[gid].dgst[2] = ctx.h[2]; + tmps[gid].dgst[3] = ctx.h[3]; + tmps[gid].dgst[4] = ctx.h[4]; + tmps[gid].dgst[5] = ctx.h[5]; + tmps[gid].dgst[6] = ctx.h[6]; + tmps[gid].dgst[7] = ctx.h[7]; +} + +KERNEL_FQ void m32040_loop (KERN_ATTR_TMPS (netiq_sspr_sha512_tmp_t)) +{ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + for (u32 i = 0; i < 8; i += 8) + { + u64x dgst[8]; + + dgst[0] = pack64v (tmps, dgst, gid, i + 0); + dgst[1] = pack64v (tmps, dgst, gid, i + 1); + dgst[2] = pack64v (tmps, dgst, gid, i + 2); + dgst[3] = pack64v (tmps, dgst, gid, i + 3); + dgst[4] = pack64v (tmps, dgst, gid, i + 4); + dgst[5] = pack64v (tmps, dgst, gid, i + 5); + dgst[6] = pack64v (tmps, dgst, gid, i + 6); + dgst[7] = pack64v (tmps, dgst, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u64x h[8]; + + h[0] = SHA512M_A; + h[1] = SHA512M_B; + h[2] = SHA512M_C; + h[3] = SHA512M_D; + h[4] = SHA512M_E; + h[5] = SHA512M_F; + h[6] = SHA512M_G; + h[7] = SHA512M_H; + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + w0[0] = h32_from_64 (dgst[0]); + w0[1] = l32_from_64 (dgst[0]); + w0[2] = h32_from_64 (dgst[1]); + w0[3] = l32_from_64 (dgst[1]); + w1[0] = h32_from_64 (dgst[2]); + w1[1] = l32_from_64 (dgst[2]); + w1[2] = h32_from_64 (dgst[3]); + w1[3] = l32_from_64 (dgst[3]); + w2[0] = h32_from_64 (dgst[4]); + w2[1] = l32_from_64 (dgst[4]); + w2[2] = h32_from_64 (dgst[5]); + w2[3] = l32_from_64 (dgst[5]); + w3[0] = h32_from_64 (dgst[6]); + w3[1] = l32_from_64 (dgst[6]); + w3[2] = h32_from_64 (dgst[7]); + w3[3] = l32_from_64 (dgst[7]); + w4[0] = 0x80000000; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 64 * 8; + + sha512_transform_vector (w0, w1, w2, w3, w4, w5, w6, w7, h); + + dgst[0] = h[0]; + dgst[1] = h[1]; + dgst[2] = h[2]; + dgst[3] = h[3]; + dgst[4] = h[4]; + dgst[5] = h[5]; + dgst[6] = h[6]; + dgst[7] = h[7]; + } + + unpack64v (tmps, dgst, gid, i + 0, dgst[0]); + unpack64v (tmps, dgst, gid, i + 1, dgst[1]); + unpack64v (tmps, dgst, gid, i + 2, dgst[2]); + unpack64v (tmps, dgst, gid, i + 3, dgst[3]); + unpack64v (tmps, dgst, gid, i + 4, dgst[4]); + unpack64v (tmps, dgst, gid, i + 5, dgst[5]); + unpack64v (tmps, dgst, gid, i + 6, dgst[6]); + unpack64v (tmps, dgst, gid, i + 7, dgst[7]); + } +} + +KERNEL_FQ void m32040_comp (KERN_ATTR_TMPS (netiq_sspr_sha512_tmp_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + + if (gid >= GID_CNT) return; + + const u64 a = tmps[gid].dgst[7]; + const u64 b = tmps[gid].dgst[3]; + + const u32 r0 = l32_from_64_S (a); + const u32 r1 = h32_from_64_S (a); + const u32 r2 = l32_from_64_S (b); + const u32 r3 = h32_from_64_S (b); + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32100-pure.cl b/OpenCL/m32100-pure.cl new file mode 100644 index 000000000..a1e9fe227 --- /dev/null +++ b/OpenCL/m32100-pure.cl @@ -0,0 +1,1038 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +typedef struct krb5asrep_17 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + u32 format; + +} krb5asrep_17_t; + +typedef struct krb5asrep_17_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[10]; + u32 out[10]; + +} krb5asrep_17_tmp_t; + +DECLSPEC void aes128_encrypt_cbc (PRIVATE_AS const u32 *aes_ks, PRIVATE_AS u32 *aes_iv, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + u32 data[4]; + + data[0] = hc_swap32_S (in[0]); + data[1] = hc_swap32_S (in[1]); + data[2] = hc_swap32_S (in[2]); + data[3] = hc_swap32_S (in[3]); + + data[0] ^= aes_iv[0]; + data[1] ^= aes_iv[1]; + data[2] ^= aes_iv[2]; + data[3] ^= aes_iv[3]; + + aes128_encrypt (aes_ks, data, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + aes_iv[0] = out[0]; + aes_iv[1] = out[1]; + aes_iv[2] = out[2]; + aes_iv[3] = out[3]; + + out[0] = hc_swap32_S (out[0]); + out[1] = hc_swap32_S (out[1]); + out[2] = hc_swap32_S (out[2]); + out[3] = hc_swap32_S (out[3]); +} + +DECLSPEC void aes128_decrypt_cbc (PRIVATE_AS const u32 *ks1, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, PRIVATE_AS u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + aes128_decrypt (ks1, in, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= essiv[0]; + out[1] ^= essiv[1]; + out[2] ^= essiv[2]; + out[3] ^= essiv[3]; + + essiv[0] = in[0]; + essiv[1] = in[1]; + essiv[2] = in[2]; + essiv[3] = in[3]; +} + +DECLSPEC void hmac_sha1_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m32100_init (KERN_ATTR_TMPS_ESALT (krb5asrep_17_tmp_t, krb5asrep_17_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + /* initialize hmac-sha1 for pbkdf2(password, account, 4096, account_len) */ + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init_global_swap (&sha1_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha1_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha1_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha1_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha1_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha1_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = sha1_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha1_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha1_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha1_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha1_hmac_ctx.opad.h[4]; + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].account_info, esalt_bufs[DIGESTS_OFFSET_HOST].account_info_len); + + for (u32 i = 0, j = 1; i < 4; i += 5, j += 1) + { + sha1_hmac_ctx_t sha1_hmac_ctx2 = sha1_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx2, w0, w1, w2, w3, 4); + + sha1_hmac_final (&sha1_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha1_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha1_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha1_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha1_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha1_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +KERNEL_FQ void m32100_loop (KERN_ATTR_TMPS_ESALT (krb5asrep_17_tmp_t, krb5asrep_17_t)) +{ + /** + * base + */ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 4; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } +} + +KERNEL_FQ void m32100_comp (KERN_ATTR_TMPS_ESALT (krb5asrep_17_tmp_t, krb5asrep_17_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + #endif + + if (gid >= GID_CNT) return; + + /* + at this point, the output ('seed') will be used to generate AES keys: + + key_bytes = derive(seed, 'kerberos'.encode(), seedsize) + + 'key_bytes' will be the AES key used to generate 'ke' and 'ki' + 'ke' will be the AES key to decrypt the ticket + 'ki' will be the key to compute the final HMAC + */ + + u32 nfolded[4]; + + // we can precompute _nfold('kerberos', 16) + nfolded[0] = 0x6b657262; + nfolded[1] = 0x65726f73; + nfolded[2] = 0x7b9b5b2b; + nfolded[3] = 0x93132b93; + + // then aes_cbc encrypt this nfolded value with 'seed' as key along with a null IV + u32 aes_key[4]; + + aes_key[0] = hc_swap32_S (tmps[gid].out[0]); + aes_key[1] = hc_swap32_S (tmps[gid].out[1]); + aes_key[2] = hc_swap32_S (tmps[gid].out[2]); + aes_key[3] = hc_swap32_S (tmps[gid].out[3]); + + u32 aes_iv[4]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + u32 aes_ks[44]; + + aes128_set_encrypt_key (aes_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + + u32 key_bytes[4]; + + aes128_encrypt_cbc (aes_ks, aes_iv, nfolded, key_bytes, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* + We will now compute 'ki', having 'key_bytes' + + Description of the key derivation function from RFC3961 Section 5.3: + The "well-known constant" used for the DK function is the key usage + number, expressed as four octets in big-endian order, followed by + one octet indicated below. + Kc = DK(base-key, usage | 0x99); + Ke = DK(base-key, usage | 0xAA); + Ki = DK(base-key, usage | 0x55); + + The key usage numbers are defined in RFC4120. In Section 5.4.2, it + specifies that a key usage number of 3 is used for the EncASRepPart + of an AS-REP message. + */ + + u32 ki[4]; + + key_bytes[0] = hc_swap32_S (key_bytes[0]); + key_bytes[1] = hc_swap32_S (key_bytes[1]); + key_bytes[2] = hc_swap32_S (key_bytes[2]); + key_bytes[3] = hc_swap32_S (key_bytes[3]); + + // we can precompute _nfold(pack('>IB', 3, 0x55), 16) + nfolded[0] = 0x6b60b058; + nfolded[1] = 0x2a6ba80d; + nfolded[2] = 0x5aad56ab; + nfolded[3] = 0x55406ad5; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes128_set_encrypt_key (aes_ks, key_bytes, s_te0, s_te1, s_te2, s_te3); + + aes128_encrypt_cbc (aes_ks, aes_iv, nfolded, ki, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* we will now compute 'ke' */ + + u32 ke[4]; + + // we can precompute _nfold(pack('>IB', 3, 0xAA), 16) + nfolded[0] = 0xbe349a4d; + nfolded[1] = 0x24be500e; + nfolded[2] = 0xaf57abd5; + nfolded[3] = 0xea80757a; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes128_encrypt_cbc (aes_ks, aes_iv, nfolded, ke, s_te0, s_te1, s_te2, s_te3, s_te4); + + /* + We now have 'ke' and 'ki' + + We will decrypt (with 'ke') the 32 first bytes to search for ASN.1 structs + and if we find ASN.1 structs, we will compute the hmac (with 'ki') + + For AS-REP EncASRepPart: + The first byte is 0x79 (01 1 11001, where 01 = "class=APPLICATION", 1 = "form=constructed", 11001 is application type 25) + + According to RFC4120 Section 5.4.2: "Some implementations unconditionally send an encrypted EncTGSRepPart (application + tag number 26) in this field regardless of whether the reply is a AS-REP or a TGS-REP. In the interest of compatibility, + implementors MAY relax the check on the tag number of the decrypted ENC-PART" + + The first byte can thus also be 0x7a (corresponding to application type 26) instead of 0x79 + + The next byte is the length: + + if length < 128 bytes: + length is on 1 byte, and the next byte is 0x30 (class=SEQUENCE) + else if length <= 256: + length is on 2 bytes, the first byte is 0x81, and the third byte is 0x30 (class=SEQUENCE) + else if length > 256: + length is on 3 bytes, the first byte is 0x82, and the fourth byte is 0x30 (class=SEQUENCE) + */ + + u32 first_blocks[16]; + + u32 decrypted_block[4]; + + first_blocks[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[0]; + first_blocks[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[1]; + first_blocks[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[2]; + first_blocks[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[3]; + + first_blocks[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[4]; // possible ASN1 structs + first_blocks[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[5]; + first_blocks[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[6]; // possible ASN1 structs + first_blocks[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[7]; + + /* + we will decrypt them here in order to be able to compute hmac directly + if ASN1 structs were to be found + */ + first_blocks[8] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[8]; + first_blocks[9] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[9]; + first_blocks[10] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[10]; + first_blocks[11] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[11]; + + first_blocks[12] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[12]; + first_blocks[13] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[13]; + first_blocks[14] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[14]; + first_blocks[15] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[15]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 aes_cts_decrypt_ks[44]; + + AES128_set_decrypt_key (aes_cts_decrypt_ks, ke, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + if (((decrypted_block[0] & 0x00ff80ff) == 0x00300079) || + ((decrypted_block[0] & 0x00ff80ff) == 0x0030007a) || + ((decrypted_block[0] & 0xFF00FFFF) == 0x30008179) || + ((decrypted_block[0] & 0xFF00FFFF) == 0x3000817a) || + ((decrypted_block[0] & 0x0000FFFF) == 0x00008279 && (decrypted_block[1] & 0x000000FF) == 0x00000030) || + ((decrypted_block[0] & 0x0000FFFF) == 0x0000827a && (decrypted_block[1] & 0x000000FF) == 0x00000030)) + { + // now we decrypt all the ticket to verify checksum + int block_position; + + int edata2_len = esalt_bufs[DIGESTS_OFFSET_HOST].edata2_len; + + int edata2_left; + + u32 block[16]; + + int last_block_size = edata2_len % 16; + + if (last_block_size == 0) + { + last_block_size = 16; + } + + int last_part = last_block_size + 16; + + int need = edata2_len - last_part; + + int last_block_cbc_position = (need - 16) / 4; + + // we need to decrypt also the 2 following blocks in order to be able to compute the hmac directly + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = hc_swap32_S (decrypted_block[0]); + w2[1] = hc_swap32_S (decrypted_block[1]); + w2[2] = hc_swap32_S (decrypted_block[2]); + w2[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = hc_swap32_S (decrypted_block[0]); + w3[1] = hc_swap32_S (decrypted_block[1]); + w3[2] = hc_swap32_S (decrypted_block[2]); + w3[3] = hc_swap32_S (decrypted_block[3]); + + sha1_hmac_ctx_t sha1_hmac_ctx; + + /* + hmac message = plaintext + hmac key = ki + */ + + u32 k0[4]; + u32 k1[4]; + u32 k2[4]; + u32 k3[4]; + + k0[0] = ki[0]; + k0[1] = ki[1]; + k0[2] = ki[2]; + k0[3] = ki[3]; + + k1[0] = 0; + k1[1] = 0; + k1[2] = 0; + k1[3] = 0; + + k2[0] = 0; + k2[1] = 0; + k2[2] = 0; + k2[3] = 0; + + k3[0] = 0; + k3[1] = 0; + k3[2] = 0; + k3[3] = 0; + + sha1_hmac_init_64 (&sha1_hmac_ctx, k0, k1, k2, k3); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position = 16; + + // first 4 blocks are already decrypted + for (edata2_left = need - 64; edata2_left >= 64; edata2_left -= 64) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + block[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 4]; + block[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 5]; + block[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 6]; + block[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 7]; + block[8] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 8]; + block[9] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 9]; + block[10] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 10]; + block[11] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 11]; + block[12] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 12]; + block[13] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 13]; + block[14] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 14]; + block[15] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 15]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = hc_swap32_S (decrypted_block[0]); + w2[1] = hc_swap32_S (decrypted_block[1]); + w2[2] = hc_swap32_S (decrypted_block[2]); + w2[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = hc_swap32_S (decrypted_block[0]); + w3[1] = hc_swap32_S (decrypted_block[1]); + w3[2] = hc_swap32_S (decrypted_block[2]); + w3[3] = hc_swap32_S (decrypted_block[3]); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position += 16; + } + + if (edata2_left == 16) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16); + + block_position += 4; + } + else if (edata2_left == 32) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + block[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 4]; + block[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 5]; + block[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 6]; + block[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 7]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 32); + + block_position += 8; + } + else if (edata2_left == 48) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + block[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 4]; + block[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 5]; + block[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 6]; + block[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 7]; + block[8] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 8]; + block[9] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 9]; + block[10] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 10]; + block[11] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 11]; + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + aes128_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = hc_swap32_S (decrypted_block[0]); + w2[1] = hc_swap32_S (decrypted_block[1]); + w2[2] = hc_swap32_S (decrypted_block[2]); + w2[3] = hc_swap32_S (decrypted_block[3]); + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 48); + + block_position += 12; + } + + /* + now all the ticket should be decrypted until block n-1 (not included) + and n + */ + + // this is block n-2, it will be xored with the n-1 block later crafted + u32 last_block_cbc[4]; + + last_block_cbc[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 0]; + last_block_cbc[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 1]; + last_block_cbc[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 2]; + last_block_cbc[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 3]; + + // n-1 block is decrypted separately from the previous blocks which were cbc decrypted + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + + aes128_decrypt (aes_cts_decrypt_ks, block, decrypted_block, s_td0, s_td1, s_td2, s_td3, s_td4); + + u32 last_block[4]; + + int last_block_position = (edata2_len - last_block_size) / 4; + + u32 n_1_crafted[4]; + + u32 last_plaintext[4]; + + last_plaintext[0] = 0; + last_plaintext[1] = 0; + last_plaintext[2] = 0; + last_plaintext[3] = 0; + + /* + n-1 block is first computed as follows: + - fill n-1 block with the X first bytes of the encrypted last block (n) + with X == length of last block + - complete the rest of the block with + + Final block (n) is computed as follows: + - fill with the X first bytes from n-1 block decrypted and xor them with last block (n) + with X == length of last block + */ + int remaining_blocks = last_block_size / 4; + + /* + last block is not necessarily aligned on 4 bytes so we will have + to shift values for the CTS crap... + */ + u32 shift = last_block_size % 4; + + u32 mask; + + switch (remaining_blocks) + { + case 0: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + + mask = (0xffffffff >> ((4 - last_block_size) * 8)); + + last_plaintext[0] = last_block[0] ^ (decrypted_block[0] & mask); + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + + n_1_crafted[0] = (last_block[0] & mask) | (decrypted_block[0] & (mask ^ 0xffffffff)); + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + break; + + case 1: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + } + else + { + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + + mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ (decrypted_block[1] & mask); + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = (last_block[1] & mask) | (decrypted_block[1] & (mask ^ 0xffffffff)); + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 2: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + } + else + { + last_block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 2]; + + mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ (decrypted_block[2] & mask); + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = (last_block[2] & mask) | (decrypted_block[2] & (mask ^ 0xffffffff)); + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 3: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 2]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + } + else + { + last_block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 3]; + + mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ (decrypted_block[3] & mask); + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + last_plaintext[3] = hc_swap32_S (last_plaintext[3]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = (last_block[3] & mask) | (decrypted_block[3] & (mask ^ 0xffffffff)); + } + break; + + case 4: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 2]; + last_block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 3]; + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = last_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ decrypted_block[3]; + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + last_plaintext[3] = hc_swap32_S (last_plaintext[3]); + break; + + default: + return; + } + + // then decrypt this newly created n-1 with 'ke' + aes128_decrypt (aes_cts_decrypt_ks, n_1_crafted, n_1_crafted, s_td0, s_td1, s_td2, s_td3, s_td4); + + // then xor with the encrypted n-2 block + n_1_crafted[0] ^= last_block_cbc[0]; + n_1_crafted[1] ^= last_block_cbc[1]; + n_1_crafted[2] ^= last_block_cbc[2]; + n_1_crafted[3] ^= last_block_cbc[3]; + + w0[0] = hc_swap32_S (n_1_crafted[0]); + w0[1] = hc_swap32_S (n_1_crafted[1]); + w0[2] = hc_swap32_S (n_1_crafted[2]); + w0[3] = hc_swap32_S (n_1_crafted[3]); + + w1[0] = last_plaintext[0]; + w1[1] = last_plaintext[1]; + w1[2] = last_plaintext[2]; + w1[3] = last_plaintext[3]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16 + last_block_size); + + sha1_hmac_final (&sha1_hmac_ctx); + + if (sha1_hmac_ctx.opad.h[0] == esalt_bufs[DIGESTS_OFFSET_HOST].checksum[0] + && sha1_hmac_ctx.opad.h[1] == esalt_bufs[DIGESTS_OFFSET_HOST].checksum[1] + && sha1_hmac_ctx.opad.h[2] == esalt_bufs[DIGESTS_OFFSET_HOST].checksum[2]) + { + if (hc_atomic_inc (&hashes_shown[DIGESTS_OFFSET_HOST]) == 0) + { + #define il_pos 0 + mark_hash (plains_buf, d_return_buf, SALT_POS_HOST, DIGESTS_CNT, 0, DIGESTS_OFFSET_HOST + 0, gid, il_pos, 0, 0); + } + } + } +} diff --git a/OpenCL/m32200-pure.cl b/OpenCL/m32200-pure.cl new file mode 100644 index 000000000..9a9d999ae --- /dev/null +++ b/OpenCL/m32200-pure.cl @@ -0,0 +1,1101 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +typedef struct krb5asrep_18 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + u32 format; + +} krb5asrep_18_t; + +typedef struct krb5asrep_18_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[16]; + u32 out[16]; + +} krb5asrep_18_tmp_t; + +DECLSPEC void aes256_encrypt_cbc (PRIVATE_AS const u32 *aes_ks, PRIVATE_AS u32 *aes_iv, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4) +{ + u32 data[4]; + + data[0] = hc_swap32_S (in[0]); + data[1] = hc_swap32_S (in[1]); + data[2] = hc_swap32_S (in[2]); + data[3] = hc_swap32_S (in[3]); + + data[0] ^= aes_iv[0]; + data[1] ^= aes_iv[1]; + data[2] ^= aes_iv[2]; + data[3] ^= aes_iv[3]; + + aes256_encrypt (aes_ks, data, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + aes_iv[0] = out[0]; + aes_iv[1] = out[1]; + aes_iv[2] = out[2]; + aes_iv[3] = out[3]; + + out[0] = hc_swap32_S (out[0]); + out[1] = hc_swap32_S (out[1]); + out[2] = hc_swap32_S (out[2]); + out[3] = hc_swap32_S (out[3]); +} + +DECLSPEC void aes256_decrypt_cbc (PRIVATE_AS const u32 *ks1, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, PRIVATE_AS u32 *essiv, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4) +{ + aes256_decrypt (ks1, in, out, s_td0, s_td1, s_td2, s_td3, s_td4); + + out[0] ^= essiv[0]; + out[1] ^= essiv[1]; + out[2] ^= essiv[2]; + out[3] ^= essiv[3]; + + essiv[0] = in[0]; + essiv[1] = in[1]; + essiv[2] = in[2]; + essiv[3] = in[3]; +} + +DECLSPEC void hmac_sha1_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + + sha1_transform_vector (w0, w1, w2, w3, digest); +} + +KERNEL_FQ void m32200_init (KERN_ATTR_TMPS_ESALT (krb5asrep_18_tmp_t, krb5asrep_18_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + /* initialize hmac-sha1 for pbkdf2(password, account, 4096, account_len) */ + + sha1_hmac_ctx_t sha1_hmac_ctx; + + sha1_hmac_init_global_swap (&sha1_hmac_ctx, pws[gid].i, pws[gid].pw_len); + + tmps[gid].ipad[0] = sha1_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha1_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha1_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha1_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha1_hmac_ctx.ipad.h[4]; + + tmps[gid].opad[0] = sha1_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha1_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha1_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha1_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha1_hmac_ctx.opad.h[4]; + + sha1_hmac_update_global_swap (&sha1_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].account_info, esalt_bufs[DIGESTS_OFFSET_HOST].account_info_len); + + for (u32 i = 0, j = 1; i < 8; i += 5, j += 1) + { + sha1_hmac_ctx_t sha1_hmac_ctx2 = sha1_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx2, w0, w1, w2, w3, 4); + + sha1_hmac_final (&sha1_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha1_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha1_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha1_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha1_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha1_hmac_ctx2.opad.h[4]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + } +} + +KERNEL_FQ void m32200_loop (KERN_ATTR_TMPS_ESALT (krb5asrep_18_tmp_t, krb5asrep_18_t)) +{ + /** + * base + */ + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u32x ipad[5]; + u32x opad[5]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + + for (u32 i = 0; i < 8; i += 5) + { + u32x dgst[5]; + u32x out[5]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = 0x80000000; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 20) * 8; + + hmac_sha1_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + } +} + +KERNEL_FQ void m32200_comp (KERN_ATTR_TMPS_ESALT (krb5asrep_18_tmp_t, krb5asrep_18_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + /* + at this point, the output ('seed') will be used to generate AES keys: + + key_bytes = derive(seed, 'kerberos'.encode(), seedsize) + + 'key_bytes' will be the AES key used to generate 'ke' and 'ki' + 'ke' will be the AES key to decrypt the ticket + 'ki' will be the key to compute the final HMAC + */ + + u32 nfolded[4]; + + // we can precompute _nfold('kerberos', 16) + nfolded[0] = 0x6b657262; + nfolded[1] = 0x65726f73; + nfolded[2] = 0x7b9b5b2b; + nfolded[3] = 0x93132b93; + + // then aes_cbc encrypt this nfolded value with 'seed' as key along with a null IV + u32 aes_key[8]; + + aes_key[0] = hc_swap32_S (tmps[gid].out[0]); + aes_key[1] = hc_swap32_S (tmps[gid].out[1]); + aes_key[2] = hc_swap32_S (tmps[gid].out[2]); + aes_key[3] = hc_swap32_S (tmps[gid].out[3]); + aes_key[4] = hc_swap32_S (tmps[gid].out[4]); + aes_key[5] = hc_swap32_S (tmps[gid].out[5]); + aes_key[6] = hc_swap32_S (tmps[gid].out[6]); + aes_key[7] = hc_swap32_S (tmps[gid].out[7]); + + u32 aes_iv[4]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + u32 aes_ks[60]; + + aes256_set_encrypt_key (aes_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + + u32 key_bytes[8]; + + u32 out[4]; + aes256_encrypt_cbc (aes_ks, aes_iv, nfolded, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + key_bytes[0] = out[0]; + key_bytes[1] = out[1]; + key_bytes[2] = out[2]; + key_bytes[3] = out[3]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_encrypt_cbc (aes_ks, aes_iv, out, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + key_bytes[4] = out[0]; + key_bytes[5] = out[1]; + key_bytes[6] = out[2]; + key_bytes[7] = out[3]; + + /* + We will now compute 'ki', having 'key_bytes' + + Description of the key derivation function from RFC3961 Section 5.3: + The "well-known constant" used for the DK function is the key usage + number, expressed as four octets in big-endian order, followed by + one octet indicated below. + Kc = DK(base-key, usage | 0x99); + Ke = DK(base-key, usage | 0xAA); + Ki = DK(base-key, usage | 0x55); + + The key usage numbers are defined in RFC4120. In Section 5.4.2, it + specifies that a key usage number of 3 is used for the EncASRepPart + of an AS-REP message. + */ + + u32 ki[8]; + + // we can precompute _nfold(pack('>IB', 3, 0x55), 16) + nfolded[0] = 0x6b60b058; + nfolded[1] = 0x2a6ba80d; + nfolded[2] = 0x5aad56ab; + nfolded[3] = 0x55406ad5; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + key_bytes[0] = hc_swap32_S (key_bytes[0]); + key_bytes[1] = hc_swap32_S (key_bytes[1]); + key_bytes[2] = hc_swap32_S (key_bytes[2]); + key_bytes[3] = hc_swap32_S (key_bytes[3]); + key_bytes[4] = hc_swap32_S (key_bytes[4]); + key_bytes[5] = hc_swap32_S (key_bytes[5]); + key_bytes[6] = hc_swap32_S (key_bytes[6]); + key_bytes[7] = hc_swap32_S (key_bytes[7]); + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes256_set_encrypt_key (aes_ks, key_bytes, s_te0, s_te1, s_te2, s_te3); + + aes256_encrypt_cbc (aes_ks, aes_iv, nfolded, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ki[0] = out[0]; + ki[1] = out[1]; + ki[2] = out[2]; + ki[3] = out[3]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_encrypt_cbc (aes_ks, aes_iv, out, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ki[4] = out[0]; + ki[5] = out[1]; + ki[6] = out[2]; + ki[7] = out[3]; + + /* we will now compute 'ke' */ + + u32 ke[8]; + + // we can precompute _nfold(pack('>IB', 3, 0xAA), 16) + nfolded[0] = 0xbe349a4d; + nfolded[1] = 0x24be500e; + nfolded[2] = 0xaf57abd5; + nfolded[3] = 0xea80757a; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + // then aes_cbc encrypt this nfolded value with 'key_bytes' as key along with a null IV + aes256_encrypt_cbc (aes_ks, aes_iv, nfolded, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ke[0] = out[0]; + ke[1] = out[1]; + ke[2] = out[2]; + ke[3] = out[3]; + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_encrypt_cbc (aes_ks, aes_iv, out, out, s_te0, s_te1, s_te2, s_te3, s_te4); + + ke[4] = out[0]; + ke[5] = out[1]; + ke[6] = out[2]; + ke[7] = out[3]; + + /* + We now have 'ke' and 'ki' + + We will decrypt (with 'ke') the 32 first bytes to search for ASN.1 structs + and if we find ASN.1 structs, we will compute the hmac (with 'ki') + + For AS-REP EncASRepPart: + The first byte is 0x79 (01 1 11001, where 01 = "class=APPLICATION", 1 = "form=constructed", 11001 is application type 25) + + According to RFC4120 Section 5.4.2: "Some implementations unconditionally send an encrypted EncTGSRepPart (application + tag number 26) in this field regardless of whether the reply is a AS-REP or a TGS-REP. In the interest of compatibility, + implementors MAY relax the check on the tag number of the decrypted ENC-PART" + + The first byte can thus also be 0x7a (corresponding to application type 26) instead of 0x79 + + The next byte is the length: + + if length < 128 bytes: + length is on 1 byte, and the next byte is 0x30 (class=SEQUENCE) + else if length <= 256: + length is on 2 bytes, the first byte is 0x81, and the third byte is 0x30 (class=SEQUENCE) + else if length > 256: + length is on 3 bytes, the first byte is 0x82, and the fourth byte is 0x30 (class=SEQUENCE) + */ + + u32 first_blocks[16]; + + u32 decrypted_block[8]; + + first_blocks[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[0]; + first_blocks[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[1]; + first_blocks[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[2]; + first_blocks[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[3]; + + first_blocks[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[4]; // possible ASN1 structs + first_blocks[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[5]; + first_blocks[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[6]; // possible ASN1 structs + first_blocks[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[7]; + + /* + we will decrypt them here in order to be able to compute hmac directly + if ASN1 structs were to be found + */ + first_blocks[8] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[8]; + first_blocks[9] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[9]; + first_blocks[10] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[10]; + first_blocks[11] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[11]; + + first_blocks[12] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[12]; + first_blocks[13] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[13]; + first_blocks[14] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[14]; + first_blocks[15] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[15]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 aes_cts_decrypt_ks[60]; + + AES256_set_decrypt_key (aes_cts_decrypt_ks, ke, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + aes_iv[0] = 0; + aes_iv[1] = 0; + aes_iv[2] = 0; + aes_iv[3] = 0; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + if (((decrypted_block[0] & 0x00ff80ff) == 0x00300079) || + ((decrypted_block[0] & 0x00ff80ff) == 0x0030007a) || + ((decrypted_block[0] & 0xFF00FFFF) == 0x30008179) || + ((decrypted_block[0] & 0xFF00FFFF) == 0x3000817a) || + ((decrypted_block[0] & 0x0000FFFF) == 0x00008279 && (decrypted_block[1] & 0x000000FF) == 0x00000030) || + ((decrypted_block[0] & 0x0000FFFF) == 0x0000827a && (decrypted_block[1] & 0x000000FF) == 0x00000030)) + { + // now we decrypt all the ticket to verify checksum + + // we need to decrypt also the 2 following blocks in order to be able to compute the hmac directly + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = hc_swap32_S (decrypted_block[0]); + w2[1] = hc_swap32_S (decrypted_block[1]); + w2[2] = hc_swap32_S (decrypted_block[2]); + w2[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, first_blocks + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = hc_swap32_S (decrypted_block[0]); + w3[1] = hc_swap32_S (decrypted_block[1]); + w3[2] = hc_swap32_S (decrypted_block[2]); + w3[3] = hc_swap32_S (decrypted_block[3]); + + int block_position; + + int edata2_len = esalt_bufs[DIGESTS_OFFSET_HOST].edata2_len; + + int edata2_left; + + u32 block[16]; + + int last_block_size = edata2_len % 16; + + if (last_block_size == 0) + { + last_block_size = 16; + } + + int last_part = last_block_size + 16; + + int need = edata2_len - last_part; + + int last_block_cbc_position = (need - 16) / 4; + + sha1_hmac_ctx_t sha1_hmac_ctx; + + /* + hmac message = plaintext + hmac key = ki + */ + + u32 k0[4]; + u32 k1[4]; + u32 k2[4]; + u32 k3[4]; + + k0[0] = ki[0]; + k0[1] = ki[1]; + k0[2] = ki[2]; + k0[3] = ki[3]; + + k1[0] = ki[4]; + k1[1] = ki[5]; + k1[2] = ki[6]; + k1[3] = ki[7]; + + k2[0] = 0; + k2[1] = 0; + k2[2] = 0; + k2[3] = 0; + + k3[0] = 0; + k3[1] = 0; + k3[2] = 0; + k3[3] = 0; + + sha1_hmac_init_64 (&sha1_hmac_ctx, k0, k1, k2, k3); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position = 16; + + // first 4 blocks are already decrypted + for (edata2_left = need - 64; edata2_left >= 64; edata2_left -= 64) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + block[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 4]; + block[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 5]; + block[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 6]; + block[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 7]; + block[8] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 8]; + block[9] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 9]; + block[10] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 10]; + block[11] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 11]; + block[12] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 12]; + block[13] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 13]; + block[14] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 14]; + block[15] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 15]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = hc_swap32_S (decrypted_block[0]); + w2[1] = hc_swap32_S (decrypted_block[1]); + w2[2] = hc_swap32_S (decrypted_block[2]); + w2[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 12, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w3[0] = hc_swap32_S (decrypted_block[0]); + w3[1] = hc_swap32_S (decrypted_block[1]); + w3[2] = hc_swap32_S (decrypted_block[2]); + w3[3] = hc_swap32_S (decrypted_block[3]); + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 64); + + block_position += 16; + } + + if (edata2_left == 16) + { + + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16); + + block_position += 4; + } + else if (edata2_left == 32) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + block[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 4]; + block[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 5]; + block[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 6]; + block[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 7]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 32); + + block_position += 8; + } + else if (edata2_left == 48) + { + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + block[4] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 4]; + block[5] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 5]; + block[6] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 6]; + block[7] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 7]; + block[8] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 8]; + block[9] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 9]; + block[10] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 10]; + block[11] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 11]; + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w0[0] = hc_swap32_S (decrypted_block[0]); + w0[1] = hc_swap32_S (decrypted_block[1]); + w0[2] = hc_swap32_S (decrypted_block[2]); + w0[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 4, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w1[0] = hc_swap32_S (decrypted_block[0]); + w1[1] = hc_swap32_S (decrypted_block[1]); + w1[2] = hc_swap32_S (decrypted_block[2]); + w1[3] = hc_swap32_S (decrypted_block[3]); + + aes256_decrypt_cbc (aes_cts_decrypt_ks, block + 8, decrypted_block, aes_iv, s_td0, s_td1, s_td2, s_td3, s_td4); + + w2[0] = hc_swap32_S (decrypted_block[0]); + w2[1] = hc_swap32_S (decrypted_block[1]); + w2[2] = hc_swap32_S (decrypted_block[2]); + w2[3] = hc_swap32_S (decrypted_block[3]); + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 48); + + block_position += 12; + } + + /* + now all the ticket should be decrypted until block n-1 (not included) + and n + */ + + // this is block n-2, it will be xored with the n-1 block later crafted + u32 last_block_cbc[4]; + + last_block_cbc[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 0]; + last_block_cbc[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 1]; + last_block_cbc[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 2]; + last_block_cbc[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_cbc_position + 3]; + + // n-1 block is decrypted separately from the previous blocks which were cbc decrypted + block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 0]; + block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 1]; + block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 2]; + block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[block_position + 3]; + + aes256_decrypt (aes_cts_decrypt_ks, block, decrypted_block, s_td0, s_td1, s_td2, s_td3, s_td4); + + u32 last_block[4]; + + int last_block_position = (edata2_len - last_block_size) / 4; + + u32 n_1_crafted[4]; + + u32 last_plaintext[4]; + + last_plaintext[0] = 0; + last_plaintext[1] = 0; + last_plaintext[2] = 0; + last_plaintext[3] = 0; + + /* + n-1 block is first computed as follows: + - fill n-1 block with the X first bytes of the encrypted last block (n) + with X == length of last block + - complete the rest of the block with + + Final block (n) is computed as follows: + - fill with the X first bytes from n-1 block decrypted and xor them with last block (n) + with X == length of last block + */ + int remaining_blocks = last_block_size / 4; + + /* + last block is not necessarily aligned on 4 bytes so we will have + to shift values for the CTS crap... + */ + u32 shift = last_block_size % 4; + + u32 mask; + + switch (remaining_blocks) + { + case 0: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + + mask = (0xffffffff >> ((4 - last_block_size) * 8)); + + last_plaintext[0] = last_block[0] ^ (decrypted_block[0] & mask); + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + + n_1_crafted[0] = (last_block[0] & mask) | (decrypted_block[0] & (mask ^ 0xffffffff)); + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + break; + + case 1: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = decrypted_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + } + else + { + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + + mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ (decrypted_block[1] & mask); + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = (last_block[1] & mask) | (decrypted_block[1] & (mask ^ 0xffffffff)); + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 2: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = decrypted_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + } + else + { + last_block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 2]; + + mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ (decrypted_block[2] & mask); + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = (last_block[2] & mask) | (decrypted_block[2] & (mask ^ 0xffffffff)); + n_1_crafted[3] = decrypted_block[3]; + } + break; + + case 3: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 2]; + + if (shift == 0) + { + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = decrypted_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + } + else + { + last_block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 3]; + + mask = (0xffffffff >> ((4 - (last_block_size % 4)) * 8)); + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ (decrypted_block[3] & mask); + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + last_plaintext[3] = hc_swap32_S (last_plaintext[3]); + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = (last_block[3] & mask) | (decrypted_block[3] & (mask ^ 0xffffffff)); + } + break; + + case 4: + + last_block[0] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 0]; + last_block[1] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 1]; + last_block[2] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 2]; + last_block[3] = esalt_bufs[DIGESTS_OFFSET_HOST].edata2[last_block_position + 3]; + + n_1_crafted[0] = last_block[0]; + n_1_crafted[1] = last_block[1]; + n_1_crafted[2] = last_block[2]; + n_1_crafted[3] = last_block[3]; + + last_plaintext[0] = last_block[0] ^ decrypted_block[0]; + last_plaintext[1] = last_block[1] ^ decrypted_block[1]; + last_plaintext[2] = last_block[2] ^ decrypted_block[2]; + last_plaintext[3] = last_block[3] ^ decrypted_block[3]; + + last_plaintext[0] = hc_swap32_S (last_plaintext[0]); + last_plaintext[1] = hc_swap32_S (last_plaintext[1]); + last_plaintext[2] = hc_swap32_S (last_plaintext[2]); + last_plaintext[3] = hc_swap32_S (last_plaintext[3]); + break; + + default: + return; + } + + + // then decrypt this newly created n-1 with 'ke' + aes256_decrypt (aes_cts_decrypt_ks, n_1_crafted, n_1_crafted, s_td0, s_td1, s_td2, s_td3, s_td4); + + // then xor with the encrypted n-2 block + n_1_crafted[0] ^= last_block_cbc[0]; + n_1_crafted[1] ^= last_block_cbc[1]; + n_1_crafted[2] ^= last_block_cbc[2]; + n_1_crafted[3] ^= last_block_cbc[3]; + + w0[0] = hc_swap32_S (n_1_crafted[0]); + w0[1] = hc_swap32_S (n_1_crafted[1]); + w0[2] = hc_swap32_S (n_1_crafted[2]); + w0[3] = hc_swap32_S (n_1_crafted[3]); + + w1[0] = last_plaintext[0]; + w1[1] = last_plaintext[1]; + w1[2] = last_plaintext[2]; + w1[3] = last_plaintext[3]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha1_hmac_update_64 (&sha1_hmac_ctx, w0, w1, w2, w3, 16 + last_block_size); + + sha1_hmac_final (&sha1_hmac_ctx); + + if (sha1_hmac_ctx.opad.h[0] == esalt_bufs[DIGESTS_OFFSET_HOST].checksum[0] + && sha1_hmac_ctx.opad.h[1] == esalt_bufs[DIGESTS_OFFSET_HOST].checksum[1] + && sha1_hmac_ctx.opad.h[2] == esalt_bufs[DIGESTS_OFFSET_HOST].checksum[2]) + { + if (hc_atomic_inc (&hashes_shown[DIGESTS_OFFSET_HOST]) == 0) + { + #define il_pos 0 + mark_hash (plains_buf, d_return_buf, SALT_POS_HOST, DIGESTS_CNT, 0, DIGESTS_OFFSET_HOST + 0, gid, il_pos, 0, 0); + } + } + } +} diff --git a/OpenCL/m32300_a0-optimized.cl b/OpenCL/m32300_a0-optimized.cl new file mode 100644 index 000000000..76400a61e --- /dev/null +++ b/OpenCL/m32300_a0-optimized.cl @@ -0,0 +1,813 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp_optimized.h) +#include M2S(INCLUDE_PATH/inc_rp_optimized.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +KERNEL_FQ void m32300_m04 (KERN_ATTR_RULES_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt1 + */ + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + /** + * salt2 + */ + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * salt3 + */ + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + // md5($password) + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + w3[2] = out_len * 8; + w3[3] = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + // md5(md5($password).$salt) + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + // md5_final_vector + + const int pos = ctx.len & 63; + + append_0x80_4x4 (ctx.w0, ctx.w1, ctx.w2, ctx.w3, pos); + + if (pos >= 56) + { + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + ctx.w0[0] = 0; + ctx.w0[1] = 0; + ctx.w0[2] = 0; + ctx.w0[3] = 0; + ctx.w1[0] = 0; + ctx.w1[1] = 0; + ctx.w1[2] = 0; + ctx.w1[3] = 0; + ctx.w2[0] = 0; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 0; + ctx.w3[3] = 0; + } + + ctx.w3[2] = ctx.len * 8; + ctx.w3[3] = 0; + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, ctx.w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, ctx.w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, ctx.w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w2[1], MD5C3f, MD5S33); + + a += ctx.h[0] - make_u32x (MD5M_A); + b += ctx.h[1] - make_u32x (MD5M_B); + c += ctx.h[2] - make_u32x (MD5M_C); + d += ctx.h[3] - make_u32x (MD5M_D); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32300_m08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m32300_m16 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m32300_s04 (KERN_ATTR_RULES_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * salt1 + */ + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + /** + * salt2 + */ + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * salt3 + */ + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + u32x w0[4] = { 0 }; + u32x w1[4] = { 0 }; + u32x w2[4] = { 0 }; + u32x w3[4] = { 0 }; + + const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1); + + append_0x80_2x4_VV (w0, w1, out_len); + + w3[2] = out_len * 8; + w3[3] = 0; + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + // md5_final_vector + + const int pos = ctx.len & 63; + + append_0x80_4x4 (ctx.w0, ctx.w1, ctx.w2, ctx.w3, pos); + + if (pos >= 56) + { + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + ctx.w0[0] = 0; + ctx.w0[1] = 0; + ctx.w0[2] = 0; + ctx.w0[3] = 0; + ctx.w1[0] = 0; + ctx.w1[1] = 0; + ctx.w1[2] = 0; + ctx.w1[3] = 0; + ctx.w2[0] = 0; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 0; + ctx.w3[3] = 0; + } + + ctx.w3[2] = ctx.len * 8; + ctx.w3[3] = 0; + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, ctx.w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, ctx.w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, ctx.w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w1[0], MD5C3c, MD5S30); + + if (MATCHES_NONE_VS ((a + ctx.h[0] - make_u32x (MD5M_A)), search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, ctx.w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w2[1], MD5C3f, MD5S33); + + a += ctx.h[0] - make_u32x (MD5M_A); + b += ctx.h[1] - make_u32x (MD5M_B); + c += ctx.h[2] - make_u32x (MD5M_C); + d += ctx.h[3] - make_u32x (MD5M_D); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32300_s08 (KERN_ATTR_RULES ()) +{ +} + +KERNEL_FQ void m32300_s16 (KERN_ATTR_RULES ()) +{ +} diff --git a/OpenCL/m32300_a0-pure.cl b/OpenCL/m32300_a0-pure.cl new file mode 100644 index 000000000..59c177abc --- /dev/null +++ b/OpenCL/m32300_a0-pure.cl @@ -0,0 +1,388 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +KERNEL_FQ void m32300_mxx (KERN_ATTR_RULES_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32 salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + md5_update (&ctx, salt2_buf, salt2_len); + + u32 ww0[4]; + u32 ww1[4]; + u32 ww2[4]; + u32 ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update (&ctx, salt3_buf, salt3_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32300_sxx (KERN_ATTR_RULES_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32 salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update (&ctx0, tmp.i, tmp.pw_len); + + md5_final (&ctx0); + + u32 a = ctx0.h[0]; + u32 b = ctx0.h[1]; + u32 c = ctx0.h[2]; + u32 d = ctx0.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + md5_update (&ctx, salt2_buf, salt2_len); + + u32 ww0[4]; + u32 ww1[4]; + u32 ww2[4]; + u32 ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update (&ctx, salt3_buf, salt3_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32300_a1-optimized.cl b/OpenCL/m32300_a1-optimized.cl new file mode 100644 index 000000000..371cb2d99 --- /dev/null +++ b/OpenCL/m32300_a1-optimized.cl @@ -0,0 +1,925 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +KERNEL_FQ void m32300_m04 (KERN_ATTR_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt1 + */ + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + /** + * salt2 + */ + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * salt3 + */ + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = pw_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + // md5_final_vector + + const int pos = ctx.len & 63; + + append_0x80_4x4 (ctx.w0, ctx.w1, ctx.w2, ctx.w3, pos); + + if (pos >= 56) + { + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + ctx.w0[0] = 0; + ctx.w0[1] = 0; + ctx.w0[2] = 0; + ctx.w0[3] = 0; + ctx.w1[0] = 0; + ctx.w1[1] = 0; + ctx.w1[2] = 0; + ctx.w1[3] = 0; + ctx.w2[0] = 0; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 0; + ctx.w3[3] = 0; + } + + ctx.w3[2] = ctx.len * 8; + ctx.w3[3] = 0; + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, ctx.w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, ctx.w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, ctx.w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w2[1], MD5C3f, MD5S33); + + a += ctx.h[0] - make_u32x (MD5M_A); + b += ctx.h[1] - make_u32x (MD5M_B); + c += ctx.h[2] - make_u32x (MD5M_C); + d += ctx.h[3] - make_u32x (MD5M_D); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32300_m08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m32300_m16 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m32300_s04 (KERN_ATTR_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 pw_buf0[4]; + u32 pw_buf1[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + pw_buf1[0] = pws[gid].i[4]; + pw_buf1[1] = pws[gid].i[5]; + pw_buf1[2] = pws[gid].i[6]; + pw_buf1[3] = pws[gid].i[7]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * salt1 + */ + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + /** + * salt2 + */ + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * salt3 + */ + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32x pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32x wordl0[4] = { 0 }; + u32x wordl1[4] = { 0 }; + u32x wordl2[4] = { 0 }; + u32x wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + wordl1[0] = pw_buf1[0]; + wordl1[1] = pw_buf1[1]; + wordl1[2] = pw_buf1[2]; + wordl1[3] = pw_buf1[3]; + + u32x wordr0[4] = { 0 }; + u32x wordr1[4] = { 0 }; + u32x wordr2[4] = { 0 }; + u32x wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + w2[0] = wordl2[0] | wordr2[0]; + w2[1] = wordl2[1] | wordr2[1]; + w2[2] = wordl2[2] | wordr2[2]; + w2[3] = wordl2[3] | wordr2[3]; + w3[0] = wordl3[0] | wordr3[0]; + w3[1] = wordl3[1] | wordr3[1]; + w3[2] = pw_len * 8; + w3[3] = 0; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + // md5_final_vector + + const int pos = ctx.len & 63; + + append_0x80_4x4 (ctx.w0, ctx.w1, ctx.w2, ctx.w3, pos); + + if (pos >= 56) + { + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + ctx.w0[0] = 0; + ctx.w0[1] = 0; + ctx.w0[2] = 0; + ctx.w0[3] = 0; + ctx.w1[0] = 0; + ctx.w1[1] = 0; + ctx.w1[2] = 0; + ctx.w1[3] = 0; + ctx.w2[0] = 0; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 0; + ctx.w3[3] = 0; + } + + ctx.w3[2] = ctx.len * 8; + ctx.w3[3] = 0; + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, ctx.w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, ctx.w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, ctx.w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w1[0], MD5C3c, MD5S30); + + if (MATCHES_NONE_VS ((a + ctx.h[0] - make_u32x (MD5M_A)), search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, ctx.w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w2[1], MD5C3f, MD5S33); + + a += ctx.h[0] - make_u32x (MD5M_A); + b += ctx.h[1] - make_u32x (MD5M_B); + c += ctx.h[2] - make_u32x (MD5M_C); + d += ctx.h[3] - make_u32x (MD5M_D); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32300_s08 (KERN_ATTR_BASIC ()) +{ +} + +KERNEL_FQ void m32300_s16 (KERN_ATTR_BASIC ()) +{ +} diff --git a/OpenCL/m32300_a1-pure.cl b/OpenCL/m32300_a1-pure.cl new file mode 100644 index 000000000..132db135a --- /dev/null +++ b/OpenCL/m32300_a1-pure.cl @@ -0,0 +1,382 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +KERNEL_FQ void m32300_mxx (KERN_ATTR_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase array + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32 salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * base + */ + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + md5_update (&ctx, salt2_buf, salt2_len); + + u32 ww0[4]; + u32 ww1[4]; + u32 ww2[4]; + u32 ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update (&ctx, salt3_buf, salt3_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32300_sxx (KERN_ATTR_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc uppercase array + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32 salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32 salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32 salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * base + */ + + md5_ctx_t ctx0; + + md5_init (&ctx0); + + md5_update_global (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + md5_ctx_t ctx1 = ctx0; + + md5_update_global (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + md5_final (&ctx1); + + u32 a = ctx1.h[0]; + u32 b = ctx1.h[1]; + u32 c = ctx1.h[2]; + u32 d = ctx1.h[3]; + + md5_ctx_t ctx; + + md5_init (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update (&ctx, salt1_buf, salt1_len); + + md5_final (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init (&ctx); + + md5_update (&ctx, salt2_buf, salt2_len); + + u32 ww0[4]; + u32 ww1[4]; + u32 ww2[4]; + u32 ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update (&ctx, salt3_buf, salt3_len); + + md5_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32300_a3-optimized.cl b/OpenCL/m32300_a3-optimized.cl new file mode 100644 index 000000000..74a051cf5 --- /dev/null +++ b/OpenCL/m32300_a3-optimized.cl @@ -0,0 +1,1169 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +DECLSPEC void m32300m (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_VECTOR_ESALT (md5_triple_salt_t), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt1 + */ + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + /** + * salt2 + */ + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * salt3 + */ + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0lr = w0l | w0r; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = w0lr; + w0_t[1] = w0[1]; + w0_t[2] = w0[2]; + w0_t[3] = w0[3]; + w1_t[0] = w1[0]; + w1_t[1] = w1[1]; + w1_t[2] = w1[2]; + w1_t[3] = w1[3]; + w2_t[0] = w2[0]; + w2_t[1] = w2[1]; + w2_t[2] = w2[2]; + w2_t[3] = w2[3]; + w3_t[0] = w3[0]; + w3_t[1] = w3[1]; + w3_t[2] = w3[2]; + w3_t[3] = w3[3]; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + // md5_final_vector + + const int pos = ctx.len & 63; + + append_0x80_4x4 (ctx.w0, ctx.w1, ctx.w2, ctx.w3, pos); + + if (pos >= 56) + { + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + ctx.w0[0] = 0; + ctx.w0[1] = 0; + ctx.w0[2] = 0; + ctx.w0[3] = 0; + ctx.w1[0] = 0; + ctx.w1[1] = 0; + ctx.w1[2] = 0; + ctx.w1[3] = 0; + ctx.w2[0] = 0; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 0; + ctx.w3[3] = 0; + } + + ctx.w3[2] = ctx.len * 8; + ctx.w3[3] = 0; + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, ctx.w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, ctx.w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, ctx.w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w1[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w2[1], MD5C3f, MD5S33); + + a += ctx.h[0] - make_u32x (MD5M_A); + b += ctx.h[1] - make_u32x (MD5M_B); + c += ctx.h[2] - make_u32x (MD5M_C); + d += ctx.h[3] - make_u32x (MD5M_D); + + COMPARE_M_SIMD (a, d, c, b); + } +} + +DECLSPEC void m32300s (PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_VECTOR_ESALT (md5_triple_salt_t), LOCAL_AS u32 *l_bin2asc) +{ + /** + * modifiers are taken from args + */ + + /** + * salt1 + */ + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + /** + * salt2 + */ + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + /** + * salt3 + */ + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * loop + */ + + u32 w0l = w0[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0lr = w0l | w0r; + + u32x w0_t[4]; + u32x w1_t[4]; + u32x w2_t[4]; + u32x w3_t[4]; + + w0_t[0] = w0lr; + w0_t[1] = w0[1]; + w0_t[2] = w0[2]; + w0_t[3] = w0[3]; + w1_t[0] = w1[0]; + w1_t[1] = w1[1]; + w1_t[2] = w1[2]; + w1_t[3] = w1[3]; + w2_t[0] = w2[0]; + w2_t[1] = w2[1]; + w2_t[2] = w2[2]; + w2_t[3] = w2[3]; + w3_t[0] = w3[0]; + w3_t[1] = w3[1]; + w3_t[2] = w3[2]; + w3_t[3] = w3[3]; + + /** + * md5 + */ + + u32x a = MD5M_A; + u32x b = MD5M_B; + u32x c = MD5M_C; + u32x d = MD5M_D; + + MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13); + + u32x t; + + MD5_STEP (MD5_H1, a, b, c, d, w1_t[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w2_t[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w2_t[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w3_t[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w0_t[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w1_t[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w1_t[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w2_t[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w3_t[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w0_t[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w0_t[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w1_t[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, w2_t[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, w3_t[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, w3_t[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, w0_t[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33); + + a += make_u32x (MD5M_A); + b += make_u32x (MD5M_B); + c += make_u32x (MD5M_C); + d += make_u32x (MD5M_D); + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + // md5_final_vector + + const int pos = ctx.len & 63; + + append_0x80_4x4 (ctx.w0, ctx.w1, ctx.w2, ctx.w3, pos); + + if (pos >= 56) + { + md5_transform_vector (ctx.w0, ctx.w1, ctx.w2, ctx.w3, ctx.h); + + ctx.w0[0] = 0; + ctx.w0[1] = 0; + ctx.w0[2] = 0; + ctx.w0[3] = 0; + ctx.w1[0] = 0; + ctx.w1[1] = 0; + ctx.w1[2] = 0; + ctx.w1[3] = 0; + ctx.w2[0] = 0; + ctx.w2[1] = 0; + ctx.w2[2] = 0; + ctx.w2[3] = 0; + ctx.w3[0] = 0; + ctx.w3[1] = 0; + ctx.w3[2] = 0; + ctx.w3[3] = 0; + } + + ctx.w3[2] = ctx.len * 8; + ctx.w3[3] = 0; + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w0[0], MD5C00, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w0[1], MD5C01, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w0[2], MD5C02, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w0[3], MD5C03, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w1[0], MD5C04, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w1[1], MD5C05, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w1[2], MD5C06, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w1[3], MD5C07, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w2[0], MD5C08, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w2[1], MD5C09, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w2[2], MD5C0a, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w2[3], MD5C0b, MD5S03); + MD5_STEP (MD5_Fo, a, b, c, d, ctx.w3[0], MD5C0c, MD5S00); + MD5_STEP (MD5_Fo, d, a, b, c, ctx.w3[1], MD5C0d, MD5S01); + MD5_STEP (MD5_Fo, c, d, a, b, ctx.w3[2], MD5C0e, MD5S02); + MD5_STEP (MD5_Fo, b, c, d, a, ctx.w3[3], MD5C0f, MD5S03); + + MD5_STEP (MD5_Go, a, b, c, d, ctx.w0[1], MD5C10, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w1[2], MD5C11, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w2[3], MD5C12, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w0[0], MD5C13, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w1[1], MD5C14, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w2[2], MD5C15, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w3[3], MD5C16, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w1[0], MD5C17, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w2[1], MD5C18, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w3[2], MD5C19, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w0[3], MD5C1a, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w2[0], MD5C1b, MD5S13); + MD5_STEP (MD5_Go, a, b, c, d, ctx.w3[1], MD5C1c, MD5S10); + MD5_STEP (MD5_Go, d, a, b, c, ctx.w0[2], MD5C1d, MD5S11); + MD5_STEP (MD5_Go, c, d, a, b, ctx.w1[3], MD5C1e, MD5S12); + MD5_STEP (MD5_Go, b, c, d, a, ctx.w3[0], MD5C1f, MD5S13); + + MD5_STEP (MD5_H1, a, b, c, d, ctx.w1[1], MD5C20, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w2[0], MD5C21, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w2[3], MD5C22, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w3[2], MD5C23, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w0[1], MD5C24, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w1[0], MD5C25, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w1[3], MD5C26, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w2[2], MD5C27, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w3[1], MD5C28, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w0[0], MD5C29, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w0[3], MD5C2a, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w1[2], MD5C2b, MD5S23); + MD5_STEP (MD5_H1, a, b, c, d, ctx.w2[1], MD5C2c, MD5S20); + MD5_STEP (MD5_H2, d, a, b, c, ctx.w3[0], MD5C2d, MD5S21); + MD5_STEP (MD5_H1, c, d, a, b, ctx.w3[3], MD5C2e, MD5S22); + MD5_STEP (MD5_H2, b, c, d, a, ctx.w0[2], MD5C2f, MD5S23); + + MD5_STEP (MD5_I , a, b, c, d, ctx.w0[0], MD5C30, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w1[3], MD5C31, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w3[2], MD5C32, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w1[1], MD5C33, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w3[0], MD5C34, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w0[3], MD5C35, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w2[2], MD5C36, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w0[1], MD5C37, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w2[0], MD5C38, MD5S30); + MD5_STEP (MD5_I , d, a, b, c, ctx.w3[3], MD5C39, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w1[2], MD5C3a, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w3[1], MD5C3b, MD5S33); + MD5_STEP (MD5_I , a, b, c, d, ctx.w1[0], MD5C3c, MD5S30); + + if (MATCHES_NONE_VS ((a + ctx.h[0] - make_u32x (MD5M_A)), search[0])) continue; + + MD5_STEP (MD5_I , d, a, b, c, ctx.w2[3], MD5C3d, MD5S31); + MD5_STEP (MD5_I , c, d, a, b, ctx.w0[2], MD5C3e, MD5S32); + MD5_STEP (MD5_I , b, c, d, a, ctx.w2[1], MD5C3f, MD5S33); + + a += ctx.h[0] - make_u32x (MD5M_A); + b += ctx.h[1] - make_u32x (MD5M_B); + c += ctx.h[2] - make_u32x (MD5M_C); + d += ctx.h[3] - make_u32x (MD5M_D); + + COMPARE_S_SIMD (a, d, c, b); + } +} + +KERNEL_FQ void m32300_m04 (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m32300_m08 (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m32300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m32300_m16 (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m32300m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m32300_s04 (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m32300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m32300_s08 (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + + u32 w3[4]; + + w3[0] = 0; + w3[1] = 0; + w3[2] = pws[gid].i[14]; + w3[3] = 0; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * main + */ + + m32300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} + +KERNEL_FQ void m32300_s16 (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * modifier + */ + + u32 w0[4]; + + w0[0] = pws[gid].i[ 0]; + w0[1] = pws[gid].i[ 1]; + w0[2] = pws[gid].i[ 2]; + w0[3] = pws[gid].i[ 3]; + + u32 w1[4]; + + w1[0] = pws[gid].i[ 4]; + w1[1] = pws[gid].i[ 5]; + w1[2] = pws[gid].i[ 6]; + w1[3] = pws[gid].i[ 7]; + + u32 w2[4]; + + w2[0] = pws[gid].i[ 8]; + w2[1] = pws[gid].i[ 9]; + w2[2] = pws[gid].i[10]; + w2[3] = pws[gid].i[11]; + + u32 w3[4]; + + w3[0] = pws[gid].i[12]; + w3[1] = pws[gid].i[13]; + w3[2] = pws[gid].i[14]; + w3[3] = pws[gid].i[15]; + + const u32 pw_len = pws[gid].pw_len & 63; + + /** + * main + */ + + m32300s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz, l_bin2asc); +} diff --git a/OpenCL/m32300_a3-pure.cl b/OpenCL/m32300_a3-pure.cl new file mode 100644 index 000000000..1345df59d --- /dev/null +++ b/OpenCL/m32300_a3-pure.cl @@ -0,0 +1,408 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_md5.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +KERNEL_FQ void m32300_mxx (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /* + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32300_sxx (KERN_ATTR_VECTOR_ESALT (md5_triple_salt_t)) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /* + * bin2asc uppercase table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt1_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_len; + + u32x salt1_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt1_len; i += 4, idx += 1) + { + salt1_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt1_buf[idx]; + } + + const u32 salt2_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_len; + + u32x salt2_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt2_len; i += 4, idx += 1) + { + salt2_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt2_buf[idx]; + } + + const u32 salt3_len = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_len; + + u32x salt3_buf[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt3_len; i += 4, idx += 1) + { + salt3_buf[idx] = esalt_bufs[DIGESTS_OFFSET_HOST].salt3_buf[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + md5_ctx_vector_t ctx0; + + md5_init_vector (&ctx0); + + md5_update_vector (&ctx0, w, pw_len); + + md5_final_vector (&ctx0); + + u32x a = ctx0.h[0]; + u32x b = ctx0.h[1]; + u32x c = ctx0.h[2]; + u32x d = ctx0.h[3]; + + md5_ctx_vector_t ctx; + + md5_init_vector (&ctx); + + ctx.w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ctx.w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ctx.w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ctx.w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ctx.w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ctx.w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ctx.w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ctx.w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ctx.len = 32; + + md5_update_vector (&ctx, salt1_buf, salt1_len); + + md5_final_vector (&ctx); + + a = ctx.h[0]; + b = ctx.h[1]; + c = ctx.h[2]; + d = ctx.h[3]; + + md5_init_vector (&ctx); + + md5_update_vector (&ctx, salt2_buf, salt2_len); + + u32x ww0[4]; + u32x ww1[4]; + u32x ww2[4]; + u32x ww3[4]; + + ww0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0 + | uint_to_hex_lower8 ((a >> 8) & 255) << 16; + ww0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0 + | uint_to_hex_lower8 ((a >> 24) & 255) << 16; + ww0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0 + | uint_to_hex_lower8 ((b >> 8) & 255) << 16; + ww0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0 + | uint_to_hex_lower8 ((b >> 24) & 255) << 16; + ww1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0 + | uint_to_hex_lower8 ((c >> 8) & 255) << 16; + ww1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0 + | uint_to_hex_lower8 ((c >> 24) & 255) << 16; + ww1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0 + | uint_to_hex_lower8 ((d >> 8) & 255) << 16; + ww1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0 + | uint_to_hex_lower8 ((d >> 24) & 255) << 16; + + ww2[0] = 0; + ww2[1] = 0; + ww2[2] = 0; + ww2[3] = 0; + ww3[0] = 0; + ww3[1] = 0; + ww3[2] = 0; + ww3[3] = 0; + + md5_update_vector_64 (&ctx, ww0, ww1, ww2, ww3, 32); + + md5_update_vector (&ctx, salt3_buf, salt3_len); + + md5_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32410_a0-pure.cl b/OpenCL/m32410_a0-pure.cl new file mode 100644 index 000000000..864468195 --- /dev/null +++ b/OpenCL/m32410_a0-pure.cl @@ -0,0 +1,369 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32410_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha512_final (&ctx0); + + const u64 a = ctx0.h[0]; + const u64 b = ctx0.h[1]; + const u64 c = ctx0.h[2]; + const u64 d = ctx0.h[3]; + const u64 e = ctx0.h[4]; + const u64 f = ctx0.h[5]; + const u64 g = ctx0.h[6]; + const u64 h = ctx0.h[7]; + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 56) & 255) << 16 + | uint_to_hex_lower8 ((a >> 48) & 255) << 0; + w0[1] = uint_to_hex_lower8 ((a >> 40) & 255) << 16 + | uint_to_hex_lower8 ((a >> 32) & 255) << 0; + w0[2] = uint_to_hex_lower8 ((a >> 24) & 255) << 16 + | uint_to_hex_lower8 ((a >> 16) & 255) << 0; + w0[3] = uint_to_hex_lower8 ((a >> 8) & 255) << 16 + | uint_to_hex_lower8 ((a >> 0) & 255) << 0; + w1[0] = uint_to_hex_lower8 ((b >> 56) & 255) << 16 + | uint_to_hex_lower8 ((b >> 48) & 255) << 0; + w1[1] = uint_to_hex_lower8 ((b >> 40) & 255) << 16 + | uint_to_hex_lower8 ((b >> 32) & 255) << 0; + w1[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 16 + | uint_to_hex_lower8 ((b >> 16) & 255) << 0; + w1[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 16 + | uint_to_hex_lower8 ((b >> 0) & 255) << 0; + w2[0] = uint_to_hex_lower8 ((c >> 56) & 255) << 16 + | uint_to_hex_lower8 ((c >> 48) & 255) << 0; + w2[1] = uint_to_hex_lower8 ((c >> 40) & 255) << 16 + | uint_to_hex_lower8 ((c >> 32) & 255) << 0; + w2[2] = uint_to_hex_lower8 ((c >> 24) & 255) << 16 + | uint_to_hex_lower8 ((c >> 16) & 255) << 0; + w2[3] = uint_to_hex_lower8 ((c >> 8) & 255) << 16 + | uint_to_hex_lower8 ((c >> 0) & 255) << 0; + w3[0] = uint_to_hex_lower8 ((d >> 56) & 255) << 16 + | uint_to_hex_lower8 ((d >> 48) & 255) << 0; + w3[1] = uint_to_hex_lower8 ((d >> 40) & 255) << 16 + | uint_to_hex_lower8 ((d >> 32) & 255) << 0; + w3[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 16 + | uint_to_hex_lower8 ((d >> 16) & 255) << 0; + w3[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 16 + | uint_to_hex_lower8 ((d >> 0) & 255) << 0; + w4[0] = uint_to_hex_lower8 ((e >> 56) & 255) << 16 + | uint_to_hex_lower8 ((e >> 48) & 255) << 0; + w4[1] = uint_to_hex_lower8 ((e >> 40) & 255) << 16 + | uint_to_hex_lower8 ((e >> 32) & 255) << 0; + w4[2] = uint_to_hex_lower8 ((e >> 24) & 255) << 16 + | uint_to_hex_lower8 ((e >> 16) & 255) << 0; + w4[3] = uint_to_hex_lower8 ((e >> 8) & 255) << 16 + | uint_to_hex_lower8 ((e >> 0) & 255) << 0; + w5[0] = uint_to_hex_lower8 ((f >> 56) & 255) << 16 + | uint_to_hex_lower8 ((f >> 48) & 255) << 0; + w5[1] = uint_to_hex_lower8 ((f >> 40) & 255) << 16 + | uint_to_hex_lower8 ((f >> 32) & 255) << 0; + w5[2] = uint_to_hex_lower8 ((f >> 24) & 255) << 16 + | uint_to_hex_lower8 ((f >> 16) & 255) << 0; + w5[3] = uint_to_hex_lower8 ((f >> 8) & 255) << 16 + | uint_to_hex_lower8 ((f >> 0) & 255) << 0; + w6[0] = uint_to_hex_lower8 ((g >> 56) & 255) << 16 + | uint_to_hex_lower8 ((g >> 48) & 255) << 0; + w6[1] = uint_to_hex_lower8 ((g >> 40) & 255) << 16 + | uint_to_hex_lower8 ((g >> 32) & 255) << 0; + w6[2] = uint_to_hex_lower8 ((g >> 24) & 255) << 16 + | uint_to_hex_lower8 ((g >> 16) & 255) << 0; + w6[3] = uint_to_hex_lower8 ((g >> 8) & 255) << 16 + | uint_to_hex_lower8 ((g >> 0) & 255) << 0; + w7[0] = uint_to_hex_lower8 ((h >> 56) & 255) << 16 + | uint_to_hex_lower8 ((h >> 48) & 255) << 0; + w7[1] = uint_to_hex_lower8 ((h >> 40) & 255) << 16 + | uint_to_hex_lower8 ((h >> 32) & 255) << 0; + w7[2] = uint_to_hex_lower8 ((h >> 24) & 255) << 16 + | uint_to_hex_lower8 ((h >> 16) & 255) << 0; + w7[3] = uint_to_hex_lower8 ((h >> 8) & 255) << 16 + | uint_to_hex_lower8 ((h >> 0) & 255) << 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 128); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32410_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha512_final (&ctx0); + + const u64 a = ctx0.h[0]; + const u64 b = ctx0.h[1]; + const u64 c = ctx0.h[2]; + const u64 d = ctx0.h[3]; + const u64 e = ctx0.h[4]; + const u64 f = ctx0.h[5]; + const u64 g = ctx0.h[6]; + const u64 h = ctx0.h[7]; + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 56) & 255) << 16 + | uint_to_hex_lower8 ((a >> 48) & 255) << 0; + w0[1] = uint_to_hex_lower8 ((a >> 40) & 255) << 16 + | uint_to_hex_lower8 ((a >> 32) & 255) << 0; + w0[2] = uint_to_hex_lower8 ((a >> 24) & 255) << 16 + | uint_to_hex_lower8 ((a >> 16) & 255) << 0; + w0[3] = uint_to_hex_lower8 ((a >> 8) & 255) << 16 + | uint_to_hex_lower8 ((a >> 0) & 255) << 0; + w1[0] = uint_to_hex_lower8 ((b >> 56) & 255) << 16 + | uint_to_hex_lower8 ((b >> 48) & 255) << 0; + w1[1] = uint_to_hex_lower8 ((b >> 40) & 255) << 16 + | uint_to_hex_lower8 ((b >> 32) & 255) << 0; + w1[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 16 + | uint_to_hex_lower8 ((b >> 16) & 255) << 0; + w1[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 16 + | uint_to_hex_lower8 ((b >> 0) & 255) << 0; + w2[0] = uint_to_hex_lower8 ((c >> 56) & 255) << 16 + | uint_to_hex_lower8 ((c >> 48) & 255) << 0; + w2[1] = uint_to_hex_lower8 ((c >> 40) & 255) << 16 + | uint_to_hex_lower8 ((c >> 32) & 255) << 0; + w2[2] = uint_to_hex_lower8 ((c >> 24) & 255) << 16 + | uint_to_hex_lower8 ((c >> 16) & 255) << 0; + w2[3] = uint_to_hex_lower8 ((c >> 8) & 255) << 16 + | uint_to_hex_lower8 ((c >> 0) & 255) << 0; + w3[0] = uint_to_hex_lower8 ((d >> 56) & 255) << 16 + | uint_to_hex_lower8 ((d >> 48) & 255) << 0; + w3[1] = uint_to_hex_lower8 ((d >> 40) & 255) << 16 + | uint_to_hex_lower8 ((d >> 32) & 255) << 0; + w3[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 16 + | uint_to_hex_lower8 ((d >> 16) & 255) << 0; + w3[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 16 + | uint_to_hex_lower8 ((d >> 0) & 255) << 0; + w4[0] = uint_to_hex_lower8 ((e >> 56) & 255) << 16 + | uint_to_hex_lower8 ((e >> 48) & 255) << 0; + w4[1] = uint_to_hex_lower8 ((e >> 40) & 255) << 16 + | uint_to_hex_lower8 ((e >> 32) & 255) << 0; + w4[2] = uint_to_hex_lower8 ((e >> 24) & 255) << 16 + | uint_to_hex_lower8 ((e >> 16) & 255) << 0; + w4[3] = uint_to_hex_lower8 ((e >> 8) & 255) << 16 + | uint_to_hex_lower8 ((e >> 0) & 255) << 0; + w5[0] = uint_to_hex_lower8 ((f >> 56) & 255) << 16 + | uint_to_hex_lower8 ((f >> 48) & 255) << 0; + w5[1] = uint_to_hex_lower8 ((f >> 40) & 255) << 16 + | uint_to_hex_lower8 ((f >> 32) & 255) << 0; + w5[2] = uint_to_hex_lower8 ((f >> 24) & 255) << 16 + | uint_to_hex_lower8 ((f >> 16) & 255) << 0; + w5[3] = uint_to_hex_lower8 ((f >> 8) & 255) << 16 + | uint_to_hex_lower8 ((f >> 0) & 255) << 0; + w6[0] = uint_to_hex_lower8 ((g >> 56) & 255) << 16 + | uint_to_hex_lower8 ((g >> 48) & 255) << 0; + w6[1] = uint_to_hex_lower8 ((g >> 40) & 255) << 16 + | uint_to_hex_lower8 ((g >> 32) & 255) << 0; + w6[2] = uint_to_hex_lower8 ((g >> 24) & 255) << 16 + | uint_to_hex_lower8 ((g >> 16) & 255) << 0; + w6[3] = uint_to_hex_lower8 ((g >> 8) & 255) << 16 + | uint_to_hex_lower8 ((g >> 0) & 255) << 0; + w7[0] = uint_to_hex_lower8 ((h >> 56) & 255) << 16 + | uint_to_hex_lower8 ((h >> 48) & 255) << 0; + w7[1] = uint_to_hex_lower8 ((h >> 40) & 255) << 16 + | uint_to_hex_lower8 ((h >> 32) & 255) << 0; + w7[2] = uint_to_hex_lower8 ((h >> 24) & 255) << 16 + | uint_to_hex_lower8 ((h >> 16) & 255) << 0; + w7[3] = uint_to_hex_lower8 ((h >> 8) & 255) << 16 + | uint_to_hex_lower8 ((h >> 0) & 255) << 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 128); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32410_a1-pure.cl b/OpenCL/m32410_a1-pure.cl new file mode 100644 index 000000000..65dccc7d6 --- /dev/null +++ b/OpenCL/m32410_a1-pure.cl @@ -0,0 +1,363 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32410_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha512_ctx_t ctx1 = ctx0; + + sha512_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha512_final (&ctx1); + + const u64 a = ctx1.h[0]; + const u64 b = ctx1.h[1]; + const u64 c = ctx1.h[2]; + const u64 d = ctx1.h[3]; + const u64 e = ctx1.h[4]; + const u64 f = ctx1.h[5]; + const u64 g = ctx1.h[6]; + const u64 h = ctx1.h[7]; + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 56) & 255) << 16 + | uint_to_hex_lower8 ((a >> 48) & 255) << 0; + w0[1] = uint_to_hex_lower8 ((a >> 40) & 255) << 16 + | uint_to_hex_lower8 ((a >> 32) & 255) << 0; + w0[2] = uint_to_hex_lower8 ((a >> 24) & 255) << 16 + | uint_to_hex_lower8 ((a >> 16) & 255) << 0; + w0[3] = uint_to_hex_lower8 ((a >> 8) & 255) << 16 + | uint_to_hex_lower8 ((a >> 0) & 255) << 0; + w1[0] = uint_to_hex_lower8 ((b >> 56) & 255) << 16 + | uint_to_hex_lower8 ((b >> 48) & 255) << 0; + w1[1] = uint_to_hex_lower8 ((b >> 40) & 255) << 16 + | uint_to_hex_lower8 ((b >> 32) & 255) << 0; + w1[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 16 + | uint_to_hex_lower8 ((b >> 16) & 255) << 0; + w1[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 16 + | uint_to_hex_lower8 ((b >> 0) & 255) << 0; + w2[0] = uint_to_hex_lower8 ((c >> 56) & 255) << 16 + | uint_to_hex_lower8 ((c >> 48) & 255) << 0; + w2[1] = uint_to_hex_lower8 ((c >> 40) & 255) << 16 + | uint_to_hex_lower8 ((c >> 32) & 255) << 0; + w2[2] = uint_to_hex_lower8 ((c >> 24) & 255) << 16 + | uint_to_hex_lower8 ((c >> 16) & 255) << 0; + w2[3] = uint_to_hex_lower8 ((c >> 8) & 255) << 16 + | uint_to_hex_lower8 ((c >> 0) & 255) << 0; + w3[0] = uint_to_hex_lower8 ((d >> 56) & 255) << 16 + | uint_to_hex_lower8 ((d >> 48) & 255) << 0; + w3[1] = uint_to_hex_lower8 ((d >> 40) & 255) << 16 + | uint_to_hex_lower8 ((d >> 32) & 255) << 0; + w3[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 16 + | uint_to_hex_lower8 ((d >> 16) & 255) << 0; + w3[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 16 + | uint_to_hex_lower8 ((d >> 0) & 255) << 0; + w4[0] = uint_to_hex_lower8 ((e >> 56) & 255) << 16 + | uint_to_hex_lower8 ((e >> 48) & 255) << 0; + w4[1] = uint_to_hex_lower8 ((e >> 40) & 255) << 16 + | uint_to_hex_lower8 ((e >> 32) & 255) << 0; + w4[2] = uint_to_hex_lower8 ((e >> 24) & 255) << 16 + | uint_to_hex_lower8 ((e >> 16) & 255) << 0; + w4[3] = uint_to_hex_lower8 ((e >> 8) & 255) << 16 + | uint_to_hex_lower8 ((e >> 0) & 255) << 0; + w5[0] = uint_to_hex_lower8 ((f >> 56) & 255) << 16 + | uint_to_hex_lower8 ((f >> 48) & 255) << 0; + w5[1] = uint_to_hex_lower8 ((f >> 40) & 255) << 16 + | uint_to_hex_lower8 ((f >> 32) & 255) << 0; + w5[2] = uint_to_hex_lower8 ((f >> 24) & 255) << 16 + | uint_to_hex_lower8 ((f >> 16) & 255) << 0; + w5[3] = uint_to_hex_lower8 ((f >> 8) & 255) << 16 + | uint_to_hex_lower8 ((f >> 0) & 255) << 0; + w6[0] = uint_to_hex_lower8 ((g >> 56) & 255) << 16 + | uint_to_hex_lower8 ((g >> 48) & 255) << 0; + w6[1] = uint_to_hex_lower8 ((g >> 40) & 255) << 16 + | uint_to_hex_lower8 ((g >> 32) & 255) << 0; + w6[2] = uint_to_hex_lower8 ((g >> 24) & 255) << 16 + | uint_to_hex_lower8 ((g >> 16) & 255) << 0; + w6[3] = uint_to_hex_lower8 ((g >> 8) & 255) << 16 + | uint_to_hex_lower8 ((g >> 0) & 255) << 0; + w7[0] = uint_to_hex_lower8 ((h >> 56) & 255) << 16 + | uint_to_hex_lower8 ((h >> 48) & 255) << 0; + w7[1] = uint_to_hex_lower8 ((h >> 40) & 255) << 16 + | uint_to_hex_lower8 ((h >> 32) & 255) << 0; + w7[2] = uint_to_hex_lower8 ((h >> 24) & 255) << 16 + | uint_to_hex_lower8 ((h >> 16) & 255) << 0; + w7[3] = uint_to_hex_lower8 ((h >> 8) & 255) << 16 + | uint_to_hex_lower8 ((h >> 0) & 255) << 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 128); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32410_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha512_ctx_t ctx1 = ctx0; + + sha512_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha512_final (&ctx1); + + const u64 a = ctx1.h[0]; + const u64 b = ctx1.h[1]; + const u64 c = ctx1.h[2]; + const u64 d = ctx1.h[3]; + const u64 e = ctx1.h[4]; + const u64 f = ctx1.h[5]; + const u64 g = ctx1.h[6]; + const u64 h = ctx1.h[7]; + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 56) & 255) << 16 + | uint_to_hex_lower8 ((a >> 48) & 255) << 0; + w0[1] = uint_to_hex_lower8 ((a >> 40) & 255) << 16 + | uint_to_hex_lower8 ((a >> 32) & 255) << 0; + w0[2] = uint_to_hex_lower8 ((a >> 24) & 255) << 16 + | uint_to_hex_lower8 ((a >> 16) & 255) << 0; + w0[3] = uint_to_hex_lower8 ((a >> 8) & 255) << 16 + | uint_to_hex_lower8 ((a >> 0) & 255) << 0; + w1[0] = uint_to_hex_lower8 ((b >> 56) & 255) << 16 + | uint_to_hex_lower8 ((b >> 48) & 255) << 0; + w1[1] = uint_to_hex_lower8 ((b >> 40) & 255) << 16 + | uint_to_hex_lower8 ((b >> 32) & 255) << 0; + w1[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 16 + | uint_to_hex_lower8 ((b >> 16) & 255) << 0; + w1[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 16 + | uint_to_hex_lower8 ((b >> 0) & 255) << 0; + w2[0] = uint_to_hex_lower8 ((c >> 56) & 255) << 16 + | uint_to_hex_lower8 ((c >> 48) & 255) << 0; + w2[1] = uint_to_hex_lower8 ((c >> 40) & 255) << 16 + | uint_to_hex_lower8 ((c >> 32) & 255) << 0; + w2[2] = uint_to_hex_lower8 ((c >> 24) & 255) << 16 + | uint_to_hex_lower8 ((c >> 16) & 255) << 0; + w2[3] = uint_to_hex_lower8 ((c >> 8) & 255) << 16 + | uint_to_hex_lower8 ((c >> 0) & 255) << 0; + w3[0] = uint_to_hex_lower8 ((d >> 56) & 255) << 16 + | uint_to_hex_lower8 ((d >> 48) & 255) << 0; + w3[1] = uint_to_hex_lower8 ((d >> 40) & 255) << 16 + | uint_to_hex_lower8 ((d >> 32) & 255) << 0; + w3[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 16 + | uint_to_hex_lower8 ((d >> 16) & 255) << 0; + w3[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 16 + | uint_to_hex_lower8 ((d >> 0) & 255) << 0; + w4[0] = uint_to_hex_lower8 ((e >> 56) & 255) << 16 + | uint_to_hex_lower8 ((e >> 48) & 255) << 0; + w4[1] = uint_to_hex_lower8 ((e >> 40) & 255) << 16 + | uint_to_hex_lower8 ((e >> 32) & 255) << 0; + w4[2] = uint_to_hex_lower8 ((e >> 24) & 255) << 16 + | uint_to_hex_lower8 ((e >> 16) & 255) << 0; + w4[3] = uint_to_hex_lower8 ((e >> 8) & 255) << 16 + | uint_to_hex_lower8 ((e >> 0) & 255) << 0; + w5[0] = uint_to_hex_lower8 ((f >> 56) & 255) << 16 + | uint_to_hex_lower8 ((f >> 48) & 255) << 0; + w5[1] = uint_to_hex_lower8 ((f >> 40) & 255) << 16 + | uint_to_hex_lower8 ((f >> 32) & 255) << 0; + w5[2] = uint_to_hex_lower8 ((f >> 24) & 255) << 16 + | uint_to_hex_lower8 ((f >> 16) & 255) << 0; + w5[3] = uint_to_hex_lower8 ((f >> 8) & 255) << 16 + | uint_to_hex_lower8 ((f >> 0) & 255) << 0; + w6[0] = uint_to_hex_lower8 ((g >> 56) & 255) << 16 + | uint_to_hex_lower8 ((g >> 48) & 255) << 0; + w6[1] = uint_to_hex_lower8 ((g >> 40) & 255) << 16 + | uint_to_hex_lower8 ((g >> 32) & 255) << 0; + w6[2] = uint_to_hex_lower8 ((g >> 24) & 255) << 16 + | uint_to_hex_lower8 ((g >> 16) & 255) << 0; + w6[3] = uint_to_hex_lower8 ((g >> 8) & 255) << 16 + | uint_to_hex_lower8 ((g >> 0) & 255) << 0; + w7[0] = uint_to_hex_lower8 ((h >> 56) & 255) << 16 + | uint_to_hex_lower8 ((h >> 48) & 255) << 0; + w7[1] = uint_to_hex_lower8 ((h >> 40) & 255) << 16 + | uint_to_hex_lower8 ((h >> 32) & 255) << 0; + w7[2] = uint_to_hex_lower8 ((h >> 24) & 255) << 16 + | uint_to_hex_lower8 ((h >> 16) & 255) << 0; + w7[3] = uint_to_hex_lower8 ((h >> 8) & 255) << 16 + | uint_to_hex_lower8 ((h >> 0) & 255) << 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 128); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32410_a3-pure.cl b/OpenCL/m32410_a3-pure.cl new file mode 100644 index 000000000..32b0c17d9 --- /dev/null +++ b/OpenCL/m32410_a3-pure.cl @@ -0,0 +1,389 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +#if VECT_SIZE == 1 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i)]) +#elif VECT_SIZE == 2 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1]) +#elif VECT_SIZE == 4 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3]) +#elif VECT_SIZE == 8 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7]) +#elif VECT_SIZE == 16 +#define uint_to_hex_lower8(i) make_u32x (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf]) +#endif + +KERNEL_FQ void m32410_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0_final = w0l | w0r; + + w[0] = w0_final; + + sha512_ctx_vector_t ctx0; + + sha512_init_vector (&ctx0); + + sha512_update_vector (&ctx0, w, pw_len); + + sha512_final_vector (&ctx0); + + const u64x a = ctx0.h[0]; + const u64x b = ctx0.h[1]; + const u64x c = ctx0.h[2]; + const u64x d = ctx0.h[3]; + const u64x e = ctx0.h[4]; + const u64x f = ctx0.h[5]; + const u64x g = ctx0.h[6]; + const u64x h = ctx0.h[7]; + + sha512_ctx_vector_t ctx; + + sha512_init_vector (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 56) & 255) << 16 + | uint_to_hex_lower8 ((a >> 48) & 255) << 0; + w0[1] = uint_to_hex_lower8 ((a >> 40) & 255) << 16 + | uint_to_hex_lower8 ((a >> 32) & 255) << 0; + w0[2] = uint_to_hex_lower8 ((a >> 24) & 255) << 16 + | uint_to_hex_lower8 ((a >> 16) & 255) << 0; + w0[3] = uint_to_hex_lower8 ((a >> 8) & 255) << 16 + | uint_to_hex_lower8 ((a >> 0) & 255) << 0; + w1[0] = uint_to_hex_lower8 ((b >> 56) & 255) << 16 + | uint_to_hex_lower8 ((b >> 48) & 255) << 0; + w1[1] = uint_to_hex_lower8 ((b >> 40) & 255) << 16 + | uint_to_hex_lower8 ((b >> 32) & 255) << 0; + w1[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 16 + | uint_to_hex_lower8 ((b >> 16) & 255) << 0; + w1[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 16 + | uint_to_hex_lower8 ((b >> 0) & 255) << 0; + w2[0] = uint_to_hex_lower8 ((c >> 56) & 255) << 16 + | uint_to_hex_lower8 ((c >> 48) & 255) << 0; + w2[1] = uint_to_hex_lower8 ((c >> 40) & 255) << 16 + | uint_to_hex_lower8 ((c >> 32) & 255) << 0; + w2[2] = uint_to_hex_lower8 ((c >> 24) & 255) << 16 + | uint_to_hex_lower8 ((c >> 16) & 255) << 0; + w2[3] = uint_to_hex_lower8 ((c >> 8) & 255) << 16 + | uint_to_hex_lower8 ((c >> 0) & 255) << 0; + w3[0] = uint_to_hex_lower8 ((d >> 56) & 255) << 16 + | uint_to_hex_lower8 ((d >> 48) & 255) << 0; + w3[1] = uint_to_hex_lower8 ((d >> 40) & 255) << 16 + | uint_to_hex_lower8 ((d >> 32) & 255) << 0; + w3[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 16 + | uint_to_hex_lower8 ((d >> 16) & 255) << 0; + w3[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 16 + | uint_to_hex_lower8 ((d >> 0) & 255) << 0; + w4[0] = uint_to_hex_lower8 ((e >> 56) & 255) << 16 + | uint_to_hex_lower8 ((e >> 48) & 255) << 0; + w4[1] = uint_to_hex_lower8 ((e >> 40) & 255) << 16 + | uint_to_hex_lower8 ((e >> 32) & 255) << 0; + w4[2] = uint_to_hex_lower8 ((e >> 24) & 255) << 16 + | uint_to_hex_lower8 ((e >> 16) & 255) << 0; + w4[3] = uint_to_hex_lower8 ((e >> 8) & 255) << 16 + | uint_to_hex_lower8 ((e >> 0) & 255) << 0; + w5[0] = uint_to_hex_lower8 ((f >> 56) & 255) << 16 + | uint_to_hex_lower8 ((f >> 48) & 255) << 0; + w5[1] = uint_to_hex_lower8 ((f >> 40) & 255) << 16 + | uint_to_hex_lower8 ((f >> 32) & 255) << 0; + w5[2] = uint_to_hex_lower8 ((f >> 24) & 255) << 16 + | uint_to_hex_lower8 ((f >> 16) & 255) << 0; + w5[3] = uint_to_hex_lower8 ((f >> 8) & 255) << 16 + | uint_to_hex_lower8 ((f >> 0) & 255) << 0; + w6[0] = uint_to_hex_lower8 ((g >> 56) & 255) << 16 + | uint_to_hex_lower8 ((g >> 48) & 255) << 0; + w6[1] = uint_to_hex_lower8 ((g >> 40) & 255) << 16 + | uint_to_hex_lower8 ((g >> 32) & 255) << 0; + w6[2] = uint_to_hex_lower8 ((g >> 24) & 255) << 16 + | uint_to_hex_lower8 ((g >> 16) & 255) << 0; + w6[3] = uint_to_hex_lower8 ((g >> 8) & 255) << 16 + | uint_to_hex_lower8 ((g >> 0) & 255) << 0; + w7[0] = uint_to_hex_lower8 ((h >> 56) & 255) << 16 + | uint_to_hex_lower8 ((h >> 48) & 255) << 0; + w7[1] = uint_to_hex_lower8 ((h >> 40) & 255) << 16 + | uint_to_hex_lower8 ((h >> 32) & 255) << 0; + w7[2] = uint_to_hex_lower8 ((h >> 24) & 255) << 16 + | uint_to_hex_lower8 ((h >> 16) & 255) << 0; + w7[3] = uint_to_hex_lower8 ((h >> 8) & 255) << 16 + | uint_to_hex_lower8 ((h >> 0) & 255) << 0; + + sha512_update_vector_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 128); + + sha512_update_vector (&ctx, s, salt_len); + + sha512_final_vector (&ctx); + + const u32x r0 = l32_from_64 (ctx.h[7]); + const u32x r1 = h32_from_64 (ctx.h[7]); + const u32x r2 = l32_from_64 (ctx.h[3]); + const u32x r3 = h32_from_64 (ctx.h[3]); + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32410_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * bin2asc table + */ + + LOCAL_VK u32 l_bin2asc[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + const u32 i0 = (i >> 0) & 15; + const u32 i1 = (i >> 4) & 15; + + l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 0 + | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 8; + } + + SYNC_THREADS (); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0_final = w0l | w0r; + + w[0] = w0_final; + + sha512_ctx_vector_t ctx0; + + sha512_init_vector (&ctx0); + + sha512_update_vector (&ctx0, w, pw_len); + + sha512_final_vector (&ctx0); + + const u64x a = ctx0.h[0]; + const u64x b = ctx0.h[1]; + const u64x c = ctx0.h[2]; + const u64x d = ctx0.h[3]; + const u64x e = ctx0.h[4]; + const u64x f = ctx0.h[5]; + const u64x g = ctx0.h[6]; + const u64x h = ctx0.h[7]; + + sha512_ctx_vector_t ctx; + + sha512_init_vector (&ctx); + + w0[0] = uint_to_hex_lower8 ((a >> 56) & 255) << 16 + | uint_to_hex_lower8 ((a >> 48) & 255) << 0; + w0[1] = uint_to_hex_lower8 ((a >> 40) & 255) << 16 + | uint_to_hex_lower8 ((a >> 32) & 255) << 0; + w0[2] = uint_to_hex_lower8 ((a >> 24) & 255) << 16 + | uint_to_hex_lower8 ((a >> 16) & 255) << 0; + w0[3] = uint_to_hex_lower8 ((a >> 8) & 255) << 16 + | uint_to_hex_lower8 ((a >> 0) & 255) << 0; + w1[0] = uint_to_hex_lower8 ((b >> 56) & 255) << 16 + | uint_to_hex_lower8 ((b >> 48) & 255) << 0; + w1[1] = uint_to_hex_lower8 ((b >> 40) & 255) << 16 + | uint_to_hex_lower8 ((b >> 32) & 255) << 0; + w1[2] = uint_to_hex_lower8 ((b >> 24) & 255) << 16 + | uint_to_hex_lower8 ((b >> 16) & 255) << 0; + w1[3] = uint_to_hex_lower8 ((b >> 8) & 255) << 16 + | uint_to_hex_lower8 ((b >> 0) & 255) << 0; + w2[0] = uint_to_hex_lower8 ((c >> 56) & 255) << 16 + | uint_to_hex_lower8 ((c >> 48) & 255) << 0; + w2[1] = uint_to_hex_lower8 ((c >> 40) & 255) << 16 + | uint_to_hex_lower8 ((c >> 32) & 255) << 0; + w2[2] = uint_to_hex_lower8 ((c >> 24) & 255) << 16 + | uint_to_hex_lower8 ((c >> 16) & 255) << 0; + w2[3] = uint_to_hex_lower8 ((c >> 8) & 255) << 16 + | uint_to_hex_lower8 ((c >> 0) & 255) << 0; + w3[0] = uint_to_hex_lower8 ((d >> 56) & 255) << 16 + | uint_to_hex_lower8 ((d >> 48) & 255) << 0; + w3[1] = uint_to_hex_lower8 ((d >> 40) & 255) << 16 + | uint_to_hex_lower8 ((d >> 32) & 255) << 0; + w3[2] = uint_to_hex_lower8 ((d >> 24) & 255) << 16 + | uint_to_hex_lower8 ((d >> 16) & 255) << 0; + w3[3] = uint_to_hex_lower8 ((d >> 8) & 255) << 16 + | uint_to_hex_lower8 ((d >> 0) & 255) << 0; + w4[0] = uint_to_hex_lower8 ((e >> 56) & 255) << 16 + | uint_to_hex_lower8 ((e >> 48) & 255) << 0; + w4[1] = uint_to_hex_lower8 ((e >> 40) & 255) << 16 + | uint_to_hex_lower8 ((e >> 32) & 255) << 0; + w4[2] = uint_to_hex_lower8 ((e >> 24) & 255) << 16 + | uint_to_hex_lower8 ((e >> 16) & 255) << 0; + w4[3] = uint_to_hex_lower8 ((e >> 8) & 255) << 16 + | uint_to_hex_lower8 ((e >> 0) & 255) << 0; + w5[0] = uint_to_hex_lower8 ((f >> 56) & 255) << 16 + | uint_to_hex_lower8 ((f >> 48) & 255) << 0; + w5[1] = uint_to_hex_lower8 ((f >> 40) & 255) << 16 + | uint_to_hex_lower8 ((f >> 32) & 255) << 0; + w5[2] = uint_to_hex_lower8 ((f >> 24) & 255) << 16 + | uint_to_hex_lower8 ((f >> 16) & 255) << 0; + w5[3] = uint_to_hex_lower8 ((f >> 8) & 255) << 16 + | uint_to_hex_lower8 ((f >> 0) & 255) << 0; + w6[0] = uint_to_hex_lower8 ((g >> 56) & 255) << 16 + | uint_to_hex_lower8 ((g >> 48) & 255) << 0; + w6[1] = uint_to_hex_lower8 ((g >> 40) & 255) << 16 + | uint_to_hex_lower8 ((g >> 32) & 255) << 0; + w6[2] = uint_to_hex_lower8 ((g >> 24) & 255) << 16 + | uint_to_hex_lower8 ((g >> 16) & 255) << 0; + w6[3] = uint_to_hex_lower8 ((g >> 8) & 255) << 16 + | uint_to_hex_lower8 ((g >> 0) & 255) << 0; + w7[0] = uint_to_hex_lower8 ((h >> 56) & 255) << 16 + | uint_to_hex_lower8 ((h >> 48) & 255) << 0; + w7[1] = uint_to_hex_lower8 ((h >> 40) & 255) << 16 + | uint_to_hex_lower8 ((h >> 32) & 255) << 0; + w7[2] = uint_to_hex_lower8 ((h >> 24) & 255) << 16 + | uint_to_hex_lower8 ((h >> 16) & 255) << 0; + w7[3] = uint_to_hex_lower8 ((h >> 8) & 255) << 16 + | uint_to_hex_lower8 ((h >> 0) & 255) << 0; + + sha512_update_vector_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 128); + + sha512_update_vector (&ctx, s, salt_len); + + sha512_final_vector (&ctx); + + const u32x r0 = l32_from_64 (ctx.h[7]); + const u32x r1 = h32_from_64 (ctx.h[7]); + const u32x r2 = l32_from_64 (ctx.h[3]); + const u32x r3 = h32_from_64 (ctx.h[3]); + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32420_a0-pure.cl b/OpenCL/m32420_a0-pure.cl new file mode 100644 index 000000000..79a7c2712 --- /dev/null +++ b/OpenCL/m32420_a0-pure.cl @@ -0,0 +1,241 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +KERNEL_FQ void m32420_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha512_final (&ctx0); + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = h32_from_64_S (ctx0.h[0]); + w0[1] = l32_from_64_S (ctx0.h[0]); + w0[2] = h32_from_64_S (ctx0.h[1]); + w0[3] = l32_from_64_S (ctx0.h[1]); + w1[0] = h32_from_64_S (ctx0.h[2]); + w1[1] = l32_from_64_S (ctx0.h[2]); + w1[2] = h32_from_64_S (ctx0.h[3]); + w1[3] = l32_from_64_S (ctx0.h[3]); + w2[0] = h32_from_64_S (ctx0.h[4]); + w2[1] = l32_from_64_S (ctx0.h[4]); + w2[2] = h32_from_64_S (ctx0.h[5]); + w2[3] = l32_from_64_S (ctx0.h[5]); + w3[0] = h32_from_64_S (ctx0.h[6]); + w3[1] = l32_from_64_S (ctx0.h[6]); + w3[2] = h32_from_64_S (ctx0.h[7]); + w3[3] = l32_from_64_S (ctx0.h[7]); + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 64); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32420_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + COPY_PW (pws[gid]); + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_swap (&ctx0, tmp.i, tmp.pw_len); + + sha512_final (&ctx0); + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = h32_from_64_S (ctx0.h[0]); + w0[1] = l32_from_64_S (ctx0.h[0]); + w0[2] = h32_from_64_S (ctx0.h[1]); + w0[3] = l32_from_64_S (ctx0.h[1]); + w1[0] = h32_from_64_S (ctx0.h[2]); + w1[1] = l32_from_64_S (ctx0.h[2]); + w1[2] = h32_from_64_S (ctx0.h[3]); + w1[3] = l32_from_64_S (ctx0.h[3]); + w2[0] = h32_from_64_S (ctx0.h[4]); + w2[1] = l32_from_64_S (ctx0.h[4]); + w2[2] = h32_from_64_S (ctx0.h[5]); + w2[3] = l32_from_64_S (ctx0.h[5]); + w3[0] = h32_from_64_S (ctx0.h[6]); + w3[1] = l32_from_64_S (ctx0.h[6]); + w3[2] = h32_from_64_S (ctx0.h[7]); + w3[3] = l32_from_64_S (ctx0.h[7]); + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 64); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32420_a1-pure.cl b/OpenCL/m32420_a1-pure.cl new file mode 100644 index 000000000..1835d4fba --- /dev/null +++ b/OpenCL/m32420_a1-pure.cl @@ -0,0 +1,235 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +KERNEL_FQ void m32420_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha512_ctx_t ctx1 = ctx0; + + sha512_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha512_final (&ctx1); + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = h32_from_64_S (ctx1.h[0]); + w0[1] = l32_from_64_S (ctx1.h[0]); + w0[2] = h32_from_64_S (ctx1.h[1]); + w0[3] = l32_from_64_S (ctx1.h[1]); + w1[0] = h32_from_64_S (ctx1.h[2]); + w1[1] = l32_from_64_S (ctx1.h[2]); + w1[2] = h32_from_64_S (ctx1.h[3]); + w1[3] = l32_from_64_S (ctx1.h[3]); + w2[0] = h32_from_64_S (ctx1.h[4]); + w2[1] = l32_from_64_S (ctx1.h[4]); + w2[2] = h32_from_64_S (ctx1.h[5]); + w2[3] = l32_from_64_S (ctx1.h[5]); + w3[0] = h32_from_64_S (ctx1.h[6]); + w3[1] = l32_from_64_S (ctx1.h[6]); + w3[2] = h32_from_64_S (ctx1.h[7]); + w3[3] = l32_from_64_S (ctx1.h[7]); + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 64); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32420_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32 s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + sha512_ctx_t ctx0; + + sha512_init (&ctx0); + + sha512_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + sha512_ctx_t ctx1 = ctx0; + + sha512_update_global_swap (&ctx1, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + sha512_final (&ctx1); + + sha512_ctx_t ctx; + + sha512_init (&ctx); + + w0[0] = h32_from_64_S (ctx1.h[0]); + w0[1] = l32_from_64_S (ctx1.h[0]); + w0[2] = h32_from_64_S (ctx1.h[1]); + w0[3] = l32_from_64_S (ctx1.h[1]); + w1[0] = h32_from_64_S (ctx1.h[2]); + w1[1] = l32_from_64_S (ctx1.h[2]); + w1[2] = h32_from_64_S (ctx1.h[3]); + w1[3] = l32_from_64_S (ctx1.h[3]); + w2[0] = h32_from_64_S (ctx1.h[4]); + w2[1] = l32_from_64_S (ctx1.h[4]); + w2[2] = h32_from_64_S (ctx1.h[5]); + w2[3] = l32_from_64_S (ctx1.h[5]); + w3[0] = h32_from_64_S (ctx1.h[6]); + w3[1] = l32_from_64_S (ctx1.h[6]); + w3[2] = h32_from_64_S (ctx1.h[7]); + w3[3] = l32_from_64_S (ctx1.h[7]); + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_update_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 64); + + sha512_update (&ctx, s, salt_len); + + sha512_final (&ctx); + + const u32 r0 = l32_from_64_S (ctx.h[7]); + const u32 r1 = h32_from_64_S (ctx.h[7]); + const u32 r2 = l32_from_64_S (ctx.h[3]); + const u32 r3 = h32_from_64_S (ctx.h[3]); + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32420_a3-pure.cl b/OpenCL/m32420_a3-pure.cl new file mode 100644 index 000000000..ae4575e1b --- /dev/null +++ b/OpenCL/m32420_a3-pure.cl @@ -0,0 +1,270 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha512.cl) +#endif + +KERNEL_FQ void m32420_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + + /** + * base + */ + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0_final = w0l | w0r; + + w[0] = w0_final; + + sha512_ctx_vector_t ctx0; + + sha512_init_vector (&ctx0); + + sha512_update_vector (&ctx0, w, pw_len); + + sha512_final_vector (&ctx0); + + const u64x a = ctx0.h[0]; + const u64x b = ctx0.h[1]; + const u64x c = ctx0.h[2]; + const u64x d = ctx0.h[3]; + const u64x e = ctx0.h[4]; + const u64x f = ctx0.h[5]; + const u64x g = ctx0.h[6]; + const u64x h = ctx0.h[7]; + + sha512_ctx_vector_t ctx; + + sha512_init_vector (&ctx); + + w0[0] = h32_from_64 (ctx0.h[0]); + w0[1] = l32_from_64 (ctx0.h[0]); + w0[2] = h32_from_64 (ctx0.h[1]); + w0[3] = l32_from_64 (ctx0.h[1]); + w1[0] = h32_from_64 (ctx0.h[2]); + w1[1] = l32_from_64 (ctx0.h[2]); + w1[2] = h32_from_64 (ctx0.h[3]); + w1[3] = l32_from_64 (ctx0.h[3]); + w2[0] = h32_from_64 (ctx0.h[4]); + w2[1] = l32_from_64 (ctx0.h[4]); + w2[2] = h32_from_64 (ctx0.h[5]); + w2[3] = l32_from_64 (ctx0.h[5]); + w3[0] = h32_from_64 (ctx0.h[6]); + w3[1] = l32_from_64 (ctx0.h[6]); + w3[2] = h32_from_64 (ctx0.h[7]); + w3[3] = l32_from_64 (ctx0.h[7]); + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_update_vector_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 64); + + sha512_update_vector (&ctx, s, salt_len); + + sha512_final_vector (&ctx); + + const u32x r0 = l32_from_64 (ctx.h[7]); + const u32x r1 = h32_from_64 (ctx.h[7]); + const u32x r2 = l32_from_64 (ctx.h[3]); + const u32x r3 = h32_from_64 (ctx.h[3]); + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32420_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + u32x w4[4]; + u32x w5[4]; + u32x w6[4]; + u32x w7[4]; + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32_S (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0_final = w0l | w0r; + + w[0] = w0_final; + + sha512_ctx_vector_t ctx0; + + sha512_init_vector (&ctx0); + + sha512_update_vector (&ctx0, w, pw_len); + + sha512_final_vector (&ctx0); + + sha512_ctx_vector_t ctx; + + sha512_init_vector (&ctx); + + w0[0] = h32_from_64 (ctx0.h[0]); + w0[1] = l32_from_64 (ctx0.h[0]); + w0[2] = h32_from_64 (ctx0.h[1]); + w0[3] = l32_from_64 (ctx0.h[1]); + w1[0] = h32_from_64 (ctx0.h[2]); + w1[1] = l32_from_64 (ctx0.h[2]); + w1[2] = h32_from_64 (ctx0.h[3]); + w1[3] = l32_from_64 (ctx0.h[3]); + w2[0] = h32_from_64 (ctx0.h[4]); + w2[1] = l32_from_64 (ctx0.h[4]); + w2[2] = h32_from_64 (ctx0.h[5]); + w2[3] = l32_from_64 (ctx0.h[5]); + w3[0] = h32_from_64 (ctx0.h[6]); + w3[1] = l32_from_64 (ctx0.h[6]); + w3[2] = h32_from_64 (ctx0.h[7]); + w3[3] = l32_from_64 (ctx0.h[7]); + w4[0] = 0; + w4[1] = 0; + w4[2] = 0; + w4[3] = 0; + w5[0] = 0; + w5[1] = 0; + w5[2] = 0; + w5[3] = 0; + w6[0] = 0; + w6[1] = 0; + w6[2] = 0; + w6[3] = 0; + w7[0] = 0; + w7[1] = 0; + w7[2] = 0; + w7[3] = 0; + + sha512_update_vector_128 (&ctx, w0, w1, w2, w3, w4, w5, w6, w7, 64); + + sha512_update_vector (&ctx, s, salt_len); + + sha512_final_vector (&ctx); + + const u32x r0 = l32_from_64 (ctx.h[7]); + const u32x r1 = h32_from_64 (ctx.h[7]); + const u32x r2 = l32_from_64 (ctx.h[3]); + const u32x r3 = h32_from_64 (ctx.h[3]); + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32500-pure.cl b/OpenCL/m32500-pure.cl new file mode 100644 index 000000000..a8861db32 --- /dev/null +++ b/OpenCL/m32500-pure.cl @@ -0,0 +1,457 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +// #define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha256.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#endif + +#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl) +#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl) + +typedef struct payload +{ + u32 pl_buf[64]; + u32 pl_len; + +} payload_t; + +typedef struct doge_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} doge_tmp_t; + +DECLSPEC void hmac_sha256_run_V (PRIVATE_AS u32x *w0, PRIVATE_AS u32x *w1, PRIVATE_AS u32x *w2, PRIVATE_AS u32x *w3, PRIVATE_AS u32x *ipad, PRIVATE_AS u32x *opad, PRIVATE_AS u32x *digest) +{ + digest[0] = ipad[0]; + digest[1] = ipad[1]; + digest[2] = ipad[2]; + digest[3] = ipad[3]; + digest[4] = ipad[4]; + digest[5] = ipad[5]; + digest[6] = ipad[6]; + digest[7] = ipad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); + + w0[0] = digest[0]; + w0[1] = digest[1]; + w0[2] = digest[2]; + w0[3] = digest[3]; + w1[0] = digest[4]; + w1[1] = digest[5]; + w1[2] = digest[6]; + w1[3] = digest[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + digest[0] = opad[0]; + digest[1] = opad[1]; + digest[2] = opad[2]; + digest[3] = opad[3]; + digest[4] = opad[4]; + digest[5] = opad[5]; + digest[6] = opad[6]; + digest[7] = opad[7]; + + sha256_transform_vector (w0, w1, w2, w3, digest); +} + +//--------------------------------------------------------------------------------------- +CONSTANT_VK u32 base64_table[64] = +{ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/', +}; + +// Wow it's the right file +u32 base64_encode_three_bytes_better (u32 in) +{ + //in has 3 u8s in, first u8 is not set) + u32 out; + + out = base64_table[(in >> 18) & 0x3F] << 24; + out |= base64_table[(in >> 12) & 0x3F] << 16; + out |= base64_table[(in >> 6) & 0x3F] << 8; + out |= base64_table[(in ) & 0x3F]; + + return out; +} + +void base64_encode_sha256 (u32 *out, const u32 *in) +{ + out[0] = base64_encode_three_bytes_better( (in[0] >> 8)); + out[1] = base64_encode_three_bytes_better((in[0] << 16) | (in[1] >> 16)); + out[2] = base64_encode_three_bytes_better((in[1] << 8) | (in[2] >> 24)); + out[3] = base64_encode_three_bytes_better((in[2] )); + + out[4] = base64_encode_three_bytes_better( (in[3] >> 8)); + out[5] = base64_encode_three_bytes_better((in[3] << 16) | (in[4] >> 16)); + out[6] = base64_encode_three_bytes_better((in[4] << 8) | (in[5] >> 24)); + out[7] = base64_encode_three_bytes_better((in[5] )); + + out[8] = base64_encode_three_bytes_better( (in[6] >> 8)); + out[9] = base64_encode_three_bytes_better((in[6] << 16) | (in[7] >> 16)); + + // 0x7c = ord('A') ^ ord('=') so replaces the A that we'll get at the end with an = + out[10] = base64_encode_three_bytes_better(in[7] << 8) ^ 0x7c; +} +//--------------------------------------------------------------------------------------- + +KERNEL_FQ void m32500_init (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t)) +{ + const u64 gid = get_global_id (0); + + if (gid >= GID_CNT) return; + + sha256_ctx_t ctx; + + sha256_init (&ctx); + sha256_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); + sha256_final (&ctx); + + u32 w[16] = { 0 }; // only uses 11, but have to be 16 for sha256_hmac_init_global function + + base64_encode_sha256 (w, ctx.h); + + // pbkdf + + sha256_hmac_ctx_t sha256_hmac_ctx; + + sha256_hmac_init_global (&sha256_hmac_ctx, w, 44); + + tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; + tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; + tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2]; + tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3]; + tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4]; + tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5]; + tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6]; + tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7]; + + tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0]; + tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1]; + tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2]; + tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3]; + tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4]; + tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5]; + tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6]; + tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7]; + + sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); + + for (u32 i = 0, j = 1; i < 8; i += 8, j += 1) + { + sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + w0[0] = j; + w0[1] = 0; + w0[2] = 0; + w0[3] = 0; + w1[0] = 0; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); + + sha256_hmac_final (&sha256_hmac_ctx2); + + tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0]; + tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1]; + tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2]; + tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3]; + tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4]; + tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5]; + tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6]; + tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7]; + + tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0]; + tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1]; + tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2]; + tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3]; + tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4]; + tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5]; + tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6]; + tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7]; + } + +} + +KERNEL_FQ void m32500_loop (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t)) +{ + //pbkdf2hmac here + + const u64 gid = get_global_id (0); + + if ((gid * VECT_SIZE) >= GID_CNT) return; + + u32x ipad[8]; + u32x opad[8]; + + ipad[0] = packv (tmps, ipad, gid, 0); + ipad[1] = packv (tmps, ipad, gid, 1); + ipad[2] = packv (tmps, ipad, gid, 2); + ipad[3] = packv (tmps, ipad, gid, 3); + ipad[4] = packv (tmps, ipad, gid, 4); + ipad[5] = packv (tmps, ipad, gid, 5); + ipad[6] = packv (tmps, ipad, gid, 6); + ipad[7] = packv (tmps, ipad, gid, 7); + + opad[0] = packv (tmps, opad, gid, 0); + opad[1] = packv (tmps, opad, gid, 1); + opad[2] = packv (tmps, opad, gid, 2); + opad[3] = packv (tmps, opad, gid, 3); + opad[4] = packv (tmps, opad, gid, 4); + opad[5] = packv (tmps, opad, gid, 5); + opad[6] = packv (tmps, opad, gid, 6); + opad[7] = packv (tmps, opad, gid, 7); + + for (u32 i = 0; i < 8; i += 8) + { + u32x dgst[8]; + u32x out[8]; + + dgst[0] = packv (tmps, dgst, gid, i + 0); + dgst[1] = packv (tmps, dgst, gid, i + 1); + dgst[2] = packv (tmps, dgst, gid, i + 2); + dgst[3] = packv (tmps, dgst, gid, i + 3); + dgst[4] = packv (tmps, dgst, gid, i + 4); + dgst[5] = packv (tmps, dgst, gid, i + 5); + dgst[6] = packv (tmps, dgst, gid, i + 6); + dgst[7] = packv (tmps, dgst, gid, i + 7); + + out[0] = packv (tmps, out, gid, i + 0); + out[1] = packv (tmps, out, gid, i + 1); + out[2] = packv (tmps, out, gid, i + 2); + out[3] = packv (tmps, out, gid, i + 3); + out[4] = packv (tmps, out, gid, i + 4); + out[5] = packv (tmps, out, gid, i + 5); + out[6] = packv (tmps, out, gid, i + 6); + out[7] = packv (tmps, out, gid, i + 7); + + for (u32 j = 0; j < LOOP_CNT; j++) + { + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + w0[0] = dgst[0]; + w0[1] = dgst[1]; + w0[2] = dgst[2]; + w0[3] = dgst[3]; + w1[0] = dgst[4]; + w1[1] = dgst[5]; + w1[2] = dgst[6]; + w1[3] = dgst[7]; + w2[0] = 0x80000000; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = (64 + 32) * 8; + + hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst); + + out[0] ^= dgst[0]; + out[1] ^= dgst[1]; + out[2] ^= dgst[2]; + out[3] ^= dgst[3]; + out[4] ^= dgst[4]; + out[5] ^= dgst[5]; + out[6] ^= dgst[6]; + out[7] ^= dgst[7]; + } + + unpackv (tmps, dgst, gid, i + 0, dgst[0]); + unpackv (tmps, dgst, gid, i + 1, dgst[1]); + unpackv (tmps, dgst, gid, i + 2, dgst[2]); + unpackv (tmps, dgst, gid, i + 3, dgst[3]); + unpackv (tmps, dgst, gid, i + 4, dgst[4]); + unpackv (tmps, dgst, gid, i + 5, dgst[5]); + unpackv (tmps, dgst, gid, i + 6, dgst[6]); + unpackv (tmps, dgst, gid, i + 7, dgst[7]); + + unpackv (tmps, out, gid, i + 0, out[0]); + unpackv (tmps, out, gid, i + 1, out[1]); + unpackv (tmps, out, gid, i + 2, out[2]); + unpackv (tmps, out, gid, i + 3, out[3]); + unpackv (tmps, out, gid, i + 4, out[4]); + unpackv (tmps, out, gid, i + 5, out[5]); + unpackv (tmps, out, gid, i + 6, out[6]); + unpackv (tmps, out, gid, i + 7, out[7]); + } +} + +KERNEL_FQ void m32500_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t)) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id(0); + const u64 lsz = get_local_size(0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS(); + + #else + + CONSTANT_AS u32a* s_td0 = td0; + CONSTANT_AS u32a* s_td1 = td1; + CONSTANT_AS u32a* s_td2 = td2; + CONSTANT_AS u32a* s_td3 = td3; + CONSTANT_AS u32a* s_td4 = td4; + + CONSTANT_AS u32a* s_te0 = te0; + CONSTANT_AS u32a* s_te1 = te1; + CONSTANT_AS u32a* s_te2 = te2; + CONSTANT_AS u32a* s_te3 = te3; + CONSTANT_AS u32a* s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + u32 ukey[8]; + + ukey[0] = tmps[gid].out[0]; + ukey[1] = tmps[gid].out[1]; + ukey[2] = tmps[gid].out[2]; + ukey[3] = tmps[gid].out[3]; + ukey[4] = tmps[gid].out[4]; + ukey[5] = tmps[gid].out[5]; + ukey[6] = tmps[gid].out[6]; + ukey[7] = tmps[gid].out[7]; + + u32 ks[60]; + + AES256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3); + + // iv + + u32 prev_ct[4]; // iv is the first 4 u32s -> needs to be prev ct for cbc encryption (each block used prior ct) + // todo: might want to swap in module + + prev_ct[0] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[0]); + prev_ct[1] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[1]); + prev_ct[2] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[2]); + prev_ct[3] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[3]); + + u32 isAscii = 0; + + // ct + u32 ct_buf[4]; + + // Padding is Crypto.pad.iso10126 -pads with random bytes until the last byte, and which defines the number of padding bytes + // So knocking off last block to not account for any non-ascii padding + // todo: pkcs_padding_bs16() might be able to replace this + + for (u32 i = 4, j = 16; j < esalt_bufs[DIGESTS_OFFSET_HOST].pl_len - 16; i += 4, j += 16) + { + ct_buf[0] = hc_swap32_S (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i + 0]); + ct_buf[1] = hc_swap32_S (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i + 1]); + ct_buf[2] = hc_swap32_S (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i + 2]); + ct_buf[3] = hc_swap32_S (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i + 3]); + + u32 pt_buf[4]; + + AES256_decrypt (ks, ct_buf, pt_buf, s_td0, s_td1, s_td2, s_td3, s_td4); + + for (u32 x = 0; x < 4; x++) + { + pt_buf[x] ^= prev_ct[x]; + isAscii |= pt_buf[x] & 0x80808080; //check the ciphertext is human readable + prev_ct[x] = ct_buf[x]; //set previous CT as the new IV for the next block + } + } + + const u32 r0 = isAscii; + const u32 r1 = 0; + const u32 r2 = 0; + const u32 r3 = 0; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} diff --git a/OpenCL/m32600_a0-pure.cl b/OpenCL/m32600_a0-pure.cl new file mode 100644 index 000000000..b3200f1cf --- /dev/null +++ b/OpenCL/m32600_a0-pure.cl @@ -0,0 +1,233 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_whirlpool.cl) +#endif + +KERNEL_FQ void m32600_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; + + #endif + + if (gid >= GID_CNT) return; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + whirlpool_ctx_t ctx0; + + whirlpool_init (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + + whirlpool_update (&ctx0, s, salt_len); + + /** + * base + */ + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + whirlpool_ctx_t ctx = ctx0; + + whirlpool_update_swap (&ctx, tmp.i, tmp.pw_len); + + whirlpool_update (&ctx, s, salt_len); + + whirlpool_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32600_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; + + #endif + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + whirlpool_ctx_t ctx0; + + whirlpool_init (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + + whirlpool_update (&ctx0, s, salt_len); + + /** + * base + */ + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + whirlpool_ctx_t ctx = ctx0; + + whirlpool_update_swap (&ctx, tmp.i, tmp.pw_len); + + whirlpool_update (&ctx, s, salt_len); + + whirlpool_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32600_a1-pure.cl b/OpenCL/m32600_a1-pure.cl new file mode 100644 index 000000000..40289ed35 --- /dev/null +++ b/OpenCL/m32600_a1-pure.cl @@ -0,0 +1,223 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +//#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#include M2S(INCLUDE_PATH/inc_hash_whirlpool.cl) +#endif + +KERNEL_FQ void m32600_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; + + #endif + + if (gid >= GID_CNT) return; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * base + */ + + whirlpool_ctx_t ctx0; + + whirlpool_init (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + + whirlpool_update (&ctx0, s, salt_len); + + whirlpool_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + whirlpool_ctx_t ctx = ctx0; + + whirlpool_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + whirlpool_update (&ctx, s, salt_len); + + whirlpool_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32600_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; + + #endif + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + /** + * base + */ + + whirlpool_ctx_t ctx0; + + whirlpool_init (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + + whirlpool_update (&ctx0, s, salt_len); + + whirlpool_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + whirlpool_ctx_t ctx = ctx0; + + whirlpool_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + whirlpool_update (&ctx, s, salt_len); + + whirlpool_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m32600_a3-pure.cl b/OpenCL/m32600_a3-pure.cl new file mode 100644 index 000000000..173ba4381 --- /dev/null +++ b/OpenCL/m32600_a3-pure.cl @@ -0,0 +1,253 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#define NEW_SIMD_CODE + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) +#include M2S(INCLUDE_PATH/inc_hash_whirlpool.cl) +#endif + +KERNEL_FQ void m32600_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; + + #endif + + if (gid >= GID_CNT) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + whirlpool_ctx_vector_t ctx0; + + whirlpool_init_vector (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + + whirlpool_update_vector (&ctx0, s, salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + whirlpool_ctx_vector_t ctx = ctx0; + + whirlpool_update_vector (&ctx, w, pw_len); + + whirlpool_update_vector (&ctx, s, salt_len); + + whirlpool_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m32600_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * Whirlpool shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u64 s_MT0[256]; + LOCAL_VK u64 s_MT1[256]; + LOCAL_VK u64 s_MT2[256]; + LOCAL_VK u64 s_MT3[256]; + LOCAL_VK u64 s_MT4[256]; + LOCAL_VK u64 s_MT5[256]; + LOCAL_VK u64 s_MT6[256]; + LOCAL_VK u64 s_MT7[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_MT0[i] = MT0[i]; + s_MT1[i] = MT1[i]; + s_MT2[i] = MT2[i]; + s_MT3[i] = MT3[i]; + s_MT4[i] = MT4[i]; + s_MT5[i] = MT5[i]; + s_MT6[i] = MT6[i]; + s_MT7[i] = MT7[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u64a *s_MT0 = MT0; + CONSTANT_AS u64a *s_MT1 = MT1; + CONSTANT_AS u64a *s_MT2 = MT2; + CONSTANT_AS u64a *s_MT3 = MT3; + CONSTANT_AS u64a *s_MT4 = MT4; + CONSTANT_AS u64a *s_MT5 = MT5; + CONSTANT_AS u64a *s_MT6 = MT6; + CONSTANT_AS u64a *s_MT7 = MT7; + + #endif + + if (gid >= GID_CNT) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + const u32 salt_len = salt_bufs[SALT_POS_HOST].salt_len; + + u32x s[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < salt_len; i += 4, idx += 1) + { + s[idx] = hc_swap32 (salt_bufs[SALT_POS_HOST].salt_buf[idx]); + } + + whirlpool_ctx_vector_t ctx0; + + whirlpool_init_vector (&ctx0, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + + whirlpool_update_vector (&ctx0, s, salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + whirlpool_ctx_vector_t ctx = ctx0; + + whirlpool_update_vector (&ctx, w, pw_len); + + whirlpool_update_vector (&ctx, s, salt_len); + + whirlpool_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/charsets/standard/Romanian/ro_ISO-8859-2.hcchr b/charsets/standard/Romanian/ro_ISO-8859-2.hcchr new file mode 100644 index 000000000..d2c3fbd3d --- /dev/null +++ b/charsets/standard/Romanian/ro_ISO-8859-2.hcchr @@ -0,0 +1 @@ +aăâbcdefghiîjklmnopqrsștțuvwxyzAĂÂBCDEFGHIÎJKLMNOPQRSȘTȚUVWXYZ diff --git a/deps/LZMA-SDK/C/7z.h b/deps/LZMA-SDK/C/7z.h index 969523cd3..304f75ffc 100644 --- a/deps/LZMA-SDK/C/7z.h +++ b/deps/LZMA-SDK/C/7z.h @@ -1,204 +1,204 @@ -/* 7z.h -- 7z interface -2018-07-02 : Igor Pavlov : Public domain */ - -#ifndef __7Z_H -#define __7Z_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define k7zStartHeaderSize 0x20 -#define k7zSignatureSize 6 - -extern const Byte k7zSignature[k7zSignatureSize]; - -typedef struct -{ - const Byte *Data; - size_t Size; -} CSzData; - -/* CSzCoderInfo & CSzFolder support only default methods */ - -typedef struct -{ - size_t PropsOffset; - UInt32 MethodID; - Byte NumStreams; - Byte PropsSize; -} CSzCoderInfo; - -typedef struct -{ - UInt32 InIndex; - UInt32 OutIndex; -} CSzBond; - -#define SZ_NUM_CODERS_IN_FOLDER_MAX 4 -#define SZ_NUM_BONDS_IN_FOLDER_MAX 3 -#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4 - -typedef struct -{ - UInt32 NumCoders; - UInt32 NumBonds; - UInt32 NumPackStreams; - UInt32 UnpackStream; - UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; - CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; - CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; -} CSzFolder; - - -SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); - -typedef struct -{ - UInt32 Low; - UInt32 High; -} CNtfsFileTime; - -typedef struct -{ - Byte *Defs; /* MSB 0 bit numbering */ - UInt32 *Vals; -} CSzBitUi32s; - -typedef struct -{ - Byte *Defs; /* MSB 0 bit numbering */ - // UInt64 *Vals; - CNtfsFileTime *Vals; -} CSzBitUi64s; - -#define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) - -#define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) - -typedef struct -{ - UInt32 NumPackStreams; - UInt32 NumFolders; - - UInt64 *PackPositions; // NumPackStreams + 1 - CSzBitUi32s FolderCRCs; // NumFolders - - size_t *FoCodersOffsets; // NumFolders + 1 - UInt32 *FoStartPackStreamIndex; // NumFolders + 1 - UInt32 *FoToCoderUnpackSizes; // NumFolders + 1 - Byte *FoToMainUnpackSizeIndex; // NumFolders - UInt64 *CoderUnpackSizes; // for all coders in all folders - - Byte *CodersData; - - UInt64 RangeLimit; -} CSzAr; - -UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); - -SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, - ILookInStream *stream, UInt64 startPos, - Byte *outBuffer, size_t outSize, - ISzAllocPtr allocMain); - -typedef struct -{ - CSzAr db; - - UInt64 startPosAfterHeader; - UInt64 dataPos; - - UInt32 NumFiles; - - UInt64 *UnpackPositions; // NumFiles + 1 - // Byte *IsEmptyFiles; - Byte *IsDirs; - CSzBitUi32s CRCs; - - CSzBitUi32s Attribs; - // CSzBitUi32s Parents; - CSzBitUi64s MTime; - CSzBitUi64s CTime; - - UInt32 *FolderToFile; // NumFolders + 1 - UInt32 *FileToFolder; // NumFiles - - size_t *FileNameOffsets; /* in 2-byte steps */ - Byte *FileNames; /* UTF-16-LE */ -} CSzArEx; - -#define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i)) - -#define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i]) - -void SzArEx_Init(CSzArEx *p); -void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc); -UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); - -/* -if dest == NULL, the return value specifies the required size of the buffer, - in 16-bit characters, including the null-terminating character. -if dest != NULL, the return value specifies the number of 16-bit characters that - are written to the dest, including the null-terminating character. */ - -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); - -/* -size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex); -UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); -*/ - - - -/* - SzArEx_Extract extracts file from archive - - *outBuffer must be 0 before first call for each new archive. - - Extracting cache: - If you need to decompress more than one file, you can send - these values from previous call: - *blockIndex, - *outBuffer, - *outBufferSize - You can consider "*outBuffer" as cache of solid block. If your archive is solid, - it will increase decompression speed. - - If you use external function, you can declare these 3 cache variables - (blockIndex, outBuffer, outBufferSize) as static in that external function. - - Free *outBuffer and set *outBuffer to 0, if you want to flush cache. -*/ - -SRes SzArEx_Extract( - const CSzArEx *db, - ILookInStream *inStream, - UInt32 fileIndex, /* index of file */ - UInt32 *blockIndex, /* index of solid block */ - Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAllocPtr allocMain, - ISzAllocPtr allocTemp); - - -/* -SzArEx_Open Errors: -SZ_ERROR_NO_ARCHIVE -SZ_ERROR_ARCHIVE -SZ_ERROR_UNSUPPORTED -SZ_ERROR_MEM -SZ_ERROR_CRC -SZ_ERROR_INPUT_EOF -SZ_ERROR_FAIL -*/ - -SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, - ISzAllocPtr allocMain, ISzAllocPtr allocTemp); - -EXTERN_C_END - -#endif +/* 7z.h -- 7z interface +2018-07-02 : Igor Pavlov : Public domain */ + +#ifndef __7Z_H +#define __7Z_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define k7zStartHeaderSize 0x20 +#define k7zSignatureSize 6 + +extern const Byte k7zSignature[k7zSignatureSize]; + +typedef struct +{ + const Byte *Data; + size_t Size; +} CSzData; + +/* CSzCoderInfo & CSzFolder support only default methods */ + +typedef struct +{ + size_t PropsOffset; + UInt32 MethodID; + Byte NumStreams; + Byte PropsSize; +} CSzCoderInfo; + +typedef struct +{ + UInt32 InIndex; + UInt32 OutIndex; +} CSzBond; + +#define SZ_NUM_CODERS_IN_FOLDER_MAX 4 +#define SZ_NUM_BONDS_IN_FOLDER_MAX 3 +#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4 + +typedef struct +{ + UInt32 NumCoders; + UInt32 NumBonds; + UInt32 NumPackStreams; + UInt32 UnpackStream; + UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; + CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; + CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; +} CSzFolder; + + +SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); + +typedef struct +{ + UInt32 Low; + UInt32 High; +} CNtfsFileTime; + +typedef struct +{ + Byte *Defs; /* MSB 0 bit numbering */ + UInt32 *Vals; +} CSzBitUi32s; + +typedef struct +{ + Byte *Defs; /* MSB 0 bit numbering */ + // UInt64 *Vals; + CNtfsFileTime *Vals; +} CSzBitUi64s; + +#define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) + +#define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) + +typedef struct +{ + UInt32 NumPackStreams; + UInt32 NumFolders; + + UInt64 *PackPositions; // NumPackStreams + 1 + CSzBitUi32s FolderCRCs; // NumFolders + + size_t *FoCodersOffsets; // NumFolders + 1 + UInt32 *FoStartPackStreamIndex; // NumFolders + 1 + UInt32 *FoToCoderUnpackSizes; // NumFolders + 1 + Byte *FoToMainUnpackSizeIndex; // NumFolders + UInt64 *CoderUnpackSizes; // for all coders in all folders + + Byte *CodersData; + + UInt64 RangeLimit; +} CSzAr; + +UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); + +SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, + ILookInStream *stream, UInt64 startPos, + Byte *outBuffer, size_t outSize, + ISzAllocPtr allocMain); + +typedef struct +{ + CSzAr db; + + UInt64 startPosAfterHeader; + UInt64 dataPos; + + UInt32 NumFiles; + + UInt64 *UnpackPositions; // NumFiles + 1 + // Byte *IsEmptyFiles; + Byte *IsDirs; + CSzBitUi32s CRCs; + + CSzBitUi32s Attribs; + // CSzBitUi32s Parents; + CSzBitUi64s MTime; + CSzBitUi64s CTime; + + UInt32 *FolderToFile; // NumFolders + 1 + UInt32 *FileToFolder; // NumFiles + + size_t *FileNameOffsets; /* in 2-byte steps */ + Byte *FileNames; /* UTF-16-LE */ +} CSzArEx; + +#define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i)) + +#define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i]) + +void SzArEx_Init(CSzArEx *p); +void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc); +UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); + +/* +if dest == NULL, the return value specifies the required size of the buffer, + in 16-bit characters, including the null-terminating character. +if dest != NULL, the return value specifies the number of 16-bit characters that + are written to the dest, including the null-terminating character. */ + +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); + +/* +size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex); +UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); +*/ + + + +/* + SzArEx_Extract extracts file from archive + + *outBuffer must be 0 before first call for each new archive. + + Extracting cache: + If you need to decompress more than one file, you can send + these values from previous call: + *blockIndex, + *outBuffer, + *outBufferSize + You can consider "*outBuffer" as cache of solid block. If your archive is solid, + it will increase decompression speed. + + If you use external function, you can declare these 3 cache variables + (blockIndex, outBuffer, outBufferSize) as static in that external function. + + Free *outBuffer and set *outBuffer to 0, if you want to flush cache. +*/ + +SRes SzArEx_Extract( + const CSzArEx *db, + ILookInStream *inStream, + UInt32 fileIndex, /* index of file */ + UInt32 *blockIndex, /* index of solid block */ + Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ + size_t *outBufferSize, /* buffer size for output buffer */ + size_t *offset, /* offset of stream for required file in *outBuffer */ + size_t *outSizeProcessed, /* size of file in *outBuffer */ + ISzAllocPtr allocMain, + ISzAllocPtr allocTemp); + + +/* +SzArEx_Open Errors: +SZ_ERROR_NO_ARCHIVE +SZ_ERROR_ARCHIVE +SZ_ERROR_UNSUPPORTED +SZ_ERROR_MEM +SZ_ERROR_CRC +SZ_ERROR_INPUT_EOF +SZ_ERROR_FAIL +*/ + +SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, + ISzAllocPtr allocMain, ISzAllocPtr allocTemp); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/7zAlloc.c b/deps/LZMA-SDK/C/7zAlloc.c index ea32809c6..c924a529f 100644 --- a/deps/LZMA-SDK/C/7zAlloc.c +++ b/deps/LZMA-SDK/C/7zAlloc.c @@ -1,80 +1,80 @@ -/* 7zAlloc.c -- Allocation functions -2017-04-03 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "7zAlloc.h" - -/* #define _SZ_ALLOC_DEBUG */ -/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ - -#ifdef _SZ_ALLOC_DEBUG - -#ifdef _WIN32 -#include -#endif - -#include -int g_allocCount = 0; -int g_allocCountTemp = 0; - -#endif - -void *SzAlloc(ISzAllocPtr p, size_t size) -{ - UNUSED_VAR(p); - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount); - g_allocCount++; - #endif - return malloc(size); -} - -void SzFree(ISzAllocPtr p, void *address) -{ - UNUSED_VAR(p); - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - { - g_allocCount--; - fprintf(stderr, "\nFree; count = %10d", g_allocCount); - } - #endif - free(address); -} - -void *SzAllocTemp(ISzAllocPtr p, size_t size) -{ - UNUSED_VAR(p); - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp); - g_allocCountTemp++; - #ifdef _WIN32 - return HeapAlloc(GetProcessHeap(), 0, size); - #endif - #endif - return malloc(size); -} - -void SzFreeTemp(ISzAllocPtr p, void *address) -{ - UNUSED_VAR(p); - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - { - g_allocCountTemp--; - fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); - } - #ifdef _WIN32 - HeapFree(GetProcessHeap(), 0, address); - return; - #endif - #endif - free(address); -} +/* 7zAlloc.c -- Allocation functions +2017-04-03 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#include "7zAlloc.h" + +/* #define _SZ_ALLOC_DEBUG */ +/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ + +#ifdef _SZ_ALLOC_DEBUG + +#ifdef _WIN32 +#include +#endif + +#include +int g_allocCount = 0; +int g_allocCountTemp = 0; + +#endif + +void *SzAlloc(ISzAllocPtr p, size_t size) +{ + UNUSED_VAR(p); + if (size == 0) + return 0; + #ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount); + g_allocCount++; + #endif + return malloc(size); +} + +void SzFree(ISzAllocPtr p, void *address) +{ + UNUSED_VAR(p); + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + { + g_allocCount--; + fprintf(stderr, "\nFree; count = %10d", g_allocCount); + } + #endif + free(address); +} + +void *SzAllocTemp(ISzAllocPtr p, size_t size) +{ + UNUSED_VAR(p); + if (size == 0) + return 0; + #ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp); + g_allocCountTemp++; + #ifdef _WIN32 + return HeapAlloc(GetProcessHeap(), 0, size); + #endif + #endif + return malloc(size); +} + +void SzFreeTemp(ISzAllocPtr p, void *address) +{ + UNUSED_VAR(p); + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + { + g_allocCountTemp--; + fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); + } + #ifdef _WIN32 + HeapFree(GetProcessHeap(), 0, address); + return; + #endif + #endif + free(address); +} diff --git a/deps/LZMA-SDK/C/7zAlloc.h b/deps/LZMA-SDK/C/7zAlloc.h index c0f89d73c..44778f9b2 100644 --- a/deps/LZMA-SDK/C/7zAlloc.h +++ b/deps/LZMA-SDK/C/7zAlloc.h @@ -1,19 +1,19 @@ -/* 7zAlloc.h -- Allocation functions -2017-04-03 : Igor Pavlov : Public domain */ - -#ifndef __7Z_ALLOC_H -#define __7Z_ALLOC_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -void *SzAlloc(ISzAllocPtr p, size_t size); -void SzFree(ISzAllocPtr p, void *address); - -void *SzAllocTemp(ISzAllocPtr p, size_t size); -void SzFreeTemp(ISzAllocPtr p, void *address); - -EXTERN_C_END - -#endif +/* 7zAlloc.h -- Allocation functions +2017-04-03 : Igor Pavlov : Public domain */ + +#ifndef __7Z_ALLOC_H +#define __7Z_ALLOC_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +void *SzAlloc(ISzAllocPtr p, size_t size); +void SzFree(ISzAllocPtr p, void *address); + +void *SzAllocTemp(ISzAllocPtr p, size_t size); +void SzFreeTemp(ISzAllocPtr p, void *address); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/7zArcIn.c b/deps/LZMA-SDK/C/7zArcIn.c index 7ccc72101..0d9dec41e 100644 --- a/deps/LZMA-SDK/C/7zArcIn.c +++ b/deps/LZMA-SDK/C/7zArcIn.c @@ -1,1783 +1,1783 @@ -/* 7zArcIn.c -- 7z Input functions -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "7z.h" -#include "7zBuf.h" -#include "7zCrc.h" -#include "CpuArch.h" - -#define MY_ALLOC(T, p, size, alloc) { \ - if ((p = (T *)ISzAlloc_Alloc(alloc, (size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; } - -#define MY_ALLOC_ZE(T, p, size, alloc) { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) } - -#define MY_ALLOC_AND_CPY(to, size, from, alloc) \ - { MY_ALLOC(Byte, to, size, alloc); memcpy(to, from, size); } - -#define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \ - { if ((size) == 0) to = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } } - -#define k7zMajorVersion 0 - -enum EIdEnum -{ - k7zIdEnd, - k7zIdHeader, - k7zIdArchiveProperties, - k7zIdAdditionalStreamsInfo, - k7zIdMainStreamsInfo, - k7zIdFilesInfo, - k7zIdPackInfo, - k7zIdUnpackInfo, - k7zIdSubStreamsInfo, - k7zIdSize, - k7zIdCRC, - k7zIdFolder, - k7zIdCodersUnpackSize, - k7zIdNumUnpackStream, - k7zIdEmptyStream, - k7zIdEmptyFile, - k7zIdAnti, - k7zIdName, - k7zIdCTime, - k7zIdATime, - k7zIdMTime, - k7zIdWinAttrib, - k7zIdComment, - k7zIdEncodedHeader, - k7zIdStartPos, - k7zIdDummy - // k7zNtSecure, - // k7zParent, - // k7zIsReal -}; - -const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; - -#define SzBitUi32s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; } - -static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) -{ - if (num == 0) - { - p->Defs = NULL; - p->Vals = NULL; - } - else - { - MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc); - MY_ALLOC(UInt32, p->Vals, num, alloc); - } - return SZ_OK; -} - -static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; - ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; -} - -#define SzBitUi64s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; } - -static void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; - ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; -} - - -static void SzAr_Init(CSzAr *p) -{ - p->NumPackStreams = 0; - p->NumFolders = 0; - - p->PackPositions = NULL; - SzBitUi32s_Init(&p->FolderCRCs); - - p->FoCodersOffsets = NULL; - p->FoStartPackStreamIndex = NULL; - p->FoToCoderUnpackSizes = NULL; - p->FoToMainUnpackSizeIndex = NULL; - p->CoderUnpackSizes = NULL; - - p->CodersData = NULL; - - p->RangeLimit = 0; -} - -static void SzAr_Free(CSzAr *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->PackPositions); - SzBitUi32s_Free(&p->FolderCRCs, alloc); - - ISzAlloc_Free(alloc, p->FoCodersOffsets); - ISzAlloc_Free(alloc, p->FoStartPackStreamIndex); - ISzAlloc_Free(alloc, p->FoToCoderUnpackSizes); - ISzAlloc_Free(alloc, p->FoToMainUnpackSizeIndex); - ISzAlloc_Free(alloc, p->CoderUnpackSizes); - - ISzAlloc_Free(alloc, p->CodersData); - - SzAr_Init(p); -} - - -void SzArEx_Init(CSzArEx *p) -{ - SzAr_Init(&p->db); - - p->NumFiles = 0; - p->dataPos = 0; - - p->UnpackPositions = NULL; - p->IsDirs = NULL; - - p->FolderToFile = NULL; - p->FileToFolder = NULL; - - p->FileNameOffsets = NULL; - p->FileNames = NULL; - - SzBitUi32s_Init(&p->CRCs); - SzBitUi32s_Init(&p->Attribs); - // SzBitUi32s_Init(&p->Parents); - SzBitUi64s_Init(&p->MTime); - SzBitUi64s_Init(&p->CTime); -} - -void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->UnpackPositions); - ISzAlloc_Free(alloc, p->IsDirs); - - ISzAlloc_Free(alloc, p->FolderToFile); - ISzAlloc_Free(alloc, p->FileToFolder); - - ISzAlloc_Free(alloc, p->FileNameOffsets); - ISzAlloc_Free(alloc, p->FileNames); - - SzBitUi32s_Free(&p->CRCs, alloc); - SzBitUi32s_Free(&p->Attribs, alloc); - // SzBitUi32s_Free(&p->Parents, alloc); - SzBitUi64s_Free(&p->MTime, alloc); - SzBitUi64s_Free(&p->CTime, alloc); - - SzAr_Free(&p->db, alloc); - SzArEx_Init(p); -} - - -static int TestSignatureCandidate(const Byte *testBytes) -{ - unsigned i; - for (i = 0; i < k7zSignatureSize; i++) - if (testBytes[i] != k7zSignature[i]) - return 0; - return 1; -} - -#define SzData_Clear(p) { (p)->Data = NULL; (p)->Size = 0; } - -#define SZ_READ_BYTE_SD(_sd_, dest) if ((_sd_)->Size == 0) return SZ_ERROR_ARCHIVE; (_sd_)->Size--; dest = *(_sd_)->Data++; -#define SZ_READ_BYTE(dest) SZ_READ_BYTE_SD(sd, dest) -#define SZ_READ_BYTE_2(dest) if (sd.Size == 0) return SZ_ERROR_ARCHIVE; sd.Size--; dest = *sd.Data++; - -#define SKIP_DATA(sd, size) { sd->Size -= (size_t)(size); sd->Data += (size_t)(size); } -#define SKIP_DATA2(sd, size) { sd.Size -= (size_t)(size); sd.Data += (size_t)(size); } - -#define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \ - dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4); - -static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) -{ - Byte firstByte, mask; - unsigned i; - UInt32 v; - - SZ_READ_BYTE(firstByte); - if ((firstByte & 0x80) == 0) - { - *value = firstByte; - return SZ_OK; - } - SZ_READ_BYTE(v); - if ((firstByte & 0x40) == 0) - { - *value = (((UInt32)firstByte & 0x3F) << 8) | v; - return SZ_OK; - } - SZ_READ_BYTE(mask); - *value = v | ((UInt32)mask << 8); - mask = 0x20; - for (i = 2; i < 8; i++) - { - Byte b; - if ((firstByte & mask) == 0) - { - UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1); - *value |= (highPart << (8 * i)); - return SZ_OK; - } - SZ_READ_BYTE(b); - *value |= ((UInt64)b << (8 * i)); - mask >>= 1; - } - return SZ_OK; -} - - -static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) -{ - Byte firstByte; - UInt64 value64; - if (sd->Size == 0) - return SZ_ERROR_ARCHIVE; - firstByte = *sd->Data; - if ((firstByte & 0x80) == 0) - { - *value = firstByte; - sd->Data++; - sd->Size--; - return SZ_OK; - } - RINOK(ReadNumber(sd, &value64)); - if (value64 >= (UInt32)0x80000000 - 1) - return SZ_ERROR_UNSUPPORTED; - if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 4))) - return SZ_ERROR_UNSUPPORTED; - *value = (UInt32)value64; - return SZ_OK; -} - -#define ReadID(sd, value) ReadNumber(sd, value) - -static SRes SkipData(CSzData *sd) -{ - UInt64 size; - RINOK(ReadNumber(sd, &size)); - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - SKIP_DATA(sd, size); - return SZ_OK; -} - -static SRes WaitId(CSzData *sd, UInt32 id) -{ - for (;;) - { - UInt64 type; - RINOK(ReadID(sd, &type)); - if (type == id) - return SZ_OK; - if (type == k7zIdEnd) - return SZ_ERROR_ARCHIVE; - RINOK(SkipData(sd)); - } -} - -static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v) -{ - UInt32 numBytes = (numItems + 7) >> 3; - if (numBytes > sd->Size) - return SZ_ERROR_ARCHIVE; - *v = sd->Data; - SKIP_DATA(sd, numBytes); - return SZ_OK; -} - -static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) -{ - Byte b = 0; - unsigned m = 0; - UInt32 sum = 0; - for (; numItems != 0; numItems--) - { - if (m == 0) - { - b = *bits++; - m = 8; - } - m--; - sum += ((b >> m) & 1); - } - return sum; -} - -static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, ISzAllocPtr alloc) -{ - Byte allAreDefined; - Byte *v2; - UInt32 numBytes = (numItems + 7) >> 3; - *v = NULL; - SZ_READ_BYTE(allAreDefined); - if (numBytes == 0) - return SZ_OK; - if (allAreDefined == 0) - { - if (numBytes > sd->Size) - return SZ_ERROR_ARCHIVE; - MY_ALLOC_AND_CPY(*v, numBytes, sd->Data, alloc); - SKIP_DATA(sd, numBytes); - return SZ_OK; - } - MY_ALLOC(Byte, *v, numBytes, alloc); - v2 = *v; - memset(v2, 0xFF, (size_t)numBytes); - { - unsigned numBits = (unsigned)numItems & 7; - if (numBits != 0) - v2[(size_t)numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits)); - } - return SZ_OK; -} - -static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) -{ - UInt32 i; - CSzData sd; - UInt32 *vals; - const Byte *defs; - MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc); - sd = *sd2; - defs = crcs->Defs; - vals = crcs->Vals; - for (i = 0; i < numItems; i++) - if (SzBitArray_Check(defs, i)) - { - SZ_READ_32(vals[i]); - } - else - vals[i] = 0; - *sd2 = sd; - return SZ_OK; -} - -static SRes ReadBitUi32s(CSzData *sd, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) -{ - SzBitUi32s_Free(crcs, alloc); - RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc)); - return ReadUi32s(sd, numItems, crcs, alloc); -} - -static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) -{ - Byte allAreDefined; - UInt32 numDefined = numItems; - SZ_READ_BYTE(allAreDefined); - if (!allAreDefined) - { - size_t numBytes = (numItems + 7) >> 3; - if (numBytes > sd->Size) - return SZ_ERROR_ARCHIVE; - numDefined = CountDefinedBits(sd->Data, numItems); - SKIP_DATA(sd, numBytes); - } - if (numDefined > (sd->Size >> 2)) - return SZ_ERROR_ARCHIVE; - SKIP_DATA(sd, (size_t)numDefined * 4); - return SZ_OK; -} - -static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) -{ - RINOK(SzReadNumber32(sd, &p->NumPackStreams)); - - RINOK(WaitId(sd, k7zIdSize)); - MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc); - { - UInt64 sum = 0; - UInt32 i; - UInt32 numPackStreams = p->NumPackStreams; - for (i = 0; i < numPackStreams; i++) - { - UInt64 packSize; - p->PackPositions[i] = sum; - RINOK(ReadNumber(sd, &packSize)); - sum += packSize; - if (sum < packSize) - return SZ_ERROR_ARCHIVE; - } - p->PackPositions[i] = sum; - } - - for (;;) - { - UInt64 type; - RINOK(ReadID(sd, &type)); - if (type == k7zIdEnd) - return SZ_OK; - if (type == k7zIdCRC) - { - /* CRC of packed streams is unused now */ - RINOK(SkipBitUi32s(sd, p->NumPackStreams)); - continue; - } - RINOK(SkipData(sd)); - } -} - -/* -static SRes SzReadSwitch(CSzData *sd) -{ - Byte external; - RINOK(SzReadByte(sd, &external)); - return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; -} -*/ - -#define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) - -SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) -{ - UInt32 numCoders, i; - UInt32 numInStreams = 0; - const Byte *dataStart = sd->Data; - - f->NumCoders = 0; - f->NumBonds = 0; - f->NumPackStreams = 0; - f->UnpackStream = 0; - - RINOK(SzReadNumber32(sd, &numCoders)); - if (numCoders == 0 || numCoders > SZ_NUM_CODERS_IN_FOLDER_MAX) - return SZ_ERROR_UNSUPPORTED; - - for (i = 0; i < numCoders; i++) - { - Byte mainByte; - CSzCoderInfo *coder = f->Coders + i; - unsigned idSize, j; - UInt64 id; - - SZ_READ_BYTE(mainByte); - if ((mainByte & 0xC0) != 0) - return SZ_ERROR_UNSUPPORTED; - - idSize = (unsigned)(mainByte & 0xF); - if (idSize > sizeof(id)) - return SZ_ERROR_UNSUPPORTED; - if (idSize > sd->Size) - return SZ_ERROR_ARCHIVE; - id = 0; - for (j = 0; j < idSize; j++) - { - id = ((id << 8) | *sd->Data); - sd->Data++; - sd->Size--; - } - if (id > (UInt32)0xFFFFFFFF) - return SZ_ERROR_UNSUPPORTED; - coder->MethodID = (UInt32)id; - - coder->NumStreams = 1; - coder->PropsOffset = 0; - coder->PropsSize = 0; - - if ((mainByte & 0x10) != 0) - { - UInt32 numStreams; - - RINOK(SzReadNumber32(sd, &numStreams)); - if (numStreams > k_NumCodersStreams_in_Folder_MAX) - return SZ_ERROR_UNSUPPORTED; - coder->NumStreams = (Byte)numStreams; - - RINOK(SzReadNumber32(sd, &numStreams)); - if (numStreams != 1) - return SZ_ERROR_UNSUPPORTED; - } - - numInStreams += coder->NumStreams; - - if (numInStreams > k_NumCodersStreams_in_Folder_MAX) - return SZ_ERROR_UNSUPPORTED; - - if ((mainByte & 0x20) != 0) - { - UInt32 propsSize = 0; - RINOK(SzReadNumber32(sd, &propsSize)); - if (propsSize > sd->Size) - return SZ_ERROR_ARCHIVE; - if (propsSize >= 0x80) - return SZ_ERROR_UNSUPPORTED; - coder->PropsOffset = (size_t)(sd->Data - dataStart); - coder->PropsSize = (Byte)propsSize; - sd->Data += (size_t)propsSize; - sd->Size -= (size_t)propsSize; - } - } - - /* - if (numInStreams == 1 && numCoders == 1) - { - f->NumPackStreams = 1; - f->PackStreams[0] = 0; - } - else - */ - { - Byte streamUsed[k_NumCodersStreams_in_Folder_MAX]; - UInt32 numBonds, numPackStreams; - - numBonds = numCoders - 1; - if (numInStreams < numBonds) - return SZ_ERROR_ARCHIVE; - if (numBonds > SZ_NUM_BONDS_IN_FOLDER_MAX) - return SZ_ERROR_UNSUPPORTED; - f->NumBonds = numBonds; - - numPackStreams = numInStreams - numBonds; - if (numPackStreams > SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) - return SZ_ERROR_UNSUPPORTED; - f->NumPackStreams = numPackStreams; - - for (i = 0; i < numInStreams; i++) - streamUsed[i] = False; - - if (numBonds != 0) - { - Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX]; - - for (i = 0; i < numCoders; i++) - coderUsed[i] = False; - - for (i = 0; i < numBonds; i++) - { - CSzBond *bp = f->Bonds + i; - - RINOK(SzReadNumber32(sd, &bp->InIndex)); - if (bp->InIndex >= numInStreams || streamUsed[bp->InIndex]) - return SZ_ERROR_ARCHIVE; - streamUsed[bp->InIndex] = True; - - RINOK(SzReadNumber32(sd, &bp->OutIndex)); - if (bp->OutIndex >= numCoders || coderUsed[bp->OutIndex]) - return SZ_ERROR_ARCHIVE; - coderUsed[bp->OutIndex] = True; - } - - for (i = 0; i < numCoders; i++) - if (!coderUsed[i]) - { - f->UnpackStream = i; - break; - } - - if (i == numCoders) - return SZ_ERROR_ARCHIVE; - } - - if (numPackStreams == 1) - { - for (i = 0; i < numInStreams; i++) - if (!streamUsed[i]) - break; - if (i == numInStreams) - return SZ_ERROR_ARCHIVE; - f->PackStreams[0] = i; - } - else - for (i = 0; i < numPackStreams; i++) - { - UInt32 index; - RINOK(SzReadNumber32(sd, &index)); - if (index >= numInStreams || streamUsed[index]) - return SZ_ERROR_ARCHIVE; - streamUsed[index] = True; - f->PackStreams[i] = index; - } - } - - f->NumCoders = numCoders; - - return SZ_OK; -} - - -static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) -{ - CSzData sd; - sd = *sd2; - for (; num != 0; num--) - { - Byte firstByte, mask; - unsigned i; - SZ_READ_BYTE_2(firstByte); - if ((firstByte & 0x80) == 0) - continue; - if ((firstByte & 0x40) == 0) - { - if (sd.Size == 0) - return SZ_ERROR_ARCHIVE; - sd.Size--; - sd.Data++; - continue; - } - mask = 0x20; - for (i = 2; i < 8 && (firstByte & mask) != 0; i++) - mask >>= 1; - if (i > sd.Size) - return SZ_ERROR_ARCHIVE; - SKIP_DATA2(sd, i); - } - *sd2 = sd; - return SZ_OK; -} - - -#define k_Scan_NumCoders_MAX 64 -#define k_Scan_NumCodersStreams_in_Folder_MAX 64 - - -static SRes ReadUnpackInfo(CSzAr *p, - CSzData *sd2, - UInt32 numFoldersMax, - const CBuf *tempBufs, UInt32 numTempBufs, - ISzAllocPtr alloc) -{ - CSzData sd; - - UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex; - const Byte *startBufPtr; - Byte external; - - RINOK(WaitId(sd2, k7zIdFolder)); - - RINOK(SzReadNumber32(sd2, &numFolders)); - if (numFolders > numFoldersMax) - return SZ_ERROR_UNSUPPORTED; - p->NumFolders = numFolders; - - SZ_READ_BYTE_SD(sd2, external); - if (external == 0) - sd = *sd2; - else - { - UInt32 index; - RINOK(SzReadNumber32(sd2, &index)); - if (index >= numTempBufs) - return SZ_ERROR_ARCHIVE; - sd.Data = tempBufs[index].data; - sd.Size = tempBufs[index].size; - } - - MY_ALLOC(size_t, p->FoCodersOffsets, (size_t)numFolders + 1, alloc); - MY_ALLOC(UInt32, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc); - MY_ALLOC(UInt32, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc); - MY_ALLOC_ZE(Byte, p->FoToMainUnpackSizeIndex, (size_t)numFolders, alloc); - - startBufPtr = sd.Data; - - packStreamIndex = 0; - numCodersOutStreams = 0; - - for (fo = 0; fo < numFolders; fo++) - { - UInt32 numCoders, ci, numInStreams = 0; - - p->FoCodersOffsets[fo] = (size_t)(sd.Data - startBufPtr); - - RINOK(SzReadNumber32(&sd, &numCoders)); - if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX) - return SZ_ERROR_UNSUPPORTED; - - for (ci = 0; ci < numCoders; ci++) - { - Byte mainByte; - unsigned idSize; - UInt32 coderInStreams; - - SZ_READ_BYTE_2(mainByte); - if ((mainByte & 0xC0) != 0) - return SZ_ERROR_UNSUPPORTED; - idSize = (mainByte & 0xF); - if (idSize > 8) - return SZ_ERROR_UNSUPPORTED; - if (idSize > sd.Size) - return SZ_ERROR_ARCHIVE; - SKIP_DATA2(sd, idSize); - - coderInStreams = 1; - - if ((mainByte & 0x10) != 0) - { - UInt32 coderOutStreams; - RINOK(SzReadNumber32(&sd, &coderInStreams)); - RINOK(SzReadNumber32(&sd, &coderOutStreams)); - if (coderInStreams > k_Scan_NumCodersStreams_in_Folder_MAX || coderOutStreams != 1) - return SZ_ERROR_UNSUPPORTED; - } - - numInStreams += coderInStreams; - - if ((mainByte & 0x20) != 0) - { - UInt32 propsSize; - RINOK(SzReadNumber32(&sd, &propsSize)); - if (propsSize > sd.Size) - return SZ_ERROR_ARCHIVE; - SKIP_DATA2(sd, propsSize); - } - } - - { - UInt32 indexOfMainStream = 0; - UInt32 numPackStreams = 1; - - if (numCoders != 1 || numInStreams != 1) - { - Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX]; - Byte coderUsed[k_Scan_NumCoders_MAX]; - - UInt32 i; - UInt32 numBonds = numCoders - 1; - if (numInStreams < numBonds) - return SZ_ERROR_ARCHIVE; - - if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX) - return SZ_ERROR_UNSUPPORTED; - - for (i = 0; i < numInStreams; i++) - streamUsed[i] = False; - for (i = 0; i < numCoders; i++) - coderUsed[i] = False; - - for (i = 0; i < numBonds; i++) - { - UInt32 index; - - RINOK(SzReadNumber32(&sd, &index)); - if (index >= numInStreams || streamUsed[index]) - return SZ_ERROR_ARCHIVE; - streamUsed[index] = True; - - RINOK(SzReadNumber32(&sd, &index)); - if (index >= numCoders || coderUsed[index]) - return SZ_ERROR_ARCHIVE; - coderUsed[index] = True; - } - - numPackStreams = numInStreams - numBonds; - - if (numPackStreams != 1) - for (i = 0; i < numPackStreams; i++) - { - UInt32 index; - RINOK(SzReadNumber32(&sd, &index)); - if (index >= numInStreams || streamUsed[index]) - return SZ_ERROR_ARCHIVE; - streamUsed[index] = True; - } - - for (i = 0; i < numCoders; i++) - if (!coderUsed[i]) - { - indexOfMainStream = i; - break; - } - - if (i == numCoders) - return SZ_ERROR_ARCHIVE; - } - - p->FoStartPackStreamIndex[fo] = packStreamIndex; - p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; - p->FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream; - numCodersOutStreams += numCoders; - if (numCodersOutStreams < numCoders) - return SZ_ERROR_UNSUPPORTED; - if (numPackStreams > p->NumPackStreams - packStreamIndex) - return SZ_ERROR_ARCHIVE; - packStreamIndex += numPackStreams; - } - } - - p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; - - { - const size_t dataSize = (size_t)(sd.Data - startBufPtr); - p->FoStartPackStreamIndex[fo] = packStreamIndex; - p->FoCodersOffsets[fo] = dataSize; - MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc); - } - - if (external != 0) - { - if (sd.Size != 0) - return SZ_ERROR_ARCHIVE; - sd = *sd2; - } - - RINOK(WaitId(&sd, k7zIdCodersUnpackSize)); - - MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc); - { - UInt32 i; - for (i = 0; i < numCodersOutStreams; i++) - { - RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i)); - } - } - - for (;;) - { - UInt64 type; - RINOK(ReadID(&sd, &type)); - if (type == k7zIdEnd) - { - *sd2 = sd; - return SZ_OK; - } - if (type == k7zIdCRC) - { - RINOK(ReadBitUi32s(&sd, numFolders, &p->FolderCRCs, alloc)); - continue; - } - RINOK(SkipData(&sd)); - } -} - - -UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex) -{ - return p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex] + p->FoToMainUnpackSizeIndex[folderIndex]]; -} - - -typedef struct -{ - UInt32 NumTotalSubStreams; - UInt32 NumSubDigests; - CSzData sdNumSubStreams; - CSzData sdSizes; - CSzData sdCRCs; -} CSubStreamInfo; - - -static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) -{ - UInt64 type = 0; - UInt32 numSubDigests = 0; - UInt32 numFolders = p->NumFolders; - UInt32 numUnpackStreams = numFolders; - UInt32 numUnpackSizesInData = 0; - - for (;;) - { - RINOK(ReadID(sd, &type)); - if (type == k7zIdNumUnpackStream) - { - UInt32 i; - ssi->sdNumSubStreams.Data = sd->Data; - numUnpackStreams = 0; - numSubDigests = 0; - for (i = 0; i < numFolders; i++) - { - UInt32 numStreams; - RINOK(SzReadNumber32(sd, &numStreams)); - if (numUnpackStreams > numUnpackStreams + numStreams) - return SZ_ERROR_UNSUPPORTED; - numUnpackStreams += numStreams; - if (numStreams != 0) - numUnpackSizesInData += (numStreams - 1); - if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i)) - numSubDigests += numStreams; - } - ssi->sdNumSubStreams.Size = (size_t)(sd->Data - ssi->sdNumSubStreams.Data); - continue; - } - if (type == k7zIdCRC || type == k7zIdSize || type == k7zIdEnd) - break; - RINOK(SkipData(sd)); - } - - if (!ssi->sdNumSubStreams.Data) - { - numSubDigests = numFolders; - if (p->FolderCRCs.Defs) - numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders); - } - - ssi->NumTotalSubStreams = numUnpackStreams; - ssi->NumSubDigests = numSubDigests; - - if (type == k7zIdSize) - { - ssi->sdSizes.Data = sd->Data; - RINOK(SkipNumbers(sd, numUnpackSizesInData)); - ssi->sdSizes.Size = (size_t)(sd->Data - ssi->sdSizes.Data); - RINOK(ReadID(sd, &type)); - } - - for (;;) - { - if (type == k7zIdEnd) - return SZ_OK; - if (type == k7zIdCRC) - { - ssi->sdCRCs.Data = sd->Data; - RINOK(SkipBitUi32s(sd, numSubDigests)); - ssi->sdCRCs.Size = (size_t)(sd->Data - ssi->sdCRCs.Data); - } - else - { - RINOK(SkipData(sd)); - } - RINOK(ReadID(sd, &type)); - } -} - -static SRes SzReadStreamsInfo(CSzAr *p, - CSzData *sd, - UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs, - UInt64 *dataOffset, - CSubStreamInfo *ssi, - ISzAllocPtr alloc) -{ - UInt64 type; - - SzData_Clear(&ssi->sdSizes); - SzData_Clear(&ssi->sdCRCs); - SzData_Clear(&ssi->sdNumSubStreams); - - *dataOffset = 0; - RINOK(ReadID(sd, &type)); - if (type == k7zIdPackInfo) - { - RINOK(ReadNumber(sd, dataOffset)); - if (*dataOffset > p->RangeLimit) - return SZ_ERROR_ARCHIVE; - RINOK(ReadPackInfo(p, sd, alloc)); - if (p->PackPositions[p->NumPackStreams] > p->RangeLimit - *dataOffset) - return SZ_ERROR_ARCHIVE; - RINOK(ReadID(sd, &type)); - } - if (type == k7zIdUnpackInfo) - { - RINOK(ReadUnpackInfo(p, sd, numFoldersMax, tempBufs, numTempBufs, alloc)); - RINOK(ReadID(sd, &type)); - } - if (type == k7zIdSubStreamsInfo) - { - RINOK(ReadSubStreamsInfo(p, sd, ssi)); - RINOK(ReadID(sd, &type)); - } - else - { - ssi->NumTotalSubStreams = p->NumFolders; - // ssi->NumSubDigests = 0; - } - - return (type == k7zIdEnd ? SZ_OK : SZ_ERROR_UNSUPPORTED); -} - -static SRes SzReadAndDecodePackedStreams( - ILookInStream *inStream, - CSzData *sd, - CBuf *tempBufs, - UInt32 numFoldersMax, - UInt64 baseOffset, - CSzAr *p, - ISzAllocPtr allocTemp) -{ - UInt64 dataStartPos; - UInt32 fo; - CSubStreamInfo ssi; - - RINOK(SzReadStreamsInfo(p, sd, numFoldersMax, NULL, 0, &dataStartPos, &ssi, allocTemp)); - - dataStartPos += baseOffset; - if (p->NumFolders == 0) - return SZ_ERROR_ARCHIVE; - - for (fo = 0; fo < p->NumFolders; fo++) - Buf_Init(tempBufs + fo); - - for (fo = 0; fo < p->NumFolders; fo++) - { - CBuf *tempBuf = tempBufs + fo; - UInt64 unpackSize = SzAr_GetFolderUnpackSize(p, fo); - if ((size_t)unpackSize != unpackSize) - return SZ_ERROR_MEM; - if (!Buf_Create(tempBuf, (size_t)unpackSize, allocTemp)) - return SZ_ERROR_MEM; - } - - for (fo = 0; fo < p->NumFolders; fo++) - { - const CBuf *tempBuf = tempBufs + fo; - RINOK(LookInStream_SeekTo(inStream, dataStartPos)); - RINOK(SzAr_DecodeFolder(p, fo, inStream, dataStartPos, tempBuf->data, tempBuf->size, allocTemp)); - } - - return SZ_OK; -} - -static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets) -{ - size_t pos = 0; - *offsets++ = 0; - if (numFiles == 0) - return (size == 0) ? SZ_OK : SZ_ERROR_ARCHIVE; - if (size < 2) - return SZ_ERROR_ARCHIVE; - if (data[size - 2] != 0 || data[size - 1] != 0) - return SZ_ERROR_ARCHIVE; - do - { - const Byte *p; - if (pos == size) - return SZ_ERROR_ARCHIVE; - for (p = data + pos; - #ifdef _WIN32 - *(const UInt16 *)(const void *)p != 0 - #else - p[0] != 0 || p[1] != 0 - #endif - ; p += 2); - pos = (size_t)(p - data) + 2; - *offsets++ = (pos >> 1); - } - while (--numFiles); - return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; -} - -static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num, - CSzData *sd2, - const CBuf *tempBufs, UInt32 numTempBufs, - ISzAllocPtr alloc) -{ - CSzData sd; - UInt32 i; - CNtfsFileTime *vals; - Byte *defs; - Byte external; - - RINOK(ReadBitVector(sd2, num, &p->Defs, alloc)); - - SZ_READ_BYTE_SD(sd2, external); - if (external == 0) - sd = *sd2; - else - { - UInt32 index; - RINOK(SzReadNumber32(sd2, &index)); - if (index >= numTempBufs) - return SZ_ERROR_ARCHIVE; - sd.Data = tempBufs[index].data; - sd.Size = tempBufs[index].size; - } - - MY_ALLOC_ZE(CNtfsFileTime, p->Vals, num, alloc); - vals = p->Vals; - defs = p->Defs; - for (i = 0; i < num; i++) - if (SzBitArray_Check(defs, i)) - { - if (sd.Size < 8) - return SZ_ERROR_ARCHIVE; - vals[i].Low = GetUi32(sd.Data); - vals[i].High = GetUi32(sd.Data + 4); - SKIP_DATA2(sd, 8); - } - else - vals[i].High = vals[i].Low = 0; - - if (external == 0) - *sd2 = sd; - - return SZ_OK; -} - - -#define NUM_ADDITIONAL_STREAMS_MAX 8 - - -static SRes SzReadHeader2( - CSzArEx *p, /* allocMain */ - CSzData *sd, - ILookInStream *inStream, - CBuf *tempBufs, UInt32 *numTempBufs, - ISzAllocPtr allocMain, - ISzAllocPtr allocTemp - ) -{ - CSubStreamInfo ssi; - -{ - UInt64 type; - - SzData_Clear(&ssi.sdSizes); - SzData_Clear(&ssi.sdCRCs); - SzData_Clear(&ssi.sdNumSubStreams); - - ssi.NumSubDigests = 0; - ssi.NumTotalSubStreams = 0; - - RINOK(ReadID(sd, &type)); - - if (type == k7zIdArchiveProperties) - { - for (;;) - { - UInt64 type2; - RINOK(ReadID(sd, &type2)); - if (type2 == k7zIdEnd) - break; - RINOK(SkipData(sd)); - } - RINOK(ReadID(sd, &type)); - } - - if (type == k7zIdAdditionalStreamsInfo) - { - CSzAr tempAr; - SRes res; - - SzAr_Init(&tempAr); - tempAr.RangeLimit = p->db.RangeLimit; - - res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX, - p->startPosAfterHeader, &tempAr, allocTemp); - *numTempBufs = tempAr.NumFolders; - SzAr_Free(&tempAr, allocTemp); - - if (res != SZ_OK) - return res; - RINOK(ReadID(sd, &type)); - } - - if (type == k7zIdMainStreamsInfo) - { - RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs, - &p->dataPos, &ssi, allocMain)); - p->dataPos += p->startPosAfterHeader; - RINOK(ReadID(sd, &type)); - } - - if (type == k7zIdEnd) - { - return SZ_OK; - } - - if (type != k7zIdFilesInfo) - return SZ_ERROR_ARCHIVE; -} - -{ - UInt32 numFiles = 0; - UInt32 numEmptyStreams = 0; - const Byte *emptyStreams = NULL; - const Byte *emptyFiles = NULL; - - RINOK(SzReadNumber32(sd, &numFiles)); - p->NumFiles = numFiles; - - for (;;) - { - UInt64 type; - UInt64 size; - RINOK(ReadID(sd, &type)); - if (type == k7zIdEnd) - break; - RINOK(ReadNumber(sd, &size)); - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - - if (type >= ((UInt32)1 << 8)) - { - SKIP_DATA(sd, size); - } - else switch ((unsigned)type) - { - case k7zIdName: - { - size_t namesSize; - const Byte *namesData; - Byte external; - - SZ_READ_BYTE(external); - if (external == 0) - { - namesSize = (size_t)size - 1; - namesData = sd->Data; - } - else - { - UInt32 index; - RINOK(SzReadNumber32(sd, &index)); - if (index >= *numTempBufs) - return SZ_ERROR_ARCHIVE; - namesData = (tempBufs)[index].data; - namesSize = (tempBufs)[index].size; - } - - if ((namesSize & 1) != 0) - return SZ_ERROR_ARCHIVE; - MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); - MY_ALLOC_ZE_AND_CPY(p->FileNames, namesSize, namesData, allocMain); - RINOK(SzReadFileNames(p->FileNames, namesSize, numFiles, p->FileNameOffsets)) - if (external == 0) - { - SKIP_DATA(sd, namesSize); - } - break; - } - case k7zIdEmptyStream: - { - RINOK(RememberBitVector(sd, numFiles, &emptyStreams)); - numEmptyStreams = CountDefinedBits(emptyStreams, numFiles); - emptyFiles = NULL; - break; - } - case k7zIdEmptyFile: - { - RINOK(RememberBitVector(sd, numEmptyStreams, &emptyFiles)); - break; - } - case k7zIdWinAttrib: - { - Byte external; - CSzData sdSwitch; - CSzData *sdPtr; - SzBitUi32s_Free(&p->Attribs, allocMain); - RINOK(ReadBitVector(sd, numFiles, &p->Attribs.Defs, allocMain)); - - SZ_READ_BYTE(external); - if (external == 0) - sdPtr = sd; - else - { - UInt32 index; - RINOK(SzReadNumber32(sd, &index)); - if (index >= *numTempBufs) - return SZ_ERROR_ARCHIVE; - sdSwitch.Data = (tempBufs)[index].data; - sdSwitch.Size = (tempBufs)[index].size; - sdPtr = &sdSwitch; - } - RINOK(ReadUi32s(sdPtr, numFiles, &p->Attribs, allocMain)); - break; - } - /* - case k7zParent: - { - SzBitUi32s_Free(&p->Parents, allocMain); - RINOK(ReadBitVector(sd, numFiles, &p->Parents.Defs, allocMain)); - RINOK(SzReadSwitch(sd)); - RINOK(ReadUi32s(sd, numFiles, &p->Parents, allocMain)); - break; - } - */ - case k7zIdMTime: RINOK(ReadTime(&p->MTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)); break; - case k7zIdCTime: RINOK(ReadTime(&p->CTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)); break; - default: - { - SKIP_DATA(sd, size); - } - } - } - - if (numFiles - numEmptyStreams != ssi.NumTotalSubStreams) - return SZ_ERROR_ARCHIVE; - - for (;;) - { - UInt64 type; - RINOK(ReadID(sd, &type)); - if (type == k7zIdEnd) - break; - RINOK(SkipData(sd)); - } - - { - UInt32 i; - UInt32 emptyFileIndex = 0; - UInt32 folderIndex = 0; - UInt32 remSubStreams = 0; - UInt32 numSubStreams = 0; - UInt64 unpackPos = 0; - const Byte *digestsDefs = NULL; - const Byte *digestsVals = NULL; - UInt32 digestsValsIndex = 0; - UInt32 digestIndex; - Byte allDigestsDefined = 0; - Byte isDirMask = 0; - Byte crcMask = 0; - Byte mask = 0x80; - - MY_ALLOC(UInt32, p->FolderToFile, p->db.NumFolders + 1, allocMain); - MY_ALLOC_ZE(UInt32, p->FileToFolder, p->NumFiles, allocMain); - MY_ALLOC(UInt64, p->UnpackPositions, p->NumFiles + 1, allocMain); - MY_ALLOC_ZE(Byte, p->IsDirs, (p->NumFiles + 7) >> 3, allocMain); - - RINOK(SzBitUi32s_Alloc(&p->CRCs, p->NumFiles, allocMain)); - - if (ssi.sdCRCs.Size != 0) - { - SZ_READ_BYTE_SD(&ssi.sdCRCs, allDigestsDefined); - if (allDigestsDefined) - digestsVals = ssi.sdCRCs.Data; - else - { - size_t numBytes = (ssi.NumSubDigests + 7) >> 3; - digestsDefs = ssi.sdCRCs.Data; - digestsVals = digestsDefs + numBytes; - } - } - - digestIndex = 0; - - for (i = 0; i < numFiles; i++, mask >>= 1) - { - if (mask == 0) - { - UInt32 byteIndex = (i - 1) >> 3; - p->IsDirs[byteIndex] = isDirMask; - p->CRCs.Defs[byteIndex] = crcMask; - isDirMask = 0; - crcMask = 0; - mask = 0x80; - } - - p->UnpackPositions[i] = unpackPos; - p->CRCs.Vals[i] = 0; - - if (emptyStreams && SzBitArray_Check(emptyStreams, i)) - { - if (emptyFiles) - { - if (!SzBitArray_Check(emptyFiles, emptyFileIndex)) - isDirMask |= mask; - emptyFileIndex++; - } - else - isDirMask |= mask; - if (remSubStreams == 0) - { - p->FileToFolder[i] = (UInt32)-1; - continue; - } - } - - if (remSubStreams == 0) - { - for (;;) - { - if (folderIndex >= p->db.NumFolders) - return SZ_ERROR_ARCHIVE; - p->FolderToFile[folderIndex] = i; - numSubStreams = 1; - if (ssi.sdNumSubStreams.Data) - { - RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams)); - } - remSubStreams = numSubStreams; - if (numSubStreams != 0) - break; - { - UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); - unpackPos += folderUnpackSize; - if (unpackPos < folderUnpackSize) - return SZ_ERROR_ARCHIVE; - } - - folderIndex++; - } - } - - p->FileToFolder[i] = folderIndex; - - if (emptyStreams && SzBitArray_Check(emptyStreams, i)) - continue; - - if (--remSubStreams == 0) - { - UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); - UInt64 startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]]; - if (folderUnpackSize < unpackPos - startFolderUnpackPos) - return SZ_ERROR_ARCHIVE; - unpackPos = startFolderUnpackPos + folderUnpackSize; - if (unpackPos < folderUnpackSize) - return SZ_ERROR_ARCHIVE; - - if (numSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i)) - { - p->CRCs.Vals[i] = p->db.FolderCRCs.Vals[folderIndex]; - crcMask |= mask; - } - else if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex))) - { - p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4); - digestsValsIndex++; - crcMask |= mask; - } - - folderIndex++; - } - else - { - UInt64 v; - RINOK(ReadNumber(&ssi.sdSizes, &v)); - unpackPos += v; - if (unpackPos < v) - return SZ_ERROR_ARCHIVE; - if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex))) - { - p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4); - digestsValsIndex++; - crcMask |= mask; - } - } - } - - if (mask != 0x80) - { - UInt32 byteIndex = (i - 1) >> 3; - p->IsDirs[byteIndex] = isDirMask; - p->CRCs.Defs[byteIndex] = crcMask; - } - - p->UnpackPositions[i] = unpackPos; - - if (remSubStreams != 0) - return SZ_ERROR_ARCHIVE; - - for (;;) - { - p->FolderToFile[folderIndex] = i; - if (folderIndex >= p->db.NumFolders) - break; - if (!ssi.sdNumSubStreams.Data) - return SZ_ERROR_ARCHIVE; - RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams)); - if (numSubStreams != 0) - return SZ_ERROR_ARCHIVE; - /* - { - UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); - unpackPos += folderUnpackSize; - if (unpackPos < folderUnpackSize) - return SZ_ERROR_ARCHIVE; - } - */ - folderIndex++; - } - - if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0) - return SZ_ERROR_ARCHIVE; - } -} - return SZ_OK; -} - - -static SRes SzReadHeader( - CSzArEx *p, - CSzData *sd, - ILookInStream *inStream, - ISzAllocPtr allocMain, - ISzAllocPtr allocTemp) -{ - UInt32 i; - UInt32 numTempBufs = 0; - SRes res; - CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX]; - - for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) - Buf_Init(tempBufs + i); - - res = SzReadHeader2(p, sd, inStream, - tempBufs, &numTempBufs, - allocMain, allocTemp); - - for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) - Buf_Free(tempBufs + i, allocTemp); - - RINOK(res); - - if (sd->Size != 0) - return SZ_ERROR_FAIL; - - return res; -} - -static SRes SzArEx_Open2( - CSzArEx *p, - ILookInStream *inStream, - ISzAllocPtr allocMain, - ISzAllocPtr allocTemp) -{ - Byte header[k7zStartHeaderSize]; - Int64 startArcPos; - UInt64 nextHeaderOffset, nextHeaderSize; - size_t nextHeaderSizeT; - UInt32 nextHeaderCRC; - CBuf buf; - SRes res; - - startArcPos = 0; - RINOK(ILookInStream_Seek(inStream, &startArcPos, SZ_SEEK_CUR)); - - RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); - - if (!TestSignatureCandidate(header)) - return SZ_ERROR_NO_ARCHIVE; - if (header[6] != k7zMajorVersion) - return SZ_ERROR_UNSUPPORTED; - - nextHeaderOffset = GetUi64(header + 12); - nextHeaderSize = GetUi64(header + 20); - nextHeaderCRC = GetUi32(header + 28); - - p->startPosAfterHeader = (UInt64)startArcPos + k7zStartHeaderSize; - - if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) - return SZ_ERROR_CRC; - - p->db.RangeLimit = nextHeaderOffset; - - nextHeaderSizeT = (size_t)nextHeaderSize; - if (nextHeaderSizeT != nextHeaderSize) - return SZ_ERROR_MEM; - if (nextHeaderSizeT == 0) - return SZ_OK; - if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || - nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) - return SZ_ERROR_NO_ARCHIVE; - - { - Int64 pos = 0; - RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END)); - if ((UInt64)pos < (UInt64)startArcPos + nextHeaderOffset || - (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) - return SZ_ERROR_INPUT_EOF; - } - - RINOK(LookInStream_SeekTo(inStream, (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset)); - - if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp)) - return SZ_ERROR_MEM; - - res = LookInStream_Read(inStream, buf.data, nextHeaderSizeT); - - if (res == SZ_OK) - { - res = SZ_ERROR_ARCHIVE; - if (CrcCalc(buf.data, nextHeaderSizeT) == nextHeaderCRC) - { - CSzData sd; - UInt64 type; - sd.Data = buf.data; - sd.Size = buf.size; - - res = ReadID(&sd, &type); - - if (res == SZ_OK && type == k7zIdEncodedHeader) - { - CSzAr tempAr; - CBuf tempBuf; - Buf_Init(&tempBuf); - - SzAr_Init(&tempAr); - tempAr.RangeLimit = p->db.RangeLimit; - - res = SzReadAndDecodePackedStreams(inStream, &sd, &tempBuf, 1, p->startPosAfterHeader, &tempAr, allocTemp); - SzAr_Free(&tempAr, allocTemp); - - if (res != SZ_OK) - { - Buf_Free(&tempBuf, allocTemp); - } - else - { - Buf_Free(&buf, allocTemp); - buf.data = tempBuf.data; - buf.size = tempBuf.size; - sd.Data = buf.data; - sd.Size = buf.size; - res = ReadID(&sd, &type); - } - } - - if (res == SZ_OK) - { - if (type == k7zIdHeader) - { - /* - CSzData sd2; - unsigned ttt; - for (ttt = 0; ttt < 40000; ttt++) - { - SzArEx_Free(p, allocMain); - sd2 = sd; - res = SzReadHeader(p, &sd2, inStream, allocMain, allocTemp); - if (res != SZ_OK) - break; - } - */ - res = SzReadHeader(p, &sd, inStream, allocMain, allocTemp); - } - else - res = SZ_ERROR_UNSUPPORTED; - } - } - } - - Buf_Free(&buf, allocTemp); - return res; -} - - -SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, - ISzAllocPtr allocMain, ISzAllocPtr allocTemp) -{ - SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); - if (res != SZ_OK) - SzArEx_Free(p, allocMain); - return res; -} - - -SRes SzArEx_Extract( - const CSzArEx *p, - ILookInStream *inStream, - UInt32 fileIndex, - UInt32 *blockIndex, - Byte **tempBuf, - size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, - ISzAllocPtr allocMain, - ISzAllocPtr allocTemp) -{ - UInt32 folderIndex = p->FileToFolder[fileIndex]; - SRes res = SZ_OK; - - *offset = 0; - *outSizeProcessed = 0; - - if (folderIndex == (UInt32)-1) - { - ISzAlloc_Free(allocMain, *tempBuf); - *blockIndex = folderIndex; - *tempBuf = NULL; - *outBufferSize = 0; - return SZ_OK; - } - - if (*tempBuf == NULL || *blockIndex != folderIndex) - { - UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex); - /* - UInt64 unpackSizeSpec = - p->UnpackPositions[p->FolderToFile[(size_t)folderIndex + 1]] - - p->UnpackPositions[p->FolderToFile[folderIndex]]; - */ - size_t unpackSize = (size_t)unpackSizeSpec; - - if (unpackSize != unpackSizeSpec) - return SZ_ERROR_MEM; - *blockIndex = folderIndex; - ISzAlloc_Free(allocMain, *tempBuf); - *tempBuf = NULL; - - if (res == SZ_OK) - { - *outBufferSize = unpackSize; - if (unpackSize != 0) - { - *tempBuf = (Byte *)ISzAlloc_Alloc(allocMain, unpackSize); - if (*tempBuf == NULL) - res = SZ_ERROR_MEM; - } - - if (res == SZ_OK) - { - res = SzAr_DecodeFolder(&p->db, folderIndex, - inStream, p->dataPos, *tempBuf, unpackSize, allocTemp); - } - } - } - - if (res == SZ_OK) - { - UInt64 unpackPos = p->UnpackPositions[fileIndex]; - *offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderToFile[folderIndex]]); - *outSizeProcessed = (size_t)(p->UnpackPositions[(size_t)fileIndex + 1] - unpackPos); - if (*offset + *outSizeProcessed > *outBufferSize) - return SZ_ERROR_FAIL; - if (SzBitWithVals_Check(&p->CRCs, fileIndex)) - if (CrcCalc(*tempBuf + *offset, *outSizeProcessed) != p->CRCs.Vals[fileIndex]) - res = SZ_ERROR_CRC; - } - - return res; -} - - -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) -{ - size_t offs = p->FileNameOffsets[fileIndex]; - size_t len = p->FileNameOffsets[fileIndex + 1] - offs; - if (dest != 0) - { - size_t i; - const Byte *src = p->FileNames + offs * 2; - for (i = 0; i < len; i++) - dest[i] = GetUi16(src + i * 2); - } - return len; -} - -/* -size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex) -{ - size_t len; - if (!p->FileNameOffsets) - return 1; - len = 0; - for (;;) - { - UInt32 parent = (UInt32)(Int32)-1; - len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - if SzBitWithVals_Check(&p->Parents, fileIndex) - parent = p->Parents.Vals[fileIndex]; - if (parent == (UInt32)(Int32)-1) - return len; - fileIndex = parent; - } -} - -UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest) -{ - BoolInt needSlash; - if (!p->FileNameOffsets) - { - *(--dest) = 0; - return dest; - } - needSlash = False; - for (;;) - { - UInt32 parent = (UInt32)(Int32)-1; - size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen); - if (needSlash) - *(dest - 1) = '/'; - needSlash = True; - dest -= curLen; - - if SzBitWithVals_Check(&p->Parents, fileIndex) - parent = p->Parents.Vals[fileIndex]; - if (parent == (UInt32)(Int32)-1) - return dest; - fileIndex = parent; - } -} -*/ +/* 7zArcIn.c -- 7z Input functions +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#include "7z.h" +#include "7zBuf.h" +#include "7zCrc.h" +#include "CpuArch.h" + +#define MY_ALLOC(T, p, size, alloc) { \ + if ((p = (T *)ISzAlloc_Alloc(alloc, (size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; } + +#define MY_ALLOC_ZE(T, p, size, alloc) { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) } + +#define MY_ALLOC_AND_CPY(to, size, from, alloc) \ + { MY_ALLOC(Byte, to, size, alloc); memcpy(to, from, size); } + +#define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \ + { if ((size) == 0) to = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } } + +#define k7zMajorVersion 0 + +enum EIdEnum +{ + k7zIdEnd, + k7zIdHeader, + k7zIdArchiveProperties, + k7zIdAdditionalStreamsInfo, + k7zIdMainStreamsInfo, + k7zIdFilesInfo, + k7zIdPackInfo, + k7zIdUnpackInfo, + k7zIdSubStreamsInfo, + k7zIdSize, + k7zIdCRC, + k7zIdFolder, + k7zIdCodersUnpackSize, + k7zIdNumUnpackStream, + k7zIdEmptyStream, + k7zIdEmptyFile, + k7zIdAnti, + k7zIdName, + k7zIdCTime, + k7zIdATime, + k7zIdMTime, + k7zIdWinAttrib, + k7zIdComment, + k7zIdEncodedHeader, + k7zIdStartPos, + k7zIdDummy + // k7zNtSecure, + // k7zParent, + // k7zIsReal +}; + +const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; + +#define SzBitUi32s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; } + +static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) +{ + if (num == 0) + { + p->Defs = NULL; + p->Vals = NULL; + } + else + { + MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc); + MY_ALLOC(UInt32, p->Vals, num, alloc); + } + return SZ_OK; +} + +static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; + ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; +} + +#define SzBitUi64s_Init(p) { (p)->Defs = NULL; (p)->Vals = NULL; } + +static void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; + ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; +} + + +static void SzAr_Init(CSzAr *p) +{ + p->NumPackStreams = 0; + p->NumFolders = 0; + + p->PackPositions = NULL; + SzBitUi32s_Init(&p->FolderCRCs); + + p->FoCodersOffsets = NULL; + p->FoStartPackStreamIndex = NULL; + p->FoToCoderUnpackSizes = NULL; + p->FoToMainUnpackSizeIndex = NULL; + p->CoderUnpackSizes = NULL; + + p->CodersData = NULL; + + p->RangeLimit = 0; +} + +static void SzAr_Free(CSzAr *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->PackPositions); + SzBitUi32s_Free(&p->FolderCRCs, alloc); + + ISzAlloc_Free(alloc, p->FoCodersOffsets); + ISzAlloc_Free(alloc, p->FoStartPackStreamIndex); + ISzAlloc_Free(alloc, p->FoToCoderUnpackSizes); + ISzAlloc_Free(alloc, p->FoToMainUnpackSizeIndex); + ISzAlloc_Free(alloc, p->CoderUnpackSizes); + + ISzAlloc_Free(alloc, p->CodersData); + + SzAr_Init(p); +} + + +void SzArEx_Init(CSzArEx *p) +{ + SzAr_Init(&p->db); + + p->NumFiles = 0; + p->dataPos = 0; + + p->UnpackPositions = NULL; + p->IsDirs = NULL; + + p->FolderToFile = NULL; + p->FileToFolder = NULL; + + p->FileNameOffsets = NULL; + p->FileNames = NULL; + + SzBitUi32s_Init(&p->CRCs); + SzBitUi32s_Init(&p->Attribs); + // SzBitUi32s_Init(&p->Parents); + SzBitUi64s_Init(&p->MTime); + SzBitUi64s_Init(&p->CTime); +} + +void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->UnpackPositions); + ISzAlloc_Free(alloc, p->IsDirs); + + ISzAlloc_Free(alloc, p->FolderToFile); + ISzAlloc_Free(alloc, p->FileToFolder); + + ISzAlloc_Free(alloc, p->FileNameOffsets); + ISzAlloc_Free(alloc, p->FileNames); + + SzBitUi32s_Free(&p->CRCs, alloc); + SzBitUi32s_Free(&p->Attribs, alloc); + // SzBitUi32s_Free(&p->Parents, alloc); + SzBitUi64s_Free(&p->MTime, alloc); + SzBitUi64s_Free(&p->CTime, alloc); + + SzAr_Free(&p->db, alloc); + SzArEx_Init(p); +} + + +static int TestSignatureCandidate(const Byte *testBytes) +{ + unsigned i; + for (i = 0; i < k7zSignatureSize; i++) + if (testBytes[i] != k7zSignature[i]) + return 0; + return 1; +} + +#define SzData_Clear(p) { (p)->Data = NULL; (p)->Size = 0; } + +#define SZ_READ_BYTE_SD(_sd_, dest) if ((_sd_)->Size == 0) return SZ_ERROR_ARCHIVE; (_sd_)->Size--; dest = *(_sd_)->Data++; +#define SZ_READ_BYTE(dest) SZ_READ_BYTE_SD(sd, dest) +#define SZ_READ_BYTE_2(dest) if (sd.Size == 0) return SZ_ERROR_ARCHIVE; sd.Size--; dest = *sd.Data++; + +#define SKIP_DATA(sd, size) { sd->Size -= (size_t)(size); sd->Data += (size_t)(size); } +#define SKIP_DATA2(sd, size) { sd.Size -= (size_t)(size); sd.Data += (size_t)(size); } + +#define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \ + dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4); + +static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) +{ + Byte firstByte, mask; + unsigned i; + UInt32 v; + + SZ_READ_BYTE(firstByte); + if ((firstByte & 0x80) == 0) + { + *value = firstByte; + return SZ_OK; + } + SZ_READ_BYTE(v); + if ((firstByte & 0x40) == 0) + { + *value = (((UInt32)firstByte & 0x3F) << 8) | v; + return SZ_OK; + } + SZ_READ_BYTE(mask); + *value = v | ((UInt32)mask << 8); + mask = 0x20; + for (i = 2; i < 8; i++) + { + Byte b; + if ((firstByte & mask) == 0) + { + UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1); + *value |= (highPart << (8 * i)); + return SZ_OK; + } + SZ_READ_BYTE(b); + *value |= ((UInt64)b << (8 * i)); + mask >>= 1; + } + return SZ_OK; +} + + +static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) +{ + Byte firstByte; + UInt64 value64; + if (sd->Size == 0) + return SZ_ERROR_ARCHIVE; + firstByte = *sd->Data; + if ((firstByte & 0x80) == 0) + { + *value = firstByte; + sd->Data++; + sd->Size--; + return SZ_OK; + } + RINOK(ReadNumber(sd, &value64)); + if (value64 >= (UInt32)0x80000000 - 1) + return SZ_ERROR_UNSUPPORTED; + if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 4))) + return SZ_ERROR_UNSUPPORTED; + *value = (UInt32)value64; + return SZ_OK; +} + +#define ReadID(sd, value) ReadNumber(sd, value) + +static SRes SkipData(CSzData *sd) +{ + UInt64 size; + RINOK(ReadNumber(sd, &size)); + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + SKIP_DATA(sd, size); + return SZ_OK; +} + +static SRes WaitId(CSzData *sd, UInt32 id) +{ + for (;;) + { + UInt64 type; + RINOK(ReadID(sd, &type)); + if (type == id) + return SZ_OK; + if (type == k7zIdEnd) + return SZ_ERROR_ARCHIVE; + RINOK(SkipData(sd)); + } +} + +static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v) +{ + UInt32 numBytes = (numItems + 7) >> 3; + if (numBytes > sd->Size) + return SZ_ERROR_ARCHIVE; + *v = sd->Data; + SKIP_DATA(sd, numBytes); + return SZ_OK; +} + +static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) +{ + Byte b = 0; + unsigned m = 0; + UInt32 sum = 0; + for (; numItems != 0; numItems--) + { + if (m == 0) + { + b = *bits++; + m = 8; + } + m--; + sum += ((b >> m) & 1); + } + return sum; +} + +static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, ISzAllocPtr alloc) +{ + Byte allAreDefined; + Byte *v2; + UInt32 numBytes = (numItems + 7) >> 3; + *v = NULL; + SZ_READ_BYTE(allAreDefined); + if (numBytes == 0) + return SZ_OK; + if (allAreDefined == 0) + { + if (numBytes > sd->Size) + return SZ_ERROR_ARCHIVE; + MY_ALLOC_AND_CPY(*v, numBytes, sd->Data, alloc); + SKIP_DATA(sd, numBytes); + return SZ_OK; + } + MY_ALLOC(Byte, *v, numBytes, alloc); + v2 = *v; + memset(v2, 0xFF, (size_t)numBytes); + { + unsigned numBits = (unsigned)numItems & 7; + if (numBits != 0) + v2[(size_t)numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits)); + } + return SZ_OK; +} + +static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) +{ + UInt32 i; + CSzData sd; + UInt32 *vals; + const Byte *defs; + MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc); + sd = *sd2; + defs = crcs->Defs; + vals = crcs->Vals; + for (i = 0; i < numItems; i++) + if (SzBitArray_Check(defs, i)) + { + SZ_READ_32(vals[i]); + } + else + vals[i] = 0; + *sd2 = sd; + return SZ_OK; +} + +static SRes ReadBitUi32s(CSzData *sd, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) +{ + SzBitUi32s_Free(crcs, alloc); + RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc)); + return ReadUi32s(sd, numItems, crcs, alloc); +} + +static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) +{ + Byte allAreDefined; + UInt32 numDefined = numItems; + SZ_READ_BYTE(allAreDefined); + if (!allAreDefined) + { + size_t numBytes = (numItems + 7) >> 3; + if (numBytes > sd->Size) + return SZ_ERROR_ARCHIVE; + numDefined = CountDefinedBits(sd->Data, numItems); + SKIP_DATA(sd, numBytes); + } + if (numDefined > (sd->Size >> 2)) + return SZ_ERROR_ARCHIVE; + SKIP_DATA(sd, (size_t)numDefined * 4); + return SZ_OK; +} + +static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) +{ + RINOK(SzReadNumber32(sd, &p->NumPackStreams)); + + RINOK(WaitId(sd, k7zIdSize)); + MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc); + { + UInt64 sum = 0; + UInt32 i; + UInt32 numPackStreams = p->NumPackStreams; + for (i = 0; i < numPackStreams; i++) + { + UInt64 packSize; + p->PackPositions[i] = sum; + RINOK(ReadNumber(sd, &packSize)); + sum += packSize; + if (sum < packSize) + return SZ_ERROR_ARCHIVE; + } + p->PackPositions[i] = sum; + } + + for (;;) + { + UInt64 type; + RINOK(ReadID(sd, &type)); + if (type == k7zIdEnd) + return SZ_OK; + if (type == k7zIdCRC) + { + /* CRC of packed streams is unused now */ + RINOK(SkipBitUi32s(sd, p->NumPackStreams)); + continue; + } + RINOK(SkipData(sd)); + } +} + +/* +static SRes SzReadSwitch(CSzData *sd) +{ + Byte external; + RINOK(SzReadByte(sd, &external)); + return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; +} +*/ + +#define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) + +SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) +{ + UInt32 numCoders, i; + UInt32 numInStreams = 0; + const Byte *dataStart = sd->Data; + + f->NumCoders = 0; + f->NumBonds = 0; + f->NumPackStreams = 0; + f->UnpackStream = 0; + + RINOK(SzReadNumber32(sd, &numCoders)); + if (numCoders == 0 || numCoders > SZ_NUM_CODERS_IN_FOLDER_MAX) + return SZ_ERROR_UNSUPPORTED; + + for (i = 0; i < numCoders; i++) + { + Byte mainByte; + CSzCoderInfo *coder = f->Coders + i; + unsigned idSize, j; + UInt64 id; + + SZ_READ_BYTE(mainByte); + if ((mainByte & 0xC0) != 0) + return SZ_ERROR_UNSUPPORTED; + + idSize = (unsigned)(mainByte & 0xF); + if (idSize > sizeof(id)) + return SZ_ERROR_UNSUPPORTED; + if (idSize > sd->Size) + return SZ_ERROR_ARCHIVE; + id = 0; + for (j = 0; j < idSize; j++) + { + id = ((id << 8) | *sd->Data); + sd->Data++; + sd->Size--; + } + if (id > (UInt32)0xFFFFFFFF) + return SZ_ERROR_UNSUPPORTED; + coder->MethodID = (UInt32)id; + + coder->NumStreams = 1; + coder->PropsOffset = 0; + coder->PropsSize = 0; + + if ((mainByte & 0x10) != 0) + { + UInt32 numStreams; + + RINOK(SzReadNumber32(sd, &numStreams)); + if (numStreams > k_NumCodersStreams_in_Folder_MAX) + return SZ_ERROR_UNSUPPORTED; + coder->NumStreams = (Byte)numStreams; + + RINOK(SzReadNumber32(sd, &numStreams)); + if (numStreams != 1) + return SZ_ERROR_UNSUPPORTED; + } + + numInStreams += coder->NumStreams; + + if (numInStreams > k_NumCodersStreams_in_Folder_MAX) + return SZ_ERROR_UNSUPPORTED; + + if ((mainByte & 0x20) != 0) + { + UInt32 propsSize = 0; + RINOK(SzReadNumber32(sd, &propsSize)); + if (propsSize > sd->Size) + return SZ_ERROR_ARCHIVE; + if (propsSize >= 0x80) + return SZ_ERROR_UNSUPPORTED; + coder->PropsOffset = (size_t)(sd->Data - dataStart); + coder->PropsSize = (Byte)propsSize; + sd->Data += (size_t)propsSize; + sd->Size -= (size_t)propsSize; + } + } + + /* + if (numInStreams == 1 && numCoders == 1) + { + f->NumPackStreams = 1; + f->PackStreams[0] = 0; + } + else + */ + { + Byte streamUsed[k_NumCodersStreams_in_Folder_MAX]; + UInt32 numBonds, numPackStreams; + + numBonds = numCoders - 1; + if (numInStreams < numBonds) + return SZ_ERROR_ARCHIVE; + if (numBonds > SZ_NUM_BONDS_IN_FOLDER_MAX) + return SZ_ERROR_UNSUPPORTED; + f->NumBonds = numBonds; + + numPackStreams = numInStreams - numBonds; + if (numPackStreams > SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) + return SZ_ERROR_UNSUPPORTED; + f->NumPackStreams = numPackStreams; + + for (i = 0; i < numInStreams; i++) + streamUsed[i] = False; + + if (numBonds != 0) + { + Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX]; + + for (i = 0; i < numCoders; i++) + coderUsed[i] = False; + + for (i = 0; i < numBonds; i++) + { + CSzBond *bp = f->Bonds + i; + + RINOK(SzReadNumber32(sd, &bp->InIndex)); + if (bp->InIndex >= numInStreams || streamUsed[bp->InIndex]) + return SZ_ERROR_ARCHIVE; + streamUsed[bp->InIndex] = True; + + RINOK(SzReadNumber32(sd, &bp->OutIndex)); + if (bp->OutIndex >= numCoders || coderUsed[bp->OutIndex]) + return SZ_ERROR_ARCHIVE; + coderUsed[bp->OutIndex] = True; + } + + for (i = 0; i < numCoders; i++) + if (!coderUsed[i]) + { + f->UnpackStream = i; + break; + } + + if (i == numCoders) + return SZ_ERROR_ARCHIVE; + } + + if (numPackStreams == 1) + { + for (i = 0; i < numInStreams; i++) + if (!streamUsed[i]) + break; + if (i == numInStreams) + return SZ_ERROR_ARCHIVE; + f->PackStreams[0] = i; + } + else + for (i = 0; i < numPackStreams; i++) + { + UInt32 index; + RINOK(SzReadNumber32(sd, &index)); + if (index >= numInStreams || streamUsed[index]) + return SZ_ERROR_ARCHIVE; + streamUsed[index] = True; + f->PackStreams[i] = index; + } + } + + f->NumCoders = numCoders; + + return SZ_OK; +} + + +static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) +{ + CSzData sd; + sd = *sd2; + for (; num != 0; num--) + { + Byte firstByte, mask; + unsigned i; + SZ_READ_BYTE_2(firstByte); + if ((firstByte & 0x80) == 0) + continue; + if ((firstByte & 0x40) == 0) + { + if (sd.Size == 0) + return SZ_ERROR_ARCHIVE; + sd.Size--; + sd.Data++; + continue; + } + mask = 0x20; + for (i = 2; i < 8 && (firstByte & mask) != 0; i++) + mask >>= 1; + if (i > sd.Size) + return SZ_ERROR_ARCHIVE; + SKIP_DATA2(sd, i); + } + *sd2 = sd; + return SZ_OK; +} + + +#define k_Scan_NumCoders_MAX 64 +#define k_Scan_NumCodersStreams_in_Folder_MAX 64 + + +static SRes ReadUnpackInfo(CSzAr *p, + CSzData *sd2, + UInt32 numFoldersMax, + const CBuf *tempBufs, UInt32 numTempBufs, + ISzAllocPtr alloc) +{ + CSzData sd; + + UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex; + const Byte *startBufPtr; + Byte external; + + RINOK(WaitId(sd2, k7zIdFolder)); + + RINOK(SzReadNumber32(sd2, &numFolders)); + if (numFolders > numFoldersMax) + return SZ_ERROR_UNSUPPORTED; + p->NumFolders = numFolders; + + SZ_READ_BYTE_SD(sd2, external); + if (external == 0) + sd = *sd2; + else + { + UInt32 index; + RINOK(SzReadNumber32(sd2, &index)); + if (index >= numTempBufs) + return SZ_ERROR_ARCHIVE; + sd.Data = tempBufs[index].data; + sd.Size = tempBufs[index].size; + } + + MY_ALLOC(size_t, p->FoCodersOffsets, (size_t)numFolders + 1, alloc); + MY_ALLOC(UInt32, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc); + MY_ALLOC(UInt32, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc); + MY_ALLOC_ZE(Byte, p->FoToMainUnpackSizeIndex, (size_t)numFolders, alloc); + + startBufPtr = sd.Data; + + packStreamIndex = 0; + numCodersOutStreams = 0; + + for (fo = 0; fo < numFolders; fo++) + { + UInt32 numCoders, ci, numInStreams = 0; + + p->FoCodersOffsets[fo] = (size_t)(sd.Data - startBufPtr); + + RINOK(SzReadNumber32(&sd, &numCoders)); + if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX) + return SZ_ERROR_UNSUPPORTED; + + for (ci = 0; ci < numCoders; ci++) + { + Byte mainByte; + unsigned idSize; + UInt32 coderInStreams; + + SZ_READ_BYTE_2(mainByte); + if ((mainByte & 0xC0) != 0) + return SZ_ERROR_UNSUPPORTED; + idSize = (mainByte & 0xF); + if (idSize > 8) + return SZ_ERROR_UNSUPPORTED; + if (idSize > sd.Size) + return SZ_ERROR_ARCHIVE; + SKIP_DATA2(sd, idSize); + + coderInStreams = 1; + + if ((mainByte & 0x10) != 0) + { + UInt32 coderOutStreams; + RINOK(SzReadNumber32(&sd, &coderInStreams)); + RINOK(SzReadNumber32(&sd, &coderOutStreams)); + if (coderInStreams > k_Scan_NumCodersStreams_in_Folder_MAX || coderOutStreams != 1) + return SZ_ERROR_UNSUPPORTED; + } + + numInStreams += coderInStreams; + + if ((mainByte & 0x20) != 0) + { + UInt32 propsSize; + RINOK(SzReadNumber32(&sd, &propsSize)); + if (propsSize > sd.Size) + return SZ_ERROR_ARCHIVE; + SKIP_DATA2(sd, propsSize); + } + } + + { + UInt32 indexOfMainStream = 0; + UInt32 numPackStreams = 1; + + if (numCoders != 1 || numInStreams != 1) + { + Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX]; + Byte coderUsed[k_Scan_NumCoders_MAX]; + + UInt32 i; + UInt32 numBonds = numCoders - 1; + if (numInStreams < numBonds) + return SZ_ERROR_ARCHIVE; + + if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX) + return SZ_ERROR_UNSUPPORTED; + + for (i = 0; i < numInStreams; i++) + streamUsed[i] = False; + for (i = 0; i < numCoders; i++) + coderUsed[i] = False; + + for (i = 0; i < numBonds; i++) + { + UInt32 index; + + RINOK(SzReadNumber32(&sd, &index)); + if (index >= numInStreams || streamUsed[index]) + return SZ_ERROR_ARCHIVE; + streamUsed[index] = True; + + RINOK(SzReadNumber32(&sd, &index)); + if (index >= numCoders || coderUsed[index]) + return SZ_ERROR_ARCHIVE; + coderUsed[index] = True; + } + + numPackStreams = numInStreams - numBonds; + + if (numPackStreams != 1) + for (i = 0; i < numPackStreams; i++) + { + UInt32 index; + RINOK(SzReadNumber32(&sd, &index)); + if (index >= numInStreams || streamUsed[index]) + return SZ_ERROR_ARCHIVE; + streamUsed[index] = True; + } + + for (i = 0; i < numCoders; i++) + if (!coderUsed[i]) + { + indexOfMainStream = i; + break; + } + + if (i == numCoders) + return SZ_ERROR_ARCHIVE; + } + + p->FoStartPackStreamIndex[fo] = packStreamIndex; + p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; + p->FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream; + numCodersOutStreams += numCoders; + if (numCodersOutStreams < numCoders) + return SZ_ERROR_UNSUPPORTED; + if (numPackStreams > p->NumPackStreams - packStreamIndex) + return SZ_ERROR_ARCHIVE; + packStreamIndex += numPackStreams; + } + } + + p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; + + { + const size_t dataSize = (size_t)(sd.Data - startBufPtr); + p->FoStartPackStreamIndex[fo] = packStreamIndex; + p->FoCodersOffsets[fo] = dataSize; + MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc); + } + + if (external != 0) + { + if (sd.Size != 0) + return SZ_ERROR_ARCHIVE; + sd = *sd2; + } + + RINOK(WaitId(&sd, k7zIdCodersUnpackSize)); + + MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc); + { + UInt32 i; + for (i = 0; i < numCodersOutStreams; i++) + { + RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i)); + } + } + + for (;;) + { + UInt64 type; + RINOK(ReadID(&sd, &type)); + if (type == k7zIdEnd) + { + *sd2 = sd; + return SZ_OK; + } + if (type == k7zIdCRC) + { + RINOK(ReadBitUi32s(&sd, numFolders, &p->FolderCRCs, alloc)); + continue; + } + RINOK(SkipData(&sd)); + } +} + + +UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex) +{ + return p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex] + p->FoToMainUnpackSizeIndex[folderIndex]]; +} + + +typedef struct +{ + UInt32 NumTotalSubStreams; + UInt32 NumSubDigests; + CSzData sdNumSubStreams; + CSzData sdSizes; + CSzData sdCRCs; +} CSubStreamInfo; + + +static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) +{ + UInt64 type = 0; + UInt32 numSubDigests = 0; + UInt32 numFolders = p->NumFolders; + UInt32 numUnpackStreams = numFolders; + UInt32 numUnpackSizesInData = 0; + + for (;;) + { + RINOK(ReadID(sd, &type)); + if (type == k7zIdNumUnpackStream) + { + UInt32 i; + ssi->sdNumSubStreams.Data = sd->Data; + numUnpackStreams = 0; + numSubDigests = 0; + for (i = 0; i < numFolders; i++) + { + UInt32 numStreams; + RINOK(SzReadNumber32(sd, &numStreams)); + if (numUnpackStreams > numUnpackStreams + numStreams) + return SZ_ERROR_UNSUPPORTED; + numUnpackStreams += numStreams; + if (numStreams != 0) + numUnpackSizesInData += (numStreams - 1); + if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i)) + numSubDigests += numStreams; + } + ssi->sdNumSubStreams.Size = (size_t)(sd->Data - ssi->sdNumSubStreams.Data); + continue; + } + if (type == k7zIdCRC || type == k7zIdSize || type == k7zIdEnd) + break; + RINOK(SkipData(sd)); + } + + if (!ssi->sdNumSubStreams.Data) + { + numSubDigests = numFolders; + if (p->FolderCRCs.Defs) + numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders); + } + + ssi->NumTotalSubStreams = numUnpackStreams; + ssi->NumSubDigests = numSubDigests; + + if (type == k7zIdSize) + { + ssi->sdSizes.Data = sd->Data; + RINOK(SkipNumbers(sd, numUnpackSizesInData)); + ssi->sdSizes.Size = (size_t)(sd->Data - ssi->sdSizes.Data); + RINOK(ReadID(sd, &type)); + } + + for (;;) + { + if (type == k7zIdEnd) + return SZ_OK; + if (type == k7zIdCRC) + { + ssi->sdCRCs.Data = sd->Data; + RINOK(SkipBitUi32s(sd, numSubDigests)); + ssi->sdCRCs.Size = (size_t)(sd->Data - ssi->sdCRCs.Data); + } + else + { + RINOK(SkipData(sd)); + } + RINOK(ReadID(sd, &type)); + } +} + +static SRes SzReadStreamsInfo(CSzAr *p, + CSzData *sd, + UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs, + UInt64 *dataOffset, + CSubStreamInfo *ssi, + ISzAllocPtr alloc) +{ + UInt64 type; + + SzData_Clear(&ssi->sdSizes); + SzData_Clear(&ssi->sdCRCs); + SzData_Clear(&ssi->sdNumSubStreams); + + *dataOffset = 0; + RINOK(ReadID(sd, &type)); + if (type == k7zIdPackInfo) + { + RINOK(ReadNumber(sd, dataOffset)); + if (*dataOffset > p->RangeLimit) + return SZ_ERROR_ARCHIVE; + RINOK(ReadPackInfo(p, sd, alloc)); + if (p->PackPositions[p->NumPackStreams] > p->RangeLimit - *dataOffset) + return SZ_ERROR_ARCHIVE; + RINOK(ReadID(sd, &type)); + } + if (type == k7zIdUnpackInfo) + { + RINOK(ReadUnpackInfo(p, sd, numFoldersMax, tempBufs, numTempBufs, alloc)); + RINOK(ReadID(sd, &type)); + } + if (type == k7zIdSubStreamsInfo) + { + RINOK(ReadSubStreamsInfo(p, sd, ssi)); + RINOK(ReadID(sd, &type)); + } + else + { + ssi->NumTotalSubStreams = p->NumFolders; + // ssi->NumSubDigests = 0; + } + + return (type == k7zIdEnd ? SZ_OK : SZ_ERROR_UNSUPPORTED); +} + +static SRes SzReadAndDecodePackedStreams( + ILookInStream *inStream, + CSzData *sd, + CBuf *tempBufs, + UInt32 numFoldersMax, + UInt64 baseOffset, + CSzAr *p, + ISzAllocPtr allocTemp) +{ + UInt64 dataStartPos; + UInt32 fo; + CSubStreamInfo ssi; + + RINOK(SzReadStreamsInfo(p, sd, numFoldersMax, NULL, 0, &dataStartPos, &ssi, allocTemp)); + + dataStartPos += baseOffset; + if (p->NumFolders == 0) + return SZ_ERROR_ARCHIVE; + + for (fo = 0; fo < p->NumFolders; fo++) + Buf_Init(tempBufs + fo); + + for (fo = 0; fo < p->NumFolders; fo++) + { + CBuf *tempBuf = tempBufs + fo; + UInt64 unpackSize = SzAr_GetFolderUnpackSize(p, fo); + if ((size_t)unpackSize != unpackSize) + return SZ_ERROR_MEM; + if (!Buf_Create(tempBuf, (size_t)unpackSize, allocTemp)) + return SZ_ERROR_MEM; + } + + for (fo = 0; fo < p->NumFolders; fo++) + { + const CBuf *tempBuf = tempBufs + fo; + RINOK(LookInStream_SeekTo(inStream, dataStartPos)); + RINOK(SzAr_DecodeFolder(p, fo, inStream, dataStartPos, tempBuf->data, tempBuf->size, allocTemp)); + } + + return SZ_OK; +} + +static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets) +{ + size_t pos = 0; + *offsets++ = 0; + if (numFiles == 0) + return (size == 0) ? SZ_OK : SZ_ERROR_ARCHIVE; + if (size < 2) + return SZ_ERROR_ARCHIVE; + if (data[size - 2] != 0 || data[size - 1] != 0) + return SZ_ERROR_ARCHIVE; + do + { + const Byte *p; + if (pos == size) + return SZ_ERROR_ARCHIVE; + for (p = data + pos; + #ifdef _WIN32 + *(const UInt16 *)(const void *)p != 0 + #else + p[0] != 0 || p[1] != 0 + #endif + ; p += 2); + pos = (size_t)(p - data) + 2; + *offsets++ = (pos >> 1); + } + while (--numFiles); + return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; +} + +static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num, + CSzData *sd2, + const CBuf *tempBufs, UInt32 numTempBufs, + ISzAllocPtr alloc) +{ + CSzData sd; + UInt32 i; + CNtfsFileTime *vals; + Byte *defs; + Byte external; + + RINOK(ReadBitVector(sd2, num, &p->Defs, alloc)); + + SZ_READ_BYTE_SD(sd2, external); + if (external == 0) + sd = *sd2; + else + { + UInt32 index; + RINOK(SzReadNumber32(sd2, &index)); + if (index >= numTempBufs) + return SZ_ERROR_ARCHIVE; + sd.Data = tempBufs[index].data; + sd.Size = tempBufs[index].size; + } + + MY_ALLOC_ZE(CNtfsFileTime, p->Vals, num, alloc); + vals = p->Vals; + defs = p->Defs; + for (i = 0; i < num; i++) + if (SzBitArray_Check(defs, i)) + { + if (sd.Size < 8) + return SZ_ERROR_ARCHIVE; + vals[i].Low = GetUi32(sd.Data); + vals[i].High = GetUi32(sd.Data + 4); + SKIP_DATA2(sd, 8); + } + else + vals[i].High = vals[i].Low = 0; + + if (external == 0) + *sd2 = sd; + + return SZ_OK; +} + + +#define NUM_ADDITIONAL_STREAMS_MAX 8 + + +static SRes SzReadHeader2( + CSzArEx *p, /* allocMain */ + CSzData *sd, + ILookInStream *inStream, + CBuf *tempBufs, UInt32 *numTempBufs, + ISzAllocPtr allocMain, + ISzAllocPtr allocTemp + ) +{ + CSubStreamInfo ssi; + +{ + UInt64 type; + + SzData_Clear(&ssi.sdSizes); + SzData_Clear(&ssi.sdCRCs); + SzData_Clear(&ssi.sdNumSubStreams); + + ssi.NumSubDigests = 0; + ssi.NumTotalSubStreams = 0; + + RINOK(ReadID(sd, &type)); + + if (type == k7zIdArchiveProperties) + { + for (;;) + { + UInt64 type2; + RINOK(ReadID(sd, &type2)); + if (type2 == k7zIdEnd) + break; + RINOK(SkipData(sd)); + } + RINOK(ReadID(sd, &type)); + } + + if (type == k7zIdAdditionalStreamsInfo) + { + CSzAr tempAr; + SRes res; + + SzAr_Init(&tempAr); + tempAr.RangeLimit = p->db.RangeLimit; + + res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX, + p->startPosAfterHeader, &tempAr, allocTemp); + *numTempBufs = tempAr.NumFolders; + SzAr_Free(&tempAr, allocTemp); + + if (res != SZ_OK) + return res; + RINOK(ReadID(sd, &type)); + } + + if (type == k7zIdMainStreamsInfo) + { + RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs, + &p->dataPos, &ssi, allocMain)); + p->dataPos += p->startPosAfterHeader; + RINOK(ReadID(sd, &type)); + } + + if (type == k7zIdEnd) + { + return SZ_OK; + } + + if (type != k7zIdFilesInfo) + return SZ_ERROR_ARCHIVE; +} + +{ + UInt32 numFiles = 0; + UInt32 numEmptyStreams = 0; + const Byte *emptyStreams = NULL; + const Byte *emptyFiles = NULL; + + RINOK(SzReadNumber32(sd, &numFiles)); + p->NumFiles = numFiles; + + for (;;) + { + UInt64 type; + UInt64 size; + RINOK(ReadID(sd, &type)); + if (type == k7zIdEnd) + break; + RINOK(ReadNumber(sd, &size)); + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + + if (type >= ((UInt32)1 << 8)) + { + SKIP_DATA(sd, size); + } + else switch ((unsigned)type) + { + case k7zIdName: + { + size_t namesSize; + const Byte *namesData; + Byte external; + + SZ_READ_BYTE(external); + if (external == 0) + { + namesSize = (size_t)size - 1; + namesData = sd->Data; + } + else + { + UInt32 index; + RINOK(SzReadNumber32(sd, &index)); + if (index >= *numTempBufs) + return SZ_ERROR_ARCHIVE; + namesData = (tempBufs)[index].data; + namesSize = (tempBufs)[index].size; + } + + if ((namesSize & 1) != 0) + return SZ_ERROR_ARCHIVE; + MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); + MY_ALLOC_ZE_AND_CPY(p->FileNames, namesSize, namesData, allocMain); + RINOK(SzReadFileNames(p->FileNames, namesSize, numFiles, p->FileNameOffsets)) + if (external == 0) + { + SKIP_DATA(sd, namesSize); + } + break; + } + case k7zIdEmptyStream: + { + RINOK(RememberBitVector(sd, numFiles, &emptyStreams)); + numEmptyStreams = CountDefinedBits(emptyStreams, numFiles); + emptyFiles = NULL; + break; + } + case k7zIdEmptyFile: + { + RINOK(RememberBitVector(sd, numEmptyStreams, &emptyFiles)); + break; + } + case k7zIdWinAttrib: + { + Byte external; + CSzData sdSwitch; + CSzData *sdPtr; + SzBitUi32s_Free(&p->Attribs, allocMain); + RINOK(ReadBitVector(sd, numFiles, &p->Attribs.Defs, allocMain)); + + SZ_READ_BYTE(external); + if (external == 0) + sdPtr = sd; + else + { + UInt32 index; + RINOK(SzReadNumber32(sd, &index)); + if (index >= *numTempBufs) + return SZ_ERROR_ARCHIVE; + sdSwitch.Data = (tempBufs)[index].data; + sdSwitch.Size = (tempBufs)[index].size; + sdPtr = &sdSwitch; + } + RINOK(ReadUi32s(sdPtr, numFiles, &p->Attribs, allocMain)); + break; + } + /* + case k7zParent: + { + SzBitUi32s_Free(&p->Parents, allocMain); + RINOK(ReadBitVector(sd, numFiles, &p->Parents.Defs, allocMain)); + RINOK(SzReadSwitch(sd)); + RINOK(ReadUi32s(sd, numFiles, &p->Parents, allocMain)); + break; + } + */ + case k7zIdMTime: RINOK(ReadTime(&p->MTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)); break; + case k7zIdCTime: RINOK(ReadTime(&p->CTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)); break; + default: + { + SKIP_DATA(sd, size); + } + } + } + + if (numFiles - numEmptyStreams != ssi.NumTotalSubStreams) + return SZ_ERROR_ARCHIVE; + + for (;;) + { + UInt64 type; + RINOK(ReadID(sd, &type)); + if (type == k7zIdEnd) + break; + RINOK(SkipData(sd)); + } + + { + UInt32 i; + UInt32 emptyFileIndex = 0; + UInt32 folderIndex = 0; + UInt32 remSubStreams = 0; + UInt32 numSubStreams = 0; + UInt64 unpackPos = 0; + const Byte *digestsDefs = NULL; + const Byte *digestsVals = NULL; + UInt32 digestsValsIndex = 0; + UInt32 digestIndex; + Byte allDigestsDefined = 0; + Byte isDirMask = 0; + Byte crcMask = 0; + Byte mask = 0x80; + + MY_ALLOC(UInt32, p->FolderToFile, p->db.NumFolders + 1, allocMain); + MY_ALLOC_ZE(UInt32, p->FileToFolder, p->NumFiles, allocMain); + MY_ALLOC(UInt64, p->UnpackPositions, p->NumFiles + 1, allocMain); + MY_ALLOC_ZE(Byte, p->IsDirs, (p->NumFiles + 7) >> 3, allocMain); + + RINOK(SzBitUi32s_Alloc(&p->CRCs, p->NumFiles, allocMain)); + + if (ssi.sdCRCs.Size != 0) + { + SZ_READ_BYTE_SD(&ssi.sdCRCs, allDigestsDefined); + if (allDigestsDefined) + digestsVals = ssi.sdCRCs.Data; + else + { + size_t numBytes = (ssi.NumSubDigests + 7) >> 3; + digestsDefs = ssi.sdCRCs.Data; + digestsVals = digestsDefs + numBytes; + } + } + + digestIndex = 0; + + for (i = 0; i < numFiles; i++, mask >>= 1) + { + if (mask == 0) + { + UInt32 byteIndex = (i - 1) >> 3; + p->IsDirs[byteIndex] = isDirMask; + p->CRCs.Defs[byteIndex] = crcMask; + isDirMask = 0; + crcMask = 0; + mask = 0x80; + } + + p->UnpackPositions[i] = unpackPos; + p->CRCs.Vals[i] = 0; + + if (emptyStreams && SzBitArray_Check(emptyStreams, i)) + { + if (emptyFiles) + { + if (!SzBitArray_Check(emptyFiles, emptyFileIndex)) + isDirMask |= mask; + emptyFileIndex++; + } + else + isDirMask |= mask; + if (remSubStreams == 0) + { + p->FileToFolder[i] = (UInt32)-1; + continue; + } + } + + if (remSubStreams == 0) + { + for (;;) + { + if (folderIndex >= p->db.NumFolders) + return SZ_ERROR_ARCHIVE; + p->FolderToFile[folderIndex] = i; + numSubStreams = 1; + if (ssi.sdNumSubStreams.Data) + { + RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams)); + } + remSubStreams = numSubStreams; + if (numSubStreams != 0) + break; + { + UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + unpackPos += folderUnpackSize; + if (unpackPos < folderUnpackSize) + return SZ_ERROR_ARCHIVE; + } + + folderIndex++; + } + } + + p->FileToFolder[i] = folderIndex; + + if (emptyStreams && SzBitArray_Check(emptyStreams, i)) + continue; + + if (--remSubStreams == 0) + { + UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + UInt64 startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]]; + if (folderUnpackSize < unpackPos - startFolderUnpackPos) + return SZ_ERROR_ARCHIVE; + unpackPos = startFolderUnpackPos + folderUnpackSize; + if (unpackPos < folderUnpackSize) + return SZ_ERROR_ARCHIVE; + + if (numSubStreams == 1 && SzBitWithVals_Check(&p->db.FolderCRCs, i)) + { + p->CRCs.Vals[i] = p->db.FolderCRCs.Vals[folderIndex]; + crcMask |= mask; + } + else if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex))) + { + p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4); + digestsValsIndex++; + crcMask |= mask; + } + + folderIndex++; + } + else + { + UInt64 v; + RINOK(ReadNumber(&ssi.sdSizes, &v)); + unpackPos += v; + if (unpackPos < v) + return SZ_ERROR_ARCHIVE; + if (allDigestsDefined || (digestsDefs && SzBitArray_Check(digestsDefs, digestIndex))) + { + p->CRCs.Vals[i] = GetUi32(digestsVals + (size_t)digestsValsIndex * 4); + digestsValsIndex++; + crcMask |= mask; + } + } + } + + if (mask != 0x80) + { + UInt32 byteIndex = (i - 1) >> 3; + p->IsDirs[byteIndex] = isDirMask; + p->CRCs.Defs[byteIndex] = crcMask; + } + + p->UnpackPositions[i] = unpackPos; + + if (remSubStreams != 0) + return SZ_ERROR_ARCHIVE; + + for (;;) + { + p->FolderToFile[folderIndex] = i; + if (folderIndex >= p->db.NumFolders) + break; + if (!ssi.sdNumSubStreams.Data) + return SZ_ERROR_ARCHIVE; + RINOK(SzReadNumber32(&ssi.sdNumSubStreams, &numSubStreams)); + if (numSubStreams != 0) + return SZ_ERROR_ARCHIVE; + /* + { + UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + unpackPos += folderUnpackSize; + if (unpackPos < folderUnpackSize) + return SZ_ERROR_ARCHIVE; + } + */ + folderIndex++; + } + + if (ssi.sdNumSubStreams.Data && ssi.sdNumSubStreams.Size != 0) + return SZ_ERROR_ARCHIVE; + } +} + return SZ_OK; +} + + +static SRes SzReadHeader( + CSzArEx *p, + CSzData *sd, + ILookInStream *inStream, + ISzAllocPtr allocMain, + ISzAllocPtr allocTemp) +{ + UInt32 i; + UInt32 numTempBufs = 0; + SRes res; + CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX]; + + for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) + Buf_Init(tempBufs + i); + + res = SzReadHeader2(p, sd, inStream, + tempBufs, &numTempBufs, + allocMain, allocTemp); + + for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) + Buf_Free(tempBufs + i, allocTemp); + + RINOK(res); + + if (sd->Size != 0) + return SZ_ERROR_FAIL; + + return res; +} + +static SRes SzArEx_Open2( + CSzArEx *p, + ILookInStream *inStream, + ISzAllocPtr allocMain, + ISzAllocPtr allocTemp) +{ + Byte header[k7zStartHeaderSize]; + Int64 startArcPos; + UInt64 nextHeaderOffset, nextHeaderSize; + size_t nextHeaderSizeT; + UInt32 nextHeaderCRC; + CBuf buf; + SRes res; + + startArcPos = 0; + RINOK(ILookInStream_Seek(inStream, &startArcPos, SZ_SEEK_CUR)); + + RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); + + if (!TestSignatureCandidate(header)) + return SZ_ERROR_NO_ARCHIVE; + if (header[6] != k7zMajorVersion) + return SZ_ERROR_UNSUPPORTED; + + nextHeaderOffset = GetUi64(header + 12); + nextHeaderSize = GetUi64(header + 20); + nextHeaderCRC = GetUi32(header + 28); + + p->startPosAfterHeader = (UInt64)startArcPos + k7zStartHeaderSize; + + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) + return SZ_ERROR_CRC; + + p->db.RangeLimit = nextHeaderOffset; + + nextHeaderSizeT = (size_t)nextHeaderSize; + if (nextHeaderSizeT != nextHeaderSize) + return SZ_ERROR_MEM; + if (nextHeaderSizeT == 0) + return SZ_OK; + if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || + nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) + return SZ_ERROR_NO_ARCHIVE; + + { + Int64 pos = 0; + RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END)); + if ((UInt64)pos < (UInt64)startArcPos + nextHeaderOffset || + (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset || + (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + return SZ_ERROR_INPUT_EOF; + } + + RINOK(LookInStream_SeekTo(inStream, (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset)); + + if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp)) + return SZ_ERROR_MEM; + + res = LookInStream_Read(inStream, buf.data, nextHeaderSizeT); + + if (res == SZ_OK) + { + res = SZ_ERROR_ARCHIVE; + if (CrcCalc(buf.data, nextHeaderSizeT) == nextHeaderCRC) + { + CSzData sd; + UInt64 type; + sd.Data = buf.data; + sd.Size = buf.size; + + res = ReadID(&sd, &type); + + if (res == SZ_OK && type == k7zIdEncodedHeader) + { + CSzAr tempAr; + CBuf tempBuf; + Buf_Init(&tempBuf); + + SzAr_Init(&tempAr); + tempAr.RangeLimit = p->db.RangeLimit; + + res = SzReadAndDecodePackedStreams(inStream, &sd, &tempBuf, 1, p->startPosAfterHeader, &tempAr, allocTemp); + SzAr_Free(&tempAr, allocTemp); + + if (res != SZ_OK) + { + Buf_Free(&tempBuf, allocTemp); + } + else + { + Buf_Free(&buf, allocTemp); + buf.data = tempBuf.data; + buf.size = tempBuf.size; + sd.Data = buf.data; + sd.Size = buf.size; + res = ReadID(&sd, &type); + } + } + + if (res == SZ_OK) + { + if (type == k7zIdHeader) + { + /* + CSzData sd2; + unsigned ttt; + for (ttt = 0; ttt < 40000; ttt++) + { + SzArEx_Free(p, allocMain); + sd2 = sd; + res = SzReadHeader(p, &sd2, inStream, allocMain, allocTemp); + if (res != SZ_OK) + break; + } + */ + res = SzReadHeader(p, &sd, inStream, allocMain, allocTemp); + } + else + res = SZ_ERROR_UNSUPPORTED; + } + } + } + + Buf_Free(&buf, allocTemp); + return res; +} + + +SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, + ISzAllocPtr allocMain, ISzAllocPtr allocTemp) +{ + SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); + if (res != SZ_OK) + SzArEx_Free(p, allocMain); + return res; +} + + +SRes SzArEx_Extract( + const CSzArEx *p, + ILookInStream *inStream, + UInt32 fileIndex, + UInt32 *blockIndex, + Byte **tempBuf, + size_t *outBufferSize, + size_t *offset, + size_t *outSizeProcessed, + ISzAllocPtr allocMain, + ISzAllocPtr allocTemp) +{ + UInt32 folderIndex = p->FileToFolder[fileIndex]; + SRes res = SZ_OK; + + *offset = 0; + *outSizeProcessed = 0; + + if (folderIndex == (UInt32)-1) + { + ISzAlloc_Free(allocMain, *tempBuf); + *blockIndex = folderIndex; + *tempBuf = NULL; + *outBufferSize = 0; + return SZ_OK; + } + + if (*tempBuf == NULL || *blockIndex != folderIndex) + { + UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex); + /* + UInt64 unpackSizeSpec = + p->UnpackPositions[p->FolderToFile[(size_t)folderIndex + 1]] - + p->UnpackPositions[p->FolderToFile[folderIndex]]; + */ + size_t unpackSize = (size_t)unpackSizeSpec; + + if (unpackSize != unpackSizeSpec) + return SZ_ERROR_MEM; + *blockIndex = folderIndex; + ISzAlloc_Free(allocMain, *tempBuf); + *tempBuf = NULL; + + if (res == SZ_OK) + { + *outBufferSize = unpackSize; + if (unpackSize != 0) + { + *tempBuf = (Byte *)ISzAlloc_Alloc(allocMain, unpackSize); + if (*tempBuf == NULL) + res = SZ_ERROR_MEM; + } + + if (res == SZ_OK) + { + res = SzAr_DecodeFolder(&p->db, folderIndex, + inStream, p->dataPos, *tempBuf, unpackSize, allocTemp); + } + } + } + + if (res == SZ_OK) + { + UInt64 unpackPos = p->UnpackPositions[fileIndex]; + *offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderToFile[folderIndex]]); + *outSizeProcessed = (size_t)(p->UnpackPositions[(size_t)fileIndex + 1] - unpackPos); + if (*offset + *outSizeProcessed > *outBufferSize) + return SZ_ERROR_FAIL; + if (SzBitWithVals_Check(&p->CRCs, fileIndex)) + if (CrcCalc(*tempBuf + *offset, *outSizeProcessed) != p->CRCs.Vals[fileIndex]) + res = SZ_ERROR_CRC; + } + + return res; +} + + +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) +{ + size_t offs = p->FileNameOffsets[fileIndex]; + size_t len = p->FileNameOffsets[fileIndex + 1] - offs; + if (dest != 0) + { + size_t i; + const Byte *src = p->FileNames + offs * 2; + for (i = 0; i < len; i++) + dest[i] = GetUi16(src + i * 2); + } + return len; +} + +/* +size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex) +{ + size_t len; + if (!p->FileNameOffsets) + return 1; + len = 0; + for (;;) + { + UInt32 parent = (UInt32)(Int32)-1; + len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; + if SzBitWithVals_Check(&p->Parents, fileIndex) + parent = p->Parents.Vals[fileIndex]; + if (parent == (UInt32)(Int32)-1) + return len; + fileIndex = parent; + } +} + +UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest) +{ + BoolInt needSlash; + if (!p->FileNameOffsets) + { + *(--dest) = 0; + return dest; + } + needSlash = False; + for (;;) + { + UInt32 parent = (UInt32)(Int32)-1; + size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; + SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen); + if (needSlash) + *(dest - 1) = '/'; + needSlash = True; + dest -= curLen; + + if SzBitWithVals_Check(&p->Parents, fileIndex) + parent = p->Parents.Vals[fileIndex]; + if (parent == (UInt32)(Int32)-1) + return dest; + fileIndex = parent; + } +} +*/ diff --git a/deps/LZMA-SDK/C/7zBuf.c b/deps/LZMA-SDK/C/7zBuf.c index 438bba68b..8865c32a8 100644 --- a/deps/LZMA-SDK/C/7zBuf.c +++ b/deps/LZMA-SDK/C/7zBuf.c @@ -1,36 +1,36 @@ -/* 7zBuf.c -- Byte Buffer -2017-04-03 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "7zBuf.h" - -void Buf_Init(CBuf *p) -{ - p->data = 0; - p->size = 0; -} - -int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc) -{ - p->size = 0; - if (size == 0) - { - p->data = 0; - return 1; - } - p->data = (Byte *)ISzAlloc_Alloc(alloc, size); - if (p->data) - { - p->size = size; - return 1; - } - return 0; -} - -void Buf_Free(CBuf *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->data); - p->data = 0; - p->size = 0; -} +/* 7zBuf.c -- Byte Buffer +2017-04-03 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "7zBuf.h" + +void Buf_Init(CBuf *p) +{ + p->data = 0; + p->size = 0; +} + +int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc) +{ + p->size = 0; + if (size == 0) + { + p->data = 0; + return 1; + } + p->data = (Byte *)ISzAlloc_Alloc(alloc, size); + if (p->data) + { + p->size = size; + return 1; + } + return 0; +} + +void Buf_Free(CBuf *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->data); + p->data = 0; + p->size = 0; +} diff --git a/deps/LZMA-SDK/C/7zBuf.h b/deps/LZMA-SDK/C/7zBuf.h index 5942d6e62..81d1b5b64 100644 --- a/deps/LZMA-SDK/C/7zBuf.h +++ b/deps/LZMA-SDK/C/7zBuf.h @@ -1,35 +1,35 @@ -/* 7zBuf.h -- Byte Buffer -2017-04-03 : Igor Pavlov : Public domain */ - -#ifndef __7Z_BUF_H -#define __7Z_BUF_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -typedef struct -{ - Byte *data; - size_t size; -} CBuf; - -void Buf_Init(CBuf *p); -int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc); -void Buf_Free(CBuf *p, ISzAllocPtr alloc); - -typedef struct -{ - Byte *data; - size_t size; - size_t pos; -} CDynBuf; - -void DynBuf_Construct(CDynBuf *p); -void DynBuf_SeekToBeg(CDynBuf *p); -int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAllocPtr alloc); -void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc); - -EXTERN_C_END - -#endif +/* 7zBuf.h -- Byte Buffer +2017-04-03 : Igor Pavlov : Public domain */ + +#ifndef __7Z_BUF_H +#define __7Z_BUF_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +typedef struct +{ + Byte *data; + size_t size; +} CBuf; + +void Buf_Init(CBuf *p); +int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc); +void Buf_Free(CBuf *p, ISzAllocPtr alloc); + +typedef struct +{ + Byte *data; + size_t size; + size_t pos; +} CDynBuf; + +void DynBuf_Construct(CDynBuf *p); +void DynBuf_SeekToBeg(CDynBuf *p); +int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAllocPtr alloc); +void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/7zBuf2.c b/deps/LZMA-SDK/C/7zBuf2.c index 49b4343b6..208347416 100644 --- a/deps/LZMA-SDK/C/7zBuf2.c +++ b/deps/LZMA-SDK/C/7zBuf2.c @@ -1,52 +1,52 @@ -/* 7zBuf2.c -- Byte Buffer -2017-04-03 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "7zBuf.h" - -void DynBuf_Construct(CDynBuf *p) -{ - p->data = 0; - p->size = 0; - p->pos = 0; -} - -void DynBuf_SeekToBeg(CDynBuf *p) -{ - p->pos = 0; -} - -int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAllocPtr alloc) -{ - if (size > p->size - p->pos) - { - size_t newSize = p->pos + size; - Byte *data; - newSize += newSize / 4; - data = (Byte *)ISzAlloc_Alloc(alloc, newSize); - if (!data) - return 0; - p->size = newSize; - if (p->pos != 0) - memcpy(data, p->data, p->pos); - ISzAlloc_Free(alloc, p->data); - p->data = data; - } - if (size != 0) - { - memcpy(p->data + p->pos, buf, size); - p->pos += size; - } - return 1; -} - -void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->data); - p->data = 0; - p->size = 0; - p->pos = 0; -} +/* 7zBuf2.c -- Byte Buffer +2017-04-03 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#include "7zBuf.h" + +void DynBuf_Construct(CDynBuf *p) +{ + p->data = 0; + p->size = 0; + p->pos = 0; +} + +void DynBuf_SeekToBeg(CDynBuf *p) +{ + p->pos = 0; +} + +int DynBuf_Write(CDynBuf *p, const Byte *buf, size_t size, ISzAllocPtr alloc) +{ + if (size > p->size - p->pos) + { + size_t newSize = p->pos + size; + Byte *data; + newSize += newSize / 4; + data = (Byte *)ISzAlloc_Alloc(alloc, newSize); + if (!data) + return 0; + p->size = newSize; + if (p->pos != 0) + memcpy(data, p->data, p->pos); + ISzAlloc_Free(alloc, p->data); + p->data = data; + } + if (size != 0) + { + memcpy(p->data + p->pos, buf, size); + p->pos += size; + } + return 1; +} + +void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->data); + p->data = 0; + p->size = 0; + p->pos = 0; +} diff --git a/deps/LZMA-SDK/C/7zCrc.c b/deps/LZMA-SDK/C/7zCrc.c index c7ec353d6..f186324dd 100644 --- a/deps/LZMA-SDK/C/7zCrc.c +++ b/deps/LZMA-SDK/C/7zCrc.c @@ -1,322 +1,322 @@ -/* 7zCrc.c -- CRC32 init -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "7zCrc.h" -#include "CpuArch.h" - -#define kCrcPoly 0xEDB88320 - -#ifdef MY_CPU_LE - #define CRC_NUM_TABLES 8 -#else - #define CRC_NUM_TABLES 9 - - #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) - - UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table); - UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table); -#endif - -#ifndef MY_CPU_BE - UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); - UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); -#endif - -typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table); - -extern -CRC_FUNC g_CrcUpdateT4; -CRC_FUNC g_CrcUpdateT4; -extern -CRC_FUNC g_CrcUpdateT8; -CRC_FUNC g_CrcUpdateT8; -extern -CRC_FUNC g_CrcUpdateT0_32; -CRC_FUNC g_CrcUpdateT0_32; -extern -CRC_FUNC g_CrcUpdateT0_64; -CRC_FUNC g_CrcUpdateT0_64; -extern -CRC_FUNC g_CrcUpdate; -CRC_FUNC g_CrcUpdate; - -UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; - -UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) -{ - return g_CrcUpdate(v, data, size, g_CrcTable); -} - -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) -{ - return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; -} - -#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table); -UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - const Byte *pEnd = p + size; - for (; p != pEnd; p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - - -/* ---------- hardware CRC ---------- */ - -#ifdef MY_CPU_LE - -#if defined(MY_CPU_ARM_OR_ARM64) - -// #pragma message("ARM*") - - #if defined(_MSC_VER) - #if defined(MY_CPU_ARM64) - #if (_MSC_VER >= 1910) - #define USE_ARM64_CRC - #endif - #endif - #elif (defined(__clang__) && (__clang_major__ >= 3)) \ - || (defined(__GNUC__) && (__GNUC__ > 4)) - #if !defined(__ARM_FEATURE_CRC32) - #define __ARM_FEATURE_CRC32 1 - #if (!defined(__clang__) || (__clang_major__ > 3)) // fix these numbers - #define ATTRIB_CRC __attribute__((__target__("arch=armv8-a+crc"))) - #endif - #endif - #if defined(__ARM_FEATURE_CRC32) - #define USE_ARM64_CRC - #include - #endif - #endif - -#else - -// no hardware CRC - -// #define USE_CRC_EMU - -#ifdef USE_CRC_EMU - -#pragma message("ARM64 CRC emulation") - -MY_FORCE_INLINE -UInt32 __crc32b(UInt32 v, UInt32 data) -{ - const UInt32 *table = g_CrcTable; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); - return v; -} - -MY_FORCE_INLINE -UInt32 __crc32w(UInt32 v, UInt32 data) -{ - const UInt32 *table = g_CrcTable; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - return v; -} - -MY_FORCE_INLINE -UInt32 __crc32d(UInt32 v, UInt64 data) -{ - const UInt32 *table = g_CrcTable; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; - return v; -} - -#endif // USE_CRC_EMU - -#endif // defined(MY_CPU_ARM64) && defined(MY_CPU_LE) - - - -#if defined(USE_ARM64_CRC) || defined(USE_CRC_EMU) - -#define T0_32_UNROLL_BYTES (4 * 4) -#define T0_64_UNROLL_BYTES (4 * 8) - -#ifndef ATTRIB_CRC -#define ATTRIB_CRC -#endif -// #pragma message("USE ARM HW CRC") - -ATTRIB_CRC -UInt32 MY_FAST_CALL CrcUpdateT0_32(UInt32 v, const void *data, size_t size, const UInt32 *table); -ATTRIB_CRC -UInt32 MY_FAST_CALL CrcUpdateT0_32(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - UNUSED_VAR(table); - - for (; size != 0 && ((unsigned)(ptrdiff_t)p & (T0_32_UNROLL_BYTES - 1)) != 0; size--) - v = __crc32b(v, *p++); - - if (size >= T0_32_UNROLL_BYTES) - { - const Byte *lim = p + size; - size &= (T0_32_UNROLL_BYTES - 1); - lim -= size; - do - { - v = __crc32w(v, *(const UInt32 *)(const void *)(p)); - v = __crc32w(v, *(const UInt32 *)(const void *)(p + 4)); p += 2 * 4; - v = __crc32w(v, *(const UInt32 *)(const void *)(p)); - v = __crc32w(v, *(const UInt32 *)(const void *)(p + 4)); p += 2 * 4; - } - while (p != lim); - } - - for (; size != 0; size--) - v = __crc32b(v, *p++); - - return v; -} - -ATTRIB_CRC -UInt32 MY_FAST_CALL CrcUpdateT0_64(UInt32 v, const void *data, size_t size, const UInt32 *table); -ATTRIB_CRC -UInt32 MY_FAST_CALL CrcUpdateT0_64(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - UNUSED_VAR(table); - - for (; size != 0 && ((unsigned)(ptrdiff_t)p & (T0_64_UNROLL_BYTES - 1)) != 0; size--) - v = __crc32b(v, *p++); - - if (size >= T0_64_UNROLL_BYTES) - { - const Byte *lim = p + size; - size &= (T0_64_UNROLL_BYTES - 1); - lim -= size; - do - { - v = __crc32d(v, *(const UInt64 *)(const void *)(p)); - v = __crc32d(v, *(const UInt64 *)(const void *)(p + 8)); p += 2 * 8; - v = __crc32d(v, *(const UInt64 *)(const void *)(p)); - v = __crc32d(v, *(const UInt64 *)(const void *)(p + 8)); p += 2 * 8; - } - while (p != lim); - } - - for (; size != 0; size--) - v = __crc32b(v, *p++); - - return v; -} - -#endif // defined(USE_ARM64_CRC) || defined(USE_CRC_EMU) - -#endif // MY_CPU_LE - - - - -void MY_FAST_CALL CrcGenerateTable() -{ - UInt32 i; - for (i = 0; i < 256; i++) - { - UInt32 r = i; - unsigned j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); - g_CrcTable[i] = r; - } - for (i = 256; i < 256 * CRC_NUM_TABLES; i++) - { - UInt32 r = g_CrcTable[(size_t)i - 256]; - g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); - } - - #if CRC_NUM_TABLES < 4 - - g_CrcUpdate = CrcUpdateT1; - - #else - - #ifdef MY_CPU_LE - - g_CrcUpdateT4 = CrcUpdateT4; - g_CrcUpdate = CrcUpdateT4; - - #if CRC_NUM_TABLES >= 8 - g_CrcUpdateT8 = CrcUpdateT8; - - #ifdef MY_CPU_X86_OR_AMD64 - if (!CPU_Is_InOrder()) - #endif - g_CrcUpdate = CrcUpdateT8; - #endif - - #else - { - #ifndef MY_CPU_BE - UInt32 k = 0x01020304; - const Byte *p = (const Byte *)&k; - if (p[0] == 4 && p[1] == 3) - { - g_CrcUpdateT4 = CrcUpdateT4; - g_CrcUpdate = CrcUpdateT4; - #if CRC_NUM_TABLES >= 8 - g_CrcUpdateT8 = CrcUpdateT8; - g_CrcUpdate = CrcUpdateT8; - #endif - } - else if (p[0] != 1 || p[1] != 2) - g_CrcUpdate = CrcUpdateT1; - else - #endif - { - for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--) - { - UInt32 x = g_CrcTable[(size_t)i - 256]; - g_CrcTable[i] = CRC_UINT32_SWAP(x); - } - g_CrcUpdateT4 = CrcUpdateT1_BeT4; - g_CrcUpdate = CrcUpdateT1_BeT4; - #if CRC_NUM_TABLES >= 8 - g_CrcUpdateT8 = CrcUpdateT1_BeT8; - g_CrcUpdate = CrcUpdateT1_BeT8; - #endif - } - } - #endif - #endif - - #ifdef MY_CPU_LE - #ifdef USE_ARM64_CRC - if (CPU_IsSupported_CRC32()) - { - g_CrcUpdateT0_32 = CrcUpdateT0_32; - g_CrcUpdateT0_64 = CrcUpdateT0_64; - g_CrcUpdate = - #if defined(MY_CPU_ARM) - CrcUpdateT0_32; - #else - CrcUpdateT0_64; - #endif - } - #endif - - #ifdef USE_CRC_EMU - g_CrcUpdateT0_32 = CrcUpdateT0_32; - g_CrcUpdateT0_64 = CrcUpdateT0_64; - g_CrcUpdate = CrcUpdateT0_64; - #endif - #endif -} +/* 7zCrc.c -- CRC32 init +2021-04-01 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "7zCrc.h" +#include "CpuArch.h" + +#define kCrcPoly 0xEDB88320 + +#ifdef MY_CPU_LE + #define CRC_NUM_TABLES 8 +#else + #define CRC_NUM_TABLES 9 + + #define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) + + UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table); + UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table); +#endif + +#ifndef MY_CPU_BE + UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); + UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); +#endif + +typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table); + +extern +CRC_FUNC g_CrcUpdateT4; +CRC_FUNC g_CrcUpdateT4; +extern +CRC_FUNC g_CrcUpdateT8; +CRC_FUNC g_CrcUpdateT8; +extern +CRC_FUNC g_CrcUpdateT0_32; +CRC_FUNC g_CrcUpdateT0_32; +extern +CRC_FUNC g_CrcUpdateT0_64; +CRC_FUNC g_CrcUpdateT0_64; +extern +CRC_FUNC g_CrcUpdate; +CRC_FUNC g_CrcUpdate; + +UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; + +UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) +{ + return g_CrcUpdate(v, data, size, g_CrcTable); +} + +UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) +{ + return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; +} + +#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table); +UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + const Byte *pEnd = p + size; + for (; p != pEnd; p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + + +/* ---------- hardware CRC ---------- */ + +#ifdef MY_CPU_LE + +#if defined(MY_CPU_ARM_OR_ARM64) + +// #pragma message("ARM*") + + #if defined(_MSC_VER) + #if defined(MY_CPU_ARM64) + #if (_MSC_VER >= 1910) + #define USE_ARM64_CRC + #endif + #endif + #elif (defined(__clang__) && (__clang_major__ >= 3)) \ + || (defined(__GNUC__) && (__GNUC__ > 4)) + #if !defined(__ARM_FEATURE_CRC32) + #define __ARM_FEATURE_CRC32 1 + #if (!defined(__clang__) || (__clang_major__ > 3)) // fix these numbers + #define ATTRIB_CRC __attribute__((__target__("arch=armv8-a+crc"))) + #endif + #endif + #if defined(__ARM_FEATURE_CRC32) + #define USE_ARM64_CRC + #include + #endif + #endif + +#else + +// no hardware CRC + +// #define USE_CRC_EMU + +#ifdef USE_CRC_EMU + +#pragma message("ARM64 CRC emulation") + +MY_FORCE_INLINE +UInt32 __crc32b(UInt32 v, UInt32 data) +{ + const UInt32 *table = g_CrcTable; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); + return v; +} + +MY_FORCE_INLINE +UInt32 __crc32w(UInt32 v, UInt32 data) +{ + const UInt32 *table = g_CrcTable; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + return v; +} + +MY_FORCE_INLINE +UInt32 __crc32d(UInt32 v, UInt64 data) +{ + const UInt32 *table = g_CrcTable; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + v = CRC_UPDATE_BYTE_2(v, (Byte)data); data >>= 8; + return v; +} + +#endif // USE_CRC_EMU + +#endif // defined(MY_CPU_ARM64) && defined(MY_CPU_LE) + + + +#if defined(USE_ARM64_CRC) || defined(USE_CRC_EMU) + +#define T0_32_UNROLL_BYTES (4 * 4) +#define T0_64_UNROLL_BYTES (4 * 8) + +#ifndef ATTRIB_CRC +#define ATTRIB_CRC +#endif +// #pragma message("USE ARM HW CRC") + +ATTRIB_CRC +UInt32 MY_FAST_CALL CrcUpdateT0_32(UInt32 v, const void *data, size_t size, const UInt32 *table); +ATTRIB_CRC +UInt32 MY_FAST_CALL CrcUpdateT0_32(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + UNUSED_VAR(table); + + for (; size != 0 && ((unsigned)(ptrdiff_t)p & (T0_32_UNROLL_BYTES - 1)) != 0; size--) + v = __crc32b(v, *p++); + + if (size >= T0_32_UNROLL_BYTES) + { + const Byte *lim = p + size; + size &= (T0_32_UNROLL_BYTES - 1); + lim -= size; + do + { + v = __crc32w(v, *(const UInt32 *)(const void *)(p)); + v = __crc32w(v, *(const UInt32 *)(const void *)(p + 4)); p += 2 * 4; + v = __crc32w(v, *(const UInt32 *)(const void *)(p)); + v = __crc32w(v, *(const UInt32 *)(const void *)(p + 4)); p += 2 * 4; + } + while (p != lim); + } + + for (; size != 0; size--) + v = __crc32b(v, *p++); + + return v; +} + +ATTRIB_CRC +UInt32 MY_FAST_CALL CrcUpdateT0_64(UInt32 v, const void *data, size_t size, const UInt32 *table); +ATTRIB_CRC +UInt32 MY_FAST_CALL CrcUpdateT0_64(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + UNUSED_VAR(table); + + for (; size != 0 && ((unsigned)(ptrdiff_t)p & (T0_64_UNROLL_BYTES - 1)) != 0; size--) + v = __crc32b(v, *p++); + + if (size >= T0_64_UNROLL_BYTES) + { + const Byte *lim = p + size; + size &= (T0_64_UNROLL_BYTES - 1); + lim -= size; + do + { + v = __crc32d(v, *(const UInt64 *)(const void *)(p)); + v = __crc32d(v, *(const UInt64 *)(const void *)(p + 8)); p += 2 * 8; + v = __crc32d(v, *(const UInt64 *)(const void *)(p)); + v = __crc32d(v, *(const UInt64 *)(const void *)(p + 8)); p += 2 * 8; + } + while (p != lim); + } + + for (; size != 0; size--) + v = __crc32b(v, *p++); + + return v; +} + +#endif // defined(USE_ARM64_CRC) || defined(USE_CRC_EMU) + +#endif // MY_CPU_LE + + + + +void MY_FAST_CALL CrcGenerateTable() +{ + UInt32 i; + for (i = 0; i < 256; i++) + { + UInt32 r = i; + unsigned j; + for (j = 0; j < 8; j++) + r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); + g_CrcTable[i] = r; + } + for (i = 256; i < 256 * CRC_NUM_TABLES; i++) + { + UInt32 r = g_CrcTable[(size_t)i - 256]; + g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); + } + + #if CRC_NUM_TABLES < 4 + + g_CrcUpdate = CrcUpdateT1; + + #else + + #ifdef MY_CPU_LE + + g_CrcUpdateT4 = CrcUpdateT4; + g_CrcUpdate = CrcUpdateT4; + + #if CRC_NUM_TABLES >= 8 + g_CrcUpdateT8 = CrcUpdateT8; + + #ifdef MY_CPU_X86_OR_AMD64 + if (!CPU_Is_InOrder()) + #endif + g_CrcUpdate = CrcUpdateT8; + #endif + + #else + { + #ifndef MY_CPU_BE + UInt32 k = 0x01020304; + const Byte *p = (const Byte *)&k; + if (p[0] == 4 && p[1] == 3) + { + g_CrcUpdateT4 = CrcUpdateT4; + g_CrcUpdate = CrcUpdateT4; + #if CRC_NUM_TABLES >= 8 + g_CrcUpdateT8 = CrcUpdateT8; + g_CrcUpdate = CrcUpdateT8; + #endif + } + else if (p[0] != 1 || p[1] != 2) + g_CrcUpdate = CrcUpdateT1; + else + #endif + { + for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--) + { + UInt32 x = g_CrcTable[(size_t)i - 256]; + g_CrcTable[i] = CRC_UINT32_SWAP(x); + } + g_CrcUpdateT4 = CrcUpdateT1_BeT4; + g_CrcUpdate = CrcUpdateT1_BeT4; + #if CRC_NUM_TABLES >= 8 + g_CrcUpdateT8 = CrcUpdateT1_BeT8; + g_CrcUpdate = CrcUpdateT1_BeT8; + #endif + } + } + #endif + #endif + + #ifdef MY_CPU_LE + #ifdef USE_ARM64_CRC + if (CPU_IsSupported_CRC32()) + { + g_CrcUpdateT0_32 = CrcUpdateT0_32; + g_CrcUpdateT0_64 = CrcUpdateT0_64; + g_CrcUpdate = + #if defined(MY_CPU_ARM) + CrcUpdateT0_32; + #else + CrcUpdateT0_64; + #endif + } + #endif + + #ifdef USE_CRC_EMU + g_CrcUpdateT0_32 = CrcUpdateT0_32; + g_CrcUpdateT0_64 = CrcUpdateT0_64; + g_CrcUpdate = CrcUpdateT0_64; + #endif + #endif +} diff --git a/deps/LZMA-SDK/C/7zCrc.h b/deps/LZMA-SDK/C/7zCrc.h index 3b0459402..8fd579587 100644 --- a/deps/LZMA-SDK/C/7zCrc.h +++ b/deps/LZMA-SDK/C/7zCrc.h @@ -1,25 +1,25 @@ -/* 7zCrc.h -- CRC32 calculation -2013-01-18 : Igor Pavlov : Public domain */ - -#ifndef __7Z_CRC_H -#define __7Z_CRC_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -extern UInt32 g_CrcTable[]; - -/* Call CrcGenerateTable one time before other CRC functions */ -void MY_FAST_CALL CrcGenerateTable(void); - -#define CRC_INIT_VAL 0xFFFFFFFF -#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) -#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); -UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); - -EXTERN_C_END - -#endif +/* 7zCrc.h -- CRC32 calculation +2013-01-18 : Igor Pavlov : Public domain */ + +#ifndef __7Z_CRC_H +#define __7Z_CRC_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +extern UInt32 g_CrcTable[]; + +/* Call CrcGenerateTable one time before other CRC functions */ +void MY_FAST_CALL CrcGenerateTable(void); + +#define CRC_INIT_VAL 0xFFFFFFFF +#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) +#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size); +UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/7zCrcOpt.c b/deps/LZMA-SDK/C/7zCrcOpt.c index efaa7ab9d..69fad9ca2 100644 --- a/deps/LZMA-SDK/C/7zCrcOpt.c +++ b/deps/LZMA-SDK/C/7zCrcOpt.c @@ -1,117 +1,117 @@ -/* 7zCrcOpt.c -- CRC32 calculation -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" - -#ifndef MY_CPU_BE - -#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); -UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - v ^= *(const UInt32 *)(const void *)p; - v = - (table + 0x300)[((v ) & 0xFF)] - ^ (table + 0x200)[((v >> 8) & 0xFF)] - ^ (table + 0x100)[((v >> 16) & 0xFF)] - ^ (table + 0x000)[((v >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - -UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); -UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - for (; size >= 8; size -= 8, p += 8) - { - UInt32 d; - v ^= *(const UInt32 *)(const void *)p; - v = - (table + 0x700)[((v ) & 0xFF)] - ^ (table + 0x600)[((v >> 8) & 0xFF)] - ^ (table + 0x500)[((v >> 16) & 0xFF)] - ^ (table + 0x400)[((v >> 24))]; - d = *((const UInt32 *)(const void *)p + 1); - v ^= - (table + 0x300)[((d ) & 0xFF)] - ^ (table + 0x200)[((d >> 8) & 0xFF)] - ^ (table + 0x100)[((d >> 16) & 0xFF)] - ^ (table + 0x000)[((d >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - -#endif - - -#ifndef MY_CPU_LE - -#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) - -#define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8)) - -UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - table += 0x100; - v = CRC_UINT32_SWAP(v); - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2_BE(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - v ^= *(const UInt32 *)(const void *)p; - v = - (table + 0x000)[((v ) & 0xFF)] - ^ (table + 0x100)[((v >> 8) & 0xFF)] - ^ (table + 0x200)[((v >> 16) & 0xFF)] - ^ (table + 0x300)[((v >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2_BE(v, *p); - return CRC_UINT32_SWAP(v); -} - -UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table) -{ - const Byte *p = (const Byte *)data; - table += 0x100; - v = CRC_UINT32_SWAP(v); - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2_BE(v, *p); - for (; size >= 8; size -= 8, p += 8) - { - UInt32 d; - v ^= *(const UInt32 *)(const void *)p; - v = - (table + 0x400)[((v ) & 0xFF)] - ^ (table + 0x500)[((v >> 8) & 0xFF)] - ^ (table + 0x600)[((v >> 16) & 0xFF)] - ^ (table + 0x700)[((v >> 24))]; - d = *((const UInt32 *)(const void *)p + 1); - v ^= - (table + 0x000)[((d ) & 0xFF)] - ^ (table + 0x100)[((d >> 8) & 0xFF)] - ^ (table + 0x200)[((d >> 16) & 0xFF)] - ^ (table + 0x300)[((d >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2_BE(v, *p); - return CRC_UINT32_SWAP(v); -} - -#endif +/* 7zCrcOpt.c -- CRC32 calculation +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" + +#ifndef MY_CPU_BE + +#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); +UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + for (; size >= 4; size -= 4, p += 4) + { + v ^= *(const UInt32 *)(const void *)p; + v = + (table + 0x300)[((v ) & 0xFF)] + ^ (table + 0x200)[((v >> 8) & 0xFF)] + ^ (table + 0x100)[((v >> 16) & 0xFF)] + ^ (table + 0x000)[((v >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + +UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); +UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + for (; size >= 8; size -= 8, p += 8) + { + UInt32 d; + v ^= *(const UInt32 *)(const void *)p; + v = + (table + 0x700)[((v ) & 0xFF)] + ^ (table + 0x600)[((v >> 8) & 0xFF)] + ^ (table + 0x500)[((v >> 16) & 0xFF)] + ^ (table + 0x400)[((v >> 24))]; + d = *((const UInt32 *)(const void *)p + 1); + v ^= + (table + 0x300)[((d ) & 0xFF)] + ^ (table + 0x200)[((d >> 8) & 0xFF)] + ^ (table + 0x100)[((d >> 16) & 0xFF)] + ^ (table + 0x000)[((d >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + +#endif + + +#ifndef MY_CPU_LE + +#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24)) + +#define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8)) + +UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + table += 0x100; + v = CRC_UINT32_SWAP(v); + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2_BE(v, *p); + for (; size >= 4; size -= 4, p += 4) + { + v ^= *(const UInt32 *)(const void *)p; + v = + (table + 0x000)[((v ) & 0xFF)] + ^ (table + 0x100)[((v >> 8) & 0xFF)] + ^ (table + 0x200)[((v >> 16) & 0xFF)] + ^ (table + 0x300)[((v >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2_BE(v, *p); + return CRC_UINT32_SWAP(v); +} + +UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table) +{ + const Byte *p = (const Byte *)data; + table += 0x100; + v = CRC_UINT32_SWAP(v); + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2_BE(v, *p); + for (; size >= 8; size -= 8, p += 8) + { + UInt32 d; + v ^= *(const UInt32 *)(const void *)p; + v = + (table + 0x400)[((v ) & 0xFF)] + ^ (table + 0x500)[((v >> 8) & 0xFF)] + ^ (table + 0x600)[((v >> 16) & 0xFF)] + ^ (table + 0x700)[((v >> 24))]; + d = *((const UInt32 *)(const void *)p + 1); + v ^= + (table + 0x000)[((d ) & 0xFF)] + ^ (table + 0x100)[((d >> 8) & 0xFF)] + ^ (table + 0x200)[((d >> 16) & 0xFF)] + ^ (table + 0x300)[((d >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2_BE(v, *p); + return CRC_UINT32_SWAP(v); +} + +#endif diff --git a/deps/LZMA-SDK/C/7zDec.c b/deps/LZMA-SDK/C/7zDec.c index 83e37d166..fbfd016e1 100644 --- a/deps/LZMA-SDK/C/7zDec.c +++ b/deps/LZMA-SDK/C/7zDec.c @@ -1,600 +1,600 @@ -/* 7zDec.c -- Decoding from 7z folder -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -/* #define _7ZIP_PPMD_SUPPPORT */ - -#include "7z.h" -#include "7zCrc.h" - -#include "Bcj2.h" -#include "Bra.h" -#include "CpuArch.h" -#include "Delta.h" -#include "LzmaDec.h" -#include "Lzma2Dec.h" -#ifdef _7ZIP_PPMD_SUPPPORT -#include "Ppmd7.h" -#endif - -#define k_Copy 0 -#ifndef _7Z_NO_METHOD_LZMA2 -#define k_LZMA2 0x21 -#endif -#define k_LZMA 0x30101 -#define k_BCJ2 0x303011B -#ifndef _7Z_NO_METHODS_FILTERS -#define k_Delta 3 -#define k_BCJ 0x3030103 -#define k_PPC 0x3030205 -#define k_IA64 0x3030401 -#define k_ARM 0x3030501 -#define k_ARMT 0x3030701 -#define k_SPARC 0x3030805 -#endif - -#ifdef _7ZIP_PPMD_SUPPPORT - -#define k_PPMD 0x30401 - -typedef struct -{ - IByteIn vt; - const Byte *cur; - const Byte *end; - const Byte *begin; - UInt64 processed; - BoolInt extra; - SRes res; - const ILookInStream *inStream; -} CByteInToLook; - -static Byte ReadByte(const IByteIn *pp) -{ - CByteInToLook *p = CONTAINER_FROM_VTBL(pp, CByteInToLook, vt); - if (p->cur != p->end) - return *p->cur++; - if (p->res == SZ_OK) - { - size_t size = (size_t)(p->cur - p->begin); - p->processed += size; - p->res = ILookInStream_Skip(p->inStream, size); - size = (1 << 25); - p->res = ILookInStream_Look(p->inStream, (const void **)&p->begin, &size); - p->cur = p->begin; - p->end = p->begin + size; - if (size != 0) - return *p->cur++;; - } - p->extra = True; - return 0; -} - -static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, const ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) -{ - CPpmd7 ppmd; - CByteInToLook s; - SRes res = SZ_OK; - - s.vt.Read = ReadByte; - s.inStream = inStream; - s.begin = s.end = s.cur = NULL; - s.extra = False; - s.res = SZ_OK; - s.processed = 0; - - if (propsSize != 5) - return SZ_ERROR_UNSUPPORTED; - - { - unsigned order = props[0]; - UInt32 memSize = GetUi32(props + 1); - if (order < PPMD7_MIN_ORDER || - order > PPMD7_MAX_ORDER || - memSize < PPMD7_MIN_MEM_SIZE || - memSize > PPMD7_MAX_MEM_SIZE) - return SZ_ERROR_UNSUPPORTED; - Ppmd7_Construct(&ppmd); - if (!Ppmd7_Alloc(&ppmd, memSize, allocMain)) - return SZ_ERROR_MEM; - Ppmd7_Init(&ppmd, order); - } - { - ppmd.rc.dec.Stream = &s.vt; - if (!Ppmd7z_RangeDec_Init(&ppmd.rc.dec)) - res = SZ_ERROR_DATA; - else if (!s.extra) - { - Byte *buf = outBuffer; - const Byte *lim = buf + outSize; - for (; buf != lim; buf++) - { - int sym = Ppmd7z_DecodeSymbol(&ppmd); - if (s.extra || sym < 0) - break; - *buf = (Byte)sym; - } - if (buf != lim) - res = SZ_ERROR_DATA; - else if (!Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) - { - /* if (Ppmd7z_DecodeSymbol(&ppmd) != PPMD7_SYM_END || !Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) */ - res = SZ_ERROR_DATA; - } - } - if (s.extra) - res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); - else if (s.processed + (size_t)(s.cur - s.begin) != inSize) - res = SZ_ERROR_DATA; - } - Ppmd7_Free(&ppmd, allocMain); - return res; -} - -#endif - - -static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) -{ - CLzmaDec state; - SRes res = SZ_OK; - - LzmaDec_Construct(&state); - RINOK(LzmaDec_AllocateProbs(&state, props, propsSize, allocMain)); - state.dic = outBuffer; - state.dicBufSize = outSize; - LzmaDec_Init(&state); - - for (;;) - { - const void *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = ILookInStream_Look(inStream, &inBuf, &lookahead); - if (res != SZ_OK) - break; - - { - SizeT inProcessed = (SizeT)lookahead, dicPos = state.dicPos; - ELzmaStatus status; - res = LzmaDec_DecodeToDic(&state, outSize, (const Byte *)inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - - if (status == LZMA_STATUS_FINISHED_WITH_MARK) - { - if (outSize != state.dicPos || inSize != 0) - res = SZ_ERROR_DATA; - break; - } - - if (outSize == state.dicPos && inSize == 0 && status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) - break; - - if (inProcessed == 0 && dicPos == state.dicPos) - { - res = SZ_ERROR_DATA; - break; - } - - res = ILookInStream_Skip(inStream, inProcessed); - if (res != SZ_OK) - break; - } - } - - LzmaDec_FreeProbs(&state, allocMain); - return res; -} - - -#ifndef _7Z_NO_METHOD_LZMA2 - -static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) -{ - CLzma2Dec state; - SRes res = SZ_OK; - - Lzma2Dec_Construct(&state); - if (propsSize != 1) - return SZ_ERROR_DATA; - RINOK(Lzma2Dec_AllocateProbs(&state, props[0], allocMain)); - state.decoder.dic = outBuffer; - state.decoder.dicBufSize = outSize; - Lzma2Dec_Init(&state); - - for (;;) - { - const void *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = ILookInStream_Look(inStream, &inBuf, &lookahead); - if (res != SZ_OK) - break; - - { - SizeT inProcessed = (SizeT)lookahead, dicPos = state.decoder.dicPos; - ELzmaStatus status; - res = Lzma2Dec_DecodeToDic(&state, outSize, (const Byte *)inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - - if (status == LZMA_STATUS_FINISHED_WITH_MARK) - { - if (outSize != state.decoder.dicPos || inSize != 0) - res = SZ_ERROR_DATA; - break; - } - - if (inProcessed == 0 && dicPos == state.decoder.dicPos) - { - res = SZ_ERROR_DATA; - break; - } - - res = ILookInStream_Skip(inStream, inProcessed); - if (res != SZ_OK) - break; - } - } - - Lzma2Dec_FreeProbs(&state, allocMain); - return res; -} - -#endif - - -static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer) -{ - while (inSize > 0) - { - const void *inBuf; - size_t curSize = (1 << 18); - if (curSize > inSize) - curSize = (size_t)inSize; - RINOK(ILookInStream_Look(inStream, &inBuf, &curSize)); - if (curSize == 0) - return SZ_ERROR_INPUT_EOF; - memcpy(outBuffer, inBuf, curSize); - outBuffer += curSize; - inSize -= curSize; - RINOK(ILookInStream_Skip(inStream, curSize)); - } - return SZ_OK; -} - -static BoolInt IS_MAIN_METHOD(UInt32 m) -{ - switch (m) - { - case k_Copy: - case k_LZMA: - #ifndef _7Z_NO_METHOD_LZMA2 - case k_LZMA2: - #endif - #ifdef _7ZIP_PPMD_SUPPPORT - case k_PPMD: - #endif - return True; - } - return False; -} - -static BoolInt IS_SUPPORTED_CODER(const CSzCoderInfo *c) -{ - return - c->NumStreams == 1 - /* && c->MethodID <= (UInt32)0xFFFFFFFF */ - && IS_MAIN_METHOD((UInt32)c->MethodID); -} - -#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumStreams == 4) - -static SRes CheckSupportedFolder(const CSzFolder *f) -{ - if (f->NumCoders < 1 || f->NumCoders > 4) - return SZ_ERROR_UNSUPPORTED; - if (!IS_SUPPORTED_CODER(&f->Coders[0])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumCoders == 1) - { - if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBonds != 0) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - - - #ifndef _7Z_NO_METHODS_FILTERS - - if (f->NumCoders == 2) - { - const CSzCoderInfo *c = &f->Coders[1]; - if ( - /* c->MethodID > (UInt32)0xFFFFFFFF || */ - c->NumStreams != 1 - || f->NumPackStreams != 1 - || f->PackStreams[0] != 0 - || f->NumBonds != 1 - || f->Bonds[0].InIndex != 1 - || f->Bonds[0].OutIndex != 0) - return SZ_ERROR_UNSUPPORTED; - switch ((UInt32)c->MethodID) - { - case k_Delta: - case k_BCJ: - case k_PPC: - case k_IA64: - case k_SPARC: - case k_ARM: - case k_ARMT: - break; - default: - return SZ_ERROR_UNSUPPORTED; - } - return SZ_OK; - } - - #endif - - - if (f->NumCoders == 4) - { - if (!IS_SUPPORTED_CODER(&f->Coders[1]) - || !IS_SUPPORTED_CODER(&f->Coders[2]) - || !IS_BCJ2(&f->Coders[3])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumPackStreams != 4 - || f->PackStreams[0] != 2 - || f->PackStreams[1] != 6 - || f->PackStreams[2] != 1 - || f->PackStreams[3] != 0 - || f->NumBonds != 3 - || f->Bonds[0].InIndex != 5 || f->Bonds[0].OutIndex != 0 - || f->Bonds[1].InIndex != 4 || f->Bonds[1].OutIndex != 1 - || f->Bonds[2].InIndex != 3 || f->Bonds[2].OutIndex != 2) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - - return SZ_ERROR_UNSUPPORTED; -} - -#ifndef _7Z_NO_METHODS_FILTERS -#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; -#endif - -static SRes SzFolder_Decode2(const CSzFolder *folder, - const Byte *propsData, - const UInt64 *unpackSizes, - const UInt64 *packPositions, - ILookInStream *inStream, UInt64 startPos, - Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain, - Byte *tempBuf[]) -{ - UInt32 ci; - SizeT tempSizes[3] = { 0, 0, 0}; - SizeT tempSize3 = 0; - Byte *tempBuf3 = 0; - - RINOK(CheckSupportedFolder(folder)); - - for (ci = 0; ci < folder->NumCoders; ci++) - { - const CSzCoderInfo *coder = &folder->Coders[ci]; - - if (IS_MAIN_METHOD((UInt32)coder->MethodID)) - { - UInt32 si = 0; - UInt64 offset; - UInt64 inSize; - Byte *outBufCur = outBuffer; - SizeT outSizeCur = outSize; - if (folder->NumCoders == 4) - { - UInt32 indices[] = { 3, 2, 0 }; - UInt64 unpackSize = unpackSizes[ci]; - si = indices[ci]; - if (ci < 2) - { - Byte *temp; - outSizeCur = (SizeT)unpackSize; - if (outSizeCur != unpackSize) - return SZ_ERROR_MEM; - temp = (Byte *)ISzAlloc_Alloc(allocMain, outSizeCur); - if (!temp && outSizeCur != 0) - return SZ_ERROR_MEM; - outBufCur = tempBuf[1 - ci] = temp; - tempSizes[1 - ci] = outSizeCur; - } - else if (ci == 2) - { - if (unpackSize > outSize) /* check it */ - return SZ_ERROR_PARAM; - tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); - tempSize3 = outSizeCur = (SizeT)unpackSize; - } - else - return SZ_ERROR_UNSUPPORTED; - } - offset = packPositions[si]; - inSize = packPositions[(size_t)si + 1] - offset; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - - if (coder->MethodID == k_Copy) - { - if (inSize != outSizeCur) /* check it */ - return SZ_ERROR_DATA; - RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); - } - else if (coder->MethodID == k_LZMA) - { - RINOK(SzDecodeLzma(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - #ifndef _7Z_NO_METHOD_LZMA2 - else if (coder->MethodID == k_LZMA2) - { - RINOK(SzDecodeLzma2(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - #endif - #ifdef _7ZIP_PPMD_SUPPPORT - else if (coder->MethodID == k_PPMD) - { - RINOK(SzDecodePpmd(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - #endif - else - return SZ_ERROR_UNSUPPORTED; - } - else if (coder->MethodID == k_BCJ2) - { - UInt64 offset = packPositions[1]; - UInt64 s3Size = packPositions[2] - offset; - - if (ci != 3) - return SZ_ERROR_UNSUPPORTED; - - tempSizes[2] = (SizeT)s3Size; - if (tempSizes[2] != s3Size) - return SZ_ERROR_MEM; - tempBuf[2] = (Byte *)ISzAlloc_Alloc(allocMain, tempSizes[2]); - if (!tempBuf[2] && tempSizes[2] != 0) - return SZ_ERROR_MEM; - - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - RINOK(SzDecodeCopy(s3Size, inStream, tempBuf[2])); - - if ((tempSizes[0] & 3) != 0 || - (tempSizes[1] & 3) != 0 || - tempSize3 + tempSizes[0] + tempSizes[1] != outSize) - return SZ_ERROR_DATA; - - { - CBcj2Dec p; - - p.bufs[0] = tempBuf3; p.lims[0] = tempBuf3 + tempSize3; - p.bufs[1] = tempBuf[0]; p.lims[1] = tempBuf[0] + tempSizes[0]; - p.bufs[2] = tempBuf[1]; p.lims[2] = tempBuf[1] + tempSizes[1]; - p.bufs[3] = tempBuf[2]; p.lims[3] = tempBuf[2] + tempSizes[2]; - - p.dest = outBuffer; - p.destLim = outBuffer + outSize; - - Bcj2Dec_Init(&p); - RINOK(Bcj2Dec_Decode(&p)); - - { - unsigned i; - for (i = 0; i < 4; i++) - if (p.bufs[i] != p.lims[i]) - return SZ_ERROR_DATA; - - if (!Bcj2Dec_IsFinished(&p)) - return SZ_ERROR_DATA; - - if (p.dest != p.destLim - || p.state != BCJ2_STREAM_MAIN) - return SZ_ERROR_DATA; - } - } - } - #ifndef _7Z_NO_METHODS_FILTERS - else if (ci == 1) - { - if (coder->MethodID == k_Delta) - { - if (coder->PropsSize != 1) - return SZ_ERROR_UNSUPPORTED; - { - Byte state[DELTA_STATE_SIZE]; - Delta_Init(state); - Delta_Decode(state, (unsigned)(propsData[coder->PropsOffset]) + 1, outBuffer, outSize); - } - } - else - { - if (coder->PropsSize != 0) - return SZ_ERROR_UNSUPPORTED; - switch (coder->MethodID) - { - case k_BCJ: - { - UInt32 state; - x86_Convert_Init(state); - x86_Convert(outBuffer, outSize, 0, &state, 0); - break; - } - CASE_BRA_CONV(PPC) - CASE_BRA_CONV(IA64) - CASE_BRA_CONV(SPARC) - CASE_BRA_CONV(ARM) - CASE_BRA_CONV(ARMT) - default: - return SZ_ERROR_UNSUPPORTED; - } - } - } - #endif - else - return SZ_ERROR_UNSUPPORTED; - } - - return SZ_OK; -} - - -SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, - ILookInStream *inStream, UInt64 startPos, - Byte *outBuffer, size_t outSize, - ISzAllocPtr allocMain) -{ - SRes res; - CSzFolder folder; - CSzData sd; - - const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex]; - sd.Data = data; - sd.Size = p->FoCodersOffsets[(size_t)folderIndex + 1] - p->FoCodersOffsets[folderIndex]; - - res = SzGetNextFolderItem(&folder, &sd); - - if (res != SZ_OK) - return res; - - if (sd.Size != 0 - || folder.UnpackStream != p->FoToMainUnpackSizeIndex[folderIndex] - || outSize != SzAr_GetFolderUnpackSize(p, folderIndex)) - return SZ_ERROR_FAIL; - { - unsigned i; - Byte *tempBuf[3] = { 0, 0, 0}; - - res = SzFolder_Decode2(&folder, data, - &p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex]], - p->PackPositions + p->FoStartPackStreamIndex[folderIndex], - inStream, startPos, - outBuffer, (SizeT)outSize, allocMain, tempBuf); - - for (i = 0; i < 3; i++) - ISzAlloc_Free(allocMain, tempBuf[i]); - - if (res == SZ_OK) - if (SzBitWithVals_Check(&p->FolderCRCs, folderIndex)) - if (CrcCalc(outBuffer, outSize) != p->FolderCRCs.Vals[folderIndex]) - res = SZ_ERROR_CRC; - - return res; - } -} +/* 7zDec.c -- Decoding from 7z folder +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +/* #define _7ZIP_PPMD_SUPPPORT */ + +#include "7z.h" +#include "7zCrc.h" + +#include "Bcj2.h" +#include "Bra.h" +#include "CpuArch.h" +#include "Delta.h" +#include "LzmaDec.h" +#include "Lzma2Dec.h" +#ifdef _7ZIP_PPMD_SUPPPORT +#include "Ppmd7.h" +#endif + +#define k_Copy 0 +#ifndef _7Z_NO_METHOD_LZMA2 +#define k_LZMA2 0x21 +#endif +#define k_LZMA 0x30101 +#define k_BCJ2 0x303011B +#ifndef _7Z_NO_METHODS_FILTERS +#define k_Delta 3 +#define k_BCJ 0x3030103 +#define k_PPC 0x3030205 +#define k_IA64 0x3030401 +#define k_ARM 0x3030501 +#define k_ARMT 0x3030701 +#define k_SPARC 0x3030805 +#endif + +#ifdef _7ZIP_PPMD_SUPPPORT + +#define k_PPMD 0x30401 + +typedef struct +{ + IByteIn vt; + const Byte *cur; + const Byte *end; + const Byte *begin; + UInt64 processed; + BoolInt extra; + SRes res; + const ILookInStream *inStream; +} CByteInToLook; + +static Byte ReadByte(const IByteIn *pp) +{ + CByteInToLook *p = CONTAINER_FROM_VTBL(pp, CByteInToLook, vt); + if (p->cur != p->end) + return *p->cur++; + if (p->res == SZ_OK) + { + size_t size = (size_t)(p->cur - p->begin); + p->processed += size; + p->res = ILookInStream_Skip(p->inStream, size); + size = (1 << 25); + p->res = ILookInStream_Look(p->inStream, (const void **)&p->begin, &size); + p->cur = p->begin; + p->end = p->begin + size; + if (size != 0) + return *p->cur++;; + } + p->extra = True; + return 0; +} + +static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, const ILookInStream *inStream, + Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) +{ + CPpmd7 ppmd; + CByteInToLook s; + SRes res = SZ_OK; + + s.vt.Read = ReadByte; + s.inStream = inStream; + s.begin = s.end = s.cur = NULL; + s.extra = False; + s.res = SZ_OK; + s.processed = 0; + + if (propsSize != 5) + return SZ_ERROR_UNSUPPORTED; + + { + unsigned order = props[0]; + UInt32 memSize = GetUi32(props + 1); + if (order < PPMD7_MIN_ORDER || + order > PPMD7_MAX_ORDER || + memSize < PPMD7_MIN_MEM_SIZE || + memSize > PPMD7_MAX_MEM_SIZE) + return SZ_ERROR_UNSUPPORTED; + Ppmd7_Construct(&ppmd); + if (!Ppmd7_Alloc(&ppmd, memSize, allocMain)) + return SZ_ERROR_MEM; + Ppmd7_Init(&ppmd, order); + } + { + ppmd.rc.dec.Stream = &s.vt; + if (!Ppmd7z_RangeDec_Init(&ppmd.rc.dec)) + res = SZ_ERROR_DATA; + else if (!s.extra) + { + Byte *buf = outBuffer; + const Byte *lim = buf + outSize; + for (; buf != lim; buf++) + { + int sym = Ppmd7z_DecodeSymbol(&ppmd); + if (s.extra || sym < 0) + break; + *buf = (Byte)sym; + } + if (buf != lim) + res = SZ_ERROR_DATA; + else if (!Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) + { + /* if (Ppmd7z_DecodeSymbol(&ppmd) != PPMD7_SYM_END || !Ppmd7z_RangeDec_IsFinishedOK(&ppmd.rc.dec)) */ + res = SZ_ERROR_DATA; + } + } + if (s.extra) + res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); + else if (s.processed + (size_t)(s.cur - s.begin) != inSize) + res = SZ_ERROR_DATA; + } + Ppmd7_Free(&ppmd, allocMain); + return res; +} + +#endif + + +static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream, + Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) +{ + CLzmaDec state; + SRes res = SZ_OK; + + LzmaDec_Construct(&state); + RINOK(LzmaDec_AllocateProbs(&state, props, propsSize, allocMain)); + state.dic = outBuffer; + state.dicBufSize = outSize; + LzmaDec_Init(&state); + + for (;;) + { + const void *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = ILookInStream_Look(inStream, &inBuf, &lookahead); + if (res != SZ_OK) + break; + + { + SizeT inProcessed = (SizeT)lookahead, dicPos = state.dicPos; + ELzmaStatus status; + res = LzmaDec_DecodeToDic(&state, outSize, (const Byte *)inBuf, &inProcessed, LZMA_FINISH_END, &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + + if (status == LZMA_STATUS_FINISHED_WITH_MARK) + { + if (outSize != state.dicPos || inSize != 0) + res = SZ_ERROR_DATA; + break; + } + + if (outSize == state.dicPos && inSize == 0 && status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) + break; + + if (inProcessed == 0 && dicPos == state.dicPos) + { + res = SZ_ERROR_DATA; + break; + } + + res = ILookInStream_Skip(inStream, inProcessed); + if (res != SZ_OK) + break; + } + } + + LzmaDec_FreeProbs(&state, allocMain); + return res; +} + + +#ifndef _7Z_NO_METHOD_LZMA2 + +static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream, + Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain) +{ + CLzma2Dec state; + SRes res = SZ_OK; + + Lzma2Dec_Construct(&state); + if (propsSize != 1) + return SZ_ERROR_DATA; + RINOK(Lzma2Dec_AllocateProbs(&state, props[0], allocMain)); + state.decoder.dic = outBuffer; + state.decoder.dicBufSize = outSize; + Lzma2Dec_Init(&state); + + for (;;) + { + const void *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = ILookInStream_Look(inStream, &inBuf, &lookahead); + if (res != SZ_OK) + break; + + { + SizeT inProcessed = (SizeT)lookahead, dicPos = state.decoder.dicPos; + ELzmaStatus status; + res = Lzma2Dec_DecodeToDic(&state, outSize, (const Byte *)inBuf, &inProcessed, LZMA_FINISH_END, &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + + if (status == LZMA_STATUS_FINISHED_WITH_MARK) + { + if (outSize != state.decoder.dicPos || inSize != 0) + res = SZ_ERROR_DATA; + break; + } + + if (inProcessed == 0 && dicPos == state.decoder.dicPos) + { + res = SZ_ERROR_DATA; + break; + } + + res = ILookInStream_Skip(inStream, inProcessed); + if (res != SZ_OK) + break; + } + } + + Lzma2Dec_FreeProbs(&state, allocMain); + return res; +} + +#endif + + +static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer) +{ + while (inSize > 0) + { + const void *inBuf; + size_t curSize = (1 << 18); + if (curSize > inSize) + curSize = (size_t)inSize; + RINOK(ILookInStream_Look(inStream, &inBuf, &curSize)); + if (curSize == 0) + return SZ_ERROR_INPUT_EOF; + memcpy(outBuffer, inBuf, curSize); + outBuffer += curSize; + inSize -= curSize; + RINOK(ILookInStream_Skip(inStream, curSize)); + } + return SZ_OK; +} + +static BoolInt IS_MAIN_METHOD(UInt32 m) +{ + switch (m) + { + case k_Copy: + case k_LZMA: + #ifndef _7Z_NO_METHOD_LZMA2 + case k_LZMA2: + #endif + #ifdef _7ZIP_PPMD_SUPPPORT + case k_PPMD: + #endif + return True; + } + return False; +} + +static BoolInt IS_SUPPORTED_CODER(const CSzCoderInfo *c) +{ + return + c->NumStreams == 1 + /* && c->MethodID <= (UInt32)0xFFFFFFFF */ + && IS_MAIN_METHOD((UInt32)c->MethodID); +} + +#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumStreams == 4) + +static SRes CheckSupportedFolder(const CSzFolder *f) +{ + if (f->NumCoders < 1 || f->NumCoders > 4) + return SZ_ERROR_UNSUPPORTED; + if (!IS_SUPPORTED_CODER(&f->Coders[0])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumCoders == 1) + { + if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBonds != 0) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + + + #ifndef _7Z_NO_METHODS_FILTERS + + if (f->NumCoders == 2) + { + const CSzCoderInfo *c = &f->Coders[1]; + if ( + /* c->MethodID > (UInt32)0xFFFFFFFF || */ + c->NumStreams != 1 + || f->NumPackStreams != 1 + || f->PackStreams[0] != 0 + || f->NumBonds != 1 + || f->Bonds[0].InIndex != 1 + || f->Bonds[0].OutIndex != 0) + return SZ_ERROR_UNSUPPORTED; + switch ((UInt32)c->MethodID) + { + case k_Delta: + case k_BCJ: + case k_PPC: + case k_IA64: + case k_SPARC: + case k_ARM: + case k_ARMT: + break; + default: + return SZ_ERROR_UNSUPPORTED; + } + return SZ_OK; + } + + #endif + + + if (f->NumCoders == 4) + { + if (!IS_SUPPORTED_CODER(&f->Coders[1]) + || !IS_SUPPORTED_CODER(&f->Coders[2]) + || !IS_BCJ2(&f->Coders[3])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumPackStreams != 4 + || f->PackStreams[0] != 2 + || f->PackStreams[1] != 6 + || f->PackStreams[2] != 1 + || f->PackStreams[3] != 0 + || f->NumBonds != 3 + || f->Bonds[0].InIndex != 5 || f->Bonds[0].OutIndex != 0 + || f->Bonds[1].InIndex != 4 || f->Bonds[1].OutIndex != 1 + || f->Bonds[2].InIndex != 3 || f->Bonds[2].OutIndex != 2) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + + return SZ_ERROR_UNSUPPORTED; +} + +#ifndef _7Z_NO_METHODS_FILTERS +#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; +#endif + +static SRes SzFolder_Decode2(const CSzFolder *folder, + const Byte *propsData, + const UInt64 *unpackSizes, + const UInt64 *packPositions, + ILookInStream *inStream, UInt64 startPos, + Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain, + Byte *tempBuf[]) +{ + UInt32 ci; + SizeT tempSizes[3] = { 0, 0, 0}; + SizeT tempSize3 = 0; + Byte *tempBuf3 = 0; + + RINOK(CheckSupportedFolder(folder)); + + for (ci = 0; ci < folder->NumCoders; ci++) + { + const CSzCoderInfo *coder = &folder->Coders[ci]; + + if (IS_MAIN_METHOD((UInt32)coder->MethodID)) + { + UInt32 si = 0; + UInt64 offset; + UInt64 inSize; + Byte *outBufCur = outBuffer; + SizeT outSizeCur = outSize; + if (folder->NumCoders == 4) + { + UInt32 indices[] = { 3, 2, 0 }; + UInt64 unpackSize = unpackSizes[ci]; + si = indices[ci]; + if (ci < 2) + { + Byte *temp; + outSizeCur = (SizeT)unpackSize; + if (outSizeCur != unpackSize) + return SZ_ERROR_MEM; + temp = (Byte *)ISzAlloc_Alloc(allocMain, outSizeCur); + if (!temp && outSizeCur != 0) + return SZ_ERROR_MEM; + outBufCur = tempBuf[1 - ci] = temp; + tempSizes[1 - ci] = outSizeCur; + } + else if (ci == 2) + { + if (unpackSize > outSize) /* check it */ + return SZ_ERROR_PARAM; + tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); + tempSize3 = outSizeCur = (SizeT)unpackSize; + } + else + return SZ_ERROR_UNSUPPORTED; + } + offset = packPositions[si]; + inSize = packPositions[(size_t)si + 1] - offset; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + + if (coder->MethodID == k_Copy) + { + if (inSize != outSizeCur) /* check it */ + return SZ_ERROR_DATA; + RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); + } + else if (coder->MethodID == k_LZMA) + { + RINOK(SzDecodeLzma(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + #ifndef _7Z_NO_METHOD_LZMA2 + else if (coder->MethodID == k_LZMA2) + { + RINOK(SzDecodeLzma2(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + #endif + #ifdef _7ZIP_PPMD_SUPPPORT + else if (coder->MethodID == k_PPMD) + { + RINOK(SzDecodePpmd(propsData + coder->PropsOffset, coder->PropsSize, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + #endif + else + return SZ_ERROR_UNSUPPORTED; + } + else if (coder->MethodID == k_BCJ2) + { + UInt64 offset = packPositions[1]; + UInt64 s3Size = packPositions[2] - offset; + + if (ci != 3) + return SZ_ERROR_UNSUPPORTED; + + tempSizes[2] = (SizeT)s3Size; + if (tempSizes[2] != s3Size) + return SZ_ERROR_MEM; + tempBuf[2] = (Byte *)ISzAlloc_Alloc(allocMain, tempSizes[2]); + if (!tempBuf[2] && tempSizes[2] != 0) + return SZ_ERROR_MEM; + + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + RINOK(SzDecodeCopy(s3Size, inStream, tempBuf[2])); + + if ((tempSizes[0] & 3) != 0 || + (tempSizes[1] & 3) != 0 || + tempSize3 + tempSizes[0] + tempSizes[1] != outSize) + return SZ_ERROR_DATA; + + { + CBcj2Dec p; + + p.bufs[0] = tempBuf3; p.lims[0] = tempBuf3 + tempSize3; + p.bufs[1] = tempBuf[0]; p.lims[1] = tempBuf[0] + tempSizes[0]; + p.bufs[2] = tempBuf[1]; p.lims[2] = tempBuf[1] + tempSizes[1]; + p.bufs[3] = tempBuf[2]; p.lims[3] = tempBuf[2] + tempSizes[2]; + + p.dest = outBuffer; + p.destLim = outBuffer + outSize; + + Bcj2Dec_Init(&p); + RINOK(Bcj2Dec_Decode(&p)); + + { + unsigned i; + for (i = 0; i < 4; i++) + if (p.bufs[i] != p.lims[i]) + return SZ_ERROR_DATA; + + if (!Bcj2Dec_IsFinished(&p)) + return SZ_ERROR_DATA; + + if (p.dest != p.destLim + || p.state != BCJ2_STREAM_MAIN) + return SZ_ERROR_DATA; + } + } + } + #ifndef _7Z_NO_METHODS_FILTERS + else if (ci == 1) + { + if (coder->MethodID == k_Delta) + { + if (coder->PropsSize != 1) + return SZ_ERROR_UNSUPPORTED; + { + Byte state[DELTA_STATE_SIZE]; + Delta_Init(state); + Delta_Decode(state, (unsigned)(propsData[coder->PropsOffset]) + 1, outBuffer, outSize); + } + } + else + { + if (coder->PropsSize != 0) + return SZ_ERROR_UNSUPPORTED; + switch (coder->MethodID) + { + case k_BCJ: + { + UInt32 state; + x86_Convert_Init(state); + x86_Convert(outBuffer, outSize, 0, &state, 0); + break; + } + CASE_BRA_CONV(PPC) + CASE_BRA_CONV(IA64) + CASE_BRA_CONV(SPARC) + CASE_BRA_CONV(ARM) + CASE_BRA_CONV(ARMT) + default: + return SZ_ERROR_UNSUPPORTED; + } + } + } + #endif + else + return SZ_ERROR_UNSUPPORTED; + } + + return SZ_OK; +} + + +SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, + ILookInStream *inStream, UInt64 startPos, + Byte *outBuffer, size_t outSize, + ISzAllocPtr allocMain) +{ + SRes res; + CSzFolder folder; + CSzData sd; + + const Byte *data = p->CodersData + p->FoCodersOffsets[folderIndex]; + sd.Data = data; + sd.Size = p->FoCodersOffsets[(size_t)folderIndex + 1] - p->FoCodersOffsets[folderIndex]; + + res = SzGetNextFolderItem(&folder, &sd); + + if (res != SZ_OK) + return res; + + if (sd.Size != 0 + || folder.UnpackStream != p->FoToMainUnpackSizeIndex[folderIndex] + || outSize != SzAr_GetFolderUnpackSize(p, folderIndex)) + return SZ_ERROR_FAIL; + { + unsigned i; + Byte *tempBuf[3] = { 0, 0, 0}; + + res = SzFolder_Decode2(&folder, data, + &p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex]], + p->PackPositions + p->FoStartPackStreamIndex[folderIndex], + inStream, startPos, + outBuffer, (SizeT)outSize, allocMain, tempBuf); + + for (i = 0; i < 3; i++) + ISzAlloc_Free(allocMain, tempBuf[i]); + + if (res == SZ_OK) + if (SzBitWithVals_Check(&p->FolderCRCs, folderIndex)) + if (CrcCalc(outBuffer, outSize) != p->FolderCRCs.Vals[folderIndex]) + res = SZ_ERROR_CRC; + + return res; + } +} diff --git a/deps/LZMA-SDK/C/7zFile.c b/deps/LZMA-SDK/C/7zFile.c index 900125d52..13d2efa47 100644 --- a/deps/LZMA-SDK/C/7zFile.c +++ b/deps/LZMA-SDK/C/7zFile.c @@ -1,442 +1,442 @@ -/* 7zFile.c -- File IO -2021-04-29 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "7zFile.h" - -#ifndef USE_WINDOWS_FILE - - #include - - #ifndef USE_FOPEN - #include - #include - #ifdef _WIN32 - #include - typedef int ssize_t; - typedef int off_t; - #else - #include - #endif - #endif - -#else - -/* - ReadFile and WriteFile functions in Windows have BUG: - If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) - from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES - (Insufficient system resources exist to complete the requested service). - Probably in some version of Windows there are problems with other sizes: - for 32 MB (maybe also for 16 MB). - And message can be "Network connection was lost" -*/ - -#endif - -#define kChunkSizeMax (1 << 22) - -void File_Construct(CSzFile *p) -{ - #ifdef USE_WINDOWS_FILE - p->handle = INVALID_HANDLE_VALUE; - #elif defined(USE_FOPEN) - p->file = NULL; - #else - p->fd = -1; - #endif -} - -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) - -static WRes File_Open(CSzFile *p, const char *name, int writeMode) -{ - #ifdef USE_WINDOWS_FILE - - p->handle = CreateFileA(name, - writeMode ? GENERIC_WRITE : GENERIC_READ, - FILE_SHARE_READ, NULL, - writeMode ? CREATE_ALWAYS : OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); - - #elif defined(USE_FOPEN) - - p->file = fopen(name, writeMode ? "wb+" : "rb"); - return (p->file != 0) ? 0 : - #ifdef UNDER_CE - 2; /* ENOENT */ - #else - errno; - #endif - - #else - - int flags = (writeMode ? (O_CREAT | O_EXCL | O_WRONLY) : O_RDONLY); - #ifdef O_BINARY - flags |= O_BINARY; - #endif - p->fd = open(name, flags, 0666); - return (p->fd != -1) ? 0 : errno; - - #endif -} - -WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); } - -WRes OutFile_Open(CSzFile *p, const char *name) -{ - #if defined(USE_WINDOWS_FILE) || defined(USE_FOPEN) - return File_Open(p, name, 1); - #else - p->fd = creat(name, 0666); - return (p->fd != -1) ? 0 : errno; - #endif -} - -#endif - - -#ifdef USE_WINDOWS_FILE -static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode) -{ - p->handle = CreateFileW(name, - writeMode ? GENERIC_WRITE : GENERIC_READ, - FILE_SHARE_READ, NULL, - writeMode ? CREATE_ALWAYS : OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); -} -WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); } -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); } -#endif - -WRes File_Close(CSzFile *p) -{ - #ifdef USE_WINDOWS_FILE - - if (p->handle != INVALID_HANDLE_VALUE) - { - if (!CloseHandle(p->handle)) - return GetLastError(); - p->handle = INVALID_HANDLE_VALUE; - } - - #elif defined(USE_FOPEN) - - if (p->file != NULL) - { - int res = fclose(p->file); - if (res != 0) - { - if (res == EOF) - return errno; - return res; - } - p->file = NULL; - } - - #else - - if (p->fd != -1) - { - if (close(p->fd) != 0) - return errno; - p->fd = -1; - } - - #endif - - return 0; -} - - -WRes File_Read(CSzFile *p, void *data, size_t *size) -{ - size_t originalSize = *size; - *size = 0; - if (originalSize == 0) - return 0; - - #ifdef USE_WINDOWS_FILE - - do - { - const DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; - DWORD processed = 0; - const BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL); - data = (void *)((Byte *)data + processed); - originalSize -= processed; - *size += processed; - if (!res) - return GetLastError(); - // debug : we can break here for partial reading mode - if (processed == 0) - break; - } - while (originalSize > 0); - - #elif defined(USE_FOPEN) - - do - { - const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; - const size_t processed = fread(data, 1, curSize, p->file); - data = (void *)((Byte *)data + (size_t)processed); - originalSize -= processed; - *size += processed; - if (processed != curSize) - return ferror(p->file); - // debug : we can break here for partial reading mode - if (processed == 0) - break; - } - while (originalSize > 0); - - #else - - do - { - const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; - const ssize_t processed = read(p->fd, data, curSize); - if (processed == -1) - return errno; - if (processed == 0) - break; - data = (void *)((Byte *)data + (size_t)processed); - originalSize -= (size_t)processed; - *size += (size_t)processed; - // debug : we can break here for partial reading mode - // break; - } - while (originalSize > 0); - - #endif - - return 0; -} - - -WRes File_Write(CSzFile *p, const void *data, size_t *size) -{ - size_t originalSize = *size; - *size = 0; - if (originalSize == 0) - return 0; - - #ifdef USE_WINDOWS_FILE - - do - { - const DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; - DWORD processed = 0; - const BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL); - data = (const void *)((const Byte *)data + processed); - originalSize -= processed; - *size += processed; - if (!res) - return GetLastError(); - if (processed == 0) - break; - } - while (originalSize > 0); - - #elif defined(USE_FOPEN) - - do - { - const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; - const size_t processed = fwrite(data, 1, curSize, p->file); - data = (void *)((Byte *)data + (size_t)processed); - originalSize -= processed; - *size += processed; - if (processed != curSize) - return ferror(p->file); - if (processed == 0) - break; - } - while (originalSize > 0); - - #else - - do - { - const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; - const ssize_t processed = write(p->fd, data, curSize); - if (processed == -1) - return errno; - if (processed == 0) - break; - data = (void *)((Byte *)data + (size_t)processed); - originalSize -= (size_t)processed; - *size += (size_t)processed; - } - while (originalSize > 0); - - #endif - - return 0; -} - - -WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) -{ - #ifdef USE_WINDOWS_FILE - - DWORD moveMethod; - UInt32 low = (UInt32)*pos; - LONG high = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */ - switch (origin) - { - case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; - case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break; - case SZ_SEEK_END: moveMethod = FILE_END; break; - default: return ERROR_INVALID_PARAMETER; - } - low = SetFilePointer(p->handle, (LONG)low, &high, moveMethod); - if (low == (UInt32)0xFFFFFFFF) - { - WRes res = GetLastError(); - if (res != NO_ERROR) - return res; - } - *pos = ((Int64)high << 32) | low; - return 0; - - #else - - int moveMethod; // = origin; - - switch (origin) - { - case SZ_SEEK_SET: moveMethod = SEEK_SET; break; - case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break; - case SZ_SEEK_END: moveMethod = SEEK_END; break; - default: return EINVAL; - } - - #if defined(USE_FOPEN) - { - int res = fseek(p->file, (long)*pos, moveMethod); - if (res == -1) - return errno; - *pos = ftell(p->file); - if (*pos == -1) - return errno; - return 0; - } - #else - { - off_t res = lseek(p->fd, (off_t)*pos, moveMethod); - if (res == -1) - return errno; - *pos = res; - return 0; - } - - #endif // USE_FOPEN - #endif // USE_WINDOWS_FILE -} - - -WRes File_GetLength(CSzFile *p, UInt64 *length) -{ - #ifdef USE_WINDOWS_FILE - - DWORD sizeHigh; - DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); - if (sizeLow == 0xFFFFFFFF) - { - DWORD res = GetLastError(); - if (res != NO_ERROR) - return res; - } - *length = (((UInt64)sizeHigh) << 32) + sizeLow; - return 0; - - #elif defined(USE_FOPEN) - - long pos = ftell(p->file); - int res = fseek(p->file, 0, SEEK_END); - *length = ftell(p->file); - fseek(p->file, pos, SEEK_SET); - return res; - - #else - - off_t pos; - *length = 0; - pos = lseek(p->fd, 0, SEEK_CUR); - if (pos != -1) - { - const off_t len2 = lseek(p->fd, 0, SEEK_END); - const off_t res2 = lseek(p->fd, pos, SEEK_SET); - if (len2 != -1) - { - *length = (UInt64)len2; - if (res2 != -1) - return 0; - } - } - return errno; - - #endif -} - - -/* ---------- FileSeqInStream ---------- */ - -static SRes FileSeqInStream_Read(const ISeqInStream *pp, void *buf, size_t *size) -{ - CFileSeqInStream *p = CONTAINER_FROM_VTBL(pp, CFileSeqInStream, vt); - WRes wres = File_Read(&p->file, buf, size); - p->wres = wres; - return (wres == 0) ? SZ_OK : SZ_ERROR_READ; -} - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p) -{ - p->vt.Read = FileSeqInStream_Read; -} - - -/* ---------- FileInStream ---------- */ - -static SRes FileInStream_Read(const ISeekInStream *pp, void *buf, size_t *size) -{ - CFileInStream *p = CONTAINER_FROM_VTBL(pp, CFileInStream, vt); - WRes wres = File_Read(&p->file, buf, size); - p->wres = wres; - return (wres == 0) ? SZ_OK : SZ_ERROR_READ; -} - -static SRes FileInStream_Seek(const ISeekInStream *pp, Int64 *pos, ESzSeek origin) -{ - CFileInStream *p = CONTAINER_FROM_VTBL(pp, CFileInStream, vt); - WRes wres = File_Seek(&p->file, pos, origin); - p->wres = wres; - return (wres == 0) ? SZ_OK : SZ_ERROR_READ; -} - -void FileInStream_CreateVTable(CFileInStream *p) -{ - p->vt.Read = FileInStream_Read; - p->vt.Seek = FileInStream_Seek; -} - - -/* ---------- FileOutStream ---------- */ - -static size_t FileOutStream_Write(const ISeqOutStream *pp, const void *data, size_t size) -{ - CFileOutStream *p = CONTAINER_FROM_VTBL(pp, CFileOutStream, vt); - WRes wres = File_Write(&p->file, data, &size); - p->wres = wres; - return size; -} - -void FileOutStream_CreateVTable(CFileOutStream *p) -{ - p->vt.Write = FileOutStream_Write; -} +/* 7zFile.c -- File IO +2021-04-29 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "7zFile.h" + +#ifndef USE_WINDOWS_FILE + + #include + + #ifndef USE_FOPEN + #include + #include + #ifdef _WIN32 + #include + typedef int ssize_t; + typedef int off_t; + #else + #include + #endif + #endif + +#else + +/* + ReadFile and WriteFile functions in Windows have BUG: + If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) + from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES + (Insufficient system resources exist to complete the requested service). + Probably in some version of Windows there are problems with other sizes: + for 32 MB (maybe also for 16 MB). + And message can be "Network connection was lost" +*/ + +#endif + +#define kChunkSizeMax (1 << 22) + +void File_Construct(CSzFile *p) +{ + #ifdef USE_WINDOWS_FILE + p->handle = INVALID_HANDLE_VALUE; + #elif defined(USE_FOPEN) + p->file = NULL; + #else + p->fd = -1; + #endif +} + +#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) + +static WRes File_Open(CSzFile *p, const char *name, int writeMode) +{ + #ifdef USE_WINDOWS_FILE + + p->handle = CreateFileA(name, + writeMode ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ, NULL, + writeMode ? CREATE_ALWAYS : OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); + + #elif defined(USE_FOPEN) + + p->file = fopen(name, writeMode ? "wb+" : "rb"); + return (p->file != 0) ? 0 : + #ifdef UNDER_CE + 2; /* ENOENT */ + #else + errno; + #endif + + #else + + int flags = (writeMode ? (O_CREAT | O_EXCL | O_WRONLY) : O_RDONLY); + #ifdef O_BINARY + flags |= O_BINARY; + #endif + p->fd = open(name, flags, 0666); + return (p->fd != -1) ? 0 : errno; + + #endif +} + +WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); } + +WRes OutFile_Open(CSzFile *p, const char *name) +{ + #if defined(USE_WINDOWS_FILE) || defined(USE_FOPEN) + return File_Open(p, name, 1); + #else + p->fd = creat(name, 0666); + return (p->fd != -1) ? 0 : errno; + #endif +} + +#endif + + +#ifdef USE_WINDOWS_FILE +static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode) +{ + p->handle = CreateFileW(name, + writeMode ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ, NULL, + writeMode ? CREATE_ALWAYS : OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); +} +WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); } +WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); } +#endif + +WRes File_Close(CSzFile *p) +{ + #ifdef USE_WINDOWS_FILE + + if (p->handle != INVALID_HANDLE_VALUE) + { + if (!CloseHandle(p->handle)) + return GetLastError(); + p->handle = INVALID_HANDLE_VALUE; + } + + #elif defined(USE_FOPEN) + + if (p->file != NULL) + { + int res = fclose(p->file); + if (res != 0) + { + if (res == EOF) + return errno; + return res; + } + p->file = NULL; + } + + #else + + if (p->fd != -1) + { + if (close(p->fd) != 0) + return errno; + p->fd = -1; + } + + #endif + + return 0; +} + + +WRes File_Read(CSzFile *p, void *data, size_t *size) +{ + size_t originalSize = *size; + *size = 0; + if (originalSize == 0) + return 0; + + #ifdef USE_WINDOWS_FILE + + do + { + const DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; + DWORD processed = 0; + const BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL); + data = (void *)((Byte *)data + processed); + originalSize -= processed; + *size += processed; + if (!res) + return GetLastError(); + // debug : we can break here for partial reading mode + if (processed == 0) + break; + } + while (originalSize > 0); + + #elif defined(USE_FOPEN) + + do + { + const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; + const size_t processed = fread(data, 1, curSize, p->file); + data = (void *)((Byte *)data + (size_t)processed); + originalSize -= processed; + *size += processed; + if (processed != curSize) + return ferror(p->file); + // debug : we can break here for partial reading mode + if (processed == 0) + break; + } + while (originalSize > 0); + + #else + + do + { + const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; + const ssize_t processed = read(p->fd, data, curSize); + if (processed == -1) + return errno; + if (processed == 0) + break; + data = (void *)((Byte *)data + (size_t)processed); + originalSize -= (size_t)processed; + *size += (size_t)processed; + // debug : we can break here for partial reading mode + // break; + } + while (originalSize > 0); + + #endif + + return 0; +} + + +WRes File_Write(CSzFile *p, const void *data, size_t *size) +{ + size_t originalSize = *size; + *size = 0; + if (originalSize == 0) + return 0; + + #ifdef USE_WINDOWS_FILE + + do + { + const DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; + DWORD processed = 0; + const BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL); + data = (const void *)((const Byte *)data + processed); + originalSize -= processed; + *size += processed; + if (!res) + return GetLastError(); + if (processed == 0) + break; + } + while (originalSize > 0); + + #elif defined(USE_FOPEN) + + do + { + const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; + const size_t processed = fwrite(data, 1, curSize, p->file); + data = (void *)((Byte *)data + (size_t)processed); + originalSize -= processed; + *size += processed; + if (processed != curSize) + return ferror(p->file); + if (processed == 0) + break; + } + while (originalSize > 0); + + #else + + do + { + const size_t curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : originalSize; + const ssize_t processed = write(p->fd, data, curSize); + if (processed == -1) + return errno; + if (processed == 0) + break; + data = (void *)((Byte *)data + (size_t)processed); + originalSize -= (size_t)processed; + *size += (size_t)processed; + } + while (originalSize > 0); + + #endif + + return 0; +} + + +WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin) +{ + #ifdef USE_WINDOWS_FILE + + DWORD moveMethod; + UInt32 low = (UInt32)*pos; + LONG high = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */ + switch (origin) + { + case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; + case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break; + case SZ_SEEK_END: moveMethod = FILE_END; break; + default: return ERROR_INVALID_PARAMETER; + } + low = SetFilePointer(p->handle, (LONG)low, &high, moveMethod); + if (low == (UInt32)0xFFFFFFFF) + { + WRes res = GetLastError(); + if (res != NO_ERROR) + return res; + } + *pos = ((Int64)high << 32) | low; + return 0; + + #else + + int moveMethod; // = origin; + + switch (origin) + { + case SZ_SEEK_SET: moveMethod = SEEK_SET; break; + case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break; + case SZ_SEEK_END: moveMethod = SEEK_END; break; + default: return EINVAL; + } + + #if defined(USE_FOPEN) + { + int res = fseek(p->file, (long)*pos, moveMethod); + if (res == -1) + return errno; + *pos = ftell(p->file); + if (*pos == -1) + return errno; + return 0; + } + #else + { + off_t res = lseek(p->fd, (off_t)*pos, moveMethod); + if (res == -1) + return errno; + *pos = res; + return 0; + } + + #endif // USE_FOPEN + #endif // USE_WINDOWS_FILE +} + + +WRes File_GetLength(CSzFile *p, UInt64 *length) +{ + #ifdef USE_WINDOWS_FILE + + DWORD sizeHigh; + DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); + if (sizeLow == 0xFFFFFFFF) + { + DWORD res = GetLastError(); + if (res != NO_ERROR) + return res; + } + *length = (((UInt64)sizeHigh) << 32) + sizeLow; + return 0; + + #elif defined(USE_FOPEN) + + long pos = ftell(p->file); + int res = fseek(p->file, 0, SEEK_END); + *length = ftell(p->file); + fseek(p->file, pos, SEEK_SET); + return res; + + #else + + off_t pos; + *length = 0; + pos = lseek(p->fd, 0, SEEK_CUR); + if (pos != -1) + { + const off_t len2 = lseek(p->fd, 0, SEEK_END); + const off_t res2 = lseek(p->fd, pos, SEEK_SET); + if (len2 != -1) + { + *length = (UInt64)len2; + if (res2 != -1) + return 0; + } + } + return errno; + + #endif +} + + +/* ---------- FileSeqInStream ---------- */ + +static SRes FileSeqInStream_Read(const ISeqInStream *pp, void *buf, size_t *size) +{ + CFileSeqInStream *p = CONTAINER_FROM_VTBL(pp, CFileSeqInStream, vt); + WRes wres = File_Read(&p->file, buf, size); + p->wres = wres; + return (wres == 0) ? SZ_OK : SZ_ERROR_READ; +} + +void FileSeqInStream_CreateVTable(CFileSeqInStream *p) +{ + p->vt.Read = FileSeqInStream_Read; +} + + +/* ---------- FileInStream ---------- */ + +static SRes FileInStream_Read(const ISeekInStream *pp, void *buf, size_t *size) +{ + CFileInStream *p = CONTAINER_FROM_VTBL(pp, CFileInStream, vt); + WRes wres = File_Read(&p->file, buf, size); + p->wres = wres; + return (wres == 0) ? SZ_OK : SZ_ERROR_READ; +} + +static SRes FileInStream_Seek(const ISeekInStream *pp, Int64 *pos, ESzSeek origin) +{ + CFileInStream *p = CONTAINER_FROM_VTBL(pp, CFileInStream, vt); + WRes wres = File_Seek(&p->file, pos, origin); + p->wres = wres; + return (wres == 0) ? SZ_OK : SZ_ERROR_READ; +} + +void FileInStream_CreateVTable(CFileInStream *p) +{ + p->vt.Read = FileInStream_Read; + p->vt.Seek = FileInStream_Seek; +} + + +/* ---------- FileOutStream ---------- */ + +static size_t FileOutStream_Write(const ISeqOutStream *pp, const void *data, size_t size) +{ + CFileOutStream *p = CONTAINER_FROM_VTBL(pp, CFileOutStream, vt); + WRes wres = File_Write(&p->file, data, &size); + p->wres = wres; + return size; +} + +void FileOutStream_CreateVTable(CFileOutStream *p) +{ + p->vt.Write = FileOutStream_Write; +} diff --git a/deps/LZMA-SDK/C/7zFile.h b/deps/LZMA-SDK/C/7zFile.h index c7a30fc2b..788abb6b9 100644 --- a/deps/LZMA-SDK/C/7zFile.h +++ b/deps/LZMA-SDK/C/7zFile.h @@ -1,91 +1,91 @@ -/* 7zFile.h -- File IO -2021-02-15 : Igor Pavlov : Public domain */ - -#ifndef __7Z_FILE_H -#define __7Z_FILE_H - -#ifdef _WIN32 -#define USE_WINDOWS_FILE -// #include -#endif - -#ifdef USE_WINDOWS_FILE -#include -#else -// note: USE_FOPEN mode is limited to 32-bit file size -// #define USE_FOPEN -// #include -#endif - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -/* ---------- File ---------- */ - -typedef struct -{ - #ifdef USE_WINDOWS_FILE - HANDLE handle; - #elif defined(USE_FOPEN) - FILE *file; - #else - int fd; - #endif -} CSzFile; - -void File_Construct(CSzFile *p); -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) -WRes InFile_Open(CSzFile *p, const char *name); -WRes OutFile_Open(CSzFile *p, const char *name); -#endif -#ifdef USE_WINDOWS_FILE -WRes InFile_OpenW(CSzFile *p, const WCHAR *name); -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); -#endif -WRes File_Close(CSzFile *p); - -/* reads max(*size, remain file's size) bytes */ -WRes File_Read(CSzFile *p, void *data, size_t *size); - -/* writes *size bytes */ -WRes File_Write(CSzFile *p, const void *data, size_t *size); - -WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); -WRes File_GetLength(CSzFile *p, UInt64 *length); - - -/* ---------- FileInStream ---------- */ - -typedef struct -{ - ISeqInStream vt; - CSzFile file; - WRes wres; -} CFileSeqInStream; - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p); - - -typedef struct -{ - ISeekInStream vt; - CSzFile file; - WRes wres; -} CFileInStream; - -void FileInStream_CreateVTable(CFileInStream *p); - - -typedef struct -{ - ISeqOutStream vt; - CSzFile file; - WRes wres; -} CFileOutStream; - -void FileOutStream_CreateVTable(CFileOutStream *p); - -EXTERN_C_END - -#endif +/* 7zFile.h -- File IO +2021-02-15 : Igor Pavlov : Public domain */ + +#ifndef __7Z_FILE_H +#define __7Z_FILE_H + +#ifdef _WIN32 +#define USE_WINDOWS_FILE +// #include +#endif + +#ifdef USE_WINDOWS_FILE +#include +#else +// note: USE_FOPEN mode is limited to 32-bit file size +// #define USE_FOPEN +// #include +#endif + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +/* ---------- File ---------- */ + +typedef struct +{ + #ifdef USE_WINDOWS_FILE + HANDLE handle; + #elif defined(USE_FOPEN) + FILE *file; + #else + int fd; + #endif +} CSzFile; + +void File_Construct(CSzFile *p); +#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) +WRes InFile_Open(CSzFile *p, const char *name); +WRes OutFile_Open(CSzFile *p, const char *name); +#endif +#ifdef USE_WINDOWS_FILE +WRes InFile_OpenW(CSzFile *p, const WCHAR *name); +WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); +#endif +WRes File_Close(CSzFile *p); + +/* reads max(*size, remain file's size) bytes */ +WRes File_Read(CSzFile *p, void *data, size_t *size); + +/* writes *size bytes */ +WRes File_Write(CSzFile *p, const void *data, size_t *size); + +WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); +WRes File_GetLength(CSzFile *p, UInt64 *length); + + +/* ---------- FileInStream ---------- */ + +typedef struct +{ + ISeqInStream vt; + CSzFile file; + WRes wres; +} CFileSeqInStream; + +void FileSeqInStream_CreateVTable(CFileSeqInStream *p); + + +typedef struct +{ + ISeekInStream vt; + CSzFile file; + WRes wres; +} CFileInStream; + +void FileInStream_CreateVTable(CFileInStream *p); + + +typedef struct +{ + ISeqOutStream vt; + CSzFile file; + WRes wres; +} CFileOutStream; + +void FileOutStream_CreateVTable(CFileOutStream *p); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/7zStream.c b/deps/LZMA-SDK/C/7zStream.c index 4b472a41d..28a14604f 100644 --- a/deps/LZMA-SDK/C/7zStream.c +++ b/deps/LZMA-SDK/C/7zStream.c @@ -1,176 +1,176 @@ -/* 7zStream.c -- 7z Stream functions -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "7zTypes.h" - -SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType) -{ - while (size != 0) - { - size_t processed = size; - RINOK(ISeqInStream_Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((Byte *)buf + processed); - size -= processed; - } - return SZ_OK; -} - -SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size) -{ - return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); -} - -SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf) -{ - size_t processed = 1; - RINOK(ISeqInStream_Read(stream, buf, &processed)); - return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; -} - - - -SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset) -{ - Int64 t = (Int64)offset; - return ILookInStream_Seek(stream, &t, SZ_SEEK_SET); -} - -SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size) -{ - const void *lookBuf; - if (*size == 0) - return SZ_OK; - RINOK(ILookInStream_Look(stream, &lookBuf, size)); - memcpy(buf, lookBuf, *size); - return ILookInStream_Skip(stream, *size); -} - -SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType) -{ - while (size != 0) - { - size_t processed = size; - RINOK(ILookInStream_Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((Byte *)buf + processed); - size -= processed; - } - return SZ_OK; -} - -SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size) -{ - return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); -} - - - -#define GET_LookToRead2 CLookToRead2 *p = CONTAINER_FROM_VTBL(pp, CLookToRead2, vt); - -static SRes LookToRead2_Look_Lookahead(const ILookInStream *pp, const void **buf, size_t *size) -{ - SRes res = SZ_OK; - GET_LookToRead2 - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size != 0) - { - p->pos = 0; - p->size = 0; - size2 = p->bufSize; - res = ISeekInStream_Read(p->realStream, p->buf, &size2); - p->size = size2; - } - if (*size > size2) - *size = size2; - *buf = p->buf + p->pos; - return res; -} - -static SRes LookToRead2_Look_Exact(const ILookInStream *pp, const void **buf, size_t *size) -{ - SRes res = SZ_OK; - GET_LookToRead2 - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size != 0) - { - p->pos = 0; - p->size = 0; - if (*size > p->bufSize) - *size = p->bufSize; - res = ISeekInStream_Read(p->realStream, p->buf, size); - size2 = p->size = *size; - } - if (*size > size2) - *size = size2; - *buf = p->buf + p->pos; - return res; -} - -static SRes LookToRead2_Skip(const ILookInStream *pp, size_t offset) -{ - GET_LookToRead2 - p->pos += offset; - return SZ_OK; -} - -static SRes LookToRead2_Read(const ILookInStream *pp, void *buf, size_t *size) -{ - GET_LookToRead2 - size_t rem = p->size - p->pos; - if (rem == 0) - return ISeekInStream_Read(p->realStream, buf, size); - if (rem > *size) - rem = *size; - memcpy(buf, p->buf + p->pos, rem); - p->pos += rem; - *size = rem; - return SZ_OK; -} - -static SRes LookToRead2_Seek(const ILookInStream *pp, Int64 *pos, ESzSeek origin) -{ - GET_LookToRead2 - p->pos = p->size = 0; - return ISeekInStream_Seek(p->realStream, pos, origin); -} - -void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead) -{ - p->vt.Look = lookahead ? - LookToRead2_Look_Lookahead : - LookToRead2_Look_Exact; - p->vt.Skip = LookToRead2_Skip; - p->vt.Read = LookToRead2_Read; - p->vt.Seek = LookToRead2_Seek; -} - - - -static SRes SecToLook_Read(const ISeqInStream *pp, void *buf, size_t *size) -{ - CSecToLook *p = CONTAINER_FROM_VTBL(pp, CSecToLook, vt); - return LookInStream_LookRead(p->realStream, buf, size); -} - -void SecToLook_CreateVTable(CSecToLook *p) -{ - p->vt.Read = SecToLook_Read; -} - -static SRes SecToRead_Read(const ISeqInStream *pp, void *buf, size_t *size) -{ - CSecToRead *p = CONTAINER_FROM_VTBL(pp, CSecToRead, vt); - return ILookInStream_Read(p->realStream, buf, size); -} - -void SecToRead_CreateVTable(CSecToRead *p) -{ - p->vt.Read = SecToRead_Read; -} +/* 7zStream.c -- 7z Stream functions +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#include "7zTypes.h" + +SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType) +{ + while (size != 0) + { + size_t processed = size; + RINOK(ISeqInStream_Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((Byte *)buf + processed); + size -= processed; + } + return SZ_OK; +} + +SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size) +{ + return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); +} + +SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf) +{ + size_t processed = 1; + RINOK(ISeqInStream_Read(stream, buf, &processed)); + return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; +} + + + +SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset) +{ + Int64 t = (Int64)offset; + return ILookInStream_Seek(stream, &t, SZ_SEEK_SET); +} + +SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size) +{ + const void *lookBuf; + if (*size == 0) + return SZ_OK; + RINOK(ILookInStream_Look(stream, &lookBuf, size)); + memcpy(buf, lookBuf, *size); + return ILookInStream_Skip(stream, *size); +} + +SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType) +{ + while (size != 0) + { + size_t processed = size; + RINOK(ILookInStream_Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((Byte *)buf + processed); + size -= processed; + } + return SZ_OK; +} + +SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size) +{ + return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); +} + + + +#define GET_LookToRead2 CLookToRead2 *p = CONTAINER_FROM_VTBL(pp, CLookToRead2, vt); + +static SRes LookToRead2_Look_Lookahead(const ILookInStream *pp, const void **buf, size_t *size) +{ + SRes res = SZ_OK; + GET_LookToRead2 + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size != 0) + { + p->pos = 0; + p->size = 0; + size2 = p->bufSize; + res = ISeekInStream_Read(p->realStream, p->buf, &size2); + p->size = size2; + } + if (*size > size2) + *size = size2; + *buf = p->buf + p->pos; + return res; +} + +static SRes LookToRead2_Look_Exact(const ILookInStream *pp, const void **buf, size_t *size) +{ + SRes res = SZ_OK; + GET_LookToRead2 + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size != 0) + { + p->pos = 0; + p->size = 0; + if (*size > p->bufSize) + *size = p->bufSize; + res = ISeekInStream_Read(p->realStream, p->buf, size); + size2 = p->size = *size; + } + if (*size > size2) + *size = size2; + *buf = p->buf + p->pos; + return res; +} + +static SRes LookToRead2_Skip(const ILookInStream *pp, size_t offset) +{ + GET_LookToRead2 + p->pos += offset; + return SZ_OK; +} + +static SRes LookToRead2_Read(const ILookInStream *pp, void *buf, size_t *size) +{ + GET_LookToRead2 + size_t rem = p->size - p->pos; + if (rem == 0) + return ISeekInStream_Read(p->realStream, buf, size); + if (rem > *size) + rem = *size; + memcpy(buf, p->buf + p->pos, rem); + p->pos += rem; + *size = rem; + return SZ_OK; +} + +static SRes LookToRead2_Seek(const ILookInStream *pp, Int64 *pos, ESzSeek origin) +{ + GET_LookToRead2 + p->pos = p->size = 0; + return ISeekInStream_Seek(p->realStream, pos, origin); +} + +void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead) +{ + p->vt.Look = lookahead ? + LookToRead2_Look_Lookahead : + LookToRead2_Look_Exact; + p->vt.Skip = LookToRead2_Skip; + p->vt.Read = LookToRead2_Read; + p->vt.Seek = LookToRead2_Seek; +} + + + +static SRes SecToLook_Read(const ISeqInStream *pp, void *buf, size_t *size) +{ + CSecToLook *p = CONTAINER_FROM_VTBL(pp, CSecToLook, vt); + return LookInStream_LookRead(p->realStream, buf, size); +} + +void SecToLook_CreateVTable(CSecToLook *p) +{ + p->vt.Read = SecToLook_Read; +} + +static SRes SecToRead_Read(const ISeqInStream *pp, void *buf, size_t *size) +{ + CSecToRead *p = CONTAINER_FROM_VTBL(pp, CSecToRead, vt); + return ILookInStream_Read(p->realStream, buf, size); +} + +void SecToRead_CreateVTable(CSecToRead *p) +{ + p->vt.Read = SecToRead_Read; +} diff --git a/deps/LZMA-SDK/C/7zTypes.h b/deps/LZMA-SDK/C/7zTypes.h index 497b14506..f7d707183 100644 --- a/deps/LZMA-SDK/C/7zTypes.h +++ b/deps/LZMA-SDK/C/7zTypes.h @@ -1,519 +1,529 @@ -/* 7zTypes.h -- Basic types -2021-04-25 : Igor Pavlov : Public domain */ - -#ifndef __7Z_TYPES_H -#define __7Z_TYPES_H - -#ifdef _WIN32 -/* #include */ -#else -#include -#endif - -#include - -#ifndef EXTERN_C_BEGIN -#ifdef __cplusplus -#define EXTERN_C_BEGIN extern "C" { -#define EXTERN_C_END } -#else -#define EXTERN_C_BEGIN -#define EXTERN_C_END -#endif -#endif - -EXTERN_C_BEGIN - -#define SZ_OK 0 - -#define SZ_ERROR_DATA 1 -#define SZ_ERROR_MEM 2 -#define SZ_ERROR_CRC 3 -#define SZ_ERROR_UNSUPPORTED 4 -#define SZ_ERROR_PARAM 5 -#define SZ_ERROR_INPUT_EOF 6 -#define SZ_ERROR_OUTPUT_EOF 7 -#define SZ_ERROR_READ 8 -#define SZ_ERROR_WRITE 9 -#define SZ_ERROR_PROGRESS 10 -#define SZ_ERROR_FAIL 11 -#define SZ_ERROR_THREAD 12 - -#define SZ_ERROR_ARCHIVE 16 -#define SZ_ERROR_NO_ARCHIVE 17 - -typedef int SRes; - - -#ifdef _MSC_VER - #if _MSC_VER > 1200 - #define MY_ALIGN(n) __declspec(align(n)) - #else - #define MY_ALIGN(n) - #endif -#else - #define MY_ALIGN(n) __attribute__ ((aligned(n))) -#endif - - -#ifdef _WIN32 - -/* typedef DWORD WRes; */ -typedef unsigned WRes; -#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x) - -#else // _WIN32 - -// #define ENV_HAVE_LSTAT -typedef int WRes; - -// (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT -#define MY__FACILITY_ERRNO 0x800 -#define MY__FACILITY_WIN32 7 -#define MY__FACILITY__WRes MY__FACILITY_ERRNO - -#define MY_HRESULT_FROM_errno_CONST_ERROR(x) ((HRESULT)( \ - ( (HRESULT)(x) & 0x0000FFFF) \ - | (MY__FACILITY__WRes << 16) \ - | (HRESULT)0x80000000 )) - -#define MY_SRes_HRESULT_FROM_WRes(x) \ - ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : MY_HRESULT_FROM_errno_CONST_ERROR(x)) - -// we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno) -#define HRESULT_FROM_WIN32(x) MY_SRes_HRESULT_FROM_WRes(x) - -/* -#define ERROR_FILE_NOT_FOUND 2L -#define ERROR_ACCESS_DENIED 5L -#define ERROR_NO_MORE_FILES 18L -#define ERROR_LOCK_VIOLATION 33L -#define ERROR_FILE_EXISTS 80L -#define ERROR_DISK_FULL 112L -#define ERROR_NEGATIVE_SEEK 131L -#define ERROR_ALREADY_EXISTS 183L -#define ERROR_DIRECTORY 267L -#define ERROR_TOO_MANY_POSTS 298L - -#define ERROR_INVALID_REPARSE_DATA 4392L -#define ERROR_REPARSE_TAG_INVALID 4393L -#define ERROR_REPARSE_TAG_MISMATCH 4394L -*/ - -// we use errno equivalents for some WIN32 errors: - -#define ERROR_INVALID_FUNCTION EINVAL -#define ERROR_ALREADY_EXISTS EEXIST -#define ERROR_FILE_EXISTS EEXIST -#define ERROR_PATH_NOT_FOUND ENOENT -#define ERROR_FILE_NOT_FOUND ENOENT -#define ERROR_DISK_FULL ENOSPC -// #define ERROR_INVALID_HANDLE EBADF - -// we use FACILITY_WIN32 for errors that has no errno equivalent -// Too many posts were made to a semaphore. -#define ERROR_TOO_MANY_POSTS ((HRESULT)0x8007012AL) -#define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L) -#define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L) - -// if (MY__FACILITY__WRes != FACILITY_WIN32), -// we use FACILITY_WIN32 for COM errors: -#define E_OUTOFMEMORY ((HRESULT)0x8007000EL) -#define E_INVALIDARG ((HRESULT)0x80070057L) -#define MY__E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L) - -/* -// we can use FACILITY_ERRNO for some COM errors, that have errno equivalents: -#define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM) -#define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) -#define MY__E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) -*/ - -// gcc / clang : (sizeof(long) == sizeof(void*)) in 32/64 bits -typedef long INT_PTR; -typedef unsigned long UINT_PTR; - -#define TEXT(quote) quote - -#define FILE_ATTRIBUTE_READONLY 0x0001 -#define FILE_ATTRIBUTE_HIDDEN 0x0002 -#define FILE_ATTRIBUTE_SYSTEM 0x0004 -#define FILE_ATTRIBUTE_DIRECTORY 0x0010 -#define FILE_ATTRIBUTE_ARCHIVE 0x0020 -#define FILE_ATTRIBUTE_DEVICE 0x0040 -#define FILE_ATTRIBUTE_NORMAL 0x0080 -#define FILE_ATTRIBUTE_TEMPORARY 0x0100 -#define FILE_ATTRIBUTE_SPARSE_FILE 0x0200 -#define FILE_ATTRIBUTE_REPARSE_POINT 0x0400 -#define FILE_ATTRIBUTE_COMPRESSED 0x0800 -#define FILE_ATTRIBUTE_OFFLINE 0x1000 -#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x2000 -#define FILE_ATTRIBUTE_ENCRYPTED 0x4000 - -#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */ - -#endif - - -#ifndef RINOK -#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } -#endif - -#ifndef RINOK_WRes -#define RINOK_WRes(x) { WRes __result__ = (x); if (__result__ != 0) return __result__; } -#endif - -typedef unsigned char Byte; -typedef short Int16; -typedef unsigned short UInt16; - -#ifdef _LZMA_UINT32_IS_ULONG -typedef long Int32; -typedef unsigned long UInt32; -#else -typedef int Int32; -typedef unsigned int UInt32; -#endif - - -#ifndef _WIN32 - -typedef int INT; -typedef Int32 INT32; -typedef unsigned int UINT; -typedef UInt32 UINT32; -typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility -typedef UINT32 ULONG; - -#undef DWORD -typedef UINT32 DWORD; - -#define VOID void - -#define HRESULT LONG - -typedef void *LPVOID; -// typedef void VOID; -// typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; -// gcc / clang on Unix : sizeof(long==sizeof(void*) in 32 or 64 bits) -typedef long INT_PTR; -typedef unsigned long UINT_PTR; -typedef long LONG_PTR; -typedef unsigned long DWORD_PTR; - -typedef size_t SIZE_T; - -#endif // _WIN32 - - - -#ifdef _SZ_NO_INT_64 - -/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. - NOTES: Some code will work incorrectly in that case! */ - -typedef long Int64; -typedef unsigned long UInt64; - -#else - -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef __int64 Int64; -typedef unsigned __int64 UInt64; -#define UINT64_CONST(n) n -#else -typedef long long int Int64; -typedef unsigned long long int UInt64; -#define UINT64_CONST(n) n ## ULL -#endif - -#endif - -#ifdef _LZMA_NO_SYSTEM_SIZE_T -typedef UInt32 SizeT; -#else -typedef size_t SizeT; -#endif - -typedef int BoolInt; -/* typedef BoolInt Bool; */ -#define True 1 -#define False 0 - - -#ifdef _WIN32 -#define MY_STD_CALL __stdcall -#else -#define MY_STD_CALL -#endif - -#ifdef _MSC_VER - -#if _MSC_VER >= 1300 -#define MY_NO_INLINE __declspec(noinline) -#else -#define MY_NO_INLINE -#endif - -#define MY_FORCE_INLINE __forceinline - -#define MY_CDECL __cdecl -#define MY_FAST_CALL __fastcall - -#else // _MSC_VER - -#if (defined(__GNUC__) && (__GNUC__ >= 4)) \ - || (defined(__clang__) && (__clang_major__ >= 4)) \ - || defined(__INTEL_COMPILER) \ - || defined(__xlC__) -#define MY_NO_INLINE __attribute__((noinline)) -// #define MY_FORCE_INLINE __attribute__((always_inline)) inline -#else -#define MY_NO_INLINE -#endif - -#define MY_FORCE_INLINE - - -#define MY_CDECL - -#if defined(_M_IX86) \ - || defined(__i386__) -// #define MY_FAST_CALL __attribute__((fastcall)) -// #define MY_FAST_CALL __attribute__((cdecl)) -#define MY_FAST_CALL -#elif defined(MY_CPU_AMD64) -// #define MY_FAST_CALL __attribute__((ms_abi)) -#define MY_FAST_CALL -#else -#define MY_FAST_CALL -#endif - -#endif // _MSC_VER - - -/* The following interfaces use first parameter as pointer to structure */ - -typedef struct IByteIn IByteIn; -struct IByteIn -{ - Byte (*Read)(const IByteIn *p); /* reads one byte, returns 0 in case of EOF or error */ -}; -#define IByteIn_Read(p) (p)->Read(p) - - -typedef struct IByteOut IByteOut; -struct IByteOut -{ - void (*Write)(const IByteOut *p, Byte b); -}; -#define IByteOut_Write(p, b) (p)->Write(p, b) - - -typedef struct ISeqInStream ISeqInStream; -struct ISeqInStream -{ - SRes (*Read)(const ISeqInStream *p, void *buf, size_t *size); - /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. - (output(*size) < input(*size)) is allowed */ -}; -#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size) - -/* it can return SZ_ERROR_INPUT_EOF */ -SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size); -SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType); -SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf); - - -typedef struct ISeqOutStream ISeqOutStream; -struct ISeqOutStream -{ - size_t (*Write)(const ISeqOutStream *p, const void *buf, size_t size); - /* Returns: result - the number of actually written bytes. - (result < size) means error */ -}; -#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size) - -typedef enum -{ - SZ_SEEK_SET = 0, - SZ_SEEK_CUR = 1, - SZ_SEEK_END = 2 -} ESzSeek; - - -typedef struct ISeekInStream ISeekInStream; -struct ISeekInStream -{ - SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ - SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin); -}; -#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size) -#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin) - - -typedef struct ILookInStream ILookInStream; -struct ILookInStream -{ - SRes (*Look)(const ILookInStream *p, const void **buf, size_t *size); - /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. - (output(*size) > input(*size)) is not allowed - (output(*size) < input(*size)) is allowed */ - SRes (*Skip)(const ILookInStream *p, size_t offset); - /* offset must be <= output(*size) of Look */ - - SRes (*Read)(const ILookInStream *p, void *buf, size_t *size); - /* reads directly (without buffer). It's same as ISeqInStream::Read */ - SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin); -}; - -#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size) -#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset) -#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size) -#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin) - - -SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size); -SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset); - -/* reads via ILookInStream::Read */ -SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType); -SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size); - - - -typedef struct -{ - ILookInStream vt; - const ISeekInStream *realStream; - - size_t pos; - size_t size; /* it's data size */ - - /* the following variables must be set outside */ - Byte *buf; - size_t bufSize; -} CLookToRead2; - -void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead); - -#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; } - - -typedef struct -{ - ISeqInStream vt; - const ILookInStream *realStream; -} CSecToLook; - -void SecToLook_CreateVTable(CSecToLook *p); - - - -typedef struct -{ - ISeqInStream vt; - const ILookInStream *realStream; -} CSecToRead; - -void SecToRead_CreateVTable(CSecToRead *p); - - -typedef struct ICompressProgress ICompressProgress; - -struct ICompressProgress -{ - SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize); - /* Returns: result. (result != SZ_OK) means break. - Value (UInt64)(Int64)-1 for size means unknown value. */ -}; -#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize) - - - -typedef struct ISzAlloc ISzAlloc; -typedef const ISzAlloc * ISzAllocPtr; - -struct ISzAlloc -{ - void *(*Alloc)(ISzAllocPtr p, size_t size); - void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */ -}; - -#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size) -#define ISzAlloc_Free(p, a) (p)->Free(p, a) - -/* deprecated */ -#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size) -#define IAlloc_Free(p, a) ISzAlloc_Free(p, a) - - - - - -#ifndef MY_offsetof - #ifdef offsetof - #define MY_offsetof(type, m) offsetof(type, m) - /* - #define MY_offsetof(type, m) FIELD_OFFSET(type, m) - */ - #else - #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m)) - #endif -#endif - - - -#ifndef MY_container_of - -/* -#define MY_container_of(ptr, type, m) container_of(ptr, type, m) -#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m) -#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m))) -#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m)))) -*/ - -/* - GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly" - GCC 3.4.4 : classes with constructor - GCC 4.8.1 : classes with non-public variable members" -*/ - -#define MY_container_of(ptr, type, m) ((type *)(void *)((char *)(void *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m))) - -#endif - -#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(void *)(ptr)) - -/* -#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) -*/ -#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m) - -#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) -/* -#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m) -*/ - - -#define MY_memset_0_ARRAY(a) memset((a), 0, sizeof(a)) - -#ifdef _WIN32 - -#define CHAR_PATH_SEPARATOR '\\' -#define WCHAR_PATH_SEPARATOR L'\\' -#define STRING_PATH_SEPARATOR "\\" -#define WSTRING_PATH_SEPARATOR L"\\" - -#else - -#define CHAR_PATH_SEPARATOR '/' -#define WCHAR_PATH_SEPARATOR L'/' -#define STRING_PATH_SEPARATOR "/" -#define WSTRING_PATH_SEPARATOR L"/" - -#endif - -EXTERN_C_END - -#endif +/* 7zTypes.h -- Basic types +2022-04-01 : Igor Pavlov : Public domain */ + +#ifndef __7Z_TYPES_H +#define __7Z_TYPES_H + +#ifdef _WIN32 +/* #include */ +#else +#include +#endif + +#include + +#ifndef EXTERN_C_BEGIN +#ifdef __cplusplus +#define EXTERN_C_BEGIN extern "C" { +#define EXTERN_C_END } +#else +#define EXTERN_C_BEGIN +#define EXTERN_C_END +#endif +#endif + +EXTERN_C_BEGIN + +#define SZ_OK 0 + +#define SZ_ERROR_DATA 1 +#define SZ_ERROR_MEM 2 +#define SZ_ERROR_CRC 3 +#define SZ_ERROR_UNSUPPORTED 4 +#define SZ_ERROR_PARAM 5 +#define SZ_ERROR_INPUT_EOF 6 +#define SZ_ERROR_OUTPUT_EOF 7 +#define SZ_ERROR_READ 8 +#define SZ_ERROR_WRITE 9 +#define SZ_ERROR_PROGRESS 10 +#define SZ_ERROR_FAIL 11 +#define SZ_ERROR_THREAD 12 + +#define SZ_ERROR_ARCHIVE 16 +#define SZ_ERROR_NO_ARCHIVE 17 + +typedef int SRes; + + +#ifdef _MSC_VER + #if _MSC_VER > 1200 + #define MY_ALIGN(n) __declspec(align(n)) + #else + #define MY_ALIGN(n) + #endif +#else + #define MY_ALIGN(n) __attribute__ ((aligned(n))) +#endif + + +#ifdef _WIN32 + +/* typedef DWORD WRes; */ +typedef unsigned WRes; +#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x) + +// #define MY_HRES_ERROR__INTERNAL_ERROR MY_SRes_HRESULT_FROM_WRes(ERROR_INTERNAL_ERROR) + +#else // _WIN32 + +// #define ENV_HAVE_LSTAT +typedef int WRes; + +// (FACILITY_ERRNO = 0x800) is 7zip's FACILITY constant to represent (errno) errors in HRESULT +#define MY__FACILITY_ERRNO 0x800 +#define MY__FACILITY_WIN32 7 +#define MY__FACILITY__WRes MY__FACILITY_ERRNO + +#define MY_HRESULT_FROM_errno_CONST_ERROR(x) ((HRESULT)( \ + ( (HRESULT)(x) & 0x0000FFFF) \ + | (MY__FACILITY__WRes << 16) \ + | (HRESULT)0x80000000 )) + +#define MY_SRes_HRESULT_FROM_WRes(x) \ + ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : MY_HRESULT_FROM_errno_CONST_ERROR(x)) + +// we call macro HRESULT_FROM_WIN32 for system errors (WRes) that are (errno) +#define HRESULT_FROM_WIN32(x) MY_SRes_HRESULT_FROM_WRes(x) + +/* +#define ERROR_FILE_NOT_FOUND 2L +#define ERROR_ACCESS_DENIED 5L +#define ERROR_NO_MORE_FILES 18L +#define ERROR_LOCK_VIOLATION 33L +#define ERROR_FILE_EXISTS 80L +#define ERROR_DISK_FULL 112L +#define ERROR_NEGATIVE_SEEK 131L +#define ERROR_ALREADY_EXISTS 183L +#define ERROR_DIRECTORY 267L +#define ERROR_TOO_MANY_POSTS 298L + +#define ERROR_INTERNAL_ERROR 1359L +#define ERROR_INVALID_REPARSE_DATA 4392L +#define ERROR_REPARSE_TAG_INVALID 4393L +#define ERROR_REPARSE_TAG_MISMATCH 4394L +*/ + +// we use errno equivalents for some WIN32 errors: + +#define ERROR_INVALID_PARAMETER EINVAL +#define ERROR_INVALID_FUNCTION EINVAL +#define ERROR_ALREADY_EXISTS EEXIST +#define ERROR_FILE_EXISTS EEXIST +#define ERROR_PATH_NOT_FOUND ENOENT +#define ERROR_FILE_NOT_FOUND ENOENT +#define ERROR_DISK_FULL ENOSPC +// #define ERROR_INVALID_HANDLE EBADF + +// we use FACILITY_WIN32 for errors that has no errno equivalent +// Too many posts were made to a semaphore. +#define ERROR_TOO_MANY_POSTS ((HRESULT)0x8007012AL) +#define ERROR_INVALID_REPARSE_DATA ((HRESULT)0x80071128L) +#define ERROR_REPARSE_TAG_INVALID ((HRESULT)0x80071129L) + +// if (MY__FACILITY__WRes != FACILITY_WIN32), +// we use FACILITY_WIN32 for COM errors: +#define E_OUTOFMEMORY ((HRESULT)0x8007000EL) +#define E_INVALIDARG ((HRESULT)0x80070057L) +#define MY__E_ERROR_NEGATIVE_SEEK ((HRESULT)0x80070083L) + +/* +// we can use FACILITY_ERRNO for some COM errors, that have errno equivalents: +#define E_OUTOFMEMORY MY_HRESULT_FROM_errno_CONST_ERROR(ENOMEM) +#define E_INVALIDARG MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) +#define MY__E_ERROR_NEGATIVE_SEEK MY_HRESULT_FROM_errno_CONST_ERROR(EINVAL) +*/ + +#define TEXT(quote) quote + +#define FILE_ATTRIBUTE_READONLY 0x0001 +#define FILE_ATTRIBUTE_HIDDEN 0x0002 +#define FILE_ATTRIBUTE_SYSTEM 0x0004 +#define FILE_ATTRIBUTE_DIRECTORY 0x0010 +#define FILE_ATTRIBUTE_ARCHIVE 0x0020 +#define FILE_ATTRIBUTE_DEVICE 0x0040 +#define FILE_ATTRIBUTE_NORMAL 0x0080 +#define FILE_ATTRIBUTE_TEMPORARY 0x0100 +#define FILE_ATTRIBUTE_SPARSE_FILE 0x0200 +#define FILE_ATTRIBUTE_REPARSE_POINT 0x0400 +#define FILE_ATTRIBUTE_COMPRESSED 0x0800 +#define FILE_ATTRIBUTE_OFFLINE 0x1000 +#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x2000 +#define FILE_ATTRIBUTE_ENCRYPTED 0x4000 + +#define FILE_ATTRIBUTE_UNIX_EXTENSION 0x8000 /* trick for Unix */ + +#endif + + +#ifndef RINOK +#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } +#endif + +#ifndef RINOK_WRes +#define RINOK_WRes(x) { WRes __result__ = (x); if (__result__ != 0) return __result__; } +#endif + +typedef unsigned char Byte; +typedef short Int16; +typedef unsigned short UInt16; + +#ifdef _LZMA_UINT32_IS_ULONG +typedef long Int32; +typedef unsigned long UInt32; +#else +typedef int Int32; +typedef unsigned int UInt32; +#endif + + +#ifndef _WIN32 + +typedef int INT; +typedef Int32 INT32; +typedef unsigned int UINT; +typedef UInt32 UINT32; +typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit for _WIN32 compatibility +typedef UINT32 ULONG; + +#undef DWORD +typedef UINT32 DWORD; + +#define VOID void + +#define HRESULT LONG + +typedef void *LPVOID; +// typedef void VOID; +// typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR; +// gcc / clang on Unix : sizeof(long==sizeof(void*) in 32 or 64 bits) +typedef long INT_PTR; +typedef unsigned long UINT_PTR; +typedef long LONG_PTR; +typedef unsigned long DWORD_PTR; + +typedef size_t SIZE_T; + +#endif // _WIN32 + + +#define MY_HRES_ERROR__INTERNAL_ERROR ((HRESULT)0x8007054FL) + + +#ifdef _SZ_NO_INT_64 + +/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. + NOTES: Some code will work incorrectly in that case! */ + +typedef long Int64; +typedef unsigned long UInt64; + +#else + +#if defined(_MSC_VER) || defined(__BORLANDC__) +typedef __int64 Int64; +typedef unsigned __int64 UInt64; +#define UINT64_CONST(n) n +#else +typedef long long int Int64; +typedef unsigned long long int UInt64; +#define UINT64_CONST(n) n ## ULL +#endif + +#endif + +#ifdef _LZMA_NO_SYSTEM_SIZE_T +typedef UInt32 SizeT; +#else +typedef size_t SizeT; +#endif + +typedef int BoolInt; +/* typedef BoolInt Bool; */ +#define True 1 +#define False 0 + + +#ifdef _WIN32 +#define MY_STD_CALL __stdcall +#else +#define MY_STD_CALL +#endif + +#ifdef _MSC_VER + +#if _MSC_VER >= 1300 +#define MY_NO_INLINE __declspec(noinline) +#else +#define MY_NO_INLINE +#endif + +#define MY_FORCE_INLINE __forceinline + +#define MY_CDECL __cdecl +#define MY_FAST_CALL __fastcall + +#else // _MSC_VER + +#if (defined(__GNUC__) && (__GNUC__ >= 4)) \ + || (defined(__clang__) && (__clang_major__ >= 4)) \ + || defined(__INTEL_COMPILER) \ + || defined(__xlC__) +#define MY_NO_INLINE __attribute__((noinline)) +// #define MY_FORCE_INLINE __attribute__((always_inline)) inline +#else +#define MY_NO_INLINE +#endif + +#define MY_FORCE_INLINE + + +#define MY_CDECL + +#if defined(_M_IX86) \ + || defined(__i386__) +// #define MY_FAST_CALL __attribute__((fastcall)) +// #define MY_FAST_CALL __attribute__((cdecl)) +#define MY_FAST_CALL +#elif defined(MY_CPU_AMD64) +// #define MY_FAST_CALL __attribute__((ms_abi)) +#define MY_FAST_CALL +#else +#define MY_FAST_CALL +#endif + +#endif // _MSC_VER + + +/* The following interfaces use first parameter as pointer to structure */ + +typedef struct IByteIn IByteIn; +struct IByteIn +{ + Byte (*Read)(const IByteIn *p); /* reads one byte, returns 0 in case of EOF or error */ +}; +#define IByteIn_Read(p) (p)->Read(p) + + +typedef struct IByteOut IByteOut; +struct IByteOut +{ + void (*Write)(const IByteOut *p, Byte b); +}; +#define IByteOut_Write(p, b) (p)->Write(p, b) + + +typedef struct ISeqInStream ISeqInStream; +struct ISeqInStream +{ + SRes (*Read)(const ISeqInStream *p, void *buf, size_t *size); + /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. + (output(*size) < input(*size)) is allowed */ +}; +#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size) + +/* it can return SZ_ERROR_INPUT_EOF */ +SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size); +SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType); +SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf); + + +typedef struct ISeqOutStream ISeqOutStream; +struct ISeqOutStream +{ + size_t (*Write)(const ISeqOutStream *p, const void *buf, size_t size); + /* Returns: result - the number of actually written bytes. + (result < size) means error */ +}; +#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size) + +typedef enum +{ + SZ_SEEK_SET = 0, + SZ_SEEK_CUR = 1, + SZ_SEEK_END = 2 +} ESzSeek; + + +typedef struct ISeekInStream ISeekInStream; +struct ISeekInStream +{ + SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ + SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin); +}; +#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size) +#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin) + + +typedef struct ILookInStream ILookInStream; +struct ILookInStream +{ + SRes (*Look)(const ILookInStream *p, const void **buf, size_t *size); + /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. + (output(*size) > input(*size)) is not allowed + (output(*size) < input(*size)) is allowed */ + SRes (*Skip)(const ILookInStream *p, size_t offset); + /* offset must be <= output(*size) of Look */ + + SRes (*Read)(const ILookInStream *p, void *buf, size_t *size); + /* reads directly (without buffer). It's same as ISeqInStream::Read */ + SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin); +}; + +#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size) +#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset) +#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size) +#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin) + + +SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size); +SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset); + +/* reads via ILookInStream::Read */ +SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType); +SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size); + + + +typedef struct +{ + ILookInStream vt; + const ISeekInStream *realStream; + + size_t pos; + size_t size; /* it's data size */ + + /* the following variables must be set outside */ + Byte *buf; + size_t bufSize; +} CLookToRead2; + +void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead); + +#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; } + + +typedef struct +{ + ISeqInStream vt; + const ILookInStream *realStream; +} CSecToLook; + +void SecToLook_CreateVTable(CSecToLook *p); + + + +typedef struct +{ + ISeqInStream vt; + const ILookInStream *realStream; +} CSecToRead; + +void SecToRead_CreateVTable(CSecToRead *p); + + +typedef struct ICompressProgress ICompressProgress; + +struct ICompressProgress +{ + SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize); + /* Returns: result. (result != SZ_OK) means break. + Value (UInt64)(Int64)-1 for size means unknown value. */ +}; +#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize) + + + +typedef struct ISzAlloc ISzAlloc; +typedef const ISzAlloc * ISzAllocPtr; + +struct ISzAlloc +{ + void *(*Alloc)(ISzAllocPtr p, size_t size); + void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */ +}; + +#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size) +#define ISzAlloc_Free(p, a) (p)->Free(p, a) + +/* deprecated */ +#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size) +#define IAlloc_Free(p, a) ISzAlloc_Free(p, a) + + + + + +#ifndef MY_offsetof + #ifdef offsetof + #define MY_offsetof(type, m) offsetof(type, m) + /* + #define MY_offsetof(type, m) FIELD_OFFSET(type, m) + */ + #else + #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m)) + #endif +#endif + + + +#ifndef MY_container_of + +/* +#define MY_container_of(ptr, type, m) container_of(ptr, type, m) +#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m) +#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m))) +#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m)))) +*/ + +/* + GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly" + GCC 3.4.4 : classes with constructor + GCC 4.8.1 : classes with non-public variable members" +*/ + +#define MY_container_of(ptr, type, m) ((type *)(void *)((char *)(void *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m))) + +#endif + +#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(void *)(ptr)) + +/* +#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +*/ +#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m) + +#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) +/* +#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m) +*/ + + +#define MY_memset_0_ARRAY(a) memset((a), 0, sizeof(a)) + +#ifdef _WIN32 + +#define CHAR_PATH_SEPARATOR '\\' +#define WCHAR_PATH_SEPARATOR L'\\' +#define STRING_PATH_SEPARATOR "\\" +#define WSTRING_PATH_SEPARATOR L"\\" + +#else + +#define CHAR_PATH_SEPARATOR '/' +#define WCHAR_PATH_SEPARATOR L'/' +#define STRING_PATH_SEPARATOR "/" +#define WSTRING_PATH_SEPARATOR L"/" + +#endif + +#define k_PropVar_TimePrec_0 0 +#define k_PropVar_TimePrec_Unix 1 +#define k_PropVar_TimePrec_DOS 2 +#define k_PropVar_TimePrec_HighPrec 3 +#define k_PropVar_TimePrec_Base 16 +#define k_PropVar_TimePrec_100ns (k_PropVar_TimePrec_Base + 7) +#define k_PropVar_TimePrec_1ns (k_PropVar_TimePrec_Base + 9) + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/7zVersion.h b/deps/LZMA-SDK/C/7zVersion.h index 0fe636abc..49ea81dd3 100644 --- a/deps/LZMA-SDK/C/7zVersion.h +++ b/deps/LZMA-SDK/C/7zVersion.h @@ -1,27 +1,27 @@ -#define MY_VER_MAJOR 21 -#define MY_VER_MINOR 02 -#define MY_VER_BUILD 0 -#define MY_VERSION_NUMBERS "21.02 alpha" -#define MY_VERSION MY_VERSION_NUMBERS - -#ifdef MY_CPU_NAME - #define MY_VERSION_CPU MY_VERSION " (" MY_CPU_NAME ")" -#else - #define MY_VERSION_CPU MY_VERSION -#endif - -#define MY_DATE "2021-05-06" -#undef MY_COPYRIGHT -#undef MY_VERSION_COPYRIGHT_DATE -#define MY_AUTHOR_NAME "Igor Pavlov" -#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" -#define MY_COPYRIGHT_CR "Copyright (c) 1999-2021 Igor Pavlov" - -#ifdef USE_COPYRIGHT_CR - #define MY_COPYRIGHT MY_COPYRIGHT_CR -#else - #define MY_COPYRIGHT MY_COPYRIGHT_PD -#endif - -#define MY_COPYRIGHT_DATE MY_COPYRIGHT " : " MY_DATE -#define MY_VERSION_COPYRIGHT_DATE MY_VERSION_CPU " : " MY_COPYRIGHT " : " MY_DATE +#define MY_VER_MAJOR 22 +#define MY_VER_MINOR 01 +#define MY_VER_BUILD 0 +#define MY_VERSION_NUMBERS "22.01" +#define MY_VERSION MY_VERSION_NUMBERS + +#ifdef MY_CPU_NAME + #define MY_VERSION_CPU MY_VERSION " (" MY_CPU_NAME ")" +#else + #define MY_VERSION_CPU MY_VERSION +#endif + +#define MY_DATE "2022-07-15" +#undef MY_COPYRIGHT +#undef MY_VERSION_COPYRIGHT_DATE +#define MY_AUTHOR_NAME "Igor Pavlov" +#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain" +#define MY_COPYRIGHT_CR "Copyright (c) 1999-2022 Igor Pavlov" + +#ifdef USE_COPYRIGHT_CR + #define MY_COPYRIGHT MY_COPYRIGHT_CR +#else + #define MY_COPYRIGHT MY_COPYRIGHT_PD +#endif + +#define MY_COPYRIGHT_DATE MY_COPYRIGHT " : " MY_DATE +#define MY_VERSION_COPYRIGHT_DATE MY_VERSION_CPU " : " MY_COPYRIGHT " : " MY_DATE diff --git a/deps/LZMA-SDK/C/7zVersion.rc b/deps/LZMA-SDK/C/7zVersion.rc index 6ed26de74..e520995dd 100644 --- a/deps/LZMA-SDK/C/7zVersion.rc +++ b/deps/LZMA-SDK/C/7zVersion.rc @@ -1,55 +1,55 @@ -#define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL -#define MY_VOS_NT_WINDOWS32 0x00040004L -#define MY_VOS_CE_WINDOWS32 0x00050004L - -#define MY_VFT_APP 0x00000001L -#define MY_VFT_DLL 0x00000002L - -// #include - -#ifndef MY_VERSION -#include "7zVersion.h" -#endif - -#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 - -#ifdef DEBUG -#define DBG_FL VS_FF_DEBUG -#else -#define DBG_FL 0 -#endif - -#define MY_VERSION_INFO(fileType, descr, intName, origName) \ -LANGUAGE 9, 1 \ -1 VERSIONINFO \ - FILEVERSION MY_VER \ - PRODUCTVERSION MY_VER \ - FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ - FILEFLAGS DBG_FL \ - FILEOS MY_VOS_NT_WINDOWS32 \ - FILETYPE fileType \ - FILESUBTYPE 0x0L \ -BEGIN \ - BLOCK "StringFileInfo" \ - BEGIN \ - BLOCK "040904b0" \ - BEGIN \ - VALUE "CompanyName", "Igor Pavlov" \ - VALUE "FileDescription", descr \ - VALUE "FileVersion", MY_VERSION \ - VALUE "InternalName", intName \ - VALUE "LegalCopyright", MY_COPYRIGHT \ - VALUE "OriginalFilename", origName \ - VALUE "ProductName", "7-Zip" \ - VALUE "ProductVersion", MY_VERSION \ - END \ - END \ - BLOCK "VarFileInfo" \ - BEGIN \ - VALUE "Translation", 0x409, 1200 \ - END \ -END - -#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") - -#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") +#define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL +#define MY_VOS_NT_WINDOWS32 0x00040004L +#define MY_VOS_CE_WINDOWS32 0x00050004L + +#define MY_VFT_APP 0x00000001L +#define MY_VFT_DLL 0x00000002L + +// #include + +#ifndef MY_VERSION +#include "7zVersion.h" +#endif + +#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 + +#ifdef DEBUG +#define DBG_FL VS_FF_DEBUG +#else +#define DBG_FL 0 +#endif + +#define MY_VERSION_INFO(fileType, descr, intName, origName) \ +LANGUAGE 9, 1 \ +1 VERSIONINFO \ + FILEVERSION MY_VER \ + PRODUCTVERSION MY_VER \ + FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ + FILEFLAGS DBG_FL \ + FILEOS MY_VOS_NT_WINDOWS32 \ + FILETYPE fileType \ + FILESUBTYPE 0x0L \ +BEGIN \ + BLOCK "StringFileInfo" \ + BEGIN \ + BLOCK "040904b0" \ + BEGIN \ + VALUE "CompanyName", "Igor Pavlov" \ + VALUE "FileDescription", descr \ + VALUE "FileVersion", MY_VERSION \ + VALUE "InternalName", intName \ + VALUE "LegalCopyright", MY_COPYRIGHT \ + VALUE "OriginalFilename", origName \ + VALUE "ProductName", "7-Zip" \ + VALUE "ProductVersion", MY_VERSION \ + END \ + END \ + BLOCK "VarFileInfo" \ + BEGIN \ + VALUE "Translation", 0x409, 1200 \ + END \ +END + +#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") + +#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") diff --git a/deps/LZMA-SDK/C/7zip_gcc_c.mak b/deps/LZMA-SDK/C/7zip_gcc_c.mak index 00ecfb043..24505f377 100644 --- a/deps/LZMA-SDK/C/7zip_gcc_c.mak +++ b/deps/LZMA-SDK/C/7zip_gcc_c.mak @@ -1,301 +1,343 @@ - -MY_ARCH_2 = $(MY_ARCH) - -MY_ASM = jwasm -MY_ASM = asmc - -PROGPATH = $(O)/$(PROG) - - -# for object file -CFLAGS_BASE_LIST = -c -# for ASM file -# CFLAGS_BASE_LIST = -S -CFLAGS_BASE = $(MY_ARCH_2) -O2 $(CFLAGS_BASE_LIST) -Wall -Werror -Wextra $(CFLAGS_WARN) \ - -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - - -LDFLAGS_STATIC = -DNDEBUG -# -static - -ifdef SystemDrive -IS_MINGW = 1 -endif - -ifdef DEF_FILE - - -ifdef IS_MINGW -SHARED_EXT=.dll -LDFLAGS = -shared -DEF $(DEF_FILE) $(LDFLAGS_STATIC) -else -SHARED_EXT=.so -LDFLAGS = -shared -fPIC $(LDFLAGS_STATIC) -CC_SHARED=-fPIC -endif - - -else - -LDFLAGS = $(LDFLAGS_STATIC) -# -s is not required for clang, do we need it for GGC ??? -# -s - -#-static -static-libgcc -static-libstdc++ - -ifdef IS_MINGW -SHARED_EXT=.exe -else -SHARED_EXT= -endif - -endif - - -PROGPATH = $(O)/$(PROG)$(SHARED_EXT) - - -ifndef O -O=_o -endif - -ifdef IS_MINGW - -RM = del -MY_MKDIR=mkdir -LIB2 = -loleaut32 -luuid -ladvapi32 -lUser32 - - -CXXFLAGS_EXTRA = -DUNICODE -D_UNICODE -# -Wno-delete-non-virtual-dtor - -DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll - -else - -RM = rm -f -MY_MKDIR=mkdir -p -# CFLAGS_BASE := $(CFLAGS_BASE) -D_7ZIP_ST -# CXXFLAGS_EXTRA = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE - -# LOCAL_LIBS=-lpthread -# LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl -LIB2 = -lpthread -ldl - -DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(OBJS) - -endif - - - -CFLAGS = $(LOCAL_FLAGS) $(CFLAGS_BASE2) $(CFLAGS_BASE) $(CC_SHARED) -o $@ - - -ifdef IS_X64 -AFLAGS_ABI = -elf64 -DABI_LINUX -else -AFLAGS_ABI = -elf -DABI_LINUX -DABI_CDECL -# -DABI_CDECL -# -DABI_LINUX -# -DABI_CDECL -endif -AFLAGS = $(AFLAGS_ABI) -Fo$(O)/ - - -CXX_WARN_FLAGS = -#-Wno-invalid-offsetof -#-Wno-reorder - -CXXFLAGS = $(LOCAL_FLAGS) $(CXXFLAGS_BASE2) $(CFLAGS_BASE) $(CXXFLAGS_EXTRA) $(CC_SHARED) -o $@ $(CXX_WARN_FLAGS) - -all: $(O) $(PROGPATH) - -$(O): - $(MY_MKDIR) $(O) - -$(PROGPATH): $(OBJS) - $(CXX) -s -o $(PROGPATH) $(MY_ARCH_2) $(LDFLAGS) $(OBJS) $(MY_LIBS) $(LIB2) - - - -ifndef NO_DEFAULT_RES -$O/resource.o: resource.rc - windres.exe $(RFLAGS) resource.rc $O/resource.o -endif - - - -$O/7zAlloc.o: ../../../C/7zAlloc.c - $(CC) $(CFLAGS) $< -$O/7zArcIn.o: ../../../C/7zArcIn.c - $(CC) $(CFLAGS) $< -$O/7zBuf.o: ../../../C/7zBuf.c - $(CC) $(CFLAGS) $< -$O/7zBuf2.o: ../../../C/7zBuf2.c - $(CC) $(CFLAGS) $< -$O/7zCrc.o: ../../../C/7zCrc.c - $(CC) $(CFLAGS) $< -$O/7zDec.o: ../../../C/7zDec.c - $(CC) $(CFLAGS) $< -$O/7zFile.o: ../../../C/7zFile.c - $(CC) $(CFLAGS) $< -$O/7zStream.o: ../../../C/7zStream.c - $(CC) $(CFLAGS) $< -$O/Aes.o: ../../../C/Aes.c - $(CC) $(CFLAGS) $< -$O/Alloc.o: ../../../C/Alloc.c - $(CC) $(CFLAGS) $< -$O/Bcj2.o: ../../../C/Bcj2.c - $(CC) $(CFLAGS) $< -$O/Bcj2Enc.o: ../../../C/Bcj2Enc.c - $(CC) $(CFLAGS) $< -$O/Blake2s.o: ../../../C/Blake2s.c - $(CC) $(CFLAGS) $< -$O/Bra.o: ../../../C/Bra.c - $(CC) $(CFLAGS) $< -$O/Bra86.o: ../../../C/Bra86.c - $(CC) $(CFLAGS) $< -$O/BraIA64.o: ../../../C/BraIA64.c - $(CC) $(CFLAGS) $< -$O/BwtSort.o: ../../../C/BwtSort.c - $(CC) $(CFLAGS) $< - -$O/CpuArch.o: ../../../C/CpuArch.c - $(CC) $(CFLAGS) $< -$O/Delta.o: ../../../C/Delta.c - $(CC) $(CFLAGS) $< -$O/DllSecur.o: ../../../C/DllSecur.c - $(CC) $(CFLAGS) $< -$O/HuffEnc.o: ../../../C/HuffEnc.c - $(CC) $(CFLAGS) $< -$O/LzFind.o: ../../../C/LzFind.c - $(CC) $(CFLAGS) $< - -# ifdef MT_FILES -$O/LzFindMt.o: ../../../C/LzFindMt.c - $(CC) $(CFLAGS) $< - -$O/Threads.o: ../../../C/Threads.c - $(CC) $(CFLAGS) $< -# endif - -$O/LzmaEnc.o: ../../../C/LzmaEnc.c - $(CC) $(CFLAGS) $< -$O/Lzma86Dec.o: ../../../C/Lzma86Dec.c - $(CC) $(CFLAGS) $< -$O/Lzma86Enc.o: ../../../C/Lzma86Enc.c - $(CC) $(CFLAGS) $< -$O/Lzma2Dec.o: ../../../C/Lzma2Dec.c - $(CC) $(CFLAGS) $< -$O/Lzma2DecMt.o: ../../../C/Lzma2DecMt.c - $(CC) $(CFLAGS) $< -$O/Lzma2Enc.o: ../../../C/Lzma2Enc.c - $(CC) $(CFLAGS) $< -$O/LzmaLib.o: ../../../C/LzmaLib.c - $(CC) $(CFLAGS) $< -$O/MtCoder.o: ../../../C/MtCoder.c - $(CC) $(CFLAGS) $< -$O/MtDec.o: ../../../C/MtDec.c - $(CC) $(CFLAGS) $< -$O/Ppmd7.o: ../../../C/Ppmd7.c - $(CC) $(CFLAGS) $< -$O/Ppmd7aDec.o: ../../../C/Ppmd7aDec.c - $(CC) $(CFLAGS) $< -$O/Ppmd7Dec.o: ../../../C/Ppmd7Dec.c - $(CC) $(CFLAGS) $< -$O/Ppmd7Enc.o: ../../../C/Ppmd7Enc.c - $(CC) $(CFLAGS) $< -$O/Ppmd8.o: ../../../C/Ppmd8.c - $(CC) $(CFLAGS) $< -$O/Ppmd8Dec.o: ../../../C/Ppmd8Dec.c - $(CC) $(CFLAGS) $< -$O/Ppmd8Enc.o: ../../../C/Ppmd8Enc.c - $(CC) $(CFLAGS) $< -$O/Sha1.o: ../../../C/Sha1.c - $(CC) $(CFLAGS) $< -$O/Sha256.o: ../../../C/Sha256.c - $(CC) $(CFLAGS) $< -$O/Sort.o: ../../../C/Sort.c - $(CC) $(CFLAGS) $< -$O/Xz.o: ../../../C/Xz.c - $(CC) $(CFLAGS) $< -$O/XzCrc64.o: ../../../C/XzCrc64.c - $(CC) $(CFLAGS) $< - - -ifdef USE_ASM -ifdef IS_X64 -USE_X86_ASM=1 -else -ifdef IS_X86 -USE_X86_ASM=1 -endif -endif -endif - -ifdef USE_X86_ASM -$O/7zCrcOpt.o: ../../../Asm/x86/7zCrcOpt.asm - $(MY_ASM) $(AFLAGS) $< -$O/XzCrc64Opt.o: ../../../Asm/x86/XzCrc64Opt.asm - $(MY_ASM) $(AFLAGS) $< -$O/AesOpt.o: ../../../Asm/x86/AesOpt.asm - $(MY_ASM) $(AFLAGS) $< -$O/Sha1Opt.o: ../../../Asm/x86/Sha1Opt.asm - $(MY_ASM) $(AFLAGS) $< -$O/Sha256Opt.o: ../../../Asm/x86/Sha256Opt.asm - $(MY_ASM) $(AFLAGS) $< -else -$O/7zCrcOpt.o: ../../7zCrcOpt.c - $(CC) $(CFLAGS) $< -$O/XzCrc64Opt.o: ../../XzCrc64Opt.c - $(CC) $(CFLAGS) $< -$O/Sha1Opt.o: ../../Sha1Opt.c - $(CC) $(CFLAGS) $< -$O/Sha256Opt.o: ../../Sha256Opt.c - $(CC) $(CFLAGS) $< -$O/AesOpt.o: ../../AesOpt.c - $(CC) $(CFLAGS) $< -endif - - -ifdef USE_LZMA_DEC_ASM - -ifdef IS_X64 -$O/LzmaDecOpt.o: ../../../Asm/x86/LzmaDecOpt.asm - $(MY_ASM) $(AFLAGS) $< -endif - -ifdef IS_ARM64 -$O/LzmaDecOpt.o: ../../../Asm/arm64/LzmaDecOpt.S ../../../Asm/arm64/7zAsm.S - $(CC) $(CFLAGS) $< -endif - -$O/LzmaDec.o: ../../LzmaDec.c - $(CC) $(CFLAGS) -D_LZMA_DEC_OPT $< - -else - -$O/LzmaDec.o: ../../LzmaDec.c - $(CC) $(CFLAGS) $< - -endif - - - -$O/XzDec.o: ../../../C/XzDec.c - $(CC) $(CFLAGS) $< -$O/XzEnc.o: ../../../C/XzEnc.c - $(CC) $(CFLAGS) $< -$O/XzIn.o: ../../../C/XzIn.c - $(CC) $(CFLAGS) $< - - -$O/7zMain.o: ../../../C/Util/7z/7zMain.c - $(CC) $(CFLAGS) $< -$O/LzmaUtil.o: ../../../C/Util/Lzma/LzmaUtil.c - $(CC) $(CFLAGS) $< - - - -clean: - -$(DEL_OBJ_EXE) + +MY_ARCH_2 = $(MY_ARCH) + +MY_ASM = jwasm +MY_ASM = asmc + +PROGPATH = $(O)/$(PROG) +PROGPATH_STATIC = $(O)/$(PROG)s + + +# for object file +CFLAGS_BASE_LIST = -c +# for ASM file +# CFLAGS_BASE_LIST = -S +CFLAGS_BASE = $(MY_ARCH_2) -O2 $(CFLAGS_BASE_LIST) -Wall -Werror -Wextra $(CFLAGS_WARN) \ + -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE + + +ifdef SystemDrive +IS_MINGW = 1 +else +ifdef SYSTEMDRIVE +# ifdef OS +IS_MINGW = 1 +endif +endif + +ifdef IS_MINGW +LDFLAGS_STATIC_2 = -static +else +ifndef DEF_FILE +ifndef IS_NOT_STANDALONE +ifndef MY_DYNAMIC_LINK +ifneq ($(CC), clang) +LDFLAGS_STATIC_2 = +# -static +# -static-libstdc++ -static-libgcc +endif +endif +endif +endif +endif + +LDFLAGS_STATIC = -DNDEBUG $(LDFLAGS_STATIC_2) + +ifdef DEF_FILE + + +ifdef IS_MINGW +SHARED_EXT=.dll +LDFLAGS = -shared -DEF $(DEF_FILE) $(LDFLAGS_STATIC) +else +SHARED_EXT=.so +LDFLAGS = -shared -fPIC $(LDFLAGS_STATIC) +CC_SHARED=-fPIC +endif + + +else + +LDFLAGS = $(LDFLAGS_STATIC) +# -s is not required for clang, do we need it for GGC ??? +# -s + +#-static -static-libgcc -static-libstdc++ + +ifdef IS_MINGW +SHARED_EXT=.exe +else +SHARED_EXT= +endif + +endif + + +PROGPATH = $(O)/$(PROG)$(SHARED_EXT) +PROGPATH_STATIC = $(O)/$(PROG)s$(SHARED_EXT) + +ifndef O +O=_o +endif + +ifdef IS_MINGW + +ifdef MSYSTEM +RM = rm -f +MY_MKDIR=mkdir -p +DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS) +else +RM = del +MY_MKDIR=mkdir +DEL_OBJ_EXE = -$(RM) $(O)\*.o $(O)\$(PROG).exe $(O)\$(PROG).dll +endif + + +LIB2 = -lOle32 -loleaut32 -luuid -ladvapi32 -lUser32 + +CXXFLAGS_EXTRA = -DUNICODE -D_UNICODE +# -Wno-delete-non-virtual-dtor + + +else + +RM = rm -f +MY_MKDIR=mkdir -p +# CFLAGS_BASE := $(CFLAGS_BASE) -D_7ZIP_ST +# CXXFLAGS_EXTRA = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE + +# LOCAL_LIBS=-lpthread +# LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl +LIB2 = -lpthread -ldl + +DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(OBJS) + +endif + + + +CFLAGS = $(LOCAL_FLAGS) $(CFLAGS_BASE2) $(CFLAGS_BASE) $(CC_SHARED) -o $@ + + +ifdef IS_X64 +AFLAGS_ABI = -elf64 -DABI_LINUX +else +AFLAGS_ABI = -elf -DABI_LINUX -DABI_CDECL +# -DABI_CDECL +# -DABI_LINUX +# -DABI_CDECL +endif +AFLAGS = $(AFLAGS_ABI) -Fo$(O)/ + + +CXX_WARN_FLAGS = +#-Wno-invalid-offsetof +#-Wno-reorder + +CXXFLAGS = $(LOCAL_FLAGS) $(CXXFLAGS_BASE2) $(CFLAGS_BASE) $(CXXFLAGS_EXTRA) $(CC_SHARED) -o $@ $(CXX_WARN_FLAGS) + +STATIC_TARGET= +ifdef COMPL_STATIC +STATIC_TARGET=$(PROGPATH_STATIC) +endif + + +all: $(O) $(PROGPATH) $(STATIC_TARGET) + +$(O): + $(MY_MKDIR) $(O) + +LFLAGS_ALL = -s $(MY_ARCH_2) $(LDFLAGS) $(LD_arch) $(OBJS) $(MY_LIBS) $(LIB2) +$(PROGPATH): $(OBJS) + $(CXX) -o $(PROGPATH) $(LFLAGS_ALL) + +$(PROGPATH_STATIC): $(OBJS) + $(CXX) -static -o $(PROGPATH_STATIC) $(LFLAGS_ALL) + + +ifndef NO_DEFAULT_RES +$O/resource.o: resource.rc + windres.exe $(RFLAGS) resource.rc $O/resource.o +endif + + + +$O/7zAlloc.o: ../../../C/7zAlloc.c + $(CC) $(CFLAGS) $< +$O/7zArcIn.o: ../../../C/7zArcIn.c + $(CC) $(CFLAGS) $< +$O/7zBuf.o: ../../../C/7zBuf.c + $(CC) $(CFLAGS) $< +$O/7zBuf2.o: ../../../C/7zBuf2.c + $(CC) $(CFLAGS) $< +$O/7zCrc.o: ../../../C/7zCrc.c + $(CC) $(CFLAGS) $< +$O/7zDec.o: ../../../C/7zDec.c + $(CC) $(CFLAGS) $< +$O/7zFile.o: ../../../C/7zFile.c + $(CC) $(CFLAGS) $< +$O/7zStream.o: ../../../C/7zStream.c + $(CC) $(CFLAGS) $< +$O/Aes.o: ../../../C/Aes.c + $(CC) $(CFLAGS) $< +$O/Alloc.o: ../../../C/Alloc.c + $(CC) $(CFLAGS) $< +$O/Bcj2.o: ../../../C/Bcj2.c + $(CC) $(CFLAGS) $< +$O/Bcj2Enc.o: ../../../C/Bcj2Enc.c + $(CC) $(CFLAGS) $< +$O/Blake2s.o: ../../../C/Blake2s.c + $(CC) $(CFLAGS) $< +$O/Bra.o: ../../../C/Bra.c + $(CC) $(CFLAGS) $< +$O/Bra86.o: ../../../C/Bra86.c + $(CC) $(CFLAGS) $< +$O/BraIA64.o: ../../../C/BraIA64.c + $(CC) $(CFLAGS) $< +$O/BwtSort.o: ../../../C/BwtSort.c + $(CC) $(CFLAGS) $< + +$O/CpuArch.o: ../../../C/CpuArch.c + $(CC) $(CFLAGS) $< +$O/Delta.o: ../../../C/Delta.c + $(CC) $(CFLAGS) $< +$O/DllSecur.o: ../../../C/DllSecur.c + $(CC) $(CFLAGS) $< +$O/HuffEnc.o: ../../../C/HuffEnc.c + $(CC) $(CFLAGS) $< +$O/LzFind.o: ../../../C/LzFind.c + $(CC) $(CFLAGS) $< + +# ifdef MT_FILES +$O/LzFindMt.o: ../../../C/LzFindMt.c + $(CC) $(CFLAGS) $< +$O/LzFindOpt.o: ../../../C/LzFindOpt.c + $(CC) $(CFLAGS) $< + +$O/Threads.o: ../../../C/Threads.c + $(CC) $(CFLAGS) $< +# endif + +$O/LzmaEnc.o: ../../../C/LzmaEnc.c + $(CC) $(CFLAGS) $< +$O/Lzma86Dec.o: ../../../C/Lzma86Dec.c + $(CC) $(CFLAGS) $< +$O/Lzma86Enc.o: ../../../C/Lzma86Enc.c + $(CC) $(CFLAGS) $< +$O/Lzma2Dec.o: ../../../C/Lzma2Dec.c + $(CC) $(CFLAGS) $< +$O/Lzma2DecMt.o: ../../../C/Lzma2DecMt.c + $(CC) $(CFLAGS) $< +$O/Lzma2Enc.o: ../../../C/Lzma2Enc.c + $(CC) $(CFLAGS) $< +$O/LzmaLib.o: ../../../C/LzmaLib.c + $(CC) $(CFLAGS) $< +$O/MtCoder.o: ../../../C/MtCoder.c + $(CC) $(CFLAGS) $< +$O/MtDec.o: ../../../C/MtDec.c + $(CC) $(CFLAGS) $< +$O/Ppmd7.o: ../../../C/Ppmd7.c + $(CC) $(CFLAGS) $< +$O/Ppmd7aDec.o: ../../../C/Ppmd7aDec.c + $(CC) $(CFLAGS) $< +$O/Ppmd7Dec.o: ../../../C/Ppmd7Dec.c + $(CC) $(CFLAGS) $< +$O/Ppmd7Enc.o: ../../../C/Ppmd7Enc.c + $(CC) $(CFLAGS) $< +$O/Ppmd8.o: ../../../C/Ppmd8.c + $(CC) $(CFLAGS) $< +$O/Ppmd8Dec.o: ../../../C/Ppmd8Dec.c + $(CC) $(CFLAGS) $< +$O/Ppmd8Enc.o: ../../../C/Ppmd8Enc.c + $(CC) $(CFLAGS) $< +$O/Sha1.o: ../../../C/Sha1.c + $(CC) $(CFLAGS) $< +$O/Sha256.o: ../../../C/Sha256.c + $(CC) $(CFLAGS) $< +$O/Sort.o: ../../../C/Sort.c + $(CC) $(CFLAGS) $< +$O/Xz.o: ../../../C/Xz.c + $(CC) $(CFLAGS) $< +$O/XzCrc64.o: ../../../C/XzCrc64.c + $(CC) $(CFLAGS) $< + + +ifdef USE_ASM +ifdef IS_X64 +USE_X86_ASM=1 +else +ifdef IS_X86 +USE_X86_ASM=1 +endif +endif +endif + +ifdef USE_X86_ASM +$O/7zCrcOpt.o: ../../../Asm/x86/7zCrcOpt.asm + $(MY_ASM) $(AFLAGS) $< +$O/XzCrc64Opt.o: ../../../Asm/x86/XzCrc64Opt.asm + $(MY_ASM) $(AFLAGS) $< +$O/AesOpt.o: ../../../Asm/x86/AesOpt.asm + $(MY_ASM) $(AFLAGS) $< +$O/Sha1Opt.o: ../../../Asm/x86/Sha1Opt.asm + $(MY_ASM) $(AFLAGS) $< +$O/Sha256Opt.o: ../../../Asm/x86/Sha256Opt.asm + $(MY_ASM) $(AFLAGS) $< +else +$O/7zCrcOpt.o: ../../7zCrcOpt.c + $(CC) $(CFLAGS) $< +$O/XzCrc64Opt.o: ../../XzCrc64Opt.c + $(CC) $(CFLAGS) $< +$O/Sha1Opt.o: ../../Sha1Opt.c + $(CC) $(CFLAGS) $< +$O/Sha256Opt.o: ../../Sha256Opt.c + $(CC) $(CFLAGS) $< +$O/AesOpt.o: ../../AesOpt.c + $(CC) $(CFLAGS) $< +endif + + +ifdef USE_LZMA_DEC_ASM + +ifdef IS_X64 +$O/LzmaDecOpt.o: ../../../Asm/x86/LzmaDecOpt.asm + $(MY_ASM) $(AFLAGS) $< +endif + +ifdef IS_ARM64 +$O/LzmaDecOpt.o: ../../../Asm/arm64/LzmaDecOpt.S ../../../Asm/arm64/7zAsm.S + $(CC) $(CFLAGS) $< +endif + +$O/LzmaDec.o: ../../LzmaDec.c + $(CC) $(CFLAGS) -D_LZMA_DEC_OPT $< + +else + +$O/LzmaDec.o: ../../LzmaDec.c + $(CC) $(CFLAGS) $< + +endif + + + +$O/XzDec.o: ../../../C/XzDec.c + $(CC) $(CFLAGS) $< +$O/XzEnc.o: ../../../C/XzEnc.c + $(CC) $(CFLAGS) $< +$O/XzIn.o: ../../../C/XzIn.c + $(CC) $(CFLAGS) $< + + +$O/7zMain.o: ../../../C/Util/7z/7zMain.c + $(CC) $(CFLAGS) $< +$O/LzmaUtil.o: ../../../C/Util/Lzma/LzmaUtil.c + $(CC) $(CFLAGS) $< +$O/7zipInstall.o: ../../../C/Util/7zipInstall/7zipInstall.c + $(CC) $(CFLAGS) $< +$O/7zipUninstall.o: ../../../C/Util/7zipUninstall/7zipUninstall.c + $(CC) $(CFLAGS) $< + + +clean: + -$(DEL_OBJ_EXE) diff --git a/deps/LZMA-SDK/C/Aes.c b/deps/LZMA-SDK/C/Aes.c index 0f0ddc87a..27e32e622 100644 --- a/deps/LZMA-SDK/C/Aes.c +++ b/deps/LZMA-SDK/C/Aes.c @@ -1,375 +1,375 @@ -/* Aes.c -- AES encryption / decryption -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" -#include "Aes.h" - -AES_CODE_FUNC g_AesCbc_Decode; -#ifndef _SFX -AES_CODE_FUNC g_AesCbc_Encode; -AES_CODE_FUNC g_AesCtr_Code; -UInt32 g_Aes_SupportedFunctions_Flags; -#endif - -static UInt32 T[256 * 4]; -static const Byte Sbox[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16}; - - -static UInt32 D[256 * 4]; -static Byte InvS[256]; - -#define xtime(x) ((((x) << 1) ^ (((x) & 0x80) != 0 ? 0x1B : 0)) & 0xFF) - -#define Ui32(a0, a1, a2, a3) ((UInt32)(a0) | ((UInt32)(a1) << 8) | ((UInt32)(a2) << 16) | ((UInt32)(a3) << 24)) - -#define gb0(x) ( (x) & 0xFF) -#define gb1(x) (((x) >> ( 8)) & 0xFF) -#define gb2(x) (((x) >> (16)) & 0xFF) -#define gb3(x) (((x) >> (24))) - -#define gb(n, x) gb ## n(x) - -#define TT(x) (T + (x << 8)) -#define DD(x) (D + (x << 8)) - - -// #define _SHOW_AES_STATUS - -#ifdef MY_CPU_X86_OR_AMD64 - #define USE_HW_AES -#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE) - #if defined(__clang__) - #if (__clang_major__ >= 8) // fix that check - #define USE_HW_AES - #endif - #elif defined(__GNUC__) - #if (__GNUC__ >= 6) // fix that check - #define USE_HW_AES - #endif - #elif defined(_MSC_VER) - #if _MSC_VER >= 1910 - #define USE_HW_AES - #endif - #endif -#endif - -#ifdef USE_HW_AES -#ifdef _SHOW_AES_STATUS -#include -#define _PRF(x) x -#else -#define _PRF(x) -#endif -#endif - - -void AesGenTables(void) -{ - unsigned i; - for (i = 0; i < 256; i++) - InvS[Sbox[i]] = (Byte)i; - - for (i = 0; i < 256; i++) - { - { - UInt32 a1 = Sbox[i]; - UInt32 a2 = xtime(a1); - UInt32 a3 = a2 ^ a1; - TT(0)[i] = Ui32(a2, a1, a1, a3); - TT(1)[i] = Ui32(a3, a2, a1, a1); - TT(2)[i] = Ui32(a1, a3, a2, a1); - TT(3)[i] = Ui32(a1, a1, a3, a2); - } - { - UInt32 a1 = InvS[i]; - UInt32 a2 = xtime(a1); - UInt32 a4 = xtime(a2); - UInt32 a8 = xtime(a4); - UInt32 a9 = a8 ^ a1; - UInt32 aB = a8 ^ a2 ^ a1; - UInt32 aD = a8 ^ a4 ^ a1; - UInt32 aE = a8 ^ a4 ^ a2; - DD(0)[i] = Ui32(aE, a9, aD, aB); - DD(1)[i] = Ui32(aB, aE, a9, aD); - DD(2)[i] = Ui32(aD, aB, aE, a9); - DD(3)[i] = Ui32(a9, aD, aB, aE); - } - } - - { - AES_CODE_FUNC d = AesCbc_Decode; - #ifndef _SFX - AES_CODE_FUNC e = AesCbc_Encode; - AES_CODE_FUNC c = AesCtr_Code; - UInt32 flags = 0; - #endif - - #ifdef USE_HW_AES - if (CPU_IsSupported_AES()) - { - // #pragma message ("AES HW") - _PRF(printf("\n===AES HW\n")); - d = AesCbc_Decode_HW; - - #ifndef _SFX - e = AesCbc_Encode_HW; - c = AesCtr_Code_HW; - flags = k_Aes_SupportedFunctions_HW; - #endif - - #ifdef MY_CPU_X86_OR_AMD64 - if (CPU_IsSupported_VAES_AVX2()) - { - _PRF(printf("\n===vaes avx2\n")); - d = AesCbc_Decode_HW_256; - #ifndef _SFX - c = AesCtr_Code_HW_256; - flags |= k_Aes_SupportedFunctions_HW_256; - #endif - } - #endif - } - #endif - - g_AesCbc_Decode = d; - #ifndef _SFX - g_AesCbc_Encode = e; - g_AesCtr_Code = c; - g_Aes_SupportedFunctions_Flags = flags; - #endif - } -} - - -#define HT(i, x, s) TT(x)[gb(x, s[(i + x) & 3])] - -#define HT4(m, i, s, p) m[i] = \ - HT(i, 0, s) ^ \ - HT(i, 1, s) ^ \ - HT(i, 2, s) ^ \ - HT(i, 3, s) ^ w[p + i] - -#define HT16(m, s, p) \ - HT4(m, 0, s, p); \ - HT4(m, 1, s, p); \ - HT4(m, 2, s, p); \ - HT4(m, 3, s, p); \ - -#define FT(i, x) Sbox[gb(x, m[(i + x) & 3])] -#define FT4(i) dest[i] = Ui32(FT(i, 0), FT(i, 1), FT(i, 2), FT(i, 3)) ^ w[i]; - - -#define HD(i, x, s) DD(x)[gb(x, s[(i - x) & 3])] - -#define HD4(m, i, s, p) m[i] = \ - HD(i, 0, s) ^ \ - HD(i, 1, s) ^ \ - HD(i, 2, s) ^ \ - HD(i, 3, s) ^ w[p + i]; - -#define HD16(m, s, p) \ - HD4(m, 0, s, p); \ - HD4(m, 1, s, p); \ - HD4(m, 2, s, p); \ - HD4(m, 3, s, p); \ - -#define FD(i, x) InvS[gb(x, m[(i - x) & 3])] -#define FD4(i) dest[i] = Ui32(FD(i, 0), FD(i, 1), FD(i, 2), FD(i, 3)) ^ w[i]; - -void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *w, const Byte *key, unsigned keySize) -{ - unsigned i, m; - const UInt32 *wLim; - UInt32 t; - UInt32 rcon = 1; - - keySize /= 4; - w[0] = ((UInt32)keySize / 2) + 3; - w += 4; - - for (i = 0; i < keySize; i++, key += 4) - w[i] = GetUi32(key); - - t = w[(size_t)keySize - 1]; - wLim = w + (size_t)keySize * 3 + 28; - m = 0; - do - { - if (m == 0) - { - t = Ui32(Sbox[gb1(t)] ^ rcon, Sbox[gb2(t)], Sbox[gb3(t)], Sbox[gb0(t)]); - rcon <<= 1; - if (rcon & 0x100) - rcon = 0x1b; - m = keySize; - } - else if (m == 4 && keySize > 6) - t = Ui32(Sbox[gb0(t)], Sbox[gb1(t)], Sbox[gb2(t)], Sbox[gb3(t)]); - m--; - t ^= w[0]; - w[keySize] = t; - } - while (++w != wLim); -} - -void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize) -{ - unsigned i, num; - Aes_SetKey_Enc(w, key, keySize); - num = keySize + 20; - w += 8; - for (i = 0; i < num; i++) - { - UInt32 r = w[i]; - w[i] = - DD(0)[Sbox[gb0(r)]] ^ - DD(1)[Sbox[gb1(r)]] ^ - DD(2)[Sbox[gb2(r)]] ^ - DD(3)[Sbox[gb3(r)]]; - } -} - -/* Aes_Encode and Aes_Decode functions work with little-endian words. - src and dest are pointers to 4 UInt32 words. - src and dest can point to same block */ - -// MY_FORCE_INLINE -static void Aes_Encode(const UInt32 *w, UInt32 *dest, const UInt32 *src) -{ - UInt32 s[4]; - UInt32 m[4]; - UInt32 numRounds2 = w[0]; - w += 4; - s[0] = src[0] ^ w[0]; - s[1] = src[1] ^ w[1]; - s[2] = src[2] ^ w[2]; - s[3] = src[3] ^ w[3]; - w += 4; - for (;;) - { - HT16(m, s, 0); - if (--numRounds2 == 0) - break; - HT16(s, m, 4); - w += 8; - } - w += 4; - FT4(0); FT4(1); FT4(2); FT4(3); -} - -MY_FORCE_INLINE -static void Aes_Decode(const UInt32 *w, UInt32 *dest, const UInt32 *src) -{ - UInt32 s[4]; - UInt32 m[4]; - UInt32 numRounds2 = w[0]; - w += 4 + numRounds2 * 8; - s[0] = src[0] ^ w[0]; - s[1] = src[1] ^ w[1]; - s[2] = src[2] ^ w[2]; - s[3] = src[3] ^ w[3]; - for (;;) - { - w -= 8; - HD16(m, s, 4); - if (--numRounds2 == 0) - break; - HD16(s, m, 0); - } - FD4(0); FD4(1); FD4(2); FD4(3); -} - -void AesCbc_Init(UInt32 *p, const Byte *iv) -{ - unsigned i; - for (i = 0; i < 4; i++) - p[i] = GetUi32(iv + i * 4); -} - -void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks) -{ - for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE) - { - p[0] ^= GetUi32(data); - p[1] ^= GetUi32(data + 4); - p[2] ^= GetUi32(data + 8); - p[3] ^= GetUi32(data + 12); - - Aes_Encode(p + 4, p, p); - - SetUi32(data, p[0]); - SetUi32(data + 4, p[1]); - SetUi32(data + 8, p[2]); - SetUi32(data + 12, p[3]); - } -} - -void MY_FAST_CALL AesCbc_Decode(UInt32 *p, Byte *data, size_t numBlocks) -{ - UInt32 in[4], out[4]; - for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE) - { - in[0] = GetUi32(data); - in[1] = GetUi32(data + 4); - in[2] = GetUi32(data + 8); - in[3] = GetUi32(data + 12); - - Aes_Decode(p + 4, out, in); - - SetUi32(data, p[0] ^ out[0]); - SetUi32(data + 4, p[1] ^ out[1]); - SetUi32(data + 8, p[2] ^ out[2]); - SetUi32(data + 12, p[3] ^ out[3]); - - p[0] = in[0]; - p[1] = in[1]; - p[2] = in[2]; - p[3] = in[3]; - } -} - -void MY_FAST_CALL AesCtr_Code(UInt32 *p, Byte *data, size_t numBlocks) -{ - for (; numBlocks != 0; numBlocks--) - { - UInt32 temp[4]; - unsigned i; - - if (++p[0] == 0) - p[1]++; - - Aes_Encode(p + 4, temp, p); - - for (i = 0; i < 4; i++, data += 4) - { - UInt32 t = temp[i]; - - #ifdef MY_CPU_LE_UNALIGN - *((UInt32 *)(void *)data) ^= t; - #else - data[0] ^= (t & 0xFF); - data[1] ^= ((t >> 8) & 0xFF); - data[2] ^= ((t >> 16) & 0xFF); - data[3] ^= ((t >> 24)); - #endif - } - } -} +/* Aes.c -- AES encryption / decryption +2021-05-13 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" +#include "Aes.h" + +AES_CODE_FUNC g_AesCbc_Decode; +#ifndef _SFX +AES_CODE_FUNC g_AesCbc_Encode; +AES_CODE_FUNC g_AesCtr_Code; +UInt32 g_Aes_SupportedFunctions_Flags; +#endif + +static UInt32 T[256 * 4]; +static const Byte Sbox[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16}; + + +static UInt32 D[256 * 4]; +static Byte InvS[256]; + +#define xtime(x) ((((x) << 1) ^ (((x) & 0x80) != 0 ? 0x1B : 0)) & 0xFF) + +#define Ui32(a0, a1, a2, a3) ((UInt32)(a0) | ((UInt32)(a1) << 8) | ((UInt32)(a2) << 16) | ((UInt32)(a3) << 24)) + +#define gb0(x) ( (x) & 0xFF) +#define gb1(x) (((x) >> ( 8)) & 0xFF) +#define gb2(x) (((x) >> (16)) & 0xFF) +#define gb3(x) (((x) >> (24))) + +#define gb(n, x) gb ## n(x) + +#define TT(x) (T + (x << 8)) +#define DD(x) (D + (x << 8)) + + +// #define _SHOW_AES_STATUS + +#ifdef MY_CPU_X86_OR_AMD64 + #define USE_HW_AES +#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE) + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define USE_HW_AES + #endif + #elif defined(__GNUC__) + #if (__GNUC__ >= 6) // fix that check + #define USE_HW_AES + #endif + #elif defined(_MSC_VER) + #if _MSC_VER >= 1910 + #define USE_HW_AES + #endif + #endif +#endif + +#ifdef USE_HW_AES +#ifdef _SHOW_AES_STATUS +#include +#define _PRF(x) x +#else +#define _PRF(x) +#endif +#endif + + +void AesGenTables(void) +{ + unsigned i; + for (i = 0; i < 256; i++) + InvS[Sbox[i]] = (Byte)i; + + for (i = 0; i < 256; i++) + { + { + UInt32 a1 = Sbox[i]; + UInt32 a2 = xtime(a1); + UInt32 a3 = a2 ^ a1; + TT(0)[i] = Ui32(a2, a1, a1, a3); + TT(1)[i] = Ui32(a3, a2, a1, a1); + TT(2)[i] = Ui32(a1, a3, a2, a1); + TT(3)[i] = Ui32(a1, a1, a3, a2); + } + { + UInt32 a1 = InvS[i]; + UInt32 a2 = xtime(a1); + UInt32 a4 = xtime(a2); + UInt32 a8 = xtime(a4); + UInt32 a9 = a8 ^ a1; + UInt32 aB = a8 ^ a2 ^ a1; + UInt32 aD = a8 ^ a4 ^ a1; + UInt32 aE = a8 ^ a4 ^ a2; + DD(0)[i] = Ui32(aE, a9, aD, aB); + DD(1)[i] = Ui32(aB, aE, a9, aD); + DD(2)[i] = Ui32(aD, aB, aE, a9); + DD(3)[i] = Ui32(a9, aD, aB, aE); + } + } + + { + AES_CODE_FUNC d = AesCbc_Decode; + #ifndef _SFX + AES_CODE_FUNC e = AesCbc_Encode; + AES_CODE_FUNC c = AesCtr_Code; + UInt32 flags = 0; + #endif + + #ifdef USE_HW_AES + if (CPU_IsSupported_AES()) + { + // #pragma message ("AES HW") + _PRF(printf("\n===AES HW\n")); + d = AesCbc_Decode_HW; + + #ifndef _SFX + e = AesCbc_Encode_HW; + c = AesCtr_Code_HW; + flags = k_Aes_SupportedFunctions_HW; + #endif + + #ifdef MY_CPU_X86_OR_AMD64 + if (CPU_IsSupported_VAES_AVX2()) + { + _PRF(printf("\n===vaes avx2\n")); + d = AesCbc_Decode_HW_256; + #ifndef _SFX + c = AesCtr_Code_HW_256; + flags |= k_Aes_SupportedFunctions_HW_256; + #endif + } + #endif + } + #endif + + g_AesCbc_Decode = d; + #ifndef _SFX + g_AesCbc_Encode = e; + g_AesCtr_Code = c; + g_Aes_SupportedFunctions_Flags = flags; + #endif + } +} + + +#define HT(i, x, s) TT(x)[gb(x, s[(i + x) & 3])] + +#define HT4(m, i, s, p) m[i] = \ + HT(i, 0, s) ^ \ + HT(i, 1, s) ^ \ + HT(i, 2, s) ^ \ + HT(i, 3, s) ^ w[p + i] + +#define HT16(m, s, p) \ + HT4(m, 0, s, p); \ + HT4(m, 1, s, p); \ + HT4(m, 2, s, p); \ + HT4(m, 3, s, p); \ + +#define FT(i, x) Sbox[gb(x, m[(i + x) & 3])] +#define FT4(i) dest[i] = Ui32(FT(i, 0), FT(i, 1), FT(i, 2), FT(i, 3)) ^ w[i]; + + +#define HD(i, x, s) DD(x)[gb(x, s[(i - x) & 3])] + +#define HD4(m, i, s, p) m[i] = \ + HD(i, 0, s) ^ \ + HD(i, 1, s) ^ \ + HD(i, 2, s) ^ \ + HD(i, 3, s) ^ w[p + i]; + +#define HD16(m, s, p) \ + HD4(m, 0, s, p); \ + HD4(m, 1, s, p); \ + HD4(m, 2, s, p); \ + HD4(m, 3, s, p); \ + +#define FD(i, x) InvS[gb(x, m[(i - x) & 3])] +#define FD4(i) dest[i] = Ui32(FD(i, 0), FD(i, 1), FD(i, 2), FD(i, 3)) ^ w[i]; + +void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *w, const Byte *key, unsigned keySize) +{ + unsigned i, m; + const UInt32 *wLim; + UInt32 t; + UInt32 rcon = 1; + + keySize /= 4; + w[0] = ((UInt32)keySize / 2) + 3; + w += 4; + + for (i = 0; i < keySize; i++, key += 4) + w[i] = GetUi32(key); + + t = w[(size_t)keySize - 1]; + wLim = w + (size_t)keySize * 3 + 28; + m = 0; + do + { + if (m == 0) + { + t = Ui32(Sbox[gb1(t)] ^ rcon, Sbox[gb2(t)], Sbox[gb3(t)], Sbox[gb0(t)]); + rcon <<= 1; + if (rcon & 0x100) + rcon = 0x1b; + m = keySize; + } + else if (m == 4 && keySize > 6) + t = Ui32(Sbox[gb0(t)], Sbox[gb1(t)], Sbox[gb2(t)], Sbox[gb3(t)]); + m--; + t ^= w[0]; + w[keySize] = t; + } + while (++w != wLim); +} + +void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *w, const Byte *key, unsigned keySize) +{ + unsigned i, num; + Aes_SetKey_Enc(w, key, keySize); + num = keySize + 20; + w += 8; + for (i = 0; i < num; i++) + { + UInt32 r = w[i]; + w[i] = + DD(0)[Sbox[gb0(r)]] ^ + DD(1)[Sbox[gb1(r)]] ^ + DD(2)[Sbox[gb2(r)]] ^ + DD(3)[Sbox[gb3(r)]]; + } +} + +/* Aes_Encode and Aes_Decode functions work with little-endian words. + src and dest are pointers to 4 UInt32 words. + src and dest can point to same block */ + +// MY_FORCE_INLINE +static void Aes_Encode(const UInt32 *w, UInt32 *dest, const UInt32 *src) +{ + UInt32 s[4]; + UInt32 m[4]; + UInt32 numRounds2 = w[0]; + w += 4; + s[0] = src[0] ^ w[0]; + s[1] = src[1] ^ w[1]; + s[2] = src[2] ^ w[2]; + s[3] = src[3] ^ w[3]; + w += 4; + for (;;) + { + HT16(m, s, 0); + if (--numRounds2 == 0) + break; + HT16(s, m, 4); + w += 8; + } + w += 4; + FT4(0); FT4(1); FT4(2); FT4(3); +} + +MY_FORCE_INLINE +static void Aes_Decode(const UInt32 *w, UInt32 *dest, const UInt32 *src) +{ + UInt32 s[4]; + UInt32 m[4]; + UInt32 numRounds2 = w[0]; + w += 4 + numRounds2 * 8; + s[0] = src[0] ^ w[0]; + s[1] = src[1] ^ w[1]; + s[2] = src[2] ^ w[2]; + s[3] = src[3] ^ w[3]; + for (;;) + { + w -= 8; + HD16(m, s, 4); + if (--numRounds2 == 0) + break; + HD16(s, m, 0); + } + FD4(0); FD4(1); FD4(2); FD4(3); +} + +void AesCbc_Init(UInt32 *p, const Byte *iv) +{ + unsigned i; + for (i = 0; i < 4; i++) + p[i] = GetUi32(iv + i * 4); +} + +void MY_FAST_CALL AesCbc_Encode(UInt32 *p, Byte *data, size_t numBlocks) +{ + for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE) + { + p[0] ^= GetUi32(data); + p[1] ^= GetUi32(data + 4); + p[2] ^= GetUi32(data + 8); + p[3] ^= GetUi32(data + 12); + + Aes_Encode(p + 4, p, p); + + SetUi32(data, p[0]); + SetUi32(data + 4, p[1]); + SetUi32(data + 8, p[2]); + SetUi32(data + 12, p[3]); + } +} + +void MY_FAST_CALL AesCbc_Decode(UInt32 *p, Byte *data, size_t numBlocks) +{ + UInt32 in[4], out[4]; + for (; numBlocks != 0; numBlocks--, data += AES_BLOCK_SIZE) + { + in[0] = GetUi32(data); + in[1] = GetUi32(data + 4); + in[2] = GetUi32(data + 8); + in[3] = GetUi32(data + 12); + + Aes_Decode(p + 4, out, in); + + SetUi32(data, p[0] ^ out[0]); + SetUi32(data + 4, p[1] ^ out[1]); + SetUi32(data + 8, p[2] ^ out[2]); + SetUi32(data + 12, p[3] ^ out[3]); + + p[0] = in[0]; + p[1] = in[1]; + p[2] = in[2]; + p[3] = in[3]; + } +} + +void MY_FAST_CALL AesCtr_Code(UInt32 *p, Byte *data, size_t numBlocks) +{ + for (; numBlocks != 0; numBlocks--) + { + UInt32 temp[4]; + unsigned i; + + if (++p[0] == 0) + p[1]++; + + Aes_Encode(p + 4, temp, p); + + for (i = 0; i < 4; i++, data += 4) + { + UInt32 t = temp[i]; + + #ifdef MY_CPU_LE_UNALIGN + *((UInt32 *)(void *)data) ^= t; + #else + data[0] = (Byte)(data[0] ^ (t & 0xFF)); + data[1] = (Byte)(data[1] ^ ((t >> 8) & 0xFF)); + data[2] = (Byte)(data[2] ^ ((t >> 16) & 0xFF)); + data[3] = (Byte)(data[3] ^ ((t >> 24))); + #endif + } + } +} diff --git a/deps/LZMA-SDK/C/Aes.h b/deps/LZMA-SDK/C/Aes.h index 602e25ea2..2aa225642 100644 --- a/deps/LZMA-SDK/C/Aes.h +++ b/deps/LZMA-SDK/C/Aes.h @@ -1,60 +1,60 @@ -/* Aes.h -- AES encryption / decryption -2018-04-28 : Igor Pavlov : Public domain */ - -#ifndef __AES_H -#define __AES_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define AES_BLOCK_SIZE 16 - -/* Call AesGenTables one time before other AES functions */ -void AesGenTables(void); - -/* UInt32 pointers must be 16-byte aligned */ - -/* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */ -#define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4) - -/* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */ -/* keySize = 16 or 24 or 32 (bytes) */ -typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize); -void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize); -void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize); - -/* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */ -void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */ - -/* data - 16-byte aligned pointer to data */ -/* numBlocks - the number of 16-byte blocks in data array */ -typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks); - -extern AES_CODE_FUNC g_AesCbc_Decode; -#ifndef _SFX -extern AES_CODE_FUNC g_AesCbc_Encode; -extern AES_CODE_FUNC g_AesCtr_Code; -#define k_Aes_SupportedFunctions_HW (1 << 2) -#define k_Aes_SupportedFunctions_HW_256 (1 << 3) -extern UInt32 g_Aes_SupportedFunctions_Flags; -#endif - - -#define DECLARE__AES_CODE_FUNC(funcName) \ - void MY_FAST_CALL funcName(UInt32 *ivAes, Byte *data, size_t numBlocks); - -DECLARE__AES_CODE_FUNC (AesCbc_Encode) -DECLARE__AES_CODE_FUNC (AesCbc_Decode) -DECLARE__AES_CODE_FUNC (AesCtr_Code) - -DECLARE__AES_CODE_FUNC (AesCbc_Encode_HW) -DECLARE__AES_CODE_FUNC (AesCbc_Decode_HW) -DECLARE__AES_CODE_FUNC (AesCtr_Code_HW) - -DECLARE__AES_CODE_FUNC (AesCbc_Decode_HW_256) -DECLARE__AES_CODE_FUNC (AesCtr_Code_HW_256) - -EXTERN_C_END - -#endif +/* Aes.h -- AES encryption / decryption +2018-04-28 : Igor Pavlov : Public domain */ + +#ifndef __AES_H +#define __AES_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define AES_BLOCK_SIZE 16 + +/* Call AesGenTables one time before other AES functions */ +void AesGenTables(void); + +/* UInt32 pointers must be 16-byte aligned */ + +/* 16-byte (4 * 32-bit words) blocks: 1 (IV) + 1 (keyMode) + 15 (AES-256 roundKeys) */ +#define AES_NUM_IVMRK_WORDS ((1 + 1 + 15) * 4) + +/* aes - 16-byte aligned pointer to keyMode+roundKeys sequence */ +/* keySize = 16 or 24 or 32 (bytes) */ +typedef void (MY_FAST_CALL *AES_SET_KEY_FUNC)(UInt32 *aes, const Byte *key, unsigned keySize); +void MY_FAST_CALL Aes_SetKey_Enc(UInt32 *aes, const Byte *key, unsigned keySize); +void MY_FAST_CALL Aes_SetKey_Dec(UInt32 *aes, const Byte *key, unsigned keySize); + +/* ivAes - 16-byte aligned pointer to iv+keyMode+roundKeys sequence: UInt32[AES_NUM_IVMRK_WORDS] */ +void AesCbc_Init(UInt32 *ivAes, const Byte *iv); /* iv size is AES_BLOCK_SIZE */ + +/* data - 16-byte aligned pointer to data */ +/* numBlocks - the number of 16-byte blocks in data array */ +typedef void (MY_FAST_CALL *AES_CODE_FUNC)(UInt32 *ivAes, Byte *data, size_t numBlocks); + +extern AES_CODE_FUNC g_AesCbc_Decode; +#ifndef _SFX +extern AES_CODE_FUNC g_AesCbc_Encode; +extern AES_CODE_FUNC g_AesCtr_Code; +#define k_Aes_SupportedFunctions_HW (1 << 2) +#define k_Aes_SupportedFunctions_HW_256 (1 << 3) +extern UInt32 g_Aes_SupportedFunctions_Flags; +#endif + + +#define DECLARE__AES_CODE_FUNC(funcName) \ + void MY_FAST_CALL funcName(UInt32 *ivAes, Byte *data, size_t numBlocks); + +DECLARE__AES_CODE_FUNC (AesCbc_Encode) +DECLARE__AES_CODE_FUNC (AesCbc_Decode) +DECLARE__AES_CODE_FUNC (AesCtr_Code) + +DECLARE__AES_CODE_FUNC (AesCbc_Encode_HW) +DECLARE__AES_CODE_FUNC (AesCbc_Decode_HW) +DECLARE__AES_CODE_FUNC (AesCtr_Code_HW) + +DECLARE__AES_CODE_FUNC (AesCbc_Decode_HW_256) +DECLARE__AES_CODE_FUNC (AesCtr_Code_HW_256) + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/AesOpt.c b/deps/LZMA-SDK/C/AesOpt.c index 1bdc9a882..8be8ff69d 100644 --- a/deps/LZMA-SDK/C/AesOpt.c +++ b/deps/LZMA-SDK/C/AesOpt.c @@ -1,776 +1,776 @@ -/* AesOpt.c -- AES optimized code for x86 AES hardware instructions -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" - -#ifdef MY_CPU_X86_OR_AMD64 - - #if defined(__clang__) - #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 8) - #define USE_INTEL_AES - #define ATTRIB_AES __attribute__((__target__("aes"))) - #if (__clang_major__ >= 8) - #define USE_INTEL_VAES - #define ATTRIB_VAES __attribute__((__target__("aes,vaes,avx2"))) - #endif - #endif - #elif defined(__GNUC__) - #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) - #define USE_INTEL_AES - #ifndef __AES__ - #define ATTRIB_AES __attribute__((__target__("aes"))) - #endif - #if (__GNUC__ >= 8) - #define USE_INTEL_VAES - #define ATTRIB_VAES __attribute__((__target__("aes,vaes,avx2"))) - #endif - #endif - #elif defined(__INTEL_COMPILER) - #if (__INTEL_COMPILER >= 1110) - #define USE_INTEL_AES - #if (__INTEL_COMPILER >= 1900) - #define USE_INTEL_VAES - #endif - #endif - #elif defined(_MSC_VER) - #if (_MSC_VER > 1500) || (_MSC_FULL_VER >= 150030729) - #define USE_INTEL_AES - #if (_MSC_VER >= 1910) - #define USE_INTEL_VAES - #endif - #endif - #endif - -#ifndef ATTRIB_AES - #define ATTRIB_AES -#endif -#ifndef ATTRIB_VAES - #define ATTRIB_VAES -#endif - - -#ifdef USE_INTEL_AES - -#include - -#ifndef USE_INTEL_VAES -#define AES_TYPE_keys __m128i -#define AES_TYPE_data __m128i -#endif - -#define AES_FUNC_START(name) \ - void MY_FAST_CALL name(__m128i *p, __m128i *data, size_t numBlocks) - -#define AES_FUNC_START2(name) \ -AES_FUNC_START (name); \ -ATTRIB_AES \ -AES_FUNC_START (name) - -#define MM_OP(op, dest, src) dest = op(dest, src); -#define MM_OP_m(op, src) MM_OP(op, m, src); - -#define MM_XOR( dest, src) MM_OP(_mm_xor_si128, dest, src); -#define AVX_XOR(dest, src) MM_OP(_mm256_xor_si256, dest, src); - - -AES_FUNC_START2 (AesCbc_Encode_HW) -{ - __m128i m = *p; - const __m128i k0 = p[2]; - const __m128i k1 = p[3]; - const UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1; - for (; numBlocks != 0; numBlocks--, data++) - { - UInt32 r = numRounds2; - const __m128i *w = p + 4; - __m128i temp = *data; - MM_XOR (temp, k0); - MM_XOR (m, temp); - MM_OP_m (_mm_aesenc_si128, k1); - do - { - MM_OP_m (_mm_aesenc_si128, w[0]); - MM_OP_m (_mm_aesenc_si128, w[1]); - w += 2; - } - while (--r); - MM_OP_m (_mm_aesenclast_si128, w[0]); - *data = m; - } - *p = m; -} - - -#define WOP_1(op) -#define WOP_2(op) WOP_1 (op) op (m1, 1); -#define WOP_3(op) WOP_2 (op) op (m2, 2); -#define WOP_4(op) WOP_3 (op) op (m3, 3); -#ifdef MY_CPU_AMD64 -#define WOP_5(op) WOP_4 (op) op (m4, 4); -#define WOP_6(op) WOP_5 (op) op (m5, 5); -#define WOP_7(op) WOP_6 (op) op (m6, 6); -#define WOP_8(op) WOP_7 (op) op (m7, 7); -#endif -/* -#define WOP_9(op) WOP_8 (op) op (m8, 8); -#define WOP_10(op) WOP_9 (op) op (m9, 9); -#define WOP_11(op) WOP_10(op) op (m10, 10); -#define WOP_12(op) WOP_11(op) op (m11, 11); -#define WOP_13(op) WOP_12(op) op (m12, 12); -#define WOP_14(op) WOP_13(op) op (m13, 13); -*/ - -#ifdef MY_CPU_AMD64 - #define NUM_WAYS 8 - #define WOP_M1 WOP_8 -#else - #define NUM_WAYS 4 - #define WOP_M1 WOP_4 -#endif - -#define WOP(op) op (m0, 0); WOP_M1(op) - - -#define DECLARE_VAR(reg, ii) __m128i reg -#define LOAD_data( reg, ii) reg = data[ii]; -#define STORE_data( reg, ii) data[ii] = reg; -#if (NUM_WAYS > 1) -#define XOR_data_M1(reg, ii) MM_XOR (reg, data[ii- 1]); -#endif - -#define AVX__DECLARE_VAR(reg, ii) __m256i reg -#define AVX__LOAD_data( reg, ii) reg = ((const __m256i *)(const void *)data)[ii]; -#define AVX__STORE_data( reg, ii) ((__m256i *)(void *)data)[ii] = reg; -#define AVX__XOR_data_M1(reg, ii) AVX_XOR (reg, (((const __m256i *)(const void *)(data - 1))[ii])); - -#define MM_OP_key(op, reg) MM_OP(op, reg, key); - -#define AES_DEC( reg, ii) MM_OP_key (_mm_aesdec_si128, reg) -#define AES_DEC_LAST( reg, ii) MM_OP_key (_mm_aesdeclast_si128, reg) -#define AES_ENC( reg, ii) MM_OP_key (_mm_aesenc_si128, reg) -#define AES_ENC_LAST( reg, ii) MM_OP_key (_mm_aesenclast_si128, reg) -#define AES_XOR( reg, ii) MM_OP_key (_mm_xor_si128, reg) - - -#define AVX__AES_DEC( reg, ii) MM_OP_key (_mm256_aesdec_epi128, reg) -#define AVX__AES_DEC_LAST( reg, ii) MM_OP_key (_mm256_aesdeclast_epi128, reg) -#define AVX__AES_ENC( reg, ii) MM_OP_key (_mm256_aesenc_epi128, reg) -#define AVX__AES_ENC_LAST( reg, ii) MM_OP_key (_mm256_aesenclast_epi128, reg) -#define AVX__AES_XOR( reg, ii) MM_OP_key (_mm256_xor_si256, reg) - -#define CTR_START(reg, ii) MM_OP (_mm_add_epi64, ctr, one); reg = ctr; -#define CTR_END( reg, ii) MM_XOR (data[ii], reg); - -#define AVX__CTR_START(reg, ii) MM_OP (_mm256_add_epi64, ctr2, two); reg = _mm256_xor_si256(ctr2, key); -#define AVX__CTR_END( reg, ii) AVX_XOR (((__m256i *)(void *)data)[ii], reg); - -#define WOP_KEY(op, n) { \ - const __m128i key = w[n]; \ - WOP(op); } - -#define AVX__WOP_KEY(op, n) { \ - const __m256i key = w[n]; \ - WOP(op); } - - -#define WIDE_LOOP_START \ - dataEnd = data + numBlocks; \ - if (numBlocks >= NUM_WAYS) \ - { dataEnd -= NUM_WAYS; do { \ - - -#define WIDE_LOOP_END \ - data += NUM_WAYS; \ - } while (data <= dataEnd); \ - dataEnd += NUM_WAYS; } \ - - -#define SINGLE_LOOP \ - for (; data < dataEnd; data++) - - -#define NUM_AES_KEYS_MAX 15 - -#define WIDE_LOOP_START_AVX(OP) \ - dataEnd = data + numBlocks; \ - if (numBlocks >= NUM_WAYS * 2) \ - { __m256i keys[NUM_AES_KEYS_MAX]; \ - UInt32 ii; \ - OP \ - for (ii = 0; ii < numRounds; ii++) \ - keys[ii] = _mm256_broadcastsi128_si256(p[ii]); \ - dataEnd -= NUM_WAYS * 2; do { \ - - -#define WIDE_LOOP_END_AVX(OP) \ - data += NUM_WAYS * 2; \ - } while (data <= dataEnd); \ - dataEnd += NUM_WAYS * 2; \ - OP \ - _mm256_zeroupper(); \ - } \ - -/* MSVC for x86: If we don't call _mm256_zeroupper(), and -arch:IA32 is not specified, - MSVC still can insert vzeroupper instruction. */ - - -AES_FUNC_START2 (AesCbc_Decode_HW) -{ - __m128i iv = *p; - const __m128i *wStart = p + *(const UInt32 *)(p + 1) * 2 + 2 - 1; - const __m128i *dataEnd; - p += 2; - - WIDE_LOOP_START - { - const __m128i *w = wStart; - - WOP (DECLARE_VAR) - WOP (LOAD_data); - WOP_KEY (AES_XOR, 1) - - do - { - WOP_KEY (AES_DEC, 0) - w--; - } - while (w != p); - WOP_KEY (AES_DEC_LAST, 0) - - MM_XOR (m0, iv); - WOP_M1 (XOR_data_M1) - iv = data[NUM_WAYS - 1]; - WOP (STORE_data); - } - WIDE_LOOP_END - - SINGLE_LOOP - { - const __m128i *w = wStart - 1; - __m128i m = _mm_xor_si128 (w[2], *data); - do - { - MM_OP_m (_mm_aesdec_si128, w[1]); - MM_OP_m (_mm_aesdec_si128, w[0]); - w -= 2; - } - while (w != p); - MM_OP_m (_mm_aesdec_si128, w[1]); - MM_OP_m (_mm_aesdeclast_si128, w[0]); - - MM_XOR (m, iv); - iv = *data; - *data = m; - } - - p[-2] = iv; -} - - -AES_FUNC_START2 (AesCtr_Code_HW) -{ - __m128i ctr = *p; - UInt32 numRoundsMinus2 = *(const UInt32 *)(p + 1) * 2 - 1; - const __m128i *dataEnd; - __m128i one = _mm_cvtsi32_si128(1); - - p += 2; - - WIDE_LOOP_START - { - const __m128i *w = p; - UInt32 r = numRoundsMinus2; - WOP (DECLARE_VAR) - WOP (CTR_START); - WOP_KEY (AES_XOR, 0) - w += 1; - do - { - WOP_KEY (AES_ENC, 0) - w += 1; - } - while (--r); - WOP_KEY (AES_ENC_LAST, 0) - - WOP (CTR_END); - } - WIDE_LOOP_END - - SINGLE_LOOP - { - UInt32 numRounds2 = *(const UInt32 *)(p - 2 + 1) - 1; - const __m128i *w = p; - __m128i m; - MM_OP (_mm_add_epi64, ctr, one); - m = _mm_xor_si128 (ctr, p[0]); - w += 1; - do - { - MM_OP_m (_mm_aesenc_si128, w[0]); - MM_OP_m (_mm_aesenc_si128, w[1]); - w += 2; - } - while (--numRounds2); - MM_OP_m (_mm_aesenc_si128, w[0]); - MM_OP_m (_mm_aesenclast_si128, w[1]); - MM_XOR (*data, m); - } - - p[-2] = ctr; -} - - - -#ifdef USE_INTEL_VAES - -#if defined(__clang__) && defined(_MSC_VER) -#define __SSE4_2__ -#define __AES__ -#define __AVX__ -#define __AVX2__ -#define __VAES__ -#define __AVX512F__ -#define __AVX512VL__ -#endif - -#include - -#define VAES_FUNC_START2(name) \ -AES_FUNC_START (name); \ -ATTRIB_VAES \ -AES_FUNC_START (name) - -VAES_FUNC_START2 (AesCbc_Decode_HW_256) -{ - __m128i iv = *p; - const __m128i *dataEnd; - UInt32 numRounds = *(const UInt32 *)(p + 1) * 2 + 1; - p += 2; - - WIDE_LOOP_START_AVX(;) - { - const __m256i *w = keys + numRounds - 2; - - WOP (AVX__DECLARE_VAR) - WOP (AVX__LOAD_data); - AVX__WOP_KEY (AVX__AES_XOR, 1) - - do - { - AVX__WOP_KEY (AVX__AES_DEC, 0) - w--; - } - while (w != keys); - AVX__WOP_KEY (AVX__AES_DEC_LAST, 0) - - AVX_XOR (m0, _mm256_setr_m128i(iv, data[0])); - WOP_M1 (AVX__XOR_data_M1) - iv = data[NUM_WAYS * 2 - 1]; - WOP (AVX__STORE_data); - } - WIDE_LOOP_END_AVX(;) - - SINGLE_LOOP - { - const __m128i *w = p + *(const UInt32 *)(p + 1 - 2) * 2 + 1 - 3; - __m128i m = _mm_xor_si128 (w[2], *data); - do - { - MM_OP_m (_mm_aesdec_si128, w[1]); - MM_OP_m (_mm_aesdec_si128, w[0]); - w -= 2; - } - while (w != p); - MM_OP_m (_mm_aesdec_si128, w[1]); - MM_OP_m (_mm_aesdeclast_si128, w[0]); - - MM_XOR (m, iv); - iv = *data; - *data = m; - } - - p[-2] = iv; -} - - -/* -SSE2: _mm_cvtsi32_si128 : movd -AVX: _mm256_setr_m128i : vinsertf128 -AVX2: _mm256_add_epi64 : vpaddq ymm, ymm, ymm - _mm256_extracti128_si256 : vextracti128 - _mm256_broadcastsi128_si256 : vbroadcasti128 -*/ - -#define AVX__CTR_LOOP_START \ - ctr2 = _mm256_setr_m128i(_mm_sub_epi64(ctr, one), ctr); \ - two = _mm256_setr_m128i(one, one); \ - two = _mm256_add_epi64(two, two); \ - -// two = _mm256_setr_epi64x(2, 0, 2, 0); - -#define AVX__CTR_LOOP_ENC \ - ctr = _mm256_extracti128_si256 (ctr2, 1); \ - -VAES_FUNC_START2 (AesCtr_Code_HW_256) -{ - __m128i ctr = *p; - UInt32 numRounds = *(const UInt32 *)(p + 1) * 2 + 1; - const __m128i *dataEnd; - __m128i one = _mm_cvtsi32_si128(1); - __m256i ctr2, two; - p += 2; - - WIDE_LOOP_START_AVX (AVX__CTR_LOOP_START) - { - const __m256i *w = keys; - UInt32 r = numRounds - 2; - WOP (AVX__DECLARE_VAR) - AVX__WOP_KEY (AVX__CTR_START, 0); - - w += 1; - do - { - AVX__WOP_KEY (AVX__AES_ENC, 0) - w += 1; - } - while (--r); - AVX__WOP_KEY (AVX__AES_ENC_LAST, 0) - - WOP (AVX__CTR_END); - } - WIDE_LOOP_END_AVX (AVX__CTR_LOOP_ENC) - - SINGLE_LOOP - { - UInt32 numRounds2 = *(const UInt32 *)(p - 2 + 1) - 1; - const __m128i *w = p; - __m128i m; - MM_OP (_mm_add_epi64, ctr, one); - m = _mm_xor_si128 (ctr, p[0]); - w += 1; - do - { - MM_OP_m (_mm_aesenc_si128, w[0]); - MM_OP_m (_mm_aesenc_si128, w[1]); - w += 2; - } - while (--numRounds2); - MM_OP_m (_mm_aesenc_si128, w[0]); - MM_OP_m (_mm_aesenclast_si128, w[1]); - MM_XOR (*data, m); - } - - p[-2] = ctr; -} - -#endif // USE_INTEL_VAES - -#else // USE_INTEL_AES - -/* no USE_INTEL_AES */ - -#pragma message("AES HW_SW stub was used") - -#define AES_TYPE_keys UInt32 -#define AES_TYPE_data Byte - -#define AES_FUNC_START(name) \ - void MY_FAST_CALL name(UInt32 *p, Byte *data, size_t numBlocks) \ - -#define AES_COMPAT_STUB(name) \ - AES_FUNC_START(name); \ - AES_FUNC_START(name ## _HW) \ - { name(p, data, numBlocks); } - -AES_COMPAT_STUB (AesCbc_Encode) -AES_COMPAT_STUB (AesCbc_Decode) -AES_COMPAT_STUB (AesCtr_Code) - -#endif // USE_INTEL_AES - - -#ifndef USE_INTEL_VAES - -#pragma message("VAES HW_SW stub was used") - -#define VAES_COMPAT_STUB(name) \ - void MY_FAST_CALL name ## _256(UInt32 *p, Byte *data, size_t numBlocks); \ - void MY_FAST_CALL name ## _256(UInt32 *p, Byte *data, size_t numBlocks) \ - { name((AES_TYPE_keys *)(void *)p, (AES_TYPE_data *)(void *)data, numBlocks); } - -VAES_COMPAT_STUB (AesCbc_Decode_HW) -VAES_COMPAT_STUB (AesCtr_Code_HW) - -#endif // ! USE_INTEL_VAES - - -#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE) - - #if defined(__clang__) - #if (__clang_major__ >= 8) // fix that check - #define USE_HW_AES - #endif - #elif defined(__GNUC__) - #if (__GNUC__ >= 6) // fix that check - #define USE_HW_AES - #endif - #elif defined(_MSC_VER) - #if _MSC_VER >= 1910 - #define USE_HW_AES - #endif - #endif - -#ifdef USE_HW_AES - -// #pragma message("=== AES HW === ") - -#if defined(__clang__) || defined(__GNUC__) - #ifdef MY_CPU_ARM64 - #define ATTRIB_AES __attribute__((__target__("+crypto"))) - #else - #define ATTRIB_AES __attribute__((__target__("fpu=crypto-neon-fp-armv8"))) - #endif -#else - // _MSC_VER - // for arm32 - #define _ARM_USE_NEW_NEON_INTRINSICS -#endif - -#ifndef ATTRIB_AES - #define ATTRIB_AES -#endif - -#if defined(_MSC_VER) && defined(MY_CPU_ARM64) -#include -#else -#include -#endif - -typedef uint8x16_t v128; - -#define AES_FUNC_START(name) \ - void MY_FAST_CALL name(v128 *p, v128 *data, size_t numBlocks) - -#define AES_FUNC_START2(name) \ -AES_FUNC_START (name); \ -ATTRIB_AES \ -AES_FUNC_START (name) - -#define MM_OP(op, dest, src) dest = op(dest, src); -#define MM_OP_m(op, src) MM_OP(op, m, src); -#define MM_OP1_m(op) m = op(m); - -#define MM_XOR( dest, src) MM_OP(veorq_u8, dest, src); -#define MM_XOR_m( src) MM_XOR(m, src); - -#define AES_E_m(k) MM_OP_m (vaeseq_u8, k); -#define AES_E_MC_m(k) AES_E_m (k); MM_OP1_m(vaesmcq_u8); - - -AES_FUNC_START2 (AesCbc_Encode_HW) -{ - v128 m = *p; - const v128 k0 = p[2]; - const v128 k1 = p[3]; - const v128 k2 = p[4]; - const v128 k3 = p[5]; - const v128 k4 = p[6]; - const v128 k5 = p[7]; - const v128 k6 = p[8]; - const v128 k7 = p[9]; - const v128 k8 = p[10]; - const v128 k9 = p[11]; - const UInt32 numRounds2 = *(const UInt32 *)(p + 1); - const v128 *w = p + ((size_t)numRounds2 * 2); - const v128 k_z1 = w[1]; - const v128 k_z0 = w[2]; - for (; numBlocks != 0; numBlocks--, data++) - { - MM_XOR_m (*data); - AES_E_MC_m (k0) - AES_E_MC_m (k1) - AES_E_MC_m (k2) - AES_E_MC_m (k3) - AES_E_MC_m (k4) - AES_E_MC_m (k5) - AES_E_MC_m (k6) - AES_E_MC_m (k7) - AES_E_MC_m (k8) - if (numRounds2 >= 6) - { - AES_E_MC_m (k9) - AES_E_MC_m (p[12]) - if (numRounds2 != 6) - { - AES_E_MC_m (p[13]) - AES_E_MC_m (p[14]) - } - } - AES_E_m (k_z1); - MM_XOR_m (k_z0); - *data = m; - } - *p = m; -} - - -#define WOP_1(op) -#define WOP_2(op) WOP_1 (op) op (m1, 1); -#define WOP_3(op) WOP_2 (op) op (m2, 2); -#define WOP_4(op) WOP_3 (op) op (m3, 3); -#define WOP_5(op) WOP_4 (op) op (m4, 4); -#define WOP_6(op) WOP_5 (op) op (m5, 5); -#define WOP_7(op) WOP_6 (op) op (m6, 6); -#define WOP_8(op) WOP_7 (op) op (m7, 7); - - #define NUM_WAYS 8 - #define WOP_M1 WOP_8 - -#define WOP(op) op (m0, 0); WOP_M1(op) - -#define DECLARE_VAR(reg, ii) v128 reg -#define LOAD_data( reg, ii) reg = data[ii]; -#define STORE_data( reg, ii) data[ii] = reg; -#if (NUM_WAYS > 1) -#define XOR_data_M1(reg, ii) MM_XOR (reg, data[ii- 1]); -#endif - -#define MM_OP_key(op, reg) MM_OP (op, reg, key); - -#define AES_D_m(k) MM_OP_m (vaesdq_u8, k); -#define AES_D_IMC_m(k) AES_D_m (k); MM_OP1_m (vaesimcq_u8); - -#define AES_XOR( reg, ii) MM_OP_key (veorq_u8, reg) -#define AES_D( reg, ii) MM_OP_key (vaesdq_u8, reg) -#define AES_E( reg, ii) MM_OP_key (vaeseq_u8, reg) - -#define AES_D_IMC( reg, ii) AES_D (reg, ii); reg = vaesimcq_u8(reg) -#define AES_E_MC( reg, ii) AES_E (reg, ii); reg = vaesmcq_u8(reg) - -#define CTR_START(reg, ii) MM_OP (vaddq_u64, ctr, one); reg = vreinterpretq_u8_u64(ctr); -#define CTR_END( reg, ii) MM_XOR (data[ii], reg); - -#define WOP_KEY(op, n) { \ - const v128 key = w[n]; \ - WOP(op); } - -#define WIDE_LOOP_START \ - dataEnd = data + numBlocks; \ - if (numBlocks >= NUM_WAYS) \ - { dataEnd -= NUM_WAYS; do { \ - -#define WIDE_LOOP_END \ - data += NUM_WAYS; \ - } while (data <= dataEnd); \ - dataEnd += NUM_WAYS; } \ - -#define SINGLE_LOOP \ - for (; data < dataEnd; data++) - - -AES_FUNC_START2 (AesCbc_Decode_HW) -{ - v128 iv = *p; - const v128 *wStart = p + ((size_t)*(const UInt32 *)(p + 1)) * 2; - const v128 *dataEnd; - p += 2; - - WIDE_LOOP_START - { - const v128 *w = wStart; - WOP (DECLARE_VAR) - WOP (LOAD_data); - WOP_KEY (AES_D_IMC, 2) - do - { - WOP_KEY (AES_D_IMC, 1) - WOP_KEY (AES_D_IMC, 0) - w -= 2; - } - while (w != p); - WOP_KEY (AES_D, 1) - WOP_KEY (AES_XOR, 0) - MM_XOR (m0, iv); - WOP_M1 (XOR_data_M1) - iv = data[NUM_WAYS - 1]; - WOP (STORE_data); - } - WIDE_LOOP_END - - SINGLE_LOOP - { - const v128 *w = wStart; - v128 m = *data; - AES_D_IMC_m (w[2]) - do - { - AES_D_IMC_m (w[1]); - AES_D_IMC_m (w[0]); - w -= 2; - } - while (w != p); - AES_D_m (w[1]); - MM_XOR_m (w[0]); - MM_XOR_m (iv); - iv = *data; - *data = m; - } - - p[-2] = iv; -} - - -AES_FUNC_START2 (AesCtr_Code_HW) -{ - uint64x2_t ctr = vreinterpretq_u64_u8(*p); - const v128 *wEnd = p + ((size_t)*(const UInt32 *)(p + 1)) * 2; - const v128 *dataEnd; - uint64x2_t one = vdupq_n_u64(0); - one = vsetq_lane_u64(1, one, 0); - p += 2; - - WIDE_LOOP_START - { - const v128 *w = p; - WOP (DECLARE_VAR) - WOP (CTR_START); - do - { - WOP_KEY (AES_E_MC, 0) - WOP_KEY (AES_E_MC, 1) - w += 2; - } - while (w != wEnd); - WOP_KEY (AES_E_MC, 0) - WOP_KEY (AES_E, 1) - WOP_KEY (AES_XOR, 2) - WOP (CTR_END); - } - WIDE_LOOP_END - - SINGLE_LOOP - { - const v128 *w = p; - v128 m; - CTR_START (m, 0); - do - { - AES_E_MC_m (w[0]); - AES_E_MC_m (w[1]); - w += 2; - } - while (w != wEnd); - AES_E_MC_m (w[0]); - AES_E_m (w[1]); - MM_XOR_m (w[2]); - CTR_END (m, 0); - } - - p[-2] = vreinterpretq_u8_u64(ctr); -} - -#endif // USE_HW_AES - -#endif // MY_CPU_ARM_OR_ARM64 +/* AesOpt.c -- AES optimized code for x86 AES hardware instructions +2021-04-01 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" + +#ifdef MY_CPU_X86_OR_AMD64 + + #if defined(__clang__) + #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 8) + #define USE_INTEL_AES + #define ATTRIB_AES __attribute__((__target__("aes"))) + #if (__clang_major__ >= 8) + #define USE_INTEL_VAES + #define ATTRIB_VAES __attribute__((__target__("aes,vaes,avx2"))) + #endif + #endif + #elif defined(__GNUC__) + #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) + #define USE_INTEL_AES + #ifndef __AES__ + #define ATTRIB_AES __attribute__((__target__("aes"))) + #endif + #if (__GNUC__ >= 8) + #define USE_INTEL_VAES + #define ATTRIB_VAES __attribute__((__target__("aes,vaes,avx2"))) + #endif + #endif + #elif defined(__INTEL_COMPILER) + #if (__INTEL_COMPILER >= 1110) + #define USE_INTEL_AES + #if (__INTEL_COMPILER >= 1900) + #define USE_INTEL_VAES + #endif + #endif + #elif defined(_MSC_VER) + #if (_MSC_VER > 1500) || (_MSC_FULL_VER >= 150030729) + #define USE_INTEL_AES + #if (_MSC_VER >= 1910) + #define USE_INTEL_VAES + #endif + #endif + #endif + +#ifndef ATTRIB_AES + #define ATTRIB_AES +#endif +#ifndef ATTRIB_VAES + #define ATTRIB_VAES +#endif + + +#ifdef USE_INTEL_AES + +#include + +#ifndef USE_INTEL_VAES +#define AES_TYPE_keys __m128i +#define AES_TYPE_data __m128i +#endif + +#define AES_FUNC_START(name) \ + void MY_FAST_CALL name(__m128i *p, __m128i *data, size_t numBlocks) + +#define AES_FUNC_START2(name) \ +AES_FUNC_START (name); \ +ATTRIB_AES \ +AES_FUNC_START (name) + +#define MM_OP(op, dest, src) dest = op(dest, src); +#define MM_OP_m(op, src) MM_OP(op, m, src); + +#define MM_XOR( dest, src) MM_OP(_mm_xor_si128, dest, src); +#define AVX_XOR(dest, src) MM_OP(_mm256_xor_si256, dest, src); + + +AES_FUNC_START2 (AesCbc_Encode_HW) +{ + __m128i m = *p; + const __m128i k0 = p[2]; + const __m128i k1 = p[3]; + const UInt32 numRounds2 = *(const UInt32 *)(p + 1) - 1; + for (; numBlocks != 0; numBlocks--, data++) + { + UInt32 r = numRounds2; + const __m128i *w = p + 4; + __m128i temp = *data; + MM_XOR (temp, k0); + MM_XOR (m, temp); + MM_OP_m (_mm_aesenc_si128, k1); + do + { + MM_OP_m (_mm_aesenc_si128, w[0]); + MM_OP_m (_mm_aesenc_si128, w[1]); + w += 2; + } + while (--r); + MM_OP_m (_mm_aesenclast_si128, w[0]); + *data = m; + } + *p = m; +} + + +#define WOP_1(op) +#define WOP_2(op) WOP_1 (op) op (m1, 1); +#define WOP_3(op) WOP_2 (op) op (m2, 2); +#define WOP_4(op) WOP_3 (op) op (m3, 3); +#ifdef MY_CPU_AMD64 +#define WOP_5(op) WOP_4 (op) op (m4, 4); +#define WOP_6(op) WOP_5 (op) op (m5, 5); +#define WOP_7(op) WOP_6 (op) op (m6, 6); +#define WOP_8(op) WOP_7 (op) op (m7, 7); +#endif +/* +#define WOP_9(op) WOP_8 (op) op (m8, 8); +#define WOP_10(op) WOP_9 (op) op (m9, 9); +#define WOP_11(op) WOP_10(op) op (m10, 10); +#define WOP_12(op) WOP_11(op) op (m11, 11); +#define WOP_13(op) WOP_12(op) op (m12, 12); +#define WOP_14(op) WOP_13(op) op (m13, 13); +*/ + +#ifdef MY_CPU_AMD64 + #define NUM_WAYS 8 + #define WOP_M1 WOP_8 +#else + #define NUM_WAYS 4 + #define WOP_M1 WOP_4 +#endif + +#define WOP(op) op (m0, 0); WOP_M1(op) + + +#define DECLARE_VAR(reg, ii) __m128i reg +#define LOAD_data( reg, ii) reg = data[ii]; +#define STORE_data( reg, ii) data[ii] = reg; +#if (NUM_WAYS > 1) +#define XOR_data_M1(reg, ii) MM_XOR (reg, data[ii- 1]); +#endif + +#define AVX__DECLARE_VAR(reg, ii) __m256i reg +#define AVX__LOAD_data( reg, ii) reg = ((const __m256i *)(const void *)data)[ii]; +#define AVX__STORE_data( reg, ii) ((__m256i *)(void *)data)[ii] = reg; +#define AVX__XOR_data_M1(reg, ii) AVX_XOR (reg, (((const __m256i *)(const void *)(data - 1))[ii])); + +#define MM_OP_key(op, reg) MM_OP(op, reg, key); + +#define AES_DEC( reg, ii) MM_OP_key (_mm_aesdec_si128, reg) +#define AES_DEC_LAST( reg, ii) MM_OP_key (_mm_aesdeclast_si128, reg) +#define AES_ENC( reg, ii) MM_OP_key (_mm_aesenc_si128, reg) +#define AES_ENC_LAST( reg, ii) MM_OP_key (_mm_aesenclast_si128, reg) +#define AES_XOR( reg, ii) MM_OP_key (_mm_xor_si128, reg) + + +#define AVX__AES_DEC( reg, ii) MM_OP_key (_mm256_aesdec_epi128, reg) +#define AVX__AES_DEC_LAST( reg, ii) MM_OP_key (_mm256_aesdeclast_epi128, reg) +#define AVX__AES_ENC( reg, ii) MM_OP_key (_mm256_aesenc_epi128, reg) +#define AVX__AES_ENC_LAST( reg, ii) MM_OP_key (_mm256_aesenclast_epi128, reg) +#define AVX__AES_XOR( reg, ii) MM_OP_key (_mm256_xor_si256, reg) + +#define CTR_START(reg, ii) MM_OP (_mm_add_epi64, ctr, one); reg = ctr; +#define CTR_END( reg, ii) MM_XOR (data[ii], reg); + +#define AVX__CTR_START(reg, ii) MM_OP (_mm256_add_epi64, ctr2, two); reg = _mm256_xor_si256(ctr2, key); +#define AVX__CTR_END( reg, ii) AVX_XOR (((__m256i *)(void *)data)[ii], reg); + +#define WOP_KEY(op, n) { \ + const __m128i key = w[n]; \ + WOP(op); } + +#define AVX__WOP_KEY(op, n) { \ + const __m256i key = w[n]; \ + WOP(op); } + + +#define WIDE_LOOP_START \ + dataEnd = data + numBlocks; \ + if (numBlocks >= NUM_WAYS) \ + { dataEnd -= NUM_WAYS; do { \ + + +#define WIDE_LOOP_END \ + data += NUM_WAYS; \ + } while (data <= dataEnd); \ + dataEnd += NUM_WAYS; } \ + + +#define SINGLE_LOOP \ + for (; data < dataEnd; data++) + + +#define NUM_AES_KEYS_MAX 15 + +#define WIDE_LOOP_START_AVX(OP) \ + dataEnd = data + numBlocks; \ + if (numBlocks >= NUM_WAYS * 2) \ + { __m256i keys[NUM_AES_KEYS_MAX]; \ + UInt32 ii; \ + OP \ + for (ii = 0; ii < numRounds; ii++) \ + keys[ii] = _mm256_broadcastsi128_si256(p[ii]); \ + dataEnd -= NUM_WAYS * 2; do { \ + + +#define WIDE_LOOP_END_AVX(OP) \ + data += NUM_WAYS * 2; \ + } while (data <= dataEnd); \ + dataEnd += NUM_WAYS * 2; \ + OP \ + _mm256_zeroupper(); \ + } \ + +/* MSVC for x86: If we don't call _mm256_zeroupper(), and -arch:IA32 is not specified, + MSVC still can insert vzeroupper instruction. */ + + +AES_FUNC_START2 (AesCbc_Decode_HW) +{ + __m128i iv = *p; + const __m128i *wStart = p + *(const UInt32 *)(p + 1) * 2 + 2 - 1; + const __m128i *dataEnd; + p += 2; + + WIDE_LOOP_START + { + const __m128i *w = wStart; + + WOP (DECLARE_VAR) + WOP (LOAD_data); + WOP_KEY (AES_XOR, 1) + + do + { + WOP_KEY (AES_DEC, 0) + w--; + } + while (w != p); + WOP_KEY (AES_DEC_LAST, 0) + + MM_XOR (m0, iv); + WOP_M1 (XOR_data_M1) + iv = data[NUM_WAYS - 1]; + WOP (STORE_data); + } + WIDE_LOOP_END + + SINGLE_LOOP + { + const __m128i *w = wStart - 1; + __m128i m = _mm_xor_si128 (w[2], *data); + do + { + MM_OP_m (_mm_aesdec_si128, w[1]); + MM_OP_m (_mm_aesdec_si128, w[0]); + w -= 2; + } + while (w != p); + MM_OP_m (_mm_aesdec_si128, w[1]); + MM_OP_m (_mm_aesdeclast_si128, w[0]); + + MM_XOR (m, iv); + iv = *data; + *data = m; + } + + p[-2] = iv; +} + + +AES_FUNC_START2 (AesCtr_Code_HW) +{ + __m128i ctr = *p; + UInt32 numRoundsMinus2 = *(const UInt32 *)(p + 1) * 2 - 1; + const __m128i *dataEnd; + __m128i one = _mm_cvtsi32_si128(1); + + p += 2; + + WIDE_LOOP_START + { + const __m128i *w = p; + UInt32 r = numRoundsMinus2; + WOP (DECLARE_VAR) + WOP (CTR_START); + WOP_KEY (AES_XOR, 0) + w += 1; + do + { + WOP_KEY (AES_ENC, 0) + w += 1; + } + while (--r); + WOP_KEY (AES_ENC_LAST, 0) + + WOP (CTR_END); + } + WIDE_LOOP_END + + SINGLE_LOOP + { + UInt32 numRounds2 = *(const UInt32 *)(p - 2 + 1) - 1; + const __m128i *w = p; + __m128i m; + MM_OP (_mm_add_epi64, ctr, one); + m = _mm_xor_si128 (ctr, p[0]); + w += 1; + do + { + MM_OP_m (_mm_aesenc_si128, w[0]); + MM_OP_m (_mm_aesenc_si128, w[1]); + w += 2; + } + while (--numRounds2); + MM_OP_m (_mm_aesenc_si128, w[0]); + MM_OP_m (_mm_aesenclast_si128, w[1]); + MM_XOR (*data, m); + } + + p[-2] = ctr; +} + + + +#ifdef USE_INTEL_VAES + +#if defined(__clang__) && defined(_MSC_VER) +#define __SSE4_2__ +#define __AES__ +#define __AVX__ +#define __AVX2__ +#define __VAES__ +#define __AVX512F__ +#define __AVX512VL__ +#endif + +#include + +#define VAES_FUNC_START2(name) \ +AES_FUNC_START (name); \ +ATTRIB_VAES \ +AES_FUNC_START (name) + +VAES_FUNC_START2 (AesCbc_Decode_HW_256) +{ + __m128i iv = *p; + const __m128i *dataEnd; + UInt32 numRounds = *(const UInt32 *)(p + 1) * 2 + 1; + p += 2; + + WIDE_LOOP_START_AVX(;) + { + const __m256i *w = keys + numRounds - 2; + + WOP (AVX__DECLARE_VAR) + WOP (AVX__LOAD_data); + AVX__WOP_KEY (AVX__AES_XOR, 1) + + do + { + AVX__WOP_KEY (AVX__AES_DEC, 0) + w--; + } + while (w != keys); + AVX__WOP_KEY (AVX__AES_DEC_LAST, 0) + + AVX_XOR (m0, _mm256_setr_m128i(iv, data[0])); + WOP_M1 (AVX__XOR_data_M1) + iv = data[NUM_WAYS * 2 - 1]; + WOP (AVX__STORE_data); + } + WIDE_LOOP_END_AVX(;) + + SINGLE_LOOP + { + const __m128i *w = p + *(const UInt32 *)(p + 1 - 2) * 2 + 1 - 3; + __m128i m = _mm_xor_si128 (w[2], *data); + do + { + MM_OP_m (_mm_aesdec_si128, w[1]); + MM_OP_m (_mm_aesdec_si128, w[0]); + w -= 2; + } + while (w != p); + MM_OP_m (_mm_aesdec_si128, w[1]); + MM_OP_m (_mm_aesdeclast_si128, w[0]); + + MM_XOR (m, iv); + iv = *data; + *data = m; + } + + p[-2] = iv; +} + + +/* +SSE2: _mm_cvtsi32_si128 : movd +AVX: _mm256_setr_m128i : vinsertf128 +AVX2: _mm256_add_epi64 : vpaddq ymm, ymm, ymm + _mm256_extracti128_si256 : vextracti128 + _mm256_broadcastsi128_si256 : vbroadcasti128 +*/ + +#define AVX__CTR_LOOP_START \ + ctr2 = _mm256_setr_m128i(_mm_sub_epi64(ctr, one), ctr); \ + two = _mm256_setr_m128i(one, one); \ + two = _mm256_add_epi64(two, two); \ + +// two = _mm256_setr_epi64x(2, 0, 2, 0); + +#define AVX__CTR_LOOP_ENC \ + ctr = _mm256_extracti128_si256 (ctr2, 1); \ + +VAES_FUNC_START2 (AesCtr_Code_HW_256) +{ + __m128i ctr = *p; + UInt32 numRounds = *(const UInt32 *)(p + 1) * 2 + 1; + const __m128i *dataEnd; + __m128i one = _mm_cvtsi32_si128(1); + __m256i ctr2, two; + p += 2; + + WIDE_LOOP_START_AVX (AVX__CTR_LOOP_START) + { + const __m256i *w = keys; + UInt32 r = numRounds - 2; + WOP (AVX__DECLARE_VAR) + AVX__WOP_KEY (AVX__CTR_START, 0); + + w += 1; + do + { + AVX__WOP_KEY (AVX__AES_ENC, 0) + w += 1; + } + while (--r); + AVX__WOP_KEY (AVX__AES_ENC_LAST, 0) + + WOP (AVX__CTR_END); + } + WIDE_LOOP_END_AVX (AVX__CTR_LOOP_ENC) + + SINGLE_LOOP + { + UInt32 numRounds2 = *(const UInt32 *)(p - 2 + 1) - 1; + const __m128i *w = p; + __m128i m; + MM_OP (_mm_add_epi64, ctr, one); + m = _mm_xor_si128 (ctr, p[0]); + w += 1; + do + { + MM_OP_m (_mm_aesenc_si128, w[0]); + MM_OP_m (_mm_aesenc_si128, w[1]); + w += 2; + } + while (--numRounds2); + MM_OP_m (_mm_aesenc_si128, w[0]); + MM_OP_m (_mm_aesenclast_si128, w[1]); + MM_XOR (*data, m); + } + + p[-2] = ctr; +} + +#endif // USE_INTEL_VAES + +#else // USE_INTEL_AES + +/* no USE_INTEL_AES */ + +#pragma message("AES HW_SW stub was used") + +#define AES_TYPE_keys UInt32 +#define AES_TYPE_data Byte + +#define AES_FUNC_START(name) \ + void MY_FAST_CALL name(UInt32 *p, Byte *data, size_t numBlocks) \ + +#define AES_COMPAT_STUB(name) \ + AES_FUNC_START(name); \ + AES_FUNC_START(name ## _HW) \ + { name(p, data, numBlocks); } + +AES_COMPAT_STUB (AesCbc_Encode) +AES_COMPAT_STUB (AesCbc_Decode) +AES_COMPAT_STUB (AesCtr_Code) + +#endif // USE_INTEL_AES + + +#ifndef USE_INTEL_VAES + +#pragma message("VAES HW_SW stub was used") + +#define VAES_COMPAT_STUB(name) \ + void MY_FAST_CALL name ## _256(UInt32 *p, Byte *data, size_t numBlocks); \ + void MY_FAST_CALL name ## _256(UInt32 *p, Byte *data, size_t numBlocks) \ + { name((AES_TYPE_keys *)(void *)p, (AES_TYPE_data *)(void *)data, numBlocks); } + +VAES_COMPAT_STUB (AesCbc_Decode_HW) +VAES_COMPAT_STUB (AesCtr_Code_HW) + +#endif // ! USE_INTEL_VAES + + +#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE) + + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define USE_HW_AES + #endif + #elif defined(__GNUC__) + #if (__GNUC__ >= 6) // fix that check + #define USE_HW_AES + #endif + #elif defined(_MSC_VER) + #if _MSC_VER >= 1910 + #define USE_HW_AES + #endif + #endif + +#ifdef USE_HW_AES + +// #pragma message("=== AES HW === ") + +#if defined(__clang__) || defined(__GNUC__) + #ifdef MY_CPU_ARM64 + #define ATTRIB_AES __attribute__((__target__("+crypto"))) + #else + #define ATTRIB_AES __attribute__((__target__("fpu=crypto-neon-fp-armv8"))) + #endif +#else + // _MSC_VER + // for arm32 + #define _ARM_USE_NEW_NEON_INTRINSICS +#endif + +#ifndef ATTRIB_AES + #define ATTRIB_AES +#endif + +#if defined(_MSC_VER) && defined(MY_CPU_ARM64) +#include +#else +#include +#endif + +typedef uint8x16_t v128; + +#define AES_FUNC_START(name) \ + void MY_FAST_CALL name(v128 *p, v128 *data, size_t numBlocks) + +#define AES_FUNC_START2(name) \ +AES_FUNC_START (name); \ +ATTRIB_AES \ +AES_FUNC_START (name) + +#define MM_OP(op, dest, src) dest = op(dest, src); +#define MM_OP_m(op, src) MM_OP(op, m, src); +#define MM_OP1_m(op) m = op(m); + +#define MM_XOR( dest, src) MM_OP(veorq_u8, dest, src); +#define MM_XOR_m( src) MM_XOR(m, src); + +#define AES_E_m(k) MM_OP_m (vaeseq_u8, k); +#define AES_E_MC_m(k) AES_E_m (k); MM_OP1_m(vaesmcq_u8); + + +AES_FUNC_START2 (AesCbc_Encode_HW) +{ + v128 m = *p; + const v128 k0 = p[2]; + const v128 k1 = p[3]; + const v128 k2 = p[4]; + const v128 k3 = p[5]; + const v128 k4 = p[6]; + const v128 k5 = p[7]; + const v128 k6 = p[8]; + const v128 k7 = p[9]; + const v128 k8 = p[10]; + const v128 k9 = p[11]; + const UInt32 numRounds2 = *(const UInt32 *)(p + 1); + const v128 *w = p + ((size_t)numRounds2 * 2); + const v128 k_z1 = w[1]; + const v128 k_z0 = w[2]; + for (; numBlocks != 0; numBlocks--, data++) + { + MM_XOR_m (*data); + AES_E_MC_m (k0) + AES_E_MC_m (k1) + AES_E_MC_m (k2) + AES_E_MC_m (k3) + AES_E_MC_m (k4) + AES_E_MC_m (k5) + AES_E_MC_m (k6) + AES_E_MC_m (k7) + AES_E_MC_m (k8) + if (numRounds2 >= 6) + { + AES_E_MC_m (k9) + AES_E_MC_m (p[12]) + if (numRounds2 != 6) + { + AES_E_MC_m (p[13]) + AES_E_MC_m (p[14]) + } + } + AES_E_m (k_z1); + MM_XOR_m (k_z0); + *data = m; + } + *p = m; +} + + +#define WOP_1(op) +#define WOP_2(op) WOP_1 (op) op (m1, 1); +#define WOP_3(op) WOP_2 (op) op (m2, 2); +#define WOP_4(op) WOP_3 (op) op (m3, 3); +#define WOP_5(op) WOP_4 (op) op (m4, 4); +#define WOP_6(op) WOP_5 (op) op (m5, 5); +#define WOP_7(op) WOP_6 (op) op (m6, 6); +#define WOP_8(op) WOP_7 (op) op (m7, 7); + + #define NUM_WAYS 8 + #define WOP_M1 WOP_8 + +#define WOP(op) op (m0, 0); WOP_M1(op) + +#define DECLARE_VAR(reg, ii) v128 reg +#define LOAD_data( reg, ii) reg = data[ii]; +#define STORE_data( reg, ii) data[ii] = reg; +#if (NUM_WAYS > 1) +#define XOR_data_M1(reg, ii) MM_XOR (reg, data[ii- 1]); +#endif + +#define MM_OP_key(op, reg) MM_OP (op, reg, key); + +#define AES_D_m(k) MM_OP_m (vaesdq_u8, k); +#define AES_D_IMC_m(k) AES_D_m (k); MM_OP1_m (vaesimcq_u8); + +#define AES_XOR( reg, ii) MM_OP_key (veorq_u8, reg) +#define AES_D( reg, ii) MM_OP_key (vaesdq_u8, reg) +#define AES_E( reg, ii) MM_OP_key (vaeseq_u8, reg) + +#define AES_D_IMC( reg, ii) AES_D (reg, ii); reg = vaesimcq_u8(reg) +#define AES_E_MC( reg, ii) AES_E (reg, ii); reg = vaesmcq_u8(reg) + +#define CTR_START(reg, ii) MM_OP (vaddq_u64, ctr, one); reg = vreinterpretq_u8_u64(ctr); +#define CTR_END( reg, ii) MM_XOR (data[ii], reg); + +#define WOP_KEY(op, n) { \ + const v128 key = w[n]; \ + WOP(op); } + +#define WIDE_LOOP_START \ + dataEnd = data + numBlocks; \ + if (numBlocks >= NUM_WAYS) \ + { dataEnd -= NUM_WAYS; do { \ + +#define WIDE_LOOP_END \ + data += NUM_WAYS; \ + } while (data <= dataEnd); \ + dataEnd += NUM_WAYS; } \ + +#define SINGLE_LOOP \ + for (; data < dataEnd; data++) + + +AES_FUNC_START2 (AesCbc_Decode_HW) +{ + v128 iv = *p; + const v128 *wStart = p + ((size_t)*(const UInt32 *)(p + 1)) * 2; + const v128 *dataEnd; + p += 2; + + WIDE_LOOP_START + { + const v128 *w = wStart; + WOP (DECLARE_VAR) + WOP (LOAD_data); + WOP_KEY (AES_D_IMC, 2) + do + { + WOP_KEY (AES_D_IMC, 1) + WOP_KEY (AES_D_IMC, 0) + w -= 2; + } + while (w != p); + WOP_KEY (AES_D, 1) + WOP_KEY (AES_XOR, 0) + MM_XOR (m0, iv); + WOP_M1 (XOR_data_M1) + iv = data[NUM_WAYS - 1]; + WOP (STORE_data); + } + WIDE_LOOP_END + + SINGLE_LOOP + { + const v128 *w = wStart; + v128 m = *data; + AES_D_IMC_m (w[2]) + do + { + AES_D_IMC_m (w[1]); + AES_D_IMC_m (w[0]); + w -= 2; + } + while (w != p); + AES_D_m (w[1]); + MM_XOR_m (w[0]); + MM_XOR_m (iv); + iv = *data; + *data = m; + } + + p[-2] = iv; +} + + +AES_FUNC_START2 (AesCtr_Code_HW) +{ + uint64x2_t ctr = vreinterpretq_u64_u8(*p); + const v128 *wEnd = p + ((size_t)*(const UInt32 *)(p + 1)) * 2; + const v128 *dataEnd; + uint64x2_t one = vdupq_n_u64(0); + one = vsetq_lane_u64(1, one, 0); + p += 2; + + WIDE_LOOP_START + { + const v128 *w = p; + WOP (DECLARE_VAR) + WOP (CTR_START); + do + { + WOP_KEY (AES_E_MC, 0) + WOP_KEY (AES_E_MC, 1) + w += 2; + } + while (w != wEnd); + WOP_KEY (AES_E_MC, 0) + WOP_KEY (AES_E, 1) + WOP_KEY (AES_XOR, 2) + WOP (CTR_END); + } + WIDE_LOOP_END + + SINGLE_LOOP + { + const v128 *w = p; + v128 m; + CTR_START (m, 0); + do + { + AES_E_MC_m (w[0]); + AES_E_MC_m (w[1]); + w += 2; + } + while (w != wEnd); + AES_E_MC_m (w[0]); + AES_E_m (w[1]); + MM_XOR_m (w[2]); + CTR_END (m, 0); + } + + p[-2] = vreinterpretq_u8_u64(ctr); +} + +#endif // USE_HW_AES + +#endif // MY_CPU_ARM_OR_ARM64 diff --git a/deps/LZMA-SDK/C/Alloc.c b/deps/LZMA-SDK/C/Alloc.c index 064701a8c..242ae3d4f 100644 --- a/deps/LZMA-SDK/C/Alloc.c +++ b/deps/LZMA-SDK/C/Alloc.c @@ -1,463 +1,463 @@ -/* Alloc.c -- Memory allocation functions -2020-10-29 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#ifdef _WIN32 -#include -#endif -#include - -#include "Alloc.h" - -/* #define _SZ_ALLOC_DEBUG */ - -/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ -#ifdef _SZ_ALLOC_DEBUG - -#include -int g_allocCount = 0; -int g_allocCountMid = 0; -int g_allocCountBig = 0; - - -#define CONVERT_INT_TO_STR(charType, tempSize) \ - unsigned char temp[tempSize]; unsigned i = 0; \ - while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \ - *s++ = (charType)('0' + (unsigned)val); \ - while (i != 0) { i--; *s++ = temp[i]; } \ - *s = 0; - -static void ConvertUInt64ToString(UInt64 val, char *s) -{ - CONVERT_INT_TO_STR(char, 24); -} - -#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))))) - -static void ConvertUInt64ToHex(UInt64 val, char *s) -{ - UInt64 v = val; - unsigned i; - for (i = 1;; i++) - { - v >>= 4; - if (v == 0) - break; - } - s[i] = 0; - do - { - unsigned t = (unsigned)(val & 0xF); - val >>= 4; - s[--i] = GET_HEX_CHAR(t); - } - while (i); -} - -#define DEBUG_OUT_STREAM stderr - -static void Print(const char *s) -{ - fputs(s, DEBUG_OUT_STREAM); -} - -static void PrintAligned(const char *s, size_t align) -{ - size_t len = strlen(s); - for(;;) - { - fputc(' ', DEBUG_OUT_STREAM); - if (len >= align) - break; - ++len; - } - Print(s); -} - -static void PrintLn() -{ - Print("\n"); -} - -static void PrintHex(UInt64 v, size_t align) -{ - char s[32]; - ConvertUInt64ToHex(v, s); - PrintAligned(s, align); -} - -static void PrintDec(UInt64 v, size_t align) -{ - char s[32]; - ConvertUInt64ToString(v, s); - PrintAligned(s, align); -} - -static void PrintAddr(void *p) -{ - PrintHex((UInt64)(size_t)(ptrdiff_t)p, 12); -} - - -#define PRINT_ALLOC(name, cnt, size, ptr) \ - Print(name " "); \ - PrintDec(cnt++, 10); \ - PrintHex(size, 10); \ - PrintAddr(ptr); \ - PrintLn(); - -#define PRINT_FREE(name, cnt, ptr) if (ptr) { \ - Print(name " "); \ - PrintDec(--cnt, 10); \ - PrintAddr(ptr); \ - PrintLn(); } - -#else - -#define PRINT_ALLOC(name, cnt, size, ptr) -#define PRINT_FREE(name, cnt, ptr) -#define Print(s) -#define PrintLn() -#define PrintHex(v, align) -#define PrintAddr(p) - -#endif - - - -void *MyAlloc(size_t size) -{ - if (size == 0) - return NULL; - PRINT_ALLOC("Alloc ", g_allocCount, size, NULL); - #ifdef _SZ_ALLOC_DEBUG - { - void *p = malloc(size); - // PRINT_ALLOC("Alloc ", g_allocCount, size, p); - return p; - } - #else - return malloc(size); - #endif -} - -void MyFree(void *address) -{ - PRINT_FREE("Free ", g_allocCount, address); - - free(address); -} - -#ifdef _WIN32 - -void *MidAlloc(size_t size) -{ - if (size == 0) - return NULL; - - PRINT_ALLOC("Alloc-Mid", g_allocCountMid, size, NULL); - - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); -} - -void MidFree(void *address) -{ - PRINT_FREE("Free-Mid", g_allocCountMid, address); - - if (!address) - return; - VirtualFree(address, 0, MEM_RELEASE); -} - -#ifdef _7ZIP_LARGE_PAGES - -#ifdef MEM_LARGE_PAGES - #define MY__MEM_LARGE_PAGES MEM_LARGE_PAGES -#else - #define MY__MEM_LARGE_PAGES 0x20000000 -#endif - -extern -SIZE_T g_LargePageSize; -SIZE_T g_LargePageSize = 0; -typedef SIZE_T (WINAPI *GetLargePageMinimumP)(VOID); - -#endif // _7ZIP_LARGE_PAGES - -void SetLargePageSize() -{ - #ifdef _7ZIP_LARGE_PAGES - SIZE_T size; - GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) - GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); - if (!largePageMinimum) - return; - size = largePageMinimum(); - if (size == 0 || (size & (size - 1)) != 0) - return; - g_LargePageSize = size; - #endif -} - - -void *BigAlloc(size_t size) -{ - if (size == 0) - return NULL; - - PRINT_ALLOC("Alloc-Big", g_allocCountBig, size, NULL); - - #ifdef _7ZIP_LARGE_PAGES - { - SIZE_T ps = g_LargePageSize; - if (ps != 0 && ps <= (1 << 30) && size > (ps / 2)) - { - size_t size2; - ps--; - size2 = (size + ps) & ~ps; - if (size2 >= size) - { - void *res = VirtualAlloc(NULL, size2, MEM_COMMIT | MY__MEM_LARGE_PAGES, PAGE_READWRITE); - if (res) - return res; - } - } - } - #endif - - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); -} - -void BigFree(void *address) -{ - PRINT_FREE("Free-Big", g_allocCountBig, address); - - if (!address) - return; - VirtualFree(address, 0, MEM_RELEASE); -} - -#endif - - -static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); } -static void SzFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MyFree(address); } -const ISzAlloc g_Alloc = { SzAlloc, SzFree }; - -static void *SzMidAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MidAlloc(size); } -static void SzMidFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MidFree(address); } -const ISzAlloc g_MidAlloc = { SzMidAlloc, SzMidFree }; - -static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); } -static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); BigFree(address); } -const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; - - -/* - uintptr_t : C99 (optional) - : unsupported in VS6 -*/ - -#ifdef _WIN32 - typedef UINT_PTR UIntPtr; -#else - /* - typedef uintptr_t UIntPtr; - */ - typedef ptrdiff_t UIntPtr; -#endif - - -#define ADJUST_ALLOC_SIZE 0 -/* -#define ADJUST_ALLOC_SIZE (sizeof(void *) - 1) -*/ -/* - Use (ADJUST_ALLOC_SIZE = (sizeof(void *) - 1)), if - MyAlloc() can return address that is NOT multiple of sizeof(void *). -*/ - - -/* -#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((char *)(p) - ((size_t)(UIntPtr)(p) & ((align) - 1)))) -*/ -#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((((UIntPtr)(p)) & ~((UIntPtr)(align) - 1)))) - - -#if !defined(_WIN32) && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) - #define USE_posix_memalign -#endif - -#ifndef USE_posix_memalign -#define MY_ALIGN_PTR_UP_PLUS(p, align) MY_ALIGN_PTR_DOWN(((char *)(p) + (align) + ADJUST_ALLOC_SIZE), align) -#endif - -/* - This posix_memalign() is for test purposes only. - We also need special Free() function instead of free(), - if this posix_memalign() is used. -*/ - -/* -static int posix_memalign(void **ptr, size_t align, size_t size) -{ - size_t newSize = size + align; - void *p; - void *pAligned; - *ptr = NULL; - if (newSize < size) - return 12; // ENOMEM - p = MyAlloc(newSize); - if (!p) - return 12; // ENOMEM - pAligned = MY_ALIGN_PTR_UP_PLUS(p, align); - ((void **)pAligned)[-1] = p; - *ptr = pAligned; - return 0; -} -*/ - -/* - ALLOC_ALIGN_SIZE >= sizeof(void *) - ALLOC_ALIGN_SIZE >= cache_line_size -*/ - -#define ALLOC_ALIGN_SIZE ((size_t)1 << 7) - -static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size) -{ - #ifndef USE_posix_memalign - - void *p; - void *pAligned; - size_t newSize; - UNUSED_VAR(pp); - - /* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned - block to prevent cache line sharing with another allocated blocks */ - - newSize = size + ALLOC_ALIGN_SIZE * 1 + ADJUST_ALLOC_SIZE; - if (newSize < size) - return NULL; - - p = MyAlloc(newSize); - - if (!p) - return NULL; - pAligned = MY_ALIGN_PTR_UP_PLUS(p, ALLOC_ALIGN_SIZE); - - Print(" size="); PrintHex(size, 8); - Print(" a_size="); PrintHex(newSize, 8); - Print(" ptr="); PrintAddr(p); - Print(" a_ptr="); PrintAddr(pAligned); - PrintLn(); - - ((void **)pAligned)[-1] = p; - - return pAligned; - - #else - - void *p; - UNUSED_VAR(pp); - if (posix_memalign(&p, ALLOC_ALIGN_SIZE, size)) - return NULL; - - Print(" posix_memalign="); PrintAddr(p); - PrintLn(); - - return p; - - #endif -} - - -static void SzAlignedFree(ISzAllocPtr pp, void *address) -{ - UNUSED_VAR(pp); - #ifndef USE_posix_memalign - if (address) - MyFree(((void **)address)[-1]); - #else - free(address); - #endif -} - - -const ISzAlloc g_AlignedAlloc = { SzAlignedAlloc, SzAlignedFree }; - - - -#define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *)) - -/* we align ptr to support cases where CAlignOffsetAlloc::offset is not multiply of sizeof(void *) */ -#define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1] -/* -#define REAL_BLOCK_PTR_VAR(p) ((void **)(p))[-1] -*/ - -static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size) -{ - CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt); - void *adr; - void *pAligned; - size_t newSize; - size_t extra; - size_t alignSize = (size_t)1 << p->numAlignBits; - - if (alignSize < sizeof(void *)) - alignSize = sizeof(void *); - - if (p->offset >= alignSize) - return NULL; - - /* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned - block to prevent cache line sharing with another allocated blocks */ - extra = p->offset & (sizeof(void *) - 1); - newSize = size + alignSize + extra + ADJUST_ALLOC_SIZE; - if (newSize < size) - return NULL; - - adr = ISzAlloc_Alloc(p->baseAlloc, newSize); - - if (!adr) - return NULL; - - pAligned = (char *)MY_ALIGN_PTR_DOWN((char *)adr + - alignSize - p->offset + extra + ADJUST_ALLOC_SIZE, alignSize) + p->offset; - - PrintLn(); - Print("- Aligned: "); - Print(" size="); PrintHex(size, 8); - Print(" a_size="); PrintHex(newSize, 8); - Print(" ptr="); PrintAddr(adr); - Print(" a_ptr="); PrintAddr(pAligned); - PrintLn(); - - REAL_BLOCK_PTR_VAR(pAligned) = adr; - - return pAligned; -} - - -static void AlignOffsetAlloc_Free(ISzAllocPtr pp, void *address) -{ - if (address) - { - CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt); - PrintLn(); - Print("- Aligned Free: "); - PrintLn(); - ISzAlloc_Free(p->baseAlloc, REAL_BLOCK_PTR_VAR(address)); - } -} - - -void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p) -{ - p->vt.Alloc = AlignOffsetAlloc_Alloc; - p->vt.Free = AlignOffsetAlloc_Free; -} +/* Alloc.c -- Memory allocation functions +2021-07-13 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#ifdef _WIN32 +#include +#endif +#include + +#include "Alloc.h" + +/* #define _SZ_ALLOC_DEBUG */ + +/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ +#ifdef _SZ_ALLOC_DEBUG + +#include +int g_allocCount = 0; +int g_allocCountMid = 0; +int g_allocCountBig = 0; + + +#define CONVERT_INT_TO_STR(charType, tempSize) \ + unsigned char temp[tempSize]; unsigned i = 0; \ + while (val >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(val % 10)); val /= 10; } \ + *s++ = (charType)('0' + (unsigned)val); \ + while (i != 0) { i--; *s++ = temp[i]; } \ + *s = 0; + +static void ConvertUInt64ToString(UInt64 val, char *s) +{ + CONVERT_INT_TO_STR(char, 24); +} + +#define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))))) + +static void ConvertUInt64ToHex(UInt64 val, char *s) +{ + UInt64 v = val; + unsigned i; + for (i = 1;; i++) + { + v >>= 4; + if (v == 0) + break; + } + s[i] = 0; + do + { + unsigned t = (unsigned)(val & 0xF); + val >>= 4; + s[--i] = GET_HEX_CHAR(t); + } + while (i); +} + +#define DEBUG_OUT_STREAM stderr + +static void Print(const char *s) +{ + fputs(s, DEBUG_OUT_STREAM); +} + +static void PrintAligned(const char *s, size_t align) +{ + size_t len = strlen(s); + for(;;) + { + fputc(' ', DEBUG_OUT_STREAM); + if (len >= align) + break; + ++len; + } + Print(s); +} + +static void PrintLn() +{ + Print("\n"); +} + +static void PrintHex(UInt64 v, size_t align) +{ + char s[32]; + ConvertUInt64ToHex(v, s); + PrintAligned(s, align); +} + +static void PrintDec(UInt64 v, size_t align) +{ + char s[32]; + ConvertUInt64ToString(v, s); + PrintAligned(s, align); +} + +static void PrintAddr(void *p) +{ + PrintHex((UInt64)(size_t)(ptrdiff_t)p, 12); +} + + +#define PRINT_ALLOC(name, cnt, size, ptr) \ + Print(name " "); \ + PrintDec(cnt++, 10); \ + PrintHex(size, 10); \ + PrintAddr(ptr); \ + PrintLn(); + +#define PRINT_FREE(name, cnt, ptr) if (ptr) { \ + Print(name " "); \ + PrintDec(--cnt, 10); \ + PrintAddr(ptr); \ + PrintLn(); } + +#else + +#define PRINT_ALLOC(name, cnt, size, ptr) +#define PRINT_FREE(name, cnt, ptr) +#define Print(s) +#define PrintLn() +#define PrintHex(v, align) +#define PrintAddr(p) + +#endif + + + +void *MyAlloc(size_t size) +{ + if (size == 0) + return NULL; + PRINT_ALLOC("Alloc ", g_allocCount, size, NULL); + #ifdef _SZ_ALLOC_DEBUG + { + void *p = malloc(size); + // PRINT_ALLOC("Alloc ", g_allocCount, size, p); + return p; + } + #else + return malloc(size); + #endif +} + +void MyFree(void *address) +{ + PRINT_FREE("Free ", g_allocCount, address); + + free(address); +} + +#ifdef _WIN32 + +void *MidAlloc(size_t size) +{ + if (size == 0) + return NULL; + + PRINT_ALLOC("Alloc-Mid", g_allocCountMid, size, NULL); + + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); +} + +void MidFree(void *address) +{ + PRINT_FREE("Free-Mid", g_allocCountMid, address); + + if (!address) + return; + VirtualFree(address, 0, MEM_RELEASE); +} + +#ifdef _7ZIP_LARGE_PAGES + +#ifdef MEM_LARGE_PAGES + #define MY__MEM_LARGE_PAGES MEM_LARGE_PAGES +#else + #define MY__MEM_LARGE_PAGES 0x20000000 +#endif + +extern +SIZE_T g_LargePageSize; +SIZE_T g_LargePageSize = 0; +typedef SIZE_T (WINAPI *GetLargePageMinimumP)(VOID); + +#endif // _7ZIP_LARGE_PAGES + +void SetLargePageSize() +{ + #ifdef _7ZIP_LARGE_PAGES + SIZE_T size; + GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) + GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); + if (!largePageMinimum) + return; + size = largePageMinimum(); + if (size == 0 || (size & (size - 1)) != 0) + return; + g_LargePageSize = size; + #endif +} + + +void *BigAlloc(size_t size) +{ + if (size == 0) + return NULL; + + PRINT_ALLOC("Alloc-Big", g_allocCountBig, size, NULL); + + #ifdef _7ZIP_LARGE_PAGES + { + SIZE_T ps = g_LargePageSize; + if (ps != 0 && ps <= (1 << 30) && size > (ps / 2)) + { + size_t size2; + ps--; + size2 = (size + ps) & ~ps; + if (size2 >= size) + { + void *res = VirtualAlloc(NULL, size2, MEM_COMMIT | MY__MEM_LARGE_PAGES, PAGE_READWRITE); + if (res) + return res; + } + } + } + #endif + + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); +} + +void BigFree(void *address) +{ + PRINT_FREE("Free-Big", g_allocCountBig, address); + + if (!address) + return; + VirtualFree(address, 0, MEM_RELEASE); +} + +#endif + + +static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); } +static void SzFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MyFree(address); } +const ISzAlloc g_Alloc = { SzAlloc, SzFree }; + +#ifdef _WIN32 +static void *SzMidAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MidAlloc(size); } +static void SzMidFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); MidFree(address); } +static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return BigAlloc(size); } +static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p); BigFree(address); } +const ISzAlloc g_MidAlloc = { SzMidAlloc, SzMidFree }; +const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; +#endif + +/* + uintptr_t : C99 (optional) + : unsupported in VS6 +*/ + +#ifdef _WIN32 + typedef UINT_PTR UIntPtr; +#else + /* + typedef uintptr_t UIntPtr; + */ + typedef ptrdiff_t UIntPtr; +#endif + + +#define ADJUST_ALLOC_SIZE 0 +/* +#define ADJUST_ALLOC_SIZE (sizeof(void *) - 1) +*/ +/* + Use (ADJUST_ALLOC_SIZE = (sizeof(void *) - 1)), if + MyAlloc() can return address that is NOT multiple of sizeof(void *). +*/ + + +/* +#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((char *)(p) - ((size_t)(UIntPtr)(p) & ((align) - 1)))) +*/ +#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((((UIntPtr)(p)) & ~((UIntPtr)(align) - 1)))) + + +#if !defined(_WIN32) && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) + #define USE_posix_memalign +#endif + +#ifndef USE_posix_memalign +#define MY_ALIGN_PTR_UP_PLUS(p, align) MY_ALIGN_PTR_DOWN(((char *)(p) + (align) + ADJUST_ALLOC_SIZE), align) +#endif + +/* + This posix_memalign() is for test purposes only. + We also need special Free() function instead of free(), + if this posix_memalign() is used. +*/ + +/* +static int posix_memalign(void **ptr, size_t align, size_t size) +{ + size_t newSize = size + align; + void *p; + void *pAligned; + *ptr = NULL; + if (newSize < size) + return 12; // ENOMEM + p = MyAlloc(newSize); + if (!p) + return 12; // ENOMEM + pAligned = MY_ALIGN_PTR_UP_PLUS(p, align); + ((void **)pAligned)[-1] = p; + *ptr = pAligned; + return 0; +} +*/ + +/* + ALLOC_ALIGN_SIZE >= sizeof(void *) + ALLOC_ALIGN_SIZE >= cache_line_size +*/ + +#define ALLOC_ALIGN_SIZE ((size_t)1 << 7) + +static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size) +{ + #ifndef USE_posix_memalign + + void *p; + void *pAligned; + size_t newSize; + UNUSED_VAR(pp); + + /* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned + block to prevent cache line sharing with another allocated blocks */ + + newSize = size + ALLOC_ALIGN_SIZE * 1 + ADJUST_ALLOC_SIZE; + if (newSize < size) + return NULL; + + p = MyAlloc(newSize); + + if (!p) + return NULL; + pAligned = MY_ALIGN_PTR_UP_PLUS(p, ALLOC_ALIGN_SIZE); + + Print(" size="); PrintHex(size, 8); + Print(" a_size="); PrintHex(newSize, 8); + Print(" ptr="); PrintAddr(p); + Print(" a_ptr="); PrintAddr(pAligned); + PrintLn(); + + ((void **)pAligned)[-1] = p; + + return pAligned; + + #else + + void *p; + UNUSED_VAR(pp); + if (posix_memalign(&p, ALLOC_ALIGN_SIZE, size)) + return NULL; + + Print(" posix_memalign="); PrintAddr(p); + PrintLn(); + + return p; + + #endif +} + + +static void SzAlignedFree(ISzAllocPtr pp, void *address) +{ + UNUSED_VAR(pp); + #ifndef USE_posix_memalign + if (address) + MyFree(((void **)address)[-1]); + #else + free(address); + #endif +} + + +const ISzAlloc g_AlignedAlloc = { SzAlignedAlloc, SzAlignedFree }; + + + +#define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *)) + +/* we align ptr to support cases where CAlignOffsetAlloc::offset is not multiply of sizeof(void *) */ +#define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1] +/* +#define REAL_BLOCK_PTR_VAR(p) ((void **)(p))[-1] +*/ + +static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size) +{ + CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt); + void *adr; + void *pAligned; + size_t newSize; + size_t extra; + size_t alignSize = (size_t)1 << p->numAlignBits; + + if (alignSize < sizeof(void *)) + alignSize = sizeof(void *); + + if (p->offset >= alignSize) + return NULL; + + /* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned + block to prevent cache line sharing with another allocated blocks */ + extra = p->offset & (sizeof(void *) - 1); + newSize = size + alignSize + extra + ADJUST_ALLOC_SIZE; + if (newSize < size) + return NULL; + + adr = ISzAlloc_Alloc(p->baseAlloc, newSize); + + if (!adr) + return NULL; + + pAligned = (char *)MY_ALIGN_PTR_DOWN((char *)adr + + alignSize - p->offset + extra + ADJUST_ALLOC_SIZE, alignSize) + p->offset; + + PrintLn(); + Print("- Aligned: "); + Print(" size="); PrintHex(size, 8); + Print(" a_size="); PrintHex(newSize, 8); + Print(" ptr="); PrintAddr(adr); + Print(" a_ptr="); PrintAddr(pAligned); + PrintLn(); + + REAL_BLOCK_PTR_VAR(pAligned) = adr; + + return pAligned; +} + + +static void AlignOffsetAlloc_Free(ISzAllocPtr pp, void *address) +{ + if (address) + { + CAlignOffsetAlloc *p = CONTAINER_FROM_VTBL(pp, CAlignOffsetAlloc, vt); + PrintLn(); + Print("- Aligned Free: "); + PrintLn(); + ISzAlloc_Free(p->baseAlloc, REAL_BLOCK_PTR_VAR(address)); + } +} + + +void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p) +{ + p->vt.Alloc = AlignOffsetAlloc_Alloc; + p->vt.Free = AlignOffsetAlloc_Free; +} diff --git a/deps/LZMA-SDK/C/Alloc.h b/deps/LZMA-SDK/C/Alloc.h index a1bbe942c..3be2041eb 100644 --- a/deps/LZMA-SDK/C/Alloc.h +++ b/deps/LZMA-SDK/C/Alloc.h @@ -1,51 +1,58 @@ -/* Alloc.h -- Memory allocation functions -2021-02-08 : Igor Pavlov : Public domain */ - -#ifndef __COMMON_ALLOC_H -#define __COMMON_ALLOC_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -void *MyAlloc(size_t size); -void MyFree(void *address); - -#ifdef _WIN32 - -void SetLargePageSize(void); - -void *MidAlloc(size_t size); -void MidFree(void *address); -void *BigAlloc(size_t size); -void BigFree(void *address); - -#else - -#define MidAlloc(size) MyAlloc(size) -#define MidFree(address) MyFree(address) -#define BigAlloc(size) MyAlloc(size) -#define BigFree(address) MyFree(address) - -#endif - -extern const ISzAlloc g_Alloc; -extern const ISzAlloc g_BigAlloc; -extern const ISzAlloc g_MidAlloc; -extern const ISzAlloc g_AlignedAlloc; - - -typedef struct -{ - ISzAlloc vt; - ISzAllocPtr baseAlloc; - unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */ - size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */ -} CAlignOffsetAlloc; - -void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p); - - -EXTERN_C_END - -#endif +/* Alloc.h -- Memory allocation functions +2021-07-13 : Igor Pavlov : Public domain */ + +#ifndef __COMMON_ALLOC_H +#define __COMMON_ALLOC_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +void *MyAlloc(size_t size); +void MyFree(void *address); + +#ifdef _WIN32 + +void SetLargePageSize(void); + +void *MidAlloc(size_t size); +void MidFree(void *address); +void *BigAlloc(size_t size); +void BigFree(void *address); + +#else + +#define MidAlloc(size) MyAlloc(size) +#define MidFree(address) MyFree(address) +#define BigAlloc(size) MyAlloc(size) +#define BigFree(address) MyFree(address) + +#endif + +extern const ISzAlloc g_Alloc; + +#ifdef _WIN32 +extern const ISzAlloc g_BigAlloc; +extern const ISzAlloc g_MidAlloc; +#else +#define g_BigAlloc g_AlignedAlloc +#define g_MidAlloc g_AlignedAlloc +#endif + +extern const ISzAlloc g_AlignedAlloc; + + +typedef struct +{ + ISzAlloc vt; + ISzAllocPtr baseAlloc; + unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */ + size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */ +} CAlignOffsetAlloc; + +void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p); + + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Bcj2.c b/deps/LZMA-SDK/C/Bcj2.c index c1772f234..c7b956708 100644 --- a/deps/LZMA-SDK/C/Bcj2.c +++ b/deps/LZMA-SDK/C/Bcj2.c @@ -1,257 +1,257 @@ -/* Bcj2.c -- BCJ2 Decoder (Converter for x86 code) -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "Bcj2.h" -#include "CpuArch.h" - -#define CProb UInt16 - -#define kTopValue ((UInt32)1 << 24) -#define kNumModelBits 11 -#define kBitModelTotal (1 << kNumModelBits) -#define kNumMoveBits 5 - -#define _IF_BIT_0 ttt = *prob; bound = (p->range >> kNumModelBits) * ttt; if (p->code < bound) -#define _UPDATE_0 p->range = bound; *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define _UPDATE_1 p->range -= bound; p->code -= bound; *prob = (CProb)(ttt - (ttt >> kNumMoveBits)); - -void Bcj2Dec_Init(CBcj2Dec *p) -{ - unsigned i; - - p->state = BCJ2_DEC_STATE_OK; - p->ip = 0; - p->temp[3] = 0; - p->range = 0; - p->code = 0; - for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++) - p->probs[i] = kBitModelTotal >> 1; -} - -SRes Bcj2Dec_Decode(CBcj2Dec *p) -{ - if (p->range <= 5) - { - p->state = BCJ2_DEC_STATE_OK; - for (; p->range != 5; p->range++) - { - if (p->range == 1 && p->code != 0) - return SZ_ERROR_DATA; - - if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC]) - { - p->state = BCJ2_STREAM_RC; - return SZ_OK; - } - - p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; - } - - if (p->code == 0xFFFFFFFF) - return SZ_ERROR_DATA; - - p->range = 0xFFFFFFFF; - } - else if (p->state >= BCJ2_DEC_STATE_ORIG_0) - { - while (p->state <= BCJ2_DEC_STATE_ORIG_3) - { - Byte *dest = p->dest; - if (dest == p->destLim) - return SZ_OK; - *dest = p->temp[(size_t)p->state - BCJ2_DEC_STATE_ORIG_0]; - p->state++; - p->dest = dest + 1; - } - } - - /* - if (BCJ2_IS_32BIT_STREAM(p->state)) - { - const Byte *cur = p->bufs[p->state]; - if (cur == p->lims[p->state]) - return SZ_OK; - p->bufs[p->state] = cur + 4; - - { - UInt32 val; - Byte *dest; - SizeT rem; - - p->ip += 4; - val = GetBe32(cur) - p->ip; - dest = p->dest; - rem = p->destLim - dest; - if (rem < 4) - { - SizeT i; - SetUi32(p->temp, val); - for (i = 0; i < rem; i++) - dest[i] = p->temp[i]; - p->dest = dest + rem; - p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem; - return SZ_OK; - } - SetUi32(dest, val); - p->temp[3] = (Byte)(val >> 24); - p->dest = dest + 4; - p->state = BCJ2_DEC_STATE_OK; - } - } - */ - - for (;;) - { - if (BCJ2_IS_32BIT_STREAM(p->state)) - p->state = BCJ2_DEC_STATE_OK; - else - { - if (p->range < kTopValue) - { - if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC]) - { - p->state = BCJ2_STREAM_RC; - return SZ_OK; - } - p->range <<= 8; - p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; - } - - { - const Byte *src = p->bufs[BCJ2_STREAM_MAIN]; - const Byte *srcLim; - Byte *dest; - SizeT num = (SizeT)(p->lims[BCJ2_STREAM_MAIN] - src); - - if (num == 0) - { - p->state = BCJ2_STREAM_MAIN; - return SZ_OK; - } - - dest = p->dest; - if (num > (SizeT)(p->destLim - dest)) - { - num = (SizeT)(p->destLim - dest); - if (num == 0) - { - p->state = BCJ2_DEC_STATE_ORIG; - return SZ_OK; - } - } - - srcLim = src + num; - - if (p->temp[3] == 0x0F && (src[0] & 0xF0) == 0x80) - *dest = src[0]; - else for (;;) - { - Byte b = *src; - *dest = b; - if (b != 0x0F) - { - if ((b & 0xFE) == 0xE8) - break; - dest++; - if (++src != srcLim) - continue; - break; - } - dest++; - if (++src == srcLim) - break; - if ((*src & 0xF0) != 0x80) - continue; - *dest = *src; - break; - } - - num = (SizeT)(src - p->bufs[BCJ2_STREAM_MAIN]); - - if (src == srcLim) - { - p->temp[3] = src[-1]; - p->bufs[BCJ2_STREAM_MAIN] = src; - p->ip += (UInt32)num; - p->dest += num; - p->state = - p->bufs[BCJ2_STREAM_MAIN] == - p->lims[BCJ2_STREAM_MAIN] ? - (unsigned)BCJ2_STREAM_MAIN : - (unsigned)BCJ2_DEC_STATE_ORIG; - return SZ_OK; - } - - { - UInt32 bound, ttt; - CProb *prob; - Byte b = src[0]; - Byte prev = (Byte)(num == 0 ? p->temp[3] : src[-1]); - - p->temp[3] = b; - p->bufs[BCJ2_STREAM_MAIN] = src + 1; - num++; - p->ip += (UInt32)num; - p->dest += num; - - prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0)); - - _IF_BIT_0 - { - _UPDATE_0 - continue; - } - _UPDATE_1 - - } - } - } - - { - UInt32 val; - unsigned cj = (p->temp[3] == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP; - const Byte *cur = p->bufs[cj]; - Byte *dest; - SizeT rem; - - if (cur == p->lims[cj]) - { - p->state = cj; - break; - } - - val = GetBe32(cur); - p->bufs[cj] = cur + 4; - - p->ip += 4; - val -= p->ip; - dest = p->dest; - rem = (SizeT)(p->destLim - dest); - - if (rem < 4) - { - p->temp[0] = (Byte)val; if (rem > 0) dest[0] = (Byte)val; val >>= 8; - p->temp[1] = (Byte)val; if (rem > 1) dest[1] = (Byte)val; val >>= 8; - p->temp[2] = (Byte)val; if (rem > 2) dest[2] = (Byte)val; val >>= 8; - p->temp[3] = (Byte)val; - p->dest = dest + rem; - p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem; - break; - } - - SetUi32(dest, val); - p->temp[3] = (Byte)(val >> 24); - p->dest = dest + 4; - } - } - - if (p->range < kTopValue && p->bufs[BCJ2_STREAM_RC] != p->lims[BCJ2_STREAM_RC]) - { - p->range <<= 8; - p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; - } - - return SZ_OK; -} +/* Bcj2.c -- BCJ2 Decoder (Converter for x86 code) +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "Bcj2.h" +#include "CpuArch.h" + +#define CProb UInt16 + +#define kTopValue ((UInt32)1 << 24) +#define kNumModelBits 11 +#define kBitModelTotal (1 << kNumModelBits) +#define kNumMoveBits 5 + +#define _IF_BIT_0 ttt = *prob; bound = (p->range >> kNumModelBits) * ttt; if (p->code < bound) +#define _UPDATE_0 p->range = bound; *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); +#define _UPDATE_1 p->range -= bound; p->code -= bound; *prob = (CProb)(ttt - (ttt >> kNumMoveBits)); + +void Bcj2Dec_Init(CBcj2Dec *p) +{ + unsigned i; + + p->state = BCJ2_DEC_STATE_OK; + p->ip = 0; + p->temp[3] = 0; + p->range = 0; + p->code = 0; + for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++) + p->probs[i] = kBitModelTotal >> 1; +} + +SRes Bcj2Dec_Decode(CBcj2Dec *p) +{ + if (p->range <= 5) + { + p->state = BCJ2_DEC_STATE_OK; + for (; p->range != 5; p->range++) + { + if (p->range == 1 && p->code != 0) + return SZ_ERROR_DATA; + + if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC]) + { + p->state = BCJ2_STREAM_RC; + return SZ_OK; + } + + p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; + } + + if (p->code == 0xFFFFFFFF) + return SZ_ERROR_DATA; + + p->range = 0xFFFFFFFF; + } + else if (p->state >= BCJ2_DEC_STATE_ORIG_0) + { + while (p->state <= BCJ2_DEC_STATE_ORIG_3) + { + Byte *dest = p->dest; + if (dest == p->destLim) + return SZ_OK; + *dest = p->temp[(size_t)p->state - BCJ2_DEC_STATE_ORIG_0]; + p->state++; + p->dest = dest + 1; + } + } + + /* + if (BCJ2_IS_32BIT_STREAM(p->state)) + { + const Byte *cur = p->bufs[p->state]; + if (cur == p->lims[p->state]) + return SZ_OK; + p->bufs[p->state] = cur + 4; + + { + UInt32 val; + Byte *dest; + SizeT rem; + + p->ip += 4; + val = GetBe32(cur) - p->ip; + dest = p->dest; + rem = p->destLim - dest; + if (rem < 4) + { + SizeT i; + SetUi32(p->temp, val); + for (i = 0; i < rem; i++) + dest[i] = p->temp[i]; + p->dest = dest + rem; + p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem; + return SZ_OK; + } + SetUi32(dest, val); + p->temp[3] = (Byte)(val >> 24); + p->dest = dest + 4; + p->state = BCJ2_DEC_STATE_OK; + } + } + */ + + for (;;) + { + if (BCJ2_IS_32BIT_STREAM(p->state)) + p->state = BCJ2_DEC_STATE_OK; + else + { + if (p->range < kTopValue) + { + if (p->bufs[BCJ2_STREAM_RC] == p->lims[BCJ2_STREAM_RC]) + { + p->state = BCJ2_STREAM_RC; + return SZ_OK; + } + p->range <<= 8; + p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; + } + + { + const Byte *src = p->bufs[BCJ2_STREAM_MAIN]; + const Byte *srcLim; + Byte *dest; + SizeT num = (SizeT)(p->lims[BCJ2_STREAM_MAIN] - src); + + if (num == 0) + { + p->state = BCJ2_STREAM_MAIN; + return SZ_OK; + } + + dest = p->dest; + if (num > (SizeT)(p->destLim - dest)) + { + num = (SizeT)(p->destLim - dest); + if (num == 0) + { + p->state = BCJ2_DEC_STATE_ORIG; + return SZ_OK; + } + } + + srcLim = src + num; + + if (p->temp[3] == 0x0F && (src[0] & 0xF0) == 0x80) + *dest = src[0]; + else for (;;) + { + Byte b = *src; + *dest = b; + if (b != 0x0F) + { + if ((b & 0xFE) == 0xE8) + break; + dest++; + if (++src != srcLim) + continue; + break; + } + dest++; + if (++src == srcLim) + break; + if ((*src & 0xF0) != 0x80) + continue; + *dest = *src; + break; + } + + num = (SizeT)(src - p->bufs[BCJ2_STREAM_MAIN]); + + if (src == srcLim) + { + p->temp[3] = src[-1]; + p->bufs[BCJ2_STREAM_MAIN] = src; + p->ip += (UInt32)num; + p->dest += num; + p->state = + p->bufs[BCJ2_STREAM_MAIN] == + p->lims[BCJ2_STREAM_MAIN] ? + (unsigned)BCJ2_STREAM_MAIN : + (unsigned)BCJ2_DEC_STATE_ORIG; + return SZ_OK; + } + + { + UInt32 bound, ttt; + CProb *prob; + Byte b = src[0]; + Byte prev = (Byte)(num == 0 ? p->temp[3] : src[-1]); + + p->temp[3] = b; + p->bufs[BCJ2_STREAM_MAIN] = src + 1; + num++; + p->ip += (UInt32)num; + p->dest += num; + + prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0)); + + _IF_BIT_0 + { + _UPDATE_0 + continue; + } + _UPDATE_1 + + } + } + } + + { + UInt32 val; + unsigned cj = (p->temp[3] == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP; + const Byte *cur = p->bufs[cj]; + Byte *dest; + SizeT rem; + + if (cur == p->lims[cj]) + { + p->state = cj; + break; + } + + val = GetBe32(cur); + p->bufs[cj] = cur + 4; + + p->ip += 4; + val -= p->ip; + dest = p->dest; + rem = (SizeT)(p->destLim - dest); + + if (rem < 4) + { + p->temp[0] = (Byte)val; if (rem > 0) dest[0] = (Byte)val; val >>= 8; + p->temp[1] = (Byte)val; if (rem > 1) dest[1] = (Byte)val; val >>= 8; + p->temp[2] = (Byte)val; if (rem > 2) dest[2] = (Byte)val; val >>= 8; + p->temp[3] = (Byte)val; + p->dest = dest + rem; + p->state = BCJ2_DEC_STATE_ORIG_0 + (unsigned)rem; + break; + } + + SetUi32(dest, val); + p->temp[3] = (Byte)(val >> 24); + p->dest = dest + 4; + } + } + + if (p->range < kTopValue && p->bufs[BCJ2_STREAM_RC] != p->lims[BCJ2_STREAM_RC]) + { + p->range <<= 8; + p->code = (p->code << 8) | *(p->bufs[BCJ2_STREAM_RC])++; + } + + return SZ_OK; +} diff --git a/deps/LZMA-SDK/C/Bcj2.h b/deps/LZMA-SDK/C/Bcj2.h index 68893d2d1..8824080ac 100644 --- a/deps/LZMA-SDK/C/Bcj2.h +++ b/deps/LZMA-SDK/C/Bcj2.h @@ -1,146 +1,146 @@ -/* Bcj2.h -- BCJ2 Converter for x86 code -2014-11-10 : Igor Pavlov : Public domain */ - -#ifndef __BCJ2_H -#define __BCJ2_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define BCJ2_NUM_STREAMS 4 - -enum -{ - BCJ2_STREAM_MAIN, - BCJ2_STREAM_CALL, - BCJ2_STREAM_JUMP, - BCJ2_STREAM_RC -}; - -enum -{ - BCJ2_DEC_STATE_ORIG_0 = BCJ2_NUM_STREAMS, - BCJ2_DEC_STATE_ORIG_1, - BCJ2_DEC_STATE_ORIG_2, - BCJ2_DEC_STATE_ORIG_3, - - BCJ2_DEC_STATE_ORIG, - BCJ2_DEC_STATE_OK -}; - -enum -{ - BCJ2_ENC_STATE_ORIG = BCJ2_NUM_STREAMS, - BCJ2_ENC_STATE_OK -}; - - -#define BCJ2_IS_32BIT_STREAM(s) ((s) == BCJ2_STREAM_CALL || (s) == BCJ2_STREAM_JUMP) - -/* -CBcj2Dec / CBcj2Enc -bufs sizes: - BUF_SIZE(n) = lims[n] - bufs[n] -bufs sizes for BCJ2_STREAM_CALL and BCJ2_STREAM_JUMP must be mutliply of 4: - (BUF_SIZE(BCJ2_STREAM_CALL) & 3) == 0 - (BUF_SIZE(BCJ2_STREAM_JUMP) & 3) == 0 -*/ - -/* -CBcj2Dec: -dest is allowed to overlap with bufs[BCJ2_STREAM_MAIN], with the following conditions: - bufs[BCJ2_STREAM_MAIN] >= dest && - bufs[BCJ2_STREAM_MAIN] - dest >= tempReserv + - BUF_SIZE(BCJ2_STREAM_CALL) + - BUF_SIZE(BCJ2_STREAM_JUMP) - tempReserv = 0 : for first call of Bcj2Dec_Decode - tempReserv = 4 : for any other calls of Bcj2Dec_Decode - overlap with offset = 1 is not allowed -*/ - -typedef struct -{ - const Byte *bufs[BCJ2_NUM_STREAMS]; - const Byte *lims[BCJ2_NUM_STREAMS]; - Byte *dest; - const Byte *destLim; - - unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */ - - UInt32 ip; - Byte temp[4]; - UInt32 range; - UInt32 code; - UInt16 probs[2 + 256]; -} CBcj2Dec; - -void Bcj2Dec_Init(CBcj2Dec *p); - -/* Returns: SZ_OK or SZ_ERROR_DATA */ -SRes Bcj2Dec_Decode(CBcj2Dec *p); - -#define Bcj2Dec_IsFinished(_p_) ((_p_)->code == 0) - - - -typedef enum -{ - BCJ2_ENC_FINISH_MODE_CONTINUE, - BCJ2_ENC_FINISH_MODE_END_BLOCK, - BCJ2_ENC_FINISH_MODE_END_STREAM -} EBcj2Enc_FinishMode; - -typedef struct -{ - Byte *bufs[BCJ2_NUM_STREAMS]; - const Byte *lims[BCJ2_NUM_STREAMS]; - const Byte *src; - const Byte *srcLim; - - unsigned state; - EBcj2Enc_FinishMode finishMode; - - Byte prevByte; - - Byte cache; - UInt32 range; - UInt64 low; - UInt64 cacheSize; - - UInt32 ip; - - /* 32-bit ralative offset in JUMP/CALL commands is - - (mod 4 GB) in 32-bit mode - - signed Int32 in 64-bit mode - We use (mod 4 GB) check for fileSize. - Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */ - UInt32 fileIp; - UInt32 fileSize; /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */ - UInt32 relatLimit; /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */ - - UInt32 tempTarget; - unsigned tempPos; - Byte temp[4 * 2]; - - unsigned flushPos; - - UInt16 probs[2 + 256]; -} CBcj2Enc; - -void Bcj2Enc_Init(CBcj2Enc *p); -void Bcj2Enc_Encode(CBcj2Enc *p); - -#define Bcj2Enc_Get_InputData_Size(p) ((SizeT)((p)->srcLim - (p)->src) + (p)->tempPos) -#define Bcj2Enc_IsFinished(p) ((p)->flushPos == 5) - - -#define BCJ2_RELAT_LIMIT_NUM_BITS 26 -#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS) - -/* limit for CBcj2Enc::fileSize variable */ -#define BCJ2_FileSize_MAX ((UInt32)1 << 31) - -EXTERN_C_END - -#endif +/* Bcj2.h -- BCJ2 Converter for x86 code +2014-11-10 : Igor Pavlov : Public domain */ + +#ifndef __BCJ2_H +#define __BCJ2_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define BCJ2_NUM_STREAMS 4 + +enum +{ + BCJ2_STREAM_MAIN, + BCJ2_STREAM_CALL, + BCJ2_STREAM_JUMP, + BCJ2_STREAM_RC +}; + +enum +{ + BCJ2_DEC_STATE_ORIG_0 = BCJ2_NUM_STREAMS, + BCJ2_DEC_STATE_ORIG_1, + BCJ2_DEC_STATE_ORIG_2, + BCJ2_DEC_STATE_ORIG_3, + + BCJ2_DEC_STATE_ORIG, + BCJ2_DEC_STATE_OK +}; + +enum +{ + BCJ2_ENC_STATE_ORIG = BCJ2_NUM_STREAMS, + BCJ2_ENC_STATE_OK +}; + + +#define BCJ2_IS_32BIT_STREAM(s) ((s) == BCJ2_STREAM_CALL || (s) == BCJ2_STREAM_JUMP) + +/* +CBcj2Dec / CBcj2Enc +bufs sizes: + BUF_SIZE(n) = lims[n] - bufs[n] +bufs sizes for BCJ2_STREAM_CALL and BCJ2_STREAM_JUMP must be mutliply of 4: + (BUF_SIZE(BCJ2_STREAM_CALL) & 3) == 0 + (BUF_SIZE(BCJ2_STREAM_JUMP) & 3) == 0 +*/ + +/* +CBcj2Dec: +dest is allowed to overlap with bufs[BCJ2_STREAM_MAIN], with the following conditions: + bufs[BCJ2_STREAM_MAIN] >= dest && + bufs[BCJ2_STREAM_MAIN] - dest >= tempReserv + + BUF_SIZE(BCJ2_STREAM_CALL) + + BUF_SIZE(BCJ2_STREAM_JUMP) + tempReserv = 0 : for first call of Bcj2Dec_Decode + tempReserv = 4 : for any other calls of Bcj2Dec_Decode + overlap with offset = 1 is not allowed +*/ + +typedef struct +{ + const Byte *bufs[BCJ2_NUM_STREAMS]; + const Byte *lims[BCJ2_NUM_STREAMS]; + Byte *dest; + const Byte *destLim; + + unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */ + + UInt32 ip; + Byte temp[4]; + UInt32 range; + UInt32 code; + UInt16 probs[2 + 256]; +} CBcj2Dec; + +void Bcj2Dec_Init(CBcj2Dec *p); + +/* Returns: SZ_OK or SZ_ERROR_DATA */ +SRes Bcj2Dec_Decode(CBcj2Dec *p); + +#define Bcj2Dec_IsFinished(_p_) ((_p_)->code == 0) + + + +typedef enum +{ + BCJ2_ENC_FINISH_MODE_CONTINUE, + BCJ2_ENC_FINISH_MODE_END_BLOCK, + BCJ2_ENC_FINISH_MODE_END_STREAM +} EBcj2Enc_FinishMode; + +typedef struct +{ + Byte *bufs[BCJ2_NUM_STREAMS]; + const Byte *lims[BCJ2_NUM_STREAMS]; + const Byte *src; + const Byte *srcLim; + + unsigned state; + EBcj2Enc_FinishMode finishMode; + + Byte prevByte; + + Byte cache; + UInt32 range; + UInt64 low; + UInt64 cacheSize; + + UInt32 ip; + + /* 32-bit ralative offset in JUMP/CALL commands is + - (mod 4 GB) in 32-bit mode + - signed Int32 in 64-bit mode + We use (mod 4 GB) check for fileSize. + Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */ + UInt32 fileIp; + UInt32 fileSize; /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */ + UInt32 relatLimit; /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */ + + UInt32 tempTarget; + unsigned tempPos; + Byte temp[4 * 2]; + + unsigned flushPos; + + UInt16 probs[2 + 256]; +} CBcj2Enc; + +void Bcj2Enc_Init(CBcj2Enc *p); +void Bcj2Enc_Encode(CBcj2Enc *p); + +#define Bcj2Enc_Get_InputData_Size(p) ((SizeT)((p)->srcLim - (p)->src) + (p)->tempPos) +#define Bcj2Enc_IsFinished(p) ((p)->flushPos == 5) + + +#define BCJ2_RELAT_LIMIT_NUM_BITS 26 +#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS) + +/* limit for CBcj2Enc::fileSize variable */ +#define BCJ2_FileSize_MAX ((UInt32)1 << 31) + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Bcj2Enc.c b/deps/LZMA-SDK/C/Bcj2Enc.c index 71ac5091d..682362a15 100644 --- a/deps/LZMA-SDK/C/Bcj2Enc.c +++ b/deps/LZMA-SDK/C/Bcj2Enc.c @@ -1,311 +1,311 @@ -/* Bcj2Enc.c -- BCJ2 Encoder (Converter for x86 code) -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -/* #define SHOW_STAT */ - -#ifdef SHOW_STAT -#include -#define PRF(x) x -#else -#define PRF(x) -#endif - -#include - -#include "Bcj2.h" -#include "CpuArch.h" - -#define CProb UInt16 - -#define kTopValue ((UInt32)1 << 24) -#define kNumModelBits 11 -#define kBitModelTotal (1 << kNumModelBits) -#define kNumMoveBits 5 - -void Bcj2Enc_Init(CBcj2Enc *p) -{ - unsigned i; - - p->state = BCJ2_ENC_STATE_OK; - p->finishMode = BCJ2_ENC_FINISH_MODE_CONTINUE; - - p->prevByte = 0; - - p->cache = 0; - p->range = 0xFFFFFFFF; - p->low = 0; - p->cacheSize = 1; - - p->ip = 0; - - p->fileIp = 0; - p->fileSize = 0; - p->relatLimit = BCJ2_RELAT_LIMIT; - - p->tempPos = 0; - - p->flushPos = 0; - - for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++) - p->probs[i] = kBitModelTotal >> 1; -} - -static BoolInt MY_FAST_CALL RangeEnc_ShiftLow(CBcj2Enc *p) -{ - if ((UInt32)p->low < (UInt32)0xFF000000 || (UInt32)(p->low >> 32) != 0) - { - Byte *buf = p->bufs[BCJ2_STREAM_RC]; - do - { - if (buf == p->lims[BCJ2_STREAM_RC]) - { - p->state = BCJ2_STREAM_RC; - p->bufs[BCJ2_STREAM_RC] = buf; - return True; - } - *buf++ = (Byte)(p->cache + (Byte)(p->low >> 32)); - p->cache = 0xFF; - } - while (--p->cacheSize); - p->bufs[BCJ2_STREAM_RC] = buf; - p->cache = (Byte)((UInt32)p->low >> 24); - } - p->cacheSize++; - p->low = (UInt32)p->low << 8; - return False; -} - -static void Bcj2Enc_Encode_2(CBcj2Enc *p) -{ - if (BCJ2_IS_32BIT_STREAM(p->state)) - { - Byte *cur = p->bufs[p->state]; - if (cur == p->lims[p->state]) - return; - SetBe32(cur, p->tempTarget); - p->bufs[p->state] = cur + 4; - } - - p->state = BCJ2_ENC_STATE_ORIG; - - for (;;) - { - if (p->range < kTopValue) - { - if (RangeEnc_ShiftLow(p)) - return; - p->range <<= 8; - } - - { - { - const Byte *src = p->src; - const Byte *srcLim; - Byte *dest; - SizeT num = (SizeT)(p->srcLim - src); - - if (p->finishMode == BCJ2_ENC_FINISH_MODE_CONTINUE) - { - if (num <= 4) - return; - num -= 4; - } - else if (num == 0) - break; - - dest = p->bufs[BCJ2_STREAM_MAIN]; - if (num > (SizeT)(p->lims[BCJ2_STREAM_MAIN] - dest)) - { - num = (SizeT)(p->lims[BCJ2_STREAM_MAIN] - dest); - if (num == 0) - { - p->state = BCJ2_STREAM_MAIN; - return; - } - } - - srcLim = src + num; - - if (p->prevByte == 0x0F && (src[0] & 0xF0) == 0x80) - *dest = src[0]; - else for (;;) - { - Byte b = *src; - *dest = b; - if (b != 0x0F) - { - if ((b & 0xFE) == 0xE8) - break; - dest++; - if (++src != srcLim) - continue; - break; - } - dest++; - if (++src == srcLim) - break; - if ((*src & 0xF0) != 0x80) - continue; - *dest = *src; - break; - } - - num = (SizeT)(src - p->src); - - if (src == srcLim) - { - p->prevByte = src[-1]; - p->bufs[BCJ2_STREAM_MAIN] = dest; - p->src = src; - p->ip += (UInt32)num; - continue; - } - - { - Byte context = (Byte)(num == 0 ? p->prevByte : src[-1]); - BoolInt needConvert; - - p->bufs[BCJ2_STREAM_MAIN] = dest + 1; - p->ip += (UInt32)num + 1; - src++; - - needConvert = False; - - if ((SizeT)(p->srcLim - src) >= 4) - { - UInt32 relatVal = GetUi32(src); - if ((p->fileSize == 0 || (UInt32)(p->ip + 4 + relatVal - p->fileIp) < p->fileSize) - && ((relatVal + p->relatLimit) >> 1) < p->relatLimit) - needConvert = True; - } - - { - UInt32 bound; - unsigned ttt; - Byte b = src[-1]; - CProb *prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)context : (b == 0xE9 ? 1 : 0)); - - ttt = *prob; - bound = (p->range >> kNumModelBits) * ttt; - - if (!needConvert) - { - p->range = bound; - *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); - p->src = src; - p->prevByte = b; - continue; - } - - p->low += bound; - p->range -= bound; - *prob = (CProb)(ttt - (ttt >> kNumMoveBits)); - - { - UInt32 relatVal = GetUi32(src); - UInt32 absVal; - p->ip += 4; - absVal = p->ip + relatVal; - p->prevByte = src[3]; - src += 4; - p->src = src; - { - unsigned cj = (b == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP; - Byte *cur = p->bufs[cj]; - if (cur == p->lims[cj]) - { - p->state = cj; - p->tempTarget = absVal; - return; - } - SetBe32(cur, absVal); - p->bufs[cj] = cur + 4; - } - } - } - } - } - } - } - - if (p->finishMode != BCJ2_ENC_FINISH_MODE_END_STREAM) - return; - - for (; p->flushPos < 5; p->flushPos++) - if (RangeEnc_ShiftLow(p)) - return; - p->state = BCJ2_ENC_STATE_OK; -} - - -void Bcj2Enc_Encode(CBcj2Enc *p) -{ - PRF(printf("\n")); - PRF(printf("---- ip = %8d tempPos = %8d src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src)); - - if (p->tempPos != 0) - { - unsigned extra = 0; - - for (;;) - { - const Byte *src = p->src; - const Byte *srcLim = p->srcLim; - EBcj2Enc_FinishMode finishMode = p->finishMode; - - p->src = p->temp; - p->srcLim = p->temp + p->tempPos; - if (src != srcLim) - p->finishMode = BCJ2_ENC_FINISH_MODE_CONTINUE; - - PRF(printf(" ip = %8d tempPos = %8d src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src)); - - Bcj2Enc_Encode_2(p); - - { - unsigned num = (unsigned)(p->src - p->temp); - unsigned tempPos = p->tempPos - num; - unsigned i; - p->tempPos = tempPos; - for (i = 0; i < tempPos; i++) - p->temp[i] = p->temp[(size_t)i + num]; - - p->src = src; - p->srcLim = srcLim; - p->finishMode = finishMode; - - if (p->state != BCJ2_ENC_STATE_ORIG || src == srcLim) - return; - - if (extra >= tempPos) - { - p->src = src - tempPos; - p->tempPos = 0; - break; - } - - p->temp[tempPos] = src[0]; - p->tempPos = tempPos + 1; - p->src = src + 1; - extra++; - } - } - } - - PRF(printf("++++ ip = %8d tempPos = %8d src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src)); - - Bcj2Enc_Encode_2(p); - - if (p->state == BCJ2_ENC_STATE_ORIG) - { - const Byte *src = p->src; - unsigned rem = (unsigned)(p->srcLim - src); - unsigned i; - for (i = 0; i < rem; i++) - p->temp[i] = src[i]; - p->tempPos = rem; - p->src = src + rem; - } -} +/* Bcj2Enc.c -- BCJ2 Encoder (Converter for x86 code) +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +/* #define SHOW_STAT */ + +#ifdef SHOW_STAT +#include +#define PRF(x) x +#else +#define PRF(x) +#endif + +#include + +#include "Bcj2.h" +#include "CpuArch.h" + +#define CProb UInt16 + +#define kTopValue ((UInt32)1 << 24) +#define kNumModelBits 11 +#define kBitModelTotal (1 << kNumModelBits) +#define kNumMoveBits 5 + +void Bcj2Enc_Init(CBcj2Enc *p) +{ + unsigned i; + + p->state = BCJ2_ENC_STATE_OK; + p->finishMode = BCJ2_ENC_FINISH_MODE_CONTINUE; + + p->prevByte = 0; + + p->cache = 0; + p->range = 0xFFFFFFFF; + p->low = 0; + p->cacheSize = 1; + + p->ip = 0; + + p->fileIp = 0; + p->fileSize = 0; + p->relatLimit = BCJ2_RELAT_LIMIT; + + p->tempPos = 0; + + p->flushPos = 0; + + for (i = 0; i < sizeof(p->probs) / sizeof(p->probs[0]); i++) + p->probs[i] = kBitModelTotal >> 1; +} + +static BoolInt MY_FAST_CALL RangeEnc_ShiftLow(CBcj2Enc *p) +{ + if ((UInt32)p->low < (UInt32)0xFF000000 || (UInt32)(p->low >> 32) != 0) + { + Byte *buf = p->bufs[BCJ2_STREAM_RC]; + do + { + if (buf == p->lims[BCJ2_STREAM_RC]) + { + p->state = BCJ2_STREAM_RC; + p->bufs[BCJ2_STREAM_RC] = buf; + return True; + } + *buf++ = (Byte)(p->cache + (Byte)(p->low >> 32)); + p->cache = 0xFF; + } + while (--p->cacheSize); + p->bufs[BCJ2_STREAM_RC] = buf; + p->cache = (Byte)((UInt32)p->low >> 24); + } + p->cacheSize++; + p->low = (UInt32)p->low << 8; + return False; +} + +static void Bcj2Enc_Encode_2(CBcj2Enc *p) +{ + if (BCJ2_IS_32BIT_STREAM(p->state)) + { + Byte *cur = p->bufs[p->state]; + if (cur == p->lims[p->state]) + return; + SetBe32(cur, p->tempTarget); + p->bufs[p->state] = cur + 4; + } + + p->state = BCJ2_ENC_STATE_ORIG; + + for (;;) + { + if (p->range < kTopValue) + { + if (RangeEnc_ShiftLow(p)) + return; + p->range <<= 8; + } + + { + { + const Byte *src = p->src; + const Byte *srcLim; + Byte *dest; + SizeT num = (SizeT)(p->srcLim - src); + + if (p->finishMode == BCJ2_ENC_FINISH_MODE_CONTINUE) + { + if (num <= 4) + return; + num -= 4; + } + else if (num == 0) + break; + + dest = p->bufs[BCJ2_STREAM_MAIN]; + if (num > (SizeT)(p->lims[BCJ2_STREAM_MAIN] - dest)) + { + num = (SizeT)(p->lims[BCJ2_STREAM_MAIN] - dest); + if (num == 0) + { + p->state = BCJ2_STREAM_MAIN; + return; + } + } + + srcLim = src + num; + + if (p->prevByte == 0x0F && (src[0] & 0xF0) == 0x80) + *dest = src[0]; + else for (;;) + { + Byte b = *src; + *dest = b; + if (b != 0x0F) + { + if ((b & 0xFE) == 0xE8) + break; + dest++; + if (++src != srcLim) + continue; + break; + } + dest++; + if (++src == srcLim) + break; + if ((*src & 0xF0) != 0x80) + continue; + *dest = *src; + break; + } + + num = (SizeT)(src - p->src); + + if (src == srcLim) + { + p->prevByte = src[-1]; + p->bufs[BCJ2_STREAM_MAIN] = dest; + p->src = src; + p->ip += (UInt32)num; + continue; + } + + { + Byte context = (Byte)(num == 0 ? p->prevByte : src[-1]); + BoolInt needConvert; + + p->bufs[BCJ2_STREAM_MAIN] = dest + 1; + p->ip += (UInt32)num + 1; + src++; + + needConvert = False; + + if ((SizeT)(p->srcLim - src) >= 4) + { + UInt32 relatVal = GetUi32(src); + if ((p->fileSize == 0 || (UInt32)(p->ip + 4 + relatVal - p->fileIp) < p->fileSize) + && ((relatVal + p->relatLimit) >> 1) < p->relatLimit) + needConvert = True; + } + + { + UInt32 bound; + unsigned ttt; + Byte b = src[-1]; + CProb *prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)context : (b == 0xE9 ? 1 : 0)); + + ttt = *prob; + bound = (p->range >> kNumModelBits) * ttt; + + if (!needConvert) + { + p->range = bound; + *prob = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); + p->src = src; + p->prevByte = b; + continue; + } + + p->low += bound; + p->range -= bound; + *prob = (CProb)(ttt - (ttt >> kNumMoveBits)); + + { + UInt32 relatVal = GetUi32(src); + UInt32 absVal; + p->ip += 4; + absVal = p->ip + relatVal; + p->prevByte = src[3]; + src += 4; + p->src = src; + { + unsigned cj = (b == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP; + Byte *cur = p->bufs[cj]; + if (cur == p->lims[cj]) + { + p->state = cj; + p->tempTarget = absVal; + return; + } + SetBe32(cur, absVal); + p->bufs[cj] = cur + 4; + } + } + } + } + } + } + } + + if (p->finishMode != BCJ2_ENC_FINISH_MODE_END_STREAM) + return; + + for (; p->flushPos < 5; p->flushPos++) + if (RangeEnc_ShiftLow(p)) + return; + p->state = BCJ2_ENC_STATE_OK; +} + + +void Bcj2Enc_Encode(CBcj2Enc *p) +{ + PRF(printf("\n")); + PRF(printf("---- ip = %8d tempPos = %8d src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src)); + + if (p->tempPos != 0) + { + unsigned extra = 0; + + for (;;) + { + const Byte *src = p->src; + const Byte *srcLim = p->srcLim; + EBcj2Enc_FinishMode finishMode = p->finishMode; + + p->src = p->temp; + p->srcLim = p->temp + p->tempPos; + if (src != srcLim) + p->finishMode = BCJ2_ENC_FINISH_MODE_CONTINUE; + + PRF(printf(" ip = %8d tempPos = %8d src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src)); + + Bcj2Enc_Encode_2(p); + + { + unsigned num = (unsigned)(p->src - p->temp); + unsigned tempPos = p->tempPos - num; + unsigned i; + p->tempPos = tempPos; + for (i = 0; i < tempPos; i++) + p->temp[i] = p->temp[(size_t)i + num]; + + p->src = src; + p->srcLim = srcLim; + p->finishMode = finishMode; + + if (p->state != BCJ2_ENC_STATE_ORIG || src == srcLim) + return; + + if (extra >= tempPos) + { + p->src = src - tempPos; + p->tempPos = 0; + break; + } + + p->temp[tempPos] = src[0]; + p->tempPos = tempPos + 1; + p->src = src + 1; + extra++; + } + } + } + + PRF(printf("++++ ip = %8d tempPos = %8d src = %8d\n", p->ip, p->tempPos, p->srcLim - p->src)); + + Bcj2Enc_Encode_2(p); + + if (p->state == BCJ2_ENC_STATE_ORIG) + { + const Byte *src = p->src; + unsigned rem = (unsigned)(p->srcLim - src); + unsigned i; + for (i = 0; i < rem; i++) + p->temp[i] = src[i]; + p->tempPos = rem; + p->src = src + rem; + } +} diff --git a/deps/LZMA-SDK/C/Bra.c b/deps/LZMA-SDK/C/Bra.c index cdefa4d2e..3b854d9ca 100644 --- a/deps/LZMA-SDK/C/Bra.c +++ b/deps/LZMA-SDK/C/Bra.c @@ -1,230 +1,230 @@ -/* Bra.c -- Converters for RISC code -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" -#include "Bra.h" - -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) -{ - Byte *p; - const Byte *lim; - size &= ~(size_t)3; - ip += 4; - p = data; - lim = data + size; - - if (encoding) - - for (;;) - { - for (;;) - { - if (p >= lim) - return (SizeT)(p - data); - p += 4; - if (p[-1] == 0xEB) - break; - } - { - UInt32 v = GetUi32(p - 4); - v <<= 2; - v += ip + (UInt32)(p - data); - v >>= 2; - v &= 0x00FFFFFF; - v |= 0xEB000000; - SetUi32(p - 4, v); - } - } - - for (;;) - { - for (;;) - { - if (p >= lim) - return (SizeT)(p - data); - p += 4; - if (p[-1] == 0xEB) - break; - } - { - UInt32 v = GetUi32(p - 4); - v <<= 2; - v -= ip + (UInt32)(p - data); - v >>= 2; - v &= 0x00FFFFFF; - v |= 0xEB000000; - SetUi32(p - 4, v); - } - } -} - - -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) -{ - Byte *p; - const Byte *lim; - size &= ~(size_t)1; - p = data; - lim = data + size - 4; - - if (encoding) - - for (;;) - { - UInt32 b1; - for (;;) - { - UInt32 b3; - if (p > lim) - return (SizeT)(p - data); - b1 = p[1]; - b3 = p[3]; - p += 2; - b1 ^= 8; - if ((b3 & b1) >= 0xF8) - break; - } - { - UInt32 v = - ((UInt32)b1 << 19) - + (((UInt32)p[1] & 0x7) << 8) - + (((UInt32)p[-2] << 11)) - + (p[0]); - - p += 2; - { - UInt32 cur = (ip + (UInt32)(p - data)) >> 1; - v += cur; - } - - p[-4] = (Byte)(v >> 11); - p[-3] = (Byte)(0xF0 | ((v >> 19) & 0x7)); - p[-2] = (Byte)v; - p[-1] = (Byte)(0xF8 | (v >> 8)); - } - } - - for (;;) - { - UInt32 b1; - for (;;) - { - UInt32 b3; - if (p > lim) - return (SizeT)(p - data); - b1 = p[1]; - b3 = p[3]; - p += 2; - b1 ^= 8; - if ((b3 & b1) >= 0xF8) - break; - } - { - UInt32 v = - ((UInt32)b1 << 19) - + (((UInt32)p[1] & 0x7) << 8) - + (((UInt32)p[-2] << 11)) - + (p[0]); - - p += 2; - { - UInt32 cur = (ip + (UInt32)(p - data)) >> 1; - v -= cur; - } - - /* - SetUi16(p - 4, (UInt16)(((v >> 11) & 0x7FF) | 0xF000)); - SetUi16(p - 2, (UInt16)(v | 0xF800)); - */ - - p[-4] = (Byte)(v >> 11); - p[-3] = (Byte)(0xF0 | ((v >> 19) & 0x7)); - p[-2] = (Byte)v; - p[-1] = (Byte)(0xF8 | (v >> 8)); - } - } -} - - -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) -{ - Byte *p; - const Byte *lim; - size &= ~(size_t)3; - ip -= 4; - p = data; - lim = data + size; - - for (;;) - { - for (;;) - { - if (p >= lim) - return (SizeT)(p - data); - p += 4; - /* if ((v & 0xFC000003) == 0x48000001) */ - if ((p[-4] & 0xFC) == 0x48 && (p[-1] & 3) == 1) - break; - } - { - UInt32 v = GetBe32(p - 4); - if (encoding) - v += ip + (UInt32)(p - data); - else - v -= ip + (UInt32)(p - data); - v &= 0x03FFFFFF; - v |= 0x48000000; - SetBe32(p - 4, v); - } - } -} - - -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) -{ - Byte *p; - const Byte *lim; - size &= ~(size_t)3; - ip -= 4; - p = data; - lim = data + size; - - for (;;) - { - for (;;) - { - if (p >= lim) - return (SizeT)(p - data); - /* - v = GetBe32(p); - p += 4; - m = v + ((UInt32)5 << 29); - m ^= (UInt32)7 << 29; - m += (UInt32)1 << 22; - if ((m & ((UInt32)0x1FF << 23)) == 0) - break; - */ - p += 4; - if ((p[-4] == 0x40 && (p[-3] & 0xC0) == 0) || - (p[-4] == 0x7F && (p[-3] >= 0xC0))) - break; - } - { - UInt32 v = GetBe32(p - 4); - v <<= 2; - if (encoding) - v += ip + (UInt32)(p - data); - else - v -= ip + (UInt32)(p - data); - - v &= 0x01FFFFFF; - v -= (UInt32)1 << 24; - v ^= 0xFF000000; - v >>= 2; - v |= 0x40000000; - SetBe32(p - 4, v); - } - } -} +/* Bra.c -- Converters for RISC code +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" +#include "Bra.h" + +SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +{ + Byte *p; + const Byte *lim; + size &= ~(size_t)3; + ip += 4; + p = data; + lim = data + size; + + if (encoding) + + for (;;) + { + for (;;) + { + if (p >= lim) + return (SizeT)(p - data); + p += 4; + if (p[-1] == 0xEB) + break; + } + { + UInt32 v = GetUi32(p - 4); + v <<= 2; + v += ip + (UInt32)(p - data); + v >>= 2; + v &= 0x00FFFFFF; + v |= 0xEB000000; + SetUi32(p - 4, v); + } + } + + for (;;) + { + for (;;) + { + if (p >= lim) + return (SizeT)(p - data); + p += 4; + if (p[-1] == 0xEB) + break; + } + { + UInt32 v = GetUi32(p - 4); + v <<= 2; + v -= ip + (UInt32)(p - data); + v >>= 2; + v &= 0x00FFFFFF; + v |= 0xEB000000; + SetUi32(p - 4, v); + } + } +} + + +SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +{ + Byte *p; + const Byte *lim; + size &= ~(size_t)1; + p = data; + lim = data + size - 4; + + if (encoding) + + for (;;) + { + UInt32 b1; + for (;;) + { + UInt32 b3; + if (p > lim) + return (SizeT)(p - data); + b1 = p[1]; + b3 = p[3]; + p += 2; + b1 ^= 8; + if ((b3 & b1) >= 0xF8) + break; + } + { + UInt32 v = + ((UInt32)b1 << 19) + + (((UInt32)p[1] & 0x7) << 8) + + (((UInt32)p[-2] << 11)) + + (p[0]); + + p += 2; + { + UInt32 cur = (ip + (UInt32)(p - data)) >> 1; + v += cur; + } + + p[-4] = (Byte)(v >> 11); + p[-3] = (Byte)(0xF0 | ((v >> 19) & 0x7)); + p[-2] = (Byte)v; + p[-1] = (Byte)(0xF8 | (v >> 8)); + } + } + + for (;;) + { + UInt32 b1; + for (;;) + { + UInt32 b3; + if (p > lim) + return (SizeT)(p - data); + b1 = p[1]; + b3 = p[3]; + p += 2; + b1 ^= 8; + if ((b3 & b1) >= 0xF8) + break; + } + { + UInt32 v = + ((UInt32)b1 << 19) + + (((UInt32)p[1] & 0x7) << 8) + + (((UInt32)p[-2] << 11)) + + (p[0]); + + p += 2; + { + UInt32 cur = (ip + (UInt32)(p - data)) >> 1; + v -= cur; + } + + /* + SetUi16(p - 4, (UInt16)(((v >> 11) & 0x7FF) | 0xF000)); + SetUi16(p - 2, (UInt16)(v | 0xF800)); + */ + + p[-4] = (Byte)(v >> 11); + p[-3] = (Byte)(0xF0 | ((v >> 19) & 0x7)); + p[-2] = (Byte)v; + p[-1] = (Byte)(0xF8 | (v >> 8)); + } + } +} + + +SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +{ + Byte *p; + const Byte *lim; + size &= ~(size_t)3; + ip -= 4; + p = data; + lim = data + size; + + for (;;) + { + for (;;) + { + if (p >= lim) + return (SizeT)(p - data); + p += 4; + /* if ((v & 0xFC000003) == 0x48000001) */ + if ((p[-4] & 0xFC) == 0x48 && (p[-1] & 3) == 1) + break; + } + { + UInt32 v = GetBe32(p - 4); + if (encoding) + v += ip + (UInt32)(p - data); + else + v -= ip + (UInt32)(p - data); + v &= 0x03FFFFFF; + v |= 0x48000000; + SetBe32(p - 4, v); + } + } +} + + +SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +{ + Byte *p; + const Byte *lim; + size &= ~(size_t)3; + ip -= 4; + p = data; + lim = data + size; + + for (;;) + { + for (;;) + { + if (p >= lim) + return (SizeT)(p - data); + /* + v = GetBe32(p); + p += 4; + m = v + ((UInt32)5 << 29); + m ^= (UInt32)7 << 29; + m += (UInt32)1 << 22; + if ((m & ((UInt32)0x1FF << 23)) == 0) + break; + */ + p += 4; + if ((p[-4] == 0x40 && (p[-3] & 0xC0) == 0) || + (p[-4] == 0x7F && (p[-3] >= 0xC0))) + break; + } + { + UInt32 v = GetBe32(p - 4); + v <<= 2; + if (encoding) + v += ip + (UInt32)(p - data); + else + v -= ip + (UInt32)(p - data); + + v &= 0x01FFFFFF; + v -= (UInt32)1 << 24; + v ^= 0xFF000000; + v >>= 2; + v |= 0x40000000; + SetBe32(p - 4, v); + } + } +} diff --git a/deps/LZMA-SDK/C/Bra.h b/deps/LZMA-SDK/C/Bra.h index aba8dce14..855e37a6b 100644 --- a/deps/LZMA-SDK/C/Bra.h +++ b/deps/LZMA-SDK/C/Bra.h @@ -1,64 +1,64 @@ -/* Bra.h -- Branch converters for executables -2013-01-18 : Igor Pavlov : Public domain */ - -#ifndef __BRA_H -#define __BRA_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -/* -These functions convert relative addresses to absolute addresses -in CALL instructions to increase the compression ratio. - - In: - data - data buffer - size - size of data - ip - current virtual Instruction Pinter (IP) value - state - state variable for x86 converter - encoding - 0 (for decoding), 1 (for encoding) - - Out: - state - state variable for x86 converter - - Returns: - The number of processed bytes. If you call these functions with multiple calls, - you must start next call with first byte after block of processed bytes. - - Type Endian Alignment LookAhead - - x86 little 1 4 - ARMT little 2 2 - ARM little 4 0 - PPC big 4 0 - SPARC big 4 0 - IA64 little 16 0 - - size must be >= Alignment + LookAhead, if it's not last block. - If (size < Alignment + LookAhead), converter returns 0. - - Example: - - UInt32 ip = 0; - for () - { - ; size must be >= Alignment + LookAhead, if it's not last block - SizeT processed = Convert(data, size, ip, 1); - data += processed; - size -= processed; - ip += processed; - } -*/ - -#define x86_Convert_Init(state) { state = 0; } -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); -SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); - -EXTERN_C_END - -#endif +/* Bra.h -- Branch converters for executables +2013-01-18 : Igor Pavlov : Public domain */ + +#ifndef __BRA_H +#define __BRA_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +/* +These functions convert relative addresses to absolute addresses +in CALL instructions to increase the compression ratio. + + In: + data - data buffer + size - size of data + ip - current virtual Instruction Pinter (IP) value + state - state variable for x86 converter + encoding - 0 (for decoding), 1 (for encoding) + + Out: + state - state variable for x86 converter + + Returns: + The number of processed bytes. If you call these functions with multiple calls, + you must start next call with first byte after block of processed bytes. + + Type Endian Alignment LookAhead + + x86 little 1 4 + ARMT little 2 2 + ARM little 4 0 + PPC big 4 0 + SPARC big 4 0 + IA64 little 16 0 + + size must be >= Alignment + LookAhead, if it's not last block. + If (size < Alignment + LookAhead), converter returns 0. + + Example: + + UInt32 ip = 0; + for () + { + ; size must be >= Alignment + LookAhead, if it's not last block + SizeT processed = Convert(data, size, ip, 1); + data += processed; + size -= processed; + ip += processed; + } +*/ + +#define x86_Convert_Init(state) { state = 0; } +SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); +SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); +SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); +SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); +SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); +SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Bra86.c b/deps/LZMA-SDK/C/Bra86.c index d857dac67..10a0fbd16 100644 --- a/deps/LZMA-SDK/C/Bra86.c +++ b/deps/LZMA-SDK/C/Bra86.c @@ -1,82 +1,82 @@ -/* Bra86.c -- Converter for x86 code (BCJ) -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "Bra.h" - -#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0) - -SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) -{ - SizeT pos = 0; - UInt32 mask = *state & 7; - if (size < 5) - return 0; - size -= 4; - ip += 5; - - for (;;) - { - Byte *p = data + pos; - const Byte *limit = data + size; - for (; p < limit; p++) - if ((*p & 0xFE) == 0xE8) - break; - - { - SizeT d = (SizeT)(p - data) - pos; - pos = (SizeT)(p - data); - if (p >= limit) - { - *state = (d > 2 ? 0 : mask >> (unsigned)d); - return pos; - } - if (d > 2) - mask = 0; - else - { - mask >>= (unsigned)d; - if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(size_t)(mask >> 1) + 1]))) - { - mask = (mask >> 1) | 4; - pos++; - continue; - } - } - } - - if (Test86MSByte(p[4])) - { - UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); - UInt32 cur = ip + (UInt32)pos; - pos += 5; - if (encoding) - v += cur; - else - v -= cur; - if (mask != 0) - { - unsigned sh = (mask & 6) << 2; - if (Test86MSByte((Byte)(v >> sh))) - { - v ^= (((UInt32)0x100 << sh) - 1); - if (encoding) - v += cur; - else - v -= cur; - } - mask = 0; - } - p[1] = (Byte)v; - p[2] = (Byte)(v >> 8); - p[3] = (Byte)(v >> 16); - p[4] = (Byte)(0 - ((v >> 24) & 1)); - } - else - { - mask = (mask >> 1) | 4; - pos++; - } - } -} +/* Bra86.c -- Converter for x86 code (BCJ) +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "Bra.h" + +#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0) + +SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) +{ + SizeT pos = 0; + UInt32 mask = *state & 7; + if (size < 5) + return 0; + size -= 4; + ip += 5; + + for (;;) + { + Byte *p = data + pos; + const Byte *limit = data + size; + for (; p < limit; p++) + if ((*p & 0xFE) == 0xE8) + break; + + { + SizeT d = (SizeT)(p - data) - pos; + pos = (SizeT)(p - data); + if (p >= limit) + { + *state = (d > 2 ? 0 : mask >> (unsigned)d); + return pos; + } + if (d > 2) + mask = 0; + else + { + mask >>= (unsigned)d; + if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(size_t)(mask >> 1) + 1]))) + { + mask = (mask >> 1) | 4; + pos++; + continue; + } + } + } + + if (Test86MSByte(p[4])) + { + UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); + UInt32 cur = ip + (UInt32)pos; + pos += 5; + if (encoding) + v += cur; + else + v -= cur; + if (mask != 0) + { + unsigned sh = (mask & 6) << 2; + if (Test86MSByte((Byte)(v >> sh))) + { + v ^= (((UInt32)0x100 << sh) - 1); + if (encoding) + v += cur; + else + v -= cur; + } + mask = 0; + } + p[1] = (Byte)v; + p[2] = (Byte)(v >> 8); + p[3] = (Byte)(v >> 16); + p[4] = (Byte)(0 - ((v >> 24) & 1)); + } + else + { + mask = (mask >> 1) | 4; + pos++; + } + } +} diff --git a/deps/LZMA-SDK/C/BraIA64.c b/deps/LZMA-SDK/C/BraIA64.c index 2656907a0..d1dbc62c5 100644 --- a/deps/LZMA-SDK/C/BraIA64.c +++ b/deps/LZMA-SDK/C/BraIA64.c @@ -1,53 +1,53 @@ -/* BraIA64.c -- Converter for IA-64 code -2017-01-26 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" -#include "Bra.h" - -SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) -{ - SizeT i; - if (size < 16) - return 0; - size -= 16; - i = 0; - do - { - unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3; - if (m) - { - m++; - do - { - Byte *p = data + (i + (size_t)m * 5 - 8); - if (((p[3] >> m) & 15) == 5 - && (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0) - { - unsigned raw = GetUi32(p); - unsigned v = raw >> m; - v = (v & 0xFFFFF) | ((v & (1 << 23)) >> 3); - - v <<= 4; - if (encoding) - v += ip + (UInt32)i; - else - v -= ip + (UInt32)i; - v >>= 4; - - v &= 0x1FFFFF; - v += 0x700000; - v &= 0x8FFFFF; - raw &= ~((UInt32)0x8FFFFF << m); - raw |= (v << m); - SetUi32(p, raw); - } - } - while (++m <= 4); - } - i += 16; - } - while (i <= size); - return i; -} +/* BraIA64.c -- Converter for IA-64 code +2017-01-26 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" +#include "Bra.h" + +SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) +{ + SizeT i; + if (size < 16) + return 0; + size -= 16; + i = 0; + do + { + unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3; + if (m) + { + m++; + do + { + Byte *p = data + (i + (size_t)m * 5 - 8); + if (((p[3] >> m) & 15) == 5 + && (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0) + { + unsigned raw = GetUi32(p); + unsigned v = raw >> m; + v = (v & 0xFFFFF) | ((v & (1 << 23)) >> 3); + + v <<= 4; + if (encoding) + v += ip + (UInt32)i; + else + v -= ip + (UInt32)i; + v >>= 4; + + v &= 0x1FFFFF; + v += 0x700000; + v &= 0x8FFFFF; + raw &= ~((UInt32)0x8FFFFF << m); + raw |= (v << m); + SetUi32(p, raw); + } + } + while (++m <= 4); + } + i += 16; + } + while (i <= size); + return i; +} diff --git a/deps/LZMA-SDK/C/Compiler.h b/deps/LZMA-SDK/C/Compiler.h index eba374298..a9816fa5a 100644 --- a/deps/LZMA-SDK/C/Compiler.h +++ b/deps/LZMA-SDK/C/Compiler.h @@ -1,43 +1,43 @@ -/* Compiler.h -2021-01-05 : Igor Pavlov : Public domain */ - -#ifndef __7Z_COMPILER_H -#define __7Z_COMPILER_H - - #ifdef __clang__ - #pragma clang diagnostic ignored "-Wunused-private-field" - #endif - -#ifdef _MSC_VER - - #ifdef UNDER_CE - #define RPC_NO_WINDOWS_H - /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ - #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union - #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int - #endif - - #if _MSC_VER >= 1300 - #pragma warning(disable : 4996) // This function or variable may be unsafe - #else - #pragma warning(disable : 4511) // copy constructor could not be generated - #pragma warning(disable : 4512) // assignment operator could not be generated - #pragma warning(disable : 4514) // unreferenced inline function has been removed - #pragma warning(disable : 4702) // unreachable code - #pragma warning(disable : 4710) // not inlined - #pragma warning(disable : 4714) // function marked as __forceinline not inlined - #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information - #endif - - #ifdef __clang__ - #pragma clang diagnostic ignored "-Wdeprecated-declarations" - #pragma clang diagnostic ignored "-Wmicrosoft-exception-spec" - // #pragma clang diagnostic ignored "-Wreserved-id-macro" - #endif - -#endif - -#define UNUSED_VAR(x) (void)x; -/* #define UNUSED_VAR(x) x=x; */ - -#endif +/* Compiler.h +2021-01-05 : Igor Pavlov : Public domain */ + +#ifndef __7Z_COMPILER_H +#define __7Z_COMPILER_H + + #ifdef __clang__ + #pragma clang diagnostic ignored "-Wunused-private-field" + #endif + +#ifdef _MSC_VER + + #ifdef UNDER_CE + #define RPC_NO_WINDOWS_H + /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */ + #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union + #pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int + #endif + + #if _MSC_VER >= 1300 + #pragma warning(disable : 4996) // This function or variable may be unsafe + #else + #pragma warning(disable : 4511) // copy constructor could not be generated + #pragma warning(disable : 4512) // assignment operator could not be generated + #pragma warning(disable : 4514) // unreferenced inline function has been removed + #pragma warning(disable : 4702) // unreachable code + #pragma warning(disable : 4710) // not inlined + #pragma warning(disable : 4714) // function marked as __forceinline not inlined + #pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information + #endif + + #ifdef __clang__ + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + #pragma clang diagnostic ignored "-Wmicrosoft-exception-spec" + // #pragma clang diagnostic ignored "-Wreserved-id-macro" + #endif + +#endif + +#define UNUSED_VAR(x) (void)x; +/* #define UNUSED_VAR(x) x=x; */ + +#endif diff --git a/deps/LZMA-SDK/C/CpuArch.c b/deps/LZMA-SDK/C/CpuArch.c index e1443f51b..110ced6d6 100644 --- a/deps/LZMA-SDK/C/CpuArch.c +++ b/deps/LZMA-SDK/C/CpuArch.c @@ -1,438 +1,478 @@ -/* CpuArch.c -- CPU specific code -2021-04-28 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" - -#ifdef MY_CPU_X86_OR_AMD64 - -#if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__) -#define USE_ASM -#endif - -#if !defined(USE_ASM) && _MSC_VER >= 1500 -#include -#endif - -#if defined(USE_ASM) && !defined(MY_CPU_AMD64) -static UInt32 CheckFlag(UInt32 flag) -{ - #ifdef _MSC_VER - __asm pushfd; - __asm pop EAX; - __asm mov EDX, EAX; - __asm xor EAX, flag; - __asm push EAX; - __asm popfd; - __asm pushfd; - __asm pop EAX; - __asm xor EAX, EDX; - __asm push EDX; - __asm popfd; - __asm and flag, EAX; - #else - __asm__ __volatile__ ( - "pushf\n\t" - "pop %%EAX\n\t" - "movl %%EAX,%%EDX\n\t" - "xorl %0,%%EAX\n\t" - "push %%EAX\n\t" - "popf\n\t" - "pushf\n\t" - "pop %%EAX\n\t" - "xorl %%EDX,%%EAX\n\t" - "push %%EDX\n\t" - "popf\n\t" - "andl %%EAX, %0\n\t": - "=c" (flag) : "c" (flag) : - "%eax", "%edx"); - #endif - return flag; -} -#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False; -#else -#define CHECK_CPUID_IS_SUPPORTED -#endif - -#ifndef USE_ASM - #ifdef _MSC_VER - #if _MSC_VER >= 1600 - #define MY__cpuidex __cpuidex - #else - -/* - __cpuid (function == 4) requires subfunction number in ECX. - MSDN: The __cpuid intrinsic clears the ECX register before calling the cpuid instruction. - __cpuid() in new MSVC clears ECX. - __cpuid() in old MSVC (14.00) doesn't clear ECX - We still can use __cpuid for low (function) values that don't require ECX, - but __cpuid() in old MSVC will be incorrect for some function values: (function == 4). - So here we use the hack for old MSVC to send (subFunction) in ECX register to cpuid instruction, - where ECX value is first parameter for FAST_CALL / NO_INLINE function, - So the caller of MY__cpuidex_HACK() sets ECX as subFunction, and - old MSVC for __cpuid() doesn't change ECX and cpuid instruction gets (subFunction) value. - - DON'T remove MY_NO_INLINE and MY_FAST_CALL for MY__cpuidex_HACK() !!! -*/ - -static -MY_NO_INLINE -void MY_FAST_CALL MY__cpuidex_HACK(UInt32 subFunction, int *CPUInfo, UInt32 function) -{ - UNUSED_VAR(subFunction); - __cpuid(CPUInfo, function); -} - - #define MY__cpuidex(info, func, func2) MY__cpuidex_HACK(func2, info, func) - #pragma message("======== MY__cpuidex_HACK WAS USED ========") - #endif - #else - #define MY__cpuidex(info, func, func2) __cpuid(info, func) - #pragma message("======== (INCORRECT ?) cpuid WAS USED ========") - #endif -#endif - - - - -void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) -{ - #ifdef USE_ASM - - #ifdef _MSC_VER - - UInt32 a2, b2, c2, d2; - __asm xor EBX, EBX; - __asm xor ECX, ECX; - __asm xor EDX, EDX; - __asm mov EAX, function; - __asm cpuid; - __asm mov a2, EAX; - __asm mov b2, EBX; - __asm mov c2, ECX; - __asm mov d2, EDX; - - *a = a2; - *b = b2; - *c = c2; - *d = d2; - - #else - - __asm__ __volatile__ ( - #if defined(MY_CPU_AMD64) && defined(__PIC__) - "mov %%rbx, %%rdi;" - "cpuid;" - "xchg %%rbx, %%rdi;" - : "=a" (*a) , - "=D" (*b) , - #elif defined(MY_CPU_X86) && defined(__PIC__) - "mov %%ebx, %%edi;" - "cpuid;" - "xchgl %%ebx, %%edi;" - : "=a" (*a) , - "=D" (*b) , - #else - "cpuid" - : "=a" (*a) , - "=b" (*b) , - #endif - "=c" (*c) , - "=d" (*d) - : "0" (function), "c"(0) ) ; - - #endif - - #else - - int CPUInfo[4]; - - MY__cpuidex(CPUInfo, (int)function, 0); - - *a = (UInt32)CPUInfo[0]; - *b = (UInt32)CPUInfo[1]; - *c = (UInt32)CPUInfo[2]; - *d = (UInt32)CPUInfo[3]; - - #endif -} - -BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p) -{ - CHECK_CPUID_IS_SUPPORTED - MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]); - MyCPUID(1, &p->ver, &p->b, &p->c, &p->d); - return True; -} - -static const UInt32 kVendors[][3] = -{ - { 0x756E6547, 0x49656E69, 0x6C65746E}, - { 0x68747541, 0x69746E65, 0x444D4163}, - { 0x746E6543, 0x48727561, 0x736C7561} -}; - -int x86cpuid_GetFirm(const Cx86cpuid *p) -{ - unsigned i; - for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++) - { - const UInt32 *v = kVendors[i]; - if (v[0] == p->vendor[0] && - v[1] == p->vendor[1] && - v[2] == p->vendor[2]) - return (int)i; - } - return -1; -} - -BoolInt CPU_Is_InOrder() -{ - Cx86cpuid p; - int firm; - UInt32 family, model; - if (!x86cpuid_CheckAndRead(&p)) - return True; - - family = x86cpuid_GetFamily(p.ver); - model = x86cpuid_GetModel(p.ver); - - firm = x86cpuid_GetFirm(&p); - - switch (firm) - { - case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && ( - /* In-Order Atom CPU */ - model == 0x1C /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */ - || model == 0x26 /* 45 nm, Z6xx */ - || model == 0x27 /* 32 nm, Z2460 */ - || model == 0x35 /* 32 nm, Z2760 */ - || model == 0x36 /* 32 nm, N2xxx, D2xxx */ - ))); - case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA))); - case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF)); - } - return True; -} - -#if !defined(MY_CPU_AMD64) && defined(_WIN32) -#include -static BoolInt CPU_Sys_Is_SSE_Supported() -{ - OSVERSIONINFO vi; - vi.dwOSVersionInfoSize = sizeof(vi); - if (!GetVersionEx(&vi)) - return False; - return (vi.dwMajorVersion >= 5); -} -#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False; -#else -#define CHECK_SYS_SSE_SUPPORT -#endif - - -static UInt32 X86_CPUID_ECX_Get_Flags() -{ - Cx86cpuid p; - CHECK_SYS_SSE_SUPPORT - if (!x86cpuid_CheckAndRead(&p)) - return 0; - return p.c; -} - -BoolInt CPU_IsSupported_AES() -{ - return (X86_CPUID_ECX_Get_Flags() >> 25) & 1; -} - -BoolInt CPU_IsSupported_SSSE3() -{ - return (X86_CPUID_ECX_Get_Flags() >> 9) & 1; -} - -BoolInt CPU_IsSupported_SSE41() -{ - return (X86_CPUID_ECX_Get_Flags() >> 19) & 1; -} - -BoolInt CPU_IsSupported_SHA() -{ - Cx86cpuid p; - CHECK_SYS_SSE_SUPPORT - if (!x86cpuid_CheckAndRead(&p)) - return False; - - if (p.maxFunc < 7) - return False; - { - UInt32 d[4] = { 0 }; - MyCPUID(7, &d[0], &d[1], &d[2], &d[3]); - return (d[1] >> 29) & 1; - } -} - -// #include - -#ifdef _WIN32 -#include -#endif - -BoolInt CPU_IsSupported_VAES_AVX2() -{ - Cx86cpuid p; - CHECK_SYS_SSE_SUPPORT - - #ifdef _WIN32 - #define MY__PF_XSAVE_ENABLED 17 - if (!IsProcessorFeaturePresent(MY__PF_XSAVE_ENABLED)) - return False; - #endif - - if (!x86cpuid_CheckAndRead(&p)) - return False; - if (p.maxFunc < 7) - return False; - { - UInt32 d[4] = { 0 }; - MyCPUID(7, &d[0], &d[1], &d[2], &d[3]); - // printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]); - return 1 - & (d[1] >> 5) // avx2 - // & (d[1] >> 31) // avx512vl - & (d[2] >> 9); // vaes // VEX-256/EVEX - } -} - -BoolInt CPU_IsSupported_PageGB() -{ - Cx86cpuid cpuid; - if (!x86cpuid_CheckAndRead(&cpuid)) - return False; - { - UInt32 d[4] = { 0 }; - MyCPUID(0x80000000, &d[0], &d[1], &d[2], &d[3]); - if (d[0] < 0x80000001) - return False; - } - { - UInt32 d[4] = { 0 }; - MyCPUID(0x80000001, &d[0], &d[1], &d[2], &d[3]); - return (d[3] >> 26) & 1; - } -} - - -#elif defined(MY_CPU_ARM_OR_ARM64) - -#ifdef _WIN32 - -#include - -BoolInt CPU_IsSupported_CRC32() - { return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } -BoolInt CPU_IsSupported_CRYPTO() - { return IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } - -#else - -#if defined(__APPLE__) - -/* -#include -#include -static void Print_sysctlbyname(const char *name) -{ - size_t bufSize = 256; - char buf[256]; - int res = sysctlbyname(name, &buf, &bufSize, NULL, 0); - { - int i; - printf("\nres = %d : %s : '%s' : bufSize = %d, numeric", res, name, buf, (unsigned)bufSize); - for (i = 0; i < 20; i++) - printf(" %2x", (unsigned)(Byte)buf[i]); - - } -} -*/ - -BoolInt CPU_IsSupported_CRC32(void) -{ - /* - Print_sysctlbyname("hw.pagesize"); - Print_sysctlbyname("machdep.cpu.brand_string"); - */ - - UInt32 val = 0; - if (My_sysctlbyname_Get_UInt32("hw.optional.armv8_crc32", &val) == 0 && val == 1) - return 1; - return 0; -} - -#ifdef MY_CPU_ARM64 -#define APPLE_CRYPTO_SUPPORT_VAL 1 -#else -#define APPLE_CRYPTO_SUPPORT_VAL 0 -#endif - -BoolInt CPU_IsSupported_SHA1(void) { return APPLE_CRYPTO_SUPPORT_VAL; } -BoolInt CPU_IsSupported_SHA2(void) { return APPLE_CRYPTO_SUPPORT_VAL; } -BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; } - - -#else // __APPLE__ - -#include - -#define USE_HWCAP - -#ifdef USE_HWCAP - -#include - -#ifdef MY_CPU_ARM64 - #define MY_HWCAP_CHECK_FUNC(name) \ - BoolInt CPU_IsSupported_ ## name() { return (getauxval(AT_HWCAP) & (HWCAP_ ## name)) ? 1 : 0; } -#elif defined(MY_CPU_ARM) - #define MY_HWCAP_CHECK_FUNC(name) \ - BoolInt CPU_IsSupported_ ## name() { return (getauxval(AT_HWCAP2) & (HWCAP2_ ## name)) ? 1 : 0; } -#endif - -#else // USE_HWCAP - - #define MY_HWCAP_CHECK_FUNC(name) \ - BoolInt CPU_IsSupported_ ## name() { return 0; } - -#endif // USE_HWCAP - -MY_HWCAP_CHECK_FUNC (CRC32) -MY_HWCAP_CHECK_FUNC (SHA1) -MY_HWCAP_CHECK_FUNC (SHA2) -MY_HWCAP_CHECK_FUNC (AES) - -#endif // __APPLE__ -#endif // _WIN32 - -#endif // MY_CPU_ARM_OR_ARM64 - - - -#ifdef __APPLE__ - -#include - -int My_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize) -{ - return sysctlbyname(name, buf, bufSize, NULL, 0); -} - -int My_sysctlbyname_Get_UInt32(const char *name, UInt32 *val) -{ - size_t bufSize = sizeof(*val); - int res = My_sysctlbyname_Get(name, val, &bufSize); - if (res == 0 && bufSize != sizeof(*val)) - return EFAULT; - return res; -} - -#endif +/* CpuArch.c -- CPU specific code +2021-07-13 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" + +#ifdef MY_CPU_X86_OR_AMD64 + +#if (defined(_MSC_VER) && !defined(MY_CPU_AMD64)) || defined(__GNUC__) +#define USE_ASM +#endif + +#if !defined(USE_ASM) && _MSC_VER >= 1500 +#include +#endif + +#if defined(USE_ASM) && !defined(MY_CPU_AMD64) +static UInt32 CheckFlag(UInt32 flag) +{ + #ifdef _MSC_VER + __asm pushfd; + __asm pop EAX; + __asm mov EDX, EAX; + __asm xor EAX, flag; + __asm push EAX; + __asm popfd; + __asm pushfd; + __asm pop EAX; + __asm xor EAX, EDX; + __asm push EDX; + __asm popfd; + __asm and flag, EAX; + #else + __asm__ __volatile__ ( + "pushf\n\t" + "pop %%EAX\n\t" + "movl %%EAX,%%EDX\n\t" + "xorl %0,%%EAX\n\t" + "push %%EAX\n\t" + "popf\n\t" + "pushf\n\t" + "pop %%EAX\n\t" + "xorl %%EDX,%%EAX\n\t" + "push %%EDX\n\t" + "popf\n\t" + "andl %%EAX, %0\n\t": + "=c" (flag) : "c" (flag) : + "%eax", "%edx"); + #endif + return flag; +} +#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False; +#else +#define CHECK_CPUID_IS_SUPPORTED +#endif + +#ifndef USE_ASM + #ifdef _MSC_VER + #if _MSC_VER >= 1600 + #define MY__cpuidex __cpuidex + #else + +/* + __cpuid (function == 4) requires subfunction number in ECX. + MSDN: The __cpuid intrinsic clears the ECX register before calling the cpuid instruction. + __cpuid() in new MSVC clears ECX. + __cpuid() in old MSVC (14.00) doesn't clear ECX + We still can use __cpuid for low (function) values that don't require ECX, + but __cpuid() in old MSVC will be incorrect for some function values: (function == 4). + So here we use the hack for old MSVC to send (subFunction) in ECX register to cpuid instruction, + where ECX value is first parameter for FAST_CALL / NO_INLINE function, + So the caller of MY__cpuidex_HACK() sets ECX as subFunction, and + old MSVC for __cpuid() doesn't change ECX and cpuid instruction gets (subFunction) value. + + DON'T remove MY_NO_INLINE and MY_FAST_CALL for MY__cpuidex_HACK() !!! +*/ + +static +MY_NO_INLINE +void MY_FAST_CALL MY__cpuidex_HACK(UInt32 subFunction, int *CPUInfo, UInt32 function) +{ + UNUSED_VAR(subFunction); + __cpuid(CPUInfo, function); +} + + #define MY__cpuidex(info, func, func2) MY__cpuidex_HACK(func2, info, func) + #pragma message("======== MY__cpuidex_HACK WAS USED ========") + #endif + #else + #define MY__cpuidex(info, func, func2) __cpuid(info, func) + #pragma message("======== (INCORRECT ?) cpuid WAS USED ========") + #endif +#endif + + + + +void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) +{ + #ifdef USE_ASM + + #ifdef _MSC_VER + + UInt32 a2, b2, c2, d2; + __asm xor EBX, EBX; + __asm xor ECX, ECX; + __asm xor EDX, EDX; + __asm mov EAX, function; + __asm cpuid; + __asm mov a2, EAX; + __asm mov b2, EBX; + __asm mov c2, ECX; + __asm mov d2, EDX; + + *a = a2; + *b = b2; + *c = c2; + *d = d2; + + #else + + __asm__ __volatile__ ( + #if defined(MY_CPU_AMD64) && defined(__PIC__) + "mov %%rbx, %%rdi;" + "cpuid;" + "xchg %%rbx, %%rdi;" + : "=a" (*a) , + "=D" (*b) , + #elif defined(MY_CPU_X86) && defined(__PIC__) + "mov %%ebx, %%edi;" + "cpuid;" + "xchgl %%ebx, %%edi;" + : "=a" (*a) , + "=D" (*b) , + #else + "cpuid" + : "=a" (*a) , + "=b" (*b) , + #endif + "=c" (*c) , + "=d" (*d) + : "0" (function), "c"(0) ) ; + + #endif + + #else + + int CPUInfo[4]; + + MY__cpuidex(CPUInfo, (int)function, 0); + + *a = (UInt32)CPUInfo[0]; + *b = (UInt32)CPUInfo[1]; + *c = (UInt32)CPUInfo[2]; + *d = (UInt32)CPUInfo[3]; + + #endif +} + +BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p) +{ + CHECK_CPUID_IS_SUPPORTED + MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]); + MyCPUID(1, &p->ver, &p->b, &p->c, &p->d); + return True; +} + +static const UInt32 kVendors[][3] = +{ + { 0x756E6547, 0x49656E69, 0x6C65746E}, + { 0x68747541, 0x69746E65, 0x444D4163}, + { 0x746E6543, 0x48727561, 0x736C7561} +}; + +int x86cpuid_GetFirm(const Cx86cpuid *p) +{ + unsigned i; + for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++) + { + const UInt32 *v = kVendors[i]; + if (v[0] == p->vendor[0] && + v[1] == p->vendor[1] && + v[2] == p->vendor[2]) + return (int)i; + } + return -1; +} + +BoolInt CPU_Is_InOrder() +{ + Cx86cpuid p; + int firm; + UInt32 family, model; + if (!x86cpuid_CheckAndRead(&p)) + return True; + + family = x86cpuid_GetFamily(p.ver); + model = x86cpuid_GetModel(p.ver); + + firm = x86cpuid_GetFirm(&p); + + switch (firm) + { + case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && ( + /* In-Order Atom CPU */ + model == 0x1C /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */ + || model == 0x26 /* 45 nm, Z6xx */ + || model == 0x27 /* 32 nm, Z2460 */ + || model == 0x35 /* 32 nm, Z2760 */ + || model == 0x36 /* 32 nm, N2xxx, D2xxx */ + ))); + case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA))); + case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF)); + } + return True; +} + +#if !defined(MY_CPU_AMD64) && defined(_WIN32) +#include +static BoolInt CPU_Sys_Is_SSE_Supported() +{ + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + if (!GetVersionEx(&vi)) + return False; + return (vi.dwMajorVersion >= 5); +} +#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False; +#else +#define CHECK_SYS_SSE_SUPPORT +#endif + + +static UInt32 X86_CPUID_ECX_Get_Flags() +{ + Cx86cpuid p; + CHECK_SYS_SSE_SUPPORT + if (!x86cpuid_CheckAndRead(&p)) + return 0; + return p.c; +} + +BoolInt CPU_IsSupported_AES() +{ + return (X86_CPUID_ECX_Get_Flags() >> 25) & 1; +} + +BoolInt CPU_IsSupported_SSSE3() +{ + return (X86_CPUID_ECX_Get_Flags() >> 9) & 1; +} + +BoolInt CPU_IsSupported_SSE41() +{ + return (X86_CPUID_ECX_Get_Flags() >> 19) & 1; +} + +BoolInt CPU_IsSupported_SHA() +{ + Cx86cpuid p; + CHECK_SYS_SSE_SUPPORT + if (!x86cpuid_CheckAndRead(&p)) + return False; + + if (p.maxFunc < 7) + return False; + { + UInt32 d[4] = { 0 }; + MyCPUID(7, &d[0], &d[1], &d[2], &d[3]); + return (d[1] >> 29) & 1; + } +} + +// #include + +#ifdef _WIN32 +#include +#endif + +BoolInt CPU_IsSupported_AVX2() +{ + Cx86cpuid p; + CHECK_SYS_SSE_SUPPORT + + #ifdef _WIN32 + #define MY__PF_XSAVE_ENABLED 17 + if (!IsProcessorFeaturePresent(MY__PF_XSAVE_ENABLED)) + return False; + #endif + + if (!x86cpuid_CheckAndRead(&p)) + return False; + if (p.maxFunc < 7) + return False; + { + UInt32 d[4] = { 0 }; + MyCPUID(7, &d[0], &d[1], &d[2], &d[3]); + // printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]); + return 1 + & (d[1] >> 5); // avx2 + } +} + +BoolInt CPU_IsSupported_VAES_AVX2() +{ + Cx86cpuid p; + CHECK_SYS_SSE_SUPPORT + + #ifdef _WIN32 + #define MY__PF_XSAVE_ENABLED 17 + if (!IsProcessorFeaturePresent(MY__PF_XSAVE_ENABLED)) + return False; + #endif + + if (!x86cpuid_CheckAndRead(&p)) + return False; + if (p.maxFunc < 7) + return False; + { + UInt32 d[4] = { 0 }; + MyCPUID(7, &d[0], &d[1], &d[2], &d[3]); + // printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]); + return 1 + & (d[1] >> 5) // avx2 + // & (d[1] >> 31) // avx512vl + & (d[2] >> 9); // vaes // VEX-256/EVEX + } +} + +BoolInt CPU_IsSupported_PageGB() +{ + Cx86cpuid cpuid; + if (!x86cpuid_CheckAndRead(&cpuid)) + return False; + { + UInt32 d[4] = { 0 }; + MyCPUID(0x80000000, &d[0], &d[1], &d[2], &d[3]); + if (d[0] < 0x80000001) + return False; + } + { + UInt32 d[4] = { 0 }; + MyCPUID(0x80000001, &d[0], &d[1], &d[2], &d[3]); + return (d[3] >> 26) & 1; + } +} + + +#elif defined(MY_CPU_ARM_OR_ARM64) + +#ifdef _WIN32 + +#include + +BoolInt CPU_IsSupported_CRC32() { return IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } +BoolInt CPU_IsSupported_CRYPTO() { return IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } +BoolInt CPU_IsSupported_NEON() { return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) ? 1 : 0; } + +#else + +#if defined(__APPLE__) + +/* +#include +#include +static void Print_sysctlbyname(const char *name) +{ + size_t bufSize = 256; + char buf[256]; + int res = sysctlbyname(name, &buf, &bufSize, NULL, 0); + { + int i; + printf("\nres = %d : %s : '%s' : bufSize = %d, numeric", res, name, buf, (unsigned)bufSize); + for (i = 0; i < 20; i++) + printf(" %2x", (unsigned)(Byte)buf[i]); + + } +} +*/ + +static BoolInt My_sysctlbyname_Get_BoolInt(const char *name) +{ + UInt32 val = 0; + if (My_sysctlbyname_Get_UInt32(name, &val) == 0 && val == 1) + return 1; + return 0; +} + + /* + Print_sysctlbyname("hw.pagesize"); + Print_sysctlbyname("machdep.cpu.brand_string"); + */ + +BoolInt CPU_IsSupported_CRC32(void) +{ + return My_sysctlbyname_Get_BoolInt("hw.optional.armv8_crc32"); +} + +BoolInt CPU_IsSupported_NEON(void) +{ + return My_sysctlbyname_Get_BoolInt("hw.optional.neon"); +} + +#ifdef MY_CPU_ARM64 +#define APPLE_CRYPTO_SUPPORT_VAL 1 +#else +#define APPLE_CRYPTO_SUPPORT_VAL 0 +#endif + +BoolInt CPU_IsSupported_SHA1(void) { return APPLE_CRYPTO_SUPPORT_VAL; } +BoolInt CPU_IsSupported_SHA2(void) { return APPLE_CRYPTO_SUPPORT_VAL; } +BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; } + + +#else // __APPLE__ + +#include + +#define USE_HWCAP + +#ifdef USE_HWCAP + +#include + + #define MY_HWCAP_CHECK_FUNC_2(name1, name2) \ + BoolInt CPU_IsSupported_ ## name1() { return (getauxval(AT_HWCAP) & (HWCAP_ ## name2)) ? 1 : 0; } + +#ifdef MY_CPU_ARM64 + #define MY_HWCAP_CHECK_FUNC(name) \ + MY_HWCAP_CHECK_FUNC_2(name, name) + MY_HWCAP_CHECK_FUNC_2(NEON, ASIMD) +// MY_HWCAP_CHECK_FUNC (ASIMD) +#elif defined(MY_CPU_ARM) + #define MY_HWCAP_CHECK_FUNC(name) \ + BoolInt CPU_IsSupported_ ## name() { return (getauxval(AT_HWCAP2) & (HWCAP2_ ## name)) ? 1 : 0; } + MY_HWCAP_CHECK_FUNC_2(NEON, NEON) +#endif + +#else // USE_HWCAP + + #define MY_HWCAP_CHECK_FUNC(name) \ + BoolInt CPU_IsSupported_ ## name() { return 0; } + MY_HWCAP_CHECK_FUNC(NEON) + +#endif // USE_HWCAP + +MY_HWCAP_CHECK_FUNC (CRC32) +MY_HWCAP_CHECK_FUNC (SHA1) +MY_HWCAP_CHECK_FUNC (SHA2) +MY_HWCAP_CHECK_FUNC (AES) + +#endif // __APPLE__ +#endif // _WIN32 + +#endif // MY_CPU_ARM_OR_ARM64 + + + +#ifdef __APPLE__ + +#include + +int My_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize) +{ + return sysctlbyname(name, buf, bufSize, NULL, 0); +} + +int My_sysctlbyname_Get_UInt32(const char *name, UInt32 *val) +{ + size_t bufSize = sizeof(*val); + int res = My_sysctlbyname_Get(name, val, &bufSize); + if (res == 0 && bufSize != sizeof(*val)) + return EFAULT; + return res; +} + +#endif diff --git a/deps/LZMA-SDK/C/CpuArch.h b/deps/LZMA-SDK/C/CpuArch.h index e1cde536d..4856fbb12 100644 --- a/deps/LZMA-SDK/C/CpuArch.h +++ b/deps/LZMA-SDK/C/CpuArch.h @@ -1,425 +1,445 @@ -/* CpuArch.h -- CPU specific code -2021-04-25 : Igor Pavlov : Public domain */ - -#ifndef __CPU_ARCH_H -#define __CPU_ARCH_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -/* -MY_CPU_LE means that CPU is LITTLE ENDIAN. -MY_CPU_BE means that CPU is BIG ENDIAN. -If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform. - -MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. - -MY_CPU_64BIT means that processor can work with 64-bit registers. - MY_CPU_64BIT can be used to select fast code branch - MY_CPU_64BIT doesn't mean that (sizeof(void *) == 8) -*/ - -#if defined(_M_X64) \ - || defined(_M_AMD64) \ - || defined(__x86_64__) \ - || defined(__AMD64__) \ - || defined(__amd64__) - #define MY_CPU_AMD64 - #ifdef __ILP32__ - #define MY_CPU_NAME "x32" - #define MY_CPU_SIZEOF_POINTER 4 - #else - #define MY_CPU_NAME "x64" - #define MY_CPU_SIZEOF_POINTER 8 - #endif - #define MY_CPU_64BIT -#endif - - -#if defined(_M_IX86) \ - || defined(__i386__) - #define MY_CPU_X86 - #define MY_CPU_NAME "x86" - /* #define MY_CPU_32BIT */ - #define MY_CPU_SIZEOF_POINTER 4 -#endif - - -#if defined(_M_ARM64) \ - || defined(__AARCH64EL__) \ - || defined(__AARCH64EB__) \ - || defined(__aarch64__) - #define MY_CPU_ARM64 - #define MY_CPU_NAME "arm64" - #define MY_CPU_64BIT -#endif - - -#if defined(_M_ARM) \ - || defined(_M_ARM_NT) \ - || defined(_M_ARMT) \ - || defined(__arm__) \ - || defined(__thumb__) \ - || defined(__ARMEL__) \ - || defined(__ARMEB__) \ - || defined(__THUMBEL__) \ - || defined(__THUMBEB__) - #define MY_CPU_ARM - - #if defined(__thumb__) || defined(__THUMBEL__) || defined(_M_ARMT) - #define MY_CPU_NAME "armt" - #else - #define MY_CPU_NAME "arm" - #endif - /* #define MY_CPU_32BIT */ - #define MY_CPU_SIZEOF_POINTER 4 -#endif - - -#if defined(_M_IA64) \ - || defined(__ia64__) - #define MY_CPU_IA64 - #define MY_CPU_NAME "ia64" - #define MY_CPU_64BIT -#endif - - -#if defined(__mips64) \ - || defined(__mips64__) \ - || (defined(__mips) && (__mips == 64 || __mips == 4 || __mips == 3)) - #define MY_CPU_NAME "mips64" - #define MY_CPU_64BIT -#elif defined(__mips__) - #define MY_CPU_NAME "mips" - /* #define MY_CPU_32BIT */ -#endif - - -#if defined(__ppc64__) \ - || defined(__powerpc64__) \ - || defined(__ppc__) \ - || defined(__powerpc__) \ - || defined(__PPC__) \ - || defined(_POWER) - -#if defined(__ppc64__) \ - || defined(__powerpc64__) \ - || defined(_LP64) \ - || defined(__64BIT__) - #ifdef __ILP32__ - #define MY_CPU_NAME "ppc64-32" - #define MY_CPU_SIZEOF_POINTER 4 - #else - #define MY_CPU_NAME "ppc64" - #define MY_CPU_SIZEOF_POINTER 8 - #endif - #define MY_CPU_64BIT -#else - #define MY_CPU_NAME "ppc" - #define MY_CPU_SIZEOF_POINTER 4 - /* #define MY_CPU_32BIT */ -#endif -#endif - - -#if defined(__sparc64__) - #define MY_CPU_NAME "sparc64" - #define MY_CPU_64BIT -#elif defined(__sparc__) - #define MY_CPU_NAME "sparc" - /* #define MY_CPU_32BIT */ -#endif - - -#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) -#define MY_CPU_X86_OR_AMD64 -#endif - -#if defined(MY_CPU_ARM) || defined(MY_CPU_ARM64) -#define MY_CPU_ARM_OR_ARM64 -#endif - - -#ifdef _WIN32 - - #ifdef MY_CPU_ARM - #define MY_CPU_ARM_LE - #endif - - #ifdef MY_CPU_ARM64 - #define MY_CPU_ARM64_LE - #endif - - #ifdef _M_IA64 - #define MY_CPU_IA64_LE - #endif - -#endif - - -#if defined(MY_CPU_X86_OR_AMD64) \ - || defined(MY_CPU_ARM_LE) \ - || defined(MY_CPU_ARM64_LE) \ - || defined(MY_CPU_IA64_LE) \ - || defined(__LITTLE_ENDIAN__) \ - || defined(__ARMEL__) \ - || defined(__THUMBEL__) \ - || defined(__AARCH64EL__) \ - || defined(__MIPSEL__) \ - || defined(__MIPSEL) \ - || defined(_MIPSEL) \ - || defined(__BFIN__) \ - || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) - #define MY_CPU_LE -#endif - -#if defined(__BIG_ENDIAN__) \ - || defined(__ARMEB__) \ - || defined(__THUMBEB__) \ - || defined(__AARCH64EB__) \ - || defined(__MIPSEB__) \ - || defined(__MIPSEB) \ - || defined(_MIPSEB) \ - || defined(__m68k__) \ - || defined(__s390__) \ - || defined(__s390x__) \ - || defined(__zarch__) \ - || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) - #define MY_CPU_BE -#endif - - -#if defined(MY_CPU_LE) && defined(MY_CPU_BE) - #error Stop_Compiling_Bad_Endian -#endif - - -#if defined(MY_CPU_32BIT) && defined(MY_CPU_64BIT) - #error Stop_Compiling_Bad_32_64_BIT -#endif - -#ifdef __SIZEOF_POINTER__ - #ifdef MY_CPU_SIZEOF_POINTER - #if MY_CPU_SIZEOF_POINTER != __SIZEOF_POINTER__ - #error Stop_Compiling_Bad_MY_CPU_PTR_SIZE - #endif - #else - #define MY_CPU_SIZEOF_POINTER __SIZEOF_POINTER__ - #endif -#endif - -#if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4) -#if defined (_LP64) - #error Stop_Compiling_Bad_MY_CPU_PTR_SIZE -#endif -#endif - -#ifdef _MSC_VER - #if _MSC_VER >= 1300 - #define MY_CPU_pragma_pack_push_1 __pragma(pack(push, 1)) - #define MY_CPU_pragma_pop __pragma(pack(pop)) - #else - #define MY_CPU_pragma_pack_push_1 - #define MY_CPU_pragma_pop - #endif -#else - #ifdef __xlC__ - // for XLC compiler: - #define MY_CPU_pragma_pack_push_1 _Pragma("pack(1)") - #define MY_CPU_pragma_pop _Pragma("pack()") - #else - #define MY_CPU_pragma_pack_push_1 _Pragma("pack(push, 1)") - #define MY_CPU_pragma_pop _Pragma("pack(pop)") - #endif -#endif - - -#ifndef MY_CPU_NAME - #ifdef MY_CPU_LE - #define MY_CPU_NAME "LE" - #elif defined(MY_CPU_BE) - #define MY_CPU_NAME "BE" - #else - /* - #define MY_CPU_NAME "" - */ - #endif -#endif - - - - - -#ifdef MY_CPU_LE - #if defined(MY_CPU_X86_OR_AMD64) \ - || defined(MY_CPU_ARM64) \ - || defined(__ARM_FEATURE_UNALIGNED) - #define MY_CPU_LE_UNALIGN - #endif -#endif - - -#ifdef MY_CPU_LE_UNALIGN - -#define GetUi16(p) (*(const UInt16 *)(const void *)(p)) -#define GetUi32(p) (*(const UInt32 *)(const void *)(p)) -#define GetUi64(p) (*(const UInt64 *)(const void *)(p)) - -#define SetUi16(p, v) { *(UInt16 *)(void *)(p) = (v); } -#define SetUi32(p, v) { *(UInt32 *)(void *)(p) = (v); } -#define SetUi64(p, v) { *(UInt64 *)(void *)(p) = (v); } - -#else - -#define GetUi16(p) ( (UInt16) ( \ - ((const Byte *)(p))[0] | \ - ((UInt16)((const Byte *)(p))[1] << 8) )) - -#define GetUi32(p) ( \ - ((const Byte *)(p))[0] | \ - ((UInt32)((const Byte *)(p))[1] << 8) | \ - ((UInt32)((const Byte *)(p))[2] << 16) | \ - ((UInt32)((const Byte *)(p))[3] << 24)) - -#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) - -#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ - _ppp_[0] = (Byte)_vvv_; \ - _ppp_[1] = (Byte)(_vvv_ >> 8); } - -#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ - _ppp_[0] = (Byte)_vvv_; \ - _ppp_[1] = (Byte)(_vvv_ >> 8); \ - _ppp_[2] = (Byte)(_vvv_ >> 16); \ - _ppp_[3] = (Byte)(_vvv_ >> 24); } - -#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \ - SetUi32(_ppp2_ , (UInt32)_vvv2_); \ - SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); } - -#endif - -#ifdef __has_builtin - #define MY__has_builtin(x) __has_builtin(x) -#else - #define MY__has_builtin(x) 0 -#endif - -#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ defined(_MSC_VER) && (_MSC_VER >= 1300) - -/* Note: we use bswap instruction, that is unsupported in 386 cpu */ - -#include - -#pragma intrinsic(_byteswap_ushort) -#pragma intrinsic(_byteswap_ulong) -#pragma intrinsic(_byteswap_uint64) - -/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */ -#define GetBe32(p) _byteswap_ulong (*(const UInt32 *)(const void *)(p)) -#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const void *)(p)) - -#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v) - -#elif defined(MY_CPU_LE_UNALIGN) && ( \ - (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \ - || (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) ) - -/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const void *)(p)) */ -#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const void *)(p)) -#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const void *)(p)) - -#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v) - -#else - -#define GetBe32(p) ( \ - ((UInt32)((const Byte *)(p))[0] << 24) | \ - ((UInt32)((const Byte *)(p))[1] << 16) | \ - ((UInt32)((const Byte *)(p))[2] << 8) | \ - ((const Byte *)(p))[3] ) - -#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) - -#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ - _ppp_[0] = (Byte)(_vvv_ >> 24); \ - _ppp_[1] = (Byte)(_vvv_ >> 16); \ - _ppp_[2] = (Byte)(_vvv_ >> 8); \ - _ppp_[3] = (Byte)_vvv_; } - -#endif - - -#ifndef GetBe16 - -#define GetBe16(p) ( (UInt16) ( \ - ((UInt16)((const Byte *)(p))[0] << 8) | \ - ((const Byte *)(p))[1] )) - -#endif - - - -#ifdef MY_CPU_X86_OR_AMD64 - -typedef struct -{ - UInt32 maxFunc; - UInt32 vendor[3]; - UInt32 ver; - UInt32 b; - UInt32 c; - UInt32 d; -} Cx86cpuid; - -enum -{ - CPU_FIRM_INTEL, - CPU_FIRM_AMD, - CPU_FIRM_VIA -}; - -void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d); - -BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p); -int x86cpuid_GetFirm(const Cx86cpuid *p); - -#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF)) -#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF)) -#define x86cpuid_GetStepping(ver) (ver & 0xF) - -BoolInt CPU_Is_InOrder(void); - -BoolInt CPU_IsSupported_AES(void); -BoolInt CPU_IsSupported_VAES_AVX2(void); -BoolInt CPU_IsSupported_SSSE3(void); -BoolInt CPU_IsSupported_SSE41(void); -BoolInt CPU_IsSupported_SHA(void); -BoolInt CPU_IsSupported_PageGB(void); - -#elif defined(MY_CPU_ARM_OR_ARM64) - -BoolInt CPU_IsSupported_CRC32(void); - -#if defined(_WIN32) -BoolInt CPU_IsSupported_CRYPTO(void); -#define CPU_IsSupported_SHA1 CPU_IsSupported_CRYPTO -#define CPU_IsSupported_SHA2 CPU_IsSupported_CRYPTO -#define CPU_IsSupported_AES CPU_IsSupported_CRYPTO -#else -BoolInt CPU_IsSupported_SHA1(void); -BoolInt CPU_IsSupported_SHA2(void); -BoolInt CPU_IsSupported_AES(void); -#endif - -#endif - -#if defined(__APPLE__) -int My_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize); -int My_sysctlbyname_Get_UInt32(const char *name, UInt32 *val); -#endif - -EXTERN_C_END - -#endif +/* CpuArch.h -- CPU specific code +2022-07-15 : Igor Pavlov : Public domain */ + +#ifndef __CPU_ARCH_H +#define __CPU_ARCH_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +/* +MY_CPU_LE means that CPU is LITTLE ENDIAN. +MY_CPU_BE means that CPU is BIG ENDIAN. +If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform. + +MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. + +MY_CPU_64BIT means that processor can work with 64-bit registers. + MY_CPU_64BIT can be used to select fast code branch + MY_CPU_64BIT doesn't mean that (sizeof(void *) == 8) +*/ + +#if defined(_M_X64) \ + || defined(_M_AMD64) \ + || defined(__x86_64__) \ + || defined(__AMD64__) \ + || defined(__amd64__) + #define MY_CPU_AMD64 + #ifdef __ILP32__ + #define MY_CPU_NAME "x32" + #define MY_CPU_SIZEOF_POINTER 4 + #else + #define MY_CPU_NAME "x64" + #define MY_CPU_SIZEOF_POINTER 8 + #endif + #define MY_CPU_64BIT +#endif + + +#if defined(_M_IX86) \ + || defined(__i386__) + #define MY_CPU_X86 + #define MY_CPU_NAME "x86" + /* #define MY_CPU_32BIT */ + #define MY_CPU_SIZEOF_POINTER 4 +#endif + + +#if defined(_M_ARM64) \ + || defined(__AARCH64EL__) \ + || defined(__AARCH64EB__) \ + || defined(__aarch64__) + #define MY_CPU_ARM64 + #define MY_CPU_NAME "arm64" + #define MY_CPU_64BIT +#endif + + +#if defined(_M_ARM) \ + || defined(_M_ARM_NT) \ + || defined(_M_ARMT) \ + || defined(__arm__) \ + || defined(__thumb__) \ + || defined(__ARMEL__) \ + || defined(__ARMEB__) \ + || defined(__THUMBEL__) \ + || defined(__THUMBEB__) + #define MY_CPU_ARM + + #if defined(__thumb__) || defined(__THUMBEL__) || defined(_M_ARMT) + #define MY_CPU_NAME "armt" + #else + #define MY_CPU_NAME "arm" + #endif + /* #define MY_CPU_32BIT */ + #define MY_CPU_SIZEOF_POINTER 4 +#endif + + +#if defined(_M_IA64) \ + || defined(__ia64__) + #define MY_CPU_IA64 + #define MY_CPU_NAME "ia64" + #define MY_CPU_64BIT +#endif + + +#if defined(__mips64) \ + || defined(__mips64__) \ + || (defined(__mips) && (__mips == 64 || __mips == 4 || __mips == 3)) + #define MY_CPU_NAME "mips64" + #define MY_CPU_64BIT +#elif defined(__mips__) + #define MY_CPU_NAME "mips" + /* #define MY_CPU_32BIT */ +#endif + + +#if defined(__ppc64__) \ + || defined(__powerpc64__) \ + || defined(__ppc__) \ + || defined(__powerpc__) \ + || defined(__PPC__) \ + || defined(_POWER) + +#if defined(__ppc64__) \ + || defined(__powerpc64__) \ + || defined(_LP64) \ + || defined(__64BIT__) + #ifdef __ILP32__ + #define MY_CPU_NAME "ppc64-32" + #define MY_CPU_SIZEOF_POINTER 4 + #else + #define MY_CPU_NAME "ppc64" + #define MY_CPU_SIZEOF_POINTER 8 + #endif + #define MY_CPU_64BIT +#else + #define MY_CPU_NAME "ppc" + #define MY_CPU_SIZEOF_POINTER 4 + /* #define MY_CPU_32BIT */ +#endif +#endif + + +#if defined(__riscv) \ + || defined(__riscv__) + #if __riscv_xlen == 32 + #define MY_CPU_NAME "riscv32" + #elif __riscv_xlen == 64 + #define MY_CPU_NAME "riscv64" + #else + #define MY_CPU_NAME "riscv" + #endif +#endif + + +#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) +#define MY_CPU_X86_OR_AMD64 +#endif + +#if defined(MY_CPU_ARM) || defined(MY_CPU_ARM64) +#define MY_CPU_ARM_OR_ARM64 +#endif + + +#ifdef _WIN32 + + #ifdef MY_CPU_ARM + #define MY_CPU_ARM_LE + #endif + + #ifdef MY_CPU_ARM64 + #define MY_CPU_ARM64_LE + #endif + + #ifdef _M_IA64 + #define MY_CPU_IA64_LE + #endif + +#endif + + +#if defined(MY_CPU_X86_OR_AMD64) \ + || defined(MY_CPU_ARM_LE) \ + || defined(MY_CPU_ARM64_LE) \ + || defined(MY_CPU_IA64_LE) \ + || defined(__LITTLE_ENDIAN__) \ + || defined(__ARMEL__) \ + || defined(__THUMBEL__) \ + || defined(__AARCH64EL__) \ + || defined(__MIPSEL__) \ + || defined(__MIPSEL) \ + || defined(_MIPSEL) \ + || defined(__BFIN__) \ + || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) + #define MY_CPU_LE +#endif + +#if defined(__BIG_ENDIAN__) \ + || defined(__ARMEB__) \ + || defined(__THUMBEB__) \ + || defined(__AARCH64EB__) \ + || defined(__MIPSEB__) \ + || defined(__MIPSEB) \ + || defined(_MIPSEB) \ + || defined(__m68k__) \ + || defined(__s390__) \ + || defined(__s390x__) \ + || defined(__zarch__) \ + || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) + #define MY_CPU_BE +#endif + + +#if defined(MY_CPU_LE) && defined(MY_CPU_BE) + #error Stop_Compiling_Bad_Endian +#endif + + +#if defined(MY_CPU_32BIT) && defined(MY_CPU_64BIT) + #error Stop_Compiling_Bad_32_64_BIT +#endif + +#ifdef __SIZEOF_POINTER__ + #ifdef MY_CPU_SIZEOF_POINTER + #if MY_CPU_SIZEOF_POINTER != __SIZEOF_POINTER__ + #error Stop_Compiling_Bad_MY_CPU_PTR_SIZE + #endif + #else + #define MY_CPU_SIZEOF_POINTER __SIZEOF_POINTER__ + #endif +#endif + +#if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4) +#if defined (_LP64) + #error Stop_Compiling_Bad_MY_CPU_PTR_SIZE +#endif +#endif + +#ifdef _MSC_VER + #if _MSC_VER >= 1300 + #define MY_CPU_pragma_pack_push_1 __pragma(pack(push, 1)) + #define MY_CPU_pragma_pop __pragma(pack(pop)) + #else + #define MY_CPU_pragma_pack_push_1 + #define MY_CPU_pragma_pop + #endif +#else + #ifdef __xlC__ + #define MY_CPU_pragma_pack_push_1 _Pragma("pack(1)") + #define MY_CPU_pragma_pop _Pragma("pack()") + #else + #define MY_CPU_pragma_pack_push_1 _Pragma("pack(push, 1)") + #define MY_CPU_pragma_pop _Pragma("pack(pop)") + #endif +#endif + + +#ifndef MY_CPU_NAME + #ifdef MY_CPU_LE + #define MY_CPU_NAME "LE" + #elif defined(MY_CPU_BE) + #define MY_CPU_NAME "BE" + #else + /* + #define MY_CPU_NAME "" + */ + #endif +#endif + + + + + +#ifdef MY_CPU_LE + #if defined(MY_CPU_X86_OR_AMD64) \ + || defined(MY_CPU_ARM64) + #define MY_CPU_LE_UNALIGN + #define MY_CPU_LE_UNALIGN_64 + #elif defined(__ARM_FEATURE_UNALIGNED) + /* gcc9 for 32-bit arm can use LDRD instruction that requires 32-bit alignment. + So we can't use unaligned 64-bit operations. */ + #define MY_CPU_LE_UNALIGN + #endif +#endif + + +#ifdef MY_CPU_LE_UNALIGN + +#define GetUi16(p) (*(const UInt16 *)(const void *)(p)) +#define GetUi32(p) (*(const UInt32 *)(const void *)(p)) +#ifdef MY_CPU_LE_UNALIGN_64 +#define GetUi64(p) (*(const UInt64 *)(const void *)(p)) +#endif + +#define SetUi16(p, v) { *(UInt16 *)(void *)(p) = (v); } +#define SetUi32(p, v) { *(UInt32 *)(void *)(p) = (v); } +#ifdef MY_CPU_LE_UNALIGN_64 +#define SetUi64(p, v) { *(UInt64 *)(void *)(p) = (v); } +#endif + +#else + +#define GetUi16(p) ( (UInt16) ( \ + ((const Byte *)(p))[0] | \ + ((UInt16)((const Byte *)(p))[1] << 8) )) + +#define GetUi32(p) ( \ + ((const Byte *)(p))[0] | \ + ((UInt32)((const Byte *)(p))[1] << 8) | \ + ((UInt32)((const Byte *)(p))[2] << 16) | \ + ((UInt32)((const Byte *)(p))[3] << 24)) + +#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ + _ppp_[0] = (Byte)_vvv_; \ + _ppp_[1] = (Byte)(_vvv_ >> 8); } + +#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ + _ppp_[0] = (Byte)_vvv_; \ + _ppp_[1] = (Byte)(_vvv_ >> 8); \ + _ppp_[2] = (Byte)(_vvv_ >> 16); \ + _ppp_[3] = (Byte)(_vvv_ >> 24); } + +#endif + + +#ifndef MY_CPU_LE_UNALIGN_64 + +#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) + +#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \ + SetUi32(_ppp2_ , (UInt32)_vvv2_); \ + SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); } + +#endif + + + + +#ifdef __has_builtin + #define MY__has_builtin(x) __has_builtin(x) +#else + #define MY__has_builtin(x) 0 +#endif + +#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ defined(_MSC_VER) && (_MSC_VER >= 1300) + +/* Note: we use bswap instruction, that is unsupported in 386 cpu */ + +#include + +#pragma intrinsic(_byteswap_ushort) +#pragma intrinsic(_byteswap_ulong) +#pragma intrinsic(_byteswap_uint64) + +/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */ +#define GetBe32(p) _byteswap_ulong (*(const UInt32 *)(const void *)(p)) +#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const void *)(p)) + +#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v) + +#elif defined(MY_CPU_LE_UNALIGN) && ( \ + (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \ + || (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) ) + +/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const void *)(p)) */ +#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const void *)(p)) +#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const void *)(p)) + +#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v) + +#else + +#define GetBe32(p) ( \ + ((UInt32)((const Byte *)(p))[0] << 24) | \ + ((UInt32)((const Byte *)(p))[1] << 16) | \ + ((UInt32)((const Byte *)(p))[2] << 8) | \ + ((const Byte *)(p))[3] ) + +#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) + +#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \ + _ppp_[0] = (Byte)(_vvv_ >> 24); \ + _ppp_[1] = (Byte)(_vvv_ >> 16); \ + _ppp_[2] = (Byte)(_vvv_ >> 8); \ + _ppp_[3] = (Byte)_vvv_; } + +#endif + + +#ifndef GetBe16 + +#define GetBe16(p) ( (UInt16) ( \ + ((UInt16)((const Byte *)(p))[0] << 8) | \ + ((const Byte *)(p))[1] )) + +#endif + + + +#ifdef MY_CPU_X86_OR_AMD64 + +typedef struct +{ + UInt32 maxFunc; + UInt32 vendor[3]; + UInt32 ver; + UInt32 b; + UInt32 c; + UInt32 d; +} Cx86cpuid; + +enum +{ + CPU_FIRM_INTEL, + CPU_FIRM_AMD, + CPU_FIRM_VIA +}; + +void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d); + +BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p); +int x86cpuid_GetFirm(const Cx86cpuid *p); + +#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF)) +#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF)) +#define x86cpuid_GetStepping(ver) (ver & 0xF) + +BoolInt CPU_Is_InOrder(void); + +BoolInt CPU_IsSupported_AES(void); +BoolInt CPU_IsSupported_AVX2(void); +BoolInt CPU_IsSupported_VAES_AVX2(void); +BoolInt CPU_IsSupported_SSSE3(void); +BoolInt CPU_IsSupported_SSE41(void); +BoolInt CPU_IsSupported_SHA(void); +BoolInt CPU_IsSupported_PageGB(void); + +#elif defined(MY_CPU_ARM_OR_ARM64) + +BoolInt CPU_IsSupported_CRC32(void); +BoolInt CPU_IsSupported_NEON(void); + +#if defined(_WIN32) +BoolInt CPU_IsSupported_CRYPTO(void); +#define CPU_IsSupported_SHA1 CPU_IsSupported_CRYPTO +#define CPU_IsSupported_SHA2 CPU_IsSupported_CRYPTO +#define CPU_IsSupported_AES CPU_IsSupported_CRYPTO +#else +BoolInt CPU_IsSupported_SHA1(void); +BoolInt CPU_IsSupported_SHA2(void); +BoolInt CPU_IsSupported_AES(void); +#endif + +#endif + +#if defined(__APPLE__) +int My_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize); +int My_sysctlbyname_Get_UInt32(const char *name, UInt32 *val); +#endif + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Delta.c b/deps/LZMA-SDK/C/Delta.c index fc7e9fe96..c4a4499fe 100644 --- a/deps/LZMA-SDK/C/Delta.c +++ b/deps/LZMA-SDK/C/Delta.c @@ -1,169 +1,169 @@ -/* Delta.c -- Delta converter -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "Delta.h" - -void Delta_Init(Byte *state) -{ - unsigned i; - for (i = 0; i < DELTA_STATE_SIZE; i++) - state[i] = 0; -} - - -void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size) -{ - Byte temp[DELTA_STATE_SIZE]; - - if (size == 0) - return; - - { - unsigned i = 0; - do - temp[i] = state[i]; - while (++i != delta); - } - - if (size <= delta) - { - unsigned i = 0, k; - do - { - Byte b = *data; - *data++ = (Byte)(b - temp[i]); - temp[i] = b; - } - while (++i != size); - - k = 0; - - do - { - if (i == delta) - i = 0; - state[k] = temp[i++]; - } - while (++k != delta); - - return; - } - - { - Byte *p = data + size - delta; - { - unsigned i = 0; - do - state[i] = *p++; - while (++i != delta); - } - { - const Byte *lim = data + delta; - ptrdiff_t dif = -(ptrdiff_t)delta; - - if (((ptrdiff_t)size + dif) & 1) - { - --p; *p = (Byte)(*p - p[dif]); - } - - while (p != lim) - { - --p; *p = (Byte)(*p - p[dif]); - --p; *p = (Byte)(*p - p[dif]); - } - - dif = -dif; - - do - { - --p; *p = (Byte)(*p - temp[--dif]); - } - while (dif != 0); - } - } -} - - -void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size) -{ - unsigned i; - const Byte *lim; - - if (size == 0) - return; - - i = 0; - lim = data + size; - - if (size <= delta) - { - do - *data = (Byte)(*data + state[i++]); - while (++data != lim); - - for (; delta != i; state++, delta--) - *state = state[i]; - data -= i; - } - else - { - /* - #define B(n) b ## n - #define I(n) Byte B(n) = state[n]; - #define U(n) { B(n) = (Byte)((B(n)) + *data++); data[-1] = (B(n)); } - #define F(n) if (data != lim) { U(n) } - - if (delta == 1) - { - I(0) - if ((lim - data) & 1) { U(0) } - while (data != lim) { U(0) U(0) } - data -= 1; - } - else if (delta == 2) - { - I(0) I(1) - lim -= 1; while (data < lim) { U(0) U(1) } - lim += 1; F(0) - data -= 2; - } - else if (delta == 3) - { - I(0) I(1) I(2) - lim -= 2; while (data < lim) { U(0) U(1) U(2) } - lim += 2; F(0) F(1) - data -= 3; - } - else if (delta == 4) - { - I(0) I(1) I(2) I(3) - lim -= 3; while (data < lim) { U(0) U(1) U(2) U(3) } - lim += 3; F(0) F(1) F(2) - data -= 4; - } - else - */ - { - do - { - *data = (Byte)(*data + state[i++]); - data++; - } - while (i != delta); - - { - ptrdiff_t dif = -(ptrdiff_t)delta; - do - *data = (Byte)(*data + data[dif]); - while (++data != lim); - data += dif; - } - } - } - - do - *state++ = *data; - while (++data != lim); -} +/* Delta.c -- Delta converter +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "Delta.h" + +void Delta_Init(Byte *state) +{ + unsigned i; + for (i = 0; i < DELTA_STATE_SIZE; i++) + state[i] = 0; +} + + +void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size) +{ + Byte temp[DELTA_STATE_SIZE]; + + if (size == 0) + return; + + { + unsigned i = 0; + do + temp[i] = state[i]; + while (++i != delta); + } + + if (size <= delta) + { + unsigned i = 0, k; + do + { + Byte b = *data; + *data++ = (Byte)(b - temp[i]); + temp[i] = b; + } + while (++i != size); + + k = 0; + + do + { + if (i == delta) + i = 0; + state[k] = temp[i++]; + } + while (++k != delta); + + return; + } + + { + Byte *p = data + size - delta; + { + unsigned i = 0; + do + state[i] = *p++; + while (++i != delta); + } + { + const Byte *lim = data + delta; + ptrdiff_t dif = -(ptrdiff_t)delta; + + if (((ptrdiff_t)size + dif) & 1) + { + --p; *p = (Byte)(*p - p[dif]); + } + + while (p != lim) + { + --p; *p = (Byte)(*p - p[dif]); + --p; *p = (Byte)(*p - p[dif]); + } + + dif = -dif; + + do + { + --p; *p = (Byte)(*p - temp[--dif]); + } + while (dif != 0); + } + } +} + + +void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size) +{ + unsigned i; + const Byte *lim; + + if (size == 0) + return; + + i = 0; + lim = data + size; + + if (size <= delta) + { + do + *data = (Byte)(*data + state[i++]); + while (++data != lim); + + for (; delta != i; state++, delta--) + *state = state[i]; + data -= i; + } + else + { + /* + #define B(n) b ## n + #define I(n) Byte B(n) = state[n]; + #define U(n) { B(n) = (Byte)((B(n)) + *data++); data[-1] = (B(n)); } + #define F(n) if (data != lim) { U(n) } + + if (delta == 1) + { + I(0) + if ((lim - data) & 1) { U(0) } + while (data != lim) { U(0) U(0) } + data -= 1; + } + else if (delta == 2) + { + I(0) I(1) + lim -= 1; while (data < lim) { U(0) U(1) } + lim += 1; F(0) + data -= 2; + } + else if (delta == 3) + { + I(0) I(1) I(2) + lim -= 2; while (data < lim) { U(0) U(1) U(2) } + lim += 2; F(0) F(1) + data -= 3; + } + else if (delta == 4) + { + I(0) I(1) I(2) I(3) + lim -= 3; while (data < lim) { U(0) U(1) U(2) U(3) } + lim += 3; F(0) F(1) F(2) + data -= 4; + } + else + */ + { + do + { + *data = (Byte)(*data + state[i++]); + data++; + } + while (i != delta); + + { + ptrdiff_t dif = -(ptrdiff_t)delta; + do + *data = (Byte)(*data + data[dif]); + while (++data != lim); + data += dif; + } + } + } + + do + *state++ = *data; + while (++data != lim); +} diff --git a/deps/LZMA-SDK/C/Delta.h b/deps/LZMA-SDK/C/Delta.h index e59d5a252..2fa54ad67 100644 --- a/deps/LZMA-SDK/C/Delta.h +++ b/deps/LZMA-SDK/C/Delta.h @@ -1,19 +1,19 @@ -/* Delta.h -- Delta converter -2013-01-18 : Igor Pavlov : Public domain */ - -#ifndef __DELTA_H -#define __DELTA_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define DELTA_STATE_SIZE 256 - -void Delta_Init(Byte *state); -void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); -void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); - -EXTERN_C_END - -#endif +/* Delta.h -- Delta converter +2013-01-18 : Igor Pavlov : Public domain */ + +#ifndef __DELTA_H +#define __DELTA_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define DELTA_STATE_SIZE 256 + +void Delta_Init(Byte *state); +void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size); +void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/DllSecur.c b/deps/LZMA-SDK/C/DllSecur.c index 19a22a9f0..a3c294bfe 100644 --- a/deps/LZMA-SDK/C/DllSecur.c +++ b/deps/LZMA-SDK/C/DllSecur.c @@ -1,108 +1,114 @@ -/* DllSecur.c -- DLL loading security -2018-02-21 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#ifdef _WIN32 - -#include - -#include "DllSecur.h" - -#ifndef UNDER_CE - -typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags); - -#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400 -#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800 - -static const char * const g_Dlls = - #ifndef _CONSOLE - "UXTHEME\0" - #endif - "USERENV\0" - "SETUPAPI\0" - "APPHELP\0" - "PROPSYS\0" - "DWMAPI\0" - "CRYPTBASE\0" - "OLEACC\0" - "CLBCATQ\0" - "VERSION\0" - ; - -#endif - -void My_SetDefaultDllDirectories() -{ - #ifndef UNDER_CE - - OSVERSIONINFO vi; - vi.dwOSVersionInfoSize = sizeof(vi); - GetVersionEx(&vi); - if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) - { - Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) - GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); - if (setDllDirs) - if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) - return; - } - - #endif -} - - -void LoadSecurityDlls() -{ - #ifndef UNDER_CE - - wchar_t buf[MAX_PATH + 100]; - - { - // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? - OSVERSIONINFO vi; - vi.dwOSVersionInfoSize = sizeof(vi); - if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) - { - Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) - GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); - if (setDllDirs) - if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) - return; - } - } - - { - unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); - if (len == 0 || len > MAX_PATH) - return; - } - { - const char *dll; - unsigned pos = (unsigned)lstrlenW(buf); - - if (buf[pos - 1] != '\\') - buf[pos++] = '\\'; - - for (dll = g_Dlls; dll[0] != 0;) - { - unsigned k = 0; - for (;;) - { - char c = *dll++; - buf[pos + k] = (Byte)c; - k++; - if (c == 0) - break; - } - - lstrcatW(buf, L".dll"); - LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - } - } - - #endif -} - -#endif +/* DllSecur.c -- DLL loading security +2022-07-15 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#ifdef _WIN32 + +#include + +#include "DllSecur.h" + +#ifndef UNDER_CE + +#if defined(__GNUC__) && (__GNUC__ >= 8) + #pragma GCC diagnostic ignored "-Wcast-function-type" +#endif + +typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags); + +#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400 +#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800 + +static const char * const g_Dlls = + #ifndef _CONSOLE + "UXTHEME\0" + #endif + "USERENV\0" + "SETUPAPI\0" + "APPHELP\0" + "PROPSYS\0" + "DWMAPI\0" + "CRYPTBASE\0" + "OLEACC\0" + "CLBCATQ\0" + "VERSION\0" + ; + +#endif + +// #define MY_CAST_FUNC (void(*)()) +#define MY_CAST_FUNC + +void My_SetDefaultDllDirectories() +{ + #ifndef UNDER_CE + + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) + { + Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) + MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); + if (setDllDirs) + if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) + return; + } + + #endif +} + + +void LoadSecurityDlls() +{ + #ifndef UNDER_CE + + wchar_t buf[MAX_PATH + 100]; + + { + // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMinorVersion != 0) + { + Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories) + MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories"); + if (setDllDirs) + if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) + return; + } + } + + { + unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); + if (len == 0 || len > MAX_PATH) + return; + } + { + const char *dll; + unsigned pos = (unsigned)lstrlenW(buf); + + if (buf[pos - 1] != '\\') + buf[pos++] = '\\'; + + for (dll = g_Dlls; dll[0] != 0;) + { + unsigned k = 0; + for (;;) + { + char c = *dll++; + buf[pos + k] = (Byte)c; + k++; + if (c == 0) + break; + } + + lstrcatW(buf, L".dll"); + LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + } + } + + #endif +} + +#endif diff --git a/deps/LZMA-SDK/C/DllSecur.h b/deps/LZMA-SDK/C/DllSecur.h index 0fd8070e5..64ff26cd9 100644 --- a/deps/LZMA-SDK/C/DllSecur.h +++ b/deps/LZMA-SDK/C/DllSecur.h @@ -1,20 +1,20 @@ -/* DllSecur.h -- DLL loading for security -2018-02-19 : Igor Pavlov : Public domain */ - -#ifndef __DLL_SECUR_H -#define __DLL_SECUR_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#ifdef _WIN32 - -void My_SetDefaultDllDirectories(void); -void LoadSecurityDlls(void); - -#endif - -EXTERN_C_END - -#endif +/* DllSecur.h -- DLL loading for security +2018-02-19 : Igor Pavlov : Public domain */ + +#ifndef __DLL_SECUR_H +#define __DLL_SECUR_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#ifdef _WIN32 + +void My_SetDefaultDllDirectories(void); +void LoadSecurityDlls(void); + +#endif + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/LzFind.c b/deps/LZMA-SDK/C/LzFind.c index 18ec00ef5..1b73c2848 100644 --- a/deps/LZMA-SDK/C/LzFind.c +++ b/deps/LZMA-SDK/C/LzFind.c @@ -1,1197 +1,1628 @@ -/* LzFind.c -- Match finder for LZ algorithms -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "CpuArch.h" -#include "LzFind.h" -#include "LzHash.h" - -#define kEmptyHashValue 0 -#define kMaxValForNormalize ((UInt32)0xFFFFFFFF) -#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */ -#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1)) -#define kMaxHistorySize ((UInt32)7 << 29) - -// #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) -#define kFix5HashSize kFix4HashSize - -/* - HASH2_CALC: - if (hv) match, then cur[0] and cur[1] also match -*/ -#define HASH2_CALC hv = GetUi16(cur); - -// (crc[0 ... 255] & 0xFF) provides one-to-one correspondence to [0 ... 255] - -/* - HASH3_CALC: - if (cur[0]) and (h2) match, then cur[1] also match - if (cur[0]) and (hv) match, then cur[1] and cur[2] also match -*/ -#define HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } - -#define HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ - h3 = temp & (kHash3Size - 1); \ - hv = (temp ^ (p->crc[cur[3]] << kLzHash_CrcShift_1)) & p->hashMask; } - -#define HASH5_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ - h3 = temp & (kHash3Size - 1); \ - temp ^= (p->crc[cur[3]] << kLzHash_CrcShift_1); \ - /* h4 = temp & p->hash4Mask; */ /* (kHash4Size - 1); */ \ - hv = (temp ^ (p->crc[cur[4]] << kLzHash_CrcShift_2)) & p->hashMask; } - -#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; - - -static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc) -{ - if (!p->directInput) - { - ISzAlloc_Free(alloc, p->bufferBase); - p->bufferBase = NULL; - } -} - -/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */ - -static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr alloc) -{ - UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv; - if (p->directInput) - { - p->blockSize = blockSize; - return 1; - } - if (!p->bufferBase || p->blockSize != blockSize) - { - LzInWindow_Free(p, alloc); - p->blockSize = blockSize; - p->bufferBase = (Byte *)ISzAlloc_Alloc(alloc, (size_t)blockSize); - } - return (p->bufferBase != NULL); -} - -static Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } - -static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; } - -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue) -{ - p->posLimit -= subValue; - p->pos -= subValue; - p->streamPos -= subValue; -} - -static void MatchFinder_ReadBlock(CMatchFinder *p) -{ - if (p->streamEndWasReached || p->result != SZ_OK) - return; - - /* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */ - - if (p->directInput) - { - UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos); - if (curSize > p->directInputRem) - curSize = (UInt32)p->directInputRem; - p->directInputRem -= curSize; - p->streamPos += curSize; - if (p->directInputRem == 0) - p->streamEndWasReached = 1; - return; - } - - for (;;) - { - Byte *dest = p->buffer + (p->streamPos - p->pos); - size_t size = (size_t)(p->bufferBase + p->blockSize - dest); - if (size == 0) - return; - - p->result = ISeqInStream_Read(p->stream, dest, &size); - if (p->result != SZ_OK) - return; - if (size == 0) - { - p->streamEndWasReached = 1; - return; - } - p->streamPos += (UInt32)size; - if (p->streamPos - p->pos > p->keepSizeAfter) - return; - } -} - -void MatchFinder_MoveBlock(CMatchFinder *p) -{ - memmove(p->bufferBase, - p->buffer - p->keepSizeBefore, - (size_t)(p->streamPos - p->pos) + p->keepSizeBefore); - p->buffer = p->bufferBase + p->keepSizeBefore; -} - -int MatchFinder_NeedMove(CMatchFinder *p) -{ - if (p->directInput) - return 0; - /* if (p->streamEndWasReached) return 0; */ - return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); -} - -void MatchFinder_ReadIfRequired(CMatchFinder *p) -{ - if (p->streamEndWasReached) - return; - if (p->keepSizeAfter >= p->streamPos - p->pos) - MatchFinder_ReadBlock(p); -} - -static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p) -{ - if (MatchFinder_NeedMove(p)) - MatchFinder_MoveBlock(p); - MatchFinder_ReadBlock(p); -} - -static void MatchFinder_SetDefaultSettings(CMatchFinder *p) -{ - p->cutValue = 32; - p->btMode = 1; - p->numHashBytes = 4; - p->bigHash = 0; -} - -#define kCrcPoly 0xEDB88320 - -void MatchFinder_Construct(CMatchFinder *p) -{ - unsigned i; - p->bufferBase = NULL; - p->directInput = 0; - p->hash = NULL; - p->expectedDataSize = (UInt64)(Int64)-1; - MatchFinder_SetDefaultSettings(p); - - for (i = 0; i < 256; i++) - { - UInt32 r = (UInt32)i; - unsigned j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); - p->crc[i] = r; - } -} - -static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->hash); - p->hash = NULL; -} - -void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc) -{ - MatchFinder_FreeThisClassMemory(p, alloc); - LzInWindow_Free(p, alloc); -} - -static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc) -{ - size_t sizeInBytes = (size_t)num * sizeof(CLzRef); - if (sizeInBytes / sizeof(CLzRef) != num) - return NULL; - return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes); -} - -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, - UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, - ISzAllocPtr alloc) -{ - UInt32 sizeReserv; - - if (historySize > kMaxHistorySize) - { - MatchFinder_Free(p, alloc); - return 0; - } - - sizeReserv = historySize >> 1; - if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3; - else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2; - - sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); - - p->keepSizeBefore = historySize + keepAddBufferBefore + 1; - p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; - - /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ - - if (LzInWindow_Create(p, sizeReserv, alloc)) - { - UInt32 newCyclicBufferSize = historySize + 1; - UInt32 hs; - p->matchMaxLen = matchMaxLen; - { - // UInt32 hs4; - p->fixedHashSize = 0; - hs = (1 << 16) - 1; - if (p->numHashBytes != 2) - { - hs = historySize; - if (hs > p->expectedDataSize) - hs = (UInt32)p->expectedDataSize; - if (hs != 0) - hs--; - hs |= (hs >> 1); - hs |= (hs >> 2); - hs |= (hs >> 4); - hs |= (hs >> 8); - // we propagated 16 bits in (hs). Low 16 bits must be set later - hs >>= 1; - if (hs >= (1 << 24)) - { - if (p->numHashBytes == 3) - hs = (1 << 24) - 1; - else - hs >>= 1; - /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */ - } - - // hs = ((UInt32)1 << 25) - 1; // for test - - // (hash_size >= (1 << 16)) : Required for (numHashBytes > 2) - hs |= (1 << 16) - 1; /* don't change it! */ - - // bt5: we adjust the size with recommended minimum size - if (p->numHashBytes >= 5) - hs |= (256 << kLzHash_CrcShift_2) - 1; - } - p->hashMask = hs; - hs++; - - /* - hs4 = (1 << 20); - if (hs4 > hs) - hs4 = hs; - // hs4 = (1 << 16); // for test - p->hash4Mask = hs4 - 1; - */ - - if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; - if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; - // if (p->numHashBytes > 4) p->fixedHashSize += hs4; // kHash4Size; - hs += p->fixedHashSize; - } - - { - size_t newSize; - size_t numSons; - p->historySize = historySize; - p->hashSizeSum = hs; - p->cyclicBufferSize = newCyclicBufferSize; - - numSons = newCyclicBufferSize; - if (p->btMode) - numSons <<= 1; - newSize = hs + numSons; - - // aligned size is not required here, but it can be better for some loops - #define NUM_REFS_ALIGN_MASK 0xF - newSize = (newSize + NUM_REFS_ALIGN_MASK) & ~(size_t)NUM_REFS_ALIGN_MASK; - - if (p->hash && p->numRefs == newSize) - return 1; - - MatchFinder_FreeThisClassMemory(p, alloc); - p->numRefs = newSize; - p->hash = AllocRefs(newSize, alloc); - - if (p->hash) - { - p->son = p->hash + p->hashSizeSum; - return 1; - } - } - } - - MatchFinder_Free(p, alloc); - return 0; -} - -static void MatchFinder_SetLimits(CMatchFinder *p) -{ - UInt32 limit = kMaxValForNormalize - p->pos; - UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos; - - if (limit2 < limit) - limit = limit2; - limit2 = p->streamPos - p->pos; - - if (limit2 <= p->keepSizeAfter) - { - if (limit2 > 0) - limit2 = 1; - } - else - limit2 -= p->keepSizeAfter; - - if (limit2 < limit) - limit = limit2; - - { - UInt32 lenLimit = p->streamPos - p->pos; - if (lenLimit > p->matchMaxLen) - lenLimit = p->matchMaxLen; - p->lenLimit = lenLimit; - } - p->posLimit = p->pos + limit; -} - - -void MatchFinder_Init_LowHash(CMatchFinder *p) -{ - size_t i; - CLzRef *items = p->hash; - size_t numItems = p->fixedHashSize; - for (i = 0; i < numItems; i++) - items[i] = kEmptyHashValue; -} - - -void MatchFinder_Init_HighHash(CMatchFinder *p) -{ - size_t i; - CLzRef *items = p->hash + p->fixedHashSize; - size_t numItems = (size_t)p->hashMask + 1; - for (i = 0; i < numItems; i++) - items[i] = kEmptyHashValue; -} - - -void MatchFinder_Init_3(CMatchFinder *p, int readData) -{ - p->cyclicBufferPos = 0; - p->buffer = p->bufferBase; - p->pos = - p->streamPos = p->cyclicBufferSize; - p->result = SZ_OK; - p->streamEndWasReached = 0; - - if (readData) - MatchFinder_ReadBlock(p); - - MatchFinder_SetLimits(p); -} - - -void MatchFinder_Init(CMatchFinder *p) -{ - MatchFinder_Init_HighHash(p); - MatchFinder_Init_LowHash(p); - MatchFinder_Init_3(p, True); -} - - -static UInt32 MatchFinder_GetSubValue(CMatchFinder *p) -{ - return (p->pos - p->historySize - 1) & kNormalizeMask; -} - -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems) -{ - if (numItems == 0) - return; - { - const CLzRef *lim = items + numItems - 1; - for (; items < lim; items += 2) - { - UInt32 v, m; - v = items[0]; m = v - subValue; if (v < subValue) m = kEmptyHashValue; - v = items[1]; items[0] = m; m = v - subValue; if (v < subValue) m = kEmptyHashValue; - items[1] = m; - } - if (items == lim) - { - UInt32 v, m; - v = items[0]; m = v - subValue; if (v < subValue) m = kEmptyHashValue; - items[0] = m; - } - } -} - -static void MatchFinder_Normalize(CMatchFinder *p) -{ - UInt32 subValue = MatchFinder_GetSubValue(p); - MatchFinder_Normalize3(subValue, p->hash, p->numRefs); - MatchFinder_ReduceOffsets(p, subValue); -} - - -MY_NO_INLINE -static void MatchFinder_CheckLimits(CMatchFinder *p) -{ - if (p->pos == kMaxValForNormalize) - MatchFinder_Normalize(p); - if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos) - MatchFinder_CheckAndMoveAndRead(p); - if (p->cyclicBufferPos == p->cyclicBufferSize) - p->cyclicBufferPos = 0; - MatchFinder_SetLimits(p); -} - - -/* - (lenLimit > maxLen) -*/ -MY_FORCE_INLINE -static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *distances, unsigned maxLen) -{ - /* - son[_cyclicBufferPos] = curMatch; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - return distances; - { - const Byte *pb = cur - delta; - curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; - if (pb[maxLen] == cur[maxLen] && *pb == *cur) - { - UInt32 len = 0; - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - maxLen = len; - *distances++ = len; - *distances++ = delta - 1; - if (len == lenLimit) - return distances; - } - } - } - } - */ - - const Byte *lim = cur + lenLimit; - son[_cyclicBufferPos] = curMatch; - do - { - UInt32 delta = pos - curMatch; - if (delta >= _cyclicBufferSize) - break; - { - ptrdiff_t diff; - curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; - diff = (ptrdiff_t)0 - (ptrdiff_t)delta; - if (cur[maxLen] == cur[(ptrdiff_t)maxLen + diff]) - { - const Byte *c = cur; - while (*c == c[diff]) - { - if (++c == lim) - { - distances[0] = (UInt32)(lim - cur); - distances[1] = delta - 1; - return distances + 2; - } - } - { - unsigned len = (unsigned)(c - cur); - if (maxLen < len) - { - maxLen = len; - distances[0] = (UInt32)len; - distances[1] = delta - 1; - distances += 2; - } - } - } - } - } - while (--cutValue); - - return distances; -} - - -MY_FORCE_INLINE -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, - UInt32 *distances, UInt32 maxLen) -{ - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - unsigned len0 = 0, len1 = 0; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - return distances; - } - { - CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); - const Byte *pb = cur - delta; - unsigned len = (len0 < len1 ? len0 : len1); - UInt32 pair0 = pair[0]; - if (pb[len] == cur[len]) - { - if (++len != lenLimit && pb[len] == cur[len]) - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - maxLen = (UInt32)len; - *distances++ = (UInt32)len; - *distances++ = delta - 1; - if (len == lenLimit) - { - *ptr1 = pair0; - *ptr0 = pair[1]; - return distances; - } - } - } - if (pb[len] < cur[len]) - { - *ptr1 = curMatch; - ptr1 = pair + 1; - curMatch = *ptr1; - len1 = len; - } - else - { - *ptr0 = curMatch; - ptr0 = pair; - curMatch = *ptr0; - len0 = len; - } - } - } -} - -static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) -{ - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - unsigned len0 = 0, len1 = 0; - for (;;) - { - UInt32 delta = pos - curMatch; - if (cutValue-- == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - return; - } - { - CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); - const Byte *pb = cur - delta; - unsigned len = (len0 < len1 ? len0 : len1); - if (pb[len] == cur[len]) - { - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - { - if (len == lenLimit) - { - *ptr1 = pair[0]; - *ptr0 = pair[1]; - return; - } - } - } - if (pb[len] < cur[len]) - { - *ptr1 = curMatch; - ptr1 = pair + 1; - curMatch = *ptr1; - len1 = len; - } - else - { - *ptr0 = curMatch; - ptr0 = pair; - curMatch = *ptr0; - len0 = len; - } - } - } -} - -#define MOVE_POS \ - ++p->cyclicBufferPos; \ - p->buffer++; \ - if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p); - -#define MOVE_POS_RET MOVE_POS return (UInt32)offset; - -static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } - -#define GET_MATCHES_HEADER2(minLen, ret_op) \ - unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \ - lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ - cur = p->buffer; - -#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0) -#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue) - -#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue - -#define GET_MATCHES_FOOTER_BASE(_maxLen_, func) \ - offset = (unsigned)(func((UInt32)lenLimit, curMatch, MF_PARAMS(p), \ - distances + offset, (UInt32)(_maxLen_)) - distances); MOVE_POS_RET; - -#define GET_MATCHES_FOOTER_BT(_maxLen_) \ - GET_MATCHES_FOOTER_BASE(_maxLen_, GetMatchesSpec1) - -#define GET_MATCHES_FOOTER_HC(_maxLen_) \ - GET_MATCHES_FOOTER_BASE(_maxLen_, Hc_GetMatchesSpec) - -#define SKIP_FOOTER \ - SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS; - -#define UPDATE_maxLen { \ - ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)d2; \ - const Byte *c = cur + maxLen; \ - const Byte *lim = cur + lenLimit; \ - for (; c != lim; c++) if (*(c + diff) != *c) break; \ - maxLen = (unsigned)(c - cur); } - -static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - unsigned offset; - GET_MATCHES_HEADER(2) - HASH2_CALC; - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - offset = 0; - GET_MATCHES_FOOTER_BT(1) -} - -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - unsigned offset; - GET_MATCHES_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - offset = 0; - GET_MATCHES_FOOTER_BT(2) -} - -static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 h2, d2, pos; - unsigned maxLen, offset; - UInt32 *hash; - GET_MATCHES_HEADER(3) - - HASH3_CALC; - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash[h2]; - - curMatch = (hash + kFix3HashSize)[hv]; - - hash[h2] = pos; - (hash + kFix3HashSize)[hv] = pos; - - maxLen = 2; - offset = 0; - - if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) - { - UPDATE_maxLen - distances[0] = (UInt32)maxLen; - distances[1] = d2 - 1; - offset = 2; - if (maxLen == lenLimit) - { - SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); - MOVE_POS_RET; - } - } - - GET_MATCHES_FOOTER_BT(maxLen) -} - - -static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 h2, h3, d2, d3, pos; - unsigned maxLen, offset; - UInt32 *hash; - GET_MATCHES_HEADER(4) - - HASH4_CALC; - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - curMatch = (hash + kFix4HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - (hash + kFix4HashSize)[hv] = pos; - - maxLen = 3; - offset = 0; - - for (;;) - { - if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - offset = 2; - if (*(cur - d2 + 2) == cur[2]) - { - // distances[0] = 3; - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - d2 = d3; - distances[2 + 1] = d3 - 1; - offset = 4; - } - else - break; - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - d2 = d3; - distances[1] = d3 - 1; - offset = 2; - } - else - break; - - UPDATE_maxLen - distances[(size_t)offset - 2] = (UInt32)maxLen; - if (maxLen == lenLimit) - { - SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); - MOVE_POS_RET - } - break; - } - - GET_MATCHES_FOOTER_BT(maxLen) -} - - -static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 h2, h3, d2, d3, maxLen, offset, pos; - UInt32 *hash; - GET_MATCHES_HEADER(5) - - HASH5_CALC; - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - // d4 = pos - (hash + kFix4HashSize)[h4]; - - curMatch = (hash + kFix5HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - // (hash + kFix4HashSize)[h4] = pos; - (hash + kFix5HashSize)[hv] = pos; - - maxLen = 4; - offset = 0; - - for (;;) - { - if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - offset = 2; - if (*(cur - d2 + 2) == cur[2]) - { - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - distances[3] = d3 - 1; - offset = 4; - d2 = d3; - } - else - break; - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - distances[1] = d3 - 1; - offset = 2; - d2 = d3; - } - else - break; - - distances[(size_t)offset - 2] = 3; - if (*(cur - d2 + 3) != cur[3]) - break; - UPDATE_maxLen - distances[(size_t)offset - 2] = maxLen; - if (maxLen == lenLimit) - { - SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); - MOVE_POS_RET; - } - break; - } - - GET_MATCHES_FOOTER_BT(maxLen) -} - - -static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 h2, h3, d2, d3, pos; - unsigned maxLen, offset; - UInt32 *hash; - GET_MATCHES_HEADER(4) - - HASH4_CALC; - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - curMatch = (hash + kFix4HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - (hash + kFix4HashSize)[hv] = pos; - - maxLen = 3; - offset = 0; - - for (;;) - { - if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - offset = 2; - if (*(cur - d2 + 2) == cur[2]) - { - // distances[0] = 3; - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - d2 = d3; - distances[2 + 1] = d3 - 1; - offset = 4; - } - else - break; - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - d2 = d3; - distances[1] = d3 - 1; - offset = 2; - } - else - break; - - UPDATE_maxLen - distances[(size_t)offset - 2] = (UInt32)maxLen; - if (maxLen == lenLimit) - { - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS_RET; - } - break; - } - - GET_MATCHES_FOOTER_HC(maxLen); -} - - -static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - UInt32 h2, h3, d2, d3, maxLen, offset, pos; - UInt32 *hash; - GET_MATCHES_HEADER(5) - - HASH5_CALC; - - hash = p->hash; - pos = p->pos; - - d2 = pos - hash [h2]; - d3 = pos - (hash + kFix3HashSize)[h3]; - // d4 = pos - (hash + kFix4HashSize)[h4]; - - curMatch = (hash + kFix5HashSize)[hv]; - - hash [h2] = pos; - (hash + kFix3HashSize)[h3] = pos; - // (hash + kFix4HashSize)[h4] = pos; - (hash + kFix5HashSize)[hv] = pos; - - maxLen = 4; - offset = 0; - - for (;;) - { - if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) - { - distances[0] = 2; - distances[1] = d2 - 1; - offset = 2; - if (*(cur - d2 + 2) == cur[2]) - { - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - distances[3] = d3 - 1; - offset = 4; - d2 = d3; - } - else - break; - } - else if (d3 < p->cyclicBufferSize && *(cur - d3) == *cur) - { - distances[1] = d3 - 1; - offset = 2; - d2 = d3; - } - else - break; - - distances[(size_t)offset - 2] = 3; - if (*(cur - d2 + 3) != cur[3]) - break; - UPDATE_maxLen - distances[(size_t)offset - 2] = maxLen; - if (maxLen == lenLimit) - { - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS_RET; - } - break; - } - - GET_MATCHES_FOOTER_HC(maxLen); -} - - -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) -{ - unsigned offset; - GET_MATCHES_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - offset = 0; - GET_MATCHES_FOOTER_HC(2) -} - - -static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - SKIP_HEADER(2) - HASH2_CALC; - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - SKIP_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 h2; - UInt32 *hash; - SKIP_HEADER(3) - HASH3_CALC; - hash = p->hash; - curMatch = (hash + kFix3HashSize)[hv]; - hash[h2] = - (hash + kFix3HashSize)[hv] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 h2, h3; - UInt32 *hash; - SKIP_HEADER(4) - HASH4_CALC; - hash = p->hash; - curMatch = (hash + kFix4HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - (hash + kFix4HashSize)[hv] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 h2, h3; - UInt32 *hash; - SKIP_HEADER(5) - HASH5_CALC; - hash = p->hash; - curMatch = (hash + kFix5HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - // (hash + kFix4HashSize)[h4] = - (hash + kFix5HashSize)[hv] = p->pos; - SKIP_FOOTER - } - while (--num != 0); -} - -static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 h2, h3; - UInt32 *hash; - SKIP_HEADER(4) - HASH4_CALC; - hash = p->hash; - curMatch = (hash + kFix4HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - (hash + kFix4HashSize)[hv] = p->pos; - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS - } - while (--num != 0); -} - -static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - UInt32 h2, h3; - UInt32 *hash; - SKIP_HEADER(5) - HASH5_CALC; - hash = p->hash; - curMatch = (hash + kFix5HashSize)[hv]; - hash [h2] = - (hash + kFix3HashSize)[h3] = - // (hash + kFix4HashSize)[h4] = - (hash + kFix5HashSize)[hv] = p->pos; - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS - } - while (--num != 0); -} - - -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) -{ - do - { - SKIP_HEADER(3) - HASH_ZIP_CALC; - curMatch = p->hash[hv]; - p->hash[hv] = p->pos; - p->son[p->cyclicBufferPos] = curMatch; - MOVE_POS - } - while (--num != 0); -} - -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) -{ - vTable->Init = (Mf_Init_Func)MatchFinder_Init; - vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; - vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; - if (!p->btMode) - { - if (p->numHashBytes <= 4) - { - vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; - } - else - { - vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip; - } - } - else if (p->numHashBytes == 2) - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; - } - else if (p->numHashBytes == 3) - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; - } - else if (p->numHashBytes == 4) - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; - } - else - { - vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches; - vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip; - } -} +/* LzFind.c -- Match finder for LZ algorithms +2021-11-29 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include +// #include + +#include "CpuArch.h" +#include "LzFind.h" +#include "LzHash.h" + +#define kBlockMoveAlign (1 << 7) // alignment for memmove() +#define kBlockSizeAlign (1 << 16) // alignment for block allocation +#define kBlockSizeReserveMin (1 << 24) // it's 1/256 from 4 GB dictinary + +#define kEmptyHashValue 0 + +#define kMaxValForNormalize ((UInt32)0) +// #define kMaxValForNormalize ((UInt32)(1 << 20) + 0xFFF) // for debug + +// #define kNormalizeAlign (1 << 7) // alignment for speculated accesses + +#define GET_AVAIL_BYTES(p) \ + Inline_MatchFinder_GetNumAvailableBytes(p) + + +// #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) +#define kFix5HashSize kFix4HashSize + +/* + HASH2_CALC: + if (hv) match, then cur[0] and cur[1] also match +*/ +#define HASH2_CALC hv = GetUi16(cur); + +// (crc[0 ... 255] & 0xFF) provides one-to-one correspondence to [0 ... 255] + +/* + HASH3_CALC: + if (cur[0]) and (h2) match, then cur[1] also match + if (cur[0]) and (hv) match, then cur[1] and cur[2] also match +*/ +#define HASH3_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + h2 = temp & (kHash2Size - 1); \ + hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } + +#define HASH4_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + h2 = temp & (kHash2Size - 1); \ + temp ^= ((UInt32)cur[2] << 8); \ + h3 = temp & (kHash3Size - 1); \ + hv = (temp ^ (p->crc[cur[3]] << kLzHash_CrcShift_1)) & p->hashMask; } + +#define HASH5_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + h2 = temp & (kHash2Size - 1); \ + temp ^= ((UInt32)cur[2] << 8); \ + h3 = temp & (kHash3Size - 1); \ + temp ^= (p->crc[cur[3]] << kLzHash_CrcShift_1); \ + /* h4 = temp & p->hash4Mask; */ /* (kHash4Size - 1); */ \ + hv = (temp ^ (p->crc[cur[4]] << kLzHash_CrcShift_2)) & p->hashMask; } + +#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; + + +static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc) +{ + if (!p->directInput) + { + ISzAlloc_Free(alloc, p->bufferBase); + p->bufferBase = NULL; + } +} + + +static int LzInWindow_Create2(CMatchFinder *p, UInt32 blockSize, ISzAllocPtr alloc) +{ + if (blockSize == 0) + return 0; + if (!p->bufferBase || p->blockSize != blockSize) + { + // size_t blockSizeT; + LzInWindow_Free(p, alloc); + p->blockSize = blockSize; + // blockSizeT = blockSize; + + // printf("\nblockSize = 0x%x\n", blockSize); + /* + #if defined _WIN64 + // we can allocate 4GiB, but still use UInt32 for (p->blockSize) + // we use UInt32 type for (p->blockSize), because + // we don't want to wrap over 4 GiB, + // when we use (p->streamPos - p->pos) that is UInt32. + if (blockSize >= (UInt32)0 - (UInt32)kBlockSizeAlign) + { + blockSizeT = ((size_t)1 << 32); + printf("\nchanged to blockSizeT = 4GiB\n"); + } + #endif + */ + + p->bufferBase = (Byte *)ISzAlloc_Alloc(alloc, blockSize); + // printf("\nbufferBase = %p\n", p->bufferBase); + // return 0; // for debug + } + return (p->bufferBase != NULL); +} + +static const Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; } + +static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return GET_AVAIL_BYTES(p); } + + +MY_NO_INLINE +static void MatchFinder_ReadBlock(CMatchFinder *p) +{ + if (p->streamEndWasReached || p->result != SZ_OK) + return; + + /* We use (p->streamPos - p->pos) value. + (p->streamPos < p->pos) is allowed. */ + + if (p->directInput) + { + UInt32 curSize = 0xFFFFFFFF - GET_AVAIL_BYTES(p); + if (curSize > p->directInputRem) + curSize = (UInt32)p->directInputRem; + p->directInputRem -= curSize; + p->streamPos += curSize; + if (p->directInputRem == 0) + p->streamEndWasReached = 1; + return; + } + + for (;;) + { + Byte *dest = p->buffer + GET_AVAIL_BYTES(p); + size_t size = (size_t)(p->bufferBase + p->blockSize - dest); + if (size == 0) + { + /* we call ReadBlock() after NeedMove() and MoveBlock(). + NeedMove() and MoveBlock() povide more than (keepSizeAfter) + to the end of (blockSize). + So we don't execute this branch in normal code flow. + We can go here, if we will call ReadBlock() before NeedMove(), MoveBlock(). + */ + // p->result = SZ_ERROR_FAIL; // we can show error here + return; + } + + // #define kRead 3 + // if (size > kRead) size = kRead; // for debug + + p->result = ISeqInStream_Read(p->stream, dest, &size); + if (p->result != SZ_OK) + return; + if (size == 0) + { + p->streamEndWasReached = 1; + return; + } + p->streamPos += (UInt32)size; + if (GET_AVAIL_BYTES(p) > p->keepSizeAfter) + return; + /* here and in another (p->keepSizeAfter) checks we keep on 1 byte more than was requested by Create() function + (GET_AVAIL_BYTES(p) >= p->keepSizeAfter) - minimal required size */ + } + + // on exit: (p->result != SZ_OK || p->streamEndWasReached || GET_AVAIL_BYTES(p) > p->keepSizeAfter) +} + + + +MY_NO_INLINE +void MatchFinder_MoveBlock(CMatchFinder *p) +{ + const size_t offset = (size_t)(p->buffer - p->bufferBase) - p->keepSizeBefore; + const size_t keepBefore = (offset & (kBlockMoveAlign - 1)) + p->keepSizeBefore; + p->buffer = p->bufferBase + keepBefore; + memmove(p->bufferBase, + p->bufferBase + (offset & ~((size_t)kBlockMoveAlign - 1)), + keepBefore + (size_t)GET_AVAIL_BYTES(p)); +} + +/* We call MoveBlock() before ReadBlock(). + So MoveBlock() can be wasteful operation, if the whole input data + can fit in current block even without calling MoveBlock(). + in important case where (dataSize <= historySize) + condition (p->blockSize > dataSize + p->keepSizeAfter) is met + So there is no MoveBlock() in that case case. +*/ + +int MatchFinder_NeedMove(CMatchFinder *p) +{ + if (p->directInput) + return 0; + if (p->streamEndWasReached || p->result != SZ_OK) + return 0; + return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter); +} + +void MatchFinder_ReadIfRequired(CMatchFinder *p) +{ + if (p->keepSizeAfter >= GET_AVAIL_BYTES(p)) + MatchFinder_ReadBlock(p); +} + + + +static void MatchFinder_SetDefaultSettings(CMatchFinder *p) +{ + p->cutValue = 32; + p->btMode = 1; + p->numHashBytes = 4; + p->bigHash = 0; +} + +#define kCrcPoly 0xEDB88320 + +void MatchFinder_Construct(CMatchFinder *p) +{ + unsigned i; + p->bufferBase = NULL; + p->directInput = 0; + p->hash = NULL; + p->expectedDataSize = (UInt64)(Int64)-1; + MatchFinder_SetDefaultSettings(p); + + for (i = 0; i < 256; i++) + { + UInt32 r = (UInt32)i; + unsigned j; + for (j = 0; j < 8; j++) + r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1))); + p->crc[i] = r; + } +} + +static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->hash); + p->hash = NULL; +} + +void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc) +{ + MatchFinder_FreeThisClassMemory(p, alloc); + LzInWindow_Free(p, alloc); +} + +static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc) +{ + size_t sizeInBytes = (size_t)num * sizeof(CLzRef); + if (sizeInBytes / sizeof(CLzRef) != num) + return NULL; + return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes); +} + +#if (kBlockSizeReserveMin < kBlockSizeAlign * 2) + #error Stop_Compiling_Bad_Reserve +#endif + + + +static UInt32 GetBlockSize(CMatchFinder *p, UInt32 historySize) +{ + UInt32 blockSize = (p->keepSizeBefore + p->keepSizeAfter); + /* + if (historySize > kMaxHistorySize) + return 0; + */ + // printf("\nhistorySize == 0x%x\n", historySize); + + if (p->keepSizeBefore < historySize || blockSize < p->keepSizeBefore) // if 32-bit overflow + return 0; + + { + const UInt32 kBlockSizeMax = (UInt32)0 - (UInt32)kBlockSizeAlign; + const UInt32 rem = kBlockSizeMax - blockSize; + const UInt32 reserve = (blockSize >> (blockSize < ((UInt32)1 << 30) ? 1 : 2)) + + (1 << 12) + kBlockMoveAlign + kBlockSizeAlign; // do not overflow 32-bit here + if (blockSize >= kBlockSizeMax + || rem < kBlockSizeReserveMin) // we reject settings that will be slow + return 0; + if (reserve >= rem) + blockSize = kBlockSizeMax; + else + { + blockSize += reserve; + blockSize &= ~(UInt32)(kBlockSizeAlign - 1); + } + } + // printf("\n LzFind_blockSize = %x\n", blockSize); + // printf("\n LzFind_blockSize = %d\n", blockSize >> 20); + return blockSize; +} + + +int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, + UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, + ISzAllocPtr alloc) +{ + /* we need one additional byte in (p->keepSizeBefore), + since we use MoveBlock() after (p->pos++) and before dictionary using */ + // keepAddBufferBefore = (UInt32)0xFFFFFFFF - (1 << 22); // for debug + p->keepSizeBefore = historySize + keepAddBufferBefore + 1; + + keepAddBufferAfter += matchMaxLen; + /* we need (p->keepSizeAfter >= p->numHashBytes) */ + if (keepAddBufferAfter < p->numHashBytes) + keepAddBufferAfter = p->numHashBytes; + // keepAddBufferAfter -= 2; // for debug + p->keepSizeAfter = keepAddBufferAfter; + + if (p->directInput) + p->blockSize = 0; + if (p->directInput || LzInWindow_Create2(p, GetBlockSize(p, historySize), alloc)) + { + const UInt32 newCyclicBufferSize = historySize + 1; // do not change it + UInt32 hs; + p->matchMaxLen = matchMaxLen; + { + // UInt32 hs4; + p->fixedHashSize = 0; + hs = (1 << 16) - 1; + if (p->numHashBytes != 2) + { + hs = historySize; + if (hs > p->expectedDataSize) + hs = (UInt32)p->expectedDataSize; + if (hs != 0) + hs--; + hs |= (hs >> 1); + hs |= (hs >> 2); + hs |= (hs >> 4); + hs |= (hs >> 8); + // we propagated 16 bits in (hs). Low 16 bits must be set later + hs >>= 1; + if (hs >= (1 << 24)) + { + if (p->numHashBytes == 3) + hs = (1 << 24) - 1; + else + hs >>= 1; + /* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */ + } + + // hs = ((UInt32)1 << 25) - 1; // for test + + // (hash_size >= (1 << 16)) : Required for (numHashBytes > 2) + hs |= (1 << 16) - 1; /* don't change it! */ + + // bt5: we adjust the size with recommended minimum size + if (p->numHashBytes >= 5) + hs |= (256 << kLzHash_CrcShift_2) - 1; + } + p->hashMask = hs; + hs++; + + /* + hs4 = (1 << 20); + if (hs4 > hs) + hs4 = hs; + // hs4 = (1 << 16); // for test + p->hash4Mask = hs4 - 1; + */ + + if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size; + if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size; + // if (p->numHashBytes > 4) p->fixedHashSize += hs4; // kHash4Size; + hs += p->fixedHashSize; + } + + { + size_t newSize; + size_t numSons; + p->historySize = historySize; + p->hashSizeSum = hs; + p->cyclicBufferSize = newCyclicBufferSize; // it must be = (historySize + 1) + + numSons = newCyclicBufferSize; + if (p->btMode) + numSons <<= 1; + newSize = hs + numSons; + + // aligned size is not required here, but it can be better for some loops + #define NUM_REFS_ALIGN_MASK 0xF + newSize = (newSize + NUM_REFS_ALIGN_MASK) & ~(size_t)NUM_REFS_ALIGN_MASK; + + if (p->hash && p->numRefs == newSize) + return 1; + + MatchFinder_FreeThisClassMemory(p, alloc); + p->numRefs = newSize; + p->hash = AllocRefs(newSize, alloc); + + if (p->hash) + { + p->son = p->hash + p->hashSizeSum; + return 1; + } + } + } + + MatchFinder_Free(p, alloc); + return 0; +} + + +static void MatchFinder_SetLimits(CMatchFinder *p) +{ + UInt32 k; + UInt32 n = kMaxValForNormalize - p->pos; + if (n == 0) + n = (UInt32)(Int32)-1; // we allow (pos == 0) at start even with (kMaxValForNormalize == 0) + + k = p->cyclicBufferSize - p->cyclicBufferPos; + if (k < n) + n = k; + + k = GET_AVAIL_BYTES(p); + { + const UInt32 ksa = p->keepSizeAfter; + UInt32 mm = p->matchMaxLen; + if (k > ksa) + k -= ksa; // we must limit exactly to keepSizeAfter for ReadBlock + else if (k >= mm) + { + // the limitation for (p->lenLimit) update + k -= mm; // optimization : to reduce the number of checks + k++; + // k = 1; // non-optimized version : for debug + } + else + { + mm = k; + if (k != 0) + k = 1; + } + p->lenLimit = mm; + } + if (k < n) + n = k; + + p->posLimit = p->pos + n; +} + + +void MatchFinder_Init_LowHash(CMatchFinder *p) +{ + size_t i; + CLzRef *items = p->hash; + const size_t numItems = p->fixedHashSize; + for (i = 0; i < numItems; i++) + items[i] = kEmptyHashValue; +} + + +void MatchFinder_Init_HighHash(CMatchFinder *p) +{ + size_t i; + CLzRef *items = p->hash + p->fixedHashSize; + const size_t numItems = (size_t)p->hashMask + 1; + for (i = 0; i < numItems; i++) + items[i] = kEmptyHashValue; +} + + +void MatchFinder_Init_4(CMatchFinder *p) +{ + p->buffer = p->bufferBase; + { + /* kEmptyHashValue = 0 (Zero) is used in hash tables as NO-VALUE marker. + the code in CMatchFinderMt expects (pos = 1) */ + p->pos = + p->streamPos = + 1; // it's smallest optimal value. do not change it + // 0; // for debug + } + p->result = SZ_OK; + p->streamEndWasReached = 0; +} + + +// (CYC_TO_POS_OFFSET == 0) is expected by some optimized code +#define CYC_TO_POS_OFFSET 0 +// #define CYC_TO_POS_OFFSET 1 // for debug + +void MatchFinder_Init(CMatchFinder *p) +{ + MatchFinder_Init_HighHash(p); + MatchFinder_Init_LowHash(p); + MatchFinder_Init_4(p); + // if (readData) + MatchFinder_ReadBlock(p); + + /* if we init (cyclicBufferPos = pos), then we can use one variable + instead of both (cyclicBufferPos) and (pos) : only before (cyclicBufferPos) wrapping */ + p->cyclicBufferPos = (p->pos - CYC_TO_POS_OFFSET); // init with relation to (pos) + // p->cyclicBufferPos = 0; // smallest value + // p->son[0] = p->son[1] = 0; // unused: we can init skipped record for speculated accesses. + MatchFinder_SetLimits(p); +} + + + +#ifdef MY_CPU_X86_OR_AMD64 + #if defined(__clang__) && (__clang_major__ >= 8) \ + || defined(__GNUC__) && (__GNUC__ >= 8) \ + || defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1900) + #define USE_SATUR_SUB_128 + #define USE_AVX2 + #define ATTRIB_SSE41 __attribute__((__target__("sse4.1"))) + #define ATTRIB_AVX2 __attribute__((__target__("avx2"))) + #elif defined(_MSC_VER) + #if (_MSC_VER >= 1600) + #define USE_SATUR_SUB_128 + #if (_MSC_VER >= 1900) + #define USE_AVX2 + #include // avx + #endif + #endif + #endif + +// #elif defined(MY_CPU_ARM_OR_ARM64) +#elif defined(MY_CPU_ARM64) + + #if defined(__clang__) && (__clang_major__ >= 8) \ + || defined(__GNUC__) && (__GNUC__ >= 8) + #define USE_SATUR_SUB_128 + #ifdef MY_CPU_ARM64 + // #define ATTRIB_SSE41 __attribute__((__target__(""))) + #else + // #define ATTRIB_SSE41 __attribute__((__target__("fpu=crypto-neon-fp-armv8"))) + #endif + + #elif defined(_MSC_VER) + #if (_MSC_VER >= 1910) + #define USE_SATUR_SUB_128 + #endif + #endif + + #if defined(_MSC_VER) && defined(MY_CPU_ARM64) + #include + #else + #include + #endif + +#endif + +/* +#ifndef ATTRIB_SSE41 + #define ATTRIB_SSE41 +#endif +#ifndef ATTRIB_AVX2 + #define ATTRIB_AVX2 +#endif +*/ + +#ifdef USE_SATUR_SUB_128 + +// #define _SHOW_HW_STATUS + +#ifdef _SHOW_HW_STATUS +#include +#define _PRF(x) x +_PRF(;) +#else +#define _PRF(x) +#endif + +#ifdef MY_CPU_ARM_OR_ARM64 + +#ifdef MY_CPU_ARM64 +// #define FORCE_SATUR_SUB_128 +#endif + +typedef uint32x4_t v128; +#define SASUB_128(i) \ + *(v128 *)(void *)(items + (i) * 4) = \ + vsubq_u32(vmaxq_u32(*(const v128 *)(const void *)(items + (i) * 4), sub2), sub2); + +#else + +#include // sse4.1 + +typedef __m128i v128; +#define SASUB_128(i) \ + *(v128 *)(void *)(items + (i) * 4) = \ + _mm_sub_epi32(_mm_max_epu32(*(const v128 *)(const void *)(items + (i) * 4), sub2), sub2); // SSE 4.1 + +#endif + + + +MY_NO_INLINE +static +#ifdef ATTRIB_SSE41 +ATTRIB_SSE41 +#endif +void +MY_FAST_CALL +LzFind_SaturSub_128(UInt32 subValue, CLzRef *items, const CLzRef *lim) +{ + v128 sub2 = + #ifdef MY_CPU_ARM_OR_ARM64 + vdupq_n_u32(subValue); + #else + _mm_set_epi32((Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue); + #endif + do + { + SASUB_128(0) + SASUB_128(1) + SASUB_128(2) + SASUB_128(3) + items += 4 * 4; + } + while (items != lim); +} + + + +#ifdef USE_AVX2 + +#include // avx + +#define SASUB_256(i) *(__m256i *)(void *)(items + (i) * 8) = _mm256_sub_epi32(_mm256_max_epu32(*(const __m256i *)(const void *)(items + (i) * 8), sub2), sub2); // AVX2 + +MY_NO_INLINE +static +#ifdef ATTRIB_AVX2 +ATTRIB_AVX2 +#endif +void +MY_FAST_CALL +LzFind_SaturSub_256(UInt32 subValue, CLzRef *items, const CLzRef *lim) +{ + __m256i sub2 = _mm256_set_epi32( + (Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue, + (Int32)subValue, (Int32)subValue, (Int32)subValue, (Int32)subValue); + do + { + SASUB_256(0) + SASUB_256(1) + items += 2 * 8; + } + while (items != lim); +} +#endif // USE_AVX2 + +#ifndef FORCE_SATUR_SUB_128 +typedef void (MY_FAST_CALL *LZFIND_SATUR_SUB_CODE_FUNC)( + UInt32 subValue, CLzRef *items, const CLzRef *lim); +static LZFIND_SATUR_SUB_CODE_FUNC g_LzFind_SaturSub; +#endif // FORCE_SATUR_SUB_128 + +#endif // USE_SATUR_SUB_128 + + +// kEmptyHashValue must be zero +// #define SASUB_32(i) v = items[i]; m = v - subValue; if (v < subValue) m = kEmptyHashValue; items[i] = m; +#define SASUB_32(i) v = items[i]; if (v < subValue) v = subValue; items[i] = v - subValue; + +#ifdef FORCE_SATUR_SUB_128 + +#define DEFAULT_SaturSub LzFind_SaturSub_128 + +#else + +#define DEFAULT_SaturSub LzFind_SaturSub_32 + +MY_NO_INLINE +static +void +MY_FAST_CALL +LzFind_SaturSub_32(UInt32 subValue, CLzRef *items, const CLzRef *lim) +{ + do + { + UInt32 v; + SASUB_32(0) + SASUB_32(1) + SASUB_32(2) + SASUB_32(3) + SASUB_32(4) + SASUB_32(5) + SASUB_32(6) + SASUB_32(7) + items += 8; + } + while (items != lim); +} + +#endif + + +MY_NO_INLINE +void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems) +{ + #define K_NORM_ALIGN_BLOCK_SIZE (1 << 6) + + CLzRef *lim; + + for (; numItems != 0 && ((unsigned)(ptrdiff_t)items & (K_NORM_ALIGN_BLOCK_SIZE - 1)) != 0; numItems--) + { + UInt32 v; + SASUB_32(0); + items++; + } + + { + #define K_NORM_ALIGN_MASK (K_NORM_ALIGN_BLOCK_SIZE / 4 - 1) + lim = items + (numItems & ~(size_t)K_NORM_ALIGN_MASK); + numItems &= K_NORM_ALIGN_MASK; + if (items != lim) + { + #if defined(USE_SATUR_SUB_128) && !defined(FORCE_SATUR_SUB_128) + if (g_LzFind_SaturSub) + g_LzFind_SaturSub(subValue, items, lim); + else + #endif + DEFAULT_SaturSub(subValue, items, lim); + } + items = lim; + } + + + for (; numItems != 0; numItems--) + { + UInt32 v; + SASUB_32(0); + items++; + } +} + + + +// call MatchFinder_CheckLimits() only after (p->pos++) update + +MY_NO_INLINE +static void MatchFinder_CheckLimits(CMatchFinder *p) +{ + if (// !p->streamEndWasReached && p->result == SZ_OK && + p->keepSizeAfter == GET_AVAIL_BYTES(p)) + { + // we try to read only in exact state (p->keepSizeAfter == GET_AVAIL_BYTES(p)) + if (MatchFinder_NeedMove(p)) + MatchFinder_MoveBlock(p); + MatchFinder_ReadBlock(p); + } + + if (p->pos == kMaxValForNormalize) + if (GET_AVAIL_BYTES(p) >= p->numHashBytes) // optional optimization for last bytes of data. + /* + if we disable normalization for last bytes of data, and + if (data_size == 4 GiB), we don't call wastfull normalization, + but (pos) will be wrapped over Zero (0) in that case. + And we cannot resume later to normal operation + */ + { + // MatchFinder_Normalize(p); + /* after normalization we need (p->pos >= p->historySize + 1); */ + /* we can reduce subValue to aligned value, if want to keep alignment + of (p->pos) and (p->buffer) for speculated accesses. */ + const UInt32 subValue = (p->pos - p->historySize - 1) /* & ~(UInt32)(kNormalizeAlign - 1) */; + // const UInt32 subValue = (1 << 15); // for debug + // printf("\nMatchFinder_Normalize() subValue == 0x%x\n", subValue); + size_t numSonRefs = p->cyclicBufferSize; + if (p->btMode) + numSonRefs <<= 1; + Inline_MatchFinder_ReduceOffsets(p, subValue); + MatchFinder_Normalize3(subValue, p->hash, (size_t)p->hashSizeSum + numSonRefs); + } + + if (p->cyclicBufferPos == p->cyclicBufferSize) + p->cyclicBufferPos = 0; + + MatchFinder_SetLimits(p); +} + + +/* + (lenLimit > maxLen) +*/ +MY_FORCE_INLINE +static UInt32 * Hc_GetMatchesSpec(size_t lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, + UInt32 *d, unsigned maxLen) +{ + /* + son[_cyclicBufferPos] = curMatch; + for (;;) + { + UInt32 delta = pos - curMatch; + if (cutValue-- == 0 || delta >= _cyclicBufferSize) + return d; + { + const Byte *pb = cur - delta; + curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; + if (pb[maxLen] == cur[maxLen] && *pb == *cur) + { + UInt32 len = 0; + while (++len != lenLimit) + if (pb[len] != cur[len]) + break; + if (maxLen < len) + { + maxLen = len; + *d++ = len; + *d++ = delta - 1; + if (len == lenLimit) + return d; + } + } + } + } + */ + + const Byte *lim = cur + lenLimit; + son[_cyclicBufferPos] = curMatch; + + do + { + UInt32 delta; + + if (curMatch == 0) + break; + // if (curMatch2 >= curMatch) return NULL; + delta = pos - curMatch; + if (delta >= _cyclicBufferSize) + break; + { + ptrdiff_t diff; + curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)]; + diff = (ptrdiff_t)0 - (ptrdiff_t)delta; + if (cur[maxLen] == cur[(ptrdiff_t)maxLen + diff]) + { + const Byte *c = cur; + while (*c == c[diff]) + { + if (++c == lim) + { + d[0] = (UInt32)(lim - cur); + d[1] = delta - 1; + return d + 2; + } + } + { + const unsigned len = (unsigned)(c - cur); + if (maxLen < len) + { + maxLen = len; + d[0] = (UInt32)len; + d[1] = delta - 1; + d += 2; + } + } + } + } + } + while (--cutValue); + + return d; +} + + +MY_FORCE_INLINE +UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue, + UInt32 *d, UInt32 maxLen) +{ + CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; + CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); + unsigned len0 = 0, len1 = 0; + + UInt32 cmCheck; + + // if (curMatch >= pos) { *ptr0 = *ptr1 = kEmptyHashValue; return NULL; } + + cmCheck = (UInt32)(pos - _cyclicBufferSize); + if ((UInt32)pos <= _cyclicBufferSize) + cmCheck = 0; + + if (cmCheck < curMatch) + do + { + const UInt32 delta = pos - curMatch; + { + CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); + const Byte *pb = cur - delta; + unsigned len = (len0 < len1 ? len0 : len1); + const UInt32 pair0 = pair[0]; + if (pb[len] == cur[len]) + { + if (++len != lenLimit && pb[len] == cur[len]) + while (++len != lenLimit) + if (pb[len] != cur[len]) + break; + if (maxLen < len) + { + maxLen = (UInt32)len; + *d++ = (UInt32)len; + *d++ = delta - 1; + if (len == lenLimit) + { + *ptr1 = pair0; + *ptr0 = pair[1]; + return d; + } + } + } + if (pb[len] < cur[len]) + { + *ptr1 = curMatch; + // const UInt32 curMatch2 = pair[1]; + // if (curMatch2 >= curMatch) { *ptr0 = *ptr1 = kEmptyHashValue; return NULL; } + // curMatch = curMatch2; + curMatch = pair[1]; + ptr1 = pair + 1; + len1 = len; + } + else + { + *ptr0 = curMatch; + curMatch = pair[0]; + ptr0 = pair; + len0 = len; + } + } + } + while(--cutValue && cmCheck < curMatch); + + *ptr0 = *ptr1 = kEmptyHashValue; + return d; +} + + +static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue) +{ + CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; + CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); + unsigned len0 = 0, len1 = 0; + + UInt32 cmCheck; + + cmCheck = (UInt32)(pos - _cyclicBufferSize); + if ((UInt32)pos <= _cyclicBufferSize) + cmCheck = 0; + + if (// curMatch >= pos || // failure + cmCheck < curMatch) + do + { + const UInt32 delta = pos - curMatch; + { + CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1); + const Byte *pb = cur - delta; + unsigned len = (len0 < len1 ? len0 : len1); + if (pb[len] == cur[len]) + { + while (++len != lenLimit) + if (pb[len] != cur[len]) + break; + { + if (len == lenLimit) + { + *ptr1 = pair[0]; + *ptr0 = pair[1]; + return; + } + } + } + if (pb[len] < cur[len]) + { + *ptr1 = curMatch; + curMatch = pair[1]; + ptr1 = pair + 1; + len1 = len; + } + else + { + *ptr0 = curMatch; + curMatch = pair[0]; + ptr0 = pair; + len0 = len; + } + } + } + while(--cutValue && cmCheck < curMatch); + + *ptr0 = *ptr1 = kEmptyHashValue; + return; +} + + +#define MOVE_POS \ + ++p->cyclicBufferPos; \ + p->buffer++; \ + { const UInt32 pos1 = p->pos + 1; p->pos = pos1; if (pos1 == p->posLimit) MatchFinder_CheckLimits(p); } + +#define MOVE_POS_RET MOVE_POS return distances; + +MY_NO_INLINE +static void MatchFinder_MovePos(CMatchFinder *p) +{ + /* we go here at the end of stream data, when (avail < num_hash_bytes) + We don't update sons[cyclicBufferPos << btMode]. + So (sons) record will contain junk. And we cannot resume match searching + to normal operation, even if we will provide more input data in buffer. + p->sons[p->cyclicBufferPos << p->btMode] = 0; // kEmptyHashValue + if (p->btMode) + p->sons[(p->cyclicBufferPos << p->btMode) + 1] = 0; // kEmptyHashValue + */ + MOVE_POS; +} + +#define GET_MATCHES_HEADER2(minLen, ret_op) \ + unsigned lenLimit; UInt32 hv; Byte *cur; UInt32 curMatch; \ + lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \ + cur = p->buffer; + +#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return distances) +#define SKIP_HEADER(minLen) do { GET_MATCHES_HEADER2(minLen, continue) + +#define MF_PARAMS(p) lenLimit, curMatch, p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue + +#define SKIP_FOOTER SkipMatchesSpec(MF_PARAMS(p)); MOVE_POS; } while (--num); + +#define GET_MATCHES_FOOTER_BASE(_maxLen_, func) \ + distances = func(MF_PARAMS(p), \ + distances, (UInt32)_maxLen_); MOVE_POS_RET; + +#define GET_MATCHES_FOOTER_BT(_maxLen_) \ + GET_MATCHES_FOOTER_BASE(_maxLen_, GetMatchesSpec1) + +#define GET_MATCHES_FOOTER_HC(_maxLen_) \ + GET_MATCHES_FOOTER_BASE(_maxLen_, Hc_GetMatchesSpec) + + + +#define UPDATE_maxLen { \ + const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)d2; \ + const Byte *c = cur + maxLen; \ + const Byte *lim = cur + lenLimit; \ + for (; c != lim; c++) if (*(c + diff) != *c) break; \ + maxLen = (unsigned)(c - cur); } + +static UInt32* Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + GET_MATCHES_HEADER(2) + HASH2_CALC; + curMatch = p->hash[hv]; + p->hash[hv] = p->pos; + GET_MATCHES_FOOTER_BT(1) +} + +UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + GET_MATCHES_HEADER(3) + HASH_ZIP_CALC; + curMatch = p->hash[hv]; + p->hash[hv] = p->pos; + GET_MATCHES_FOOTER_BT(2) +} + + +#define SET_mmm \ + mmm = p->cyclicBufferSize; \ + if (pos < mmm) \ + mmm = pos; + + +static UInt32* Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + UInt32 mmm; + UInt32 h2, d2, pos; + unsigned maxLen; + UInt32 *hash; + GET_MATCHES_HEADER(3) + + HASH3_CALC; + + hash = p->hash; + pos = p->pos; + + d2 = pos - hash[h2]; + + curMatch = (hash + kFix3HashSize)[hv]; + + hash[h2] = pos; + (hash + kFix3HashSize)[hv] = pos; + + SET_mmm + + maxLen = 2; + + if (d2 < mmm && *(cur - d2) == *cur) + { + UPDATE_maxLen + distances[0] = (UInt32)maxLen; + distances[1] = d2 - 1; + distances += 2; + if (maxLen == lenLimit) + { + SkipMatchesSpec(MF_PARAMS(p)); + MOVE_POS_RET; + } + } + + GET_MATCHES_FOOTER_BT(maxLen) +} + + +static UInt32* Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + UInt32 mmm; + UInt32 h2, h3, d2, d3, pos; + unsigned maxLen; + UInt32 *hash; + GET_MATCHES_HEADER(4) + + HASH4_CALC; + + hash = p->hash; + pos = p->pos; + + d2 = pos - hash [h2]; + d3 = pos - (hash + kFix3HashSize)[h3]; + curMatch = (hash + kFix4HashSize)[hv]; + + hash [h2] = pos; + (hash + kFix3HashSize)[h3] = pos; + (hash + kFix4HashSize)[hv] = pos; + + SET_mmm + + maxLen = 3; + + for (;;) + { + if (d2 < mmm && *(cur - d2) == *cur) + { + distances[0] = 2; + distances[1] = d2 - 1; + distances += 2; + if (*(cur - d2 + 2) == cur[2]) + { + // distances[-2] = 3; + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + d2 = d3; + distances[1] = d3 - 1; + distances += 2; + } + else + break; + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + d2 = d3; + distances[1] = d3 - 1; + distances += 2; + } + else + break; + + UPDATE_maxLen + distances[-2] = (UInt32)maxLen; + if (maxLen == lenLimit) + { + SkipMatchesSpec(MF_PARAMS(p)); + MOVE_POS_RET + } + break; + } + + GET_MATCHES_FOOTER_BT(maxLen) +} + + +static UInt32* Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + UInt32 mmm; + UInt32 h2, h3, d2, d3, maxLen, pos; + UInt32 *hash; + GET_MATCHES_HEADER(5) + + HASH5_CALC; + + hash = p->hash; + pos = p->pos; + + d2 = pos - hash [h2]; + d3 = pos - (hash + kFix3HashSize)[h3]; + // d4 = pos - (hash + kFix4HashSize)[h4]; + + curMatch = (hash + kFix5HashSize)[hv]; + + hash [h2] = pos; + (hash + kFix3HashSize)[h3] = pos; + // (hash + kFix4HashSize)[h4] = pos; + (hash + kFix5HashSize)[hv] = pos; + + SET_mmm + + maxLen = 4; + + for (;;) + { + if (d2 < mmm && *(cur - d2) == *cur) + { + distances[0] = 2; + distances[1] = d2 - 1; + distances += 2; + if (*(cur - d2 + 2) == cur[2]) + { + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + distances[1] = d3 - 1; + distances += 2; + d2 = d3; + } + else + break; + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + distances[1] = d3 - 1; + distances += 2; + d2 = d3; + } + else + break; + + distances[-2] = 3; + if (*(cur - d2 + 3) != cur[3]) + break; + UPDATE_maxLen + distances[-2] = (UInt32)maxLen; + if (maxLen == lenLimit) + { + SkipMatchesSpec(MF_PARAMS(p)); + MOVE_POS_RET; + } + break; + } + + GET_MATCHES_FOOTER_BT(maxLen) +} + + +static UInt32* Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + UInt32 mmm; + UInt32 h2, h3, d2, d3, pos; + unsigned maxLen; + UInt32 *hash; + GET_MATCHES_HEADER(4) + + HASH4_CALC; + + hash = p->hash; + pos = p->pos; + + d2 = pos - hash [h2]; + d3 = pos - (hash + kFix3HashSize)[h3]; + curMatch = (hash + kFix4HashSize)[hv]; + + hash [h2] = pos; + (hash + kFix3HashSize)[h3] = pos; + (hash + kFix4HashSize)[hv] = pos; + + SET_mmm + + maxLen = 3; + + for (;;) + { + if (d2 < mmm && *(cur - d2) == *cur) + { + distances[0] = 2; + distances[1] = d2 - 1; + distances += 2; + if (*(cur - d2 + 2) == cur[2]) + { + // distances[-2] = 3; + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + d2 = d3; + distances[1] = d3 - 1; + distances += 2; + } + else + break; + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + d2 = d3; + distances[1] = d3 - 1; + distances += 2; + } + else + break; + + UPDATE_maxLen + distances[-2] = (UInt32)maxLen; + if (maxLen == lenLimit) + { + p->son[p->cyclicBufferPos] = curMatch; + MOVE_POS_RET; + } + break; + } + + GET_MATCHES_FOOTER_HC(maxLen); +} + + +static UInt32 * Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + UInt32 mmm; + UInt32 h2, h3, d2, d3, maxLen, pos; + UInt32 *hash; + GET_MATCHES_HEADER(5) + + HASH5_CALC; + + hash = p->hash; + pos = p->pos; + + d2 = pos - hash [h2]; + d3 = pos - (hash + kFix3HashSize)[h3]; + // d4 = pos - (hash + kFix4HashSize)[h4]; + + curMatch = (hash + kFix5HashSize)[hv]; + + hash [h2] = pos; + (hash + kFix3HashSize)[h3] = pos; + // (hash + kFix4HashSize)[h4] = pos; + (hash + kFix5HashSize)[hv] = pos; + + SET_mmm + + maxLen = 4; + + for (;;) + { + if (d2 < mmm && *(cur - d2) == *cur) + { + distances[0] = 2; + distances[1] = d2 - 1; + distances += 2; + if (*(cur - d2 + 2) == cur[2]) + { + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + distances[1] = d3 - 1; + distances += 2; + d2 = d3; + } + else + break; + } + else if (d3 < mmm && *(cur - d3) == *cur) + { + distances[1] = d3 - 1; + distances += 2; + d2 = d3; + } + else + break; + + distances[-2] = 3; + if (*(cur - d2 + 3) != cur[3]) + break; + UPDATE_maxLen + distances[-2] = maxLen; + if (maxLen == lenLimit) + { + p->son[p->cyclicBufferPos] = curMatch; + MOVE_POS_RET; + } + break; + } + + GET_MATCHES_FOOTER_HC(maxLen); +} + + +UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) +{ + GET_MATCHES_HEADER(3) + HASH_ZIP_CALC; + curMatch = p->hash[hv]; + p->hash[hv] = p->pos; + GET_MATCHES_FOOTER_HC(2) +} + + +static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + SKIP_HEADER(2) + { + HASH2_CALC; + curMatch = p->hash[hv]; + p->hash[hv] = p->pos; + } + SKIP_FOOTER +} + +void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + SKIP_HEADER(3) + { + HASH_ZIP_CALC; + curMatch = p->hash[hv]; + p->hash[hv] = p->pos; + } + SKIP_FOOTER +} + +static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + SKIP_HEADER(3) + { + UInt32 h2; + UInt32 *hash; + HASH3_CALC; + hash = p->hash; + curMatch = (hash + kFix3HashSize)[hv]; + hash[h2] = + (hash + kFix3HashSize)[hv] = p->pos; + } + SKIP_FOOTER +} + +static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + SKIP_HEADER(4) + { + UInt32 h2, h3; + UInt32 *hash; + HASH4_CALC; + hash = p->hash; + curMatch = (hash + kFix4HashSize)[hv]; + hash [h2] = + (hash + kFix3HashSize)[h3] = + (hash + kFix4HashSize)[hv] = p->pos; + } + SKIP_FOOTER +} + +static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + SKIP_HEADER(5) + { + UInt32 h2, h3; + UInt32 *hash; + HASH5_CALC; + hash = p->hash; + curMatch = (hash + kFix5HashSize)[hv]; + hash [h2] = + (hash + kFix3HashSize)[h3] = + // (hash + kFix4HashSize)[h4] = + (hash + kFix5HashSize)[hv] = p->pos; + } + SKIP_FOOTER +} + + +#define HC_SKIP_HEADER(minLen) \ + do { if (p->lenLimit < minLen) { MatchFinder_MovePos(p); num--; continue; } { \ + Byte *cur; \ + UInt32 *hash; \ + UInt32 *son; \ + UInt32 pos = p->pos; \ + UInt32 num2 = num; \ + /* (p->pos == p->posLimit) is not allowed here !!! */ \ + { const UInt32 rem = p->posLimit - pos; if (num2 > rem) num2 = rem; } \ + num -= num2; \ + { const UInt32 cycPos = p->cyclicBufferPos; \ + son = p->son + cycPos; \ + p->cyclicBufferPos = cycPos + num2; } \ + cur = p->buffer; \ + hash = p->hash; \ + do { \ + UInt32 curMatch; \ + UInt32 hv; + + +#define HC_SKIP_FOOTER \ + cur++; pos++; *son++ = curMatch; \ + } while (--num2); \ + p->buffer = cur; \ + p->pos = pos; \ + if (pos == p->posLimit) MatchFinder_CheckLimits(p); \ + }} while(num); \ + + +static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + HC_SKIP_HEADER(4) + + UInt32 h2, h3; + HASH4_CALC; + curMatch = (hash + kFix4HashSize)[hv]; + hash [h2] = + (hash + kFix3HashSize)[h3] = + (hash + kFix4HashSize)[hv] = pos; + + HC_SKIP_FOOTER +} + + +static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + HC_SKIP_HEADER(5) + + UInt32 h2, h3; + HASH5_CALC + curMatch = (hash + kFix5HashSize)[hv]; + hash [h2] = + (hash + kFix3HashSize)[h3] = + // (hash + kFix4HashSize)[h4] = + (hash + kFix5HashSize)[hv] = pos; + + HC_SKIP_FOOTER +} + + +void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num) +{ + HC_SKIP_HEADER(3) + + HASH_ZIP_CALC; + curMatch = hash[hv]; + hash[hv] = pos; + + HC_SKIP_FOOTER +} + + +void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable) +{ + vTable->Init = (Mf_Init_Func)MatchFinder_Init; + vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes; + vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos; + if (!p->btMode) + { + if (p->numHashBytes <= 4) + { + vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip; + } + else + { + vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip; + } + } + else if (p->numHashBytes == 2) + { + vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip; + } + else if (p->numHashBytes == 3) + { + vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip; + } + else if (p->numHashBytes == 4) + { + vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip; + } + else + { + vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches; + vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip; + } +} + + + +void LzFindPrepare() +{ + #ifndef FORCE_SATUR_SUB_128 + #ifdef USE_SATUR_SUB_128 + LZFIND_SATUR_SUB_CODE_FUNC f = NULL; + #ifdef MY_CPU_ARM_OR_ARM64 + { + if (CPU_IsSupported_NEON()) + { + // #pragma message ("=== LzFind NEON") + _PRF(printf("\n=== LzFind NEON\n")); + f = LzFind_SaturSub_128; + } + // f = 0; // for debug + } + #else // MY_CPU_ARM_OR_ARM64 + if (CPU_IsSupported_SSE41()) + { + // #pragma message ("=== LzFind SSE41") + _PRF(printf("\n=== LzFind SSE41\n")); + f = LzFind_SaturSub_128; + + #ifdef USE_AVX2 + if (CPU_IsSupported_AVX2()) + { + // #pragma message ("=== LzFind AVX2") + _PRF(printf("\n=== LzFind AVX2\n")); + f = LzFind_SaturSub_256; + } + #endif + } + #endif // MY_CPU_ARM_OR_ARM64 + g_LzFind_SaturSub = f; + #endif // USE_SATUR_SUB_128 + #endif // FORCE_SATUR_SUB_128 +} diff --git a/deps/LZMA-SDK/C/LzFind.h b/deps/LZMA-SDK/C/LzFind.h index 3e2248e7d..eea873ff6 100644 --- a/deps/LZMA-SDK/C/LzFind.h +++ b/deps/LZMA-SDK/C/LzFind.h @@ -1,121 +1,136 @@ -/* LzFind.h -- Match finder for LZ algorithms -2021-02-09 : Igor Pavlov : Public domain */ - -#ifndef __LZ_FIND_H -#define __LZ_FIND_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -typedef UInt32 CLzRef; - -typedef struct _CMatchFinder -{ - Byte *buffer; - UInt32 pos; - UInt32 posLimit; - UInt32 streamPos; - UInt32 lenLimit; - - UInt32 cyclicBufferPos; - UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ - - Byte streamEndWasReached; - Byte btMode; - Byte bigHash; - Byte directInput; - - UInt32 matchMaxLen; - CLzRef *hash; - CLzRef *son; - UInt32 hashMask; - UInt32 cutValue; - - Byte *bufferBase; - ISeqInStream *stream; - - UInt32 blockSize; - UInt32 keepSizeBefore; - UInt32 keepSizeAfter; - - UInt32 numHashBytes; - size_t directInputRem; - UInt32 historySize; - UInt32 fixedHashSize; - UInt32 hashSizeSum; - SRes result; - UInt32 crc[256]; - size_t numRefs; - - UInt64 expectedDataSize; -} CMatchFinder; - -#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer) - -#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos) - -#define Inline_MatchFinder_IsFinishedOK(p) \ - ((p)->streamEndWasReached \ - && (p)->streamPos == (p)->pos \ - && (!(p)->directInput || (p)->directInputRem == 0)) - -int MatchFinder_NeedMove(CMatchFinder *p); -// Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); -void MatchFinder_MoveBlock(CMatchFinder *p); -void MatchFinder_ReadIfRequired(CMatchFinder *p); - -void MatchFinder_Construct(CMatchFinder *p); - -/* Conditions: - historySize <= 3 GB - keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB -*/ -int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, - UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, - ISzAllocPtr alloc); -void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); -void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); -void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); - -UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, - UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, - UInt32 *distances, UInt32 maxLen); - -/* -Conditions: - Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. - Mf_GetPointerToCurrentPos_Func's result must be used only before any other function -*/ - -typedef void (*Mf_Init_Func)(void *object); -typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); -typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); -typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances); -typedef void (*Mf_Skip_Func)(void *object, UInt32); - -typedef struct _IMatchFinder -{ - Mf_Init_Func Init; - Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; - Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; - Mf_GetMatches_Func GetMatches; - Mf_Skip_Func Skip; -} IMatchFinder; - -void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable); - -void MatchFinder_Init_LowHash(CMatchFinder *p); -void MatchFinder_Init_HighHash(CMatchFinder *p); -void MatchFinder_Init_3(CMatchFinder *p, int readData); -void MatchFinder_Init(CMatchFinder *p); - -UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); -UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); - -void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); -void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); - -EXTERN_C_END - -#endif +/* LzFind.h -- Match finder for LZ algorithms +2021-07-13 : Igor Pavlov : Public domain */ + +#ifndef __LZ_FIND_H +#define __LZ_FIND_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +typedef UInt32 CLzRef; + +typedef struct _CMatchFinder +{ + Byte *buffer; + UInt32 pos; + UInt32 posLimit; + UInt32 streamPos; /* wrap over Zero is allowed (streamPos < pos). Use (UInt32)(streamPos - pos) */ + UInt32 lenLimit; + + UInt32 cyclicBufferPos; + UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ + + Byte streamEndWasReached; + Byte btMode; + Byte bigHash; + Byte directInput; + + UInt32 matchMaxLen; + CLzRef *hash; + CLzRef *son; + UInt32 hashMask; + UInt32 cutValue; + + Byte *bufferBase; + ISeqInStream *stream; + + UInt32 blockSize; + UInt32 keepSizeBefore; + UInt32 keepSizeAfter; + + UInt32 numHashBytes; + size_t directInputRem; + UInt32 historySize; + UInt32 fixedHashSize; + UInt32 hashSizeSum; + SRes result; + UInt32 crc[256]; + size_t numRefs; + + UInt64 expectedDataSize; +} CMatchFinder; + +#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((const Byte *)(p)->buffer) + +#define Inline_MatchFinder_GetNumAvailableBytes(p) ((UInt32)((p)->streamPos - (p)->pos)) + +/* +#define Inline_MatchFinder_IsFinishedOK(p) \ + ((p)->streamEndWasReached \ + && (p)->streamPos == (p)->pos \ + && (!(p)->directInput || (p)->directInputRem == 0)) +*/ + +int MatchFinder_NeedMove(CMatchFinder *p); +/* Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); */ +void MatchFinder_MoveBlock(CMatchFinder *p); +void MatchFinder_ReadIfRequired(CMatchFinder *p); + +void MatchFinder_Construct(CMatchFinder *p); + +/* Conditions: + historySize <= 3 GB + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB +*/ +int MatchFinder_Create(CMatchFinder *p, UInt32 historySize, + UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter, + ISzAllocPtr alloc); +void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc); +void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems); +// void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue); + +/* +#define Inline_MatchFinder_InitPos(p, val) \ + (p)->pos = (val); \ + (p)->streamPos = (val); +*/ + +#define Inline_MatchFinder_ReduceOffsets(p, subValue) \ + (p)->pos -= (subValue); \ + (p)->streamPos -= (subValue); + + +UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, + UInt32 *distances, UInt32 maxLen); + +/* +Conditions: + Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func. + Mf_GetPointerToCurrentPos_Func's result must be used only before any other function +*/ + +typedef void (*Mf_Init_Func)(void *object); +typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object); +typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object); +typedef UInt32 * (*Mf_GetMatches_Func)(void *object, UInt32 *distances); +typedef void (*Mf_Skip_Func)(void *object, UInt32); + +typedef struct _IMatchFinder +{ + Mf_Init_Func Init; + Mf_GetNumAvailableBytes_Func GetNumAvailableBytes; + Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos; + Mf_GetMatches_Func GetMatches; + Mf_Skip_Func Skip; +} IMatchFinder2; + +void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable); + +void MatchFinder_Init_LowHash(CMatchFinder *p); +void MatchFinder_Init_HighHash(CMatchFinder *p); +void MatchFinder_Init_4(CMatchFinder *p); +void MatchFinder_Init(CMatchFinder *p); + +UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); +UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances); + +void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); +void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num); + +void LzFindPrepare(void); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/LzFindMt.c b/deps/LZMA-SDK/C/LzFindMt.c index cb29a1eac..4e67fc3f2 100644 --- a/deps/LZMA-SDK/C/LzFindMt.c +++ b/deps/LZMA-SDK/C/LzFindMt.c @@ -1,1182 +1,1400 @@ -/* LzFindMt.c -- multithreaded Match finder for LZ algorithms -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" - -#include "LzHash.h" -#include "LzFindMt.h" - -// #define LOG_ITERS - -#ifdef LOG_ITERS -#include -static UInt64 g_NumIters_Tree; -static UInt64 g_NumIters_Loop; -#define LOG_ITER(x) x -#else -#define LOG_ITER(x) -#endif - -#define kMtHashBlockSize (1 << 17) -#define kMtHashNumBlocks (1 << 1) -#define kMtHashNumBlocksMask (kMtHashNumBlocks - 1) - -#define kMtBtBlockSize (1 << 16) -#define kMtBtNumBlocks (1 << 4) -#define kMtBtNumBlocksMask (kMtBtNumBlocks - 1) - -/* - HASH functions: - We use raw 8/16 bits from a[1] and a[2], - xored with crc(a[0]) and crc(a[3]). - We check a[0], a[3] only. We don't need to compare a[1] and a[2] in matches. - our crc() function provides one-to-one correspondence for low 8-bit values: - (crc[0...0xFF] & 0xFF) <-> [0...0xFF] -*/ - -#define MT_HASH2_CALC \ - h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); - -#define MT_HASH3_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } - -/* -#define MT_HASH3_CALC__NO_2 { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } - -#define __MT_HASH4_CALC { \ - UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ - h2 = temp & (kHash2Size - 1); \ - temp ^= ((UInt32)cur[2] << 8); \ - h3 = temp & (kHash3Size - 1); \ - h4 = (temp ^ (p->crc[cur[3]] << kLzHash_CrcShift_1)) & p->hash4Mask; } - // (kHash4Size - 1); -*/ - - -static void MtSync_Construct(CMtSync *p) -{ - p->wasCreated = False; - p->csWasInitialized = False; - p->csWasEntered = False; - Thread_Construct(&p->thread); - Event_Construct(&p->canStart); - Event_Construct(&p->wasStarted); - Event_Construct(&p->wasStopped); - Semaphore_Construct(&p->freeSemaphore); - Semaphore_Construct(&p->filledSemaphore); - p->affinity = 0; -} - - -MY_NO_INLINE -static void MtSync_GetNextBlock(CMtSync *p) -{ - if (p->needStart) - { - p->numProcessedBlocks = 1; - p->needStart = False; - p->stopWriting = False; - p->exit = False; - Event_Reset(&p->wasStarted); - Event_Reset(&p->wasStopped); - - Event_Set(&p->canStart); - Event_Wait(&p->wasStarted); - - // if (mt) MatchFinder_Init_LowHash(mt->MatchFinder); - } - else - { - CriticalSection_Leave(&p->cs); - p->csWasEntered = False; - p->numProcessedBlocks++; - Semaphore_Release1(&p->freeSemaphore); - } - Semaphore_Wait(&p->filledSemaphore); - CriticalSection_Enter(&p->cs); - p->csWasEntered = True; -} - -/* MtSync_StopWriting must be called if Writing was started */ - -static void MtSync_StopWriting(CMtSync *p) -{ - UInt32 myNumBlocks = p->numProcessedBlocks; - if (!Thread_WasCreated(&p->thread) || p->needStart) - return; - p->stopWriting = True; - if (p->csWasEntered) - { - CriticalSection_Leave(&p->cs); - p->csWasEntered = False; - } - Semaphore_Release1(&p->freeSemaphore); - - Event_Wait(&p->wasStopped); - - while (myNumBlocks++ != p->numProcessedBlocks) - { - Semaphore_Wait(&p->filledSemaphore); - Semaphore_Release1(&p->freeSemaphore); - } - p->needStart = True; -} - -static void MtSync_Destruct(CMtSync *p) -{ - if (Thread_WasCreated(&p->thread)) - { - MtSync_StopWriting(p); - p->exit = True; - if (p->needStart) - Event_Set(&p->canStart); - Thread_Wait_Close(&p->thread); - } - if (p->csWasInitialized) - { - CriticalSection_Delete(&p->cs); - p->csWasInitialized = False; - } - - Event_Close(&p->canStart); - Event_Close(&p->wasStarted); - Event_Close(&p->wasStopped); - Semaphore_Close(&p->freeSemaphore); - Semaphore_Close(&p->filledSemaphore); - - p->wasCreated = False; -} - -#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; } - -static SRes MtSync_Create2(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj, UInt32 numBlocks) -{ - WRes wres; - if (p->wasCreated) - return SZ_OK; - - RINOK_THREAD(CriticalSection_Init(&p->cs)); - p->csWasInitialized = True; - - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart)); - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStarted)); - RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped)); - - RINOK_THREAD(Semaphore_Create(&p->freeSemaphore, numBlocks, numBlocks)); - RINOK_THREAD(Semaphore_Create(&p->filledSemaphore, 0, numBlocks)); - - p->needStart = True; - - if (p->affinity != 0) - wres = Thread_Create_With_Affinity(&p->thread, startAddress, obj, (CAffinityMask)p->affinity); - else - wres = Thread_Create(&p->thread, startAddress, obj); - RINOK_THREAD(wres); - p->wasCreated = True; - return SZ_OK; -} - -static SRes MtSync_Create(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj, UInt32 numBlocks) -{ - SRes res = MtSync_Create2(p, startAddress, obj, numBlocks); - if (res != SZ_OK) - MtSync_Destruct(p); - return res; -} - -// static void MtSync_Init(CMtSync *p) { p->needStart = True; } - -#define kMtMaxValForNormalize 0xFFFFFFFF -// #define kMtMaxValForNormalize ((1 << 25) + (1 << 20)) - - -#ifdef MY_CPU_LE_UNALIGN - #define GetUi24hi_from32(p) ((UInt32)GetUi32(p) >> 8) -#else - #define GetUi24hi_from32(p) ((p)[1] ^ ((UInt32)(p)[2] << 8) ^ ((UInt32)(p)[3] << 16)) -#endif - -#define GetHeads_DECL(name) \ - static void GetHeads ## name(const Byte *p, UInt32 pos, \ - UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) - -#define GetHeads_LOOP(v) \ - for (; numHeads != 0; numHeads--) { \ - const UInt32 value = (v); \ - p++; \ - *heads++ = pos - hash[value]; \ - hash[value] = pos++; } - -#define DEF_GetHeads2(name, v, action) \ - GetHeads_DECL(name) { action \ - GetHeads_LOOP(v) } - -#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;) - -DEF_GetHeads2(2, GetUi16(p), UNUSED_VAR(hashMask); UNUSED_VAR(crc); ) -DEF_GetHeads(3, (crc[p[0]] ^ GetUi16(p + 1)) & hashMask) -DEF_GetHeads2(3b, GetUi16(p) ^ ((UInt32)(p)[2] << 16), UNUSED_VAR(hashMask); UNUSED_VAR(crc); ) -// BT3 is not good for crc collisions for big hashMask values. - -/* -GetHeads_DECL(3b) -{ - UNUSED_VAR(hashMask); - UNUSED_VAR(crc); - { - const Byte *pLim = p + numHeads; - if (numHeads == 0) - return; - pLim--; - while (p < pLim) - { - UInt32 v1 = GetUi32(p); - UInt32 v0 = v1 & 0xFFFFFF; - UInt32 h0, h1; - p += 2; - v1 >>= 8; - h0 = hash[v0]; hash[v0] = pos; heads[0] = pos - h0; pos++; - h1 = hash[v1]; hash[v1] = pos; heads[1] = pos - h1; pos++; - heads += 2; - } - if (p == pLim) - { - UInt32 v0 = GetUi16(p) ^ ((UInt32)(p)[2] << 16); - *heads = pos - hash[v0]; - hash[v0] = pos; - } - } -} -*/ - -/* -GetHeads_DECL(4) -{ - unsigned sh = 0; - UNUSED_VAR(crc) - while ((hashMask & 0x80000000) == 0) - { - hashMask <<= 1; - sh++; - } - GetHeads_LOOP((GetUi32(p) * 0xa54a1) >> sh) -} -#define GetHeads4b GetHeads4 -*/ - -#define USE_GetHeads_LOCAL_CRC - -#ifdef USE_GetHeads_LOCAL_CRC - -GetHeads_DECL(4) -{ - UInt32 crc0[256]; - UInt32 crc1[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - { - UInt32 v = crc[i]; - crc0[i] = v & hashMask; - crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; - // crc1[i] = rotlFixed(v, 8) & hashMask; - } - } - GetHeads_LOOP(crc0[p[0]] ^ crc1[p[3]] ^ (UInt32)GetUi16(p+1)) -} - -GetHeads_DECL(4b) -{ - UInt32 crc0[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - crc0[i] = crc[i] & hashMask; - } - GetHeads_LOOP(crc0[p[0]] ^ GetUi24hi_from32(p)) -} - -GetHeads_DECL(5) -{ - UInt32 crc0[256]; - UInt32 crc1[256]; - UInt32 crc2[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - { - UInt32 v = crc[i]; - crc0[i] = v & hashMask; - crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; - crc2[i] = (v << kLzHash_CrcShift_2) & hashMask; - } - } - GetHeads_LOOP(crc0[p[0]] ^ crc1[p[3]] ^ crc2[p[4]] ^ (UInt32)GetUi16(p+1)) -} - -GetHeads_DECL(5b) -{ - UInt32 crc0[256]; - UInt32 crc1[256]; - { - unsigned i; - for (i = 0; i < 256; i++) - { - UInt32 v = crc[i]; - crc0[i] = v & hashMask; - crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; - } - } - GetHeads_LOOP(crc0[p[0]] ^ crc1[p[4]] ^ GetUi24hi_from32(p)) -} - -#else - -DEF_GetHeads(4, (crc[p[0]] ^ (crc[p[3]] << kLzHash_CrcShift_1) ^ (UInt32)GetUi16(p+1)) & hashMask) -DEF_GetHeads(4b, (crc[p[0]] ^ GetUi24hi_from32(p)) & hashMask) -DEF_GetHeads(5, (crc[p[0]] ^ (crc[p[3]] << kLzHash_CrcShift_1) ^ (crc[p[4]] << kLzHash_CrcShift_2) ^ (UInt32)GetUi16(p + 1)) & hashMask) -DEF_GetHeads(5b, (crc[p[0]] ^ (crc[p[4]] << kLzHash_CrcShift_1) ^ GetUi24hi_from32(p)) & hashMask) - -#endif - - -static void HashThreadFunc(CMatchFinderMt *mt) -{ - CMtSync *p = &mt->hashSync; - for (;;) - { - UInt32 numProcessedBlocks = 0; - Event_Wait(&p->canStart); - Event_Set(&p->wasStarted); - - MatchFinder_Init_HighHash(mt->MatchFinder); - - for (;;) - { - if (p->exit) - return; - if (p->stopWriting) - { - p->numProcessedBlocks = numProcessedBlocks; - Event_Set(&p->wasStopped); - break; - } - - { - CMatchFinder *mf = mt->MatchFinder; - if (MatchFinder_NeedMove(mf)) - { - CriticalSection_Enter(&mt->btSync.cs); - CriticalSection_Enter(&mt->hashSync.cs); - { - const Byte *beforePtr = Inline_MatchFinder_GetPointerToCurrentPos(mf); - ptrdiff_t offset; - MatchFinder_MoveBlock(mf); - offset = beforePtr - Inline_MatchFinder_GetPointerToCurrentPos(mf); - mt->pointerToCurPos -= offset; - mt->buffer -= offset; - } - CriticalSection_Leave(&mt->btSync.cs); - CriticalSection_Leave(&mt->hashSync.cs); - continue; - } - - Semaphore_Wait(&p->freeSemaphore); - - MatchFinder_ReadIfRequired(mf); - if (mf->pos > (kMtMaxValForNormalize - kMtHashBlockSize)) - { - UInt32 subValue = (mf->pos - mf->historySize - 1); - MatchFinder_ReduceOffsets(mf, subValue); - MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, (size_t)mf->hashMask + 1); - } - { - UInt32 *heads = mt->hashBuf + ((numProcessedBlocks++) & kMtHashNumBlocksMask) * kMtHashBlockSize; - UInt32 num = mf->streamPos - mf->pos; - heads[0] = 2; - heads[1] = num; - if (num >= mf->numHashBytes) - { - num = num - mf->numHashBytes + 1; - if (num > kMtHashBlockSize - 2) - num = kMtHashBlockSize - 2; - mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc); - heads[0] = 2 + num; - } - mf->pos += num; - mf->buffer += num; - } - } - - Semaphore_Release1(&p->filledSemaphore); - } - } -} - -static void MatchFinderMt_GetNextBlock_Hash(CMatchFinderMt *p) -{ - MtSync_GetNextBlock(&p->hashSync); - p->hashBufPosLimit = p->hashBufPos = ((p->hashSync.numProcessedBlocks - 1) & kMtHashNumBlocksMask) * kMtHashBlockSize; - p->hashBufPosLimit += p->hashBuf[p->hashBufPos++]; - p->hashNumAvail = p->hashBuf[p->hashBufPos++]; -} - -#define kEmptyHashValue 0 - -#define MFMT_GM_INLINE - -#ifdef MFMT_GM_INLINE - -/* - we use size_t for _cyclicBufferPos instead of UInt32 - to eliminate "movsx" BUG in old MSVC x64 compiler. -*/ - -MY_NO_INLINE -static UInt32 *GetMatchesSpecN(UInt32 lenLimit, UInt32 pos, const Byte *cur, CLzRef *son, - size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue, - UInt32 *d, UInt32 _maxLen, const UInt32 *hash, const UInt32 *limit, UInt32 size, UInt32 *posRes) -{ - do - { - UInt32 *_distances = ++d; - UInt32 delta = *hash++; - - CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; - CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); - unsigned len0 = 0, len1 = 0; - UInt32 cutValue = _cutValue; - unsigned maxLen = (unsigned)_maxLen; - - /* - #define PREF_STEP 1 - if (size > PREF_STEP) - { - UInt32 delta = hash[PREF_STEP - 1]; - if (delta < _cyclicBufferSize) - { - size_t cyc1 = _cyclicBufferPos + PREF_STEP; - CLzRef *pair = son + ((size_t)(cyc1 - delta + ((delta > cyc1) ? _cyclicBufferSize : 0)) << 1); - Byte b = *(cur + PREF_STEP - delta); - _distances[0] = pair[0]; - _distances[1] = b; - } - } - */ - if (cutValue == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - } - else - for (LOG_ITER(g_NumIters_Tree++);;) - { - LOG_ITER(g_NumIters_Loop++); - { - CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((_cyclicBufferPos < delta) ? _cyclicBufferSize : 0)) << 1); - const Byte *pb = cur - delta; - unsigned len = (len0 < len1 ? len0 : len1); - UInt32 pair0 = *pair; - if (pb[len] == cur[len]) - { - if (++len != lenLimit && pb[len] == cur[len]) - while (++len != lenLimit) - if (pb[len] != cur[len]) - break; - if (maxLen < len) - { - maxLen = len; - *d++ = (UInt32)len; - *d++ = delta - 1; - if (len == lenLimit) - { - UInt32 pair1 = pair[1]; - *ptr1 = pair0; - *ptr0 = pair1; - break; - } - } - } - { - UInt32 curMatch = pos - delta; - // delta = pos - *pair; - // delta = pos - pair[((UInt32)pb[len] - (UInt32)cur[len]) >> 31]; - if (pb[len] < cur[len]) - { - delta = pos - pair[1]; - *ptr1 = curMatch; - ptr1 = pair + 1; - len1 = len; - } - else - { - delta = pos - *pair; - *ptr0 = curMatch; - ptr0 = pair; - len0 = len; - } - } - } - if (--cutValue == 0 || delta >= _cyclicBufferSize) - { - *ptr0 = *ptr1 = kEmptyHashValue; - break; - } - } - pos++; - _cyclicBufferPos++; - cur++; - { - UInt32 num = (UInt32)(d - _distances); - _distances[-1] = num; - } - } - while (d < limit && --size != 0); - *posRes = pos; - return d; -} - -#endif - - - -static void BtGetMatches(CMatchFinderMt *p, UInt32 *d) -{ - UInt32 numProcessed = 0; - UInt32 curPos = 2; - UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); // * 2 - - d[1] = p->hashNumAvail; - - while (curPos < limit) - { - if (p->hashBufPos == p->hashBufPosLimit) - { - MatchFinderMt_GetNextBlock_Hash(p); - d[1] = numProcessed + p->hashNumAvail; - if (p->hashNumAvail >= p->numHashBytes) - continue; - d[0] = curPos + p->hashNumAvail; - d += curPos; - for (; p->hashNumAvail != 0; p->hashNumAvail--) - *d++ = 0; - return; - } - { - UInt32 size = p->hashBufPosLimit - p->hashBufPos; - UInt32 lenLimit = p->matchMaxLen; - UInt32 pos = p->pos; - UInt32 cyclicBufferPos = p->cyclicBufferPos; - if (lenLimit >= p->hashNumAvail) - lenLimit = p->hashNumAvail; - { - UInt32 size2 = p->hashNumAvail - lenLimit + 1; - if (size2 < size) - size = size2; - size2 = p->cyclicBufferSize - cyclicBufferPos; - if (size2 < size) - size = size2; - } - - #ifndef MFMT_GM_INLINE - while (curPos < limit && size-- != 0) - { - UInt32 *startDistances = d + curPos; - UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++], - pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, - startDistances + 1, p->numHashBytes - 1) - startDistances); - *startDistances = num - 1; - curPos += num; - cyclicBufferPos++; - pos++; - p->buffer++; - } - #else - { - UInt32 posRes; - curPos = (UInt32)(GetMatchesSpecN(lenLimit, pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, - d + curPos, p->numHashBytes - 1, p->hashBuf + p->hashBufPos, - d + limit, - size, &posRes) - d); - p->hashBufPos += posRes - pos; - cyclicBufferPos += posRes - pos; - p->buffer += posRes - pos; - pos = posRes; - } - #endif - - numProcessed += pos - p->pos; - p->hashNumAvail -= pos - p->pos; - p->pos = pos; - if (cyclicBufferPos == p->cyclicBufferSize) - cyclicBufferPos = 0; - p->cyclicBufferPos = cyclicBufferPos; - } - } - - d[0] = curPos; -} - -static void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex) -{ - CMtSync *sync = &p->hashSync; - if (!sync->needStart) - { - CriticalSection_Enter(&sync->cs); - sync->csWasEntered = True; - } - - BtGetMatches(p, p->btBuf + (globalBlockIndex & kMtBtNumBlocksMask) * kMtBtBlockSize); - - if (p->pos > kMtMaxValForNormalize - kMtBtBlockSize) - { - UInt32 subValue = p->pos - p->cyclicBufferSize; - MatchFinder_Normalize3(subValue, p->son, (size_t)p->cyclicBufferSize * 2); - p->pos -= subValue; - } - - if (!sync->needStart) - { - CriticalSection_Leave(&sync->cs); - sync->csWasEntered = False; - } -} - -static void BtThreadFunc(CMatchFinderMt *mt) -{ - CMtSync *p = &mt->btSync; - for (;;) - { - UInt32 blockIndex = 0; - Event_Wait(&p->canStart); - Event_Set(&p->wasStarted); - for (;;) - { - if (p->exit) - return; - if (p->stopWriting) - { - p->numProcessedBlocks = blockIndex; - MtSync_StopWriting(&mt->hashSync); - Event_Set(&p->wasStopped); - break; - } - Semaphore_Wait(&p->freeSemaphore); - BtFillBlock(mt, blockIndex++); - Semaphore_Release1(&p->filledSemaphore); - } - } -} - -void MatchFinderMt_Construct(CMatchFinderMt *p) -{ - p->hashBuf = NULL; - MtSync_Construct(&p->hashSync); - MtSync_Construct(&p->btSync); -} - -static void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->hashBuf); - p->hashBuf = NULL; -} - -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc) -{ - MtSync_Destruct(&p->hashSync); - MtSync_Destruct(&p->btSync); - - LOG_ITER( - printf("\nTree %9d * %7d iter = %9d sum \n", - (UInt32)(g_NumIters_Tree / 1000), - (UInt32)(((UInt64)g_NumIters_Loop * 1000) / (g_NumIters_Tree + 1)), - (UInt32)(g_NumIters_Loop / 1000) - )); - - MatchFinderMt_FreeMem(p, alloc); -} - -#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks) -#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks) - -static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; } -static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE BtThreadFunc2(void *p) -{ - Byte allocaDummy[0x180]; - unsigned i = 0; - for (i = 0; i < 16; i++) - allocaDummy[i] = (Byte)0; - if (allocaDummy[0] == 0) - BtThreadFunc((CMatchFinderMt *)p); - return 0; -} - -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc) -{ - CMatchFinder *mf = p->MatchFinder; - p->historySize = historySize; - if (kMtBtBlockSize <= matchMaxLen * 4) - return SZ_ERROR_PARAM; - if (!p->hashBuf) - { - p->hashBuf = (UInt32 *)ISzAlloc_Alloc(alloc, (kHashBufferSize + kBtBufferSize) * sizeof(UInt32)); - if (!p->hashBuf) - return SZ_ERROR_MEM; - p->btBuf = p->hashBuf + kHashBufferSize; - } - keepAddBufferBefore += (kHashBufferSize + kBtBufferSize); - keepAddBufferAfter += kMtHashBlockSize; - if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc)) - return SZ_ERROR_MEM; - - RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p, kMtHashNumBlocks)); - RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p, kMtBtNumBlocks)); - return SZ_OK; -} - -/* Call it after ReleaseStream / SetStream */ -static void MatchFinderMt_Init(CMatchFinderMt *p) -{ - CMatchFinder *mf = p->MatchFinder; - - p->btBufPos = - p->btBufPosLimit = 0; - p->hashBufPos = - p->hashBufPosLimit = 0; - - /* Init without data reading. We don't want to read data in this thread */ - MatchFinder_Init_3(mf, False); - MatchFinder_Init_LowHash(mf); - - p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf); - p->btNumAvailBytes = 0; - p->lzPos = p->historySize + 1; - - p->hash = mf->hash; - p->fixedHashSize = mf->fixedHashSize; - // p->hash4Mask = mf->hash4Mask; - p->crc = mf->crc; - - p->son = mf->son; - p->matchMaxLen = mf->matchMaxLen; - p->numHashBytes = mf->numHashBytes; - p->pos = mf->pos; - p->buffer = mf->buffer; - p->cyclicBufferPos = mf->cyclicBufferPos; - p->cyclicBufferSize = mf->cyclicBufferSize; - p->cutValue = mf->cutValue; -} - -/* ReleaseStream is required to finish multithreading */ -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p) -{ - MtSync_StopWriting(&p->btSync); - /* p->MatchFinder->ReleaseStream(); */ -} - - -MY_NO_INLINE -static void MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p) -{ - UInt32 blockIndex, k; - - MtSync_GetNextBlock(&p->btSync); - - blockIndex = ((p->btSync.numProcessedBlocks - 1) & kMtBtNumBlocksMask); - k = blockIndex * kMtBtBlockSize; - p->btBufPosLimit = k + p->btBuf[k]; - p->btNumAvailBytes = p->btBuf[k + 1]; - p->btBufPos = k + 2; - if (p->lzPos >= kMtMaxValForNormalize - kMtBtBlockSize) - { - MatchFinder_Normalize3(p->lzPos - p->historySize - 1, p->hash, p->fixedHashSize); - p->lzPos = p->historySize + 1; - } -} - -static const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p) -{ - return p->pointerToCurPos; -} - -#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p); - -static UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p) -{ - GET_NEXT_BLOCK_IF_REQUIRED; - return p->btNumAvailBytes; -} - -static UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) -{ - UInt32 h2, c2; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 m = p->lzPos; - MT_HASH2_CALC - - c2 = hash[h2]; - hash[h2] = m; - - if (c2 >= matchMinPos) - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - *d++ = 2; - *d++ = m - c2 - 1; - } - - return d; -} - -static UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) -{ - UInt32 h2, h3, c2, c3; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 m = p->lzPos; - MT_HASH3_CALC - - c2 = hash[h2]; - c3 = (hash + kFix3HashSize)[h3]; - - hash[h2] = m; - (hash + kFix3HashSize)[h3] = m; - - if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c2 - 1; - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) - { - d[0] = 3; - return d + 2; - } - d[0] = 2; - d += 2; - } - - if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) - { - *d++ = 3; - *d++ = m - c3 - 1; - } - - return d; -} - - -#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++; - -/* -static -UInt32 MatchFinderMt_GetMatches_Bt4(CMatchFinderMt *p, UInt32 *d) -{ - UInt32 pos = p->btBufPos; - const UInt32 *bt = p->btBuf + pos; - UInt32 len = *bt++; - UInt32 matchMinPos; - const UInt32 *d_base = d; - UInt32 avail = p->btNumAvailBytes - 1; - p->btBufPos = pos + 1 + len; - - { - UInt32 temp1 = p->historySize; - p->btNumAvailBytes = avail; - - #define BT_HASH_BYTES_MAX 5 - - if (len != 0) - temp1 = bt[1]; - else if (avail < (BT_HASH_BYTES_MAX - 2)) - { - INCREASE_LZ_POS - return 0; - } - matchMinPos = p->lzPos - temp1; - } - - for (;;) - { - - UInt32 h2, h3, c2, c3; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 m = p->lzPos; - MT_HASH3_CALC - - c2 = hash[h2]; - c3 = (hash + kFix3HashSize)[h3]; - - hash[h2] = m; - (hash + kFix3HashSize)[h3] = m; - - if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c2 - 1; - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) - { - d[0] = 3; - d += 2; - break; - } - // else - { - d[0] = 2; - d += 2; - } - } - if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) - { - *d++ = 3; - *d++ = m - c3 - 1; - } - break; - } - - if (len != 0) - { - do - { - UInt32 v0 = bt[0]; - UInt32 v1 = bt[1]; - bt += 2; - d[0] = v0; - d[1] = v1; - d += 2; - } - while ((len -= 2) != 0); - } - INCREASE_LZ_POS - return (UInt32)(d - d_base); -} -*/ - - -static UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) -{ - UInt32 h2, h3, /* h4, */ c2, c3 /* , c4 */; - UInt32 *hash = p->hash; - const Byte *cur = p->pointerToCurPos; - UInt32 m = p->lzPos; - MT_HASH3_CALC - // MT_HASH4_CALC - c2 = hash[h2]; - c3 = (hash + kFix3HashSize)[h3]; - // c4 = (hash + kFix4HashSize)[h4]; - - hash[h2] = m; - (hash + kFix3HashSize)[h3] = m; - // (hash + kFix4HashSize)[h4] = m; - - #define _USE_H2 - - #ifdef _USE_H2 - if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c2 - 1; - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) - { - // d[0] = (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) ? 4 : 3; - // return d + 2; - - if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) - { - d[0] = 4; - return d + 2; - } - d[0] = 3; - d += 2; - - #ifdef _USE_H4 - if (c4 >= matchMinPos) - if ( - cur[(ptrdiff_t)c4 - (ptrdiff_t)m] == cur[0] && - cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3] - ) - { - *d++ = 4; - *d++ = m - c4 - 1; - } - #endif - return d; - } - d[0] = 2; - d += 2; - } - #endif - - if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) - { - d[1] = m - c3 - 1; - if (cur[(ptrdiff_t)c3 - (ptrdiff_t)m + 3] == cur[3]) - { - d[0] = 4; - return d + 2; - } - d[0] = 3; - d += 2; - } - - #ifdef _USE_H4 - if (c4 >= matchMinPos) - if ( - cur[(ptrdiff_t)c4 - (ptrdiff_t)m] == cur[0] && - cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3] - ) - { - *d++ = 4; - *d++ = m - c4 - 1; - } - #endif - - return d; -} - - -static UInt32 MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *d) -{ - const UInt32 *bt = p->btBuf + p->btBufPos; - UInt32 len = *bt++; - p->btBufPos += 1 + len; - p->btNumAvailBytes--; - { - UInt32 i; - for (i = 0; i < len; i += 2) - { - UInt32 v0 = bt[0]; - UInt32 v1 = bt[1]; - bt += 2; - d[0] = v0; - d[1] = v1; - d += 2; - } - } - INCREASE_LZ_POS - return len; -} - - - -static UInt32 MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *d) -{ - UInt32 pos = p->btBufPos; - const UInt32 *bt = p->btBuf + pos; - UInt32 len = *bt++; - UInt32 avail = p->btNumAvailBytes - 1; - p->btNumAvailBytes = avail; - p->btBufPos = pos + 1 + len; - if (len == 0) - { - #define BT_HASH_BYTES_MAX 5 - if (avail >= (BT_HASH_BYTES_MAX - 1) - 1) - len = (UInt32)(p->MixMatchesFunc(p, p->lzPos - p->historySize, d) - d); - } - else - { - /* - first match pair from BinTree: (match_len, match_dist), - (match_len >= numHashBytes). - MixMatchesFunc() inserts only hash matches that are nearer than (match_dist) - */ - UInt32 *d2; - d2 = p->MixMatchesFunc(p, p->lzPos - bt[1], d); - do - { - UInt32 v0 = bt[0]; - UInt32 v1 = bt[1]; - bt += 2; - d2[0] = v0; - d2[1] = v1; - d2 += 2; - } - while ((len -= 2) != 0); - len = (UInt32)(d2 - d); - } - INCREASE_LZ_POS - return len; -} - -#define SKIP_HEADER2_MT do { GET_NEXT_BLOCK_IF_REQUIRED -#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash; -#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += p->btBuf[p->btBufPos] + 1; } while (--num != 0); - -static void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER2_MT { p->btNumAvailBytes--; - SKIP_FOOTER_MT -} - -static void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(2) - UInt32 h2; - MT_HASH2_CALC - hash[h2] = p->lzPos; - SKIP_FOOTER_MT -} - -static void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(3) - UInt32 h2, h3; - MT_HASH3_CALC - (hash + kFix3HashSize)[h3] = - hash[ h2] = - p->lzPos; - SKIP_FOOTER_MT -} - -static void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num) -{ - SKIP_HEADER_MT(4) - UInt32 h2, h3 /*, h4 */; - MT_HASH3_CALC - // MT_HASH4_CALC - // (hash + kFix4HashSize)[h4] = - (hash + kFix3HashSize)[h3] = - hash[ h2] = - p->lzPos; - SKIP_FOOTER_MT -} - -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable) -{ - vTable->Init = (Mf_Init_Func)MatchFinderMt_Init; - vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes; - vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos; - vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches; - - switch (p->MatchFinder->numHashBytes) - { - case 2: - p->GetHeadsFunc = GetHeads2; - p->MixMatchesFunc = (Mf_Mix_Matches)NULL; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip; - vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches; - break; - case 3: - p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads3b : GetHeads3; - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip; - break; - case 4: - p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads4b : GetHeads4; - - // it's fast inline version of GetMatches() - // vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches_Bt4; - - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip; - break; - default: - p->GetHeadsFunc = p->MatchFinder->bigHash ? GetHeads5b : GetHeads5; - p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4; - vTable->Skip = (Mf_Skip_Func)MatchFinderMt4_Skip; - break; - } -} +/* LzFindMt.c -- multithreaded Match finder for LZ algorithms +2021-12-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +// #include + +#include "CpuArch.h" + +#include "LzHash.h" +#include "LzFindMt.h" + +// #define LOG_ITERS + +// #define LOG_THREAD + +#ifdef LOG_THREAD +#include +#define PRF(x) x +#else +#define PRF(x) +#endif + +#ifdef LOG_ITERS +#include +extern UInt64 g_NumIters_Tree; +extern UInt64 g_NumIters_Loop; +extern UInt64 g_NumIters_Bytes; +#define LOG_ITER(x) x +#else +#define LOG_ITER(x) +#endif + +#define kMtHashBlockSize ((UInt32)1 << 17) +#define kMtHashNumBlocks (1 << 1) + +#define GET_HASH_BLOCK_OFFSET(i) (((i) & (kMtHashNumBlocks - 1)) * kMtHashBlockSize) + +#define kMtBtBlockSize ((UInt32)1 << 16) +#define kMtBtNumBlocks (1 << 4) + +#define GET_BT_BLOCK_OFFSET(i) (((i) & (kMtBtNumBlocks - 1)) * (size_t)kMtBtBlockSize) + +/* + HASH functions: + We use raw 8/16 bits from a[1] and a[2], + xored with crc(a[0]) and crc(a[3]). + We check a[0], a[3] only. We don't need to compare a[1] and a[2] in matches. + our crc() function provides one-to-one correspondence for low 8-bit values: + (crc[0...0xFF] & 0xFF) <-> [0...0xFF] +*/ + +#define MF(mt) ((mt)->MatchFinder) +#define MF_CRC (p->crc) + +// #define MF(mt) (&(mt)->MatchFinder) +// #define MF_CRC (p->MatchFinder.crc) + +#define MT_HASH2_CALC \ + h2 = (MF_CRC[cur[0]] ^ cur[1]) & (kHash2Size - 1); + +#define MT_HASH3_CALC { \ + UInt32 temp = MF_CRC[cur[0]] ^ cur[1]; \ + h2 = temp & (kHash2Size - 1); \ + h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } + +/* +#define MT_HASH3_CALC__NO_2 { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } + +#define __MT_HASH4_CALC { \ + UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ + h2 = temp & (kHash2Size - 1); \ + temp ^= ((UInt32)cur[2] << 8); \ + h3 = temp & (kHash3Size - 1); \ + h4 = (temp ^ (p->crc[cur[3]] << kLzHash_CrcShift_1)) & p->hash4Mask; } + // (kHash4Size - 1); +*/ + + +MY_NO_INLINE +static void MtSync_Construct(CMtSync *p) +{ + p->affinity = 0; + p->wasCreated = False; + p->csWasInitialized = False; + p->csWasEntered = False; + Thread_Construct(&p->thread); + Event_Construct(&p->canStart); + Event_Construct(&p->wasStopped); + Semaphore_Construct(&p->freeSemaphore); + Semaphore_Construct(&p->filledSemaphore); +} + + +#define DEBUG_BUFFER_LOCK // define it to debug lock state + +#ifdef DEBUG_BUFFER_LOCK +#include +#define BUFFER_MUST_BE_LOCKED(p) if (!(p)->csWasEntered) exit(1); +#define BUFFER_MUST_BE_UNLOCKED(p) if ( (p)->csWasEntered) exit(1); +#else +#define BUFFER_MUST_BE_LOCKED(p) +#define BUFFER_MUST_BE_UNLOCKED(p) +#endif + +#define LOCK_BUFFER(p) { \ + BUFFER_MUST_BE_UNLOCKED(p); \ + CriticalSection_Enter(&(p)->cs); \ + (p)->csWasEntered = True; } + +#define UNLOCK_BUFFER(p) { \ + BUFFER_MUST_BE_LOCKED(p); \ + CriticalSection_Leave(&(p)->cs); \ + (p)->csWasEntered = False; } + + +MY_NO_INLINE +static UInt32 MtSync_GetNextBlock(CMtSync *p) +{ + UInt32 numBlocks = 0; + if (p->needStart) + { + BUFFER_MUST_BE_UNLOCKED(p) + p->numProcessedBlocks = 1; + p->needStart = False; + p->stopWriting = False; + p->exit = False; + Event_Reset(&p->wasStopped); + Event_Set(&p->canStart); + } + else + { + UNLOCK_BUFFER(p) + // we free current block + numBlocks = p->numProcessedBlocks++; + Semaphore_Release1(&p->freeSemaphore); + } + + // buffer is UNLOCKED here + Semaphore_Wait(&p->filledSemaphore); + LOCK_BUFFER(p); + return numBlocks; +} + + +/* if Writing (Processing) thread was started, we must call MtSync_StopWriting() */ + +MY_NO_INLINE +static void MtSync_StopWriting(CMtSync *p) +{ + if (!Thread_WasCreated(&p->thread) || p->needStart) + return; + + PRF(printf("\nMtSync_StopWriting %p\n", p)); + + if (p->csWasEntered) + { + /* we don't use buffer in this thread after StopWriting(). + So we UNLOCK buffer. + And we restore default UNLOCKED state for stopped thread */ + UNLOCK_BUFFER(p) + } + + /* We send (p->stopWriting) message and release freeSemaphore + to free current block. + So the thread will see (p->stopWriting) at some + iteration after Wait(freeSemaphore). + The thread doesn't need to fill all avail free blocks, + so we can get fast thread stop. + */ + + p->stopWriting = True; + Semaphore_Release1(&p->freeSemaphore); // check semaphore count !!! + + PRF(printf("\nMtSync_StopWriting %p : Event_Wait(&p->wasStopped)\n", p)); + Event_Wait(&p->wasStopped); + PRF(printf("\nMtSync_StopWriting %p : Event_Wait() finsihed\n", p)); + + /* 21.03 : we don't restore samaphore counters here. + We will recreate and reinit samaphores in next start */ + + p->needStart = True; +} + + +MY_NO_INLINE +static void MtSync_Destruct(CMtSync *p) +{ + PRF(printf("\nMtSync_Destruct %p\n", p)); + + if (Thread_WasCreated(&p->thread)) + { + /* we want thread to be in Stopped state before sending EXIT command. + note: stop(btSync) will stop (htSync) also */ + MtSync_StopWriting(p); + /* thread in Stopped state here : (p->needStart == true) */ + p->exit = True; + // if (p->needStart) // it's (true) + Event_Set(&p->canStart); // we send EXIT command to thread + Thread_Wait_Close(&p->thread); // we wait thread finishing + } + + if (p->csWasInitialized) + { + CriticalSection_Delete(&p->cs); + p->csWasInitialized = False; + } + p->csWasEntered = False; + + Event_Close(&p->canStart); + Event_Close(&p->wasStopped); + Semaphore_Close(&p->freeSemaphore); + Semaphore_Close(&p->filledSemaphore); + + p->wasCreated = False; +} + + +// #define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; } +// we want to get real system error codes here instead of SZ_ERROR_THREAD +#define RINOK_THREAD(x) RINOK(x) + + +// call it before each new file (when new starting is required): +MY_NO_INLINE +static SRes MtSync_Init(CMtSync *p, UInt32 numBlocks) +{ + WRes wres; + // BUFFER_MUST_BE_UNLOCKED(p) + if (!p->needStart || p->csWasEntered) + return SZ_ERROR_FAIL; + wres = Semaphore_OptCreateInit(&p->freeSemaphore, numBlocks, numBlocks); + if (wres == 0) + wres = Semaphore_OptCreateInit(&p->filledSemaphore, 0, numBlocks); + return MY_SRes_HRESULT_FROM_WRes(wres); +} + + +static WRes MtSync_Create_WRes(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj) +{ + WRes wres; + + if (p->wasCreated) + return SZ_OK; + + RINOK_THREAD(CriticalSection_Init(&p->cs)); + p->csWasInitialized = True; + p->csWasEntered = False; + + RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->canStart)); + RINOK_THREAD(AutoResetEvent_CreateNotSignaled(&p->wasStopped)); + + p->needStart = True; + p->exit = True; /* p->exit is unused before (canStart) Event. + But in case of some unexpected code failure we will get fast exit from thread */ + + // return ERROR_TOO_MANY_POSTS; // for debug + // return EINVAL; // for debug + + if (p->affinity != 0) + wres = Thread_Create_With_Affinity(&p->thread, startAddress, obj, (CAffinityMask)p->affinity); + else + wres = Thread_Create(&p->thread, startAddress, obj); + + RINOK_THREAD(wres); + p->wasCreated = True; + return SZ_OK; +} + + +MY_NO_INLINE +static SRes MtSync_Create(CMtSync *p, THREAD_FUNC_TYPE startAddress, void *obj) +{ + const WRes wres = MtSync_Create_WRes(p, startAddress, obj); + if (wres == 0) + return 0; + MtSync_Destruct(p); + return MY_SRes_HRESULT_FROM_WRes(wres); +} + + +// ---------- HASH THREAD ---------- + +#define kMtMaxValForNormalize 0xFFFFFFFF +// #define kMtMaxValForNormalize ((1 << 21)) // for debug +// #define kNormalizeAlign (1 << 7) // alignment for speculated accesses + +#ifdef MY_CPU_LE_UNALIGN + #define GetUi24hi_from32(p) ((UInt32)GetUi32(p) >> 8) +#else + #define GetUi24hi_from32(p) ((p)[1] ^ ((UInt32)(p)[2] << 8) ^ ((UInt32)(p)[3] << 16)) +#endif + +#define GetHeads_DECL(name) \ + static void GetHeads ## name(const Byte *p, UInt32 pos, \ + UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc) + +#define GetHeads_LOOP(v) \ + for (; numHeads != 0; numHeads--) { \ + const UInt32 value = (v); \ + p++; \ + *heads++ = pos - hash[value]; \ + hash[value] = pos++; } + +#define DEF_GetHeads2(name, v, action) \ + GetHeads_DECL(name) { action \ + GetHeads_LOOP(v) } + +#define DEF_GetHeads(name, v) DEF_GetHeads2(name, v, ;) + +DEF_GetHeads2(2, GetUi16(p), UNUSED_VAR(hashMask); UNUSED_VAR(crc); ) +DEF_GetHeads(3, (crc[p[0]] ^ GetUi16(p + 1)) & hashMask) +DEF_GetHeads2(3b, GetUi16(p) ^ ((UInt32)(p)[2] << 16), UNUSED_VAR(hashMask); UNUSED_VAR(crc); ) +// BT3 is not good for crc collisions for big hashMask values. + +/* +GetHeads_DECL(3b) +{ + UNUSED_VAR(hashMask); + UNUSED_VAR(crc); + { + const Byte *pLim = p + numHeads; + if (numHeads == 0) + return; + pLim--; + while (p < pLim) + { + UInt32 v1 = GetUi32(p); + UInt32 v0 = v1 & 0xFFFFFF; + UInt32 h0, h1; + p += 2; + v1 >>= 8; + h0 = hash[v0]; hash[v0] = pos; heads[0] = pos - h0; pos++; + h1 = hash[v1]; hash[v1] = pos; heads[1] = pos - h1; pos++; + heads += 2; + } + if (p == pLim) + { + UInt32 v0 = GetUi16(p) ^ ((UInt32)(p)[2] << 16); + *heads = pos - hash[v0]; + hash[v0] = pos; + } + } +} +*/ + +/* +GetHeads_DECL(4) +{ + unsigned sh = 0; + UNUSED_VAR(crc) + while ((hashMask & 0x80000000) == 0) + { + hashMask <<= 1; + sh++; + } + GetHeads_LOOP((GetUi32(p) * 0xa54a1) >> sh) +} +#define GetHeads4b GetHeads4 +*/ + +#define USE_GetHeads_LOCAL_CRC + +#ifdef USE_GetHeads_LOCAL_CRC + +GetHeads_DECL(4) +{ + UInt32 crc0[256]; + UInt32 crc1[256]; + { + unsigned i; + for (i = 0; i < 256; i++) + { + UInt32 v = crc[i]; + crc0[i] = v & hashMask; + crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; + // crc1[i] = rotlFixed(v, 8) & hashMask; + } + } + GetHeads_LOOP(crc0[p[0]] ^ crc1[p[3]] ^ (UInt32)GetUi16(p+1)) +} + +GetHeads_DECL(4b) +{ + UInt32 crc0[256]; + { + unsigned i; + for (i = 0; i < 256; i++) + crc0[i] = crc[i] & hashMask; + } + GetHeads_LOOP(crc0[p[0]] ^ GetUi24hi_from32(p)) +} + +GetHeads_DECL(5) +{ + UInt32 crc0[256]; + UInt32 crc1[256]; + UInt32 crc2[256]; + { + unsigned i; + for (i = 0; i < 256; i++) + { + UInt32 v = crc[i]; + crc0[i] = v & hashMask; + crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; + crc2[i] = (v << kLzHash_CrcShift_2) & hashMask; + } + } + GetHeads_LOOP(crc0[p[0]] ^ crc1[p[3]] ^ crc2[p[4]] ^ (UInt32)GetUi16(p+1)) +} + +GetHeads_DECL(5b) +{ + UInt32 crc0[256]; + UInt32 crc1[256]; + { + unsigned i; + for (i = 0; i < 256; i++) + { + UInt32 v = crc[i]; + crc0[i] = v & hashMask; + crc1[i] = (v << kLzHash_CrcShift_1) & hashMask; + } + } + GetHeads_LOOP(crc0[p[0]] ^ crc1[p[4]] ^ GetUi24hi_from32(p)) +} + +#else + +DEF_GetHeads(4, (crc[p[0]] ^ (crc[p[3]] << kLzHash_CrcShift_1) ^ (UInt32)GetUi16(p+1)) & hashMask) +DEF_GetHeads(4b, (crc[p[0]] ^ GetUi24hi_from32(p)) & hashMask) +DEF_GetHeads(5, (crc[p[0]] ^ (crc[p[3]] << kLzHash_CrcShift_1) ^ (crc[p[4]] << kLzHash_CrcShift_2) ^ (UInt32)GetUi16(p + 1)) & hashMask) +DEF_GetHeads(5b, (crc[p[0]] ^ (crc[p[4]] << kLzHash_CrcShift_1) ^ GetUi24hi_from32(p)) & hashMask) + +#endif + + +static void HashThreadFunc(CMatchFinderMt *mt) +{ + CMtSync *p = &mt->hashSync; + PRF(printf("\nHashThreadFunc\n")); + + for (;;) + { + UInt32 blockIndex = 0; + PRF(printf("\nHashThreadFunc : Event_Wait(&p->canStart)\n")); + Event_Wait(&p->canStart); + PRF(printf("\nHashThreadFunc : Event_Wait(&p->canStart) : after \n")); + if (p->exit) + { + PRF(printf("\nHashThreadFunc : exit \n")); + return; + } + + MatchFinder_Init_HighHash(MF(mt)); + + for (;;) + { + PRF(printf("Hash thread block = %d pos = %d\n", (unsigned)blockIndex, mt->MatchFinder->pos)); + + { + CMatchFinder *mf = MF(mt); + if (MatchFinder_NeedMove(mf)) + { + CriticalSection_Enter(&mt->btSync.cs); + CriticalSection_Enter(&mt->hashSync.cs); + { + const Byte *beforePtr = Inline_MatchFinder_GetPointerToCurrentPos(mf); + ptrdiff_t offset; + MatchFinder_MoveBlock(mf); + offset = beforePtr - Inline_MatchFinder_GetPointerToCurrentPos(mf); + mt->pointerToCurPos -= offset; + mt->buffer -= offset; + } + CriticalSection_Leave(&mt->hashSync.cs); + CriticalSection_Leave(&mt->btSync.cs); + continue; + } + + Semaphore_Wait(&p->freeSemaphore); + + if (p->exit) // exit is unexpected here. But we check it here for some failure case + return; + + // for faster stop : we check (p->stopWriting) after Wait(freeSemaphore) + if (p->stopWriting) + break; + + MatchFinder_ReadIfRequired(mf); + { + UInt32 *heads = mt->hashBuf + GET_HASH_BLOCK_OFFSET(blockIndex++); + UInt32 num = Inline_MatchFinder_GetNumAvailableBytes(mf); + heads[0] = 2; + heads[1] = num; + + /* heads[1] contains the number of avail bytes: + if (avail < mf->numHashBytes) : + { + it means that stream was finished + HASH_THREAD and BT_TREAD must move position for heads[1] (avail) bytes. + HASH_THREAD doesn't stop, + HASH_THREAD fills only the header (2 numbers) for all next blocks: + {2, NumHashBytes - 1}, {2,0}, {2,0}, ... , {2,0} + } + else + { + HASH_THREAD and BT_TREAD must move position for (heads[0] - 2) bytes; + } + */ + + if (num >= mf->numHashBytes) + { + num = num - mf->numHashBytes + 1; + if (num > kMtHashBlockSize - 2) + num = kMtHashBlockSize - 2; + + if (mf->pos > (UInt32)kMtMaxValForNormalize - num) + { + const UInt32 subValue = (mf->pos - mf->historySize - 1); // & ~(UInt32)(kNormalizeAlign - 1); + Inline_MatchFinder_ReduceOffsets(mf, subValue); + MatchFinder_Normalize3(subValue, mf->hash + mf->fixedHashSize, (size_t)mf->hashMask + 1); + } + + heads[0] = 2 + num; + mt->GetHeadsFunc(mf->buffer, mf->pos, mf->hash + mf->fixedHashSize, mf->hashMask, heads + 2, num, mf->crc); + } + + mf->pos += num; // wrap over zero is allowed at the end of stream + mf->buffer += num; + } + } + + Semaphore_Release1(&p->filledSemaphore); + } // for() processing end + + // p->numBlocks_Sent = blockIndex; + Event_Set(&p->wasStopped); + } // for() thread end +} + + + + +// ---------- BT THREAD ---------- + +/* we use one variable instead of two (cyclicBufferPos == pos) before CyclicBuf wrap. + here we define fixed offset of (p->pos) from (p->cyclicBufferPos) */ +#define CYC_TO_POS_OFFSET 0 +// #define CYC_TO_POS_OFFSET 1 // for debug + +#define MFMT_GM_INLINE + +#ifdef MFMT_GM_INLINE + +/* + we use size_t for (pos) instead of UInt32 + to eliminate "movsx" BUG in old MSVC x64 compiler. +*/ + + +UInt32 * MY_FAST_CALL GetMatchesSpecN_2(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, + UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, + UInt32 *posRes); + +#endif + + +static void BtGetMatches(CMatchFinderMt *p, UInt32 *d) +{ + UInt32 numProcessed = 0; + UInt32 curPos = 2; + + /* GetMatchesSpec() functions don't create (len = 1) + in [len, dist] match pairs, if (p->numHashBytes >= 2) + Also we suppose here that (matchMaxLen >= 2). + So the following code for (reserve) is not required + UInt32 reserve = (p->matchMaxLen * 2); + const UInt32 kNumHashBytes_Max = 5; // BT_HASH_BYTES_MAX + if (reserve < kNumHashBytes_Max - 1) + reserve = kNumHashBytes_Max - 1; + const UInt32 limit = kMtBtBlockSize - (reserve); + */ + + const UInt32 limit = kMtBtBlockSize - (p->matchMaxLen * 2); + + d[1] = p->hashNumAvail; + + if (p->failure_BT) + { + // printf("\n == 1 BtGetMatches() p->failure_BT\n"); + d[0] = 0; + // d[1] = 0; + return; + } + + while (curPos < limit) + { + if (p->hashBufPos == p->hashBufPosLimit) + { + // MatchFinderMt_GetNextBlock_Hash(p); + UInt32 avail; + { + const UInt32 bi = MtSync_GetNextBlock(&p->hashSync); + const UInt32 k = GET_HASH_BLOCK_OFFSET(bi); + const UInt32 *h = p->hashBuf + k; + avail = h[1]; + p->hashBufPosLimit = k + h[0]; + p->hashNumAvail = avail; + p->hashBufPos = k + 2; + } + + { + /* we must prevent UInt32 overflow for avail total value, + if avail was increased with new hash block */ + UInt32 availSum = numProcessed + avail; + if (availSum < numProcessed) + availSum = (UInt32)(Int32)-1; + d[1] = availSum; + } + + if (avail >= p->numHashBytes) + continue; + + // if (p->hashBufPos != p->hashBufPosLimit) exit(1); + + /* (avail < p->numHashBytes) + It means that stream was finished. + And (avail) - is a number of remaining bytes, + we fill (d) for (avail) bytes for LZ_THREAD (receiver). + but we don't update (p->pos) and (p->cyclicBufferPos) here in BT_THREAD */ + + /* here we suppose that we have space enough: + (kMtBtBlockSize - curPos >= p->hashNumAvail) */ + p->hashNumAvail = 0; + d[0] = curPos + avail; + d += curPos; + for (; avail != 0; avail--) + *d++ = 0; + return; + } + { + UInt32 size = p->hashBufPosLimit - p->hashBufPos; + UInt32 pos = p->pos; + UInt32 cyclicBufferPos = p->cyclicBufferPos; + UInt32 lenLimit = p->matchMaxLen; + if (lenLimit >= p->hashNumAvail) + lenLimit = p->hashNumAvail; + { + UInt32 size2 = p->hashNumAvail - lenLimit + 1; + if (size2 < size) + size = size2; + size2 = p->cyclicBufferSize - cyclicBufferPos; + if (size2 < size) + size = size2; + } + + if (pos > (UInt32)kMtMaxValForNormalize - size) + { + const UInt32 subValue = (pos - p->cyclicBufferSize); // & ~(UInt32)(kNormalizeAlign - 1); + pos -= subValue; + p->pos = pos; + MatchFinder_Normalize3(subValue, p->son, (size_t)p->cyclicBufferSize * 2); + } + + #ifndef MFMT_GM_INLINE + while (curPos < limit && size-- != 0) + { + UInt32 *startDistances = d + curPos; + UInt32 num = (UInt32)(GetMatchesSpec1(lenLimit, pos - p->hashBuf[p->hashBufPos++], + pos, p->buffer, p->son, cyclicBufferPos, p->cyclicBufferSize, p->cutValue, + startDistances + 1, p->numHashBytes - 1) - startDistances); + *startDistances = num - 1; + curPos += num; + cyclicBufferPos++; + pos++; + p->buffer++; + } + #else + { + UInt32 posRes = pos; + const UInt32 *d_end; + { + d_end = GetMatchesSpecN_2( + p->buffer + lenLimit - 1, + pos, p->buffer, p->son, p->cutValue, d + curPos, + p->numHashBytes - 1, p->hashBuf + p->hashBufPos, + d + limit, p->hashBuf + p->hashBufPos + size, + cyclicBufferPos, p->cyclicBufferSize, + &posRes); + } + { + if (!d_end) + { + // printf("\n == 2 BtGetMatches() p->failure_BT\n"); + // internal data failure + p->failure_BT = True; + d[0] = 0; + // d[1] = 0; + return; + } + } + curPos = (UInt32)(d_end - d); + { + const UInt32 processed = posRes - pos; + pos = posRes; + p->hashBufPos += processed; + cyclicBufferPos += processed; + p->buffer += processed; + } + } + #endif + + { + const UInt32 processed = pos - p->pos; + numProcessed += processed; + p->hashNumAvail -= processed; + p->pos = pos; + } + if (cyclicBufferPos == p->cyclicBufferSize) + cyclicBufferPos = 0; + p->cyclicBufferPos = cyclicBufferPos; + } + } + + d[0] = curPos; +} + + +static void BtFillBlock(CMatchFinderMt *p, UInt32 globalBlockIndex) +{ + CMtSync *sync = &p->hashSync; + + BUFFER_MUST_BE_UNLOCKED(sync) + + if (!sync->needStart) + { + LOCK_BUFFER(sync) + } + + BtGetMatches(p, p->btBuf + GET_BT_BLOCK_OFFSET(globalBlockIndex)); + + /* We suppose that we have called GetNextBlock() from start. + So buffer is LOCKED */ + + UNLOCK_BUFFER(sync) +} + + +MY_NO_INLINE +static void BtThreadFunc(CMatchFinderMt *mt) +{ + CMtSync *p = &mt->btSync; + for (;;) + { + UInt32 blockIndex = 0; + Event_Wait(&p->canStart); + + for (;;) + { + PRF(printf(" BT thread block = %d pos = %d\n", (unsigned)blockIndex, mt->pos)); + /* (p->exit == true) is possible after (p->canStart) at first loop iteration + and is unexpected after more Wait(freeSemaphore) iterations */ + if (p->exit) + return; + + Semaphore_Wait(&p->freeSemaphore); + + // for faster stop : we check (p->stopWriting) after Wait(freeSemaphore) + if (p->stopWriting) + break; + + BtFillBlock(mt, blockIndex++); + + Semaphore_Release1(&p->filledSemaphore); + } + + // we stop HASH_THREAD here + MtSync_StopWriting(&mt->hashSync); + + // p->numBlocks_Sent = blockIndex; + Event_Set(&p->wasStopped); + } +} + + +void MatchFinderMt_Construct(CMatchFinderMt *p) +{ + p->hashBuf = NULL; + MtSync_Construct(&p->hashSync); + MtSync_Construct(&p->btSync); +} + +static void MatchFinderMt_FreeMem(CMatchFinderMt *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->hashBuf); + p->hashBuf = NULL; +} + +void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc) +{ + /* + HASH_THREAD can use CriticalSection(s) btSync.cs and hashSync.cs. + So we must be sure that HASH_THREAD will not use CriticalSection(s) + after deleting CriticalSection here. + + we call ReleaseStream(p) + that calls StopWriting(btSync) + that calls StopWriting(hashSync), if it's required to stop HASH_THREAD. + after StopWriting() it's safe to destruct MtSync(s) in any order */ + + MatchFinderMt_ReleaseStream(p); + + MtSync_Destruct(&p->btSync); + MtSync_Destruct(&p->hashSync); + + LOG_ITER( + printf("\nTree %9d * %7d iter = %9d = sum : bytes = %9d\n", + (UInt32)(g_NumIters_Tree / 1000), + (UInt32)(((UInt64)g_NumIters_Loop * 1000) / (g_NumIters_Tree + 1)), + (UInt32)(g_NumIters_Loop / 1000), + (UInt32)(g_NumIters_Bytes / 1000) + )); + + MatchFinderMt_FreeMem(p, alloc); +} + + +#define kHashBufferSize (kMtHashBlockSize * kMtHashNumBlocks) +#define kBtBufferSize (kMtBtBlockSize * kMtBtNumBlocks) + + +static THREAD_FUNC_DECL HashThreadFunc2(void *p) { HashThreadFunc((CMatchFinderMt *)p); return 0; } +static THREAD_FUNC_DECL BtThreadFunc2(void *p) +{ + Byte allocaDummy[0x180]; + unsigned i = 0; + for (i = 0; i < 16; i++) + allocaDummy[i] = (Byte)0; + if (allocaDummy[0] == 0) + BtThreadFunc((CMatchFinderMt *)p); + return 0; +} + + +SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, + UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc) +{ + CMatchFinder *mf = MF(p); + p->historySize = historySize; + if (kMtBtBlockSize <= matchMaxLen * 4) + return SZ_ERROR_PARAM; + if (!p->hashBuf) + { + p->hashBuf = (UInt32 *)ISzAlloc_Alloc(alloc, ((size_t)kHashBufferSize + (size_t)kBtBufferSize) * sizeof(UInt32)); + if (!p->hashBuf) + return SZ_ERROR_MEM; + p->btBuf = p->hashBuf + kHashBufferSize; + } + keepAddBufferBefore += (kHashBufferSize + kBtBufferSize); + keepAddBufferAfter += kMtHashBlockSize; + if (!MatchFinder_Create(mf, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter, alloc)) + return SZ_ERROR_MEM; + + RINOK(MtSync_Create(&p->hashSync, HashThreadFunc2, p)); + RINOK(MtSync_Create(&p->btSync, BtThreadFunc2, p)); + return SZ_OK; +} + + +SRes MatchFinderMt_InitMt(CMatchFinderMt *p) +{ + RINOK(MtSync_Init(&p->hashSync, kMtHashNumBlocks)); + return MtSync_Init(&p->btSync, kMtBtNumBlocks); +} + + +static void MatchFinderMt_Init(CMatchFinderMt *p) +{ + CMatchFinder *mf = MF(p); + + p->btBufPos = + p->btBufPosLimit = NULL; + p->hashBufPos = + p->hashBufPosLimit = 0; + p->hashNumAvail = 0; // 21.03 + + p->failure_BT = False; + + /* Init without data reading. We don't want to read data in this thread */ + MatchFinder_Init_4(mf); + + MatchFinder_Init_LowHash(mf); + + p->pointerToCurPos = Inline_MatchFinder_GetPointerToCurrentPos(mf); + p->btNumAvailBytes = 0; + p->failure_LZ_BT = False; + // p->failure_LZ_LZ = False; + + p->lzPos = + 1; // optimal smallest value + // 0; // for debug: ignores match to start + // kNormalizeAlign; // for debug + + p->hash = mf->hash; + p->fixedHashSize = mf->fixedHashSize; + // p->hash4Mask = mf->hash4Mask; + p->crc = mf->crc; + // memcpy(p->crc, mf->crc, sizeof(mf->crc)); + + p->son = mf->son; + p->matchMaxLen = mf->matchMaxLen; + p->numHashBytes = mf->numHashBytes; + + /* (mf->pos) and (mf->streamPos) were already initialized to 1 in MatchFinder_Init_4() */ + // mf->streamPos = mf->pos = 1; // optimal smallest value + // 0; // for debug: ignores match to start + // kNormalizeAlign; // for debug + + /* we must init (p->pos = mf->pos) for BT, because + BT code needs (p->pos == delta_value_for_empty_hash_record == mf->pos) */ + p->pos = mf->pos; // do not change it + + p->cyclicBufferPos = (p->pos - CYC_TO_POS_OFFSET); + p->cyclicBufferSize = mf->cyclicBufferSize; + p->buffer = mf->buffer; + p->cutValue = mf->cutValue; + // p->son[0] = p->son[1] = 0; // unused: to init skipped record for speculated accesses. +} + + +/* ReleaseStream is required to finish multithreading */ +void MatchFinderMt_ReleaseStream(CMatchFinderMt *p) +{ + // Sleep(1); // for debug + MtSync_StopWriting(&p->btSync); + // Sleep(200); // for debug + /* p->MatchFinder->ReleaseStream(); */ +} + + +MY_NO_INLINE +static UInt32 MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p) +{ + if (p->failure_LZ_BT) + p->btBufPos = p->failureBuf; + else + { + const UInt32 bi = MtSync_GetNextBlock(&p->btSync); + const UInt32 *bt = p->btBuf + GET_BT_BLOCK_OFFSET(bi); + { + const UInt32 numItems = bt[0]; + p->btBufPosLimit = bt + numItems; + p->btNumAvailBytes = bt[1]; + p->btBufPos = bt + 2; + if (numItems < 2 || numItems > kMtBtBlockSize) + { + p->failureBuf[0] = 0; + p->btBufPos = p->failureBuf; + p->btBufPosLimit = p->failureBuf + 1; + p->failure_LZ_BT = True; + // p->btNumAvailBytes = 0; + /* we don't want to decrease AvailBytes, that was load before. + that can be unxepected for the code that have loaded anopther value before */ + } + } + + if (p->lzPos >= (UInt32)kMtMaxValForNormalize - (UInt32)kMtBtBlockSize) + { + /* we don't check (lzPos) over exact avail bytes in (btBuf). + (fixedHashSize) is small, so normalization is fast */ + const UInt32 subValue = (p->lzPos - p->historySize - 1); // & ~(UInt32)(kNormalizeAlign - 1); + p->lzPos -= subValue; + MatchFinder_Normalize3(subValue, p->hash, p->fixedHashSize); + } + } + return p->btNumAvailBytes; +} + + + +static const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p) +{ + return p->pointerToCurPos; +} + + +#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p); + + +static UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p) +{ + if (p->btBufPos != p->btBufPosLimit) + return p->btNumAvailBytes; + return MatchFinderMt_GetNextBlock_Bt(p); +} + + +// #define CHECK_FAILURE_LZ(_match_, _pos_) if (_match_ >= _pos_) { p->failure_LZ_LZ = True; return d; } +#define CHECK_FAILURE_LZ(_match_, _pos_) + +static UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) +{ + UInt32 h2, c2; + UInt32 *hash = p->hash; + const Byte *cur = p->pointerToCurPos; + const UInt32 m = p->lzPos; + MT_HASH2_CALC + + c2 = hash[h2]; + hash[h2] = m; + + if (c2 >= matchMinPos) + { + CHECK_FAILURE_LZ(c2, m) + if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) + { + *d++ = 2; + *d++ = m - c2 - 1; + } + } + + return d; +} + +static UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) +{ + UInt32 h2, h3, c2, c3; + UInt32 *hash = p->hash; + const Byte *cur = p->pointerToCurPos; + const UInt32 m = p->lzPos; + MT_HASH3_CALC + + c2 = hash[h2]; + c3 = (hash + kFix3HashSize)[h3]; + + hash[h2] = m; + (hash + kFix3HashSize)[h3] = m; + + if (c2 >= matchMinPos) + { + CHECK_FAILURE_LZ(c2, m) + if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) + { + d[1] = m - c2 - 1; + if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) + { + d[0] = 3; + return d + 2; + } + d[0] = 2; + d += 2; + } + } + + if (c3 >= matchMinPos) + { + CHECK_FAILURE_LZ(c3, m) + if (cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) + { + *d++ = 3; + *d++ = m - c3 - 1; + } + } + + return d; +} + + +#define INCREASE_LZ_POS p->lzPos++; p->pointerToCurPos++; + +/* +static +UInt32* MatchFinderMt_GetMatches_Bt4(CMatchFinderMt *p, UInt32 *d) +{ + const UInt32 *bt = p->btBufPos; + const UInt32 len = *bt++; + const UInt32 *btLim = bt + len; + UInt32 matchMinPos; + UInt32 avail = p->btNumAvailBytes - 1; + p->btBufPos = btLim; + + { + p->btNumAvailBytes = avail; + + #define BT_HASH_BYTES_MAX 5 + + matchMinPos = p->lzPos; + + if (len != 0) + matchMinPos -= bt[1]; + else if (avail < (BT_HASH_BYTES_MAX - 1) - 1) + { + INCREASE_LZ_POS + return d; + } + else + { + const UInt32 hs = p->historySize; + if (matchMinPos > hs) + matchMinPos -= hs; + else + matchMinPos = 1; + } + } + + for (;;) + { + + UInt32 h2, h3, c2, c3; + UInt32 *hash = p->hash; + const Byte *cur = p->pointerToCurPos; + UInt32 m = p->lzPos; + MT_HASH3_CALC + + c2 = hash[h2]; + c3 = (hash + kFix3HashSize)[h3]; + + hash[h2] = m; + (hash + kFix3HashSize)[h3] = m; + + if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) + { + d[1] = m - c2 - 1; + if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) + { + d[0] = 3; + d += 2; + break; + } + // else + { + d[0] = 2; + d += 2; + } + } + if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) + { + *d++ = 3; + *d++ = m - c3 - 1; + } + break; + } + + if (len != 0) + { + do + { + const UInt32 v0 = bt[0]; + const UInt32 v1 = bt[1]; + bt += 2; + d[0] = v0; + d[1] = v1; + d += 2; + } + while (bt != btLim); + } + INCREASE_LZ_POS + return d; +} +*/ + + +static UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d) +{ + UInt32 h2, h3, /* h4, */ c2, c3 /* , c4 */; + UInt32 *hash = p->hash; + const Byte *cur = p->pointerToCurPos; + const UInt32 m = p->lzPos; + MT_HASH3_CALC + // MT_HASH4_CALC + c2 = hash[h2]; + c3 = (hash + kFix3HashSize)[h3]; + // c4 = (hash + kFix4HashSize)[h4]; + + hash[h2] = m; + (hash + kFix3HashSize)[h3] = m; + // (hash + kFix4HashSize)[h4] = m; + + #define _USE_H2 + + #ifdef _USE_H2 + if (c2 >= matchMinPos && cur[(ptrdiff_t)c2 - (ptrdiff_t)m] == cur[0]) + { + d[1] = m - c2 - 1; + if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 2] == cur[2]) + { + // d[0] = (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) ? 4 : 3; + // return d + 2; + + if (cur[(ptrdiff_t)c2 - (ptrdiff_t)m + 3] == cur[3]) + { + d[0] = 4; + return d + 2; + } + d[0] = 3; + d += 2; + + #ifdef _USE_H4 + if (c4 >= matchMinPos) + if ( + cur[(ptrdiff_t)c4 - (ptrdiff_t)m] == cur[0] && + cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3] + ) + { + *d++ = 4; + *d++ = m - c4 - 1; + } + #endif + return d; + } + d[0] = 2; + d += 2; + } + #endif + + if (c3 >= matchMinPos && cur[(ptrdiff_t)c3 - (ptrdiff_t)m] == cur[0]) + { + d[1] = m - c3 - 1; + if (cur[(ptrdiff_t)c3 - (ptrdiff_t)m + 3] == cur[3]) + { + d[0] = 4; + return d + 2; + } + d[0] = 3; + d += 2; + } + + #ifdef _USE_H4 + if (c4 >= matchMinPos) + if ( + cur[(ptrdiff_t)c4 - (ptrdiff_t)m] == cur[0] && + cur[(ptrdiff_t)c4 - (ptrdiff_t)m + 3] == cur[3] + ) + { + *d++ = 4; + *d++ = m - c4 - 1; + } + #endif + + return d; +} + + +static UInt32* MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *d) +{ + const UInt32 *bt = p->btBufPos; + const UInt32 len = *bt++; + const UInt32 *btLim = bt + len; + p->btBufPos = btLim; + p->btNumAvailBytes--; + INCREASE_LZ_POS + { + while (bt != btLim) + { + const UInt32 v0 = bt[0]; + const UInt32 v1 = bt[1]; + bt += 2; + d[0] = v0; + d[1] = v1; + d += 2; + } + } + return d; +} + + + +static UInt32* MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *d) +{ + const UInt32 *bt = p->btBufPos; + UInt32 len = *bt++; + const UInt32 avail = p->btNumAvailBytes - 1; + p->btNumAvailBytes = avail; + p->btBufPos = bt + len; + if (len == 0) + { + #define BT_HASH_BYTES_MAX 5 + if (avail >= (BT_HASH_BYTES_MAX - 1) - 1) + { + UInt32 m = p->lzPos; + if (m > p->historySize) + m -= p->historySize; + else + m = 1; + d = p->MixMatchesFunc(p, m, d); + } + } + else + { + /* + first match pair from BinTree: (match_len, match_dist), + (match_len >= numHashBytes). + MixMatchesFunc() inserts only hash matches that are nearer than (match_dist) + */ + d = p->MixMatchesFunc(p, p->lzPos - bt[1], d); + // if (d) // check for failure + do + { + const UInt32 v0 = bt[0]; + const UInt32 v1 = bt[1]; + bt += 2; + d[0] = v0; + d[1] = v1; + d += 2; + } + while (len -= 2); + } + INCREASE_LZ_POS + return d; +} + +#define SKIP_HEADER2_MT do { GET_NEXT_BLOCK_IF_REQUIRED +#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash; +#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += (size_t)*p->btBufPos + 1; } while (--num != 0); + +static void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num) +{ + SKIP_HEADER2_MT { p->btNumAvailBytes--; + SKIP_FOOTER_MT +} + +static void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num) +{ + SKIP_HEADER_MT(2) + UInt32 h2; + MT_HASH2_CALC + hash[h2] = p->lzPos; + SKIP_FOOTER_MT +} + +static void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num) +{ + SKIP_HEADER_MT(3) + UInt32 h2, h3; + MT_HASH3_CALC + (hash + kFix3HashSize)[h3] = + hash[ h2] = + p->lzPos; + SKIP_FOOTER_MT +} + +/* +// MatchFinderMt4_Skip() is similar to MatchFinderMt3_Skip(). +// The difference is that MatchFinderMt3_Skip() updates hash for last 3 bytes of stream. + +static void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num) +{ + SKIP_HEADER_MT(4) + UInt32 h2, h3; // h4 + MT_HASH3_CALC + // MT_HASH4_CALC + // (hash + kFix4HashSize)[h4] = + (hash + kFix3HashSize)[h3] = + hash[ h2] = + p->lzPos; + SKIP_FOOTER_MT +} +*/ + +void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable) +{ + vTable->Init = (Mf_Init_Func)MatchFinderMt_Init; + vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes; + vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos; + vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches; + + switch (MF(p)->numHashBytes) + { + case 2: + p->GetHeadsFunc = GetHeads2; + p->MixMatchesFunc = (Mf_Mix_Matches)NULL; + vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip; + vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches; + break; + case 3: + p->GetHeadsFunc = MF(p)->bigHash ? GetHeads3b : GetHeads3; + p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2; + vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip; + break; + case 4: + p->GetHeadsFunc = MF(p)->bigHash ? GetHeads4b : GetHeads4; + + // it's fast inline version of GetMatches() + // vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches_Bt4; + + p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3; + vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip; + break; + default: + p->GetHeadsFunc = MF(p)->bigHash ? GetHeads5b : GetHeads5; + p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4; + vTable->Skip = + (Mf_Skip_Func)MatchFinderMt3_Skip; + // (Mf_Skip_Func)MatchFinderMt4_Skip; + break; + } +} diff --git a/deps/LZMA-SDK/C/LzFindMt.h b/deps/LZMA-SDK/C/LzFindMt.h index 888c787cb..660b7244d 100644 --- a/deps/LZMA-SDK/C/LzFindMt.h +++ b/deps/LZMA-SDK/C/LzFindMt.h @@ -1,95 +1,109 @@ -/* LzFindMt.h -- multithreaded Match finder for LZ algorithms -2019-11-05 : Igor Pavlov : Public domain */ - -#ifndef __LZ_FIND_MT_H -#define __LZ_FIND_MT_H - -#include "LzFind.h" -#include "Threads.h" - -EXTERN_C_BEGIN - -typedef struct _CMtSync -{ - BoolInt wasCreated; - BoolInt needStart; - BoolInt exit; - BoolInt stopWriting; - - CThread thread; - CAutoResetEvent canStart; - CAutoResetEvent wasStarted; - CAutoResetEvent wasStopped; - CSemaphore freeSemaphore; - CSemaphore filledSemaphore; - BoolInt csWasInitialized; - BoolInt csWasEntered; - CCriticalSection cs; - UInt32 numProcessedBlocks; - UInt64 affinity; -} CMtSync; - -typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); - -/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ -#define kMtCacheLineDummy 128 - -typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, - UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); - -typedef struct _CMatchFinderMt -{ - /* LZ */ - const Byte *pointerToCurPos; - UInt32 *btBuf; - UInt32 btBufPos; - UInt32 btBufPosLimit; - UInt32 lzPos; - UInt32 btNumAvailBytes; - - UInt32 *hash; - UInt32 fixedHashSize; - // UInt32 hash4Mask; - UInt32 historySize; - const UInt32 *crc; - - Mf_Mix_Matches MixMatchesFunc; - - /* LZ + BT */ - CMtSync btSync; - Byte btDummy[kMtCacheLineDummy]; - - /* BT */ - UInt32 *hashBuf; - UInt32 hashBufPos; - UInt32 hashBufPosLimit; - UInt32 hashNumAvail; - - CLzRef *son; - UInt32 matchMaxLen; - UInt32 numHashBytes; - UInt32 pos; - const Byte *buffer; - UInt32 cyclicBufferPos; - UInt32 cyclicBufferSize; /* it must be historySize + 1 */ - UInt32 cutValue; - - /* BT + Hash */ - CMtSync hashSync; - /* Byte hashDummy[kMtCacheLineDummy]; */ - - /* Hash */ - Mf_GetHeads GetHeadsFunc; - CMatchFinder *MatchFinder; -} CMatchFinderMt; - -void MatchFinderMt_Construct(CMatchFinderMt *p); -void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc); -SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, - UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc); -void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder *vTable); -void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); - -EXTERN_C_END - -#endif +/* LzFindMt.h -- multithreaded Match finder for LZ algorithms +2021-07-12 : Igor Pavlov : Public domain */ + +#ifndef __LZ_FIND_MT_H +#define __LZ_FIND_MT_H + +#include "LzFind.h" +#include "Threads.h" + +EXTERN_C_BEGIN + +typedef struct _CMtSync +{ + UInt32 numProcessedBlocks; + CThread thread; + UInt64 affinity; + + BoolInt wasCreated; + BoolInt needStart; + BoolInt csWasInitialized; + BoolInt csWasEntered; + + BoolInt exit; + BoolInt stopWriting; + + CAutoResetEvent canStart; + CAutoResetEvent wasStopped; + CSemaphore freeSemaphore; + CSemaphore filledSemaphore; + CCriticalSection cs; + // UInt32 numBlocks_Sent; +} CMtSync; + +typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances); + +/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */ +#define kMtCacheLineDummy 128 + +typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos, + UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc); + +typedef struct _CMatchFinderMt +{ + /* LZ */ + const Byte *pointerToCurPos; + UInt32 *btBuf; + const UInt32 *btBufPos; + const UInt32 *btBufPosLimit; + UInt32 lzPos; + UInt32 btNumAvailBytes; + + UInt32 *hash; + UInt32 fixedHashSize; + // UInt32 hash4Mask; + UInt32 historySize; + const UInt32 *crc; + + Mf_Mix_Matches MixMatchesFunc; + UInt32 failure_LZ_BT; // failure in BT transfered to LZ + // UInt32 failure_LZ_LZ; // failure in LZ tables + UInt32 failureBuf[1]; + // UInt32 crc[256]; + + /* LZ + BT */ + CMtSync btSync; + Byte btDummy[kMtCacheLineDummy]; + + /* BT */ + UInt32 *hashBuf; + UInt32 hashBufPos; + UInt32 hashBufPosLimit; + UInt32 hashNumAvail; + UInt32 failure_BT; + + + CLzRef *son; + UInt32 matchMaxLen; + UInt32 numHashBytes; + UInt32 pos; + const Byte *buffer; + UInt32 cyclicBufferPos; + UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */ + UInt32 cutValue; + + /* BT + Hash */ + CMtSync hashSync; + /* Byte hashDummy[kMtCacheLineDummy]; */ + + /* Hash */ + Mf_GetHeads GetHeadsFunc; + CMatchFinder *MatchFinder; + // CMatchFinder MatchFinder; +} CMatchFinderMt; + +// only for Mt part +void MatchFinderMt_Construct(CMatchFinderMt *p); +void MatchFinderMt_Destruct(CMatchFinderMt *p, ISzAllocPtr alloc); + +SRes MatchFinderMt_Create(CMatchFinderMt *p, UInt32 historySize, UInt32 keepAddBufferBefore, + UInt32 matchMaxLen, UInt32 keepAddBufferAfter, ISzAllocPtr alloc); +void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable); + +/* call MatchFinderMt_InitMt() before IMatchFinder::Init() */ +SRes MatchFinderMt_InitMt(CMatchFinderMt *p); +void MatchFinderMt_ReleaseStream(CMatchFinderMt *p); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/LzFindOpt.c b/deps/LZMA-SDK/C/LzFindOpt.c new file mode 100644 index 000000000..8ff006e07 --- /dev/null +++ b/deps/LZMA-SDK/C/LzFindOpt.c @@ -0,0 +1,578 @@ +/* LzFindOpt.c -- multithreaded Match finder for LZ algorithms +2021-07-13 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" +#include "LzFind.h" + +// #include "LzFindMt.h" + +// #define LOG_ITERS + +// #define LOG_THREAD + +#ifdef LOG_THREAD +#include +#define PRF(x) x +#else +// #define PRF(x) +#endif + +#ifdef LOG_ITERS +#include +UInt64 g_NumIters_Tree; +UInt64 g_NumIters_Loop; +UInt64 g_NumIters_Bytes; +#define LOG_ITER(x) x +#else +#define LOG_ITER(x) +#endif + +// ---------- BT THREAD ---------- + +#define USE_SON_PREFETCH +#define USE_LONG_MATCH_OPT + +#define kEmptyHashValue 0 + +// #define CYC_TO_POS_OFFSET 0 + +// #define CYC_TO_POS_OFFSET 1 // for debug + +/* +MY_NO_INLINE +UInt32 * MY_FAST_CALL GetMatchesSpecN_1(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, + UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, UInt32 *posRes) +{ + do + { + UInt32 delta; + if (hash == size) + break; + delta = *hash++; + + if (delta == 0 || delta > (UInt32)pos) + return NULL; + + lenLimit++; + + if (delta == (UInt32)pos) + { + CLzRef *ptr1 = son + ((size_t)pos << 1) - CYC_TO_POS_OFFSET * 2; + *d++ = 0; + ptr1[0] = kEmptyHashValue; + ptr1[1] = kEmptyHashValue; + } +else +{ + UInt32 *_distances = ++d; + + CLzRef *ptr0 = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2 + 1; + CLzRef *ptr1 = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2; + + const Byte *len0 = cur, *len1 = cur; + UInt32 cutValue = _cutValue; + const Byte *maxLen = cur + _maxLen; + + for (LOG_ITER(g_NumIters_Tree++);;) + { + LOG_ITER(g_NumIters_Loop++); + { + const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; + CLzRef *pair = son + ((size_t)(((ptrdiff_t)pos - CYC_TO_POS_OFFSET) + diff) << 1); + const Byte *len = (len0 < len1 ? len0 : len1); + + #ifdef USE_SON_PREFETCH + const UInt32 pair0 = *pair; + #endif + + if (len[diff] == len[0]) + { + if (++len != lenLimit && len[diff] == len[0]) + while (++len != lenLimit) + { + LOG_ITER(g_NumIters_Bytes++); + if (len[diff] != len[0]) + break; + } + if (maxLen < len) + { + maxLen = len; + *d++ = (UInt32)(len - cur); + *d++ = delta - 1; + + if (len == lenLimit) + { + const UInt32 pair1 = pair[1]; + *ptr1 = + #ifdef USE_SON_PREFETCH + pair0; + #else + pair[0]; + #endif + *ptr0 = pair1; + + _distances[-1] = (UInt32)(d - _distances); + + #ifdef USE_LONG_MATCH_OPT + + if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) + break; + + { + for (;;) + { + hash++; + pos++; + cur++; + lenLimit++; + { + CLzRef *ptr = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2; + #if 0 + *(UInt64 *)(void *)ptr = ((const UInt64 *)(const void *)ptr)[diff]; + #else + const UInt32 p0 = ptr[0 + (diff * 2)]; + const UInt32 p1 = ptr[1 + (diff * 2)]; + ptr[0] = p0; + ptr[1] = p1; + // ptr[0] = ptr[0 + (diff * 2)]; + // ptr[1] = ptr[1 + (diff * 2)]; + #endif + } + // PrintSon(son + 2, pos - 1); + // printf("\npos = %x delta = %x\n", pos, delta); + len++; + *d++ = 2; + *d++ = (UInt32)(len - cur); + *d++ = delta - 1; + if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) + break; + } + } + #endif + + break; + } + } + } + + { + const UInt32 curMatch = (UInt32)pos - delta; // (UInt32)(pos + diff); + if (len[diff] < len[0]) + { + delta = pair[1]; + if (delta >= curMatch) + return NULL; + *ptr1 = curMatch; + ptr1 = pair + 1; + len1 = len; + } + else + { + delta = *pair; + if (delta >= curMatch) + return NULL; + *ptr0 = curMatch; + ptr0 = pair; + len0 = len; + } + + delta = (UInt32)pos - delta; + + if (--cutValue == 0 || delta >= pos) + { + *ptr0 = *ptr1 = kEmptyHashValue; + _distances[-1] = (UInt32)(d - _distances); + break; + } + } + } + } // for (tree iterations) +} + pos++; + cur++; + } + while (d < limit); + *posRes = (UInt32)pos; + return d; +} +*/ + +/* define cbs if you use 2 functions. + GetMatchesSpecN_1() : (pos < _cyclicBufferSize) + GetMatchesSpecN_2() : (pos >= _cyclicBufferSize) + + do not define cbs if you use 1 function: + GetMatchesSpecN_2() +*/ + +// #define cbs _cyclicBufferSize + +/* + we use size_t for (pos) and (_cyclicBufferPos_ instead of UInt32 + to eliminate "movsx" BUG in old MSVC x64 compiler. +*/ + +UInt32 * MY_FAST_CALL GetMatchesSpecN_2(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, + UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, + UInt32 *posRes); + +MY_NO_INLINE +UInt32 * MY_FAST_CALL GetMatchesSpecN_2(const Byte *lenLimit, size_t pos, const Byte *cur, CLzRef *son, + UInt32 _cutValue, UInt32 *d, size_t _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, + UInt32 *posRes) +{ + do // while (hash != size) + { + UInt32 delta; + + #ifndef cbs + UInt32 cbs; + #endif + + if (hash == size) + break; + + delta = *hash++; + + if (delta == 0) + return NULL; + + lenLimit++; + + #ifndef cbs + cbs = _cyclicBufferSize; + if ((UInt32)pos < cbs) + { + if (delta > (UInt32)pos) + return NULL; + cbs = (UInt32)pos; + } + #endif + + if (delta >= cbs) + { + CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); + *d++ = 0; + ptr1[0] = kEmptyHashValue; + ptr1[1] = kEmptyHashValue; + } +else +{ + UInt32 *_distances = ++d; + + CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; + CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); + + UInt32 cutValue = _cutValue; + const Byte *len0 = cur, *len1 = cur; + const Byte *maxLen = cur + _maxLen; + + // if (cutValue == 0) { *ptr0 = *ptr1 = kEmptyHashValue; } else + for (LOG_ITER(g_NumIters_Tree++);;) + { + LOG_ITER(g_NumIters_Loop++); + { + // SPEC code + CLzRef *pair = son + ((size_t)((ptrdiff_t)_cyclicBufferPos - (ptrdiff_t)delta + + (ptrdiff_t)(UInt32)(_cyclicBufferPos < delta ? cbs : 0) + ) << 1); + + const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; + const Byte *len = (len0 < len1 ? len0 : len1); + + #ifdef USE_SON_PREFETCH + const UInt32 pair0 = *pair; + #endif + + if (len[diff] == len[0]) + { + if (++len != lenLimit && len[diff] == len[0]) + while (++len != lenLimit) + { + LOG_ITER(g_NumIters_Bytes++); + if (len[diff] != len[0]) + break; + } + if (maxLen < len) + { + maxLen = len; + *d++ = (UInt32)(len - cur); + *d++ = delta - 1; + + if (len == lenLimit) + { + const UInt32 pair1 = pair[1]; + *ptr1 = + #ifdef USE_SON_PREFETCH + pair0; + #else + pair[0]; + #endif + *ptr0 = pair1; + + _distances[-1] = (UInt32)(d - _distances); + + #ifdef USE_LONG_MATCH_OPT + + if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) + break; + + { + for (;;) + { + *d++ = 2; + *d++ = (UInt32)(lenLimit - cur); + *d++ = delta - 1; + cur++; + lenLimit++; + // SPEC + _cyclicBufferPos++; + { + // SPEC code + CLzRef *dest = son + ((size_t)(_cyclicBufferPos) << 1); + const CLzRef *src = dest + ((diff + + (ptrdiff_t)(UInt32)((_cyclicBufferPos < delta) ? cbs : 0)) << 1); + // CLzRef *ptr = son + ((size_t)(pos) << 1) - CYC_TO_POS_OFFSET * 2; + #if 0 + *(UInt64 *)(void *)dest = *((const UInt64 *)(const void *)src); + #else + const UInt32 p0 = src[0]; + const UInt32 p1 = src[1]; + dest[0] = p0; + dest[1] = p1; + #endif + } + pos++; + hash++; + if (hash == size || *hash != delta || lenLimit[diff] != lenLimit[0] || d >= limit) + break; + } // for() end for long matches + } + #endif + + break; // break from TREE iterations + } + } + } + { + const UInt32 curMatch = (UInt32)pos - delta; // (UInt32)(pos + diff); + if (len[diff] < len[0]) + { + delta = pair[1]; + *ptr1 = curMatch; + ptr1 = pair + 1; + len1 = len; + if (delta >= curMatch) + return NULL; + } + else + { + delta = *pair; + *ptr0 = curMatch; + ptr0 = pair; + len0 = len; + if (delta >= curMatch) + return NULL; + } + delta = (UInt32)pos - delta; + + if (--cutValue == 0 || delta >= cbs) + { + *ptr0 = *ptr1 = kEmptyHashValue; + _distances[-1] = (UInt32)(d - _distances); + break; + } + } + } + } // for (tree iterations) +} + pos++; + _cyclicBufferPos++; + cur++; + } + while (d < limit); + *posRes = (UInt32)pos; + return d; +} + + + +/* +typedef UInt32 uint32plus; // size_t + +UInt32 * MY_FAST_CALL GetMatchesSpecN_3(uint32plus lenLimit, size_t pos, const Byte *cur, CLzRef *son, + UInt32 _cutValue, UInt32 *d, uint32plus _maxLen, const UInt32 *hash, const UInt32 *limit, const UInt32 *size, + size_t _cyclicBufferPos, UInt32 _cyclicBufferSize, + UInt32 *posRes) +{ + do // while (hash != size) + { + UInt32 delta; + + #ifndef cbs + UInt32 cbs; + #endif + + if (hash == size) + break; + + delta = *hash++; + + if (delta == 0) + return NULL; + + #ifndef cbs + cbs = _cyclicBufferSize; + if ((UInt32)pos < cbs) + { + if (delta > (UInt32)pos) + return NULL; + cbs = (UInt32)pos; + } + #endif + + if (delta >= cbs) + { + CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); + *d++ = 0; + ptr1[0] = kEmptyHashValue; + ptr1[1] = kEmptyHashValue; + } +else +{ + CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1; + CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1); + UInt32 *_distances = ++d; + uint32plus len0 = 0, len1 = 0; + UInt32 cutValue = _cutValue; + uint32plus maxLen = _maxLen; + // lenLimit++; // const Byte *lenLimit = cur + _lenLimit; + + for (LOG_ITER(g_NumIters_Tree++);;) + { + LOG_ITER(g_NumIters_Loop++); + { + // const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; + CLzRef *pair = son + ((size_t)((ptrdiff_t)_cyclicBufferPos - delta + + (ptrdiff_t)(UInt32)(_cyclicBufferPos < delta ? cbs : 0) + ) << 1); + const Byte *pb = cur - delta; + uint32plus len = (len0 < len1 ? len0 : len1); + + #ifdef USE_SON_PREFETCH + const UInt32 pair0 = *pair; + #endif + + if (pb[len] == cur[len]) + { + if (++len != lenLimit && pb[len] == cur[len]) + while (++len != lenLimit) + if (pb[len] != cur[len]) + break; + if (maxLen < len) + { + maxLen = len; + *d++ = (UInt32)len; + *d++ = delta - 1; + if (len == lenLimit) + { + { + const UInt32 pair1 = pair[1]; + *ptr0 = pair1; + *ptr1 = + #ifdef USE_SON_PREFETCH + pair0; + #else + pair[0]; + #endif + } + + _distances[-1] = (UInt32)(d - _distances); + + #ifdef USE_LONG_MATCH_OPT + + if (hash == size || *hash != delta || pb[lenLimit] != cur[lenLimit] || d >= limit) + break; + + { + const ptrdiff_t diff = (ptrdiff_t)0 - (ptrdiff_t)delta; + for (;;) + { + *d++ = 2; + *d++ = (UInt32)lenLimit; + *d++ = delta - 1; + _cyclicBufferPos++; + { + CLzRef *dest = son + ((size_t)_cyclicBufferPos << 1); + const CLzRef *src = dest + ((diff + + (ptrdiff_t)(UInt32)(_cyclicBufferPos < delta ? cbs : 0)) << 1); + #if 0 + *(UInt64 *)(void *)dest = *((const UInt64 *)(const void *)src); + #else + const UInt32 p0 = src[0]; + const UInt32 p1 = src[1]; + dest[0] = p0; + dest[1] = p1; + #endif + } + hash++; + pos++; + cur++; + pb++; + if (hash == size || *hash != delta || pb[lenLimit] != cur[lenLimit] || d >= limit) + break; + } + } + #endif + + break; + } + } + } + { + const UInt32 curMatch = (UInt32)pos - delta; + if (pb[len] < cur[len]) + { + delta = pair[1]; + *ptr1 = curMatch; + ptr1 = pair + 1; + len1 = len; + } + else + { + delta = *pair; + *ptr0 = curMatch; + ptr0 = pair; + len0 = len; + } + + { + if (delta >= curMatch) + return NULL; + delta = (UInt32)pos - delta; + if (delta >= cbs + // delta >= _cyclicBufferSize || delta >= pos + || --cutValue == 0) + { + *ptr0 = *ptr1 = kEmptyHashValue; + _distances[-1] = (UInt32)(d - _distances); + break; + } + } + } + } + } // for (tree iterations) +} + pos++; + _cyclicBufferPos++; + cur++; + } + while (d < limit); + *posRes = (UInt32)pos; + return d; +} +*/ diff --git a/deps/LZMA-SDK/C/LzHash.h b/deps/LZMA-SDK/C/LzHash.h index a682f83be..77b898cfa 100644 --- a/deps/LZMA-SDK/C/LzHash.h +++ b/deps/LZMA-SDK/C/LzHash.h @@ -1,34 +1,34 @@ -/* LzHash.h -- HASH functions for LZ algorithms -2019-10-30 : Igor Pavlov : Public domain */ - -#ifndef __LZ_HASH_H -#define __LZ_HASH_H - -/* - (kHash2Size >= (1 << 8)) : Required - (kHash3Size >= (1 << 16)) : Required -*/ - -#define kHash2Size (1 << 10) -#define kHash3Size (1 << 16) -// #define kHash4Size (1 << 20) - -#define kFix3HashSize (kHash2Size) -#define kFix4HashSize (kHash2Size + kHash3Size) -// #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) - -/* - We use up to 3 crc values for hash: - crc0 - crc1 << Shift_1 - crc2 << Shift_2 - (Shift_1 = 5) and (Shift_2 = 10) is good tradeoff. - Small values for Shift are not good for collision rate. - Big value for Shift_2 increases the minimum size - of hash table, that will be slow for small files. -*/ - -#define kLzHash_CrcShift_1 5 -#define kLzHash_CrcShift_2 10 - -#endif +/* LzHash.h -- HASH functions for LZ algorithms +2019-10-30 : Igor Pavlov : Public domain */ + +#ifndef __LZ_HASH_H +#define __LZ_HASH_H + +/* + (kHash2Size >= (1 << 8)) : Required + (kHash3Size >= (1 << 16)) : Required +*/ + +#define kHash2Size (1 << 10) +#define kHash3Size (1 << 16) +// #define kHash4Size (1 << 20) + +#define kFix3HashSize (kHash2Size) +#define kFix4HashSize (kHash2Size + kHash3Size) +// #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) + +/* + We use up to 3 crc values for hash: + crc0 + crc1 << Shift_1 + crc2 << Shift_2 + (Shift_1 = 5) and (Shift_2 = 10) is good tradeoff. + Small values for Shift are not good for collision rate. + Big value for Shift_2 increases the minimum size + of hash table, that will be slow for small files. +*/ + +#define kLzHash_CrcShift_1 5 +#define kLzHash_CrcShift_2 10 + +#endif diff --git a/deps/LZMA-SDK/C/Lzma2Dec.c b/deps/LZMA-SDK/C/Lzma2Dec.c index f9f98095d..ac970a843 100644 --- a/deps/LZMA-SDK/C/Lzma2Dec.c +++ b/deps/LZMA-SDK/C/Lzma2Dec.c @@ -1,489 +1,489 @@ -/* Lzma2Dec.c -- LZMA2 Decoder -2021-02-09 : Igor Pavlov : Public domain */ - -/* #define SHOW_DEBUG_INFO */ - -#include "Precomp.h" - -#ifdef SHOW_DEBUG_INFO -#include -#endif - -#include - -#include "Lzma2Dec.h" - -/* -00000000 - End of data -00000001 U U - Uncompressed, reset dic, need reset state and set new prop -00000010 U U - Uncompressed, no reset -100uuuuu U U P P - LZMA, no reset -101uuuuu U U P P - LZMA, reset state -110uuuuu U U P P S - LZMA, reset state + set new prop -111uuuuu U U P P S - LZMA, reset state + set new prop, reset dic - - u, U - Unpack Size - P - Pack Size - S - Props -*/ - -#define LZMA2_CONTROL_COPY_RESET_DIC 1 - -#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & (1 << 7)) == 0) - -#define LZMA2_LCLP_MAX 4 -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) - -#ifdef SHOW_DEBUG_INFO -#define PRF(x) x -#else -#define PRF(x) -#endif - -typedef enum -{ - LZMA2_STATE_CONTROL, - LZMA2_STATE_UNPACK0, - LZMA2_STATE_UNPACK1, - LZMA2_STATE_PACK0, - LZMA2_STATE_PACK1, - LZMA2_STATE_PROP, - LZMA2_STATE_DATA, - LZMA2_STATE_DATA_CONT, - LZMA2_STATE_FINISHED, - LZMA2_STATE_ERROR -} ELzma2State; - -static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props) -{ - UInt32 dicSize; - if (prop > 40) - return SZ_ERROR_UNSUPPORTED; - dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); - props[0] = (Byte)LZMA2_LCLP_MAX; - props[1] = (Byte)(dicSize); - props[2] = (Byte)(dicSize >> 8); - props[3] = (Byte)(dicSize >> 16); - props[4] = (Byte)(dicSize >> 24); - return SZ_OK; -} - -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc) -{ - Byte props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); -} - -SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc) -{ - Byte props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); -} - -void Lzma2Dec_Init(CLzma2Dec *p) -{ - p->state = LZMA2_STATE_CONTROL; - p->needInitLevel = 0xE0; - p->isExtraMode = False; - p->unpackSize = 0; - - // p->decoder.dicPos = 0; // we can use it instead of full init - LzmaDec_Init(&p->decoder); -} - -// ELzma2State -static unsigned Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) -{ - switch (p->state) - { - case LZMA2_STATE_CONTROL: - p->isExtraMode = False; - p->control = b; - PRF(printf("\n %8X", (unsigned)p->decoder.dicPos)); - PRF(printf(" %02X", (unsigned)b)); - if (b == 0) - return LZMA2_STATE_FINISHED; - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if (b == LZMA2_CONTROL_COPY_RESET_DIC) - p->needInitLevel = 0xC0; - else if (b > 2 || p->needInitLevel == 0xE0) - return LZMA2_STATE_ERROR; - } - else - { - if (b < p->needInitLevel) - return LZMA2_STATE_ERROR; - p->needInitLevel = 0; - p->unpackSize = (UInt32)(b & 0x1F) << 16; - } - return LZMA2_STATE_UNPACK0; - - case LZMA2_STATE_UNPACK0: - p->unpackSize |= (UInt32)b << 8; - return LZMA2_STATE_UNPACK1; - - case LZMA2_STATE_UNPACK1: - p->unpackSize |= (UInt32)b; - p->unpackSize++; - PRF(printf(" %7u", (unsigned)p->unpackSize)); - return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; - - case LZMA2_STATE_PACK0: - p->packSize = (UInt32)b << 8; - return LZMA2_STATE_PACK1; - - case LZMA2_STATE_PACK1: - p->packSize |= (UInt32)b; - p->packSize++; - // if (p->packSize < 5) return LZMA2_STATE_ERROR; - PRF(printf(" %5u", (unsigned)p->packSize)); - return (p->control & 0x40) ? LZMA2_STATE_PROP : LZMA2_STATE_DATA; - - case LZMA2_STATE_PROP: - { - unsigned lc, lp; - if (b >= (9 * 5 * 5)) - return LZMA2_STATE_ERROR; - lc = b % 9; - b /= 9; - p->decoder.prop.pb = (Byte)(b / 5); - lp = b % 5; - if (lc + lp > LZMA2_LCLP_MAX) - return LZMA2_STATE_ERROR; - p->decoder.prop.lc = (Byte)lc; - p->decoder.prop.lp = (Byte)lp; - return LZMA2_STATE_DATA; - } - } - return LZMA2_STATE_ERROR; -} - -static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size) -{ - memcpy(p->dic + p->dicPos, src, size); - p->dicPos += size; - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) - p->checkDicSize = p->prop.dicSize; - p->processedPos += (UInt32)size; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState); - - -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT inSize = *srcLen; - *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->state != LZMA2_STATE_ERROR) - { - SizeT dicPos; - - if (p->state == LZMA2_STATE_FINISHED) - { - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return SZ_OK; - } - - dicPos = p->decoder.dicPos; - - if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - - if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - (*srcLen)++; - p->state = Lzma2Dec_UpdateState(p, *src++); - if (dicPos == dicLimit && p->state != LZMA2_STATE_FINISHED) - break; - continue; - } - - { - SizeT inCur = inSize - *srcLen; - SizeT outCur = dicLimit - dicPos; - ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; - - if (outCur >= p->unpackSize) - { - outCur = (SizeT)p->unpackSize; - curFinishMode = LZMA_FINISH_END; - } - - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if (inCur == 0) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - - if (p->state == LZMA2_STATE_DATA) - { - BoolInt initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); - LzmaDec_InitDicAndState(&p->decoder, initDic, False); - } - - if (inCur > outCur) - inCur = outCur; - if (inCur == 0) - break; - - LzmaDec_UpdateWithUncompressed(&p->decoder, src, inCur); - - src += inCur; - *srcLen += inCur; - p->unpackSize -= (UInt32)inCur; - p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; - } - else - { - SRes res; - - if (p->state == LZMA2_STATE_DATA) - { - BoolInt initDic = (p->control >= 0xE0); - BoolInt initState = (p->control >= 0xA0); - LzmaDec_InitDicAndState(&p->decoder, initDic, initState); - p->state = LZMA2_STATE_DATA_CONT; - } - - if (inCur > p->packSize) - inCur = (SizeT)p->packSize; - - res = LzmaDec_DecodeToDic(&p->decoder, dicPos + outCur, src, &inCur, curFinishMode, status); - - src += inCur; - *srcLen += inCur; - p->packSize -= (UInt32)inCur; - outCur = p->decoder.dicPos - dicPos; - p->unpackSize -= (UInt32)outCur; - - if (res != 0) - break; - - if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) - { - if (p->packSize == 0) - break; - return SZ_OK; - } - - if (inCur == 0 && outCur == 0) - { - if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK - || p->unpackSize != 0 - || p->packSize != 0) - break; - p->state = LZMA2_STATE_CONTROL; - } - - *status = LZMA_STATUS_NOT_SPECIFIED; - } - } - } - - *status = LZMA_STATUS_NOT_SPECIFIED; - p->state = LZMA2_STATE_ERROR; - return SZ_ERROR_DATA; -} - - - - -ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, - SizeT outSize, - const Byte *src, SizeT *srcLen, - int checkFinishBlock) -{ - SizeT inSize = *srcLen; - *srcLen = 0; - - while (p->state != LZMA2_STATE_ERROR) - { - if (p->state == LZMA2_STATE_FINISHED) - return (ELzma2ParseStatus)LZMA_STATUS_FINISHED_WITH_MARK; - - if (outSize == 0 && !checkFinishBlock) - return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED; - - if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) - { - if (*srcLen == inSize) - return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT; - (*srcLen)++; - - p->state = Lzma2Dec_UpdateState(p, *src++); - - if (p->state == LZMA2_STATE_UNPACK0) - { - // if (p->decoder.dicPos != 0) - if (p->control == LZMA2_CONTROL_COPY_RESET_DIC || p->control >= 0xE0) - return LZMA2_PARSE_STATUS_NEW_BLOCK; - // if (outSize == 0) return LZMA_STATUS_NOT_FINISHED; - } - - // The following code can be commented. - // It's not big problem, if we read additional input bytes. - // It will be stopped later in LZMA2_STATE_DATA / LZMA2_STATE_DATA_CONT state. - - if (outSize == 0 && p->state != LZMA2_STATE_FINISHED) - { - // checkFinishBlock is true. So we expect that block must be finished, - // We can return LZMA_STATUS_NOT_SPECIFIED or LZMA_STATUS_NOT_FINISHED here - // break; - return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED; - } - - if (p->state == LZMA2_STATE_DATA) - return LZMA2_PARSE_STATUS_NEW_CHUNK; - - continue; - } - - if (outSize == 0) - return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED; - - { - SizeT inCur = inSize - *srcLen; - - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if (inCur == 0) - return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT; - if (inCur > p->unpackSize) - inCur = p->unpackSize; - if (inCur > outSize) - inCur = outSize; - p->decoder.dicPos += inCur; - src += inCur; - *srcLen += inCur; - outSize -= inCur; - p->unpackSize -= (UInt32)inCur; - p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; - } - else - { - p->isExtraMode = True; - - if (inCur == 0) - { - if (p->packSize != 0) - return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT; - } - else if (p->state == LZMA2_STATE_DATA) - { - p->state = LZMA2_STATE_DATA_CONT; - if (*src != 0) - { - // first byte of lzma chunk must be Zero - *srcLen += 1; - p->packSize--; - break; - } - } - - if (inCur > p->packSize) - inCur = (SizeT)p->packSize; - - src += inCur; - *srcLen += inCur; - p->packSize -= (UInt32)inCur; - - if (p->packSize == 0) - { - SizeT rem = outSize; - if (rem > p->unpackSize) - rem = p->unpackSize; - p->decoder.dicPos += rem; - p->unpackSize -= (UInt32)rem; - outSize -= rem; - if (p->unpackSize == 0) - p->state = LZMA2_STATE_CONTROL; - } - } - } - } - - p->state = LZMA2_STATE_ERROR; - return (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED; -} - - - - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT outSize = *destLen, inSize = *srcLen; - *srcLen = *destLen = 0; - - for (;;) - { - SizeT inCur = inSize, outCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - - if (p->decoder.dicPos == p->decoder.dicBufSize) - p->decoder.dicPos = 0; - dicPos = p->decoder.dicPos; - curFinishMode = LZMA_FINISH_ANY; - outCur = p->decoder.dicBufSize - dicPos; - - if (outCur >= outSize) - { - outCur = outSize; - curFinishMode = finishMode; - } - - res = Lzma2Dec_DecodeToDic(p, dicPos + outCur, src, &inCur, curFinishMode, status); - - src += inCur; - inSize -= inCur; - *srcLen += inCur; - outCur = p->decoder.dicPos - dicPos; - memcpy(dest, p->decoder.dic + dicPos, outCur); - dest += outCur; - outSize -= outCur; - *destLen += outCur; - if (res != 0) - return res; - if (outCur == 0 || outSize == 0) - return SZ_OK; - } -} - - -SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc) -{ - CLzma2Dec p; - SRes res; - SizeT outSize = *destLen, inSize = *srcLen; - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - Lzma2Dec_Construct(&p); - RINOK(Lzma2Dec_AllocateProbs(&p, prop, alloc)); - p.decoder.dic = dest; - p.decoder.dicBufSize = outSize; - Lzma2Dec_Init(&p); - *srcLen = inSize; - res = Lzma2Dec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - *destLen = p.decoder.dicPos; - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - Lzma2Dec_FreeProbs(&p, alloc); - return res; -} +/* Lzma2Dec.c -- LZMA2 Decoder +2021-02-09 : Igor Pavlov : Public domain */ + +/* #define SHOW_DEBUG_INFO */ + +#include "Precomp.h" + +#ifdef SHOW_DEBUG_INFO +#include +#endif + +#include + +#include "Lzma2Dec.h" + +/* +00000000 - End of data +00000001 U U - Uncompressed, reset dic, need reset state and set new prop +00000010 U U - Uncompressed, no reset +100uuuuu U U P P - LZMA, no reset +101uuuuu U U P P - LZMA, reset state +110uuuuu U U P P S - LZMA, reset state + set new prop +111uuuuu U U P P S - LZMA, reset state + set new prop, reset dic + + u, U - Unpack Size + P - Pack Size + S - Props +*/ + +#define LZMA2_CONTROL_COPY_RESET_DIC 1 + +#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & (1 << 7)) == 0) + +#define LZMA2_LCLP_MAX 4 +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) + +#ifdef SHOW_DEBUG_INFO +#define PRF(x) x +#else +#define PRF(x) +#endif + +typedef enum +{ + LZMA2_STATE_CONTROL, + LZMA2_STATE_UNPACK0, + LZMA2_STATE_UNPACK1, + LZMA2_STATE_PACK0, + LZMA2_STATE_PACK1, + LZMA2_STATE_PROP, + LZMA2_STATE_DATA, + LZMA2_STATE_DATA_CONT, + LZMA2_STATE_FINISHED, + LZMA2_STATE_ERROR +} ELzma2State; + +static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props) +{ + UInt32 dicSize; + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); + props[0] = (Byte)LZMA2_LCLP_MAX; + props[1] = (Byte)(dicSize); + props[2] = (Byte)(dicSize >> 8); + props[3] = (Byte)(dicSize >> 16); + props[4] = (Byte)(dicSize >> 24); + return SZ_OK; +} + +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc) +{ + Byte props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); +} + +SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc) +{ + Byte props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); +} + +void Lzma2Dec_Init(CLzma2Dec *p) +{ + p->state = LZMA2_STATE_CONTROL; + p->needInitLevel = 0xE0; + p->isExtraMode = False; + p->unpackSize = 0; + + // p->decoder.dicPos = 0; // we can use it instead of full init + LzmaDec_Init(&p->decoder); +} + +// ELzma2State +static unsigned Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) +{ + switch (p->state) + { + case LZMA2_STATE_CONTROL: + p->isExtraMode = False; + p->control = b; + PRF(printf("\n %8X", (unsigned)p->decoder.dicPos)); + PRF(printf(" %02X", (unsigned)b)); + if (b == 0) + return LZMA2_STATE_FINISHED; + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if (b == LZMA2_CONTROL_COPY_RESET_DIC) + p->needInitLevel = 0xC0; + else if (b > 2 || p->needInitLevel == 0xE0) + return LZMA2_STATE_ERROR; + } + else + { + if (b < p->needInitLevel) + return LZMA2_STATE_ERROR; + p->needInitLevel = 0; + p->unpackSize = (UInt32)(b & 0x1F) << 16; + } + return LZMA2_STATE_UNPACK0; + + case LZMA2_STATE_UNPACK0: + p->unpackSize |= (UInt32)b << 8; + return LZMA2_STATE_UNPACK1; + + case LZMA2_STATE_UNPACK1: + p->unpackSize |= (UInt32)b; + p->unpackSize++; + PRF(printf(" %7u", (unsigned)p->unpackSize)); + return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; + + case LZMA2_STATE_PACK0: + p->packSize = (UInt32)b << 8; + return LZMA2_STATE_PACK1; + + case LZMA2_STATE_PACK1: + p->packSize |= (UInt32)b; + p->packSize++; + // if (p->packSize < 5) return LZMA2_STATE_ERROR; + PRF(printf(" %5u", (unsigned)p->packSize)); + return (p->control & 0x40) ? LZMA2_STATE_PROP : LZMA2_STATE_DATA; + + case LZMA2_STATE_PROP: + { + unsigned lc, lp; + if (b >= (9 * 5 * 5)) + return LZMA2_STATE_ERROR; + lc = b % 9; + b /= 9; + p->decoder.prop.pb = (Byte)(b / 5); + lp = b % 5; + if (lc + lp > LZMA2_LCLP_MAX) + return LZMA2_STATE_ERROR; + p->decoder.prop.lc = (Byte)lc; + p->decoder.prop.lp = (Byte)lp; + return LZMA2_STATE_DATA; + } + } + return LZMA2_STATE_ERROR; +} + +static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size) +{ + memcpy(p->dic + p->dicPos, src, size); + p->dicPos += size; + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) + p->checkDicSize = p->prop.dicSize; + p->processedPos += (UInt32)size; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState); + + +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + SizeT inSize = *srcLen; + *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + + while (p->state != LZMA2_STATE_ERROR) + { + SizeT dicPos; + + if (p->state == LZMA2_STATE_FINISHED) + { + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return SZ_OK; + } + + dicPos = p->decoder.dicPos; + + if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + + if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) + { + if (*srcLen == inSize) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + (*srcLen)++; + p->state = Lzma2Dec_UpdateState(p, *src++); + if (dicPos == dicLimit && p->state != LZMA2_STATE_FINISHED) + break; + continue; + } + + { + SizeT inCur = inSize - *srcLen; + SizeT outCur = dicLimit - dicPos; + ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; + + if (outCur >= p->unpackSize) + { + outCur = (SizeT)p->unpackSize; + curFinishMode = LZMA_FINISH_END; + } + + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if (inCur == 0) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + if (p->state == LZMA2_STATE_DATA) + { + BoolInt initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); + LzmaDec_InitDicAndState(&p->decoder, initDic, False); + } + + if (inCur > outCur) + inCur = outCur; + if (inCur == 0) + break; + + LzmaDec_UpdateWithUncompressed(&p->decoder, src, inCur); + + src += inCur; + *srcLen += inCur; + p->unpackSize -= (UInt32)inCur; + p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; + } + else + { + SRes res; + + if (p->state == LZMA2_STATE_DATA) + { + BoolInt initDic = (p->control >= 0xE0); + BoolInt initState = (p->control >= 0xA0); + LzmaDec_InitDicAndState(&p->decoder, initDic, initState); + p->state = LZMA2_STATE_DATA_CONT; + } + + if (inCur > p->packSize) + inCur = (SizeT)p->packSize; + + res = LzmaDec_DecodeToDic(&p->decoder, dicPos + outCur, src, &inCur, curFinishMode, status); + + src += inCur; + *srcLen += inCur; + p->packSize -= (UInt32)inCur; + outCur = p->decoder.dicPos - dicPos; + p->unpackSize -= (UInt32)outCur; + + if (res != 0) + break; + + if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) + { + if (p->packSize == 0) + break; + return SZ_OK; + } + + if (inCur == 0 && outCur == 0) + { + if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + || p->unpackSize != 0 + || p->packSize != 0) + break; + p->state = LZMA2_STATE_CONTROL; + } + + *status = LZMA_STATUS_NOT_SPECIFIED; + } + } + } + + *status = LZMA_STATUS_NOT_SPECIFIED; + p->state = LZMA2_STATE_ERROR; + return SZ_ERROR_DATA; +} + + + + +ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, + SizeT outSize, + const Byte *src, SizeT *srcLen, + int checkFinishBlock) +{ + SizeT inSize = *srcLen; + *srcLen = 0; + + while (p->state != LZMA2_STATE_ERROR) + { + if (p->state == LZMA2_STATE_FINISHED) + return (ELzma2ParseStatus)LZMA_STATUS_FINISHED_WITH_MARK; + + if (outSize == 0 && !checkFinishBlock) + return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED; + + if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) + { + if (*srcLen == inSize) + return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT; + (*srcLen)++; + + p->state = Lzma2Dec_UpdateState(p, *src++); + + if (p->state == LZMA2_STATE_UNPACK0) + { + // if (p->decoder.dicPos != 0) + if (p->control == LZMA2_CONTROL_COPY_RESET_DIC || p->control >= 0xE0) + return LZMA2_PARSE_STATUS_NEW_BLOCK; + // if (outSize == 0) return LZMA_STATUS_NOT_FINISHED; + } + + // The following code can be commented. + // It's not big problem, if we read additional input bytes. + // It will be stopped later in LZMA2_STATE_DATA / LZMA2_STATE_DATA_CONT state. + + if (outSize == 0 && p->state != LZMA2_STATE_FINISHED) + { + // checkFinishBlock is true. So we expect that block must be finished, + // We can return LZMA_STATUS_NOT_SPECIFIED or LZMA_STATUS_NOT_FINISHED here + // break; + return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED; + } + + if (p->state == LZMA2_STATE_DATA) + return LZMA2_PARSE_STATUS_NEW_CHUNK; + + continue; + } + + if (outSize == 0) + return (ELzma2ParseStatus)LZMA_STATUS_NOT_FINISHED; + + { + SizeT inCur = inSize - *srcLen; + + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if (inCur == 0) + return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT; + if (inCur > p->unpackSize) + inCur = p->unpackSize; + if (inCur > outSize) + inCur = outSize; + p->decoder.dicPos += inCur; + src += inCur; + *srcLen += inCur; + outSize -= inCur; + p->unpackSize -= (UInt32)inCur; + p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; + } + else + { + p->isExtraMode = True; + + if (inCur == 0) + { + if (p->packSize != 0) + return (ELzma2ParseStatus)LZMA_STATUS_NEEDS_MORE_INPUT; + } + else if (p->state == LZMA2_STATE_DATA) + { + p->state = LZMA2_STATE_DATA_CONT; + if (*src != 0) + { + // first byte of lzma chunk must be Zero + *srcLen += 1; + p->packSize--; + break; + } + } + + if (inCur > p->packSize) + inCur = (SizeT)p->packSize; + + src += inCur; + *srcLen += inCur; + p->packSize -= (UInt32)inCur; + + if (p->packSize == 0) + { + SizeT rem = outSize; + if (rem > p->unpackSize) + rem = p->unpackSize; + p->decoder.dicPos += rem; + p->unpackSize -= (UInt32)rem; + outSize -= rem; + if (p->unpackSize == 0) + p->state = LZMA2_STATE_CONTROL; + } + } + } + } + + p->state = LZMA2_STATE_ERROR; + return (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED; +} + + + + +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + SizeT outSize = *destLen, inSize = *srcLen; + *srcLen = *destLen = 0; + + for (;;) + { + SizeT inCur = inSize, outCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + + if (p->decoder.dicPos == p->decoder.dicBufSize) + p->decoder.dicPos = 0; + dicPos = p->decoder.dicPos; + curFinishMode = LZMA_FINISH_ANY; + outCur = p->decoder.dicBufSize - dicPos; + + if (outCur >= outSize) + { + outCur = outSize; + curFinishMode = finishMode; + } + + res = Lzma2Dec_DecodeToDic(p, dicPos + outCur, src, &inCur, curFinishMode, status); + + src += inCur; + inSize -= inCur; + *srcLen += inCur; + outCur = p->decoder.dicPos - dicPos; + memcpy(dest, p->decoder.dic + dicPos, outCur); + dest += outCur; + outSize -= outCur; + *destLen += outCur; + if (res != 0) + return res; + if (outCur == 0 || outSize == 0) + return SZ_OK; + } +} + + +SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc) +{ + CLzma2Dec p; + SRes res; + SizeT outSize = *destLen, inSize = *srcLen; + *destLen = *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + Lzma2Dec_Construct(&p); + RINOK(Lzma2Dec_AllocateProbs(&p, prop, alloc)); + p.decoder.dic = dest; + p.decoder.dicBufSize = outSize; + Lzma2Dec_Init(&p); + *srcLen = inSize; + res = Lzma2Dec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); + *destLen = p.decoder.dicPos; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + Lzma2Dec_FreeProbs(&p, alloc); + return res; +} diff --git a/deps/LZMA-SDK/C/Lzma2Dec.h b/deps/LZMA-SDK/C/Lzma2Dec.h index da5038725..b8ddeac89 100644 --- a/deps/LZMA-SDK/C/Lzma2Dec.h +++ b/deps/LZMA-SDK/C/Lzma2Dec.h @@ -1,120 +1,120 @@ -/* Lzma2Dec.h -- LZMA2 Decoder -2018-02-19 : Igor Pavlov : Public domain */ - -#ifndef __LZMA2_DEC_H -#define __LZMA2_DEC_H - -#include "LzmaDec.h" - -EXTERN_C_BEGIN - -/* ---------- State Interface ---------- */ - -typedef struct -{ - unsigned state; - Byte control; - Byte needInitLevel; - Byte isExtraMode; - Byte _pad_; - UInt32 packSize; - UInt32 unpackSize; - CLzmaDec decoder; -} CLzma2Dec; - -#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) -#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc) -#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc) - -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); -SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); -void Lzma2Dec_Init(CLzma2Dec *p); - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen or dicLimit). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_NEEDS_MORE_INPUT - SZ_ERROR_DATA - Data error -*/ - -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- LZMA2 block and chunk parsing ---------- */ - -/* -Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data. -It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code: - - LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input. - - LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read. - CLzma2Dec::unpackSize contains unpack size of that chunk -*/ - -typedef enum -{ -/* - LZMA_STATUS_NOT_SPECIFIED // data error - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED // - LZMA_STATUS_NEEDS_MORE_INPUT - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused -*/ - LZMA2_PARSE_STATUS_NEW_BLOCK = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + 1, - LZMA2_PARSE_STATUS_NEW_CHUNK -} ELzma2ParseStatus; - -ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, - SizeT outSize, // output size - const Byte *src, SizeT *srcLen, - int checkFinishBlock // set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position. - ); - -/* -LZMA2 parser doesn't decode LZMA chunks, so we must read - full input LZMA chunk to decode some part of LZMA chunk. - -Lzma2Dec_GetUnpackExtra() returns the value that shows - max possible number of output bytes that can be output by decoder - at current input positon. -*/ - -#define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0); - - -/* ---------- One Call Interface ---------- */ - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). -*/ - -SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc); - -EXTERN_C_END - -#endif +/* Lzma2Dec.h -- LZMA2 Decoder +2018-02-19 : Igor Pavlov : Public domain */ + +#ifndef __LZMA2_DEC_H +#define __LZMA2_DEC_H + +#include "LzmaDec.h" + +EXTERN_C_BEGIN + +/* ---------- State Interface ---------- */ + +typedef struct +{ + unsigned state; + Byte control; + Byte needInitLevel; + Byte isExtraMode; + Byte _pad_; + UInt32 packSize; + UInt32 unpackSize; + CLzmaDec decoder; +} CLzma2Dec; + +#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) +#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc) +#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc) + +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); +SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAllocPtr alloc); +void Lzma2Dec_Init(CLzma2Dec *p); + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen or dicLimit). + LZMA_FINISH_ANY - use smallest number of input bytes + LZMA_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_NEEDS_MORE_INPUT + SZ_ERROR_DATA - Data error +*/ + +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- LZMA2 block and chunk parsing ---------- */ + +/* +Lzma2Dec_Parse() parses compressed data stream up to next independent block or next chunk data. +It can return LZMA_STATUS_* code or LZMA2_PARSE_STATUS_* code: + - LZMA2_PARSE_STATUS_NEW_BLOCK - there is new block, and 1 additional byte (control byte of next block header) was read from input. + - LZMA2_PARSE_STATUS_NEW_CHUNK - there is new chunk, and only lzma2 header of new chunk was read. + CLzma2Dec::unpackSize contains unpack size of that chunk +*/ + +typedef enum +{ +/* + LZMA_STATUS_NOT_SPECIFIED // data error + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED // + LZMA_STATUS_NEEDS_MORE_INPUT + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK // unused +*/ + LZMA2_PARSE_STATUS_NEW_BLOCK = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + 1, + LZMA2_PARSE_STATUS_NEW_CHUNK +} ELzma2ParseStatus; + +ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p, + SizeT outSize, // output size + const Byte *src, SizeT *srcLen, + int checkFinishBlock // set (checkFinishBlock = 1), if it must read full input data, if decoder.dicPos reaches blockMax position. + ); + +/* +LZMA2 parser doesn't decode LZMA chunks, so we must read + full input LZMA chunk to decode some part of LZMA chunk. + +Lzma2Dec_GetUnpackExtra() returns the value that shows + max possible number of output bytes that can be output by decoder + at current input positon. +*/ + +#define Lzma2Dec_GetUnpackExtra(p) ((p)->isExtraMode ? (p)->unpackSize : 0); + + +/* ---------- One Call Interface ---------- */ + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - use smallest number of input bytes + LZMA_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). +*/ + +SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAllocPtr alloc); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Lzma2DecMt.c b/deps/LZMA-SDK/C/Lzma2DecMt.c index 252b5be49..9f1dc52ba 100644 --- a/deps/LZMA-SDK/C/Lzma2DecMt.c +++ b/deps/LZMA-SDK/C/Lzma2DecMt.c @@ -1,1090 +1,1090 @@ -/* Lzma2DecMt.c -- LZMA2 Decoder Multi-thread -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -// #define SHOW_DEBUG_INFO - -// #define _7ZIP_ST - -#ifdef SHOW_DEBUG_INFO -#include -#endif - -#ifndef _7ZIP_ST -#ifdef SHOW_DEBUG_INFO -#define PRF(x) x -#else -#define PRF(x) -#endif -#define PRF_STR(s) PRF(printf("\n" s "\n")) -#define PRF_STR_INT_2(s, d1, d2) PRF(printf("\n" s " %d %d\n", (unsigned)d1, (unsigned)d2)) -#endif - -#include "Alloc.h" - -#include "Lzma2Dec.h" -#include "Lzma2DecMt.h" - -#ifndef _7ZIP_ST -#include "MtDec.h" - -#define LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT (1 << 28) -#endif - - -void Lzma2DecMtProps_Init(CLzma2DecMtProps *p) -{ - p->inBufSize_ST = 1 << 20; - p->outStep_ST = 1 << 20; - - #ifndef _7ZIP_ST - p->numThreads = 1; - p->inBufSize_MT = 1 << 18; - p->outBlockMax = LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT; - p->inBlockMax = p->outBlockMax + p->outBlockMax / 16; - #endif -} - - - -#ifndef _7ZIP_ST - -/* ---------- CLzma2DecMtThread ---------- */ - -typedef struct -{ - CLzma2Dec dec; - Byte dec_created; - Byte needInit; - - Byte *outBuf; - size_t outBufSize; - - EMtDecParseState state; - ELzma2ParseStatus parseStatus; - - size_t inPreSize; - size_t outPreSize; - - size_t inCodeSize; - size_t outCodeSize; - SRes codeRes; - - CAlignOffsetAlloc alloc; - - Byte mtPad[1 << 7]; -} CLzma2DecMtThread; - -#endif - - -/* ---------- CLzma2DecMt ---------- */ - -typedef struct -{ - // ISzAllocPtr alloc; - ISzAllocPtr allocMid; - - CAlignOffsetAlloc alignOffsetAlloc; - CLzma2DecMtProps props; - Byte prop; - - ISeqInStream *inStream; - ISeqOutStream *outStream; - ICompressProgress *progress; - - BoolInt finishMode; - BoolInt outSize_Defined; - UInt64 outSize; - - UInt64 outProcessed; - UInt64 inProcessed; - BoolInt readWasFinished; - SRes readRes; - - Byte *inBuf; - size_t inBufSize; - Byte dec_created; - CLzma2Dec dec; - - size_t inPos; - size_t inLim; - - #ifndef _7ZIP_ST - UInt64 outProcessed_Parse; - BoolInt mtc_WasConstructed; - CMtDec mtc; - CLzma2DecMtThread coders[MTDEC__THREADS_MAX]; - #endif - -} CLzma2DecMt; - - - -CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid) -{ - CLzma2DecMt *p = (CLzma2DecMt *)ISzAlloc_Alloc(alloc, sizeof(CLzma2DecMt)); - if (!p) - return NULL; - - // p->alloc = alloc; - p->allocMid = allocMid; - - AlignOffsetAlloc_CreateVTable(&p->alignOffsetAlloc); - p->alignOffsetAlloc.numAlignBits = 7; - p->alignOffsetAlloc.offset = 0; - p->alignOffsetAlloc.baseAlloc = alloc; - - p->inBuf = NULL; - p->inBufSize = 0; - p->dec_created = False; - - // Lzma2DecMtProps_Init(&p->props); - - #ifndef _7ZIP_ST - p->mtc_WasConstructed = False; - { - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CLzma2DecMtThread *t = &p->coders[i]; - t->dec_created = False; - t->outBuf = NULL; - t->outBufSize = 0; - } - } - #endif - - return p; -} - - -#ifndef _7ZIP_ST - -static void Lzma2DecMt_FreeOutBufs(CLzma2DecMt *p) -{ - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CLzma2DecMtThread *t = &p->coders[i]; - if (t->outBuf) - { - ISzAlloc_Free(p->allocMid, t->outBuf); - t->outBuf = NULL; - t->outBufSize = 0; - } - } -} - -#endif - - -static void Lzma2DecMt_FreeSt(CLzma2DecMt *p) -{ - if (p->dec_created) - { - Lzma2Dec_Free(&p->dec, &p->alignOffsetAlloc.vt); - p->dec_created = False; - } - if (p->inBuf) - { - ISzAlloc_Free(p->allocMid, p->inBuf); - p->inBuf = NULL; - } - p->inBufSize = 0; -} - - -void Lzma2DecMt_Destroy(CLzma2DecMtHandle pp) -{ - CLzma2DecMt *p = (CLzma2DecMt *)pp; - - Lzma2DecMt_FreeSt(p); - - #ifndef _7ZIP_ST - - if (p->mtc_WasConstructed) - { - MtDec_Destruct(&p->mtc); - p->mtc_WasConstructed = False; - } - { - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CLzma2DecMtThread *t = &p->coders[i]; - if (t->dec_created) - { - // we don't need to free dict here - Lzma2Dec_FreeProbs(&t->dec, &t->alloc.vt); // p->alloc !!! - t->dec_created = False; - } - } - } - Lzma2DecMt_FreeOutBufs(p); - - #endif - - ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); -} - - - -#ifndef _7ZIP_ST - -static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc) -{ - CLzma2DecMt *me = (CLzma2DecMt *)obj; - CLzma2DecMtThread *t = &me->coders[coderIndex]; - - PRF_STR_INT_2("Parse", coderIndex, cc->srcSize); - - cc->state = MTDEC_PARSE_CONTINUE; - - if (cc->startCall) - { - if (!t->dec_created) - { - Lzma2Dec_Construct(&t->dec); - t->dec_created = True; - AlignOffsetAlloc_CreateVTable(&t->alloc); - { - /* (1 << 12) is expected size of one way in data cache. - We optimize alignment for cache line size of 128 bytes and smaller */ - const unsigned kNumAlignBits = 12; - const unsigned kNumCacheLineBits = 7; /* <= kNumAlignBits */ - t->alloc.numAlignBits = kNumAlignBits; - t->alloc.offset = ((UInt32)coderIndex * (((unsigned)1 << 11) + (1 << 8) + (1 << 6))) & (((unsigned)1 << kNumAlignBits) - ((unsigned)1 << kNumCacheLineBits)); - t->alloc.baseAlloc = me->alignOffsetAlloc.baseAlloc; - } - } - Lzma2Dec_Init(&t->dec); - - t->inPreSize = 0; - t->outPreSize = 0; - // t->blockWasFinished = False; - // t->finishedWithMark = False; - t->parseStatus = (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED; - t->state = MTDEC_PARSE_CONTINUE; - - t->inCodeSize = 0; - t->outCodeSize = 0; - t->codeRes = SZ_OK; - - // (cc->srcSize == 0) is allowed - } - - { - ELzma2ParseStatus status; - BoolInt overflow; - UInt32 unpackRem = 0; - - int checkFinishBlock = True; - size_t limit = me->props.outBlockMax; - if (me->outSize_Defined) - { - UInt64 rem = me->outSize - me->outProcessed_Parse; - if (limit >= rem) - { - limit = (size_t)rem; - if (!me->finishMode) - checkFinishBlock = False; - } - } - - // checkFinishBlock = False, if we want to decode partial data - // that must be finished at position <= outBlockMax. - - { - const SizeT srcOrig = cc->srcSize; - SizeT srcSize_Point = 0; - SizeT dicPos_Point = 0; - - cc->srcSize = 0; - overflow = False; - - for (;;) - { - SizeT srcCur = srcOrig - cc->srcSize; - - status = Lzma2Dec_Parse(&t->dec, - limit - t->dec.decoder.dicPos, - cc->src + cc->srcSize, &srcCur, - checkFinishBlock); - - cc->srcSize += srcCur; - - if (status == LZMA2_PARSE_STATUS_NEW_CHUNK) - { - if (t->dec.unpackSize > me->props.outBlockMax - t->dec.decoder.dicPos) - { - overflow = True; - break; - } - continue; - } - - if (status == LZMA2_PARSE_STATUS_NEW_BLOCK) - { - if (t->dec.decoder.dicPos == 0) - continue; - // we decode small blocks in one thread - if (t->dec.decoder.dicPos >= (1 << 14)) - break; - dicPos_Point = t->dec.decoder.dicPos; - srcSize_Point = cc->srcSize; - continue; - } - - if ((int)status == LZMA_STATUS_NOT_FINISHED && checkFinishBlock - // && limit == t->dec.decoder.dicPos - // && limit == me->props.outBlockMax - ) - { - overflow = True; - break; - } - - unpackRem = Lzma2Dec_GetUnpackExtra(&t->dec); - break; - } - - if (dicPos_Point != 0 - && (int)status != LZMA2_PARSE_STATUS_NEW_BLOCK - && (int)status != LZMA_STATUS_FINISHED_WITH_MARK - && (int)status != LZMA_STATUS_NOT_SPECIFIED) - { - // we revert to latest newBlock state - status = LZMA2_PARSE_STATUS_NEW_BLOCK; - unpackRem = 0; - t->dec.decoder.dicPos = dicPos_Point; - cc->srcSize = srcSize_Point; - overflow = False; - } - } - - t->inPreSize += cc->srcSize; - t->parseStatus = status; - - if (overflow) - cc->state = MTDEC_PARSE_OVERFLOW; - else - { - size_t dicPos = t->dec.decoder.dicPos; - - if ((int)status != LZMA_STATUS_NEEDS_MORE_INPUT) - { - if (status == LZMA2_PARSE_STATUS_NEW_BLOCK) - { - cc->state = MTDEC_PARSE_NEW; - cc->srcSize--; // we don't need control byte of next block - t->inPreSize--; - } - else - { - cc->state = MTDEC_PARSE_END; - if ((int)status != LZMA_STATUS_FINISHED_WITH_MARK) - { - // (status == LZMA_STATUS_NOT_SPECIFIED) - // (status == LZMA_STATUS_NOT_FINISHED) - if (unpackRem != 0) - { - /* we also reserve space for max possible number of output bytes of current LZMA chunk */ - SizeT rem = limit - dicPos; - if (rem > unpackRem) - rem = unpackRem; - dicPos += rem; - } - } - } - - me->outProcessed_Parse += dicPos; - } - - cc->outPos = dicPos; - t->outPreSize = (size_t)dicPos; - } - - t->state = cc->state; - return; - } -} - - -static SRes Lzma2DecMt_MtCallback_PreCode(void *pp, unsigned coderIndex) -{ - CLzma2DecMt *me = (CLzma2DecMt *)pp; - CLzma2DecMtThread *t = &me->coders[coderIndex]; - Byte *dest = t->outBuf; - - if (t->inPreSize == 0) - { - t->codeRes = SZ_ERROR_DATA; - return t->codeRes; - } - - if (!dest || t->outBufSize < t->outPreSize) - { - if (dest) - { - ISzAlloc_Free(me->allocMid, dest); - t->outBuf = NULL; - t->outBufSize = 0; - } - - dest = (Byte *)ISzAlloc_Alloc(me->allocMid, t->outPreSize - // + (1 << 28) - ); - // Sleep(200); - if (!dest) - return SZ_ERROR_MEM; - t->outBuf = dest; - t->outBufSize = t->outPreSize; - } - - t->dec.decoder.dic = dest; - t->dec.decoder.dicBufSize = t->outPreSize; - - t->needInit = True; - - return Lzma2Dec_AllocateProbs(&t->dec, me->prop, &t->alloc.vt); // alloc.vt -} - - -static SRes Lzma2DecMt_MtCallback_Code(void *pp, unsigned coderIndex, - const Byte *src, size_t srcSize, int srcFinished, - // int finished, int blockFinished, - UInt64 *inCodePos, UInt64 *outCodePos, int *stop) -{ - CLzma2DecMt *me = (CLzma2DecMt *)pp; - CLzma2DecMtThread *t = &me->coders[coderIndex]; - - UNUSED_VAR(srcFinished) - - PRF_STR_INT_2("Code", coderIndex, srcSize); - - *inCodePos = t->inCodeSize; - *outCodePos = 0; - *stop = True; - - if (t->needInit) - { - Lzma2Dec_Init(&t->dec); - t->needInit = False; - } - - { - ELzmaStatus status; - size_t srcProcessed = srcSize; - BoolInt blockWasFinished = - ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK - || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK); - - SRes res = Lzma2Dec_DecodeToDic(&t->dec, - t->outPreSize, - src, &srcProcessed, - blockWasFinished ? LZMA_FINISH_END : LZMA_FINISH_ANY, - &status); - - t->codeRes = res; - - t->inCodeSize += srcProcessed; - *inCodePos = t->inCodeSize; - t->outCodeSize = t->dec.decoder.dicPos; - *outCodePos = t->dec.decoder.dicPos; - - if (res != SZ_OK) - return res; - - if (srcProcessed == srcSize) - *stop = False; - - if (blockWasFinished) - { - if (srcSize != srcProcessed) - return SZ_ERROR_FAIL; - - if (t->inPreSize == t->inCodeSize) - { - if (t->outPreSize != t->outCodeSize) - return SZ_ERROR_FAIL; - *stop = True; - } - } - else - { - if (t->outPreSize == t->outCodeSize) - *stop = True; - } - - return SZ_OK; - } -} - - -#define LZMA2DECMT_STREAM_WRITE_STEP (1 << 24) - -static SRes Lzma2DecMt_MtCallback_Write(void *pp, unsigned coderIndex, - BoolInt needWriteToStream, - const Byte *src, size_t srcSize, BoolInt isCross, - BoolInt *needContinue, BoolInt *canRecode) -{ - CLzma2DecMt *me = (CLzma2DecMt *)pp; - const CLzma2DecMtThread *t = &me->coders[coderIndex]; - size_t size = t->outCodeSize; - const Byte *data = t->outBuf; - BoolInt needContinue2 = True; - - UNUSED_VAR(src) - UNUSED_VAR(srcSize) - UNUSED_VAR(isCross) - - PRF_STR_INT_2("Write", coderIndex, srcSize); - - *needContinue = False; - *canRecode = True; - - if ( - // t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK - t->state == MTDEC_PARSE_OVERFLOW - || t->state == MTDEC_PARSE_END) - needContinue2 = False; - - - if (!needWriteToStream) - return SZ_OK; - - me->mtc.inProcessed += t->inCodeSize; - - if (t->codeRes == SZ_OK) - if ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK - || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK) - if (t->outPreSize != t->outCodeSize - || t->inPreSize != t->inCodeSize) - return SZ_ERROR_FAIL; - - *canRecode = False; - - if (me->outStream) - { - for (;;) - { - size_t cur = size; - size_t written; - if (cur > LZMA2DECMT_STREAM_WRITE_STEP) - cur = LZMA2DECMT_STREAM_WRITE_STEP; - - written = ISeqOutStream_Write(me->outStream, data, cur); - - me->outProcessed += written; - // me->mtc.writtenTotal += written; - if (written != cur) - return SZ_ERROR_WRITE; - data += cur; - size -= cur; - if (size == 0) - { - *needContinue = needContinue2; - return SZ_OK; - } - RINOK(MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0)); - } - } - - return SZ_ERROR_FAIL; - /* - if (size > me->outBufSize) - return SZ_ERROR_OUTPUT_EOF; - memcpy(me->outBuf, data, size); - me->outBufSize -= size; - me->outBuf += size; - *needContinue = needContinue2; - return SZ_OK; - */ -} - -#endif - - -static SRes Lzma2Dec_Prepare_ST(CLzma2DecMt *p) -{ - if (!p->dec_created) - { - Lzma2Dec_Construct(&p->dec); - p->dec_created = True; - } - - RINOK(Lzma2Dec_Allocate(&p->dec, p->prop, &p->alignOffsetAlloc.vt)); - - if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) - { - ISzAlloc_Free(p->allocMid, p->inBuf); - p->inBufSize = 0; - p->inBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.inBufSize_ST); - if (!p->inBuf) - return SZ_ERROR_MEM; - p->inBufSize = p->props.inBufSize_ST; - } - - Lzma2Dec_Init(&p->dec); - - return SZ_OK; -} - - -static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p - #ifndef _7ZIP_ST - , BoolInt tMode - #endif - ) -{ - SizeT wrPos; - size_t inPos, inLim; - const Byte *inData; - UInt64 inPrev, outPrev; - - CLzma2Dec *dec; - - #ifndef _7ZIP_ST - if (tMode) - { - Lzma2DecMt_FreeOutBufs(p); - tMode = MtDec_PrepareRead(&p->mtc); - } - #endif - - RINOK(Lzma2Dec_Prepare_ST(p)); - - dec = &p->dec; - - inPrev = p->inProcessed; - outPrev = p->outProcessed; - - inPos = 0; - inLim = 0; - inData = NULL; - wrPos = dec->decoder.dicPos; - - for (;;) - { - SizeT dicPos; - SizeT size; - ELzmaFinishMode finishMode; - SizeT inProcessed; - ELzmaStatus status; - SRes res; - - SizeT outProcessed; - BoolInt outFinished; - BoolInt needStop; - - if (inPos == inLim) - { - #ifndef _7ZIP_ST - if (tMode) - { - inData = MtDec_Read(&p->mtc, &inLim); - inPos = 0; - if (inData) - continue; - tMode = False; - inLim = 0; - } - #endif - - if (!p->readWasFinished) - { - inPos = 0; - inLim = p->inBufSize; - inData = p->inBuf; - p->readRes = ISeqInStream_Read(p->inStream, (void *)(p->inBuf), &inLim); - // p->readProcessed += inLim; - // inLim -= 5; p->readWasFinished = True; // for test - if (inLim == 0 || p->readRes != SZ_OK) - p->readWasFinished = True; - } - } - - dicPos = dec->decoder.dicPos; - { - SizeT next = dec->decoder.dicBufSize; - if (next - wrPos > p->props.outStep_ST) - next = wrPos + p->props.outStep_ST; - size = next - dicPos; - } - - finishMode = LZMA_FINISH_ANY; - if (p->outSize_Defined) - { - const UInt64 rem = p->outSize - p->outProcessed; - if (size >= rem) - { - size = (SizeT)rem; - if (p->finishMode) - finishMode = LZMA_FINISH_END; - } - } - - inProcessed = inLim - inPos; - - res = Lzma2Dec_DecodeToDic(dec, dicPos + size, inData + inPos, &inProcessed, finishMode, &status); - - inPos += inProcessed; - p->inProcessed += inProcessed; - outProcessed = dec->decoder.dicPos - dicPos; - p->outProcessed += outProcessed; - - outFinished = (p->outSize_Defined && p->outSize <= p->outProcessed); - - needStop = (res != SZ_OK - || (inProcessed == 0 && outProcessed == 0) - || status == LZMA_STATUS_FINISHED_WITH_MARK - || (!p->finishMode && outFinished)); - - if (needStop || outProcessed >= size) - { - SRes res2; - { - size_t writeSize = dec->decoder.dicPos - wrPos; - size_t written = ISeqOutStream_Write(p->outStream, dec->decoder.dic + wrPos, writeSize); - res2 = (written == writeSize) ? SZ_OK : SZ_ERROR_WRITE; - } - - if (dec->decoder.dicPos == dec->decoder.dicBufSize) - dec->decoder.dicPos = 0; - wrPos = dec->decoder.dicPos; - - RINOK(res2); - - if (needStop) - { - if (res != SZ_OK) - return res; - - if (status == LZMA_STATUS_FINISHED_WITH_MARK) - { - if (p->finishMode) - { - if (p->outSize_Defined && p->outSize != p->outProcessed) - return SZ_ERROR_DATA; - } - return SZ_OK; - } - - if (!p->finishMode && outFinished) - return SZ_OK; - - if (status == LZMA_STATUS_NEEDS_MORE_INPUT) - return SZ_ERROR_INPUT_EOF; - - return SZ_ERROR_DATA; - } - } - - if (p->progress) - { - UInt64 inDelta = p->inProcessed - inPrev; - UInt64 outDelta = p->outProcessed - outPrev; - if (inDelta >= (1 << 22) || outDelta >= (1 << 22)) - { - RINOK(ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed)); - inPrev = p->inProcessed; - outPrev = p->outProcessed; - } - } - } -} - - - -SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp, - Byte prop, - const CLzma2DecMtProps *props, - ISeqOutStream *outStream, const UInt64 *outDataSize, int finishMode, - // Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - // const Byte *inData, size_t inDataSize, - UInt64 *inProcessed, - // UInt64 *outProcessed, - int *isMT, - ICompressProgress *progress) -{ - CLzma2DecMt *p = (CLzma2DecMt *)pp; - #ifndef _7ZIP_ST - BoolInt tMode; - #endif - - *inProcessed = 0; - - if (prop > 40) - return SZ_ERROR_UNSUPPORTED; - - p->prop = prop; - p->props = *props; - - p->inStream = inStream; - p->outStream = outStream; - p->progress = progress; - - p->outSize = 0; - p->outSize_Defined = False; - if (outDataSize) - { - p->outSize_Defined = True; - p->outSize = *outDataSize; - } - p->finishMode = finishMode; - - p->outProcessed = 0; - p->inProcessed = 0; - - p->readWasFinished = False; - p->readRes = SZ_OK; - - *isMT = False; - - - #ifndef _7ZIP_ST - - tMode = False; - - // p->mtc.parseRes = SZ_OK; - - // p->mtc.numFilledThreads = 0; - // p->mtc.crossStart = 0; - // p->mtc.crossEnd = 0; - // p->mtc.allocError_for_Read_BlockIndex = 0; - // p->mtc.isAllocError = False; - - if (p->props.numThreads > 1) - { - IMtDecCallback2 vt; - - Lzma2DecMt_FreeSt(p); - - p->outProcessed_Parse = 0; - - if (!p->mtc_WasConstructed) - { - p->mtc_WasConstructed = True; - MtDec_Construct(&p->mtc); - } - - p->mtc.progress = progress; - p->mtc.inStream = inStream; - - // p->outBuf = NULL; - // p->outBufSize = 0; - /* - if (!outStream) - { - // p->outBuf = outBuf; - // p->outBufSize = *outBufSize; - // *outBufSize = 0; - return SZ_ERROR_PARAM; - } - */ - - // p->mtc.inBlockMax = p->props.inBlockMax; - p->mtc.alloc = &p->alignOffsetAlloc.vt; - // p->alignOffsetAlloc.baseAlloc; - // p->mtc.inData = inData; - // p->mtc.inDataSize = inDataSize; - p->mtc.mtCallback = &vt; - p->mtc.mtCallbackObject = p; - - p->mtc.inBufSize = p->props.inBufSize_MT; - - p->mtc.numThreadsMax = p->props.numThreads; - - *isMT = True; - - vt.Parse = Lzma2DecMt_MtCallback_Parse; - vt.PreCode = Lzma2DecMt_MtCallback_PreCode; - vt.Code = Lzma2DecMt_MtCallback_Code; - vt.Write = Lzma2DecMt_MtCallback_Write; - - { - BoolInt needContinue = False; - - SRes res = MtDec_Code(&p->mtc); - - /* - if (!outStream) - *outBufSize = p->outBuf - outBuf; - */ - - *inProcessed = p->mtc.inProcessed; - - needContinue = False; - - if (res == SZ_OK) - { - if (p->mtc.mtProgress.res != SZ_OK) - res = p->mtc.mtProgress.res; - else - needContinue = p->mtc.needContinue; - } - - if (!needContinue) - { - if (res == SZ_OK) - return p->mtc.readRes; - return res; - } - - tMode = True; - p->readRes = p->mtc.readRes; - p->readWasFinished = p->mtc.readWasFinished; - p->inProcessed = p->mtc.inProcessed; - - PRF_STR("----- decoding ST -----"); - } - } - - #endif - - - *isMT = False; - - { - SRes res = Lzma2Dec_Decode_ST(p - #ifndef _7ZIP_ST - , tMode - #endif - ); - - *inProcessed = p->inProcessed; - - // res = SZ_OK; // for test - if (res == SZ_ERROR_INPUT_EOF) - { - if (p->readRes != SZ_OK) - res = p->readRes; - } - else if (res == SZ_OK && p->readRes != SZ_OK) - res = p->readRes; - - /* - #ifndef _7ZIP_ST - if (res == SZ_OK && tMode && p->mtc.parseRes != SZ_OK) - res = p->mtc.parseRes; - #endif - */ - - return res; - } -} - - -/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ - -SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, - Byte prop, - const CLzma2DecMtProps *props, - const UInt64 *outDataSize, int finishMode, - ISeqInStream *inStream) -{ - CLzma2DecMt *p = (CLzma2DecMt *)pp; - - if (prop > 40) - return SZ_ERROR_UNSUPPORTED; - - p->prop = prop; - p->props = *props; - - p->inStream = inStream; - - p->outSize = 0; - p->outSize_Defined = False; - if (outDataSize) - { - p->outSize_Defined = True; - p->outSize = *outDataSize; - } - p->finishMode = finishMode; - - p->outProcessed = 0; - p->inProcessed = 0; - - p->inPos = 0; - p->inLim = 0; - - return Lzma2Dec_Prepare_ST(p); -} - - -SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, - Byte *data, size_t *outSize, - UInt64 *inStreamProcessed) -{ - CLzma2DecMt *p = (CLzma2DecMt *)pp; - ELzmaFinishMode finishMode; - SRes readRes; - size_t size = *outSize; - - *outSize = 0; - *inStreamProcessed = 0; - - finishMode = LZMA_FINISH_ANY; - if (p->outSize_Defined) - { - const UInt64 rem = p->outSize - p->outProcessed; - if (size >= rem) - { - size = (size_t)rem; - if (p->finishMode) - finishMode = LZMA_FINISH_END; - } - } - - readRes = SZ_OK; - - for (;;) - { - SizeT inCur; - SizeT outCur; - ELzmaStatus status; - SRes res; - - if (p->inPos == p->inLim && readRes == SZ_OK) - { - p->inPos = 0; - p->inLim = p->props.inBufSize_ST; - readRes = ISeqInStream_Read(p->inStream, p->inBuf, &p->inLim); - } - - inCur = p->inLim - p->inPos; - outCur = size; - - res = Lzma2Dec_DecodeToBuf(&p->dec, data, &outCur, - p->inBuf + p->inPos, &inCur, finishMode, &status); - - p->inPos += inCur; - p->inProcessed += inCur; - *inStreamProcessed += inCur; - p->outProcessed += outCur; - *outSize += outCur; - size -= outCur; - data += outCur; - - if (res != 0) - return res; - - /* - if (status == LZMA_STATUS_FINISHED_WITH_MARK) - return readRes; - - if (size == 0 && status != LZMA_STATUS_NEEDS_MORE_INPUT) - { - if (p->finishMode && p->outSize_Defined && p->outProcessed >= p->outSize) - return SZ_ERROR_DATA; - return readRes; - } - */ - - if (inCur == 0 && outCur == 0) - return readRes; - } -} +/* Lzma2DecMt.c -- LZMA2 Decoder Multi-thread +2021-04-01 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +// #define SHOW_DEBUG_INFO + +// #define _7ZIP_ST + +#ifdef SHOW_DEBUG_INFO +#include +#endif + +#ifndef _7ZIP_ST +#ifdef SHOW_DEBUG_INFO +#define PRF(x) x +#else +#define PRF(x) +#endif +#define PRF_STR(s) PRF(printf("\n" s "\n")) +#define PRF_STR_INT_2(s, d1, d2) PRF(printf("\n" s " %d %d\n", (unsigned)d1, (unsigned)d2)) +#endif + +#include "Alloc.h" + +#include "Lzma2Dec.h" +#include "Lzma2DecMt.h" + +#ifndef _7ZIP_ST +#include "MtDec.h" + +#define LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT (1 << 28) +#endif + + +void Lzma2DecMtProps_Init(CLzma2DecMtProps *p) +{ + p->inBufSize_ST = 1 << 20; + p->outStep_ST = 1 << 20; + + #ifndef _7ZIP_ST + p->numThreads = 1; + p->inBufSize_MT = 1 << 18; + p->outBlockMax = LZMA2DECMT_OUT_BLOCK_MAX_DEFAULT; + p->inBlockMax = p->outBlockMax + p->outBlockMax / 16; + #endif +} + + + +#ifndef _7ZIP_ST + +/* ---------- CLzma2DecMtThread ---------- */ + +typedef struct +{ + CLzma2Dec dec; + Byte dec_created; + Byte needInit; + + Byte *outBuf; + size_t outBufSize; + + EMtDecParseState state; + ELzma2ParseStatus parseStatus; + + size_t inPreSize; + size_t outPreSize; + + size_t inCodeSize; + size_t outCodeSize; + SRes codeRes; + + CAlignOffsetAlloc alloc; + + Byte mtPad[1 << 7]; +} CLzma2DecMtThread; + +#endif + + +/* ---------- CLzma2DecMt ---------- */ + +typedef struct +{ + // ISzAllocPtr alloc; + ISzAllocPtr allocMid; + + CAlignOffsetAlloc alignOffsetAlloc; + CLzma2DecMtProps props; + Byte prop; + + ISeqInStream *inStream; + ISeqOutStream *outStream; + ICompressProgress *progress; + + BoolInt finishMode; + BoolInt outSize_Defined; + UInt64 outSize; + + UInt64 outProcessed; + UInt64 inProcessed; + BoolInt readWasFinished; + SRes readRes; + + Byte *inBuf; + size_t inBufSize; + Byte dec_created; + CLzma2Dec dec; + + size_t inPos; + size_t inLim; + + #ifndef _7ZIP_ST + UInt64 outProcessed_Parse; + BoolInt mtc_WasConstructed; + CMtDec mtc; + CLzma2DecMtThread coders[MTDEC__THREADS_MAX]; + #endif + +} CLzma2DecMt; + + + +CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid) +{ + CLzma2DecMt *p = (CLzma2DecMt *)ISzAlloc_Alloc(alloc, sizeof(CLzma2DecMt)); + if (!p) + return NULL; + + // p->alloc = alloc; + p->allocMid = allocMid; + + AlignOffsetAlloc_CreateVTable(&p->alignOffsetAlloc); + p->alignOffsetAlloc.numAlignBits = 7; + p->alignOffsetAlloc.offset = 0; + p->alignOffsetAlloc.baseAlloc = alloc; + + p->inBuf = NULL; + p->inBufSize = 0; + p->dec_created = False; + + // Lzma2DecMtProps_Init(&p->props); + + #ifndef _7ZIP_ST + p->mtc_WasConstructed = False; + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CLzma2DecMtThread *t = &p->coders[i]; + t->dec_created = False; + t->outBuf = NULL; + t->outBufSize = 0; + } + } + #endif + + return p; +} + + +#ifndef _7ZIP_ST + +static void Lzma2DecMt_FreeOutBufs(CLzma2DecMt *p) +{ + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CLzma2DecMtThread *t = &p->coders[i]; + if (t->outBuf) + { + ISzAlloc_Free(p->allocMid, t->outBuf); + t->outBuf = NULL; + t->outBufSize = 0; + } + } +} + +#endif + + +static void Lzma2DecMt_FreeSt(CLzma2DecMt *p) +{ + if (p->dec_created) + { + Lzma2Dec_Free(&p->dec, &p->alignOffsetAlloc.vt); + p->dec_created = False; + } + if (p->inBuf) + { + ISzAlloc_Free(p->allocMid, p->inBuf); + p->inBuf = NULL; + } + p->inBufSize = 0; +} + + +void Lzma2DecMt_Destroy(CLzma2DecMtHandle pp) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + + Lzma2DecMt_FreeSt(p); + + #ifndef _7ZIP_ST + + if (p->mtc_WasConstructed) + { + MtDec_Destruct(&p->mtc); + p->mtc_WasConstructed = False; + } + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CLzma2DecMtThread *t = &p->coders[i]; + if (t->dec_created) + { + // we don't need to free dict here + Lzma2Dec_FreeProbs(&t->dec, &t->alloc.vt); // p->alloc !!! + t->dec_created = False; + } + } + } + Lzma2DecMt_FreeOutBufs(p); + + #endif + + ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); +} + + + +#ifndef _7ZIP_ST + +static void Lzma2DecMt_MtCallback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc) +{ + CLzma2DecMt *me = (CLzma2DecMt *)obj; + CLzma2DecMtThread *t = &me->coders[coderIndex]; + + PRF_STR_INT_2("Parse", coderIndex, cc->srcSize); + + cc->state = MTDEC_PARSE_CONTINUE; + + if (cc->startCall) + { + if (!t->dec_created) + { + Lzma2Dec_Construct(&t->dec); + t->dec_created = True; + AlignOffsetAlloc_CreateVTable(&t->alloc); + { + /* (1 << 12) is expected size of one way in data cache. + We optimize alignment for cache line size of 128 bytes and smaller */ + const unsigned kNumAlignBits = 12; + const unsigned kNumCacheLineBits = 7; /* <= kNumAlignBits */ + t->alloc.numAlignBits = kNumAlignBits; + t->alloc.offset = ((UInt32)coderIndex * (((unsigned)1 << 11) + (1 << 8) + (1 << 6))) & (((unsigned)1 << kNumAlignBits) - ((unsigned)1 << kNumCacheLineBits)); + t->alloc.baseAlloc = me->alignOffsetAlloc.baseAlloc; + } + } + Lzma2Dec_Init(&t->dec); + + t->inPreSize = 0; + t->outPreSize = 0; + // t->blockWasFinished = False; + // t->finishedWithMark = False; + t->parseStatus = (ELzma2ParseStatus)LZMA_STATUS_NOT_SPECIFIED; + t->state = MTDEC_PARSE_CONTINUE; + + t->inCodeSize = 0; + t->outCodeSize = 0; + t->codeRes = SZ_OK; + + // (cc->srcSize == 0) is allowed + } + + { + ELzma2ParseStatus status; + BoolInt overflow; + UInt32 unpackRem = 0; + + int checkFinishBlock = True; + size_t limit = me->props.outBlockMax; + if (me->outSize_Defined) + { + UInt64 rem = me->outSize - me->outProcessed_Parse; + if (limit >= rem) + { + limit = (size_t)rem; + if (!me->finishMode) + checkFinishBlock = False; + } + } + + // checkFinishBlock = False, if we want to decode partial data + // that must be finished at position <= outBlockMax. + + { + const SizeT srcOrig = cc->srcSize; + SizeT srcSize_Point = 0; + SizeT dicPos_Point = 0; + + cc->srcSize = 0; + overflow = False; + + for (;;) + { + SizeT srcCur = srcOrig - cc->srcSize; + + status = Lzma2Dec_Parse(&t->dec, + limit - t->dec.decoder.dicPos, + cc->src + cc->srcSize, &srcCur, + checkFinishBlock); + + cc->srcSize += srcCur; + + if (status == LZMA2_PARSE_STATUS_NEW_CHUNK) + { + if (t->dec.unpackSize > me->props.outBlockMax - t->dec.decoder.dicPos) + { + overflow = True; + break; + } + continue; + } + + if (status == LZMA2_PARSE_STATUS_NEW_BLOCK) + { + if (t->dec.decoder.dicPos == 0) + continue; + // we decode small blocks in one thread + if (t->dec.decoder.dicPos >= (1 << 14)) + break; + dicPos_Point = t->dec.decoder.dicPos; + srcSize_Point = cc->srcSize; + continue; + } + + if ((int)status == LZMA_STATUS_NOT_FINISHED && checkFinishBlock + // && limit == t->dec.decoder.dicPos + // && limit == me->props.outBlockMax + ) + { + overflow = True; + break; + } + + unpackRem = Lzma2Dec_GetUnpackExtra(&t->dec); + break; + } + + if (dicPos_Point != 0 + && (int)status != LZMA2_PARSE_STATUS_NEW_BLOCK + && (int)status != LZMA_STATUS_FINISHED_WITH_MARK + && (int)status != LZMA_STATUS_NOT_SPECIFIED) + { + // we revert to latest newBlock state + status = LZMA2_PARSE_STATUS_NEW_BLOCK; + unpackRem = 0; + t->dec.decoder.dicPos = dicPos_Point; + cc->srcSize = srcSize_Point; + overflow = False; + } + } + + t->inPreSize += cc->srcSize; + t->parseStatus = status; + + if (overflow) + cc->state = MTDEC_PARSE_OVERFLOW; + else + { + size_t dicPos = t->dec.decoder.dicPos; + + if ((int)status != LZMA_STATUS_NEEDS_MORE_INPUT) + { + if (status == LZMA2_PARSE_STATUS_NEW_BLOCK) + { + cc->state = MTDEC_PARSE_NEW; + cc->srcSize--; // we don't need control byte of next block + t->inPreSize--; + } + else + { + cc->state = MTDEC_PARSE_END; + if ((int)status != LZMA_STATUS_FINISHED_WITH_MARK) + { + // (status == LZMA_STATUS_NOT_SPECIFIED) + // (status == LZMA_STATUS_NOT_FINISHED) + if (unpackRem != 0) + { + /* we also reserve space for max possible number of output bytes of current LZMA chunk */ + SizeT rem = limit - dicPos; + if (rem > unpackRem) + rem = unpackRem; + dicPos += rem; + } + } + } + + me->outProcessed_Parse += dicPos; + } + + cc->outPos = dicPos; + t->outPreSize = (size_t)dicPos; + } + + t->state = cc->state; + return; + } +} + + +static SRes Lzma2DecMt_MtCallback_PreCode(void *pp, unsigned coderIndex) +{ + CLzma2DecMt *me = (CLzma2DecMt *)pp; + CLzma2DecMtThread *t = &me->coders[coderIndex]; + Byte *dest = t->outBuf; + + if (t->inPreSize == 0) + { + t->codeRes = SZ_ERROR_DATA; + return t->codeRes; + } + + if (!dest || t->outBufSize < t->outPreSize) + { + if (dest) + { + ISzAlloc_Free(me->allocMid, dest); + t->outBuf = NULL; + t->outBufSize = 0; + } + + dest = (Byte *)ISzAlloc_Alloc(me->allocMid, t->outPreSize + // + (1 << 28) + ); + // Sleep(200); + if (!dest) + return SZ_ERROR_MEM; + t->outBuf = dest; + t->outBufSize = t->outPreSize; + } + + t->dec.decoder.dic = dest; + t->dec.decoder.dicBufSize = t->outPreSize; + + t->needInit = True; + + return Lzma2Dec_AllocateProbs(&t->dec, me->prop, &t->alloc.vt); // alloc.vt +} + + +static SRes Lzma2DecMt_MtCallback_Code(void *pp, unsigned coderIndex, + const Byte *src, size_t srcSize, int srcFinished, + // int finished, int blockFinished, + UInt64 *inCodePos, UInt64 *outCodePos, int *stop) +{ + CLzma2DecMt *me = (CLzma2DecMt *)pp; + CLzma2DecMtThread *t = &me->coders[coderIndex]; + + UNUSED_VAR(srcFinished) + + PRF_STR_INT_2("Code", coderIndex, srcSize); + + *inCodePos = t->inCodeSize; + *outCodePos = 0; + *stop = True; + + if (t->needInit) + { + Lzma2Dec_Init(&t->dec); + t->needInit = False; + } + + { + ELzmaStatus status; + size_t srcProcessed = srcSize; + BoolInt blockWasFinished = + ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK + || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK); + + SRes res = Lzma2Dec_DecodeToDic(&t->dec, + t->outPreSize, + src, &srcProcessed, + blockWasFinished ? LZMA_FINISH_END : LZMA_FINISH_ANY, + &status); + + t->codeRes = res; + + t->inCodeSize += srcProcessed; + *inCodePos = t->inCodeSize; + t->outCodeSize = t->dec.decoder.dicPos; + *outCodePos = t->dec.decoder.dicPos; + + if (res != SZ_OK) + return res; + + if (srcProcessed == srcSize) + *stop = False; + + if (blockWasFinished) + { + if (srcSize != srcProcessed) + return SZ_ERROR_FAIL; + + if (t->inPreSize == t->inCodeSize) + { + if (t->outPreSize != t->outCodeSize) + return SZ_ERROR_FAIL; + *stop = True; + } + } + else + { + if (t->outPreSize == t->outCodeSize) + *stop = True; + } + + return SZ_OK; + } +} + + +#define LZMA2DECMT_STREAM_WRITE_STEP (1 << 24) + +static SRes Lzma2DecMt_MtCallback_Write(void *pp, unsigned coderIndex, + BoolInt needWriteToStream, + const Byte *src, size_t srcSize, BoolInt isCross, + BoolInt *needContinue, BoolInt *canRecode) +{ + CLzma2DecMt *me = (CLzma2DecMt *)pp; + const CLzma2DecMtThread *t = &me->coders[coderIndex]; + size_t size = t->outCodeSize; + const Byte *data = t->outBuf; + BoolInt needContinue2 = True; + + UNUSED_VAR(src) + UNUSED_VAR(srcSize) + UNUSED_VAR(isCross) + + PRF_STR_INT_2("Write", coderIndex, srcSize); + + *needContinue = False; + *canRecode = True; + + if ( + // t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK + t->state == MTDEC_PARSE_OVERFLOW + || t->state == MTDEC_PARSE_END) + needContinue2 = False; + + + if (!needWriteToStream) + return SZ_OK; + + me->mtc.inProcessed += t->inCodeSize; + + if (t->codeRes == SZ_OK) + if ((int)t->parseStatus == LZMA_STATUS_FINISHED_WITH_MARK + || t->parseStatus == LZMA2_PARSE_STATUS_NEW_BLOCK) + if (t->outPreSize != t->outCodeSize + || t->inPreSize != t->inCodeSize) + return SZ_ERROR_FAIL; + + *canRecode = False; + + if (me->outStream) + { + for (;;) + { + size_t cur = size; + size_t written; + if (cur > LZMA2DECMT_STREAM_WRITE_STEP) + cur = LZMA2DECMT_STREAM_WRITE_STEP; + + written = ISeqOutStream_Write(me->outStream, data, cur); + + me->outProcessed += written; + // me->mtc.writtenTotal += written; + if (written != cur) + return SZ_ERROR_WRITE; + data += cur; + size -= cur; + if (size == 0) + { + *needContinue = needContinue2; + return SZ_OK; + } + RINOK(MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0)); + } + } + + return SZ_ERROR_FAIL; + /* + if (size > me->outBufSize) + return SZ_ERROR_OUTPUT_EOF; + memcpy(me->outBuf, data, size); + me->outBufSize -= size; + me->outBuf += size; + *needContinue = needContinue2; + return SZ_OK; + */ +} + +#endif + + +static SRes Lzma2Dec_Prepare_ST(CLzma2DecMt *p) +{ + if (!p->dec_created) + { + Lzma2Dec_Construct(&p->dec); + p->dec_created = True; + } + + RINOK(Lzma2Dec_Allocate(&p->dec, p->prop, &p->alignOffsetAlloc.vt)); + + if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) + { + ISzAlloc_Free(p->allocMid, p->inBuf); + p->inBufSize = 0; + p->inBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.inBufSize_ST); + if (!p->inBuf) + return SZ_ERROR_MEM; + p->inBufSize = p->props.inBufSize_ST; + } + + Lzma2Dec_Init(&p->dec); + + return SZ_OK; +} + + +static SRes Lzma2Dec_Decode_ST(CLzma2DecMt *p + #ifndef _7ZIP_ST + , BoolInt tMode + #endif + ) +{ + SizeT wrPos; + size_t inPos, inLim; + const Byte *inData; + UInt64 inPrev, outPrev; + + CLzma2Dec *dec; + + #ifndef _7ZIP_ST + if (tMode) + { + Lzma2DecMt_FreeOutBufs(p); + tMode = MtDec_PrepareRead(&p->mtc); + } + #endif + + RINOK(Lzma2Dec_Prepare_ST(p)); + + dec = &p->dec; + + inPrev = p->inProcessed; + outPrev = p->outProcessed; + + inPos = 0; + inLim = 0; + inData = NULL; + wrPos = dec->decoder.dicPos; + + for (;;) + { + SizeT dicPos; + SizeT size; + ELzmaFinishMode finishMode; + SizeT inProcessed; + ELzmaStatus status; + SRes res; + + SizeT outProcessed; + BoolInt outFinished; + BoolInt needStop; + + if (inPos == inLim) + { + #ifndef _7ZIP_ST + if (tMode) + { + inData = MtDec_Read(&p->mtc, &inLim); + inPos = 0; + if (inData) + continue; + tMode = False; + inLim = 0; + } + #endif + + if (!p->readWasFinished) + { + inPos = 0; + inLim = p->inBufSize; + inData = p->inBuf; + p->readRes = ISeqInStream_Read(p->inStream, (void *)(p->inBuf), &inLim); + // p->readProcessed += inLim; + // inLim -= 5; p->readWasFinished = True; // for test + if (inLim == 0 || p->readRes != SZ_OK) + p->readWasFinished = True; + } + } + + dicPos = dec->decoder.dicPos; + { + SizeT next = dec->decoder.dicBufSize; + if (next - wrPos > p->props.outStep_ST) + next = wrPos + p->props.outStep_ST; + size = next - dicPos; + } + + finishMode = LZMA_FINISH_ANY; + if (p->outSize_Defined) + { + const UInt64 rem = p->outSize - p->outProcessed; + if (size >= rem) + { + size = (SizeT)rem; + if (p->finishMode) + finishMode = LZMA_FINISH_END; + } + } + + inProcessed = inLim - inPos; + + res = Lzma2Dec_DecodeToDic(dec, dicPos + size, inData + inPos, &inProcessed, finishMode, &status); + + inPos += inProcessed; + p->inProcessed += inProcessed; + outProcessed = dec->decoder.dicPos - dicPos; + p->outProcessed += outProcessed; + + outFinished = (p->outSize_Defined && p->outSize <= p->outProcessed); + + needStop = (res != SZ_OK + || (inProcessed == 0 && outProcessed == 0) + || status == LZMA_STATUS_FINISHED_WITH_MARK + || (!p->finishMode && outFinished)); + + if (needStop || outProcessed >= size) + { + SRes res2; + { + size_t writeSize = dec->decoder.dicPos - wrPos; + size_t written = ISeqOutStream_Write(p->outStream, dec->decoder.dic + wrPos, writeSize); + res2 = (written == writeSize) ? SZ_OK : SZ_ERROR_WRITE; + } + + if (dec->decoder.dicPos == dec->decoder.dicBufSize) + dec->decoder.dicPos = 0; + wrPos = dec->decoder.dicPos; + + RINOK(res2); + + if (needStop) + { + if (res != SZ_OK) + return res; + + if (status == LZMA_STATUS_FINISHED_WITH_MARK) + { + if (p->finishMode) + { + if (p->outSize_Defined && p->outSize != p->outProcessed) + return SZ_ERROR_DATA; + } + return SZ_OK; + } + + if (!p->finishMode && outFinished) + return SZ_OK; + + if (status == LZMA_STATUS_NEEDS_MORE_INPUT) + return SZ_ERROR_INPUT_EOF; + + return SZ_ERROR_DATA; + } + } + + if (p->progress) + { + UInt64 inDelta = p->inProcessed - inPrev; + UInt64 outDelta = p->outProcessed - outPrev; + if (inDelta >= (1 << 22) || outDelta >= (1 << 22)) + { + RINOK(ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed)); + inPrev = p->inProcessed; + outPrev = p->outProcessed; + } + } + } +} + + + +SRes Lzma2DecMt_Decode(CLzma2DecMtHandle pp, + Byte prop, + const CLzma2DecMtProps *props, + ISeqOutStream *outStream, const UInt64 *outDataSize, int finishMode, + // Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + // const Byte *inData, size_t inDataSize, + UInt64 *inProcessed, + // UInt64 *outProcessed, + int *isMT, + ICompressProgress *progress) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + #ifndef _7ZIP_ST + BoolInt tMode; + #endif + + *inProcessed = 0; + + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + + p->prop = prop; + p->props = *props; + + p->inStream = inStream; + p->outStream = outStream; + p->progress = progress; + + p->outSize = 0; + p->outSize_Defined = False; + if (outDataSize) + { + p->outSize_Defined = True; + p->outSize = *outDataSize; + } + p->finishMode = finishMode; + + p->outProcessed = 0; + p->inProcessed = 0; + + p->readWasFinished = False; + p->readRes = SZ_OK; + + *isMT = False; + + + #ifndef _7ZIP_ST + + tMode = False; + + // p->mtc.parseRes = SZ_OK; + + // p->mtc.numFilledThreads = 0; + // p->mtc.crossStart = 0; + // p->mtc.crossEnd = 0; + // p->mtc.allocError_for_Read_BlockIndex = 0; + // p->mtc.isAllocError = False; + + if (p->props.numThreads > 1) + { + IMtDecCallback2 vt; + + Lzma2DecMt_FreeSt(p); + + p->outProcessed_Parse = 0; + + if (!p->mtc_WasConstructed) + { + p->mtc_WasConstructed = True; + MtDec_Construct(&p->mtc); + } + + p->mtc.progress = progress; + p->mtc.inStream = inStream; + + // p->outBuf = NULL; + // p->outBufSize = 0; + /* + if (!outStream) + { + // p->outBuf = outBuf; + // p->outBufSize = *outBufSize; + // *outBufSize = 0; + return SZ_ERROR_PARAM; + } + */ + + // p->mtc.inBlockMax = p->props.inBlockMax; + p->mtc.alloc = &p->alignOffsetAlloc.vt; + // p->alignOffsetAlloc.baseAlloc; + // p->mtc.inData = inData; + // p->mtc.inDataSize = inDataSize; + p->mtc.mtCallback = &vt; + p->mtc.mtCallbackObject = p; + + p->mtc.inBufSize = p->props.inBufSize_MT; + + p->mtc.numThreadsMax = p->props.numThreads; + + *isMT = True; + + vt.Parse = Lzma2DecMt_MtCallback_Parse; + vt.PreCode = Lzma2DecMt_MtCallback_PreCode; + vt.Code = Lzma2DecMt_MtCallback_Code; + vt.Write = Lzma2DecMt_MtCallback_Write; + + { + BoolInt needContinue = False; + + SRes res = MtDec_Code(&p->mtc); + + /* + if (!outStream) + *outBufSize = p->outBuf - outBuf; + */ + + *inProcessed = p->mtc.inProcessed; + + needContinue = False; + + if (res == SZ_OK) + { + if (p->mtc.mtProgress.res != SZ_OK) + res = p->mtc.mtProgress.res; + else + needContinue = p->mtc.needContinue; + } + + if (!needContinue) + { + if (res == SZ_OK) + return p->mtc.readRes; + return res; + } + + tMode = True; + p->readRes = p->mtc.readRes; + p->readWasFinished = p->mtc.readWasFinished; + p->inProcessed = p->mtc.inProcessed; + + PRF_STR("----- decoding ST -----"); + } + } + + #endif + + + *isMT = False; + + { + SRes res = Lzma2Dec_Decode_ST(p + #ifndef _7ZIP_ST + , tMode + #endif + ); + + *inProcessed = p->inProcessed; + + // res = SZ_OK; // for test + if (res == SZ_ERROR_INPUT_EOF) + { + if (p->readRes != SZ_OK) + res = p->readRes; + } + else if (res == SZ_OK && p->readRes != SZ_OK) + res = p->readRes; + + /* + #ifndef _7ZIP_ST + if (res == SZ_OK && tMode && p->mtc.parseRes != SZ_OK) + res = p->mtc.parseRes; + #endif + */ + + return res; + } +} + + +/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ + +SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, + Byte prop, + const CLzma2DecMtProps *props, + const UInt64 *outDataSize, int finishMode, + ISeqInStream *inStream) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + + p->prop = prop; + p->props = *props; + + p->inStream = inStream; + + p->outSize = 0; + p->outSize_Defined = False; + if (outDataSize) + { + p->outSize_Defined = True; + p->outSize = *outDataSize; + } + p->finishMode = finishMode; + + p->outProcessed = 0; + p->inProcessed = 0; + + p->inPos = 0; + p->inLim = 0; + + return Lzma2Dec_Prepare_ST(p); +} + + +SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, + Byte *data, size_t *outSize, + UInt64 *inStreamProcessed) +{ + CLzma2DecMt *p = (CLzma2DecMt *)pp; + ELzmaFinishMode finishMode; + SRes readRes; + size_t size = *outSize; + + *outSize = 0; + *inStreamProcessed = 0; + + finishMode = LZMA_FINISH_ANY; + if (p->outSize_Defined) + { + const UInt64 rem = p->outSize - p->outProcessed; + if (size >= rem) + { + size = (size_t)rem; + if (p->finishMode) + finishMode = LZMA_FINISH_END; + } + } + + readRes = SZ_OK; + + for (;;) + { + SizeT inCur; + SizeT outCur; + ELzmaStatus status; + SRes res; + + if (p->inPos == p->inLim && readRes == SZ_OK) + { + p->inPos = 0; + p->inLim = p->props.inBufSize_ST; + readRes = ISeqInStream_Read(p->inStream, p->inBuf, &p->inLim); + } + + inCur = p->inLim - p->inPos; + outCur = size; + + res = Lzma2Dec_DecodeToBuf(&p->dec, data, &outCur, + p->inBuf + p->inPos, &inCur, finishMode, &status); + + p->inPos += inCur; + p->inProcessed += inCur; + *inStreamProcessed += inCur; + p->outProcessed += outCur; + *outSize += outCur; + size -= outCur; + data += outCur; + + if (res != 0) + return res; + + /* + if (status == LZMA_STATUS_FINISHED_WITH_MARK) + return readRes; + + if (size == 0 && status != LZMA_STATUS_NEEDS_MORE_INPUT) + { + if (p->finishMode && p->outSize_Defined && p->outProcessed >= p->outSize) + return SZ_ERROR_DATA; + return readRes; + } + */ + + if (inCur == 0 && outCur == 0) + return readRes; + } +} diff --git a/deps/LZMA-SDK/C/Lzma2DecMt.h b/deps/LZMA-SDK/C/Lzma2DecMt.h index 96f89a3ca..7791c310b 100644 --- a/deps/LZMA-SDK/C/Lzma2DecMt.h +++ b/deps/LZMA-SDK/C/Lzma2DecMt.h @@ -1,79 +1,79 @@ -/* Lzma2DecMt.h -- LZMA2 Decoder Multi-thread -2018-02-17 : Igor Pavlov : Public domain */ - -#ifndef __LZMA2_DEC_MT_H -#define __LZMA2_DEC_MT_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -typedef struct -{ - size_t inBufSize_ST; - size_t outStep_ST; - - #ifndef _7ZIP_ST - unsigned numThreads; - size_t inBufSize_MT; - size_t outBlockMax; - size_t inBlockMax; - #endif -} CLzma2DecMtProps; - -/* init to single-thread mode */ -void Lzma2DecMtProps_Init(CLzma2DecMtProps *p); - - -/* ---------- CLzma2DecMtHandle Interface ---------- */ - -/* Lzma2DecMt_ * functions can return the following exit codes: -SRes: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater in props - SZ_ERROR_WRITE - ISeqOutStream write callback error - // SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output - SZ_ERROR_PROGRESS - some break from progress callback - SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) -*/ - -typedef void * CLzma2DecMtHandle; - -CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid); -void Lzma2DecMt_Destroy(CLzma2DecMtHandle p); - -SRes Lzma2DecMt_Decode(CLzma2DecMtHandle p, - Byte prop, - const CLzma2DecMtProps *props, - ISeqOutStream *outStream, - const UInt64 *outDataSize, // NULL means undefined - int finishMode, // 0 - partial unpacking is allowed, 1 - if lzma2 stream must be finished - // Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - // const Byte *inData, size_t inDataSize, - - // out variables: - UInt64 *inProcessed, - int *isMT, /* out: (*isMT == 0), if single thread decoding was used */ - - // UInt64 *outProcessed, - ICompressProgress *progress); - - -/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ - -SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, - Byte prop, - const CLzma2DecMtProps *props, - const UInt64 *outDataSize, int finishMode, - ISeqInStream *inStream); - -SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, - Byte *data, size_t *outSize, - UInt64 *inStreamProcessed); - - -EXTERN_C_END - -#endif +/* Lzma2DecMt.h -- LZMA2 Decoder Multi-thread +2018-02-17 : Igor Pavlov : Public domain */ + +#ifndef __LZMA2_DEC_MT_H +#define __LZMA2_DEC_MT_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +typedef struct +{ + size_t inBufSize_ST; + size_t outStep_ST; + + #ifndef _7ZIP_ST + unsigned numThreads; + size_t inBufSize_MT; + size_t outBlockMax; + size_t inBlockMax; + #endif +} CLzma2DecMtProps; + +/* init to single-thread mode */ +void Lzma2DecMtProps_Init(CLzma2DecMtProps *p); + + +/* ---------- CLzma2DecMtHandle Interface ---------- */ + +/* Lzma2DecMt_ * functions can return the following exit codes: +SRes: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater in props + SZ_ERROR_WRITE - ISeqOutStream write callback error + // SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output + SZ_ERROR_PROGRESS - some break from progress callback + SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) +*/ + +typedef void * CLzma2DecMtHandle; + +CLzma2DecMtHandle Lzma2DecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid); +void Lzma2DecMt_Destroy(CLzma2DecMtHandle p); + +SRes Lzma2DecMt_Decode(CLzma2DecMtHandle p, + Byte prop, + const CLzma2DecMtProps *props, + ISeqOutStream *outStream, + const UInt64 *outDataSize, // NULL means undefined + int finishMode, // 0 - partial unpacking is allowed, 1 - if lzma2 stream must be finished + // Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + // const Byte *inData, size_t inDataSize, + + // out variables: + UInt64 *inProcessed, + int *isMT, /* out: (*isMT == 0), if single thread decoding was used */ + + // UInt64 *outProcessed, + ICompressProgress *progress); + + +/* ---------- Read from CLzma2DecMtHandle Interface ---------- */ + +SRes Lzma2DecMt_Init(CLzma2DecMtHandle pp, + Byte prop, + const CLzma2DecMtProps *props, + const UInt64 *outDataSize, int finishMode, + ISeqInStream *inStream); + +SRes Lzma2DecMt_Read(CLzma2DecMtHandle pp, + Byte *data, size_t *outSize, + UInt64 *inStreamProcessed); + + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Lzma2Enc.c b/deps/LZMA-SDK/C/Lzma2Enc.c index c8b114cb4..e61a5dfe0 100644 --- a/deps/LZMA-SDK/C/Lzma2Enc.c +++ b/deps/LZMA-SDK/C/Lzma2Enc.c @@ -1,803 +1,803 @@ -/* Lzma2Enc.c -- LZMA2 Encoder -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -/* #define _7ZIP_ST */ - -#include "Lzma2Enc.h" - -#ifndef _7ZIP_ST -#include "MtCoder.h" -#else -#define MTCODER__THREADS_MAX 1 -#endif - -#define LZMA2_CONTROL_LZMA (1 << 7) -#define LZMA2_CONTROL_COPY_NO_RESET 2 -#define LZMA2_CONTROL_COPY_RESET_DIC 1 -#define LZMA2_CONTROL_EOF 0 - -#define LZMA2_LCLP_MAX 4 - -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) - -#define LZMA2_PACK_SIZE_MAX (1 << 16) -#define LZMA2_COPY_CHUNK_SIZE LZMA2_PACK_SIZE_MAX -#define LZMA2_UNPACK_SIZE_MAX (1 << 21) -#define LZMA2_KEEP_WINDOW_SIZE LZMA2_UNPACK_SIZE_MAX - -#define LZMA2_CHUNK_SIZE_COMPRESSED_MAX ((1 << 16) + 16) - - -#define PRF(x) /* x */ - - -/* ---------- CLimitedSeqInStream ---------- */ - -typedef struct -{ - ISeqInStream vt; - ISeqInStream *realStream; - UInt64 limit; - UInt64 processed; - int finished; -} CLimitedSeqInStream; - -static void LimitedSeqInStream_Init(CLimitedSeqInStream *p) -{ - p->limit = (UInt64)(Int64)-1; - p->processed = 0; - p->finished = 0; -} - -static SRes LimitedSeqInStream_Read(const ISeqInStream *pp, void *data, size_t *size) -{ - CLimitedSeqInStream *p = CONTAINER_FROM_VTBL(pp, CLimitedSeqInStream, vt); - size_t size2 = *size; - SRes res = SZ_OK; - - if (p->limit != (UInt64)(Int64)-1) - { - UInt64 rem = p->limit - p->processed; - if (size2 > rem) - size2 = (size_t)rem; - } - if (size2 != 0) - { - res = ISeqInStream_Read(p->realStream, data, &size2); - p->finished = (size2 == 0 ? 1 : 0); - p->processed += size2; - } - *size = size2; - return res; -} - - -/* ---------- CLzma2EncInt ---------- */ - -typedef struct -{ - CLzmaEncHandle enc; - Byte propsAreSet; - Byte propsByte; - Byte needInitState; - Byte needInitProp; - UInt64 srcPos; -} CLzma2EncInt; - - -static SRes Lzma2EncInt_InitStream(CLzma2EncInt *p, const CLzma2EncProps *props) -{ - if (!p->propsAreSet) - { - SizeT propsSize = LZMA_PROPS_SIZE; - Byte propsEncoded[LZMA_PROPS_SIZE]; - RINOK(LzmaEnc_SetProps(p->enc, &props->lzmaProps)); - RINOK(LzmaEnc_WriteProperties(p->enc, propsEncoded, &propsSize)); - p->propsByte = propsEncoded[0]; - p->propsAreSet = True; - } - return SZ_OK; -} - -static void Lzma2EncInt_InitBlock(CLzma2EncInt *p) -{ - p->srcPos = 0; - p->needInitState = True; - p->needInitProp = True; -} - - -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize, - ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize); -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp); -void LzmaEnc_Finish(CLzmaEncHandle pp); -void LzmaEnc_SaveState(CLzmaEncHandle pp); -void LzmaEnc_RestoreState(CLzmaEncHandle pp); - -/* -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp); -*/ - -static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, - size_t *packSizeRes, ISeqOutStream *outStream) -{ - size_t packSizeLimit = *packSizeRes; - size_t packSize = packSizeLimit; - UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX; - unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0); - BoolInt useCopyBlock; - SRes res; - - *packSizeRes = 0; - if (packSize < lzHeaderSize) - return SZ_ERROR_OUTPUT_EOF; - packSize -= lzHeaderSize; - - LzmaEnc_SaveState(p->enc); - res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState, - outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize); - - PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize)); - - if (unpackSize == 0) - return res; - - if (res == SZ_OK) - useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16)); - else - { - if (res != SZ_ERROR_OUTPUT_EOF) - return res; - res = SZ_OK; - useCopyBlock = True; - } - - if (useCopyBlock) - { - size_t destPos = 0; - PRF(printf("################# COPY ")); - - while (unpackSize > 0) - { - UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE; - if (packSizeLimit - destPos < u + 3) - return SZ_ERROR_OUTPUT_EOF; - outBuf[destPos++] = (Byte)(p->srcPos == 0 ? LZMA2_CONTROL_COPY_RESET_DIC : LZMA2_CONTROL_COPY_NO_RESET); - outBuf[destPos++] = (Byte)((u - 1) >> 8); - outBuf[destPos++] = (Byte)(u - 1); - memcpy(outBuf + destPos, LzmaEnc_GetCurBuf(p->enc) - unpackSize, u); - unpackSize -= u; - destPos += u; - p->srcPos += u; - - if (outStream) - { - *packSizeRes += destPos; - if (ISeqOutStream_Write(outStream, outBuf, destPos) != destPos) - return SZ_ERROR_WRITE; - destPos = 0; - } - else - *packSizeRes = destPos; - /* needInitState = True; */ - } - - LzmaEnc_RestoreState(p->enc); - return SZ_OK; - } - - { - size_t destPos = 0; - UInt32 u = unpackSize - 1; - UInt32 pm = (UInt32)(packSize - 1); - unsigned mode = (p->srcPos == 0) ? 3 : (p->needInitState ? (p->needInitProp ? 2 : 1) : 0); - - PRF(printf(" ")); - - outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | ((u >> 16) & 0x1F)); - outBuf[destPos++] = (Byte)(u >> 8); - outBuf[destPos++] = (Byte)u; - outBuf[destPos++] = (Byte)(pm >> 8); - outBuf[destPos++] = (Byte)pm; - - if (p->needInitProp) - outBuf[destPos++] = p->propsByte; - - p->needInitProp = False; - p->needInitState = False; - destPos += packSize; - p->srcPos += unpackSize; - - if (outStream) - if (ISeqOutStream_Write(outStream, outBuf, destPos) != destPos) - return SZ_ERROR_WRITE; - - *packSizeRes = destPos; - return SZ_OK; - } -} - - -/* ---------- Lzma2 Props ---------- */ - -void Lzma2EncProps_Init(CLzma2EncProps *p) -{ - LzmaEncProps_Init(&p->lzmaProps); - p->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO; - p->numBlockThreads_Reduced = -1; - p->numBlockThreads_Max = -1; - p->numTotalThreads = -1; -} - -void Lzma2EncProps_Normalize(CLzma2EncProps *p) -{ - UInt64 fileSize; - int t1, t1n, t2, t2r, t3; - { - CLzmaEncProps lzmaProps = p->lzmaProps; - LzmaEncProps_Normalize(&lzmaProps); - t1n = lzmaProps.numThreads; - } - - t1 = p->lzmaProps.numThreads; - t2 = p->numBlockThreads_Max; - t3 = p->numTotalThreads; - - if (t2 > MTCODER__THREADS_MAX) - t2 = MTCODER__THREADS_MAX; - - if (t3 <= 0) - { - if (t2 <= 0) - t2 = 1; - t3 = t1n * t2; - } - else if (t2 <= 0) - { - t2 = t3 / t1n; - if (t2 == 0) - { - t1 = 1; - t2 = t3; - } - if (t2 > MTCODER__THREADS_MAX) - t2 = MTCODER__THREADS_MAX; - } - else if (t1 <= 0) - { - t1 = t3 / t2; - if (t1 == 0) - t1 = 1; - } - else - t3 = t1n * t2; - - p->lzmaProps.numThreads = t1; - - t2r = t2; - - fileSize = p->lzmaProps.reduceSize; - - if ( p->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID - && p->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO - && (p->blockSize < fileSize || fileSize == (UInt64)(Int64)-1)) - p->lzmaProps.reduceSize = p->blockSize; - - LzmaEncProps_Normalize(&p->lzmaProps); - - p->lzmaProps.reduceSize = fileSize; - - t1 = p->lzmaProps.numThreads; - - if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) - { - t2r = t2 = 1; - t3 = t1; - } - else if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO && t2 <= 1) - { - /* if there is no block multi-threading, we use SOLID block */ - p->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID; - } - else - { - if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) - { - const UInt32 kMinSize = (UInt32)1 << 20; - const UInt32 kMaxSize = (UInt32)1 << 28; - const UInt32 dictSize = p->lzmaProps.dictSize; - UInt64 blockSize = (UInt64)dictSize << 2; - if (blockSize < kMinSize) blockSize = kMinSize; - if (blockSize > kMaxSize) blockSize = kMaxSize; - if (blockSize < dictSize) blockSize = dictSize; - blockSize += (kMinSize - 1); - blockSize &= ~(UInt64)(kMinSize - 1); - p->blockSize = blockSize; - } - - if (t2 > 1 && fileSize != (UInt64)(Int64)-1) - { - UInt64 numBlocks = fileSize / p->blockSize; - if (numBlocks * p->blockSize != fileSize) - numBlocks++; - if (numBlocks < (unsigned)t2) - { - t2r = (int)numBlocks; - if (t2r == 0) - t2r = 1; - t3 = t1 * t2r; - } - } - } - - p->numBlockThreads_Max = t2; - p->numBlockThreads_Reduced = t2r; - p->numTotalThreads = t3; -} - - -static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize) -{ - return (p && ICompressProgress_Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK; -} - - -/* ---------- Lzma2 ---------- */ - -typedef struct -{ - Byte propEncoded; - CLzma2EncProps props; - UInt64 expectedDataSize; - - Byte *tempBufLzma; - - ISzAllocPtr alloc; - ISzAllocPtr allocBig; - - CLzma2EncInt coders[MTCODER__THREADS_MAX]; - - #ifndef _7ZIP_ST - - ISeqOutStream *outStream; - Byte *outBuf; - size_t outBuf_Rem; /* remainder in outBuf */ - - size_t outBufSize; /* size of allocated outBufs[i] */ - size_t outBufsDataSizes[MTCODER__BLOCKS_MAX]; - BoolInt mtCoder_WasConstructed; - CMtCoder mtCoder; - Byte *outBufs[MTCODER__BLOCKS_MAX]; - - #endif - -} CLzma2Enc; - - - -CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - CLzma2Enc *p = (CLzma2Enc *)ISzAlloc_Alloc(alloc, sizeof(CLzma2Enc)); - if (!p) - return NULL; - Lzma2EncProps_Init(&p->props); - Lzma2EncProps_Normalize(&p->props); - p->expectedDataSize = (UInt64)(Int64)-1; - p->tempBufLzma = NULL; - p->alloc = alloc; - p->allocBig = allocBig; - { - unsigned i; - for (i = 0; i < MTCODER__THREADS_MAX; i++) - p->coders[i].enc = NULL; - } - - #ifndef _7ZIP_ST - p->mtCoder_WasConstructed = False; - { - unsigned i; - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - p->outBufs[i] = NULL; - p->outBufSize = 0; - } - #endif - - return p; -} - - -#ifndef _7ZIP_ST - -static void Lzma2Enc_FreeOutBufs(CLzma2Enc *p) -{ - unsigned i; - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - if (p->outBufs[i]) - { - ISzAlloc_Free(p->alloc, p->outBufs[i]); - p->outBufs[i] = NULL; - } - p->outBufSize = 0; -} - -#endif - - -void Lzma2Enc_Destroy(CLzma2EncHandle pp) -{ - CLzma2Enc *p = (CLzma2Enc *)pp; - unsigned i; - for (i = 0; i < MTCODER__THREADS_MAX; i++) - { - CLzma2EncInt *t = &p->coders[i]; - if (t->enc) - { - LzmaEnc_Destroy(t->enc, p->alloc, p->allocBig); - t->enc = NULL; - } - } - - - #ifndef _7ZIP_ST - if (p->mtCoder_WasConstructed) - { - MtCoder_Destruct(&p->mtCoder); - p->mtCoder_WasConstructed = False; - } - Lzma2Enc_FreeOutBufs(p); - #endif - - ISzAlloc_Free(p->alloc, p->tempBufLzma); - p->tempBufLzma = NULL; - - ISzAlloc_Free(p->alloc, pp); -} - - -SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props) -{ - CLzma2Enc *p = (CLzma2Enc *)pp; - CLzmaEncProps lzmaProps = props->lzmaProps; - LzmaEncProps_Normalize(&lzmaProps); - if (lzmaProps.lc + lzmaProps.lp > LZMA2_LCLP_MAX) - return SZ_ERROR_PARAM; - p->props = *props; - Lzma2EncProps_Normalize(&p->props); - return SZ_OK; -} - - -void Lzma2Enc_SetDataSize(CLzmaEncHandle pp, UInt64 expectedDataSiize) -{ - CLzma2Enc *p = (CLzma2Enc *)pp; - p->expectedDataSize = expectedDataSiize; -} - - -Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp) -{ - CLzma2Enc *p = (CLzma2Enc *)pp; - unsigned i; - UInt32 dicSize = LzmaEncProps_GetDictSize(&p->props.lzmaProps); - for (i = 0; i < 40; i++) - if (dicSize <= LZMA2_DIC_SIZE_FROM_PROP(i)) - break; - return (Byte)i; -} - - -static SRes Lzma2Enc_EncodeMt1( - CLzma2Enc *me, - CLzma2EncInt *p, - ISeqOutStream *outStream, - Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - const Byte *inData, size_t inDataSize, - int finished, - ICompressProgress *progress) -{ - UInt64 unpackTotal = 0; - UInt64 packTotal = 0; - size_t outLim = 0; - CLimitedSeqInStream limitedInStream; - - if (outBuf) - { - outLim = *outBufSize; - *outBufSize = 0; - } - - if (!p->enc) - { - p->propsAreSet = False; - p->enc = LzmaEnc_Create(me->alloc); - if (!p->enc) - return SZ_ERROR_MEM; - } - - limitedInStream.realStream = inStream; - if (inStream) - { - limitedInStream.vt.Read = LimitedSeqInStream_Read; - } - - if (!outBuf) - { - // outStream version works only in one thread. So we use CLzma2Enc::tempBufLzma - if (!me->tempBufLzma) - { - me->tempBufLzma = (Byte *)ISzAlloc_Alloc(me->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX); - if (!me->tempBufLzma) - return SZ_ERROR_MEM; - } - } - - RINOK(Lzma2EncInt_InitStream(p, &me->props)); - - for (;;) - { - SRes res = SZ_OK; - size_t inSizeCur = 0; - - Lzma2EncInt_InitBlock(p); - - LimitedSeqInStream_Init(&limitedInStream); - limitedInStream.limit = me->props.blockSize; - - if (inStream) - { - UInt64 expected = (UInt64)(Int64)-1; - // inStream version works only in one thread. So we use CLzma2Enc::expectedDataSize - if (me->expectedDataSize != (UInt64)(Int64)-1 - && me->expectedDataSize >= unpackTotal) - expected = me->expectedDataSize - unpackTotal; - if (me->props.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID - && expected > me->props.blockSize) - expected = (size_t)me->props.blockSize; - - LzmaEnc_SetDataSize(p->enc, expected); - - RINOK(LzmaEnc_PrepareForLzma2(p->enc, - &limitedInStream.vt, - LZMA2_KEEP_WINDOW_SIZE, - me->alloc, - me->allocBig)); - } - else - { - inSizeCur = inDataSize - (size_t)unpackTotal; - if (me->props.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID - && inSizeCur > me->props.blockSize) - inSizeCur = (size_t)me->props.blockSize; - - // LzmaEnc_SetDataSize(p->enc, inSizeCur); - - RINOK(LzmaEnc_MemPrepare(p->enc, - inData + (size_t)unpackTotal, inSizeCur, - LZMA2_KEEP_WINDOW_SIZE, - me->alloc, - me->allocBig)); - } - - for (;;) - { - size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX; - if (outBuf) - packSize = outLim - (size_t)packTotal; - - res = Lzma2EncInt_EncodeSubblock(p, - outBuf ? outBuf + (size_t)packTotal : me->tempBufLzma, &packSize, - outBuf ? NULL : outStream); - - if (res != SZ_OK) - break; - - packTotal += packSize; - if (outBuf) - *outBufSize = (size_t)packTotal; - - res = Progress(progress, unpackTotal + p->srcPos, packTotal); - if (res != SZ_OK) - break; - - /* - if (LzmaEnc_GetNumAvailableBytes(p->enc) == 0) - break; - */ - - if (packSize == 0) - break; - } - - LzmaEnc_Finish(p->enc); - - unpackTotal += p->srcPos; - - RINOK(res); - - if (p->srcPos != (inStream ? limitedInStream.processed : inSizeCur)) - return SZ_ERROR_FAIL; - - if (inStream ? limitedInStream.finished : (unpackTotal == inDataSize)) - { - if (finished) - { - if (outBuf) - { - const size_t destPos = *outBufSize; - if (destPos >= outLim) - return SZ_ERROR_OUTPUT_EOF; - outBuf[destPos] = LZMA2_CONTROL_EOF; // 0 - *outBufSize = destPos + 1; - } - else - { - const Byte b = LZMA2_CONTROL_EOF; // 0; - if (ISeqOutStream_Write(outStream, &b, 1) != 1) - return SZ_ERROR_WRITE; - } - } - return SZ_OK; - } - } -} - - - -#ifndef _7ZIP_ST - -static SRes Lzma2Enc_MtCallback_Code(void *pp, unsigned coderIndex, unsigned outBufIndex, - const Byte *src, size_t srcSize, int finished) -{ - CLzma2Enc *me = (CLzma2Enc *)pp; - size_t destSize = me->outBufSize; - SRes res; - CMtProgressThunk progressThunk; - - Byte *dest = me->outBufs[outBufIndex]; - - me->outBufsDataSizes[outBufIndex] = 0; - - if (!dest) - { - dest = (Byte *)ISzAlloc_Alloc(me->alloc, me->outBufSize); - if (!dest) - return SZ_ERROR_MEM; - me->outBufs[outBufIndex] = dest; - } - - MtProgressThunk_CreateVTable(&progressThunk); - progressThunk.mtProgress = &me->mtCoder.mtProgress; - progressThunk.inSize = 0; - progressThunk.outSize = 0; - - res = Lzma2Enc_EncodeMt1(me, - &me->coders[coderIndex], - NULL, dest, &destSize, - NULL, src, srcSize, - finished, - &progressThunk.vt); - - me->outBufsDataSizes[outBufIndex] = destSize; - - return res; -} - - -static SRes Lzma2Enc_MtCallback_Write(void *pp, unsigned outBufIndex) -{ - CLzma2Enc *me = (CLzma2Enc *)pp; - size_t size = me->outBufsDataSizes[outBufIndex]; - const Byte *data = me->outBufs[outBufIndex]; - - if (me->outStream) - return ISeqOutStream_Write(me->outStream, data, size) == size ? SZ_OK : SZ_ERROR_WRITE; - - if (size > me->outBuf_Rem) - return SZ_ERROR_OUTPUT_EOF; - memcpy(me->outBuf, data, size); - me->outBuf_Rem -= size; - me->outBuf += size; - return SZ_OK; -} - -#endif - - - -SRes Lzma2Enc_Encode2(CLzma2EncHandle pp, - ISeqOutStream *outStream, - Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - const Byte *inData, size_t inDataSize, - ICompressProgress *progress) -{ - CLzma2Enc *p = (CLzma2Enc *)pp; - - if (inStream && inData) - return SZ_ERROR_PARAM; - - if (outStream && outBuf) - return SZ_ERROR_PARAM; - - { - unsigned i; - for (i = 0; i < MTCODER__THREADS_MAX; i++) - p->coders[i].propsAreSet = False; - } - - #ifndef _7ZIP_ST - - if (p->props.numBlockThreads_Reduced > 1) - { - IMtCoderCallback2 vt; - - if (!p->mtCoder_WasConstructed) - { - p->mtCoder_WasConstructed = True; - MtCoder_Construct(&p->mtCoder); - } - - vt.Code = Lzma2Enc_MtCallback_Code; - vt.Write = Lzma2Enc_MtCallback_Write; - - p->outStream = outStream; - p->outBuf = NULL; - p->outBuf_Rem = 0; - if (!outStream) - { - p->outBuf = outBuf; - p->outBuf_Rem = *outBufSize; - *outBufSize = 0; - } - - p->mtCoder.allocBig = p->allocBig; - p->mtCoder.progress = progress; - p->mtCoder.inStream = inStream; - p->mtCoder.inData = inData; - p->mtCoder.inDataSize = inDataSize; - p->mtCoder.mtCallback = &vt; - p->mtCoder.mtCallbackObject = p; - - p->mtCoder.blockSize = (size_t)p->props.blockSize; - if (p->mtCoder.blockSize != p->props.blockSize) - return SZ_ERROR_PARAM; /* SZ_ERROR_MEM */ - - { - size_t destBlockSize = p->mtCoder.blockSize + (p->mtCoder.blockSize >> 10) + 16; - if (destBlockSize < p->mtCoder.blockSize) - return SZ_ERROR_PARAM; - if (p->outBufSize != destBlockSize) - Lzma2Enc_FreeOutBufs(p); - p->outBufSize = destBlockSize; - } - - p->mtCoder.numThreadsMax = (unsigned)p->props.numBlockThreads_Max; - p->mtCoder.expectedDataSize = p->expectedDataSize; - - { - SRes res = MtCoder_Code(&p->mtCoder); - if (!outStream) - *outBufSize = (size_t)(p->outBuf - outBuf); - return res; - } - } - - #endif - - - return Lzma2Enc_EncodeMt1(p, - &p->coders[0], - outStream, outBuf, outBufSize, - inStream, inData, inDataSize, - True, /* finished */ - progress); -} +/* Lzma2Enc.c -- LZMA2 Encoder +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +/* #define _7ZIP_ST */ + +#include "Lzma2Enc.h" + +#ifndef _7ZIP_ST +#include "MtCoder.h" +#else +#define MTCODER__THREADS_MAX 1 +#endif + +#define LZMA2_CONTROL_LZMA (1 << 7) +#define LZMA2_CONTROL_COPY_NO_RESET 2 +#define LZMA2_CONTROL_COPY_RESET_DIC 1 +#define LZMA2_CONTROL_EOF 0 + +#define LZMA2_LCLP_MAX 4 + +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) + +#define LZMA2_PACK_SIZE_MAX (1 << 16) +#define LZMA2_COPY_CHUNK_SIZE LZMA2_PACK_SIZE_MAX +#define LZMA2_UNPACK_SIZE_MAX (1 << 21) +#define LZMA2_KEEP_WINDOW_SIZE LZMA2_UNPACK_SIZE_MAX + +#define LZMA2_CHUNK_SIZE_COMPRESSED_MAX ((1 << 16) + 16) + + +#define PRF(x) /* x */ + + +/* ---------- CLimitedSeqInStream ---------- */ + +typedef struct +{ + ISeqInStream vt; + ISeqInStream *realStream; + UInt64 limit; + UInt64 processed; + int finished; +} CLimitedSeqInStream; + +static void LimitedSeqInStream_Init(CLimitedSeqInStream *p) +{ + p->limit = (UInt64)(Int64)-1; + p->processed = 0; + p->finished = 0; +} + +static SRes LimitedSeqInStream_Read(const ISeqInStream *pp, void *data, size_t *size) +{ + CLimitedSeqInStream *p = CONTAINER_FROM_VTBL(pp, CLimitedSeqInStream, vt); + size_t size2 = *size; + SRes res = SZ_OK; + + if (p->limit != (UInt64)(Int64)-1) + { + UInt64 rem = p->limit - p->processed; + if (size2 > rem) + size2 = (size_t)rem; + } + if (size2 != 0) + { + res = ISeqInStream_Read(p->realStream, data, &size2); + p->finished = (size2 == 0 ? 1 : 0); + p->processed += size2; + } + *size = size2; + return res; +} + + +/* ---------- CLzma2EncInt ---------- */ + +typedef struct +{ + CLzmaEncHandle enc; + Byte propsAreSet; + Byte propsByte; + Byte needInitState; + Byte needInitProp; + UInt64 srcPos; +} CLzma2EncInt; + + +static SRes Lzma2EncInt_InitStream(CLzma2EncInt *p, const CLzma2EncProps *props) +{ + if (!p->propsAreSet) + { + SizeT propsSize = LZMA_PROPS_SIZE; + Byte propsEncoded[LZMA_PROPS_SIZE]; + RINOK(LzmaEnc_SetProps(p->enc, &props->lzmaProps)); + RINOK(LzmaEnc_WriteProperties(p->enc, propsEncoded, &propsSize)); + p->propsByte = propsEncoded[0]; + p->propsAreSet = True; + } + return SZ_OK; +} + +static void Lzma2EncInt_InitBlock(CLzma2EncInt *p) +{ + p->srcPos = 0; + p->needInitState = True; + p->needInitProp = True; +} + + +SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize, + ISzAllocPtr alloc, ISzAllocPtr allocBig); +SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, + UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig); +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, + Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize); +const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp); +void LzmaEnc_Finish(CLzmaEncHandle pp); +void LzmaEnc_SaveState(CLzmaEncHandle pp); +void LzmaEnc_RestoreState(CLzmaEncHandle pp); + +/* +UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp); +*/ + +static SRes Lzma2EncInt_EncodeSubblock(CLzma2EncInt *p, Byte *outBuf, + size_t *packSizeRes, ISeqOutStream *outStream) +{ + size_t packSizeLimit = *packSizeRes; + size_t packSize = packSizeLimit; + UInt32 unpackSize = LZMA2_UNPACK_SIZE_MAX; + unsigned lzHeaderSize = 5 + (p->needInitProp ? 1 : 0); + BoolInt useCopyBlock; + SRes res; + + *packSizeRes = 0; + if (packSize < lzHeaderSize) + return SZ_ERROR_OUTPUT_EOF; + packSize -= lzHeaderSize; + + LzmaEnc_SaveState(p->enc); + res = LzmaEnc_CodeOneMemBlock(p->enc, p->needInitState, + outBuf + lzHeaderSize, &packSize, LZMA2_PACK_SIZE_MAX, &unpackSize); + + PRF(printf("\npackSize = %7d unpackSize = %7d ", packSize, unpackSize)); + + if (unpackSize == 0) + return res; + + if (res == SZ_OK) + useCopyBlock = (packSize + 2 >= unpackSize || packSize > (1 << 16)); + else + { + if (res != SZ_ERROR_OUTPUT_EOF) + return res; + res = SZ_OK; + useCopyBlock = True; + } + + if (useCopyBlock) + { + size_t destPos = 0; + PRF(printf("################# COPY ")); + + while (unpackSize > 0) + { + UInt32 u = (unpackSize < LZMA2_COPY_CHUNK_SIZE) ? unpackSize : LZMA2_COPY_CHUNK_SIZE; + if (packSizeLimit - destPos < u + 3) + return SZ_ERROR_OUTPUT_EOF; + outBuf[destPos++] = (Byte)(p->srcPos == 0 ? LZMA2_CONTROL_COPY_RESET_DIC : LZMA2_CONTROL_COPY_NO_RESET); + outBuf[destPos++] = (Byte)((u - 1) >> 8); + outBuf[destPos++] = (Byte)(u - 1); + memcpy(outBuf + destPos, LzmaEnc_GetCurBuf(p->enc) - unpackSize, u); + unpackSize -= u; + destPos += u; + p->srcPos += u; + + if (outStream) + { + *packSizeRes += destPos; + if (ISeqOutStream_Write(outStream, outBuf, destPos) != destPos) + return SZ_ERROR_WRITE; + destPos = 0; + } + else + *packSizeRes = destPos; + /* needInitState = True; */ + } + + LzmaEnc_RestoreState(p->enc); + return SZ_OK; + } + + { + size_t destPos = 0; + UInt32 u = unpackSize - 1; + UInt32 pm = (UInt32)(packSize - 1); + unsigned mode = (p->srcPos == 0) ? 3 : (p->needInitState ? (p->needInitProp ? 2 : 1) : 0); + + PRF(printf(" ")); + + outBuf[destPos++] = (Byte)(LZMA2_CONTROL_LZMA | (mode << 5) | ((u >> 16) & 0x1F)); + outBuf[destPos++] = (Byte)(u >> 8); + outBuf[destPos++] = (Byte)u; + outBuf[destPos++] = (Byte)(pm >> 8); + outBuf[destPos++] = (Byte)pm; + + if (p->needInitProp) + outBuf[destPos++] = p->propsByte; + + p->needInitProp = False; + p->needInitState = False; + destPos += packSize; + p->srcPos += unpackSize; + + if (outStream) + if (ISeqOutStream_Write(outStream, outBuf, destPos) != destPos) + return SZ_ERROR_WRITE; + + *packSizeRes = destPos; + return SZ_OK; + } +} + + +/* ---------- Lzma2 Props ---------- */ + +void Lzma2EncProps_Init(CLzma2EncProps *p) +{ + LzmaEncProps_Init(&p->lzmaProps); + p->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO; + p->numBlockThreads_Reduced = -1; + p->numBlockThreads_Max = -1; + p->numTotalThreads = -1; +} + +void Lzma2EncProps_Normalize(CLzma2EncProps *p) +{ + UInt64 fileSize; + int t1, t1n, t2, t2r, t3; + { + CLzmaEncProps lzmaProps = p->lzmaProps; + LzmaEncProps_Normalize(&lzmaProps); + t1n = lzmaProps.numThreads; + } + + t1 = p->lzmaProps.numThreads; + t2 = p->numBlockThreads_Max; + t3 = p->numTotalThreads; + + if (t2 > MTCODER__THREADS_MAX) + t2 = MTCODER__THREADS_MAX; + + if (t3 <= 0) + { + if (t2 <= 0) + t2 = 1; + t3 = t1n * t2; + } + else if (t2 <= 0) + { + t2 = t3 / t1n; + if (t2 == 0) + { + t1 = 1; + t2 = t3; + } + if (t2 > MTCODER__THREADS_MAX) + t2 = MTCODER__THREADS_MAX; + } + else if (t1 <= 0) + { + t1 = t3 / t2; + if (t1 == 0) + t1 = 1; + } + else + t3 = t1n * t2; + + p->lzmaProps.numThreads = t1; + + t2r = t2; + + fileSize = p->lzmaProps.reduceSize; + + if ( p->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID + && p->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO + && (p->blockSize < fileSize || fileSize == (UInt64)(Int64)-1)) + p->lzmaProps.reduceSize = p->blockSize; + + LzmaEncProps_Normalize(&p->lzmaProps); + + p->lzmaProps.reduceSize = fileSize; + + t1 = p->lzmaProps.numThreads; + + if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) + { + t2r = t2 = 1; + t3 = t1; + } + else if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO && t2 <= 1) + { + /* if there is no block multi-threading, we use SOLID block */ + p->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID; + } + else + { + if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) + { + const UInt32 kMinSize = (UInt32)1 << 20; + const UInt32 kMaxSize = (UInt32)1 << 28; + const UInt32 dictSize = p->lzmaProps.dictSize; + UInt64 blockSize = (UInt64)dictSize << 2; + if (blockSize < kMinSize) blockSize = kMinSize; + if (blockSize > kMaxSize) blockSize = kMaxSize; + if (blockSize < dictSize) blockSize = dictSize; + blockSize += (kMinSize - 1); + blockSize &= ~(UInt64)(kMinSize - 1); + p->blockSize = blockSize; + } + + if (t2 > 1 && fileSize != (UInt64)(Int64)-1) + { + UInt64 numBlocks = fileSize / p->blockSize; + if (numBlocks * p->blockSize != fileSize) + numBlocks++; + if (numBlocks < (unsigned)t2) + { + t2r = (int)numBlocks; + if (t2r == 0) + t2r = 1; + t3 = t1 * t2r; + } + } + } + + p->numBlockThreads_Max = t2; + p->numBlockThreads_Reduced = t2r; + p->numTotalThreads = t3; +} + + +static SRes Progress(ICompressProgress *p, UInt64 inSize, UInt64 outSize) +{ + return (p && ICompressProgress_Progress(p, inSize, outSize) != SZ_OK) ? SZ_ERROR_PROGRESS : SZ_OK; +} + + +/* ---------- Lzma2 ---------- */ + +typedef struct +{ + Byte propEncoded; + CLzma2EncProps props; + UInt64 expectedDataSize; + + Byte *tempBufLzma; + + ISzAllocPtr alloc; + ISzAllocPtr allocBig; + + CLzma2EncInt coders[MTCODER__THREADS_MAX]; + + #ifndef _7ZIP_ST + + ISeqOutStream *outStream; + Byte *outBuf; + size_t outBuf_Rem; /* remainder in outBuf */ + + size_t outBufSize; /* size of allocated outBufs[i] */ + size_t outBufsDataSizes[MTCODER__BLOCKS_MAX]; + BoolInt mtCoder_WasConstructed; + CMtCoder mtCoder; + Byte *outBufs[MTCODER__BLOCKS_MAX]; + + #endif + +} CLzma2Enc; + + + +CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + CLzma2Enc *p = (CLzma2Enc *)ISzAlloc_Alloc(alloc, sizeof(CLzma2Enc)); + if (!p) + return NULL; + Lzma2EncProps_Init(&p->props); + Lzma2EncProps_Normalize(&p->props); + p->expectedDataSize = (UInt64)(Int64)-1; + p->tempBufLzma = NULL; + p->alloc = alloc; + p->allocBig = allocBig; + { + unsigned i; + for (i = 0; i < MTCODER__THREADS_MAX; i++) + p->coders[i].enc = NULL; + } + + #ifndef _7ZIP_ST + p->mtCoder_WasConstructed = False; + { + unsigned i; + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + p->outBufs[i] = NULL; + p->outBufSize = 0; + } + #endif + + return p; +} + + +#ifndef _7ZIP_ST + +static void Lzma2Enc_FreeOutBufs(CLzma2Enc *p) +{ + unsigned i; + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + if (p->outBufs[i]) + { + ISzAlloc_Free(p->alloc, p->outBufs[i]); + p->outBufs[i] = NULL; + } + p->outBufSize = 0; +} + +#endif + + +void Lzma2Enc_Destroy(CLzma2EncHandle pp) +{ + CLzma2Enc *p = (CLzma2Enc *)pp; + unsigned i; + for (i = 0; i < MTCODER__THREADS_MAX; i++) + { + CLzma2EncInt *t = &p->coders[i]; + if (t->enc) + { + LzmaEnc_Destroy(t->enc, p->alloc, p->allocBig); + t->enc = NULL; + } + } + + + #ifndef _7ZIP_ST + if (p->mtCoder_WasConstructed) + { + MtCoder_Destruct(&p->mtCoder); + p->mtCoder_WasConstructed = False; + } + Lzma2Enc_FreeOutBufs(p); + #endif + + ISzAlloc_Free(p->alloc, p->tempBufLzma); + p->tempBufLzma = NULL; + + ISzAlloc_Free(p->alloc, pp); +} + + +SRes Lzma2Enc_SetProps(CLzma2EncHandle pp, const CLzma2EncProps *props) +{ + CLzma2Enc *p = (CLzma2Enc *)pp; + CLzmaEncProps lzmaProps = props->lzmaProps; + LzmaEncProps_Normalize(&lzmaProps); + if (lzmaProps.lc + lzmaProps.lp > LZMA2_LCLP_MAX) + return SZ_ERROR_PARAM; + p->props = *props; + Lzma2EncProps_Normalize(&p->props); + return SZ_OK; +} + + +void Lzma2Enc_SetDataSize(CLzmaEncHandle pp, UInt64 expectedDataSiize) +{ + CLzma2Enc *p = (CLzma2Enc *)pp; + p->expectedDataSize = expectedDataSiize; +} + + +Byte Lzma2Enc_WriteProperties(CLzma2EncHandle pp) +{ + CLzma2Enc *p = (CLzma2Enc *)pp; + unsigned i; + UInt32 dicSize = LzmaEncProps_GetDictSize(&p->props.lzmaProps); + for (i = 0; i < 40; i++) + if (dicSize <= LZMA2_DIC_SIZE_FROM_PROP(i)) + break; + return (Byte)i; +} + + +static SRes Lzma2Enc_EncodeMt1( + CLzma2Enc *me, + CLzma2EncInt *p, + ISeqOutStream *outStream, + Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + const Byte *inData, size_t inDataSize, + int finished, + ICompressProgress *progress) +{ + UInt64 unpackTotal = 0; + UInt64 packTotal = 0; + size_t outLim = 0; + CLimitedSeqInStream limitedInStream; + + if (outBuf) + { + outLim = *outBufSize; + *outBufSize = 0; + } + + if (!p->enc) + { + p->propsAreSet = False; + p->enc = LzmaEnc_Create(me->alloc); + if (!p->enc) + return SZ_ERROR_MEM; + } + + limitedInStream.realStream = inStream; + if (inStream) + { + limitedInStream.vt.Read = LimitedSeqInStream_Read; + } + + if (!outBuf) + { + // outStream version works only in one thread. So we use CLzma2Enc::tempBufLzma + if (!me->tempBufLzma) + { + me->tempBufLzma = (Byte *)ISzAlloc_Alloc(me->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX); + if (!me->tempBufLzma) + return SZ_ERROR_MEM; + } + } + + RINOK(Lzma2EncInt_InitStream(p, &me->props)); + + for (;;) + { + SRes res = SZ_OK; + size_t inSizeCur = 0; + + Lzma2EncInt_InitBlock(p); + + LimitedSeqInStream_Init(&limitedInStream); + limitedInStream.limit = me->props.blockSize; + + if (inStream) + { + UInt64 expected = (UInt64)(Int64)-1; + // inStream version works only in one thread. So we use CLzma2Enc::expectedDataSize + if (me->expectedDataSize != (UInt64)(Int64)-1 + && me->expectedDataSize >= unpackTotal) + expected = me->expectedDataSize - unpackTotal; + if (me->props.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID + && expected > me->props.blockSize) + expected = (size_t)me->props.blockSize; + + LzmaEnc_SetDataSize(p->enc, expected); + + RINOK(LzmaEnc_PrepareForLzma2(p->enc, + &limitedInStream.vt, + LZMA2_KEEP_WINDOW_SIZE, + me->alloc, + me->allocBig)); + } + else + { + inSizeCur = inDataSize - (size_t)unpackTotal; + if (me->props.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID + && inSizeCur > me->props.blockSize) + inSizeCur = (size_t)me->props.blockSize; + + // LzmaEnc_SetDataSize(p->enc, inSizeCur); + + RINOK(LzmaEnc_MemPrepare(p->enc, + inData + (size_t)unpackTotal, inSizeCur, + LZMA2_KEEP_WINDOW_SIZE, + me->alloc, + me->allocBig)); + } + + for (;;) + { + size_t packSize = LZMA2_CHUNK_SIZE_COMPRESSED_MAX; + if (outBuf) + packSize = outLim - (size_t)packTotal; + + res = Lzma2EncInt_EncodeSubblock(p, + outBuf ? outBuf + (size_t)packTotal : me->tempBufLzma, &packSize, + outBuf ? NULL : outStream); + + if (res != SZ_OK) + break; + + packTotal += packSize; + if (outBuf) + *outBufSize = (size_t)packTotal; + + res = Progress(progress, unpackTotal + p->srcPos, packTotal); + if (res != SZ_OK) + break; + + /* + if (LzmaEnc_GetNumAvailableBytes(p->enc) == 0) + break; + */ + + if (packSize == 0) + break; + } + + LzmaEnc_Finish(p->enc); + + unpackTotal += p->srcPos; + + RINOK(res); + + if (p->srcPos != (inStream ? limitedInStream.processed : inSizeCur)) + return SZ_ERROR_FAIL; + + if (inStream ? limitedInStream.finished : (unpackTotal == inDataSize)) + { + if (finished) + { + if (outBuf) + { + const size_t destPos = *outBufSize; + if (destPos >= outLim) + return SZ_ERROR_OUTPUT_EOF; + outBuf[destPos] = LZMA2_CONTROL_EOF; // 0 + *outBufSize = destPos + 1; + } + else + { + const Byte b = LZMA2_CONTROL_EOF; // 0; + if (ISeqOutStream_Write(outStream, &b, 1) != 1) + return SZ_ERROR_WRITE; + } + } + return SZ_OK; + } + } +} + + + +#ifndef _7ZIP_ST + +static SRes Lzma2Enc_MtCallback_Code(void *pp, unsigned coderIndex, unsigned outBufIndex, + const Byte *src, size_t srcSize, int finished) +{ + CLzma2Enc *me = (CLzma2Enc *)pp; + size_t destSize = me->outBufSize; + SRes res; + CMtProgressThunk progressThunk; + + Byte *dest = me->outBufs[outBufIndex]; + + me->outBufsDataSizes[outBufIndex] = 0; + + if (!dest) + { + dest = (Byte *)ISzAlloc_Alloc(me->alloc, me->outBufSize); + if (!dest) + return SZ_ERROR_MEM; + me->outBufs[outBufIndex] = dest; + } + + MtProgressThunk_CreateVTable(&progressThunk); + progressThunk.mtProgress = &me->mtCoder.mtProgress; + progressThunk.inSize = 0; + progressThunk.outSize = 0; + + res = Lzma2Enc_EncodeMt1(me, + &me->coders[coderIndex], + NULL, dest, &destSize, + NULL, src, srcSize, + finished, + &progressThunk.vt); + + me->outBufsDataSizes[outBufIndex] = destSize; + + return res; +} + + +static SRes Lzma2Enc_MtCallback_Write(void *pp, unsigned outBufIndex) +{ + CLzma2Enc *me = (CLzma2Enc *)pp; + size_t size = me->outBufsDataSizes[outBufIndex]; + const Byte *data = me->outBufs[outBufIndex]; + + if (me->outStream) + return ISeqOutStream_Write(me->outStream, data, size) == size ? SZ_OK : SZ_ERROR_WRITE; + + if (size > me->outBuf_Rem) + return SZ_ERROR_OUTPUT_EOF; + memcpy(me->outBuf, data, size); + me->outBuf_Rem -= size; + me->outBuf += size; + return SZ_OK; +} + +#endif + + + +SRes Lzma2Enc_Encode2(CLzma2EncHandle pp, + ISeqOutStream *outStream, + Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + const Byte *inData, size_t inDataSize, + ICompressProgress *progress) +{ + CLzma2Enc *p = (CLzma2Enc *)pp; + + if (inStream && inData) + return SZ_ERROR_PARAM; + + if (outStream && outBuf) + return SZ_ERROR_PARAM; + + { + unsigned i; + for (i = 0; i < MTCODER__THREADS_MAX; i++) + p->coders[i].propsAreSet = False; + } + + #ifndef _7ZIP_ST + + if (p->props.numBlockThreads_Reduced > 1) + { + IMtCoderCallback2 vt; + + if (!p->mtCoder_WasConstructed) + { + p->mtCoder_WasConstructed = True; + MtCoder_Construct(&p->mtCoder); + } + + vt.Code = Lzma2Enc_MtCallback_Code; + vt.Write = Lzma2Enc_MtCallback_Write; + + p->outStream = outStream; + p->outBuf = NULL; + p->outBuf_Rem = 0; + if (!outStream) + { + p->outBuf = outBuf; + p->outBuf_Rem = *outBufSize; + *outBufSize = 0; + } + + p->mtCoder.allocBig = p->allocBig; + p->mtCoder.progress = progress; + p->mtCoder.inStream = inStream; + p->mtCoder.inData = inData; + p->mtCoder.inDataSize = inDataSize; + p->mtCoder.mtCallback = &vt; + p->mtCoder.mtCallbackObject = p; + + p->mtCoder.blockSize = (size_t)p->props.blockSize; + if (p->mtCoder.blockSize != p->props.blockSize) + return SZ_ERROR_PARAM; /* SZ_ERROR_MEM */ + + { + size_t destBlockSize = p->mtCoder.blockSize + (p->mtCoder.blockSize >> 10) + 16; + if (destBlockSize < p->mtCoder.blockSize) + return SZ_ERROR_PARAM; + if (p->outBufSize != destBlockSize) + Lzma2Enc_FreeOutBufs(p); + p->outBufSize = destBlockSize; + } + + p->mtCoder.numThreadsMax = (unsigned)p->props.numBlockThreads_Max; + p->mtCoder.expectedDataSize = p->expectedDataSize; + + { + SRes res = MtCoder_Code(&p->mtCoder); + if (!outStream) + *outBufSize = (size_t)(p->outBuf - outBuf); + return res; + } + } + + #endif + + + return Lzma2Enc_EncodeMt1(p, + &p->coders[0], + outStream, outBuf, outBufSize, + inStream, inData, inDataSize, + True, /* finished */ + progress); +} diff --git a/deps/LZMA-SDK/C/Lzma2Enc.h b/deps/LZMA-SDK/C/Lzma2Enc.h index 65f2dd145..6a6110ff7 100644 --- a/deps/LZMA-SDK/C/Lzma2Enc.h +++ b/deps/LZMA-SDK/C/Lzma2Enc.h @@ -1,55 +1,55 @@ -/* Lzma2Enc.h -- LZMA2 Encoder -2017-07-27 : Igor Pavlov : Public domain */ - -#ifndef __LZMA2_ENC_H -#define __LZMA2_ENC_H - -#include "LzmaEnc.h" - -EXTERN_C_BEGIN - -#define LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO 0 -#define LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID ((UInt64)(Int64)-1) - -typedef struct -{ - CLzmaEncProps lzmaProps; - UInt64 blockSize; - int numBlockThreads_Reduced; - int numBlockThreads_Max; - int numTotalThreads; -} CLzma2EncProps; - -void Lzma2EncProps_Init(CLzma2EncProps *p); -void Lzma2EncProps_Normalize(CLzma2EncProps *p); - -/* ---------- CLzmaEnc2Handle Interface ---------- */ - -/* Lzma2Enc_* functions can return the following exit codes: -SRes: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater in props - SZ_ERROR_WRITE - ISeqOutStream write callback error - SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output - SZ_ERROR_PROGRESS - some break from progress callback - SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) -*/ - -typedef void * CLzma2EncHandle; - -CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig); -void Lzma2Enc_Destroy(CLzma2EncHandle p); -SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props); -void Lzma2Enc_SetDataSize(CLzma2EncHandle p, UInt64 expectedDataSiize); -Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p); -SRes Lzma2Enc_Encode2(CLzma2EncHandle p, - ISeqOutStream *outStream, - Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - const Byte *inData, size_t inDataSize, - ICompressProgress *progress); - -EXTERN_C_END - -#endif +/* Lzma2Enc.h -- LZMA2 Encoder +2017-07-27 : Igor Pavlov : Public domain */ + +#ifndef __LZMA2_ENC_H +#define __LZMA2_ENC_H + +#include "LzmaEnc.h" + +EXTERN_C_BEGIN + +#define LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO 0 +#define LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID ((UInt64)(Int64)-1) + +typedef struct +{ + CLzmaEncProps lzmaProps; + UInt64 blockSize; + int numBlockThreads_Reduced; + int numBlockThreads_Max; + int numTotalThreads; +} CLzma2EncProps; + +void Lzma2EncProps_Init(CLzma2EncProps *p); +void Lzma2EncProps_Normalize(CLzma2EncProps *p); + +/* ---------- CLzmaEnc2Handle Interface ---------- */ + +/* Lzma2Enc_* functions can return the following exit codes: +SRes: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater in props + SZ_ERROR_WRITE - ISeqOutStream write callback error + SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output + SZ_ERROR_PROGRESS - some break from progress callback + SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) +*/ + +typedef void * CLzma2EncHandle; + +CLzma2EncHandle Lzma2Enc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig); +void Lzma2Enc_Destroy(CLzma2EncHandle p); +SRes Lzma2Enc_SetProps(CLzma2EncHandle p, const CLzma2EncProps *props); +void Lzma2Enc_SetDataSize(CLzma2EncHandle p, UInt64 expectedDataSiize); +Byte Lzma2Enc_WriteProperties(CLzma2EncHandle p); +SRes Lzma2Enc_Encode2(CLzma2EncHandle p, + ISeqOutStream *outStream, + Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + const Byte *inData, size_t inDataSize, + ICompressProgress *progress); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Lzma86.h b/deps/LZMA-SDK/C/Lzma86.h index 83057e598..bebed5cb7 100644 --- a/deps/LZMA-SDK/C/Lzma86.h +++ b/deps/LZMA-SDK/C/Lzma86.h @@ -1,111 +1,111 @@ -/* Lzma86.h -- LZMA + x86 (BCJ) Filter -2013-01-18 : Igor Pavlov : Public domain */ - -#ifndef __LZMA86_H -#define __LZMA86_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define LZMA86_SIZE_OFFSET (1 + 5) -#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8) - -/* -It's an example for LZMA + x86 Filter use. -You can use .lzma86 extension, if you write that stream to file. -.lzma86 header adds one additional byte to standard .lzma header. -.lzma86 header (14 bytes): - Offset Size Description - 0 1 = 0 - no filter, pure LZMA - = 1 - x86 filter + LZMA - 1 1 lc, lp and pb in encoded form - 2 4 dictSize (little endian) - 6 8 uncompressed size (little endian) - - -Lzma86_Encode -------------- -level - compression level: 0 <= level <= 9, the default value for "level" is 5. - -dictSize - The dictionary size in bytes. The maximum value is - 128 MB = (1 << 27) bytes for 32-bit version - 1 GB = (1 << 30) bytes for 64-bit version - The default value is 16 MB = (1 << 24) bytes, for level = 5. - It's recommended to use the dictionary that is larger than 4 KB and - that can be calculated as (1 << N) or (3 << N) sizes. - For better compression ratio dictSize must be >= inSize. - -filterMode: - SZ_FILTER_NO - no Filter - SZ_FILTER_YES - x86 Filter - SZ_FILTER_AUTO - it tries both alternatives to select best. - Encoder will use 2 or 3 passes: - 2 passes when FILTER_NO provides better compression. - 3 passes when FILTER_YES provides better compression. - -Lzma86Encode allocates Data with MyAlloc functions. -RAM Requirements for compressing: - RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize - filterMode FilterBlockSize - SZ_FILTER_NO 0 - SZ_FILTER_YES inSize - SZ_FILTER_AUTO inSize - - -Return code: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater - SZ_ERROR_OUTPUT_EOF - output buffer overflow - SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) -*/ - -enum ESzFilterMode -{ - SZ_FILTER_NO, - SZ_FILTER_YES, - SZ_FILTER_AUTO -}; - -SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, - int level, UInt32 dictSize, int filterMode); - - -/* -Lzma86_GetUnpackSize: - In: - src - input data - srcLen - input data size - Out: - unpackSize - size of uncompressed stream - Return code: - SZ_OK - OK - SZ_ERROR_INPUT_EOF - Error in headers -*/ - -SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize); - -/* -Lzma86_Decode: - In: - dest - output data - destLen - output data size - src - input data - srcLen - input data size - Out: - destLen - processed output size - srcLen - processed input size - Return code: - SZ_OK - OK - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - unsupported file - SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer -*/ - -SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen); - -EXTERN_C_END - -#endif +/* Lzma86.h -- LZMA + x86 (BCJ) Filter +2013-01-18 : Igor Pavlov : Public domain */ + +#ifndef __LZMA86_H +#define __LZMA86_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define LZMA86_SIZE_OFFSET (1 + 5) +#define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8) + +/* +It's an example for LZMA + x86 Filter use. +You can use .lzma86 extension, if you write that stream to file. +.lzma86 header adds one additional byte to standard .lzma header. +.lzma86 header (14 bytes): + Offset Size Description + 0 1 = 0 - no filter, pure LZMA + = 1 - x86 filter + LZMA + 1 1 lc, lp and pb in encoded form + 2 4 dictSize (little endian) + 6 8 uncompressed size (little endian) + + +Lzma86_Encode +------------- +level - compression level: 0 <= level <= 9, the default value for "level" is 5. + +dictSize - The dictionary size in bytes. The maximum value is + 128 MB = (1 << 27) bytes for 32-bit version + 1 GB = (1 << 30) bytes for 64-bit version + The default value is 16 MB = (1 << 24) bytes, for level = 5. + It's recommended to use the dictionary that is larger than 4 KB and + that can be calculated as (1 << N) or (3 << N) sizes. + For better compression ratio dictSize must be >= inSize. + +filterMode: + SZ_FILTER_NO - no Filter + SZ_FILTER_YES - x86 Filter + SZ_FILTER_AUTO - it tries both alternatives to select best. + Encoder will use 2 or 3 passes: + 2 passes when FILTER_NO provides better compression. + 3 passes when FILTER_YES provides better compression. + +Lzma86Encode allocates Data with MyAlloc functions. +RAM Requirements for compressing: + RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize + filterMode FilterBlockSize + SZ_FILTER_NO 0 + SZ_FILTER_YES inSize + SZ_FILTER_AUTO inSize + + +Return code: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater + SZ_ERROR_OUTPUT_EOF - output buffer overflow + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) +*/ + +enum ESzFilterMode +{ + SZ_FILTER_NO, + SZ_FILTER_YES, + SZ_FILTER_AUTO +}; + +SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, + int level, UInt32 dictSize, int filterMode); + + +/* +Lzma86_GetUnpackSize: + In: + src - input data + srcLen - input data size + Out: + unpackSize - size of uncompressed stream + Return code: + SZ_OK - OK + SZ_ERROR_INPUT_EOF - Error in headers +*/ + +SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize); + +/* +Lzma86_Decode: + In: + dest - output data + destLen - output data size + src - input data + srcLen - input data size + Out: + destLen - processed output size + srcLen - processed input size + Return code: + SZ_OK - OK + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - unsupported file + SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer +*/ + +SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Lzma86Dec.c b/deps/LZMA-SDK/C/Lzma86Dec.c index 20ac5e7a9..21031745c 100644 --- a/deps/LZMA-SDK/C/Lzma86Dec.c +++ b/deps/LZMA-SDK/C/Lzma86Dec.c @@ -1,54 +1,54 @@ -/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder -2016-05-16 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "Lzma86.h" - -#include "Alloc.h" -#include "Bra.h" -#include "LzmaDec.h" - -SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize) -{ - unsigned i; - if (srcLen < LZMA86_HEADER_SIZE) - return SZ_ERROR_INPUT_EOF; - *unpackSize = 0; - for (i = 0; i < sizeof(UInt64); i++) - *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i); - return SZ_OK; -} - -SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen) -{ - SRes res; - int useFilter; - SizeT inSizePure; - ELzmaStatus status; - - if (*srcLen < LZMA86_HEADER_SIZE) - return SZ_ERROR_INPUT_EOF; - - useFilter = src[0]; - - if (useFilter > 1) - { - *destLen = 0; - return SZ_ERROR_UNSUPPORTED; - } - - inSizePure = *srcLen - LZMA86_HEADER_SIZE; - res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure, - src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc); - *srcLen = inSizePure + LZMA86_HEADER_SIZE; - if (res != SZ_OK) - return res; - if (useFilter == 1) - { - UInt32 x86State; - x86_Convert_Init(x86State); - x86_Convert(dest, *destLen, 0, &x86State, 0); - } - return SZ_OK; -} +/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder +2016-05-16 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "Lzma86.h" + +#include "Alloc.h" +#include "Bra.h" +#include "LzmaDec.h" + +SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize) +{ + unsigned i; + if (srcLen < LZMA86_HEADER_SIZE) + return SZ_ERROR_INPUT_EOF; + *unpackSize = 0; + for (i = 0; i < sizeof(UInt64); i++) + *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i); + return SZ_OK; +} + +SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen) +{ + SRes res; + int useFilter; + SizeT inSizePure; + ELzmaStatus status; + + if (*srcLen < LZMA86_HEADER_SIZE) + return SZ_ERROR_INPUT_EOF; + + useFilter = src[0]; + + if (useFilter > 1) + { + *destLen = 0; + return SZ_ERROR_UNSUPPORTED; + } + + inSizePure = *srcLen - LZMA86_HEADER_SIZE; + res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure, + src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc); + *srcLen = inSizePure + LZMA86_HEADER_SIZE; + if (res != SZ_OK) + return res; + if (useFilter == 1) + { + UInt32 x86State; + x86_Convert_Init(x86State); + x86_Convert(dest, *destLen, 0, &x86State, 0); + } + return SZ_OK; +} diff --git a/deps/LZMA-SDK/C/Lzma86Enc.c b/deps/LZMA-SDK/C/Lzma86Enc.c index 99397bc5e..14fcd65c6 100644 --- a/deps/LZMA-SDK/C/Lzma86Enc.c +++ b/deps/LZMA-SDK/C/Lzma86Enc.c @@ -1,104 +1,104 @@ -/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder -2018-07-04 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "Lzma86.h" - -#include "Alloc.h" -#include "Bra.h" -#include "LzmaEnc.h" - -int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, - int level, UInt32 dictSize, int filterMode) -{ - size_t outSize2 = *destLen; - Byte *filteredStream; - BoolInt useFilter; - int mainResult = SZ_ERROR_OUTPUT_EOF; - CLzmaEncProps props; - LzmaEncProps_Init(&props); - props.level = level; - props.dictSize = dictSize; - - *destLen = 0; - if (outSize2 < LZMA86_HEADER_SIZE) - return SZ_ERROR_OUTPUT_EOF; - - { - int i; - UInt64 t = srcLen; - for (i = 0; i < 8; i++, t >>= 8) - dest[LZMA86_SIZE_OFFSET + i] = (Byte)t; - } - - filteredStream = 0; - useFilter = (filterMode != SZ_FILTER_NO); - if (useFilter) - { - if (srcLen != 0) - { - filteredStream = (Byte *)MyAlloc(srcLen); - if (filteredStream == 0) - return SZ_ERROR_MEM; - memcpy(filteredStream, src, srcLen); - } - { - UInt32 x86State; - x86_Convert_Init(x86State); - x86_Convert(filteredStream, srcLen, 0, &x86State, 1); - } - } - - { - size_t minSize = 0; - BoolInt bestIsFiltered = False; - - /* passes for SZ_FILTER_AUTO: - 0 - BCJ + LZMA - 1 - LZMA - 2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better. - */ - int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1; - - int i; - for (i = 0; i < numPasses; i++) - { - size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE; - size_t outPropsSize = 5; - SRes curRes; - BoolInt curModeIsFiltered = (numPasses > 1 && i == numPasses - 1); - if (curModeIsFiltered && !bestIsFiltered) - break; - if (useFilter && i == 0) - curModeIsFiltered = True; - - curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed, - curModeIsFiltered ? filteredStream : src, srcLen, - &props, dest + 1, &outPropsSize, 0, - NULL, &g_Alloc, &g_Alloc); - - if (curRes != SZ_ERROR_OUTPUT_EOF) - { - if (curRes != SZ_OK) - { - mainResult = curRes; - break; - } - if (outSizeProcessed <= minSize || mainResult != SZ_OK) - { - minSize = outSizeProcessed; - bestIsFiltered = curModeIsFiltered; - mainResult = SZ_OK; - } - } - } - dest[0] = (Byte)(bestIsFiltered ? 1 : 0); - *destLen = LZMA86_HEADER_SIZE + minSize; - } - if (useFilter) - MyFree(filteredStream); - return mainResult; -} +/* Lzma86Enc.c -- LZMA + x86 (BCJ) Filter Encoder +2018-07-04 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#include "Lzma86.h" + +#include "Alloc.h" +#include "Bra.h" +#include "LzmaEnc.h" + +int Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen, + int level, UInt32 dictSize, int filterMode) +{ + size_t outSize2 = *destLen; + Byte *filteredStream; + BoolInt useFilter; + int mainResult = SZ_ERROR_OUTPUT_EOF; + CLzmaEncProps props; + LzmaEncProps_Init(&props); + props.level = level; + props.dictSize = dictSize; + + *destLen = 0; + if (outSize2 < LZMA86_HEADER_SIZE) + return SZ_ERROR_OUTPUT_EOF; + + { + int i; + UInt64 t = srcLen; + for (i = 0; i < 8; i++, t >>= 8) + dest[LZMA86_SIZE_OFFSET + i] = (Byte)t; + } + + filteredStream = 0; + useFilter = (filterMode != SZ_FILTER_NO); + if (useFilter) + { + if (srcLen != 0) + { + filteredStream = (Byte *)MyAlloc(srcLen); + if (filteredStream == 0) + return SZ_ERROR_MEM; + memcpy(filteredStream, src, srcLen); + } + { + UInt32 x86State; + x86_Convert_Init(x86State); + x86_Convert(filteredStream, srcLen, 0, &x86State, 1); + } + } + + { + size_t minSize = 0; + BoolInt bestIsFiltered = False; + + /* passes for SZ_FILTER_AUTO: + 0 - BCJ + LZMA + 1 - LZMA + 2 - BCJ + LZMA agaian, if pass 0 (BCJ + LZMA) is better. + */ + int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1; + + int i; + for (i = 0; i < numPasses; i++) + { + size_t outSizeProcessed = outSize2 - LZMA86_HEADER_SIZE; + size_t outPropsSize = 5; + SRes curRes; + BoolInt curModeIsFiltered = (numPasses > 1 && i == numPasses - 1); + if (curModeIsFiltered && !bestIsFiltered) + break; + if (useFilter && i == 0) + curModeIsFiltered = True; + + curRes = LzmaEncode(dest + LZMA86_HEADER_SIZE, &outSizeProcessed, + curModeIsFiltered ? filteredStream : src, srcLen, + &props, dest + 1, &outPropsSize, 0, + NULL, &g_Alloc, &g_Alloc); + + if (curRes != SZ_ERROR_OUTPUT_EOF) + { + if (curRes != SZ_OK) + { + mainResult = curRes; + break; + } + if (outSizeProcessed <= minSize || mainResult != SZ_OK) + { + minSize = outSizeProcessed; + bestIsFiltered = curModeIsFiltered; + mainResult = SZ_OK; + } + } + } + dest[0] = (Byte)(bestIsFiltered ? 1 : 0); + *destLen = LZMA86_HEADER_SIZE + minSize; + } + if (useFilter) + MyFree(filteredStream); + return mainResult; +} diff --git a/deps/LZMA-SDK/C/LzmaDec.c b/deps/LZMA-SDK/C/LzmaDec.c index 80b70a9ee..d6742e5af 100644 --- a/deps/LZMA-SDK/C/LzmaDec.c +++ b/deps/LZMA-SDK/C/LzmaDec.c @@ -1,1363 +1,1363 @@ -/* LzmaDec.c -- LZMA Decoder -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -/* #include "CpuArch.h" */ -#include "LzmaDec.h" - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) - -#define RC_INIT_SIZE 5 - -#ifndef _LZMA_DEC_OPT - -#define kNumMoveBits 5 -#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } - -#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) -#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); -#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ - { UPDATE_0(p); i = (i + i); A0; } else \ - { UPDATE_1(p); i = (i + i) + 1; A1; } - -#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); } - -#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \ - { UPDATE_0(p + i); A0; } else \ - { UPDATE_1(p + i); A1; } -#define REV_BIT_VAR( p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; ) -#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; ) -#define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m , ; ) - -#define TREE_DECODE(probs, limit, i) \ - { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } - -/* #define _LZMA_SIZE_OPT */ - -#ifdef _LZMA_SIZE_OPT -#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) -#else -#define TREE_6_DECODE(probs, i) \ - { i = 1; \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - i -= 0x40; } -#endif - -#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol) -#define MATCHED_LITER_DEC \ - matchByte += matchByte; \ - bit = offs; \ - offs &= matchByte; \ - probLit = prob + (offs + bit + symbol); \ - GET_BIT2(probLit, symbol, offs ^= bit; , ;) - -#endif // _LZMA_DEC_OPT - - -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_INPUT_EOF; range <<= 8; code = (code << 8) | (*buf++); } - -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) -#define UPDATE_0_CHECK range = bound; -#define UPDATE_1_CHECK range -= bound; code -= bound; -#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ - { UPDATE_0_CHECK; i = (i + i); A0; } else \ - { UPDATE_1_CHECK; i = (i + i) + 1; A1; } -#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) -#define TREE_DECODE_CHECK(probs, limit, i) \ - { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } - - -#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \ - { UPDATE_0_CHECK; i += m; m += m; } else \ - { UPDATE_1_CHECK; m += m; i += m; } - - -#define kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenLow 0 -#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - -#define LenChoice LenLow -#define LenChoice2 (LenLow + (1 << kLenNumLowBits)) - -#define kNumStates 12 -#define kNumStates2 16 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols) - -#define kMatchSpecLen_Error_Data (1 << 9) -#define kMatchSpecLen_Error_Fail (kMatchSpecLen_Error_Data - 1) - -/* External ASM code needs same CLzmaProb array layout. So don't change it. */ - -/* (probs_1664) is faster and better for code size at some platforms */ -/* -#ifdef MY_CPU_X86_OR_AMD64 -*/ -#define kStartOffset 1664 -#define GET_PROBS p->probs_1664 -/* -#define GET_PROBS p->probs + kStartOffset -#else -#define kStartOffset 0 -#define GET_PROBS p->probs -#endif -*/ - -#define SpecPos (-kStartOffset) -#define IsRep0Long (SpecPos + kNumFullDistances) -#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax)) -#define LenCoder (RepLenCoder + kNumLenProbs) -#define IsMatch (LenCoder + kNumLenProbs) -#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax)) -#define IsRep (Align + kAlignTableSize) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define PosSlot (IsRepG2 + kNumStates) -#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define NUM_BASE_PROBS (Literal + kStartOffset) - -#if Align != 0 && kStartOffset != 0 - #error Stop_Compiling_Bad_LZMA_kAlign -#endif - -#if NUM_BASE_PROBS != 1984 - #error Stop_Compiling_Bad_LZMA_PROBS -#endif - - -#define LZMA_LIT_SIZE 0x300 - -#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) - - -#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4) -#define COMBINED_PS_STATE (posState + state) -#define GET_LEN_STATE (posState) - -#define LZMA_DIC_MIN (1 << 12) - -/* -p->remainLen : shows status of LZMA decoder: - < kMatchSpecLenStart : the number of bytes to be copied with (p->rep0) offset - = kMatchSpecLenStart : the LZMA stream was finished with end mark - = kMatchSpecLenStart + 1 : need init range coder - = kMatchSpecLenStart + 2 : need init range coder and state - = kMatchSpecLen_Error_Fail : Internal Code Failure - = kMatchSpecLen_Error_Data + [0 ... 273] : LZMA Data Error -*/ - -/* ---------- LZMA_DECODE_REAL ---------- */ -/* -LzmaDec_DecodeReal_3() can be implemented in external ASM file. -3 - is the code compatibility version of that function for check at link time. -*/ - -#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3 - -/* -LZMA_DECODE_REAL() -In: - RangeCoder is normalized - if (p->dicPos == limit) - { - LzmaDec_TryDummy() was called before to exclude LITERAL and MATCH-REP cases. - So first symbol can be only MATCH-NON-REP. And if that MATCH-NON-REP symbol - is not END_OF_PAYALOAD_MARKER, then the function doesn't write any byte to dictionary, - the function returns SZ_OK, and the caller can use (p->remainLen) and (p->reps[0]) later. - } - -Processing: - The first LZMA symbol will be decoded in any case. - All main checks for limits are at the end of main loop, - It decodes additional LZMA-symbols while (p->buf < bufLimit && dicPos < limit), - RangeCoder is still without last normalization when (p->buf < bufLimit) is being checked. - But if (p->buf < bufLimit), the caller provided at least (LZMA_REQUIRED_INPUT_MAX + 1) bytes for - next iteration before limit (bufLimit + LZMA_REQUIRED_INPUT_MAX), - that is enough for worst case LZMA symbol with one additional RangeCoder normalization for one bit. - So that function never reads bufLimit [LZMA_REQUIRED_INPUT_MAX] byte. - -Out: - RangeCoder is normalized - Result: - SZ_OK - OK - p->remainLen: - < kMatchSpecLenStart : the number of bytes to be copied with (p->reps[0]) offset - = kMatchSpecLenStart : the LZMA stream was finished with end mark - - SZ_ERROR_DATA - error, when the MATCH-Symbol refers out of dictionary - p->remainLen : undefined - p->reps[*] : undefined -*/ - - -#ifdef _LZMA_DEC_OPT - -int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit); - -#else - -static -int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) -{ - CLzmaProb *probs = GET_PROBS; - unsigned state = (unsigned)p->state; - UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; - unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; - unsigned lc = p->prop.lc; - unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc); - - Byte *dic = p->dic; - SizeT dicBufSize = p->dicBufSize; - SizeT dicPos = p->dicPos; - - UInt32 processedPos = p->processedPos; - UInt32 checkDicSize = p->checkDicSize; - unsigned len = 0; - - const Byte *buf = p->buf; - UInt32 range = p->range; - UInt32 code = p->code; - - do - { - CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = CALC_POS_STATE(processedPos, pbMask); - - prob = probs + IsMatch + COMBINED_PS_STATE; - IF_BIT_0(prob) - { - unsigned symbol; - UPDATE_0(prob); - prob = probs + Literal; - if (processedPos != 0 || checkDicSize != 0) - prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc); - processedPos++; - - if (state < kNumLitStates) - { - state -= (state < 4) ? state : 3; - symbol = 1; - #ifdef _LZMA_SIZE_OPT - do { NORMAL_LITER_DEC } while (symbol < 0x100); - #else - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - NORMAL_LITER_DEC - #endif - } - else - { - unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; - unsigned offs = 0x100; - state -= (state < 10) ? 3 : 6; - symbol = 1; - #ifdef _LZMA_SIZE_OPT - do - { - unsigned bit; - CLzmaProb *probLit; - MATCHED_LITER_DEC - } - while (symbol < 0x100); - #else - { - unsigned bit; - CLzmaProb *probLit; - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - MATCHED_LITER_DEC - } - #endif - } - - dic[dicPos++] = (Byte)symbol; - continue; - } - - { - UPDATE_1(prob); - prob = probs + IsRep + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - state += kNumStates; - prob = probs + LenCoder; - } - else - { - UPDATE_1(prob); - prob = probs + IsRepG0 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - prob = probs + IsRep0Long + COMBINED_PS_STATE; - IF_BIT_0(prob) - { - UPDATE_0(prob); - - // that case was checked before with kBadRepCode - // if (checkDicSize == 0 && processedPos == 0) { len = kMatchSpecLen_Error_Data + 1; break; } - // The caller doesn't allow (dicPos == limit) case here - // so we don't need the following check: - // if (dicPos == limit) { state = state < kNumLitStates ? 9 : 11; len = 1; break; } - - dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; - dicPos++; - processedPos++; - state = state < kNumLitStates ? 9 : 11; - continue; - } - UPDATE_1(prob); - } - else - { - UInt32 distance; - UPDATE_1(prob); - prob = probs + IsRepG1 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - distance = rep1; - } - else - { - UPDATE_1(prob); - prob = probs + IsRepG2 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - distance = rep2; - } - else - { - UPDATE_1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = probs + RepLenCoder; - } - - #ifdef _LZMA_SIZE_OPT - { - unsigned lim, offset; - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenLow + GET_LEN_STATE; - offset = 0; - lim = (1 << kLenNumLowBits); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenChoice2; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); - offset = kLenNumLowSymbols; - lim = (1 << kLenNumLowBits); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols * 2; - lim = (1 << kLenNumHighBits); - } - } - TREE_DECODE(probLen, lim, len); - len += offset; - } - #else - { - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenLow + GET_LEN_STATE; - len = 1; - TREE_GET_BIT(probLen, len); - TREE_GET_BIT(probLen, len); - TREE_GET_BIT(probLen, len); - len -= 8; - } - else - { - UPDATE_1(probLen); - probLen = prob + LenChoice2; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); - len = 1; - TREE_GET_BIT(probLen, len); - TREE_GET_BIT(probLen, len); - TREE_GET_BIT(probLen, len); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenHigh; - TREE_DECODE(probLen, (1 << kLenNumHighBits), len); - len += kLenNumLowSymbols * 2; - } - } - } - #endif - - if (state >= kNumStates) - { - UInt32 distance; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_6_DECODE(prob, distance); - if (distance >= kStartPosModelIndex) - { - unsigned posSlot = (unsigned)distance; - unsigned numDirectBits = (unsigned)(((distance >> 1) - 1)); - distance = (2 | (distance & 1)); - if (posSlot < kEndPosModelIndex) - { - distance <<= numDirectBits; - prob = probs + SpecPos; - { - UInt32 m = 1; - distance++; - do - { - REV_BIT_VAR(prob, distance, m); - } - while (--numDirectBits); - distance -= m; - } - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE - range >>= 1; - - { - UInt32 t; - code -= range; - t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ - distance = (distance << 1) + (t + 1); - code += range & t; - } - /* - distance <<= 1; - if (code >= range) - { - code -= range; - distance |= 1; - } - */ - } - while (--numDirectBits); - prob = probs + Align; - distance <<= kNumAlignBits; - { - unsigned i = 1; - REV_BIT_CONST(prob, i, 1); - REV_BIT_CONST(prob, i, 2); - REV_BIT_CONST(prob, i, 4); - REV_BIT_LAST (prob, i, 8); - distance |= i; - } - if (distance == (UInt32)0xFFFFFFFF) - { - len = kMatchSpecLenStart; - state -= kNumStates; - break; - } - } - } - - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance + 1; - state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; - if (distance >= (checkDicSize == 0 ? processedPos: checkDicSize)) - { - len += kMatchSpecLen_Error_Data + kMatchMinLen; - // len = kMatchSpecLen_Error_Data; - // len += kMatchMinLen; - break; - } - } - - len += kMatchMinLen; - - { - SizeT rem; - unsigned curLen; - SizeT pos; - - if ((rem = limit - dicPos) == 0) - { - /* - We stop decoding and return SZ_OK, and we can resume decoding later. - Any error conditions can be tested later in caller code. - For more strict mode we can stop decoding with error - // len += kMatchSpecLen_Error_Data; - */ - break; - } - - curLen = ((rem < len) ? (unsigned)rem : len); - pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0); - - processedPos += (UInt32)curLen; - - len -= curLen; - if (curLen <= dicBufSize - pos) - { - Byte *dest = dic + dicPos; - ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; - const Byte *lim = dest + curLen; - dicPos += (SizeT)curLen; - do - *(dest) = (Byte)*(dest + src); - while (++dest != lim); - } - else - { - do - { - dic[dicPos++] = dic[pos]; - if (++pos == dicBufSize) - pos = 0; - } - while (--curLen != 0); - } - } - } - } - while (dicPos < limit && buf < bufLimit); - - NORMALIZE; - - p->buf = buf; - p->range = range; - p->code = code; - p->remainLen = (UInt32)len; // & (kMatchSpecLen_Error_Data - 1); // we can write real length for error matches too. - p->dicPos = dicPos; - p->processedPos = processedPos; - p->reps[0] = rep0; - p->reps[1] = rep1; - p->reps[2] = rep2; - p->reps[3] = rep3; - p->state = (UInt32)state; - if (len >= kMatchSpecLen_Error_Data) - return SZ_ERROR_DATA; - return SZ_OK; -} -#endif - - - -static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) -{ - unsigned len = (unsigned)p->remainLen; - if (len == 0 /* || len >= kMatchSpecLenStart */) - return; - { - SizeT dicPos = p->dicPos; - Byte *dic; - SizeT dicBufSize; - SizeT rep0; /* we use SizeT to avoid the BUG of VC14 for AMD64 */ - { - SizeT rem = limit - dicPos; - if (rem < len) - { - len = (unsigned)(rem); - if (len == 0) - return; - } - } - - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) - p->checkDicSize = p->prop.dicSize; - - p->processedPos += (UInt32)len; - p->remainLen -= (UInt32)len; - dic = p->dic; - rep0 = p->reps[0]; - dicBufSize = p->dicBufSize; - do - { - dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; - dicPos++; - } - while (--len); - p->dicPos = dicPos; - } -} - - -/* -At staring of new stream we have one of the following symbols: - - Literal - is allowed - - Non-Rep-Match - is allowed only if it's end marker symbol - - Rep-Match - is not allowed -We use early check of (RangeCoder:Code) over kBadRepCode to simplify main decoding code -*/ - -#define kRange0 0xFFFFFFFF -#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)) -#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))) -#if kBadRepCode != (0xC0000000 - 0x400) - #error Stop_Compiling_Bad_LZMA_Check -#endif - - -/* -LzmaDec_DecodeReal2(): - It calls LZMA_DECODE_REAL() and it adjusts limit according (p->checkDicSize). - -We correct (p->checkDicSize) after LZMA_DECODE_REAL() and in LzmaDec_WriteRem(), -and we support the following state of (p->checkDicSize): - if (total_processed < p->prop.dicSize) then - { - (total_processed == p->processedPos) - (p->checkDicSize == 0) - } - else - (p->checkDicSize == p->prop.dicSize) -*/ - -static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) -{ - if (p->checkDicSize == 0) - { - UInt32 rem = p->prop.dicSize - p->processedPos; - if (limit - p->dicPos > rem) - limit = p->dicPos + rem; - } - { - int res = LZMA_DECODE_REAL(p, limit, bufLimit); - if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize) - p->checkDicSize = p->prop.dicSize; - return res; - } -} - - - -typedef enum -{ - DUMMY_INPUT_EOF, /* need more input data */ - DUMMY_LIT, - DUMMY_MATCH, - DUMMY_REP -} ELzmaDummy; - - -#define IS_DUMMY_END_MARKER_POSSIBLE(dummyRes) ((dummyRes) == DUMMY_MATCH) - -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byte **bufOut) -{ - UInt32 range = p->range; - UInt32 code = p->code; - const Byte *bufLimit = *bufOut; - const CLzmaProb *probs = GET_PROBS; - unsigned state = (unsigned)p->state; - ELzmaDummy res; - - for (;;) - { - const CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = CALC_POS_STATE(p->processedPos, ((unsigned)1 << p->prop.pb) - 1); - - prob = probs + IsMatch + COMBINED_PS_STATE; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK - - prob = probs + Literal; - if (p->checkDicSize != 0 || p->processedPos != 0) - prob += ((UInt32)LZMA_LIT_SIZE * - ((((p->processedPos) & (((unsigned)1 << (p->prop.lp)) - 1)) << p->prop.lc) + - ((unsigned)p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); - - if (state < kNumLitStates) - { - unsigned symbol = 1; - do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchByte = p->dic[p->dicPos - p->reps[0] + - (p->dicPos < p->reps[0] ? p->dicBufSize : 0)]; - unsigned offs = 0x100; - unsigned symbol = 1; - do - { - unsigned bit; - const CLzmaProb *probLit; - matchByte += matchByte; - bit = offs; - offs &= matchByte; - probLit = prob + (offs + bit + symbol); - GET_BIT2_CHECK(probLit, symbol, offs ^= bit; , ; ) - } - while (symbol < 0x100); - } - res = DUMMY_LIT; - } - else - { - unsigned len; - UPDATE_1_CHECK; - - prob = probs + IsRep + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - state = 0; - prob = probs + LenCoder; - res = DUMMY_MATCH; - } - else - { - UPDATE_1_CHECK; - res = DUMMY_REP; - prob = probs + IsRepG0 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - prob = probs + IsRep0Long + COMBINED_PS_STATE; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - break; - } - else - { - UPDATE_1_CHECK; - } - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG1 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG2 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - } - } - } - state = kNumStates; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - const CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenLow + GET_LEN_STATE; - offset = 0; - limit = 1 << kLenNumLowBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenChoice2; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); - offset = kLenNumLowSymbols; - limit = 1 << kLenNumLowBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenHigh; - offset = kLenNumLowSymbols * 2; - limit = 1 << kLenNumHighBits; - } - } - TREE_DECODE_CHECK(probLen, limit, len); - len += offset; - } - - if (state < 4) - { - unsigned posSlot; - prob = probs + PosSlot + - ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - unsigned numDirectBits = ((posSlot >> 1) - 1); - - if (posSlot < kEndPosModelIndex) - { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits); - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE_CHECK - range >>= 1; - code -= range & (((code - range) >> 31) - 1); - /* if (code >= range) code -= range; */ - } - while (--numDirectBits); - prob = probs + Align; - numDirectBits = kNumAlignBits; - } - { - unsigned i = 1; - unsigned m = 1; - do - { - REV_BIT_CHECK(prob, i, m); - } - while (--numDirectBits); - } - } - } - } - break; - } - NORMALIZE_CHECK; - - *bufOut = buf; - return res; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState); -void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState) -{ - p->remainLen = kMatchSpecLenStart + 1; - p->tempBufSize = 0; - - if (initDic) - { - p->processedPos = 0; - p->checkDicSize = 0; - p->remainLen = kMatchSpecLenStart + 2; - } - if (initState) - p->remainLen = kMatchSpecLenStart + 2; -} - -void LzmaDec_Init(CLzmaDec *p) -{ - p->dicPos = 0; - LzmaDec_InitDicAndState(p, True, True); -} - - -/* -LZMA supports optional end_marker. -So the decoder can lookahead for one additional LZMA-Symbol to check end_marker. -That additional LZMA-Symbol can require up to LZMA_REQUIRED_INPUT_MAX bytes in input stream. -When the decoder reaches dicLimit, it looks (finishMode) parameter: - if (finishMode == LZMA_FINISH_ANY), the decoder doesn't lookahead - if (finishMode != LZMA_FINISH_ANY), the decoder lookahead, if end_marker is possible for current position - -When the decoder lookahead, and the lookahead symbol is not end_marker, we have two ways: - 1) Strict mode (default) : the decoder returns SZ_ERROR_DATA. - 2) The relaxed mode (alternative mode) : we could return SZ_OK, and the caller - must check (status) value. The caller can show the error, - if the end of stream is expected, and the (status) is noit - LZMA_STATUS_FINISHED_WITH_MARK or LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK. -*/ - - -#define RETURN__NOT_FINISHED__FOR_FINISH \ - *status = LZMA_STATUS_NOT_FINISHED; \ - return SZ_ERROR_DATA; // for strict mode - // return SZ_OK; // for relaxed mode - - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, - ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT inSize = *srcLen; - (*srcLen) = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - - if (p->remainLen > kMatchSpecLenStart) - { - if (p->remainLen > kMatchSpecLenStart + 2) - return p->remainLen == kMatchSpecLen_Error_Fail ? SZ_ERROR_FAIL : SZ_ERROR_DATA; - - for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) - p->tempBuf[p->tempBufSize++] = *src++; - if (p->tempBufSize != 0 && p->tempBuf[0] != 0) - return SZ_ERROR_DATA; - if (p->tempBufSize < RC_INIT_SIZE) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - p->code = - ((UInt32)p->tempBuf[1] << 24) - | ((UInt32)p->tempBuf[2] << 16) - | ((UInt32)p->tempBuf[3] << 8) - | ((UInt32)p->tempBuf[4]); - - if (p->checkDicSize == 0 - && p->processedPos == 0 - && p->code >= kBadRepCode) - return SZ_ERROR_DATA; - - p->range = 0xFFFFFFFF; - p->tempBufSize = 0; - - if (p->remainLen > kMatchSpecLenStart + 1) - { - SizeT numProbs = LzmaProps_GetNumProbs(&p->prop); - SizeT i; - CLzmaProb *probs = p->probs; - for (i = 0; i < numProbs; i++) - probs[i] = kBitModelTotal >> 1; - p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; - p->state = 0; - } - - p->remainLen = 0; - } - - for (;;) - { - if (p->remainLen == kMatchSpecLenStart) - { - if (p->code != 0) - return SZ_ERROR_DATA; - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return SZ_OK; - } - - LzmaDec_WriteRem(p, dicLimit); - - { - // (p->remainLen == 0 || p->dicPos == dicLimit) - - int checkEndMarkNow = 0; - - if (p->dicPos >= dicLimit) - { - if (p->remainLen == 0 && p->code == 0) - { - *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; - return SZ_OK; - } - if (finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->remainLen != 0) - { - RETURN__NOT_FINISHED__FOR_FINISH; - } - checkEndMarkNow = 1; - } - - // (p->remainLen == 0) - - if (p->tempBufSize == 0) - { - const Byte *bufLimit; - int dummyProcessed = -1; - - if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - const Byte *bufOut = src + inSize; - - ELzmaDummy dummyRes = LzmaDec_TryDummy(p, src, &bufOut); - - if (dummyRes == DUMMY_INPUT_EOF) - { - size_t i; - if (inSize >= LZMA_REQUIRED_INPUT_MAX) - break; - (*srcLen) += inSize; - p->tempBufSize = (unsigned)inSize; - for (i = 0; i < inSize; i++) - p->tempBuf[i] = src[i]; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - - dummyProcessed = (int)(bufOut - src); - if ((unsigned)dummyProcessed > LZMA_REQUIRED_INPUT_MAX) - break; - - if (checkEndMarkNow && !IS_DUMMY_END_MARKER_POSSIBLE(dummyRes)) - { - unsigned i; - (*srcLen) += (unsigned)dummyProcessed; - p->tempBufSize = (unsigned)dummyProcessed; - for (i = 0; i < (unsigned)dummyProcessed; i++) - p->tempBuf[i] = src[i]; - // p->remainLen = kMatchSpecLen_Error_Data; - RETURN__NOT_FINISHED__FOR_FINISH; - } - - bufLimit = src; - // we will decode only one iteration - } - else - bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; - - p->buf = src; - - { - int res = LzmaDec_DecodeReal2(p, dicLimit, bufLimit); - - SizeT processed = (SizeT)(p->buf - src); - - if (dummyProcessed < 0) - { - if (processed > inSize) - break; - } - else if ((unsigned)dummyProcessed != processed) - break; - - src += processed; - inSize -= processed; - (*srcLen) += processed; - - if (res != SZ_OK) - { - p->remainLen = kMatchSpecLen_Error_Data; - return SZ_ERROR_DATA; - } - } - continue; - } - - { - // we have some data in (p->tempBuf) - // in strict mode: tempBufSize is not enough for one Symbol decoding. - // in relaxed mode: tempBufSize not larger than required for one Symbol decoding. - - unsigned rem = p->tempBufSize; - unsigned ahead = 0; - int dummyProcessed = -1; - - while (rem < LZMA_REQUIRED_INPUT_MAX && ahead < inSize) - p->tempBuf[rem++] = src[ahead++]; - - // ahead - the size of new data copied from (src) to (p->tempBuf) - // rem - the size of temp buffer including new data from (src) - - if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - const Byte *bufOut = p->tempBuf + rem; - - ELzmaDummy dummyRes = LzmaDec_TryDummy(p, p->tempBuf, &bufOut); - - if (dummyRes == DUMMY_INPUT_EOF) - { - if (rem >= LZMA_REQUIRED_INPUT_MAX) - break; - p->tempBufSize = rem; - (*srcLen) += (SizeT)ahead; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - - dummyProcessed = (int)(bufOut - p->tempBuf); - - if ((unsigned)dummyProcessed < p->tempBufSize) - break; - - if (checkEndMarkNow && !IS_DUMMY_END_MARKER_POSSIBLE(dummyRes)) - { - (*srcLen) += (unsigned)dummyProcessed - p->tempBufSize; - p->tempBufSize = (unsigned)dummyProcessed; - // p->remainLen = kMatchSpecLen_Error_Data; - RETURN__NOT_FINISHED__FOR_FINISH; - } - } - - p->buf = p->tempBuf; - - { - // we decode one symbol from (p->tempBuf) here, so the (bufLimit) is equal to (p->buf) - int res = LzmaDec_DecodeReal2(p, dicLimit, p->buf); - - SizeT processed = (SizeT)(p->buf - p->tempBuf); - rem = p->tempBufSize; - - if (dummyProcessed < 0) - { - if (processed > LZMA_REQUIRED_INPUT_MAX) - break; - if (processed < rem) - break; - } - else if ((unsigned)dummyProcessed != processed) - break; - - processed -= rem; - - src += processed; - inSize -= processed; - (*srcLen) += processed; - p->tempBufSize = 0; - - if (res != SZ_OK) - { - p->remainLen = kMatchSpecLen_Error_Data; - return SZ_ERROR_DATA; - } - } - } - } - } - - /* Some unexpected error: internal error of code, memory corruption or hardware failure */ - p->remainLen = kMatchSpecLen_Error_Fail; - return SZ_ERROR_FAIL; -} - - - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT outSize = *destLen; - SizeT inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - SizeT inSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->dicPos == p->dicBufSize) - p->dicPos = 0; - dicPos = p->dicPos; - if (outSize > p->dicBufSize - dicPos) - { - outSizeCur = p->dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); - src += inSizeCur; - inSize -= inSizeCur; - *srcLen += inSizeCur; - outSizeCur = p->dicPos - dicPos; - memcpy(dest, p->dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->probs); - p->probs = NULL; -} - -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->dic); - p->dic = NULL; -} - -void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc) -{ - LzmaDec_FreeProbs(p, alloc); - LzmaDec_FreeDict(p, alloc); -} - -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) -{ - UInt32 dicSize; - Byte d; - - if (size < LZMA_PROPS_SIZE) - return SZ_ERROR_UNSUPPORTED; - else - dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); - - if (dicSize < LZMA_DIC_MIN) - dicSize = LZMA_DIC_MIN; - p->dicSize = dicSize; - - d = data[0]; - if (d >= (9 * 5 * 5)) - return SZ_ERROR_UNSUPPORTED; - - p->lc = (Byte)(d % 9); - d /= 9; - p->pb = (Byte)(d / 5); - p->lp = (Byte)(d % 5); - - return SZ_OK; -} - -static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc) -{ - UInt32 numProbs = LzmaProps_GetNumProbs(propNew); - if (!p->probs || numProbs != p->numProbs) - { - LzmaDec_FreeProbs(p, alloc); - p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb)); - if (!p->probs) - return SZ_ERROR_MEM; - p->probs_1664 = p->probs + 1664; - p->numProbs = numProbs; - } - return SZ_OK; -} - -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) -{ - CLzmaProps propNew; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) -{ - CLzmaProps propNew; - SizeT dicBufSize; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - - { - UInt32 dictSize = propNew.dicSize; - SizeT mask = ((UInt32)1 << 12) - 1; - if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1; - else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;; - dicBufSize = ((SizeT)dictSize + mask) & ~mask; - if (dicBufSize < dictSize) - dicBufSize = dictSize; - } - - if (!p->dic || dicBufSize != p->dicBufSize) - { - LzmaDec_FreeDict(p, alloc); - p->dic = (Byte *)ISzAlloc_Alloc(alloc, dicBufSize); - if (!p->dic) - { - LzmaDec_FreeProbs(p, alloc); - return SZ_ERROR_MEM; - } - } - p->dicBufSize = dicBufSize; - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAllocPtr alloc) -{ - CLzmaDec p; - SRes res; - SizeT outSize = *destLen, inSize = *srcLen; - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - if (inSize < RC_INIT_SIZE) - return SZ_ERROR_INPUT_EOF; - LzmaDec_Construct(&p); - RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc)); - p.dic = dest; - p.dicBufSize = outSize; - LzmaDec_Init(&p); - *srcLen = inSize; - res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - *destLen = p.dicPos; - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - LzmaDec_FreeProbs(&p, alloc); - return res; -} +/* LzmaDec.c -- LZMA Decoder +2021-04-01 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +/* #include "CpuArch.h" */ +#include "LzmaDec.h" + +#define kNumTopBits 24 +#define kTopValue ((UInt32)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) + +#define RC_INIT_SIZE 5 + +#ifndef _LZMA_DEC_OPT + +#define kNumMoveBits 5 +#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } + +#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) +#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); +#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); +#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ + { UPDATE_0(p); i = (i + i); A0; } else \ + { UPDATE_1(p); i = (i + i) + 1; A1; } + +#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); } + +#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \ + { UPDATE_0(p + i); A0; } else \ + { UPDATE_1(p + i); A1; } +#define REV_BIT_VAR( p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; ) +#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; ) +#define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m , ; ) + +#define TREE_DECODE(probs, limit, i) \ + { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } + +/* #define _LZMA_SIZE_OPT */ + +#ifdef _LZMA_SIZE_OPT +#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) +#else +#define TREE_6_DECODE(probs, i) \ + { i = 1; \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + i -= 0x40; } +#endif + +#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol) +#define MATCHED_LITER_DEC \ + matchByte += matchByte; \ + bit = offs; \ + offs &= matchByte; \ + probLit = prob + (offs + bit + symbol); \ + GET_BIT2(probLit, symbol, offs ^= bit; , ;) + +#endif // _LZMA_DEC_OPT + + +#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_INPUT_EOF; range <<= 8; code = (code << 8) | (*buf++); } + +#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound) +#define UPDATE_0_CHECK range = bound; +#define UPDATE_1_CHECK range -= bound; code -= bound; +#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ + { UPDATE_0_CHECK; i = (i + i); A0; } else \ + { UPDATE_1_CHECK; i = (i + i) + 1; A1; } +#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) +#define TREE_DECODE_CHECK(probs, limit, i) \ + { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } + + +#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \ + { UPDATE_0_CHECK; i += m; m += m; } else \ + { UPDATE_1_CHECK; m += m; i += m; } + + +#define kNumPosBitsMax 4 +#define kNumPosStatesMax (1 << kNumPosBitsMax) + +#define kLenNumLowBits 3 +#define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumHighBits 8 +#define kLenNumHighSymbols (1 << kLenNumHighBits) + +#define LenLow 0 +#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits)) +#define kNumLenProbs (LenHigh + kLenNumHighSymbols) + +#define LenChoice LenLow +#define LenChoice2 (LenLow + (1 << kLenNumLowBits)) + +#define kNumStates 12 +#define kNumStates2 16 +#define kNumLitStates 7 + +#define kStartPosModelIndex 4 +#define kEndPosModelIndex 14 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + +#define kNumPosSlotBits 6 +#define kNumLenToPosStates 4 + +#define kNumAlignBits 4 +#define kAlignTableSize (1 << kNumAlignBits) + +#define kMatchMinLen 2 +#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols) + +#define kMatchSpecLen_Error_Data (1 << 9) +#define kMatchSpecLen_Error_Fail (kMatchSpecLen_Error_Data - 1) + +/* External ASM code needs same CLzmaProb array layout. So don't change it. */ + +/* (probs_1664) is faster and better for code size at some platforms */ +/* +#ifdef MY_CPU_X86_OR_AMD64 +*/ +#define kStartOffset 1664 +#define GET_PROBS p->probs_1664 +/* +#define GET_PROBS p->probs + kStartOffset +#else +#define kStartOffset 0 +#define GET_PROBS p->probs +#endif +*/ + +#define SpecPos (-kStartOffset) +#define IsRep0Long (SpecPos + kNumFullDistances) +#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax)) +#define LenCoder (RepLenCoder + kNumLenProbs) +#define IsMatch (LenCoder + kNumLenProbs) +#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax)) +#define IsRep (Align + kAlignTableSize) +#define IsRepG0 (IsRep + kNumStates) +#define IsRepG1 (IsRepG0 + kNumStates) +#define IsRepG2 (IsRepG1 + kNumStates) +#define PosSlot (IsRepG2 + kNumStates) +#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) +#define NUM_BASE_PROBS (Literal + kStartOffset) + +#if Align != 0 && kStartOffset != 0 + #error Stop_Compiling_Bad_LZMA_kAlign +#endif + +#if NUM_BASE_PROBS != 1984 + #error Stop_Compiling_Bad_LZMA_PROBS +#endif + + +#define LZMA_LIT_SIZE 0x300 + +#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) + + +#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4) +#define COMBINED_PS_STATE (posState + state) +#define GET_LEN_STATE (posState) + +#define LZMA_DIC_MIN (1 << 12) + +/* +p->remainLen : shows status of LZMA decoder: + < kMatchSpecLenStart : the number of bytes to be copied with (p->rep0) offset + = kMatchSpecLenStart : the LZMA stream was finished with end mark + = kMatchSpecLenStart + 1 : need init range coder + = kMatchSpecLenStart + 2 : need init range coder and state + = kMatchSpecLen_Error_Fail : Internal Code Failure + = kMatchSpecLen_Error_Data + [0 ... 273] : LZMA Data Error +*/ + +/* ---------- LZMA_DECODE_REAL ---------- */ +/* +LzmaDec_DecodeReal_3() can be implemented in external ASM file. +3 - is the code compatibility version of that function for check at link time. +*/ + +#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3 + +/* +LZMA_DECODE_REAL() +In: + RangeCoder is normalized + if (p->dicPos == limit) + { + LzmaDec_TryDummy() was called before to exclude LITERAL and MATCH-REP cases. + So first symbol can be only MATCH-NON-REP. And if that MATCH-NON-REP symbol + is not END_OF_PAYALOAD_MARKER, then the function doesn't write any byte to dictionary, + the function returns SZ_OK, and the caller can use (p->remainLen) and (p->reps[0]) later. + } + +Processing: + The first LZMA symbol will be decoded in any case. + All main checks for limits are at the end of main loop, + It decodes additional LZMA-symbols while (p->buf < bufLimit && dicPos < limit), + RangeCoder is still without last normalization when (p->buf < bufLimit) is being checked. + But if (p->buf < bufLimit), the caller provided at least (LZMA_REQUIRED_INPUT_MAX + 1) bytes for + next iteration before limit (bufLimit + LZMA_REQUIRED_INPUT_MAX), + that is enough for worst case LZMA symbol with one additional RangeCoder normalization for one bit. + So that function never reads bufLimit [LZMA_REQUIRED_INPUT_MAX] byte. + +Out: + RangeCoder is normalized + Result: + SZ_OK - OK + p->remainLen: + < kMatchSpecLenStart : the number of bytes to be copied with (p->reps[0]) offset + = kMatchSpecLenStart : the LZMA stream was finished with end mark + + SZ_ERROR_DATA - error, when the MATCH-Symbol refers out of dictionary + p->remainLen : undefined + p->reps[*] : undefined +*/ + + +#ifdef _LZMA_DEC_OPT + +int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit); + +#else + +static +int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit) +{ + CLzmaProb *probs = GET_PROBS; + unsigned state = (unsigned)p->state; + UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; + unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; + unsigned lc = p->prop.lc; + unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc); + + Byte *dic = p->dic; + SizeT dicBufSize = p->dicBufSize; + SizeT dicPos = p->dicPos; + + UInt32 processedPos = p->processedPos; + UInt32 checkDicSize = p->checkDicSize; + unsigned len = 0; + + const Byte *buf = p->buf; + UInt32 range = p->range; + UInt32 code = p->code; + + do + { + CLzmaProb *prob; + UInt32 bound; + unsigned ttt; + unsigned posState = CALC_POS_STATE(processedPos, pbMask); + + prob = probs + IsMatch + COMBINED_PS_STATE; + IF_BIT_0(prob) + { + unsigned symbol; + UPDATE_0(prob); + prob = probs + Literal; + if (processedPos != 0 || checkDicSize != 0) + prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc); + processedPos++; + + if (state < kNumLitStates) + { + state -= (state < 4) ? state : 3; + symbol = 1; + #ifdef _LZMA_SIZE_OPT + do { NORMAL_LITER_DEC } while (symbol < 0x100); + #else + NORMAL_LITER_DEC + NORMAL_LITER_DEC + NORMAL_LITER_DEC + NORMAL_LITER_DEC + NORMAL_LITER_DEC + NORMAL_LITER_DEC + NORMAL_LITER_DEC + NORMAL_LITER_DEC + #endif + } + else + { + unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; + unsigned offs = 0x100; + state -= (state < 10) ? 3 : 6; + symbol = 1; + #ifdef _LZMA_SIZE_OPT + do + { + unsigned bit; + CLzmaProb *probLit; + MATCHED_LITER_DEC + } + while (symbol < 0x100); + #else + { + unsigned bit; + CLzmaProb *probLit; + MATCHED_LITER_DEC + MATCHED_LITER_DEC + MATCHED_LITER_DEC + MATCHED_LITER_DEC + MATCHED_LITER_DEC + MATCHED_LITER_DEC + MATCHED_LITER_DEC + MATCHED_LITER_DEC + } + #endif + } + + dic[dicPos++] = (Byte)symbol; + continue; + } + + { + UPDATE_1(prob); + prob = probs + IsRep + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + state += kNumStates; + prob = probs + LenCoder; + } + else + { + UPDATE_1(prob); + prob = probs + IsRepG0 + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + prob = probs + IsRep0Long + COMBINED_PS_STATE; + IF_BIT_0(prob) + { + UPDATE_0(prob); + + // that case was checked before with kBadRepCode + // if (checkDicSize == 0 && processedPos == 0) { len = kMatchSpecLen_Error_Data + 1; break; } + // The caller doesn't allow (dicPos == limit) case here + // so we don't need the following check: + // if (dicPos == limit) { state = state < kNumLitStates ? 9 : 11; len = 1; break; } + + dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; + dicPos++; + processedPos++; + state = state < kNumLitStates ? 9 : 11; + continue; + } + UPDATE_1(prob); + } + else + { + UInt32 distance; + UPDATE_1(prob); + prob = probs + IsRepG1 + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + distance = rep1; + } + else + { + UPDATE_1(prob); + prob = probs + IsRepG2 + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + distance = rep2; + } + else + { + UPDATE_1(prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < kNumLitStates ? 8 : 11; + prob = probs + RepLenCoder; + } + + #ifdef _LZMA_SIZE_OPT + { + unsigned lim, offset; + CLzmaProb *probLen = prob + LenChoice; + IF_BIT_0(probLen) + { + UPDATE_0(probLen); + probLen = prob + LenLow + GET_LEN_STATE; + offset = 0; + lim = (1 << kLenNumLowBits); + } + else + { + UPDATE_1(probLen); + probLen = prob + LenChoice2; + IF_BIT_0(probLen) + { + UPDATE_0(probLen); + probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); + offset = kLenNumLowSymbols; + lim = (1 << kLenNumLowBits); + } + else + { + UPDATE_1(probLen); + probLen = prob + LenHigh; + offset = kLenNumLowSymbols * 2; + lim = (1 << kLenNumHighBits); + } + } + TREE_DECODE(probLen, lim, len); + len += offset; + } + #else + { + CLzmaProb *probLen = prob + LenChoice; + IF_BIT_0(probLen) + { + UPDATE_0(probLen); + probLen = prob + LenLow + GET_LEN_STATE; + len = 1; + TREE_GET_BIT(probLen, len); + TREE_GET_BIT(probLen, len); + TREE_GET_BIT(probLen, len); + len -= 8; + } + else + { + UPDATE_1(probLen); + probLen = prob + LenChoice2; + IF_BIT_0(probLen) + { + UPDATE_0(probLen); + probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); + len = 1; + TREE_GET_BIT(probLen, len); + TREE_GET_BIT(probLen, len); + TREE_GET_BIT(probLen, len); + } + else + { + UPDATE_1(probLen); + probLen = prob + LenHigh; + TREE_DECODE(probLen, (1 << kLenNumHighBits), len); + len += kLenNumLowSymbols * 2; + } + } + } + #endif + + if (state >= kNumStates) + { + UInt32 distance; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); + TREE_6_DECODE(prob, distance); + if (distance >= kStartPosModelIndex) + { + unsigned posSlot = (unsigned)distance; + unsigned numDirectBits = (unsigned)(((distance >> 1) - 1)); + distance = (2 | (distance & 1)); + if (posSlot < kEndPosModelIndex) + { + distance <<= numDirectBits; + prob = probs + SpecPos; + { + UInt32 m = 1; + distance++; + do + { + REV_BIT_VAR(prob, distance, m); + } + while (--numDirectBits); + distance -= m; + } + } + else + { + numDirectBits -= kNumAlignBits; + do + { + NORMALIZE + range >>= 1; + + { + UInt32 t; + code -= range; + t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ + distance = (distance << 1) + (t + 1); + code += range & t; + } + /* + distance <<= 1; + if (code >= range) + { + code -= range; + distance |= 1; + } + */ + } + while (--numDirectBits); + prob = probs + Align; + distance <<= kNumAlignBits; + { + unsigned i = 1; + REV_BIT_CONST(prob, i, 1); + REV_BIT_CONST(prob, i, 2); + REV_BIT_CONST(prob, i, 4); + REV_BIT_LAST (prob, i, 8); + distance |= i; + } + if (distance == (UInt32)0xFFFFFFFF) + { + len = kMatchSpecLenStart; + state -= kNumStates; + break; + } + } + } + + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance + 1; + state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; + if (distance >= (checkDicSize == 0 ? processedPos: checkDicSize)) + { + len += kMatchSpecLen_Error_Data + kMatchMinLen; + // len = kMatchSpecLen_Error_Data; + // len += kMatchMinLen; + break; + } + } + + len += kMatchMinLen; + + { + SizeT rem; + unsigned curLen; + SizeT pos; + + if ((rem = limit - dicPos) == 0) + { + /* + We stop decoding and return SZ_OK, and we can resume decoding later. + Any error conditions can be tested later in caller code. + For more strict mode we can stop decoding with error + // len += kMatchSpecLen_Error_Data; + */ + break; + } + + curLen = ((rem < len) ? (unsigned)rem : len); + pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0); + + processedPos += (UInt32)curLen; + + len -= curLen; + if (curLen <= dicBufSize - pos) + { + Byte *dest = dic + dicPos; + ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; + const Byte *lim = dest + curLen; + dicPos += (SizeT)curLen; + do + *(dest) = (Byte)*(dest + src); + while (++dest != lim); + } + else + { + do + { + dic[dicPos++] = dic[pos]; + if (++pos == dicBufSize) + pos = 0; + } + while (--curLen != 0); + } + } + } + } + while (dicPos < limit && buf < bufLimit); + + NORMALIZE; + + p->buf = buf; + p->range = range; + p->code = code; + p->remainLen = (UInt32)len; // & (kMatchSpecLen_Error_Data - 1); // we can write real length for error matches too. + p->dicPos = dicPos; + p->processedPos = processedPos; + p->reps[0] = rep0; + p->reps[1] = rep1; + p->reps[2] = rep2; + p->reps[3] = rep3; + p->state = (UInt32)state; + if (len >= kMatchSpecLen_Error_Data) + return SZ_ERROR_DATA; + return SZ_OK; +} +#endif + + + +static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) +{ + unsigned len = (unsigned)p->remainLen; + if (len == 0 /* || len >= kMatchSpecLenStart */) + return; + { + SizeT dicPos = p->dicPos; + Byte *dic; + SizeT dicBufSize; + SizeT rep0; /* we use SizeT to avoid the BUG of VC14 for AMD64 */ + { + SizeT rem = limit - dicPos; + if (rem < len) + { + len = (unsigned)(rem); + if (len == 0) + return; + } + } + + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) + p->checkDicSize = p->prop.dicSize; + + p->processedPos += (UInt32)len; + p->remainLen -= (UInt32)len; + dic = p->dic; + rep0 = p->reps[0]; + dicBufSize = p->dicBufSize; + do + { + dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)]; + dicPos++; + } + while (--len); + p->dicPos = dicPos; + } +} + + +/* +At staring of new stream we have one of the following symbols: + - Literal - is allowed + - Non-Rep-Match - is allowed only if it's end marker symbol + - Rep-Match - is not allowed +We use early check of (RangeCoder:Code) over kBadRepCode to simplify main decoding code +*/ + +#define kRange0 0xFFFFFFFF +#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)) +#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))) +#if kBadRepCode != (0xC0000000 - 0x400) + #error Stop_Compiling_Bad_LZMA_Check +#endif + + +/* +LzmaDec_DecodeReal2(): + It calls LZMA_DECODE_REAL() and it adjusts limit according (p->checkDicSize). + +We correct (p->checkDicSize) after LZMA_DECODE_REAL() and in LzmaDec_WriteRem(), +and we support the following state of (p->checkDicSize): + if (total_processed < p->prop.dicSize) then + { + (total_processed == p->processedPos) + (p->checkDicSize == 0) + } + else + (p->checkDicSize == p->prop.dicSize) +*/ + +static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) +{ + if (p->checkDicSize == 0) + { + UInt32 rem = p->prop.dicSize - p->processedPos; + if (limit - p->dicPos > rem) + limit = p->dicPos + rem; + } + { + int res = LZMA_DECODE_REAL(p, limit, bufLimit); + if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize) + p->checkDicSize = p->prop.dicSize; + return res; + } +} + + + +typedef enum +{ + DUMMY_INPUT_EOF, /* need more input data */ + DUMMY_LIT, + DUMMY_MATCH, + DUMMY_REP +} ELzmaDummy; + + +#define IS_DUMMY_END_MARKER_POSSIBLE(dummyRes) ((dummyRes) == DUMMY_MATCH) + +static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, const Byte **bufOut) +{ + UInt32 range = p->range; + UInt32 code = p->code; + const Byte *bufLimit = *bufOut; + const CLzmaProb *probs = GET_PROBS; + unsigned state = (unsigned)p->state; + ELzmaDummy res; + + for (;;) + { + const CLzmaProb *prob; + UInt32 bound; + unsigned ttt; + unsigned posState = CALC_POS_STATE(p->processedPos, ((unsigned)1 << p->prop.pb) - 1); + + prob = probs + IsMatch + COMBINED_PS_STATE; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK + + prob = probs + Literal; + if (p->checkDicSize != 0 || p->processedPos != 0) + prob += ((UInt32)LZMA_LIT_SIZE * + ((((p->processedPos) & (((unsigned)1 << (p->prop.lp)) - 1)) << p->prop.lc) + + ((unsigned)p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); + + if (state < kNumLitStates) + { + unsigned symbol = 1; + do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); + } + else + { + unsigned matchByte = p->dic[p->dicPos - p->reps[0] + + (p->dicPos < p->reps[0] ? p->dicBufSize : 0)]; + unsigned offs = 0x100; + unsigned symbol = 1; + do + { + unsigned bit; + const CLzmaProb *probLit; + matchByte += matchByte; + bit = offs; + offs &= matchByte; + probLit = prob + (offs + bit + symbol); + GET_BIT2_CHECK(probLit, symbol, offs ^= bit; , ; ) + } + while (symbol < 0x100); + } + res = DUMMY_LIT; + } + else + { + unsigned len; + UPDATE_1_CHECK; + + prob = probs + IsRep + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + state = 0; + prob = probs + LenCoder; + res = DUMMY_MATCH; + } + else + { + UPDATE_1_CHECK; + res = DUMMY_REP; + prob = probs + IsRepG0 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + prob = probs + IsRep0Long + COMBINED_PS_STATE; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + break; + } + else + { + UPDATE_1_CHECK; + } + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG1 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG2 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + } + } + } + state = kNumStates; + prob = probs + RepLenCoder; + } + { + unsigned limit, offset; + const CLzmaProb *probLen = prob + LenChoice; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenLow + GET_LEN_STATE; + offset = 0; + limit = 1 << kLenNumLowBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenChoice2; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits); + offset = kLenNumLowSymbols; + limit = 1 << kLenNumLowBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenHigh; + offset = kLenNumLowSymbols * 2; + limit = 1 << kLenNumHighBits; + } + } + TREE_DECODE_CHECK(probLen, limit, len); + len += offset; + } + + if (state < 4) + { + unsigned posSlot; + prob = probs + PosSlot + + ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) << + kNumPosSlotBits); + TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); + if (posSlot >= kStartPosModelIndex) + { + unsigned numDirectBits = ((posSlot >> 1) - 1); + + if (posSlot < kEndPosModelIndex) + { + prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits); + } + else + { + numDirectBits -= kNumAlignBits; + do + { + NORMALIZE_CHECK + range >>= 1; + code -= range & (((code - range) >> 31) - 1); + /* if (code >= range) code -= range; */ + } + while (--numDirectBits); + prob = probs + Align; + numDirectBits = kNumAlignBits; + } + { + unsigned i = 1; + unsigned m = 1; + do + { + REV_BIT_CHECK(prob, i, m); + } + while (--numDirectBits); + } + } + } + } + break; + } + NORMALIZE_CHECK; + + *bufOut = buf; + return res; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState); +void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState) +{ + p->remainLen = kMatchSpecLenStart + 1; + p->tempBufSize = 0; + + if (initDic) + { + p->processedPos = 0; + p->checkDicSize = 0; + p->remainLen = kMatchSpecLenStart + 2; + } + if (initState) + p->remainLen = kMatchSpecLenStart + 2; +} + +void LzmaDec_Init(CLzmaDec *p) +{ + p->dicPos = 0; + LzmaDec_InitDicAndState(p, True, True); +} + + +/* +LZMA supports optional end_marker. +So the decoder can lookahead for one additional LZMA-Symbol to check end_marker. +That additional LZMA-Symbol can require up to LZMA_REQUIRED_INPUT_MAX bytes in input stream. +When the decoder reaches dicLimit, it looks (finishMode) parameter: + if (finishMode == LZMA_FINISH_ANY), the decoder doesn't lookahead + if (finishMode != LZMA_FINISH_ANY), the decoder lookahead, if end_marker is possible for current position + +When the decoder lookahead, and the lookahead symbol is not end_marker, we have two ways: + 1) Strict mode (default) : the decoder returns SZ_ERROR_DATA. + 2) The relaxed mode (alternative mode) : we could return SZ_OK, and the caller + must check (status) value. The caller can show the error, + if the end of stream is expected, and the (status) is noit + LZMA_STATUS_FINISHED_WITH_MARK or LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK. +*/ + + +#define RETURN__NOT_FINISHED__FOR_FINISH \ + *status = LZMA_STATUS_NOT_FINISHED; \ + return SZ_ERROR_DATA; // for strict mode + // return SZ_OK; // for relaxed mode + + +SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + SizeT inSize = *srcLen; + (*srcLen) = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + + if (p->remainLen > kMatchSpecLenStart) + { + if (p->remainLen > kMatchSpecLenStart + 2) + return p->remainLen == kMatchSpecLen_Error_Fail ? SZ_ERROR_FAIL : SZ_ERROR_DATA; + + for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) + p->tempBuf[p->tempBufSize++] = *src++; + if (p->tempBufSize != 0 && p->tempBuf[0] != 0) + return SZ_ERROR_DATA; + if (p->tempBufSize < RC_INIT_SIZE) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + p->code = + ((UInt32)p->tempBuf[1] << 24) + | ((UInt32)p->tempBuf[2] << 16) + | ((UInt32)p->tempBuf[3] << 8) + | ((UInt32)p->tempBuf[4]); + + if (p->checkDicSize == 0 + && p->processedPos == 0 + && p->code >= kBadRepCode) + return SZ_ERROR_DATA; + + p->range = 0xFFFFFFFF; + p->tempBufSize = 0; + + if (p->remainLen > kMatchSpecLenStart + 1) + { + SizeT numProbs = LzmaProps_GetNumProbs(&p->prop); + SizeT i; + CLzmaProb *probs = p->probs; + for (i = 0; i < numProbs; i++) + probs[i] = kBitModelTotal >> 1; + p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; + p->state = 0; + } + + p->remainLen = 0; + } + + for (;;) + { + if (p->remainLen == kMatchSpecLenStart) + { + if (p->code != 0) + return SZ_ERROR_DATA; + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return SZ_OK; + } + + LzmaDec_WriteRem(p, dicLimit); + + { + // (p->remainLen == 0 || p->dicPos == dicLimit) + + int checkEndMarkNow = 0; + + if (p->dicPos >= dicLimit) + { + if (p->remainLen == 0 && p->code == 0) + { + *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; + return SZ_OK; + } + if (finishMode == LZMA_FINISH_ANY) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->remainLen != 0) + { + RETURN__NOT_FINISHED__FOR_FINISH; + } + checkEndMarkNow = 1; + } + + // (p->remainLen == 0) + + if (p->tempBufSize == 0) + { + const Byte *bufLimit; + int dummyProcessed = -1; + + if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) + { + const Byte *bufOut = src + inSize; + + ELzmaDummy dummyRes = LzmaDec_TryDummy(p, src, &bufOut); + + if (dummyRes == DUMMY_INPUT_EOF) + { + size_t i; + if (inSize >= LZMA_REQUIRED_INPUT_MAX) + break; + (*srcLen) += inSize; + p->tempBufSize = (unsigned)inSize; + for (i = 0; i < inSize; i++) + p->tempBuf[i] = src[i]; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + dummyProcessed = (int)(bufOut - src); + if ((unsigned)dummyProcessed > LZMA_REQUIRED_INPUT_MAX) + break; + + if (checkEndMarkNow && !IS_DUMMY_END_MARKER_POSSIBLE(dummyRes)) + { + unsigned i; + (*srcLen) += (unsigned)dummyProcessed; + p->tempBufSize = (unsigned)dummyProcessed; + for (i = 0; i < (unsigned)dummyProcessed; i++) + p->tempBuf[i] = src[i]; + // p->remainLen = kMatchSpecLen_Error_Data; + RETURN__NOT_FINISHED__FOR_FINISH; + } + + bufLimit = src; + // we will decode only one iteration + } + else + bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; + + p->buf = src; + + { + int res = LzmaDec_DecodeReal2(p, dicLimit, bufLimit); + + SizeT processed = (SizeT)(p->buf - src); + + if (dummyProcessed < 0) + { + if (processed > inSize) + break; + } + else if ((unsigned)dummyProcessed != processed) + break; + + src += processed; + inSize -= processed; + (*srcLen) += processed; + + if (res != SZ_OK) + { + p->remainLen = kMatchSpecLen_Error_Data; + return SZ_ERROR_DATA; + } + } + continue; + } + + { + // we have some data in (p->tempBuf) + // in strict mode: tempBufSize is not enough for one Symbol decoding. + // in relaxed mode: tempBufSize not larger than required for one Symbol decoding. + + unsigned rem = p->tempBufSize; + unsigned ahead = 0; + int dummyProcessed = -1; + + while (rem < LZMA_REQUIRED_INPUT_MAX && ahead < inSize) + p->tempBuf[rem++] = src[ahead++]; + + // ahead - the size of new data copied from (src) to (p->tempBuf) + // rem - the size of temp buffer including new data from (src) + + if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) + { + const Byte *bufOut = p->tempBuf + rem; + + ELzmaDummy dummyRes = LzmaDec_TryDummy(p, p->tempBuf, &bufOut); + + if (dummyRes == DUMMY_INPUT_EOF) + { + if (rem >= LZMA_REQUIRED_INPUT_MAX) + break; + p->tempBufSize = rem; + (*srcLen) += (SizeT)ahead; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + dummyProcessed = (int)(bufOut - p->tempBuf); + + if ((unsigned)dummyProcessed < p->tempBufSize) + break; + + if (checkEndMarkNow && !IS_DUMMY_END_MARKER_POSSIBLE(dummyRes)) + { + (*srcLen) += (unsigned)dummyProcessed - p->tempBufSize; + p->tempBufSize = (unsigned)dummyProcessed; + // p->remainLen = kMatchSpecLen_Error_Data; + RETURN__NOT_FINISHED__FOR_FINISH; + } + } + + p->buf = p->tempBuf; + + { + // we decode one symbol from (p->tempBuf) here, so the (bufLimit) is equal to (p->buf) + int res = LzmaDec_DecodeReal2(p, dicLimit, p->buf); + + SizeT processed = (SizeT)(p->buf - p->tempBuf); + rem = p->tempBufSize; + + if (dummyProcessed < 0) + { + if (processed > LZMA_REQUIRED_INPUT_MAX) + break; + if (processed < rem) + break; + } + else if ((unsigned)dummyProcessed != processed) + break; + + processed -= rem; + + src += processed; + inSize -= processed; + (*srcLen) += processed; + p->tempBufSize = 0; + + if (res != SZ_OK) + { + p->remainLen = kMatchSpecLen_Error_Data; + return SZ_ERROR_DATA; + } + } + } + } + } + + /* Some unexpected error: internal error of code, memory corruption or hardware failure */ + p->remainLen = kMatchSpecLen_Error_Fail; + return SZ_ERROR_FAIL; +} + + + +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + SizeT outSize = *destLen; + SizeT inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) + { + SizeT inSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->dicPos == p->dicBufSize) + p->dicPos = 0; + dicPos = p->dicPos; + if (outSize > p->dicBufSize - dicPos) + { + outSizeCur = p->dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } + else + { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } + + res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); + src += inSizeCur; + inSize -= inSizeCur; + *srcLen += inSizeCur; + outSizeCur = p->dicPos - dicPos; + memcpy(dest, p->dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; + } +} + +void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->probs); + p->probs = NULL; +} + +static void LzmaDec_FreeDict(CLzmaDec *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->dic); + p->dic = NULL; +} + +void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc) +{ + LzmaDec_FreeProbs(p, alloc); + LzmaDec_FreeDict(p, alloc); +} + +SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) +{ + UInt32 dicSize; + Byte d; + + if (size < LZMA_PROPS_SIZE) + return SZ_ERROR_UNSUPPORTED; + else + dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); + + if (dicSize < LZMA_DIC_MIN) + dicSize = LZMA_DIC_MIN; + p->dicSize = dicSize; + + d = data[0]; + if (d >= (9 * 5 * 5)) + return SZ_ERROR_UNSUPPORTED; + + p->lc = (Byte)(d % 9); + d /= 9; + p->pb = (Byte)(d / 5); + p->lp = (Byte)(d % 5); + + return SZ_OK; +} + +static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc) +{ + UInt32 numProbs = LzmaProps_GetNumProbs(propNew); + if (!p->probs || numProbs != p->numProbs) + { + LzmaDec_FreeProbs(p, alloc); + p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb)); + if (!p->probs) + return SZ_ERROR_MEM; + p->probs_1664 = p->probs + 1664; + p->numProbs = numProbs; + } + return SZ_OK; +} + +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) +{ + CLzmaProps propNew; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + p->prop = propNew; + return SZ_OK; +} + +SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc) +{ + CLzmaProps propNew; + SizeT dicBufSize; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + + { + UInt32 dictSize = propNew.dicSize; + SizeT mask = ((UInt32)1 << 12) - 1; + if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1; + else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;; + dicBufSize = ((SizeT)dictSize + mask) & ~mask; + if (dicBufSize < dictSize) + dicBufSize = dictSize; + } + + if (!p->dic || dicBufSize != p->dicBufSize) + { + LzmaDec_FreeDict(p, alloc); + p->dic = (Byte *)ISzAlloc_Alloc(alloc, dicBufSize); + if (!p->dic) + { + LzmaDec_FreeProbs(p, alloc); + return SZ_ERROR_MEM; + } + } + p->dicBufSize = dicBufSize; + p->prop = propNew; + return SZ_OK; +} + +SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAllocPtr alloc) +{ + CLzmaDec p; + SRes res; + SizeT outSize = *destLen, inSize = *srcLen; + *destLen = *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + if (inSize < RC_INIT_SIZE) + return SZ_ERROR_INPUT_EOF; + LzmaDec_Construct(&p); + RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc)); + p.dic = dest; + p.dicBufSize = outSize; + LzmaDec_Init(&p); + *srcLen = inSize; + res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); + *destLen = p.dicPos; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + LzmaDec_FreeProbs(&p, alloc); + return res; +} diff --git a/deps/LZMA-SDK/C/LzmaDec.h b/deps/LZMA-SDK/C/LzmaDec.h index 6194b7d12..6f1296250 100644 --- a/deps/LZMA-SDK/C/LzmaDec.h +++ b/deps/LZMA-SDK/C/LzmaDec.h @@ -1,236 +1,236 @@ -/* LzmaDec.h -- LZMA Decoder -2020-03-19 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_DEC_H -#define __LZMA_DEC_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -/* #define _LZMA_PROB32 */ -/* _LZMA_PROB32 can increase the speed on some CPUs, - but memory usage for CLzmaDec::probs will be doubled in that case */ - -typedef -#ifdef _LZMA_PROB32 - UInt32 -#else - UInt16 -#endif - CLzmaProb; - - -/* ---------- LZMA Properties ---------- */ - -#define LZMA_PROPS_SIZE 5 - -typedef struct _CLzmaProps -{ - Byte lc; - Byte lp; - Byte pb; - Byte _pad_; - UInt32 dicSize; -} CLzmaProps; - -/* LzmaProps_Decode - decodes properties -Returns: - SZ_OK - SZ_ERROR_UNSUPPORTED - Unsupported properties -*/ - -SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); - - -/* ---------- LZMA Decoder state ---------- */ - -/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. - Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ - -#define LZMA_REQUIRED_INPUT_MAX 20 - -typedef struct -{ - /* Don't change this structure. ASM code can use it. */ - CLzmaProps prop; - CLzmaProb *probs; - CLzmaProb *probs_1664; - Byte *dic; - SizeT dicBufSize; - SizeT dicPos; - const Byte *buf; - UInt32 range; - UInt32 code; - UInt32 processedPos; - UInt32 checkDicSize; - UInt32 reps[4]; - UInt32 state; - UInt32 remainLen; - - UInt32 numProbs; - unsigned tempBufSize; - Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; -} CLzmaDec; - -#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; } - -void LzmaDec_Init(CLzmaDec *p); - -/* There are two types of LZMA streams: - - Stream with end mark. That end mark adds about 6 bytes to compressed size. - - Stream without end mark. You must know exact uncompressed size to decompress such stream. */ - -typedef enum -{ - LZMA_FINISH_ANY, /* finish at any point */ - LZMA_FINISH_END /* block must be finished at the end */ -} ELzmaFinishMode; - -/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! - - You must use LZMA_FINISH_END, when you know that current output buffer - covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. - - If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, - and output value of destLen will be less than output buffer size limit. - You can check status result also. - - You can use multiple checks to test data integrity after full decompression: - 1) Check Result and "status" variable. - 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. - 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. - You must use correct finish mode in that case. */ - -typedef enum -{ - LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ - LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ - LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ - LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ -} ELzmaStatus; - -/* ELzmaStatus is used only as output value for function call */ - - -/* ---------- Interfaces ---------- */ - -/* There are 3 levels of interfaces: - 1) Dictionary Interface - 2) Buffer Interface - 3) One Call Interface - You can select any of these interfaces, but don't mix functions from different - groups for same object. */ - - -/* There are two variants to allocate state for Dictionary Interface: - 1) LzmaDec_Allocate / LzmaDec_Free - 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs - You can use variant 2, if you set dictionary buffer manually. - For Buffer Interface you must always use variant 1. - -LzmaDec_Allocate* can return: - SZ_OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties -*/ - -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc); -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc); - -SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc); -void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc); - -/* ---------- Dictionary Interface ---------- */ - -/* You can use it, if you want to eliminate the overhead for data copying from - dictionary to some other external buffer. - You must work with CLzmaDec variables directly in this interface. - - STEPS: - LzmaDec_Construct() - LzmaDec_Allocate() - for (each new stream) - { - LzmaDec_Init() - while (it needs more decompression) - { - LzmaDec_DecodeToDic() - use data from CLzmaDec::dic and update CLzmaDec::dicPos - } - } - LzmaDec_Free() -*/ - -/* LzmaDec_DecodeToDic - - The decoding to internal dictionary buffer (CLzmaDec::dic). - You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! - -finishMode: - It has meaning only if the decoding reaches output limit (dicLimit). - LZMA_FINISH_ANY - Decode just dicLimit bytes. - LZMA_FINISH_END - Stream must be finished after dicLimit. - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_NEEDS_MORE_INPUT - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK - SZ_ERROR_DATA - Data error - SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure -*/ - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- Buffer Interface ---------- */ - -/* It's zlib-like interface. - See LzmaDec_DecodeToDic description for information about STEPS and return results, - but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need - to work with CLzmaDec variables manually. - -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - Decode just destLen bytes. - LZMA_FINISH_END - Stream must be finished after (*destLen). -*/ - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- One Call Interface ---------- */ - -/* LzmaDecode - -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - Decode just destLen bytes. - LZMA_FINISH_END - Stream must be finished after (*destLen). - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). - SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure -*/ - -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAllocPtr alloc); - -EXTERN_C_END - -#endif +/* LzmaDec.h -- LZMA Decoder +2020-03-19 : Igor Pavlov : Public domain */ + +#ifndef __LZMA_DEC_H +#define __LZMA_DEC_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +/* #define _LZMA_PROB32 */ +/* _LZMA_PROB32 can increase the speed on some CPUs, + but memory usage for CLzmaDec::probs will be doubled in that case */ + +typedef +#ifdef _LZMA_PROB32 + UInt32 +#else + UInt16 +#endif + CLzmaProb; + + +/* ---------- LZMA Properties ---------- */ + +#define LZMA_PROPS_SIZE 5 + +typedef struct _CLzmaProps +{ + Byte lc; + Byte lp; + Byte pb; + Byte _pad_; + UInt32 dicSize; +} CLzmaProps; + +/* LzmaProps_Decode - decodes properties +Returns: + SZ_OK + SZ_ERROR_UNSUPPORTED - Unsupported properties +*/ + +SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); + + +/* ---------- LZMA Decoder state ---------- */ + +/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. + Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ + +#define LZMA_REQUIRED_INPUT_MAX 20 + +typedef struct +{ + /* Don't change this structure. ASM code can use it. */ + CLzmaProps prop; + CLzmaProb *probs; + CLzmaProb *probs_1664; + Byte *dic; + SizeT dicBufSize; + SizeT dicPos; + const Byte *buf; + UInt32 range; + UInt32 code; + UInt32 processedPos; + UInt32 checkDicSize; + UInt32 reps[4]; + UInt32 state; + UInt32 remainLen; + + UInt32 numProbs; + unsigned tempBufSize; + Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; +} CLzmaDec; + +#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; } + +void LzmaDec_Init(CLzmaDec *p); + +/* There are two types of LZMA streams: + - Stream with end mark. That end mark adds about 6 bytes to compressed size. + - Stream without end mark. You must know exact uncompressed size to decompress such stream. */ + +typedef enum +{ + LZMA_FINISH_ANY, /* finish at any point */ + LZMA_FINISH_END /* block must be finished at the end */ +} ELzmaFinishMode; + +/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! + + You must use LZMA_FINISH_END, when you know that current output buffer + covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. + + If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, + and output value of destLen will be less than output buffer size limit. + You can check status result also. + + You can use multiple checks to test data integrity after full decompression: + 1) Check Result and "status" variable. + 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. + 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. + You must use correct finish mode in that case. */ + +typedef enum +{ + LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ + LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ + LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ + LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ +} ELzmaStatus; + +/* ELzmaStatus is used only as output value for function call */ + + +/* ---------- Interfaces ---------- */ + +/* There are 3 levels of interfaces: + 1) Dictionary Interface + 2) Buffer Interface + 3) One Call Interface + You can select any of these interfaces, but don't mix functions from different + groups for same object. */ + + +/* There are two variants to allocate state for Dictionary Interface: + 1) LzmaDec_Allocate / LzmaDec_Free + 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs + You can use variant 2, if you set dictionary buffer manually. + For Buffer Interface you must always use variant 1. + +LzmaDec_Allocate* can return: + SZ_OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties +*/ + +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc); +void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc); + +SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc); +void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc); + +/* ---------- Dictionary Interface ---------- */ + +/* You can use it, if you want to eliminate the overhead for data copying from + dictionary to some other external buffer. + You must work with CLzmaDec variables directly in this interface. + + STEPS: + LzmaDec_Construct() + LzmaDec_Allocate() + for (each new stream) + { + LzmaDec_Init() + while (it needs more decompression) + { + LzmaDec_DecodeToDic() + use data from CLzmaDec::dic and update CLzmaDec::dicPos + } + } + LzmaDec_Free() +*/ + +/* LzmaDec_DecodeToDic + + The decoding to internal dictionary buffer (CLzmaDec::dic). + You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! + +finishMode: + It has meaning only if the decoding reaches output limit (dicLimit). + LZMA_FINISH_ANY - Decode just dicLimit bytes. + LZMA_FINISH_END - Stream must be finished after dicLimit. + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_NEEDS_MORE_INPUT + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + SZ_ERROR_DATA - Data error + SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure +*/ + +SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- Buffer Interface ---------- */ + +/* It's zlib-like interface. + See LzmaDec_DecodeToDic description for information about STEPS and return results, + but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need + to work with CLzmaDec variables manually. + +finishMode: + It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - Decode just destLen bytes. + LZMA_FINISH_END - Stream must be finished after (*destLen). +*/ + +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- One Call Interface ---------- */ + +/* LzmaDecode + +finishMode: + It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - Decode just destLen bytes. + LZMA_FINISH_END - Stream must be finished after (*destLen). + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). + SZ_ERROR_FAIL - Some unexpected error: internal error of code, memory corruption or hardware failure +*/ + +SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAllocPtr alloc); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/LzmaEnc.c b/deps/LZMA-SDK/C/LzmaEnc.c index 86dcb1963..c8b31a19e 100644 --- a/deps/LZMA-SDK/C/LzmaEnc.c +++ b/deps/LZMA-SDK/C/LzmaEnc.c @@ -1,3013 +1,3162 @@ -/* LzmaEnc.c -- LZMA Encoder -2021-04-01: Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -/* #define SHOW_STAT */ -/* #define SHOW_STAT2 */ - -#if defined(SHOW_STAT) || defined(SHOW_STAT2) -#include -#endif - -#include "LzmaEnc.h" - -#include "LzFind.h" -#ifndef _7ZIP_ST -#include "LzFindMt.h" -#endif - -/* the following LzmaEnc_* declarations is internal LZMA interface for LZMA2 encoder */ - -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize, - ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize); -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp); -void LzmaEnc_Finish(CLzmaEncHandle pp); -void LzmaEnc_SaveState(CLzmaEncHandle pp); -void LzmaEnc_RestoreState(CLzmaEncHandle pp); - -#ifdef SHOW_STAT -static unsigned g_STAT_OFFSET = 0; -#endif - -#define kLzmaMaxHistorySize ((UInt32)3 << 29) -/* #define kLzmaMaxHistorySize ((UInt32)7 << 29) */ - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 -#define kProbInitValue (kBitModelTotal >> 1) - -#define kNumMoveReducingBits 4 -#define kNumBitPriceShiftBits 4 -// #define kBitPrice (1 << kNumBitPriceShiftBits) - -#define REP_LEN_COUNT 64 - -void LzmaEncProps_Init(CLzmaEncProps *p) -{ - p->level = 5; - p->dictSize = p->mc = 0; - p->reduceSize = (UInt64)(Int64)-1; - p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; - p->writeEndMark = 0; - p->affinity = 0; -} - -void LzmaEncProps_Normalize(CLzmaEncProps *p) -{ - int level = p->level; - if (level < 0) level = 5; - p->level = level; - - if (p->dictSize == 0) - p->dictSize = - ( level <= 3 ? ((UInt32)1 << (level * 2 + 16)) : - ( level <= 6 ? ((UInt32)1 << (level + 19)) : - ( level <= 7 ? ((UInt32)1 << 25) : ((UInt32)1 << 26) - ))); - - if (p->dictSize > p->reduceSize) - { - unsigned i; - UInt32 reduceSize = (UInt32)p->reduceSize; - for (i = 11; i <= 30; i++) - { - if (reduceSize <= ((UInt32)2 << i)) { p->dictSize = ((UInt32)2 << i); break; } - if (reduceSize <= ((UInt32)3 << i)) { p->dictSize = ((UInt32)3 << i); break; } - } - } - - if (p->lc < 0) p->lc = 3; - if (p->lp < 0) p->lp = 0; - if (p->pb < 0) p->pb = 2; - - if (p->algo < 0) p->algo = (level < 5 ? 0 : 1); - if (p->fb < 0) p->fb = (level < 7 ? 32 : 64); - if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); - if (p->numHashBytes < 0) p->numHashBytes = (p->btMode ? 4 : 5); - if (p->mc == 0) p->mc = (16 + ((unsigned)p->fb >> 1)) >> (p->btMode ? 0 : 1); - - if (p->numThreads < 0) - p->numThreads = - #ifndef _7ZIP_ST - ((p->btMode && p->algo) ? 2 : 1); - #else - 1; - #endif -} - -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) -{ - CLzmaEncProps props = *props2; - LzmaEncProps_Normalize(&props); - return props.dictSize; -} - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -/* BSR code is fast for some new CPUs */ -/* #define LZMA_LOG_BSR */ -#endif - -#ifdef LZMA_LOG_BSR - -#define kDicLogSizeMaxCompress 32 - -#define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); res = (zz + zz) + ((pos >> (zz - 1)) & 1); } - -static unsigned GetPosSlot1(UInt32 pos) -{ - unsigned res; - BSR2_RET(pos, res); - return res; -} -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } -#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } - -#else - -#define kNumLogBits (9 + sizeof(size_t) / 2) -/* #define kNumLogBits (11 + sizeof(size_t) / 8 * 3) */ - -#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) - -static void LzmaEnc_FastPosInit(Byte *g_FastPos) -{ - unsigned slot; - g_FastPos[0] = 0; - g_FastPos[1] = 1; - g_FastPos += 2; - - for (slot = 2; slot < kNumLogBits * 2; slot++) - { - size_t k = ((size_t)1 << ((slot >> 1) - 1)); - size_t j; - for (j = 0; j < k; j++) - g_FastPos[j] = (Byte)slot; - g_FastPos += k; - } -} - -/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */ -/* -#define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ - (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ - res = p->g_FastPos[pos >> zz] + (zz * 2); } -*/ - -/* -#define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ - (0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \ - res = p->g_FastPos[pos >> zz] + (zz * 2); } -*/ - -#define BSR2_RET(pos, res) { unsigned zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \ - res = p->g_FastPos[pos >> zz] + (zz * 2); } - -/* -#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \ - p->g_FastPos[pos >> 6] + 12 : \ - p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; } -*/ - -#define GetPosSlot1(pos) p->g_FastPos[pos] -#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } -#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos & (kNumFullDistances - 1)]; else BSR2_RET(pos, res); } - -#endif - - -#define LZMA_NUM_REPS 4 - -typedef UInt16 CState; -typedef UInt16 CExtra; - -typedef struct -{ - UInt32 price; - CState state; - CExtra extra; - // 0 : normal - // 1 : LIT : MATCH - // > 1 : MATCH (extra-1) : LIT : REP0 (len) - UInt32 len; - UInt32 dist; - UInt32 reps[LZMA_NUM_REPS]; -} COptimal; - - -// 18.06 -#define kNumOpts (1 << 11) -#define kPackReserve (kNumOpts * 8) -// #define kNumOpts (1 << 12) -// #define kPackReserve (1 + kNumOpts * 2) - -#define kNumLenToPosStates 4 -#define kNumPosSlotBits 6 -// #define kDicLogSizeMin 0 -#define kDicLogSizeMax 32 -#define kDistTableSizeMax (kDicLogSizeMax * 2) - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) -#define kAlignMask (kAlignTableSize - 1) - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -typedef -#ifdef _LZMA_PROB32 - UInt32 -#else - UInt16 -#endif - CLzmaProb; - -#define LZMA_PB_MAX 4 -#define LZMA_LC_MAX 8 -#define LZMA_LP_MAX 4 - -#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) -#define kLenNumSymbolsTotal (kLenNumLowSymbols * 2 + kLenNumHighSymbols) - -#define LZMA_MATCH_LEN_MIN 2 -#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1) - -#define kNumStates 12 - - -typedef struct -{ - CLzmaProb low[LZMA_NUM_PB_STATES_MAX << (kLenNumLowBits + 1)]; - CLzmaProb high[kLenNumHighSymbols]; -} CLenEnc; - - -typedef struct -{ - unsigned tableSize; - UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; - // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2]; - // UInt32 prices2[kLenNumSymbolsTotal]; -} CLenPriceEnc; - -#define GET_PRICE_LEN(p, posState, len) \ - ((p)->prices[posState][(size_t)(len) - LZMA_MATCH_LEN_MIN]) - -/* -#define GET_PRICE_LEN(p, posState, len) \ - ((p)->prices2[(size_t)(len) - 2] + ((p)->prices1[posState][((len) - 2) & (kLenNumLowSymbols * 2 - 1)] & (((len) - 2 - kLenNumLowSymbols * 2) >> 9))) -*/ - -typedef struct -{ - UInt32 range; - unsigned cache; - UInt64 low; - UInt64 cacheSize; - Byte *buf; - Byte *bufLim; - Byte *bufBase; - ISeqOutStream *outStream; - UInt64 processed; - SRes res; -} CRangeEnc; - - -typedef struct -{ - CLzmaProb *litProbs; - - unsigned state; - UInt32 reps[LZMA_NUM_REPS]; - - CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - CLzmaProb isRep[kNumStates]; - CLzmaProb isRepG0[kNumStates]; - CLzmaProb isRepG1[kNumStates]; - CLzmaProb isRepG2[kNumStates]; - CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; - - CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; - CLzmaProb posEncoders[kNumFullDistances]; - - CLenEnc lenProbs; - CLenEnc repLenProbs; - -} CSaveState; - - -typedef UInt32 CProbPrice; - - -typedef struct -{ - void *matchFinderObj; - IMatchFinder matchFinder; - - unsigned optCur; - unsigned optEnd; - - unsigned longestMatchLen; - unsigned numPairs; - UInt32 numAvail; - - unsigned state; - unsigned numFastBytes; - unsigned additionalOffset; - UInt32 reps[LZMA_NUM_REPS]; - unsigned lpMask, pbMask; - CLzmaProb *litProbs; - CRangeEnc rc; - - UInt32 backRes; - - unsigned lc, lp, pb; - unsigned lclp; - - BoolInt fastMode; - BoolInt writeEndMark; - BoolInt finished; - BoolInt multiThread; - BoolInt needInit; - // BoolInt _maxMode; - - UInt64 nowPos64; - - unsigned matchPriceCount; - // unsigned alignPriceCount; - int repLenEncCounter; - - unsigned distTableSize; - - UInt32 dictSize; - SRes result; - - #ifndef _7ZIP_ST - BoolInt mtMode; - // begin of CMatchFinderMt is used in LZ thread - CMatchFinderMt matchFinderMt; - // end of CMatchFinderMt is used in BT and HASH threads - #endif - - CMatchFinder matchFinderBase; - - #ifndef _7ZIP_ST - Byte pad[128]; - #endif - - // LZ thread - CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; - - UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2 + 1]; - - UInt32 alignPrices[kAlignTableSize]; - UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; - UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; - - CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - CLzmaProb isRep[kNumStates]; - CLzmaProb isRepG0[kNumStates]; - CLzmaProb isRepG1[kNumStates]; - CLzmaProb isRepG2[kNumStates]; - CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; - CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; - CLzmaProb posEncoders[kNumFullDistances]; - - CLenEnc lenProbs; - CLenEnc repLenProbs; - - #ifndef LZMA_LOG_BSR - Byte g_FastPos[1 << kNumLogBits]; - #endif - - CLenPriceEnc lenEnc; - CLenPriceEnc repLenEnc; - - COptimal opt[kNumOpts]; - - CSaveState saveState; - - #ifndef _7ZIP_ST - Byte pad2[128]; - #endif -} CLzmaEnc; - - - -#define COPY_ARR(dest, src, arr) memcpy(dest->arr, src->arr, sizeof(src->arr)); - -void LzmaEnc_SaveState(CLzmaEncHandle pp) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - CSaveState *dest = &p->saveState; - - dest->state = p->state; - - dest->lenProbs = p->lenProbs; - dest->repLenProbs = p->repLenProbs; - - COPY_ARR(dest, p, reps); - - COPY_ARR(dest, p, posAlignEncoder); - COPY_ARR(dest, p, isRep); - COPY_ARR(dest, p, isRepG0); - COPY_ARR(dest, p, isRepG1); - COPY_ARR(dest, p, isRepG2); - COPY_ARR(dest, p, isMatch); - COPY_ARR(dest, p, isRep0Long); - COPY_ARR(dest, p, posSlotEncoder); - COPY_ARR(dest, p, posEncoders); - - memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << p->lclp) * sizeof(CLzmaProb)); -} - - -void LzmaEnc_RestoreState(CLzmaEncHandle pp) -{ - CLzmaEnc *dest = (CLzmaEnc *)pp; - const CSaveState *p = &dest->saveState; - - dest->state = p->state; - - dest->lenProbs = p->lenProbs; - dest->repLenProbs = p->repLenProbs; - - COPY_ARR(dest, p, reps); - - COPY_ARR(dest, p, posAlignEncoder); - COPY_ARR(dest, p, isRep); - COPY_ARR(dest, p, isRepG0); - COPY_ARR(dest, p, isRepG1); - COPY_ARR(dest, p, isRepG2); - COPY_ARR(dest, p, isMatch); - COPY_ARR(dest, p, isRep0Long); - COPY_ARR(dest, p, posSlotEncoder); - COPY_ARR(dest, p, posEncoders); - - memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << dest->lclp) * sizeof(CLzmaProb)); -} - - - -SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - CLzmaEncProps props = *props2; - LzmaEncProps_Normalize(&props); - - if (props.lc > LZMA_LC_MAX - || props.lp > LZMA_LP_MAX - || props.pb > LZMA_PB_MAX - || props.dictSize > ((UInt64)1 << kDicLogSizeMaxCompress) - || props.dictSize > kLzmaMaxHistorySize) - return SZ_ERROR_PARAM; - - p->dictSize = props.dictSize; - { - unsigned fb = (unsigned)props.fb; - if (fb < 5) - fb = 5; - if (fb > LZMA_MATCH_LEN_MAX) - fb = LZMA_MATCH_LEN_MAX; - p->numFastBytes = fb; - } - p->lc = (unsigned)props.lc; - p->lp = (unsigned)props.lp; - p->pb = (unsigned)props.pb; - p->fastMode = (props.algo == 0); - // p->_maxMode = True; - p->matchFinderBase.btMode = (Byte)(props.btMode ? 1 : 0); - { - unsigned numHashBytes = 4; - if (props.btMode) - { - if (props.numHashBytes < 2) numHashBytes = 2; - else if (props.numHashBytes < 4) numHashBytes = (unsigned)props.numHashBytes; - } - if (props.numHashBytes >= 5) numHashBytes = 5; - - p->matchFinderBase.numHashBytes = numHashBytes; - } - - p->matchFinderBase.cutValue = props.mc; - - p->writeEndMark = (BoolInt)props.writeEndMark; - - #ifndef _7ZIP_ST - /* - if (newMultiThread != _multiThread) - { - ReleaseMatchFinder(); - _multiThread = newMultiThread; - } - */ - p->multiThread = (props.numThreads > 1); - p->matchFinderMt.btSync.affinity = - p->matchFinderMt.hashSync.affinity = props.affinity; - #endif - - return SZ_OK; -} - - -void LzmaEnc_SetDataSize(CLzmaEncHandle pp, UInt64 expectedDataSiize) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - p->matchFinderBase.expectedDataSize = expectedDataSiize; -} - - -#define kState_Start 0 -#define kState_LitAfterMatch 4 -#define kState_LitAfterRep 5 -#define kState_MatchAfterLit 7 -#define kState_RepAfterLit 8 - -static const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; -static const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; -static const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; -static const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; - -#define IsLitState(s) ((s) < 7) -#define GetLenToPosState2(len) (((len) < kNumLenToPosStates - 1) ? (len) : kNumLenToPosStates - 1) -#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1) - -#define kInfinityPrice (1 << 30) - -static void RangeEnc_Construct(CRangeEnc *p) -{ - p->outStream = NULL; - p->bufBase = NULL; -} - -#define RangeEnc_GetProcessed(p) ( (p)->processed + (size_t)((p)->buf - (p)->bufBase) + (p)->cacheSize) -#define RangeEnc_GetProcessed_sizet(p) ((size_t)(p)->processed + (size_t)((p)->buf - (p)->bufBase) + (size_t)(p)->cacheSize) - -#define RC_BUF_SIZE (1 << 16) - -static int RangeEnc_Alloc(CRangeEnc *p, ISzAllocPtr alloc) -{ - if (!p->bufBase) - { - p->bufBase = (Byte *)ISzAlloc_Alloc(alloc, RC_BUF_SIZE); - if (!p->bufBase) - return 0; - p->bufLim = p->bufBase + RC_BUF_SIZE; - } - return 1; -} - -static void RangeEnc_Free(CRangeEnc *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->bufBase); - p->bufBase = 0; -} - -static void RangeEnc_Init(CRangeEnc *p) -{ - /* Stream.Init(); */ - p->range = 0xFFFFFFFF; - p->cache = 0; - p->low = 0; - p->cacheSize = 0; - - p->buf = p->bufBase; - - p->processed = 0; - p->res = SZ_OK; -} - -MY_NO_INLINE static void RangeEnc_FlushStream(CRangeEnc *p) -{ - size_t num; - if (p->res != SZ_OK) - return; - num = (size_t)(p->buf - p->bufBase); - if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num)) - p->res = SZ_ERROR_WRITE; - p->processed += num; - p->buf = p->bufBase; -} - -MY_NO_INLINE static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) -{ - UInt32 low = (UInt32)p->low; - unsigned high = (unsigned)(p->low >> 32); - p->low = (UInt32)(low << 8); - if (low < (UInt32)0xFF000000 || high != 0) - { - { - Byte *buf = p->buf; - *buf++ = (Byte)(p->cache + high); - p->cache = (unsigned)(low >> 24); - p->buf = buf; - if (buf == p->bufLim) - RangeEnc_FlushStream(p); - if (p->cacheSize == 0) - return; - } - high += 0xFF; - for (;;) - { - Byte *buf = p->buf; - *buf++ = (Byte)(high); - p->buf = buf; - if (buf == p->bufLim) - RangeEnc_FlushStream(p); - if (--p->cacheSize == 0) - return; - } - } - p->cacheSize++; -} - -static void RangeEnc_FlushData(CRangeEnc *p) -{ - int i; - for (i = 0; i < 5; i++) - RangeEnc_ShiftLow(p); -} - -#define RC_NORM(p) if (range < kTopValue) { range <<= 8; RangeEnc_ShiftLow(p); } - -#define RC_BIT_PRE(p, prob) \ - ttt = *(prob); \ - newBound = (range >> kNumBitModelTotalBits) * ttt; - -// #define _LZMA_ENC_USE_BRANCH - -#ifdef _LZMA_ENC_USE_BRANCH - -#define RC_BIT(p, prob, bit) { \ - RC_BIT_PRE(p, prob) \ - if (bit == 0) { range = newBound; ttt += (kBitModelTotal - ttt) >> kNumMoveBits; } \ - else { (p)->low += newBound; range -= newBound; ttt -= ttt >> kNumMoveBits; } \ - *(prob) = (CLzmaProb)ttt; \ - RC_NORM(p) \ - } - -#else - -#define RC_BIT(p, prob, bit) { \ - UInt32 mask; \ - RC_BIT_PRE(p, prob) \ - mask = 0 - (UInt32)bit; \ - range &= mask; \ - mask &= newBound; \ - range -= mask; \ - (p)->low += mask; \ - mask = (UInt32)bit - 1; \ - range += newBound & mask; \ - mask &= (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \ - mask += ((1 << kNumMoveBits) - 1); \ - ttt += (UInt32)((Int32)(mask - ttt) >> kNumMoveBits); \ - *(prob) = (CLzmaProb)ttt; \ - RC_NORM(p) \ - } - -#endif - - - - -#define RC_BIT_0_BASE(p, prob) \ - range = newBound; *(prob) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); - -#define RC_BIT_1_BASE(p, prob) \ - range -= newBound; (p)->low += newBound; *(prob) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); \ - -#define RC_BIT_0(p, prob) \ - RC_BIT_0_BASE(p, prob) \ - RC_NORM(p) - -#define RC_BIT_1(p, prob) \ - RC_BIT_1_BASE(p, prob) \ - RC_NORM(p) - -static void RangeEnc_EncodeBit_0(CRangeEnc *p, CLzmaProb *prob) -{ - UInt32 range, ttt, newBound; - range = p->range; - RC_BIT_PRE(p, prob) - RC_BIT_0(p, prob) - p->range = range; -} - -static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym) -{ - UInt32 range = p->range; - sym |= 0x100; - do - { - UInt32 ttt, newBound; - // RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1); - CLzmaProb *prob = probs + (sym >> 8); - UInt32 bit = (sym >> 7) & 1; - sym <<= 1; - RC_BIT(p, prob, bit); - } - while (sym < 0x10000); - p->range = range; -} - -static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sym, UInt32 matchByte) -{ - UInt32 range = p->range; - UInt32 offs = 0x100; - sym |= 0x100; - do - { - UInt32 ttt, newBound; - CLzmaProb *prob; - UInt32 bit; - matchByte <<= 1; - // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (sym >> 8)), (sym >> 7) & 1); - prob = probs + (offs + (matchByte & offs) + (sym >> 8)); - bit = (sym >> 7) & 1; - sym <<= 1; - offs &= ~(matchByte ^ sym); - RC_BIT(p, prob, bit); - } - while (sym < 0x10000); - p->range = range; -} - - - -static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices) -{ - UInt32 i; - for (i = 0; i < (kBitModelTotal >> kNumMoveReducingBits); i++) - { - const unsigned kCyclesBits = kNumBitPriceShiftBits; - UInt32 w = (i << kNumMoveReducingBits) + (1 << (kNumMoveReducingBits - 1)); - unsigned bitCount = 0; - unsigned j; - for (j = 0; j < kCyclesBits; j++) - { - w = w * w; - bitCount <<= 1; - while (w >= ((UInt32)1 << 16)) - { - w >>= 1; - bitCount++; - } - } - ProbPrices[i] = (CProbPrice)(((unsigned)kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); - // printf("\n%3d: %5d", i, ProbPrices[i]); - } -} - - -#define GET_PRICE(prob, bit) \ - p->ProbPrices[((prob) ^ (unsigned)(((-(int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; - -#define GET_PRICEa(prob, bit) \ - ProbPrices[((prob) ^ (unsigned)((-((int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; - -#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits] -#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] - -#define GET_PRICEa_0(prob) ProbPrices[(prob) >> kNumMoveReducingBits] -#define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] - - -static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CProbPrice *ProbPrices) -{ - UInt32 price = 0; - sym |= 0x100; - do - { - unsigned bit = sym & 1; - sym >>= 1; - price += GET_PRICEa(probs[sym], bit); - } - while (sym >= 2); - return price; -} - - -static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, UInt32 matchByte, const CProbPrice *ProbPrices) -{ - UInt32 price = 0; - UInt32 offs = 0x100; - sym |= 0x100; - do - { - matchByte <<= 1; - price += GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> 8)], (sym >> 7) & 1); - sym <<= 1; - offs &= ~(matchByte ^ sym); - } - while (sym < 0x10000); - return price; -} - - -static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned numBits, unsigned sym) -{ - UInt32 range = rc->range; - unsigned m = 1; - do - { - UInt32 ttt, newBound; - unsigned bit = sym & 1; - // RangeEnc_EncodeBit(rc, probs + m, bit); - sym >>= 1; - RC_BIT(rc, probs + m, bit); - m = (m << 1) | bit; - } - while (--numBits); - rc->range = range; -} - - - -static void LenEnc_Init(CLenEnc *p) -{ - unsigned i; - for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << (kLenNumLowBits + 1)); i++) - p->low[i] = kProbInitValue; - for (i = 0; i < kLenNumHighSymbols; i++) - p->high[i] = kProbInitValue; -} - -static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posState) -{ - UInt32 range, ttt, newBound; - CLzmaProb *probs = p->low; - range = rc->range; - RC_BIT_PRE(rc, probs); - if (sym >= kLenNumLowSymbols) - { - RC_BIT_1(rc, probs); - probs += kLenNumLowSymbols; - RC_BIT_PRE(rc, probs); - if (sym >= kLenNumLowSymbols * 2) - { - RC_BIT_1(rc, probs); - rc->range = range; - // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - kLenNumLowSymbols * 2); - LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2); - return; - } - sym -= kLenNumLowSymbols; - } - - // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBits, sym); - { - unsigned m; - unsigned bit; - RC_BIT_0(rc, probs); - probs += (posState << (1 + kLenNumLowBits)); - bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit); m = (1 << 1) + bit; - bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit); m = (m << 1) + bit; - bit = sym & 1; RC_BIT(rc, probs + m, bit); - rc->range = range; - } -} - -static void SetPrices_3(const CLzmaProb *probs, UInt32 startPrice, UInt32 *prices, const CProbPrice *ProbPrices) -{ - unsigned i; - for (i = 0; i < 8; i += 2) - { - UInt32 price = startPrice; - UInt32 prob; - price += GET_PRICEa(probs[1 ], (i >> 2)); - price += GET_PRICEa(probs[2 + (i >> 2)], (i >> 1) & 1); - prob = probs[4 + (i >> 1)]; - prices[i ] = price + GET_PRICEa_0(prob); - prices[i + 1] = price + GET_PRICEa_1(prob); - } -} - - -MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( - CLenPriceEnc *p, - unsigned numPosStates, - const CLenEnc *enc, - const CProbPrice *ProbPrices) -{ - UInt32 b; - - { - unsigned prob = enc->low[0]; - UInt32 a, c; - unsigned posState; - b = GET_PRICEa_1(prob); - a = GET_PRICEa_0(prob); - c = b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); - for (posState = 0; posState < numPosStates; posState++) - { - UInt32 *prices = p->prices[posState]; - const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits)); - SetPrices_3(probs, a, prices, ProbPrices); - SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); - } - } - - /* - { - unsigned i; - UInt32 b; - a = GET_PRICEa_0(enc->low[0]); - for (i = 0; i < kLenNumLowSymbols; i++) - p->prices2[i] = a; - a = GET_PRICEa_1(enc->low[0]); - b = a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); - for (i = kLenNumLowSymbols; i < kLenNumLowSymbols * 2; i++) - p->prices2[i] = b; - a += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); - } - */ - - // p->counter = numSymbols; - // p->counter = 64; - - { - unsigned i = p->tableSize; - - if (i > kLenNumLowSymbols * 2) - { - const CLzmaProb *probs = enc->high; - UInt32 *prices = p->prices[0] + kLenNumLowSymbols * 2; - i -= kLenNumLowSymbols * 2 - 1; - i >>= 1; - b += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); - do - { - /* - p->prices2[i] = a + - // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbols * 2, ProbPrices); - LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, ProbPrices); - */ - // UInt32 price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices); - unsigned sym = --i + (1 << (kLenNumHighBits - 1)); - UInt32 price = b; - do - { - unsigned bit = sym & 1; - sym >>= 1; - price += GET_PRICEa(probs[sym], bit); - } - while (sym >= 2); - - { - unsigned prob = probs[(size_t)i + (1 << (kLenNumHighBits - 1))]; - prices[(size_t)i * 2 ] = price + GET_PRICEa_0(prob); - prices[(size_t)i * 2 + 1] = price + GET_PRICEa_1(prob); - } - } - while (i); - - { - unsigned posState; - size_t num = (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->prices[0][0]); - for (posState = 1; posState < numPosStates; posState++) - memcpy(p->prices[posState] + kLenNumLowSymbols * 2, p->prices[0] + kLenNumLowSymbols * 2, num); - } - } - } -} - -/* - #ifdef SHOW_STAT - g_STAT_OFFSET += num; - printf("\n MovePos %u", num); - #endif -*/ - -#define MOVE_POS(p, num) { \ - p->additionalOffset += (num); \ - p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); } - - -static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) -{ - unsigned numPairs; - - p->additionalOffset++; - p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); - numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - *numPairsRes = numPairs; - - #ifdef SHOW_STAT - printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2); - g_STAT_OFFSET++; - { - unsigned i; - for (i = 0; i < numPairs; i += 2) - printf("%2u %6u | ", p->matches[i], p->matches[i + 1]); - } - #endif - - if (numPairs == 0) - return 0; - { - unsigned len = p->matches[(size_t)numPairs - 2]; - if (len != p->numFastBytes) - return len; - { - UInt32 numAvail = p->numAvail; - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - { - const Byte *p1 = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - const Byte *p2 = p1 + len; - ptrdiff_t dif = (ptrdiff_t)-1 - (ptrdiff_t)p->matches[(size_t)numPairs - 1]; - const Byte *lim = p1 + numAvail; - for (; p2 != lim && *p2 == p2[dif]; p2++) - {} - return (unsigned)(p2 - p1); - } - } - } -} - -#define MARK_LIT ((UInt32)(Int32)-1) - -#define MakeAs_Lit(p) { (p)->dist = MARK_LIT; (p)->extra = 0; } -#define MakeAs_ShortRep(p) { (p)->dist = 0; (p)->extra = 0; } -#define IsShortRep(p) ((p)->dist == 0) - - -#define GetPrice_ShortRep(p, state, posState) \ - ( GET_PRICE_0(p->isRepG0[state]) + GET_PRICE_0(p->isRep0Long[state][posState])) - -#define GetPrice_Rep_0(p, state, posState) ( \ - GET_PRICE_1(p->isMatch[state][posState]) \ - + GET_PRICE_1(p->isRep0Long[state][posState])) \ - + GET_PRICE_1(p->isRep[state]) \ - + GET_PRICE_0(p->isRepG0[state]) - -MY_FORCE_INLINE -static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_t state, size_t posState) -{ - UInt32 price; - UInt32 prob = p->isRepG0[state]; - if (repIndex == 0) - { - price = GET_PRICE_0(prob); - price += GET_PRICE_1(p->isRep0Long[state][posState]); - } - else - { - price = GET_PRICE_1(prob); - prob = p->isRepG1[state]; - if (repIndex == 1) - price += GET_PRICE_0(prob); - else - { - price += GET_PRICE_1(prob); - price += GET_PRICE(p->isRepG2[state], repIndex - 2); - } - } - return price; -} - - -static unsigned Backward(CLzmaEnc *p, unsigned cur) -{ - unsigned wr = cur + 1; - p->optEnd = wr; - - for (;;) - { - UInt32 dist = p->opt[cur].dist; - unsigned len = (unsigned)p->opt[cur].len; - unsigned extra = (unsigned)p->opt[cur].extra; - cur -= len; - - if (extra) - { - wr--; - p->opt[wr].len = (UInt32)len; - cur -= extra; - len = extra; - if (extra == 1) - { - p->opt[wr].dist = dist; - dist = MARK_LIT; - } - else - { - p->opt[wr].dist = 0; - len--; - wr--; - p->opt[wr].dist = MARK_LIT; - p->opt[wr].len = 1; - } - } - - if (cur == 0) - { - p->backRes = dist; - p->optCur = wr; - return len; - } - - wr--; - p->opt[wr].dist = dist; - p->opt[wr].len = (UInt32)len; - } -} - - - -#define LIT_PROBS(pos, prevByte) \ - (p->litProbs + (UInt32)3 * (((((pos) << 8) + (prevByte)) & p->lpMask) << p->lc)) - - -static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) -{ - unsigned last, cur; - UInt32 reps[LZMA_NUM_REPS]; - unsigned repLens[LZMA_NUM_REPS]; - UInt32 *matches; - - { - UInt32 numAvail; - unsigned numPairs, mainLen, repMaxIndex, i, posState; - UInt32 matchPrice, repMatchPrice; - const Byte *data; - Byte curByte, matchByte; - - p->optCur = p->optEnd = 0; - - if (p->additionalOffset == 0) - mainLen = ReadMatchDistances(p, &numPairs); - else - { - mainLen = p->longestMatchLen; - numPairs = p->numPairs; - } - - numAvail = p->numAvail; - if (numAvail < 2) - { - p->backRes = MARK_LIT; - return 1; - } - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - repMaxIndex = 0; - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - unsigned len; - const Byte *data2; - reps[i] = p->reps[i]; - data2 = data - reps[i]; - if (data[0] != data2[0] || data[1] != data2[1]) - { - repLens[i] = 0; - continue; - } - for (len = 2; len < numAvail && data[len] == data2[len]; len++) - {} - repLens[i] = len; - if (len > repLens[repMaxIndex]) - repMaxIndex = i; - } - - if (repLens[repMaxIndex] >= p->numFastBytes) - { - unsigned len; - p->backRes = (UInt32)repMaxIndex; - len = repLens[repMaxIndex]; - MOVE_POS(p, len - 1) - return len; - } - - matches = p->matches; - - if (mainLen >= p->numFastBytes) - { - p->backRes = matches[(size_t)numPairs - 1] + LZMA_NUM_REPS; - MOVE_POS(p, mainLen - 1) - return mainLen; - } - - curByte = *data; - matchByte = *(data - reps[0]); - - last = repLens[repMaxIndex]; - if (last <= mainLen) - last = mainLen; - - if (last < 2 && curByte != matchByte) - { - p->backRes = MARK_LIT; - return 1; - } - - p->opt[0].state = (CState)p->state; - - posState = (position & p->pbMask); - - { - const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); - p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + - (!IsLitState(p->state) ? - LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) : - LitEnc_GetPrice(probs, curByte, p->ProbPrices)); - } - - MakeAs_Lit(&p->opt[1]); - - matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); - repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); - - // 18.06 - if (matchByte == curByte && repLens[0] == 0) - { - UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, p->state, posState); - if (shortRepPrice < p->opt[1].price) - { - p->opt[1].price = shortRepPrice; - MakeAs_ShortRep(&p->opt[1]); - } - if (last < 2) - { - p->backRes = p->opt[1].dist; - return 1; - } - } - - p->opt[1].len = 1; - - p->opt[0].reps[0] = reps[0]; - p->opt[0].reps[1] = reps[1]; - p->opt[0].reps[2] = reps[2]; - p->opt[0].reps[3] = reps[3]; - - // ---------- REP ---------- - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - unsigned repLen = repLens[i]; - UInt32 price; - if (repLen < 2) - continue; - price = repMatchPrice + GetPrice_PureRep(p, i, p->state, posState); - do - { - UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, repLen); - COptimal *opt = &p->opt[repLen]; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)repLen; - opt->dist = (UInt32)i; - opt->extra = 0; - } - } - while (--repLen >= 2); - } - - - // ---------- MATCH ---------- - { - unsigned len = repLens[0] + 1; - if (len <= mainLen) - { - unsigned offs = 0; - UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); - - if (len < 2) - len = 2; - else - while (len > matches[offs]) - offs += 2; - - for (; ; len++) - { - COptimal *opt; - UInt32 dist = matches[(size_t)offs + 1]; - UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); - unsigned lenToPosState = GetLenToPosState(len); - - if (dist < kNumFullDistances) - price += p->distancesPrices[lenToPosState][dist & (kNumFullDistances - 1)]; - else - { - unsigned slot; - GetPosSlot2(dist, slot); - price += p->alignPrices[dist & kAlignMask]; - price += p->posSlotPrices[lenToPosState][slot]; - } - - opt = &p->opt[len]; - - if (price < opt->price) - { - opt->price = price; - opt->len = (UInt32)len; - opt->dist = dist + LZMA_NUM_REPS; - opt->extra = 0; - } - - if (len == matches[offs]) - { - offs += 2; - if (offs == numPairs) - break; - } - } - } - } - - - cur = 0; - - #ifdef SHOW_STAT2 - /* if (position >= 0) */ - { - unsigned i; - printf("\n pos = %4X", position); - for (i = cur; i <= last; i++) - printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price); - } - #endif - } - - - - // ---------- Optimal Parsing ---------- - - for (;;) - { - unsigned numAvail; - UInt32 numAvailFull; - unsigned newLen, numPairs, prev, state, posState, startLen; - UInt32 litPrice, matchPrice, repMatchPrice; - BoolInt nextIsLit; - Byte curByte, matchByte; - const Byte *data; - COptimal *curOpt, *nextOpt; - - if (++cur == last) - break; - - // 18.06 - if (cur >= kNumOpts - 64) - { - unsigned j, best; - UInt32 price = p->opt[cur].price; - best = cur; - for (j = cur + 1; j <= last; j++) - { - UInt32 price2 = p->opt[j].price; - if (price >= price2) - { - price = price2; - best = j; - } - } - { - unsigned delta = best - cur; - if (delta != 0) - { - MOVE_POS(p, delta); - } - } - cur = best; - break; - } - - newLen = ReadMatchDistances(p, &numPairs); - - if (newLen >= p->numFastBytes) - { - p->numPairs = numPairs; - p->longestMatchLen = newLen; - break; - } - - curOpt = &p->opt[cur]; - - position++; - - // we need that check here, if skip_items in p->opt are possible - /* - if (curOpt->price >= kInfinityPrice) - continue; - */ - - prev = cur - curOpt->len; - - if (curOpt->len == 1) - { - state = (unsigned)p->opt[prev].state; - if (IsShortRep(curOpt)) - state = kShortRepNextStates[state]; - else - state = kLiteralNextStates[state]; - } - else - { - const COptimal *prevOpt; - UInt32 b0; - UInt32 dist = curOpt->dist; - - if (curOpt->extra) - { - prev -= (unsigned)curOpt->extra; - state = kState_RepAfterLit; - if (curOpt->extra == 1) - state = (dist < LZMA_NUM_REPS ? kState_RepAfterLit : kState_MatchAfterLit); - } - else - { - state = (unsigned)p->opt[prev].state; - if (dist < LZMA_NUM_REPS) - state = kRepNextStates[state]; - else - state = kMatchNextStates[state]; - } - - prevOpt = &p->opt[prev]; - b0 = prevOpt->reps[0]; - - if (dist < LZMA_NUM_REPS) - { - if (dist == 0) - { - reps[0] = b0; - reps[1] = prevOpt->reps[1]; - reps[2] = prevOpt->reps[2]; - reps[3] = prevOpt->reps[3]; - } - else - { - reps[1] = b0; - b0 = prevOpt->reps[1]; - if (dist == 1) - { - reps[0] = b0; - reps[2] = prevOpt->reps[2]; - reps[3] = prevOpt->reps[3]; - } - else - { - reps[2] = b0; - reps[0] = prevOpt->reps[dist]; - reps[3] = prevOpt->reps[dist ^ 1]; - } - } - } - else - { - reps[0] = (dist - LZMA_NUM_REPS + 1); - reps[1] = b0; - reps[2] = prevOpt->reps[1]; - reps[3] = prevOpt->reps[2]; - } - } - - curOpt->state = (CState)state; - curOpt->reps[0] = reps[0]; - curOpt->reps[1] = reps[1]; - curOpt->reps[2] = reps[2]; - curOpt->reps[3] = reps[3]; - - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - curByte = *data; - matchByte = *(data - reps[0]); - - posState = (position & p->pbMask); - - /* - The order of Price checks: - < LIT - <= SHORT_REP - < LIT : REP_0 - < REP [ : LIT : REP_0 ] - < MATCH [ : LIT : REP_0 ] - */ - - { - UInt32 curPrice = curOpt->price; - unsigned prob = p->isMatch[state][posState]; - matchPrice = curPrice + GET_PRICE_1(prob); - litPrice = curPrice + GET_PRICE_0(prob); - } - - nextOpt = &p->opt[(size_t)cur + 1]; - nextIsLit = False; - - // here we can allow skip_items in p->opt, if we don't check (nextOpt->price < kInfinityPrice) - // 18.new.06 - if ((nextOpt->price < kInfinityPrice - // && !IsLitState(state) - && matchByte == curByte) - || litPrice > nextOpt->price - ) - litPrice = 0; - else - { - const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); - litPrice += (!IsLitState(state) ? - LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) : - LitEnc_GetPrice(probs, curByte, p->ProbPrices)); - - if (litPrice < nextOpt->price) - { - nextOpt->price = litPrice; - nextOpt->len = 1; - MakeAs_Lit(nextOpt); - nextIsLit = True; - } - } - - repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); - - numAvailFull = p->numAvail; - { - unsigned temp = kNumOpts - 1 - cur; - if (numAvailFull > temp) - numAvailFull = (UInt32)temp; - } - - // 18.06 - // ---------- SHORT_REP ---------- - if (IsLitState(state)) // 18.new - if (matchByte == curByte) - if (repMatchPrice < nextOpt->price) // 18.new - // if (numAvailFull < 2 || data[1] != *(data - reps[0] + 1)) - if ( - // nextOpt->price >= kInfinityPrice || - nextOpt->len < 2 // we can check nextOpt->len, if skip items are not allowed in p->opt - || (nextOpt->dist != 0 - // && nextOpt->extra <= 1 // 17.old - ) - ) - { - UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, state, posState); - // if (shortRepPrice <= nextOpt->price) // 17.old - if (shortRepPrice < nextOpt->price) // 18.new - { - nextOpt->price = shortRepPrice; - nextOpt->len = 1; - MakeAs_ShortRep(nextOpt); - nextIsLit = False; - } - } - - if (numAvailFull < 2) - continue; - numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes); - - // numAvail <= p->numFastBytes - - // ---------- LIT : REP_0 ---------- - - if (!nextIsLit - && litPrice != 0 // 18.new - && matchByte != curByte - && numAvailFull > 2) - { - const Byte *data2 = data - reps[0]; - if (data[1] == data2[1] && data[2] == data2[2]) - { - unsigned len; - unsigned limit = p->numFastBytes + 1; - if (limit > numAvailFull) - limit = numAvailFull; - for (len = 3; len < limit && data[len] == data2[len]; len++) - {} - - { - unsigned state2 = kLiteralNextStates[state]; - unsigned posState2 = (position + 1) & p->pbMask; - UInt32 price = litPrice + GetPrice_Rep_0(p, state2, posState2); - { - unsigned offset = cur + len; - - if (last < offset) - last = offset; - - // do - { - UInt32 price2; - COptimal *opt; - len--; - // price2 = price + GetPrice_Len_Rep_0(p, len, state2, posState2); - price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len); - - opt = &p->opt[offset]; - // offset--; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len; - opt->dist = 0; - opt->extra = 1; - } - } - // while (len >= 3); - } - } - } - } - - startLen = 2; /* speed optimization */ - - { - // ---------- REP ---------- - unsigned repIndex = 0; // 17.old - // unsigned repIndex = IsLitState(state) ? 0 : 1; // 18.notused - for (; repIndex < LZMA_NUM_REPS; repIndex++) - { - unsigned len; - UInt32 price; - const Byte *data2 = data - reps[repIndex]; - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - - for (len = 2; len < numAvail && data[len] == data2[len]; len++) - {} - - // if (len < startLen) continue; // 18.new: speed optimization - - { - unsigned offset = cur + len; - if (last < offset) - last = offset; - } - { - unsigned len2 = len; - price = repMatchPrice + GetPrice_PureRep(p, repIndex, state, posState); - do - { - UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, len2); - COptimal *opt = &p->opt[cur + len2]; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len2; - opt->dist = (UInt32)repIndex; - opt->extra = 0; - } - } - while (--len2 >= 2); - } - - if (repIndex == 0) startLen = len + 1; // 17.old - // startLen = len + 1; // 18.new - - /* if (_maxMode) */ - { - // ---------- REP : LIT : REP_0 ---------- - // numFastBytes + 1 + numFastBytes - - unsigned len2 = len + 1; - unsigned limit = len2 + p->numFastBytes; - if (limit > numAvailFull) - limit = numAvailFull; - - len2 += 2; - if (len2 <= limit) - if (data[len2 - 2] == data2[len2 - 2]) - if (data[len2 - 1] == data2[len2 - 1]) - { - unsigned state2 = kRepNextStates[state]; - unsigned posState2 = (position + len) & p->pbMask; - price += GET_PRICE_LEN(&p->repLenEnc, posState, len) - + GET_PRICE_0(p->isMatch[state2][posState2]) - + LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]), - data[len], data2[len], p->ProbPrices); - - // state2 = kLiteralNextStates[state2]; - state2 = kState_LitAfterRep; - posState2 = (posState2 + 1) & p->pbMask; - - - price += GetPrice_Rep_0(p, state2, posState2); - - for (; len2 < limit && data[len2] == data2[len2]; len2++) - {} - - len2 -= len; - // if (len2 >= 3) - { - { - unsigned offset = cur + len + len2; - - if (last < offset) - last = offset; - // do - { - UInt32 price2; - COptimal *opt; - len2--; - // price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); - price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2); - - opt = &p->opt[offset]; - // offset--; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len2; - opt->extra = (CExtra)(len + 1); - opt->dist = (UInt32)repIndex; - } - } - // while (len2 >= 3); - } - } - } - } - } - } - - - // ---------- MATCH ---------- - /* for (unsigned len = 2; len <= newLen; len++) */ - if (newLen > numAvail) - { - newLen = numAvail; - for (numPairs = 0; newLen > matches[numPairs]; numPairs += 2); - matches[numPairs] = (UInt32)newLen; - numPairs += 2; - } - - // startLen = 2; /* speed optimization */ - - if (newLen >= startLen) - { - UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); - UInt32 dist; - unsigned offs, posSlot, len; - - { - unsigned offset = cur + newLen; - if (last < offset) - last = offset; - } - - offs = 0; - while (startLen > matches[offs]) - offs += 2; - dist = matches[(size_t)offs + 1]; - - // if (dist >= kNumFullDistances) - GetPosSlot2(dist, posSlot); - - for (len = /*2*/ startLen; ; len++) - { - UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); - { - COptimal *opt; - unsigned lenNorm = len - 2; - lenNorm = GetLenToPosState2(lenNorm); - if (dist < kNumFullDistances) - price += p->distancesPrices[lenNorm][dist & (kNumFullDistances - 1)]; - else - price += p->posSlotPrices[lenNorm][posSlot] + p->alignPrices[dist & kAlignMask]; - - opt = &p->opt[cur + len]; - if (price < opt->price) - { - opt->price = price; - opt->len = (UInt32)len; - opt->dist = dist + LZMA_NUM_REPS; - opt->extra = 0; - } - } - - if (len == matches[offs]) - { - // if (p->_maxMode) { - // MATCH : LIT : REP_0 - - const Byte *data2 = data - dist - 1; - unsigned len2 = len + 1; - unsigned limit = len2 + p->numFastBytes; - if (limit > numAvailFull) - limit = numAvailFull; - - len2 += 2; - if (len2 <= limit) - if (data[len2 - 2] == data2[len2 - 2]) - if (data[len2 - 1] == data2[len2 - 1]) - { - for (; len2 < limit && data[len2] == data2[len2]; len2++) - {} - - len2 -= len; - - // if (len2 >= 3) - { - unsigned state2 = kMatchNextStates[state]; - unsigned posState2 = (position + len) & p->pbMask; - unsigned offset; - price += GET_PRICE_0(p->isMatch[state2][posState2]); - price += LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]), - data[len], data2[len], p->ProbPrices); - - // state2 = kLiteralNextStates[state2]; - state2 = kState_LitAfterMatch; - - posState2 = (posState2 + 1) & p->pbMask; - price += GetPrice_Rep_0(p, state2, posState2); - - offset = cur + len + len2; - - if (last < offset) - last = offset; - // do - { - UInt32 price2; - COptimal *opt; - len2--; - // price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); - price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2); - opt = &p->opt[offset]; - // offset--; - if (price2 < opt->price) - { - opt->price = price2; - opt->len = (UInt32)len2; - opt->extra = (CExtra)(len + 1); - opt->dist = dist + LZMA_NUM_REPS; - } - } - // while (len2 >= 3); - } - - } - - offs += 2; - if (offs == numPairs) - break; - dist = matches[(size_t)offs + 1]; - // if (dist >= kNumFullDistances) - GetPosSlot2(dist, posSlot); - } - } - } - } - - do - p->opt[last].price = kInfinityPrice; - while (--last); - - return Backward(p, cur); -} - - - -#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist)) - - - -static unsigned GetOptimumFast(CLzmaEnc *p) -{ - UInt32 numAvail, mainDist; - unsigned mainLen, numPairs, repIndex, repLen, i; - const Byte *data; - - if (p->additionalOffset == 0) - mainLen = ReadMatchDistances(p, &numPairs); - else - { - mainLen = p->longestMatchLen; - numPairs = p->numPairs; - } - - numAvail = p->numAvail; - p->backRes = MARK_LIT; - if (numAvail < 2) - return 1; - // if (mainLen < 2 && p->state == 0) return 1; // 18.06.notused - if (numAvail > LZMA_MATCH_LEN_MAX) - numAvail = LZMA_MATCH_LEN_MAX; - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - repLen = repIndex = 0; - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - unsigned len; - const Byte *data2 = data - p->reps[i]; - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - for (len = 2; len < numAvail && data[len] == data2[len]; len++) - {} - if (len >= p->numFastBytes) - { - p->backRes = (UInt32)i; - MOVE_POS(p, len - 1) - return len; - } - if (len > repLen) - { - repIndex = i; - repLen = len; - } - } - - if (mainLen >= p->numFastBytes) - { - p->backRes = p->matches[(size_t)numPairs - 1] + LZMA_NUM_REPS; - MOVE_POS(p, mainLen - 1) - return mainLen; - } - - mainDist = 0; /* for GCC */ - - if (mainLen >= 2) - { - mainDist = p->matches[(size_t)numPairs - 1]; - while (numPairs > 2) - { - UInt32 dist2; - if (mainLen != p->matches[(size_t)numPairs - 4] + 1) - break; - dist2 = p->matches[(size_t)numPairs - 3]; - if (!ChangePair(dist2, mainDist)) - break; - numPairs -= 2; - mainLen--; - mainDist = dist2; - } - if (mainLen == 2 && mainDist >= 0x80) - mainLen = 1; - } - - if (repLen >= 2) - if ( repLen + 1 >= mainLen - || (repLen + 2 >= mainLen && mainDist >= (1 << 9)) - || (repLen + 3 >= mainLen && mainDist >= (1 << 15))) - { - p->backRes = (UInt32)repIndex; - MOVE_POS(p, repLen - 1) - return repLen; - } - - if (mainLen < 2 || numAvail <= 2) - return 1; - - { - unsigned len1 = ReadMatchDistances(p, &p->numPairs); - p->longestMatchLen = len1; - - if (len1 >= 2) - { - UInt32 newDist = p->matches[(size_t)p->numPairs - 1]; - if ( (len1 >= mainLen && newDist < mainDist) - || (len1 == mainLen + 1 && !ChangePair(mainDist, newDist)) - || (len1 > mainLen + 1) - || (len1 + 1 >= mainLen && mainLen >= 3 && ChangePair(newDist, mainDist))) - return 1; - } - } - - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; - - for (i = 0; i < LZMA_NUM_REPS; i++) - { - unsigned len, limit; - const Byte *data2 = data - p->reps[i]; - if (data[0] != data2[0] || data[1] != data2[1]) - continue; - limit = mainLen - 1; - for (len = 2;; len++) - { - if (len >= limit) - return 1; - if (data[len] != data2[len]) - break; - } - } - - p->backRes = mainDist + LZMA_NUM_REPS; - if (mainLen != 2) - { - MOVE_POS(p, mainLen - 2) - } - return mainLen; -} - - - - -static void WriteEndMarker(CLzmaEnc *p, unsigned posState) -{ - UInt32 range; - range = p->rc.range; - { - UInt32 ttt, newBound; - CLzmaProb *prob = &p->isMatch[p->state][posState]; - RC_BIT_PRE(&p->rc, prob) - RC_BIT_1(&p->rc, prob) - prob = &p->isRep[p->state]; - RC_BIT_PRE(&p->rc, prob) - RC_BIT_0(&p->rc, prob) - } - p->state = kMatchNextStates[p->state]; - - p->rc.range = range; - LenEnc_Encode(&p->lenProbs, &p->rc, 0, posState); - range = p->rc.range; - - { - // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[0], (1 << kNumPosSlotBits) - 1); - CLzmaProb *probs = p->posSlotEncoder[0]; - unsigned m = 1; - do - { - UInt32 ttt, newBound; - RC_BIT_PRE(p, probs + m) - RC_BIT_1(&p->rc, probs + m); - m = (m << 1) + 1; - } - while (m < (1 << kNumPosSlotBits)); - } - { - // RangeEnc_EncodeDirectBits(&p->rc, ((UInt32)1 << (30 - kNumAlignBits)) - 1, 30 - kNumAlignBits); UInt32 range = p->range; - unsigned numBits = 30 - kNumAlignBits; - do - { - range >>= 1; - p->rc.low += range; - RC_NORM(&p->rc) - } - while (--numBits); - } - - { - // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); - CLzmaProb *probs = p->posAlignEncoder; - unsigned m = 1; - do - { - UInt32 ttt, newBound; - RC_BIT_PRE(p, probs + m) - RC_BIT_1(&p->rc, probs + m); - m = (m << 1) + 1; - } - while (m < kAlignTableSize); - } - p->rc.range = range; -} - - -static SRes CheckErrors(CLzmaEnc *p) -{ - if (p->result != SZ_OK) - return p->result; - if (p->rc.res != SZ_OK) - p->result = SZ_ERROR_WRITE; - if (p->matchFinderBase.result != SZ_OK) - p->result = SZ_ERROR_READ; - if (p->result != SZ_OK) - p->finished = True; - return p->result; -} - - -MY_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 nowPos) -{ - /* ReleaseMFStream(); */ - p->finished = True; - if (p->writeEndMark) - WriteEndMarker(p, nowPos & p->pbMask); - RangeEnc_FlushData(&p->rc); - RangeEnc_FlushStream(&p->rc); - return CheckErrors(p); -} - - -MY_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) -{ - unsigned i; - const CProbPrice *ProbPrices = p->ProbPrices; - const CLzmaProb *probs = p->posAlignEncoder; - // p->alignPriceCount = 0; - for (i = 0; i < kAlignTableSize / 2; i++) - { - UInt32 price = 0; - unsigned sym = i; - unsigned m = 1; - unsigned bit; - UInt32 prob; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; - prob = probs[m]; - p->alignPrices[i ] = price + GET_PRICEa_0(prob); - p->alignPrices[i + 8] = price + GET_PRICEa_1(prob); - // p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); - } -} - - -MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) -{ - // int y; for (y = 0; y < 100; y++) { - - UInt32 tempPrices[kNumFullDistances]; - unsigned i, lps; - - const CProbPrice *ProbPrices = p->ProbPrices; - p->matchPriceCount = 0; - - for (i = kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++) - { - unsigned posSlot = GetPosSlot1(i); - unsigned footerBits = (posSlot >> 1) - 1; - unsigned base = ((2 | (posSlot & 1)) << footerBits); - const CLzmaProb *probs = p->posEncoders + (size_t)base * 2; - // tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base, footerBits, i - base, p->ProbPrices); - UInt32 price = 0; - unsigned m = 1; - unsigned sym = i; - unsigned offset = (unsigned)1 << footerBits; - base += i; - - if (footerBits) - do - { - unsigned bit = sym & 1; - sym >>= 1; - price += GET_PRICEa(probs[m], bit); - m = (m << 1) + bit; - } - while (--footerBits); - - { - unsigned prob = probs[m]; - tempPrices[base ] = price + GET_PRICEa_0(prob); - tempPrices[base + offset] = price + GET_PRICEa_1(prob); - } - } - - for (lps = 0; lps < kNumLenToPosStates; lps++) - { - unsigned slot; - unsigned distTableSize2 = (p->distTableSize + 1) >> 1; - UInt32 *posSlotPrices = p->posSlotPrices[lps]; - const CLzmaProb *probs = p->posSlotEncoder[lps]; - - for (slot = 0; slot < distTableSize2; slot++) - { - // posSlotPrices[slot] = RcTree_GetPrice(encoder, kNumPosSlotBits, slot, p->ProbPrices); - UInt32 price; - unsigned bit; - unsigned sym = slot + (1 << (kNumPosSlotBits - 1)); - unsigned prob; - bit = sym & 1; sym >>= 1; price = GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); - prob = probs[(size_t)slot + (1 << (kNumPosSlotBits - 1))]; - posSlotPrices[(size_t)slot * 2 ] = price + GET_PRICEa_0(prob); - posSlotPrices[(size_t)slot * 2 + 1] = price + GET_PRICEa_1(prob); - } - - { - UInt32 delta = ((UInt32)((kEndPosModelIndex / 2 - 1) - kNumAlignBits) << kNumBitPriceShiftBits); - for (slot = kEndPosModelIndex / 2; slot < distTableSize2; slot++) - { - posSlotPrices[(size_t)slot * 2 ] += delta; - posSlotPrices[(size_t)slot * 2 + 1] += delta; - delta += ((UInt32)1 << kNumBitPriceShiftBits); - } - } - - { - UInt32 *dp = p->distancesPrices[lps]; - - dp[0] = posSlotPrices[0]; - dp[1] = posSlotPrices[1]; - dp[2] = posSlotPrices[2]; - dp[3] = posSlotPrices[3]; - - for (i = 4; i < kNumFullDistances; i += 2) - { - UInt32 slotPrice = posSlotPrices[GetPosSlot1(i)]; - dp[i ] = slotPrice + tempPrices[i]; - dp[i + 1] = slotPrice + tempPrices[i + 1]; - } - } - } - // } -} - - - -static void LzmaEnc_Construct(CLzmaEnc *p) -{ - RangeEnc_Construct(&p->rc); - MatchFinder_Construct(&p->matchFinderBase); - - #ifndef _7ZIP_ST - MatchFinderMt_Construct(&p->matchFinderMt); - p->matchFinderMt.MatchFinder = &p->matchFinderBase; - #endif - - { - CLzmaEncProps props; - LzmaEncProps_Init(&props); - LzmaEnc_SetProps(p, &props); - } - - #ifndef LZMA_LOG_BSR - LzmaEnc_FastPosInit(p->g_FastPos); - #endif - - LzmaEnc_InitPriceTables(p->ProbPrices); - p->litProbs = NULL; - p->saveState.litProbs = NULL; - -} - -CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc) -{ - void *p; - p = ISzAlloc_Alloc(alloc, sizeof(CLzmaEnc)); - if (p) - LzmaEnc_Construct((CLzmaEnc *)p); - return p; -} - -static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->litProbs); - ISzAlloc_Free(alloc, p->saveState.litProbs); - p->litProbs = NULL; - p->saveState.litProbs = NULL; -} - -static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - #ifndef _7ZIP_ST - MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); - #endif - - MatchFinder_Free(&p->matchFinderBase, allocBig); - LzmaEnc_FreeLits(p, alloc); - RangeEnc_Free(&p->rc, alloc); -} - -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig); - ISzAlloc_Free(alloc, p); -} - - -MY_NO_INLINE -static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpackSize) -{ - UInt32 nowPos32, startPos32; - if (p->needInit) - { - p->matchFinder.Init(p->matchFinderObj); - p->needInit = 0; - } - - if (p->finished) - return p->result; - RINOK(CheckErrors(p)); - - nowPos32 = (UInt32)p->nowPos64; - startPos32 = nowPos32; - - if (p->nowPos64 == 0) - { - unsigned numPairs; - Byte curByte; - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) - return Flush(p, nowPos32); - ReadMatchDistances(p, &numPairs); - RangeEnc_EncodeBit_0(&p->rc, &p->isMatch[kState_Start][0]); - // p->state = kLiteralNextStates[p->state]; - curByte = *(p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset); - LitEnc_Encode(&p->rc, p->litProbs, curByte); - p->additionalOffset--; - nowPos32++; - } - - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0) - - for (;;) - { - UInt32 dist; - unsigned len, posState; - UInt32 range, ttt, newBound; - CLzmaProb *probs; - - if (p->fastMode) - len = GetOptimumFast(p); - else - { - unsigned oci = p->optCur; - if (p->optEnd == oci) - len = GetOptimum(p, nowPos32); - else - { - const COptimal *opt = &p->opt[oci]; - len = opt->len; - p->backRes = opt->dist; - p->optCur = oci + 1; - } - } - - posState = (unsigned)nowPos32 & p->pbMask; - range = p->rc.range; - probs = &p->isMatch[p->state][posState]; - - RC_BIT_PRE(&p->rc, probs) - - dist = p->backRes; - - #ifdef SHOW_STAT2 - printf("\n pos = %6X, len = %3u pos = %6u", nowPos32, len, dist); - #endif - - if (dist == MARK_LIT) - { - Byte curByte; - const Byte *data; - unsigned state; - - RC_BIT_0(&p->rc, probs); - p->rc.range = range; - data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; - probs = LIT_PROBS(nowPos32, *(data - 1)); - curByte = *data; - state = p->state; - p->state = kLiteralNextStates[state]; - if (IsLitState(state)) - LitEnc_Encode(&p->rc, probs, curByte); - else - LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0])); - } - else - { - RC_BIT_1(&p->rc, probs); - probs = &p->isRep[p->state]; - RC_BIT_PRE(&p->rc, probs) - - if (dist < LZMA_NUM_REPS) - { - RC_BIT_1(&p->rc, probs); - probs = &p->isRepG0[p->state]; - RC_BIT_PRE(&p->rc, probs) - if (dist == 0) - { - RC_BIT_0(&p->rc, probs); - probs = &p->isRep0Long[p->state][posState]; - RC_BIT_PRE(&p->rc, probs) - if (len != 1) - { - RC_BIT_1_BASE(&p->rc, probs); - } - else - { - RC_BIT_0_BASE(&p->rc, probs); - p->state = kShortRepNextStates[p->state]; - } - } - else - { - RC_BIT_1(&p->rc, probs); - probs = &p->isRepG1[p->state]; - RC_BIT_PRE(&p->rc, probs) - if (dist == 1) - { - RC_BIT_0_BASE(&p->rc, probs); - dist = p->reps[1]; - } - else - { - RC_BIT_1(&p->rc, probs); - probs = &p->isRepG2[p->state]; - RC_BIT_PRE(&p->rc, probs) - if (dist == 2) - { - RC_BIT_0_BASE(&p->rc, probs); - dist = p->reps[2]; - } - else - { - RC_BIT_1_BASE(&p->rc, probs); - dist = p->reps[3]; - p->reps[3] = p->reps[2]; - } - p->reps[2] = p->reps[1]; - } - p->reps[1] = p->reps[0]; - p->reps[0] = dist; - } - - RC_NORM(&p->rc) - - p->rc.range = range; - - if (len != 1) - { - LenEnc_Encode(&p->repLenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState); - --p->repLenEncCounter; - p->state = kRepNextStates[p->state]; - } - } - else - { - unsigned posSlot; - RC_BIT_0(&p->rc, probs); - p->rc.range = range; - p->state = kMatchNextStates[p->state]; - - LenEnc_Encode(&p->lenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState); - // --p->lenEnc.counter; - - dist -= LZMA_NUM_REPS; - p->reps[3] = p->reps[2]; - p->reps[2] = p->reps[1]; - p->reps[1] = p->reps[0]; - p->reps[0] = dist + 1; - - p->matchPriceCount++; - GetPosSlot(dist, posSlot); - // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], posSlot); - { - UInt32 sym = (UInt32)posSlot + (1 << kNumPosSlotBits); - range = p->rc.range; - probs = p->posSlotEncoder[GetLenToPosState(len)]; - do - { - CLzmaProb *prob = probs + (sym >> kNumPosSlotBits); - UInt32 bit = (sym >> (kNumPosSlotBits - 1)) & 1; - sym <<= 1; - RC_BIT(&p->rc, prob, bit); - } - while (sym < (1 << kNumPosSlotBits * 2)); - p->rc.range = range; - } - - if (dist >= kStartPosModelIndex) - { - unsigned footerBits = ((posSlot >> 1) - 1); - - if (dist < kNumFullDistances) - { - unsigned base = ((2 | (posSlot & 1)) << footerBits); - RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits, (unsigned)(dist /* - base */)); - } - else - { - UInt32 pos2 = (dist | 0xF) << (32 - footerBits); - range = p->rc.range; - // RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); - /* - do - { - range >>= 1; - p->rc.low += range & (0 - ((dist >> --footerBits) & 1)); - RC_NORM(&p->rc) - } - while (footerBits > kNumAlignBits); - */ - do - { - range >>= 1; - p->rc.low += range & (0 - (pos2 >> 31)); - pos2 += pos2; - RC_NORM(&p->rc) - } - while (pos2 != 0xF0000000); - - - // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); - - { - unsigned m = 1; - unsigned bit; - bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit; - bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit; - bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit; - bit = dist & 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); - p->rc.range = range; - // p->alignPriceCount++; - } - } - } - } - } - - nowPos32 += (UInt32)len; - p->additionalOffset -= len; - - if (p->additionalOffset == 0) - { - UInt32 processed; - - if (!p->fastMode) - { - /* - if (p->alignPriceCount >= 16) // kAlignTableSize - FillAlignPrices(p); - if (p->matchPriceCount >= 128) - FillDistancesPrices(p); - if (p->lenEnc.counter <= 0) - LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPrices); - */ - if (p->matchPriceCount >= 64) - { - FillAlignPrices(p); - // { int y; for (y = 0; y < 100; y++) { - FillDistancesPrices(p); - // }} - LenPriceEnc_UpdateTables(&p->lenEnc, (unsigned)1 << p->pb, &p->lenProbs, p->ProbPrices); - } - if (p->repLenEncCounter <= 0) - { - p->repLenEncCounter = REP_LEN_COUNT; - LenPriceEnc_UpdateTables(&p->repLenEnc, (unsigned)1 << p->pb, &p->repLenProbs, p->ProbPrices); - } - } - - if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) - break; - processed = nowPos32 - startPos32; - - if (maxPackSize) - { - if (processed + kNumOpts + 300 >= maxUnpackSize - || RangeEnc_GetProcessed_sizet(&p->rc) + kPackReserve >= maxPackSize) - break; - } - else if (processed >= (1 << 17)) - { - p->nowPos64 += nowPos32 - startPos32; - return CheckErrors(p); - } - } - } - - p->nowPos64 += nowPos32 - startPos32; - return Flush(p, nowPos32); -} - - - -#define kBigHashDicLimit ((UInt32)1 << 24) - -static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - UInt32 beforeSize = kNumOpts; - if (!RangeEnc_Alloc(&p->rc, alloc)) - return SZ_ERROR_MEM; - - #ifndef _7ZIP_ST - p->mtMode = (p->multiThread && !p->fastMode && (p->matchFinderBase.btMode != 0)); - #endif - - { - unsigned lclp = p->lc + p->lp; - if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp) - { - LzmaEnc_FreeLits(p, alloc); - p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); - p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); - if (!p->litProbs || !p->saveState.litProbs) - { - LzmaEnc_FreeLits(p, alloc); - return SZ_ERROR_MEM; - } - p->lclp = lclp; - } - } - - p->matchFinderBase.bigHash = (Byte)(p->dictSize > kBigHashDicLimit ? 1 : 0); - - if (beforeSize + p->dictSize < keepWindowSize) - beforeSize = keepWindowSize - p->dictSize; - - #ifndef _7ZIP_ST - if (p->mtMode) - { - RINOK(MatchFinderMt_Create(&p->matchFinderMt, p->dictSize, beforeSize, p->numFastBytes, - LZMA_MATCH_LEN_MAX - + 1 /* 18.04 */ - , allocBig)); - p->matchFinderObj = &p->matchFinderMt; - p->matchFinderBase.bigHash = (Byte)( - (p->dictSize > kBigHashDicLimit && p->matchFinderBase.hashMask >= 0xFFFFFF) ? 1 : 0); - MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); - } - else - #endif - { - if (!MatchFinder_Create(&p->matchFinderBase, p->dictSize, beforeSize, p->numFastBytes, LZMA_MATCH_LEN_MAX, allocBig)) - return SZ_ERROR_MEM; - p->matchFinderObj = &p->matchFinderBase; - MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); - } - - return SZ_OK; -} - -static void LzmaEnc_Init(CLzmaEnc *p) -{ - unsigned i; - p->state = 0; - p->reps[0] = - p->reps[1] = - p->reps[2] = - p->reps[3] = 1; - - RangeEnc_Init(&p->rc); - - for (i = 0; i < (1 << kNumAlignBits); i++) - p->posAlignEncoder[i] = kProbInitValue; - - for (i = 0; i < kNumStates; i++) - { - unsigned j; - for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++) - { - p->isMatch[i][j] = kProbInitValue; - p->isRep0Long[i][j] = kProbInitValue; - } - p->isRep[i] = kProbInitValue; - p->isRepG0[i] = kProbInitValue; - p->isRepG1[i] = kProbInitValue; - p->isRepG2[i] = kProbInitValue; - } - - { - for (i = 0; i < kNumLenToPosStates; i++) - { - CLzmaProb *probs = p->posSlotEncoder[i]; - unsigned j; - for (j = 0; j < (1 << kNumPosSlotBits); j++) - probs[j] = kProbInitValue; - } - } - { - for (i = 0; i < kNumFullDistances; i++) - p->posEncoders[i] = kProbInitValue; - } - - { - UInt32 num = (UInt32)0x300 << (p->lp + p->lc); - UInt32 k; - CLzmaProb *probs = p->litProbs; - for (k = 0; k < num; k++) - probs[k] = kProbInitValue; - } - - - LenEnc_Init(&p->lenProbs); - LenEnc_Init(&p->repLenProbs); - - p->optEnd = 0; - p->optCur = 0; - - { - for (i = 0; i < kNumOpts; i++) - p->opt[i].price = kInfinityPrice; - } - - p->additionalOffset = 0; - - p->pbMask = ((unsigned)1 << p->pb) - 1; - p->lpMask = ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc); -} - - -static void LzmaEnc_InitPrices(CLzmaEnc *p) -{ - if (!p->fastMode) - { - FillDistancesPrices(p); - FillAlignPrices(p); - } - - p->lenEnc.tableSize = - p->repLenEnc.tableSize = - p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; - - p->repLenEncCounter = REP_LEN_COUNT; - - LenPriceEnc_UpdateTables(&p->lenEnc, (unsigned)1 << p->pb, &p->lenProbs, p->ProbPrices); - LenPriceEnc_UpdateTables(&p->repLenEnc, (unsigned)1 << p->pb, &p->repLenProbs, p->ProbPrices); -} - -static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - unsigned i; - for (i = kEndPosModelIndex / 2; i < kDicLogSizeMax; i++) - if (p->dictSize <= ((UInt32)1 << i)) - break; - p->distTableSize = i * 2; - - p->finished = False; - p->result = SZ_OK; - RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)); - LzmaEnc_Init(p); - LzmaEnc_InitPrices(p); - p->nowPos64 = 0; - return SZ_OK; -} - -static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, - ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - p->matchFinderBase.stream = inStream; - p->needInit = 1; - p->rc.outStream = outStream; - return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); -} - -SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, - ISeqInStream *inStream, UInt32 keepWindowSize, - ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - p->matchFinderBase.stream = inStream; - p->needInit = 1; - return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); -} - -static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) -{ - p->matchFinderBase.directInput = 1; - p->matchFinderBase.bufferBase = (Byte *)src; - p->matchFinderBase.directInputRem = srcLen; -} - -SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, - UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - LzmaEnc_SetInputBuf(p, src, srcLen); - p->needInit = 1; - - LzmaEnc_SetDataSize(pp, srcLen); - return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); -} - -void LzmaEnc_Finish(CLzmaEncHandle pp) -{ - #ifndef _7ZIP_ST - CLzmaEnc *p = (CLzmaEnc *)pp; - if (p->mtMode) - MatchFinderMt_ReleaseStream(&p->matchFinderMt); - #else - UNUSED_VAR(pp); - #endif -} - - -typedef struct -{ - ISeqOutStream vt; - Byte *data; - SizeT rem; - BoolInt overflow; -} CLzmaEnc_SeqOutStreamBuf; - -static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *data, size_t size) -{ - CLzmaEnc_SeqOutStreamBuf *p = CONTAINER_FROM_VTBL(pp, CLzmaEnc_SeqOutStreamBuf, vt); - if (p->rem < size) - { - size = p->rem; - p->overflow = True; - } - memcpy(p->data, data, size); - p->rem -= size; - p->data += size; - return size; -} - - -/* -UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) -{ - const CLzmaEnc *p = (CLzmaEnc *)pp; - return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); -} -*/ - -const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) -{ - const CLzmaEnc *p = (CLzmaEnc *)pp; - return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; -} - - -SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, - Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - UInt64 nowPos64; - SRes res; - CLzmaEnc_SeqOutStreamBuf outStream; - - outStream.vt.Write = SeqOutStreamBuf_Write; - outStream.data = dest; - outStream.rem = *destLen; - outStream.overflow = False; - - p->writeEndMark = False; - p->finished = False; - p->result = SZ_OK; - - if (reInit) - LzmaEnc_Init(p); - LzmaEnc_InitPrices(p); - - nowPos64 = p->nowPos64; - RangeEnc_Init(&p->rc); - p->rc.outStream = &outStream.vt; - - if (desiredPackSize == 0) - return SZ_ERROR_OUTPUT_EOF; - - res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize); - - *unpackSize = (UInt32)(p->nowPos64 - nowPos64); - *destLen -= outStream.rem; - if (outStream.overflow) - return SZ_ERROR_OUTPUT_EOF; - - return res; -} - - -MY_NO_INLINE -static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) -{ - SRes res = SZ_OK; - - #ifndef _7ZIP_ST - Byte allocaDummy[0x300]; - allocaDummy[0] = 0; - allocaDummy[1] = allocaDummy[0]; - #endif - - for (;;) - { - res = LzmaEnc_CodeOneBlock(p, 0, 0); - if (res != SZ_OK || p->finished) - break; - if (progress) - { - res = ICompressProgress_Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); - if (res != SZ_OK) - { - res = SZ_ERROR_PROGRESS; - break; - } - } - } - - LzmaEnc_Finish(p); - - /* - if (res == SZ_OK && !Inline_MatchFinder_IsFinishedOK(&p->matchFinderBase)) - res = SZ_ERROR_FAIL; - } - */ - - return res; -} - - -SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, - ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); - return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); -} - - -SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) -{ - CLzmaEnc *p = (CLzmaEnc *)pp; - unsigned i; - UInt32 dictSize = p->dictSize; - if (*size < LZMA_PROPS_SIZE) - return SZ_ERROR_PARAM; - *size = LZMA_PROPS_SIZE; - props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); - - if (dictSize >= ((UInt32)1 << 22)) - { - const UInt32 kDictMask = ((UInt32)1 << 20) - 1; - if (dictSize < (UInt32)0xFFFFFFFF - kDictMask) - dictSize = (dictSize + kDictMask) & ~kDictMask; - } - else for (i = 11; i <= 30; i++) - { - if (dictSize <= ((UInt32)2 << i)) { dictSize = ((UInt32)2 << i); break; } - if (dictSize <= ((UInt32)3 << i)) { dictSize = ((UInt32)3 << i); break; } - } - - for (i = 0; i < 4; i++) - props[1 + i] = (Byte)(dictSize >> (8 * i)); - return SZ_OK; -} - - -unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle pp) -{ - return (unsigned)((CLzmaEnc *)pp)->writeEndMark; -} - - -SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - SRes res; - CLzmaEnc *p = (CLzmaEnc *)pp; - - CLzmaEnc_SeqOutStreamBuf outStream; - - outStream.vt.Write = SeqOutStreamBuf_Write; - outStream.data = dest; - outStream.rem = *destLen; - outStream.overflow = False; - - p->writeEndMark = writeEndMark; - p->rc.outStream = &outStream.vt; - - res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); - - if (res == SZ_OK) - { - res = LzmaEnc_Encode2(p, progress); - if (res == SZ_OK && p->nowPos64 != srcLen) - res = SZ_ERROR_FAIL; - } - - *destLen -= outStream.rem; - if (outStream.overflow) - return SZ_ERROR_OUTPUT_EOF; - return res; -} - - -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); - SRes res; - if (!p) - return SZ_ERROR_MEM; - - res = LzmaEnc_SetProps(p, props); - if (res == SZ_OK) - { - res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); - if (res == SZ_OK) - res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, - writeEndMark, progress, alloc, allocBig); - } - - LzmaEnc_Destroy(p, alloc, allocBig); - return res; -} - - -/* -#ifndef _7ZIP_ST -void LzmaEnc_GetLzThreads(CLzmaEncHandle pp, HANDLE lz_threads[2]) -{ - const CLzmaEnc *p = (CLzmaEnc *)pp; - lz_threads[0] = p->matchFinderMt.hashSync.thread; - lz_threads[1] = p->matchFinderMt.btSync.thread; -} -#endif -*/ +/* LzmaEnc.c -- LZMA Encoder +2022-07-15: Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +/* #define SHOW_STAT */ +/* #define SHOW_STAT2 */ + +#if defined(SHOW_STAT) || defined(SHOW_STAT2) +#include +#endif + +#include "CpuArch.h" +#include "LzmaEnc.h" + +#include "LzFind.h" +#ifndef _7ZIP_ST +#include "LzFindMt.h" +#endif + +/* the following LzmaEnc_* declarations is internal LZMA interface for LZMA2 encoder */ + +SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, ISeqInStream *inStream, UInt32 keepWindowSize, + ISzAllocPtr alloc, ISzAllocPtr allocBig); +SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, + UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig); +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, + Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize); +const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp); +void LzmaEnc_Finish(CLzmaEncHandle pp); +void LzmaEnc_SaveState(CLzmaEncHandle pp); +void LzmaEnc_RestoreState(CLzmaEncHandle pp); + +#ifdef SHOW_STAT +static unsigned g_STAT_OFFSET = 0; +#endif + +/* for good normalization speed we still reserve 256 MB before 4 GB range */ +#define kLzmaMaxHistorySize ((UInt32)15 << 28) + +#define kNumTopBits 24 +#define kTopValue ((UInt32)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 +#define kProbInitValue (kBitModelTotal >> 1) + +#define kNumMoveReducingBits 4 +#define kNumBitPriceShiftBits 4 +// #define kBitPrice (1 << kNumBitPriceShiftBits) + +#define REP_LEN_COUNT 64 + +void LzmaEncProps_Init(CLzmaEncProps *p) +{ + p->level = 5; + p->dictSize = p->mc = 0; + p->reduceSize = (UInt64)(Int64)-1; + p->lc = p->lp = p->pb = p->algo = p->fb = p->btMode = p->numHashBytes = p->numThreads = -1; + p->writeEndMark = 0; + p->affinity = 0; +} + +void LzmaEncProps_Normalize(CLzmaEncProps *p) +{ + int level = p->level; + if (level < 0) level = 5; + p->level = level; + + if (p->dictSize == 0) + p->dictSize = + ( level <= 3 ? ((UInt32)1 << (level * 2 + 16)) : + ( level <= 6 ? ((UInt32)1 << (level + 19)) : + ( level <= 7 ? ((UInt32)1 << 25) : ((UInt32)1 << 26) + ))); + + if (p->dictSize > p->reduceSize) + { + UInt32 v = (UInt32)p->reduceSize; + const UInt32 kReduceMin = ((UInt32)1 << 12); + if (v < kReduceMin) + v = kReduceMin; + if (p->dictSize > v) + p->dictSize = v; + } + + if (p->lc < 0) p->lc = 3; + if (p->lp < 0) p->lp = 0; + if (p->pb < 0) p->pb = 2; + + if (p->algo < 0) p->algo = (level < 5 ? 0 : 1); + if (p->fb < 0) p->fb = (level < 7 ? 32 : 64); + if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); + if (p->numHashBytes < 0) p->numHashBytes = (p->btMode ? 4 : 5); + if (p->mc == 0) p->mc = (16 + ((unsigned)p->fb >> 1)) >> (p->btMode ? 0 : 1); + + if (p->numThreads < 0) + p->numThreads = + #ifndef _7ZIP_ST + ((p->btMode && p->algo) ? 2 : 1); + #else + 1; + #endif +} + +UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2) +{ + CLzmaEncProps props = *props2; + LzmaEncProps_Normalize(&props); + return props.dictSize; +} + + +/* +x86/x64: + +BSR: + IF (SRC == 0) ZF = 1, DEST is undefined; + AMD : DEST is unchanged; + IF (SRC != 0) ZF = 0; DEST is index of top non-zero bit + BSR is slow in some processors + +LZCNT: + IF (SRC == 0) CF = 1, DEST is size_in_bits_of_register(src) (32 or 64) + IF (SRC != 0) CF = 0, DEST = num_lead_zero_bits + IF (DEST == 0) ZF = 1; + +LZCNT works only in new processors starting from Haswell. +if LZCNT is not supported by processor, then it's executed as BSR. +LZCNT can be faster than BSR, if supported. +*/ + +// #define LZMA_LOG_BSR + +#if defined(MY_CPU_ARM_OR_ARM64) /* || defined(MY_CPU_X86_OR_AMD64) */ + + #if (defined(__clang__) && (__clang_major__ >= 6)) \ + || (defined(__GNUC__) && (__GNUC__ >= 6)) + #define LZMA_LOG_BSR + #elif defined(_MSC_VER) && (_MSC_VER >= 1300) + // #if defined(MY_CPU_ARM_OR_ARM64) + #define LZMA_LOG_BSR + // #endif + #endif +#endif + +// #include + +#ifdef LZMA_LOG_BSR + +#if defined(__clang__) \ + || defined(__GNUC__) + +/* + C code: : (30 - __builtin_clz(x)) + gcc9/gcc10 for x64 /x86 : 30 - (bsr(x) xor 31) + clang10 for x64 : 31 + (bsr(x) xor -32) +*/ + + #define MY_clz(x) ((unsigned)__builtin_clz(x)) + // __lzcnt32 + // __builtin_ia32_lzcnt_u32 + +#else // #if defined(_MSC_VER) + + #ifdef MY_CPU_ARM_OR_ARM64 + + #define MY_clz _CountLeadingZeros + + #else // if defined(MY_CPU_X86_OR_AMD64) + + // #define MY_clz __lzcnt // we can use lzcnt (unsupported by old CPU) + // _BitScanReverse code is not optimal for some MSVC compilers + #define BSR2_RET(pos, res) { unsigned long zz; _BitScanReverse(&zz, (pos)); zz--; \ + res = (zz + zz) + (pos >> zz); } + + #endif // MY_CPU_X86_OR_AMD64 + +#endif // _MSC_VER + + +#ifndef BSR2_RET + + #define BSR2_RET(pos, res) { unsigned zz = 30 - MY_clz(pos); \ + res = (zz + zz) + (pos >> zz); } + +#endif + + +unsigned GetPosSlot1(UInt32 pos); +unsigned GetPosSlot1(UInt32 pos) +{ + unsigned res; + BSR2_RET(pos, res); + return res; +} +#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } +#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); } + + +#else // ! LZMA_LOG_BSR + +#define kNumLogBits (11 + sizeof(size_t) / 8 * 3) + +#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7) + +static void LzmaEnc_FastPosInit(Byte *g_FastPos) +{ + unsigned slot; + g_FastPos[0] = 0; + g_FastPos[1] = 1; + g_FastPos += 2; + + for (slot = 2; slot < kNumLogBits * 2; slot++) + { + size_t k = ((size_t)1 << ((slot >> 1) - 1)); + size_t j; + for (j = 0; j < k; j++) + g_FastPos[j] = (Byte)slot; + g_FastPos += k; + } +} + +/* we can use ((limit - pos) >> 31) only if (pos < ((UInt32)1 << 31)) */ +/* +#define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ + (0 - (((((UInt32)1 << (kNumLogBits + 6)) - 1) - pos) >> 31))); \ + res = p->g_FastPos[pos >> zz] + (zz * 2); } +*/ + +/* +#define BSR2_RET(pos, res) { unsigned zz = 6 + ((kNumLogBits - 1) & \ + (0 - (((((UInt32)1 << (kNumLogBits)) - 1) - (pos >> 6)) >> 31))); \ + res = p->g_FastPos[pos >> zz] + (zz * 2); } +*/ + +#define BSR2_RET(pos, res) { unsigned zz = (pos < (1 << (kNumLogBits + 6))) ? 6 : 6 + kNumLogBits - 1; \ + res = p->g_FastPos[pos >> zz] + (zz * 2); } + +/* +#define BSR2_RET(pos, res) { res = (pos < (1 << (kNumLogBits + 6))) ? \ + p->g_FastPos[pos >> 6] + 12 : \ + p->g_FastPos[pos >> (6 + kNumLogBits - 1)] + (6 + (kNumLogBits - 1)) * 2; } +*/ + +#define GetPosSlot1(pos) p->g_FastPos[pos] +#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); } +#define GetPosSlot(pos, res) { if (pos < kNumFullDistances) res = p->g_FastPos[pos & (kNumFullDistances - 1)]; else BSR2_RET(pos, res); } + +#endif // LZMA_LOG_BSR + + +#define LZMA_NUM_REPS 4 + +typedef UInt16 CState; +typedef UInt16 CExtra; + +typedef struct +{ + UInt32 price; + CState state; + CExtra extra; + // 0 : normal + // 1 : LIT : MATCH + // > 1 : MATCH (extra-1) : LIT : REP0 (len) + UInt32 len; + UInt32 dist; + UInt32 reps[LZMA_NUM_REPS]; +} COptimal; + + +// 18.06 +#define kNumOpts (1 << 11) +#define kPackReserve (kNumOpts * 8) +// #define kNumOpts (1 << 12) +// #define kPackReserve (1 + kNumOpts * 2) + +#define kNumLenToPosStates 4 +#define kNumPosSlotBits 6 +// #define kDicLogSizeMin 0 +#define kDicLogSizeMax 32 +#define kDistTableSizeMax (kDicLogSizeMax * 2) + +#define kNumAlignBits 4 +#define kAlignTableSize (1 << kNumAlignBits) +#define kAlignMask (kAlignTableSize - 1) + +#define kStartPosModelIndex 4 +#define kEndPosModelIndex 14 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + +typedef +#ifdef _LZMA_PROB32 + UInt32 +#else + UInt16 +#endif + CLzmaProb; + +#define LZMA_PB_MAX 4 +#define LZMA_LC_MAX 8 +#define LZMA_LP_MAX 4 + +#define LZMA_NUM_PB_STATES_MAX (1 << LZMA_PB_MAX) + +#define kLenNumLowBits 3 +#define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumHighBits 8 +#define kLenNumHighSymbols (1 << kLenNumHighBits) +#define kLenNumSymbolsTotal (kLenNumLowSymbols * 2 + kLenNumHighSymbols) + +#define LZMA_MATCH_LEN_MIN 2 +#define LZMA_MATCH_LEN_MAX (LZMA_MATCH_LEN_MIN + kLenNumSymbolsTotal - 1) + +#define kNumStates 12 + + +typedef struct +{ + CLzmaProb low[LZMA_NUM_PB_STATES_MAX << (kLenNumLowBits + 1)]; + CLzmaProb high[kLenNumHighSymbols]; +} CLenEnc; + + +typedef struct +{ + unsigned tableSize; + UInt32 prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal]; + // UInt32 prices1[LZMA_NUM_PB_STATES_MAX][kLenNumLowSymbols * 2]; + // UInt32 prices2[kLenNumSymbolsTotal]; +} CLenPriceEnc; + +#define GET_PRICE_LEN(p, posState, len) \ + ((p)->prices[posState][(size_t)(len) - LZMA_MATCH_LEN_MIN]) + +/* +#define GET_PRICE_LEN(p, posState, len) \ + ((p)->prices2[(size_t)(len) - 2] + ((p)->prices1[posState][((len) - 2) & (kLenNumLowSymbols * 2 - 1)] & (((len) - 2 - kLenNumLowSymbols * 2) >> 9))) +*/ + +typedef struct +{ + UInt32 range; + unsigned cache; + UInt64 low; + UInt64 cacheSize; + Byte *buf; + Byte *bufLim; + Byte *bufBase; + ISeqOutStream *outStream; + UInt64 processed; + SRes res; +} CRangeEnc; + + +typedef struct +{ + CLzmaProb *litProbs; + + unsigned state; + UInt32 reps[LZMA_NUM_REPS]; + + CLzmaProb posAlignEncoder[1 << kNumAlignBits]; + CLzmaProb isRep[kNumStates]; + CLzmaProb isRepG0[kNumStates]; + CLzmaProb isRepG1[kNumStates]; + CLzmaProb isRepG2[kNumStates]; + CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; + CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; + + CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; + CLzmaProb posEncoders[kNumFullDistances]; + + CLenEnc lenProbs; + CLenEnc repLenProbs; + +} CSaveState; + + +typedef UInt32 CProbPrice; + + +typedef struct +{ + void *matchFinderObj; + IMatchFinder2 matchFinder; + + unsigned optCur; + unsigned optEnd; + + unsigned longestMatchLen; + unsigned numPairs; + UInt32 numAvail; + + unsigned state; + unsigned numFastBytes; + unsigned additionalOffset; + UInt32 reps[LZMA_NUM_REPS]; + unsigned lpMask, pbMask; + CLzmaProb *litProbs; + CRangeEnc rc; + + UInt32 backRes; + + unsigned lc, lp, pb; + unsigned lclp; + + BoolInt fastMode; + BoolInt writeEndMark; + BoolInt finished; + BoolInt multiThread; + BoolInt needInit; + // BoolInt _maxMode; + + UInt64 nowPos64; + + unsigned matchPriceCount; + // unsigned alignPriceCount; + int repLenEncCounter; + + unsigned distTableSize; + + UInt32 dictSize; + SRes result; + + #ifndef _7ZIP_ST + BoolInt mtMode; + // begin of CMatchFinderMt is used in LZ thread + CMatchFinderMt matchFinderMt; + // end of CMatchFinderMt is used in BT and HASH threads + // #else + // CMatchFinder matchFinderBase; + #endif + CMatchFinder matchFinderBase; + + + // we suppose that we have 8-bytes alignment after CMatchFinder + + #ifndef _7ZIP_ST + Byte pad[128]; + #endif + + // LZ thread + CProbPrice ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; + + // we want {len , dist} pairs to be 8-bytes aligned in matches array + UInt32 matches[LZMA_MATCH_LEN_MAX * 2 + 2]; + + // we want 8-bytes alignment here + UInt32 alignPrices[kAlignTableSize]; + UInt32 posSlotPrices[kNumLenToPosStates][kDistTableSizeMax]; + UInt32 distancesPrices[kNumLenToPosStates][kNumFullDistances]; + + CLzmaProb posAlignEncoder[1 << kNumAlignBits]; + CLzmaProb isRep[kNumStates]; + CLzmaProb isRepG0[kNumStates]; + CLzmaProb isRepG1[kNumStates]; + CLzmaProb isRepG2[kNumStates]; + CLzmaProb isMatch[kNumStates][LZMA_NUM_PB_STATES_MAX]; + CLzmaProb isRep0Long[kNumStates][LZMA_NUM_PB_STATES_MAX]; + CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; + CLzmaProb posEncoders[kNumFullDistances]; + + CLenEnc lenProbs; + CLenEnc repLenProbs; + + #ifndef LZMA_LOG_BSR + Byte g_FastPos[1 << kNumLogBits]; + #endif + + CLenPriceEnc lenEnc; + CLenPriceEnc repLenEnc; + + COptimal opt[kNumOpts]; + + CSaveState saveState; + + // BoolInt mf_Failure; + #ifndef _7ZIP_ST + Byte pad2[128]; + #endif +} CLzmaEnc; + + +#define MFB (p->matchFinderBase) +/* +#ifndef _7ZIP_ST +#define MFB (p->matchFinderMt.MatchFinder) +#endif +*/ + +#define COPY_ARR(dest, src, arr) memcpy(dest->arr, src->arr, sizeof(src->arr)); + +void LzmaEnc_SaveState(CLzmaEncHandle pp) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + CSaveState *dest = &p->saveState; + + dest->state = p->state; + + dest->lenProbs = p->lenProbs; + dest->repLenProbs = p->repLenProbs; + + COPY_ARR(dest, p, reps); + + COPY_ARR(dest, p, posAlignEncoder); + COPY_ARR(dest, p, isRep); + COPY_ARR(dest, p, isRepG0); + COPY_ARR(dest, p, isRepG1); + COPY_ARR(dest, p, isRepG2); + COPY_ARR(dest, p, isMatch); + COPY_ARR(dest, p, isRep0Long); + COPY_ARR(dest, p, posSlotEncoder); + COPY_ARR(dest, p, posEncoders); + + memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << p->lclp) * sizeof(CLzmaProb)); +} + + +void LzmaEnc_RestoreState(CLzmaEncHandle pp) +{ + CLzmaEnc *dest = (CLzmaEnc *)pp; + const CSaveState *p = &dest->saveState; + + dest->state = p->state; + + dest->lenProbs = p->lenProbs; + dest->repLenProbs = p->repLenProbs; + + COPY_ARR(dest, p, reps); + + COPY_ARR(dest, p, posAlignEncoder); + COPY_ARR(dest, p, isRep); + COPY_ARR(dest, p, isRepG0); + COPY_ARR(dest, p, isRepG1); + COPY_ARR(dest, p, isRepG2); + COPY_ARR(dest, p, isMatch); + COPY_ARR(dest, p, isRep0Long); + COPY_ARR(dest, p, posSlotEncoder); + COPY_ARR(dest, p, posEncoders); + + memcpy(dest->litProbs, p->litProbs, ((UInt32)0x300 << dest->lclp) * sizeof(CLzmaProb)); +} + + + +SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + CLzmaEncProps props = *props2; + LzmaEncProps_Normalize(&props); + + if (props.lc > LZMA_LC_MAX + || props.lp > LZMA_LP_MAX + || props.pb > LZMA_PB_MAX) + return SZ_ERROR_PARAM; + + + if (props.dictSize > kLzmaMaxHistorySize) + props.dictSize = kLzmaMaxHistorySize; + + #ifndef LZMA_LOG_BSR + { + const UInt64 dict64 = props.dictSize; + if (dict64 > ((UInt64)1 << kDicLogSizeMaxCompress)) + return SZ_ERROR_PARAM; + } + #endif + + p->dictSize = props.dictSize; + { + unsigned fb = (unsigned)props.fb; + if (fb < 5) + fb = 5; + if (fb > LZMA_MATCH_LEN_MAX) + fb = LZMA_MATCH_LEN_MAX; + p->numFastBytes = fb; + } + p->lc = (unsigned)props.lc; + p->lp = (unsigned)props.lp; + p->pb = (unsigned)props.pb; + p->fastMode = (props.algo == 0); + // p->_maxMode = True; + MFB.btMode = (Byte)(props.btMode ? 1 : 0); + { + unsigned numHashBytes = 4; + if (props.btMode) + { + if (props.numHashBytes < 2) numHashBytes = 2; + else if (props.numHashBytes < 4) numHashBytes = (unsigned)props.numHashBytes; + } + if (props.numHashBytes >= 5) numHashBytes = 5; + + MFB.numHashBytes = numHashBytes; + } + + MFB.cutValue = props.mc; + + p->writeEndMark = (BoolInt)props.writeEndMark; + + #ifndef _7ZIP_ST + /* + if (newMultiThread != _multiThread) + { + ReleaseMatchFinder(); + _multiThread = newMultiThread; + } + */ + p->multiThread = (props.numThreads > 1); + p->matchFinderMt.btSync.affinity = + p->matchFinderMt.hashSync.affinity = props.affinity; + #endif + + return SZ_OK; +} + + +void LzmaEnc_SetDataSize(CLzmaEncHandle pp, UInt64 expectedDataSiize) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + MFB.expectedDataSize = expectedDataSiize; +} + + +#define kState_Start 0 +#define kState_LitAfterMatch 4 +#define kState_LitAfterRep 5 +#define kState_MatchAfterLit 7 +#define kState_RepAfterLit 8 + +static const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; +static const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; +static const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; +static const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; + +#define IsLitState(s) ((s) < 7) +#define GetLenToPosState2(len) (((len) < kNumLenToPosStates - 1) ? (len) : kNumLenToPosStates - 1) +#define GetLenToPosState(len) (((len) < kNumLenToPosStates + 1) ? (len) - 2 : kNumLenToPosStates - 1) + +#define kInfinityPrice (1 << 30) + +static void RangeEnc_Construct(CRangeEnc *p) +{ + p->outStream = NULL; + p->bufBase = NULL; +} + +#define RangeEnc_GetProcessed(p) ( (p)->processed + (size_t)((p)->buf - (p)->bufBase) + (p)->cacheSize) +#define RangeEnc_GetProcessed_sizet(p) ((size_t)(p)->processed + (size_t)((p)->buf - (p)->bufBase) + (size_t)(p)->cacheSize) + +#define RC_BUF_SIZE (1 << 16) + +static int RangeEnc_Alloc(CRangeEnc *p, ISzAllocPtr alloc) +{ + if (!p->bufBase) + { + p->bufBase = (Byte *)ISzAlloc_Alloc(alloc, RC_BUF_SIZE); + if (!p->bufBase) + return 0; + p->bufLim = p->bufBase + RC_BUF_SIZE; + } + return 1; +} + +static void RangeEnc_Free(CRangeEnc *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->bufBase); + p->bufBase = NULL; +} + +static void RangeEnc_Init(CRangeEnc *p) +{ + p->range = 0xFFFFFFFF; + p->cache = 0; + p->low = 0; + p->cacheSize = 0; + + p->buf = p->bufBase; + + p->processed = 0; + p->res = SZ_OK; +} + +MY_NO_INLINE static void RangeEnc_FlushStream(CRangeEnc *p) +{ + const size_t num = (size_t)(p->buf - p->bufBase); + if (p->res == SZ_OK) + { + if (num != ISeqOutStream_Write(p->outStream, p->bufBase, num)) + p->res = SZ_ERROR_WRITE; + } + p->processed += num; + p->buf = p->bufBase; +} + +MY_NO_INLINE static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p) +{ + UInt32 low = (UInt32)p->low; + unsigned high = (unsigned)(p->low >> 32); + p->low = (UInt32)(low << 8); + if (low < (UInt32)0xFF000000 || high != 0) + { + { + Byte *buf = p->buf; + *buf++ = (Byte)(p->cache + high); + p->cache = (unsigned)(low >> 24); + p->buf = buf; + if (buf == p->bufLim) + RangeEnc_FlushStream(p); + if (p->cacheSize == 0) + return; + } + high += 0xFF; + for (;;) + { + Byte *buf = p->buf; + *buf++ = (Byte)(high); + p->buf = buf; + if (buf == p->bufLim) + RangeEnc_FlushStream(p); + if (--p->cacheSize == 0) + return; + } + } + p->cacheSize++; +} + +static void RangeEnc_FlushData(CRangeEnc *p) +{ + int i; + for (i = 0; i < 5; i++) + RangeEnc_ShiftLow(p); +} + +#define RC_NORM(p) if (range < kTopValue) { range <<= 8; RangeEnc_ShiftLow(p); } + +#define RC_BIT_PRE(p, prob) \ + ttt = *(prob); \ + newBound = (range >> kNumBitModelTotalBits) * ttt; + +// #define _LZMA_ENC_USE_BRANCH + +#ifdef _LZMA_ENC_USE_BRANCH + +#define RC_BIT(p, prob, bit) { \ + RC_BIT_PRE(p, prob) \ + if (bit == 0) { range = newBound; ttt += (kBitModelTotal - ttt) >> kNumMoveBits; } \ + else { (p)->low += newBound; range -= newBound; ttt -= ttt >> kNumMoveBits; } \ + *(prob) = (CLzmaProb)ttt; \ + RC_NORM(p) \ + } + +#else + +#define RC_BIT(p, prob, bit) { \ + UInt32 mask; \ + RC_BIT_PRE(p, prob) \ + mask = 0 - (UInt32)bit; \ + range &= mask; \ + mask &= newBound; \ + range -= mask; \ + (p)->low += mask; \ + mask = (UInt32)bit - 1; \ + range += newBound & mask; \ + mask &= (kBitModelTotal - ((1 << kNumMoveBits) - 1)); \ + mask += ((1 << kNumMoveBits) - 1); \ + ttt += (UInt32)((Int32)(mask - ttt) >> kNumMoveBits); \ + *(prob) = (CLzmaProb)ttt; \ + RC_NORM(p) \ + } + +#endif + + + + +#define RC_BIT_0_BASE(p, prob) \ + range = newBound; *(prob) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); + +#define RC_BIT_1_BASE(p, prob) \ + range -= newBound; (p)->low += newBound; *(prob) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); \ + +#define RC_BIT_0(p, prob) \ + RC_BIT_0_BASE(p, prob) \ + RC_NORM(p) + +#define RC_BIT_1(p, prob) \ + RC_BIT_1_BASE(p, prob) \ + RC_NORM(p) + +static void RangeEnc_EncodeBit_0(CRangeEnc *p, CLzmaProb *prob) +{ + UInt32 range, ttt, newBound; + range = p->range; + RC_BIT_PRE(p, prob) + RC_BIT_0(p, prob) + p->range = range; +} + +static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, UInt32 sym) +{ + UInt32 range = p->range; + sym |= 0x100; + do + { + UInt32 ttt, newBound; + // RangeEnc_EncodeBit(p, probs + (sym >> 8), (sym >> 7) & 1); + CLzmaProb *prob = probs + (sym >> 8); + UInt32 bit = (sym >> 7) & 1; + sym <<= 1; + RC_BIT(p, prob, bit); + } + while (sym < 0x10000); + p->range = range; +} + +static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, UInt32 sym, UInt32 matchByte) +{ + UInt32 range = p->range; + UInt32 offs = 0x100; + sym |= 0x100; + do + { + UInt32 ttt, newBound; + CLzmaProb *prob; + UInt32 bit; + matchByte <<= 1; + // RangeEnc_EncodeBit(p, probs + (offs + (matchByte & offs) + (sym >> 8)), (sym >> 7) & 1); + prob = probs + (offs + (matchByte & offs) + (sym >> 8)); + bit = (sym >> 7) & 1; + sym <<= 1; + offs &= ~(matchByte ^ sym); + RC_BIT(p, prob, bit); + } + while (sym < 0x10000); + p->range = range; +} + + + +static void LzmaEnc_InitPriceTables(CProbPrice *ProbPrices) +{ + UInt32 i; + for (i = 0; i < (kBitModelTotal >> kNumMoveReducingBits); i++) + { + const unsigned kCyclesBits = kNumBitPriceShiftBits; + UInt32 w = (i << kNumMoveReducingBits) + (1 << (kNumMoveReducingBits - 1)); + unsigned bitCount = 0; + unsigned j; + for (j = 0; j < kCyclesBits; j++) + { + w = w * w; + bitCount <<= 1; + while (w >= ((UInt32)1 << 16)) + { + w >>= 1; + bitCount++; + } + } + ProbPrices[i] = (CProbPrice)(((unsigned)kNumBitModelTotalBits << kCyclesBits) - 15 - bitCount); + // printf("\n%3d: %5d", i, ProbPrices[i]); + } +} + + +#define GET_PRICE(prob, bit) \ + p->ProbPrices[((prob) ^ (unsigned)(((-(int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; + +#define GET_PRICEa(prob, bit) \ + ProbPrices[((prob) ^ (unsigned)((-((int)(bit))) & (kBitModelTotal - 1))) >> kNumMoveReducingBits]; + +#define GET_PRICE_0(prob) p->ProbPrices[(prob) >> kNumMoveReducingBits] +#define GET_PRICE_1(prob) p->ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] + +#define GET_PRICEa_0(prob) ProbPrices[(prob) >> kNumMoveReducingBits] +#define GET_PRICEa_1(prob) ProbPrices[((prob) ^ (kBitModelTotal - 1)) >> kNumMoveReducingBits] + + +static UInt32 LitEnc_GetPrice(const CLzmaProb *probs, UInt32 sym, const CProbPrice *ProbPrices) +{ + UInt32 price = 0; + sym |= 0x100; + do + { + unsigned bit = sym & 1; + sym >>= 1; + price += GET_PRICEa(probs[sym], bit); + } + while (sym >= 2); + return price; +} + + +static UInt32 LitEnc_Matched_GetPrice(const CLzmaProb *probs, UInt32 sym, UInt32 matchByte, const CProbPrice *ProbPrices) +{ + UInt32 price = 0; + UInt32 offs = 0x100; + sym |= 0x100; + do + { + matchByte <<= 1; + price += GET_PRICEa(probs[offs + (matchByte & offs) + (sym >> 8)], (sym >> 7) & 1); + sym <<= 1; + offs &= ~(matchByte ^ sym); + } + while (sym < 0x10000); + return price; +} + + +static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, unsigned numBits, unsigned sym) +{ + UInt32 range = rc->range; + unsigned m = 1; + do + { + UInt32 ttt, newBound; + unsigned bit = sym & 1; + // RangeEnc_EncodeBit(rc, probs + m, bit); + sym >>= 1; + RC_BIT(rc, probs + m, bit); + m = (m << 1) | bit; + } + while (--numBits); + rc->range = range; +} + + + +static void LenEnc_Init(CLenEnc *p) +{ + unsigned i; + for (i = 0; i < (LZMA_NUM_PB_STATES_MAX << (kLenNumLowBits + 1)); i++) + p->low[i] = kProbInitValue; + for (i = 0; i < kLenNumHighSymbols; i++) + p->high[i] = kProbInitValue; +} + +static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, unsigned sym, unsigned posState) +{ + UInt32 range, ttt, newBound; + CLzmaProb *probs = p->low; + range = rc->range; + RC_BIT_PRE(rc, probs); + if (sym >= kLenNumLowSymbols) + { + RC_BIT_1(rc, probs); + probs += kLenNumLowSymbols; + RC_BIT_PRE(rc, probs); + if (sym >= kLenNumLowSymbols * 2) + { + RC_BIT_1(rc, probs); + rc->range = range; + // RcTree_Encode(rc, p->high, kLenNumHighBits, sym - kLenNumLowSymbols * 2); + LitEnc_Encode(rc, p->high, sym - kLenNumLowSymbols * 2); + return; + } + sym -= kLenNumLowSymbols; + } + + // RcTree_Encode(rc, probs + (posState << kLenNumLowBits), kLenNumLowBits, sym); + { + unsigned m; + unsigned bit; + RC_BIT_0(rc, probs); + probs += (posState << (1 + kLenNumLowBits)); + bit = (sym >> 2) ; RC_BIT(rc, probs + 1, bit); m = (1 << 1) + bit; + bit = (sym >> 1) & 1; RC_BIT(rc, probs + m, bit); m = (m << 1) + bit; + bit = sym & 1; RC_BIT(rc, probs + m, bit); + rc->range = range; + } +} + +static void SetPrices_3(const CLzmaProb *probs, UInt32 startPrice, UInt32 *prices, const CProbPrice *ProbPrices) +{ + unsigned i; + for (i = 0; i < 8; i += 2) + { + UInt32 price = startPrice; + UInt32 prob; + price += GET_PRICEa(probs[1 ], (i >> 2)); + price += GET_PRICEa(probs[2 + (i >> 2)], (i >> 1) & 1); + prob = probs[4 + (i >> 1)]; + prices[i ] = price + GET_PRICEa_0(prob); + prices[i + 1] = price + GET_PRICEa_1(prob); + } +} + + +MY_NO_INLINE static void MY_FAST_CALL LenPriceEnc_UpdateTables( + CLenPriceEnc *p, + unsigned numPosStates, + const CLenEnc *enc, + const CProbPrice *ProbPrices) +{ + UInt32 b; + + { + unsigned prob = enc->low[0]; + UInt32 a, c; + unsigned posState; + b = GET_PRICEa_1(prob); + a = GET_PRICEa_0(prob); + c = b + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); + for (posState = 0; posState < numPosStates; posState++) + { + UInt32 *prices = p->prices[posState]; + const CLzmaProb *probs = enc->low + (posState << (1 + kLenNumLowBits)); + SetPrices_3(probs, a, prices, ProbPrices); + SetPrices_3(probs + kLenNumLowSymbols, c, prices + kLenNumLowSymbols, ProbPrices); + } + } + + /* + { + unsigned i; + UInt32 b; + a = GET_PRICEa_0(enc->low[0]); + for (i = 0; i < kLenNumLowSymbols; i++) + p->prices2[i] = a; + a = GET_PRICEa_1(enc->low[0]); + b = a + GET_PRICEa_0(enc->low[kLenNumLowSymbols]); + for (i = kLenNumLowSymbols; i < kLenNumLowSymbols * 2; i++) + p->prices2[i] = b; + a += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); + } + */ + + // p->counter = numSymbols; + // p->counter = 64; + + { + unsigned i = p->tableSize; + + if (i > kLenNumLowSymbols * 2) + { + const CLzmaProb *probs = enc->high; + UInt32 *prices = p->prices[0] + kLenNumLowSymbols * 2; + i -= kLenNumLowSymbols * 2 - 1; + i >>= 1; + b += GET_PRICEa_1(enc->low[kLenNumLowSymbols]); + do + { + /* + p->prices2[i] = a + + // RcTree_GetPrice(enc->high, kLenNumHighBits, i - kLenNumLowSymbols * 2, ProbPrices); + LitEnc_GetPrice(probs, i - kLenNumLowSymbols * 2, ProbPrices); + */ + // UInt32 price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices); + unsigned sym = --i + (1 << (kLenNumHighBits - 1)); + UInt32 price = b; + do + { + unsigned bit = sym & 1; + sym >>= 1; + price += GET_PRICEa(probs[sym], bit); + } + while (sym >= 2); + + { + unsigned prob = probs[(size_t)i + (1 << (kLenNumHighBits - 1))]; + prices[(size_t)i * 2 ] = price + GET_PRICEa_0(prob); + prices[(size_t)i * 2 + 1] = price + GET_PRICEa_1(prob); + } + } + while (i); + + { + unsigned posState; + size_t num = (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->prices[0][0]); + for (posState = 1; posState < numPosStates; posState++) + memcpy(p->prices[posState] + kLenNumLowSymbols * 2, p->prices[0] + kLenNumLowSymbols * 2, num); + } + } + } +} + +/* + #ifdef SHOW_STAT + g_STAT_OFFSET += num; + printf("\n MovePos %u", num); + #endif +*/ + +#define MOVE_POS(p, num) { \ + p->additionalOffset += (num); \ + p->matchFinder.Skip(p->matchFinderObj, (UInt32)(num)); } + + +static unsigned ReadMatchDistances(CLzmaEnc *p, unsigned *numPairsRes) +{ + unsigned numPairs; + + p->additionalOffset++; + p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); + { + const UInt32 *d = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); + // if (!d) { p->mf_Failure = True; *numPairsRes = 0; return 0; } + numPairs = (unsigned)(d - p->matches); + } + *numPairsRes = numPairs; + + #ifdef SHOW_STAT + printf("\n i = %u numPairs = %u ", g_STAT_OFFSET, numPairs / 2); + g_STAT_OFFSET++; + { + unsigned i; + for (i = 0; i < numPairs; i += 2) + printf("%2u %6u | ", p->matches[i], p->matches[i + 1]); + } + #endif + + if (numPairs == 0) + return 0; + { + const unsigned len = p->matches[(size_t)numPairs - 2]; + if (len != p->numFastBytes) + return len; + { + UInt32 numAvail = p->numAvail; + if (numAvail > LZMA_MATCH_LEN_MAX) + numAvail = LZMA_MATCH_LEN_MAX; + { + const Byte *p1 = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + const Byte *p2 = p1 + len; + const ptrdiff_t dif = (ptrdiff_t)-1 - (ptrdiff_t)p->matches[(size_t)numPairs - 1]; + const Byte *lim = p1 + numAvail; + for (; p2 != lim && *p2 == p2[dif]; p2++) + {} + return (unsigned)(p2 - p1); + } + } + } +} + +#define MARK_LIT ((UInt32)(Int32)-1) + +#define MakeAs_Lit(p) { (p)->dist = MARK_LIT; (p)->extra = 0; } +#define MakeAs_ShortRep(p) { (p)->dist = 0; (p)->extra = 0; } +#define IsShortRep(p) ((p)->dist == 0) + + +#define GetPrice_ShortRep(p, state, posState) \ + ( GET_PRICE_0(p->isRepG0[state]) + GET_PRICE_0(p->isRep0Long[state][posState])) + +#define GetPrice_Rep_0(p, state, posState) ( \ + GET_PRICE_1(p->isMatch[state][posState]) \ + + GET_PRICE_1(p->isRep0Long[state][posState])) \ + + GET_PRICE_1(p->isRep[state]) \ + + GET_PRICE_0(p->isRepG0[state]) + +MY_FORCE_INLINE +static UInt32 GetPrice_PureRep(const CLzmaEnc *p, unsigned repIndex, size_t state, size_t posState) +{ + UInt32 price; + UInt32 prob = p->isRepG0[state]; + if (repIndex == 0) + { + price = GET_PRICE_0(prob); + price += GET_PRICE_1(p->isRep0Long[state][posState]); + } + else + { + price = GET_PRICE_1(prob); + prob = p->isRepG1[state]; + if (repIndex == 1) + price += GET_PRICE_0(prob); + else + { + price += GET_PRICE_1(prob); + price += GET_PRICE(p->isRepG2[state], repIndex - 2); + } + } + return price; +} + + +static unsigned Backward(CLzmaEnc *p, unsigned cur) +{ + unsigned wr = cur + 1; + p->optEnd = wr; + + for (;;) + { + UInt32 dist = p->opt[cur].dist; + unsigned len = (unsigned)p->opt[cur].len; + unsigned extra = (unsigned)p->opt[cur].extra; + cur -= len; + + if (extra) + { + wr--; + p->opt[wr].len = (UInt32)len; + cur -= extra; + len = extra; + if (extra == 1) + { + p->opt[wr].dist = dist; + dist = MARK_LIT; + } + else + { + p->opt[wr].dist = 0; + len--; + wr--; + p->opt[wr].dist = MARK_LIT; + p->opt[wr].len = 1; + } + } + + if (cur == 0) + { + p->backRes = dist; + p->optCur = wr; + return len; + } + + wr--; + p->opt[wr].dist = dist; + p->opt[wr].len = (UInt32)len; + } +} + + + +#define LIT_PROBS(pos, prevByte) \ + (p->litProbs + (UInt32)3 * (((((pos) << 8) + (prevByte)) & p->lpMask) << p->lc)) + + +static unsigned GetOptimum(CLzmaEnc *p, UInt32 position) +{ + unsigned last, cur; + UInt32 reps[LZMA_NUM_REPS]; + unsigned repLens[LZMA_NUM_REPS]; + UInt32 *matches; + + { + UInt32 numAvail; + unsigned numPairs, mainLen, repMaxIndex, i, posState; + UInt32 matchPrice, repMatchPrice; + const Byte *data; + Byte curByte, matchByte; + + p->optCur = p->optEnd = 0; + + if (p->additionalOffset == 0) + mainLen = ReadMatchDistances(p, &numPairs); + else + { + mainLen = p->longestMatchLen; + numPairs = p->numPairs; + } + + numAvail = p->numAvail; + if (numAvail < 2) + { + p->backRes = MARK_LIT; + return 1; + } + if (numAvail > LZMA_MATCH_LEN_MAX) + numAvail = LZMA_MATCH_LEN_MAX; + + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + repMaxIndex = 0; + + for (i = 0; i < LZMA_NUM_REPS; i++) + { + unsigned len; + const Byte *data2; + reps[i] = p->reps[i]; + data2 = data - reps[i]; + if (data[0] != data2[0] || data[1] != data2[1]) + { + repLens[i] = 0; + continue; + } + for (len = 2; len < numAvail && data[len] == data2[len]; len++) + {} + repLens[i] = len; + if (len > repLens[repMaxIndex]) + repMaxIndex = i; + if (len == LZMA_MATCH_LEN_MAX) // 21.03 : optimization + break; + } + + if (repLens[repMaxIndex] >= p->numFastBytes) + { + unsigned len; + p->backRes = (UInt32)repMaxIndex; + len = repLens[repMaxIndex]; + MOVE_POS(p, len - 1) + return len; + } + + matches = p->matches; + #define MATCHES matches + // #define MATCHES p->matches + + if (mainLen >= p->numFastBytes) + { + p->backRes = MATCHES[(size_t)numPairs - 1] + LZMA_NUM_REPS; + MOVE_POS(p, mainLen - 1) + return mainLen; + } + + curByte = *data; + matchByte = *(data - reps[0]); + + last = repLens[repMaxIndex]; + if (last <= mainLen) + last = mainLen; + + if (last < 2 && curByte != matchByte) + { + p->backRes = MARK_LIT; + return 1; + } + + p->opt[0].state = (CState)p->state; + + posState = (position & p->pbMask); + + { + const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); + p->opt[1].price = GET_PRICE_0(p->isMatch[p->state][posState]) + + (!IsLitState(p->state) ? + LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) : + LitEnc_GetPrice(probs, curByte, p->ProbPrices)); + } + + MakeAs_Lit(&p->opt[1]); + + matchPrice = GET_PRICE_1(p->isMatch[p->state][posState]); + repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[p->state]); + + // 18.06 + if (matchByte == curByte && repLens[0] == 0) + { + UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, p->state, posState); + if (shortRepPrice < p->opt[1].price) + { + p->opt[1].price = shortRepPrice; + MakeAs_ShortRep(&p->opt[1]); + } + if (last < 2) + { + p->backRes = p->opt[1].dist; + return 1; + } + } + + p->opt[1].len = 1; + + p->opt[0].reps[0] = reps[0]; + p->opt[0].reps[1] = reps[1]; + p->opt[0].reps[2] = reps[2]; + p->opt[0].reps[3] = reps[3]; + + // ---------- REP ---------- + + for (i = 0; i < LZMA_NUM_REPS; i++) + { + unsigned repLen = repLens[i]; + UInt32 price; + if (repLen < 2) + continue; + price = repMatchPrice + GetPrice_PureRep(p, i, p->state, posState); + do + { + UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, repLen); + COptimal *opt = &p->opt[repLen]; + if (price2 < opt->price) + { + opt->price = price2; + opt->len = (UInt32)repLen; + opt->dist = (UInt32)i; + opt->extra = 0; + } + } + while (--repLen >= 2); + } + + + // ---------- MATCH ---------- + { + unsigned len = repLens[0] + 1; + if (len <= mainLen) + { + unsigned offs = 0; + UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[p->state]); + + if (len < 2) + len = 2; + else + while (len > MATCHES[offs]) + offs += 2; + + for (; ; len++) + { + COptimal *opt; + UInt32 dist = MATCHES[(size_t)offs + 1]; + UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); + unsigned lenToPosState = GetLenToPosState(len); + + if (dist < kNumFullDistances) + price += p->distancesPrices[lenToPosState][dist & (kNumFullDistances - 1)]; + else + { + unsigned slot; + GetPosSlot2(dist, slot); + price += p->alignPrices[dist & kAlignMask]; + price += p->posSlotPrices[lenToPosState][slot]; + } + + opt = &p->opt[len]; + + if (price < opt->price) + { + opt->price = price; + opt->len = (UInt32)len; + opt->dist = dist + LZMA_NUM_REPS; + opt->extra = 0; + } + + if (len == MATCHES[offs]) + { + offs += 2; + if (offs == numPairs) + break; + } + } + } + } + + + cur = 0; + + #ifdef SHOW_STAT2 + /* if (position >= 0) */ + { + unsigned i; + printf("\n pos = %4X", position); + for (i = cur; i <= last; i++) + printf("\nprice[%4X] = %u", position - cur + i, p->opt[i].price); + } + #endif + } + + + + // ---------- Optimal Parsing ---------- + + for (;;) + { + unsigned numAvail; + UInt32 numAvailFull; + unsigned newLen, numPairs, prev, state, posState, startLen; + UInt32 litPrice, matchPrice, repMatchPrice; + BoolInt nextIsLit; + Byte curByte, matchByte; + const Byte *data; + COptimal *curOpt, *nextOpt; + + if (++cur == last) + break; + + // 18.06 + if (cur >= kNumOpts - 64) + { + unsigned j, best; + UInt32 price = p->opt[cur].price; + best = cur; + for (j = cur + 1; j <= last; j++) + { + UInt32 price2 = p->opt[j].price; + if (price >= price2) + { + price = price2; + best = j; + } + } + { + unsigned delta = best - cur; + if (delta != 0) + { + MOVE_POS(p, delta); + } + } + cur = best; + break; + } + + newLen = ReadMatchDistances(p, &numPairs); + + if (newLen >= p->numFastBytes) + { + p->numPairs = numPairs; + p->longestMatchLen = newLen; + break; + } + + curOpt = &p->opt[cur]; + + position++; + + // we need that check here, if skip_items in p->opt are possible + /* + if (curOpt->price >= kInfinityPrice) + continue; + */ + + prev = cur - curOpt->len; + + if (curOpt->len == 1) + { + state = (unsigned)p->opt[prev].state; + if (IsShortRep(curOpt)) + state = kShortRepNextStates[state]; + else + state = kLiteralNextStates[state]; + } + else + { + const COptimal *prevOpt; + UInt32 b0; + UInt32 dist = curOpt->dist; + + if (curOpt->extra) + { + prev -= (unsigned)curOpt->extra; + state = kState_RepAfterLit; + if (curOpt->extra == 1) + state = (dist < LZMA_NUM_REPS ? kState_RepAfterLit : kState_MatchAfterLit); + } + else + { + state = (unsigned)p->opt[prev].state; + if (dist < LZMA_NUM_REPS) + state = kRepNextStates[state]; + else + state = kMatchNextStates[state]; + } + + prevOpt = &p->opt[prev]; + b0 = prevOpt->reps[0]; + + if (dist < LZMA_NUM_REPS) + { + if (dist == 0) + { + reps[0] = b0; + reps[1] = prevOpt->reps[1]; + reps[2] = prevOpt->reps[2]; + reps[3] = prevOpt->reps[3]; + } + else + { + reps[1] = b0; + b0 = prevOpt->reps[1]; + if (dist == 1) + { + reps[0] = b0; + reps[2] = prevOpt->reps[2]; + reps[3] = prevOpt->reps[3]; + } + else + { + reps[2] = b0; + reps[0] = prevOpt->reps[dist]; + reps[3] = prevOpt->reps[dist ^ 1]; + } + } + } + else + { + reps[0] = (dist - LZMA_NUM_REPS + 1); + reps[1] = b0; + reps[2] = prevOpt->reps[1]; + reps[3] = prevOpt->reps[2]; + } + } + + curOpt->state = (CState)state; + curOpt->reps[0] = reps[0]; + curOpt->reps[1] = reps[1]; + curOpt->reps[2] = reps[2]; + curOpt->reps[3] = reps[3]; + + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + curByte = *data; + matchByte = *(data - reps[0]); + + posState = (position & p->pbMask); + + /* + The order of Price checks: + < LIT + <= SHORT_REP + < LIT : REP_0 + < REP [ : LIT : REP_0 ] + < MATCH [ : LIT : REP_0 ] + */ + + { + UInt32 curPrice = curOpt->price; + unsigned prob = p->isMatch[state][posState]; + matchPrice = curPrice + GET_PRICE_1(prob); + litPrice = curPrice + GET_PRICE_0(prob); + } + + nextOpt = &p->opt[(size_t)cur + 1]; + nextIsLit = False; + + // here we can allow skip_items in p->opt, if we don't check (nextOpt->price < kInfinityPrice) + // 18.new.06 + if ((nextOpt->price < kInfinityPrice + // && !IsLitState(state) + && matchByte == curByte) + || litPrice > nextOpt->price + ) + litPrice = 0; + else + { + const CLzmaProb *probs = LIT_PROBS(position, *(data - 1)); + litPrice += (!IsLitState(state) ? + LitEnc_Matched_GetPrice(probs, curByte, matchByte, p->ProbPrices) : + LitEnc_GetPrice(probs, curByte, p->ProbPrices)); + + if (litPrice < nextOpt->price) + { + nextOpt->price = litPrice; + nextOpt->len = 1; + MakeAs_Lit(nextOpt); + nextIsLit = True; + } + } + + repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); + + numAvailFull = p->numAvail; + { + unsigned temp = kNumOpts - 1 - cur; + if (numAvailFull > temp) + numAvailFull = (UInt32)temp; + } + + // 18.06 + // ---------- SHORT_REP ---------- + if (IsLitState(state)) // 18.new + if (matchByte == curByte) + if (repMatchPrice < nextOpt->price) // 18.new + // if (numAvailFull < 2 || data[1] != *(data - reps[0] + 1)) + if ( + // nextOpt->price >= kInfinityPrice || + nextOpt->len < 2 // we can check nextOpt->len, if skip items are not allowed in p->opt + || (nextOpt->dist != 0 + // && nextOpt->extra <= 1 // 17.old + ) + ) + { + UInt32 shortRepPrice = repMatchPrice + GetPrice_ShortRep(p, state, posState); + // if (shortRepPrice <= nextOpt->price) // 17.old + if (shortRepPrice < nextOpt->price) // 18.new + { + nextOpt->price = shortRepPrice; + nextOpt->len = 1; + MakeAs_ShortRep(nextOpt); + nextIsLit = False; + } + } + + if (numAvailFull < 2) + continue; + numAvail = (numAvailFull <= p->numFastBytes ? numAvailFull : p->numFastBytes); + + // numAvail <= p->numFastBytes + + // ---------- LIT : REP_0 ---------- + + if (!nextIsLit + && litPrice != 0 // 18.new + && matchByte != curByte + && numAvailFull > 2) + { + const Byte *data2 = data - reps[0]; + if (data[1] == data2[1] && data[2] == data2[2]) + { + unsigned len; + unsigned limit = p->numFastBytes + 1; + if (limit > numAvailFull) + limit = numAvailFull; + for (len = 3; len < limit && data[len] == data2[len]; len++) + {} + + { + unsigned state2 = kLiteralNextStates[state]; + unsigned posState2 = (position + 1) & p->pbMask; + UInt32 price = litPrice + GetPrice_Rep_0(p, state2, posState2); + { + unsigned offset = cur + len; + + if (last < offset) + last = offset; + + // do + { + UInt32 price2; + COptimal *opt; + len--; + // price2 = price + GetPrice_Len_Rep_0(p, len, state2, posState2); + price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len); + + opt = &p->opt[offset]; + // offset--; + if (price2 < opt->price) + { + opt->price = price2; + opt->len = (UInt32)len; + opt->dist = 0; + opt->extra = 1; + } + } + // while (len >= 3); + } + } + } + } + + startLen = 2; /* speed optimization */ + + { + // ---------- REP ---------- + unsigned repIndex = 0; // 17.old + // unsigned repIndex = IsLitState(state) ? 0 : 1; // 18.notused + for (; repIndex < LZMA_NUM_REPS; repIndex++) + { + unsigned len; + UInt32 price; + const Byte *data2 = data - reps[repIndex]; + if (data[0] != data2[0] || data[1] != data2[1]) + continue; + + for (len = 2; len < numAvail && data[len] == data2[len]; len++) + {} + + // if (len < startLen) continue; // 18.new: speed optimization + + { + unsigned offset = cur + len; + if (last < offset) + last = offset; + } + { + unsigned len2 = len; + price = repMatchPrice + GetPrice_PureRep(p, repIndex, state, posState); + do + { + UInt32 price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState, len2); + COptimal *opt = &p->opt[cur + len2]; + if (price2 < opt->price) + { + opt->price = price2; + opt->len = (UInt32)len2; + opt->dist = (UInt32)repIndex; + opt->extra = 0; + } + } + while (--len2 >= 2); + } + + if (repIndex == 0) startLen = len + 1; // 17.old + // startLen = len + 1; // 18.new + + /* if (_maxMode) */ + { + // ---------- REP : LIT : REP_0 ---------- + // numFastBytes + 1 + numFastBytes + + unsigned len2 = len + 1; + unsigned limit = len2 + p->numFastBytes; + if (limit > numAvailFull) + limit = numAvailFull; + + len2 += 2; + if (len2 <= limit) + if (data[len2 - 2] == data2[len2 - 2]) + if (data[len2 - 1] == data2[len2 - 1]) + { + unsigned state2 = kRepNextStates[state]; + unsigned posState2 = (position + len) & p->pbMask; + price += GET_PRICE_LEN(&p->repLenEnc, posState, len) + + GET_PRICE_0(p->isMatch[state2][posState2]) + + LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]), + data[len], data2[len], p->ProbPrices); + + // state2 = kLiteralNextStates[state2]; + state2 = kState_LitAfterRep; + posState2 = (posState2 + 1) & p->pbMask; + + + price += GetPrice_Rep_0(p, state2, posState2); + + for (; len2 < limit && data[len2] == data2[len2]; len2++) + {} + + len2 -= len; + // if (len2 >= 3) + { + { + unsigned offset = cur + len + len2; + + if (last < offset) + last = offset; + // do + { + UInt32 price2; + COptimal *opt; + len2--; + // price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); + price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2); + + opt = &p->opt[offset]; + // offset--; + if (price2 < opt->price) + { + opt->price = price2; + opt->len = (UInt32)len2; + opt->extra = (CExtra)(len + 1); + opt->dist = (UInt32)repIndex; + } + } + // while (len2 >= 3); + } + } + } + } + } + } + + + // ---------- MATCH ---------- + /* for (unsigned len = 2; len <= newLen; len++) */ + if (newLen > numAvail) + { + newLen = numAvail; + for (numPairs = 0; newLen > MATCHES[numPairs]; numPairs += 2); + MATCHES[numPairs] = (UInt32)newLen; + numPairs += 2; + } + + // startLen = 2; /* speed optimization */ + + if (newLen >= startLen) + { + UInt32 normalMatchPrice = matchPrice + GET_PRICE_0(p->isRep[state]); + UInt32 dist; + unsigned offs, posSlot, len; + + { + unsigned offset = cur + newLen; + if (last < offset) + last = offset; + } + + offs = 0; + while (startLen > MATCHES[offs]) + offs += 2; + dist = MATCHES[(size_t)offs + 1]; + + // if (dist >= kNumFullDistances) + GetPosSlot2(dist, posSlot); + + for (len = /*2*/ startLen; ; len++) + { + UInt32 price = normalMatchPrice + GET_PRICE_LEN(&p->lenEnc, posState, len); + { + COptimal *opt; + unsigned lenNorm = len - 2; + lenNorm = GetLenToPosState2(lenNorm); + if (dist < kNumFullDistances) + price += p->distancesPrices[lenNorm][dist & (kNumFullDistances - 1)]; + else + price += p->posSlotPrices[lenNorm][posSlot] + p->alignPrices[dist & kAlignMask]; + + opt = &p->opt[cur + len]; + if (price < opt->price) + { + opt->price = price; + opt->len = (UInt32)len; + opt->dist = dist + LZMA_NUM_REPS; + opt->extra = 0; + } + } + + if (len == MATCHES[offs]) + { + // if (p->_maxMode) { + // MATCH : LIT : REP_0 + + const Byte *data2 = data - dist - 1; + unsigned len2 = len + 1; + unsigned limit = len2 + p->numFastBytes; + if (limit > numAvailFull) + limit = numAvailFull; + + len2 += 2; + if (len2 <= limit) + if (data[len2 - 2] == data2[len2 - 2]) + if (data[len2 - 1] == data2[len2 - 1]) + { + for (; len2 < limit && data[len2] == data2[len2]; len2++) + {} + + len2 -= len; + + // if (len2 >= 3) + { + unsigned state2 = kMatchNextStates[state]; + unsigned posState2 = (position + len) & p->pbMask; + unsigned offset; + price += GET_PRICE_0(p->isMatch[state2][posState2]); + price += LitEnc_Matched_GetPrice(LIT_PROBS(position + len, data[(size_t)len - 1]), + data[len], data2[len], p->ProbPrices); + + // state2 = kLiteralNextStates[state2]; + state2 = kState_LitAfterMatch; + + posState2 = (posState2 + 1) & p->pbMask; + price += GetPrice_Rep_0(p, state2, posState2); + + offset = cur + len + len2; + + if (last < offset) + last = offset; + // do + { + UInt32 price2; + COptimal *opt; + len2--; + // price2 = price + GetPrice_Len_Rep_0(p, len2, state2, posState2); + price2 = price + GET_PRICE_LEN(&p->repLenEnc, posState2, len2); + opt = &p->opt[offset]; + // offset--; + if (price2 < opt->price) + { + opt->price = price2; + opt->len = (UInt32)len2; + opt->extra = (CExtra)(len + 1); + opt->dist = dist + LZMA_NUM_REPS; + } + } + // while (len2 >= 3); + } + + } + + offs += 2; + if (offs == numPairs) + break; + dist = MATCHES[(size_t)offs + 1]; + // if (dist >= kNumFullDistances) + GetPosSlot2(dist, posSlot); + } + } + } + } + + do + p->opt[last].price = kInfinityPrice; + while (--last); + + return Backward(p, cur); +} + + + +#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist)) + + + +static unsigned GetOptimumFast(CLzmaEnc *p) +{ + UInt32 numAvail, mainDist; + unsigned mainLen, numPairs, repIndex, repLen, i; + const Byte *data; + + if (p->additionalOffset == 0) + mainLen = ReadMatchDistances(p, &numPairs); + else + { + mainLen = p->longestMatchLen; + numPairs = p->numPairs; + } + + numAvail = p->numAvail; + p->backRes = MARK_LIT; + if (numAvail < 2) + return 1; + // if (mainLen < 2 && p->state == 0) return 1; // 18.06.notused + if (numAvail > LZMA_MATCH_LEN_MAX) + numAvail = LZMA_MATCH_LEN_MAX; + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + repLen = repIndex = 0; + + for (i = 0; i < LZMA_NUM_REPS; i++) + { + unsigned len; + const Byte *data2 = data - p->reps[i]; + if (data[0] != data2[0] || data[1] != data2[1]) + continue; + for (len = 2; len < numAvail && data[len] == data2[len]; len++) + {} + if (len >= p->numFastBytes) + { + p->backRes = (UInt32)i; + MOVE_POS(p, len - 1) + return len; + } + if (len > repLen) + { + repIndex = i; + repLen = len; + } + } + + if (mainLen >= p->numFastBytes) + { + p->backRes = p->matches[(size_t)numPairs - 1] + LZMA_NUM_REPS; + MOVE_POS(p, mainLen - 1) + return mainLen; + } + + mainDist = 0; /* for GCC */ + + if (mainLen >= 2) + { + mainDist = p->matches[(size_t)numPairs - 1]; + while (numPairs > 2) + { + UInt32 dist2; + if (mainLen != p->matches[(size_t)numPairs - 4] + 1) + break; + dist2 = p->matches[(size_t)numPairs - 3]; + if (!ChangePair(dist2, mainDist)) + break; + numPairs -= 2; + mainLen--; + mainDist = dist2; + } + if (mainLen == 2 && mainDist >= 0x80) + mainLen = 1; + } + + if (repLen >= 2) + if ( repLen + 1 >= mainLen + || (repLen + 2 >= mainLen && mainDist >= (1 << 9)) + || (repLen + 3 >= mainLen && mainDist >= (1 << 15))) + { + p->backRes = (UInt32)repIndex; + MOVE_POS(p, repLen - 1) + return repLen; + } + + if (mainLen < 2 || numAvail <= 2) + return 1; + + { + unsigned len1 = ReadMatchDistances(p, &p->numPairs); + p->longestMatchLen = len1; + + if (len1 >= 2) + { + UInt32 newDist = p->matches[(size_t)p->numPairs - 1]; + if ( (len1 >= mainLen && newDist < mainDist) + || (len1 == mainLen + 1 && !ChangePair(mainDist, newDist)) + || (len1 > mainLen + 1) + || (len1 + 1 >= mainLen && mainLen >= 3 && ChangePair(newDist, mainDist))) + return 1; + } + } + + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; + + for (i = 0; i < LZMA_NUM_REPS; i++) + { + unsigned len, limit; + const Byte *data2 = data - p->reps[i]; + if (data[0] != data2[0] || data[1] != data2[1]) + continue; + limit = mainLen - 1; + for (len = 2;; len++) + { + if (len >= limit) + return 1; + if (data[len] != data2[len]) + break; + } + } + + p->backRes = mainDist + LZMA_NUM_REPS; + if (mainLen != 2) + { + MOVE_POS(p, mainLen - 2) + } + return mainLen; +} + + + + +static void WriteEndMarker(CLzmaEnc *p, unsigned posState) +{ + UInt32 range; + range = p->rc.range; + { + UInt32 ttt, newBound; + CLzmaProb *prob = &p->isMatch[p->state][posState]; + RC_BIT_PRE(&p->rc, prob) + RC_BIT_1(&p->rc, prob) + prob = &p->isRep[p->state]; + RC_BIT_PRE(&p->rc, prob) + RC_BIT_0(&p->rc, prob) + } + p->state = kMatchNextStates[p->state]; + + p->rc.range = range; + LenEnc_Encode(&p->lenProbs, &p->rc, 0, posState); + range = p->rc.range; + + { + // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[0], (1 << kNumPosSlotBits) - 1); + CLzmaProb *probs = p->posSlotEncoder[0]; + unsigned m = 1; + do + { + UInt32 ttt, newBound; + RC_BIT_PRE(p, probs + m) + RC_BIT_1(&p->rc, probs + m); + m = (m << 1) + 1; + } + while (m < (1 << kNumPosSlotBits)); + } + { + // RangeEnc_EncodeDirectBits(&p->rc, ((UInt32)1 << (30 - kNumAlignBits)) - 1, 30 - kNumAlignBits); UInt32 range = p->range; + unsigned numBits = 30 - kNumAlignBits; + do + { + range >>= 1; + p->rc.low += range; + RC_NORM(&p->rc) + } + while (--numBits); + } + + { + // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask); + CLzmaProb *probs = p->posAlignEncoder; + unsigned m = 1; + do + { + UInt32 ttt, newBound; + RC_BIT_PRE(p, probs + m) + RC_BIT_1(&p->rc, probs + m); + m = (m << 1) + 1; + } + while (m < kAlignTableSize); + } + p->rc.range = range; +} + + +static SRes CheckErrors(CLzmaEnc *p) +{ + if (p->result != SZ_OK) + return p->result; + if (p->rc.res != SZ_OK) + p->result = SZ_ERROR_WRITE; + + #ifndef _7ZIP_ST + if ( + // p->mf_Failure || + (p->mtMode && + ( // p->matchFinderMt.failure_LZ_LZ || + p->matchFinderMt.failure_LZ_BT)) + ) + { + p->result = MY_HRES_ERROR__INTERNAL_ERROR; + // printf("\nCheckErrors p->matchFinderMt.failureLZ\n"); + } + #endif + + if (MFB.result != SZ_OK) + p->result = SZ_ERROR_READ; + + if (p->result != SZ_OK) + p->finished = True; + return p->result; +} + + +MY_NO_INLINE static SRes Flush(CLzmaEnc *p, UInt32 nowPos) +{ + /* ReleaseMFStream(); */ + p->finished = True; + if (p->writeEndMark) + WriteEndMarker(p, nowPos & p->pbMask); + RangeEnc_FlushData(&p->rc); + RangeEnc_FlushStream(&p->rc); + return CheckErrors(p); +} + + +MY_NO_INLINE static void FillAlignPrices(CLzmaEnc *p) +{ + unsigned i; + const CProbPrice *ProbPrices = p->ProbPrices; + const CLzmaProb *probs = p->posAlignEncoder; + // p->alignPriceCount = 0; + for (i = 0; i < kAlignTableSize / 2; i++) + { + UInt32 price = 0; + unsigned sym = i; + unsigned m = 1; + unsigned bit; + UInt32 prob; + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[m], bit); m = (m << 1) + bit; + prob = probs[m]; + p->alignPrices[i ] = price + GET_PRICEa_0(prob); + p->alignPrices[i + 8] = price + GET_PRICEa_1(prob); + // p->alignPrices[i] = RcTree_ReverseGetPrice(p->posAlignEncoder, kNumAlignBits, i, p->ProbPrices); + } +} + + +MY_NO_INLINE static void FillDistancesPrices(CLzmaEnc *p) +{ + // int y; for (y = 0; y < 100; y++) { + + UInt32 tempPrices[kNumFullDistances]; + unsigned i, lps; + + const CProbPrice *ProbPrices = p->ProbPrices; + p->matchPriceCount = 0; + + for (i = kStartPosModelIndex / 2; i < kNumFullDistances / 2; i++) + { + unsigned posSlot = GetPosSlot1(i); + unsigned footerBits = (posSlot >> 1) - 1; + unsigned base = ((2 | (posSlot & 1)) << footerBits); + const CLzmaProb *probs = p->posEncoders + (size_t)base * 2; + // tempPrices[i] = RcTree_ReverseGetPrice(p->posEncoders + base, footerBits, i - base, p->ProbPrices); + UInt32 price = 0; + unsigned m = 1; + unsigned sym = i; + unsigned offset = (unsigned)1 << footerBits; + base += i; + + if (footerBits) + do + { + unsigned bit = sym & 1; + sym >>= 1; + price += GET_PRICEa(probs[m], bit); + m = (m << 1) + bit; + } + while (--footerBits); + + { + unsigned prob = probs[m]; + tempPrices[base ] = price + GET_PRICEa_0(prob); + tempPrices[base + offset] = price + GET_PRICEa_1(prob); + } + } + + for (lps = 0; lps < kNumLenToPosStates; lps++) + { + unsigned slot; + unsigned distTableSize2 = (p->distTableSize + 1) >> 1; + UInt32 *posSlotPrices = p->posSlotPrices[lps]; + const CLzmaProb *probs = p->posSlotEncoder[lps]; + + for (slot = 0; slot < distTableSize2; slot++) + { + // posSlotPrices[slot] = RcTree_GetPrice(encoder, kNumPosSlotBits, slot, p->ProbPrices); + UInt32 price; + unsigned bit; + unsigned sym = slot + (1 << (kNumPosSlotBits - 1)); + unsigned prob; + bit = sym & 1; sym >>= 1; price = GET_PRICEa(probs[sym], bit); + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); + bit = sym & 1; sym >>= 1; price += GET_PRICEa(probs[sym], bit); + prob = probs[(size_t)slot + (1 << (kNumPosSlotBits - 1))]; + posSlotPrices[(size_t)slot * 2 ] = price + GET_PRICEa_0(prob); + posSlotPrices[(size_t)slot * 2 + 1] = price + GET_PRICEa_1(prob); + } + + { + UInt32 delta = ((UInt32)((kEndPosModelIndex / 2 - 1) - kNumAlignBits) << kNumBitPriceShiftBits); + for (slot = kEndPosModelIndex / 2; slot < distTableSize2; slot++) + { + posSlotPrices[(size_t)slot * 2 ] += delta; + posSlotPrices[(size_t)slot * 2 + 1] += delta; + delta += ((UInt32)1 << kNumBitPriceShiftBits); + } + } + + { + UInt32 *dp = p->distancesPrices[lps]; + + dp[0] = posSlotPrices[0]; + dp[1] = posSlotPrices[1]; + dp[2] = posSlotPrices[2]; + dp[3] = posSlotPrices[3]; + + for (i = 4; i < kNumFullDistances; i += 2) + { + UInt32 slotPrice = posSlotPrices[GetPosSlot1(i)]; + dp[i ] = slotPrice + tempPrices[i]; + dp[i + 1] = slotPrice + tempPrices[i + 1]; + } + } + } + // } +} + + + +static void LzmaEnc_Construct(CLzmaEnc *p) +{ + RangeEnc_Construct(&p->rc); + MatchFinder_Construct(&MFB); + + #ifndef _7ZIP_ST + p->matchFinderMt.MatchFinder = &MFB; + MatchFinderMt_Construct(&p->matchFinderMt); + #endif + + { + CLzmaEncProps props; + LzmaEncProps_Init(&props); + LzmaEnc_SetProps(p, &props); + } + + #ifndef LZMA_LOG_BSR + LzmaEnc_FastPosInit(p->g_FastPos); + #endif + + LzmaEnc_InitPriceTables(p->ProbPrices); + p->litProbs = NULL; + p->saveState.litProbs = NULL; +} + +CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc) +{ + void *p; + p = ISzAlloc_Alloc(alloc, sizeof(CLzmaEnc)); + if (p) + LzmaEnc_Construct((CLzmaEnc *)p); + return p; +} + +static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->litProbs); + ISzAlloc_Free(alloc, p->saveState.litProbs); + p->litProbs = NULL; + p->saveState.litProbs = NULL; +} + +static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + #ifndef _7ZIP_ST + MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); + #endif + + MatchFinder_Free(&MFB, allocBig); + LzmaEnc_FreeLits(p, alloc); + RangeEnc_Free(&p->rc, alloc); +} + +void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig); + ISzAlloc_Free(alloc, p); +} + + +MY_NO_INLINE +static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, UInt32 maxPackSize, UInt32 maxUnpackSize) +{ + UInt32 nowPos32, startPos32; + if (p->needInit) + { + #ifndef _7ZIP_ST + if (p->mtMode) + { + RINOK(MatchFinderMt_InitMt(&p->matchFinderMt)); + } + #endif + p->matchFinder.Init(p->matchFinderObj); + p->needInit = 0; + } + + if (p->finished) + return p->result; + RINOK(CheckErrors(p)); + + nowPos32 = (UInt32)p->nowPos64; + startPos32 = nowPos32; + + if (p->nowPos64 == 0) + { + unsigned numPairs; + Byte curByte; + if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) + return Flush(p, nowPos32); + ReadMatchDistances(p, &numPairs); + RangeEnc_EncodeBit_0(&p->rc, &p->isMatch[kState_Start][0]); + // p->state = kLiteralNextStates[p->state]; + curByte = *(p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset); + LitEnc_Encode(&p->rc, p->litProbs, curByte); + p->additionalOffset--; + nowPos32++; + } + + if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) != 0) + + for (;;) + { + UInt32 dist; + unsigned len, posState; + UInt32 range, ttt, newBound; + CLzmaProb *probs; + + if (p->fastMode) + len = GetOptimumFast(p); + else + { + unsigned oci = p->optCur; + if (p->optEnd == oci) + len = GetOptimum(p, nowPos32); + else + { + const COptimal *opt = &p->opt[oci]; + len = opt->len; + p->backRes = opt->dist; + p->optCur = oci + 1; + } + } + + posState = (unsigned)nowPos32 & p->pbMask; + range = p->rc.range; + probs = &p->isMatch[p->state][posState]; + + RC_BIT_PRE(&p->rc, probs) + + dist = p->backRes; + + #ifdef SHOW_STAT2 + printf("\n pos = %6X, len = %3u pos = %6u", nowPos32, len, dist); + #endif + + if (dist == MARK_LIT) + { + Byte curByte; + const Byte *data; + unsigned state; + + RC_BIT_0(&p->rc, probs); + p->rc.range = range; + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; + probs = LIT_PROBS(nowPos32, *(data - 1)); + curByte = *data; + state = p->state; + p->state = kLiteralNextStates[state]; + if (IsLitState(state)) + LitEnc_Encode(&p->rc, probs, curByte); + else + LitEnc_EncodeMatched(&p->rc, probs, curByte, *(data - p->reps[0])); + } + else + { + RC_BIT_1(&p->rc, probs); + probs = &p->isRep[p->state]; + RC_BIT_PRE(&p->rc, probs) + + if (dist < LZMA_NUM_REPS) + { + RC_BIT_1(&p->rc, probs); + probs = &p->isRepG0[p->state]; + RC_BIT_PRE(&p->rc, probs) + if (dist == 0) + { + RC_BIT_0(&p->rc, probs); + probs = &p->isRep0Long[p->state][posState]; + RC_BIT_PRE(&p->rc, probs) + if (len != 1) + { + RC_BIT_1_BASE(&p->rc, probs); + } + else + { + RC_BIT_0_BASE(&p->rc, probs); + p->state = kShortRepNextStates[p->state]; + } + } + else + { + RC_BIT_1(&p->rc, probs); + probs = &p->isRepG1[p->state]; + RC_BIT_PRE(&p->rc, probs) + if (dist == 1) + { + RC_BIT_0_BASE(&p->rc, probs); + dist = p->reps[1]; + } + else + { + RC_BIT_1(&p->rc, probs); + probs = &p->isRepG2[p->state]; + RC_BIT_PRE(&p->rc, probs) + if (dist == 2) + { + RC_BIT_0_BASE(&p->rc, probs); + dist = p->reps[2]; + } + else + { + RC_BIT_1_BASE(&p->rc, probs); + dist = p->reps[3]; + p->reps[3] = p->reps[2]; + } + p->reps[2] = p->reps[1]; + } + p->reps[1] = p->reps[0]; + p->reps[0] = dist; + } + + RC_NORM(&p->rc) + + p->rc.range = range; + + if (len != 1) + { + LenEnc_Encode(&p->repLenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState); + --p->repLenEncCounter; + p->state = kRepNextStates[p->state]; + } + } + else + { + unsigned posSlot; + RC_BIT_0(&p->rc, probs); + p->rc.range = range; + p->state = kMatchNextStates[p->state]; + + LenEnc_Encode(&p->lenProbs, &p->rc, len - LZMA_MATCH_LEN_MIN, posState); + // --p->lenEnc.counter; + + dist -= LZMA_NUM_REPS; + p->reps[3] = p->reps[2]; + p->reps[2] = p->reps[1]; + p->reps[1] = p->reps[0]; + p->reps[0] = dist + 1; + + p->matchPriceCount++; + GetPosSlot(dist, posSlot); + // RcTree_Encode_PosSlot(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], posSlot); + { + UInt32 sym = (UInt32)posSlot + (1 << kNumPosSlotBits); + range = p->rc.range; + probs = p->posSlotEncoder[GetLenToPosState(len)]; + do + { + CLzmaProb *prob = probs + (sym >> kNumPosSlotBits); + UInt32 bit = (sym >> (kNumPosSlotBits - 1)) & 1; + sym <<= 1; + RC_BIT(&p->rc, prob, bit); + } + while (sym < (1 << kNumPosSlotBits * 2)); + p->rc.range = range; + } + + if (dist >= kStartPosModelIndex) + { + unsigned footerBits = ((posSlot >> 1) - 1); + + if (dist < kNumFullDistances) + { + unsigned base = ((2 | (posSlot & 1)) << footerBits); + RcTree_ReverseEncode(&p->rc, p->posEncoders + base, footerBits, (unsigned)(dist /* - base */)); + } + else + { + UInt32 pos2 = (dist | 0xF) << (32 - footerBits); + range = p->rc.range; + // RangeEnc_EncodeDirectBits(&p->rc, posReduced >> kNumAlignBits, footerBits - kNumAlignBits); + /* + do + { + range >>= 1; + p->rc.low += range & (0 - ((dist >> --footerBits) & 1)); + RC_NORM(&p->rc) + } + while (footerBits > kNumAlignBits); + */ + do + { + range >>= 1; + p->rc.low += range & (0 - (pos2 >> 31)); + pos2 += pos2; + RC_NORM(&p->rc) + } + while (pos2 != 0xF0000000); + + + // RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, posReduced & kAlignMask); + + { + unsigned m = 1; + unsigned bit; + bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit; + bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit; + bit = dist & 1; dist >>= 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); m = (m << 1) + bit; + bit = dist & 1; RC_BIT(&p->rc, p->posAlignEncoder + m, bit); + p->rc.range = range; + // p->alignPriceCount++; + } + } + } + } + } + + nowPos32 += (UInt32)len; + p->additionalOffset -= len; + + if (p->additionalOffset == 0) + { + UInt32 processed; + + if (!p->fastMode) + { + /* + if (p->alignPriceCount >= 16) // kAlignTableSize + FillAlignPrices(p); + if (p->matchPriceCount >= 128) + FillDistancesPrices(p); + if (p->lenEnc.counter <= 0) + LenPriceEnc_UpdateTables(&p->lenEnc, 1 << p->pb, &p->lenProbs, p->ProbPrices); + */ + if (p->matchPriceCount >= 64) + { + FillAlignPrices(p); + // { int y; for (y = 0; y < 100; y++) { + FillDistancesPrices(p); + // }} + LenPriceEnc_UpdateTables(&p->lenEnc, (unsigned)1 << p->pb, &p->lenProbs, p->ProbPrices); + } + if (p->repLenEncCounter <= 0) + { + p->repLenEncCounter = REP_LEN_COUNT; + LenPriceEnc_UpdateTables(&p->repLenEnc, (unsigned)1 << p->pb, &p->repLenProbs, p->ProbPrices); + } + } + + if (p->matchFinder.GetNumAvailableBytes(p->matchFinderObj) == 0) + break; + processed = nowPos32 - startPos32; + + if (maxPackSize) + { + if (processed + kNumOpts + 300 >= maxUnpackSize + || RangeEnc_GetProcessed_sizet(&p->rc) + kPackReserve >= maxPackSize) + break; + } + else if (processed >= (1 << 17)) + { + p->nowPos64 += nowPos32 - startPos32; + return CheckErrors(p); + } + } + } + + p->nowPos64 += nowPos32 - startPos32; + return Flush(p, nowPos32); +} + + + +#define kBigHashDicLimit ((UInt32)1 << 24) + +static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + UInt32 beforeSize = kNumOpts; + UInt32 dictSize; + + if (!RangeEnc_Alloc(&p->rc, alloc)) + return SZ_ERROR_MEM; + + #ifndef _7ZIP_ST + p->mtMode = (p->multiThread && !p->fastMode && (MFB.btMode != 0)); + #endif + + { + unsigned lclp = p->lc + p->lp; + if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp) + { + LzmaEnc_FreeLits(p, alloc); + p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); + p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb)); + if (!p->litProbs || !p->saveState.litProbs) + { + LzmaEnc_FreeLits(p, alloc); + return SZ_ERROR_MEM; + } + p->lclp = lclp; + } + } + + MFB.bigHash = (Byte)(p->dictSize > kBigHashDicLimit ? 1 : 0); + + + dictSize = p->dictSize; + if (dictSize == ((UInt32)2 << 30) || + dictSize == ((UInt32)3 << 30)) + { + /* 21.03 : here we reduce the dictionary for 2 reasons: + 1) we don't want 32-bit back_distance matches in decoder for 2 GB dictionary. + 2) we want to elimate useless last MatchFinder_Normalize3() for corner cases, + where data size is aligned for 1 GB: 5/6/8 GB. + That reducing must be >= 1 for such corner cases. */ + dictSize -= 1; + } + + if (beforeSize + dictSize < keepWindowSize) + beforeSize = keepWindowSize - dictSize; + + /* in worst case we can look ahead for + max(LZMA_MATCH_LEN_MAX, numFastBytes + 1 + numFastBytes) bytes. + we send larger value for (keepAfter) to MantchFinder_Create(): + (numFastBytes + LZMA_MATCH_LEN_MAX + 1) + */ + + #ifndef _7ZIP_ST + if (p->mtMode) + { + RINOK(MatchFinderMt_Create(&p->matchFinderMt, dictSize, beforeSize, + p->numFastBytes, LZMA_MATCH_LEN_MAX + 1 /* 18.04 */ + , allocBig)); + p->matchFinderObj = &p->matchFinderMt; + MFB.bigHash = (Byte)( + (p->dictSize > kBigHashDicLimit && MFB.hashMask >= 0xFFFFFF) ? 1 : 0); + MatchFinderMt_CreateVTable(&p->matchFinderMt, &p->matchFinder); + } + else + #endif + { + if (!MatchFinder_Create(&MFB, dictSize, beforeSize, + p->numFastBytes, LZMA_MATCH_LEN_MAX + 1 /* 21.03 */ + , allocBig)) + return SZ_ERROR_MEM; + p->matchFinderObj = &MFB; + MatchFinder_CreateVTable(&MFB, &p->matchFinder); + } + + return SZ_OK; +} + +static void LzmaEnc_Init(CLzmaEnc *p) +{ + unsigned i; + p->state = 0; + p->reps[0] = + p->reps[1] = + p->reps[2] = + p->reps[3] = 1; + + RangeEnc_Init(&p->rc); + + for (i = 0; i < (1 << kNumAlignBits); i++) + p->posAlignEncoder[i] = kProbInitValue; + + for (i = 0; i < kNumStates; i++) + { + unsigned j; + for (j = 0; j < LZMA_NUM_PB_STATES_MAX; j++) + { + p->isMatch[i][j] = kProbInitValue; + p->isRep0Long[i][j] = kProbInitValue; + } + p->isRep[i] = kProbInitValue; + p->isRepG0[i] = kProbInitValue; + p->isRepG1[i] = kProbInitValue; + p->isRepG2[i] = kProbInitValue; + } + + { + for (i = 0; i < kNumLenToPosStates; i++) + { + CLzmaProb *probs = p->posSlotEncoder[i]; + unsigned j; + for (j = 0; j < (1 << kNumPosSlotBits); j++) + probs[j] = kProbInitValue; + } + } + { + for (i = 0; i < kNumFullDistances; i++) + p->posEncoders[i] = kProbInitValue; + } + + { + UInt32 num = (UInt32)0x300 << (p->lp + p->lc); + UInt32 k; + CLzmaProb *probs = p->litProbs; + for (k = 0; k < num; k++) + probs[k] = kProbInitValue; + } + + + LenEnc_Init(&p->lenProbs); + LenEnc_Init(&p->repLenProbs); + + p->optEnd = 0; + p->optCur = 0; + + { + for (i = 0; i < kNumOpts; i++) + p->opt[i].price = kInfinityPrice; + } + + p->additionalOffset = 0; + + p->pbMask = ((unsigned)1 << p->pb) - 1; + p->lpMask = ((UInt32)0x100 << p->lp) - ((unsigned)0x100 >> p->lc); + + // p->mf_Failure = False; +} + + +static void LzmaEnc_InitPrices(CLzmaEnc *p) +{ + if (!p->fastMode) + { + FillDistancesPrices(p); + FillAlignPrices(p); + } + + p->lenEnc.tableSize = + p->repLenEnc.tableSize = + p->numFastBytes + 1 - LZMA_MATCH_LEN_MIN; + + p->repLenEncCounter = REP_LEN_COUNT; + + LenPriceEnc_UpdateTables(&p->lenEnc, (unsigned)1 << p->pb, &p->lenProbs, p->ProbPrices); + LenPriceEnc_UpdateTables(&p->repLenEnc, (unsigned)1 << p->pb, &p->repLenProbs, p->ProbPrices); +} + +static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + unsigned i; + for (i = kEndPosModelIndex / 2; i < kDicLogSizeMax; i++) + if (p->dictSize <= ((UInt32)1 << i)) + break; + p->distTableSize = i * 2; + + p->finished = False; + p->result = SZ_OK; + RINOK(LzmaEnc_Alloc(p, keepWindowSize, alloc, allocBig)); + LzmaEnc_Init(p); + LzmaEnc_InitPrices(p); + p->nowPos64 = 0; + return SZ_OK; +} + +static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, + ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + MFB.stream = inStream; + p->needInit = 1; + p->rc.outStream = outStream; + return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig); +} + +SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, + ISeqInStream *inStream, UInt32 keepWindowSize, + ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + MFB.stream = inStream; + p->needInit = 1; + return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); +} + +static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const Byte *src, SizeT srcLen) +{ + MFB.directInput = 1; + MFB.bufferBase = (Byte *)src; + MFB.directInputRem = srcLen; +} + +SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen, + UInt32 keepWindowSize, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + LzmaEnc_SetInputBuf(p, src, srcLen); + p->needInit = 1; + + LzmaEnc_SetDataSize(pp, srcLen); + return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig); +} + +void LzmaEnc_Finish(CLzmaEncHandle pp) +{ + #ifndef _7ZIP_ST + CLzmaEnc *p = (CLzmaEnc *)pp; + if (p->mtMode) + MatchFinderMt_ReleaseStream(&p->matchFinderMt); + #else + UNUSED_VAR(pp); + #endif +} + + +typedef struct +{ + ISeqOutStream vt; + Byte *data; + SizeT rem; + BoolInt overflow; +} CLzmaEnc_SeqOutStreamBuf; + +static size_t SeqOutStreamBuf_Write(const ISeqOutStream *pp, const void *data, size_t size) +{ + CLzmaEnc_SeqOutStreamBuf *p = CONTAINER_FROM_VTBL(pp, CLzmaEnc_SeqOutStreamBuf, vt); + if (p->rem < size) + { + size = p->rem; + p->overflow = True; + } + if (size != 0) + { + memcpy(p->data, data, size); + p->rem -= size; + p->data += size; + } + return size; +} + + +/* +UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp) +{ + const CLzmaEnc *p = (CLzmaEnc *)pp; + return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); +} +*/ + +const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp) +{ + const CLzmaEnc *p = (CLzmaEnc *)pp; + return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset; +} + + +// (desiredPackSize == 0) is not allowed +SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, + Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize) +{ + CLzmaEnc *p = (CLzmaEnc *)pp; + UInt64 nowPos64; + SRes res; + CLzmaEnc_SeqOutStreamBuf outStream; + + outStream.vt.Write = SeqOutStreamBuf_Write; + outStream.data = dest; + outStream.rem = *destLen; + outStream.overflow = False; + + p->writeEndMark = False; + p->finished = False; + p->result = SZ_OK; + + if (reInit) + LzmaEnc_Init(p); + LzmaEnc_InitPrices(p); + RangeEnc_Init(&p->rc); + p->rc.outStream = &outStream.vt; + nowPos64 = p->nowPos64; + + res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize); + + *unpackSize = (UInt32)(p->nowPos64 - nowPos64); + *destLen -= outStream.rem; + if (outStream.overflow) + return SZ_ERROR_OUTPUT_EOF; + + return res; +} + + +MY_NO_INLINE +static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) +{ + SRes res = SZ_OK; + + #ifndef _7ZIP_ST + Byte allocaDummy[0x300]; + allocaDummy[0] = 0; + allocaDummy[1] = allocaDummy[0]; + #endif + + for (;;) + { + res = LzmaEnc_CodeOneBlock(p, 0, 0); + if (res != SZ_OK || p->finished) + break; + if (progress) + { + res = ICompressProgress_Progress(progress, p->nowPos64, RangeEnc_GetProcessed(&p->rc)); + if (res != SZ_OK) + { + res = SZ_ERROR_PROGRESS; + break; + } + } + } + + LzmaEnc_Finish(p); + + /* + if (res == SZ_OK && !Inline_MatchFinder_IsFinishedOK(&MFB)) + res = SZ_ERROR_FAIL; + } + */ + + return res; +} + + +SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress, + ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig)); + return LzmaEnc_Encode2((CLzmaEnc *)pp, progress); +} + + +SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, Byte *props, SizeT *size) +{ + if (*size < LZMA_PROPS_SIZE) + return SZ_ERROR_PARAM; + *size = LZMA_PROPS_SIZE; + { + const CLzmaEnc *p = (const CLzmaEnc *)pp; + const UInt32 dictSize = p->dictSize; + UInt32 v; + props[0] = (Byte)((p->pb * 5 + p->lp) * 9 + p->lc); + + // we write aligned dictionary value to properties for lzma decoder + if (dictSize >= ((UInt32)1 << 21)) + { + const UInt32 kDictMask = ((UInt32)1 << 20) - 1; + v = (dictSize + kDictMask) & ~kDictMask; + if (v < dictSize) + v = dictSize; + } + else + { + unsigned i = 11 * 2; + do + { + v = (UInt32)(2 + (i & 1)) << (i >> 1); + i++; + } + while (v < dictSize); + } + + SetUi32(props + 1, v); + return SZ_OK; + } +} + + +unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle pp) +{ + return (unsigned)((CLzmaEnc *)pp)->writeEndMark; +} + + +SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + SRes res; + CLzmaEnc *p = (CLzmaEnc *)pp; + + CLzmaEnc_SeqOutStreamBuf outStream; + + outStream.vt.Write = SeqOutStreamBuf_Write; + outStream.data = dest; + outStream.rem = *destLen; + outStream.overflow = False; + + p->writeEndMark = writeEndMark; + p->rc.outStream = &outStream.vt; + + res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); + + if (res == SZ_OK) + { + res = LzmaEnc_Encode2(p, progress); + if (res == SZ_OK && p->nowPos64 != srcLen) + res = SZ_ERROR_FAIL; + } + + *destLen -= outStream.rem; + if (outStream.overflow) + return SZ_ERROR_OUTPUT_EOF; + return res; +} + + +SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, + ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc); + SRes res; + if (!p) + return SZ_ERROR_MEM; + + res = LzmaEnc_SetProps(p, props); + if (res == SZ_OK) + { + res = LzmaEnc_WriteProperties(p, propsEncoded, propsSize); + if (res == SZ_OK) + res = LzmaEnc_MemEncode(p, dest, destLen, src, srcLen, + writeEndMark, progress, alloc, allocBig); + } + + LzmaEnc_Destroy(p, alloc, allocBig); + return res; +} + + +/* +#ifndef _7ZIP_ST +void LzmaEnc_GetLzThreads(CLzmaEncHandle pp, HANDLE lz_threads[2]) +{ + const CLzmaEnc *p = (CLzmaEnc *)pp; + lz_threads[0] = p->matchFinderMt.hashSync.thread; + lz_threads[1] = p->matchFinderMt.btSync.thread; +} +#endif +*/ diff --git a/deps/LZMA-SDK/C/LzmaEnc.h b/deps/LZMA-SDK/C/LzmaEnc.h index 26757ba6b..bc2ed5042 100644 --- a/deps/LZMA-SDK/C/LzmaEnc.h +++ b/deps/LZMA-SDK/C/LzmaEnc.h @@ -1,78 +1,78 @@ -/* LzmaEnc.h -- LZMA Encoder -2019-10-30 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_ENC_H -#define __LZMA_ENC_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define LZMA_PROPS_SIZE 5 - -typedef struct _CLzmaEncProps -{ - int level; /* 0 <= level <= 9 */ - UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version - (1 << 12) <= dictSize <= (3 << 29) for 64-bit version - default = (1 << 24) */ - int lc; /* 0 <= lc <= 8, default = 3 */ - int lp; /* 0 <= lp <= 4, default = 0 */ - int pb; /* 0 <= pb <= 4, default = 2 */ - int algo; /* 0 - fast, 1 - normal, default = 1 */ - int fb; /* 5 <= fb <= 273, default = 32 */ - int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ - int numHashBytes; /* 2, 3 or 4, default = 4 */ - UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ - unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ - int numThreads; /* 1 or 2, default = 2 */ - - UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1. - Encoder uses this value to reduce dictionary size */ - - UInt64 affinity; -} CLzmaEncProps; - -void LzmaEncProps_Init(CLzmaEncProps *p); -void LzmaEncProps_Normalize(CLzmaEncProps *p); -UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); - - -/* ---------- CLzmaEncHandle Interface ---------- */ - -/* LzmaEnc* functions can return the following exit codes: -SRes: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater in props - SZ_ERROR_WRITE - ISeqOutStream write callback error - SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output - SZ_ERROR_PROGRESS - some break from progress callback - SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) -*/ - -typedef void * CLzmaEncHandle; - -CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc); -void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig); - -SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); -void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize); -SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); -unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p); - -SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, - ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); -SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); - - -/* ---------- One Call Interface ---------- */ - -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); - -EXTERN_C_END - -#endif +/* LzmaEnc.h -- LZMA Encoder +2019-10-30 : Igor Pavlov : Public domain */ + +#ifndef __LZMA_ENC_H +#define __LZMA_ENC_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define LZMA_PROPS_SIZE 5 + +typedef struct _CLzmaEncProps +{ + int level; /* 0 <= level <= 9 */ + UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version + (1 << 12) <= dictSize <= (3 << 29) for 64-bit version + default = (1 << 24) */ + int lc; /* 0 <= lc <= 8, default = 3 */ + int lp; /* 0 <= lp <= 4, default = 0 */ + int pb; /* 0 <= pb <= 4, default = 2 */ + int algo; /* 0 - fast, 1 - normal, default = 1 */ + int fb; /* 5 <= fb <= 273, default = 32 */ + int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */ + int numHashBytes; /* 2, 3 or 4, default = 4 */ + UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */ + unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */ + int numThreads; /* 1 or 2, default = 2 */ + + UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1. + Encoder uses this value to reduce dictionary size */ + + UInt64 affinity; +} CLzmaEncProps; + +void LzmaEncProps_Init(CLzmaEncProps *p); +void LzmaEncProps_Normalize(CLzmaEncProps *p); +UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2); + + +/* ---------- CLzmaEncHandle Interface ---------- */ + +/* LzmaEnc* functions can return the following exit codes: +SRes: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater in props + SZ_ERROR_WRITE - ISeqOutStream write callback error + SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output + SZ_ERROR_PROGRESS - some break from progress callback + SZ_ERROR_THREAD - error in multithreading functions (only for Mt version) +*/ + +typedef void * CLzmaEncHandle; + +CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc); +void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig); + +SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props); +void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize); +SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size); +unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p); + +SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, + ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); +SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); + + +/* ---------- One Call Interface ---------- */ + +SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, + ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/LzmaLib.c b/deps/LZMA-SDK/C/LzmaLib.c index c10cf1a0f..706e9e58c 100644 --- a/deps/LZMA-SDK/C/LzmaLib.c +++ b/deps/LZMA-SDK/C/LzmaLib.c @@ -1,40 +1,40 @@ -/* LzmaLib.c -- LZMA library wrapper -2015-06-13 : Igor Pavlov : Public domain */ - -#include "Alloc.h" -#include "LzmaDec.h" -#include "LzmaEnc.h" -#include "LzmaLib.h" - -MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, - unsigned char *outProps, size_t *outPropsSize, - int level, /* 0 <= level <= 9, default = 5 */ - unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */ - int lc, /* 0 <= lc <= 8, default = 3 */ - int lp, /* 0 <= lp <= 4, default = 0 */ - int pb, /* 0 <= pb <= 4, default = 2 */ - int fb, /* 5 <= fb <= 273, default = 32 */ - int numThreads /* 1 or 2, default = 2 */ -) -{ - CLzmaEncProps props; - LzmaEncProps_Init(&props); - props.level = level; - props.dictSize = dictSize; - props.lc = lc; - props.lp = lp; - props.pb = pb; - props.fb = fb; - props.numThreads = numThreads; - - return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0, - NULL, &g_Alloc, &g_Alloc); -} - - -MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen, - const unsigned char *props, size_t propsSize) -{ - ELzmaStatus status; - return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc); -} +/* LzmaLib.c -- LZMA library wrapper +2015-06-13 : Igor Pavlov : Public domain */ + +#include "Alloc.h" +#include "LzmaDec.h" +#include "LzmaEnc.h" +#include "LzmaLib.h" + +MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, + unsigned char *outProps, size_t *outPropsSize, + int level, /* 0 <= level <= 9, default = 5 */ + unsigned dictSize, /* use (1 << N) or (3 << N). 4 KB < dictSize <= 128 MB */ + int lc, /* 0 <= lc <= 8, default = 3 */ + int lp, /* 0 <= lp <= 4, default = 0 */ + int pb, /* 0 <= pb <= 4, default = 2 */ + int fb, /* 5 <= fb <= 273, default = 32 */ + int numThreads /* 1 or 2, default = 2 */ +) +{ + CLzmaEncProps props; + LzmaEncProps_Init(&props); + props.level = level; + props.dictSize = dictSize; + props.lc = lc; + props.lp = lp; + props.pb = pb; + props.fb = fb; + props.numThreads = numThreads; + + return LzmaEncode(dest, destLen, src, srcLen, &props, outProps, outPropsSize, 0, + NULL, &g_Alloc, &g_Alloc); +} + + +MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t *srcLen, + const unsigned char *props, size_t propsSize) +{ + ELzmaStatus status; + return LzmaDecode(dest, destLen, src, srcLen, props, (unsigned)propsSize, LZMA_FINISH_ANY, &status, &g_Alloc); +} diff --git a/deps/LZMA-SDK/C/LzmaLib.h b/deps/LZMA-SDK/C/LzmaLib.h index 4103e224a..c343a8596 100644 --- a/deps/LZMA-SDK/C/LzmaLib.h +++ b/deps/LZMA-SDK/C/LzmaLib.h @@ -1,138 +1,138 @@ -/* LzmaLib.h -- LZMA library interface -2021-04-03 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_LIB_H -#define __LZMA_LIB_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define MY_STDAPI int MY_STD_CALL - -#define LZMA_PROPS_SIZE 5 - -/* -RAM requirements for LZMA: - for compression: (dictSize * 11.5 + 6 MB) + state_size - for decompression: dictSize + state_size - state_size = (4 + (1.5 << (lc + lp))) KB - by default (lc=3, lp=0), state_size = 16 KB. - -LZMA properties (5 bytes) format - Offset Size Description - 0 1 lc, lp and pb in encoded form. - 1 4 dictSize (little endian). -*/ - -/* -LzmaCompress ------------- - -outPropsSize - - In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. - Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. - - LZMA Encoder will use defult values for any parameter, if it is - -1 for any from: level, loc, lp, pb, fb, numThreads - 0 for dictSize - -level - compression level: 0 <= level <= 9; - - level dictSize algo fb - 0: 64 KB 0 32 - 1: 256 KB 0 32 - 2: 1 MB 0 32 - 3: 4 MB 0 32 - 4: 16 MB 0 32 - 5: 16 MB 1 32 - 6: 32 MB 1 32 - 7: 32 MB 1 64 - 8: 64 MB 1 64 - 9: 64 MB 1 64 - - The default value for "level" is 5. - - algo = 0 means fast method - algo = 1 means normal method - -dictSize - The dictionary size in bytes. The maximum value is - 128 MB = (1 << 27) bytes for 32-bit version - 1 GB = (1 << 30) bytes for 64-bit version - The default value is 16 MB = (1 << 24) bytes. - It's recommended to use the dictionary that is larger than 4 KB and - that can be calculated as (1 << N) or (3 << N) sizes. - -lc - The number of literal context bits (high bits of previous literal). - It can be in the range from 0 to 8. The default value is 3. - Sometimes lc=4 gives the gain for big files. - -lp - The number of literal pos bits (low bits of current position for literals). - It can be in the range from 0 to 4. The default value is 0. - The lp switch is intended for periodical data when the period is equal to 2^lp. - For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's - better to set lc=0, if you change lp switch. - -pb - The number of pos bits (low bits of current position). - It can be in the range from 0 to 4. The default value is 2. - The pb switch is intended for periodical data when the period is equal 2^pb. - -fb - Word size (the number of fast bytes). - It can be in the range from 5 to 273. The default value is 32. - Usually, a big number gives a little bit better compression ratio and - slower compression process. - -numThreads - The number of thereads. 1 or 2. The default value is 2. - Fast mode (algo = 0) can use only 1 thread. - -In: - dest - output data buffer - destLen - output data buffer size - src - input data - srcLen - input data size -Out: - destLen - processed output size -Returns: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater - SZ_ERROR_OUTPUT_EOF - output buffer overflow - SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) -*/ - -MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, - unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ - int level, /* 0 <= level <= 9, default = 5 */ - unsigned dictSize, /* default = (1 << 24) */ - int lc, /* 0 <= lc <= 8, default = 3 */ - int lp, /* 0 <= lp <= 4, default = 0 */ - int pb, /* 0 <= pb <= 4, default = 2 */ - int fb, /* 5 <= fb <= 273, default = 32 */ - int numThreads /* 1 or 2, default = 2 */ - ); - -/* -LzmaUncompress --------------- -In: - dest - output data buffer - destLen - output data buffer size - src - input data - srcLen - input data size -Out: - destLen - processed output size - srcLen - processed input size -Returns: - SZ_OK - OK - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation arror - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) -*/ - -MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, - const unsigned char *props, size_t propsSize); - -EXTERN_C_END - -#endif +/* LzmaLib.h -- LZMA library interface +2021-04-03 : Igor Pavlov : Public domain */ + +#ifndef __LZMA_LIB_H +#define __LZMA_LIB_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define MY_STDAPI int MY_STD_CALL + +#define LZMA_PROPS_SIZE 5 + +/* +RAM requirements for LZMA: + for compression: (dictSize * 11.5 + 6 MB) + state_size + for decompression: dictSize + state_size + state_size = (4 + (1.5 << (lc + lp))) KB + by default (lc=3, lp=0), state_size = 16 KB. + +LZMA properties (5 bytes) format + Offset Size Description + 0 1 lc, lp and pb in encoded form. + 1 4 dictSize (little endian). +*/ + +/* +LzmaCompress +------------ + +outPropsSize - + In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. + Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. + + LZMA Encoder will use defult values for any parameter, if it is + -1 for any from: level, loc, lp, pb, fb, numThreads + 0 for dictSize + +level - compression level: 0 <= level <= 9; + + level dictSize algo fb + 0: 64 KB 0 32 + 1: 256 KB 0 32 + 2: 1 MB 0 32 + 3: 4 MB 0 32 + 4: 16 MB 0 32 + 5: 16 MB 1 32 + 6: 32 MB 1 32 + 7: 32 MB 1 64 + 8: 64 MB 1 64 + 9: 64 MB 1 64 + + The default value for "level" is 5. + + algo = 0 means fast method + algo = 1 means normal method + +dictSize - The dictionary size in bytes. The maximum value is + 128 MB = (1 << 27) bytes for 32-bit version + 1 GB = (1 << 30) bytes for 64-bit version + The default value is 16 MB = (1 << 24) bytes. + It's recommended to use the dictionary that is larger than 4 KB and + that can be calculated as (1 << N) or (3 << N) sizes. + +lc - The number of literal context bits (high bits of previous literal). + It can be in the range from 0 to 8. The default value is 3. + Sometimes lc=4 gives the gain for big files. + +lp - The number of literal pos bits (low bits of current position for literals). + It can be in the range from 0 to 4. The default value is 0. + The lp switch is intended for periodical data when the period is equal to 2^lp. + For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's + better to set lc=0, if you change lp switch. + +pb - The number of pos bits (low bits of current position). + It can be in the range from 0 to 4. The default value is 2. + The pb switch is intended for periodical data when the period is equal 2^pb. + +fb - Word size (the number of fast bytes). + It can be in the range from 5 to 273. The default value is 32. + Usually, a big number gives a little bit better compression ratio and + slower compression process. + +numThreads - The number of thereads. 1 or 2. The default value is 2. + Fast mode (algo = 0) can use only 1 thread. + +In: + dest - output data buffer + destLen - output data buffer size + src - input data + srcLen - input data size +Out: + destLen - processed output size +Returns: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater + SZ_ERROR_OUTPUT_EOF - output buffer overflow + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) +*/ + +MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, + unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ + int level, /* 0 <= level <= 9, default = 5 */ + unsigned dictSize, /* default = (1 << 24) */ + int lc, /* 0 <= lc <= 8, default = 3 */ + int lp, /* 0 <= lp <= 4, default = 0 */ + int pb, /* 0 <= pb <= 4, default = 2 */ + int fb, /* 5 <= fb <= 273, default = 32 */ + int numThreads /* 1 or 2, default = 2 */ + ); + +/* +LzmaUncompress +-------------- +In: + dest - output data buffer + destLen - output data buffer size + src - input data + srcLen - input data size +Out: + destLen - processed output size + srcLen - processed input size +Returns: + SZ_OK - OK + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation arror + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) +*/ + +MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, + const unsigned char *props, size_t propsSize); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/MtCoder.c b/deps/LZMA-SDK/C/MtCoder.c index 85444f484..99dc9090a 100644 --- a/deps/LZMA-SDK/C/MtCoder.c +++ b/deps/LZMA-SDK/C/MtCoder.c @@ -1,600 +1,595 @@ -/* MtCoder.c -- Multi-thread Coder -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "MtCoder.h" - -#ifndef _7ZIP_ST - -static SRes MtProgressThunk_Progress(const ICompressProgress *pp, UInt64 inSize, UInt64 outSize) -{ - CMtProgressThunk *thunk = CONTAINER_FROM_VTBL(pp, CMtProgressThunk, vt); - UInt64 inSize2 = 0; - UInt64 outSize2 = 0; - if (inSize != (UInt64)(Int64)-1) - { - inSize2 = inSize - thunk->inSize; - thunk->inSize = inSize; - } - if (outSize != (UInt64)(Int64)-1) - { - outSize2 = outSize - thunk->outSize; - thunk->outSize = outSize; - } - return MtProgress_ProgressAdd(thunk->mtProgress, inSize2, outSize2); -} - - -void MtProgressThunk_CreateVTable(CMtProgressThunk *p) -{ - p->vt.Progress = MtProgressThunk_Progress; -} - - - -#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; } - - -static WRes ArEvent_OptCreate_And_Reset(CEvent *p) -{ - if (Event_IsCreated(p)) - return Event_Reset(p); - return AutoResetEvent_CreateNotSignaled(p); -} - - -static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp); - - -static SRes MtCoderThread_CreateAndStart(CMtCoderThread *t) -{ - WRes wres = ArEvent_OptCreate_And_Reset(&t->startEvent); - if (wres == 0) - { - t->stop = False; - if (!Thread_WasCreated(&t->thread)) - wres = Thread_Create(&t->thread, ThreadFunc, t); - if (wres == 0) - wres = Event_Set(&t->startEvent); - } - if (wres == 0) - return SZ_OK; - return MY_SRes_HRESULT_FROM_WRes(wres); -} - - -static void MtCoderThread_Destruct(CMtCoderThread *t) -{ - if (Thread_WasCreated(&t->thread)) - { - t->stop = 1; - Event_Set(&t->startEvent); - Thread_Wait_Close(&t->thread); - } - - Event_Close(&t->startEvent); - - if (t->inBuf) - { - ISzAlloc_Free(t->mtCoder->allocBig, t->inBuf); - t->inBuf = NULL; - } -} - - - -static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize) -{ - size_t size = *processedSize; - *processedSize = 0; - while (size != 0) - { - size_t cur = size; - SRes res = ISeqInStream_Read(stream, data, &cur); - *processedSize += cur; - data += cur; - size -= cur; - RINOK(res); - if (cur == 0) - return SZ_OK; - } - return SZ_OK; -} - - -/* - ThreadFunc2() returns: - SZ_OK - in all normal cases (even for stream error or memory allocation error) - SZ_ERROR_THREAD - in case of failure in system synch function -*/ - -static SRes ThreadFunc2(CMtCoderThread *t) -{ - CMtCoder *mtc = t->mtCoder; - - for (;;) - { - unsigned bi; - SRes res; - SRes res2; - BoolInt finished; - unsigned bufIndex; - size_t size; - const Byte *inData; - UInt64 readProcessed = 0; - - RINOK_THREAD(Event_Wait(&mtc->readEvent)) - - /* after Event_Wait(&mtc->readEvent) we must call Event_Set(&mtc->readEvent) in any case to unlock another threads */ - - if (mtc->stopReading) - { - return Event_Set(&mtc->readEvent) == 0 ? SZ_OK : SZ_ERROR_THREAD; - } - - res = MtProgress_GetError(&mtc->mtProgress); - - size = 0; - inData = NULL; - finished = True; - - if (res == SZ_OK) - { - size = mtc->blockSize; - if (mtc->inStream) - { - if (!t->inBuf) - { - t->inBuf = (Byte *)ISzAlloc_Alloc(mtc->allocBig, mtc->blockSize); - if (!t->inBuf) - res = SZ_ERROR_MEM; - } - if (res == SZ_OK) - { - res = FullRead(mtc->inStream, t->inBuf, &size); - readProcessed = mtc->readProcessed + size; - mtc->readProcessed = readProcessed; - } - if (res != SZ_OK) - { - mtc->readRes = res; - /* after reading error - we can stop encoding of previous blocks */ - MtProgress_SetError(&mtc->mtProgress, res); - } - else - finished = (size != mtc->blockSize); - } - else - { - size_t rem; - readProcessed = mtc->readProcessed; - rem = mtc->inDataSize - (size_t)readProcessed; - if (size > rem) - size = rem; - inData = mtc->inData + (size_t)readProcessed; - readProcessed += size; - mtc->readProcessed = readProcessed; - finished = (mtc->inDataSize == (size_t)readProcessed); - } - } - - /* we must get some block from blocksSemaphore before Event_Set(&mtc->readEvent) */ - - res2 = SZ_OK; - - if (Semaphore_Wait(&mtc->blocksSemaphore) != 0) - { - res2 = SZ_ERROR_THREAD; - if (res == SZ_OK) - { - res = res2; - // MtProgress_SetError(&mtc->mtProgress, res); - } - } - - bi = mtc->blockIndex; - - if (++mtc->blockIndex >= mtc->numBlocksMax) - mtc->blockIndex = 0; - - bufIndex = (unsigned)(int)-1; - - if (res == SZ_OK) - res = MtProgress_GetError(&mtc->mtProgress); - - if (res != SZ_OK) - finished = True; - - if (!finished) - { - if (mtc->numStartedThreads < mtc->numStartedThreadsLimit - && mtc->expectedDataSize != readProcessed) - { - res = MtCoderThread_CreateAndStart(&mtc->threads[mtc->numStartedThreads]); - if (res == SZ_OK) - mtc->numStartedThreads++; - else - { - MtProgress_SetError(&mtc->mtProgress, res); - finished = True; - } - } - } - - if (finished) - mtc->stopReading = True; - - RINOK_THREAD(Event_Set(&mtc->readEvent)) - - if (res2 != SZ_OK) - return res2; - - if (res == SZ_OK) - { - CriticalSection_Enter(&mtc->cs); - bufIndex = mtc->freeBlockHead; - mtc->freeBlockHead = mtc->freeBlockList[bufIndex]; - CriticalSection_Leave(&mtc->cs); - - res = mtc->mtCallback->Code(mtc->mtCallbackObject, t->index, bufIndex, - mtc->inStream ? t->inBuf : inData, size, finished); - - // MtProgress_Reinit(&mtc->mtProgress, t->index); - - if (res != SZ_OK) - MtProgress_SetError(&mtc->mtProgress, res); - } - - { - CMtCoderBlock *block = &mtc->blocks[bi]; - block->res = res; - block->bufIndex = bufIndex; - block->finished = finished; - } - - #ifdef MTCODER__USE_WRITE_THREAD - RINOK_THREAD(Event_Set(&mtc->writeEvents[bi])) - #else - { - unsigned wi; - { - CriticalSection_Enter(&mtc->cs); - wi = mtc->writeIndex; - if (wi == bi) - mtc->writeIndex = (unsigned)(int)-1; - else - mtc->ReadyBlocks[bi] = True; - CriticalSection_Leave(&mtc->cs); - } - - if (wi != bi) - { - if (res != SZ_OK || finished) - return 0; - continue; - } - - if (mtc->writeRes != SZ_OK) - res = mtc->writeRes; - - for (;;) - { - if (res == SZ_OK && bufIndex != (unsigned)(int)-1) - { - res = mtc->mtCallback->Write(mtc->mtCallbackObject, bufIndex); - if (res != SZ_OK) - { - mtc->writeRes = res; - MtProgress_SetError(&mtc->mtProgress, res); - } - } - - if (++wi >= mtc->numBlocksMax) - wi = 0; - { - BoolInt isReady; - - CriticalSection_Enter(&mtc->cs); - - if (bufIndex != (unsigned)(int)-1) - { - mtc->freeBlockList[bufIndex] = mtc->freeBlockHead; - mtc->freeBlockHead = bufIndex; - } - - isReady = mtc->ReadyBlocks[wi]; - - if (isReady) - mtc->ReadyBlocks[wi] = False; - else - mtc->writeIndex = wi; - - CriticalSection_Leave(&mtc->cs); - - RINOK_THREAD(Semaphore_Release1(&mtc->blocksSemaphore)) - - if (!isReady) - break; - } - - { - CMtCoderBlock *block = &mtc->blocks[wi]; - if (res == SZ_OK && block->res != SZ_OK) - res = block->res; - bufIndex = block->bufIndex; - finished = block->finished; - } - } - } - #endif - - if (finished || res != SZ_OK) - return 0; - } -} - - -static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp) -{ - CMtCoderThread *t = (CMtCoderThread *)pp; - for (;;) - { - if (Event_Wait(&t->startEvent) != 0) - return (THREAD_FUNC_RET_TYPE)SZ_ERROR_THREAD; - if (t->stop) - return 0; - { - SRes res = ThreadFunc2(t); - CMtCoder *mtc = t->mtCoder; - if (res != SZ_OK) - { - MtProgress_SetError(&mtc->mtProgress, res); - } - - #ifndef MTCODER__USE_WRITE_THREAD - { - unsigned numFinished = (unsigned)InterlockedIncrement(&mtc->numFinishedThreads); - if (numFinished == mtc->numStartedThreads) - if (Event_Set(&mtc->finishedEvent) != 0) - return (THREAD_FUNC_RET_TYPE)SZ_ERROR_THREAD; - } - #endif - } - } -} - - - -void MtCoder_Construct(CMtCoder *p) -{ - unsigned i; - - p->blockSize = 0; - p->numThreadsMax = 0; - p->expectedDataSize = (UInt64)(Int64)-1; - - p->inStream = NULL; - p->inData = NULL; - p->inDataSize = 0; - - p->progress = NULL; - p->allocBig = NULL; - - p->mtCallback = NULL; - p->mtCallbackObject = NULL; - - p->allocatedBufsSize = 0; - - Event_Construct(&p->readEvent); - Semaphore_Construct(&p->blocksSemaphore); - - for (i = 0; i < MTCODER__THREADS_MAX; i++) - { - CMtCoderThread *t = &p->threads[i]; - t->mtCoder = p; - t->index = i; - t->inBuf = NULL; - t->stop = False; - Event_Construct(&t->startEvent); - Thread_Construct(&t->thread); - } - - #ifdef MTCODER__USE_WRITE_THREAD - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - Event_Construct(&p->writeEvents[i]); - #else - Event_Construct(&p->finishedEvent); - #endif - - CriticalSection_Init(&p->cs); - CriticalSection_Init(&p->mtProgress.cs); -} - - - - -static void MtCoder_Free(CMtCoder *p) -{ - unsigned i; - - /* - p->stopReading = True; - if (Event_IsCreated(&p->readEvent)) - Event_Set(&p->readEvent); - */ - - for (i = 0; i < MTCODER__THREADS_MAX; i++) - MtCoderThread_Destruct(&p->threads[i]); - - Event_Close(&p->readEvent); - Semaphore_Close(&p->blocksSemaphore); - - #ifdef MTCODER__USE_WRITE_THREAD - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - Event_Close(&p->writeEvents[i]); - #else - Event_Close(&p->finishedEvent); - #endif -} - - -void MtCoder_Destruct(CMtCoder *p) -{ - MtCoder_Free(p); - - CriticalSection_Delete(&p->cs); - CriticalSection_Delete(&p->mtProgress.cs); -} - - -SRes MtCoder_Code(CMtCoder *p) -{ - unsigned numThreads = p->numThreadsMax; - unsigned numBlocksMax; - unsigned i; - SRes res = SZ_OK; - - if (numThreads > MTCODER__THREADS_MAX) - numThreads = MTCODER__THREADS_MAX; - numBlocksMax = MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads); - - if (p->blockSize < ((UInt32)1 << 26)) numBlocksMax++; - if (p->blockSize < ((UInt32)1 << 24)) numBlocksMax++; - if (p->blockSize < ((UInt32)1 << 22)) numBlocksMax++; - - if (numBlocksMax > MTCODER__BLOCKS_MAX) - numBlocksMax = MTCODER__BLOCKS_MAX; - - if (p->blockSize != p->allocatedBufsSize) - { - for (i = 0; i < MTCODER__THREADS_MAX; i++) - { - CMtCoderThread *t = &p->threads[i]; - if (t->inBuf) - { - ISzAlloc_Free(p->allocBig, t->inBuf); - t->inBuf = NULL; - } - } - p->allocatedBufsSize = p->blockSize; - } - - p->readRes = SZ_OK; - - MtProgress_Init(&p->mtProgress, p->progress); - - #ifdef MTCODER__USE_WRITE_THREAD - for (i = 0; i < numBlocksMax; i++) - { - RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->writeEvents[i])); - } - #else - RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->finishedEvent)); - #endif - - { - RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->readEvent)); - - if (Semaphore_IsCreated(&p->blocksSemaphore)) - { - RINOK_THREAD(Semaphore_Close(&p->blocksSemaphore)); - } - RINOK_THREAD(Semaphore_Create(&p->blocksSemaphore, numBlocksMax, numBlocksMax)); - } - - for (i = 0; i < MTCODER__BLOCKS_MAX - 1; i++) - p->freeBlockList[i] = i + 1; - p->freeBlockList[MTCODER__BLOCKS_MAX - 1] = (unsigned)(int)-1; - p->freeBlockHead = 0; - - p->readProcessed = 0; - p->blockIndex = 0; - p->numBlocksMax = numBlocksMax; - p->stopReading = False; - - #ifndef MTCODER__USE_WRITE_THREAD - p->writeIndex = 0; - p->writeRes = SZ_OK; - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - p->ReadyBlocks[i] = False; - p->numFinishedThreads = 0; - #endif - - p->numStartedThreadsLimit = numThreads; - p->numStartedThreads = 0; - - // for (i = 0; i < numThreads; i++) - { - CMtCoderThread *nextThread = &p->threads[p->numStartedThreads++]; - RINOK(MtCoderThread_CreateAndStart(nextThread)); - } - - RINOK_THREAD(Event_Set(&p->readEvent)) - - #ifdef MTCODER__USE_WRITE_THREAD - { - unsigned bi = 0; - - for (;; bi++) - { - if (bi >= numBlocksMax) - bi = 0; - - RINOK_THREAD(Event_Wait(&p->writeEvents[bi])) - - { - const CMtCoderBlock *block = &p->blocks[bi]; - unsigned bufIndex = block->bufIndex; - BoolInt finished = block->finished; - if (res == SZ_OK && block->res != SZ_OK) - res = block->res; - - if (bufIndex != (unsigned)(int)-1) - { - if (res == SZ_OK) - { - res = p->mtCallback->Write(p->mtCallbackObject, bufIndex); - if (res != SZ_OK) - MtProgress_SetError(&p->mtProgress, res); - } - - CriticalSection_Enter(&p->cs); - { - p->freeBlockList[bufIndex] = p->freeBlockHead; - p->freeBlockHead = bufIndex; - } - CriticalSection_Leave(&p->cs); - } - - RINOK_THREAD(Semaphore_Release1(&p->blocksSemaphore)) - - if (finished) - break; - } - } - } - #else - { - WRes wres = Event_Wait(&p->finishedEvent); - res = MY_SRes_HRESULT_FROM_WRes(wres); - } - #endif - - if (res == SZ_OK) - res = p->readRes; - - if (res == SZ_OK) - res = p->mtProgress.res; - - #ifndef MTCODER__USE_WRITE_THREAD - if (res == SZ_OK) - res = p->writeRes; - #endif - - if (res != SZ_OK) - MtCoder_Free(p); - return res; -} - -#endif +/* MtCoder.c -- Multi-thread Coder +2021-12-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "MtCoder.h" + +#ifndef _7ZIP_ST + +static SRes MtProgressThunk_Progress(const ICompressProgress *pp, UInt64 inSize, UInt64 outSize) +{ + CMtProgressThunk *thunk = CONTAINER_FROM_VTBL(pp, CMtProgressThunk, vt); + UInt64 inSize2 = 0; + UInt64 outSize2 = 0; + if (inSize != (UInt64)(Int64)-1) + { + inSize2 = inSize - thunk->inSize; + thunk->inSize = inSize; + } + if (outSize != (UInt64)(Int64)-1) + { + outSize2 = outSize - thunk->outSize; + thunk->outSize = outSize; + } + return MtProgress_ProgressAdd(thunk->mtProgress, inSize2, outSize2); +} + + +void MtProgressThunk_CreateVTable(CMtProgressThunk *p) +{ + p->vt.Progress = MtProgressThunk_Progress; +} + + + +#define RINOK_THREAD(x) { if ((x) != 0) return SZ_ERROR_THREAD; } + + +static WRes ArEvent_OptCreate_And_Reset(CEvent *p) +{ + if (Event_IsCreated(p)) + return Event_Reset(p); + return AutoResetEvent_CreateNotSignaled(p); +} + + +static THREAD_FUNC_DECL ThreadFunc(void *pp); + + +static SRes MtCoderThread_CreateAndStart(CMtCoderThread *t) +{ + WRes wres = ArEvent_OptCreate_And_Reset(&t->startEvent); + if (wres == 0) + { + t->stop = False; + if (!Thread_WasCreated(&t->thread)) + wres = Thread_Create(&t->thread, ThreadFunc, t); + if (wres == 0) + wres = Event_Set(&t->startEvent); + } + if (wres == 0) + return SZ_OK; + return MY_SRes_HRESULT_FROM_WRes(wres); +} + + +static void MtCoderThread_Destruct(CMtCoderThread *t) +{ + if (Thread_WasCreated(&t->thread)) + { + t->stop = 1; + Event_Set(&t->startEvent); + Thread_Wait_Close(&t->thread); + } + + Event_Close(&t->startEvent); + + if (t->inBuf) + { + ISzAlloc_Free(t->mtCoder->allocBig, t->inBuf); + t->inBuf = NULL; + } +} + + + +static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize) +{ + size_t size = *processedSize; + *processedSize = 0; + while (size != 0) + { + size_t cur = size; + SRes res = ISeqInStream_Read(stream, data, &cur); + *processedSize += cur; + data += cur; + size -= cur; + RINOK(res); + if (cur == 0) + return SZ_OK; + } + return SZ_OK; +} + + +/* + ThreadFunc2() returns: + SZ_OK - in all normal cases (even for stream error or memory allocation error) + SZ_ERROR_THREAD - in case of failure in system synch function +*/ + +static SRes ThreadFunc2(CMtCoderThread *t) +{ + CMtCoder *mtc = t->mtCoder; + + for (;;) + { + unsigned bi; + SRes res; + SRes res2; + BoolInt finished; + unsigned bufIndex; + size_t size; + const Byte *inData; + UInt64 readProcessed = 0; + + RINOK_THREAD(Event_Wait(&mtc->readEvent)) + + /* after Event_Wait(&mtc->readEvent) we must call Event_Set(&mtc->readEvent) in any case to unlock another threads */ + + if (mtc->stopReading) + { + return Event_Set(&mtc->readEvent) == 0 ? SZ_OK : SZ_ERROR_THREAD; + } + + res = MtProgress_GetError(&mtc->mtProgress); + + size = 0; + inData = NULL; + finished = True; + + if (res == SZ_OK) + { + size = mtc->blockSize; + if (mtc->inStream) + { + if (!t->inBuf) + { + t->inBuf = (Byte *)ISzAlloc_Alloc(mtc->allocBig, mtc->blockSize); + if (!t->inBuf) + res = SZ_ERROR_MEM; + } + if (res == SZ_OK) + { + res = FullRead(mtc->inStream, t->inBuf, &size); + readProcessed = mtc->readProcessed + size; + mtc->readProcessed = readProcessed; + } + if (res != SZ_OK) + { + mtc->readRes = res; + /* after reading error - we can stop encoding of previous blocks */ + MtProgress_SetError(&mtc->mtProgress, res); + } + else + finished = (size != mtc->blockSize); + } + else + { + size_t rem; + readProcessed = mtc->readProcessed; + rem = mtc->inDataSize - (size_t)readProcessed; + if (size > rem) + size = rem; + inData = mtc->inData + (size_t)readProcessed; + readProcessed += size; + mtc->readProcessed = readProcessed; + finished = (mtc->inDataSize == (size_t)readProcessed); + } + } + + /* we must get some block from blocksSemaphore before Event_Set(&mtc->readEvent) */ + + res2 = SZ_OK; + + if (Semaphore_Wait(&mtc->blocksSemaphore) != 0) + { + res2 = SZ_ERROR_THREAD; + if (res == SZ_OK) + { + res = res2; + // MtProgress_SetError(&mtc->mtProgress, res); + } + } + + bi = mtc->blockIndex; + + if (++mtc->blockIndex >= mtc->numBlocksMax) + mtc->blockIndex = 0; + + bufIndex = (unsigned)(int)-1; + + if (res == SZ_OK) + res = MtProgress_GetError(&mtc->mtProgress); + + if (res != SZ_OK) + finished = True; + + if (!finished) + { + if (mtc->numStartedThreads < mtc->numStartedThreadsLimit + && mtc->expectedDataSize != readProcessed) + { + res = MtCoderThread_CreateAndStart(&mtc->threads[mtc->numStartedThreads]); + if (res == SZ_OK) + mtc->numStartedThreads++; + else + { + MtProgress_SetError(&mtc->mtProgress, res); + finished = True; + } + } + } + + if (finished) + mtc->stopReading = True; + + RINOK_THREAD(Event_Set(&mtc->readEvent)) + + if (res2 != SZ_OK) + return res2; + + if (res == SZ_OK) + { + CriticalSection_Enter(&mtc->cs); + bufIndex = mtc->freeBlockHead; + mtc->freeBlockHead = mtc->freeBlockList[bufIndex]; + CriticalSection_Leave(&mtc->cs); + + res = mtc->mtCallback->Code(mtc->mtCallbackObject, t->index, bufIndex, + mtc->inStream ? t->inBuf : inData, size, finished); + + // MtProgress_Reinit(&mtc->mtProgress, t->index); + + if (res != SZ_OK) + MtProgress_SetError(&mtc->mtProgress, res); + } + + { + CMtCoderBlock *block = &mtc->blocks[bi]; + block->res = res; + block->bufIndex = bufIndex; + block->finished = finished; + } + + #ifdef MTCODER__USE_WRITE_THREAD + RINOK_THREAD(Event_Set(&mtc->writeEvents[bi])) + #else + { + unsigned wi; + { + CriticalSection_Enter(&mtc->cs); + wi = mtc->writeIndex; + if (wi == bi) + mtc->writeIndex = (unsigned)(int)-1; + else + mtc->ReadyBlocks[bi] = True; + CriticalSection_Leave(&mtc->cs); + } + + if (wi != bi) + { + if (res != SZ_OK || finished) + return 0; + continue; + } + + if (mtc->writeRes != SZ_OK) + res = mtc->writeRes; + + for (;;) + { + if (res == SZ_OK && bufIndex != (unsigned)(int)-1) + { + res = mtc->mtCallback->Write(mtc->mtCallbackObject, bufIndex); + if (res != SZ_OK) + { + mtc->writeRes = res; + MtProgress_SetError(&mtc->mtProgress, res); + } + } + + if (++wi >= mtc->numBlocksMax) + wi = 0; + { + BoolInt isReady; + + CriticalSection_Enter(&mtc->cs); + + if (bufIndex != (unsigned)(int)-1) + { + mtc->freeBlockList[bufIndex] = mtc->freeBlockHead; + mtc->freeBlockHead = bufIndex; + } + + isReady = mtc->ReadyBlocks[wi]; + + if (isReady) + mtc->ReadyBlocks[wi] = False; + else + mtc->writeIndex = wi; + + CriticalSection_Leave(&mtc->cs); + + RINOK_THREAD(Semaphore_Release1(&mtc->blocksSemaphore)) + + if (!isReady) + break; + } + + { + CMtCoderBlock *block = &mtc->blocks[wi]; + if (res == SZ_OK && block->res != SZ_OK) + res = block->res; + bufIndex = block->bufIndex; + finished = block->finished; + } + } + } + #endif + + if (finished || res != SZ_OK) + return 0; + } +} + + +static THREAD_FUNC_DECL ThreadFunc(void *pp) +{ + CMtCoderThread *t = (CMtCoderThread *)pp; + for (;;) + { + if (Event_Wait(&t->startEvent) != 0) + return (THREAD_FUNC_RET_TYPE)SZ_ERROR_THREAD; + if (t->stop) + return 0; + { + SRes res = ThreadFunc2(t); + CMtCoder *mtc = t->mtCoder; + if (res != SZ_OK) + { + MtProgress_SetError(&mtc->mtProgress, res); + } + + #ifndef MTCODER__USE_WRITE_THREAD + { + unsigned numFinished = (unsigned)InterlockedIncrement(&mtc->numFinishedThreads); + if (numFinished == mtc->numStartedThreads) + if (Event_Set(&mtc->finishedEvent) != 0) + return (THREAD_FUNC_RET_TYPE)SZ_ERROR_THREAD; + } + #endif + } + } +} + + + +void MtCoder_Construct(CMtCoder *p) +{ + unsigned i; + + p->blockSize = 0; + p->numThreadsMax = 0; + p->expectedDataSize = (UInt64)(Int64)-1; + + p->inStream = NULL; + p->inData = NULL; + p->inDataSize = 0; + + p->progress = NULL; + p->allocBig = NULL; + + p->mtCallback = NULL; + p->mtCallbackObject = NULL; + + p->allocatedBufsSize = 0; + + Event_Construct(&p->readEvent); + Semaphore_Construct(&p->blocksSemaphore); + + for (i = 0; i < MTCODER__THREADS_MAX; i++) + { + CMtCoderThread *t = &p->threads[i]; + t->mtCoder = p; + t->index = i; + t->inBuf = NULL; + t->stop = False; + Event_Construct(&t->startEvent); + Thread_Construct(&t->thread); + } + + #ifdef MTCODER__USE_WRITE_THREAD + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + Event_Construct(&p->writeEvents[i]); + #else + Event_Construct(&p->finishedEvent); + #endif + + CriticalSection_Init(&p->cs); + CriticalSection_Init(&p->mtProgress.cs); +} + + + + +static void MtCoder_Free(CMtCoder *p) +{ + unsigned i; + + /* + p->stopReading = True; + if (Event_IsCreated(&p->readEvent)) + Event_Set(&p->readEvent); + */ + + for (i = 0; i < MTCODER__THREADS_MAX; i++) + MtCoderThread_Destruct(&p->threads[i]); + + Event_Close(&p->readEvent); + Semaphore_Close(&p->blocksSemaphore); + + #ifdef MTCODER__USE_WRITE_THREAD + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + Event_Close(&p->writeEvents[i]); + #else + Event_Close(&p->finishedEvent); + #endif +} + + +void MtCoder_Destruct(CMtCoder *p) +{ + MtCoder_Free(p); + + CriticalSection_Delete(&p->cs); + CriticalSection_Delete(&p->mtProgress.cs); +} + + +SRes MtCoder_Code(CMtCoder *p) +{ + unsigned numThreads = p->numThreadsMax; + unsigned numBlocksMax; + unsigned i; + SRes res = SZ_OK; + + if (numThreads > MTCODER__THREADS_MAX) + numThreads = MTCODER__THREADS_MAX; + numBlocksMax = MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads); + + if (p->blockSize < ((UInt32)1 << 26)) numBlocksMax++; + if (p->blockSize < ((UInt32)1 << 24)) numBlocksMax++; + if (p->blockSize < ((UInt32)1 << 22)) numBlocksMax++; + + if (numBlocksMax > MTCODER__BLOCKS_MAX) + numBlocksMax = MTCODER__BLOCKS_MAX; + + if (p->blockSize != p->allocatedBufsSize) + { + for (i = 0; i < MTCODER__THREADS_MAX; i++) + { + CMtCoderThread *t = &p->threads[i]; + if (t->inBuf) + { + ISzAlloc_Free(p->allocBig, t->inBuf); + t->inBuf = NULL; + } + } + p->allocatedBufsSize = p->blockSize; + } + + p->readRes = SZ_OK; + + MtProgress_Init(&p->mtProgress, p->progress); + + #ifdef MTCODER__USE_WRITE_THREAD + for (i = 0; i < numBlocksMax; i++) + { + RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->writeEvents[i])); + } + #else + RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->finishedEvent)); + #endif + + { + RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->readEvent)); + RINOK_THREAD(Semaphore_OptCreateInit(&p->blocksSemaphore, numBlocksMax, numBlocksMax)); + } + + for (i = 0; i < MTCODER__BLOCKS_MAX - 1; i++) + p->freeBlockList[i] = i + 1; + p->freeBlockList[MTCODER__BLOCKS_MAX - 1] = (unsigned)(int)-1; + p->freeBlockHead = 0; + + p->readProcessed = 0; + p->blockIndex = 0; + p->numBlocksMax = numBlocksMax; + p->stopReading = False; + + #ifndef MTCODER__USE_WRITE_THREAD + p->writeIndex = 0; + p->writeRes = SZ_OK; + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + p->ReadyBlocks[i] = False; + p->numFinishedThreads = 0; + #endif + + p->numStartedThreadsLimit = numThreads; + p->numStartedThreads = 0; + + // for (i = 0; i < numThreads; i++) + { + CMtCoderThread *nextThread = &p->threads[p->numStartedThreads++]; + RINOK(MtCoderThread_CreateAndStart(nextThread)); + } + + RINOK_THREAD(Event_Set(&p->readEvent)) + + #ifdef MTCODER__USE_WRITE_THREAD + { + unsigned bi = 0; + + for (;; bi++) + { + if (bi >= numBlocksMax) + bi = 0; + + RINOK_THREAD(Event_Wait(&p->writeEvents[bi])) + + { + const CMtCoderBlock *block = &p->blocks[bi]; + unsigned bufIndex = block->bufIndex; + BoolInt finished = block->finished; + if (res == SZ_OK && block->res != SZ_OK) + res = block->res; + + if (bufIndex != (unsigned)(int)-1) + { + if (res == SZ_OK) + { + res = p->mtCallback->Write(p->mtCallbackObject, bufIndex); + if (res != SZ_OK) + MtProgress_SetError(&p->mtProgress, res); + } + + CriticalSection_Enter(&p->cs); + { + p->freeBlockList[bufIndex] = p->freeBlockHead; + p->freeBlockHead = bufIndex; + } + CriticalSection_Leave(&p->cs); + } + + RINOK_THREAD(Semaphore_Release1(&p->blocksSemaphore)) + + if (finished) + break; + } + } + } + #else + { + WRes wres = Event_Wait(&p->finishedEvent); + res = MY_SRes_HRESULT_FROM_WRes(wres); + } + #endif + + if (res == SZ_OK) + res = p->readRes; + + if (res == SZ_OK) + res = p->mtProgress.res; + + #ifndef MTCODER__USE_WRITE_THREAD + if (res == SZ_OK) + res = p->writeRes; + #endif + + if (res != SZ_OK) + MtCoder_Free(p); + return res; +} + +#endif diff --git a/deps/LZMA-SDK/C/MtCoder.h b/deps/LZMA-SDK/C/MtCoder.h index 603329d36..5a5f4d11b 100644 --- a/deps/LZMA-SDK/C/MtCoder.h +++ b/deps/LZMA-SDK/C/MtCoder.h @@ -1,141 +1,141 @@ -/* MtCoder.h -- Multi-thread Coder -2018-07-04 : Igor Pavlov : Public domain */ - -#ifndef __MT_CODER_H -#define __MT_CODER_H - -#include "MtDec.h" - -EXTERN_C_BEGIN - -/* - if ( defined MTCODER__USE_WRITE_THREAD) : main thread writes all data blocks to output stream - if (not defined MTCODER__USE_WRITE_THREAD) : any coder thread can write data blocks to output stream -*/ -/* #define MTCODER__USE_WRITE_THREAD */ - -#ifndef _7ZIP_ST - #define MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1) - #define MTCODER__THREADS_MAX 64 - #define MTCODER__BLOCKS_MAX (MTCODER__GET_NUM_BLOCKS_FROM_THREADS(MTCODER__THREADS_MAX) + 3) -#else - #define MTCODER__THREADS_MAX 1 - #define MTCODER__BLOCKS_MAX 1 -#endif - - -#ifndef _7ZIP_ST - - -typedef struct -{ - ICompressProgress vt; - CMtProgress *mtProgress; - UInt64 inSize; - UInt64 outSize; -} CMtProgressThunk; - -void MtProgressThunk_CreateVTable(CMtProgressThunk *p); - -#define MtProgressThunk_Init(p) { (p)->inSize = 0; (p)->outSize = 0; } - - -struct _CMtCoder; - - -typedef struct -{ - struct _CMtCoder *mtCoder; - unsigned index; - int stop; - Byte *inBuf; - - CAutoResetEvent startEvent; - CThread thread; -} CMtCoderThread; - - -typedef struct -{ - SRes (*Code)(void *p, unsigned coderIndex, unsigned outBufIndex, - const Byte *src, size_t srcSize, int finished); - SRes (*Write)(void *p, unsigned outBufIndex); -} IMtCoderCallback2; - - -typedef struct -{ - SRes res; - unsigned bufIndex; - BoolInt finished; -} CMtCoderBlock; - - -typedef struct _CMtCoder -{ - /* input variables */ - - size_t blockSize; /* size of input block */ - unsigned numThreadsMax; - UInt64 expectedDataSize; - - ISeqInStream *inStream; - const Byte *inData; - size_t inDataSize; - - ICompressProgress *progress; - ISzAllocPtr allocBig; - - IMtCoderCallback2 *mtCallback; - void *mtCallbackObject; - - - /* internal variables */ - - size_t allocatedBufsSize; - - CAutoResetEvent readEvent; - CSemaphore blocksSemaphore; - - BoolInt stopReading; - SRes readRes; - - #ifdef MTCODER__USE_WRITE_THREAD - CAutoResetEvent writeEvents[MTCODER__BLOCKS_MAX]; - #else - CAutoResetEvent finishedEvent; - SRes writeRes; - unsigned writeIndex; - Byte ReadyBlocks[MTCODER__BLOCKS_MAX]; - LONG numFinishedThreads; - #endif - - unsigned numStartedThreadsLimit; - unsigned numStartedThreads; - - unsigned numBlocksMax; - unsigned blockIndex; - UInt64 readProcessed; - - CCriticalSection cs; - - unsigned freeBlockHead; - unsigned freeBlockList[MTCODER__BLOCKS_MAX]; - - CMtProgress mtProgress; - CMtCoderBlock blocks[MTCODER__BLOCKS_MAX]; - CMtCoderThread threads[MTCODER__THREADS_MAX]; -} CMtCoder; - - -void MtCoder_Construct(CMtCoder *p); -void MtCoder_Destruct(CMtCoder *p); -SRes MtCoder_Code(CMtCoder *p); - - -#endif - - -EXTERN_C_END - -#endif +/* MtCoder.h -- Multi-thread Coder +2018-07-04 : Igor Pavlov : Public domain */ + +#ifndef __MT_CODER_H +#define __MT_CODER_H + +#include "MtDec.h" + +EXTERN_C_BEGIN + +/* + if ( defined MTCODER__USE_WRITE_THREAD) : main thread writes all data blocks to output stream + if (not defined MTCODER__USE_WRITE_THREAD) : any coder thread can write data blocks to output stream +*/ +/* #define MTCODER__USE_WRITE_THREAD */ + +#ifndef _7ZIP_ST + #define MTCODER__GET_NUM_BLOCKS_FROM_THREADS(numThreads) ((numThreads) + (numThreads) / 8 + 1) + #define MTCODER__THREADS_MAX 64 + #define MTCODER__BLOCKS_MAX (MTCODER__GET_NUM_BLOCKS_FROM_THREADS(MTCODER__THREADS_MAX) + 3) +#else + #define MTCODER__THREADS_MAX 1 + #define MTCODER__BLOCKS_MAX 1 +#endif + + +#ifndef _7ZIP_ST + + +typedef struct +{ + ICompressProgress vt; + CMtProgress *mtProgress; + UInt64 inSize; + UInt64 outSize; +} CMtProgressThunk; + +void MtProgressThunk_CreateVTable(CMtProgressThunk *p); + +#define MtProgressThunk_Init(p) { (p)->inSize = 0; (p)->outSize = 0; } + + +struct _CMtCoder; + + +typedef struct +{ + struct _CMtCoder *mtCoder; + unsigned index; + int stop; + Byte *inBuf; + + CAutoResetEvent startEvent; + CThread thread; +} CMtCoderThread; + + +typedef struct +{ + SRes (*Code)(void *p, unsigned coderIndex, unsigned outBufIndex, + const Byte *src, size_t srcSize, int finished); + SRes (*Write)(void *p, unsigned outBufIndex); +} IMtCoderCallback2; + + +typedef struct +{ + SRes res; + unsigned bufIndex; + BoolInt finished; +} CMtCoderBlock; + + +typedef struct _CMtCoder +{ + /* input variables */ + + size_t blockSize; /* size of input block */ + unsigned numThreadsMax; + UInt64 expectedDataSize; + + ISeqInStream *inStream; + const Byte *inData; + size_t inDataSize; + + ICompressProgress *progress; + ISzAllocPtr allocBig; + + IMtCoderCallback2 *mtCallback; + void *mtCallbackObject; + + + /* internal variables */ + + size_t allocatedBufsSize; + + CAutoResetEvent readEvent; + CSemaphore blocksSemaphore; + + BoolInt stopReading; + SRes readRes; + + #ifdef MTCODER__USE_WRITE_THREAD + CAutoResetEvent writeEvents[MTCODER__BLOCKS_MAX]; + #else + CAutoResetEvent finishedEvent; + SRes writeRes; + unsigned writeIndex; + Byte ReadyBlocks[MTCODER__BLOCKS_MAX]; + LONG numFinishedThreads; + #endif + + unsigned numStartedThreadsLimit; + unsigned numStartedThreads; + + unsigned numBlocksMax; + unsigned blockIndex; + UInt64 readProcessed; + + CCriticalSection cs; + + unsigned freeBlockHead; + unsigned freeBlockList[MTCODER__BLOCKS_MAX]; + + CMtProgress mtProgress; + CMtCoderBlock blocks[MTCODER__BLOCKS_MAX]; + CMtCoderThread threads[MTCODER__THREADS_MAX]; +} CMtCoder; + + +void MtCoder_Construct(CMtCoder *p); +void MtCoder_Destruct(CMtCoder *p); +SRes MtCoder_Code(CMtCoder *p); + + +#endif + + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/MtDec.c b/deps/LZMA-SDK/C/MtDec.c index 24441b3a7..45a671396 100644 --- a/deps/LZMA-SDK/C/MtDec.c +++ b/deps/LZMA-SDK/C/MtDec.c @@ -1,1139 +1,1139 @@ -/* MtDec.c -- Multi-thread Decoder -2021-02-27 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -// #define SHOW_DEBUG_INFO - -// #include -#include - -#ifdef SHOW_DEBUG_INFO -#include -#endif - -#include "MtDec.h" - -#ifndef _7ZIP_ST - -#ifdef SHOW_DEBUG_INFO -#define PRF(x) x -#else -#define PRF(x) -#endif - -#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) - -void MtProgress_Init(CMtProgress *p, ICompressProgress *progress) -{ - p->progress = progress; - p->res = SZ_OK; - p->totalInSize = 0; - p->totalOutSize = 0; -} - - -SRes MtProgress_Progress_ST(CMtProgress *p) -{ - if (p->res == SZ_OK && p->progress) - if (ICompressProgress_Progress(p->progress, p->totalInSize, p->totalOutSize) != SZ_OK) - p->res = SZ_ERROR_PROGRESS; - return p->res; -} - - -SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize) -{ - SRes res; - CriticalSection_Enter(&p->cs); - - p->totalInSize += inSize; - p->totalOutSize += outSize; - if (p->res == SZ_OK && p->progress) - if (ICompressProgress_Progress(p->progress, p->totalInSize, p->totalOutSize) != SZ_OK) - p->res = SZ_ERROR_PROGRESS; - res = p->res; - - CriticalSection_Leave(&p->cs); - return res; -} - - -SRes MtProgress_GetError(CMtProgress *p) -{ - SRes res; - CriticalSection_Enter(&p->cs); - res = p->res; - CriticalSection_Leave(&p->cs); - return res; -} - - -void MtProgress_SetError(CMtProgress *p, SRes res) -{ - CriticalSection_Enter(&p->cs); - if (p->res == SZ_OK) - p->res = res; - CriticalSection_Leave(&p->cs); -} - - -#define RINOK_THREAD(x) RINOK_WRes(x) - - -static WRes ArEvent_OptCreate_And_Reset(CEvent *p) -{ - if (Event_IsCreated(p)) - return Event_Reset(p); - return AutoResetEvent_CreateNotSignaled(p); -} - - -struct __CMtDecBufLink -{ - struct __CMtDecBufLink *next; - void *pad[3]; -}; - -typedef struct __CMtDecBufLink CMtDecBufLink; - -#define MTDEC__LINK_DATA_OFFSET sizeof(CMtDecBufLink) -#define MTDEC__DATA_PTR_FROM_LINK(link) ((Byte *)(link) + MTDEC__LINK_DATA_OFFSET) - - - -static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp); - - -static WRes MtDecThread_CreateEvents(CMtDecThread *t) -{ - WRes wres = ArEvent_OptCreate_And_Reset(&t->canWrite); - if (wres == 0) - { - wres = ArEvent_OptCreate_And_Reset(&t->canRead); - if (wres == 0) - return SZ_OK; - } - return wres; -} - - -static SRes MtDecThread_CreateAndStart(CMtDecThread *t) -{ - WRes wres = MtDecThread_CreateEvents(t); - // wres = 17; // for test - if (wres == 0) - { - if (Thread_WasCreated(&t->thread)) - return SZ_OK; - wres = Thread_Create(&t->thread, ThreadFunc, t); - if (wres == 0) - return SZ_OK; - } - return MY_SRes_HRESULT_FROM_WRes(wres); -} - - -void MtDecThread_FreeInBufs(CMtDecThread *t) -{ - if (t->inBuf) - { - void *link = t->inBuf; - t->inBuf = NULL; - do - { - void *next = ((CMtDecBufLink *)link)->next; - ISzAlloc_Free(t->mtDec->alloc, link); - link = next; - } - while (link); - } -} - - -static void MtDecThread_CloseThread(CMtDecThread *t) -{ - if (Thread_WasCreated(&t->thread)) - { - Event_Set(&t->canWrite); /* we can disable it. There are no threads waiting canWrite in normal cases */ - Event_Set(&t->canRead); - Thread_Wait_Close(&t->thread); - } - - Event_Close(&t->canRead); - Event_Close(&t->canWrite); -} - -static void MtDec_CloseThreads(CMtDec *p) -{ - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - MtDecThread_CloseThread(&p->threads[i]); -} - -static void MtDecThread_Destruct(CMtDecThread *t) -{ - MtDecThread_CloseThread(t); - MtDecThread_FreeInBufs(t); -} - - - -static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize) -{ - size_t size = *processedSize; - *processedSize = 0; - while (size != 0) - { - size_t cur = size; - SRes res = ISeqInStream_Read(stream, data, &cur); - *processedSize += cur; - data += cur; - size -= cur; - RINOK(res); - if (cur == 0) - return SZ_OK; - } - return SZ_OK; -} - - -static SRes MtDec_GetError_Spec(CMtDec *p, UInt64 interruptIndex, BoolInt *wasInterrupted) -{ - SRes res; - CriticalSection_Enter(&p->mtProgress.cs); - *wasInterrupted = (p->needInterrupt && interruptIndex > p->interruptIndex); - res = p->mtProgress.res; - CriticalSection_Leave(&p->mtProgress.cs); - return res; -} - -static SRes MtDec_Progress_GetError_Spec(CMtDec *p, UInt64 inSize, UInt64 outSize, UInt64 interruptIndex, BoolInt *wasInterrupted) -{ - SRes res; - CriticalSection_Enter(&p->mtProgress.cs); - - p->mtProgress.totalInSize += inSize; - p->mtProgress.totalOutSize += outSize; - if (p->mtProgress.res == SZ_OK && p->mtProgress.progress) - if (ICompressProgress_Progress(p->mtProgress.progress, p->mtProgress.totalInSize, p->mtProgress.totalOutSize) != SZ_OK) - p->mtProgress.res = SZ_ERROR_PROGRESS; - - *wasInterrupted = (p->needInterrupt && interruptIndex > p->interruptIndex); - res = p->mtProgress.res; - - CriticalSection_Leave(&p->mtProgress.cs); - - return res; -} - -static void MtDec_Interrupt(CMtDec *p, UInt64 interruptIndex) -{ - CriticalSection_Enter(&p->mtProgress.cs); - if (!p->needInterrupt || interruptIndex < p->interruptIndex) - { - p->interruptIndex = interruptIndex; - p->needInterrupt = True; - } - CriticalSection_Leave(&p->mtProgress.cs); -} - -Byte *MtDec_GetCrossBuff(CMtDec *p) -{ - Byte *cr = p->crossBlock; - if (!cr) - { - cr = (Byte *)ISzAlloc_Alloc(p->alloc, MTDEC__LINK_DATA_OFFSET + p->inBufSize); - if (!cr) - return NULL; - p->crossBlock = cr; - } - return MTDEC__DATA_PTR_FROM_LINK(cr); -} - - -/* - ThreadFunc2() returns: - 0 - in all normal cases (even for stream error or memory allocation error) - (!= 0) - WRes error return by system threading function -*/ - -// #define MTDEC_ProgessStep (1 << 22) -#define MTDEC_ProgessStep (1 << 0) - -static WRes ThreadFunc2(CMtDecThread *t) -{ - CMtDec *p = t->mtDec; - - PRF_STR_INT("ThreadFunc2", t->index); - - // SetThreadAffinityMask(GetCurrentThread(), 1 << t->index); - - for (;;) - { - SRes res, codeRes; - BoolInt wasInterrupted, isAllocError, overflow, finish; - SRes threadingErrorSRes; - BoolInt needCode, needWrite, needContinue; - - size_t inDataSize_Start; - UInt64 inDataSize; - // UInt64 inDataSize_Full; - - UInt64 blockIndex; - - UInt64 inPrev = 0; - UInt64 outPrev = 0; - UInt64 inCodePos; - UInt64 outCodePos; - - Byte *afterEndData = NULL; - size_t afterEndData_Size = 0; - BoolInt afterEndData_IsCross = False; - - BoolInt canCreateNewThread = False; - // CMtDecCallbackInfo parse; - CMtDecThread *nextThread; - - PRF_STR_INT("=============== Event_Wait(&t->canRead)", t->index); - - RINOK_THREAD(Event_Wait(&t->canRead)); - if (p->exitThread) - return 0; - - PRF_STR_INT("after Event_Wait(&t->canRead)", t->index); - - // if (t->index == 3) return 19; // for test - - blockIndex = p->blockIndex++; - - // PRF(printf("\ncanRead\n")) - - res = MtDec_Progress_GetError_Spec(p, 0, 0, blockIndex, &wasInterrupted); - - finish = p->readWasFinished; - needCode = False; - needWrite = False; - isAllocError = False; - overflow = False; - - inDataSize_Start = 0; - inDataSize = 0; - // inDataSize_Full = 0; - - if (res == SZ_OK && !wasInterrupted) - { - // if (p->inStream) - { - CMtDecBufLink *prev = NULL; - CMtDecBufLink *link = (CMtDecBufLink *)t->inBuf; - size_t crossSize = p->crossEnd - p->crossStart; - - PRF(printf("\ncrossSize = %d\n", crossSize)); - - for (;;) - { - if (!link) - { - link = (CMtDecBufLink *)ISzAlloc_Alloc(p->alloc, MTDEC__LINK_DATA_OFFSET + p->inBufSize); - if (!link) - { - finish = True; - // p->allocError_for_Read_BlockIndex = blockIndex; - isAllocError = True; - break; - } - link->next = NULL; - if (prev) - { - // static unsigned g_num = 0; - // printf("\n%6d : %x", ++g_num, (unsigned)(size_t)((Byte *)link - (Byte *)prev)); - prev->next = link; - } - else - t->inBuf = (void *)link; - } - - { - Byte *data = MTDEC__DATA_PTR_FROM_LINK(link); - Byte *parseData = data; - size_t size; - - if (crossSize != 0) - { - inDataSize = crossSize; - // inDataSize_Full = inDataSize; - inDataSize_Start = crossSize; - size = crossSize; - parseData = MTDEC__DATA_PTR_FROM_LINK(p->crossBlock) + p->crossStart; - PRF(printf("\ncross : crossStart = %7d crossEnd = %7d finish = %1d", - (int)p->crossStart, (int)p->crossEnd, (int)finish)); - } - else - { - size = p->inBufSize; - - res = FullRead(p->inStream, data, &size); - - // size = 10; // test - - inDataSize += size; - // inDataSize_Full = inDataSize; - if (!prev) - inDataSize_Start = size; - - p->readProcessed += size; - finish = (size != p->inBufSize); - if (finish) - p->readWasFinished = True; - - // res = E_INVALIDARG; // test - - if (res != SZ_OK) - { - // PRF(printf("\nRead error = %d\n", res)) - // we want to decode all data before error - p->readRes = res; - // p->readError_BlockIndex = blockIndex; - p->readWasFinished = True; - finish = True; - res = SZ_OK; - // break; - } - - if (inDataSize - inPrev >= MTDEC_ProgessStep) - { - res = MtDec_Progress_GetError_Spec(p, 0, 0, blockIndex, &wasInterrupted); - if (res != SZ_OK || wasInterrupted) - break; - inPrev = inDataSize; - } - } - - { - CMtDecCallbackInfo parse; - - parse.startCall = (prev == NULL); - parse.src = parseData; - parse.srcSize = size; - parse.srcFinished = finish; - parse.canCreateNewThread = True; - - PRF(printf("\nParse size = %d\n", (unsigned)size)); - - p->mtCallback->Parse(p->mtCallbackObject, t->index, &parse); - - PRF(printf(" Parse processed = %d, state = %d \n", (unsigned)parse.srcSize, (unsigned)parse.state)); - - needWrite = True; - canCreateNewThread = parse.canCreateNewThread; - - // printf("\n\n%12I64u %12I64u", (UInt64)p->mtProgress.totalInSize, (UInt64)p->mtProgress.totalOutSize); - - if ( - // parseRes != SZ_OK || - // inDataSize - (size - parse.srcSize) > p->inBlockMax - // || - parse.state == MTDEC_PARSE_OVERFLOW - // || wasInterrupted - ) - { - // Overflow or Parse error - switch from MT decoding to ST decoding - finish = True; - overflow = True; - - { - PRF(printf("\n Overflow")); - // PRF(printf("\nisBlockFinished = %d", (unsigned)parse.blockWasFinished)); - PRF(printf("\n inDataSize = %d", (unsigned)inDataSize)); - } - - if (crossSize != 0) - memcpy(data, parseData, size); - p->crossStart = 0; - p->crossEnd = 0; - break; - } - - if (crossSize != 0) - { - memcpy(data, parseData, parse.srcSize); - p->crossStart += parse.srcSize; - } - - if (parse.state != MTDEC_PARSE_CONTINUE || finish) - { - // we don't need to parse in current thread anymore - - if (parse.state == MTDEC_PARSE_END) - finish = True; - - needCode = True; - // p->crossFinished = finish; - - if (parse.srcSize == size) - { - // full parsed - no cross transfer - p->crossStart = 0; - p->crossEnd = 0; - break; - } - - if (parse.state == MTDEC_PARSE_END) - { - afterEndData = parseData + parse.srcSize; - afterEndData_Size = size - parse.srcSize; - if (crossSize != 0) - afterEndData_IsCross = True; - // we reduce data size to required bytes (parsed only) - inDataSize -= afterEndData_Size; - if (!prev) - inDataSize_Start = parse.srcSize; - break; - } - - { - // partial parsed - need cross transfer - if (crossSize != 0) - inDataSize = parse.srcSize; // it's only parsed now - else - { - // partial parsed - is not in initial cross block - we need to copy new data to cross block - Byte *cr = MtDec_GetCrossBuff(p); - if (!cr) - { - { - PRF(printf("\ncross alloc error error\n")); - // res = SZ_ERROR_MEM; - finish = True; - // p->allocError_for_Read_BlockIndex = blockIndex; - isAllocError = True; - break; - } - } - - { - size_t crSize = size - parse.srcSize; - inDataSize -= crSize; - p->crossEnd = crSize; - p->crossStart = 0; - memcpy(cr, parseData + parse.srcSize, crSize); - } - } - - // inDataSize_Full = inDataSize; - if (!prev) - inDataSize_Start = parse.srcSize; // it's partial size (parsed only) - - finish = False; - break; - } - } - - if (parse.srcSize != size) - { - res = SZ_ERROR_FAIL; - PRF(printf("\nfinished error SZ_ERROR_FAIL = %d\n", res)); - break; - } - } - } - - prev = link; - link = link->next; - - if (crossSize != 0) - { - crossSize = 0; - p->crossStart = 0; - p->crossEnd = 0; - } - } - } - - if (res == SZ_OK) - res = MtDec_GetError_Spec(p, blockIndex, &wasInterrupted); - } - - codeRes = SZ_OK; - - if (res == SZ_OK && needCode && !wasInterrupted) - { - codeRes = p->mtCallback->PreCode(p->mtCallbackObject, t->index); - if (codeRes != SZ_OK) - { - needCode = False; - finish = True; - // SZ_ERROR_MEM is expected error here. - // if (codeRes == SZ_ERROR_MEM) - we will try single-thread decoding later. - // if (codeRes != SZ_ERROR_MEM) - we can stop decoding or try single-thread decoding. - } - } - - if (res != SZ_OK || wasInterrupted) - finish = True; - - nextThread = NULL; - threadingErrorSRes = SZ_OK; - - if (!finish) - { - if (p->numStartedThreads < p->numStartedThreads_Limit && canCreateNewThread) - { - SRes res2 = MtDecThread_CreateAndStart(&p->threads[p->numStartedThreads]); - if (res2 == SZ_OK) - { - // if (p->numStartedThreads % 1000 == 0) PRF(printf("\n numStartedThreads=%d\n", p->numStartedThreads)); - p->numStartedThreads++; - } - else - { - PRF(printf("\nERROR: numStartedThreads=%d\n", p->numStartedThreads)); - if (p->numStartedThreads == 1) - { - // if only one thread is possible, we leave muti-threading code - finish = True; - needCode = False; - threadingErrorSRes = res2; - } - else - p->numStartedThreads_Limit = p->numStartedThreads; - } - } - - if (!finish) - { - unsigned nextIndex = t->index + 1; - nextThread = &p->threads[nextIndex >= p->numStartedThreads ? 0 : nextIndex]; - RINOK_THREAD(Event_Set(&nextThread->canRead)) - // We have started executing for new iteration (with next thread) - // And that next thread now is responsible for possible exit from decoding (threading_code) - } - } - - // each call of Event_Set(&nextThread->canRead) must be followed by call of Event_Set(&nextThread->canWrite) - // if ( !finish ) we must call Event_Set(&nextThread->canWrite) in any case - // if ( finish ) we switch to single-thread mode and there are 2 ways at the end of current iteration (current block): - // - if (needContinue) after Write(&needContinue), we restore decoding with new iteration - // - otherwise we stop decoding and exit from ThreadFunc2() - - // Don't change (finish) variable in the further code - - - // ---------- CODE ---------- - - inPrev = 0; - outPrev = 0; - inCodePos = 0; - outCodePos = 0; - - if (res == SZ_OK && needCode && codeRes == SZ_OK) - { - BoolInt isStartBlock = True; - CMtDecBufLink *link = (CMtDecBufLink *)t->inBuf; - - for (;;) - { - size_t inSize; - int stop; - - if (isStartBlock) - inSize = inDataSize_Start; - else - { - UInt64 rem = inDataSize - inCodePos; - inSize = p->inBufSize; - if (inSize > rem) - inSize = (size_t)rem; - } - - inCodePos += inSize; - stop = True; - - codeRes = p->mtCallback->Code(p->mtCallbackObject, t->index, - (const Byte *)MTDEC__DATA_PTR_FROM_LINK(link), inSize, - (inCodePos == inDataSize), // srcFinished - &inCodePos, &outCodePos, &stop); - - if (codeRes != SZ_OK) - { - PRF(printf("\nCode Interrupt error = %x\n", codeRes)); - // we interrupt only later blocks - MtDec_Interrupt(p, blockIndex); - break; - } - - if (stop || inCodePos == inDataSize) - break; - - { - const UInt64 inDelta = inCodePos - inPrev; - const UInt64 outDelta = outCodePos - outPrev; - if (inDelta >= MTDEC_ProgessStep || outDelta >= MTDEC_ProgessStep) - { - // Sleep(1); - res = MtDec_Progress_GetError_Spec(p, inDelta, outDelta, blockIndex, &wasInterrupted); - if (res != SZ_OK || wasInterrupted) - break; - inPrev = inCodePos; - outPrev = outCodePos; - } - } - - link = link->next; - isStartBlock = False; - } - } - - - // ---------- WRITE ---------- - - RINOK_THREAD(Event_Wait(&t->canWrite)); - - { - BoolInt isErrorMode = False; - BoolInt canRecode = True; - BoolInt needWriteToStream = needWrite; - - if (p->exitThread) return 0; // it's never executed in normal cases - - if (p->wasInterrupted) - wasInterrupted = True; - else - { - if (codeRes != SZ_OK) // || !needCode // check it !!! - { - p->wasInterrupted = True; - p->codeRes = codeRes; - if (codeRes == SZ_ERROR_MEM) - isAllocError = True; - } - - if (threadingErrorSRes) - { - p->wasInterrupted = True; - p->threadingErrorSRes = threadingErrorSRes; - needWriteToStream = False; - } - if (isAllocError) - { - p->wasInterrupted = True; - p->isAllocError = True; - needWriteToStream = False; - } - if (overflow) - { - p->wasInterrupted = True; - p->overflow = True; - needWriteToStream = False; - } - } - - if (needCode) - { - if (wasInterrupted) - { - inCodePos = 0; - outCodePos = 0; - } - { - const UInt64 inDelta = inCodePos - inPrev; - const UInt64 outDelta = outCodePos - outPrev; - // if (inDelta != 0 || outDelta != 0) - res = MtProgress_ProgressAdd(&p->mtProgress, inDelta, outDelta); - } - } - - needContinue = (!finish); - - // if (res == SZ_OK && needWrite && !wasInterrupted) - if (needWrite) - { - // p->inProcessed += inCodePos; - - PRF(printf("\n--Write afterSize = %d\n", (unsigned)afterEndData_Size)); - - res = p->mtCallback->Write(p->mtCallbackObject, t->index, - res == SZ_OK && needWriteToStream && !wasInterrupted, // needWrite - afterEndData, afterEndData_Size, afterEndData_IsCross, - &needContinue, - &canRecode); - - // res = SZ_ERROR_FAIL; // for test - - PRF(printf("\nAfter Write needContinue = %d\n", (unsigned)needContinue)); - PRF(printf("\nprocessed = %d\n", (unsigned)p->inProcessed)); - - if (res != SZ_OK) - { - PRF(printf("\nWrite error = %d\n", res)); - isErrorMode = True; - p->wasInterrupted = True; - } - if (res != SZ_OK - || (!needContinue && !finish)) - { - PRF(printf("\nWrite Interrupt error = %x\n", res)); - MtDec_Interrupt(p, blockIndex); - } - } - - if (canRecode) - if (!needCode - || res != SZ_OK - || p->wasInterrupted - || codeRes != SZ_OK - || wasInterrupted - || p->numFilledThreads != 0 - || isErrorMode) - { - if (p->numFilledThreads == 0) - p->filledThreadStart = t->index; - if (inDataSize != 0 || !finish) - { - t->inDataSize_Start = inDataSize_Start; - t->inDataSize = inDataSize; - p->numFilledThreads++; - } - PRF(printf("\np->numFilledThreads = %d\n", p->numFilledThreads)); - PRF(printf("p->filledThreadStart = %d\n", p->filledThreadStart)); - } - - if (!finish) - { - RINOK_THREAD(Event_Set(&nextThread->canWrite)); - } - else - { - if (needContinue) - { - // we restore decoding with new iteration - RINOK_THREAD(Event_Set(&p->threads[0].canWrite)); - } - else - { - // we exit from decoding - if (t->index == 0) - return SZ_OK; - p->exitThread = True; - } - RINOK_THREAD(Event_Set(&p->threads[0].canRead)); - } - } - } -} - -#ifdef _WIN32 -#define USE_ALLOCA -#endif - -#ifdef USE_ALLOCA -#ifdef _WIN32 -#include -#else -#include -#endif -#endif - - -static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc1(void *pp) -{ - WRes res; - - CMtDecThread *t = (CMtDecThread *)pp; - CMtDec *p; - - // fprintf(stdout, "\n%d = %p\n", t->index, &t); - - res = ThreadFunc2(t); - p = t->mtDec; - if (res == 0) - return (THREAD_FUNC_RET_TYPE)(UINT_PTR)p->exitThreadWRes; - { - // it's unexpected situation for some threading function error - if (p->exitThreadWRes == 0) - p->exitThreadWRes = res; - PRF(printf("\nthread exit error = %d\n", res)); - p->exitThread = True; - Event_Set(&p->threads[0].canRead); - Event_Set(&p->threads[0].canWrite); - MtProgress_SetError(&p->mtProgress, MY_SRes_HRESULT_FROM_WRes(res)); - } - return (THREAD_FUNC_RET_TYPE)(UINT_PTR)res; -} - -static MY_NO_INLINE THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE ThreadFunc(void *pp) -{ - #ifdef USE_ALLOCA - CMtDecThread *t = (CMtDecThread *)pp; - // fprintf(stderr, "\n%d = %p - before", t->index, &t); - t->allocaPtr = alloca(t->index * 128); - #endif - return ThreadFunc1(pp); -} - - -int MtDec_PrepareRead(CMtDec *p) -{ - if (p->crossBlock && p->crossStart == p->crossEnd) - { - ISzAlloc_Free(p->alloc, p->crossBlock); - p->crossBlock = NULL; - } - - { - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - if (i > p->numStartedThreads - || p->numFilledThreads <= - (i >= p->filledThreadStart ? - i - p->filledThreadStart : - i + p->numStartedThreads - p->filledThreadStart)) - MtDecThread_FreeInBufs(&p->threads[i]); - } - - return (p->numFilledThreads != 0) || (p->crossStart != p->crossEnd); -} - - -const Byte *MtDec_Read(CMtDec *p, size_t *inLim) -{ - while (p->numFilledThreads != 0) - { - CMtDecThread *t = &p->threads[p->filledThreadStart]; - - if (*inLim != 0) - { - { - void *link = t->inBuf; - void *next = ((CMtDecBufLink *)link)->next; - ISzAlloc_Free(p->alloc, link); - t->inBuf = next; - } - - if (t->inDataSize == 0) - { - MtDecThread_FreeInBufs(t); - if (--p->numFilledThreads == 0) - break; - if (++p->filledThreadStart == p->numStartedThreads) - p->filledThreadStart = 0; - t = &p->threads[p->filledThreadStart]; - } - } - - { - size_t lim = t->inDataSize_Start; - if (lim != 0) - t->inDataSize_Start = 0; - else - { - UInt64 rem = t->inDataSize; - lim = p->inBufSize; - if (lim > rem) - lim = (size_t)rem; - } - t->inDataSize -= lim; - *inLim = lim; - return (const Byte *)MTDEC__DATA_PTR_FROM_LINK(t->inBuf); - } - } - - { - size_t crossSize = p->crossEnd - p->crossStart; - if (crossSize != 0) - { - const Byte *data = MTDEC__DATA_PTR_FROM_LINK(p->crossBlock) + p->crossStart; - *inLim = crossSize; - p->crossStart = 0; - p->crossEnd = 0; - return data; - } - *inLim = 0; - if (p->crossBlock) - { - ISzAlloc_Free(p->alloc, p->crossBlock); - p->crossBlock = NULL; - } - return NULL; - } -} - - -void MtDec_Construct(CMtDec *p) -{ - unsigned i; - - p->inBufSize = (size_t)1 << 18; - - p->numThreadsMax = 0; - - p->inStream = NULL; - - // p->inData = NULL; - // p->inDataSize = 0; - - p->crossBlock = NULL; - p->crossStart = 0; - p->crossEnd = 0; - - p->numFilledThreads = 0; - - p->progress = NULL; - p->alloc = NULL; - - p->mtCallback = NULL; - p->mtCallbackObject = NULL; - - p->allocatedBufsSize = 0; - - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CMtDecThread *t = &p->threads[i]; - t->mtDec = p; - t->index = i; - t->inBuf = NULL; - Event_Construct(&t->canRead); - Event_Construct(&t->canWrite); - Thread_Construct(&t->thread); - } - - // Event_Construct(&p->finishedEvent); - - CriticalSection_Init(&p->mtProgress.cs); -} - - -static void MtDec_Free(CMtDec *p) -{ - unsigned i; - - p->exitThread = True; - - for (i = 0; i < MTDEC__THREADS_MAX; i++) - MtDecThread_Destruct(&p->threads[i]); - - // Event_Close(&p->finishedEvent); - - if (p->crossBlock) - { - ISzAlloc_Free(p->alloc, p->crossBlock); - p->crossBlock = NULL; - } -} - - -void MtDec_Destruct(CMtDec *p) -{ - MtDec_Free(p); - - CriticalSection_Delete(&p->mtProgress.cs); -} - - -SRes MtDec_Code(CMtDec *p) -{ - unsigned i; - - p->inProcessed = 0; - - p->blockIndex = 1; // it must be larger than not_defined index (0) - p->isAllocError = False; - p->overflow = False; - p->threadingErrorSRes = SZ_OK; - - p->needContinue = True; - - p->readWasFinished = False; - p->needInterrupt = False; - p->interruptIndex = (UInt64)(Int64)-1; - - p->readProcessed = 0; - p->readRes = SZ_OK; - p->codeRes = SZ_OK; - p->wasInterrupted = False; - - p->crossStart = 0; - p->crossEnd = 0; - - p->filledThreadStart = 0; - p->numFilledThreads = 0; - - { - unsigned numThreads = p->numThreadsMax; - if (numThreads > MTDEC__THREADS_MAX) - numThreads = MTDEC__THREADS_MAX; - p->numStartedThreads_Limit = numThreads; - p->numStartedThreads = 0; - } - - if (p->inBufSize != p->allocatedBufsSize) - { - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CMtDecThread *t = &p->threads[i]; - if (t->inBuf) - MtDecThread_FreeInBufs(t); - } - if (p->crossBlock) - { - ISzAlloc_Free(p->alloc, p->crossBlock); - p->crossBlock = NULL; - } - - p->allocatedBufsSize = p->inBufSize; - } - - MtProgress_Init(&p->mtProgress, p->progress); - - // RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->finishedEvent)); - p->exitThread = False; - p->exitThreadWRes = 0; - - { - WRes wres; - SRes sres; - CMtDecThread *nextThread = &p->threads[p->numStartedThreads++]; - // wres = MtDecThread_CreateAndStart(nextThread); - wres = MtDecThread_CreateEvents(nextThread); - if (wres == 0) { wres = Event_Set(&nextThread->canWrite); - if (wres == 0) { wres = Event_Set(&nextThread->canRead); - if (wres == 0) { THREAD_FUNC_RET_TYPE res = ThreadFunc(nextThread); - wres = (WRes)(UINT_PTR)res; - if (wres != 0) - { - p->needContinue = False; - MtDec_CloseThreads(p); - }}}} - - // wres = 17; // for test - // wres = Event_Wait(&p->finishedEvent); - - sres = MY_SRes_HRESULT_FROM_WRes(wres); - - if (sres != 0) - p->threadingErrorSRes = sres; - - if ( - // wres == 0 - // wres != 0 - // || p->mtc.codeRes == SZ_ERROR_MEM - p->isAllocError - || p->threadingErrorSRes != SZ_OK - || p->overflow) - { - // p->needContinue = True; - } - else - p->needContinue = False; - - if (p->needContinue) - return SZ_OK; - - // if (sres != SZ_OK) - return sres; - // return SZ_ERROR_FAIL; - } -} - -#endif +/* MtDec.c -- Multi-thread Decoder +2021-12-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +// #define SHOW_DEBUG_INFO + +// #include +#include + +#ifdef SHOW_DEBUG_INFO +#include +#endif + +#include "MtDec.h" + +#ifndef _7ZIP_ST + +#ifdef SHOW_DEBUG_INFO +#define PRF(x) x +#else +#define PRF(x) +#endif + +#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) + +void MtProgress_Init(CMtProgress *p, ICompressProgress *progress) +{ + p->progress = progress; + p->res = SZ_OK; + p->totalInSize = 0; + p->totalOutSize = 0; +} + + +SRes MtProgress_Progress_ST(CMtProgress *p) +{ + if (p->res == SZ_OK && p->progress) + if (ICompressProgress_Progress(p->progress, p->totalInSize, p->totalOutSize) != SZ_OK) + p->res = SZ_ERROR_PROGRESS; + return p->res; +} + + +SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize) +{ + SRes res; + CriticalSection_Enter(&p->cs); + + p->totalInSize += inSize; + p->totalOutSize += outSize; + if (p->res == SZ_OK && p->progress) + if (ICompressProgress_Progress(p->progress, p->totalInSize, p->totalOutSize) != SZ_OK) + p->res = SZ_ERROR_PROGRESS; + res = p->res; + + CriticalSection_Leave(&p->cs); + return res; +} + + +SRes MtProgress_GetError(CMtProgress *p) +{ + SRes res; + CriticalSection_Enter(&p->cs); + res = p->res; + CriticalSection_Leave(&p->cs); + return res; +} + + +void MtProgress_SetError(CMtProgress *p, SRes res) +{ + CriticalSection_Enter(&p->cs); + if (p->res == SZ_OK) + p->res = res; + CriticalSection_Leave(&p->cs); +} + + +#define RINOK_THREAD(x) RINOK_WRes(x) + + +static WRes ArEvent_OptCreate_And_Reset(CEvent *p) +{ + if (Event_IsCreated(p)) + return Event_Reset(p); + return AutoResetEvent_CreateNotSignaled(p); +} + + +struct __CMtDecBufLink +{ + struct __CMtDecBufLink *next; + void *pad[3]; +}; + +typedef struct __CMtDecBufLink CMtDecBufLink; + +#define MTDEC__LINK_DATA_OFFSET sizeof(CMtDecBufLink) +#define MTDEC__DATA_PTR_FROM_LINK(link) ((Byte *)(link) + MTDEC__LINK_DATA_OFFSET) + + + +static THREAD_FUNC_DECL ThreadFunc(void *pp); + + +static WRes MtDecThread_CreateEvents(CMtDecThread *t) +{ + WRes wres = ArEvent_OptCreate_And_Reset(&t->canWrite); + if (wres == 0) + { + wres = ArEvent_OptCreate_And_Reset(&t->canRead); + if (wres == 0) + return SZ_OK; + } + return wres; +} + + +static SRes MtDecThread_CreateAndStart(CMtDecThread *t) +{ + WRes wres = MtDecThread_CreateEvents(t); + // wres = 17; // for test + if (wres == 0) + { + if (Thread_WasCreated(&t->thread)) + return SZ_OK; + wres = Thread_Create(&t->thread, ThreadFunc, t); + if (wres == 0) + return SZ_OK; + } + return MY_SRes_HRESULT_FROM_WRes(wres); +} + + +void MtDecThread_FreeInBufs(CMtDecThread *t) +{ + if (t->inBuf) + { + void *link = t->inBuf; + t->inBuf = NULL; + do + { + void *next = ((CMtDecBufLink *)link)->next; + ISzAlloc_Free(t->mtDec->alloc, link); + link = next; + } + while (link); + } +} + + +static void MtDecThread_CloseThread(CMtDecThread *t) +{ + if (Thread_WasCreated(&t->thread)) + { + Event_Set(&t->canWrite); /* we can disable it. There are no threads waiting canWrite in normal cases */ + Event_Set(&t->canRead); + Thread_Wait_Close(&t->thread); + } + + Event_Close(&t->canRead); + Event_Close(&t->canWrite); +} + +static void MtDec_CloseThreads(CMtDec *p) +{ + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + MtDecThread_CloseThread(&p->threads[i]); +} + +static void MtDecThread_Destruct(CMtDecThread *t) +{ + MtDecThread_CloseThread(t); + MtDecThread_FreeInBufs(t); +} + + + +static SRes FullRead(ISeqInStream *stream, Byte *data, size_t *processedSize) +{ + size_t size = *processedSize; + *processedSize = 0; + while (size != 0) + { + size_t cur = size; + SRes res = ISeqInStream_Read(stream, data, &cur); + *processedSize += cur; + data += cur; + size -= cur; + RINOK(res); + if (cur == 0) + return SZ_OK; + } + return SZ_OK; +} + + +static SRes MtDec_GetError_Spec(CMtDec *p, UInt64 interruptIndex, BoolInt *wasInterrupted) +{ + SRes res; + CriticalSection_Enter(&p->mtProgress.cs); + *wasInterrupted = (p->needInterrupt && interruptIndex > p->interruptIndex); + res = p->mtProgress.res; + CriticalSection_Leave(&p->mtProgress.cs); + return res; +} + +static SRes MtDec_Progress_GetError_Spec(CMtDec *p, UInt64 inSize, UInt64 outSize, UInt64 interruptIndex, BoolInt *wasInterrupted) +{ + SRes res; + CriticalSection_Enter(&p->mtProgress.cs); + + p->mtProgress.totalInSize += inSize; + p->mtProgress.totalOutSize += outSize; + if (p->mtProgress.res == SZ_OK && p->mtProgress.progress) + if (ICompressProgress_Progress(p->mtProgress.progress, p->mtProgress.totalInSize, p->mtProgress.totalOutSize) != SZ_OK) + p->mtProgress.res = SZ_ERROR_PROGRESS; + + *wasInterrupted = (p->needInterrupt && interruptIndex > p->interruptIndex); + res = p->mtProgress.res; + + CriticalSection_Leave(&p->mtProgress.cs); + + return res; +} + +static void MtDec_Interrupt(CMtDec *p, UInt64 interruptIndex) +{ + CriticalSection_Enter(&p->mtProgress.cs); + if (!p->needInterrupt || interruptIndex < p->interruptIndex) + { + p->interruptIndex = interruptIndex; + p->needInterrupt = True; + } + CriticalSection_Leave(&p->mtProgress.cs); +} + +Byte *MtDec_GetCrossBuff(CMtDec *p) +{ + Byte *cr = p->crossBlock; + if (!cr) + { + cr = (Byte *)ISzAlloc_Alloc(p->alloc, MTDEC__LINK_DATA_OFFSET + p->inBufSize); + if (!cr) + return NULL; + p->crossBlock = cr; + } + return MTDEC__DATA_PTR_FROM_LINK(cr); +} + + +/* + ThreadFunc2() returns: + 0 - in all normal cases (even for stream error or memory allocation error) + (!= 0) - WRes error return by system threading function +*/ + +// #define MTDEC_ProgessStep (1 << 22) +#define MTDEC_ProgessStep (1 << 0) + +static WRes ThreadFunc2(CMtDecThread *t) +{ + CMtDec *p = t->mtDec; + + PRF_STR_INT("ThreadFunc2", t->index); + + // SetThreadAffinityMask(GetCurrentThread(), 1 << t->index); + + for (;;) + { + SRes res, codeRes; + BoolInt wasInterrupted, isAllocError, overflow, finish; + SRes threadingErrorSRes; + BoolInt needCode, needWrite, needContinue; + + size_t inDataSize_Start; + UInt64 inDataSize; + // UInt64 inDataSize_Full; + + UInt64 blockIndex; + + UInt64 inPrev = 0; + UInt64 outPrev = 0; + UInt64 inCodePos; + UInt64 outCodePos; + + Byte *afterEndData = NULL; + size_t afterEndData_Size = 0; + BoolInt afterEndData_IsCross = False; + + BoolInt canCreateNewThread = False; + // CMtDecCallbackInfo parse; + CMtDecThread *nextThread; + + PRF_STR_INT("=============== Event_Wait(&t->canRead)", t->index); + + RINOK_THREAD(Event_Wait(&t->canRead)); + if (p->exitThread) + return 0; + + PRF_STR_INT("after Event_Wait(&t->canRead)", t->index); + + // if (t->index == 3) return 19; // for test + + blockIndex = p->blockIndex++; + + // PRF(printf("\ncanRead\n")) + + res = MtDec_Progress_GetError_Spec(p, 0, 0, blockIndex, &wasInterrupted); + + finish = p->readWasFinished; + needCode = False; + needWrite = False; + isAllocError = False; + overflow = False; + + inDataSize_Start = 0; + inDataSize = 0; + // inDataSize_Full = 0; + + if (res == SZ_OK && !wasInterrupted) + { + // if (p->inStream) + { + CMtDecBufLink *prev = NULL; + CMtDecBufLink *link = (CMtDecBufLink *)t->inBuf; + size_t crossSize = p->crossEnd - p->crossStart; + + PRF(printf("\ncrossSize = %d\n", crossSize)); + + for (;;) + { + if (!link) + { + link = (CMtDecBufLink *)ISzAlloc_Alloc(p->alloc, MTDEC__LINK_DATA_OFFSET + p->inBufSize); + if (!link) + { + finish = True; + // p->allocError_for_Read_BlockIndex = blockIndex; + isAllocError = True; + break; + } + link->next = NULL; + if (prev) + { + // static unsigned g_num = 0; + // printf("\n%6d : %x", ++g_num, (unsigned)(size_t)((Byte *)link - (Byte *)prev)); + prev->next = link; + } + else + t->inBuf = (void *)link; + } + + { + Byte *data = MTDEC__DATA_PTR_FROM_LINK(link); + Byte *parseData = data; + size_t size; + + if (crossSize != 0) + { + inDataSize = crossSize; + // inDataSize_Full = inDataSize; + inDataSize_Start = crossSize; + size = crossSize; + parseData = MTDEC__DATA_PTR_FROM_LINK(p->crossBlock) + p->crossStart; + PRF(printf("\ncross : crossStart = %7d crossEnd = %7d finish = %1d", + (int)p->crossStart, (int)p->crossEnd, (int)finish)); + } + else + { + size = p->inBufSize; + + res = FullRead(p->inStream, data, &size); + + // size = 10; // test + + inDataSize += size; + // inDataSize_Full = inDataSize; + if (!prev) + inDataSize_Start = size; + + p->readProcessed += size; + finish = (size != p->inBufSize); + if (finish) + p->readWasFinished = True; + + // res = E_INVALIDARG; // test + + if (res != SZ_OK) + { + // PRF(printf("\nRead error = %d\n", res)) + // we want to decode all data before error + p->readRes = res; + // p->readError_BlockIndex = blockIndex; + p->readWasFinished = True; + finish = True; + res = SZ_OK; + // break; + } + + if (inDataSize - inPrev >= MTDEC_ProgessStep) + { + res = MtDec_Progress_GetError_Spec(p, 0, 0, blockIndex, &wasInterrupted); + if (res != SZ_OK || wasInterrupted) + break; + inPrev = inDataSize; + } + } + + { + CMtDecCallbackInfo parse; + + parse.startCall = (prev == NULL); + parse.src = parseData; + parse.srcSize = size; + parse.srcFinished = finish; + parse.canCreateNewThread = True; + + PRF(printf("\nParse size = %d\n", (unsigned)size)); + + p->mtCallback->Parse(p->mtCallbackObject, t->index, &parse); + + PRF(printf(" Parse processed = %d, state = %d \n", (unsigned)parse.srcSize, (unsigned)parse.state)); + + needWrite = True; + canCreateNewThread = parse.canCreateNewThread; + + // printf("\n\n%12I64u %12I64u", (UInt64)p->mtProgress.totalInSize, (UInt64)p->mtProgress.totalOutSize); + + if ( + // parseRes != SZ_OK || + // inDataSize - (size - parse.srcSize) > p->inBlockMax + // || + parse.state == MTDEC_PARSE_OVERFLOW + // || wasInterrupted + ) + { + // Overflow or Parse error - switch from MT decoding to ST decoding + finish = True; + overflow = True; + + { + PRF(printf("\n Overflow")); + // PRF(printf("\nisBlockFinished = %d", (unsigned)parse.blockWasFinished)); + PRF(printf("\n inDataSize = %d", (unsigned)inDataSize)); + } + + if (crossSize != 0) + memcpy(data, parseData, size); + p->crossStart = 0; + p->crossEnd = 0; + break; + } + + if (crossSize != 0) + { + memcpy(data, parseData, parse.srcSize); + p->crossStart += parse.srcSize; + } + + if (parse.state != MTDEC_PARSE_CONTINUE || finish) + { + // we don't need to parse in current thread anymore + + if (parse.state == MTDEC_PARSE_END) + finish = True; + + needCode = True; + // p->crossFinished = finish; + + if (parse.srcSize == size) + { + // full parsed - no cross transfer + p->crossStart = 0; + p->crossEnd = 0; + break; + } + + if (parse.state == MTDEC_PARSE_END) + { + afterEndData = parseData + parse.srcSize; + afterEndData_Size = size - parse.srcSize; + if (crossSize != 0) + afterEndData_IsCross = True; + // we reduce data size to required bytes (parsed only) + inDataSize -= afterEndData_Size; + if (!prev) + inDataSize_Start = parse.srcSize; + break; + } + + { + // partial parsed - need cross transfer + if (crossSize != 0) + inDataSize = parse.srcSize; // it's only parsed now + else + { + // partial parsed - is not in initial cross block - we need to copy new data to cross block + Byte *cr = MtDec_GetCrossBuff(p); + if (!cr) + { + { + PRF(printf("\ncross alloc error error\n")); + // res = SZ_ERROR_MEM; + finish = True; + // p->allocError_for_Read_BlockIndex = blockIndex; + isAllocError = True; + break; + } + } + + { + size_t crSize = size - parse.srcSize; + inDataSize -= crSize; + p->crossEnd = crSize; + p->crossStart = 0; + memcpy(cr, parseData + parse.srcSize, crSize); + } + } + + // inDataSize_Full = inDataSize; + if (!prev) + inDataSize_Start = parse.srcSize; // it's partial size (parsed only) + + finish = False; + break; + } + } + + if (parse.srcSize != size) + { + res = SZ_ERROR_FAIL; + PRF(printf("\nfinished error SZ_ERROR_FAIL = %d\n", res)); + break; + } + } + } + + prev = link; + link = link->next; + + if (crossSize != 0) + { + crossSize = 0; + p->crossStart = 0; + p->crossEnd = 0; + } + } + } + + if (res == SZ_OK) + res = MtDec_GetError_Spec(p, blockIndex, &wasInterrupted); + } + + codeRes = SZ_OK; + + if (res == SZ_OK && needCode && !wasInterrupted) + { + codeRes = p->mtCallback->PreCode(p->mtCallbackObject, t->index); + if (codeRes != SZ_OK) + { + needCode = False; + finish = True; + // SZ_ERROR_MEM is expected error here. + // if (codeRes == SZ_ERROR_MEM) - we will try single-thread decoding later. + // if (codeRes != SZ_ERROR_MEM) - we can stop decoding or try single-thread decoding. + } + } + + if (res != SZ_OK || wasInterrupted) + finish = True; + + nextThread = NULL; + threadingErrorSRes = SZ_OK; + + if (!finish) + { + if (p->numStartedThreads < p->numStartedThreads_Limit && canCreateNewThread) + { + SRes res2 = MtDecThread_CreateAndStart(&p->threads[p->numStartedThreads]); + if (res2 == SZ_OK) + { + // if (p->numStartedThreads % 1000 == 0) PRF(printf("\n numStartedThreads=%d\n", p->numStartedThreads)); + p->numStartedThreads++; + } + else + { + PRF(printf("\nERROR: numStartedThreads=%d\n", p->numStartedThreads)); + if (p->numStartedThreads == 1) + { + // if only one thread is possible, we leave muti-threading code + finish = True; + needCode = False; + threadingErrorSRes = res2; + } + else + p->numStartedThreads_Limit = p->numStartedThreads; + } + } + + if (!finish) + { + unsigned nextIndex = t->index + 1; + nextThread = &p->threads[nextIndex >= p->numStartedThreads ? 0 : nextIndex]; + RINOK_THREAD(Event_Set(&nextThread->canRead)) + // We have started executing for new iteration (with next thread) + // And that next thread now is responsible for possible exit from decoding (threading_code) + } + } + + // each call of Event_Set(&nextThread->canRead) must be followed by call of Event_Set(&nextThread->canWrite) + // if ( !finish ) we must call Event_Set(&nextThread->canWrite) in any case + // if ( finish ) we switch to single-thread mode and there are 2 ways at the end of current iteration (current block): + // - if (needContinue) after Write(&needContinue), we restore decoding with new iteration + // - otherwise we stop decoding and exit from ThreadFunc2() + + // Don't change (finish) variable in the further code + + + // ---------- CODE ---------- + + inPrev = 0; + outPrev = 0; + inCodePos = 0; + outCodePos = 0; + + if (res == SZ_OK && needCode && codeRes == SZ_OK) + { + BoolInt isStartBlock = True; + CMtDecBufLink *link = (CMtDecBufLink *)t->inBuf; + + for (;;) + { + size_t inSize; + int stop; + + if (isStartBlock) + inSize = inDataSize_Start; + else + { + UInt64 rem = inDataSize - inCodePos; + inSize = p->inBufSize; + if (inSize > rem) + inSize = (size_t)rem; + } + + inCodePos += inSize; + stop = True; + + codeRes = p->mtCallback->Code(p->mtCallbackObject, t->index, + (const Byte *)MTDEC__DATA_PTR_FROM_LINK(link), inSize, + (inCodePos == inDataSize), // srcFinished + &inCodePos, &outCodePos, &stop); + + if (codeRes != SZ_OK) + { + PRF(printf("\nCode Interrupt error = %x\n", codeRes)); + // we interrupt only later blocks + MtDec_Interrupt(p, blockIndex); + break; + } + + if (stop || inCodePos == inDataSize) + break; + + { + const UInt64 inDelta = inCodePos - inPrev; + const UInt64 outDelta = outCodePos - outPrev; + if (inDelta >= MTDEC_ProgessStep || outDelta >= MTDEC_ProgessStep) + { + // Sleep(1); + res = MtDec_Progress_GetError_Spec(p, inDelta, outDelta, blockIndex, &wasInterrupted); + if (res != SZ_OK || wasInterrupted) + break; + inPrev = inCodePos; + outPrev = outCodePos; + } + } + + link = link->next; + isStartBlock = False; + } + } + + + // ---------- WRITE ---------- + + RINOK_THREAD(Event_Wait(&t->canWrite)); + + { + BoolInt isErrorMode = False; + BoolInt canRecode = True; + BoolInt needWriteToStream = needWrite; + + if (p->exitThread) return 0; // it's never executed in normal cases + + if (p->wasInterrupted) + wasInterrupted = True; + else + { + if (codeRes != SZ_OK) // || !needCode // check it !!! + { + p->wasInterrupted = True; + p->codeRes = codeRes; + if (codeRes == SZ_ERROR_MEM) + isAllocError = True; + } + + if (threadingErrorSRes) + { + p->wasInterrupted = True; + p->threadingErrorSRes = threadingErrorSRes; + needWriteToStream = False; + } + if (isAllocError) + { + p->wasInterrupted = True; + p->isAllocError = True; + needWriteToStream = False; + } + if (overflow) + { + p->wasInterrupted = True; + p->overflow = True; + needWriteToStream = False; + } + } + + if (needCode) + { + if (wasInterrupted) + { + inCodePos = 0; + outCodePos = 0; + } + { + const UInt64 inDelta = inCodePos - inPrev; + const UInt64 outDelta = outCodePos - outPrev; + // if (inDelta != 0 || outDelta != 0) + res = MtProgress_ProgressAdd(&p->mtProgress, inDelta, outDelta); + } + } + + needContinue = (!finish); + + // if (res == SZ_OK && needWrite && !wasInterrupted) + if (needWrite) + { + // p->inProcessed += inCodePos; + + PRF(printf("\n--Write afterSize = %d\n", (unsigned)afterEndData_Size)); + + res = p->mtCallback->Write(p->mtCallbackObject, t->index, + res == SZ_OK && needWriteToStream && !wasInterrupted, // needWrite + afterEndData, afterEndData_Size, afterEndData_IsCross, + &needContinue, + &canRecode); + + // res = SZ_ERROR_FAIL; // for test + + PRF(printf("\nAfter Write needContinue = %d\n", (unsigned)needContinue)); + PRF(printf("\nprocessed = %d\n", (unsigned)p->inProcessed)); + + if (res != SZ_OK) + { + PRF(printf("\nWrite error = %d\n", res)); + isErrorMode = True; + p->wasInterrupted = True; + } + if (res != SZ_OK + || (!needContinue && !finish)) + { + PRF(printf("\nWrite Interrupt error = %x\n", res)); + MtDec_Interrupt(p, blockIndex); + } + } + + if (canRecode) + if (!needCode + || res != SZ_OK + || p->wasInterrupted + || codeRes != SZ_OK + || wasInterrupted + || p->numFilledThreads != 0 + || isErrorMode) + { + if (p->numFilledThreads == 0) + p->filledThreadStart = t->index; + if (inDataSize != 0 || !finish) + { + t->inDataSize_Start = inDataSize_Start; + t->inDataSize = inDataSize; + p->numFilledThreads++; + } + PRF(printf("\np->numFilledThreads = %d\n", p->numFilledThreads)); + PRF(printf("p->filledThreadStart = %d\n", p->filledThreadStart)); + } + + if (!finish) + { + RINOK_THREAD(Event_Set(&nextThread->canWrite)); + } + else + { + if (needContinue) + { + // we restore decoding with new iteration + RINOK_THREAD(Event_Set(&p->threads[0].canWrite)); + } + else + { + // we exit from decoding + if (t->index == 0) + return SZ_OK; + p->exitThread = True; + } + RINOK_THREAD(Event_Set(&p->threads[0].canRead)); + } + } + } +} + +#ifdef _WIN32 +#define USE_ALLOCA +#endif + +#ifdef USE_ALLOCA +#ifdef _WIN32 +#include +#else +#include +#endif +#endif + + +static THREAD_FUNC_DECL ThreadFunc1(void *pp) +{ + WRes res; + + CMtDecThread *t = (CMtDecThread *)pp; + CMtDec *p; + + // fprintf(stdout, "\n%d = %p\n", t->index, &t); + + res = ThreadFunc2(t); + p = t->mtDec; + if (res == 0) + return (THREAD_FUNC_RET_TYPE)(UINT_PTR)p->exitThreadWRes; + { + // it's unexpected situation for some threading function error + if (p->exitThreadWRes == 0) + p->exitThreadWRes = res; + PRF(printf("\nthread exit error = %d\n", res)); + p->exitThread = True; + Event_Set(&p->threads[0].canRead); + Event_Set(&p->threads[0].canWrite); + MtProgress_SetError(&p->mtProgress, MY_SRes_HRESULT_FROM_WRes(res)); + } + return (THREAD_FUNC_RET_TYPE)(UINT_PTR)res; +} + +static MY_NO_INLINE THREAD_FUNC_DECL ThreadFunc(void *pp) +{ + #ifdef USE_ALLOCA + CMtDecThread *t = (CMtDecThread *)pp; + // fprintf(stderr, "\n%d = %p - before", t->index, &t); + t->allocaPtr = alloca(t->index * 128); + #endif + return ThreadFunc1(pp); +} + + +int MtDec_PrepareRead(CMtDec *p) +{ + if (p->crossBlock && p->crossStart == p->crossEnd) + { + ISzAlloc_Free(p->alloc, p->crossBlock); + p->crossBlock = NULL; + } + + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + if (i > p->numStartedThreads + || p->numFilledThreads <= + (i >= p->filledThreadStart ? + i - p->filledThreadStart : + i + p->numStartedThreads - p->filledThreadStart)) + MtDecThread_FreeInBufs(&p->threads[i]); + } + + return (p->numFilledThreads != 0) || (p->crossStart != p->crossEnd); +} + + +const Byte *MtDec_Read(CMtDec *p, size_t *inLim) +{ + while (p->numFilledThreads != 0) + { + CMtDecThread *t = &p->threads[p->filledThreadStart]; + + if (*inLim != 0) + { + { + void *link = t->inBuf; + void *next = ((CMtDecBufLink *)link)->next; + ISzAlloc_Free(p->alloc, link); + t->inBuf = next; + } + + if (t->inDataSize == 0) + { + MtDecThread_FreeInBufs(t); + if (--p->numFilledThreads == 0) + break; + if (++p->filledThreadStart == p->numStartedThreads) + p->filledThreadStart = 0; + t = &p->threads[p->filledThreadStart]; + } + } + + { + size_t lim = t->inDataSize_Start; + if (lim != 0) + t->inDataSize_Start = 0; + else + { + UInt64 rem = t->inDataSize; + lim = p->inBufSize; + if (lim > rem) + lim = (size_t)rem; + } + t->inDataSize -= lim; + *inLim = lim; + return (const Byte *)MTDEC__DATA_PTR_FROM_LINK(t->inBuf); + } + } + + { + size_t crossSize = p->crossEnd - p->crossStart; + if (crossSize != 0) + { + const Byte *data = MTDEC__DATA_PTR_FROM_LINK(p->crossBlock) + p->crossStart; + *inLim = crossSize; + p->crossStart = 0; + p->crossEnd = 0; + return data; + } + *inLim = 0; + if (p->crossBlock) + { + ISzAlloc_Free(p->alloc, p->crossBlock); + p->crossBlock = NULL; + } + return NULL; + } +} + + +void MtDec_Construct(CMtDec *p) +{ + unsigned i; + + p->inBufSize = (size_t)1 << 18; + + p->numThreadsMax = 0; + + p->inStream = NULL; + + // p->inData = NULL; + // p->inDataSize = 0; + + p->crossBlock = NULL; + p->crossStart = 0; + p->crossEnd = 0; + + p->numFilledThreads = 0; + + p->progress = NULL; + p->alloc = NULL; + + p->mtCallback = NULL; + p->mtCallbackObject = NULL; + + p->allocatedBufsSize = 0; + + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CMtDecThread *t = &p->threads[i]; + t->mtDec = p; + t->index = i; + t->inBuf = NULL; + Event_Construct(&t->canRead); + Event_Construct(&t->canWrite); + Thread_Construct(&t->thread); + } + + // Event_Construct(&p->finishedEvent); + + CriticalSection_Init(&p->mtProgress.cs); +} + + +static void MtDec_Free(CMtDec *p) +{ + unsigned i; + + p->exitThread = True; + + for (i = 0; i < MTDEC__THREADS_MAX; i++) + MtDecThread_Destruct(&p->threads[i]); + + // Event_Close(&p->finishedEvent); + + if (p->crossBlock) + { + ISzAlloc_Free(p->alloc, p->crossBlock); + p->crossBlock = NULL; + } +} + + +void MtDec_Destruct(CMtDec *p) +{ + MtDec_Free(p); + + CriticalSection_Delete(&p->mtProgress.cs); +} + + +SRes MtDec_Code(CMtDec *p) +{ + unsigned i; + + p->inProcessed = 0; + + p->blockIndex = 1; // it must be larger than not_defined index (0) + p->isAllocError = False; + p->overflow = False; + p->threadingErrorSRes = SZ_OK; + + p->needContinue = True; + + p->readWasFinished = False; + p->needInterrupt = False; + p->interruptIndex = (UInt64)(Int64)-1; + + p->readProcessed = 0; + p->readRes = SZ_OK; + p->codeRes = SZ_OK; + p->wasInterrupted = False; + + p->crossStart = 0; + p->crossEnd = 0; + + p->filledThreadStart = 0; + p->numFilledThreads = 0; + + { + unsigned numThreads = p->numThreadsMax; + if (numThreads > MTDEC__THREADS_MAX) + numThreads = MTDEC__THREADS_MAX; + p->numStartedThreads_Limit = numThreads; + p->numStartedThreads = 0; + } + + if (p->inBufSize != p->allocatedBufsSize) + { + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CMtDecThread *t = &p->threads[i]; + if (t->inBuf) + MtDecThread_FreeInBufs(t); + } + if (p->crossBlock) + { + ISzAlloc_Free(p->alloc, p->crossBlock); + p->crossBlock = NULL; + } + + p->allocatedBufsSize = p->inBufSize; + } + + MtProgress_Init(&p->mtProgress, p->progress); + + // RINOK_THREAD(ArEvent_OptCreate_And_Reset(&p->finishedEvent)); + p->exitThread = False; + p->exitThreadWRes = 0; + + { + WRes wres; + SRes sres; + CMtDecThread *nextThread = &p->threads[p->numStartedThreads++]; + // wres = MtDecThread_CreateAndStart(nextThread); + wres = MtDecThread_CreateEvents(nextThread); + if (wres == 0) { wres = Event_Set(&nextThread->canWrite); + if (wres == 0) { wres = Event_Set(&nextThread->canRead); + if (wres == 0) { THREAD_FUNC_RET_TYPE res = ThreadFunc(nextThread); + wres = (WRes)(UINT_PTR)res; + if (wres != 0) + { + p->needContinue = False; + MtDec_CloseThreads(p); + }}}} + + // wres = 17; // for test + // wres = Event_Wait(&p->finishedEvent); + + sres = MY_SRes_HRESULT_FROM_WRes(wres); + + if (sres != 0) + p->threadingErrorSRes = sres; + + if ( + // wres == 0 + // wres != 0 + // || p->mtc.codeRes == SZ_ERROR_MEM + p->isAllocError + || p->threadingErrorSRes != SZ_OK + || p->overflow) + { + // p->needContinue = True; + } + else + p->needContinue = False; + + if (p->needContinue) + return SZ_OK; + + // if (sres != SZ_OK) + return sres; + // return SZ_ERROR_FAIL; + } +} + +#endif diff --git a/deps/LZMA-SDK/C/MtDec.h b/deps/LZMA-SDK/C/MtDec.h index 7a30b6a9e..c2da46ae2 100644 --- a/deps/LZMA-SDK/C/MtDec.h +++ b/deps/LZMA-SDK/C/MtDec.h @@ -1,202 +1,202 @@ -/* MtDec.h -- Multi-thread Decoder -2020-03-05 : Igor Pavlov : Public domain */ - -#ifndef __MT_DEC_H -#define __MT_DEC_H - -#include "7zTypes.h" - -#ifndef _7ZIP_ST -#include "Threads.h" -#endif - -EXTERN_C_BEGIN - -#ifndef _7ZIP_ST - -#ifndef _7ZIP_ST - #define MTDEC__THREADS_MAX 32 -#else - #define MTDEC__THREADS_MAX 1 -#endif - - -typedef struct -{ - ICompressProgress *progress; - SRes res; - UInt64 totalInSize; - UInt64 totalOutSize; - CCriticalSection cs; -} CMtProgress; - -void MtProgress_Init(CMtProgress *p, ICompressProgress *progress); -SRes MtProgress_Progress_ST(CMtProgress *p); -SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize); -SRes MtProgress_GetError(CMtProgress *p); -void MtProgress_SetError(CMtProgress *p, SRes res); - -struct _CMtDec; - -typedef struct -{ - struct _CMtDec *mtDec; - unsigned index; - void *inBuf; - - size_t inDataSize_Start; // size of input data in start block - UInt64 inDataSize; // total size of input data in all blocks - - CThread thread; - CAutoResetEvent canRead; - CAutoResetEvent canWrite; - void *allocaPtr; -} CMtDecThread; - -void MtDecThread_FreeInBufs(CMtDecThread *t); - - -typedef enum -{ - MTDEC_PARSE_CONTINUE, // continue this block with more input data - MTDEC_PARSE_OVERFLOW, // MT buffers overflow, need switch to single-thread - MTDEC_PARSE_NEW, // new block - MTDEC_PARSE_END // end of block threading. But we still can return to threading after Write(&needContinue) -} EMtDecParseState; - -typedef struct -{ - // in - int startCall; - const Byte *src; - size_t srcSize; - // in : (srcSize == 0) is allowed - // out : it's allowed to return less that actually was used ? - int srcFinished; - - // out - EMtDecParseState state; - BoolInt canCreateNewThread; - UInt64 outPos; // check it (size_t) -} CMtDecCallbackInfo; - - -typedef struct -{ - void (*Parse)(void *p, unsigned coderIndex, CMtDecCallbackInfo *ci); - - // PreCode() and Code(): - // (SRes_return_result != SZ_OK) means stop decoding, no need another blocks - SRes (*PreCode)(void *p, unsigned coderIndex); - SRes (*Code)(void *p, unsigned coderIndex, - const Byte *src, size_t srcSize, int srcFinished, - UInt64 *inCodePos, UInt64 *outCodePos, int *stop); - // stop - means stop another Code calls - - - /* Write() must be called, if Parse() was called - set (needWrite) if - { - && (was not interrupted by progress) - && (was not interrupted in previous block) - } - - out: - if (*needContinue), decoder still need to continue decoding with new iteration, - even after MTDEC_PARSE_END - if (*canRecode), we didn't flush current block data, so we still can decode current block later. - */ - SRes (*Write)(void *p, unsigned coderIndex, - BoolInt needWriteToStream, - const Byte *src, size_t srcSize, BoolInt isCross, - // int srcFinished, - BoolInt *needContinue, - BoolInt *canRecode); - -} IMtDecCallback2; - - - -typedef struct _CMtDec -{ - /* input variables */ - - size_t inBufSize; /* size of input block */ - unsigned numThreadsMax; - // size_t inBlockMax; - unsigned numThreadsMax_2; - - ISeqInStream *inStream; - // const Byte *inData; - // size_t inDataSize; - - ICompressProgress *progress; - ISzAllocPtr alloc; - - IMtDecCallback2 *mtCallback; - void *mtCallbackObject; - - - /* internal variables */ - - size_t allocatedBufsSize; - - BoolInt exitThread; - WRes exitThreadWRes; - - UInt64 blockIndex; - BoolInt isAllocError; - BoolInt overflow; - SRes threadingErrorSRes; - - BoolInt needContinue; - - // CAutoResetEvent finishedEvent; - - SRes readRes; - SRes codeRes; - - BoolInt wasInterrupted; - - unsigned numStartedThreads_Limit; - unsigned numStartedThreads; - - Byte *crossBlock; - size_t crossStart; - size_t crossEnd; - UInt64 readProcessed; - BoolInt readWasFinished; - UInt64 inProcessed; - - unsigned filledThreadStart; - unsigned numFilledThreads; - - #ifndef _7ZIP_ST - BoolInt needInterrupt; - UInt64 interruptIndex; - CMtProgress mtProgress; - CMtDecThread threads[MTDEC__THREADS_MAX]; - #endif -} CMtDec; - - -void MtDec_Construct(CMtDec *p); -void MtDec_Destruct(CMtDec *p); - -/* -MtDec_Code() returns: - SZ_OK - in most cases - MY_SRes_HRESULT_FROM_WRes(WRes_error) - in case of unexpected error in threading function -*/ - -SRes MtDec_Code(CMtDec *p); -Byte *MtDec_GetCrossBuff(CMtDec *p); - -int MtDec_PrepareRead(CMtDec *p); -const Byte *MtDec_Read(CMtDec *p, size_t *inLim); - -#endif - -EXTERN_C_END - -#endif +/* MtDec.h -- Multi-thread Decoder +2020-03-05 : Igor Pavlov : Public domain */ + +#ifndef __MT_DEC_H +#define __MT_DEC_H + +#include "7zTypes.h" + +#ifndef _7ZIP_ST +#include "Threads.h" +#endif + +EXTERN_C_BEGIN + +#ifndef _7ZIP_ST + +#ifndef _7ZIP_ST + #define MTDEC__THREADS_MAX 32 +#else + #define MTDEC__THREADS_MAX 1 +#endif + + +typedef struct +{ + ICompressProgress *progress; + SRes res; + UInt64 totalInSize; + UInt64 totalOutSize; + CCriticalSection cs; +} CMtProgress; + +void MtProgress_Init(CMtProgress *p, ICompressProgress *progress); +SRes MtProgress_Progress_ST(CMtProgress *p); +SRes MtProgress_ProgressAdd(CMtProgress *p, UInt64 inSize, UInt64 outSize); +SRes MtProgress_GetError(CMtProgress *p); +void MtProgress_SetError(CMtProgress *p, SRes res); + +struct _CMtDec; + +typedef struct +{ + struct _CMtDec *mtDec; + unsigned index; + void *inBuf; + + size_t inDataSize_Start; // size of input data in start block + UInt64 inDataSize; // total size of input data in all blocks + + CThread thread; + CAutoResetEvent canRead; + CAutoResetEvent canWrite; + void *allocaPtr; +} CMtDecThread; + +void MtDecThread_FreeInBufs(CMtDecThread *t); + + +typedef enum +{ + MTDEC_PARSE_CONTINUE, // continue this block with more input data + MTDEC_PARSE_OVERFLOW, // MT buffers overflow, need switch to single-thread + MTDEC_PARSE_NEW, // new block + MTDEC_PARSE_END // end of block threading. But we still can return to threading after Write(&needContinue) +} EMtDecParseState; + +typedef struct +{ + // in + int startCall; + const Byte *src; + size_t srcSize; + // in : (srcSize == 0) is allowed + // out : it's allowed to return less that actually was used ? + int srcFinished; + + // out + EMtDecParseState state; + BoolInt canCreateNewThread; + UInt64 outPos; // check it (size_t) +} CMtDecCallbackInfo; + + +typedef struct +{ + void (*Parse)(void *p, unsigned coderIndex, CMtDecCallbackInfo *ci); + + // PreCode() and Code(): + // (SRes_return_result != SZ_OK) means stop decoding, no need another blocks + SRes (*PreCode)(void *p, unsigned coderIndex); + SRes (*Code)(void *p, unsigned coderIndex, + const Byte *src, size_t srcSize, int srcFinished, + UInt64 *inCodePos, UInt64 *outCodePos, int *stop); + // stop - means stop another Code calls + + + /* Write() must be called, if Parse() was called + set (needWrite) if + { + && (was not interrupted by progress) + && (was not interrupted in previous block) + } + + out: + if (*needContinue), decoder still need to continue decoding with new iteration, + even after MTDEC_PARSE_END + if (*canRecode), we didn't flush current block data, so we still can decode current block later. + */ + SRes (*Write)(void *p, unsigned coderIndex, + BoolInt needWriteToStream, + const Byte *src, size_t srcSize, BoolInt isCross, + // int srcFinished, + BoolInt *needContinue, + BoolInt *canRecode); + +} IMtDecCallback2; + + + +typedef struct _CMtDec +{ + /* input variables */ + + size_t inBufSize; /* size of input block */ + unsigned numThreadsMax; + // size_t inBlockMax; + unsigned numThreadsMax_2; + + ISeqInStream *inStream; + // const Byte *inData; + // size_t inDataSize; + + ICompressProgress *progress; + ISzAllocPtr alloc; + + IMtDecCallback2 *mtCallback; + void *mtCallbackObject; + + + /* internal variables */ + + size_t allocatedBufsSize; + + BoolInt exitThread; + WRes exitThreadWRes; + + UInt64 blockIndex; + BoolInt isAllocError; + BoolInt overflow; + SRes threadingErrorSRes; + + BoolInt needContinue; + + // CAutoResetEvent finishedEvent; + + SRes readRes; + SRes codeRes; + + BoolInt wasInterrupted; + + unsigned numStartedThreads_Limit; + unsigned numStartedThreads; + + Byte *crossBlock; + size_t crossStart; + size_t crossEnd; + UInt64 readProcessed; + BoolInt readWasFinished; + UInt64 inProcessed; + + unsigned filledThreadStart; + unsigned numFilledThreads; + + #ifndef _7ZIP_ST + BoolInt needInterrupt; + UInt64 interruptIndex; + CMtProgress mtProgress; + CMtDecThread threads[MTDEC__THREADS_MAX]; + #endif +} CMtDec; + + +void MtDec_Construct(CMtDec *p); +void MtDec_Destruct(CMtDec *p); + +/* +MtDec_Code() returns: + SZ_OK - in most cases + MY_SRes_HRESULT_FROM_WRes(WRes_error) - in case of unexpected error in threading function +*/ + +SRes MtDec_Code(CMtDec *p); +Byte *MtDec_GetCrossBuff(CMtDec *p); + +int MtDec_PrepareRead(CMtDec *p); +const Byte *MtDec_Read(CMtDec *p, size_t *inLim); + +#endif + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Ppmd.h b/deps/LZMA-SDK/C/Ppmd.h index ee93ecece..b19879208 100644 --- a/deps/LZMA-SDK/C/Ppmd.h +++ b/deps/LZMA-SDK/C/Ppmd.h @@ -1,167 +1,167 @@ -/* Ppmd.h -- PPMD codec common code -2021-04-13 : Igor Pavlov : Public domain -This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ - -#ifndef __PPMD_H -#define __PPMD_H - -#include "CpuArch.h" - -EXTERN_C_BEGIN - -#if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4) -/* - PPMD code always uses 32-bit internal fields in PPMD structures to store internal references in main block. - if (PPMD_32BIT is defined), the PPMD code stores internal pointers to 32-bit reference fields. - if (PPMD_32BIT is NOT defined), the PPMD code stores internal UInt32 offsets to reference fields. - if (pointer size is 64-bit), then (PPMD_32BIT) mode is not allowed, - if (pointer size is 32-bit), then (PPMD_32BIT) mode is optional, - and it's allowed to disable PPMD_32BIT mode even if pointer is 32-bit. - PPMD code works slightly faster in (PPMD_32BIT) mode. -*/ - #define PPMD_32BIT -#endif - -#define PPMD_INT_BITS 7 -#define PPMD_PERIOD_BITS 7 -#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) - -#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) -#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) -#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) -#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) - -#define PPMD_N1 4 -#define PPMD_N2 4 -#define PPMD_N3 4 -#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) -#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) - -MY_CPU_pragma_pack_push_1 -/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ - -/* SEE-contexts for PPM-contexts with masked symbols */ -typedef struct -{ - UInt16 Summ; /* Freq */ - Byte Shift; /* Speed of Freq change; low Shift is for fast change */ - Byte Count; /* Count to next change of Shift */ -} CPpmd_See; - -#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ - { (p)->Summ = (UInt16)((p)->Summ << 1); (p)->Count = (Byte)(3 << (p)->Shift++); } - - -typedef struct -{ - Byte Symbol; - Byte Freq; - UInt16 Successor_0; - UInt16 Successor_1; -} CPpmd_State; - -typedef struct CPpmd_State2_ -{ - Byte Symbol; - Byte Freq; -} CPpmd_State2; - -typedef struct CPpmd_State4_ -{ - UInt16 Successor_0; - UInt16 Successor_1; -} CPpmd_State4; - -MY_CPU_pragma_pop - -/* - PPMD code can write full CPpmd_State structure data to CPpmd*_Context - at (byte offset = 2) instead of some fields of original CPpmd*_Context structure. - - If we use pointers to different types, but that point to shared - memory space, we can have aliasing problem (strict aliasing). - - XLC compiler in -O2 mode can change the order of memory write instructions - in relation to read instructions, if we have use pointers to different types. - - To solve that aliasing problem we use combined CPpmd*_Context structure - with unions that contain the fields from both structures: - the original CPpmd*_Context and CPpmd_State. - So we can access the fields from both structures via one pointer, - and the compiler doesn't change the order of write instructions - in relation to read instructions. - - If we don't use memory write instructions to shared memory in - some local code, and we use only reading instructions (read only), - then probably it's safe to use pointers to different types for reading. -*/ - - - -#ifdef PPMD_32BIT - - #define Ppmd_Ref_Type(type) type * - #define Ppmd_GetRef(p, ptr) (ptr) - #define Ppmd_GetPtr(p, ptr) (ptr) - #define Ppmd_GetPtr_Type(p, ptr, note_type) (ptr) - -#else - - #define Ppmd_Ref_Type(type) UInt32 - #define Ppmd_GetRef(p, ptr) ((UInt32)((Byte *)(ptr) - (p)->Base)) - #define Ppmd_GetPtr(p, offs) ((void *)((p)->Base + (offs))) - #define Ppmd_GetPtr_Type(p, offs, type) ((type *)Ppmd_GetPtr(p, offs)) - -#endif // PPMD_32BIT - - -typedef Ppmd_Ref_Type(CPpmd_State) CPpmd_State_Ref; -typedef Ppmd_Ref_Type(void) CPpmd_Void_Ref; -typedef Ppmd_Ref_Type(Byte) CPpmd_Byte_Ref; - - -/* -#ifdef MY_CPU_LE_UNALIGN -// the unaligned 32-bit access latency can be too large, if the data is not in L1 cache. -#define Ppmd_GET_SUCCESSOR(p) ((CPpmd_Void_Ref)*(const UInt32 *)(const void *)&(p)->Successor_0) -#define Ppmd_SET_SUCCESSOR(p, v) *(UInt32 *)(void *)(void *)&(p)->Successor_0 = (UInt32)(v) - -#else -*/ - -/* - We can write 16-bit halves to 32-bit (Successor) field in any selected order. - But the native order is more consistent way. - So we use the native order, if LE/BE order can be detected here at compile time. -*/ - -#ifdef MY_CPU_BE - - #define Ppmd_GET_SUCCESSOR(p) \ - ( (CPpmd_Void_Ref) (((UInt32)(p)->Successor_0 << 16) | (p)->Successor_1) ) - - #define Ppmd_SET_SUCCESSOR(p, v) { \ - (p)->Successor_0 = (UInt16)(((UInt32)(v) >> 16) /* & 0xFFFF */); \ - (p)->Successor_1 = (UInt16)((UInt32)(v) /* & 0xFFFF */); } - -#else - - #define Ppmd_GET_SUCCESSOR(p) \ - ( (CPpmd_Void_Ref) ((p)->Successor_0 | ((UInt32)(p)->Successor_1 << 16)) ) - - #define Ppmd_SET_SUCCESSOR(p, v) { \ - (p)->Successor_0 = (UInt16)((UInt32)(v) /* & 0xFFFF */); \ - (p)->Successor_1 = (UInt16)(((UInt32)(v) >> 16) /* & 0xFFFF */); } - -#endif - -// #endif - - -#define PPMD_SetAllBitsIn256Bytes(p) \ - { size_t z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \ - p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }} - -EXTERN_C_END - -#endif +/* Ppmd.h -- PPMD codec common code +2021-04-13 : Igor Pavlov : Public domain +This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ + +#ifndef __PPMD_H +#define __PPMD_H + +#include "CpuArch.h" + +EXTERN_C_BEGIN + +#if defined(MY_CPU_SIZEOF_POINTER) && (MY_CPU_SIZEOF_POINTER == 4) +/* + PPMD code always uses 32-bit internal fields in PPMD structures to store internal references in main block. + if (PPMD_32BIT is defined), the PPMD code stores internal pointers to 32-bit reference fields. + if (PPMD_32BIT is NOT defined), the PPMD code stores internal UInt32 offsets to reference fields. + if (pointer size is 64-bit), then (PPMD_32BIT) mode is not allowed, + if (pointer size is 32-bit), then (PPMD_32BIT) mode is optional, + and it's allowed to disable PPMD_32BIT mode even if pointer is 32-bit. + PPMD code works slightly faster in (PPMD_32BIT) mode. +*/ + #define PPMD_32BIT +#endif + +#define PPMD_INT_BITS 7 +#define PPMD_PERIOD_BITS 7 +#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) + +#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) +#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) +#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) +#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) + +#define PPMD_N1 4 +#define PPMD_N2 4 +#define PPMD_N3 4 +#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) +#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) + +MY_CPU_pragma_pack_push_1 +/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ + +/* SEE-contexts for PPM-contexts with masked symbols */ +typedef struct +{ + UInt16 Summ; /* Freq */ + Byte Shift; /* Speed of Freq change; low Shift is for fast change */ + Byte Count; /* Count to next change of Shift */ +} CPpmd_See; + +#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ + { (p)->Summ = (UInt16)((p)->Summ << 1); (p)->Count = (Byte)(3 << (p)->Shift++); } + + +typedef struct +{ + Byte Symbol; + Byte Freq; + UInt16 Successor_0; + UInt16 Successor_1; +} CPpmd_State; + +typedef struct CPpmd_State2_ +{ + Byte Symbol; + Byte Freq; +} CPpmd_State2; + +typedef struct CPpmd_State4_ +{ + UInt16 Successor_0; + UInt16 Successor_1; +} CPpmd_State4; + +MY_CPU_pragma_pop + +/* + PPMD code can write full CPpmd_State structure data to CPpmd*_Context + at (byte offset = 2) instead of some fields of original CPpmd*_Context structure. + + If we use pointers to different types, but that point to shared + memory space, we can have aliasing problem (strict aliasing). + + XLC compiler in -O2 mode can change the order of memory write instructions + in relation to read instructions, if we have use pointers to different types. + + To solve that aliasing problem we use combined CPpmd*_Context structure + with unions that contain the fields from both structures: + the original CPpmd*_Context and CPpmd_State. + So we can access the fields from both structures via one pointer, + and the compiler doesn't change the order of write instructions + in relation to read instructions. + + If we don't use memory write instructions to shared memory in + some local code, and we use only reading instructions (read only), + then probably it's safe to use pointers to different types for reading. +*/ + + + +#ifdef PPMD_32BIT + + #define Ppmd_Ref_Type(type) type * + #define Ppmd_GetRef(p, ptr) (ptr) + #define Ppmd_GetPtr(p, ptr) (ptr) + #define Ppmd_GetPtr_Type(p, ptr, note_type) (ptr) + +#else + + #define Ppmd_Ref_Type(type) UInt32 + #define Ppmd_GetRef(p, ptr) ((UInt32)((Byte *)(ptr) - (p)->Base)) + #define Ppmd_GetPtr(p, offs) ((void *)((p)->Base + (offs))) + #define Ppmd_GetPtr_Type(p, offs, type) ((type *)Ppmd_GetPtr(p, offs)) + +#endif // PPMD_32BIT + + +typedef Ppmd_Ref_Type(CPpmd_State) CPpmd_State_Ref; +typedef Ppmd_Ref_Type(void) CPpmd_Void_Ref; +typedef Ppmd_Ref_Type(Byte) CPpmd_Byte_Ref; + + +/* +#ifdef MY_CPU_LE_UNALIGN +// the unaligned 32-bit access latency can be too large, if the data is not in L1 cache. +#define Ppmd_GET_SUCCESSOR(p) ((CPpmd_Void_Ref)*(const UInt32 *)(const void *)&(p)->Successor_0) +#define Ppmd_SET_SUCCESSOR(p, v) *(UInt32 *)(void *)(void *)&(p)->Successor_0 = (UInt32)(v) + +#else +*/ + +/* + We can write 16-bit halves to 32-bit (Successor) field in any selected order. + But the native order is more consistent way. + So we use the native order, if LE/BE order can be detected here at compile time. +*/ + +#ifdef MY_CPU_BE + + #define Ppmd_GET_SUCCESSOR(p) \ + ( (CPpmd_Void_Ref) (((UInt32)(p)->Successor_0 << 16) | (p)->Successor_1) ) + + #define Ppmd_SET_SUCCESSOR(p, v) { \ + (p)->Successor_0 = (UInt16)(((UInt32)(v) >> 16) /* & 0xFFFF */); \ + (p)->Successor_1 = (UInt16)((UInt32)(v) /* & 0xFFFF */); } + +#else + + #define Ppmd_GET_SUCCESSOR(p) \ + ( (CPpmd_Void_Ref) ((p)->Successor_0 | ((UInt32)(p)->Successor_1 << 16)) ) + + #define Ppmd_SET_SUCCESSOR(p, v) { \ + (p)->Successor_0 = (UInt16)((UInt32)(v) /* & 0xFFFF */); \ + (p)->Successor_1 = (UInt16)(((UInt32)(v) >> 16) /* & 0xFFFF */); } + +#endif + +// #endif + + +#define PPMD_SetAllBitsIn256Bytes(p) \ + { size_t z; for (z = 0; z < 256 / sizeof(p[0]); z += 8) { \ + p[z+7] = p[z+6] = p[z+5] = p[z+4] = p[z+3] = p[z+2] = p[z+1] = p[z+0] = ~(size_t)0; }} + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Ppmd7.c b/deps/LZMA-SDK/C/Ppmd7.c index b6ecf1430..cf401cb37 100644 --- a/deps/LZMA-SDK/C/Ppmd7.c +++ b/deps/LZMA-SDK/C/Ppmd7.c @@ -1,1104 +1,1104 @@ -/* Ppmd7.c -- PPMdH codec -2021-04-13 : Igor Pavlov : Public domain -This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ - -#include "Precomp.h" - -#include - -#include "Ppmd7.h" - -/* define PPMD7_ORDER_0_SUPPPORT to suport order-0 mode, unsupported by orignal PPMd var.H. code */ -// #define PPMD7_ORDER_0_SUPPPORT - -MY_ALIGN(16) -static const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 }; -MY_ALIGN(16) -static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051}; - -#define MAX_FREQ 124 -#define UNIT_SIZE 12 - -#define U2B(nu) ((UInt32)(nu) * UNIT_SIZE) -#define U2I(nu) (p->Units2Indx[(size_t)(nu) - 1]) -#define I2U(indx) ((unsigned)p->Indx2Units[indx]) -#define I2U_UInt16(indx) ((UInt16)p->Indx2Units[indx]) - -#define REF(ptr) Ppmd_GetRef(p, ptr) - -#define STATS_REF(ptr) ((CPpmd_State_Ref)REF(ptr)) - -#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref)) -#define STATS(ctx) Ppmd7_GetStats(p, ctx) -#define ONE_STATE(ctx) Ppmd7Context_OneState(ctx) -#define SUFFIX(ctx) CTX((ctx)->Suffix) - -typedef CPpmd7_Context * CTX_PTR; - -struct CPpmd7_Node_; - -typedef Ppmd_Ref_Type(struct CPpmd7_Node_) CPpmd7_Node_Ref; - -typedef struct CPpmd7_Node_ -{ - UInt16 Stamp; /* must be at offset 0 as CPpmd7_Context::NumStats. Stamp=0 means free */ - UInt16 NU; - CPpmd7_Node_Ref Next; /* must be at offset >= 4 */ - CPpmd7_Node_Ref Prev; -} CPpmd7_Node; - -#define NODE(r) Ppmd_GetPtr_Type(p, r, CPpmd7_Node) - -void Ppmd7_Construct(CPpmd7 *p) -{ - unsigned i, k, m; - - p->Base = NULL; - - for (i = 0, k = 0; i < PPMD_NUM_INDEXES; i++) - { - unsigned step = (i >= 12 ? 4 : (i >> 2) + 1); - do { p->Units2Indx[k++] = (Byte)i; } while (--step); - p->Indx2Units[i] = (Byte)k; - } - - p->NS2BSIndx[0] = (0 << 1); - p->NS2BSIndx[1] = (1 << 1); - memset(p->NS2BSIndx + 2, (2 << 1), 9); - memset(p->NS2BSIndx + 11, (3 << 1), 256 - 11); - - for (i = 0; i < 3; i++) - p->NS2Indx[i] = (Byte)i; - - for (m = i, k = 1; i < 256; i++) - { - p->NS2Indx[i] = (Byte)m; - if (--k == 0) - k = (++m) - 2; - } - - memcpy(p->ExpEscape, PPMD7_kExpEscape, 16); -} - - -void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->Base); - p->Size = 0; - p->Base = NULL; -} - - -BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc) -{ - if (!p->Base || p->Size != size) - { - Ppmd7_Free(p, alloc); - p->AlignOffset = (4 - size) & 3; - if ((p->Base = (Byte *)ISzAlloc_Alloc(alloc, p->AlignOffset + size)) == NULL) - return False; - p->Size = size; - } - return True; -} - - - -// ---------- Internal Memory Allocator ---------- - -/* We can use CPpmd7_Node in list of free units (as in Ppmd8) - But we still need one additional list walk pass in GlueFreeBlocks(). - So we use simple CPpmd_Void_Ref instead of CPpmd7_Node in InsertNode() / RemoveNode() -*/ - -#define EMPTY_NODE 0 - - -static void InsertNode(CPpmd7 *p, void *node, unsigned indx) -{ - *((CPpmd_Void_Ref *)node) = p->FreeList[indx]; - // ((CPpmd7_Node *)node)->Next = (CPpmd7_Node_Ref)p->FreeList[indx]; - - p->FreeList[indx] = REF(node); - -} - - -static void *RemoveNode(CPpmd7 *p, unsigned indx) -{ - CPpmd_Void_Ref *node = (CPpmd_Void_Ref *)Ppmd7_GetPtr(p, p->FreeList[indx]); - p->FreeList[indx] = *node; - // CPpmd7_Node *node = NODE((CPpmd7_Node_Ref)p->FreeList[indx]); - // p->FreeList[indx] = node->Next; - return node; -} - - -static void SplitBlock(CPpmd7 *p, void *ptr, unsigned oldIndx, unsigned newIndx) -{ - unsigned i, nu = I2U(oldIndx) - I2U(newIndx); - ptr = (Byte *)ptr + U2B(I2U(newIndx)); - if (I2U(i = U2I(nu)) != nu) - { - unsigned k = I2U(--i); - InsertNode(p, ((Byte *)ptr) + U2B(k), nu - k - 1); - } - InsertNode(p, ptr, i); -} - - -/* we use CPpmd7_Node_Union union to solve XLC -O2 strict pointer aliasing problem */ - -typedef union _CPpmd7_Node_Union -{ - CPpmd7_Node Node; - CPpmd7_Node_Ref NextRef; -} CPpmd7_Node_Union; - -/* Original PPmdH (Ppmd7) code uses doubly linked list in GlueFreeBlocks() - we use single linked list similar to Ppmd8 code */ - - -static void GlueFreeBlocks(CPpmd7 *p) -{ - /* - we use first UInt16 field of 12-bytes UNITs as record type stamp - CPpmd_State { Byte Symbol; Byte Freq; : Freq != 0 - CPpmd7_Context { UInt16 NumStats; : NumStats != 0 - CPpmd7_Node { UInt16 Stamp : Stamp == 0 for free record - : Stamp == 1 for head record and guard - Last 12-bytes UNIT in array is always contains 12-bytes order-0 CPpmd7_Context record. - */ - CPpmd7_Node_Ref head, n = 0; - - p->GlueCount = 255; - - - /* we set guard NODE at LoUnit */ - if (p->LoUnit != p->HiUnit) - ((CPpmd7_Node *)(void *)p->LoUnit)->Stamp = 1; - - { - /* Create list of free blocks. - We still need one additional list walk pass before Glue. */ - unsigned i; - for (i = 0; i < PPMD_NUM_INDEXES; i++) - { - const UInt16 nu = I2U_UInt16(i); - CPpmd7_Node_Ref next = (CPpmd7_Node_Ref)p->FreeList[i]; - p->FreeList[i] = 0; - while (next != 0) - { - /* Don't change the order of the following commands: */ - CPpmd7_Node_Union *un = (CPpmd7_Node_Union *)NODE(next); - const CPpmd7_Node_Ref tmp = next; - next = un->NextRef; - un->Node.Stamp = EMPTY_NODE; - un->Node.NU = nu; - un->Node.Next = n; - n = tmp; - } - } - } - - head = n; - /* Glue and Fill must walk the list in same direction */ - { - /* Glue free blocks */ - CPpmd7_Node_Ref *prev = &head; - while (n) - { - CPpmd7_Node *node = NODE(n); - UInt32 nu = node->NU; - n = node->Next; - if (nu == 0) - { - *prev = n; - continue; - } - prev = &node->Next; - for (;;) - { - CPpmd7_Node *node2 = node + nu; - nu += node2->NU; - if (node2->Stamp != EMPTY_NODE || nu >= 0x10000) - break; - node->NU = (UInt16)nu; - node2->NU = 0; - } - } - } - - /* Fill lists of free blocks */ - for (n = head; n != 0;) - { - CPpmd7_Node *node = NODE(n); - UInt32 nu = node->NU; - unsigned i; - n = node->Next; - if (nu == 0) - continue; - for (; nu > 128; nu -= 128, node += 128) - InsertNode(p, node, PPMD_NUM_INDEXES - 1); - if (I2U(i = U2I(nu)) != nu) - { - unsigned k = I2U(--i); - InsertNode(p, node + k, (unsigned)nu - k - 1); - } - InsertNode(p, node, i); - } -} - - -MY_NO_INLINE -static void *AllocUnitsRare(CPpmd7 *p, unsigned indx) -{ - unsigned i; - - if (p->GlueCount == 0) - { - GlueFreeBlocks(p); - if (p->FreeList[indx] != 0) - return RemoveNode(p, indx); - } - - i = indx; - - do - { - if (++i == PPMD_NUM_INDEXES) - { - UInt32 numBytes = U2B(I2U(indx)); - Byte *us = p->UnitsStart; - p->GlueCount--; - return ((UInt32)(us - p->Text) > numBytes) ? (p->UnitsStart = us - numBytes) : NULL; - } - } - while (p->FreeList[i] == 0); - - { - void *block = RemoveNode(p, i); - SplitBlock(p, block, i, indx); - return block; - } -} - - -static void *AllocUnits(CPpmd7 *p, unsigned indx) -{ - if (p->FreeList[indx] != 0) - return RemoveNode(p, indx); - { - UInt32 numBytes = U2B(I2U(indx)); - Byte *lo = p->LoUnit; - if ((UInt32)(p->HiUnit - lo) >= numBytes) - { - p->LoUnit = lo + numBytes; - return lo; - } - } - return AllocUnitsRare(p, indx); -} - - -#define MyMem12Cpy(dest, src, num) \ - { UInt32 *d = (UInt32 *)dest; const UInt32 *z = (const UInt32 *)src; UInt32 n = num; \ - do { d[0] = z[0]; d[1] = z[1]; d[2] = z[2]; z += 3; d += 3; } while (--n); } - - -/* -static void *ShrinkUnits(CPpmd7 *p, void *oldPtr, unsigned oldNU, unsigned newNU) -{ - unsigned i0 = U2I(oldNU); - unsigned i1 = U2I(newNU); - if (i0 == i1) - return oldPtr; - if (p->FreeList[i1] != 0) - { - void *ptr = RemoveNode(p, i1); - MyMem12Cpy(ptr, oldPtr, newNU); - InsertNode(p, oldPtr, i0); - return ptr; - } - SplitBlock(p, oldPtr, i0, i1); - return oldPtr; -} -*/ - - -#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) -static void SetSuccessor(CPpmd_State *p, CPpmd_Void_Ref v) -{ - Ppmd_SET_SUCCESSOR(p, v); -} - - - -MY_NO_INLINE -static -void RestartModel(CPpmd7 *p) -{ - unsigned i, k; - - memset(p->FreeList, 0, sizeof(p->FreeList)); - - p->Text = p->Base + p->AlignOffset; - p->HiUnit = p->Text + p->Size; - p->LoUnit = p->UnitsStart = p->HiUnit - p->Size / 8 / UNIT_SIZE * 7 * UNIT_SIZE; - p->GlueCount = 0; - - p->OrderFall = p->MaxOrder; - p->RunLength = p->InitRL = -(Int32)((p->MaxOrder < 12) ? p->MaxOrder : 12) - 1; - p->PrevSuccess = 0; - - { - CPpmd7_Context *mc = (CTX_PTR)(void *)(p->HiUnit -= UNIT_SIZE); /* AllocContext(p); */ - CPpmd_State *s = (CPpmd_State *)p->LoUnit; /* AllocUnits(p, PPMD_NUM_INDEXES - 1); */ - - p->LoUnit += U2B(256 / 2); - p->MaxContext = p->MinContext = mc; - p->FoundState = s; - - mc->NumStats = 256; - mc->Union2.SummFreq = 256 + 1; - mc->Union4.Stats = REF(s); - mc->Suffix = 0; - - for (i = 0; i < 256; i++, s++) - { - s->Symbol = (Byte)i; - s->Freq = 1; - SetSuccessor(s, 0); - } - - #ifdef PPMD7_ORDER_0_SUPPPORT - if (p->MaxOrder == 0) - { - CPpmd_Void_Ref r = REF(mc); - s = p->FoundState; - for (i = 0; i < 256; i++, s++) - SetSuccessor(s, r); - return; - } - #endif - } - - for (i = 0; i < 128; i++) - - - - for (k = 0; k < 8; k++) - { - unsigned m; - UInt16 *dest = p->BinSumm[i] + k; - UInt16 val = (UInt16)(PPMD_BIN_SCALE - kInitBinEsc[k] / (i + 2)); - for (m = 0; m < 64; m += 8) - dest[m] = val; - } - - - for (i = 0; i < 25; i++) - { - - CPpmd_See *s = p->See[i]; - - - - unsigned summ = ((5 * i + 10) << (PPMD_PERIOD_BITS - 4)); - for (k = 0; k < 16; k++, s++) - { - s->Summ = (UInt16)summ; - s->Shift = (PPMD_PERIOD_BITS - 4); - s->Count = 4; - } - } - - p->DummySee.Summ = 0; /* unused */ - p->DummySee.Shift = PPMD_PERIOD_BITS; - p->DummySee.Count = 64; /* unused */ -} - - -void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder) -{ - p->MaxOrder = maxOrder; - - RestartModel(p); -} - - - -/* - CreateSuccessors() - It's called when (FoundState->Successor) is RAW-Successor, - that is the link to position in Raw text. - So we create Context records and write the links to - FoundState->Successor and to identical RAW-Successors in suffix - contexts of MinContex. - - The function returns: - if (OrderFall == 0) then MinContext is already at MAX order, - { return pointer to new or existing context of same MAX order } - else - { return pointer to new real context that will be (Order+1) in comparison with MinContext - - also it can return pointer to real context of same order, -*/ - -MY_NO_INLINE -static CTX_PTR CreateSuccessors(CPpmd7 *p) -{ - CTX_PTR c = p->MinContext; - CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState); - Byte newSym, newFreq; - unsigned numPs = 0; - CPpmd_State *ps[PPMD7_MAX_ORDER]; - - if (p->OrderFall != 0) - ps[numPs++] = p->FoundState; - - while (c->Suffix) - { - CPpmd_Void_Ref successor; - CPpmd_State *s; - c = SUFFIX(c); - - - if (c->NumStats != 1) - { - Byte sym = p->FoundState->Symbol; - for (s = STATS(c); s->Symbol != sym; s++); - - } - else - { - s = ONE_STATE(c); - - } - successor = SUCCESSOR(s); - if (successor != upBranch) - { - // (c) is real record Context here, - c = CTX(successor); - if (numPs == 0) - { - // (c) is real record MAX Order Context here, - // So we don't need to create any new contexts. - return c; - } - break; - } - ps[numPs++] = s; - } - - // All created contexts will have single-symbol with new RAW-Successor - // All new RAW-Successors will point to next position in RAW text - // after FoundState->Successor - - newSym = *(const Byte *)Ppmd7_GetPtr(p, upBranch); - upBranch++; - - - if (c->NumStats == 1) - newFreq = ONE_STATE(c)->Freq; - else - { - UInt32 cf, s0; - CPpmd_State *s; - for (s = STATS(c); s->Symbol != newSym; s++); - cf = (UInt32)s->Freq - 1; - s0 = (UInt32)c->Union2.SummFreq - c->NumStats - cf; - /* - cf - is frequency of symbol that will be Successor in new context records. - s0 - is commulative frequency sum of another symbols from parent context. - max(newFreq)= (s->Freq + 1), when (s0 == 1) - we have requirement (Ppmd7Context_OneState()->Freq <= 128) in BinSumm[] - so (s->Freq < 128) - is requirement for multi-symbol contexts - */ - newFreq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) : (2 * cf + s0 - 1) / (2 * s0) + 1)); - } - - // Create new single-symbol contexts from low order to high order in loop - - do - { - CTX_PTR c1; - /* = AllocContext(p); */ - if (p->HiUnit != p->LoUnit) - c1 = (CTX_PTR)(void *)(p->HiUnit -= UNIT_SIZE); - else if (p->FreeList[0] != 0) - c1 = (CTX_PTR)RemoveNode(p, 0); - else - { - c1 = (CTX_PTR)AllocUnitsRare(p, 0); - if (!c1) - return NULL; - } - - c1->NumStats = 1; - ONE_STATE(c1)->Symbol = newSym; - ONE_STATE(c1)->Freq = newFreq; - SetSuccessor(ONE_STATE(c1), upBranch); - c1->Suffix = REF(c); - SetSuccessor(ps[--numPs], REF(c1)); - c = c1; - } - while (numPs != 0); - - return c; -} - - - -#define SwapStates(s) \ - { CPpmd_State tmp = s[0]; s[0] = s[-1]; s[-1] = tmp; } - - -void Ppmd7_UpdateModel(CPpmd7 *p); -MY_NO_INLINE -void Ppmd7_UpdateModel(CPpmd7 *p) -{ - CPpmd_Void_Ref maxSuccessor, minSuccessor; - CTX_PTR c, mc; - unsigned s0, ns; - - - - if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) - { - /* Update Freqs in Suffix Context */ - - c = SUFFIX(p->MinContext); - - if (c->NumStats == 1) - { - CPpmd_State *s = ONE_STATE(c); - if (s->Freq < 32) - s->Freq++; - } - else - { - CPpmd_State *s = STATS(c); - Byte sym = p->FoundState->Symbol; - - if (s->Symbol != sym) - { - do - { - // s++; if (s->Symbol == sym) break; - s++; - } - while (s->Symbol != sym); - - if (s[0].Freq >= s[-1].Freq) - { - SwapStates(s); - s--; - } - } - - if (s->Freq < MAX_FREQ - 9) - { - s->Freq = (Byte)(s->Freq + 2); - c->Union2.SummFreq = (UInt16)(c->Union2.SummFreq + 2); - } - } - } - - - if (p->OrderFall == 0) - { - /* MAX ORDER context */ - /* (FoundState->Successor) is RAW-Successor. */ - p->MaxContext = p->MinContext = CreateSuccessors(p); - if (!p->MinContext) - { - RestartModel(p); - return; - } - SetSuccessor(p->FoundState, REF(p->MinContext)); - return; - } - - - /* NON-MAX ORDER context */ - - { - Byte *text = p->Text; - *text++ = p->FoundState->Symbol; - p->Text = text; - if (text >= p->UnitsStart) - { - RestartModel(p); - return; - } - maxSuccessor = REF(text); - } - - minSuccessor = SUCCESSOR(p->FoundState); - - if (minSuccessor) - { - // there is Successor for FoundState in MinContext. - // So the next context will be one order higher than MinContext. - - if (minSuccessor <= maxSuccessor) - { - // minSuccessor is RAW-Successor. So we will create real contexts records: - CTX_PTR cs = CreateSuccessors(p); - if (!cs) - { - RestartModel(p); - return; - } - minSuccessor = REF(cs); - } - - // minSuccessor now is real Context pointer that points to existing (Order+1) context - - if (--p->OrderFall == 0) - { - /* - if we move to MaxOrder context, then minSuccessor will be common Succesor for both: - MinContext that is (MaxOrder - 1) - MaxContext that is (MaxOrder) - so we don't need new RAW-Successor, and we can use real minSuccessor - as succssors for both MinContext and MaxContext. - */ - maxSuccessor = minSuccessor; - - /* - if (MaxContext != MinContext) - { - there was order fall from MaxOrder and we don't need current symbol - to transfer some RAW-Succesors to real contexts. - So we roll back pointer in raw data for one position. - } - */ - p->Text -= (p->MaxContext != p->MinContext); - } - } - else - { - /* - FoundState has NULL-Successor here. - And only root 0-order context can contain NULL-Successors. - We change Successor in FoundState to RAW-Successor, - And next context will be same 0-order root Context. - */ - SetSuccessor(p->FoundState, maxSuccessor); - minSuccessor = REF(p->MinContext); - } - - mc = p->MinContext; - c = p->MaxContext; - - p->MaxContext = p->MinContext = CTX(minSuccessor); - - if (c == mc) - return; - - // s0 : is pure Escape Freq - s0 = mc->Union2.SummFreq - (ns = mc->NumStats) - ((unsigned)p->FoundState->Freq - 1); - - do - { - unsigned ns1; - UInt32 sum; - - if ((ns1 = c->NumStats) != 1) - { - if ((ns1 & 1) == 0) - { - /* Expand for one UNIT */ - unsigned oldNU = ns1 >> 1; - unsigned i = U2I(oldNU); - if (i != U2I((size_t)oldNU + 1)) - { - void *ptr = AllocUnits(p, i + 1); - void *oldPtr; - if (!ptr) - { - RestartModel(p); - return; - } - oldPtr = STATS(c); - MyMem12Cpy(ptr, oldPtr, oldNU); - InsertNode(p, oldPtr, i); - c->Union4.Stats = STATS_REF(ptr); - } - } - sum = c->Union2.SummFreq; - /* max increase of Escape_Freq is 3 here. - total increase of Union2.SummFreq for all symbols is less than 256 here */ - sum += (UInt32)(2 * ns1 < ns) + 2 * ((unsigned)(4 * ns1 <= ns) & (sum <= 8 * ns1)); - /* original PPMdH uses 16-bit variable for (sum) here. - But (sum < 0x9000). So we don't truncate (sum) to 16-bit */ - // sum = (UInt16)sum; - } - else - { - // instead of One-symbol context we create 2-symbol context - CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0); - if (!s) - { - RestartModel(p); - return; - } - { - unsigned freq = c->Union2.State2.Freq; - // s = *ONE_STATE(c); - s->Symbol = c->Union2.State2.Symbol; - s->Successor_0 = c->Union4.State4.Successor_0; - s->Successor_1 = c->Union4.State4.Successor_1; - // SetSuccessor(s, c->Union4.Stats); // call it only for debug purposes to check the order of - // (Successor_0 and Successor_1) in LE/BE. - c->Union4.Stats = REF(s); - if (freq < MAX_FREQ / 4 - 1) - freq <<= 1; - else - freq = MAX_FREQ - 4; - // (max(s->freq) == 120), when we convert from 1-symbol into 2-symbol context - s->Freq = (Byte)freq; - // max(InitEsc = PPMD7_kExpEscape[*]) is 25. So the max(escapeFreq) is 26 here - sum = freq + p->InitEsc + (ns > 3); - } - } - - { - CPpmd_State *s = STATS(c) + ns1; - UInt32 cf = 2 * (sum + 6) * (UInt32)p->FoundState->Freq; - UInt32 sf = (UInt32)s0 + sum; - s->Symbol = p->FoundState->Symbol; - c->NumStats = (UInt16)(ns1 + 1); - SetSuccessor(s, maxSuccessor); - - if (cf < 6 * sf) - { - cf = (UInt32)1 + (cf > sf) + (cf >= 4 * sf); - sum += 3; - /* It can add (0, 1, 2) to Escape_Freq */ - } - else - { - cf = (UInt32)4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf); - sum += cf; - } - - c->Union2.SummFreq = (UInt16)sum; - s->Freq = (Byte)cf; - } - c = SUFFIX(c); - } - while (c != mc); -} - - - -MY_NO_INLINE -static void Rescale(CPpmd7 *p) -{ - unsigned i, adder, sumFreq, escFreq; - CPpmd_State *stats = STATS(p->MinContext); - CPpmd_State *s = p->FoundState; - - /* Sort the list by Freq */ - if (s != stats) - { - CPpmd_State tmp = *s; - do - s[0] = s[-1]; - while (--s != stats); - *s = tmp; - } - - sumFreq = s->Freq; - escFreq = p->MinContext->Union2.SummFreq - sumFreq; - - /* - if (p->OrderFall == 0), adder = 0 : it's allowed to remove symbol from MAX Order context - if (p->OrderFall != 0), adder = 1 : it's NOT allowed to remove symbol from NON-MAX Order context - */ - - adder = (p->OrderFall != 0); - - #ifdef PPMD7_ORDER_0_SUPPPORT - adder |= (p->MaxOrder == 0); // we don't remove symbols from order-0 context - #endif - - sumFreq = (sumFreq + 4 + adder) >> 1; - i = (unsigned)p->MinContext->NumStats - 1; - s->Freq = (Byte)sumFreq; - - do - { - unsigned freq = (++s)->Freq; - escFreq -= freq; - freq = (freq + adder) >> 1; - sumFreq += freq; - s->Freq = (Byte)freq; - if (freq > s[-1].Freq) - { - CPpmd_State tmp = *s; - CPpmd_State *s1 = s; - do - { - s1[0] = s1[-1]; - } - while (--s1 != stats && freq > s1[-1].Freq); - *s1 = tmp; - } - } - while (--i); - - if (s->Freq == 0) - { - /* Remove all items with Freq == 0 */ - CPpmd7_Context *mc; - unsigned numStats, numStatsNew, n0, n1; - - i = 0; do { i++; } while ((--s)->Freq == 0); - - /* We increase (escFreq) for the number of removed symbols. - So we will have (0.5) increase for Escape_Freq in avarage per - removed symbol after Escape_Freq halving */ - escFreq += i; - mc = p->MinContext; - numStats = mc->NumStats; - numStatsNew = numStats - i; - mc->NumStats = (UInt16)(numStatsNew); - n0 = (numStats + 1) >> 1; - - if (numStatsNew == 1) - { - /* Create Single-Symbol context */ - unsigned freq = stats->Freq; - - do - { - escFreq >>= 1; - freq = (freq + 1) >> 1; - } - while (escFreq > 1); - - s = ONE_STATE(mc); - *s = *stats; - s->Freq = (Byte)freq; // (freq <= 260 / 4) - p->FoundState = s; - InsertNode(p, stats, U2I(n0)); - return; - } - - n1 = (numStatsNew + 1) >> 1; - if (n0 != n1) - { - // p->MinContext->Union4.Stats = STATS_REF(ShrinkUnits(p, stats, n0, n1)); - unsigned i0 = U2I(n0); - unsigned i1 = U2I(n1); - if (i0 != i1) - { - if (p->FreeList[i1] != 0) - { - void *ptr = RemoveNode(p, i1); - p->MinContext->Union4.Stats = STATS_REF(ptr); - MyMem12Cpy(ptr, (const void *)stats, n1); - InsertNode(p, stats, i0); - } - else - SplitBlock(p, stats, i0, i1); - } - } - } - { - CPpmd7_Context *mc = p->MinContext; - mc->Union2.SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1)); - // Escape_Freq halving here - p->FoundState = STATS(mc); - } -} - - -CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *escFreq) -{ - CPpmd_See *see; - const CPpmd7_Context *mc = p->MinContext; - unsigned numStats = mc->NumStats; - if (numStats != 256) - { - unsigned nonMasked = numStats - numMasked; - see = p->See[(unsigned)p->NS2Indx[(size_t)nonMasked - 1]] - + (nonMasked < (unsigned)SUFFIX(mc)->NumStats - numStats) - + 2 * (unsigned)(mc->Union2.SummFreq < 11 * numStats) - + 4 * (unsigned)(numMasked > nonMasked) + - p->HiBitsFlag; - { - // if (see->Summ) field is larger than 16-bit, we need only low 16 bits of Summ - unsigned summ = (UInt16)see->Summ; // & 0xFFFF - unsigned r = (summ >> see->Shift); - see->Summ = (UInt16)(summ - r); - *escFreq = r + (r == 0); - } - } - else - { - see = &p->DummySee; - *escFreq = 1; - } - return see; -} - - -static void NextContext(CPpmd7 *p) -{ - CTX_PTR c = CTX(SUCCESSOR(p->FoundState)); - if (p->OrderFall == 0 && (const Byte *)c > p->Text) - p->MaxContext = p->MinContext = c; - else - Ppmd7_UpdateModel(p); -} - - -void Ppmd7_Update1(CPpmd7 *p) -{ - CPpmd_State *s = p->FoundState; - unsigned freq = s->Freq; - freq += 4; - p->MinContext->Union2.SummFreq = (UInt16)(p->MinContext->Union2.SummFreq + 4); - s->Freq = (Byte)freq; - if (freq > s[-1].Freq) - { - SwapStates(s); - p->FoundState = --s; - if (freq > MAX_FREQ) - Rescale(p); - } - NextContext(p); -} - - -void Ppmd7_Update1_0(CPpmd7 *p) -{ - CPpmd_State *s = p->FoundState; - CPpmd7_Context *mc = p->MinContext; - unsigned freq = s->Freq; - unsigned summFreq = mc->Union2.SummFreq; - p->PrevSuccess = (2 * freq > summFreq); - p->RunLength += (int)p->PrevSuccess; - mc->Union2.SummFreq = (UInt16)(summFreq + 4); - freq += 4; - s->Freq = (Byte)freq; - if (freq > MAX_FREQ) - Rescale(p); - NextContext(p); -} - - -/* -void Ppmd7_UpdateBin(CPpmd7 *p) -{ - unsigned freq = p->FoundState->Freq; - p->FoundState->Freq = (Byte)(freq + (freq < 128)); - p->PrevSuccess = 1; - p->RunLength++; - NextContext(p); -} -*/ - -void Ppmd7_Update2(CPpmd7 *p) -{ - CPpmd_State *s = p->FoundState; - unsigned freq = s->Freq; - freq += 4; - p->RunLength = p->InitRL; - p->MinContext->Union2.SummFreq = (UInt16)(p->MinContext->Union2.SummFreq + 4); - s->Freq = (Byte)freq; - if (freq > MAX_FREQ) - Rescale(p); - Ppmd7_UpdateModel(p); -} - - - -/* -PPMd Memory Map: -{ - [ 0 ] contains subset of original raw text, that is required to create context - records, Some symbols are not written, when max order context was reached - [ Text ] free area - [ UnitsStart ] CPpmd_State vectors and CPpmd7_Context records - [ LoUnit ] free area for CPpmd_State and CPpmd7_Context items -[ HiUnit ] CPpmd7_Context records - [ Size ] end of array -} - -These addresses don't cross at any time. -And the following condtions is true for addresses: - (0 <= Text < UnitsStart <= LoUnit <= HiUnit <= Size) - -Raw text is BYTE--aligned. -the data in block [ UnitsStart ... Size ] contains 12-bytes aligned UNITs. - -Last UNIT of array at offset (Size - 12) is root order-0 CPpmd7_Context record. -The code can free UNITs memory blocks that were allocated to store CPpmd_State vectors. -The code doesn't free UNITs allocated for CPpmd7_Context records. - -The code calls RestartModel(), when there is no free memory for allocation. -And RestartModel() changes the state to orignal start state, with full free block. - - -The code allocates UNITs with the following order: - -Allocation of 1 UNIT for Context record - - from free space (HiUnit) down to (LoUnit) - - from FreeList[0] - - AllocUnitsRare() - -AllocUnits() for CPpmd_State vectors: - - from FreeList[i] - - from free space (LoUnit) up to (HiUnit) - - AllocUnitsRare() - -AllocUnitsRare() - - if (GlueCount == 0) - { Glue lists, GlueCount = 255, allocate from FreeList[i]] } - - loop for all higher sized FreeList[...] lists - - from (UnitsStart - Text), GlueCount-- - - ERROR - - -Each Record with Context contains the CPpmd_State vector, where each -CPpmd_State contains the link to Successor. -There are 3 types of Successor: - 1) NULL-Successor - NULL pointer. NULL-Successor links can be stored - only in 0-order Root Context Record. - We use 0 value as NULL-Successor - 2) RAW-Successor - the link to position in raw text, - that "RAW-Successor" is being created after first - occurrence of new symbol for some existing context record. - (RAW-Successor > 0). - 3) RECORD-Successor - the link to CPpmd7_Context record of (Order+1), - that record is being created when we go via RAW-Successor again. - -For any successors at any time: the following condtions are true for Successor links: -(NULL-Successor < RAW-Successor < UnitsStart <= RECORD-Successor) - - ----------- Symbol Frequency, SummFreq and Range in Range_Coder ---------- - -CPpmd7_Context::SummFreq = Sum(Stats[].Freq) + Escape_Freq - -The PPMd code tries to fulfill the condition: - (SummFreq <= (256 * 128 = RC::kBot)) - -We have (Sum(Stats[].Freq) <= 256 * 124), because of (MAX_FREQ = 124) -So (4 = 128 - 124) is average reserve for Escape_Freq for each symbol. -If (CPpmd_State::Freq) is not aligned for 4, the reserve can be 5, 6 or 7. -SummFreq and Escape_Freq can be changed in Rescale() and *Update*() functions. -Rescale() can remove symbols only from max-order contexts. So Escape_Freq can increase after multiple calls of Rescale() for -max-order context. - -When the PPMd code still break (Total <= RC::Range) condition in range coder, -we have two ways to resolve that problem: - 1) we can report error, if we want to keep compatibility with original PPMd code that has no fix for such cases. - 2) we can reduce (Total) value to (RC::Range) by reducing (Escape_Freq) part of (Total) value. -*/ +/* Ppmd7.c -- PPMdH codec +2021-04-13 : Igor Pavlov : Public domain +This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ + +#include "Precomp.h" + +#include + +#include "Ppmd7.h" + +/* define PPMD7_ORDER_0_SUPPPORT to suport order-0 mode, unsupported by orignal PPMd var.H. code */ +// #define PPMD7_ORDER_0_SUPPPORT + +MY_ALIGN(16) +static const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 }; +MY_ALIGN(16) +static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051}; + +#define MAX_FREQ 124 +#define UNIT_SIZE 12 + +#define U2B(nu) ((UInt32)(nu) * UNIT_SIZE) +#define U2I(nu) (p->Units2Indx[(size_t)(nu) - 1]) +#define I2U(indx) ((unsigned)p->Indx2Units[indx]) +#define I2U_UInt16(indx) ((UInt16)p->Indx2Units[indx]) + +#define REF(ptr) Ppmd_GetRef(p, ptr) + +#define STATS_REF(ptr) ((CPpmd_State_Ref)REF(ptr)) + +#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref)) +#define STATS(ctx) Ppmd7_GetStats(p, ctx) +#define ONE_STATE(ctx) Ppmd7Context_OneState(ctx) +#define SUFFIX(ctx) CTX((ctx)->Suffix) + +typedef CPpmd7_Context * CTX_PTR; + +struct CPpmd7_Node_; + +typedef Ppmd_Ref_Type(struct CPpmd7_Node_) CPpmd7_Node_Ref; + +typedef struct CPpmd7_Node_ +{ + UInt16 Stamp; /* must be at offset 0 as CPpmd7_Context::NumStats. Stamp=0 means free */ + UInt16 NU; + CPpmd7_Node_Ref Next; /* must be at offset >= 4 */ + CPpmd7_Node_Ref Prev; +} CPpmd7_Node; + +#define NODE(r) Ppmd_GetPtr_Type(p, r, CPpmd7_Node) + +void Ppmd7_Construct(CPpmd7 *p) +{ + unsigned i, k, m; + + p->Base = NULL; + + for (i = 0, k = 0; i < PPMD_NUM_INDEXES; i++) + { + unsigned step = (i >= 12 ? 4 : (i >> 2) + 1); + do { p->Units2Indx[k++] = (Byte)i; } while (--step); + p->Indx2Units[i] = (Byte)k; + } + + p->NS2BSIndx[0] = (0 << 1); + p->NS2BSIndx[1] = (1 << 1); + memset(p->NS2BSIndx + 2, (2 << 1), 9); + memset(p->NS2BSIndx + 11, (3 << 1), 256 - 11); + + for (i = 0; i < 3; i++) + p->NS2Indx[i] = (Byte)i; + + for (m = i, k = 1; i < 256; i++) + { + p->NS2Indx[i] = (Byte)m; + if (--k == 0) + k = (++m) - 2; + } + + memcpy(p->ExpEscape, PPMD7_kExpEscape, 16); +} + + +void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->Base); + p->Size = 0; + p->Base = NULL; +} + + +BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc) +{ + if (!p->Base || p->Size != size) + { + Ppmd7_Free(p, alloc); + p->AlignOffset = (4 - size) & 3; + if ((p->Base = (Byte *)ISzAlloc_Alloc(alloc, p->AlignOffset + size)) == NULL) + return False; + p->Size = size; + } + return True; +} + + + +// ---------- Internal Memory Allocator ---------- + +/* We can use CPpmd7_Node in list of free units (as in Ppmd8) + But we still need one additional list walk pass in GlueFreeBlocks(). + So we use simple CPpmd_Void_Ref instead of CPpmd7_Node in InsertNode() / RemoveNode() +*/ + +#define EMPTY_NODE 0 + + +static void InsertNode(CPpmd7 *p, void *node, unsigned indx) +{ + *((CPpmd_Void_Ref *)node) = p->FreeList[indx]; + // ((CPpmd7_Node *)node)->Next = (CPpmd7_Node_Ref)p->FreeList[indx]; + + p->FreeList[indx] = REF(node); + +} + + +static void *RemoveNode(CPpmd7 *p, unsigned indx) +{ + CPpmd_Void_Ref *node = (CPpmd_Void_Ref *)Ppmd7_GetPtr(p, p->FreeList[indx]); + p->FreeList[indx] = *node; + // CPpmd7_Node *node = NODE((CPpmd7_Node_Ref)p->FreeList[indx]); + // p->FreeList[indx] = node->Next; + return node; +} + + +static void SplitBlock(CPpmd7 *p, void *ptr, unsigned oldIndx, unsigned newIndx) +{ + unsigned i, nu = I2U(oldIndx) - I2U(newIndx); + ptr = (Byte *)ptr + U2B(I2U(newIndx)); + if (I2U(i = U2I(nu)) != nu) + { + unsigned k = I2U(--i); + InsertNode(p, ((Byte *)ptr) + U2B(k), nu - k - 1); + } + InsertNode(p, ptr, i); +} + + +/* we use CPpmd7_Node_Union union to solve XLC -O2 strict pointer aliasing problem */ + +typedef union _CPpmd7_Node_Union +{ + CPpmd7_Node Node; + CPpmd7_Node_Ref NextRef; +} CPpmd7_Node_Union; + +/* Original PPmdH (Ppmd7) code uses doubly linked list in GlueFreeBlocks() + we use single linked list similar to Ppmd8 code */ + + +static void GlueFreeBlocks(CPpmd7 *p) +{ + /* + we use first UInt16 field of 12-bytes UNITs as record type stamp + CPpmd_State { Byte Symbol; Byte Freq; : Freq != 0 + CPpmd7_Context { UInt16 NumStats; : NumStats != 0 + CPpmd7_Node { UInt16 Stamp : Stamp == 0 for free record + : Stamp == 1 for head record and guard + Last 12-bytes UNIT in array is always contains 12-bytes order-0 CPpmd7_Context record. + */ + CPpmd7_Node_Ref head, n = 0; + + p->GlueCount = 255; + + + /* we set guard NODE at LoUnit */ + if (p->LoUnit != p->HiUnit) + ((CPpmd7_Node *)(void *)p->LoUnit)->Stamp = 1; + + { + /* Create list of free blocks. + We still need one additional list walk pass before Glue. */ + unsigned i; + for (i = 0; i < PPMD_NUM_INDEXES; i++) + { + const UInt16 nu = I2U_UInt16(i); + CPpmd7_Node_Ref next = (CPpmd7_Node_Ref)p->FreeList[i]; + p->FreeList[i] = 0; + while (next != 0) + { + /* Don't change the order of the following commands: */ + CPpmd7_Node_Union *un = (CPpmd7_Node_Union *)NODE(next); + const CPpmd7_Node_Ref tmp = next; + next = un->NextRef; + un->Node.Stamp = EMPTY_NODE; + un->Node.NU = nu; + un->Node.Next = n; + n = tmp; + } + } + } + + head = n; + /* Glue and Fill must walk the list in same direction */ + { + /* Glue free blocks */ + CPpmd7_Node_Ref *prev = &head; + while (n) + { + CPpmd7_Node *node = NODE(n); + UInt32 nu = node->NU; + n = node->Next; + if (nu == 0) + { + *prev = n; + continue; + } + prev = &node->Next; + for (;;) + { + CPpmd7_Node *node2 = node + nu; + nu += node2->NU; + if (node2->Stamp != EMPTY_NODE || nu >= 0x10000) + break; + node->NU = (UInt16)nu; + node2->NU = 0; + } + } + } + + /* Fill lists of free blocks */ + for (n = head; n != 0;) + { + CPpmd7_Node *node = NODE(n); + UInt32 nu = node->NU; + unsigned i; + n = node->Next; + if (nu == 0) + continue; + for (; nu > 128; nu -= 128, node += 128) + InsertNode(p, node, PPMD_NUM_INDEXES - 1); + if (I2U(i = U2I(nu)) != nu) + { + unsigned k = I2U(--i); + InsertNode(p, node + k, (unsigned)nu - k - 1); + } + InsertNode(p, node, i); + } +} + + +MY_NO_INLINE +static void *AllocUnitsRare(CPpmd7 *p, unsigned indx) +{ + unsigned i; + + if (p->GlueCount == 0) + { + GlueFreeBlocks(p); + if (p->FreeList[indx] != 0) + return RemoveNode(p, indx); + } + + i = indx; + + do + { + if (++i == PPMD_NUM_INDEXES) + { + UInt32 numBytes = U2B(I2U(indx)); + Byte *us = p->UnitsStart; + p->GlueCount--; + return ((UInt32)(us - p->Text) > numBytes) ? (p->UnitsStart = us - numBytes) : NULL; + } + } + while (p->FreeList[i] == 0); + + { + void *block = RemoveNode(p, i); + SplitBlock(p, block, i, indx); + return block; + } +} + + +static void *AllocUnits(CPpmd7 *p, unsigned indx) +{ + if (p->FreeList[indx] != 0) + return RemoveNode(p, indx); + { + UInt32 numBytes = U2B(I2U(indx)); + Byte *lo = p->LoUnit; + if ((UInt32)(p->HiUnit - lo) >= numBytes) + { + p->LoUnit = lo + numBytes; + return lo; + } + } + return AllocUnitsRare(p, indx); +} + + +#define MyMem12Cpy(dest, src, num) \ + { UInt32 *d = (UInt32 *)dest; const UInt32 *z = (const UInt32 *)src; UInt32 n = num; \ + do { d[0] = z[0]; d[1] = z[1]; d[2] = z[2]; z += 3; d += 3; } while (--n); } + + +/* +static void *ShrinkUnits(CPpmd7 *p, void *oldPtr, unsigned oldNU, unsigned newNU) +{ + unsigned i0 = U2I(oldNU); + unsigned i1 = U2I(newNU); + if (i0 == i1) + return oldPtr; + if (p->FreeList[i1] != 0) + { + void *ptr = RemoveNode(p, i1); + MyMem12Cpy(ptr, oldPtr, newNU); + InsertNode(p, oldPtr, i0); + return ptr; + } + SplitBlock(p, oldPtr, i0, i1); + return oldPtr; +} +*/ + + +#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) +static void SetSuccessor(CPpmd_State *p, CPpmd_Void_Ref v) +{ + Ppmd_SET_SUCCESSOR(p, v); +} + + + +MY_NO_INLINE +static +void RestartModel(CPpmd7 *p) +{ + unsigned i, k; + + memset(p->FreeList, 0, sizeof(p->FreeList)); + + p->Text = p->Base + p->AlignOffset; + p->HiUnit = p->Text + p->Size; + p->LoUnit = p->UnitsStart = p->HiUnit - p->Size / 8 / UNIT_SIZE * 7 * UNIT_SIZE; + p->GlueCount = 0; + + p->OrderFall = p->MaxOrder; + p->RunLength = p->InitRL = -(Int32)((p->MaxOrder < 12) ? p->MaxOrder : 12) - 1; + p->PrevSuccess = 0; + + { + CPpmd7_Context *mc = (CTX_PTR)(void *)(p->HiUnit -= UNIT_SIZE); /* AllocContext(p); */ + CPpmd_State *s = (CPpmd_State *)p->LoUnit; /* AllocUnits(p, PPMD_NUM_INDEXES - 1); */ + + p->LoUnit += U2B(256 / 2); + p->MaxContext = p->MinContext = mc; + p->FoundState = s; + + mc->NumStats = 256; + mc->Union2.SummFreq = 256 + 1; + mc->Union4.Stats = REF(s); + mc->Suffix = 0; + + for (i = 0; i < 256; i++, s++) + { + s->Symbol = (Byte)i; + s->Freq = 1; + SetSuccessor(s, 0); + } + + #ifdef PPMD7_ORDER_0_SUPPPORT + if (p->MaxOrder == 0) + { + CPpmd_Void_Ref r = REF(mc); + s = p->FoundState; + for (i = 0; i < 256; i++, s++) + SetSuccessor(s, r); + return; + } + #endif + } + + for (i = 0; i < 128; i++) + + + + for (k = 0; k < 8; k++) + { + unsigned m; + UInt16 *dest = p->BinSumm[i] + k; + UInt16 val = (UInt16)(PPMD_BIN_SCALE - kInitBinEsc[k] / (i + 2)); + for (m = 0; m < 64; m += 8) + dest[m] = val; + } + + + for (i = 0; i < 25; i++) + { + + CPpmd_See *s = p->See[i]; + + + + unsigned summ = ((5 * i + 10) << (PPMD_PERIOD_BITS - 4)); + for (k = 0; k < 16; k++, s++) + { + s->Summ = (UInt16)summ; + s->Shift = (PPMD_PERIOD_BITS - 4); + s->Count = 4; + } + } + + p->DummySee.Summ = 0; /* unused */ + p->DummySee.Shift = PPMD_PERIOD_BITS; + p->DummySee.Count = 64; /* unused */ +} + + +void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder) +{ + p->MaxOrder = maxOrder; + + RestartModel(p); +} + + + +/* + CreateSuccessors() + It's called when (FoundState->Successor) is RAW-Successor, + that is the link to position in Raw text. + So we create Context records and write the links to + FoundState->Successor and to identical RAW-Successors in suffix + contexts of MinContex. + + The function returns: + if (OrderFall == 0) then MinContext is already at MAX order, + { return pointer to new or existing context of same MAX order } + else + { return pointer to new real context that will be (Order+1) in comparison with MinContext + + also it can return pointer to real context of same order, +*/ + +MY_NO_INLINE +static CTX_PTR CreateSuccessors(CPpmd7 *p) +{ + CTX_PTR c = p->MinContext; + CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState); + Byte newSym, newFreq; + unsigned numPs = 0; + CPpmd_State *ps[PPMD7_MAX_ORDER]; + + if (p->OrderFall != 0) + ps[numPs++] = p->FoundState; + + while (c->Suffix) + { + CPpmd_Void_Ref successor; + CPpmd_State *s; + c = SUFFIX(c); + + + if (c->NumStats != 1) + { + Byte sym = p->FoundState->Symbol; + for (s = STATS(c); s->Symbol != sym; s++); + + } + else + { + s = ONE_STATE(c); + + } + successor = SUCCESSOR(s); + if (successor != upBranch) + { + // (c) is real record Context here, + c = CTX(successor); + if (numPs == 0) + { + // (c) is real record MAX Order Context here, + // So we don't need to create any new contexts. + return c; + } + break; + } + ps[numPs++] = s; + } + + // All created contexts will have single-symbol with new RAW-Successor + // All new RAW-Successors will point to next position in RAW text + // after FoundState->Successor + + newSym = *(const Byte *)Ppmd7_GetPtr(p, upBranch); + upBranch++; + + + if (c->NumStats == 1) + newFreq = ONE_STATE(c)->Freq; + else + { + UInt32 cf, s0; + CPpmd_State *s; + for (s = STATS(c); s->Symbol != newSym; s++); + cf = (UInt32)s->Freq - 1; + s0 = (UInt32)c->Union2.SummFreq - c->NumStats - cf; + /* + cf - is frequency of symbol that will be Successor in new context records. + s0 - is commulative frequency sum of another symbols from parent context. + max(newFreq)= (s->Freq + 1), when (s0 == 1) + we have requirement (Ppmd7Context_OneState()->Freq <= 128) in BinSumm[] + so (s->Freq < 128) - is requirement for multi-symbol contexts + */ + newFreq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) : (2 * cf + s0 - 1) / (2 * s0) + 1)); + } + + // Create new single-symbol contexts from low order to high order in loop + + do + { + CTX_PTR c1; + /* = AllocContext(p); */ + if (p->HiUnit != p->LoUnit) + c1 = (CTX_PTR)(void *)(p->HiUnit -= UNIT_SIZE); + else if (p->FreeList[0] != 0) + c1 = (CTX_PTR)RemoveNode(p, 0); + else + { + c1 = (CTX_PTR)AllocUnitsRare(p, 0); + if (!c1) + return NULL; + } + + c1->NumStats = 1; + ONE_STATE(c1)->Symbol = newSym; + ONE_STATE(c1)->Freq = newFreq; + SetSuccessor(ONE_STATE(c1), upBranch); + c1->Suffix = REF(c); + SetSuccessor(ps[--numPs], REF(c1)); + c = c1; + } + while (numPs != 0); + + return c; +} + + + +#define SwapStates(s) \ + { CPpmd_State tmp = s[0]; s[0] = s[-1]; s[-1] = tmp; } + + +void Ppmd7_UpdateModel(CPpmd7 *p); +MY_NO_INLINE +void Ppmd7_UpdateModel(CPpmd7 *p) +{ + CPpmd_Void_Ref maxSuccessor, minSuccessor; + CTX_PTR c, mc; + unsigned s0, ns; + + + + if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) + { + /* Update Freqs in Suffix Context */ + + c = SUFFIX(p->MinContext); + + if (c->NumStats == 1) + { + CPpmd_State *s = ONE_STATE(c); + if (s->Freq < 32) + s->Freq++; + } + else + { + CPpmd_State *s = STATS(c); + Byte sym = p->FoundState->Symbol; + + if (s->Symbol != sym) + { + do + { + // s++; if (s->Symbol == sym) break; + s++; + } + while (s->Symbol != sym); + + if (s[0].Freq >= s[-1].Freq) + { + SwapStates(s); + s--; + } + } + + if (s->Freq < MAX_FREQ - 9) + { + s->Freq = (Byte)(s->Freq + 2); + c->Union2.SummFreq = (UInt16)(c->Union2.SummFreq + 2); + } + } + } + + + if (p->OrderFall == 0) + { + /* MAX ORDER context */ + /* (FoundState->Successor) is RAW-Successor. */ + p->MaxContext = p->MinContext = CreateSuccessors(p); + if (!p->MinContext) + { + RestartModel(p); + return; + } + SetSuccessor(p->FoundState, REF(p->MinContext)); + return; + } + + + /* NON-MAX ORDER context */ + + { + Byte *text = p->Text; + *text++ = p->FoundState->Symbol; + p->Text = text; + if (text >= p->UnitsStart) + { + RestartModel(p); + return; + } + maxSuccessor = REF(text); + } + + minSuccessor = SUCCESSOR(p->FoundState); + + if (minSuccessor) + { + // there is Successor for FoundState in MinContext. + // So the next context will be one order higher than MinContext. + + if (minSuccessor <= maxSuccessor) + { + // minSuccessor is RAW-Successor. So we will create real contexts records: + CTX_PTR cs = CreateSuccessors(p); + if (!cs) + { + RestartModel(p); + return; + } + minSuccessor = REF(cs); + } + + // minSuccessor now is real Context pointer that points to existing (Order+1) context + + if (--p->OrderFall == 0) + { + /* + if we move to MaxOrder context, then minSuccessor will be common Succesor for both: + MinContext that is (MaxOrder - 1) + MaxContext that is (MaxOrder) + so we don't need new RAW-Successor, and we can use real minSuccessor + as succssors for both MinContext and MaxContext. + */ + maxSuccessor = minSuccessor; + + /* + if (MaxContext != MinContext) + { + there was order fall from MaxOrder and we don't need current symbol + to transfer some RAW-Succesors to real contexts. + So we roll back pointer in raw data for one position. + } + */ + p->Text -= (p->MaxContext != p->MinContext); + } + } + else + { + /* + FoundState has NULL-Successor here. + And only root 0-order context can contain NULL-Successors. + We change Successor in FoundState to RAW-Successor, + And next context will be same 0-order root Context. + */ + SetSuccessor(p->FoundState, maxSuccessor); + minSuccessor = REF(p->MinContext); + } + + mc = p->MinContext; + c = p->MaxContext; + + p->MaxContext = p->MinContext = CTX(minSuccessor); + + if (c == mc) + return; + + // s0 : is pure Escape Freq + s0 = mc->Union2.SummFreq - (ns = mc->NumStats) - ((unsigned)p->FoundState->Freq - 1); + + do + { + unsigned ns1; + UInt32 sum; + + if ((ns1 = c->NumStats) != 1) + { + if ((ns1 & 1) == 0) + { + /* Expand for one UNIT */ + unsigned oldNU = ns1 >> 1; + unsigned i = U2I(oldNU); + if (i != U2I((size_t)oldNU + 1)) + { + void *ptr = AllocUnits(p, i + 1); + void *oldPtr; + if (!ptr) + { + RestartModel(p); + return; + } + oldPtr = STATS(c); + MyMem12Cpy(ptr, oldPtr, oldNU); + InsertNode(p, oldPtr, i); + c->Union4.Stats = STATS_REF(ptr); + } + } + sum = c->Union2.SummFreq; + /* max increase of Escape_Freq is 3 here. + total increase of Union2.SummFreq for all symbols is less than 256 here */ + sum += (UInt32)(2 * ns1 < ns) + 2 * ((unsigned)(4 * ns1 <= ns) & (sum <= 8 * ns1)); + /* original PPMdH uses 16-bit variable for (sum) here. + But (sum < 0x9000). So we don't truncate (sum) to 16-bit */ + // sum = (UInt16)sum; + } + else + { + // instead of One-symbol context we create 2-symbol context + CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0); + if (!s) + { + RestartModel(p); + return; + } + { + unsigned freq = c->Union2.State2.Freq; + // s = *ONE_STATE(c); + s->Symbol = c->Union2.State2.Symbol; + s->Successor_0 = c->Union4.State4.Successor_0; + s->Successor_1 = c->Union4.State4.Successor_1; + // SetSuccessor(s, c->Union4.Stats); // call it only for debug purposes to check the order of + // (Successor_0 and Successor_1) in LE/BE. + c->Union4.Stats = REF(s); + if (freq < MAX_FREQ / 4 - 1) + freq <<= 1; + else + freq = MAX_FREQ - 4; + // (max(s->freq) == 120), when we convert from 1-symbol into 2-symbol context + s->Freq = (Byte)freq; + // max(InitEsc = PPMD7_kExpEscape[*]) is 25. So the max(escapeFreq) is 26 here + sum = freq + p->InitEsc + (ns > 3); + } + } + + { + CPpmd_State *s = STATS(c) + ns1; + UInt32 cf = 2 * (sum + 6) * (UInt32)p->FoundState->Freq; + UInt32 sf = (UInt32)s0 + sum; + s->Symbol = p->FoundState->Symbol; + c->NumStats = (UInt16)(ns1 + 1); + SetSuccessor(s, maxSuccessor); + + if (cf < 6 * sf) + { + cf = (UInt32)1 + (cf > sf) + (cf >= 4 * sf); + sum += 3; + /* It can add (0, 1, 2) to Escape_Freq */ + } + else + { + cf = (UInt32)4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf); + sum += cf; + } + + c->Union2.SummFreq = (UInt16)sum; + s->Freq = (Byte)cf; + } + c = SUFFIX(c); + } + while (c != mc); +} + + + +MY_NO_INLINE +static void Rescale(CPpmd7 *p) +{ + unsigned i, adder, sumFreq, escFreq; + CPpmd_State *stats = STATS(p->MinContext); + CPpmd_State *s = p->FoundState; + + /* Sort the list by Freq */ + if (s != stats) + { + CPpmd_State tmp = *s; + do + s[0] = s[-1]; + while (--s != stats); + *s = tmp; + } + + sumFreq = s->Freq; + escFreq = p->MinContext->Union2.SummFreq - sumFreq; + + /* + if (p->OrderFall == 0), adder = 0 : it's allowed to remove symbol from MAX Order context + if (p->OrderFall != 0), adder = 1 : it's NOT allowed to remove symbol from NON-MAX Order context + */ + + adder = (p->OrderFall != 0); + + #ifdef PPMD7_ORDER_0_SUPPPORT + adder |= (p->MaxOrder == 0); // we don't remove symbols from order-0 context + #endif + + sumFreq = (sumFreq + 4 + adder) >> 1; + i = (unsigned)p->MinContext->NumStats - 1; + s->Freq = (Byte)sumFreq; + + do + { + unsigned freq = (++s)->Freq; + escFreq -= freq; + freq = (freq + adder) >> 1; + sumFreq += freq; + s->Freq = (Byte)freq; + if (freq > s[-1].Freq) + { + CPpmd_State tmp = *s; + CPpmd_State *s1 = s; + do + { + s1[0] = s1[-1]; + } + while (--s1 != stats && freq > s1[-1].Freq); + *s1 = tmp; + } + } + while (--i); + + if (s->Freq == 0) + { + /* Remove all items with Freq == 0 */ + CPpmd7_Context *mc; + unsigned numStats, numStatsNew, n0, n1; + + i = 0; do { i++; } while ((--s)->Freq == 0); + + /* We increase (escFreq) for the number of removed symbols. + So we will have (0.5) increase for Escape_Freq in avarage per + removed symbol after Escape_Freq halving */ + escFreq += i; + mc = p->MinContext; + numStats = mc->NumStats; + numStatsNew = numStats - i; + mc->NumStats = (UInt16)(numStatsNew); + n0 = (numStats + 1) >> 1; + + if (numStatsNew == 1) + { + /* Create Single-Symbol context */ + unsigned freq = stats->Freq; + + do + { + escFreq >>= 1; + freq = (freq + 1) >> 1; + } + while (escFreq > 1); + + s = ONE_STATE(mc); + *s = *stats; + s->Freq = (Byte)freq; // (freq <= 260 / 4) + p->FoundState = s; + InsertNode(p, stats, U2I(n0)); + return; + } + + n1 = (numStatsNew + 1) >> 1; + if (n0 != n1) + { + // p->MinContext->Union4.Stats = STATS_REF(ShrinkUnits(p, stats, n0, n1)); + unsigned i0 = U2I(n0); + unsigned i1 = U2I(n1); + if (i0 != i1) + { + if (p->FreeList[i1] != 0) + { + void *ptr = RemoveNode(p, i1); + p->MinContext->Union4.Stats = STATS_REF(ptr); + MyMem12Cpy(ptr, (const void *)stats, n1); + InsertNode(p, stats, i0); + } + else + SplitBlock(p, stats, i0, i1); + } + } + } + { + CPpmd7_Context *mc = p->MinContext; + mc->Union2.SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1)); + // Escape_Freq halving here + p->FoundState = STATS(mc); + } +} + + +CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *escFreq) +{ + CPpmd_See *see; + const CPpmd7_Context *mc = p->MinContext; + unsigned numStats = mc->NumStats; + if (numStats != 256) + { + unsigned nonMasked = numStats - numMasked; + see = p->See[(unsigned)p->NS2Indx[(size_t)nonMasked - 1]] + + (nonMasked < (unsigned)SUFFIX(mc)->NumStats - numStats) + + 2 * (unsigned)(mc->Union2.SummFreq < 11 * numStats) + + 4 * (unsigned)(numMasked > nonMasked) + + p->HiBitsFlag; + { + // if (see->Summ) field is larger than 16-bit, we need only low 16 bits of Summ + unsigned summ = (UInt16)see->Summ; // & 0xFFFF + unsigned r = (summ >> see->Shift); + see->Summ = (UInt16)(summ - r); + *escFreq = r + (r == 0); + } + } + else + { + see = &p->DummySee; + *escFreq = 1; + } + return see; +} + + +static void NextContext(CPpmd7 *p) +{ + CTX_PTR c = CTX(SUCCESSOR(p->FoundState)); + if (p->OrderFall == 0 && (const Byte *)c > p->Text) + p->MaxContext = p->MinContext = c; + else + Ppmd7_UpdateModel(p); +} + + +void Ppmd7_Update1(CPpmd7 *p) +{ + CPpmd_State *s = p->FoundState; + unsigned freq = s->Freq; + freq += 4; + p->MinContext->Union2.SummFreq = (UInt16)(p->MinContext->Union2.SummFreq + 4); + s->Freq = (Byte)freq; + if (freq > s[-1].Freq) + { + SwapStates(s); + p->FoundState = --s; + if (freq > MAX_FREQ) + Rescale(p); + } + NextContext(p); +} + + +void Ppmd7_Update1_0(CPpmd7 *p) +{ + CPpmd_State *s = p->FoundState; + CPpmd7_Context *mc = p->MinContext; + unsigned freq = s->Freq; + unsigned summFreq = mc->Union2.SummFreq; + p->PrevSuccess = (2 * freq > summFreq); + p->RunLength += (int)p->PrevSuccess; + mc->Union2.SummFreq = (UInt16)(summFreq + 4); + freq += 4; + s->Freq = (Byte)freq; + if (freq > MAX_FREQ) + Rescale(p); + NextContext(p); +} + + +/* +void Ppmd7_UpdateBin(CPpmd7 *p) +{ + unsigned freq = p->FoundState->Freq; + p->FoundState->Freq = (Byte)(freq + (freq < 128)); + p->PrevSuccess = 1; + p->RunLength++; + NextContext(p); +} +*/ + +void Ppmd7_Update2(CPpmd7 *p) +{ + CPpmd_State *s = p->FoundState; + unsigned freq = s->Freq; + freq += 4; + p->RunLength = p->InitRL; + p->MinContext->Union2.SummFreq = (UInt16)(p->MinContext->Union2.SummFreq + 4); + s->Freq = (Byte)freq; + if (freq > MAX_FREQ) + Rescale(p); + Ppmd7_UpdateModel(p); +} + + + +/* +PPMd Memory Map: +{ + [ 0 ] contains subset of original raw text, that is required to create context + records, Some symbols are not written, when max order context was reached + [ Text ] free area + [ UnitsStart ] CPpmd_State vectors and CPpmd7_Context records + [ LoUnit ] free area for CPpmd_State and CPpmd7_Context items +[ HiUnit ] CPpmd7_Context records + [ Size ] end of array +} + +These addresses don't cross at any time. +And the following condtions is true for addresses: + (0 <= Text < UnitsStart <= LoUnit <= HiUnit <= Size) + +Raw text is BYTE--aligned. +the data in block [ UnitsStart ... Size ] contains 12-bytes aligned UNITs. + +Last UNIT of array at offset (Size - 12) is root order-0 CPpmd7_Context record. +The code can free UNITs memory blocks that were allocated to store CPpmd_State vectors. +The code doesn't free UNITs allocated for CPpmd7_Context records. + +The code calls RestartModel(), when there is no free memory for allocation. +And RestartModel() changes the state to orignal start state, with full free block. + + +The code allocates UNITs with the following order: + +Allocation of 1 UNIT for Context record + - from free space (HiUnit) down to (LoUnit) + - from FreeList[0] + - AllocUnitsRare() + +AllocUnits() for CPpmd_State vectors: + - from FreeList[i] + - from free space (LoUnit) up to (HiUnit) + - AllocUnitsRare() + +AllocUnitsRare() + - if (GlueCount == 0) + { Glue lists, GlueCount = 255, allocate from FreeList[i]] } + - loop for all higher sized FreeList[...] lists + - from (UnitsStart - Text), GlueCount-- + - ERROR + + +Each Record with Context contains the CPpmd_State vector, where each +CPpmd_State contains the link to Successor. +There are 3 types of Successor: + 1) NULL-Successor - NULL pointer. NULL-Successor links can be stored + only in 0-order Root Context Record. + We use 0 value as NULL-Successor + 2) RAW-Successor - the link to position in raw text, + that "RAW-Successor" is being created after first + occurrence of new symbol for some existing context record. + (RAW-Successor > 0). + 3) RECORD-Successor - the link to CPpmd7_Context record of (Order+1), + that record is being created when we go via RAW-Successor again. + +For any successors at any time: the following condtions are true for Successor links: +(NULL-Successor < RAW-Successor < UnitsStart <= RECORD-Successor) + + +---------- Symbol Frequency, SummFreq and Range in Range_Coder ---------- + +CPpmd7_Context::SummFreq = Sum(Stats[].Freq) + Escape_Freq + +The PPMd code tries to fulfill the condition: + (SummFreq <= (256 * 128 = RC::kBot)) + +We have (Sum(Stats[].Freq) <= 256 * 124), because of (MAX_FREQ = 124) +So (4 = 128 - 124) is average reserve for Escape_Freq for each symbol. +If (CPpmd_State::Freq) is not aligned for 4, the reserve can be 5, 6 or 7. +SummFreq and Escape_Freq can be changed in Rescale() and *Update*() functions. +Rescale() can remove symbols only from max-order contexts. So Escape_Freq can increase after multiple calls of Rescale() for +max-order context. + +When the PPMd code still break (Total <= RC::Range) condition in range coder, +we have two ways to resolve that problem: + 1) we can report error, if we want to keep compatibility with original PPMd code that has no fix for such cases. + 2) we can reduce (Total) value to (RC::Range) by reducing (Escape_Freq) part of (Total) value. +*/ diff --git a/deps/LZMA-SDK/C/Ppmd7.h b/deps/LZMA-SDK/C/Ppmd7.h index 297e35fe9..d31809aeb 100644 --- a/deps/LZMA-SDK/C/Ppmd7.h +++ b/deps/LZMA-SDK/C/Ppmd7.h @@ -1,181 +1,181 @@ -/* Ppmd7.h -- Ppmd7 (PPMdH) compression codec -2021-04-13 : Igor Pavlov : Public domain -This code is based on: - PPMd var.H (2001): Dmitry Shkarin : Public domain */ - - -#ifndef __PPMD7_H -#define __PPMD7_H - -#include "Ppmd.h" - -EXTERN_C_BEGIN - -#define PPMD7_MIN_ORDER 2 -#define PPMD7_MAX_ORDER 64 - -#define PPMD7_MIN_MEM_SIZE (1 << 11) -#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) - -struct CPpmd7_Context_; - -typedef Ppmd_Ref_Type(struct CPpmd7_Context_) CPpmd7_Context_Ref; - -// MY_CPU_pragma_pack_push_1 - -typedef struct CPpmd7_Context_ -{ - UInt16 NumStats; - - - union - { - UInt16 SummFreq; - CPpmd_State2 State2; - } Union2; - - union - { - CPpmd_State_Ref Stats; - CPpmd_State4 State4; - } Union4; - - CPpmd7_Context_Ref Suffix; -} CPpmd7_Context; - -// MY_CPU_pragma_pop - -#define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->Union2) - - - - -typedef struct -{ - UInt32 Range; - UInt32 Code; - UInt32 Low; - IByteIn *Stream; -} CPpmd7_RangeDec; - - -typedef struct -{ - UInt32 Range; - Byte Cache; - // Byte _dummy_[3]; - UInt64 Low; - UInt64 CacheSize; - IByteOut *Stream; -} CPpmd7z_RangeEnc; - - -typedef struct -{ - CPpmd7_Context *MinContext, *MaxContext; - CPpmd_State *FoundState; - unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; - Int32 RunLength, InitRL; /* must be 32-bit at least */ - - UInt32 Size; - UInt32 GlueCount; - UInt32 AlignOffset; - Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; - - - - - union - { - CPpmd7_RangeDec dec; - CPpmd7z_RangeEnc enc; - } rc; - - Byte Indx2Units[PPMD_NUM_INDEXES + 2]; // +2 for alignment - Byte Units2Indx[128]; - CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; - - Byte NS2BSIndx[256], NS2Indx[256]; - Byte ExpEscape[16]; - CPpmd_See DummySee, See[25][16]; - UInt16 BinSumm[128][64]; - // int LastSymbol; -} CPpmd7; - - -void Ppmd7_Construct(CPpmd7 *p); -BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc); -void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc); -void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); -#define Ppmd7_WasAllocated(p) ((p)->Base != NULL) - - -/* ---------- Internal Functions ---------- */ - -#define Ppmd7_GetPtr(p, ptr) Ppmd_GetPtr(p, ptr) -#define Ppmd7_GetContext(p, ptr) Ppmd_GetPtr_Type(p, ptr, CPpmd7_Context) -#define Ppmd7_GetStats(p, ctx) Ppmd_GetPtr_Type(p, (ctx)->Union4.Stats, CPpmd_State) - -void Ppmd7_Update1(CPpmd7 *p); -void Ppmd7_Update1_0(CPpmd7 *p); -void Ppmd7_Update2(CPpmd7 *p); - -#define PPMD7_HiBitsFlag_3(sym) ((((unsigned)sym + 0xC0) >> (8 - 3)) & (1 << 3)) -#define PPMD7_HiBitsFlag_4(sym) ((((unsigned)sym + 0xC0) >> (8 - 4)) & (1 << 4)) -// #define PPMD7_HiBitsFlag_3(sym) ((sym) < 0x40 ? 0 : (1 << 3)) -// #define PPMD7_HiBitsFlag_4(sym) ((sym) < 0x40 ? 0 : (1 << 4)) - -#define Ppmd7_GetBinSumm(p) \ - &p->BinSumm[(size_t)(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1] \ - [ p->PrevSuccess + ((p->RunLength >> 26) & 0x20) \ - + p->NS2BSIndx[(size_t)Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] \ - + PPMD7_HiBitsFlag_4(Ppmd7Context_OneState(p->MinContext)->Symbol) \ - + (p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol)) ] - -CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); - - -/* -We support two versions of Ppmd7 (PPMdH) methods that use same CPpmd7 structure: - 1) Ppmd7a_*: original PPMdH - 2) Ppmd7z_*: modified PPMdH with 7z Range Coder -Ppmd7_*: the structures and functions that are common for both versions of PPMd7 (PPMdH) -*/ - -/* ---------- Decode ---------- */ - -#define PPMD7_SYM_END (-1) -#define PPMD7_SYM_ERROR (-2) - -/* -You must set (CPpmd7::rc.dec.Stream) before Ppmd7*_RangeDec_Init() - -Ppmd7*_DecodeSymbol() -out: - >= 0 : decoded byte - -1 : PPMD7_SYM_END : End of payload marker - -2 : PPMD7_SYM_ERROR : Data error -*/ - -/* Ppmd7a_* : original PPMdH */ -BoolInt Ppmd7a_RangeDec_Init(CPpmd7_RangeDec *p); -#define Ppmd7a_RangeDec_IsFinishedOK(p) ((p)->Code == 0) -int Ppmd7a_DecodeSymbol(CPpmd7 *p); - -/* Ppmd7z_* : modified PPMdH with 7z Range Coder */ -BoolInt Ppmd7z_RangeDec_Init(CPpmd7_RangeDec *p); -#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) -int Ppmd7z_DecodeSymbol(CPpmd7 *p); -// Byte *Ppmd7z_DecodeSymbols(CPpmd7 *p, Byte *buf, const Byte *lim); - - -/* ---------- Encode ---------- */ - -void Ppmd7z_Init_RangeEnc(CPpmd7 *p); -void Ppmd7z_Flush_RangeEnc(CPpmd7 *p); -// void Ppmd7z_EncodeSymbol(CPpmd7 *p, int symbol); -void Ppmd7z_EncodeSymbols(CPpmd7 *p, const Byte *buf, const Byte *lim); - -EXTERN_C_END - -#endif +/* Ppmd7.h -- Ppmd7 (PPMdH) compression codec +2021-04-13 : Igor Pavlov : Public domain +This code is based on: + PPMd var.H (2001): Dmitry Shkarin : Public domain */ + + +#ifndef __PPMD7_H +#define __PPMD7_H + +#include "Ppmd.h" + +EXTERN_C_BEGIN + +#define PPMD7_MIN_ORDER 2 +#define PPMD7_MAX_ORDER 64 + +#define PPMD7_MIN_MEM_SIZE (1 << 11) +#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3) + +struct CPpmd7_Context_; + +typedef Ppmd_Ref_Type(struct CPpmd7_Context_) CPpmd7_Context_Ref; + +// MY_CPU_pragma_pack_push_1 + +typedef struct CPpmd7_Context_ +{ + UInt16 NumStats; + + + union + { + UInt16 SummFreq; + CPpmd_State2 State2; + } Union2; + + union + { + CPpmd_State_Ref Stats; + CPpmd_State4 State4; + } Union4; + + CPpmd7_Context_Ref Suffix; +} CPpmd7_Context; + +// MY_CPU_pragma_pop + +#define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->Union2) + + + + +typedef struct +{ + UInt32 Range; + UInt32 Code; + UInt32 Low; + IByteIn *Stream; +} CPpmd7_RangeDec; + + +typedef struct +{ + UInt32 Range; + Byte Cache; + // Byte _dummy_[3]; + UInt64 Low; + UInt64 CacheSize; + IByteOut *Stream; +} CPpmd7z_RangeEnc; + + +typedef struct +{ + CPpmd7_Context *MinContext, *MaxContext; + CPpmd_State *FoundState; + unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag; + Int32 RunLength, InitRL; /* must be 32-bit at least */ + + UInt32 Size; + UInt32 GlueCount; + UInt32 AlignOffset; + Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; + + + + + union + { + CPpmd7_RangeDec dec; + CPpmd7z_RangeEnc enc; + } rc; + + Byte Indx2Units[PPMD_NUM_INDEXES + 2]; // +2 for alignment + Byte Units2Indx[128]; + CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; + + Byte NS2BSIndx[256], NS2Indx[256]; + Byte ExpEscape[16]; + CPpmd_See DummySee, See[25][16]; + UInt16 BinSumm[128][64]; + // int LastSymbol; +} CPpmd7; + + +void Ppmd7_Construct(CPpmd7 *p); +BoolInt Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAllocPtr alloc); +void Ppmd7_Free(CPpmd7 *p, ISzAllocPtr alloc); +void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder); +#define Ppmd7_WasAllocated(p) ((p)->Base != NULL) + + +/* ---------- Internal Functions ---------- */ + +#define Ppmd7_GetPtr(p, ptr) Ppmd_GetPtr(p, ptr) +#define Ppmd7_GetContext(p, ptr) Ppmd_GetPtr_Type(p, ptr, CPpmd7_Context) +#define Ppmd7_GetStats(p, ctx) Ppmd_GetPtr_Type(p, (ctx)->Union4.Stats, CPpmd_State) + +void Ppmd7_Update1(CPpmd7 *p); +void Ppmd7_Update1_0(CPpmd7 *p); +void Ppmd7_Update2(CPpmd7 *p); + +#define PPMD7_HiBitsFlag_3(sym) ((((unsigned)sym + 0xC0) >> (8 - 3)) & (1 << 3)) +#define PPMD7_HiBitsFlag_4(sym) ((((unsigned)sym + 0xC0) >> (8 - 4)) & (1 << 4)) +// #define PPMD7_HiBitsFlag_3(sym) ((sym) < 0x40 ? 0 : (1 << 3)) +// #define PPMD7_HiBitsFlag_4(sym) ((sym) < 0x40 ? 0 : (1 << 4)) + +#define Ppmd7_GetBinSumm(p) \ + &p->BinSumm[(size_t)(unsigned)Ppmd7Context_OneState(p->MinContext)->Freq - 1] \ + [ p->PrevSuccess + ((p->RunLength >> 26) & 0x20) \ + + p->NS2BSIndx[(size_t)Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] \ + + PPMD7_HiBitsFlag_4(Ppmd7Context_OneState(p->MinContext)->Symbol) \ + + (p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol)) ] + +CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale); + + +/* +We support two versions of Ppmd7 (PPMdH) methods that use same CPpmd7 structure: + 1) Ppmd7a_*: original PPMdH + 2) Ppmd7z_*: modified PPMdH with 7z Range Coder +Ppmd7_*: the structures and functions that are common for both versions of PPMd7 (PPMdH) +*/ + +/* ---------- Decode ---------- */ + +#define PPMD7_SYM_END (-1) +#define PPMD7_SYM_ERROR (-2) + +/* +You must set (CPpmd7::rc.dec.Stream) before Ppmd7*_RangeDec_Init() + +Ppmd7*_DecodeSymbol() +out: + >= 0 : decoded byte + -1 : PPMD7_SYM_END : End of payload marker + -2 : PPMD7_SYM_ERROR : Data error +*/ + +/* Ppmd7a_* : original PPMdH */ +BoolInt Ppmd7a_RangeDec_Init(CPpmd7_RangeDec *p); +#define Ppmd7a_RangeDec_IsFinishedOK(p) ((p)->Code == 0) +int Ppmd7a_DecodeSymbol(CPpmd7 *p); + +/* Ppmd7z_* : modified PPMdH with 7z Range Coder */ +BoolInt Ppmd7z_RangeDec_Init(CPpmd7_RangeDec *p); +#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0) +int Ppmd7z_DecodeSymbol(CPpmd7 *p); +// Byte *Ppmd7z_DecodeSymbols(CPpmd7 *p, Byte *buf, const Byte *lim); + + +/* ---------- Encode ---------- */ + +void Ppmd7z_Init_RangeEnc(CPpmd7 *p); +void Ppmd7z_Flush_RangeEnc(CPpmd7 *p); +// void Ppmd7z_EncodeSymbol(CPpmd7 *p, int symbol); +void Ppmd7z_EncodeSymbols(CPpmd7 *p, const Byte *buf, const Byte *lim); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Ppmd7Dec.c b/deps/LZMA-SDK/C/Ppmd7Dec.c index a18f0b873..55d74ff9d 100644 --- a/deps/LZMA-SDK/C/Ppmd7Dec.c +++ b/deps/LZMA-SDK/C/Ppmd7Dec.c @@ -1,297 +1,297 @@ -/* Ppmd7Dec.c -- Ppmd7z (PPMdH with 7z Range Coder) Decoder -2021-04-13 : Igor Pavlov : Public domain -This code is based on: - PPMd var.H (2001): Dmitry Shkarin : Public domain */ - - -#include "Precomp.h" - -#include "Ppmd7.h" - -#define kTopValue (1 << 24) - - -#define READ_BYTE(p) IByteIn_Read((p)->Stream) - -BoolInt Ppmd7z_RangeDec_Init(CPpmd7_RangeDec *p) -{ - unsigned i; - p->Code = 0; - p->Range = 0xFFFFFFFF; - if (READ_BYTE(p) != 0) - return False; - for (i = 0; i < 4; i++) - p->Code = (p->Code << 8) | READ_BYTE(p); - return (p->Code < 0xFFFFFFFF); -} - -#define RC_NORM_BASE(p) if ((p)->Range < kTopValue) \ - { (p)->Code = ((p)->Code << 8) | READ_BYTE(p); (p)->Range <<= 8; - -#define RC_NORM_1(p) RC_NORM_BASE(p) } -#define RC_NORM(p) RC_NORM_BASE(p) RC_NORM_BASE(p) }} - -// we must use only one type of Normalization from two: LOCAL or REMOTE -#define RC_NORM_LOCAL(p) // RC_NORM(p) -#define RC_NORM_REMOTE(p) RC_NORM(p) - -#define R (&p->rc.dec) - -MY_FORCE_INLINE -// MY_NO_INLINE -static void RangeDec_Decode(CPpmd7 *p, UInt32 start, UInt32 size) -{ - - - R->Code -= start * R->Range; - R->Range *= size; - RC_NORM_LOCAL(R) -} - -#define RC_Decode(start, size) RangeDec_Decode(p, start, size); -#define RC_DecodeFinal(start, size) RC_Decode(start, size) RC_NORM_REMOTE(R) -#define RC_GetThreshold(total) (R->Code / (R->Range /= (total))) - - -#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref)) -typedef CPpmd7_Context * CTX_PTR; -#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) -void Ppmd7_UpdateModel(CPpmd7 *p); - -#define MASK(sym) ((unsigned char *)charMask)[sym] -// MY_FORCE_INLINE -// static -int Ppmd7z_DecodeSymbol(CPpmd7 *p) -{ - size_t charMask[256 / sizeof(size_t)]; - - if (p->MinContext->NumStats != 1) - { - CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); - unsigned i; - UInt32 count, hiCnt; - UInt32 summFreq = p->MinContext->Union2.SummFreq; - - - - - count = RC_GetThreshold(summFreq); - hiCnt = count; - - if ((Int32)(count -= s->Freq) < 0) - { - Byte sym; - RC_DecodeFinal(0, s->Freq); - p->FoundState = s; - sym = s->Symbol; - Ppmd7_Update1_0(p); - return sym; - } - - p->PrevSuccess = 0; - i = (unsigned)p->MinContext->NumStats - 1; - - do - { - if ((Int32)(count -= (++s)->Freq) < 0) - { - Byte sym; - RC_DecodeFinal((hiCnt - count) - s->Freq, s->Freq); - p->FoundState = s; - sym = s->Symbol; - Ppmd7_Update1(p); - return sym; - } - } - while (--i); - - if (hiCnt >= summFreq) - return PPMD7_SYM_ERROR; - - hiCnt -= count; - RC_Decode(hiCnt, summFreq - hiCnt); - - p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol); - PPMD_SetAllBitsIn256Bytes(charMask); - // i = p->MinContext->NumStats - 1; - // do { MASK((--s)->Symbol) = 0; } while (--i); - { - CPpmd_State *s2 = Ppmd7_GetStats(p, p->MinContext); - MASK(s->Symbol) = 0; - do - { - unsigned sym0 = s2[0].Symbol; - unsigned sym1 = s2[1].Symbol; - s2 += 2; - MASK(sym0) = 0; - MASK(sym1) = 0; - } - while (s2 < s); - } - } - else - { - CPpmd_State *s = Ppmd7Context_OneState(p->MinContext); - UInt16 *prob = Ppmd7_GetBinSumm(p); - UInt32 pr = *prob; - UInt32 size0 = (R->Range >> 14) * pr; - pr = PPMD_UPDATE_PROB_1(pr); - - if (R->Code < size0) - { - Byte sym; - *prob = (UInt16)(pr + (1 << PPMD_INT_BITS)); - - // RangeDec_DecodeBit0(size0); - R->Range = size0; - RC_NORM_1(R) - /* we can use single byte normalization here because of - (min(BinSumm[][]) = 95) > (1 << (14 - 8)) */ - - // sym = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol; - // Ppmd7_UpdateBin(p); - { - unsigned freq = s->Freq; - CTX_PTR c = CTX(SUCCESSOR(s)); - sym = s->Symbol; - p->FoundState = s; - p->PrevSuccess = 1; - p->RunLength++; - s->Freq = (Byte)(freq + (freq < 128)); - // NextContext(p); - if (p->OrderFall == 0 && (const Byte *)c > p->Text) - p->MaxContext = p->MinContext = c; - else - Ppmd7_UpdateModel(p); - } - return sym; - } - - *prob = (UInt16)pr; - p->InitEsc = p->ExpEscape[pr >> 10]; - - // RangeDec_DecodeBit1(size0); - - R->Code -= size0; - R->Range -= size0; - RC_NORM_LOCAL(R) - - PPMD_SetAllBitsIn256Bytes(charMask); - MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0; - p->PrevSuccess = 0; - } - - for (;;) - { - CPpmd_State *s, *s2; - UInt32 freqSum, count, hiCnt; - - CPpmd_See *see; - CPpmd7_Context *mc; - unsigned numMasked; - RC_NORM_REMOTE(R) - mc = p->MinContext; - numMasked = mc->NumStats; - - do - { - p->OrderFall++; - if (!mc->Suffix) - return PPMD7_SYM_END; - mc = Ppmd7_GetContext(p, mc->Suffix); - } - while (mc->NumStats == numMasked); - - s = Ppmd7_GetStats(p, mc); - - { - unsigned num = mc->NumStats; - unsigned num2 = num / 2; - - num &= 1; - hiCnt = (s->Freq & (unsigned)(MASK(s->Symbol))) & (0 - (UInt32)num); - s += num; - p->MinContext = mc; - - do - { - unsigned sym0 = s[0].Symbol; - unsigned sym1 = s[1].Symbol; - s += 2; - hiCnt += (s[-2].Freq & (unsigned)(MASK(sym0))); - hiCnt += (s[-1].Freq & (unsigned)(MASK(sym1))); - } - while (--num2); - } - - see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum); - freqSum += hiCnt; - - - - - count = RC_GetThreshold(freqSum); - - if (count < hiCnt) - { - Byte sym; - - s = Ppmd7_GetStats(p, p->MinContext); - hiCnt = count; - // count -= s->Freq & (unsigned)(MASK(s->Symbol)); - // if ((Int32)count >= 0) - { - for (;;) - { - count -= s->Freq & (unsigned)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break; - // count -= s->Freq & (unsigned)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break; - }; - } - s--; - RC_DecodeFinal((hiCnt - count) - s->Freq, s->Freq); - - // new (see->Summ) value can overflow over 16-bits in some rare cases - Ppmd_See_Update(see); - p->FoundState = s; - sym = s->Symbol; - Ppmd7_Update2(p); - return sym; - } - - if (count >= freqSum) - return PPMD7_SYM_ERROR; - - RC_Decode(hiCnt, freqSum - hiCnt); - - // We increase (see->Summ) for sum of Freqs of all non_Masked symbols. - // new (see->Summ) value can overflow over 16-bits in some rare cases - see->Summ = (UInt16)(see->Summ + freqSum); - - s = Ppmd7_GetStats(p, p->MinContext); - s2 = s + p->MinContext->NumStats; - do - { - MASK(s->Symbol) = 0; - s++; - } - while (s != s2); - } -} - -/* -Byte *Ppmd7z_DecodeSymbols(CPpmd7 *p, Byte *buf, const Byte *lim) -{ - int sym = 0; - if (buf != lim) - do - { - sym = Ppmd7z_DecodeSymbol(p); - if (sym < 0) - break; - *buf = (Byte)sym; - } - while (++buf < lim); - p->LastSymbol = sym; - return buf; -} -*/ +/* Ppmd7Dec.c -- Ppmd7z (PPMdH with 7z Range Coder) Decoder +2021-04-13 : Igor Pavlov : Public domain +This code is based on: + PPMd var.H (2001): Dmitry Shkarin : Public domain */ + + +#include "Precomp.h" + +#include "Ppmd7.h" + +#define kTopValue (1 << 24) + + +#define READ_BYTE(p) IByteIn_Read((p)->Stream) + +BoolInt Ppmd7z_RangeDec_Init(CPpmd7_RangeDec *p) +{ + unsigned i; + p->Code = 0; + p->Range = 0xFFFFFFFF; + if (READ_BYTE(p) != 0) + return False; + for (i = 0; i < 4; i++) + p->Code = (p->Code << 8) | READ_BYTE(p); + return (p->Code < 0xFFFFFFFF); +} + +#define RC_NORM_BASE(p) if ((p)->Range < kTopValue) \ + { (p)->Code = ((p)->Code << 8) | READ_BYTE(p); (p)->Range <<= 8; + +#define RC_NORM_1(p) RC_NORM_BASE(p) } +#define RC_NORM(p) RC_NORM_BASE(p) RC_NORM_BASE(p) }} + +// we must use only one type of Normalization from two: LOCAL or REMOTE +#define RC_NORM_LOCAL(p) // RC_NORM(p) +#define RC_NORM_REMOTE(p) RC_NORM(p) + +#define R (&p->rc.dec) + +MY_FORCE_INLINE +// MY_NO_INLINE +static void RangeDec_Decode(CPpmd7 *p, UInt32 start, UInt32 size) +{ + + + R->Code -= start * R->Range; + R->Range *= size; + RC_NORM_LOCAL(R) +} + +#define RC_Decode(start, size) RangeDec_Decode(p, start, size); +#define RC_DecodeFinal(start, size) RC_Decode(start, size) RC_NORM_REMOTE(R) +#define RC_GetThreshold(total) (R->Code / (R->Range /= (total))) + + +#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref)) +typedef CPpmd7_Context * CTX_PTR; +#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) +void Ppmd7_UpdateModel(CPpmd7 *p); + +#define MASK(sym) ((unsigned char *)charMask)[sym] +// MY_FORCE_INLINE +// static +int Ppmd7z_DecodeSymbol(CPpmd7 *p) +{ + size_t charMask[256 / sizeof(size_t)]; + + if (p->MinContext->NumStats != 1) + { + CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); + unsigned i; + UInt32 count, hiCnt; + UInt32 summFreq = p->MinContext->Union2.SummFreq; + + + + + count = RC_GetThreshold(summFreq); + hiCnt = count; + + if ((Int32)(count -= s->Freq) < 0) + { + Byte sym; + RC_DecodeFinal(0, s->Freq); + p->FoundState = s; + sym = s->Symbol; + Ppmd7_Update1_0(p); + return sym; + } + + p->PrevSuccess = 0; + i = (unsigned)p->MinContext->NumStats - 1; + + do + { + if ((Int32)(count -= (++s)->Freq) < 0) + { + Byte sym; + RC_DecodeFinal((hiCnt - count) - s->Freq, s->Freq); + p->FoundState = s; + sym = s->Symbol; + Ppmd7_Update1(p); + return sym; + } + } + while (--i); + + if (hiCnt >= summFreq) + return PPMD7_SYM_ERROR; + + hiCnt -= count; + RC_Decode(hiCnt, summFreq - hiCnt); + + p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol); + PPMD_SetAllBitsIn256Bytes(charMask); + // i = p->MinContext->NumStats - 1; + // do { MASK((--s)->Symbol) = 0; } while (--i); + { + CPpmd_State *s2 = Ppmd7_GetStats(p, p->MinContext); + MASK(s->Symbol) = 0; + do + { + unsigned sym0 = s2[0].Symbol; + unsigned sym1 = s2[1].Symbol; + s2 += 2; + MASK(sym0) = 0; + MASK(sym1) = 0; + } + while (s2 < s); + } + } + else + { + CPpmd_State *s = Ppmd7Context_OneState(p->MinContext); + UInt16 *prob = Ppmd7_GetBinSumm(p); + UInt32 pr = *prob; + UInt32 size0 = (R->Range >> 14) * pr; + pr = PPMD_UPDATE_PROB_1(pr); + + if (R->Code < size0) + { + Byte sym; + *prob = (UInt16)(pr + (1 << PPMD_INT_BITS)); + + // RangeDec_DecodeBit0(size0); + R->Range = size0; + RC_NORM_1(R) + /* we can use single byte normalization here because of + (min(BinSumm[][]) = 95) > (1 << (14 - 8)) */ + + // sym = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol; + // Ppmd7_UpdateBin(p); + { + unsigned freq = s->Freq; + CTX_PTR c = CTX(SUCCESSOR(s)); + sym = s->Symbol; + p->FoundState = s; + p->PrevSuccess = 1; + p->RunLength++; + s->Freq = (Byte)(freq + (freq < 128)); + // NextContext(p); + if (p->OrderFall == 0 && (const Byte *)c > p->Text) + p->MaxContext = p->MinContext = c; + else + Ppmd7_UpdateModel(p); + } + return sym; + } + + *prob = (UInt16)pr; + p->InitEsc = p->ExpEscape[pr >> 10]; + + // RangeDec_DecodeBit1(size0); + + R->Code -= size0; + R->Range -= size0; + RC_NORM_LOCAL(R) + + PPMD_SetAllBitsIn256Bytes(charMask); + MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0; + p->PrevSuccess = 0; + } + + for (;;) + { + CPpmd_State *s, *s2; + UInt32 freqSum, count, hiCnt; + + CPpmd_See *see; + CPpmd7_Context *mc; + unsigned numMasked; + RC_NORM_REMOTE(R) + mc = p->MinContext; + numMasked = mc->NumStats; + + do + { + p->OrderFall++; + if (!mc->Suffix) + return PPMD7_SYM_END; + mc = Ppmd7_GetContext(p, mc->Suffix); + } + while (mc->NumStats == numMasked); + + s = Ppmd7_GetStats(p, mc); + + { + unsigned num = mc->NumStats; + unsigned num2 = num / 2; + + num &= 1; + hiCnt = (s->Freq & (unsigned)(MASK(s->Symbol))) & (0 - (UInt32)num); + s += num; + p->MinContext = mc; + + do + { + unsigned sym0 = s[0].Symbol; + unsigned sym1 = s[1].Symbol; + s += 2; + hiCnt += (s[-2].Freq & (unsigned)(MASK(sym0))); + hiCnt += (s[-1].Freq & (unsigned)(MASK(sym1))); + } + while (--num2); + } + + see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum); + freqSum += hiCnt; + + + + + count = RC_GetThreshold(freqSum); + + if (count < hiCnt) + { + Byte sym; + + s = Ppmd7_GetStats(p, p->MinContext); + hiCnt = count; + // count -= s->Freq & (unsigned)(MASK(s->Symbol)); + // if ((Int32)count >= 0) + { + for (;;) + { + count -= s->Freq & (unsigned)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break; + // count -= s->Freq & (unsigned)(MASK((s)->Symbol)); s++; if ((Int32)count < 0) break; + }; + } + s--; + RC_DecodeFinal((hiCnt - count) - s->Freq, s->Freq); + + // new (see->Summ) value can overflow over 16-bits in some rare cases + Ppmd_See_Update(see); + p->FoundState = s; + sym = s->Symbol; + Ppmd7_Update2(p); + return sym; + } + + if (count >= freqSum) + return PPMD7_SYM_ERROR; + + RC_Decode(hiCnt, freqSum - hiCnt); + + // We increase (see->Summ) for sum of Freqs of all non_Masked symbols. + // new (see->Summ) value can overflow over 16-bits in some rare cases + see->Summ = (UInt16)(see->Summ + freqSum); + + s = Ppmd7_GetStats(p, p->MinContext); + s2 = s + p->MinContext->NumStats; + do + { + MASK(s->Symbol) = 0; + s++; + } + while (s != s2); + } +} + +/* +Byte *Ppmd7z_DecodeSymbols(CPpmd7 *p, Byte *buf, const Byte *lim) +{ + int sym = 0; + if (buf != lim) + do + { + sym = Ppmd7z_DecodeSymbol(p); + if (sym < 0) + break; + *buf = (Byte)sym; + } + while (++buf < lim); + p->LastSymbol = sym; + return buf; +} +*/ diff --git a/deps/LZMA-SDK/C/Ppmd7Enc.c b/deps/LZMA-SDK/C/Ppmd7Enc.c index 6af1ec15e..62139c5b6 100644 --- a/deps/LZMA-SDK/C/Ppmd7Enc.c +++ b/deps/LZMA-SDK/C/Ppmd7Enc.c @@ -1,323 +1,323 @@ -/* Ppmd7Enc.c -- Ppmd7z (PPMdH with 7z Range Coder) Encoder -2021-04-13 : Igor Pavlov : Public domain -This code is based on: - PPMd var.H (2001): Dmitry Shkarin : Public domain */ - - -#include "Precomp.h" - -#include "Ppmd7.h" - -#define kTopValue (1 << 24) - -#define R (&p->rc.enc) - -void Ppmd7z_Init_RangeEnc(CPpmd7 *p) -{ - R->Low = 0; - R->Range = 0xFFFFFFFF; - R->Cache = 0; - R->CacheSize = 1; -} - -MY_NO_INLINE -static void RangeEnc_ShiftLow(CPpmd7 *p) -{ - if ((UInt32)R->Low < (UInt32)0xFF000000 || (unsigned)(R->Low >> 32) != 0) - { - Byte temp = R->Cache; - do - { - IByteOut_Write(R->Stream, (Byte)(temp + (Byte)(R->Low >> 32))); - temp = 0xFF; - } - while (--R->CacheSize != 0); - R->Cache = (Byte)((UInt32)R->Low >> 24); - } - R->CacheSize++; - R->Low = (UInt32)((UInt32)R->Low << 8); -} - -#define RC_NORM_BASE(p) if (R->Range < kTopValue) { R->Range <<= 8; RangeEnc_ShiftLow(p); -#define RC_NORM_1(p) RC_NORM_BASE(p) } -#define RC_NORM(p) RC_NORM_BASE(p) RC_NORM_BASE(p) }} - -// we must use only one type of Normalization from two: LOCAL or REMOTE -#define RC_NORM_LOCAL(p) // RC_NORM(p) -#define RC_NORM_REMOTE(p) RC_NORM(p) - -/* -#define RangeEnc_Encode(p, start, _size_) \ - { UInt32 size = _size_; \ - R->Low += start * R->Range; \ - R->Range *= size; \ - RC_NORM_LOCAL(p); } -*/ - -MY_FORCE_INLINE -// MY_NO_INLINE -static void RangeEnc_Encode(CPpmd7 *p, UInt32 start, UInt32 size) -{ - R->Low += start * R->Range; - R->Range *= size; - RC_NORM_LOCAL(p); -} - -void Ppmd7z_Flush_RangeEnc(CPpmd7 *p) -{ - unsigned i; - for (i = 0; i < 5; i++) - RangeEnc_ShiftLow(p); -} - - - -#define RC_Encode(start, size) RangeEnc_Encode(p, start, size); -#define RC_EncodeFinal(start, size) RC_Encode(start, size); RC_NORM_REMOTE(p); - -#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref)) -#define SUFFIX(ctx) CTX((ctx)->Suffix) -typedef CPpmd7_Context * CTX_PTR; -#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) - -void Ppmd7_UpdateModel(CPpmd7 *p); - -#define MASK(sym) ((unsigned char *)charMask)[sym] - -MY_FORCE_INLINE -static -void Ppmd7z_EncodeSymbol(CPpmd7 *p, int symbol) -{ - size_t charMask[256 / sizeof(size_t)]; - - if (p->MinContext->NumStats != 1) - { - CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); - UInt32 sum; - unsigned i; - - - - - R->Range /= p->MinContext->Union2.SummFreq; - - if (s->Symbol == symbol) - { - // R->Range /= p->MinContext->Union2.SummFreq; - RC_EncodeFinal(0, s->Freq); - p->FoundState = s; - Ppmd7_Update1_0(p); - return; - } - p->PrevSuccess = 0; - sum = s->Freq; - i = (unsigned)p->MinContext->NumStats - 1; - do - { - if ((++s)->Symbol == symbol) - { - // R->Range /= p->MinContext->Union2.SummFreq; - RC_EncodeFinal(sum, s->Freq); - p->FoundState = s; - Ppmd7_Update1(p); - return; - } - sum += s->Freq; - } - while (--i); - - // R->Range /= p->MinContext->Union2.SummFreq; - RC_Encode(sum, p->MinContext->Union2.SummFreq - sum); - - p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol); - PPMD_SetAllBitsIn256Bytes(charMask); - // MASK(s->Symbol) = 0; - // i = p->MinContext->NumStats - 1; - // do { MASK((--s)->Symbol) = 0; } while (--i); - { - CPpmd_State *s2 = Ppmd7_GetStats(p, p->MinContext); - MASK(s->Symbol) = 0; - do - { - unsigned sym0 = s2[0].Symbol; - unsigned sym1 = s2[1].Symbol; - s2 += 2; - MASK(sym0) = 0; - MASK(sym1) = 0; - } - while (s2 < s); - } - } - else - { - UInt16 *prob = Ppmd7_GetBinSumm(p); - CPpmd_State *s = Ppmd7Context_OneState(p->MinContext); - UInt32 pr = *prob; - UInt32 bound = (R->Range >> 14) * pr; - pr = PPMD_UPDATE_PROB_1(pr); - if (s->Symbol == symbol) - { - *prob = (UInt16)(pr + (1 << PPMD_INT_BITS)); - // RangeEnc_EncodeBit_0(p, bound); - R->Range = bound; - RC_NORM_1(p); - - // p->FoundState = s; - // Ppmd7_UpdateBin(p); - { - unsigned freq = s->Freq; - CTX_PTR c = CTX(SUCCESSOR(s)); - p->FoundState = s; - p->PrevSuccess = 1; - p->RunLength++; - s->Freq = (Byte)(freq + (freq < 128)); - // NextContext(p); - if (p->OrderFall == 0 && (const Byte *)c > p->Text) - p->MaxContext = p->MinContext = c; - else - Ppmd7_UpdateModel(p); - } - return; - } - - *prob = (UInt16)pr; - p->InitEsc = p->ExpEscape[pr >> 10]; - // RangeEnc_EncodeBit_1(p, bound); - R->Low += bound; - R->Range -= bound; - RC_NORM_LOCAL(p) - - PPMD_SetAllBitsIn256Bytes(charMask); - MASK(s->Symbol) = 0; - p->PrevSuccess = 0; - } - - for (;;) - { - CPpmd_See *see; - CPpmd_State *s; - UInt32 sum, escFreq; - CPpmd7_Context *mc; - unsigned i, numMasked; - - RC_NORM_REMOTE(p) - - mc = p->MinContext; - numMasked = mc->NumStats; - - do - { - p->OrderFall++; - if (!mc->Suffix) - return; /* EndMarker (symbol = -1) */ - mc = Ppmd7_GetContext(p, mc->Suffix); - i = mc->NumStats; - } - while (i == numMasked); - - p->MinContext = mc; - - // see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq); - { - if (i != 256) - { - unsigned nonMasked = i - numMasked; - see = p->See[(unsigned)p->NS2Indx[(size_t)nonMasked - 1]] - + p->HiBitsFlag - + (nonMasked < (unsigned)SUFFIX(mc)->NumStats - i) - + 2 * (unsigned)(mc->Union2.SummFreq < 11 * i) - + 4 * (unsigned)(numMasked > nonMasked); - { - // if (see->Summ) field is larger than 16-bit, we need only low 16 bits of Summ - unsigned summ = (UInt16)see->Summ; // & 0xFFFF - unsigned r = (summ >> see->Shift); - see->Summ = (UInt16)(summ - r); - escFreq = r + (r == 0); - } - } - else - { - see = &p->DummySee; - escFreq = 1; - } - } - - s = Ppmd7_GetStats(p, mc); - sum = 0; - // i = mc->NumStats; - - do - { - unsigned cur = s->Symbol; - if ((int)cur == symbol) - { - UInt32 low = sum; - UInt32 freq = s->Freq; - unsigned num2; - - Ppmd_See_Update(see); - p->FoundState = s; - sum += escFreq; - - num2 = i / 2; - i &= 1; - sum += freq & (0 - (UInt32)i); - if (num2 != 0) - { - s += i; - for (;;) - { - unsigned sym0 = s[0].Symbol; - unsigned sym1 = s[1].Symbol; - s += 2; - sum += (s[-2].Freq & (unsigned)(MASK(sym0))); - sum += (s[-1].Freq & (unsigned)(MASK(sym1))); - if (--num2 == 0) - break; - } - } - - - R->Range /= sum; - RC_EncodeFinal(low, freq); - Ppmd7_Update2(p); - return; - } - sum += (s->Freq & (unsigned)(MASK(cur))); - s++; - } - while (--i); - - { - UInt32 total = sum + escFreq; - see->Summ = (UInt16)(see->Summ + total); - - R->Range /= total; - RC_Encode(sum, escFreq); - } - - { - CPpmd_State *s2 = Ppmd7_GetStats(p, p->MinContext); - s--; - MASK(s->Symbol) = 0; - do - { - unsigned sym0 = s2[0].Symbol; - unsigned sym1 = s2[1].Symbol; - s2 += 2; - MASK(sym0) = 0; - MASK(sym1) = 0; - } - while (s2 < s); - } - } -} - - -void Ppmd7z_EncodeSymbols(CPpmd7 *p, const Byte *buf, const Byte *lim) -{ - for (; buf < lim; buf++) - { - Ppmd7z_EncodeSymbol(p, *buf); - } -} +/* Ppmd7Enc.c -- Ppmd7z (PPMdH with 7z Range Coder) Encoder +2021-04-13 : Igor Pavlov : Public domain +This code is based on: + PPMd var.H (2001): Dmitry Shkarin : Public domain */ + + +#include "Precomp.h" + +#include "Ppmd7.h" + +#define kTopValue (1 << 24) + +#define R (&p->rc.enc) + +void Ppmd7z_Init_RangeEnc(CPpmd7 *p) +{ + R->Low = 0; + R->Range = 0xFFFFFFFF; + R->Cache = 0; + R->CacheSize = 1; +} + +MY_NO_INLINE +static void RangeEnc_ShiftLow(CPpmd7 *p) +{ + if ((UInt32)R->Low < (UInt32)0xFF000000 || (unsigned)(R->Low >> 32) != 0) + { + Byte temp = R->Cache; + do + { + IByteOut_Write(R->Stream, (Byte)(temp + (Byte)(R->Low >> 32))); + temp = 0xFF; + } + while (--R->CacheSize != 0); + R->Cache = (Byte)((UInt32)R->Low >> 24); + } + R->CacheSize++; + R->Low = (UInt32)((UInt32)R->Low << 8); +} + +#define RC_NORM_BASE(p) if (R->Range < kTopValue) { R->Range <<= 8; RangeEnc_ShiftLow(p); +#define RC_NORM_1(p) RC_NORM_BASE(p) } +#define RC_NORM(p) RC_NORM_BASE(p) RC_NORM_BASE(p) }} + +// we must use only one type of Normalization from two: LOCAL or REMOTE +#define RC_NORM_LOCAL(p) // RC_NORM(p) +#define RC_NORM_REMOTE(p) RC_NORM(p) + +/* +#define RangeEnc_Encode(p, start, _size_) \ + { UInt32 size = _size_; \ + R->Low += start * R->Range; \ + R->Range *= size; \ + RC_NORM_LOCAL(p); } +*/ + +MY_FORCE_INLINE +// MY_NO_INLINE +static void RangeEnc_Encode(CPpmd7 *p, UInt32 start, UInt32 size) +{ + R->Low += start * R->Range; + R->Range *= size; + RC_NORM_LOCAL(p); +} + +void Ppmd7z_Flush_RangeEnc(CPpmd7 *p) +{ + unsigned i; + for (i = 0; i < 5; i++) + RangeEnc_ShiftLow(p); +} + + + +#define RC_Encode(start, size) RangeEnc_Encode(p, start, size); +#define RC_EncodeFinal(start, size) RC_Encode(start, size); RC_NORM_REMOTE(p); + +#define CTX(ref) ((CPpmd7_Context *)Ppmd7_GetContext(p, ref)) +#define SUFFIX(ctx) CTX((ctx)->Suffix) +typedef CPpmd7_Context * CTX_PTR; +#define SUCCESSOR(p) Ppmd_GET_SUCCESSOR(p) + +void Ppmd7_UpdateModel(CPpmd7 *p); + +#define MASK(sym) ((unsigned char *)charMask)[sym] + +MY_FORCE_INLINE +static +void Ppmd7z_EncodeSymbol(CPpmd7 *p, int symbol) +{ + size_t charMask[256 / sizeof(size_t)]; + + if (p->MinContext->NumStats != 1) + { + CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext); + UInt32 sum; + unsigned i; + + + + + R->Range /= p->MinContext->Union2.SummFreq; + + if (s->Symbol == symbol) + { + // R->Range /= p->MinContext->Union2.SummFreq; + RC_EncodeFinal(0, s->Freq); + p->FoundState = s; + Ppmd7_Update1_0(p); + return; + } + p->PrevSuccess = 0; + sum = s->Freq; + i = (unsigned)p->MinContext->NumStats - 1; + do + { + if ((++s)->Symbol == symbol) + { + // R->Range /= p->MinContext->Union2.SummFreq; + RC_EncodeFinal(sum, s->Freq); + p->FoundState = s; + Ppmd7_Update1(p); + return; + } + sum += s->Freq; + } + while (--i); + + // R->Range /= p->MinContext->Union2.SummFreq; + RC_Encode(sum, p->MinContext->Union2.SummFreq - sum); + + p->HiBitsFlag = PPMD7_HiBitsFlag_3(p->FoundState->Symbol); + PPMD_SetAllBitsIn256Bytes(charMask); + // MASK(s->Symbol) = 0; + // i = p->MinContext->NumStats - 1; + // do { MASK((--s)->Symbol) = 0; } while (--i); + { + CPpmd_State *s2 = Ppmd7_GetStats(p, p->MinContext); + MASK(s->Symbol) = 0; + do + { + unsigned sym0 = s2[0].Symbol; + unsigned sym1 = s2[1].Symbol; + s2 += 2; + MASK(sym0) = 0; + MASK(sym1) = 0; + } + while (s2 < s); + } + } + else + { + UInt16 *prob = Ppmd7_GetBinSumm(p); + CPpmd_State *s = Ppmd7Context_OneState(p->MinContext); + UInt32 pr = *prob; + UInt32 bound = (R->Range >> 14) * pr; + pr = PPMD_UPDATE_PROB_1(pr); + if (s->Symbol == symbol) + { + *prob = (UInt16)(pr + (1 << PPMD_INT_BITS)); + // RangeEnc_EncodeBit_0(p, bound); + R->Range = bound; + RC_NORM_1(p); + + // p->FoundState = s; + // Ppmd7_UpdateBin(p); + { + unsigned freq = s->Freq; + CTX_PTR c = CTX(SUCCESSOR(s)); + p->FoundState = s; + p->PrevSuccess = 1; + p->RunLength++; + s->Freq = (Byte)(freq + (freq < 128)); + // NextContext(p); + if (p->OrderFall == 0 && (const Byte *)c > p->Text) + p->MaxContext = p->MinContext = c; + else + Ppmd7_UpdateModel(p); + } + return; + } + + *prob = (UInt16)pr; + p->InitEsc = p->ExpEscape[pr >> 10]; + // RangeEnc_EncodeBit_1(p, bound); + R->Low += bound; + R->Range -= bound; + RC_NORM_LOCAL(p) + + PPMD_SetAllBitsIn256Bytes(charMask); + MASK(s->Symbol) = 0; + p->PrevSuccess = 0; + } + + for (;;) + { + CPpmd_See *see; + CPpmd_State *s; + UInt32 sum, escFreq; + CPpmd7_Context *mc; + unsigned i, numMasked; + + RC_NORM_REMOTE(p) + + mc = p->MinContext; + numMasked = mc->NumStats; + + do + { + p->OrderFall++; + if (!mc->Suffix) + return; /* EndMarker (symbol = -1) */ + mc = Ppmd7_GetContext(p, mc->Suffix); + i = mc->NumStats; + } + while (i == numMasked); + + p->MinContext = mc; + + // see = Ppmd7_MakeEscFreq(p, numMasked, &escFreq); + { + if (i != 256) + { + unsigned nonMasked = i - numMasked; + see = p->See[(unsigned)p->NS2Indx[(size_t)nonMasked - 1]] + + p->HiBitsFlag + + (nonMasked < (unsigned)SUFFIX(mc)->NumStats - i) + + 2 * (unsigned)(mc->Union2.SummFreq < 11 * i) + + 4 * (unsigned)(numMasked > nonMasked); + { + // if (see->Summ) field is larger than 16-bit, we need only low 16 bits of Summ + unsigned summ = (UInt16)see->Summ; // & 0xFFFF + unsigned r = (summ >> see->Shift); + see->Summ = (UInt16)(summ - r); + escFreq = r + (r == 0); + } + } + else + { + see = &p->DummySee; + escFreq = 1; + } + } + + s = Ppmd7_GetStats(p, mc); + sum = 0; + // i = mc->NumStats; + + do + { + unsigned cur = s->Symbol; + if ((int)cur == symbol) + { + UInt32 low = sum; + UInt32 freq = s->Freq; + unsigned num2; + + Ppmd_See_Update(see); + p->FoundState = s; + sum += escFreq; + + num2 = i / 2; + i &= 1; + sum += freq & (0 - (UInt32)i); + if (num2 != 0) + { + s += i; + for (;;) + { + unsigned sym0 = s[0].Symbol; + unsigned sym1 = s[1].Symbol; + s += 2; + sum += (s[-2].Freq & (unsigned)(MASK(sym0))); + sum += (s[-1].Freq & (unsigned)(MASK(sym1))); + if (--num2 == 0) + break; + } + } + + + R->Range /= sum; + RC_EncodeFinal(low, freq); + Ppmd7_Update2(p); + return; + } + sum += (s->Freq & (unsigned)(MASK(cur))); + s++; + } + while (--i); + + { + UInt32 total = sum + escFreq; + see->Summ = (UInt16)(see->Summ + total); + + R->Range /= total; + RC_Encode(sum, escFreq); + } + + { + CPpmd_State *s2 = Ppmd7_GetStats(p, p->MinContext); + s--; + MASK(s->Symbol) = 0; + do + { + unsigned sym0 = s2[0].Symbol; + unsigned sym1 = s2[1].Symbol; + s2 += 2; + MASK(sym0) = 0; + MASK(sym1) = 0; + } + while (s2 < s); + } + } +} + + +void Ppmd7z_EncodeSymbols(CPpmd7 *p, const Byte *buf, const Byte *lim) +{ + for (; buf < lim; buf++) + { + Ppmd7z_EncodeSymbol(p, *buf); + } +} diff --git a/deps/LZMA-SDK/C/Precomp.h b/deps/LZMA-SDK/C/Precomp.h index edb581443..e8ff8b40e 100644 --- a/deps/LZMA-SDK/C/Precomp.h +++ b/deps/LZMA-SDK/C/Precomp.h @@ -1,10 +1,10 @@ -/* Precomp.h -- StdAfx -2013-11-12 : Igor Pavlov : Public domain */ - -#ifndef __7Z_PRECOMP_H -#define __7Z_PRECOMP_H - -#include "Compiler.h" -/* #include "7zTypes.h" */ - -#endif +/* Precomp.h -- StdAfx +2013-11-12 : Igor Pavlov : Public domain */ + +#ifndef __7Z_PRECOMP_H +#define __7Z_PRECOMP_H + +#include "Compiler.h" +/* #include "7zTypes.h" */ + +#endif diff --git a/deps/LZMA-SDK/C/RotateDefs.h b/deps/LZMA-SDK/C/RotateDefs.h index 6c790e791..8f01d1a6c 100644 --- a/deps/LZMA-SDK/C/RotateDefs.h +++ b/deps/LZMA-SDK/C/RotateDefs.h @@ -1,30 +1,30 @@ -/* RotateDefs.h -- Rotate functions -2015-03-25 : Igor Pavlov : Public domain */ - -#ifndef __ROTATE_DEFS_H -#define __ROTATE_DEFS_H - -#ifdef _MSC_VER - -#include - -/* don't use _rotl with MINGW. It can insert slow call to function. */ - -/* #if (_MSC_VER >= 1200) */ -#pragma intrinsic(_rotl) -#pragma intrinsic(_rotr) -/* #endif */ - -#define rotlFixed(x, n) _rotl((x), (n)) -#define rotrFixed(x, n) _rotr((x), (n)) - -#else - -/* new compilers can translate these macros to fast commands. */ - -#define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) -#define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) - -#endif - -#endif +/* RotateDefs.h -- Rotate functions +2015-03-25 : Igor Pavlov : Public domain */ + +#ifndef __ROTATE_DEFS_H +#define __ROTATE_DEFS_H + +#ifdef _MSC_VER + +#include + +/* don't use _rotl with MINGW. It can insert slow call to function. */ + +/* #if (_MSC_VER >= 1200) */ +#pragma intrinsic(_rotl) +#pragma intrinsic(_rotr) +/* #endif */ + +#define rotlFixed(x, n) _rotl((x), (n)) +#define rotrFixed(x, n) _rotr((x), (n)) + +#else + +/* new compilers can translate these macros to fast commands. */ + +#define rotlFixed(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) +#define rotrFixed(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) + +#endif + +#endif diff --git a/deps/LZMA-SDK/C/Sha256.c b/deps/LZMA-SDK/C/Sha256.c index c03b75afe..8b3983ea7 100644 --- a/deps/LZMA-SDK/C/Sha256.c +++ b/deps/LZMA-SDK/C/Sha256.c @@ -1,486 +1,486 @@ -/* Sha256.c -- SHA-256 Hash -2021-04-01 : Igor Pavlov : Public domain -This code is based on public domain code from Wei Dai's Crypto++ library. */ - -#include "Precomp.h" - -#include - -#include "CpuArch.h" -#include "RotateDefs.h" -#include "Sha256.h" - -#if defined(_MSC_VER) && (_MSC_VER < 1900) -// #define USE_MY_MM -#endif - -#ifdef MY_CPU_X86_OR_AMD64 - #ifdef _MSC_VER - #if _MSC_VER >= 1200 - #define _SHA_SUPPORTED - #endif - #elif defined(__clang__) - #if (__clang_major__ >= 8) // fix that check - #define _SHA_SUPPORTED - #endif - #elif defined(__GNUC__) - #if (__GNUC__ >= 8) // fix that check - #define _SHA_SUPPORTED - #endif - #elif defined(__INTEL_COMPILER) - #if (__INTEL_COMPILER >= 1800) // fix that check - #define _SHA_SUPPORTED - #endif - #endif -#elif defined(MY_CPU_ARM_OR_ARM64) - #ifdef _MSC_VER - #if _MSC_VER >= 1910 - #define _SHA_SUPPORTED - #endif - #elif defined(__clang__) - #if (__clang_major__ >= 8) // fix that check - #define _SHA_SUPPORTED - #endif - #elif defined(__GNUC__) - #if (__GNUC__ >= 6) // fix that check - #define _SHA_SUPPORTED - #endif - #endif -#endif - -void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); - -#ifdef _SHA_SUPPORTED - void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); - - static SHA256_FUNC_UPDATE_BLOCKS g_FUNC_UPDATE_BLOCKS = Sha256_UpdateBlocks; - static SHA256_FUNC_UPDATE_BLOCKS g_FUNC_UPDATE_BLOCKS_HW; - - #define UPDATE_BLOCKS(p) p->func_UpdateBlocks -#else - #define UPDATE_BLOCKS(p) Sha256_UpdateBlocks -#endif - - -BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo) -{ - SHA256_FUNC_UPDATE_BLOCKS func = Sha256_UpdateBlocks; - - #ifdef _SHA_SUPPORTED - if (algo != SHA256_ALGO_SW) - { - if (algo == SHA256_ALGO_DEFAULT) - func = g_FUNC_UPDATE_BLOCKS; - else - { - if (algo != SHA256_ALGO_HW) - return False; - func = g_FUNC_UPDATE_BLOCKS_HW; - if (!func) - return False; - } - } - #else - if (algo > 1) - return False; - #endif - - p->func_UpdateBlocks = func; - return True; -} - - -/* define it for speed optimization */ - -#ifdef _SFX - #define STEP_PRE 1 - #define STEP_MAIN 1 -#else - #define STEP_PRE 2 - #define STEP_MAIN 4 - // #define _SHA256_UNROLL -#endif - -#if STEP_MAIN != 16 - #define _SHA256_BIG_W -#endif - - - - -void Sha256_InitState(CSha256 *p) -{ - p->count = 0; - p->state[0] = 0x6a09e667; - p->state[1] = 0xbb67ae85; - p->state[2] = 0x3c6ef372; - p->state[3] = 0xa54ff53a; - p->state[4] = 0x510e527f; - p->state[5] = 0x9b05688c; - p->state[6] = 0x1f83d9ab; - p->state[7] = 0x5be0cd19; -} - -void Sha256_Init(CSha256 *p) -{ - p->func_UpdateBlocks = - #ifdef _SHA_SUPPORTED - g_FUNC_UPDATE_BLOCKS; - #else - NULL; - #endif - Sha256_InitState(p); -} - -#define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22)) -#define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25)) -#define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3)) -#define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10)) - -#define Ch(x,y,z) (z^(x&(y^z))) -#define Maj(x,y,z) ((x&y)|(z&(x|y))) - - -#define W_PRE(i) (W[(i) + (size_t)(j)] = GetBe32(data + ((size_t)(j) + i) * 4)) - -#define blk2_main(j, i) s1(w(j, (i)-2)) + w(j, (i)-7) + s0(w(j, (i)-15)) - -#ifdef _SHA256_BIG_W - // we use +i instead of +(i) to change the order to solve CLANG compiler warning for signed/unsigned. - #define w(j, i) W[(size_t)(j) + i] - #define blk2(j, i) (w(j, i) = w(j, (i)-16) + blk2_main(j, i)) -#else - #if STEP_MAIN == 16 - #define w(j, i) W[(i) & 15] - #else - #define w(j, i) W[((size_t)(j) + (i)) & 15] - #endif - #define blk2(j, i) (w(j, i) += blk2_main(j, i)) -#endif - -#define W_MAIN(i) blk2(j, i) - - -#define T1(wx, i) \ - tmp = h + S1(e) + Ch(e,f,g) + K[(i)+(size_t)(j)] + wx(i); \ - h = g; \ - g = f; \ - f = e; \ - e = d + tmp; \ - tmp += S0(a) + Maj(a, b, c); \ - d = c; \ - c = b; \ - b = a; \ - a = tmp; \ - -#define R1_PRE(i) T1( W_PRE, i) -#define R1_MAIN(i) T1( W_MAIN, i) - -#if (!defined(_SHA256_UNROLL) || STEP_MAIN < 8) && (STEP_MAIN >= 4) -#define R2_MAIN(i) \ - R1_MAIN(i) \ - R1_MAIN(i + 1) \ - -#endif - - - -#if defined(_SHA256_UNROLL) && STEP_MAIN >= 8 - -#define T4( a,b,c,d,e,f,g,h, wx, i) \ - h += S1(e) + Ch(e,f,g) + K[(i)+(size_t)(j)] + wx(i); \ - tmp = h; \ - h += d; \ - d = tmp + S0(a) + Maj(a, b, c); \ - -#define R4( wx, i) \ - T4 ( a,b,c,d,e,f,g,h, wx, (i )); \ - T4 ( d,a,b,c,h,e,f,g, wx, (i+1)); \ - T4 ( c,d,a,b,g,h,e,f, wx, (i+2)); \ - T4 ( b,c,d,a,f,g,h,e, wx, (i+3)); \ - -#define R4_PRE(i) R4( W_PRE, i) -#define R4_MAIN(i) R4( W_MAIN, i) - - -#define T8( a,b,c,d,e,f,g,h, wx, i) \ - h += S1(e) + Ch(e,f,g) + K[(i)+(size_t)(j)] + wx(i); \ - d += h; \ - h += S0(a) + Maj(a, b, c); \ - -#define R8( wx, i) \ - T8 ( a,b,c,d,e,f,g,h, wx, i ); \ - T8 ( h,a,b,c,d,e,f,g, wx, i+1); \ - T8 ( g,h,a,b,c,d,e,f, wx, i+2); \ - T8 ( f,g,h,a,b,c,d,e, wx, i+3); \ - T8 ( e,f,g,h,a,b,c,d, wx, i+4); \ - T8 ( d,e,f,g,h,a,b,c, wx, i+5); \ - T8 ( c,d,e,f,g,h,a,b, wx, i+6); \ - T8 ( b,c,d,e,f,g,h,a, wx, i+7); \ - -#define R8_PRE(i) R8( W_PRE, i) -#define R8_MAIN(i) R8( W_MAIN, i) - -#endif - -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); - -// static -extern MY_ALIGN(64) -const UInt32 SHA256_K_ARRAY[64]; - -MY_ALIGN(64) -const UInt32 SHA256_K_ARRAY[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -}; - -#define K SHA256_K_ARRAY - - -MY_NO_INLINE -void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks) -{ - UInt32 W - #ifdef _SHA256_BIG_W - [64]; - #else - [16]; - #endif - - unsigned j; - - UInt32 a,b,c,d,e,f,g,h; - - #if !defined(_SHA256_UNROLL) || (STEP_MAIN <= 4) || (STEP_PRE <= 4) - UInt32 tmp; - #endif - - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - f = state[5]; - g = state[6]; - h = state[7]; - - while (numBlocks) - { - - for (j = 0; j < 16; j += STEP_PRE) - { - #if STEP_PRE > 4 - - #if STEP_PRE < 8 - R4_PRE(0); - #else - R8_PRE(0); - #if STEP_PRE == 16 - R8_PRE(8); - #endif - #endif - - #else - - R1_PRE(0); - #if STEP_PRE >= 2 - R1_PRE(1); - #if STEP_PRE >= 4 - R1_PRE(2); - R1_PRE(3); - #endif - #endif - - #endif - } - - for (j = 16; j < 64; j += STEP_MAIN) - { - #if defined(_SHA256_UNROLL) && STEP_MAIN >= 8 - - #if STEP_MAIN < 8 - R4_MAIN(0); - #else - R8_MAIN(0); - #if STEP_MAIN == 16 - R8_MAIN(8); - #endif - #endif - - #else - - R1_MAIN(0); - #if STEP_MAIN >= 2 - R1_MAIN(1); - #if STEP_MAIN >= 4 - R2_MAIN(2); - #if STEP_MAIN >= 8 - R2_MAIN(4); - R2_MAIN(6); - #if STEP_MAIN >= 16 - R2_MAIN(8); - R2_MAIN(10); - R2_MAIN(12); - R2_MAIN(14); - #endif - #endif - #endif - #endif - #endif - } - - a += state[0]; state[0] = a; - b += state[1]; state[1] = b; - c += state[2]; state[2] = c; - d += state[3]; state[3] = d; - e += state[4]; state[4] = e; - f += state[5]; state[5] = f; - g += state[6]; state[6] = g; - h += state[7]; state[7] = h; - - data += 64; - numBlocks--; - } - - /* Wipe variables */ - /* memset(W, 0, sizeof(W)); */ -} - -#undef S0 -#undef S1 -#undef s0 -#undef s1 -#undef K - -#define Sha256_UpdateBlock(p) UPDATE_BLOCKS(p)(p->state, p->buffer, 1) - -void Sha256_Update(CSha256 *p, const Byte *data, size_t size) -{ - if (size == 0) - return; - - { - unsigned pos = (unsigned)p->count & 0x3F; - unsigned num; - - p->count += size; - - num = 64 - pos; - if (num > size) - { - memcpy(p->buffer + pos, data, size); - return; - } - - if (pos != 0) - { - size -= num; - memcpy(p->buffer + pos, data, num); - data += num; - Sha256_UpdateBlock(p); - } - } - { - size_t numBlocks = size >> 6; - UPDATE_BLOCKS(p)(p->state, data, numBlocks); - size &= 0x3F; - if (size == 0) - return; - data += (numBlocks << 6); - memcpy(p->buffer, data, size); - } -} - - -void Sha256_Final(CSha256 *p, Byte *digest) -{ - unsigned pos = (unsigned)p->count & 0x3F; - unsigned i; - - p->buffer[pos++] = 0x80; - - if (pos > (64 - 8)) - { - while (pos != 64) { p->buffer[pos++] = 0; } - // memset(&p->buf.buffer[pos], 0, 64 - pos); - Sha256_UpdateBlock(p); - pos = 0; - } - - /* - if (pos & 3) - { - p->buffer[pos] = 0; - p->buffer[pos + 1] = 0; - p->buffer[pos + 2] = 0; - pos += 3; - pos &= ~3; - } - { - for (; pos < 64 - 8; pos += 4) - *(UInt32 *)(&p->buffer[pos]) = 0; - } - */ - - memset(&p->buffer[pos], 0, (64 - 8) - pos); - - { - UInt64 numBits = (p->count << 3); - SetBe32(p->buffer + 64 - 8, (UInt32)(numBits >> 32)); - SetBe32(p->buffer + 64 - 4, (UInt32)(numBits)); - } - - Sha256_UpdateBlock(p); - - for (i = 0; i < 8; i += 2) - { - UInt32 v0 = p->state[i]; - UInt32 v1 = p->state[(size_t)i + 1]; - SetBe32(digest , v0); - SetBe32(digest + 4, v1); - digest += 8; - } - - Sha256_InitState(p); -} - - -void Sha256Prepare() -{ - #ifdef _SHA_SUPPORTED - SHA256_FUNC_UPDATE_BLOCKS f, f_hw; - f = Sha256_UpdateBlocks; - f_hw = NULL; - #ifdef MY_CPU_X86_OR_AMD64 - #ifndef USE_MY_MM - if (CPU_IsSupported_SHA() - && CPU_IsSupported_SSSE3() - // && CPU_IsSupported_SSE41() - ) - #endif - #else - if (CPU_IsSupported_SHA2()) - #endif - { - // printf("\n========== HW SHA256 ======== \n"); - f = f_hw = Sha256_UpdateBlocks_HW; - } - g_FUNC_UPDATE_BLOCKS = f; - g_FUNC_UPDATE_BLOCKS_HW = f_hw; - #endif -} +/* Sha256.c -- SHA-256 Hash +2021-04-01 : Igor Pavlov : Public domain +This code is based on public domain code from Wei Dai's Crypto++ library. */ + +#include "Precomp.h" + +#include + +#include "CpuArch.h" +#include "RotateDefs.h" +#include "Sha256.h" + +#if defined(_MSC_VER) && (_MSC_VER < 1900) +// #define USE_MY_MM +#endif + +#ifdef MY_CPU_X86_OR_AMD64 + #ifdef _MSC_VER + #if _MSC_VER >= 1200 + #define _SHA_SUPPORTED + #endif + #elif defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define _SHA_SUPPORTED + #endif + #elif defined(__GNUC__) + #if (__GNUC__ >= 8) // fix that check + #define _SHA_SUPPORTED + #endif + #elif defined(__INTEL_COMPILER) + #if (__INTEL_COMPILER >= 1800) // fix that check + #define _SHA_SUPPORTED + #endif + #endif +#elif defined(MY_CPU_ARM_OR_ARM64) + #ifdef _MSC_VER + #if _MSC_VER >= 1910 + #define _SHA_SUPPORTED + #endif + #elif defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define _SHA_SUPPORTED + #endif + #elif defined(__GNUC__) + #if (__GNUC__ >= 6) // fix that check + #define _SHA_SUPPORTED + #endif + #endif +#endif + +void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); + +#ifdef _SHA_SUPPORTED + void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); + + static SHA256_FUNC_UPDATE_BLOCKS g_FUNC_UPDATE_BLOCKS = Sha256_UpdateBlocks; + static SHA256_FUNC_UPDATE_BLOCKS g_FUNC_UPDATE_BLOCKS_HW; + + #define UPDATE_BLOCKS(p) p->func_UpdateBlocks +#else + #define UPDATE_BLOCKS(p) Sha256_UpdateBlocks +#endif + + +BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo) +{ + SHA256_FUNC_UPDATE_BLOCKS func = Sha256_UpdateBlocks; + + #ifdef _SHA_SUPPORTED + if (algo != SHA256_ALGO_SW) + { + if (algo == SHA256_ALGO_DEFAULT) + func = g_FUNC_UPDATE_BLOCKS; + else + { + if (algo != SHA256_ALGO_HW) + return False; + func = g_FUNC_UPDATE_BLOCKS_HW; + if (!func) + return False; + } + } + #else + if (algo > 1) + return False; + #endif + + p->func_UpdateBlocks = func; + return True; +} + + +/* define it for speed optimization */ + +#ifdef _SFX + #define STEP_PRE 1 + #define STEP_MAIN 1 +#else + #define STEP_PRE 2 + #define STEP_MAIN 4 + // #define _SHA256_UNROLL +#endif + +#if STEP_MAIN != 16 + #define _SHA256_BIG_W +#endif + + + + +void Sha256_InitState(CSha256 *p) +{ + p->count = 0; + p->state[0] = 0x6a09e667; + p->state[1] = 0xbb67ae85; + p->state[2] = 0x3c6ef372; + p->state[3] = 0xa54ff53a; + p->state[4] = 0x510e527f; + p->state[5] = 0x9b05688c; + p->state[6] = 0x1f83d9ab; + p->state[7] = 0x5be0cd19; +} + +void Sha256_Init(CSha256 *p) +{ + p->func_UpdateBlocks = + #ifdef _SHA_SUPPORTED + g_FUNC_UPDATE_BLOCKS; + #else + NULL; + #endif + Sha256_InitState(p); +} + +#define S0(x) (rotrFixed(x, 2) ^ rotrFixed(x,13) ^ rotrFixed(x, 22)) +#define S1(x) (rotrFixed(x, 6) ^ rotrFixed(x,11) ^ rotrFixed(x, 25)) +#define s0(x) (rotrFixed(x, 7) ^ rotrFixed(x,18) ^ (x >> 3)) +#define s1(x) (rotrFixed(x,17) ^ rotrFixed(x,19) ^ (x >> 10)) + +#define Ch(x,y,z) (z^(x&(y^z))) +#define Maj(x,y,z) ((x&y)|(z&(x|y))) + + +#define W_PRE(i) (W[(i) + (size_t)(j)] = GetBe32(data + ((size_t)(j) + i) * 4)) + +#define blk2_main(j, i) s1(w(j, (i)-2)) + w(j, (i)-7) + s0(w(j, (i)-15)) + +#ifdef _SHA256_BIG_W + // we use +i instead of +(i) to change the order to solve CLANG compiler warning for signed/unsigned. + #define w(j, i) W[(size_t)(j) + i] + #define blk2(j, i) (w(j, i) = w(j, (i)-16) + blk2_main(j, i)) +#else + #if STEP_MAIN == 16 + #define w(j, i) W[(i) & 15] + #else + #define w(j, i) W[((size_t)(j) + (i)) & 15] + #endif + #define blk2(j, i) (w(j, i) += blk2_main(j, i)) +#endif + +#define W_MAIN(i) blk2(j, i) + + +#define T1(wx, i) \ + tmp = h + S1(e) + Ch(e,f,g) + K[(i)+(size_t)(j)] + wx(i); \ + h = g; \ + g = f; \ + f = e; \ + e = d + tmp; \ + tmp += S0(a) + Maj(a, b, c); \ + d = c; \ + c = b; \ + b = a; \ + a = tmp; \ + +#define R1_PRE(i) T1( W_PRE, i) +#define R1_MAIN(i) T1( W_MAIN, i) + +#if (!defined(_SHA256_UNROLL) || STEP_MAIN < 8) && (STEP_MAIN >= 4) +#define R2_MAIN(i) \ + R1_MAIN(i) \ + R1_MAIN(i + 1) \ + +#endif + + + +#if defined(_SHA256_UNROLL) && STEP_MAIN >= 8 + +#define T4( a,b,c,d,e,f,g,h, wx, i) \ + h += S1(e) + Ch(e,f,g) + K[(i)+(size_t)(j)] + wx(i); \ + tmp = h; \ + h += d; \ + d = tmp + S0(a) + Maj(a, b, c); \ + +#define R4( wx, i) \ + T4 ( a,b,c,d,e,f,g,h, wx, (i )); \ + T4 ( d,a,b,c,h,e,f,g, wx, (i+1)); \ + T4 ( c,d,a,b,g,h,e,f, wx, (i+2)); \ + T4 ( b,c,d,a,f,g,h,e, wx, (i+3)); \ + +#define R4_PRE(i) R4( W_PRE, i) +#define R4_MAIN(i) R4( W_MAIN, i) + + +#define T8( a,b,c,d,e,f,g,h, wx, i) \ + h += S1(e) + Ch(e,f,g) + K[(i)+(size_t)(j)] + wx(i); \ + d += h; \ + h += S0(a) + Maj(a, b, c); \ + +#define R8( wx, i) \ + T8 ( a,b,c,d,e,f,g,h, wx, i ); \ + T8 ( h,a,b,c,d,e,f,g, wx, i+1); \ + T8 ( g,h,a,b,c,d,e,f, wx, i+2); \ + T8 ( f,g,h,a,b,c,d,e, wx, i+3); \ + T8 ( e,f,g,h,a,b,c,d, wx, i+4); \ + T8 ( d,e,f,g,h,a,b,c, wx, i+5); \ + T8 ( c,d,e,f,g,h,a,b, wx, i+6); \ + T8 ( b,c,d,e,f,g,h,a, wx, i+7); \ + +#define R8_PRE(i) R8( W_PRE, i) +#define R8_MAIN(i) R8( W_MAIN, i) + +#endif + +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); + +// static +extern MY_ALIGN(64) +const UInt32 SHA256_K_ARRAY[64]; + +MY_ALIGN(64) +const UInt32 SHA256_K_ARRAY[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +#define K SHA256_K_ARRAY + + +MY_NO_INLINE +void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks) +{ + UInt32 W + #ifdef _SHA256_BIG_W + [64]; + #else + [16]; + #endif + + unsigned j; + + UInt32 a,b,c,d,e,f,g,h; + + #if !defined(_SHA256_UNROLL) || (STEP_MAIN <= 4) || (STEP_PRE <= 4) + UInt32 tmp; + #endif + + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; + + while (numBlocks) + { + + for (j = 0; j < 16; j += STEP_PRE) + { + #if STEP_PRE > 4 + + #if STEP_PRE < 8 + R4_PRE(0); + #else + R8_PRE(0); + #if STEP_PRE == 16 + R8_PRE(8); + #endif + #endif + + #else + + R1_PRE(0); + #if STEP_PRE >= 2 + R1_PRE(1); + #if STEP_PRE >= 4 + R1_PRE(2); + R1_PRE(3); + #endif + #endif + + #endif + } + + for (j = 16; j < 64; j += STEP_MAIN) + { + #if defined(_SHA256_UNROLL) && STEP_MAIN >= 8 + + #if STEP_MAIN < 8 + R4_MAIN(0); + #else + R8_MAIN(0); + #if STEP_MAIN == 16 + R8_MAIN(8); + #endif + #endif + + #else + + R1_MAIN(0); + #if STEP_MAIN >= 2 + R1_MAIN(1); + #if STEP_MAIN >= 4 + R2_MAIN(2); + #if STEP_MAIN >= 8 + R2_MAIN(4); + R2_MAIN(6); + #if STEP_MAIN >= 16 + R2_MAIN(8); + R2_MAIN(10); + R2_MAIN(12); + R2_MAIN(14); + #endif + #endif + #endif + #endif + #endif + } + + a += state[0]; state[0] = a; + b += state[1]; state[1] = b; + c += state[2]; state[2] = c; + d += state[3]; state[3] = d; + e += state[4]; state[4] = e; + f += state[5]; state[5] = f; + g += state[6]; state[6] = g; + h += state[7]; state[7] = h; + + data += 64; + numBlocks--; + } + + /* Wipe variables */ + /* memset(W, 0, sizeof(W)); */ +} + +#undef S0 +#undef S1 +#undef s0 +#undef s1 +#undef K + +#define Sha256_UpdateBlock(p) UPDATE_BLOCKS(p)(p->state, p->buffer, 1) + +void Sha256_Update(CSha256 *p, const Byte *data, size_t size) +{ + if (size == 0) + return; + + { + unsigned pos = (unsigned)p->count & 0x3F; + unsigned num; + + p->count += size; + + num = 64 - pos; + if (num > size) + { + memcpy(p->buffer + pos, data, size); + return; + } + + if (pos != 0) + { + size -= num; + memcpy(p->buffer + pos, data, num); + data += num; + Sha256_UpdateBlock(p); + } + } + { + size_t numBlocks = size >> 6; + UPDATE_BLOCKS(p)(p->state, data, numBlocks); + size &= 0x3F; + if (size == 0) + return; + data += (numBlocks << 6); + memcpy(p->buffer, data, size); + } +} + + +void Sha256_Final(CSha256 *p, Byte *digest) +{ + unsigned pos = (unsigned)p->count & 0x3F; + unsigned i; + + p->buffer[pos++] = 0x80; + + if (pos > (64 - 8)) + { + while (pos != 64) { p->buffer[pos++] = 0; } + // memset(&p->buf.buffer[pos], 0, 64 - pos); + Sha256_UpdateBlock(p); + pos = 0; + } + + /* + if (pos & 3) + { + p->buffer[pos] = 0; + p->buffer[pos + 1] = 0; + p->buffer[pos + 2] = 0; + pos += 3; + pos &= ~3; + } + { + for (; pos < 64 - 8; pos += 4) + *(UInt32 *)(&p->buffer[pos]) = 0; + } + */ + + memset(&p->buffer[pos], 0, (64 - 8) - pos); + + { + UInt64 numBits = (p->count << 3); + SetBe32(p->buffer + 64 - 8, (UInt32)(numBits >> 32)); + SetBe32(p->buffer + 64 - 4, (UInt32)(numBits)); + } + + Sha256_UpdateBlock(p); + + for (i = 0; i < 8; i += 2) + { + UInt32 v0 = p->state[i]; + UInt32 v1 = p->state[(size_t)i + 1]; + SetBe32(digest , v0); + SetBe32(digest + 4, v1); + digest += 8; + } + + Sha256_InitState(p); +} + + +void Sha256Prepare() +{ + #ifdef _SHA_SUPPORTED + SHA256_FUNC_UPDATE_BLOCKS f, f_hw; + f = Sha256_UpdateBlocks; + f_hw = NULL; + #ifdef MY_CPU_X86_OR_AMD64 + #ifndef USE_MY_MM + if (CPU_IsSupported_SHA() + && CPU_IsSupported_SSSE3() + // && CPU_IsSupported_SSE41() + ) + #endif + #else + if (CPU_IsSupported_SHA2()) + #endif + { + // printf("\n========== HW SHA256 ======== \n"); + f = f_hw = Sha256_UpdateBlocks_HW; + } + g_FUNC_UPDATE_BLOCKS = f; + g_FUNC_UPDATE_BLOCKS_HW = f_hw; + #endif +} diff --git a/deps/LZMA-SDK/C/Sha256.h b/deps/LZMA-SDK/C/Sha256.h index f52933986..aa38501e5 100644 --- a/deps/LZMA-SDK/C/Sha256.h +++ b/deps/LZMA-SDK/C/Sha256.h @@ -1,76 +1,76 @@ -/* Sha256.h -- SHA-256 Hash -2021-01-01 : Igor Pavlov : Public domain */ - -#ifndef __7Z_SHA256_H -#define __7Z_SHA256_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#define SHA256_NUM_BLOCK_WORDS 16 -#define SHA256_NUM_DIGEST_WORDS 8 - -#define SHA256_BLOCK_SIZE (SHA256_NUM_BLOCK_WORDS * 4) -#define SHA256_DIGEST_SIZE (SHA256_NUM_DIGEST_WORDS * 4) - -typedef void (MY_FAST_CALL *SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks); - -/* - if (the system supports different SHA256 code implementations) - { - (CSha256::func_UpdateBlocks) will be used - (CSha256::func_UpdateBlocks) can be set by - Sha256_Init() - to default (fastest) - Sha256_SetFunction() - to any algo - } - else - { - (CSha256::func_UpdateBlocks) is ignored. - } -*/ - -typedef struct -{ - SHA256_FUNC_UPDATE_BLOCKS func_UpdateBlocks; - UInt64 count; - UInt64 __pad_2[2]; - UInt32 state[SHA256_NUM_DIGEST_WORDS]; - - Byte buffer[SHA256_BLOCK_SIZE]; -} CSha256; - - -#define SHA256_ALGO_DEFAULT 0 -#define SHA256_ALGO_SW 1 -#define SHA256_ALGO_HW 2 - -/* -Sha256_SetFunction() -return: - 0 - (algo) value is not supported, and func_UpdateBlocks was not changed - 1 - func_UpdateBlocks was set according (algo) value. -*/ - -BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo); - -void Sha256_InitState(CSha256 *p); -void Sha256_Init(CSha256 *p); -void Sha256_Update(CSha256 *p, const Byte *data, size_t size); -void Sha256_Final(CSha256 *p, Byte *digest); - - - - -// void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); - -/* -call Sha256Prepare() once at program start. -It prepares all supported implementations, and detects the fastest implementation. -*/ - -void Sha256Prepare(void); - -EXTERN_C_END - -#endif +/* Sha256.h -- SHA-256 Hash +2021-01-01 : Igor Pavlov : Public domain */ + +#ifndef __7Z_SHA256_H +#define __7Z_SHA256_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#define SHA256_NUM_BLOCK_WORDS 16 +#define SHA256_NUM_DIGEST_WORDS 8 + +#define SHA256_BLOCK_SIZE (SHA256_NUM_BLOCK_WORDS * 4) +#define SHA256_DIGEST_SIZE (SHA256_NUM_DIGEST_WORDS * 4) + +typedef void (MY_FAST_CALL *SHA256_FUNC_UPDATE_BLOCKS)(UInt32 state[8], const Byte *data, size_t numBlocks); + +/* + if (the system supports different SHA256 code implementations) + { + (CSha256::func_UpdateBlocks) will be used + (CSha256::func_UpdateBlocks) can be set by + Sha256_Init() - to default (fastest) + Sha256_SetFunction() - to any algo + } + else + { + (CSha256::func_UpdateBlocks) is ignored. + } +*/ + +typedef struct +{ + SHA256_FUNC_UPDATE_BLOCKS func_UpdateBlocks; + UInt64 count; + UInt64 __pad_2[2]; + UInt32 state[SHA256_NUM_DIGEST_WORDS]; + + Byte buffer[SHA256_BLOCK_SIZE]; +} CSha256; + + +#define SHA256_ALGO_DEFAULT 0 +#define SHA256_ALGO_SW 1 +#define SHA256_ALGO_HW 2 + +/* +Sha256_SetFunction() +return: + 0 - (algo) value is not supported, and func_UpdateBlocks was not changed + 1 - func_UpdateBlocks was set according (algo) value. +*/ + +BoolInt Sha256_SetFunction(CSha256 *p, unsigned algo); + +void Sha256_InitState(CSha256 *p); +void Sha256_Init(CSha256 *p); +void Sha256_Update(CSha256 *p, const Byte *data, size_t size); +void Sha256_Final(CSha256 *p, Byte *digest); + + + + +// void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); + +/* +call Sha256Prepare() once at program start. +It prepares all supported implementations, and detects the fastest implementation. +*/ + +void Sha256Prepare(void); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Sha256Opt.c b/deps/LZMA-SDK/C/Sha256Opt.c index cc8c53e1b..decc1382c 100644 --- a/deps/LZMA-SDK/C/Sha256Opt.c +++ b/deps/LZMA-SDK/C/Sha256Opt.c @@ -1,373 +1,373 @@ -/* Sha256Opt.c -- SHA-256 optimized code for SHA-256 hardware instructions -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#if defined(_MSC_VER) -#if (_MSC_VER < 1900) && (_MSC_VER >= 1200) -// #define USE_MY_MM -#endif -#endif - -#include "CpuArch.h" - -#ifdef MY_CPU_X86_OR_AMD64 - #if defined(__clang__) - #if (__clang_major__ >= 8) // fix that check - #define USE_HW_SHA - #ifndef __SHA__ - #define ATTRIB_SHA __attribute__((__target__("sha,ssse3"))) - #if defined(_MSC_VER) - // SSSE3: for clang-cl: - #include - #define __SHA__ - #endif - #endif - - #endif - #elif defined(__GNUC__) - #if (__GNUC__ >= 8) // fix that check - #define USE_HW_SHA - #ifndef __SHA__ - #define ATTRIB_SHA __attribute__((__target__("sha,ssse3"))) - // #pragma GCC target("sha,ssse3") - #endif - #endif - #elif defined(__INTEL_COMPILER) - #if (__INTEL_COMPILER >= 1800) // fix that check - #define USE_HW_SHA - #endif - #elif defined(_MSC_VER) - #ifdef USE_MY_MM - #define USE_VER_MIN 1300 - #else - #define USE_VER_MIN 1910 - #endif - #if _MSC_VER >= USE_VER_MIN - #define USE_HW_SHA - #endif - #endif -// #endif // MY_CPU_X86_OR_AMD64 - -#ifdef USE_HW_SHA - -// #pragma message("Sha256 HW") -// #include - -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) -#include -#else -#include - -#if defined(_MSC_VER) && (_MSC_VER >= 1600) -// #include -#endif - -#ifdef USE_MY_MM -#include "My_mm.h" -#endif - -#endif - -/* -SHA256 uses: -SSE2: - _mm_loadu_si128 - _mm_storeu_si128 - _mm_set_epi32 - _mm_add_epi32 - _mm_shuffle_epi32 / pshufd - - - -SSSE3: - _mm_shuffle_epi8 / pshufb - _mm_alignr_epi8 -SHA: - _mm_sha256* -*/ - -// K array must be aligned for 16-bytes at least. -// The compiler can look align attribute and selects -// movdqu - for code without align attribute -// movdqa - for code with align attribute -extern -MY_ALIGN(64) -const UInt32 SHA256_K_ARRAY[64]; - -#define K SHA256_K_ARRAY - - -#define ADD_EPI32(dest, src) dest = _mm_add_epi32(dest, src); -#define SHA256_MSG1(dest, src) dest = _mm_sha256msg1_epu32(dest, src); -#define SHA25G_MSG2(dest, src) dest = _mm_sha256msg2_epu32(dest, src); - - -#define LOAD_SHUFFLE(m, k) \ - m = _mm_loadu_si128((const __m128i *)(const void *)(data + (k) * 16)); \ - m = _mm_shuffle_epi8(m, mask); \ - -#define SM1(g0, g1, g2, g3) \ - SHA256_MSG1(g3, g0); \ - -#define SM2(g0, g1, g2, g3) \ - tmp = _mm_alignr_epi8(g1, g0, 4); \ - ADD_EPI32(g2, tmp); \ - SHA25G_MSG2(g2, g1); \ - -// #define LS0(k, g0, g1, g2, g3) LOAD_SHUFFLE(g0, k) -// #define LS1(k, g0, g1, g2, g3) LOAD_SHUFFLE(g1, k+1) - - -#define NNN(g0, g1, g2, g3) - - -#define RND2(t0, t1) \ - t0 = _mm_sha256rnds2_epu32(t0, t1, msg); - -#define RND2_0(m, k) \ - msg = _mm_add_epi32(m, *(const __m128i *) (const void *) &K[(k) * 4]); \ - RND2(state0, state1); \ - msg = _mm_shuffle_epi32(msg, 0x0E); \ - - -#define RND2_1 \ - RND2(state1, state0); \ - - -// We use scheme with 3 rounds ahead for SHA256_MSG1 / 2 rounds ahead for SHA256_MSG2 - -#define R4(k, g0, g1, g2, g3, OP0, OP1) \ - RND2_0(g0, k); \ - OP0(g0, g1, g2, g3); \ - RND2_1; \ - OP1(g0, g1, g2, g3); \ - -#define R16(k, OP0, OP1, OP2, OP3, OP4, OP5, OP6, OP7) \ - R4 ( (k)*4+0, m0, m1, m2, m3, OP0, OP1 ) \ - R4 ( (k)*4+1, m1, m2, m3, m0, OP2, OP3 ) \ - R4 ( (k)*4+2, m2, m3, m0, m1, OP4, OP5 ) \ - R4 ( (k)*4+3, m3, m0, m1, m2, OP6, OP7 ) \ - -#define PREPARE_STATE \ - tmp = _mm_shuffle_epi32(state0, 0x1B); /* abcd */ \ - state0 = _mm_shuffle_epi32(state1, 0x1B); /* efgh */ \ - state1 = state0; \ - state0 = _mm_unpacklo_epi64(state0, tmp); /* cdgh */ \ - state1 = _mm_unpackhi_epi64(state1, tmp); /* abef */ \ - - -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); -#ifdef ATTRIB_SHA -ATTRIB_SHA -#endif -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks) -{ - const __m128i mask = _mm_set_epi32(0x0c0d0e0f, 0x08090a0b, 0x04050607, 0x00010203); - __m128i tmp; - __m128i state0, state1; - - if (numBlocks == 0) - return; - - state0 = _mm_loadu_si128((const __m128i *) (const void *) &state[0]); - state1 = _mm_loadu_si128((const __m128i *) (const void *) &state[4]); - - PREPARE_STATE - - do - { - __m128i state0_save, state1_save; - __m128i m0, m1, m2, m3; - __m128i msg; - // #define msg tmp - - state0_save = state0; - state1_save = state1; - - LOAD_SHUFFLE (m0, 0) - LOAD_SHUFFLE (m1, 1) - LOAD_SHUFFLE (m2, 2) - LOAD_SHUFFLE (m3, 3) - - - - R16 ( 0, NNN, NNN, SM1, NNN, SM1, SM2, SM1, SM2 ); - R16 ( 1, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); - R16 ( 2, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); - R16 ( 3, SM1, SM2, NNN, SM2, NNN, NNN, NNN, NNN ); - - ADD_EPI32(state0, state0_save); - ADD_EPI32(state1, state1_save); - - data += 64; - } - while (--numBlocks); - - PREPARE_STATE - - _mm_storeu_si128((__m128i *) (void *) &state[0], state0); - _mm_storeu_si128((__m128i *) (void *) &state[4], state1); -} - -#endif // USE_HW_SHA - -#elif defined(MY_CPU_ARM_OR_ARM64) - - #if defined(__clang__) - #if (__clang_major__ >= 8) // fix that check - #define USE_HW_SHA - #endif - #elif defined(__GNUC__) - #if (__GNUC__ >= 6) // fix that check - #define USE_HW_SHA - #endif - #elif defined(_MSC_VER) - #if _MSC_VER >= 1910 - #define USE_HW_SHA - #endif - #endif - -#ifdef USE_HW_SHA - -// #pragma message("=== Sha256 HW === ") - -#if defined(__clang__) || defined(__GNUC__) - #ifdef MY_CPU_ARM64 - #define ATTRIB_SHA __attribute__((__target__("+crypto"))) - #else - #define ATTRIB_SHA __attribute__((__target__("fpu=crypto-neon-fp-armv8"))) - #endif -#else - // _MSC_VER - // for arm32 - #define _ARM_USE_NEW_NEON_INTRINSICS -#endif - -#if defined(_MSC_VER) && defined(MY_CPU_ARM64) -#include -#else -#include -#endif - -typedef uint32x4_t v128; -// typedef __n128 v128; // MSVC - -#ifdef MY_CPU_BE - #define MY_rev32_for_LE(x) -#else - #define MY_rev32_for_LE(x) x = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(x))) -#endif - -#define LOAD_128(_p) (*(const v128 *)(const void *)(_p)) -#define STORE_128(_p, _v) *(v128 *)(void *)(_p) = (_v) - -#define LOAD_SHUFFLE(m, k) \ - m = LOAD_128((data + (k) * 16)); \ - MY_rev32_for_LE(m); \ - -// K array must be aligned for 16-bytes at least. -extern -MY_ALIGN(64) -const UInt32 SHA256_K_ARRAY[64]; - -#define K SHA256_K_ARRAY - - -#define SHA256_SU0(dest, src) dest = vsha256su0q_u32(dest, src); -#define SHA25G_SU1(dest, src2, src3) dest = vsha256su1q_u32(dest, src2, src3); - -#define SM1(g0, g1, g2, g3) SHA256_SU0(g3, g0) -#define SM2(g0, g1, g2, g3) SHA25G_SU1(g2, g0, g1) -#define NNN(g0, g1, g2, g3) - - -#define R4(k, g0, g1, g2, g3, OP0, OP1) \ - msg = vaddq_u32(g0, *(const v128 *) (const void *) &K[(k) * 4]); \ - tmp = state0; \ - state0 = vsha256hq_u32( state0, state1, msg ); \ - state1 = vsha256h2q_u32( state1, tmp, msg ); \ - OP0(g0, g1, g2, g3); \ - OP1(g0, g1, g2, g3); \ - - -#define R16(k, OP0, OP1, OP2, OP3, OP4, OP5, OP6, OP7) \ - R4 ( (k)*4+0, m0, m1, m2, m3, OP0, OP1 ) \ - R4 ( (k)*4+1, m1, m2, m3, m0, OP2, OP3 ) \ - R4 ( (k)*4+2, m2, m3, m0, m1, OP4, OP5 ) \ - R4 ( (k)*4+3, m3, m0, m1, m2, OP6, OP7 ) \ - - -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); -#ifdef ATTRIB_SHA -ATTRIB_SHA -#endif -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks) -{ - v128 state0, state1; - - if (numBlocks == 0) - return; - - state0 = LOAD_128(&state[0]); - state1 = LOAD_128(&state[4]); - - do - { - v128 state0_save, state1_save; - v128 m0, m1, m2, m3; - v128 msg, tmp; - - state0_save = state0; - state1_save = state1; - - LOAD_SHUFFLE (m0, 0) - LOAD_SHUFFLE (m1, 1) - LOAD_SHUFFLE (m2, 2) - LOAD_SHUFFLE (m3, 3) - - R16 ( 0, NNN, NNN, SM1, NNN, SM1, SM2, SM1, SM2 ); - R16 ( 1, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); - R16 ( 2, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); - R16 ( 3, SM1, SM2, NNN, SM2, NNN, NNN, NNN, NNN ); - - state0 = vaddq_u32(state0, state0_save); - state1 = vaddq_u32(state1, state1_save); - - data += 64; - } - while (--numBlocks); - - STORE_128(&state[0], state0); - STORE_128(&state[4], state1); -} - -#endif // USE_HW_SHA - -#endif // MY_CPU_ARM_OR_ARM64 - - -#ifndef USE_HW_SHA - -// #error Stop_Compiling_UNSUPPORTED_SHA -// #include - -// #include "Sha256.h" -void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); - -#pragma message("Sha256 HW-SW stub was used") - -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); -void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks) -{ - Sha256_UpdateBlocks(state, data, numBlocks); - /* - UNUSED_VAR(state); - UNUSED_VAR(data); - UNUSED_VAR(numBlocks); - exit(1); - return; - */ -} - -#endif +/* Sha256Opt.c -- SHA-256 optimized code for SHA-256 hardware instructions +2021-04-01 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#if defined(_MSC_VER) +#if (_MSC_VER < 1900) && (_MSC_VER >= 1200) +// #define USE_MY_MM +#endif +#endif + +#include "CpuArch.h" + +#ifdef MY_CPU_X86_OR_AMD64 + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define USE_HW_SHA + #ifndef __SHA__ + #define ATTRIB_SHA __attribute__((__target__("sha,ssse3"))) + #if defined(_MSC_VER) + // SSSE3: for clang-cl: + #include + #define __SHA__ + #endif + #endif + + #endif + #elif defined(__GNUC__) + #if (__GNUC__ >= 8) // fix that check + #define USE_HW_SHA + #ifndef __SHA__ + #define ATTRIB_SHA __attribute__((__target__("sha,ssse3"))) + // #pragma GCC target("sha,ssse3") + #endif + #endif + #elif defined(__INTEL_COMPILER) + #if (__INTEL_COMPILER >= 1800) // fix that check + #define USE_HW_SHA + #endif + #elif defined(_MSC_VER) + #ifdef USE_MY_MM + #define USE_VER_MIN 1300 + #else + #define USE_VER_MIN 1910 + #endif + #if _MSC_VER >= USE_VER_MIN + #define USE_HW_SHA + #endif + #endif +// #endif // MY_CPU_X86_OR_AMD64 + +#ifdef USE_HW_SHA + +// #pragma message("Sha256 HW") +// #include + +#if !defined(_MSC_VER) || (_MSC_VER >= 1900) +#include +#else +#include + +#if defined(_MSC_VER) && (_MSC_VER >= 1600) +// #include +#endif + +#ifdef USE_MY_MM +#include "My_mm.h" +#endif + +#endif + +/* +SHA256 uses: +SSE2: + _mm_loadu_si128 + _mm_storeu_si128 + _mm_set_epi32 + _mm_add_epi32 + _mm_shuffle_epi32 / pshufd + + + +SSSE3: + _mm_shuffle_epi8 / pshufb + _mm_alignr_epi8 +SHA: + _mm_sha256* +*/ + +// K array must be aligned for 16-bytes at least. +// The compiler can look align attribute and selects +// movdqu - for code without align attribute +// movdqa - for code with align attribute +extern +MY_ALIGN(64) +const UInt32 SHA256_K_ARRAY[64]; + +#define K SHA256_K_ARRAY + + +#define ADD_EPI32(dest, src) dest = _mm_add_epi32(dest, src); +#define SHA256_MSG1(dest, src) dest = _mm_sha256msg1_epu32(dest, src); +#define SHA25G_MSG2(dest, src) dest = _mm_sha256msg2_epu32(dest, src); + + +#define LOAD_SHUFFLE(m, k) \ + m = _mm_loadu_si128((const __m128i *)(const void *)(data + (k) * 16)); \ + m = _mm_shuffle_epi8(m, mask); \ + +#define SM1(g0, g1, g2, g3) \ + SHA256_MSG1(g3, g0); \ + +#define SM2(g0, g1, g2, g3) \ + tmp = _mm_alignr_epi8(g1, g0, 4); \ + ADD_EPI32(g2, tmp); \ + SHA25G_MSG2(g2, g1); \ + +// #define LS0(k, g0, g1, g2, g3) LOAD_SHUFFLE(g0, k) +// #define LS1(k, g0, g1, g2, g3) LOAD_SHUFFLE(g1, k+1) + + +#define NNN(g0, g1, g2, g3) + + +#define RND2(t0, t1) \ + t0 = _mm_sha256rnds2_epu32(t0, t1, msg); + +#define RND2_0(m, k) \ + msg = _mm_add_epi32(m, *(const __m128i *) (const void *) &K[(k) * 4]); \ + RND2(state0, state1); \ + msg = _mm_shuffle_epi32(msg, 0x0E); \ + + +#define RND2_1 \ + RND2(state1, state0); \ + + +// We use scheme with 3 rounds ahead for SHA256_MSG1 / 2 rounds ahead for SHA256_MSG2 + +#define R4(k, g0, g1, g2, g3, OP0, OP1) \ + RND2_0(g0, k); \ + OP0(g0, g1, g2, g3); \ + RND2_1; \ + OP1(g0, g1, g2, g3); \ + +#define R16(k, OP0, OP1, OP2, OP3, OP4, OP5, OP6, OP7) \ + R4 ( (k)*4+0, m0, m1, m2, m3, OP0, OP1 ) \ + R4 ( (k)*4+1, m1, m2, m3, m0, OP2, OP3 ) \ + R4 ( (k)*4+2, m2, m3, m0, m1, OP4, OP5 ) \ + R4 ( (k)*4+3, m3, m0, m1, m2, OP6, OP7 ) \ + +#define PREPARE_STATE \ + tmp = _mm_shuffle_epi32(state0, 0x1B); /* abcd */ \ + state0 = _mm_shuffle_epi32(state1, 0x1B); /* efgh */ \ + state1 = state0; \ + state0 = _mm_unpacklo_epi64(state0, tmp); /* cdgh */ \ + state1 = _mm_unpackhi_epi64(state1, tmp); /* abef */ \ + + +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); +#ifdef ATTRIB_SHA +ATTRIB_SHA +#endif +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks) +{ + const __m128i mask = _mm_set_epi32(0x0c0d0e0f, 0x08090a0b, 0x04050607, 0x00010203); + __m128i tmp; + __m128i state0, state1; + + if (numBlocks == 0) + return; + + state0 = _mm_loadu_si128((const __m128i *) (const void *) &state[0]); + state1 = _mm_loadu_si128((const __m128i *) (const void *) &state[4]); + + PREPARE_STATE + + do + { + __m128i state0_save, state1_save; + __m128i m0, m1, m2, m3; + __m128i msg; + // #define msg tmp + + state0_save = state0; + state1_save = state1; + + LOAD_SHUFFLE (m0, 0) + LOAD_SHUFFLE (m1, 1) + LOAD_SHUFFLE (m2, 2) + LOAD_SHUFFLE (m3, 3) + + + + R16 ( 0, NNN, NNN, SM1, NNN, SM1, SM2, SM1, SM2 ); + R16 ( 1, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); + R16 ( 2, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); + R16 ( 3, SM1, SM2, NNN, SM2, NNN, NNN, NNN, NNN ); + + ADD_EPI32(state0, state0_save); + ADD_EPI32(state1, state1_save); + + data += 64; + } + while (--numBlocks); + + PREPARE_STATE + + _mm_storeu_si128((__m128i *) (void *) &state[0], state0); + _mm_storeu_si128((__m128i *) (void *) &state[4], state1); +} + +#endif // USE_HW_SHA + +#elif defined(MY_CPU_ARM_OR_ARM64) + + #if defined(__clang__) + #if (__clang_major__ >= 8) // fix that check + #define USE_HW_SHA + #endif + #elif defined(__GNUC__) + #if (__GNUC__ >= 6) // fix that check + #define USE_HW_SHA + #endif + #elif defined(_MSC_VER) + #if _MSC_VER >= 1910 + #define USE_HW_SHA + #endif + #endif + +#ifdef USE_HW_SHA + +// #pragma message("=== Sha256 HW === ") + +#if defined(__clang__) || defined(__GNUC__) + #ifdef MY_CPU_ARM64 + #define ATTRIB_SHA __attribute__((__target__("+crypto"))) + #else + #define ATTRIB_SHA __attribute__((__target__("fpu=crypto-neon-fp-armv8"))) + #endif +#else + // _MSC_VER + // for arm32 + #define _ARM_USE_NEW_NEON_INTRINSICS +#endif + +#if defined(_MSC_VER) && defined(MY_CPU_ARM64) +#include +#else +#include +#endif + +typedef uint32x4_t v128; +// typedef __n128 v128; // MSVC + +#ifdef MY_CPU_BE + #define MY_rev32_for_LE(x) +#else + #define MY_rev32_for_LE(x) x = vreinterpretq_u32_u8(vrev32q_u8(vreinterpretq_u8_u32(x))) +#endif + +#define LOAD_128(_p) (*(const v128 *)(const void *)(_p)) +#define STORE_128(_p, _v) *(v128 *)(void *)(_p) = (_v) + +#define LOAD_SHUFFLE(m, k) \ + m = LOAD_128((data + (k) * 16)); \ + MY_rev32_for_LE(m); \ + +// K array must be aligned for 16-bytes at least. +extern +MY_ALIGN(64) +const UInt32 SHA256_K_ARRAY[64]; + +#define K SHA256_K_ARRAY + + +#define SHA256_SU0(dest, src) dest = vsha256su0q_u32(dest, src); +#define SHA25G_SU1(dest, src2, src3) dest = vsha256su1q_u32(dest, src2, src3); + +#define SM1(g0, g1, g2, g3) SHA256_SU0(g3, g0) +#define SM2(g0, g1, g2, g3) SHA25G_SU1(g2, g0, g1) +#define NNN(g0, g1, g2, g3) + + +#define R4(k, g0, g1, g2, g3, OP0, OP1) \ + msg = vaddq_u32(g0, *(const v128 *) (const void *) &K[(k) * 4]); \ + tmp = state0; \ + state0 = vsha256hq_u32( state0, state1, msg ); \ + state1 = vsha256h2q_u32( state1, tmp, msg ); \ + OP0(g0, g1, g2, g3); \ + OP1(g0, g1, g2, g3); \ + + +#define R16(k, OP0, OP1, OP2, OP3, OP4, OP5, OP6, OP7) \ + R4 ( (k)*4+0, m0, m1, m2, m3, OP0, OP1 ) \ + R4 ( (k)*4+1, m1, m2, m3, m0, OP2, OP3 ) \ + R4 ( (k)*4+2, m2, m3, m0, m1, OP4, OP5 ) \ + R4 ( (k)*4+3, m3, m0, m1, m2, OP6, OP7 ) \ + + +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); +#ifdef ATTRIB_SHA +ATTRIB_SHA +#endif +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks) +{ + v128 state0, state1; + + if (numBlocks == 0) + return; + + state0 = LOAD_128(&state[0]); + state1 = LOAD_128(&state[4]); + + do + { + v128 state0_save, state1_save; + v128 m0, m1, m2, m3; + v128 msg, tmp; + + state0_save = state0; + state1_save = state1; + + LOAD_SHUFFLE (m0, 0) + LOAD_SHUFFLE (m1, 1) + LOAD_SHUFFLE (m2, 2) + LOAD_SHUFFLE (m3, 3) + + R16 ( 0, NNN, NNN, SM1, NNN, SM1, SM2, SM1, SM2 ); + R16 ( 1, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); + R16 ( 2, SM1, SM2, SM1, SM2, SM1, SM2, SM1, SM2 ); + R16 ( 3, SM1, SM2, NNN, SM2, NNN, NNN, NNN, NNN ); + + state0 = vaddq_u32(state0, state0_save); + state1 = vaddq_u32(state1, state1_save); + + data += 64; + } + while (--numBlocks); + + STORE_128(&state[0], state0); + STORE_128(&state[4], state1); +} + +#endif // USE_HW_SHA + +#endif // MY_CPU_ARM_OR_ARM64 + + +#ifndef USE_HW_SHA + +// #error Stop_Compiling_UNSUPPORTED_SHA +// #include + +// #include "Sha256.h" +void MY_FAST_CALL Sha256_UpdateBlocks(UInt32 state[8], const Byte *data, size_t numBlocks); + +#pragma message("Sha256 HW-SW stub was used") + +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks); +void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[8], const Byte *data, size_t numBlocks) +{ + Sha256_UpdateBlocks(state, data, numBlocks); + /* + UNUSED_VAR(state); + UNUSED_VAR(data); + UNUSED_VAR(numBlocks); + exit(1); + return; + */ +} + +#endif diff --git a/deps/LZMA-SDK/C/Sort.c b/deps/LZMA-SDK/C/Sort.c index 73dcbf059..e1097e380 100644 --- a/deps/LZMA-SDK/C/Sort.c +++ b/deps/LZMA-SDK/C/Sort.c @@ -1,141 +1,141 @@ -/* Sort.c -- Sort functions -2014-04-05 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "Sort.h" - -#define HeapSortDown(p, k, size, temp) \ - { for (;;) { \ - size_t s = (k << 1); \ - if (s > size) break; \ - if (s < size && p[s + 1] > p[s]) s++; \ - if (temp >= p[s]) break; \ - p[k] = p[s]; k = s; \ - } p[k] = temp; } - -void HeapSort(UInt32 *p, size_t size) -{ - if (size <= 1) - return; - p--; - { - size_t i = size / 2; - do - { - UInt32 temp = p[i]; - size_t k = i; - HeapSortDown(p, k, size, temp) - } - while (--i != 0); - } - /* - do - { - size_t k = 1; - UInt32 temp = p[size]; - p[size--] = p[1]; - HeapSortDown(p, k, size, temp) - } - while (size > 1); - */ - while (size > 3) - { - UInt32 temp = p[size]; - size_t k = (p[3] > p[2]) ? 3 : 2; - p[size--] = p[1]; - p[1] = p[k]; - HeapSortDown(p, k, size, temp) - } - { - UInt32 temp = p[size]; - p[size] = p[1]; - if (size > 2 && p[2] < temp) - { - p[1] = p[2]; - p[2] = temp; - } - else - p[1] = temp; - } -} - -void HeapSort64(UInt64 *p, size_t size) -{ - if (size <= 1) - return; - p--; - { - size_t i = size / 2; - do - { - UInt64 temp = p[i]; - size_t k = i; - HeapSortDown(p, k, size, temp) - } - while (--i != 0); - } - /* - do - { - size_t k = 1; - UInt64 temp = p[size]; - p[size--] = p[1]; - HeapSortDown(p, k, size, temp) - } - while (size > 1); - */ - while (size > 3) - { - UInt64 temp = p[size]; - size_t k = (p[3] > p[2]) ? 3 : 2; - p[size--] = p[1]; - p[1] = p[k]; - HeapSortDown(p, k, size, temp) - } - { - UInt64 temp = p[size]; - p[size] = p[1]; - if (size > 2 && p[2] < temp) - { - p[1] = p[2]; - p[2] = temp; - } - else - p[1] = temp; - } -} - -/* -#define HeapSortRefDown(p, vals, n, size, temp) \ - { size_t k = n; UInt32 val = vals[temp]; for (;;) { \ - size_t s = (k << 1); \ - if (s > size) break; \ - if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \ - if (val >= vals[p[s]]) break; \ - p[k] = p[s]; k = s; \ - } p[k] = temp; } - -void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size) -{ - if (size <= 1) - return; - p--; - { - size_t i = size / 2; - do - { - UInt32 temp = p[i]; - HeapSortRefDown(p, vals, i, size, temp); - } - while (--i != 0); - } - do - { - UInt32 temp = p[size]; - p[size--] = p[1]; - HeapSortRefDown(p, vals, 1, size, temp); - } - while (size > 1); -} -*/ +/* Sort.c -- Sort functions +2014-04-05 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "Sort.h" + +#define HeapSortDown(p, k, size, temp) \ + { for (;;) { \ + size_t s = (k << 1); \ + if (s > size) break; \ + if (s < size && p[s + 1] > p[s]) s++; \ + if (temp >= p[s]) break; \ + p[k] = p[s]; k = s; \ + } p[k] = temp; } + +void HeapSort(UInt32 *p, size_t size) +{ + if (size <= 1) + return; + p--; + { + size_t i = size / 2; + do + { + UInt32 temp = p[i]; + size_t k = i; + HeapSortDown(p, k, size, temp) + } + while (--i != 0); + } + /* + do + { + size_t k = 1; + UInt32 temp = p[size]; + p[size--] = p[1]; + HeapSortDown(p, k, size, temp) + } + while (size > 1); + */ + while (size > 3) + { + UInt32 temp = p[size]; + size_t k = (p[3] > p[2]) ? 3 : 2; + p[size--] = p[1]; + p[1] = p[k]; + HeapSortDown(p, k, size, temp) + } + { + UInt32 temp = p[size]; + p[size] = p[1]; + if (size > 2 && p[2] < temp) + { + p[1] = p[2]; + p[2] = temp; + } + else + p[1] = temp; + } +} + +void HeapSort64(UInt64 *p, size_t size) +{ + if (size <= 1) + return; + p--; + { + size_t i = size / 2; + do + { + UInt64 temp = p[i]; + size_t k = i; + HeapSortDown(p, k, size, temp) + } + while (--i != 0); + } + /* + do + { + size_t k = 1; + UInt64 temp = p[size]; + p[size--] = p[1]; + HeapSortDown(p, k, size, temp) + } + while (size > 1); + */ + while (size > 3) + { + UInt64 temp = p[size]; + size_t k = (p[3] > p[2]) ? 3 : 2; + p[size--] = p[1]; + p[1] = p[k]; + HeapSortDown(p, k, size, temp) + } + { + UInt64 temp = p[size]; + p[size] = p[1]; + if (size > 2 && p[2] < temp) + { + p[1] = p[2]; + p[2] = temp; + } + else + p[1] = temp; + } +} + +/* +#define HeapSortRefDown(p, vals, n, size, temp) \ + { size_t k = n; UInt32 val = vals[temp]; for (;;) { \ + size_t s = (k << 1); \ + if (s > size) break; \ + if (s < size && vals[p[s + 1]] > vals[p[s]]) s++; \ + if (val >= vals[p[s]]) break; \ + p[k] = p[s]; k = s; \ + } p[k] = temp; } + +void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size) +{ + if (size <= 1) + return; + p--; + { + size_t i = size / 2; + do + { + UInt32 temp = p[i]; + HeapSortRefDown(p, vals, i, size, temp); + } + while (--i != 0); + } + do + { + UInt32 temp = p[size]; + p[size--] = p[1]; + HeapSortRefDown(p, vals, 1, size, temp); + } + while (size > 1); +} +*/ diff --git a/deps/LZMA-SDK/C/Sort.h b/deps/LZMA-SDK/C/Sort.h index 7209d7824..2e2963a23 100644 --- a/deps/LZMA-SDK/C/Sort.h +++ b/deps/LZMA-SDK/C/Sort.h @@ -1,18 +1,18 @@ -/* Sort.h -- Sort functions -2014-04-05 : Igor Pavlov : Public domain */ - -#ifndef __7Z_SORT_H -#define __7Z_SORT_H - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -void HeapSort(UInt32 *p, size_t size); -void HeapSort64(UInt64 *p, size_t size); - -/* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */ - -EXTERN_C_END - -#endif +/* Sort.h -- Sort functions +2014-04-05 : Igor Pavlov : Public domain */ + +#ifndef __7Z_SORT_H +#define __7Z_SORT_H + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +void HeapSort(UInt32 *p, size_t size); +void HeapSort64(UInt64 *p, size_t size); + +/* void HeapSortRef(UInt32 *p, UInt32 *vals, size_t size); */ + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Threads.c b/deps/LZMA-SDK/C/Threads.c index 402abab01..58eb90ffa 100644 --- a/deps/LZMA-SDK/C/Threads.c +++ b/deps/LZMA-SDK/C/Threads.c @@ -1,506 +1,540 @@ -/* Threads.c -- multithreading library -2021-04-25 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#ifdef _WIN32 - -#ifndef UNDER_CE -#include -#endif - -#include "Threads.h" - -static WRes GetError() -{ - DWORD res = GetLastError(); - return res ? (WRes)res : 1; -} - -static WRes HandleToWRes(HANDLE h) { return (h != NULL) ? 0 : GetError(); } -static WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); } - -WRes HandlePtr_Close(HANDLE *p) -{ - if (*p != NULL) - { - if (!CloseHandle(*p)) - return GetError(); - *p = NULL; - } - return 0; -} - -WRes Handle_WaitObject(HANDLE h) -{ - DWORD dw = WaitForSingleObject(h, INFINITE); - /* - (dw) result: - WAIT_OBJECT_0 // 0 - WAIT_ABANDONED // 0x00000080 : is not compatible with Win32 Error space - WAIT_TIMEOUT // 0x00000102 : is compatible with Win32 Error space - WAIT_FAILED // 0xFFFFFFFF - */ - if (dw == WAIT_FAILED) - { - dw = GetLastError(); - if (dw == 0) - return WAIT_FAILED; - } - return (WRes)dw; -} - -#define Thread_Wait(p) Handle_WaitObject(*(p)) - -WRes Thread_Wait_Close(CThread *p) -{ - WRes res = Thread_Wait(p); - WRes res2 = Thread_Close(p); - return (res != 0 ? res : res2); -} - -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) -{ - /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ - - #ifdef UNDER_CE - - DWORD threadId; - *p = CreateThread(0, 0, func, param, 0, &threadId); - - #else - - unsigned threadId; - *p = (HANDLE)(_beginthreadex(NULL, 0, func, param, 0, &threadId)); - - #endif - - /* maybe we must use errno here, but probably GetLastError() is also OK. */ - return HandleToWRes(*p); -} - - -WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity) -{ - #ifdef UNDER_CE - - UNUSED_VAR(affinity) - return Thread_Create(p, func, param); - - #else - - /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ - HANDLE h; - WRes wres; - unsigned threadId; - h = (HANDLE)(_beginthreadex(NULL, 0, func, param, CREATE_SUSPENDED, &threadId)); - *p = h; - wres = HandleToWRes(h); - if (h) - { - { - // DWORD_PTR prevMask = - SetThreadAffinityMask(h, (DWORD_PTR)affinity); - /* - if (prevMask == 0) - { - // affinity change is non-critical error, so we can ignore it - // wres = GetError(); - } - */ - } - { - DWORD prevSuspendCount = ResumeThread(h); - /* ResumeThread() returns: - 0 : was_not_suspended - 1 : was_resumed - -1 : error - */ - if (prevSuspendCount == (DWORD)-1) - wres = GetError(); - } - } - - /* maybe we must use errno here, but probably GetLastError() is also OK. */ - return wres; - - #endif -} - - -static WRes Event_Create(CEvent *p, BOOL manualReset, int signaled) -{ - *p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL); - return HandleToWRes(*p); -} - -WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(*p)); } -WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(*p)); } - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) { return Event_Create(p, TRUE, signaled); } -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Create(p, FALSE, signaled); } -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); } -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); } - - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - // negative ((LONG)maxCount) is not supported in WIN32::CreateSemaphore() - *p = CreateSemaphore(NULL, (LONG)initCount, (LONG)maxCount, NULL); - return HandleToWRes(*p); -} - -static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount) - { return BOOLToWRes(ReleaseSemaphore(*p, releaseCount, previousCount)); } -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num) - { return Semaphore_Release(p, (LONG)num, NULL); } -WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); } - -WRes CriticalSection_Init(CCriticalSection *p) -{ - /* InitializeCriticalSection can raise only STATUS_NO_MEMORY exception */ - #ifdef _MSC_VER - __try - #endif - { - InitializeCriticalSection(p); - /* InitializeCriticalSectionAndSpinCount(p, 0); */ - } - #ifdef _MSC_VER - __except (EXCEPTION_EXECUTE_HANDLER) { return 1; } - #endif - return 0; -} - - - - -#else // _WIN32 - -// ---------- POSIX ---------- - -#ifndef __APPLE__ -#ifndef _7ZIP_AFFINITY_DISABLE -// _GNU_SOURCE can be required for pthread_setaffinity_np() / CPU_ZERO / CPU_SET -#define _GNU_SOURCE -#endif -#endif - -#include "Threads.h" - -#include -#include -#include -#ifdef _7ZIP_AFFINITY_SUPPORTED -// #include -#endif - - -// #include -// #define PRF(p) p -#define PRF(p) - -#define Print(s) PRF(printf("\n%s\n", s)) - -// #include - -WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, const CCpuSet *cpuSet) -{ - // new thread in Posix probably inherits affinity from parrent thread - Print("Thread_Create_With_CpuSet"); - - pthread_attr_t attr; - int ret; - // int ret2; - - p->_created = 0; - - RINOK(pthread_attr_init(&attr)); - - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - if (!ret) - { - if (cpuSet) - { - #ifdef _7ZIP_AFFINITY_SUPPORTED - - /* - printf("\n affinity :"); - unsigned i; - for (i = 0; i < sizeof(*cpuSet) && i < 8; i++) - { - Byte b = *((const Byte *)cpuSet + i); - char temp[32]; - #define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))))) - temp[0] = GET_HEX_CHAR((b & 0xF)); - temp[1] = GET_HEX_CHAR((b >> 4)); - // temp[0] = GET_HEX_CHAR((b >> 4)); // big-endian - // temp[1] = GET_HEX_CHAR((b & 0xF)); // big-endian - temp[2] = 0; - printf("%s", temp); - } - printf("\n"); - */ - - // ret2 = - pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet); - // if (ret2) ret = ret2; - #endif - } - - ret = pthread_create(&p->_tid, &attr, func, param); - - if (!ret) - { - p->_created = 1; - /* - if (cpuSet) - { - // ret2 = - pthread_setaffinity_np(p->_tid, sizeof(*cpuSet), cpuSet); - // if (ret2) ret = ret2; - } - */ - } - } - // ret2 = - pthread_attr_destroy(&attr); - // if (ret2 != 0) ret = ret2; - return ret; -} - - -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) -{ - return Thread_Create_With_CpuSet(p, func, param, NULL); -} - - -WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity) -{ - Print("Thread_Create_WithAffinity"); - CCpuSet cs; - unsigned i; - CpuSet_Zero(&cs); - for (i = 0; i < sizeof(affinity) * 8; i++) - { - if (affinity == 0) - break; - if (affinity & 1) - { - CpuSet_Set(&cs, i); - } - affinity >>= 1; - } - return Thread_Create_With_CpuSet(p, func, param, &cs); -} - - -WRes Thread_Close(CThread *p) -{ - // Print("Thread_Close"); - int ret; - if (!p->_created) - return 0; - - ret = pthread_detach(p->_tid); - p->_tid = 0; - p->_created = 0; - return ret; -} - - -WRes Thread_Wait_Close(CThread *p) -{ - // Print("Thread_Wait_Close"); - void *thread_return; - int ret; - if (!p->_created) - return EINVAL; - - ret = pthread_join(p->_tid, &thread_return); - // probably we can't use that (_tid) after pthread_join(), so we close thread here - p->_created = 0; - p->_tid = 0; - return ret; -} - - - -static WRes Event_Create(CEvent *p, int manualReset, int signaled) -{ - RINOK(pthread_mutex_init(&p->_mutex, NULL)); - RINOK(pthread_cond_init(&p->_cond, NULL)); - p->_manual_reset = manualReset; - p->_state = (signaled ? True : False); - p->_created = 1; - return 0; -} - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) - { return Event_Create(p, True, signaled); } -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) - { return ManualResetEvent_Create(p, 0); } -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) - { return Event_Create(p, False, signaled); } -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) - { return AutoResetEvent_Create(p, 0); } - - -WRes Event_Set(CEvent *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)); - p->_state = True; - int res1 = pthread_cond_broadcast(&p->_cond); - int res2 = pthread_mutex_unlock(&p->_mutex); - return (res2 ? res2 : res1); -} - -WRes Event_Reset(CEvent *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)); - p->_state = False; - return pthread_mutex_unlock(&p->_mutex); -} - -WRes Event_Wait(CEvent *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)); - while (p->_state == False) - { - // ETIMEDOUT - // ret = - pthread_cond_wait(&p->_cond, &p->_mutex); - // if (ret != 0) break; - } - if (p->_manual_reset == False) - { - p->_state = False; - } - return pthread_mutex_unlock(&p->_mutex); -} - -WRes Event_Close(CEvent *p) -{ - if (!p->_created) - return 0; - p->_created = 0; - { - int res1 = pthread_mutex_destroy(&p->_mutex); - int res2 = pthread_cond_destroy(&p->_cond); - return (res1 ? res1 : res2); - } -} - - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) -{ - if (initCount > maxCount || maxCount < 1) - return EINVAL; - RINOK(pthread_mutex_init(&p->_mutex, NULL)); - RINOK(pthread_cond_init(&p->_cond, NULL)); - p->_count = initCount; - p->_maxCount = maxCount; - p->_created = 1; - return 0; -} - -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount) -{ - UInt32 newCount; - int ret; - - if (releaseCount < 1) - return EINVAL; - - RINOK(pthread_mutex_lock(&p->_mutex)); - - newCount = p->_count + releaseCount; - if (newCount > p->_maxCount) - ret = ERROR_TOO_MANY_POSTS; // EINVAL; - else - { - p->_count = newCount; - ret = pthread_cond_broadcast(&p->_cond); - } - RINOK(pthread_mutex_unlock(&p->_mutex)); - return ret; -} - -WRes Semaphore_Wait(CSemaphore *p) -{ - RINOK(pthread_mutex_lock(&p->_mutex)); - while (p->_count < 1) - { - pthread_cond_wait(&p->_cond, &p->_mutex); - } - p->_count--; - return pthread_mutex_unlock(&p->_mutex); -} - -WRes Semaphore_Close(CSemaphore *p) -{ - if (!p->_created) - return 0; - p->_created = 0; - { - int res1 = pthread_mutex_destroy(&p->_mutex); - int res2 = pthread_cond_destroy(&p->_cond); - return (res1 ? res1 : res2); - } -} - - - -WRes CriticalSection_Init(CCriticalSection *p) -{ - // Print("CriticalSection_Init"); - if (!p) - return EINTR; - return pthread_mutex_init(&p->_mutex, NULL); -} - -void CriticalSection_Enter(CCriticalSection *p) -{ - // Print("CriticalSection_Enter"); - if (p) - { - // int ret = - pthread_mutex_lock(&p->_mutex); - } -} - -void CriticalSection_Leave(CCriticalSection *p) -{ - // Print("CriticalSection_Leave"); - if (p) - { - // int ret = - pthread_mutex_unlock(&p->_mutex); - } -} - -void CriticalSection_Delete(CCriticalSection *p) -{ - // Print("CriticalSection_Delete"); - if (p) - { - // int ret = - pthread_mutex_destroy(&p->_mutex); - } -} - -LONG InterlockedIncrement(LONG volatile *addend) -{ - // Print("InterlockedIncrement"); - #ifdef USE_HACK_UNSAFE_ATOMIC - LONG val = *addend + 1; - *addend = val; - return val; - #else - return __sync_add_and_fetch(addend, 1); - #endif -} - -#endif // _WIN32 +/* Threads.c -- multithreading library +2021-12-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#ifdef _WIN32 + +#ifndef USE_THREADS_CreateThread +#include +#endif + +#include "Threads.h" + +static WRes GetError() +{ + DWORD res = GetLastError(); + return res ? (WRes)res : 1; +} + +static WRes HandleToWRes(HANDLE h) { return (h != NULL) ? 0 : GetError(); } +static WRes BOOLToWRes(BOOL v) { return v ? 0 : GetError(); } + +WRes HandlePtr_Close(HANDLE *p) +{ + if (*p != NULL) + { + if (!CloseHandle(*p)) + return GetError(); + *p = NULL; + } + return 0; +} + +WRes Handle_WaitObject(HANDLE h) +{ + DWORD dw = WaitForSingleObject(h, INFINITE); + /* + (dw) result: + WAIT_OBJECT_0 // 0 + WAIT_ABANDONED // 0x00000080 : is not compatible with Win32 Error space + WAIT_TIMEOUT // 0x00000102 : is compatible with Win32 Error space + WAIT_FAILED // 0xFFFFFFFF + */ + if (dw == WAIT_FAILED) + { + dw = GetLastError(); + if (dw == 0) + return WAIT_FAILED; + } + return (WRes)dw; +} + +#define Thread_Wait(p) Handle_WaitObject(*(p)) + +WRes Thread_Wait_Close(CThread *p) +{ + WRes res = Thread_Wait(p); + WRes res2 = Thread_Close(p); + return (res != 0 ? res : res2); +} + +WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) +{ + /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ + + #ifdef USE_THREADS_CreateThread + + DWORD threadId; + *p = CreateThread(NULL, 0, func, param, 0, &threadId); + + #else + + unsigned threadId; + *p = (HANDLE)(_beginthreadex(NULL, 0, func, param, 0, &threadId)); + + #endif + + /* maybe we must use errno here, but probably GetLastError() is also OK. */ + return HandleToWRes(*p); +} + + +WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity) +{ + #ifdef USE_THREADS_CreateThread + + UNUSED_VAR(affinity) + return Thread_Create(p, func, param); + + #else + + /* Windows Me/98/95: threadId parameter may not be NULL in _beginthreadex/CreateThread functions */ + HANDLE h; + WRes wres; + unsigned threadId; + h = (HANDLE)(_beginthreadex(NULL, 0, func, param, CREATE_SUSPENDED, &threadId)); + *p = h; + wres = HandleToWRes(h); + if (h) + { + { + // DWORD_PTR prevMask = + SetThreadAffinityMask(h, (DWORD_PTR)affinity); + /* + if (prevMask == 0) + { + // affinity change is non-critical error, so we can ignore it + // wres = GetError(); + } + */ + } + { + DWORD prevSuspendCount = ResumeThread(h); + /* ResumeThread() returns: + 0 : was_not_suspended + 1 : was_resumed + -1 : error + */ + if (prevSuspendCount == (DWORD)-1) + wres = GetError(); + } + } + + /* maybe we must use errno here, but probably GetLastError() is also OK. */ + return wres; + + #endif +} + + +static WRes Event_Create(CEvent *p, BOOL manualReset, int signaled) +{ + *p = CreateEvent(NULL, manualReset, (signaled ? TRUE : FALSE), NULL); + return HandleToWRes(*p); +} + +WRes Event_Set(CEvent *p) { return BOOLToWRes(SetEvent(*p)); } +WRes Event_Reset(CEvent *p) { return BOOLToWRes(ResetEvent(*p)); } + +WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) { return Event_Create(p, TRUE, signaled); } +WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Create(p, FALSE, signaled); } +WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); } +WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); } + + +WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) +{ + // negative ((LONG)maxCount) is not supported in WIN32::CreateSemaphore() + *p = CreateSemaphore(NULL, (LONG)initCount, (LONG)maxCount, NULL); + return HandleToWRes(*p); +} + +WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount) +{ + // if (Semaphore_IsCreated(p)) + { + WRes wres = Semaphore_Close(p); + if (wres != 0) + return wres; + } + return Semaphore_Create(p, initCount, maxCount); +} + +static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount) + { return BOOLToWRes(ReleaseSemaphore(*p, releaseCount, previousCount)); } +WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num) + { return Semaphore_Release(p, (LONG)num, NULL); } +WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); } + +WRes CriticalSection_Init(CCriticalSection *p) +{ + /* InitializeCriticalSection() can raise exception: + Windows XP, 2003 : can raise a STATUS_NO_MEMORY exception + Windows Vista+ : no exceptions */ + #ifdef _MSC_VER + __try + #endif + { + InitializeCriticalSection(p); + /* InitializeCriticalSectionAndSpinCount(p, 0); */ + } + #ifdef _MSC_VER + __except (EXCEPTION_EXECUTE_HANDLER) { return ERROR_NOT_ENOUGH_MEMORY; } + #endif + return 0; +} + + + + +#else // _WIN32 + +// ---------- POSIX ---------- + +#ifndef __APPLE__ +#ifndef _7ZIP_AFFINITY_DISABLE +// _GNU_SOURCE can be required for pthread_setaffinity_np() / CPU_ZERO / CPU_SET +#define _GNU_SOURCE +#endif +#endif + +#include "Threads.h" + +#include +#include +#include +#ifdef _7ZIP_AFFINITY_SUPPORTED +// #include +#endif + + +// #include +// #define PRF(p) p +#define PRF(p) + +#define Print(s) PRF(printf("\n%s\n", s)) + +// #include + +WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, const CCpuSet *cpuSet) +{ + // new thread in Posix probably inherits affinity from parrent thread + Print("Thread_Create_With_CpuSet"); + + pthread_attr_t attr; + int ret; + // int ret2; + + p->_created = 0; + + RINOK(pthread_attr_init(&attr)); + + ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + + if (!ret) + { + if (cpuSet) + { + #ifdef _7ZIP_AFFINITY_SUPPORTED + + /* + printf("\n affinity :"); + unsigned i; + for (i = 0; i < sizeof(*cpuSet) && i < 8; i++) + { + Byte b = *((const Byte *)cpuSet + i); + char temp[32]; + #define GET_HEX_CHAR(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10))))) + temp[0] = GET_HEX_CHAR((b & 0xF)); + temp[1] = GET_HEX_CHAR((b >> 4)); + // temp[0] = GET_HEX_CHAR((b >> 4)); // big-endian + // temp[1] = GET_HEX_CHAR((b & 0xF)); // big-endian + temp[2] = 0; + printf("%s", temp); + } + printf("\n"); + */ + + // ret2 = + pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet); + // if (ret2) ret = ret2; + #endif + } + + ret = pthread_create(&p->_tid, &attr, func, param); + + if (!ret) + { + p->_created = 1; + /* + if (cpuSet) + { + // ret2 = + pthread_setaffinity_np(p->_tid, sizeof(*cpuSet), cpuSet); + // if (ret2) ret = ret2; + } + */ + } + } + // ret2 = + pthread_attr_destroy(&attr); + // if (ret2 != 0) ret = ret2; + return ret; +} + + +WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param) +{ + return Thread_Create_With_CpuSet(p, func, param, NULL); +} + + +WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity) +{ + Print("Thread_Create_WithAffinity"); + CCpuSet cs; + unsigned i; + CpuSet_Zero(&cs); + for (i = 0; i < sizeof(affinity) * 8; i++) + { + if (affinity == 0) + break; + if (affinity & 1) + { + CpuSet_Set(&cs, i); + } + affinity >>= 1; + } + return Thread_Create_With_CpuSet(p, func, param, &cs); +} + + +WRes Thread_Close(CThread *p) +{ + // Print("Thread_Close"); + int ret; + if (!p->_created) + return 0; + + ret = pthread_detach(p->_tid); + p->_tid = 0; + p->_created = 0; + return ret; +} + + +WRes Thread_Wait_Close(CThread *p) +{ + // Print("Thread_Wait_Close"); + void *thread_return; + int ret; + if (!p->_created) + return EINVAL; + + ret = pthread_join(p->_tid, &thread_return); + // probably we can't use that (_tid) after pthread_join(), so we close thread here + p->_created = 0; + p->_tid = 0; + return ret; +} + + + +static WRes Event_Create(CEvent *p, int manualReset, int signaled) +{ + RINOK(pthread_mutex_init(&p->_mutex, NULL)); + RINOK(pthread_cond_init(&p->_cond, NULL)); + p->_manual_reset = manualReset; + p->_state = (signaled ? True : False); + p->_created = 1; + return 0; +} + +WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled) + { return Event_Create(p, True, signaled); } +WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) + { return ManualResetEvent_Create(p, 0); } +WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) + { return Event_Create(p, False, signaled); } +WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) + { return AutoResetEvent_Create(p, 0); } + + +WRes Event_Set(CEvent *p) +{ + RINOK(pthread_mutex_lock(&p->_mutex)); + p->_state = True; + int res1 = pthread_cond_broadcast(&p->_cond); + int res2 = pthread_mutex_unlock(&p->_mutex); + return (res2 ? res2 : res1); +} + +WRes Event_Reset(CEvent *p) +{ + RINOK(pthread_mutex_lock(&p->_mutex)); + p->_state = False; + return pthread_mutex_unlock(&p->_mutex); +} + +WRes Event_Wait(CEvent *p) +{ + RINOK(pthread_mutex_lock(&p->_mutex)); + while (p->_state == False) + { + // ETIMEDOUT + // ret = + pthread_cond_wait(&p->_cond, &p->_mutex); + // if (ret != 0) break; + } + if (p->_manual_reset == False) + { + p->_state = False; + } + return pthread_mutex_unlock(&p->_mutex); +} + +WRes Event_Close(CEvent *p) +{ + if (!p->_created) + return 0; + p->_created = 0; + { + int res1 = pthread_mutex_destroy(&p->_mutex); + int res2 = pthread_cond_destroy(&p->_cond); + return (res1 ? res1 : res2); + } +} + + +WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount) +{ + if (initCount > maxCount || maxCount < 1) + return EINVAL; + RINOK(pthread_mutex_init(&p->_mutex, NULL)); + RINOK(pthread_cond_init(&p->_cond, NULL)); + p->_count = initCount; + p->_maxCount = maxCount; + p->_created = 1; + return 0; +} + + +WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount) +{ + if (Semaphore_IsCreated(p)) + { + /* + WRes wres = Semaphore_Close(p); + if (wres != 0) + return wres; + */ + if (initCount > maxCount || maxCount < 1) + return EINVAL; + // return EINVAL; // for debug + p->_count = initCount; + p->_maxCount = maxCount; + return 0; + } + return Semaphore_Create(p, initCount, maxCount); +} + + +WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 releaseCount) +{ + UInt32 newCount; + int ret; + + if (releaseCount < 1) + return EINVAL; + + RINOK(pthread_mutex_lock(&p->_mutex)); + + newCount = p->_count + releaseCount; + if (newCount > p->_maxCount) + ret = ERROR_TOO_MANY_POSTS; // EINVAL; + else + { + p->_count = newCount; + ret = pthread_cond_broadcast(&p->_cond); + } + RINOK(pthread_mutex_unlock(&p->_mutex)); + return ret; +} + +WRes Semaphore_Wait(CSemaphore *p) +{ + RINOK(pthread_mutex_lock(&p->_mutex)); + while (p->_count < 1) + { + pthread_cond_wait(&p->_cond, &p->_mutex); + } + p->_count--; + return pthread_mutex_unlock(&p->_mutex); +} + +WRes Semaphore_Close(CSemaphore *p) +{ + if (!p->_created) + return 0; + p->_created = 0; + { + int res1 = pthread_mutex_destroy(&p->_mutex); + int res2 = pthread_cond_destroy(&p->_cond); + return (res1 ? res1 : res2); + } +} + + + +WRes CriticalSection_Init(CCriticalSection *p) +{ + // Print("CriticalSection_Init"); + if (!p) + return EINTR; + return pthread_mutex_init(&p->_mutex, NULL); +} + +void CriticalSection_Enter(CCriticalSection *p) +{ + // Print("CriticalSection_Enter"); + if (p) + { + // int ret = + pthread_mutex_lock(&p->_mutex); + } +} + +void CriticalSection_Leave(CCriticalSection *p) +{ + // Print("CriticalSection_Leave"); + if (p) + { + // int ret = + pthread_mutex_unlock(&p->_mutex); + } +} + +void CriticalSection_Delete(CCriticalSection *p) +{ + // Print("CriticalSection_Delete"); + if (p) + { + // int ret = + pthread_mutex_destroy(&p->_mutex); + } +} + +LONG InterlockedIncrement(LONG volatile *addend) +{ + // Print("InterlockedIncrement"); + #ifdef USE_HACK_UNSAFE_ATOMIC + LONG val = *addend + 1; + *addend = val; + return val; + #else + return __sync_add_and_fetch(addend, 1); + #endif +} + +#endif // _WIN32 diff --git a/deps/LZMA-SDK/C/Threads.h b/deps/LZMA-SDK/C/Threads.h index c555c8b97..ceb844a23 100644 --- a/deps/LZMA-SDK/C/Threads.h +++ b/deps/LZMA-SDK/C/Threads.h @@ -1,197 +1,232 @@ -/* Threads.h -- multithreading library -2021-04-25 : Igor Pavlov : Public domain */ - -#ifndef __7Z_THREADS_H -#define __7Z_THREADS_H - -#ifdef _WIN32 -#include -#else - -#if !defined(__APPLE__) && !defined(_AIX) -#ifndef _7ZIP_AFFINITY_DISABLE -#define _7ZIP_AFFINITY_SUPPORTED -// #define _GNU_SOURCE -#endif -#endif - -#include -#endif - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -#ifdef _WIN32 - -WRes HandlePtr_Close(HANDLE *h); -WRes Handle_WaitObject(HANDLE h); - -typedef HANDLE CThread; - -#define Thread_Construct(p) { *(p) = NULL; } -#define Thread_WasCreated(p) (*(p) != NULL) -#define Thread_Close(p) HandlePtr_Close(p) -// #define Thread_Wait(p) Handle_WaitObject(*(p)) - -typedef - #ifdef UNDER_CE - DWORD - #else - unsigned - #endif - THREAD_FUNC_RET_TYPE; - -typedef DWORD_PTR CAffinityMask; -typedef DWORD_PTR CCpuSet; - -#define CpuSet_Zero(p) { *(p) = 0; } -#define CpuSet_Set(p, cpu) { *(p) |= ((DWORD_PTR)1 << (cpu)); } - -#else // _WIN32 - -typedef struct _CThread -{ - pthread_t _tid; - int _created; -} CThread; - -#define Thread_Construct(p) { (p)->_tid = 0; (p)->_created = 0; } -#define Thread_WasCreated(p) ((p)->_created != 0) -WRes Thread_Close(CThread *p); -// #define Thread_Wait Thread_Wait_Close - -typedef void * THREAD_FUNC_RET_TYPE; - -typedef UInt64 CAffinityMask; - -#ifdef _7ZIP_AFFINITY_SUPPORTED - -typedef cpu_set_t CCpuSet; -#define CpuSet_Zero(p) CPU_ZERO(p) -#define CpuSet_Set(p, cpu) CPU_SET(cpu, p) -#define CpuSet_IsSet(p, cpu) CPU_ISSET(cpu, p) - -#else - -typedef UInt64 CCpuSet; -#define CpuSet_Zero(p) { *(p) = 0; } -#define CpuSet_Set(p, cpu) { *(p) |= ((UInt64)1 << (cpu)); } -#define CpuSet_IsSet(p, cpu) ((*(p) & ((UInt64)1 << (cpu))) != 0) - -#endif - - -#endif // _WIN32 - - -#define THREAD_FUNC_CALL_TYPE MY_STD_CALL -#define THREAD_FUNC_DECL THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE -typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *); -WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param); -WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity); -WRes Thread_Wait_Close(CThread *p); - -#ifdef _WIN32 -#define Thread_Create_With_CpuSet(p, func, param, cs) \ - Thread_Create_With_Affinity(p, func, param, *cs) -#else -WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, const CCpuSet *cpuSet); -#endif - - -#ifdef _WIN32 - -typedef HANDLE CEvent; -typedef CEvent CAutoResetEvent; -typedef CEvent CManualResetEvent; -#define Event_Construct(p) *(p) = NULL -#define Event_IsCreated(p) (*(p) != NULL) -#define Event_Close(p) HandlePtr_Close(p) -#define Event_Wait(p) Handle_WaitObject(*(p)) -WRes Event_Set(CEvent *p); -WRes Event_Reset(CEvent *p); -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); - -typedef HANDLE CSemaphore; -#define Semaphore_Construct(p) *(p) = NULL -#define Semaphore_IsCreated(p) (*(p) != NULL) -#define Semaphore_Close(p) HandlePtr_Close(p) -#define Semaphore_Wait(p) Handle_WaitObject(*(p)) -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); -WRes Semaphore_Release1(CSemaphore *p); - -typedef CRITICAL_SECTION CCriticalSection; -WRes CriticalSection_Init(CCriticalSection *p); -#define CriticalSection_Delete(p) DeleteCriticalSection(p) -#define CriticalSection_Enter(p) EnterCriticalSection(p) -#define CriticalSection_Leave(p) LeaveCriticalSection(p) - - -#else // _WIN32 - -typedef struct _CEvent -{ - int _created; - int _manual_reset; - int _state; - pthread_mutex_t _mutex; - pthread_cond_t _cond; -} CEvent; - -typedef CEvent CAutoResetEvent; -typedef CEvent CManualResetEvent; - -#define Event_Construct(p) (p)->_created = 0 -#define Event_IsCreated(p) ((p)->_created) - -WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); -WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); -WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); -WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); -WRes Event_Set(CEvent *p); -WRes Event_Reset(CEvent *p); -WRes Event_Wait(CEvent *p); -WRes Event_Close(CEvent *p); - - -typedef struct _CSemaphore -{ - int _created; - UInt32 _count; - UInt32 _maxCount; - pthread_mutex_t _mutex; - pthread_cond_t _cond; -} CSemaphore; - -#define Semaphore_Construct(p) (p)->_created = 0 -#define Semaphore_IsCreated(p) ((p)->_created) - -WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); -WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); -#define Semaphore_Release1(p) Semaphore_ReleaseN(p, 1) -WRes Semaphore_Wait(CSemaphore *p); -WRes Semaphore_Close(CSemaphore *p); - - -typedef struct _CCriticalSection -{ - pthread_mutex_t _mutex; -} CCriticalSection; - -WRes CriticalSection_Init(CCriticalSection *p); -void CriticalSection_Delete(CCriticalSection *cs); -void CriticalSection_Enter(CCriticalSection *cs); -void CriticalSection_Leave(CCriticalSection *cs); - -LONG InterlockedIncrement(LONG volatile *addend); - -#endif // _WIN32 - -EXTERN_C_END - -#endif +/* Threads.h -- multithreading library +2021-12-21 : Igor Pavlov : Public domain */ + +#ifndef __7Z_THREADS_H +#define __7Z_THREADS_H + +#ifdef _WIN32 +#include +#else + +#if defined(__linux__) +#if !defined(__APPLE__) && !defined(_AIX) && !defined(__ANDROID__) +#ifndef _7ZIP_AFFINITY_DISABLE +#define _7ZIP_AFFINITY_SUPPORTED +// #pragma message(" ==== _7ZIP_AFFINITY_SUPPORTED") +// #define _GNU_SOURCE +#endif +#endif +#endif + +#include + +#endif + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +#ifdef _WIN32 + +WRes HandlePtr_Close(HANDLE *h); +WRes Handle_WaitObject(HANDLE h); + +typedef HANDLE CThread; + +#define Thread_Construct(p) { *(p) = NULL; } +#define Thread_WasCreated(p) (*(p) != NULL) +#define Thread_Close(p) HandlePtr_Close(p) +// #define Thread_Wait(p) Handle_WaitObject(*(p)) + +#ifdef UNDER_CE + // if (USE_THREADS_CreateThread is defined), we use _beginthreadex() + // if (USE_THREADS_CreateThread is not definned), we use CreateThread() + #define USE_THREADS_CreateThread +#endif + +typedef + #ifdef USE_THREADS_CreateThread + DWORD + #else + unsigned + #endif + THREAD_FUNC_RET_TYPE; + +typedef DWORD_PTR CAffinityMask; +typedef DWORD_PTR CCpuSet; + +#define CpuSet_Zero(p) { *(p) = 0; } +#define CpuSet_Set(p, cpu) { *(p) |= ((DWORD_PTR)1 << (cpu)); } + +#else // _WIN32 + +typedef struct _CThread +{ + pthread_t _tid; + int _created; +} CThread; + +#define Thread_Construct(p) { (p)->_tid = 0; (p)->_created = 0; } +#define Thread_WasCreated(p) ((p)->_created != 0) +WRes Thread_Close(CThread *p); +// #define Thread_Wait Thread_Wait_Close + +typedef void * THREAD_FUNC_RET_TYPE; + +typedef UInt64 CAffinityMask; + +#ifdef _7ZIP_AFFINITY_SUPPORTED + +typedef cpu_set_t CCpuSet; +#define CpuSet_Zero(p) CPU_ZERO(p) +#define CpuSet_Set(p, cpu) CPU_SET(cpu, p) +#define CpuSet_IsSet(p, cpu) CPU_ISSET(cpu, p) + +#else + +typedef UInt64 CCpuSet; +#define CpuSet_Zero(p) { *(p) = 0; } +#define CpuSet_Set(p, cpu) { *(p) |= ((UInt64)1 << (cpu)); } +#define CpuSet_IsSet(p, cpu) ((*(p) & ((UInt64)1 << (cpu))) != 0) + +#endif + + +#endif // _WIN32 + + +#define THREAD_FUNC_CALL_TYPE MY_STD_CALL + +#if defined(_WIN32) && defined(__GNUC__) +/* GCC compiler for x86 32-bit uses the rule: + the stack is 16-byte aligned before CALL instruction for function calling. + But only root function main() contains instructions that + set 16-byte alignment for stack pointer. And another functions + just keep alignment, if it was set in some parent function. + + The problem: + if we create new thread in MinGW (GCC) 32-bit x86 via _beginthreadex() or CreateThread(), + the root function of thread doesn't set 16-byte alignment. + And stack frames in all child functions also will be unaligned in that case. + + Here we set (force_align_arg_pointer) attribute for root function of new thread. + Do we need (force_align_arg_pointer) also for another systems? */ + + #define THREAD_FUNC_ATTRIB_ALIGN_ARG __attribute__((force_align_arg_pointer)) + // #define THREAD_FUNC_ATTRIB_ALIGN_ARG // for debug : bad alignment in SSE functions +#else + #define THREAD_FUNC_ATTRIB_ALIGN_ARG +#endif + +#define THREAD_FUNC_DECL THREAD_FUNC_ATTRIB_ALIGN_ARG THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE + +typedef THREAD_FUNC_RET_TYPE (THREAD_FUNC_CALL_TYPE * THREAD_FUNC_TYPE)(void *); +WRes Thread_Create(CThread *p, THREAD_FUNC_TYPE func, LPVOID param); +WRes Thread_Create_With_Affinity(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, CAffinityMask affinity); +WRes Thread_Wait_Close(CThread *p); + +#ifdef _WIN32 +#define Thread_Create_With_CpuSet(p, func, param, cs) \ + Thread_Create_With_Affinity(p, func, param, *cs) +#else +WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param, const CCpuSet *cpuSet); +#endif + + +#ifdef _WIN32 + +typedef HANDLE CEvent; +typedef CEvent CAutoResetEvent; +typedef CEvent CManualResetEvent; +#define Event_Construct(p) *(p) = NULL +#define Event_IsCreated(p) (*(p) != NULL) +#define Event_Close(p) HandlePtr_Close(p) +#define Event_Wait(p) Handle_WaitObject(*(p)) +WRes Event_Set(CEvent *p); +WRes Event_Reset(CEvent *p); +WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); +WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); +WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); +WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); + +typedef HANDLE CSemaphore; +#define Semaphore_Construct(p) *(p) = NULL +#define Semaphore_IsCreated(p) (*(p) != NULL) +#define Semaphore_Close(p) HandlePtr_Close(p) +#define Semaphore_Wait(p) Handle_WaitObject(*(p)) +WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); +WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount); +WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); +WRes Semaphore_Release1(CSemaphore *p); + +typedef CRITICAL_SECTION CCriticalSection; +WRes CriticalSection_Init(CCriticalSection *p); +#define CriticalSection_Delete(p) DeleteCriticalSection(p) +#define CriticalSection_Enter(p) EnterCriticalSection(p) +#define CriticalSection_Leave(p) LeaveCriticalSection(p) + + +#else // _WIN32 + +typedef struct _CEvent +{ + int _created; + int _manual_reset; + int _state; + pthread_mutex_t _mutex; + pthread_cond_t _cond; +} CEvent; + +typedef CEvent CAutoResetEvent; +typedef CEvent CManualResetEvent; + +#define Event_Construct(p) (p)->_created = 0 +#define Event_IsCreated(p) ((p)->_created) + +WRes ManualResetEvent_Create(CManualResetEvent *p, int signaled); +WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p); +WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled); +WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p); +WRes Event_Set(CEvent *p); +WRes Event_Reset(CEvent *p); +WRes Event_Wait(CEvent *p); +WRes Event_Close(CEvent *p); + + +typedef struct _CSemaphore +{ + int _created; + UInt32 _count; + UInt32 _maxCount; + pthread_mutex_t _mutex; + pthread_cond_t _cond; +} CSemaphore; + +#define Semaphore_Construct(p) (p)->_created = 0 +#define Semaphore_IsCreated(p) ((p)->_created) + +WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount); +WRes Semaphore_OptCreateInit(CSemaphore *p, UInt32 initCount, UInt32 maxCount); +WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num); +#define Semaphore_Release1(p) Semaphore_ReleaseN(p, 1) +WRes Semaphore_Wait(CSemaphore *p); +WRes Semaphore_Close(CSemaphore *p); + + +typedef struct _CCriticalSection +{ + pthread_mutex_t _mutex; +} CCriticalSection; + +WRes CriticalSection_Init(CCriticalSection *p); +void CriticalSection_Delete(CCriticalSection *cs); +void CriticalSection_Enter(CCriticalSection *cs); +void CriticalSection_Leave(CCriticalSection *cs); + +LONG InterlockedIncrement(LONG volatile *addend); + +#endif // _WIN32 + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/Util/7z/7z.dsp b/deps/LZMA-SDK/C/Util/7z/7z.dsp index d3bf0fe00..be0f0a743 100644 --- a/deps/LZMA-SDK/C/Util/7z/7z.dsp +++ b/deps/LZMA-SDK/C/Util/7z/7z.dsp @@ -1,241 +1,241 @@ -# Microsoft Developer Studio Project File - Name="7z" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=7z - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "7z.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "7z - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x419 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7zDec.exe" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "7z - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x419 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7zDec.exe" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "7z - Win32 Release" -# Name "7z - Win32 Debug" -# Begin Group "Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\7z.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zAlloc.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zAlloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zArcIn.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zBuf.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zBuf.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zCrc.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zCrc.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zCrcOpt.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zDec.c -# ADD CPP /D "_7ZIP_PPMD_SUPPPORT" -# End Source File -# Begin Source File - -SOURCE=..\..\7zFile.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zFile.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zStream.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\Bcj2.c -# End Source File -# Begin Source File - -SOURCE=..\..\Bcj2.h -# End Source File -# Begin Source File - -SOURCE=..\..\Bra.c -# End Source File -# Begin Source File - -SOURCE=..\..\Bra.h -# End Source File -# Begin Source File - -SOURCE=..\..\Bra86.c -# End Source File -# Begin Source File - -SOURCE=..\..\BraIA64.c -# End Source File -# Begin Source File - -SOURCE=..\..\CpuArch.c -# End Source File -# Begin Source File - -SOURCE=..\..\CpuArch.h -# End Source File -# Begin Source File - -SOURCE=..\..\Delta.c -# End Source File -# Begin Source File - -SOURCE=..\..\Delta.h -# End Source File -# Begin Source File - -SOURCE=..\..\Lzma2Dec.c -# End Source File -# Begin Source File - -SOURCE=..\..\Lzma2Dec.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.h -# End Source File -# Begin Source File - -SOURCE=..\..\Ppmd.h -# End Source File -# Begin Source File - -SOURCE=..\..\Ppmd7.c -# End Source File -# Begin Source File - -SOURCE=..\..\Ppmd7.h -# End Source File -# Begin Source File - -SOURCE=..\..\Ppmd7Dec.c -# End Source File -# End Group -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Compiler.h -# End Source File -# Begin Source File - -SOURCE=.\Precomp.c -# ADD CPP /Yc"Precomp.h" -# End Source File -# Begin Source File - -SOURCE=.\Precomp.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\7zMain.c -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="7z" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=7z - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "7z.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "7z - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /FAcs /Yu"Precomp.h" /FD /c +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x419 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7zDec.exe" /opt:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "7z - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_SZ_ALLOC_DEBUG2" /D "_SZ_NO_INT_64_A" /D "WIN32" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x419 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7zDec.exe" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "7z - Win32 Release" +# Name "7z - Win32 Debug" +# Begin Group "Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\7z.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zAlloc.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zAlloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zArcIn.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zBuf.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zBuf.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zCrc.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zCrc.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zCrcOpt.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zDec.c +# ADD CPP /D "_7ZIP_PPMD_SUPPPORT" +# End Source File +# Begin Source File + +SOURCE=..\..\7zFile.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zFile.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zStream.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zTypes.h +# End Source File +# Begin Source File + +SOURCE=..\..\Bcj2.c +# End Source File +# Begin Source File + +SOURCE=..\..\Bcj2.h +# End Source File +# Begin Source File + +SOURCE=..\..\Bra.c +# End Source File +# Begin Source File + +SOURCE=..\..\Bra.h +# End Source File +# Begin Source File + +SOURCE=..\..\Bra86.c +# End Source File +# Begin Source File + +SOURCE=..\..\BraIA64.c +# End Source File +# Begin Source File + +SOURCE=..\..\CpuArch.c +# End Source File +# Begin Source File + +SOURCE=..\..\CpuArch.h +# End Source File +# Begin Source File + +SOURCE=..\..\Delta.c +# End Source File +# Begin Source File + +SOURCE=..\..\Delta.h +# End Source File +# Begin Source File + +SOURCE=..\..\Lzma2Dec.c +# End Source File +# Begin Source File + +SOURCE=..\..\Lzma2Dec.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.h +# End Source File +# Begin Source File + +SOURCE=..\..\Ppmd.h +# End Source File +# Begin Source File + +SOURCE=..\..\Ppmd7.c +# End Source File +# Begin Source File + +SOURCE=..\..\Ppmd7.h +# End Source File +# Begin Source File + +SOURCE=..\..\Ppmd7Dec.c +# End Source File +# End Group +# Begin Group "Spec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Compiler.h +# End Source File +# Begin Source File + +SOURCE=.\Precomp.c +# ADD CPP /Yc"Precomp.h" +# End Source File +# Begin Source File + +SOURCE=.\Precomp.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\7zMain.c +# End Source File +# End Target +# End Project diff --git a/deps/LZMA-SDK/C/Util/7z/7z.dsw b/deps/LZMA-SDK/C/Util/7z/7z.dsw index 23089fb79..848d13cb1 100644 --- a/deps/LZMA-SDK/C/Util/7z/7z.dsw +++ b/deps/LZMA-SDK/C/Util/7z/7z.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "7z"=.\7z.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "7z"=.\7z.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/deps/LZMA-SDK/C/Util/7z/7zMain.c b/deps/LZMA-SDK/C/Util/7z/7zMain.c index 3ab63a3d9..9d555098e 100644 --- a/deps/LZMA-SDK/C/Util/7z/7zMain.c +++ b/deps/LZMA-SDK/C/Util/7z/7zMain.c @@ -1,887 +1,887 @@ -/* 7zMain.c - Test application for 7z Decoder -2021-04-29 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include -#include - -#include "../../CpuArch.h" - -#include "../../7z.h" -#include "../../7zAlloc.h" -#include "../../7zBuf.h" -#include "../../7zCrc.h" -#include "../../7zFile.h" -#include "../../7zVersion.h" - -#ifndef USE_WINDOWS_FILE -/* for mkdir */ -#ifdef _WIN32 -#include -#else -#include -#include -#ifdef __GNUC__ -#include -#endif -#include -// #include -#include -#include -#endif -#endif - - -#define kInputBufSize ((size_t)1 << 18) - -static const ISzAlloc g_Alloc = { SzAlloc, SzFree }; - - -static void Print(const char *s) -{ - fputs(s, stdout); -} - - -static int Buf_EnsureSize(CBuf *dest, size_t size) -{ - if (dest->size >= size) - return 1; - Buf_Free(dest, &g_Alloc); - return Buf_Create(dest, size, &g_Alloc); -} - -#ifndef _WIN32 -#define _USE_UTF8 -#endif - -/* #define _USE_UTF8 */ - -#ifdef _USE_UTF8 - -#define _UTF8_START(n) (0x100 - (1 << (7 - (n)))) - -#define _UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6)) - -#define _UTF8_HEAD(n, val) ((Byte)(_UTF8_START(n) + (val >> (6 * (n))))) -#define _UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F))) - -static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) -{ - size_t size = 0; - for (;;) - { - UInt32 val; - if (src == srcLim) - return size; - - size++; - val = *src++; - - if (val < 0x80) - continue; - - if (val < _UTF8_RANGE(1)) - { - size++; - continue; - } - - if (val >= 0xD800 && val < 0xDC00 && src != srcLim) - { - UInt32 c2 = *src; - if (c2 >= 0xDC00 && c2 < 0xE000) - { - src++; - size += 3; - continue; - } - } - - size += 2; - } -} - -static Byte *Utf16_To_Utf8(Byte *dest, const UInt16 *src, const UInt16 *srcLim) -{ - for (;;) - { - UInt32 val; - if (src == srcLim) - return dest; - - val = *src++; - - if (val < 0x80) - { - *dest++ = (Byte)val; - continue; - } - - if (val < _UTF8_RANGE(1)) - { - dest[0] = _UTF8_HEAD(1, val); - dest[1] = _UTF8_CHAR(0, val); - dest += 2; - continue; - } - - if (val >= 0xD800 && val < 0xDC00 && src != srcLim) - { - UInt32 c2 = *src; - if (c2 >= 0xDC00 && c2 < 0xE000) - { - src++; - val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; - dest[0] = _UTF8_HEAD(3, val); - dest[1] = _UTF8_CHAR(2, val); - dest[2] = _UTF8_CHAR(1, val); - dest[3] = _UTF8_CHAR(0, val); - dest += 4; - continue; - } - } - - dest[0] = _UTF8_HEAD(2, val); - dest[1] = _UTF8_CHAR(1, val); - dest[2] = _UTF8_CHAR(0, val); - dest += 3; - } -} - -static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen) -{ - size_t destLen = Utf16_To_Utf8_Calc(src, src + srcLen); - destLen += 1; - if (!Buf_EnsureSize(dest, destLen)) - return SZ_ERROR_MEM; - *Utf16_To_Utf8(dest->data, src, src + srcLen) = 0; - return SZ_OK; -} - -#endif - -static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s - #ifndef _USE_UTF8 - , UINT codePage - #endif - ) -{ - unsigned len = 0; - for (len = 0; s[len] != 0; len++) {} - - #ifndef _USE_UTF8 - { - const unsigned size = len * 3 + 100; - if (!Buf_EnsureSize(buf, size)) - return SZ_ERROR_MEM; - { - buf->data[0] = 0; - if (len != 0) - { - const char defaultChar = '_'; - BOOL defUsed; - const unsigned numChars = (unsigned)WideCharToMultiByte( - codePage, 0, (LPCWSTR)s, (int)len, (char *)buf->data, (int)size, &defaultChar, &defUsed); - if (numChars == 0 || numChars >= size) - return SZ_ERROR_FAIL; - buf->data[numChars] = 0; - } - return SZ_OK; - } - } - #else - return Utf16_To_Utf8Buf(buf, s, len); - #endif -} - -#ifdef _WIN32 - #ifndef USE_WINDOWS_FILE - static UINT g_FileCodePage = CP_ACP; - #define MY_FILE_CODE_PAGE_PARAM ,g_FileCodePage - #endif -#else - #define MY_FILE_CODE_PAGE_PARAM -#endif - -static WRes MyCreateDir(const UInt16 *name) -{ - #ifdef USE_WINDOWS_FILE - - return CreateDirectoryW((LPCWSTR)name, NULL) ? 0 : GetLastError(); - - #else - - CBuf buf; - WRes res; - Buf_Init(&buf); - RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); - - res = - #ifdef _WIN32 - _mkdir((const char *)buf.data) - #else - mkdir((const char *)buf.data, 0777) - #endif - == 0 ? 0 : errno; - Buf_Free(&buf, &g_Alloc); - return res; - - #endif -} - -static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name) -{ - #ifdef USE_WINDOWS_FILE - return OutFile_OpenW(p, (LPCWSTR)name); - #else - CBuf buf; - WRes res; - Buf_Init(&buf); - RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); - res = OutFile_Open(p, (const char *)buf.data); - Buf_Free(&buf, &g_Alloc); - return res; - #endif -} - - -static SRes PrintString(const UInt16 *s) -{ - CBuf buf; - SRes res; - Buf_Init(&buf); - res = Utf16_To_Char(&buf, s - #ifndef _USE_UTF8 - , CP_OEMCP - #endif - ); - if (res == SZ_OK) - Print((const char *)buf.data); - Buf_Free(&buf, &g_Alloc); - return res; -} - -static void UInt64ToStr(UInt64 value, char *s, int numDigits) -{ - char temp[32]; - int pos = 0; - do - { - temp[pos++] = (char)('0' + (unsigned)(value % 10)); - value /= 10; - } - while (value != 0); - - for (numDigits -= pos; numDigits > 0; numDigits--) - *s++ = ' '; - - do - *s++ = temp[--pos]; - while (pos); - *s = '\0'; -} - -static char *UIntToStr(char *s, unsigned value, int numDigits) -{ - char temp[16]; - int pos = 0; - do - temp[pos++] = (char)('0' + (value % 10)); - while (value /= 10); - - for (numDigits -= pos; numDigits > 0; numDigits--) - *s++ = '0'; - - do - *s++ = temp[--pos]; - while (pos); - *s = '\0'; - return s; -} - -static void UIntToStr_2(char *s, unsigned value) -{ - s[0] = (char)('0' + (value / 10)); - s[1] = (char)('0' + (value % 10)); -} - - -#define PERIOD_4 (4 * 365 + 1) -#define PERIOD_100 (PERIOD_4 * 25 - 1) -#define PERIOD_400 (PERIOD_100 * 4 + 1) - - - -#ifndef _WIN32 - -// MS uses long for BOOL, but long is 32-bit in MS. So we use int. -// typedef long BOOL; -typedef int BOOL; - -typedef struct _FILETIME -{ - DWORD dwLowDateTime; - DWORD dwHighDateTime; -} FILETIME; - -static LONG TIME_GetBias() -{ - time_t utc = time(NULL); - struct tm *ptm = localtime(&utc); - int localdaylight = ptm->tm_isdst; /* daylight for local timezone */ - ptm = gmtime(&utc); - ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */ - LONG bias = (int)(mktime(ptm)-utc); - return bias; -} - -#define TICKS_PER_SEC 10000000 - -#define GET_TIME_64(pft) ((pft)->dwLowDateTime | ((UInt64)(pft)->dwHighDateTime << 32)) - -#define SET_FILETIME(ft, v64) \ - (ft)->dwLowDateTime = (DWORD)v64; \ - (ft)->dwHighDateTime = (DWORD)(v64 >> 32); - -#define WINAPI -#define TRUE 1 - -static BOOL WINAPI FileTimeToLocalFileTime(const FILETIME *fileTime, FILETIME *localFileTime) -{ - UInt64 v = GET_TIME_64(fileTime); - v = (UInt64)((Int64)v - (Int64)TIME_GetBias() * TICKS_PER_SEC); - SET_FILETIME(localFileTime, v); - return TRUE; -} - -static const UInt32 kNumTimeQuantumsInSecond = 10000000; -static const UInt32 kFileTimeStartYear = 1601; -static const UInt32 kUnixTimeStartYear = 1970; -static const UInt64 kUnixTimeOffset = - (UInt64)60 * 60 * 24 * (89 + 365 * (kUnixTimeStartYear - kFileTimeStartYear)); - -static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft) -{ - UInt64 winTime = GET_TIME_64(ft); - return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset; -} - -#if defined(_AIX) - #define MY_ST_TIMESPEC st_timespec -#else - #define MY_ST_TIMESPEC timespec -#endif - -static void FILETIME_To_timespec(const FILETIME *ft, struct MY_ST_TIMESPEC *ts) -{ - if (ft) - { - const Int64 sec = Time_FileTimeToUnixTime64(ft); - // time_t is long - const time_t sec2 = (time_t)sec; - if (sec2 == sec) - { - ts->tv_sec = sec2; - UInt64 winTime = GET_TIME_64(ft); - ts->tv_nsec = (long)((winTime % 10000000) * 100);; - return; - } - } - // else - { - ts->tv_sec = 0; - // ts.tv_nsec = UTIME_NOW; // set to the current time - ts->tv_nsec = UTIME_OMIT; // keep old timesptamp - } -} - -static WRes Set_File_FILETIME(const UInt16 *name, const FILETIME *mTime) -{ - struct timespec times[2]; - - const int flags = 0; // follow link - // = AT_SYMLINK_NOFOLLOW; // don't follow link - - CBuf buf; - int res; - Buf_Init(&buf); - RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); - FILETIME_To_timespec(NULL, ×[0]); - FILETIME_To_timespec(mTime, ×[1]); - res = utimensat(AT_FDCWD, (const char *)buf.data, times, flags); - Buf_Free(&buf, &g_Alloc); - if (res == 0) - return 0; - return errno; -} - -#endif - -static void NtfsFileTime_to_FILETIME(const CNtfsFileTime *t, FILETIME *ft) -{ - ft->dwLowDateTime = (DWORD)(t->Low); - ft->dwHighDateTime = (DWORD)(t->High); -} - -static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s) -{ - unsigned year, mon, hour, min, sec; - Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - unsigned t; - UInt32 v; - // UInt64 v64 = nt->Low | ((UInt64)nt->High << 32); - UInt64 v64; - { - FILETIME fileTime, locTime; - NtfsFileTime_to_FILETIME(nTime, &fileTime); - if (!FileTimeToLocalFileTime(&fileTime, &locTime)) - { - locTime.dwHighDateTime = - locTime.dwLowDateTime = 0; - } - v64 = locTime.dwLowDateTime | ((UInt64)locTime.dwHighDateTime << 32); - } - v64 /= 10000000; - sec = (unsigned)(v64 % 60); v64 /= 60; - min = (unsigned)(v64 % 60); v64 /= 60; - hour = (unsigned)(v64 % 24); v64 /= 24; - - v = (UInt32)v64; - - year = (unsigned)(1601 + v / PERIOD_400 * 400); - v %= PERIOD_400; - - t = v / PERIOD_100; if (t == 4) t = 3; year += t * 100; v -= t * PERIOD_100; - t = v / PERIOD_4; if (t == 25) t = 24; year += t * 4; v -= t * PERIOD_4; - t = v / 365; if (t == 4) t = 3; year += t; v -= t * 365; - - if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) - ms[1] = 29; - for (mon = 0;; mon++) - { - unsigned d = ms[mon]; - if (v < d) - break; - v -= d; - } - s = UIntToStr(s, year, 4); *s++ = '-'; - UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3; - UIntToStr_2(s, (unsigned)v + 1); s[2] = ' '; s += 3; - UIntToStr_2(s, hour); s[2] = ':'; s += 3; - UIntToStr_2(s, min); s[2] = ':'; s += 3; - UIntToStr_2(s, sec); s[2] = 0; -} - -static void PrintLF() -{ - Print("\n"); -} - -static void PrintError(char *s) -{ - Print("\nERROR: "); - Print(s); - PrintLF(); -} - -static void PrintError_WRes(const char *message, WRes wres) -{ - Print("\nERROR: "); - Print(message); - PrintLF(); - { - char s[32]; - UIntToStr(s, (unsigned)wres, 1); - Print("System error code: "); - Print(s); - } - // sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres); - #ifdef _WIN32 - { - char *s = NULL; - if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, wres, 0, (LPSTR) &s, 0, NULL) != 0 && s) - { - Print(" : "); - Print(s); - LocalFree(s); - } - } - #else - { - const char *s = strerror(wres); - if (s) - { - Print(" : "); - Print(s); - } - } - #endif - PrintLF(); -} - -static void GetAttribString(UInt32 wa, BoolInt isDir, char *s) -{ - #ifdef USE_WINDOWS_FILE - s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : '.'); - s[1] = (char)(((wa & FILE_ATTRIBUTE_READONLY ) != 0) ? 'R': '.'); - s[2] = (char)(((wa & FILE_ATTRIBUTE_HIDDEN ) != 0) ? 'H': '.'); - s[3] = (char)(((wa & FILE_ATTRIBUTE_SYSTEM ) != 0) ? 'S': '.'); - s[4] = (char)(((wa & FILE_ATTRIBUTE_ARCHIVE ) != 0) ? 'A': '.'); - s[5] = 0; - #else - s[0] = (char)(((wa & (1 << 4)) != 0 || isDir) ? 'D' : '.'); - s[1] = 0; - #endif -} - - -// #define NUM_PARENTS_MAX 128 - -int MY_CDECL main(int numargs, char *args[]) -{ - ISzAlloc allocImp; - ISzAlloc allocTempImp; - - CFileInStream archiveStream; - CLookToRead2 lookStream; - CSzArEx db; - SRes res; - UInt16 *temp = NULL; - size_t tempSize = 0; - // UInt32 parents[NUM_PARENTS_MAX]; - - Print("\n7z Decoder " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n"); - - if (numargs == 1) - { - Print( - "Usage: 7zDec \n\n" - "\n" - " e: Extract files from archive (without using directory names)\n" - " l: List contents of archive\n" - " t: Test integrity of archive\n" - " x: eXtract files with full paths\n"); - return 0; - } - - if (numargs < 3) - { - PrintError("incorrect command"); - return 1; - } - - #if defined(_WIN32) && !defined(USE_WINDOWS_FILE) && !defined(UNDER_CE) - g_FileCodePage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - #endif - - - allocImp = g_Alloc; - allocTempImp = g_Alloc; - - { - WRes wres = - #ifdef UNDER_CE - InFile_OpenW(&archiveStream.file, L"\test.7z"); // change it - #else - InFile_Open(&archiveStream.file, args[2]); - #endif - if (wres != 0) - { - PrintError_WRes("cannot open input file", wres); - return 1; - } - } - - FileInStream_CreateVTable(&archiveStream); - archiveStream.wres = 0; - LookToRead2_CreateVTable(&lookStream, False); - lookStream.buf = NULL; - - res = SZ_OK; - - { - lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize); - if (!lookStream.buf) - res = SZ_ERROR_MEM; - else - { - lookStream.bufSize = kInputBufSize; - lookStream.realStream = &archiveStream.vt; - LookToRead2_Init(&lookStream); - } - } - - CrcGenerateTable(); - - SzArEx_Init(&db); - - if (res == SZ_OK) - { - res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp); - } - - if (res == SZ_OK) - { - char *command = args[1]; - int listCommand = 0, testCommand = 0, fullPaths = 0; - - if (strcmp(command, "l") == 0) listCommand = 1; - else if (strcmp(command, "t") == 0) testCommand = 1; - else if (strcmp(command, "e") == 0) { } - else if (strcmp(command, "x") == 0) { fullPaths = 1; } - else - { - PrintError("incorrect command"); - res = SZ_ERROR_FAIL; - } - - if (res == SZ_OK) - { - UInt32 i; - - /* - if you need cache, use these 3 variables. - if you use external function, you can make these variable as static. - */ - UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ - Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */ - size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */ - - for (i = 0; i < db.NumFiles; i++) - { - size_t offset = 0; - size_t outSizeProcessed = 0; - // const CSzFileItem *f = db.Files + i; - size_t len; - const BoolInt isDir = SzArEx_IsDir(&db, i); - if (listCommand == 0 && isDir && !fullPaths) - continue; - len = SzArEx_GetFileNameUtf16(&db, i, NULL); - // len = SzArEx_GetFullNameLen(&db, i); - - if (len > tempSize) - { - SzFree(NULL, temp); - tempSize = len; - temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0])); - if (!temp) - { - res = SZ_ERROR_MEM; - break; - } - } - - SzArEx_GetFileNameUtf16(&db, i, temp); - /* - if (SzArEx_GetFullNameUtf16_Back(&db, i, temp + len) != temp) - { - res = SZ_ERROR_FAIL; - break; - } - */ - - if (listCommand) - { - char attr[8], s[32], t[32]; - UInt64 fileSize; - - GetAttribString(SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0, isDir, attr); - - fileSize = SzArEx_GetFileSize(&db, i); - UInt64ToStr(fileSize, s, 10); - - if (SzBitWithVals_Check(&db.MTime, i)) - ConvertFileTimeToString(&db.MTime.Vals[i], t); - else - { - size_t j; - for (j = 0; j < 19; j++) - t[j] = ' '; - t[j] = '\0'; - } - - Print(t); - Print(" "); - Print(attr); - Print(" "); - Print(s); - Print(" "); - res = PrintString(temp); - if (res != SZ_OK) - break; - if (isDir) - Print("/"); - PrintLF(); - continue; - } - - Print(testCommand ? - "T ": - "- "); - res = PrintString(temp); - if (res != SZ_OK) - break; - - if (isDir) - Print("/"); - else - { - res = SzArEx_Extract(&db, &lookStream.vt, i, - &blockIndex, &outBuffer, &outBufferSize, - &offset, &outSizeProcessed, - &allocImp, &allocTempImp); - if (res != SZ_OK) - break; - } - - if (!testCommand) - { - CSzFile outFile; - size_t processedSize; - size_t j; - UInt16 *name = (UInt16 *)temp; - const UInt16 *destPath = (const UInt16 *)name; - - for (j = 0; name[j] != 0; j++) - if (name[j] == '/') - { - if (fullPaths) - { - name[j] = 0; - MyCreateDir(name); - name[j] = CHAR_PATH_SEPARATOR; - } - else - destPath = name + j + 1; - } - - if (isDir) - { - MyCreateDir(destPath); - PrintLF(); - continue; - } - else - { - WRes wres = OutFile_OpenUtf16(&outFile, destPath); - if (wres != 0) - { - PrintError_WRes("cannot open output file", wres); - res = SZ_ERROR_FAIL; - break; - } - } - - processedSize = outSizeProcessed; - - { - WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize); - if (wres != 0 || processedSize != outSizeProcessed) - { - PrintError_WRes("cannot write output file", wres); - res = SZ_ERROR_FAIL; - break; - } - } - - { - FILETIME mtime; - FILETIME *mtimePtr = NULL; - - #ifdef USE_WINDOWS_FILE - FILETIME ctime; - FILETIME *ctimePtr = NULL; - #endif - - if (SzBitWithVals_Check(&db.MTime, i)) - { - const CNtfsFileTime *t = &db.MTime.Vals[i]; - mtime.dwLowDateTime = (DWORD)(t->Low); - mtime.dwHighDateTime = (DWORD)(t->High); - mtimePtr = &mtime; - } - - #ifdef USE_WINDOWS_FILE - if (SzBitWithVals_Check(&db.CTime, i)) - { - const CNtfsFileTime *t = &db.CTime.Vals[i]; - ctime.dwLowDateTime = (DWORD)(t->Low); - ctime.dwHighDateTime = (DWORD)(t->High); - ctimePtr = &ctime; - } - - if (mtimePtr || ctimePtr) - SetFileTime(outFile.handle, ctimePtr, NULL, mtimePtr); - #endif - - { - WRes wres = File_Close(&outFile); - if (wres != 0) - { - PrintError_WRes("cannot close output file", wres); - res = SZ_ERROR_FAIL; - break; - } - } - - #ifndef USE_WINDOWS_FILE - #ifdef _WIN32 - mtimePtr = mtimePtr; - #else - if (mtimePtr) - Set_File_FILETIME(destPath, mtimePtr); - #endif - #endif - } - - #ifdef USE_WINDOWS_FILE - if (SzBitWithVals_Check(&db.Attribs, i)) - { - UInt32 attrib = db.Attribs.Vals[i]; - /* p7zip stores posix attributes in high 16 bits and adds 0x8000 as marker. - We remove posix bits, if we detect posix mode field */ - if ((attrib & 0xF0000000) != 0) - attrib &= 0x7FFF; - SetFileAttributesW((LPCWSTR)destPath, attrib); - } - #endif - } - PrintLF(); - } - ISzAlloc_Free(&allocImp, outBuffer); - } - } - - SzFree(NULL, temp); - SzArEx_Free(&db, &allocImp); - ISzAlloc_Free(&allocImp, lookStream.buf); - - File_Close(&archiveStream.file); - - if (res == SZ_OK) - { - Print("\nEverything is Ok\n"); - return 0; - } - - if (res == SZ_ERROR_UNSUPPORTED) - PrintError("decoder doesn't support this archive"); - else if (res == SZ_ERROR_MEM) - PrintError("cannot allocate memory"); - else if (res == SZ_ERROR_CRC) - PrintError("CRC error"); - else if (res == SZ_ERROR_READ /* || archiveStream.Res != 0 */) - PrintError_WRes("Read Error", archiveStream.wres); - else - { - char s[32]; - UInt64ToStr((unsigned)res, s, 0); - PrintError(s); - } - - return 1; -} +/* 7zMain.c - Test application for 7z Decoder +2021-04-29 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include +#include + +#include "../../CpuArch.h" + +#include "../../7z.h" +#include "../../7zAlloc.h" +#include "../../7zBuf.h" +#include "../../7zCrc.h" +#include "../../7zFile.h" +#include "../../7zVersion.h" + +#ifndef USE_WINDOWS_FILE +/* for mkdir */ +#ifdef _WIN32 +#include +#else +#include +#include +#ifdef __GNUC__ +#include +#endif +#include +// #include +#include +#include +#endif +#endif + + +#define kInputBufSize ((size_t)1 << 18) + +static const ISzAlloc g_Alloc = { SzAlloc, SzFree }; + + +static void Print(const char *s) +{ + fputs(s, stdout); +} + + +static int Buf_EnsureSize(CBuf *dest, size_t size) +{ + if (dest->size >= size) + return 1; + Buf_Free(dest, &g_Alloc); + return Buf_Create(dest, size, &g_Alloc); +} + +#ifndef _WIN32 +#define _USE_UTF8 +#endif + +/* #define _USE_UTF8 */ + +#ifdef _USE_UTF8 + +#define _UTF8_START(n) (0x100 - (1 << (7 - (n)))) + +#define _UTF8_RANGE(n) (((UInt32)1) << ((n) * 5 + 6)) + +#define _UTF8_HEAD(n, val) ((Byte)(_UTF8_START(n) + (val >> (6 * (n))))) +#define _UTF8_CHAR(n, val) ((Byte)(0x80 + (((val) >> (6 * (n))) & 0x3F))) + +static size_t Utf16_To_Utf8_Calc(const UInt16 *src, const UInt16 *srcLim) +{ + size_t size = 0; + for (;;) + { + UInt32 val; + if (src == srcLim) + return size; + + size++; + val = *src++; + + if (val < 0x80) + continue; + + if (val < _UTF8_RANGE(1)) + { + size++; + continue; + } + + if (val >= 0xD800 && val < 0xDC00 && src != srcLim) + { + UInt32 c2 = *src; + if (c2 >= 0xDC00 && c2 < 0xE000) + { + src++; + size += 3; + continue; + } + } + + size += 2; + } +} + +static Byte *Utf16_To_Utf8(Byte *dest, const UInt16 *src, const UInt16 *srcLim) +{ + for (;;) + { + UInt32 val; + if (src == srcLim) + return dest; + + val = *src++; + + if (val < 0x80) + { + *dest++ = (Byte)val; + continue; + } + + if (val < _UTF8_RANGE(1)) + { + dest[0] = _UTF8_HEAD(1, val); + dest[1] = _UTF8_CHAR(0, val); + dest += 2; + continue; + } + + if (val >= 0xD800 && val < 0xDC00 && src != srcLim) + { + UInt32 c2 = *src; + if (c2 >= 0xDC00 && c2 < 0xE000) + { + src++; + val = (((val - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000; + dest[0] = _UTF8_HEAD(3, val); + dest[1] = _UTF8_CHAR(2, val); + dest[2] = _UTF8_CHAR(1, val); + dest[3] = _UTF8_CHAR(0, val); + dest += 4; + continue; + } + } + + dest[0] = _UTF8_HEAD(2, val); + dest[1] = _UTF8_CHAR(1, val); + dest[2] = _UTF8_CHAR(0, val); + dest += 3; + } +} + +static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen) +{ + size_t destLen = Utf16_To_Utf8_Calc(src, src + srcLen); + destLen += 1; + if (!Buf_EnsureSize(dest, destLen)) + return SZ_ERROR_MEM; + *Utf16_To_Utf8(dest->data, src, src + srcLen) = 0; + return SZ_OK; +} + +#endif + +static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s + #ifndef _USE_UTF8 + , UINT codePage + #endif + ) +{ + unsigned len = 0; + for (len = 0; s[len] != 0; len++) {} + + #ifndef _USE_UTF8 + { + const unsigned size = len * 3 + 100; + if (!Buf_EnsureSize(buf, size)) + return SZ_ERROR_MEM; + { + buf->data[0] = 0; + if (len != 0) + { + const char defaultChar = '_'; + BOOL defUsed; + const unsigned numChars = (unsigned)WideCharToMultiByte( + codePage, 0, (LPCWSTR)s, (int)len, (char *)buf->data, (int)size, &defaultChar, &defUsed); + if (numChars == 0 || numChars >= size) + return SZ_ERROR_FAIL; + buf->data[numChars] = 0; + } + return SZ_OK; + } + } + #else + return Utf16_To_Utf8Buf(buf, s, len); + #endif +} + +#ifdef _WIN32 + #ifndef USE_WINDOWS_FILE + static UINT g_FileCodePage = CP_ACP; + #define MY_FILE_CODE_PAGE_PARAM ,g_FileCodePage + #endif +#else + #define MY_FILE_CODE_PAGE_PARAM +#endif + +static WRes MyCreateDir(const UInt16 *name) +{ + #ifdef USE_WINDOWS_FILE + + return CreateDirectoryW((LPCWSTR)name, NULL) ? 0 : GetLastError(); + + #else + + CBuf buf; + WRes res; + Buf_Init(&buf); + RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); + + res = + #ifdef _WIN32 + _mkdir((const char *)buf.data) + #else + mkdir((const char *)buf.data, 0777) + #endif + == 0 ? 0 : errno; + Buf_Free(&buf, &g_Alloc); + return res; + + #endif +} + +static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name) +{ + #ifdef USE_WINDOWS_FILE + return OutFile_OpenW(p, (LPCWSTR)name); + #else + CBuf buf; + WRes res; + Buf_Init(&buf); + RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); + res = OutFile_Open(p, (const char *)buf.data); + Buf_Free(&buf, &g_Alloc); + return res; + #endif +} + + +static SRes PrintString(const UInt16 *s) +{ + CBuf buf; + SRes res; + Buf_Init(&buf); + res = Utf16_To_Char(&buf, s + #ifndef _USE_UTF8 + , CP_OEMCP + #endif + ); + if (res == SZ_OK) + Print((const char *)buf.data); + Buf_Free(&buf, &g_Alloc); + return res; +} + +static void UInt64ToStr(UInt64 value, char *s, int numDigits) +{ + char temp[32]; + int pos = 0; + do + { + temp[pos++] = (char)('0' + (unsigned)(value % 10)); + value /= 10; + } + while (value != 0); + + for (numDigits -= pos; numDigits > 0; numDigits--) + *s++ = ' '; + + do + *s++ = temp[--pos]; + while (pos); + *s = '\0'; +} + +static char *UIntToStr(char *s, unsigned value, int numDigits) +{ + char temp[16]; + int pos = 0; + do + temp[pos++] = (char)('0' + (value % 10)); + while (value /= 10); + + for (numDigits -= pos; numDigits > 0; numDigits--) + *s++ = '0'; + + do + *s++ = temp[--pos]; + while (pos); + *s = '\0'; + return s; +} + +static void UIntToStr_2(char *s, unsigned value) +{ + s[0] = (char)('0' + (value / 10)); + s[1] = (char)('0' + (value % 10)); +} + + +#define PERIOD_4 (4 * 365 + 1) +#define PERIOD_100 (PERIOD_4 * 25 - 1) +#define PERIOD_400 (PERIOD_100 * 4 + 1) + + + +#ifndef _WIN32 + +// MS uses long for BOOL, but long is 32-bit in MS. So we use int. +// typedef long BOOL; +typedef int BOOL; + +typedef struct _FILETIME +{ + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME; + +static LONG TIME_GetBias() +{ + time_t utc = time(NULL); + struct tm *ptm = localtime(&utc); + int localdaylight = ptm->tm_isdst; /* daylight for local timezone */ + ptm = gmtime(&utc); + ptm->tm_isdst = localdaylight; /* use local daylight, not that of Greenwich */ + LONG bias = (int)(mktime(ptm)-utc); + return bias; +} + +#define TICKS_PER_SEC 10000000 + +#define GET_TIME_64(pft) ((pft)->dwLowDateTime | ((UInt64)(pft)->dwHighDateTime << 32)) + +#define SET_FILETIME(ft, v64) \ + (ft)->dwLowDateTime = (DWORD)v64; \ + (ft)->dwHighDateTime = (DWORD)(v64 >> 32); + +#define WINAPI +#define TRUE 1 + +static BOOL WINAPI FileTimeToLocalFileTime(const FILETIME *fileTime, FILETIME *localFileTime) +{ + UInt64 v = GET_TIME_64(fileTime); + v = (UInt64)((Int64)v - (Int64)TIME_GetBias() * TICKS_PER_SEC); + SET_FILETIME(localFileTime, v); + return TRUE; +} + +static const UInt32 kNumTimeQuantumsInSecond = 10000000; +static const UInt32 kFileTimeStartYear = 1601; +static const UInt32 kUnixTimeStartYear = 1970; +static const UInt64 kUnixTimeOffset = + (UInt64)60 * 60 * 24 * (89 + 365 * (kUnixTimeStartYear - kFileTimeStartYear)); + +static Int64 Time_FileTimeToUnixTime64(const FILETIME *ft) +{ + UInt64 winTime = GET_TIME_64(ft); + return (Int64)(winTime / kNumTimeQuantumsInSecond) - (Int64)kUnixTimeOffset; +} + +#if defined(_AIX) + #define MY_ST_TIMESPEC st_timespec +#else + #define MY_ST_TIMESPEC timespec +#endif + +static void FILETIME_To_timespec(const FILETIME *ft, struct MY_ST_TIMESPEC *ts) +{ + if (ft) + { + const Int64 sec = Time_FileTimeToUnixTime64(ft); + // time_t is long + const time_t sec2 = (time_t)sec; + if (sec2 == sec) + { + ts->tv_sec = sec2; + UInt64 winTime = GET_TIME_64(ft); + ts->tv_nsec = (long)((winTime % 10000000) * 100);; + return; + } + } + // else + { + ts->tv_sec = 0; + // ts.tv_nsec = UTIME_NOW; // set to the current time + ts->tv_nsec = UTIME_OMIT; // keep old timesptamp + } +} + +static WRes Set_File_FILETIME(const UInt16 *name, const FILETIME *mTime) +{ + struct timespec times[2]; + + const int flags = 0; // follow link + // = AT_SYMLINK_NOFOLLOW; // don't follow link + + CBuf buf; + int res; + Buf_Init(&buf); + RINOK(Utf16_To_Char(&buf, name MY_FILE_CODE_PAGE_PARAM)); + FILETIME_To_timespec(NULL, ×[0]); + FILETIME_To_timespec(mTime, ×[1]); + res = utimensat(AT_FDCWD, (const char *)buf.data, times, flags); + Buf_Free(&buf, &g_Alloc); + if (res == 0) + return 0; + return errno; +} + +#endif + +static void NtfsFileTime_to_FILETIME(const CNtfsFileTime *t, FILETIME *ft) +{ + ft->dwLowDateTime = (DWORD)(t->Low); + ft->dwHighDateTime = (DWORD)(t->High); +} + +static void ConvertFileTimeToString(const CNtfsFileTime *nTime, char *s) +{ + unsigned year, mon, hour, min, sec; + Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + unsigned t; + UInt32 v; + // UInt64 v64 = nt->Low | ((UInt64)nt->High << 32); + UInt64 v64; + { + FILETIME fileTime, locTime; + NtfsFileTime_to_FILETIME(nTime, &fileTime); + if (!FileTimeToLocalFileTime(&fileTime, &locTime)) + { + locTime.dwHighDateTime = + locTime.dwLowDateTime = 0; + } + v64 = locTime.dwLowDateTime | ((UInt64)locTime.dwHighDateTime << 32); + } + v64 /= 10000000; + sec = (unsigned)(v64 % 60); v64 /= 60; + min = (unsigned)(v64 % 60); v64 /= 60; + hour = (unsigned)(v64 % 24); v64 /= 24; + + v = (UInt32)v64; + + year = (unsigned)(1601 + v / PERIOD_400 * 400); + v %= PERIOD_400; + + t = v / PERIOD_100; if (t == 4) t = 3; year += t * 100; v -= t * PERIOD_100; + t = v / PERIOD_4; if (t == 25) t = 24; year += t * 4; v -= t * PERIOD_4; + t = v / 365; if (t == 4) t = 3; year += t; v -= t * 365; + + if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) + ms[1] = 29; + for (mon = 0;; mon++) + { + unsigned d = ms[mon]; + if (v < d) + break; + v -= d; + } + s = UIntToStr(s, year, 4); *s++ = '-'; + UIntToStr_2(s, mon + 1); s[2] = '-'; s += 3; + UIntToStr_2(s, (unsigned)v + 1); s[2] = ' '; s += 3; + UIntToStr_2(s, hour); s[2] = ':'; s += 3; + UIntToStr_2(s, min); s[2] = ':'; s += 3; + UIntToStr_2(s, sec); s[2] = 0; +} + +static void PrintLF() +{ + Print("\n"); +} + +static void PrintError(char *s) +{ + Print("\nERROR: "); + Print(s); + PrintLF(); +} + +static void PrintError_WRes(const char *message, WRes wres) +{ + Print("\nERROR: "); + Print(message); + PrintLF(); + { + char s[32]; + UIntToStr(s, (unsigned)wres, 1); + Print("System error code: "); + Print(s); + } + // sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres); + #ifdef _WIN32 + { + char *s = NULL; + if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, wres, 0, (LPSTR) &s, 0, NULL) != 0 && s) + { + Print(" : "); + Print(s); + LocalFree(s); + } + } + #else + { + const char *s = strerror(wres); + if (s) + { + Print(" : "); + Print(s); + } + } + #endif + PrintLF(); +} + +static void GetAttribString(UInt32 wa, BoolInt isDir, char *s) +{ + #ifdef USE_WINDOWS_FILE + s[0] = (char)(((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : '.'); + s[1] = (char)(((wa & FILE_ATTRIBUTE_READONLY ) != 0) ? 'R': '.'); + s[2] = (char)(((wa & FILE_ATTRIBUTE_HIDDEN ) != 0) ? 'H': '.'); + s[3] = (char)(((wa & FILE_ATTRIBUTE_SYSTEM ) != 0) ? 'S': '.'); + s[4] = (char)(((wa & FILE_ATTRIBUTE_ARCHIVE ) != 0) ? 'A': '.'); + s[5] = 0; + #else + s[0] = (char)(((wa & (1 << 4)) != 0 || isDir) ? 'D' : '.'); + s[1] = 0; + #endif +} + + +// #define NUM_PARENTS_MAX 128 + +int MY_CDECL main(int numargs, char *args[]) +{ + ISzAlloc allocImp; + ISzAlloc allocTempImp; + + CFileInStream archiveStream; + CLookToRead2 lookStream; + CSzArEx db; + SRes res; + UInt16 *temp = NULL; + size_t tempSize = 0; + // UInt32 parents[NUM_PARENTS_MAX]; + + Print("\n7z Decoder " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n"); + + if (numargs == 1) + { + Print( + "Usage: 7zDec \n\n" + "\n" + " e: Extract files from archive (without using directory names)\n" + " l: List contents of archive\n" + " t: Test integrity of archive\n" + " x: eXtract files with full paths\n"); + return 0; + } + + if (numargs < 3) + { + PrintError("incorrect command"); + return 1; + } + + #if defined(_WIN32) && !defined(USE_WINDOWS_FILE) && !defined(UNDER_CE) + g_FileCodePage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; + #endif + + + allocImp = g_Alloc; + allocTempImp = g_Alloc; + + { + WRes wres = + #ifdef UNDER_CE + InFile_OpenW(&archiveStream.file, L"\test.7z"); // change it + #else + InFile_Open(&archiveStream.file, args[2]); + #endif + if (wres != 0) + { + PrintError_WRes("cannot open input file", wres); + return 1; + } + } + + FileInStream_CreateVTable(&archiveStream); + archiveStream.wres = 0; + LookToRead2_CreateVTable(&lookStream, False); + lookStream.buf = NULL; + + res = SZ_OK; + + { + lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize); + if (!lookStream.buf) + res = SZ_ERROR_MEM; + else + { + lookStream.bufSize = kInputBufSize; + lookStream.realStream = &archiveStream.vt; + LookToRead2_Init(&lookStream); + } + } + + CrcGenerateTable(); + + SzArEx_Init(&db); + + if (res == SZ_OK) + { + res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp); + } + + if (res == SZ_OK) + { + char *command = args[1]; + int listCommand = 0, testCommand = 0, fullPaths = 0; + + if (strcmp(command, "l") == 0) listCommand = 1; + else if (strcmp(command, "t") == 0) testCommand = 1; + else if (strcmp(command, "e") == 0) { } + else if (strcmp(command, "x") == 0) { fullPaths = 1; } + else + { + PrintError("incorrect command"); + res = SZ_ERROR_FAIL; + } + + if (res == SZ_OK) + { + UInt32 i; + + /* + if you need cache, use these 3 variables. + if you use external function, you can make these variable as static. + */ + UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ + Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */ + size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */ + + for (i = 0; i < db.NumFiles; i++) + { + size_t offset = 0; + size_t outSizeProcessed = 0; + // const CSzFileItem *f = db.Files + i; + size_t len; + const BoolInt isDir = SzArEx_IsDir(&db, i); + if (listCommand == 0 && isDir && !fullPaths) + continue; + len = SzArEx_GetFileNameUtf16(&db, i, NULL); + // len = SzArEx_GetFullNameLen(&db, i); + + if (len > tempSize) + { + SzFree(NULL, temp); + tempSize = len; + temp = (UInt16 *)SzAlloc(NULL, tempSize * sizeof(temp[0])); + if (!temp) + { + res = SZ_ERROR_MEM; + break; + } + } + + SzArEx_GetFileNameUtf16(&db, i, temp); + /* + if (SzArEx_GetFullNameUtf16_Back(&db, i, temp + len) != temp) + { + res = SZ_ERROR_FAIL; + break; + } + */ + + if (listCommand) + { + char attr[8], s[32], t[32]; + UInt64 fileSize; + + GetAttribString(SzBitWithVals_Check(&db.Attribs, i) ? db.Attribs.Vals[i] : 0, isDir, attr); + + fileSize = SzArEx_GetFileSize(&db, i); + UInt64ToStr(fileSize, s, 10); + + if (SzBitWithVals_Check(&db.MTime, i)) + ConvertFileTimeToString(&db.MTime.Vals[i], t); + else + { + size_t j; + for (j = 0; j < 19; j++) + t[j] = ' '; + t[j] = '\0'; + } + + Print(t); + Print(" "); + Print(attr); + Print(" "); + Print(s); + Print(" "); + res = PrintString(temp); + if (res != SZ_OK) + break; + if (isDir) + Print("/"); + PrintLF(); + continue; + } + + Print(testCommand ? + "T ": + "- "); + res = PrintString(temp); + if (res != SZ_OK) + break; + + if (isDir) + Print("/"); + else + { + res = SzArEx_Extract(&db, &lookStream.vt, i, + &blockIndex, &outBuffer, &outBufferSize, + &offset, &outSizeProcessed, + &allocImp, &allocTempImp); + if (res != SZ_OK) + break; + } + + if (!testCommand) + { + CSzFile outFile; + size_t processedSize; + size_t j; + UInt16 *name = (UInt16 *)temp; + const UInt16 *destPath = (const UInt16 *)name; + + for (j = 0; name[j] != 0; j++) + if (name[j] == '/') + { + if (fullPaths) + { + name[j] = 0; + MyCreateDir(name); + name[j] = CHAR_PATH_SEPARATOR; + } + else + destPath = name + j + 1; + } + + if (isDir) + { + MyCreateDir(destPath); + PrintLF(); + continue; + } + else + { + WRes wres = OutFile_OpenUtf16(&outFile, destPath); + if (wres != 0) + { + PrintError_WRes("cannot open output file", wres); + res = SZ_ERROR_FAIL; + break; + } + } + + processedSize = outSizeProcessed; + + { + WRes wres = File_Write(&outFile, outBuffer + offset, &processedSize); + if (wres != 0 || processedSize != outSizeProcessed) + { + PrintError_WRes("cannot write output file", wres); + res = SZ_ERROR_FAIL; + break; + } + } + + { + FILETIME mtime; + FILETIME *mtimePtr = NULL; + + #ifdef USE_WINDOWS_FILE + FILETIME ctime; + FILETIME *ctimePtr = NULL; + #endif + + if (SzBitWithVals_Check(&db.MTime, i)) + { + const CNtfsFileTime *t = &db.MTime.Vals[i]; + mtime.dwLowDateTime = (DWORD)(t->Low); + mtime.dwHighDateTime = (DWORD)(t->High); + mtimePtr = &mtime; + } + + #ifdef USE_WINDOWS_FILE + if (SzBitWithVals_Check(&db.CTime, i)) + { + const CNtfsFileTime *t = &db.CTime.Vals[i]; + ctime.dwLowDateTime = (DWORD)(t->Low); + ctime.dwHighDateTime = (DWORD)(t->High); + ctimePtr = &ctime; + } + + if (mtimePtr || ctimePtr) + SetFileTime(outFile.handle, ctimePtr, NULL, mtimePtr); + #endif + + { + WRes wres = File_Close(&outFile); + if (wres != 0) + { + PrintError_WRes("cannot close output file", wres); + res = SZ_ERROR_FAIL; + break; + } + } + + #ifndef USE_WINDOWS_FILE + #ifdef _WIN32 + mtimePtr = mtimePtr; + #else + if (mtimePtr) + Set_File_FILETIME(destPath, mtimePtr); + #endif + #endif + } + + #ifdef USE_WINDOWS_FILE + if (SzBitWithVals_Check(&db.Attribs, i)) + { + UInt32 attrib = db.Attribs.Vals[i]; + /* p7zip stores posix attributes in high 16 bits and adds 0x8000 as marker. + We remove posix bits, if we detect posix mode field */ + if ((attrib & 0xF0000000) != 0) + attrib &= 0x7FFF; + SetFileAttributesW((LPCWSTR)destPath, attrib); + } + #endif + } + PrintLF(); + } + ISzAlloc_Free(&allocImp, outBuffer); + } + } + + SzFree(NULL, temp); + SzArEx_Free(&db, &allocImp); + ISzAlloc_Free(&allocImp, lookStream.buf); + + File_Close(&archiveStream.file); + + if (res == SZ_OK) + { + Print("\nEverything is Ok\n"); + return 0; + } + + if (res == SZ_ERROR_UNSUPPORTED) + PrintError("decoder doesn't support this archive"); + else if (res == SZ_ERROR_MEM) + PrintError("cannot allocate memory"); + else if (res == SZ_ERROR_CRC) + PrintError("CRC error"); + else if (res == SZ_ERROR_READ /* || archiveStream.Res != 0 */) + PrintError_WRes("Read Error", archiveStream.wres); + else + { + char s[32]; + UInt64ToStr((unsigned)res, s, 0); + PrintError(s); + } + + return 1; +} diff --git a/deps/LZMA-SDK/C/Util/7z/Precomp.c b/deps/LZMA-SDK/C/Util/7z/Precomp.c index 34b60f8fc..01605e3c2 100644 --- a/deps/LZMA-SDK/C/Util/7z/Precomp.c +++ b/deps/LZMA-SDK/C/Util/7z/Precomp.c @@ -1,4 +1,4 @@ -/* Precomp.c -- StdAfx -2013-01-21 : Igor Pavlov : Public domain */ - -#include "Precomp.h" +/* Precomp.c -- StdAfx +2013-01-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" diff --git a/deps/LZMA-SDK/C/Util/7z/Precomp.h b/deps/LZMA-SDK/C/Util/7z/Precomp.h index 9f398d08f..588a66f7e 100644 --- a/deps/LZMA-SDK/C/Util/7z/Precomp.h +++ b/deps/LZMA-SDK/C/Util/7z/Precomp.h @@ -1,10 +1,10 @@ -/* Precomp.h -- StdAfx -2013-06-16 : Igor Pavlov : Public domain */ - -#ifndef __7Z_PRECOMP_H -#define __7Z_PRECOMP_H - -#include "../../Compiler.h" -#include "../../7zTypes.h" - -#endif +/* Precomp.h -- StdAfx +2013-06-16 : Igor Pavlov : Public domain */ + +#ifndef __7Z_PRECOMP_H +#define __7Z_PRECOMP_H + +#include "../../Compiler.h" +#include "../../7zTypes.h" + +#endif diff --git a/deps/LZMA-SDK/C/Util/7z/makefile b/deps/LZMA-SDK/C/Util/7z/makefile index f4a54af73..9a49fd515 100644 --- a/deps/LZMA-SDK/C/Util/7z/makefile +++ b/deps/LZMA-SDK/C/Util/7z/makefile @@ -1,40 +1,40 @@ -CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT - -PROG = 7zDec.exe - -C_OBJS = \ - $O\7zAlloc.obj \ - $O\7zBuf.obj \ - $O\7zCrc.obj \ - $O\7zCrcOpt.obj \ - $O\7zFile.obj \ - $O\7zDec.obj \ - $O\7zArcIn.obj \ - $O\7zStream.obj \ - $O\Bcj2.obj \ - $O\Bra.obj \ - $O\Bra86.obj \ - $O\BraIA64.obj \ - $O\CpuArch.obj \ - $O\Delta.obj \ - $O\Lzma2Dec.obj \ - $O\LzmaDec.obj \ - $O\Ppmd7.obj \ - $O\Ppmd7Dec.obj \ - -7Z_OBJS = \ - $O\7zMain.obj \ - -OBJS = \ - $O\Precomp.obj \ - $(7Z_OBJS) \ - $(C_OBJS) \ - -!include "../../../CPP/Build.mak" - -$(7Z_OBJS): $(*B).c - $(CCOMPL_USE) -$(C_OBJS): ../../$(*B).c - $(CCOMPL_USE) -$O\Precomp.obj: Precomp.c - $(CCOMPL_PCH) +CFLAGS = $(CFLAGS) -D_7ZIP_PPMD_SUPPPORT + +PROG = 7zDec.exe + +C_OBJS = \ + $O\7zAlloc.obj \ + $O\7zBuf.obj \ + $O\7zCrc.obj \ + $O\7zCrcOpt.obj \ + $O\7zFile.obj \ + $O\7zDec.obj \ + $O\7zArcIn.obj \ + $O\7zStream.obj \ + $O\Bcj2.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\CpuArch.obj \ + $O\Delta.obj \ + $O\Lzma2Dec.obj \ + $O\LzmaDec.obj \ + $O\Ppmd7.obj \ + $O\Ppmd7Dec.obj \ + +7Z_OBJS = \ + $O\7zMain.obj \ + +OBJS = \ + $O\Precomp.obj \ + $(7Z_OBJS) \ + $(C_OBJS) \ + +!include "../../../CPP/Build.mak" + +$(7Z_OBJS): $(*B).c + $(CCOMPL_USE) +$(C_OBJS): ../../$(*B).c + $(CCOMPL_USE) +$O\Precomp.obj: Precomp.c + $(CCOMPL_PCH) diff --git a/deps/LZMA-SDK/C/Util/7z/makefile.gcc b/deps/LZMA-SDK/C/Util/7z/makefile.gcc index d6ef9b2a7..4263d6755 100644 --- a/deps/LZMA-SDK/C/Util/7z/makefile.gcc +++ b/deps/LZMA-SDK/C/Util/7z/makefile.gcc @@ -1,34 +1,34 @@ -PROG = 7zdec - -LOCAL_FLAGS = -D_7ZIP_PPMD_SUPPPORT - -include ../../../CPP/7zip/LzmaDec_gcc.mak - - -OBJS = \ - $(LZMA_DEC_OPT_OBJS) \ - $O/Bcj2.o \ - $O/Bra.o \ - $O/Bra86.o \ - $O/BraIA64.o \ - $O/CpuArch.o \ - $O/Delta.o \ - $O/Lzma2Dec.o \ - $O/LzmaDec.o \ - $O/Ppmd7.o \ - $O/Ppmd7Dec.o \ - $O/7zCrc.o \ - $O/7zCrcOpt.o \ - $O/Sha256.o \ - $O/Sha256Opt.o \ - $O/7zAlloc.o \ - $O/7zArcIn.o \ - $O/7zBuf.o \ - $O/7zBuf2.o \ - $O/7zDec.o \ - $O/7zMain.o \ - $O/7zFile.o \ - $O/7zStream.o \ - - -include ../../7zip_gcc_c.mak +PROG = 7zdec + +LOCAL_FLAGS = -D_7ZIP_PPMD_SUPPPORT + +include ../../../CPP/7zip/LzmaDec_gcc.mak + + +OBJS = \ + $(LZMA_DEC_OPT_OBJS) \ + $O/Bcj2.o \ + $O/Bra.o \ + $O/Bra86.o \ + $O/BraIA64.o \ + $O/CpuArch.o \ + $O/Delta.o \ + $O/Lzma2Dec.o \ + $O/LzmaDec.o \ + $O/Ppmd7.o \ + $O/Ppmd7Dec.o \ + $O/7zCrc.o \ + $O/7zCrcOpt.o \ + $O/Sha256.o \ + $O/Sha256Opt.o \ + $O/7zAlloc.o \ + $O/7zArcIn.o \ + $O/7zBuf.o \ + $O/7zBuf2.o \ + $O/7zDec.o \ + $O/7zMain.o \ + $O/7zFile.o \ + $O/7zStream.o \ + + +include ../../7zip_gcc_c.mak diff --git a/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.c b/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.c index 6b4293e33..62a59079f 100644 --- a/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.c +++ b/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.c @@ -1,283 +1,286 @@ -/* LzmaUtil.c -- Test application for LZMA compression -2021-02-15 : Igor Pavlov : Public domain */ - -#include "../../Precomp.h" - -#include -#include -#include - -#include "../../CpuArch.h" - -#include "../../Alloc.h" -#include "../../7zFile.h" -#include "../../7zVersion.h" -#include "../../LzmaDec.h" -#include "../../LzmaEnc.h" - -static const char * const kCantReadMessage = "Cannot read input file"; -static const char * const kCantWriteMessage = "Cannot write output file"; -static const char * const kCantAllocateMessage = "Cannot allocate memory"; -static const char * const kDataErrorMessage = "Data error"; - -static void PrintHelp(char *buffer) -{ - strcat(buffer, - "\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n" - "Usage: lzma inputFile outputFile\n" - " e: encode file\n" - " d: decode file\n"); -} - -static int PrintError(char *buffer, const char *message) -{ - strcat(buffer, "\nError: "); - strcat(buffer, message); - strcat(buffer, "\n"); - return 1; -} - -static int PrintError_WRes(char *buffer, const char *message, WRes wres) -{ - strcat(buffer, "\nError: "); - strcat(buffer, message); - sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres); - #ifndef _WIN32 - { - const char *s = strerror(wres); - if (s) - sprintf(buffer + strlen(buffer), " : %s", s); - } - #endif - strcat(buffer, "\n"); - return 1; -} - -static int PrintErrorNumber(char *buffer, SRes val) -{ - sprintf(buffer + strlen(buffer), "\n7-Zip error code: %d\n", (unsigned)val); - return 1; -} - -static int PrintUserError(char *buffer) -{ - return PrintError(buffer, "Incorrect command"); -} - - -#define IN_BUF_SIZE (1 << 16) -#define OUT_BUF_SIZE (1 << 16) - - -static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream, - UInt64 unpackSize) -{ - int thereIsSize = (unpackSize != (UInt64)(Int64)-1); - Byte inBuf[IN_BUF_SIZE]; - Byte outBuf[OUT_BUF_SIZE]; - size_t inPos = 0, inSize = 0, outPos = 0; - LzmaDec_Init(state); - for (;;) - { - if (inPos == inSize) - { - inSize = IN_BUF_SIZE; - RINOK(inStream->Read(inStream, inBuf, &inSize)); - inPos = 0; - } - { - SRes res; - SizeT inProcessed = inSize - inPos; - SizeT outProcessed = OUT_BUF_SIZE - outPos; - ELzmaFinishMode finishMode = LZMA_FINISH_ANY; - ELzmaStatus status; - if (thereIsSize && outProcessed > unpackSize) - { - outProcessed = (SizeT)unpackSize; - finishMode = LZMA_FINISH_END; - } - - res = LzmaDec_DecodeToBuf(state, outBuf + outPos, &outProcessed, - inBuf + inPos, &inProcessed, finishMode, &status); - inPos += inProcessed; - outPos += outProcessed; - unpackSize -= outProcessed; - - if (outStream) - if (outStream->Write(outStream, outBuf, outPos) != outPos) - return SZ_ERROR_WRITE; - - outPos = 0; - - if (res != SZ_OK || (thereIsSize && unpackSize == 0)) - return res; - - if (inProcessed == 0 && outProcessed == 0) - { - if (thereIsSize || status != LZMA_STATUS_FINISHED_WITH_MARK) - return SZ_ERROR_DATA; - return res; - } - } - } -} - - -static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) -{ - UInt64 unpackSize; - int i; - SRes res = 0; - - CLzmaDec state; - - /* header: 5 bytes of LZMA properties and 8 bytes of uncompressed size */ - unsigned char header[LZMA_PROPS_SIZE + 8]; - - /* Read and parse header */ - - RINOK(SeqInStream_Read(inStream, header, sizeof(header))); - - unpackSize = 0; - for (i = 0; i < 8; i++) - unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); - - LzmaDec_Construct(&state); - RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)); - res = Decode2(&state, outStream, inStream, unpackSize); - LzmaDec_Free(&state, &g_Alloc); - return res; -} - -static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs) -{ - CLzmaEncHandle enc; - SRes res; - CLzmaEncProps props; - - UNUSED_VAR(rs); - - enc = LzmaEnc_Create(&g_Alloc); - if (enc == 0) - return SZ_ERROR_MEM; - - LzmaEncProps_Init(&props); - res = LzmaEnc_SetProps(enc, &props); - - if (res == SZ_OK) - { - Byte header[LZMA_PROPS_SIZE + 8]; - size_t headerSize = LZMA_PROPS_SIZE; - int i; - - res = LzmaEnc_WriteProperties(enc, header, &headerSize); - for (i = 0; i < 8; i++) - header[headerSize++] = (Byte)(fileSize >> (8 * i)); - if (outStream->Write(outStream, header, headerSize) != headerSize) - res = SZ_ERROR_WRITE; - else - { - if (res == SZ_OK) - res = LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc); - } - } - LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc); - return res; -} - - -static int main2(int numArgs, const char *args[], char *rs) -{ - CFileSeqInStream inStream; - CFileOutStream outStream; - char c; - int res; - int encodeMode; - BoolInt useOutFile = False; - - FileSeqInStream_CreateVTable(&inStream); - File_Construct(&inStream.file); - inStream.wres = 0; - - FileOutStream_CreateVTable(&outStream); - File_Construct(&outStream.file); - outStream.wres = 0; - - if (numArgs == 1) - { - PrintHelp(rs); - return 0; - } - - if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1) - return PrintUserError(rs); - - c = args[1][0]; - encodeMode = (c == 'e' || c == 'E'); - if (!encodeMode && c != 'd' && c != 'D') - return PrintUserError(rs); - - { - size_t t4 = sizeof(UInt32); - size_t t8 = sizeof(UInt64); - if (t4 != 4 || t8 != 8) - return PrintError(rs, "Incorrect UInt32 or UInt64"); - } - - { - WRes wres = InFile_Open(&inStream.file, args[2]); - if (wres != 0) - return PrintError_WRes(rs, "Cannot open input file", wres); - } - - if (numArgs > 3) - { - WRes wres; - useOutFile = True; - wres = OutFile_Open(&outStream.file, args[3]); - if (wres != 0) - return PrintError_WRes(rs, "Cannot open output file", wres); - } - else if (encodeMode) - PrintUserError(rs); - - if (encodeMode) - { - UInt64 fileSize; - WRes wres = File_GetLength(&inStream.file, &fileSize); - if (wres != 0) - return PrintError_WRes(rs, "Cannot get file length", wres); - res = Encode(&outStream.vt, &inStream.vt, fileSize, rs); - } - else - { - res = Decode(&outStream.vt, useOutFile ? &inStream.vt : NULL); - } - - if (useOutFile) - File_Close(&outStream.file); - File_Close(&inStream.file); - - if (res != SZ_OK) - { - if (res == SZ_ERROR_MEM) - return PrintError(rs, kCantAllocateMessage); - else if (res == SZ_ERROR_DATA) - return PrintError(rs, kDataErrorMessage); - else if (res == SZ_ERROR_WRITE) - return PrintError_WRes(rs, kCantWriteMessage, outStream.wres); - else if (res == SZ_ERROR_READ) - return PrintError_WRes(rs, kCantReadMessage, inStream.wres); - return PrintErrorNumber(rs, res); - } - return 0; -} - - -int MY_CDECL main(int numArgs, const char *args[]) -{ - char rs[800] = { 0 }; - int res = main2(numArgs, args, rs); - fputs(rs, stdout); - return res; -} +/* LzmaUtil.c -- Test application for LZMA compression +2021-11-01 : Igor Pavlov : Public domain */ + +#include "../../Precomp.h" + +#include +#include +#include + +#include "../../CpuArch.h" + +#include "../../Alloc.h" +#include "../../7zFile.h" +#include "../../7zVersion.h" +#include "../../LzFind.h" +#include "../../LzmaDec.h" +#include "../../LzmaEnc.h" + +static const char * const kCantReadMessage = "Cannot read input file"; +static const char * const kCantWriteMessage = "Cannot write output file"; +static const char * const kCantAllocateMessage = "Cannot allocate memory"; +static const char * const kDataErrorMessage = "Data error"; + +static void PrintHelp(char *buffer) +{ + strcat(buffer, + "\nLZMA-C " MY_VERSION_CPU " : " MY_COPYRIGHT_DATE "\n\n" + "Usage: lzma inputFile outputFile\n" + " e: encode file\n" + " d: decode file\n"); +} + +static int PrintError(char *buffer, const char *message) +{ + strcat(buffer, "\nError: "); + strcat(buffer, message); + strcat(buffer, "\n"); + return 1; +} + +static int PrintError_WRes(char *buffer, const char *message, WRes wres) +{ + strcat(buffer, "\nError: "); + strcat(buffer, message); + sprintf(buffer + strlen(buffer), "\nSystem error code: %d", (unsigned)wres); + #ifndef _WIN32 + { + const char *s = strerror(wres); + if (s) + sprintf(buffer + strlen(buffer), " : %s", s); + } + #endif + strcat(buffer, "\n"); + return 1; +} + +static int PrintErrorNumber(char *buffer, SRes val) +{ + sprintf(buffer + strlen(buffer), "\n7-Zip error code: %d\n", (unsigned)val); + return 1; +} + +static int PrintUserError(char *buffer) +{ + return PrintError(buffer, "Incorrect command"); +} + + +#define IN_BUF_SIZE (1 << 16) +#define OUT_BUF_SIZE (1 << 16) + + +static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inStream, + UInt64 unpackSize) +{ + int thereIsSize = (unpackSize != (UInt64)(Int64)-1); + Byte inBuf[IN_BUF_SIZE]; + Byte outBuf[OUT_BUF_SIZE]; + size_t inPos = 0, inSize = 0, outPos = 0; + LzmaDec_Init(state); + for (;;) + { + if (inPos == inSize) + { + inSize = IN_BUF_SIZE; + RINOK(inStream->Read(inStream, inBuf, &inSize)); + inPos = 0; + } + { + SRes res; + SizeT inProcessed = inSize - inPos; + SizeT outProcessed = OUT_BUF_SIZE - outPos; + ELzmaFinishMode finishMode = LZMA_FINISH_ANY; + ELzmaStatus status; + if (thereIsSize && outProcessed > unpackSize) + { + outProcessed = (SizeT)unpackSize; + finishMode = LZMA_FINISH_END; + } + + res = LzmaDec_DecodeToBuf(state, outBuf + outPos, &outProcessed, + inBuf + inPos, &inProcessed, finishMode, &status); + inPos += inProcessed; + outPos += outProcessed; + unpackSize -= outProcessed; + + if (outStream) + if (outStream->Write(outStream, outBuf, outPos) != outPos) + return SZ_ERROR_WRITE; + + outPos = 0; + + if (res != SZ_OK || (thereIsSize && unpackSize == 0)) + return res; + + if (inProcessed == 0 && outProcessed == 0) + { + if (thereIsSize || status != LZMA_STATUS_FINISHED_WITH_MARK) + return SZ_ERROR_DATA; + return res; + } + } + } +} + + +static SRes Decode(ISeqOutStream *outStream, ISeqInStream *inStream) +{ + UInt64 unpackSize; + int i; + SRes res = 0; + + CLzmaDec state; + + /* header: 5 bytes of LZMA properties and 8 bytes of uncompressed size */ + unsigned char header[LZMA_PROPS_SIZE + 8]; + + /* Read and parse header */ + + RINOK(SeqInStream_Read(inStream, header, sizeof(header))); + + unpackSize = 0; + for (i = 0; i < 8; i++) + unpackSize += (UInt64)header[LZMA_PROPS_SIZE + i] << (i * 8); + + LzmaDec_Construct(&state); + RINOK(LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc)); + res = Decode2(&state, outStream, inStream, unpackSize); + LzmaDec_Free(&state, &g_Alloc); + return res; +} + +static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize, char *rs) +{ + CLzmaEncHandle enc; + SRes res; + CLzmaEncProps props; + + UNUSED_VAR(rs); + + enc = LzmaEnc_Create(&g_Alloc); + if (enc == 0) + return SZ_ERROR_MEM; + + LzmaEncProps_Init(&props); + res = LzmaEnc_SetProps(enc, &props); + + if (res == SZ_OK) + { + Byte header[LZMA_PROPS_SIZE + 8]; + size_t headerSize = LZMA_PROPS_SIZE; + int i; + + res = LzmaEnc_WriteProperties(enc, header, &headerSize); + for (i = 0; i < 8; i++) + header[headerSize++] = (Byte)(fileSize >> (8 * i)); + if (outStream->Write(outStream, header, headerSize) != headerSize) + res = SZ_ERROR_WRITE; + else + { + if (res == SZ_OK) + res = LzmaEnc_Encode(enc, outStream, inStream, NULL, &g_Alloc, &g_Alloc); + } + } + LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc); + return res; +} + + +static int main2(int numArgs, const char *args[], char *rs) +{ + CFileSeqInStream inStream; + CFileOutStream outStream; + char c; + int res; + int encodeMode; + BoolInt useOutFile = False; + + LzFindPrepare(); + + FileSeqInStream_CreateVTable(&inStream); + File_Construct(&inStream.file); + inStream.wres = 0; + + FileOutStream_CreateVTable(&outStream); + File_Construct(&outStream.file); + outStream.wres = 0; + + if (numArgs == 1) + { + PrintHelp(rs); + return 0; + } + + if (numArgs < 3 || numArgs > 4 || strlen(args[1]) != 1) + return PrintUserError(rs); + + c = args[1][0]; + encodeMode = (c == 'e' || c == 'E'); + if (!encodeMode && c != 'd' && c != 'D') + return PrintUserError(rs); + + { + size_t t4 = sizeof(UInt32); + size_t t8 = sizeof(UInt64); + if (t4 != 4 || t8 != 8) + return PrintError(rs, "Incorrect UInt32 or UInt64"); + } + + { + WRes wres = InFile_Open(&inStream.file, args[2]); + if (wres != 0) + return PrintError_WRes(rs, "Cannot open input file", wres); + } + + if (numArgs > 3) + { + WRes wres; + useOutFile = True; + wres = OutFile_Open(&outStream.file, args[3]); + if (wres != 0) + return PrintError_WRes(rs, "Cannot open output file", wres); + } + else if (encodeMode) + PrintUserError(rs); + + if (encodeMode) + { + UInt64 fileSize; + WRes wres = File_GetLength(&inStream.file, &fileSize); + if (wres != 0) + return PrintError_WRes(rs, "Cannot get file length", wres); + res = Encode(&outStream.vt, &inStream.vt, fileSize, rs); + } + else + { + res = Decode(&outStream.vt, useOutFile ? &inStream.vt : NULL); + } + + if (useOutFile) + File_Close(&outStream.file); + File_Close(&inStream.file); + + if (res != SZ_OK) + { + if (res == SZ_ERROR_MEM) + return PrintError(rs, kCantAllocateMessage); + else if (res == SZ_ERROR_DATA) + return PrintError(rs, kDataErrorMessage); + else if (res == SZ_ERROR_WRITE) + return PrintError_WRes(rs, kCantWriteMessage, outStream.wres); + else if (res == SZ_ERROR_READ) + return PrintError_WRes(rs, kCantReadMessage, inStream.wres); + return PrintErrorNumber(rs, res); + } + return 0; +} + + +int MY_CDECL main(int numArgs, const char *args[]) +{ + char rs[1000] = { 0 }; + int res = main2(numArgs, args, rs); + fputs(rs, stdout); + return res; +} diff --git a/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsp b/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsp index eedde07d8..4e38e4a65 100644 --- a/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsp +++ b/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsp @@ -1,168 +1,172 @@ -# Microsoft Developer Studio Project File - Name="LzmaUtil" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=LzmaUtil - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "LzmaUtil.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "LzmaUtil.mak" CFG="LzmaUtil - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "LzmaUtil - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "LzmaUtil - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LzmaUtil - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W4 /WX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x419 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7lzma.exe" - -!ELSEIF "$(CFG)" == "LzmaUtil - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W4 /WX /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x419 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7lzma.exe" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "LzmaUtil - Win32 Release" -# Name "LzmaUtil - Win32 Debug" -# Begin Source File - -SOURCE=..\..\7zFile.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zFile.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zStream.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zVersion.h -# End Source File -# Begin Source File - -SOURCE=..\..\Alloc.c -# End Source File -# Begin Source File - -SOURCE=..\..\Alloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\CpuArch.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzFind.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzFind.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzFindMt.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzFindMt.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzHash.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaEnc.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaEnc.h -# End Source File -# Begin Source File - -SOURCE=.\LzmaUtil.c -# End Source File -# Begin Source File - -SOURCE=..\..\Threads.c -# End Source File -# Begin Source File - -SOURCE=..\..\Threads.h -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="LzmaUtil" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=LzmaUtil - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "LzmaUtil.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "LzmaUtil.mak" CFG="LzmaUtil - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "LzmaUtil - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "LzmaUtil - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "LzmaUtil - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W4 /WX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x419 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\util\7lzma.exe" + +!ELSEIF "$(CFG)" == "LzmaUtil - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W4 /WX /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x419 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\util\7lzma.exe" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "LzmaUtil - Win32 Release" +# Name "LzmaUtil - Win32 Debug" +# Begin Source File + +SOURCE=..\..\7zFile.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zFile.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zStream.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zTypes.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zVersion.h +# End Source File +# Begin Source File + +SOURCE=..\..\Alloc.c +# End Source File +# Begin Source File + +SOURCE=..\..\Alloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\CpuArch.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzFind.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzFind.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzFindMt.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzFindMt.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzFindOpt.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzHash.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaEnc.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaEnc.h +# End Source File +# Begin Source File + +SOURCE=.\LzmaUtil.c +# End Source File +# Begin Source File + +SOURCE=..\..\Threads.c +# End Source File +# Begin Source File + +SOURCE=..\..\Threads.h +# End Source File +# End Target +# End Project diff --git a/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsw b/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsw index f43548752..c52eaf6d0 100644 --- a/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsw +++ b/deps/LZMA-SDK/C/Util/Lzma/LzmaUtil.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "LzmaUtil"=.\LzmaUtil.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "LzmaUtil"=.\LzmaUtil.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/deps/LZMA-SDK/C/Util/Lzma/makefile b/deps/LZMA-SDK/C/Util/Lzma/makefile index 3b825f21a..7813bdb05 100644 --- a/deps/LZMA-SDK/C/Util/Lzma/makefile +++ b/deps/LZMA-SDK/C/Util/Lzma/makefile @@ -1,28 +1,30 @@ -# MY_STATIC_LINK=1 -PROG = LZMAc.exe - -CFLAGS = $(CFLAGS) \ - -LIB_OBJS = \ - $O\LzmaUtil.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - $O\LzFind.obj \ - $O\LzFindMt.obj \ - $O\LzmaDec.obj \ - $O\LzmaEnc.obj \ - $O\7zFile.obj \ - $O\7zStream.obj \ - $O\Threads.obj \ - -OBJS = \ - $(LIB_OBJS) \ - $(C_OBJS) \ - -!include "../../../CPP/Build.mak" - -$(LIB_OBJS): $(*B).c - $(COMPL_O2) -$(C_OBJS): ../../$(*B).c - $(COMPL_O2) +# MY_STATIC_LINK=1 +PROG = LZMAc.exe + +CFLAGS = $(CFLAGS) \ + +LIB_OBJS = \ + $O\LzmaUtil.obj \ + +C_OBJS = \ + $O\Alloc.obj \ + $O\CpuArch.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\LzFindOpt.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ + $O\7zFile.obj \ + $O\7zStream.obj \ + $O\Threads.obj \ + +OBJS = \ + $(LIB_OBJS) \ + $(C_OBJS) \ + +!include "../../../CPP/Build.mak" + +$(LIB_OBJS): $(*B).c + $(COMPL_O2) +$(C_OBJS): ../../$(*B).c + $(COMPL_O2) diff --git a/deps/LZMA-SDK/C/Util/Lzma/makefile.gcc b/deps/LZMA-SDK/C/Util/Lzma/makefile.gcc index 89b3e11f7..2acb0b808 100644 --- a/deps/LZMA-SDK/C/Util/Lzma/makefile.gcc +++ b/deps/LZMA-SDK/C/Util/Lzma/makefile.gcc @@ -1,19 +1,21 @@ -PROG = 7lzma - -include ../../../CPP/7zip/LzmaDec_gcc.mak - - -OBJS = \ - $(LZMA_DEC_OPT_OBJS) \ - $O/7zFile.o \ - $O/7zStream.o \ - $O/Alloc.o \ - $O/LzFind.o \ - $O/LzFindMt.o \ - $O/LzmaDec.o \ - $O/LzmaEnc.o \ - $O/LzmaUtil.o \ - $O/Threads.o \ - - -include ../../7zip_gcc_c.mak +PROG = 7lzma + +include ../../../CPP/7zip/LzmaDec_gcc.mak + + +OBJS = \ + $(LZMA_DEC_OPT_OBJS) \ + $O/7zFile.o \ + $O/7zStream.o \ + $O/Alloc.o \ + $O/CpuArch.o \ + $O/LzFind.o \ + $O/LzFindMt.o \ + $O/LzFindOpt.o \ + $O/LzmaDec.o \ + $O/LzmaEnc.o \ + $O/LzmaUtil.o \ + $O/Threads.o \ + + +include ../../7zip_gcc_c.mak diff --git a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.def b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.def index 43b959778..8bc6add93 100644 --- a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.def +++ b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.def @@ -1,4 +1,4 @@ -EXPORTS - LzmaCompress - LzmaUncompress - +EXPORTS + LzmaCompress + LzmaUncompress + diff --git a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsp b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsp index 0d4c981c4..6ce91dcd2 100644 --- a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsp +++ b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsp @@ -1,178 +1,182 @@ -# Microsoft Developer Studio Project File - Name="LzmaLib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=LzmaLib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "LzmaLib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "LzmaLib.mak" CFG="LzmaLib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "LzmaLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "LzmaLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "LzmaLib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x419 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Util\LZMA.dll" /opt:NOWIN98 -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "LzmaLib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /D "COMPRESS_MF_MT" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x419 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Util\LZMA.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "LzmaLib - Win32 Release" -# Name "LzmaLib - Win32 Debug" -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\LzmaLib.def -# End Source File -# Begin Source File - -SOURCE=.\LzmaLibExports.c -# End Source File -# End Group -# Begin Source File - -SOURCE=..\..\7zTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\Alloc.c -# End Source File -# Begin Source File - -SOURCE=..\..\Alloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\IStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzFind.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzFind.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzFindMt.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzFindMt.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzHash.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaEnc.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaEnc.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaLib.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaLib.h -# End Source File -# Begin Source File - -SOURCE=.\resource.rc -# End Source File -# Begin Source File - -SOURCE=..\..\Threads.c -# End Source File -# Begin Source File - -SOURCE=..\..\Threads.h -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="LzmaLib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=LzmaLib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "LzmaLib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "LzmaLib.mak" CFG="LzmaLib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "LzmaLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "LzmaLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "LzmaLib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /c +# ADD CPP /nologo /Gr /MT /W3 /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x419 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Util\LZMA.dll" /opt:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "LzmaLib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMALIB_EXPORTS" /D "COMPRESS_MF_MT" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x419 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Util\LZMA.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "LzmaLib - Win32 Release" +# Name "LzmaLib - Win32 Debug" +# Begin Group "Spec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\LzmaLib.def +# End Source File +# Begin Source File + +SOURCE=.\LzmaLibExports.c +# End Source File +# End Group +# Begin Source File + +SOURCE=..\..\7zTypes.h +# End Source File +# Begin Source File + +SOURCE=..\..\Alloc.c +# End Source File +# Begin Source File + +SOURCE=..\..\Alloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\IStream.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzFind.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzFind.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzFindMt.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzFindMt.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzFindOpt.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzHash.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaEnc.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaEnc.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaLib.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaLib.h +# End Source File +# Begin Source File + +SOURCE=.\resource.rc +# End Source File +# Begin Source File + +SOURCE=..\..\Threads.c +# End Source File +# Begin Source File + +SOURCE=..\..\Threads.h +# End Source File +# End Target +# End Project diff --git a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsw b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsw index f6c55593f..6faf33365 100644 --- a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsw +++ b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLib.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "LzmaLib"=.\LzmaLib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "LzmaLib"=.\LzmaLib.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLibExports.c b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLibExports.c index 02600c724..4a28a9a6b 100644 --- a/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLibExports.c +++ b/deps/LZMA-SDK/C/Util/LzmaLib/LzmaLibExports.c @@ -1,14 +1,14 @@ -/* LzmaLibExports.c -- LZMA library DLL Entry point -2015-11-08 : Igor Pavlov : Public domain */ - -#include "../../Precomp.h" - -#include - -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - UNUSED_VAR(hInstance); - UNUSED_VAR(dwReason); - UNUSED_VAR(lpReserved); - return TRUE; -} +/* LzmaLibExports.c -- LZMA library DLL Entry point +2015-11-08 : Igor Pavlov : Public domain */ + +#include "../../Precomp.h" + +#include + +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) +{ + UNUSED_VAR(hInstance); + UNUSED_VAR(dwReason); + UNUSED_VAR(lpReserved); + return TRUE; +} diff --git a/deps/LZMA-SDK/C/Util/LzmaLib/makefile b/deps/LZMA-SDK/C/Util/LzmaLib/makefile index e0f311471..b36f1de09 100644 --- a/deps/LZMA-SDK/C/Util/LzmaLib/makefile +++ b/deps/LZMA-SDK/C/Util/LzmaLib/makefile @@ -1,34 +1,36 @@ -MY_STATIC_LINK=1 -SLIB = sLZMA.lib -PROG = LZMA.dll -SLIBPATH = $O\$(SLIB) - -DEF_FILE = LzmaLib.def -CFLAGS = $(CFLAGS) \ - -LIB_OBJS = \ - $O\LzmaLibExports.obj \ - -C_OBJS = \ - $O\Alloc.obj \ - $O\LzFind.obj \ - $O\LzFindMt.obj \ - $O\LzmaDec.obj \ - $O\LzmaEnc.obj \ - $O\LzmaLib.obj \ - $O\Threads.obj \ - -OBJS = \ - $(LIB_OBJS) \ - $(C_OBJS) \ - $O\resource.res - -!include "../../../CPP/Build.mak" - -$(SLIBPATH): $O $(OBJS) - lib -out:$(SLIBPATH) $(OBJS) $(LIBS) - -$(LIB_OBJS): $(*B).c - $(COMPL_O2) -$(C_OBJS): ../../$(*B).c - $(COMPL_O2) +MY_STATIC_LINK=1 +SLIB = sLZMA.lib +PROG = LZMA.dll +SLIBPATH = $O\$(SLIB) + +DEF_FILE = LzmaLib.def +CFLAGS = $(CFLAGS) \ + +LIB_OBJS = \ + $O\LzmaLibExports.obj \ + +C_OBJS = \ + $O\Alloc.obj \ + $O\CpuArch.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\LzFindOpt.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ + $O\LzmaLib.obj \ + $O\Threads.obj \ + +OBJS = \ + $(LIB_OBJS) \ + $(C_OBJS) \ + $O\resource.res + +!include "../../../CPP/Build.mak" + +$(SLIBPATH): $O $(OBJS) + lib -out:$(SLIBPATH) $(OBJS) $(LIBS) + +$(LIB_OBJS): $(*B).c + $(COMPL_O2) +$(C_OBJS): ../../$(*B).c + $(COMPL_O2) diff --git a/deps/LZMA-SDK/C/Util/LzmaLib/resource.rc b/deps/LZMA-SDK/C/Util/LzmaLib/resource.rc index d95e3f358..674832e05 100644 --- a/deps/LZMA-SDK/C/Util/LzmaLib/resource.rc +++ b/deps/LZMA-SDK/C/Util/LzmaLib/resource.rc @@ -1,3 +1,3 @@ -#include "../../7zVersion.rc" - -MY_VERSION_INFO_DLL("LZMA library", "LZMA") +#include "../../7zVersion.rc" + +MY_VERSION_INFO_DLL("LZMA library", "LZMA") diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.c b/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.c index 34b60f8fc..01605e3c2 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.c +++ b/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.c @@ -1,4 +1,4 @@ -/* Precomp.c -- StdAfx -2013-01-21 : Igor Pavlov : Public domain */ - -#include "Precomp.h" +/* Precomp.c -- StdAfx +2013-01-21 : Igor Pavlov : Public domain */ + +#include "Precomp.h" diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.h b/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.h index 9f398d08f..588a66f7e 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.h +++ b/deps/LZMA-SDK/C/Util/SfxSetup/Precomp.h @@ -1,10 +1,10 @@ -/* Precomp.h -- StdAfx -2013-06-16 : Igor Pavlov : Public domain */ - -#ifndef __7Z_PRECOMP_H -#define __7Z_PRECOMP_H - -#include "../../Compiler.h" -#include "../../7zTypes.h" - -#endif +/* Precomp.h -- StdAfx +2013-06-16 : Igor Pavlov : Public domain */ + +#ifndef __7Z_PRECOMP_H +#define __7Z_PRECOMP_H + +#include "../../Compiler.h" +#include "../../7zTypes.h" + +#endif diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.c b/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.c index 394369abd..ef19aeac5 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.c +++ b/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.c @@ -1,640 +1,640 @@ -/* SfxSetup.c - 7z SFX Setup -2019-02-02 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#ifndef UNICODE -#define UNICODE -#endif - -#ifndef _UNICODE -#define _UNICODE -#endif - -#ifdef _CONSOLE -#include -#endif - -#include "../../7z.h" -#include "../../7zAlloc.h" -#include "../../7zCrc.h" -#include "../../7zFile.h" -#include "../../CpuArch.h" -#include "../../DllSecur.h" - -#define k_EXE_ExtIndex 2 - -#define kInputBufSize ((size_t)1 << 18) - -static const char * const kExts[] = -{ - "bat" - , "cmd" - , "exe" - , "inf" - , "msi" - #ifdef UNDER_CE - , "cab" - #endif - , "html" - , "htm" -}; - -static const char * const kNames[] = -{ - "setup" - , "install" - , "run" - , "start" -}; - -static unsigned FindExt(const wchar_t *s, unsigned *extLen) -{ - unsigned len = (unsigned)wcslen(s); - unsigned i; - for (i = len; i > 0; i--) - { - if (s[i - 1] == '.') - { - *extLen = len - i; - return i - 1; - } - } - *extLen = 0; - return len; -} - -#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) - -static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) -{ - unsigned i; - for (i = 0; i < num; i++) - { - const char *item = items[i]; - unsigned itemLen = (unsigned)strlen(item); - unsigned j; - if (len != itemLen) - continue; - for (j = 0; j < len; j++) - { - unsigned c = (Byte)item[j]; - if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j]) - break; - } - if (j == len) - return i; - } - return i; -} - -#ifdef _CONSOLE -static BOOL WINAPI HandlerRoutine(DWORD ctrlType) -{ - UNUSED_VAR(ctrlType); - return TRUE; -} -#endif - -static void PrintErrorMessage(const char *message) -{ - #ifdef _CONSOLE - printf("\n7-Zip Error: %s\n", message); - #else - #ifdef UNDER_CE - WCHAR messageW[256 + 4]; - unsigned i; - for (i = 0; i < 256 && message[i] != 0; i++) - messageW[i] = message[i]; - messageW[i] = 0; - MessageBoxW(0, messageW, L"7-Zip Error", MB_ICONERROR); - #else - MessageBoxA(0, message, "7-Zip Error", MB_ICONERROR); - #endif - #endif -} - -static WRes MyCreateDir(const WCHAR *name) -{ - return CreateDirectoryW(name, NULL) ? 0 : GetLastError(); -} - -#ifdef UNDER_CE -#define kBufferSize (1 << 13) -#else -#define kBufferSize (1 << 15) -#endif - -#define kSignatureSearchLimit (1 << 22) - -static BoolInt FindSignature(CSzFile *stream, UInt64 *resPos) -{ - Byte buf[kBufferSize]; - size_t numPrevBytes = 0; - *resPos = 0; - for (;;) - { - size_t processed, pos; - if (*resPos > kSignatureSearchLimit) - return False; - processed = kBufferSize - numPrevBytes; - if (File_Read(stream, buf + numPrevBytes, &processed) != 0) - return False; - processed += numPrevBytes; - if (processed < k7zStartHeaderSize || - (processed == k7zStartHeaderSize && numPrevBytes != 0)) - return False; - processed -= k7zStartHeaderSize; - for (pos = 0; pos <= processed; pos++) - { - for (; pos <= processed && buf[pos] != '7'; pos++); - if (pos > processed) - break; - if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0) - if (CrcCalc(buf + pos + 12, 20) == GetUi32(buf + pos + 8)) - { - *resPos += pos; - return True; - } - } - *resPos += processed; - numPrevBytes = k7zStartHeaderSize; - memmove(buf, buf + processed, k7zStartHeaderSize); - } -} - -static BoolInt DoesFileOrDirExist(const WCHAR *path) -{ - WIN32_FIND_DATAW fd; - HANDLE handle; - handle = FindFirstFileW(path, &fd); - if (handle == INVALID_HANDLE_VALUE) - return False; - FindClose(handle); - return True; -} - -static WRes RemoveDirWithSubItems(WCHAR *path) -{ - WIN32_FIND_DATAW fd; - HANDLE handle; - WRes res = 0; - size_t len = wcslen(path); - wcscpy(path + len, L"*"); - handle = FindFirstFileW(path, &fd); - path[len] = L'\0'; - if (handle == INVALID_HANDLE_VALUE) - return GetLastError(); - - for (;;) - { - if (wcscmp(fd.cFileName, L".") != 0 && - wcscmp(fd.cFileName, L"..") != 0) - { - wcscpy(path + len, fd.cFileName); - if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) - { - wcscat(path, WSTRING_PATH_SEPARATOR); - res = RemoveDirWithSubItems(path); - } - else - { - SetFileAttributesW(path, 0); - if (DeleteFileW(path) == 0) - res = GetLastError(); - } - - if (res != 0) - break; - } - - if (!FindNextFileW(handle, &fd)) - { - res = GetLastError(); - if (res == ERROR_NO_MORE_FILES) - res = 0; - break; - } - } - - path[len] = L'\0'; - FindClose(handle); - if (res == 0) - { - if (!RemoveDirectoryW(path)) - res = GetLastError(); - } - return res; -} - -#ifdef _CONSOLE -int MY_CDECL main() -#else -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - #ifdef UNDER_CE - LPWSTR - #else - LPSTR - #endif - lpCmdLine, int nCmdShow) -#endif -{ - CFileInStream archiveStream; - CLookToRead2 lookStream; - CSzArEx db; - SRes res = SZ_OK; - ISzAlloc allocImp; - ISzAlloc allocTempImp; - WCHAR sfxPath[MAX_PATH + 2]; - WCHAR path[MAX_PATH * 3 + 2]; - #ifndef UNDER_CE - WCHAR workCurDir[MAX_PATH + 32]; - #endif - size_t pathLen; - DWORD winRes; - const wchar_t *cmdLineParams; - const char *errorMessage = NULL; - BoolInt useShellExecute = True; - DWORD exitCode = 0; - - LoadSecurityDlls(); - - #ifdef _CONSOLE - SetConsoleCtrlHandler(HandlerRoutine, TRUE); - #else - UNUSED_VAR(hInstance); - UNUSED_VAR(hPrevInstance); - UNUSED_VAR(lpCmdLine); - UNUSED_VAR(nCmdShow); - #endif - - CrcGenerateTable(); - - allocImp.Alloc = SzAlloc; - allocImp.Free = SzFree; - - allocTempImp.Alloc = SzAllocTemp; - allocTempImp.Free = SzFreeTemp; - - FileInStream_CreateVTable(&archiveStream); - LookToRead2_CreateVTable(&lookStream, False); - lookStream.buf = NULL; - - winRes = GetModuleFileNameW(NULL, sfxPath, MAX_PATH); - if (winRes == 0 || winRes > MAX_PATH) - return 1; - { - cmdLineParams = GetCommandLineW(); - #ifndef UNDER_CE - { - BoolInt quoteMode = False; - for (;; cmdLineParams++) - { - wchar_t c = *cmdLineParams; - if (c == L'\"') - quoteMode = !quoteMode; - else if (c == 0 || (c == L' ' && !quoteMode)) - break; - } - } - #endif - } - - { - unsigned i; - DWORD d; - winRes = GetTempPathW(MAX_PATH, path); - if (winRes == 0 || winRes > MAX_PATH) - return 1; - pathLen = wcslen(path); - d = (GetTickCount() << 12) ^ (GetCurrentThreadId() << 14) ^ GetCurrentProcessId(); - - for (i = 0;; i++, d += GetTickCount()) - { - if (i >= 100) - { - res = SZ_ERROR_FAIL; - break; - } - wcscpy(path + pathLen, L"7z"); - - { - wchar_t *s = path + wcslen(path); - UInt32 value = d; - unsigned k; - for (k = 0; k < 8; k++) - { - unsigned t = value & 0xF; - value >>= 4; - s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); - } - s[k] = '\0'; - } - - if (DoesFileOrDirExist(path)) - continue; - if (CreateDirectoryW(path, NULL)) - { - wcscat(path, WSTRING_PATH_SEPARATOR); - pathLen = wcslen(path); - break; - } - if (GetLastError() != ERROR_ALREADY_EXISTS) - { - res = SZ_ERROR_FAIL; - break; - } - } - - #ifndef UNDER_CE - wcscpy(workCurDir, path); - #endif - if (res != SZ_OK) - errorMessage = "Can't create temp folder"; - } - - if (res != SZ_OK) - { - if (!errorMessage) - errorMessage = "Error"; - PrintErrorMessage(errorMessage); - return 1; - } - - if (InFile_OpenW(&archiveStream.file, sfxPath) != 0) - { - errorMessage = "can not open input file"; - res = SZ_ERROR_FAIL; - } - else - { - UInt64 pos = 0; - if (!FindSignature(&archiveStream.file, &pos)) - res = SZ_ERROR_FAIL; - else if (File_Seek(&archiveStream.file, (Int64 *)&pos, SZ_SEEK_SET) != 0) - res = SZ_ERROR_FAIL; - if (res != 0) - errorMessage = "Can't find 7z archive"; - } - - if (res == SZ_OK) - { - lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize); - if (!lookStream.buf) - res = SZ_ERROR_MEM; - else - { - lookStream.bufSize = kInputBufSize; - lookStream.realStream = &archiveStream.vt; - LookToRead2_Init(&lookStream); - } - } - - SzArEx_Init(&db); - - if (res == SZ_OK) - { - res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp); - } - - if (res == SZ_OK) - { - UInt32 executeFileIndex = (UInt32)(Int32)-1; - UInt32 minPrice = 1 << 30; - UInt32 i; - UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ - Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */ - size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */ - - for (i = 0; i < db.NumFiles; i++) - { - size_t offset = 0; - size_t outSizeProcessed = 0; - WCHAR *temp; - - if (SzArEx_GetFileNameUtf16(&db, i, NULL) >= MAX_PATH) - { - res = SZ_ERROR_FAIL; - break; - } - - temp = path + pathLen; - - SzArEx_GetFileNameUtf16(&db, i, (UInt16 *)temp); - { - res = SzArEx_Extract(&db, &lookStream.vt, i, - &blockIndex, &outBuffer, &outBufferSize, - &offset, &outSizeProcessed, - &allocImp, &allocTempImp); - if (res != SZ_OK) - break; - } - { - CSzFile outFile; - size_t processedSize; - size_t j; - size_t nameStartPos = 0; - for (j = 0; temp[j] != 0; j++) - { - if (temp[j] == '/') - { - temp[j] = 0; - MyCreateDir(path); - temp[j] = CHAR_PATH_SEPARATOR; - nameStartPos = j + 1; - } - } - - if (SzArEx_IsDir(&db, i)) - { - MyCreateDir(path); - continue; - } - else - { - unsigned extLen; - const WCHAR *name = temp + nameStartPos; - unsigned len = (unsigned)wcslen(name); - unsigned nameLen = FindExt(temp + nameStartPos, &extLen); - unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen); - unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen); - - unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12)); - if (minPrice > price) - { - minPrice = price; - executeFileIndex = i; - useShellExecute = (extPrice != k_EXE_ExtIndex); - } - - if (DoesFileOrDirExist(path)) - { - errorMessage = "Duplicate file"; - res = SZ_ERROR_FAIL; - break; - } - if (OutFile_OpenW(&outFile, path)) - { - errorMessage = "Can't open output file"; - res = SZ_ERROR_FAIL; - break; - } - } - - processedSize = outSizeProcessed; - if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed) - { - errorMessage = "Can't write output file"; - res = SZ_ERROR_FAIL; - } - - #ifdef USE_WINDOWS_FILE - if (SzBitWithVals_Check(&db.MTime, i)) - { - const CNtfsFileTime *t = db.MTime.Vals + i; - FILETIME mTime; - mTime.dwLowDateTime = t->Low; - mTime.dwHighDateTime = t->High; - SetFileTime(outFile.handle, NULL, NULL, &mTime); - } - #endif - - { - SRes res2 = File_Close(&outFile); - if (res != SZ_OK) - break; - if (res2 != SZ_OK) - { - res = res2; - break; - } - } - #ifdef USE_WINDOWS_FILE - if (SzBitWithVals_Check(&db.Attribs, i)) - SetFileAttributesW(path, db.Attribs.Vals[i]); - #endif - } - } - - if (res == SZ_OK) - { - if (executeFileIndex == (UInt32)(Int32)-1) - { - errorMessage = "There is no file to execute"; - res = SZ_ERROR_FAIL; - } - else - { - WCHAR *temp = path + pathLen; - UInt32 j; - SzArEx_GetFileNameUtf16(&db, executeFileIndex, (UInt16 *)temp); - for (j = 0; temp[j] != 0; j++) - if (temp[j] == '/') - temp[j] = CHAR_PATH_SEPARATOR; - } - } - ISzAlloc_Free(&allocImp, outBuffer); - } - - SzArEx_Free(&db, &allocImp); - - ISzAlloc_Free(&allocImp, lookStream.buf); - - File_Close(&archiveStream.file); - - if (res == SZ_OK) - { - HANDLE hProcess = 0; - - #ifndef UNDER_CE - WCHAR oldCurDir[MAX_PATH + 2]; - oldCurDir[0] = 0; - { - DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir); - if (needLen == 0 || needLen > MAX_PATH) - oldCurDir[0] = 0; - SetCurrentDirectory(workCurDir); - } - #endif - - if (useShellExecute) - { - SHELLEXECUTEINFO ei; - UINT32 executeRes; - BOOL success; - - memset(&ei, 0, sizeof(ei)); - ei.cbSize = sizeof(ei); - ei.lpFile = path; - ei.fMask = SEE_MASK_NOCLOSEPROCESS - #ifndef UNDER_CE - | SEE_MASK_FLAG_DDEWAIT - #endif - /* | SEE_MASK_NO_CONSOLE */ - ; - if (wcslen(cmdLineParams) != 0) - ei.lpParameters = cmdLineParams; - ei.nShow = SW_SHOWNORMAL; /* SW_HIDE; */ - success = ShellExecuteEx(&ei); - executeRes = (UINT32)(UINT_PTR)ei.hInstApp; - if (!success || (executeRes <= 32 && executeRes != 0)) /* executeRes = 0 in Windows CE */ - res = SZ_ERROR_FAIL; - else - hProcess = ei.hProcess; - } - else - { - STARTUPINFOW si; - PROCESS_INFORMATION pi; - WCHAR cmdLine[MAX_PATH * 3]; - - wcscpy(cmdLine, path); - wcscat(cmdLine, cmdLineParams); - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - if (CreateProcessW(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) - res = SZ_ERROR_FAIL; - else - { - CloseHandle(pi.hThread); - hProcess = pi.hProcess; - } - } - - if (hProcess != 0) - { - WaitForSingleObject(hProcess, INFINITE); - if (!GetExitCodeProcess(hProcess, &exitCode)) - exitCode = 1; - CloseHandle(hProcess); - } - - #ifndef UNDER_CE - SetCurrentDirectory(oldCurDir); - #endif - } - - path[pathLen] = L'\0'; - RemoveDirWithSubItems(path); - - if (res == SZ_OK) - return (int)exitCode; - - { - if (res == SZ_ERROR_UNSUPPORTED) - errorMessage = "Decoder doesn't support this archive"; - else if (res == SZ_ERROR_MEM) - errorMessage = "Can't allocate required memory"; - else if (res == SZ_ERROR_CRC) - errorMessage = "CRC error"; - else - { - if (!errorMessage) - errorMessage = "ERROR"; - } - - if (errorMessage) - PrintErrorMessage(errorMessage); - } - return 1; -} +/* SfxSetup.c - 7z SFX Setup +2019-02-02 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#ifndef UNICODE +#define UNICODE +#endif + +#ifndef _UNICODE +#define _UNICODE +#endif + +#ifdef _CONSOLE +#include +#endif + +#include "../../7z.h" +#include "../../7zAlloc.h" +#include "../../7zCrc.h" +#include "../../7zFile.h" +#include "../../CpuArch.h" +#include "../../DllSecur.h" + +#define k_EXE_ExtIndex 2 + +#define kInputBufSize ((size_t)1 << 18) + +static const char * const kExts[] = +{ + "bat" + , "cmd" + , "exe" + , "inf" + , "msi" + #ifdef UNDER_CE + , "cab" + #endif + , "html" + , "htm" +}; + +static const char * const kNames[] = +{ + "setup" + , "install" + , "run" + , "start" +}; + +static unsigned FindExt(const wchar_t *s, unsigned *extLen) +{ + unsigned len = (unsigned)wcslen(s); + unsigned i; + for (i = len; i > 0; i--) + { + if (s[i - 1] == '.') + { + *extLen = len - i; + return i - 1; + } + } + *extLen = 0; + return len; +} + +#define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) -= 0x20 : (c))) + +static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) +{ + unsigned i; + for (i = 0; i < num; i++) + { + const char *item = items[i]; + unsigned itemLen = (unsigned)strlen(item); + unsigned j; + if (len != itemLen) + continue; + for (j = 0; j < len; j++) + { + unsigned c = (Byte)item[j]; + if (c != s[j] && MAKE_CHAR_UPPER(c) != s[j]) + break; + } + if (j == len) + return i; + } + return i; +} + +#ifdef _CONSOLE +static BOOL WINAPI HandlerRoutine(DWORD ctrlType) +{ + UNUSED_VAR(ctrlType); + return TRUE; +} +#endif + +static void PrintErrorMessage(const char *message) +{ + #ifdef _CONSOLE + printf("\n7-Zip Error: %s\n", message); + #else + #ifdef UNDER_CE + WCHAR messageW[256 + 4]; + unsigned i; + for (i = 0; i < 256 && message[i] != 0; i++) + messageW[i] = message[i]; + messageW[i] = 0; + MessageBoxW(0, messageW, L"7-Zip Error", MB_ICONERROR); + #else + MessageBoxA(0, message, "7-Zip Error", MB_ICONERROR); + #endif + #endif +} + +static WRes MyCreateDir(const WCHAR *name) +{ + return CreateDirectoryW(name, NULL) ? 0 : GetLastError(); +} + +#ifdef UNDER_CE +#define kBufferSize (1 << 13) +#else +#define kBufferSize (1 << 15) +#endif + +#define kSignatureSearchLimit (1 << 22) + +static BoolInt FindSignature(CSzFile *stream, UInt64 *resPos) +{ + Byte buf[kBufferSize]; + size_t numPrevBytes = 0; + *resPos = 0; + for (;;) + { + size_t processed, pos; + if (*resPos > kSignatureSearchLimit) + return False; + processed = kBufferSize - numPrevBytes; + if (File_Read(stream, buf + numPrevBytes, &processed) != 0) + return False; + processed += numPrevBytes; + if (processed < k7zStartHeaderSize || + (processed == k7zStartHeaderSize && numPrevBytes != 0)) + return False; + processed -= k7zStartHeaderSize; + for (pos = 0; pos <= processed; pos++) + { + for (; pos <= processed && buf[pos] != '7'; pos++); + if (pos > processed) + break; + if (memcmp(buf + pos, k7zSignature, k7zSignatureSize) == 0) + if (CrcCalc(buf + pos + 12, 20) == GetUi32(buf + pos + 8)) + { + *resPos += pos; + return True; + } + } + *resPos += processed; + numPrevBytes = k7zStartHeaderSize; + memmove(buf, buf + processed, k7zStartHeaderSize); + } +} + +static BoolInt DoesFileOrDirExist(const WCHAR *path) +{ + WIN32_FIND_DATAW fd; + HANDLE handle; + handle = FindFirstFileW(path, &fd); + if (handle == INVALID_HANDLE_VALUE) + return False; + FindClose(handle); + return True; +} + +static WRes RemoveDirWithSubItems(WCHAR *path) +{ + WIN32_FIND_DATAW fd; + HANDLE handle; + WRes res = 0; + size_t len = wcslen(path); + wcscpy(path + len, L"*"); + handle = FindFirstFileW(path, &fd); + path[len] = L'\0'; + if (handle == INVALID_HANDLE_VALUE) + return GetLastError(); + + for (;;) + { + if (wcscmp(fd.cFileName, L".") != 0 && + wcscmp(fd.cFileName, L"..") != 0) + { + wcscpy(path + len, fd.cFileName); + if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + { + wcscat(path, WSTRING_PATH_SEPARATOR); + res = RemoveDirWithSubItems(path); + } + else + { + SetFileAttributesW(path, 0); + if (DeleteFileW(path) == 0) + res = GetLastError(); + } + + if (res != 0) + break; + } + + if (!FindNextFileW(handle, &fd)) + { + res = GetLastError(); + if (res == ERROR_NO_MORE_FILES) + res = 0; + break; + } + } + + path[len] = L'\0'; + FindClose(handle); + if (res == 0) + { + if (!RemoveDirectoryW(path)) + res = GetLastError(); + } + return res; +} + +#ifdef _CONSOLE +int MY_CDECL main() +#else +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + #ifdef UNDER_CE + LPWSTR + #else + LPSTR + #endif + lpCmdLine, int nCmdShow) +#endif +{ + CFileInStream archiveStream; + CLookToRead2 lookStream; + CSzArEx db; + SRes res = SZ_OK; + ISzAlloc allocImp; + ISzAlloc allocTempImp; + WCHAR sfxPath[MAX_PATH + 2]; + WCHAR path[MAX_PATH * 3 + 2]; + #ifndef UNDER_CE + WCHAR workCurDir[MAX_PATH + 32]; + #endif + size_t pathLen; + DWORD winRes; + const wchar_t *cmdLineParams; + const char *errorMessage = NULL; + BoolInt useShellExecute = True; + DWORD exitCode = 0; + + LoadSecurityDlls(); + + #ifdef _CONSOLE + SetConsoleCtrlHandler(HandlerRoutine, TRUE); + #else + UNUSED_VAR(hInstance); + UNUSED_VAR(hPrevInstance); + UNUSED_VAR(lpCmdLine); + UNUSED_VAR(nCmdShow); + #endif + + CrcGenerateTable(); + + allocImp.Alloc = SzAlloc; + allocImp.Free = SzFree; + + allocTempImp.Alloc = SzAllocTemp; + allocTempImp.Free = SzFreeTemp; + + FileInStream_CreateVTable(&archiveStream); + LookToRead2_CreateVTable(&lookStream, False); + lookStream.buf = NULL; + + winRes = GetModuleFileNameW(NULL, sfxPath, MAX_PATH); + if (winRes == 0 || winRes > MAX_PATH) + return 1; + { + cmdLineParams = GetCommandLineW(); + #ifndef UNDER_CE + { + BoolInt quoteMode = False; + for (;; cmdLineParams++) + { + wchar_t c = *cmdLineParams; + if (c == L'\"') + quoteMode = !quoteMode; + else if (c == 0 || (c == L' ' && !quoteMode)) + break; + } + } + #endif + } + + { + unsigned i; + DWORD d; + winRes = GetTempPathW(MAX_PATH, path); + if (winRes == 0 || winRes > MAX_PATH) + return 1; + pathLen = wcslen(path); + d = (GetTickCount() << 12) ^ (GetCurrentThreadId() << 14) ^ GetCurrentProcessId(); + + for (i = 0;; i++, d += GetTickCount()) + { + if (i >= 100) + { + res = SZ_ERROR_FAIL; + break; + } + wcscpy(path + pathLen, L"7z"); + + { + wchar_t *s = path + wcslen(path); + UInt32 value = d; + unsigned k; + for (k = 0; k < 8; k++) + { + unsigned t = value & 0xF; + value >>= 4; + s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); + } + s[k] = '\0'; + } + + if (DoesFileOrDirExist(path)) + continue; + if (CreateDirectoryW(path, NULL)) + { + wcscat(path, WSTRING_PATH_SEPARATOR); + pathLen = wcslen(path); + break; + } + if (GetLastError() != ERROR_ALREADY_EXISTS) + { + res = SZ_ERROR_FAIL; + break; + } + } + + #ifndef UNDER_CE + wcscpy(workCurDir, path); + #endif + if (res != SZ_OK) + errorMessage = "Can't create temp folder"; + } + + if (res != SZ_OK) + { + if (!errorMessage) + errorMessage = "Error"; + PrintErrorMessage(errorMessage); + return 1; + } + + if (InFile_OpenW(&archiveStream.file, sfxPath) != 0) + { + errorMessage = "can not open input file"; + res = SZ_ERROR_FAIL; + } + else + { + UInt64 pos = 0; + if (!FindSignature(&archiveStream.file, &pos)) + res = SZ_ERROR_FAIL; + else if (File_Seek(&archiveStream.file, (Int64 *)&pos, SZ_SEEK_SET) != 0) + res = SZ_ERROR_FAIL; + if (res != 0) + errorMessage = "Can't find 7z archive"; + } + + if (res == SZ_OK) + { + lookStream.buf = (Byte *)ISzAlloc_Alloc(&allocImp, kInputBufSize); + if (!lookStream.buf) + res = SZ_ERROR_MEM; + else + { + lookStream.bufSize = kInputBufSize; + lookStream.realStream = &archiveStream.vt; + LookToRead2_Init(&lookStream); + } + } + + SzArEx_Init(&db); + + if (res == SZ_OK) + { + res = SzArEx_Open(&db, &lookStream.vt, &allocImp, &allocTempImp); + } + + if (res == SZ_OK) + { + UInt32 executeFileIndex = (UInt32)(Int32)-1; + UInt32 minPrice = 1 << 30; + UInt32 i; + UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */ + Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */ + size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */ + + for (i = 0; i < db.NumFiles; i++) + { + size_t offset = 0; + size_t outSizeProcessed = 0; + WCHAR *temp; + + if (SzArEx_GetFileNameUtf16(&db, i, NULL) >= MAX_PATH) + { + res = SZ_ERROR_FAIL; + break; + } + + temp = path + pathLen; + + SzArEx_GetFileNameUtf16(&db, i, (UInt16 *)temp); + { + res = SzArEx_Extract(&db, &lookStream.vt, i, + &blockIndex, &outBuffer, &outBufferSize, + &offset, &outSizeProcessed, + &allocImp, &allocTempImp); + if (res != SZ_OK) + break; + } + { + CSzFile outFile; + size_t processedSize; + size_t j; + size_t nameStartPos = 0; + for (j = 0; temp[j] != 0; j++) + { + if (temp[j] == '/') + { + temp[j] = 0; + MyCreateDir(path); + temp[j] = CHAR_PATH_SEPARATOR; + nameStartPos = j + 1; + } + } + + if (SzArEx_IsDir(&db, i)) + { + MyCreateDir(path); + continue; + } + else + { + unsigned extLen; + const WCHAR *name = temp + nameStartPos; + unsigned len = (unsigned)wcslen(name); + unsigned nameLen = FindExt(temp + nameStartPos, &extLen); + unsigned extPrice = FindItem(kExts, sizeof(kExts) / sizeof(kExts[0]), name + len - extLen, extLen); + unsigned namePrice = FindItem(kNames, sizeof(kNames) / sizeof(kNames[0]), name, nameLen); + + unsigned price = namePrice + extPrice * 64 + (nameStartPos == 0 ? 0 : (1 << 12)); + if (minPrice > price) + { + minPrice = price; + executeFileIndex = i; + useShellExecute = (extPrice != k_EXE_ExtIndex); + } + + if (DoesFileOrDirExist(path)) + { + errorMessage = "Duplicate file"; + res = SZ_ERROR_FAIL; + break; + } + if (OutFile_OpenW(&outFile, path)) + { + errorMessage = "Can't open output file"; + res = SZ_ERROR_FAIL; + break; + } + } + + processedSize = outSizeProcessed; + if (File_Write(&outFile, outBuffer + offset, &processedSize) != 0 || processedSize != outSizeProcessed) + { + errorMessage = "Can't write output file"; + res = SZ_ERROR_FAIL; + } + + #ifdef USE_WINDOWS_FILE + if (SzBitWithVals_Check(&db.MTime, i)) + { + const CNtfsFileTime *t = db.MTime.Vals + i; + FILETIME mTime; + mTime.dwLowDateTime = t->Low; + mTime.dwHighDateTime = t->High; + SetFileTime(outFile.handle, NULL, NULL, &mTime); + } + #endif + + { + SRes res2 = File_Close(&outFile); + if (res != SZ_OK) + break; + if (res2 != SZ_OK) + { + res = res2; + break; + } + } + #ifdef USE_WINDOWS_FILE + if (SzBitWithVals_Check(&db.Attribs, i)) + SetFileAttributesW(path, db.Attribs.Vals[i]); + #endif + } + } + + if (res == SZ_OK) + { + if (executeFileIndex == (UInt32)(Int32)-1) + { + errorMessage = "There is no file to execute"; + res = SZ_ERROR_FAIL; + } + else + { + WCHAR *temp = path + pathLen; + UInt32 j; + SzArEx_GetFileNameUtf16(&db, executeFileIndex, (UInt16 *)temp); + for (j = 0; temp[j] != 0; j++) + if (temp[j] == '/') + temp[j] = CHAR_PATH_SEPARATOR; + } + } + ISzAlloc_Free(&allocImp, outBuffer); + } + + SzArEx_Free(&db, &allocImp); + + ISzAlloc_Free(&allocImp, lookStream.buf); + + File_Close(&archiveStream.file); + + if (res == SZ_OK) + { + HANDLE hProcess = 0; + + #ifndef UNDER_CE + WCHAR oldCurDir[MAX_PATH + 2]; + oldCurDir[0] = 0; + { + DWORD needLen = GetCurrentDirectory(MAX_PATH + 1, oldCurDir); + if (needLen == 0 || needLen > MAX_PATH) + oldCurDir[0] = 0; + SetCurrentDirectory(workCurDir); + } + #endif + + if (useShellExecute) + { + SHELLEXECUTEINFO ei; + UINT32 executeRes; + BOOL success; + + memset(&ei, 0, sizeof(ei)); + ei.cbSize = sizeof(ei); + ei.lpFile = path; + ei.fMask = SEE_MASK_NOCLOSEPROCESS + #ifndef UNDER_CE + | SEE_MASK_FLAG_DDEWAIT + #endif + /* | SEE_MASK_NO_CONSOLE */ + ; + if (wcslen(cmdLineParams) != 0) + ei.lpParameters = cmdLineParams; + ei.nShow = SW_SHOWNORMAL; /* SW_HIDE; */ + success = ShellExecuteEx(&ei); + executeRes = (UINT32)(UINT_PTR)ei.hInstApp; + if (!success || (executeRes <= 32 && executeRes != 0)) /* executeRes = 0 in Windows CE */ + res = SZ_ERROR_FAIL; + else + hProcess = ei.hProcess; + } + else + { + STARTUPINFOW si; + PROCESS_INFORMATION pi; + WCHAR cmdLine[MAX_PATH * 3]; + + wcscpy(cmdLine, path); + wcscat(cmdLine, cmdLineParams); + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + if (CreateProcessW(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == 0) + res = SZ_ERROR_FAIL; + else + { + CloseHandle(pi.hThread); + hProcess = pi.hProcess; + } + } + + if (hProcess != 0) + { + WaitForSingleObject(hProcess, INFINITE); + if (!GetExitCodeProcess(hProcess, &exitCode)) + exitCode = 1; + CloseHandle(hProcess); + } + + #ifndef UNDER_CE + SetCurrentDirectory(oldCurDir); + #endif + } + + path[pathLen] = L'\0'; + RemoveDirWithSubItems(path); + + if (res == SZ_OK) + return (int)exitCode; + + { + if (res == SZ_ERROR_UNSUPPORTED) + errorMessage = "Decoder doesn't support this archive"; + else if (res == SZ_ERROR_MEM) + errorMessage = "Can't allocate required memory"; + else if (res == SZ_ERROR_CRC) + errorMessage = "CRC error"; + else + { + if (!errorMessage) + errorMessage = "ERROR"; + } + + if (errorMessage) + PrintErrorMessage(errorMessage); + } + return 1; +} diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsp b/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsp index be9de6dec..60439a6f7 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsp +++ b/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsp @@ -1,231 +1,231 @@ -# Microsoft Developer Studio Project File - Name="SfxSetup" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=SfxSetup - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "SfxSetup.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "SfxSetup.mak" CFG="SfxSetup - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "SfxSetup - Win32 Release" (based on "Win32 (x86) Application") -!MESSAGE "SfxSetup - Win32 Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "SfxSetup - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x419 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 - -!ELSEIF "$(CFG)" == "SfxSetup - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x419 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "SfxSetup - Win32 Release" -# Name "SfxSetup - Win32 Debug" -# Begin Group "Common" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\7z.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zAlloc.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zAlloc.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zArcIn.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zBuf.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zBuf.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zCrc.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zCrc.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zCrcOpt.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zDec.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zFile.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zFile.h -# End Source File -# Begin Source File - -SOURCE=..\..\7zStream.c -# End Source File -# Begin Source File - -SOURCE=..\..\7zTypes.h -# End Source File -# Begin Source File - -SOURCE=..\..\Bcj2.c -# End Source File -# Begin Source File - -SOURCE=..\..\Bcj2.h -# End Source File -# Begin Source File - -SOURCE=..\..\Bra.c -# End Source File -# Begin Source File - -SOURCE=..\..\Bra.h -# End Source File -# Begin Source File - -SOURCE=..\..\Bra86.c -# End Source File -# Begin Source File - -SOURCE=..\..\BraIA64.c -# End Source File -# Begin Source File - -SOURCE=..\..\CpuArch.c -# End Source File -# Begin Source File - -SOURCE=..\..\CpuArch.h -# End Source File -# Begin Source File - -SOURCE=..\..\Delta.c -# End Source File -# Begin Source File - -SOURCE=..\..\Delta.h -# End Source File -# Begin Source File - -SOURCE=..\..\DllSecur.c -# End Source File -# Begin Source File - -SOURCE=..\..\DllSecur.h -# End Source File -# Begin Source File - -SOURCE=..\..\Lzma2Dec.c -# End Source File -# Begin Source File - -SOURCE=..\..\Lzma2Dec.h -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.c -# End Source File -# Begin Source File - -SOURCE=..\..\LzmaDec.h -# End Source File -# End Group -# Begin Group "Spec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\Precomp.c -# ADD CPP /Yc"Precomp.h" -# End Source File -# Begin Source File - -SOURCE=.\Precomp.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\SfxSetup.c -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="SfxSetup" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=SfxSetup - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "SfxSetup.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "SfxSetup.mak" CFG="SfxSetup - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "SfxSetup - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "SfxSetup - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "SfxSetup - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W4 /WX /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x419 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "SfxSetup - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Yu"Precomp.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x419 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "SfxSetup - Win32 Release" +# Name "SfxSetup - Win32 Debug" +# Begin Group "Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\7z.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zAlloc.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zAlloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zArcIn.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zBuf.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zBuf.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zCrc.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zCrc.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zCrcOpt.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zDec.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zFile.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zFile.h +# End Source File +# Begin Source File + +SOURCE=..\..\7zStream.c +# End Source File +# Begin Source File + +SOURCE=..\..\7zTypes.h +# End Source File +# Begin Source File + +SOURCE=..\..\Bcj2.c +# End Source File +# Begin Source File + +SOURCE=..\..\Bcj2.h +# End Source File +# Begin Source File + +SOURCE=..\..\Bra.c +# End Source File +# Begin Source File + +SOURCE=..\..\Bra.h +# End Source File +# Begin Source File + +SOURCE=..\..\Bra86.c +# End Source File +# Begin Source File + +SOURCE=..\..\BraIA64.c +# End Source File +# Begin Source File + +SOURCE=..\..\CpuArch.c +# End Source File +# Begin Source File + +SOURCE=..\..\CpuArch.h +# End Source File +# Begin Source File + +SOURCE=..\..\Delta.c +# End Source File +# Begin Source File + +SOURCE=..\..\Delta.h +# End Source File +# Begin Source File + +SOURCE=..\..\DllSecur.c +# End Source File +# Begin Source File + +SOURCE=..\..\DllSecur.h +# End Source File +# Begin Source File + +SOURCE=..\..\Lzma2Dec.c +# End Source File +# Begin Source File + +SOURCE=..\..\Lzma2Dec.h +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.c +# End Source File +# Begin Source File + +SOURCE=..\..\LzmaDec.h +# End Source File +# End Group +# Begin Group "Spec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\Precomp.c +# ADD CPP /Yc"Precomp.h" +# End Source File +# Begin Source File + +SOURCE=.\Precomp.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\SfxSetup.c +# End Source File +# End Target +# End Project diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsw b/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsw index 128fcdd3e..ea2311129 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsw +++ b/deps/LZMA-SDK/C/Util/SfxSetup/SfxSetup.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "SfxSetup"=.\SfxSetup.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "SfxSetup"=.\SfxSetup.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/makefile b/deps/LZMA-SDK/C/Util/SfxSetup/makefile index c9f59ccd3..544da67df 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/makefile +++ b/deps/LZMA-SDK/C/Util/SfxSetup/makefile @@ -1,37 +1,37 @@ -PROG = 7zS2.sfx -MY_FIXED = 1 - -C_OBJS = \ - $O\7zAlloc.obj \ - $O\7zArcIn.obj \ - $O\7zBuf.obj \ - $O\7zBuf2.obj \ - $O\7zCrc.obj \ - $O\7zCrcOpt.obj \ - $O\7zFile.obj \ - $O\7zDec.obj \ - $O\7zStream.obj \ - $O\Bcj2.obj \ - $O\Bra.obj \ - $O\Bra86.obj \ - $O\BraIA64.obj \ - $O\CpuArch.obj \ - $O\Delta.obj \ - $O\DllSecur.obj \ - $O\Lzma2Dec.obj \ - $O\LzmaDec.obj \ - -7Z_OBJS = \ - $O\SfxSetup.obj \ - -OBJS = \ - $(7Z_OBJS) \ - $(C_OBJS) \ - $O\resource.res - -!include "../../../CPP/Build.mak" - -$(7Z_OBJS): $(*B).c - $(COMPL_O1) -$(C_OBJS): ../../$(*B).c - $(COMPL_O1) +PROG = 7zS2.sfx +MY_FIXED = 1 + +C_OBJS = \ + $O\7zAlloc.obj \ + $O\7zArcIn.obj \ + $O\7zBuf.obj \ + $O\7zBuf2.obj \ + $O\7zCrc.obj \ + $O\7zCrcOpt.obj \ + $O\7zFile.obj \ + $O\7zDec.obj \ + $O\7zStream.obj \ + $O\Bcj2.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\CpuArch.obj \ + $O\Delta.obj \ + $O\DllSecur.obj \ + $O\Lzma2Dec.obj \ + $O\LzmaDec.obj \ + +7Z_OBJS = \ + $O\SfxSetup.obj \ + +OBJS = \ + $(7Z_OBJS) \ + $(C_OBJS) \ + $O\resource.res + +!include "../../../CPP/Build.mak" + +$(7Z_OBJS): $(*B).c + $(COMPL_O1) +$(C_OBJS): ../../$(*B).c + $(COMPL_O1) diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/makefile_con b/deps/LZMA-SDK/C/Util/SfxSetup/makefile_con index 6f604ed81..d0f835254 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/makefile_con +++ b/deps/LZMA-SDK/C/Util/SfxSetup/makefile_con @@ -1,38 +1,38 @@ -PROG = 7zS2con.sfx -MY_FIXED = 1 -CFLAGS = $(CFLAGS) -D_CONSOLE - -C_OBJS = \ - $O\7zAlloc.obj \ - $O\7zArcIn.obj \ - $O\7zBuf.obj \ - $O\7zBuf2.obj \ - $O\7zCrc.obj \ - $O\7zCrcOpt.obj \ - $O\7zFile.obj \ - $O\7zDec.obj \ - $O\7zStream.obj \ - $O\Bcj2.obj \ - $O\Bra.obj \ - $O\Bra86.obj \ - $O\BraIA64.obj \ - $O\CpuArch.obj \ - $O\Delta.obj \ - $O\DllSecur.obj \ - $O\Lzma2Dec.obj \ - $O\LzmaDec.obj \ - -7Z_OBJS = \ - $O\SfxSetup.obj \ - -OBJS = \ - $(7Z_OBJS) \ - $(C_OBJS) \ - $O\resource.res - -!include "../../../CPP/Build.mak" - -$(7Z_OBJS): $(*B).c - $(COMPL_O1) -$(C_OBJS): ../../$(*B).c - $(COMPL_O1) +PROG = 7zS2con.sfx +MY_FIXED = 1 +CFLAGS = $(CFLAGS) -D_CONSOLE + +C_OBJS = \ + $O\7zAlloc.obj \ + $O\7zArcIn.obj \ + $O\7zBuf.obj \ + $O\7zBuf2.obj \ + $O\7zCrc.obj \ + $O\7zCrcOpt.obj \ + $O\7zFile.obj \ + $O\7zDec.obj \ + $O\7zStream.obj \ + $O\Bcj2.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\CpuArch.obj \ + $O\Delta.obj \ + $O\DllSecur.obj \ + $O\Lzma2Dec.obj \ + $O\LzmaDec.obj \ + +7Z_OBJS = \ + $O\SfxSetup.obj \ + +OBJS = \ + $(7Z_OBJS) \ + $(C_OBJS) \ + $O\resource.res + +!include "../../../CPP/Build.mak" + +$(7Z_OBJS): $(*B).c + $(COMPL_O1) +$(C_OBJS): ../../$(*B).c + $(COMPL_O1) diff --git a/deps/LZMA-SDK/C/Util/SfxSetup/resource.rc b/deps/LZMA-SDK/C/Util/SfxSetup/resource.rc index 64f4e2ce7..0c1637f23 100644 --- a/deps/LZMA-SDK/C/Util/SfxSetup/resource.rc +++ b/deps/LZMA-SDK/C/Util/SfxSetup/resource.rc @@ -1,5 +1,5 @@ -#include "../../7zVersion.rc" - -MY_VERSION_INFO_APP("7z Setup SFX small", "7zS2.sfx") - -1 ICON "setup.ico" +#include "../../7zVersion.rc" + +MY_VERSION_INFO_APP("7z Setup SFX small", "7zS2.sfx") + +1 ICON "setup.ico" diff --git a/deps/LZMA-SDK/C/Xz.c b/deps/LZMA-SDK/C/Xz.c index d6e2596a9..7c53b6007 100644 --- a/deps/LZMA-SDK/C/Xz.c +++ b/deps/LZMA-SDK/C/Xz.c @@ -1,90 +1,90 @@ -/* Xz.c - Xz -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "7zCrc.h" -#include "CpuArch.h" -#include "Xz.h" -#include "XzCrc64.h" - -const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 }; -/* const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' }; */ - -unsigned Xz_WriteVarInt(Byte *buf, UInt64 v) -{ - unsigned i = 0; - do - { - buf[i++] = (Byte)((v & 0x7F) | 0x80); - v >>= 7; - } - while (v != 0); - buf[(size_t)i - 1] &= 0x7F; - return i; -} - -void Xz_Construct(CXzStream *p) -{ - p->numBlocks = 0; - p->blocks = NULL; - p->flags = 0; -} - -void Xz_Free(CXzStream *p, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, p->blocks); - p->numBlocks = 0; - p->blocks = NULL; -} - -unsigned XzFlags_GetCheckSize(CXzStreamFlags f) -{ - unsigned t = XzFlags_GetCheckType(f); - return (t == 0) ? 0 : ((unsigned)4 << ((t - 1) / 3)); -} - -void XzCheck_Init(CXzCheck *p, unsigned mode) -{ - p->mode = mode; - switch (mode) - { - case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break; - case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break; - case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break; - } -} - -void XzCheck_Update(CXzCheck *p, const void *data, size_t size) -{ - switch (p->mode) - { - case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break; - case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break; - case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break; - } -} - -int XzCheck_Final(CXzCheck *p, Byte *digest) -{ - switch (p->mode) - { - case XZ_CHECK_CRC32: - SetUi32(digest, CRC_GET_DIGEST(p->crc)); - break; - case XZ_CHECK_CRC64: - { - int i; - UInt64 v = CRC64_GET_DIGEST(p->crc64); - for (i = 0; i < 8; i++, v >>= 8) - digest[i] = (Byte)(v & 0xFF); - break; - } - case XZ_CHECK_SHA256: - Sha256_Final(&p->sha, digest); - break; - default: - return 0; - } - return 1; -} +/* Xz.c - Xz +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "7zCrc.h" +#include "CpuArch.h" +#include "Xz.h" +#include "XzCrc64.h" + +const Byte XZ_SIG[XZ_SIG_SIZE] = { 0xFD, '7', 'z', 'X', 'Z', 0 }; +/* const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE] = { 'Y', 'Z' }; */ + +unsigned Xz_WriteVarInt(Byte *buf, UInt64 v) +{ + unsigned i = 0; + do + { + buf[i++] = (Byte)((v & 0x7F) | 0x80); + v >>= 7; + } + while (v != 0); + buf[(size_t)i - 1] &= 0x7F; + return i; +} + +void Xz_Construct(CXzStream *p) +{ + p->numBlocks = 0; + p->blocks = NULL; + p->flags = 0; +} + +void Xz_Free(CXzStream *p, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, p->blocks); + p->numBlocks = 0; + p->blocks = NULL; +} + +unsigned XzFlags_GetCheckSize(CXzStreamFlags f) +{ + unsigned t = XzFlags_GetCheckType(f); + return (t == 0) ? 0 : ((unsigned)4 << ((t - 1) / 3)); +} + +void XzCheck_Init(CXzCheck *p, unsigned mode) +{ + p->mode = mode; + switch (mode) + { + case XZ_CHECK_CRC32: p->crc = CRC_INIT_VAL; break; + case XZ_CHECK_CRC64: p->crc64 = CRC64_INIT_VAL; break; + case XZ_CHECK_SHA256: Sha256_Init(&p->sha); break; + } +} + +void XzCheck_Update(CXzCheck *p, const void *data, size_t size) +{ + switch (p->mode) + { + case XZ_CHECK_CRC32: p->crc = CrcUpdate(p->crc, data, size); break; + case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break; + case XZ_CHECK_SHA256: Sha256_Update(&p->sha, (const Byte *)data, size); break; + } +} + +int XzCheck_Final(CXzCheck *p, Byte *digest) +{ + switch (p->mode) + { + case XZ_CHECK_CRC32: + SetUi32(digest, CRC_GET_DIGEST(p->crc)); + break; + case XZ_CHECK_CRC64: + { + int i; + UInt64 v = CRC64_GET_DIGEST(p->crc64); + for (i = 0; i < 8; i++, v >>= 8) + digest[i] = (Byte)(v & 0xFF); + break; + } + case XZ_CHECK_SHA256: + Sha256_Final(&p->sha, digest); + break; + default: + return 0; + } + return 1; +} diff --git a/deps/LZMA-SDK/C/Xz.h b/deps/LZMA-SDK/C/Xz.h index cf9458e39..849b944bf 100644 --- a/deps/LZMA-SDK/C/Xz.h +++ b/deps/LZMA-SDK/C/Xz.h @@ -1,517 +1,517 @@ -/* Xz.h - Xz interface -2021-04-01 : Igor Pavlov : Public domain */ - -#ifndef __XZ_H -#define __XZ_H - -#include "Sha256.h" - -EXTERN_C_BEGIN - -#define XZ_ID_Subblock 1 -#define XZ_ID_Delta 3 -#define XZ_ID_X86 4 -#define XZ_ID_PPC 5 -#define XZ_ID_IA64 6 -#define XZ_ID_ARM 7 -#define XZ_ID_ARMT 8 -#define XZ_ID_SPARC 9 -#define XZ_ID_LZMA2 0x21 - -unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value); -unsigned Xz_WriteVarInt(Byte *buf, UInt64 v); - -/* ---------- xz block ---------- */ - -#define XZ_BLOCK_HEADER_SIZE_MAX 1024 - -#define XZ_NUM_FILTERS_MAX 4 -#define XZ_BF_NUM_FILTERS_MASK 3 -#define XZ_BF_PACK_SIZE (1 << 6) -#define XZ_BF_UNPACK_SIZE (1 << 7) - -#define XZ_FILTER_PROPS_SIZE_MAX 20 - -typedef struct -{ - UInt64 id; - UInt32 propsSize; - Byte props[XZ_FILTER_PROPS_SIZE_MAX]; -} CXzFilter; - -typedef struct -{ - UInt64 packSize; - UInt64 unpackSize; - Byte flags; - CXzFilter filters[XZ_NUM_FILTERS_MAX]; -} CXzBlock; - -#define XzBlock_GetNumFilters(p) (((unsigned)(p)->flags & XZ_BF_NUM_FILTERS_MASK) + 1) -#define XzBlock_HasPackSize(p) (((p)->flags & XZ_BF_PACK_SIZE) != 0) -#define XzBlock_HasUnpackSize(p) (((p)->flags & XZ_BF_UNPACK_SIZE) != 0) -#define XzBlock_HasUnsupportedFlags(p) (((p)->flags & ~(XZ_BF_NUM_FILTERS_MASK | XZ_BF_PACK_SIZE | XZ_BF_UNPACK_SIZE)) != 0) - -SRes XzBlock_Parse(CXzBlock *p, const Byte *header); -SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, BoolInt *isIndex, UInt32 *headerSizeRes); - -/* ---------- xz stream ---------- */ - -#define XZ_SIG_SIZE 6 -#define XZ_FOOTER_SIG_SIZE 2 - -extern const Byte XZ_SIG[XZ_SIG_SIZE]; - -/* -extern const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE]; -*/ - -#define XZ_FOOTER_SIG_0 'Y' -#define XZ_FOOTER_SIG_1 'Z' - -#define XZ_STREAM_FLAGS_SIZE 2 -#define XZ_STREAM_CRC_SIZE 4 - -#define XZ_STREAM_HEADER_SIZE (XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE) -#define XZ_STREAM_FOOTER_SIZE (XZ_FOOTER_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE + 4) - -#define XZ_CHECK_MASK 0xF -#define XZ_CHECK_NO 0 -#define XZ_CHECK_CRC32 1 -#define XZ_CHECK_CRC64 4 -#define XZ_CHECK_SHA256 10 - -typedef struct -{ - unsigned mode; - UInt32 crc; - UInt64 crc64; - CSha256 sha; -} CXzCheck; - -void XzCheck_Init(CXzCheck *p, unsigned mode); -void XzCheck_Update(CXzCheck *p, const void *data, size_t size); -int XzCheck_Final(CXzCheck *p, Byte *digest); - -typedef UInt16 CXzStreamFlags; - -#define XzFlags_IsSupported(f) ((f) <= XZ_CHECK_MASK) -#define XzFlags_GetCheckType(f) ((f) & XZ_CHECK_MASK) -#define XzFlags_HasDataCrc32(f) (Xz_GetCheckType(f) == XZ_CHECK_CRC32) -unsigned XzFlags_GetCheckSize(CXzStreamFlags f); - -SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf); -SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream); - -typedef struct -{ - UInt64 unpackSize; - UInt64 totalSize; -} CXzBlockSizes; - -typedef struct -{ - CXzStreamFlags flags; - size_t numBlocks; - CXzBlockSizes *blocks; - UInt64 startOffset; -} CXzStream; - -void Xz_Construct(CXzStream *p); -void Xz_Free(CXzStream *p, ISzAllocPtr alloc); - -#define XZ_SIZE_OVERFLOW ((UInt64)(Int64)-1) - -UInt64 Xz_GetUnpackSize(const CXzStream *p); -UInt64 Xz_GetPackSize(const CXzStream *p); - -typedef struct -{ - size_t num; - size_t numAllocated; - CXzStream *streams; -} CXzs; - -void Xzs_Construct(CXzs *p); -void Xzs_Free(CXzs *p, ISzAllocPtr alloc); -SRes Xzs_ReadBackward(CXzs *p, ILookInStream *inStream, Int64 *startOffset, ICompressProgress *progress, ISzAllocPtr alloc); - -UInt64 Xzs_GetNumBlocks(const CXzs *p); -UInt64 Xzs_GetUnpackSize(const CXzs *p); - - -// ECoderStatus values are identical to ELzmaStatus values of LZMA2 decoder - -typedef enum -{ - CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */ - CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ - CODER_STATUS_NOT_FINISHED, /* stream was not finished */ - CODER_STATUS_NEEDS_MORE_INPUT /* you must provide more input bytes */ -} ECoderStatus; - - -// ECoderFinishMode values are identical to ELzmaFinishMode - -typedef enum -{ - CODER_FINISH_ANY, /* finish at any point */ - CODER_FINISH_END /* block must be finished at the end */ -} ECoderFinishMode; - - -typedef struct _IStateCoder -{ - void *p; - void (*Free)(void *p, ISzAllocPtr alloc); - SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAllocPtr alloc); - void (*Init)(void *p); - SRes (*Code2)(void *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - int srcWasFinished, ECoderFinishMode finishMode, - // int *wasFinished, - ECoderStatus *status); - SizeT (*Filter)(void *p, Byte *data, SizeT size); -} IStateCoder; - - - -#define MIXCODER_NUM_FILTERS_MAX 4 - -typedef struct -{ - ISzAllocPtr alloc; - Byte *buf; - unsigned numCoders; - - Byte *outBuf; - size_t outBufSize; - size_t outWritten; // is equal to lzmaDecoder.dicPos (in outBuf mode) - BoolInt wasFinished; - SRes res; - ECoderStatus status; - // BoolInt SingleBufMode; - - int finished[MIXCODER_NUM_FILTERS_MAX - 1]; - size_t pos[MIXCODER_NUM_FILTERS_MAX - 1]; - size_t size[MIXCODER_NUM_FILTERS_MAX - 1]; - UInt64 ids[MIXCODER_NUM_FILTERS_MAX]; - SRes results[MIXCODER_NUM_FILTERS_MAX]; - IStateCoder coders[MIXCODER_NUM_FILTERS_MAX]; -} CMixCoder; - - -typedef enum -{ - XZ_STATE_STREAM_HEADER, - XZ_STATE_STREAM_INDEX, - XZ_STATE_STREAM_INDEX_CRC, - XZ_STATE_STREAM_FOOTER, - XZ_STATE_STREAM_PADDING, - XZ_STATE_BLOCK_HEADER, - XZ_STATE_BLOCK, - XZ_STATE_BLOCK_FOOTER -} EXzState; - - -typedef struct -{ - EXzState state; - UInt32 pos; - unsigned alignPos; - unsigned indexPreSize; - - CXzStreamFlags streamFlags; - - UInt32 blockHeaderSize; - UInt64 packSize; - UInt64 unpackSize; - - UInt64 numBlocks; // number of finished blocks in current stream - UInt64 indexSize; - UInt64 indexPos; - UInt64 padSize; - - UInt64 numStartedStreams; - UInt64 numFinishedStreams; - UInt64 numTotalBlocks; - - UInt32 crc; - CMixCoder decoder; - CXzBlock block; - CXzCheck check; - CSha256 sha; - - BoolInt parseMode; - BoolInt headerParsedOk; - BoolInt decodeToStreamSignature; - unsigned decodeOnlyOneBlock; - - Byte *outBuf; - size_t outBufSize; - size_t outDataWritten; // the size of data in (outBuf) that were fully unpacked - - Byte shaDigest[SHA256_DIGEST_SIZE]; - Byte buf[XZ_BLOCK_HEADER_SIZE_MAX]; -} CXzUnpacker; - -/* alloc : aligned for cache line allocation is better */ -void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc); -void XzUnpacker_Init(CXzUnpacker *p); -void XzUnpacker_SetOutBuf(CXzUnpacker *p, Byte *outBuf, size_t outBufSize); -void XzUnpacker_Free(CXzUnpacker *p); - -/* - XzUnpacker - The sequence for decoding functions: - { - XzUnpacker_Construct() - [Decoding_Calls] - XzUnpacker_Free() - } - - [Decoding_Calls] - - There are 3 types of interfaces for [Decoding_Calls] calls: - - Interface-1 : Partial output buffers: - { - XzUnpacker_Init() - for() - { - XzUnpacker_Code(); - } - XzUnpacker_IsStreamWasFinished() - } - - Interface-2 : Direct output buffer: - Use it, if you know exact size of decoded data, and you need - whole xz unpacked data in one output buffer. - xz unpacker doesn't allocate additional buffer for lzma2 dictionary in that mode. - { - XzUnpacker_Init() - XzUnpacker_SetOutBufMode(); // to set output buffer and size - for() - { - XzUnpacker_Code(); // (dest = NULL) in XzUnpacker_Code() - } - XzUnpacker_IsStreamWasFinished() - } - - Interface-3 : Direct output buffer : One call full decoding - It unpacks whole input buffer to output buffer in one call. - It uses Interface-2 internally. - { - XzUnpacker_CodeFull() - XzUnpacker_IsStreamWasFinished() - } -*/ - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - CODER_FINISH_ANY - use smallest number of input bytes - CODER_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - CODER_STATUS_NOT_FINISHED, - CODER_STATUS_NEEDS_MORE_INPUT - the decoder can return it in two cases: - 1) it needs more input data to finish current xz stream - 2) xz stream was finished successfully. But the decoder supports multiple - concatented xz streams. So it expects more input data for new xz streams. - Call XzUnpacker_IsStreamWasFinished() to check that latest xz stream was finished successfully. - - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_DATA - Data error - SZ_ERROR_UNSUPPORTED - Unsupported method or method properties - SZ_ERROR_CRC - CRC error - // SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). - - SZ_ERROR_NO_ARCHIVE - the error with xz Stream Header with one of the following reasons: - - xz Stream Signature failure - - CRC32 of xz Stream Header is failed - - The size of Stream padding is not multiple of four bytes. - It's possible to get that error, if xz stream was finished and the stream - contains some another data. In that case you can call XzUnpacker_GetExtraSize() - function to get real size of xz stream. -*/ - - -SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, int srcFinished, - ECoderFinishMode finishMode, ECoderStatus *status); - -SRes XzUnpacker_CodeFull(CXzUnpacker *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, - ECoderFinishMode finishMode, ECoderStatus *status); - -/* -If you decode full xz stream(s), then you can call XzUnpacker_IsStreamWasFinished() -after successful XzUnpacker_CodeFull() or after last call of XzUnpacker_Code(). -*/ - -BoolInt XzUnpacker_IsStreamWasFinished(const CXzUnpacker *p); - -/* -XzUnpacker_GetExtraSize() returns then number of unconfirmed bytes, - if it's in (XZ_STATE_STREAM_HEADER) state or in (XZ_STATE_STREAM_PADDING) state. -These bytes can be some data after xz archive, or -it can be start of new xz stream. - -Call XzUnpacker_GetExtraSize() after XzUnpacker_Code() function to detect real size of -xz stream in two cases, if XzUnpacker_Code() returns: - res == SZ_OK && status == CODER_STATUS_NEEDS_MORE_INPUT - res == SZ_ERROR_NO_ARCHIVE -*/ - -UInt64 XzUnpacker_GetExtraSize(const CXzUnpacker *p); - - -/* - for random block decoding: - XzUnpacker_Init(); - set CXzUnpacker::streamFlags - XzUnpacker_PrepareToRandomBlockDecoding() - loop - { - XzUnpacker_Code() - XzUnpacker_IsBlockFinished() - } -*/ - -void XzUnpacker_PrepareToRandomBlockDecoding(CXzUnpacker *p); -BoolInt XzUnpacker_IsBlockFinished(const CXzUnpacker *p); - -#define XzUnpacker_GetPackSizeForIndex(p) ((p)->packSize + (p)->blockHeaderSize + XzFlags_GetCheckSize((p)->streamFlags)) - - - - - - -/* ---- Single-Thread and Multi-Thread xz Decoding with Input/Output Streams ---- */ - -/* - if (CXzDecMtProps::numThreads > 1), the decoder can try to use - Multi-Threading. The decoder analyses xz block header, and if - there are pack size and unpack size values stored in xz block header, - the decoder reads compressed data of block to internal buffers, - and then it can start parallel decoding, if there are another blocks. - The decoder can switch back to Single-Thread decoding after some conditions. - - The sequence of calls for xz decoding with in/out Streams: - { - XzDecMt_Create() - XzDecMtProps_Init(XzDecMtProps) to set default values of properties - // then you can change some XzDecMtProps parameters with required values - // here you can set the number of threads and (memUseMax) - the maximum - Memory usage for multithreading decoding. - for() - { - XzDecMt_Decode() // one call per one file - } - XzDecMt_Destroy() - } -*/ - - -typedef struct -{ - size_t inBufSize_ST; // size of input buffer for Single-Thread decoding - size_t outStep_ST; // size of output buffer for Single-Thread decoding - BoolInt ignoreErrors; // if set to 1, the decoder can ignore some errors and it skips broken parts of data. - - #ifndef _7ZIP_ST - unsigned numThreads; // the number of threads for Multi-Thread decoding. if (umThreads == 1) it will use Single-thread decoding - size_t inBufSize_MT; // size of small input data buffers for Multi-Thread decoding. Big number of such small buffers can be created - size_t memUseMax; // the limit of total memory usage for Multi-Thread decoding. - // it's recommended to set (memUseMax) manually to value that is smaller of total size of RAM in computer. - #endif -} CXzDecMtProps; - -void XzDecMtProps_Init(CXzDecMtProps *p); - - -typedef void * CXzDecMtHandle; - -/* - alloc : XzDecMt uses CAlignOffsetAlloc internally for addresses allocated by (alloc). - allocMid : for big allocations, aligned allocation is better -*/ - -CXzDecMtHandle XzDecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid); -void XzDecMt_Destroy(CXzDecMtHandle p); - - -typedef struct -{ - Byte UnpackSize_Defined; - Byte NumStreams_Defined; - Byte NumBlocks_Defined; - - Byte DataAfterEnd; // there are some additional data after good xz streams, and that data is not new xz stream. - Byte DecodingTruncated; // Decoding was Truncated, we need only partial output data - - UInt64 InSize; // pack size processed. That value doesn't include the data after - // end of xz stream, if that data was not correct - UInt64 OutSize; - - UInt64 NumStreams; - UInt64 NumBlocks; - - SRes DecodeRes; // the error code of xz streams data decoding - SRes ReadRes; // error code from ISeqInStream:Read() - SRes ProgressRes; // error code from ICompressProgress:Progress() - - SRes CombinedRes; // Combined result error code that shows main rusult - // = S_OK, if there is no error. - // but check also (DataAfterEnd) that can show additional minor errors. - - SRes CombinedRes_Type; // = SZ_ERROR_READ, if error from ISeqInStream - // = SZ_ERROR_PROGRESS, if error from ICompressProgress - // = SZ_ERROR_WRITE, if error from ISeqOutStream - // = SZ_ERROR_* codes for decoding -} CXzStatInfo; - -void XzStatInfo_Clear(CXzStatInfo *p); - -/* - -XzDecMt_Decode() -SRes: it's combined decoding result. It also is equal to stat->CombinedRes. - - SZ_OK - no error - check also output value in (stat->DataAfterEnd) - that can show additional possible error - - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_NO_ARCHIVE - is not xz archive - SZ_ERROR_ARCHIVE - Headers error - SZ_ERROR_DATA - Data Error - SZ_ERROR_UNSUPPORTED - Unsupported method or method properties - SZ_ERROR_CRC - CRC Error - SZ_ERROR_INPUT_EOF - it needs more input data - SZ_ERROR_WRITE - ISeqOutStream error - (SZ_ERROR_READ) - ISeqInStream errors - (SZ_ERROR_PROGRESS) - ICompressProgress errors - // SZ_ERROR_THREAD - error in multi-threading functions - MY_SRes_HRESULT_FROM_WRes(WRes_error) - error in multi-threading function -*/ - -SRes XzDecMt_Decode(CXzDecMtHandle p, - const CXzDecMtProps *props, - const UInt64 *outDataSize, // NULL means undefined - int finishMode, // 0 - partial unpacking is allowed, 1 - xz stream(s) must be finished - ISeqOutStream *outStream, - // Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - // const Byte *inData, size_t inDataSize, - CXzStatInfo *stat, // out: decoding results and statistics - int *isMT, // out: 0 means that ST (Single-Thread) version was used - // 1 means that MT (Multi-Thread) version was used - ICompressProgress *progress); - -EXTERN_C_END - -#endif +/* Xz.h - Xz interface +2021-04-01 : Igor Pavlov : Public domain */ + +#ifndef __XZ_H +#define __XZ_H + +#include "Sha256.h" + +EXTERN_C_BEGIN + +#define XZ_ID_Subblock 1 +#define XZ_ID_Delta 3 +#define XZ_ID_X86 4 +#define XZ_ID_PPC 5 +#define XZ_ID_IA64 6 +#define XZ_ID_ARM 7 +#define XZ_ID_ARMT 8 +#define XZ_ID_SPARC 9 +#define XZ_ID_LZMA2 0x21 + +unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value); +unsigned Xz_WriteVarInt(Byte *buf, UInt64 v); + +/* ---------- xz block ---------- */ + +#define XZ_BLOCK_HEADER_SIZE_MAX 1024 + +#define XZ_NUM_FILTERS_MAX 4 +#define XZ_BF_NUM_FILTERS_MASK 3 +#define XZ_BF_PACK_SIZE (1 << 6) +#define XZ_BF_UNPACK_SIZE (1 << 7) + +#define XZ_FILTER_PROPS_SIZE_MAX 20 + +typedef struct +{ + UInt64 id; + UInt32 propsSize; + Byte props[XZ_FILTER_PROPS_SIZE_MAX]; +} CXzFilter; + +typedef struct +{ + UInt64 packSize; + UInt64 unpackSize; + Byte flags; + CXzFilter filters[XZ_NUM_FILTERS_MAX]; +} CXzBlock; + +#define XzBlock_GetNumFilters(p) (((unsigned)(p)->flags & XZ_BF_NUM_FILTERS_MASK) + 1) +#define XzBlock_HasPackSize(p) (((p)->flags & XZ_BF_PACK_SIZE) != 0) +#define XzBlock_HasUnpackSize(p) (((p)->flags & XZ_BF_UNPACK_SIZE) != 0) +#define XzBlock_HasUnsupportedFlags(p) (((p)->flags & ~(XZ_BF_NUM_FILTERS_MASK | XZ_BF_PACK_SIZE | XZ_BF_UNPACK_SIZE)) != 0) + +SRes XzBlock_Parse(CXzBlock *p, const Byte *header); +SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, BoolInt *isIndex, UInt32 *headerSizeRes); + +/* ---------- xz stream ---------- */ + +#define XZ_SIG_SIZE 6 +#define XZ_FOOTER_SIG_SIZE 2 + +extern const Byte XZ_SIG[XZ_SIG_SIZE]; + +/* +extern const Byte XZ_FOOTER_SIG[XZ_FOOTER_SIG_SIZE]; +*/ + +#define XZ_FOOTER_SIG_0 'Y' +#define XZ_FOOTER_SIG_1 'Z' + +#define XZ_STREAM_FLAGS_SIZE 2 +#define XZ_STREAM_CRC_SIZE 4 + +#define XZ_STREAM_HEADER_SIZE (XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE) +#define XZ_STREAM_FOOTER_SIZE (XZ_FOOTER_SIG_SIZE + XZ_STREAM_FLAGS_SIZE + XZ_STREAM_CRC_SIZE + 4) + +#define XZ_CHECK_MASK 0xF +#define XZ_CHECK_NO 0 +#define XZ_CHECK_CRC32 1 +#define XZ_CHECK_CRC64 4 +#define XZ_CHECK_SHA256 10 + +typedef struct +{ + unsigned mode; + UInt32 crc; + UInt64 crc64; + CSha256 sha; +} CXzCheck; + +void XzCheck_Init(CXzCheck *p, unsigned mode); +void XzCheck_Update(CXzCheck *p, const void *data, size_t size); +int XzCheck_Final(CXzCheck *p, Byte *digest); + +typedef UInt16 CXzStreamFlags; + +#define XzFlags_IsSupported(f) ((f) <= XZ_CHECK_MASK) +#define XzFlags_GetCheckType(f) ((f) & XZ_CHECK_MASK) +#define XzFlags_HasDataCrc32(f) (Xz_GetCheckType(f) == XZ_CHECK_CRC32) +unsigned XzFlags_GetCheckSize(CXzStreamFlags f); + +SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf); +SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream); + +typedef struct +{ + UInt64 unpackSize; + UInt64 totalSize; +} CXzBlockSizes; + +typedef struct +{ + CXzStreamFlags flags; + size_t numBlocks; + CXzBlockSizes *blocks; + UInt64 startOffset; +} CXzStream; + +void Xz_Construct(CXzStream *p); +void Xz_Free(CXzStream *p, ISzAllocPtr alloc); + +#define XZ_SIZE_OVERFLOW ((UInt64)(Int64)-1) + +UInt64 Xz_GetUnpackSize(const CXzStream *p); +UInt64 Xz_GetPackSize(const CXzStream *p); + +typedef struct +{ + size_t num; + size_t numAllocated; + CXzStream *streams; +} CXzs; + +void Xzs_Construct(CXzs *p); +void Xzs_Free(CXzs *p, ISzAllocPtr alloc); +SRes Xzs_ReadBackward(CXzs *p, ILookInStream *inStream, Int64 *startOffset, ICompressProgress *progress, ISzAllocPtr alloc); + +UInt64 Xzs_GetNumBlocks(const CXzs *p); +UInt64 Xzs_GetUnpackSize(const CXzs *p); + + +// ECoderStatus values are identical to ELzmaStatus values of LZMA2 decoder + +typedef enum +{ + CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */ + CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ + CODER_STATUS_NOT_FINISHED, /* stream was not finished */ + CODER_STATUS_NEEDS_MORE_INPUT /* you must provide more input bytes */ +} ECoderStatus; + + +// ECoderFinishMode values are identical to ELzmaFinishMode + +typedef enum +{ + CODER_FINISH_ANY, /* finish at any point */ + CODER_FINISH_END /* block must be finished at the end */ +} ECoderFinishMode; + + +typedef struct _IStateCoder +{ + void *p; + void (*Free)(void *p, ISzAllocPtr alloc); + SRes (*SetProps)(void *p, const Byte *props, size_t propSize, ISzAllocPtr alloc); + void (*Init)(void *p); + SRes (*Code2)(void *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + int srcWasFinished, ECoderFinishMode finishMode, + // int *wasFinished, + ECoderStatus *status); + SizeT (*Filter)(void *p, Byte *data, SizeT size); +} IStateCoder; + + + +#define MIXCODER_NUM_FILTERS_MAX 4 + +typedef struct +{ + ISzAllocPtr alloc; + Byte *buf; + unsigned numCoders; + + Byte *outBuf; + size_t outBufSize; + size_t outWritten; // is equal to lzmaDecoder.dicPos (in outBuf mode) + BoolInt wasFinished; + SRes res; + ECoderStatus status; + // BoolInt SingleBufMode; + + int finished[MIXCODER_NUM_FILTERS_MAX - 1]; + size_t pos[MIXCODER_NUM_FILTERS_MAX - 1]; + size_t size[MIXCODER_NUM_FILTERS_MAX - 1]; + UInt64 ids[MIXCODER_NUM_FILTERS_MAX]; + SRes results[MIXCODER_NUM_FILTERS_MAX]; + IStateCoder coders[MIXCODER_NUM_FILTERS_MAX]; +} CMixCoder; + + +typedef enum +{ + XZ_STATE_STREAM_HEADER, + XZ_STATE_STREAM_INDEX, + XZ_STATE_STREAM_INDEX_CRC, + XZ_STATE_STREAM_FOOTER, + XZ_STATE_STREAM_PADDING, + XZ_STATE_BLOCK_HEADER, + XZ_STATE_BLOCK, + XZ_STATE_BLOCK_FOOTER +} EXzState; + + +typedef struct +{ + EXzState state; + UInt32 pos; + unsigned alignPos; + unsigned indexPreSize; + + CXzStreamFlags streamFlags; + + UInt32 blockHeaderSize; + UInt64 packSize; + UInt64 unpackSize; + + UInt64 numBlocks; // number of finished blocks in current stream + UInt64 indexSize; + UInt64 indexPos; + UInt64 padSize; + + UInt64 numStartedStreams; + UInt64 numFinishedStreams; + UInt64 numTotalBlocks; + + UInt32 crc; + CMixCoder decoder; + CXzBlock block; + CXzCheck check; + CSha256 sha; + + BoolInt parseMode; + BoolInt headerParsedOk; + BoolInt decodeToStreamSignature; + unsigned decodeOnlyOneBlock; + + Byte *outBuf; + size_t outBufSize; + size_t outDataWritten; // the size of data in (outBuf) that were fully unpacked + + Byte shaDigest[SHA256_DIGEST_SIZE]; + Byte buf[XZ_BLOCK_HEADER_SIZE_MAX]; +} CXzUnpacker; + +/* alloc : aligned for cache line allocation is better */ +void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc); +void XzUnpacker_Init(CXzUnpacker *p); +void XzUnpacker_SetOutBuf(CXzUnpacker *p, Byte *outBuf, size_t outBufSize); +void XzUnpacker_Free(CXzUnpacker *p); + +/* + XzUnpacker + The sequence for decoding functions: + { + XzUnpacker_Construct() + [Decoding_Calls] + XzUnpacker_Free() + } + + [Decoding_Calls] + + There are 3 types of interfaces for [Decoding_Calls] calls: + + Interface-1 : Partial output buffers: + { + XzUnpacker_Init() + for() + { + XzUnpacker_Code(); + } + XzUnpacker_IsStreamWasFinished() + } + + Interface-2 : Direct output buffer: + Use it, if you know exact size of decoded data, and you need + whole xz unpacked data in one output buffer. + xz unpacker doesn't allocate additional buffer for lzma2 dictionary in that mode. + { + XzUnpacker_Init() + XzUnpacker_SetOutBufMode(); // to set output buffer and size + for() + { + XzUnpacker_Code(); // (dest = NULL) in XzUnpacker_Code() + } + XzUnpacker_IsStreamWasFinished() + } + + Interface-3 : Direct output buffer : One call full decoding + It unpacks whole input buffer to output buffer in one call. + It uses Interface-2 internally. + { + XzUnpacker_CodeFull() + XzUnpacker_IsStreamWasFinished() + } +*/ + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen). + CODER_FINISH_ANY - use smallest number of input bytes + CODER_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + CODER_STATUS_NOT_FINISHED, + CODER_STATUS_NEEDS_MORE_INPUT - the decoder can return it in two cases: + 1) it needs more input data to finish current xz stream + 2) xz stream was finished successfully. But the decoder supports multiple + concatented xz streams. So it expects more input data for new xz streams. + Call XzUnpacker_IsStreamWasFinished() to check that latest xz stream was finished successfully. + + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_DATA - Data error + SZ_ERROR_UNSUPPORTED - Unsupported method or method properties + SZ_ERROR_CRC - CRC error + // SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). + + SZ_ERROR_NO_ARCHIVE - the error with xz Stream Header with one of the following reasons: + - xz Stream Signature failure + - CRC32 of xz Stream Header is failed + - The size of Stream padding is not multiple of four bytes. + It's possible to get that error, if xz stream was finished and the stream + contains some another data. In that case you can call XzUnpacker_GetExtraSize() + function to get real size of xz stream. +*/ + + +SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, int srcFinished, + ECoderFinishMode finishMode, ECoderStatus *status); + +SRes XzUnpacker_CodeFull(CXzUnpacker *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, + ECoderFinishMode finishMode, ECoderStatus *status); + +/* +If you decode full xz stream(s), then you can call XzUnpacker_IsStreamWasFinished() +after successful XzUnpacker_CodeFull() or after last call of XzUnpacker_Code(). +*/ + +BoolInt XzUnpacker_IsStreamWasFinished(const CXzUnpacker *p); + +/* +XzUnpacker_GetExtraSize() returns then number of unconfirmed bytes, + if it's in (XZ_STATE_STREAM_HEADER) state or in (XZ_STATE_STREAM_PADDING) state. +These bytes can be some data after xz archive, or +it can be start of new xz stream. + +Call XzUnpacker_GetExtraSize() after XzUnpacker_Code() function to detect real size of +xz stream in two cases, if XzUnpacker_Code() returns: + res == SZ_OK && status == CODER_STATUS_NEEDS_MORE_INPUT + res == SZ_ERROR_NO_ARCHIVE +*/ + +UInt64 XzUnpacker_GetExtraSize(const CXzUnpacker *p); + + +/* + for random block decoding: + XzUnpacker_Init(); + set CXzUnpacker::streamFlags + XzUnpacker_PrepareToRandomBlockDecoding() + loop + { + XzUnpacker_Code() + XzUnpacker_IsBlockFinished() + } +*/ + +void XzUnpacker_PrepareToRandomBlockDecoding(CXzUnpacker *p); +BoolInt XzUnpacker_IsBlockFinished(const CXzUnpacker *p); + +#define XzUnpacker_GetPackSizeForIndex(p) ((p)->packSize + (p)->blockHeaderSize + XzFlags_GetCheckSize((p)->streamFlags)) + + + + + + +/* ---- Single-Thread and Multi-Thread xz Decoding with Input/Output Streams ---- */ + +/* + if (CXzDecMtProps::numThreads > 1), the decoder can try to use + Multi-Threading. The decoder analyses xz block header, and if + there are pack size and unpack size values stored in xz block header, + the decoder reads compressed data of block to internal buffers, + and then it can start parallel decoding, if there are another blocks. + The decoder can switch back to Single-Thread decoding after some conditions. + + The sequence of calls for xz decoding with in/out Streams: + { + XzDecMt_Create() + XzDecMtProps_Init(XzDecMtProps) to set default values of properties + // then you can change some XzDecMtProps parameters with required values + // here you can set the number of threads and (memUseMax) - the maximum + Memory usage for multithreading decoding. + for() + { + XzDecMt_Decode() // one call per one file + } + XzDecMt_Destroy() + } +*/ + + +typedef struct +{ + size_t inBufSize_ST; // size of input buffer for Single-Thread decoding + size_t outStep_ST; // size of output buffer for Single-Thread decoding + BoolInt ignoreErrors; // if set to 1, the decoder can ignore some errors and it skips broken parts of data. + + #ifndef _7ZIP_ST + unsigned numThreads; // the number of threads for Multi-Thread decoding. if (umThreads == 1) it will use Single-thread decoding + size_t inBufSize_MT; // size of small input data buffers for Multi-Thread decoding. Big number of such small buffers can be created + size_t memUseMax; // the limit of total memory usage for Multi-Thread decoding. + // it's recommended to set (memUseMax) manually to value that is smaller of total size of RAM in computer. + #endif +} CXzDecMtProps; + +void XzDecMtProps_Init(CXzDecMtProps *p); + + +typedef void * CXzDecMtHandle; + +/* + alloc : XzDecMt uses CAlignOffsetAlloc internally for addresses allocated by (alloc). + allocMid : for big allocations, aligned allocation is better +*/ + +CXzDecMtHandle XzDecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid); +void XzDecMt_Destroy(CXzDecMtHandle p); + + +typedef struct +{ + Byte UnpackSize_Defined; + Byte NumStreams_Defined; + Byte NumBlocks_Defined; + + Byte DataAfterEnd; // there are some additional data after good xz streams, and that data is not new xz stream. + Byte DecodingTruncated; // Decoding was Truncated, we need only partial output data + + UInt64 InSize; // pack size processed. That value doesn't include the data after + // end of xz stream, if that data was not correct + UInt64 OutSize; + + UInt64 NumStreams; + UInt64 NumBlocks; + + SRes DecodeRes; // the error code of xz streams data decoding + SRes ReadRes; // error code from ISeqInStream:Read() + SRes ProgressRes; // error code from ICompressProgress:Progress() + + SRes CombinedRes; // Combined result error code that shows main rusult + // = S_OK, if there is no error. + // but check also (DataAfterEnd) that can show additional minor errors. + + SRes CombinedRes_Type; // = SZ_ERROR_READ, if error from ISeqInStream + // = SZ_ERROR_PROGRESS, if error from ICompressProgress + // = SZ_ERROR_WRITE, if error from ISeqOutStream + // = SZ_ERROR_* codes for decoding +} CXzStatInfo; + +void XzStatInfo_Clear(CXzStatInfo *p); + +/* + +XzDecMt_Decode() +SRes: it's combined decoding result. It also is equal to stat->CombinedRes. + + SZ_OK - no error + check also output value in (stat->DataAfterEnd) + that can show additional possible error + + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_NO_ARCHIVE - is not xz archive + SZ_ERROR_ARCHIVE - Headers error + SZ_ERROR_DATA - Data Error + SZ_ERROR_UNSUPPORTED - Unsupported method or method properties + SZ_ERROR_CRC - CRC Error + SZ_ERROR_INPUT_EOF - it needs more input data + SZ_ERROR_WRITE - ISeqOutStream error + (SZ_ERROR_READ) - ISeqInStream errors + (SZ_ERROR_PROGRESS) - ICompressProgress errors + // SZ_ERROR_THREAD - error in multi-threading functions + MY_SRes_HRESULT_FROM_WRes(WRes_error) - error in multi-threading function +*/ + +SRes XzDecMt_Decode(CXzDecMtHandle p, + const CXzDecMtProps *props, + const UInt64 *outDataSize, // NULL means undefined + int finishMode, // 0 - partial unpacking is allowed, 1 - xz stream(s) must be finished + ISeqOutStream *outStream, + // Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + // const Byte *inData, size_t inDataSize, + CXzStatInfo *stat, // out: decoding results and statistics + int *isMT, // out: 0 means that ST (Single-Thread) version was used + // 1 means that MT (Multi-Thread) version was used + ICompressProgress *progress); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/XzCrc64.c b/deps/LZMA-SDK/C/XzCrc64.c index e9ca9ec26..b6d02cbeb 100644 --- a/deps/LZMA-SDK/C/XzCrc64.c +++ b/deps/LZMA-SDK/C/XzCrc64.c @@ -1,86 +1,86 @@ -/* XzCrc64.c -- CRC64 calculation -2017-05-23 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "XzCrc64.h" -#include "CpuArch.h" - -#define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42) - -#ifdef MY_CPU_LE - #define CRC64_NUM_TABLES 4 -#else - #define CRC64_NUM_TABLES 5 - #define CRC_UINT64_SWAP(v) \ - ((v >> 56) \ - | ((v >> 40) & ((UInt64)0xFF << 8)) \ - | ((v >> 24) & ((UInt64)0xFF << 16)) \ - | ((v >> 8) & ((UInt64)0xFF << 24)) \ - | ((v << 8) & ((UInt64)0xFF << 32)) \ - | ((v << 24) & ((UInt64)0xFF << 40)) \ - | ((v << 40) & ((UInt64)0xFF << 48)) \ - | ((v << 56))) - - UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); -#endif - -#ifndef MY_CPU_BE - UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); -#endif - -typedef UInt64 (MY_FAST_CALL *CRC64_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table); - -static CRC64_FUNC g_Crc64Update; -UInt64 g_Crc64Table[256 * CRC64_NUM_TABLES]; - -UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size) -{ - return g_Crc64Update(v, data, size, g_Crc64Table); -} - -UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size) -{ - return g_Crc64Update(CRC64_INIT_VAL, data, size, g_Crc64Table) ^ CRC64_INIT_VAL; -} - -void MY_FAST_CALL Crc64GenerateTable() -{ - UInt32 i; - for (i = 0; i < 256; i++) - { - UInt64 r = i; - unsigned j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrc64Poly & ((UInt64)0 - (r & 1))); - g_Crc64Table[i] = r; - } - for (i = 256; i < 256 * CRC64_NUM_TABLES; i++) - { - UInt64 r = g_Crc64Table[(size_t)i - 256]; - g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8); - } - - #ifdef MY_CPU_LE - - g_Crc64Update = XzCrc64UpdateT4; - - #else - { - #ifndef MY_CPU_BE - UInt32 k = 1; - if (*(const Byte *)&k == 1) - g_Crc64Update = XzCrc64UpdateT4; - else - #endif - { - for (i = 256 * CRC64_NUM_TABLES - 1; i >= 256; i--) - { - UInt64 x = g_Crc64Table[(size_t)i - 256]; - g_Crc64Table[i] = CRC_UINT64_SWAP(x); - } - g_Crc64Update = XzCrc64UpdateT1_BeT4; - } - } - #endif -} +/* XzCrc64.c -- CRC64 calculation +2017-05-23 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "XzCrc64.h" +#include "CpuArch.h" + +#define kCrc64Poly UINT64_CONST(0xC96C5795D7870F42) + +#ifdef MY_CPU_LE + #define CRC64_NUM_TABLES 4 +#else + #define CRC64_NUM_TABLES 5 + #define CRC_UINT64_SWAP(v) \ + ((v >> 56) \ + | ((v >> 40) & ((UInt64)0xFF << 8)) \ + | ((v >> 24) & ((UInt64)0xFF << 16)) \ + | ((v >> 8) & ((UInt64)0xFF << 24)) \ + | ((v << 8) & ((UInt64)0xFF << 32)) \ + | ((v << 24) & ((UInt64)0xFF << 40)) \ + | ((v << 40) & ((UInt64)0xFF << 48)) \ + | ((v << 56))) + + UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); +#endif + +#ifndef MY_CPU_BE + UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); +#endif + +typedef UInt64 (MY_FAST_CALL *CRC64_FUNC)(UInt64 v, const void *data, size_t size, const UInt64 *table); + +static CRC64_FUNC g_Crc64Update; +UInt64 g_Crc64Table[256 * CRC64_NUM_TABLES]; + +UInt64 MY_FAST_CALL Crc64Update(UInt64 v, const void *data, size_t size) +{ + return g_Crc64Update(v, data, size, g_Crc64Table); +} + +UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size) +{ + return g_Crc64Update(CRC64_INIT_VAL, data, size, g_Crc64Table) ^ CRC64_INIT_VAL; +} + +void MY_FAST_CALL Crc64GenerateTable() +{ + UInt32 i; + for (i = 0; i < 256; i++) + { + UInt64 r = i; + unsigned j; + for (j = 0; j < 8; j++) + r = (r >> 1) ^ (kCrc64Poly & ((UInt64)0 - (r & 1))); + g_Crc64Table[i] = r; + } + for (i = 256; i < 256 * CRC64_NUM_TABLES; i++) + { + UInt64 r = g_Crc64Table[(size_t)i - 256]; + g_Crc64Table[i] = g_Crc64Table[r & 0xFF] ^ (r >> 8); + } + + #ifdef MY_CPU_LE + + g_Crc64Update = XzCrc64UpdateT4; + + #else + { + #ifndef MY_CPU_BE + UInt32 k = 1; + if (*(const Byte *)&k == 1) + g_Crc64Update = XzCrc64UpdateT4; + else + #endif + { + for (i = 256 * CRC64_NUM_TABLES - 1; i >= 256; i--) + { + UInt64 x = g_Crc64Table[(size_t)i - 256]; + g_Crc64Table[i] = CRC_UINT64_SWAP(x); + } + g_Crc64Update = XzCrc64UpdateT1_BeT4; + } + } + #endif +} diff --git a/deps/LZMA-SDK/C/XzCrc64.h b/deps/LZMA-SDK/C/XzCrc64.h index 71b10d57e..08dbc330c 100644 --- a/deps/LZMA-SDK/C/XzCrc64.h +++ b/deps/LZMA-SDK/C/XzCrc64.h @@ -1,26 +1,26 @@ -/* XzCrc64.h -- CRC64 calculation -2013-01-18 : Igor Pavlov : Public domain */ - -#ifndef __XZ_CRC64_H -#define __XZ_CRC64_H - -#include - -#include "7zTypes.h" - -EXTERN_C_BEGIN - -extern UInt64 g_Crc64Table[]; - -void MY_FAST_CALL Crc64GenerateTable(void); - -#define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF) -#define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL) -#define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size); -UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size); - -EXTERN_C_END - -#endif +/* XzCrc64.h -- CRC64 calculation +2013-01-18 : Igor Pavlov : Public domain */ + +#ifndef __XZ_CRC64_H +#define __XZ_CRC64_H + +#include + +#include "7zTypes.h" + +EXTERN_C_BEGIN + +extern UInt64 g_Crc64Table[]; + +void MY_FAST_CALL Crc64GenerateTable(void); + +#define CRC64_INIT_VAL UINT64_CONST(0xFFFFFFFFFFFFFFFF) +#define CRC64_GET_DIGEST(crc) ((crc) ^ CRC64_INIT_VAL) +#define CRC64_UPDATE_BYTE(crc, b) (g_Crc64Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +UInt64 MY_FAST_CALL Crc64Update(UInt64 crc, const void *data, size_t size); +UInt64 MY_FAST_CALL Crc64Calc(const void *data, size_t size); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/XzCrc64Opt.c b/deps/LZMA-SDK/C/XzCrc64Opt.c index a0637dd22..93a9ffff5 100644 --- a/deps/LZMA-SDK/C/XzCrc64Opt.c +++ b/deps/LZMA-SDK/C/XzCrc64Opt.c @@ -1,71 +1,71 @@ -/* XzCrc64Opt.c -- CRC64 calculation -2021-02-09 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include "CpuArch.h" - -#ifndef MY_CPU_BE - -#define CRC64_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); -UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table) -{ - const Byte *p = (const Byte *)data; - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC64_UPDATE_BYTE_2(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - UInt32 d = (UInt32)v ^ *(const UInt32 *)(const void *)p; - v = (v >> 32) - ^ (table + 0x300)[((d ) & 0xFF)] - ^ (table + 0x200)[((d >> 8) & 0xFF)] - ^ (table + 0x100)[((d >> 16) & 0xFF)] - ^ (table + 0x000)[((d >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC64_UPDATE_BYTE_2(v, *p); - return v; -} - -#endif - - -#ifndef MY_CPU_LE - -#define CRC_UINT64_SWAP(v) \ - ((v >> 56) \ - | ((v >> 40) & ((UInt64)0xFF << 8)) \ - | ((v >> 24) & ((UInt64)0xFF << 16)) \ - | ((v >> 8) & ((UInt64)0xFF << 24)) \ - | ((v << 8) & ((UInt64)0xFF << 32)) \ - | ((v << 24) & ((UInt64)0xFF << 40)) \ - | ((v << 40) & ((UInt64)0xFF << 48)) \ - | ((v << 56))) - -#define CRC64_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8)) - -UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); -UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table) -{ - const Byte *p = (const Byte *)data; - table += 0x100; - v = CRC_UINT64_SWAP(v); - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC64_UPDATE_BYTE_2_BE(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)(const void *)p; - v = (v << 32) - ^ (table + 0x000)[((d ) & 0xFF)] - ^ (table + 0x100)[((d >> 8) & 0xFF)] - ^ (table + 0x200)[((d >> 16) & 0xFF)] - ^ (table + 0x300)[((d >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC64_UPDATE_BYTE_2_BE(v, *p); - return CRC_UINT64_SWAP(v); -} - -#endif +/* XzCrc64Opt.c -- CRC64 calculation +2021-02-09 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include "CpuArch.h" + +#ifndef MY_CPU_BE + +#define CRC64_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table); +UInt64 MY_FAST_CALL XzCrc64UpdateT4(UInt64 v, const void *data, size_t size, const UInt64 *table) +{ + const Byte *p = (const Byte *)data; + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC64_UPDATE_BYTE_2(v, *p); + for (; size >= 4; size -= 4, p += 4) + { + UInt32 d = (UInt32)v ^ *(const UInt32 *)(const void *)p; + v = (v >> 32) + ^ (table + 0x300)[((d ) & 0xFF)] + ^ (table + 0x200)[((d >> 8) & 0xFF)] + ^ (table + 0x100)[((d >> 16) & 0xFF)] + ^ (table + 0x000)[((d >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC64_UPDATE_BYTE_2(v, *p); + return v; +} + +#endif + + +#ifndef MY_CPU_LE + +#define CRC_UINT64_SWAP(v) \ + ((v >> 56) \ + | ((v >> 40) & ((UInt64)0xFF << 8)) \ + | ((v >> 24) & ((UInt64)0xFF << 16)) \ + | ((v >> 8) & ((UInt64)0xFF << 24)) \ + | ((v << 8) & ((UInt64)0xFF << 32)) \ + | ((v << 24) & ((UInt64)0xFF << 40)) \ + | ((v << 40) & ((UInt64)0xFF << 48)) \ + | ((v << 56))) + +#define CRC64_UPDATE_BYTE_2_BE(crc, b) (table[(Byte)((crc) >> 56) ^ (b)] ^ ((crc) << 8)) + +UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table); +UInt64 MY_FAST_CALL XzCrc64UpdateT1_BeT4(UInt64 v, const void *data, size_t size, const UInt64 *table) +{ + const Byte *p = (const Byte *)data; + table += 0x100; + v = CRC_UINT64_SWAP(v); + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC64_UPDATE_BYTE_2_BE(v, *p); + for (; size >= 4; size -= 4, p += 4) + { + UInt32 d = (UInt32)(v >> 32) ^ *(const UInt32 *)(const void *)p; + v = (v << 32) + ^ (table + 0x000)[((d ) & 0xFF)] + ^ (table + 0x100)[((d >> 8) & 0xFF)] + ^ (table + 0x200)[((d >> 16) & 0xFF)] + ^ (table + 0x300)[((d >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC64_UPDATE_BYTE_2_BE(v, *p); + return CRC_UINT64_SWAP(v); +} + +#endif diff --git a/deps/LZMA-SDK/C/XzDec.c b/deps/LZMA-SDK/C/XzDec.c index d345f68c1..3f96a37f9 100644 --- a/deps/LZMA-SDK/C/XzDec.c +++ b/deps/LZMA-SDK/C/XzDec.c @@ -1,2836 +1,2837 @@ -/* XzDec.c -- Xz Decode -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -// #include - -// #define XZ_DUMP - -/* #define XZ_DUMP */ - -#ifdef XZ_DUMP -#include -#endif - -// #define SHOW_DEBUG_INFO - -#ifdef SHOW_DEBUG_INFO -#include -#endif - -#ifdef SHOW_DEBUG_INFO -#define PRF(x) x -#else -#define PRF(x) -#endif - -#define PRF_STR(s) PRF(printf("\n" s "\n")) -#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) - -#include -#include - -#include "7zCrc.h" -#include "Alloc.h" -#include "Bra.h" -#include "CpuArch.h" -#include "Delta.h" -#include "Lzma2Dec.h" - -// #define USE_SUBBLOCK - -#ifdef USE_SUBBLOCK -#include "Bcj3Dec.c" -#include "SbDec.h" -#endif - -#include "Xz.h" - -#define XZ_CHECK_SIZE_MAX 64 - -#define CODER_BUF_SIZE ((size_t)1 << 17) - -unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value) -{ - unsigned i, limit; - *value = 0; - limit = (maxSize > 9) ? 9 : (unsigned)maxSize; - - for (i = 0; i < limit;) - { - Byte b = p[i]; - *value |= (UInt64)(b & 0x7F) << (7 * i++); - if ((b & 0x80) == 0) - return (b == 0 && i != 1) ? 0 : i; - } - return 0; -} - -/* ---------- BraState ---------- */ - -#define BRA_BUF_SIZE (1 << 14) - -typedef struct -{ - size_t bufPos; - size_t bufConv; - size_t bufTotal; - - int encodeMode; - - UInt32 methodId; - UInt32 delta; - UInt32 ip; - UInt32 x86State; - Byte deltaState[DELTA_STATE_SIZE]; - - Byte buf[BRA_BUF_SIZE]; -} CBraState; - -static void BraState_Free(void *pp, ISzAllocPtr alloc) -{ - ISzAlloc_Free(alloc, pp); -} - -static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAllocPtr alloc) -{ - CBraState *p = ((CBraState *)pp); - UNUSED_VAR(alloc); - p->ip = 0; - if (p->methodId == XZ_ID_Delta) - { - if (propSize != 1) - return SZ_ERROR_UNSUPPORTED; - p->delta = (unsigned)props[0] + 1; - } - else - { - if (propSize == 4) - { - UInt32 v = GetUi32(props); - switch (p->methodId) - { - case XZ_ID_PPC: - case XZ_ID_ARM: - case XZ_ID_SPARC: - if ((v & 3) != 0) - return SZ_ERROR_UNSUPPORTED; - break; - case XZ_ID_ARMT: - if ((v & 1) != 0) - return SZ_ERROR_UNSUPPORTED; - break; - case XZ_ID_IA64: - if ((v & 0xF) != 0) - return SZ_ERROR_UNSUPPORTED; - break; - } - p->ip = v; - } - else if (propSize != 0) - return SZ_ERROR_UNSUPPORTED; - } - return SZ_OK; -} - -static void BraState_Init(void *pp) -{ - CBraState *p = ((CBraState *)pp); - p->bufPos = p->bufConv = p->bufTotal = 0; - x86_Convert_Init(p->x86State); - if (p->methodId == XZ_ID_Delta) - Delta_Init(p->deltaState); -} - - -#define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: size = isa ## _Convert(data, size, p->ip, p->encodeMode); break; - -static SizeT BraState_Filter(void *pp, Byte *data, SizeT size) -{ - CBraState *p = ((CBraState *)pp); - switch (p->methodId) - { - case XZ_ID_Delta: - if (p->encodeMode) - Delta_Encode(p->deltaState, p->delta, data, size); - else - Delta_Decode(p->deltaState, p->delta, data, size); - break; - case XZ_ID_X86: - size = x86_Convert(data, size, p->ip, &p->x86State, p->encodeMode); - break; - CASE_BRA_CONV(PPC) - CASE_BRA_CONV(IA64) - CASE_BRA_CONV(ARM) - CASE_BRA_CONV(ARMT) - CASE_BRA_CONV(SPARC) - } - p->ip += (UInt32)size; - return size; -} - - -static SRes BraState_Code2(void *pp, - Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, int srcWasFinished, - ECoderFinishMode finishMode, - // int *wasFinished - ECoderStatus *status) -{ - CBraState *p = ((CBraState *)pp); - SizeT destRem = *destLen; - SizeT srcRem = *srcLen; - UNUSED_VAR(finishMode); - - *destLen = 0; - *srcLen = 0; - // *wasFinished = False; - *status = CODER_STATUS_NOT_FINISHED; - - while (destRem > 0) - { - if (p->bufPos != p->bufConv) - { - size_t size = p->bufConv - p->bufPos; - if (size > destRem) - size = destRem; - memcpy(dest, p->buf + p->bufPos, size); - p->bufPos += size; - *destLen += size; - dest += size; - destRem -= size; - continue; - } - - p->bufTotal -= p->bufPos; - memmove(p->buf, p->buf + p->bufPos, p->bufTotal); - p->bufPos = 0; - p->bufConv = 0; - { - size_t size = BRA_BUF_SIZE - p->bufTotal; - if (size > srcRem) - size = srcRem; - memcpy(p->buf + p->bufTotal, src, size); - *srcLen += size; - src += size; - srcRem -= size; - p->bufTotal += size; - } - if (p->bufTotal == 0) - break; - - p->bufConv = BraState_Filter(pp, p->buf, p->bufTotal); - - if (p->bufConv == 0) - { - if (!srcWasFinished) - break; - p->bufConv = p->bufTotal; - } - } - - if (p->bufTotal == p->bufPos && srcRem == 0 && srcWasFinished) - { - *status = CODER_STATUS_FINISHED_WITH_MARK; - // *wasFinished = 1; - } - - return SZ_OK; -} - - -SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc); -SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc) -{ - CBraState *decoder; - if (id < XZ_ID_Delta || id > XZ_ID_SPARC) - return SZ_ERROR_UNSUPPORTED; - decoder = (CBraState *)p->p; - if (!decoder) - { - decoder = (CBraState *)ISzAlloc_Alloc(alloc, sizeof(CBraState)); - if (!decoder) - return SZ_ERROR_MEM; - p->p = decoder; - p->Free = BraState_Free; - p->SetProps = BraState_SetProps; - p->Init = BraState_Init; - p->Code2 = BraState_Code2; - p->Filter = BraState_Filter; - } - decoder->methodId = (UInt32)id; - decoder->encodeMode = encodeMode; - return SZ_OK; -} - - - -/* ---------- SbState ---------- */ - -#ifdef USE_SUBBLOCK - -static void SbState_Free(void *pp, ISzAllocPtr alloc) -{ - CSbDec *p = (CSbDec *)pp; - SbDec_Free(p); - ISzAlloc_Free(alloc, pp); -} - -static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAllocPtr alloc) -{ - UNUSED_VAR(pp); - UNUSED_VAR(props); - UNUSED_VAR(alloc); - return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED; -} - -static void SbState_Init(void *pp) -{ - SbDec_Init((CSbDec *)pp); -} - -static SRes SbState_Code2(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - int srcWasFinished, ECoderFinishMode finishMode, - // int *wasFinished - ECoderStatus *status) -{ - CSbDec *p = (CSbDec *)pp; - SRes res; - UNUSED_VAR(srcWasFinished); - p->dest = dest; - p->destLen = *destLen; - p->src = src; - p->srcLen = *srcLen; - p->finish = finishMode; /* change it */ - res = SbDec_Decode((CSbDec *)pp); - *destLen -= p->destLen; - *srcLen -= p->srcLen; - // *wasFinished = (*destLen == 0 && *srcLen == 0); /* change it */ - *status = (*destLen == 0 && *srcLen == 0) ? - CODER_STATUS_FINISHED_WITH_MARK : - CODER_STATUS_NOT_FINISHED; - return res; -} - -static SRes SbState_SetFromMethod(IStateCoder *p, ISzAllocPtr alloc) -{ - CSbDec *decoder = (CSbDec *)p->p; - if (!decoder) - { - decoder = (CSbDec *)ISzAlloc_Alloc(alloc, sizeof(CSbDec)); - if (!decoder) - return SZ_ERROR_MEM; - p->p = decoder; - p->Free = SbState_Free; - p->SetProps = SbState_SetProps; - p->Init = SbState_Init; - p->Code2 = SbState_Code2; - p->Filter = NULL; - } - SbDec_Construct(decoder); - SbDec_SetAlloc(decoder, alloc); - return SZ_OK; -} - -#endif - - - -/* ---------- Lzma2 ---------- */ - -typedef struct -{ - CLzma2Dec decoder; - BoolInt outBufMode; -} CLzma2Dec_Spec; - - -static void Lzma2State_Free(void *pp, ISzAllocPtr alloc) -{ - CLzma2Dec_Spec *p = (CLzma2Dec_Spec *)pp; - if (p->outBufMode) - Lzma2Dec_FreeProbs(&p->decoder, alloc); - else - Lzma2Dec_Free(&p->decoder, alloc); - ISzAlloc_Free(alloc, pp); -} - -static SRes Lzma2State_SetProps(void *pp, const Byte *props, size_t propSize, ISzAllocPtr alloc) -{ - if (propSize != 1) - return SZ_ERROR_UNSUPPORTED; - { - CLzma2Dec_Spec *p = (CLzma2Dec_Spec *)pp; - if (p->outBufMode) - return Lzma2Dec_AllocateProbs(&p->decoder, props[0], alloc); - else - return Lzma2Dec_Allocate(&p->decoder, props[0], alloc); - } -} - -static void Lzma2State_Init(void *pp) -{ - Lzma2Dec_Init(&((CLzma2Dec_Spec *)pp)->decoder); -} - - -/* - if (outBufMode), then (dest) is not used. Use NULL. - Data is unpacked to (spec->decoder.decoder.dic) output buffer. -*/ - -static SRes Lzma2State_Code2(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - int srcWasFinished, ECoderFinishMode finishMode, - // int *wasFinished, - ECoderStatus *status) -{ - CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)pp; - ELzmaStatus status2; - /* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */ - SRes res; - UNUSED_VAR(srcWasFinished); - if (spec->outBufMode) - { - SizeT dicPos = spec->decoder.decoder.dicPos; - SizeT dicLimit = dicPos + *destLen; - res = Lzma2Dec_DecodeToDic(&spec->decoder, dicLimit, src, srcLen, (ELzmaFinishMode)finishMode, &status2); - *destLen = spec->decoder.decoder.dicPos - dicPos; - } - else - res = Lzma2Dec_DecodeToBuf(&spec->decoder, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status2); - // *wasFinished = (status2 == LZMA_STATUS_FINISHED_WITH_MARK); - // ECoderStatus values are identical to ELzmaStatus values of LZMA2 decoder - *status = (ECoderStatus)status2; - return res; -} - - -static SRes Lzma2State_SetFromMethod(IStateCoder *p, Byte *outBuf, size_t outBufSize, ISzAllocPtr alloc) -{ - CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)p->p; - if (!spec) - { - spec = (CLzma2Dec_Spec *)ISzAlloc_Alloc(alloc, sizeof(CLzma2Dec_Spec)); - if (!spec) - return SZ_ERROR_MEM; - p->p = spec; - p->Free = Lzma2State_Free; - p->SetProps = Lzma2State_SetProps; - p->Init = Lzma2State_Init; - p->Code2 = Lzma2State_Code2; - p->Filter = NULL; - Lzma2Dec_Construct(&spec->decoder); - } - spec->outBufMode = False; - if (outBuf) - { - spec->outBufMode = True; - spec->decoder.decoder.dic = outBuf; - spec->decoder.decoder.dicBufSize = outBufSize; - } - return SZ_OK; -} - - -static SRes Lzma2State_ResetOutBuf(IStateCoder *p, Byte *outBuf, size_t outBufSize) -{ - CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)p->p; - if ((spec->outBufMode && !outBuf) || (!spec->outBufMode && outBuf)) - return SZ_ERROR_FAIL; - if (outBuf) - { - spec->decoder.decoder.dic = outBuf; - spec->decoder.decoder.dicBufSize = outBufSize; - } - return SZ_OK; -} - - - -static void MixCoder_Construct(CMixCoder *p, ISzAllocPtr alloc) -{ - unsigned i; - p->alloc = alloc; - p->buf = NULL; - p->numCoders = 0; - - p->outBufSize = 0; - p->outBuf = NULL; - // p->SingleBufMode = False; - - for (i = 0; i < MIXCODER_NUM_FILTERS_MAX; i++) - p->coders[i].p = NULL; -} - - -static void MixCoder_Free(CMixCoder *p) -{ - unsigned i; - p->numCoders = 0; - for (i = 0; i < MIXCODER_NUM_FILTERS_MAX; i++) - { - IStateCoder *sc = &p->coders[i]; - if (sc->p) - { - sc->Free(sc->p, p->alloc); - sc->p = NULL; - } - } - if (p->buf) - { - ISzAlloc_Free(p->alloc, p->buf); - p->buf = NULL; /* 9.31: the BUG was fixed */ - } -} - -static void MixCoder_Init(CMixCoder *p) -{ - unsigned i; - for (i = 0; i < MIXCODER_NUM_FILTERS_MAX - 1; i++) - { - p->size[i] = 0; - p->pos[i] = 0; - p->finished[i] = 0; - } - for (i = 0; i < p->numCoders; i++) - { - IStateCoder *coder = &p->coders[i]; - coder->Init(coder->p); - p->results[i] = SZ_OK; - } - p->outWritten = 0; - p->wasFinished = False; - p->res = SZ_OK; - p->status = CODER_STATUS_NOT_SPECIFIED; -} - - -static SRes MixCoder_SetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId, Byte *outBuf, size_t outBufSize) -{ - IStateCoder *sc = &p->coders[coderIndex]; - p->ids[coderIndex] = methodId; - switch (methodId) - { - case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, outBuf, outBufSize, p->alloc); - #ifdef USE_SUBBLOCK - case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc); - #endif - } - if (coderIndex == 0) - return SZ_ERROR_UNSUPPORTED; - return BraState_SetFromMethod(sc, methodId, 0, p->alloc); -} - - -static SRes MixCoder_ResetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId, Byte *outBuf, size_t outBufSize) -{ - IStateCoder *sc = &p->coders[coderIndex]; - switch (methodId) - { - case XZ_ID_LZMA2: return Lzma2State_ResetOutBuf(sc, outBuf, outBufSize); - } - return SZ_ERROR_UNSUPPORTED; -} - - - -/* - if (destFinish) - then unpack data block is finished at (*destLen) position, - and we can return data that were not processed by filter - -output (status) can be : - CODER_STATUS_NOT_FINISHED - CODER_STATUS_FINISHED_WITH_MARK - CODER_STATUS_NEEDS_MORE_INPUT - not implemented still -*/ - -static SRes MixCoder_Code(CMixCoder *p, - Byte *dest, SizeT *destLen, int destFinish, - const Byte *src, SizeT *srcLen, int srcWasFinished, - ECoderFinishMode finishMode) -{ - SizeT destLenOrig = *destLen; - SizeT srcLenOrig = *srcLen; - - *destLen = 0; - *srcLen = 0; - - if (p->wasFinished) - return p->res; - - p->status = CODER_STATUS_NOT_FINISHED; - - // if (p->SingleBufMode) - if (p->outBuf) - { - SRes res; - SizeT destLen2, srcLen2; - int wasFinished; - - PRF_STR("------- MixCoder Single ----------"); - - srcLen2 = srcLenOrig; - destLen2 = destLenOrig; - - { - IStateCoder *coder = &p->coders[0]; - res = coder->Code2(coder->p, NULL, &destLen2, src, &srcLen2, srcWasFinished, finishMode, - // &wasFinished, - &p->status); - wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); - } - - p->res = res; - - /* - if (wasFinished) - p->status = CODER_STATUS_FINISHED_WITH_MARK; - else - { - if (res == SZ_OK) - if (destLen2 != destLenOrig) - p->status = CODER_STATUS_NEEDS_MORE_INPUT; - } - */ - - - *srcLen = srcLen2; - src += srcLen2; - p->outWritten += destLen2; - - if (res != SZ_OK || srcWasFinished || wasFinished) - p->wasFinished = True; - - if (p->numCoders == 1) - *destLen = destLen2; - else if (p->wasFinished) - { - unsigned i; - size_t processed = p->outWritten; - - for (i = 1; i < p->numCoders; i++) - { - IStateCoder *coder = &p->coders[i]; - processed = coder->Filter(coder->p, p->outBuf, processed); - if (wasFinished || (destFinish && p->outWritten == destLenOrig)) - processed = p->outWritten; - PRF_STR_INT("filter", i); - } - *destLen = processed; - } - return res; - } - - PRF_STR("standard mix"); - - if (p->numCoders != 1) - { - if (!p->buf) - { - p->buf = (Byte *)ISzAlloc_Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1)); - if (!p->buf) - return SZ_ERROR_MEM; - } - - finishMode = CODER_FINISH_ANY; - } - - for (;;) - { - BoolInt processed = False; - BoolInt allFinished = True; - SRes resMain = SZ_OK; - unsigned i; - - p->status = CODER_STATUS_NOT_FINISHED; - /* - if (p->numCoders == 1 && *destLen == destLenOrig && finishMode == LZMA_FINISH_ANY) - break; - */ - - for (i = 0; i < p->numCoders; i++) - { - SRes res; - IStateCoder *coder = &p->coders[i]; - Byte *dest2; - SizeT destLen2, srcLen2; // destLen2_Orig; - const Byte *src2; - int srcFinished2; - int encodingWasFinished; - ECoderStatus status2; - - if (i == 0) - { - src2 = src; - srcLen2 = srcLenOrig - *srcLen; - srcFinished2 = srcWasFinished; - } - else - { - size_t k = i - 1; - src2 = p->buf + (CODER_BUF_SIZE * k) + p->pos[k]; - srcLen2 = p->size[k] - p->pos[k]; - srcFinished2 = p->finished[k]; - } - - if (i == p->numCoders - 1) - { - dest2 = dest; - destLen2 = destLenOrig - *destLen; - } - else - { - if (p->pos[i] != p->size[i]) - continue; - dest2 = p->buf + (CODER_BUF_SIZE * i); - destLen2 = CODER_BUF_SIZE; - } - - // destLen2_Orig = destLen2; - - if (p->results[i] != SZ_OK) - { - if (resMain == SZ_OK) - resMain = p->results[i]; - continue; - } - - res = coder->Code2(coder->p, - dest2, &destLen2, - src2, &srcLen2, srcFinished2, - finishMode, - // &encodingWasFinished, - &status2); - - if (res != SZ_OK) - { - p->results[i] = res; - if (resMain == SZ_OK) - resMain = res; - } - - encodingWasFinished = (status2 == CODER_STATUS_FINISHED_WITH_MARK); - - if (!encodingWasFinished) - { - allFinished = False; - if (p->numCoders == 1 && res == SZ_OK) - p->status = status2; - } - - if (i == 0) - { - *srcLen += srcLen2; - src += srcLen2; - } - else - p->pos[(size_t)i - 1] += srcLen2; - - if (i == p->numCoders - 1) - { - *destLen += destLen2; - dest += destLen2; - } - else - { - p->size[i] = destLen2; - p->pos[i] = 0; - p->finished[i] = encodingWasFinished; - } - - if (destLen2 != 0 || srcLen2 != 0) - processed = True; - } - - if (!processed) - { - if (allFinished) - p->status = CODER_STATUS_FINISHED_WITH_MARK; - return resMain; - } - } -} - - -SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf) -{ - *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE); - if (CrcCalc(buf + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE) != - GetUi32(buf + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE)) - return SZ_ERROR_NO_ARCHIVE; - return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED; -} - -static BoolInt Xz_CheckFooter(CXzStreamFlags flags, UInt64 indexSize, const Byte *buf) -{ - return indexSize == (((UInt64)GetUi32(buf + 4) + 1) << 2) - && GetUi32(buf) == CrcCalc(buf + 4, 6) - && flags == GetBe16(buf + 8) - && buf[10] == XZ_FOOTER_SIG_0 - && buf[11] == XZ_FOOTER_SIG_1; -} - -#define READ_VARINT_AND_CHECK(buf, pos, size, res) \ - { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \ - if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; } - - -static BoolInt XzBlock_AreSupportedFilters(const CXzBlock *p) -{ - unsigned numFilters = XzBlock_GetNumFilters(p) - 1; - unsigned i; - { - const CXzFilter *f = &p->filters[numFilters]; - if (f->id != XZ_ID_LZMA2 || f->propsSize != 1 || f->props[0] > 40) - return False; - } - - for (i = 0; i < numFilters; i++) - { - const CXzFilter *f = &p->filters[i]; - if (f->id == XZ_ID_Delta) - { - if (f->propsSize != 1) - return False; - } - else if (f->id < XZ_ID_Delta - || f->id > XZ_ID_SPARC - || (f->propsSize != 0 && f->propsSize != 4)) - return False; - } - return True; -} - - -SRes XzBlock_Parse(CXzBlock *p, const Byte *header) -{ - unsigned pos; - unsigned numFilters, i; - unsigned headerSize = (unsigned)header[0] << 2; - - /* (headerSize != 0) : another code checks */ - - if (CrcCalc(header, headerSize) != GetUi32(header + headerSize)) - return SZ_ERROR_ARCHIVE; - - pos = 1; - p->flags = header[pos++]; - - p->packSize = (UInt64)(Int64)-1; - if (XzBlock_HasPackSize(p)) - { - READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize); - if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63) - return SZ_ERROR_ARCHIVE; - } - - p->unpackSize = (UInt64)(Int64)-1; - if (XzBlock_HasUnpackSize(p)) - READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize); - - numFilters = XzBlock_GetNumFilters(p); - for (i = 0; i < numFilters; i++) - { - CXzFilter *filter = p->filters + i; - UInt64 size; - READ_VARINT_AND_CHECK(header, pos, headerSize, &filter->id); - READ_VARINT_AND_CHECK(header, pos, headerSize, &size); - if (size > headerSize - pos || size > XZ_FILTER_PROPS_SIZE_MAX) - return SZ_ERROR_ARCHIVE; - filter->propsSize = (UInt32)size; - memcpy(filter->props, header + pos, (size_t)size); - pos += (unsigned)size; - - #ifdef XZ_DUMP - printf("\nf[%u] = %2X: ", i, (unsigned)filter->id); - { - unsigned i; - for (i = 0; i < size; i++) - printf(" %2X", filter->props[i]); - } - #endif - } - - if (XzBlock_HasUnsupportedFlags(p)) - return SZ_ERROR_UNSUPPORTED; - - while (pos < headerSize) - if (header[pos++] != 0) - return SZ_ERROR_ARCHIVE; - return SZ_OK; -} - - - - -static SRes XzDecMix_Init(CMixCoder *p, const CXzBlock *block, Byte *outBuf, size_t outBufSize) -{ - unsigned i; - BoolInt needReInit = True; - unsigned numFilters = XzBlock_GetNumFilters(block); - - if (numFilters == p->numCoders && ((p->outBuf && outBuf) || (!p->outBuf && !outBuf))) - { - needReInit = False; - for (i = 0; i < numFilters; i++) - if (p->ids[i] != block->filters[numFilters - 1 - i].id) - { - needReInit = True; - break; - } - } - - // p->SingleBufMode = (outBuf != NULL); - p->outBuf = outBuf; - p->outBufSize = outBufSize; - - // p->SingleBufMode = False; - // outBuf = NULL; - - if (needReInit) - { - MixCoder_Free(p); - for (i = 0; i < numFilters; i++) - { - RINOK(MixCoder_SetFromMethod(p, i, block->filters[numFilters - 1 - i].id, outBuf, outBufSize)); - } - p->numCoders = numFilters; - } - else - { - RINOK(MixCoder_ResetFromMethod(p, 0, block->filters[numFilters - 1].id, outBuf, outBufSize)); - } - - for (i = 0; i < numFilters; i++) - { - const CXzFilter *f = &block->filters[numFilters - 1 - i]; - IStateCoder *sc = &p->coders[i]; - RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc)); - } - - MixCoder_Init(p); - return SZ_OK; -} - - - -void XzUnpacker_Init(CXzUnpacker *p) -{ - p->state = XZ_STATE_STREAM_HEADER; - p->pos = 0; - p->numStartedStreams = 0; - p->numFinishedStreams = 0; - p->numTotalBlocks = 0; - p->padSize = 0; - p->decodeOnlyOneBlock = 0; - - p->parseMode = False; - p->decodeToStreamSignature = False; - - // p->outBuf = NULL; - // p->outBufSize = 0; - p->outDataWritten = 0; -} - - -void XzUnpacker_SetOutBuf(CXzUnpacker *p, Byte *outBuf, size_t outBufSize) -{ - p->outBuf = outBuf; - p->outBufSize = outBufSize; -} - - -void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc) -{ - MixCoder_Construct(&p->decoder, alloc); - p->outBuf = NULL; - p->outBufSize = 0; - XzUnpacker_Init(p); -} - - -void XzUnpacker_Free(CXzUnpacker *p) -{ - MixCoder_Free(&p->decoder); -} - - -void XzUnpacker_PrepareToRandomBlockDecoding(CXzUnpacker *p) -{ - p->indexSize = 0; - p->numBlocks = 0; - Sha256_Init(&p->sha); - p->state = XZ_STATE_BLOCK_HEADER; - p->pos = 0; - p->decodeOnlyOneBlock = 1; -} - - -static void XzUnpacker_UpdateIndex(CXzUnpacker *p, UInt64 packSize, UInt64 unpackSize) -{ - Byte temp[32]; - unsigned num = Xz_WriteVarInt(temp, packSize); - num += Xz_WriteVarInt(temp + num, unpackSize); - Sha256_Update(&p->sha, temp, num); - p->indexSize += num; - p->numBlocks++; -} - - - -SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, int srcFinished, - ECoderFinishMode finishMode, ECoderStatus *status) -{ - SizeT destLenOrig = *destLen; - SizeT srcLenOrig = *srcLen; - *destLen = 0; - *srcLen = 0; - *status = CODER_STATUS_NOT_SPECIFIED; - - for (;;) - { - SizeT srcRem; - - if (p->state == XZ_STATE_BLOCK) - { - SizeT destLen2 = destLenOrig - *destLen; - SizeT srcLen2 = srcLenOrig - *srcLen; - SRes res; - - ECoderFinishMode finishMode2 = finishMode; - BoolInt srcFinished2 = srcFinished; - BoolInt destFinish = False; - - if (p->block.packSize != (UInt64)(Int64)-1) - { - UInt64 rem = p->block.packSize - p->packSize; - if (srcLen2 >= rem) - { - srcFinished2 = True; - srcLen2 = (SizeT)rem; - } - if (rem == 0 && p->block.unpackSize == p->unpackSize) - return SZ_ERROR_DATA; - } - - if (p->block.unpackSize != (UInt64)(Int64)-1) - { - UInt64 rem = p->block.unpackSize - p->unpackSize; - if (destLen2 >= rem) - { - destFinish = True; - finishMode2 = CODER_FINISH_END; - destLen2 = (SizeT)rem; - } - } - - /* - if (srcLen2 == 0 && destLen2 == 0) - { - *status = CODER_STATUS_NOT_FINISHED; - return SZ_OK; - } - */ - - { - res = MixCoder_Code(&p->decoder, - (p->outBuf ? NULL : dest), &destLen2, destFinish, - src, &srcLen2, srcFinished2, - finishMode2); - - *status = p->decoder.status; - XzCheck_Update(&p->check, (p->outBuf ? p->outBuf + p->outDataWritten : dest), destLen2); - if (!p->outBuf) - dest += destLen2; - p->outDataWritten += destLen2; - } - - (*srcLen) += srcLen2; - src += srcLen2; - p->packSize += srcLen2; - (*destLen) += destLen2; - p->unpackSize += destLen2; - - RINOK(res); - - if (*status != CODER_STATUS_FINISHED_WITH_MARK) - { - if (p->block.packSize == p->packSize - && *status == CODER_STATUS_NEEDS_MORE_INPUT) - { - PRF_STR("CODER_STATUS_NEEDS_MORE_INPUT"); - *status = CODER_STATUS_NOT_SPECIFIED; - return SZ_ERROR_DATA; - } - - return SZ_OK; - } - { - XzUnpacker_UpdateIndex(p, XzUnpacker_GetPackSizeForIndex(p), p->unpackSize); - p->state = XZ_STATE_BLOCK_FOOTER; - p->pos = 0; - p->alignPos = 0; - *status = CODER_STATUS_NOT_SPECIFIED; - - if ((p->block.packSize != (UInt64)(Int64)-1 && p->block.packSize != p->packSize) - || (p->block.unpackSize != (UInt64)(Int64)-1 && p->block.unpackSize != p->unpackSize)) - { - PRF_STR("ERROR: block.size mismatch"); - return SZ_ERROR_DATA; - } - } - // continue; - } - - srcRem = srcLenOrig - *srcLen; - - // XZ_STATE_BLOCK_FOOTER can transit to XZ_STATE_BLOCK_HEADER without input bytes - if (srcRem == 0 && p->state != XZ_STATE_BLOCK_FOOTER) - { - *status = CODER_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - - switch (p->state) - { - case XZ_STATE_STREAM_HEADER: - { - if (p->pos < XZ_STREAM_HEADER_SIZE) - { - if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos]) - return SZ_ERROR_NO_ARCHIVE; - if (p->decodeToStreamSignature) - return SZ_OK; - p->buf[p->pos++] = *src++; - (*srcLen)++; - } - else - { - RINOK(Xz_ParseHeader(&p->streamFlags, p->buf)); - p->numStartedStreams++; - p->indexSize = 0; - p->numBlocks = 0; - Sha256_Init(&p->sha); - p->state = XZ_STATE_BLOCK_HEADER; - p->pos = 0; - } - break; - } - - case XZ_STATE_BLOCK_HEADER: - { - if (p->pos == 0) - { - p->buf[p->pos++] = *src++; - (*srcLen)++; - if (p->buf[0] == 0) - { - if (p->decodeOnlyOneBlock) - return SZ_ERROR_DATA; - p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks); - p->indexPos = p->indexPreSize; - p->indexSize += p->indexPreSize; - Sha256_Final(&p->sha, p->shaDigest); - Sha256_Init(&p->sha); - p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize); - p->state = XZ_STATE_STREAM_INDEX; - break; - } - p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4; - break; - } - - if (p->pos != p->blockHeaderSize) - { - UInt32 cur = p->blockHeaderSize - p->pos; - if (cur > srcRem) - cur = (UInt32)srcRem; - memcpy(p->buf + p->pos, src, cur); - p->pos += cur; - (*srcLen) += cur; - src += cur; - } - else - { - RINOK(XzBlock_Parse(&p->block, p->buf)); - if (!XzBlock_AreSupportedFilters(&p->block)) - return SZ_ERROR_UNSUPPORTED; - p->numTotalBlocks++; - p->state = XZ_STATE_BLOCK; - p->packSize = 0; - p->unpackSize = 0; - XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags)); - if (p->parseMode) - { - p->headerParsedOk = True; - return SZ_OK; - } - RINOK(XzDecMix_Init(&p->decoder, &p->block, p->outBuf, p->outBufSize)); - } - break; - } - - case XZ_STATE_BLOCK_FOOTER: - { - if ((((unsigned)p->packSize + p->alignPos) & 3) != 0) - { - if (srcRem == 0) - { - *status = CODER_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - (*srcLen)++; - p->alignPos++; - if (*src++ != 0) - return SZ_ERROR_CRC; - } - else - { - UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags); - UInt32 cur = checkSize - p->pos; - if (cur != 0) - { - if (srcRem == 0) - { - *status = CODER_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (cur > srcRem) - cur = (UInt32)srcRem; - memcpy(p->buf + p->pos, src, cur); - p->pos += cur; - (*srcLen) += cur; - src += cur; - if (checkSize != p->pos) - break; - } - { - Byte digest[XZ_CHECK_SIZE_MAX]; - p->state = XZ_STATE_BLOCK_HEADER; - p->pos = 0; - if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0) - return SZ_ERROR_CRC; - if (p->decodeOnlyOneBlock) - { - *status = CODER_STATUS_FINISHED_WITH_MARK; - return SZ_OK; - } - } - } - break; - } - - case XZ_STATE_STREAM_INDEX: - { - if (p->pos < p->indexPreSize) - { - (*srcLen)++; - if (*src++ != p->buf[p->pos++]) - return SZ_ERROR_CRC; - } - else - { - if (p->indexPos < p->indexSize) - { - UInt64 cur = p->indexSize - p->indexPos; - if (srcRem > cur) - srcRem = (SizeT)cur; - p->crc = CrcUpdate(p->crc, src, srcRem); - Sha256_Update(&p->sha, src, srcRem); - (*srcLen) += srcRem; - src += srcRem; - p->indexPos += srcRem; - } - else if ((p->indexPos & 3) != 0) - { - Byte b = *src++; - p->crc = CRC_UPDATE_BYTE(p->crc, b); - (*srcLen)++; - p->indexPos++; - p->indexSize++; - if (b != 0) - return SZ_ERROR_CRC; - } - else - { - Byte digest[SHA256_DIGEST_SIZE]; - p->state = XZ_STATE_STREAM_INDEX_CRC; - p->indexSize += 4; - p->pos = 0; - Sha256_Final(&p->sha, digest); - if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0) - return SZ_ERROR_CRC; - } - } - break; - } - - case XZ_STATE_STREAM_INDEX_CRC: - { - if (p->pos < 4) - { - (*srcLen)++; - p->buf[p->pos++] = *src++; - } - else - { - const Byte *ptr = p->buf; - p->state = XZ_STATE_STREAM_FOOTER; - p->pos = 0; - if (CRC_GET_DIGEST(p->crc) != GetUi32(ptr)) - return SZ_ERROR_CRC; - } - break; - } - - case XZ_STATE_STREAM_FOOTER: - { - UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos; - if (cur > srcRem) - cur = (UInt32)srcRem; - memcpy(p->buf + p->pos, src, cur); - p->pos += cur; - (*srcLen) += cur; - src += cur; - if (p->pos == XZ_STREAM_FOOTER_SIZE) - { - p->state = XZ_STATE_STREAM_PADDING; - p->numFinishedStreams++; - p->padSize = 0; - if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf)) - return SZ_ERROR_CRC; - } - break; - } - - case XZ_STATE_STREAM_PADDING: - { - if (*src != 0) - { - if (((UInt32)p->padSize & 3) != 0) - return SZ_ERROR_NO_ARCHIVE; - p->pos = 0; - p->state = XZ_STATE_STREAM_HEADER; - } - else - { - (*srcLen)++; - src++; - p->padSize++; - } - break; - } - - case XZ_STATE_BLOCK: break; /* to disable GCC warning */ - } - } - /* - if (p->state == XZ_STATE_FINISHED) - *status = CODER_STATUS_FINISHED_WITH_MARK; - return SZ_OK; - */ -} - - -SRes XzUnpacker_CodeFull(CXzUnpacker *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, - ECoderFinishMode finishMode, ECoderStatus *status) -{ - XzUnpacker_Init(p); - XzUnpacker_SetOutBuf(p, dest, *destLen); - - return XzUnpacker_Code(p, - NULL, destLen, - src, srcLen, True, - finishMode, status); -} - - -BoolInt XzUnpacker_IsBlockFinished(const CXzUnpacker *p) -{ - return (p->state == XZ_STATE_BLOCK_HEADER) && (p->pos == 0); -} - -BoolInt XzUnpacker_IsStreamWasFinished(const CXzUnpacker *p) -{ - return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0); -} - -UInt64 XzUnpacker_GetExtraSize(const CXzUnpacker *p) -{ - UInt64 num = 0; - if (p->state == XZ_STATE_STREAM_PADDING) - num = p->padSize; - else if (p->state == XZ_STATE_STREAM_HEADER) - num = p->padSize + p->pos; - return num; -} - - - - - - - - - - - - - - - - - - - - - -#ifndef _7ZIP_ST -#include "MtDec.h" -#endif - - -void XzDecMtProps_Init(CXzDecMtProps *p) -{ - p->inBufSize_ST = 1 << 18; - p->outStep_ST = 1 << 20; - p->ignoreErrors = False; - - #ifndef _7ZIP_ST - p->numThreads = 1; - p->inBufSize_MT = 1 << 18; - p->memUseMax = sizeof(size_t) << 28; - #endif -} - - - -#ifndef _7ZIP_ST - -/* ---------- CXzDecMtThread ---------- */ - -typedef struct -{ - Byte *outBuf; - size_t outBufSize; - size_t outPreSize; - size_t inPreSize; - size_t inPreHeaderSize; - size_t blockPackSize_for_Index; // including block header and checksum. - size_t blockPackTotal; // including stream header, block header and checksum. - size_t inCodeSize; - size_t outCodeSize; - ECoderStatus status; - SRes codeRes; - BoolInt skipMode; - // BoolInt finishedWithMark; - EMtDecParseState parseState; - BoolInt parsing_Truncated; - BoolInt atBlockHeader; - CXzStreamFlags streamFlags; - // UInt64 numFinishedStreams - UInt64 numStreams; - UInt64 numTotalBlocks; - UInt64 numBlocks; - - BoolInt dec_created; - CXzUnpacker dec; - - Byte mtPad[1 << 7]; -} CXzDecMtThread; - -#endif - - -/* ---------- CXzDecMt ---------- */ - -typedef struct -{ - CAlignOffsetAlloc alignOffsetAlloc; - ISzAllocPtr allocMid; - - CXzDecMtProps props; - size_t unpackBlockMaxSize; - - ISeqInStream *inStream; - ISeqOutStream *outStream; - ICompressProgress *progress; - - BoolInt finishMode; - BoolInt outSize_Defined; - UInt64 outSize; - - UInt64 outProcessed; - UInt64 inProcessed; - UInt64 readProcessed; - BoolInt readWasFinished; - SRes readRes; - SRes writeRes; - - Byte *outBuf; - size_t outBufSize; - Byte *inBuf; - size_t inBufSize; - - CXzUnpacker dec; - - ECoderStatus status; - SRes codeRes; - - #ifndef _7ZIP_ST - BoolInt mainDecoderWasCalled; - // int statErrorDefined; - int finishedDecoderIndex; - - // global values that are used in Parse stage - CXzStreamFlags streamFlags; - // UInt64 numFinishedStreams - UInt64 numStreams; - UInt64 numTotalBlocks; - UInt64 numBlocks; - - // UInt64 numBadBlocks; - SRes mainErrorCode; // it's set to error code, if the size Code() output doesn't patch the size from Parsing stage - // it can be = SZ_ERROR_INPUT_EOF - // it can be = SZ_ERROR_DATA, in some another cases - BoolInt isBlockHeaderState_Parse; - BoolInt isBlockHeaderState_Write; - UInt64 outProcessed_Parse; - BoolInt parsing_Truncated; - - BoolInt mtc_WasConstructed; - CMtDec mtc; - CXzDecMtThread coders[MTDEC__THREADS_MAX]; - #endif - -} CXzDecMt; - - - -CXzDecMtHandle XzDecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid) -{ - CXzDecMt *p = (CXzDecMt *)ISzAlloc_Alloc(alloc, sizeof(CXzDecMt)); - if (!p) - return NULL; - - AlignOffsetAlloc_CreateVTable(&p->alignOffsetAlloc); - p->alignOffsetAlloc.baseAlloc = alloc; - p->alignOffsetAlloc.numAlignBits = 7; - p->alignOffsetAlloc.offset = 0; - - p->allocMid = allocMid; - - p->outBuf = NULL; - p->outBufSize = 0; - p->inBuf = NULL; - p->inBufSize = 0; - - XzUnpacker_Construct(&p->dec, &p->alignOffsetAlloc.vt); - - p->unpackBlockMaxSize = 0; - - XzDecMtProps_Init(&p->props); - - #ifndef _7ZIP_ST - p->mtc_WasConstructed = False; - { - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CXzDecMtThread *coder = &p->coders[i]; - coder->dec_created = False; - coder->outBuf = NULL; - coder->outBufSize = 0; - } - } - #endif - - return p; -} - - -#ifndef _7ZIP_ST - -static void XzDecMt_FreeOutBufs(CXzDecMt *p) -{ - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CXzDecMtThread *coder = &p->coders[i]; - if (coder->outBuf) - { - ISzAlloc_Free(p->allocMid, coder->outBuf); - coder->outBuf = NULL; - coder->outBufSize = 0; - } - } - p->unpackBlockMaxSize = 0; -} - -#endif - - - -static void XzDecMt_FreeSt(CXzDecMt *p) -{ - XzUnpacker_Free(&p->dec); - - if (p->outBuf) - { - ISzAlloc_Free(p->allocMid, p->outBuf); - p->outBuf = NULL; - } - p->outBufSize = 0; - - if (p->inBuf) - { - ISzAlloc_Free(p->allocMid, p->inBuf); - p->inBuf = NULL; - } - p->inBufSize = 0; -} - - -void XzDecMt_Destroy(CXzDecMtHandle pp) -{ - CXzDecMt *p = (CXzDecMt *)pp; - - XzDecMt_FreeSt(p); - - #ifndef _7ZIP_ST - - if (p->mtc_WasConstructed) - { - MtDec_Destruct(&p->mtc); - p->mtc_WasConstructed = False; - } - { - unsigned i; - for (i = 0; i < MTDEC__THREADS_MAX; i++) - { - CXzDecMtThread *t = &p->coders[i]; - if (t->dec_created) - { - // we don't need to free dict here - XzUnpacker_Free(&t->dec); - t->dec_created = False; - } - } - } - XzDecMt_FreeOutBufs(p); - - #endif - - ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); -} - - - -#ifndef _7ZIP_ST - -static void XzDecMt_Callback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc) -{ - CXzDecMt *me = (CXzDecMt *)obj; - CXzDecMtThread *coder = &me->coders[coderIndex]; - size_t srcSize = cc->srcSize; - - cc->srcSize = 0; - cc->outPos = 0; - cc->state = MTDEC_PARSE_CONTINUE; - - cc->canCreateNewThread = True; - - if (cc->startCall) - { - coder->outPreSize = 0; - coder->inPreSize = 0; - coder->inPreHeaderSize = 0; - coder->parseState = MTDEC_PARSE_CONTINUE; - coder->parsing_Truncated = False; - coder->skipMode = False; - coder->codeRes = SZ_OK; - coder->status = CODER_STATUS_NOT_SPECIFIED; - coder->inCodeSize = 0; - coder->outCodeSize = 0; - - coder->numStreams = me->numStreams; - coder->numTotalBlocks = me->numTotalBlocks; - coder->numBlocks = me->numBlocks; - - if (!coder->dec_created) - { - XzUnpacker_Construct(&coder->dec, &me->alignOffsetAlloc.vt); - coder->dec_created = True; - } - - XzUnpacker_Init(&coder->dec); - - if (me->isBlockHeaderState_Parse) - { - coder->dec.streamFlags = me->streamFlags; - coder->atBlockHeader = True; - XzUnpacker_PrepareToRandomBlockDecoding(&coder->dec); - } - else - { - coder->atBlockHeader = False; - me->isBlockHeaderState_Parse = True; - } - - coder->dec.numStartedStreams = me->numStreams; - coder->dec.numTotalBlocks = me->numTotalBlocks; - coder->dec.numBlocks = me->numBlocks; - } - - while (!coder->skipMode) - { - ECoderStatus status; - SRes res; - size_t srcSize2 = srcSize; - size_t destSize = (size_t)0 - 1; - - coder->dec.parseMode = True; - coder->dec.headerParsedOk = False; - - PRF_STR_INT("Parse", srcSize2); - - res = XzUnpacker_Code(&coder->dec, - NULL, &destSize, - cc->src, &srcSize2, cc->srcFinished, - CODER_FINISH_END, &status); - - // PRF(printf(" res = %d, srcSize2 = %d", res, (unsigned)srcSize2)); - - coder->codeRes = res; - coder->status = status; - cc->srcSize += srcSize2; - srcSize -= srcSize2; - coder->inPreHeaderSize += srcSize2; - coder->inPreSize = coder->inPreHeaderSize; - - if (res != SZ_OK) - { - cc->state = - coder->parseState = MTDEC_PARSE_END; - /* - if (res == SZ_ERROR_MEM) - return res; - return SZ_OK; - */ - return; // res; - } - - if (coder->dec.headerParsedOk) - { - const CXzBlock *block = &coder->dec.block; - if (XzBlock_HasUnpackSize(block) - // && block->unpackSize <= me->props.outBlockMax - && XzBlock_HasPackSize(block)) - { - { - if (block->unpackSize * 2 * me->mtc.numStartedThreads > me->props.memUseMax) - { - cc->state = MTDEC_PARSE_OVERFLOW; - return; // SZ_OK; - } - } - { - UInt64 packSize = block->packSize; - UInt64 packSizeAligned = packSize + ((0 - (unsigned)packSize) & 3); - UInt32 checkSize = XzFlags_GetCheckSize(coder->dec.streamFlags); - UInt64 blockPackSum = coder->inPreSize + packSizeAligned + checkSize; - // if (blockPackSum <= me->props.inBlockMax) - // unpackBlockMaxSize - { - coder->blockPackSize_for_Index = (size_t)(coder->dec.blockHeaderSize + packSize + checkSize); - coder->blockPackTotal = (size_t)blockPackSum; - coder->outPreSize = (size_t)block->unpackSize; - coder->streamFlags = coder->dec.streamFlags; - me->streamFlags = coder->dec.streamFlags; - coder->skipMode = True; - break; - } - } - } - } - else - // if (coder->inPreSize <= me->props.inBlockMax) - { - if (!cc->srcFinished) - return; // SZ_OK; - cc->state = - coder->parseState = MTDEC_PARSE_END; - return; // SZ_OK; - } - cc->state = MTDEC_PARSE_OVERFLOW; - return; // SZ_OK; - } - - // ---------- skipMode ---------- - { - UInt64 rem = coder->blockPackTotal - coder->inPreSize; - size_t cur = srcSize; - if (cur > rem) - cur = (size_t)rem; - cc->srcSize += cur; - coder->inPreSize += cur; - srcSize -= cur; - - if (coder->inPreSize == coder->blockPackTotal) - { - if (srcSize == 0) - { - if (!cc->srcFinished) - return; // SZ_OK; - cc->state = MTDEC_PARSE_END; - } - else if ((cc->src)[cc->srcSize] == 0) // we check control byte of next block - cc->state = MTDEC_PARSE_END; - else - { - cc->state = MTDEC_PARSE_NEW; - - { - size_t blockMax = me->unpackBlockMaxSize; - if (blockMax < coder->outPreSize) - blockMax = coder->outPreSize; - { - UInt64 required = (UInt64)blockMax * (me->mtc.numStartedThreads + 1) * 2; - if (me->props.memUseMax < required) - cc->canCreateNewThread = False; - } - } - - if (me->outSize_Defined) - { - // next block can be zero size - const UInt64 rem2 = me->outSize - me->outProcessed_Parse; - if (rem2 < coder->outPreSize) - { - coder->parsing_Truncated = True; - cc->state = MTDEC_PARSE_END; - } - me->outProcessed_Parse += coder->outPreSize; - } - } - } - else if (cc->srcFinished) - cc->state = MTDEC_PARSE_END; - else - return; // SZ_OK; - - coder->parseState = cc->state; - cc->outPos = coder->outPreSize; - - me->numStreams = coder->dec.numStartedStreams; - me->numTotalBlocks = coder->dec.numTotalBlocks; - me->numBlocks = coder->dec.numBlocks + 1; - return; // SZ_OK; - } -} - - -static SRes XzDecMt_Callback_PreCode(void *pp, unsigned coderIndex) -{ - CXzDecMt *me = (CXzDecMt *)pp; - CXzDecMtThread *coder = &me->coders[coderIndex]; - Byte *dest; - - if (!coder->dec.headerParsedOk) - return SZ_OK; - - dest = coder->outBuf; - - if (!dest || coder->outBufSize < coder->outPreSize) - { - if (dest) - { - ISzAlloc_Free(me->allocMid, dest); - coder->outBuf = NULL; - coder->outBufSize = 0; - } - { - size_t outPreSize = coder->outPreSize; - if (outPreSize == 0) - outPreSize = 1; - dest = (Byte *)ISzAlloc_Alloc(me->allocMid, outPreSize); - } - if (!dest) - return SZ_ERROR_MEM; - coder->outBuf = dest; - coder->outBufSize = coder->outPreSize; - - if (coder->outBufSize > me->unpackBlockMaxSize) - me->unpackBlockMaxSize = coder->outBufSize; - } - - // return SZ_ERROR_MEM; - - XzUnpacker_SetOutBuf(&coder->dec, coder->outBuf, coder->outBufSize); - - { - SRes res = XzDecMix_Init(&coder->dec.decoder, &coder->dec.block, coder->outBuf, coder->outBufSize); - // res = SZ_ERROR_UNSUPPORTED; // to test - coder->codeRes = res; - if (res != SZ_OK) - { - // if (res == SZ_ERROR_MEM) return res; - if (me->props.ignoreErrors && res != SZ_ERROR_MEM) - return SZ_OK; - return res; - } - } - - return SZ_OK; -} - - -static SRes XzDecMt_Callback_Code(void *pp, unsigned coderIndex, - const Byte *src, size_t srcSize, int srcFinished, - // int finished, int blockFinished, - UInt64 *inCodePos, UInt64 *outCodePos, int *stop) -{ - CXzDecMt *me = (CXzDecMt *)pp; - CXzDecMtThread *coder = &me->coders[coderIndex]; - - *inCodePos = coder->inCodeSize; - *outCodePos = coder->outCodeSize; - *stop = True; - - if (srcSize > coder->inPreSize - coder->inCodeSize) - return SZ_ERROR_FAIL; - - if (coder->inCodeSize < coder->inPreHeaderSize) - { - size_t step = coder->inPreHeaderSize - coder->inCodeSize; - if (step > srcSize) - step = srcSize; - src += step; - srcSize -= step; - coder->inCodeSize += step; - *inCodePos = coder->inCodeSize; - if (coder->inCodeSize < coder->inPreHeaderSize) - { - *stop = False; - return SZ_OK; - } - } - - if (!coder->dec.headerParsedOk) - return SZ_OK; - if (!coder->outBuf) - return SZ_OK; - - if (coder->codeRes == SZ_OK) - { - ECoderStatus status; - SRes res; - size_t srcProcessed = srcSize; - size_t outSizeCur = coder->outPreSize - coder->dec.outDataWritten; - - // PRF(printf("\nCallback_Code: Code %d %d\n", (unsigned)srcSize, (unsigned)outSizeCur)); - - res = XzUnpacker_Code(&coder->dec, - NULL, &outSizeCur, - src, &srcProcessed, srcFinished, - // coder->finishedWithMark ? CODER_FINISH_END : CODER_FINISH_ANY, - CODER_FINISH_END, - &status); - - // PRF(printf(" res = %d, srcSize2 = %d, outSizeCur = %d", res, (unsigned)srcProcessed, (unsigned)outSizeCur)); - - coder->codeRes = res; - coder->status = status; - coder->inCodeSize += srcProcessed; - coder->outCodeSize = coder->dec.outDataWritten; - *inCodePos = coder->inCodeSize; - *outCodePos = coder->outCodeSize; - - if (res == SZ_OK) - { - if (srcProcessed == srcSize) - *stop = False; - return SZ_OK; - } - } - - if (me->props.ignoreErrors && coder->codeRes != SZ_ERROR_MEM) - { - *inCodePos = coder->inPreSize; - *outCodePos = coder->outPreSize; - return SZ_OK; - } - return coder->codeRes; -} - - -#define XZDECMT_STREAM_WRITE_STEP (1 << 24) - -static SRes XzDecMt_Callback_Write(void *pp, unsigned coderIndex, - BoolInt needWriteToStream, - const Byte *src, size_t srcSize, BoolInt isCross, - // int srcFinished, - BoolInt *needContinue, - BoolInt *canRecode) -{ - CXzDecMt *me = (CXzDecMt *)pp; - const CXzDecMtThread *coder = &me->coders[coderIndex]; - - // PRF(printf("\nWrite processed = %d srcSize = %d\n", (unsigned)me->mtc.inProcessed, (unsigned)srcSize)); - - *needContinue = False; - *canRecode = True; - - if (!needWriteToStream) - return SZ_OK; - - if (!coder->dec.headerParsedOk || !coder->outBuf) - { - if (me->finishedDecoderIndex < 0) - me->finishedDecoderIndex = (int)coderIndex; - return SZ_OK; - } - - if (me->finishedDecoderIndex >= 0) - return SZ_OK; - - me->mtc.inProcessed += coder->inCodeSize; - - *canRecode = False; - - { - SRes res; - size_t size = coder->outCodeSize; - Byte *data = coder->outBuf; - - // we use in me->dec: sha, numBlocks, indexSize - - if (!me->isBlockHeaderState_Write) - { - XzUnpacker_PrepareToRandomBlockDecoding(&me->dec); - me->dec.decodeOnlyOneBlock = False; - me->dec.numStartedStreams = coder->dec.numStartedStreams; - me->dec.streamFlags = coder->streamFlags; - - me->isBlockHeaderState_Write = True; - } - - me->dec.numTotalBlocks = coder->dec.numTotalBlocks; - XzUnpacker_UpdateIndex(&me->dec, coder->blockPackSize_for_Index, coder->outPreSize); - - if (coder->outPreSize != size) - { - if (me->props.ignoreErrors) - { - memset(data + size, 0, coder->outPreSize - size); - size = coder->outPreSize; - } - // me->numBadBlocks++; - if (me->mainErrorCode == SZ_OK) - { - if ((int)coder->status == LZMA_STATUS_NEEDS_MORE_INPUT) - me->mainErrorCode = SZ_ERROR_INPUT_EOF; - else - me->mainErrorCode = SZ_ERROR_DATA; - } - } - - if (me->writeRes != SZ_OK) - return me->writeRes; - - res = SZ_OK; - { - if (me->outSize_Defined) - { - const UInt64 rem = me->outSize - me->outProcessed; - if (size > rem) - size = (SizeT)rem; - } - - for (;;) - { - size_t cur = size; - size_t written; - if (cur > XZDECMT_STREAM_WRITE_STEP) - cur = XZDECMT_STREAM_WRITE_STEP; - - written = ISeqOutStream_Write(me->outStream, data, cur); - - // PRF(printf("\nWritten ask = %d written = %d\n", (unsigned)cur, (unsigned)written)); - - me->outProcessed += written; - if (written != cur) - { - me->writeRes = SZ_ERROR_WRITE; - res = me->writeRes; - break; - } - data += cur; - size -= cur; - // PRF_STR_INT("Written size =", size); - if (size == 0) - break; - res = MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0); - if (res != SZ_OK) - break; - } - } - - if (coder->codeRes != SZ_OK) - if (!me->props.ignoreErrors) - { - me->finishedDecoderIndex = (int)coderIndex; - return res; - } - - RINOK(res); - - if (coder->inPreSize != coder->inCodeSize - || coder->blockPackTotal != coder->inCodeSize) - { - me->finishedDecoderIndex = (int)coderIndex; - return SZ_OK; - } - - if (coder->parseState != MTDEC_PARSE_END) - { - *needContinue = True; - return SZ_OK; - } - } - - // (coder->state == MTDEC_PARSE_END) means that there are no other working threads - // so we can use mtc variables without lock - - PRF_STR_INT("Write MTDEC_PARSE_END", me->mtc.inProcessed); - - me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; - { - CXzUnpacker *dec = &me->dec; - - PRF_STR_INT("PostSingle", srcSize); - - { - size_t srcProcessed = srcSize; - ECoderStatus status; - size_t outSizeCur = 0; - SRes res; - - // dec->decodeOnlyOneBlock = False; - dec->decodeToStreamSignature = True; - - me->mainDecoderWasCalled = True; - - if (coder->parsing_Truncated) - { - me->parsing_Truncated = True; - return SZ_OK; - } - - /* - We have processed all xz-blocks of stream, - And xz unpacker is at XZ_STATE_BLOCK_HEADER state, where - (src) is a pointer to xz-Index structure. - We finish reading of current xz-Stream, including Zero padding after xz-Stream. - We exit, if we reach extra byte (first byte of new-Stream or another data). - But we don't update input stream pointer for that new extra byte. - If extra byte is not correct first byte of xz-signature, - we have SZ_ERROR_NO_ARCHIVE error here. - */ - - res = XzUnpacker_Code(dec, - NULL, &outSizeCur, - src, &srcProcessed, - me->mtc.readWasFinished, // srcFinished - CODER_FINISH_END, // CODER_FINISH_ANY, - &status); - - // res = SZ_ERROR_ARCHIVE; // for failure test - - me->status = status; - me->codeRes = res; - - if (isCross) - me->mtc.crossStart += srcProcessed; - - me->mtc.inProcessed += srcProcessed; - me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; - - srcSize -= srcProcessed; - src += srcProcessed; - - if (res != SZ_OK) - { - return SZ_OK; - // return res; - } - - if (dec->state == XZ_STATE_STREAM_HEADER) - { - *needContinue = True; - me->isBlockHeaderState_Parse = False; - me->isBlockHeaderState_Write = False; - - if (!isCross) - { - Byte *crossBuf = MtDec_GetCrossBuff(&me->mtc); - if (!crossBuf) - return SZ_ERROR_MEM; - if (srcSize != 0) - memcpy(crossBuf, src, srcSize); - me->mtc.crossStart = 0; - me->mtc.crossEnd = srcSize; - } - - PRF_STR_INT("XZ_STATE_STREAM_HEADER crossEnd = ", (unsigned)me->mtc.crossEnd); - - return SZ_OK; - } - - if (status != CODER_STATUS_NEEDS_MORE_INPUT || srcSize != 0) - { - return SZ_ERROR_FAIL; - } - - if (me->mtc.readWasFinished) - { - return SZ_OK; - } - } - - { - size_t inPos; - size_t inLim; - // const Byte *inData; - UInt64 inProgressPrev = me->mtc.inProcessed; - - // XzDecMt_Prepare_InBuf_ST(p); - Byte *crossBuf = MtDec_GetCrossBuff(&me->mtc); - if (!crossBuf) - return SZ_ERROR_MEM; - - inPos = 0; - inLim = 0; - - // inData = crossBuf; - - for (;;) - { - SizeT inProcessed; - SizeT outProcessed; - ECoderStatus status; - SRes res; - - if (inPos == inLim) - { - if (!me->mtc.readWasFinished) - { - inPos = 0; - inLim = me->mtc.inBufSize; - me->mtc.readRes = ISeqInStream_Read(me->inStream, (void *)crossBuf, &inLim); - me->mtc.readProcessed += inLim; - if (inLim == 0 || me->mtc.readRes != SZ_OK) - me->mtc.readWasFinished = True; - } - } - - inProcessed = inLim - inPos; - outProcessed = 0; - - res = XzUnpacker_Code(dec, - NULL, &outProcessed, - crossBuf + inPos, &inProcessed, - (inProcessed == 0), // srcFinished - CODER_FINISH_END, &status); - - me->codeRes = res; - me->status = status; - inPos += inProcessed; - me->mtc.inProcessed += inProcessed; - me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; - - if (res != SZ_OK) - { - return SZ_OK; - // return res; - } - - if (dec->state == XZ_STATE_STREAM_HEADER) - { - *needContinue = True; - me->mtc.crossStart = inPos; - me->mtc.crossEnd = inLim; - me->isBlockHeaderState_Parse = False; - me->isBlockHeaderState_Write = False; - return SZ_OK; - } - - if (status != CODER_STATUS_NEEDS_MORE_INPUT) - return SZ_ERROR_FAIL; - - if (me->mtc.progress) - { - UInt64 inDelta = me->mtc.inProcessed - inProgressPrev; - if (inDelta >= (1 << 22)) - { - RINOK(MtProgress_Progress_ST(&me->mtc.mtProgress)); - inProgressPrev = me->mtc.inProcessed; - } - } - if (me->mtc.readWasFinished) - return SZ_OK; - } - } - } -} - - -#endif - - - -void XzStatInfo_Clear(CXzStatInfo *p) -{ - p->InSize = 0; - p->OutSize = 0; - - p->NumStreams = 0; - p->NumBlocks = 0; - - p->UnpackSize_Defined = False; - - p->NumStreams_Defined = False; - p->NumBlocks_Defined = False; - - p->DataAfterEnd = False; - p->DecodingTruncated = False; - - p->DecodeRes = SZ_OK; - p->ReadRes = SZ_OK; - p->ProgressRes = SZ_OK; - - p->CombinedRes = SZ_OK; - p->CombinedRes_Type = SZ_OK; -} - - - -/* - XzDecMt_Decode_ST() can return SZ_OK or the following errors - - SZ_ERROR_MEM for memory allocation error - - error from XzUnpacker_Code() function - - SZ_ERROR_WRITE for ISeqOutStream::Write(). stat->CombinedRes_Type = SZ_ERROR_WRITE in that case - - ICompressProgress::Progress() error, stat->CombinedRes_Type = SZ_ERROR_PROGRESS. - But XzDecMt_Decode_ST() doesn't return ISeqInStream::Read() errors. - ISeqInStream::Read() result is set to p->readRes. - also it can set stat->CombinedRes_Type to SZ_ERROR_WRITE or SZ_ERROR_PROGRESS. -*/ - -static SRes XzDecMt_Decode_ST(CXzDecMt *p - #ifndef _7ZIP_ST - , BoolInt tMode - #endif - , CXzStatInfo *stat) -{ - size_t outPos; - size_t inPos, inLim; - const Byte *inData; - UInt64 inPrev, outPrev; - - CXzUnpacker *dec; - - #ifndef _7ZIP_ST - if (tMode) - { - XzDecMt_FreeOutBufs(p); - tMode = MtDec_PrepareRead(&p->mtc); - } - #endif - - if (!p->outBuf || p->outBufSize != p->props.outStep_ST) - { - ISzAlloc_Free(p->allocMid, p->outBuf); - p->outBufSize = 0; - p->outBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.outStep_ST); - if (!p->outBuf) - return SZ_ERROR_MEM; - p->outBufSize = p->props.outStep_ST; - } - - if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) - { - ISzAlloc_Free(p->allocMid, p->inBuf); - p->inBufSize = 0; - p->inBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.inBufSize_ST); - if (!p->inBuf) - return SZ_ERROR_MEM; - p->inBufSize = p->props.inBufSize_ST; - } - - dec = &p->dec; - dec->decodeToStreamSignature = False; - // dec->decodeOnlyOneBlock = False; - - XzUnpacker_SetOutBuf(dec, NULL, 0); - - inPrev = p->inProcessed; - outPrev = p->outProcessed; - - inPos = 0; - inLim = 0; - inData = NULL; - outPos = 0; - - for (;;) - { - SizeT outSize; - BoolInt finished; - ECoderFinishMode finishMode; - SizeT inProcessed; - ECoderStatus status; - SRes res; - - SizeT outProcessed; - - - - if (inPos == inLim) - { - #ifndef _7ZIP_ST - if (tMode) - { - inData = MtDec_Read(&p->mtc, &inLim); - inPos = 0; - if (inData) - continue; - tMode = False; - inLim = 0; - } - #endif - - if (!p->readWasFinished) - { - inPos = 0; - inLim = p->inBufSize; - inData = p->inBuf; - p->readRes = ISeqInStream_Read(p->inStream, (void *)p->inBuf, &inLim); - p->readProcessed += inLim; - if (inLim == 0 || p->readRes != SZ_OK) - p->readWasFinished = True; - } - } - - outSize = p->props.outStep_ST - outPos; - - finishMode = CODER_FINISH_ANY; - if (p->outSize_Defined) - { - const UInt64 rem = p->outSize - p->outProcessed; - if (outSize >= rem) - { - outSize = (SizeT)rem; - if (p->finishMode) - finishMode = CODER_FINISH_END; - } - } - - inProcessed = inLim - inPos; - outProcessed = outSize; - - res = XzUnpacker_Code(dec, p->outBuf + outPos, &outProcessed, - inData + inPos, &inProcessed, - (inPos == inLim), // srcFinished - finishMode, &status); - - p->codeRes = res; - p->status = status; - - inPos += inProcessed; - outPos += outProcessed; - p->inProcessed += inProcessed; - p->outProcessed += outProcessed; - - finished = ((inProcessed == 0 && outProcessed == 0) || res != SZ_OK); - - if (finished || outProcessed >= outSize) - if (outPos != 0) - { - const size_t written = ISeqOutStream_Write(p->outStream, p->outBuf, outPos); - // p->outProcessed += written; // 21.01: BUG fixed - if (written != outPos) - { - stat->CombinedRes_Type = SZ_ERROR_WRITE; - return SZ_ERROR_WRITE; - } - outPos = 0; - } - - if (p->progress && res == SZ_OK) - { - if (p->inProcessed - inPrev >= (1 << 22) || - p->outProcessed - outPrev >= (1 << 22)) - { - res = ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed); - if (res != SZ_OK) - { - stat->CombinedRes_Type = SZ_ERROR_PROGRESS; - stat->ProgressRes = res; - return res; - } - inPrev = p->inProcessed; - outPrev = p->outProcessed; - } - } - - if (finished) - { - // p->codeRes is preliminary error from XzUnpacker_Code. - // and it can be corrected later as final result - // so we return SZ_OK here instead of (res); - return SZ_OK; - // return res; - } - } -} - - - -/* -XzStatInfo_SetStat() transforms - CXzUnpacker return code and status to combined CXzStatInfo results. - it can convert SZ_OK to SZ_ERROR_INPUT_EOF - it can convert SZ_ERROR_NO_ARCHIVE to SZ_OK and (DataAfterEnd = 1) -*/ - -static void XzStatInfo_SetStat(const CXzUnpacker *dec, - int finishMode, - // UInt64 readProcessed, - UInt64 inProcessed, - SRes res, // it's result from CXzUnpacker unpacker - ECoderStatus status, - BoolInt decodingTruncated, - CXzStatInfo *stat) -{ - UInt64 extraSize; - - stat->DecodingTruncated = (Byte)(decodingTruncated ? 1 : 0); - stat->InSize = inProcessed; - stat->NumStreams = dec->numStartedStreams; - stat->NumBlocks = dec->numTotalBlocks; - - stat->UnpackSize_Defined = True; - stat->NumStreams_Defined = True; - stat->NumBlocks_Defined = True; - - extraSize = XzUnpacker_GetExtraSize(dec); - - if (res == SZ_OK) - { - if (status == CODER_STATUS_NEEDS_MORE_INPUT) - { - // CODER_STATUS_NEEDS_MORE_INPUT is expected status for correct xz streams - // any extra data is part of correct data - extraSize = 0; - // if xz stream was not finished, then we need more data - if (!XzUnpacker_IsStreamWasFinished(dec)) - res = SZ_ERROR_INPUT_EOF; - } - else - { - // CODER_STATUS_FINISHED_WITH_MARK is not possible for multi stream xz decoding - // so he we have (status == CODER_STATUS_NOT_FINISHED) - // if (status != CODER_STATUS_FINISHED_WITH_MARK) - if (!decodingTruncated || finishMode) - res = SZ_ERROR_DATA; - } - } - else if (res == SZ_ERROR_NO_ARCHIVE) - { - /* - SZ_ERROR_NO_ARCHIVE is possible for 2 states: - XZ_STATE_STREAM_HEADER - if bad signature or bad CRC - XZ_STATE_STREAM_PADDING - if non-zero padding data - extraSize and inProcessed don't include "bad" byte - */ - // if (inProcessed == extraSize), there was no any good xz stream header, and we keep error - if (inProcessed != extraSize) // if there were good xz streams before error - { - // if (extraSize != 0 || readProcessed != inProcessed) - { - // he we suppose that all xz streams were finsihed OK, and we have - // some extra data after all streams - stat->DataAfterEnd = True; - res = SZ_OK; - } - } - } - - if (stat->DecodeRes == SZ_OK) - stat->DecodeRes = res; - - stat->InSize -= extraSize; -} - - - -SRes XzDecMt_Decode(CXzDecMtHandle pp, - const CXzDecMtProps *props, - const UInt64 *outDataSize, int finishMode, - ISeqOutStream *outStream, - // Byte *outBuf, size_t *outBufSize, - ISeqInStream *inStream, - // const Byte *inData, size_t inDataSize, - CXzStatInfo *stat, - int *isMT, - ICompressProgress *progress) -{ - CXzDecMt *p = (CXzDecMt *)pp; - #ifndef _7ZIP_ST - BoolInt tMode; - #endif - - XzStatInfo_Clear(stat); - - p->props = *props; - - p->inStream = inStream; - p->outStream = outStream; - p->progress = progress; - // p->stat = stat; - - p->outSize = 0; - p->outSize_Defined = False; - if (outDataSize) - { - p->outSize_Defined = True; - p->outSize = *outDataSize; - } - - p->finishMode = finishMode; - - // p->outSize = 457; p->outSize_Defined = True; p->finishMode = False; // for test - - p->writeRes = SZ_OK; - p->outProcessed = 0; - p->inProcessed = 0; - p->readProcessed = 0; - p->readWasFinished = False; - p->readRes = SZ_OK; - - p->codeRes = SZ_OK; - p->status = CODER_STATUS_NOT_SPECIFIED; - - XzUnpacker_Init(&p->dec); - - *isMT = False; - - /* - p->outBuf = NULL; - p->outBufSize = 0; - if (!outStream) - { - p->outBuf = outBuf; - p->outBufSize = *outBufSize; - *outBufSize = 0; - } - */ - - - #ifndef _7ZIP_ST - - p->isBlockHeaderState_Parse = False; - p->isBlockHeaderState_Write = False; - // p->numBadBlocks = 0; - p->mainErrorCode = SZ_OK; - p->mainDecoderWasCalled = False; - - tMode = False; - - if (p->props.numThreads > 1) - { - IMtDecCallback2 vt; - BoolInt needContinue; - SRes res; - // we just free ST buffers here - // but we still keep state variables, that was set in XzUnpacker_Init() - XzDecMt_FreeSt(p); - - p->outProcessed_Parse = 0; - p->parsing_Truncated = False; - - p->numStreams = 0; - p->numTotalBlocks = 0; - p->numBlocks = 0; - p->finishedDecoderIndex = -1; - - if (!p->mtc_WasConstructed) - { - p->mtc_WasConstructed = True; - MtDec_Construct(&p->mtc); - } - - p->mtc.mtCallback = &vt; - p->mtc.mtCallbackObject = p; - - p->mtc.progress = progress; - p->mtc.inStream = inStream; - p->mtc.alloc = &p->alignOffsetAlloc.vt; - // p->mtc.inData = inData; - // p->mtc.inDataSize = inDataSize; - p->mtc.inBufSize = p->props.inBufSize_MT; - // p->mtc.inBlockMax = p->props.inBlockMax; - p->mtc.numThreadsMax = p->props.numThreads; - - *isMT = True; - - vt.Parse = XzDecMt_Callback_Parse; - vt.PreCode = XzDecMt_Callback_PreCode; - vt.Code = XzDecMt_Callback_Code; - vt.Write = XzDecMt_Callback_Write; - - - res = MtDec_Code(&p->mtc); - - - stat->InSize = p->mtc.inProcessed; - - p->inProcessed = p->mtc.inProcessed; - p->readRes = p->mtc.readRes; - p->readWasFinished = p->mtc.readWasFinished; - p->readProcessed = p->mtc.readProcessed; - - tMode = True; - needContinue = False; - - if (res == SZ_OK) - { - if (p->mtc.mtProgress.res != SZ_OK) - { - res = p->mtc.mtProgress.res; - stat->ProgressRes = res; - stat->CombinedRes_Type = SZ_ERROR_PROGRESS; - } - else - needContinue = p->mtc.needContinue; - } - - if (!needContinue) - { - { - SRes codeRes; - BoolInt truncated = False; - ECoderStatus status; - const CXzUnpacker *dec; - - stat->OutSize = p->outProcessed; - - if (p->finishedDecoderIndex >= 0) - { - const CXzDecMtThread *coder = &p->coders[(unsigned)p->finishedDecoderIndex]; - codeRes = coder->codeRes; - dec = &coder->dec; - status = coder->status; - } - else if (p->mainDecoderWasCalled) - { - codeRes = p->codeRes; - dec = &p->dec; - status = p->status; - truncated = p->parsing_Truncated; - } - else - return SZ_ERROR_FAIL; - - if (p->mainErrorCode != SZ_OK) - stat->DecodeRes = p->mainErrorCode; - - XzStatInfo_SetStat(dec, p->finishMode, - // p->mtc.readProcessed, - p->mtc.inProcessed, - codeRes, status, - truncated, - stat); - } - - if (res == SZ_OK) - { - stat->ReadRes = p->mtc.readRes; - - if (p->writeRes != SZ_OK) - { - res = p->writeRes; - stat->CombinedRes_Type = SZ_ERROR_WRITE; - } - else if (p->mtc.readRes != SZ_OK - // && p->mtc.inProcessed == p->mtc.readProcessed - && stat->DecodeRes == SZ_ERROR_INPUT_EOF) - { - res = p->mtc.readRes; - stat->CombinedRes_Type = SZ_ERROR_READ; - } - else if (stat->DecodeRes != SZ_OK) - res = stat->DecodeRes; - } - - stat->CombinedRes = res; - if (stat->CombinedRes_Type == SZ_OK) - stat->CombinedRes_Type = res; - return res; - } - - PRF_STR("----- decoding ST -----"); - } - - #endif - - - *isMT = False; - - { - SRes res = XzDecMt_Decode_ST(p - #ifndef _7ZIP_ST - , tMode - #endif - , stat - ); - - #ifndef _7ZIP_ST - // we must set error code from MT decoding at first - if (p->mainErrorCode != SZ_OK) - stat->DecodeRes = p->mainErrorCode; - #endif - - XzStatInfo_SetStat(&p->dec, - p->finishMode, - // p->readProcessed, - p->inProcessed, - p->codeRes, p->status, - False, // truncated - stat); - - stat->ReadRes = p->readRes; - - if (res == SZ_OK) - { - if (p->readRes != SZ_OK - // && p->inProcessed == p->readProcessed - && stat->DecodeRes == SZ_ERROR_INPUT_EOF) - { - // we set read error as combined error, only if that error was the reason - // of decoding problem - res = p->readRes; - stat->CombinedRes_Type = SZ_ERROR_READ; - } - else if (stat->DecodeRes != SZ_OK) - res = stat->DecodeRes; - } - - stat->CombinedRes = res; - if (stat->CombinedRes_Type == SZ_OK) - stat->CombinedRes_Type = res; - return res; - } -} +/* XzDec.c -- Xz Decode +2021-09-04 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +// #include + +// #define XZ_DUMP + +/* #define XZ_DUMP */ + +#ifdef XZ_DUMP +#include +#endif + +// #define SHOW_DEBUG_INFO + +#ifdef SHOW_DEBUG_INFO +#include +#endif + +#ifdef SHOW_DEBUG_INFO +#define PRF(x) x +#else +#define PRF(x) +#endif + +#define PRF_STR(s) PRF(printf("\n" s "\n")) +#define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) + +#include +#include + +#include "7zCrc.h" +#include "Alloc.h" +#include "Bra.h" +#include "CpuArch.h" +#include "Delta.h" +#include "Lzma2Dec.h" + +// #define USE_SUBBLOCK + +#ifdef USE_SUBBLOCK +#include "Bcj3Dec.c" +#include "SbDec.h" +#endif + +#include "Xz.h" + +#define XZ_CHECK_SIZE_MAX 64 + +#define CODER_BUF_SIZE ((size_t)1 << 17) + +unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value) +{ + unsigned i, limit; + *value = 0; + limit = (maxSize > 9) ? 9 : (unsigned)maxSize; + + for (i = 0; i < limit;) + { + Byte b = p[i]; + *value |= (UInt64)(b & 0x7F) << (7 * i++); + if ((b & 0x80) == 0) + return (b == 0 && i != 1) ? 0 : i; + } + return 0; +} + +/* ---------- BraState ---------- */ + +#define BRA_BUF_SIZE (1 << 14) + +typedef struct +{ + size_t bufPos; + size_t bufConv; + size_t bufTotal; + + int encodeMode; + + UInt32 methodId; + UInt32 delta; + UInt32 ip; + UInt32 x86State; + Byte deltaState[DELTA_STATE_SIZE]; + + Byte buf[BRA_BUF_SIZE]; +} CBraState; + +static void BraState_Free(void *pp, ISzAllocPtr alloc) +{ + ISzAlloc_Free(alloc, pp); +} + +static SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAllocPtr alloc) +{ + CBraState *p = ((CBraState *)pp); + UNUSED_VAR(alloc); + p->ip = 0; + if (p->methodId == XZ_ID_Delta) + { + if (propSize != 1) + return SZ_ERROR_UNSUPPORTED; + p->delta = (unsigned)props[0] + 1; + } + else + { + if (propSize == 4) + { + UInt32 v = GetUi32(props); + switch (p->methodId) + { + case XZ_ID_PPC: + case XZ_ID_ARM: + case XZ_ID_SPARC: + if ((v & 3) != 0) + return SZ_ERROR_UNSUPPORTED; + break; + case XZ_ID_ARMT: + if ((v & 1) != 0) + return SZ_ERROR_UNSUPPORTED; + break; + case XZ_ID_IA64: + if ((v & 0xF) != 0) + return SZ_ERROR_UNSUPPORTED; + break; + } + p->ip = v; + } + else if (propSize != 0) + return SZ_ERROR_UNSUPPORTED; + } + return SZ_OK; +} + +static void BraState_Init(void *pp) +{ + CBraState *p = ((CBraState *)pp); + p->bufPos = p->bufConv = p->bufTotal = 0; + x86_Convert_Init(p->x86State); + if (p->methodId == XZ_ID_Delta) + Delta_Init(p->deltaState); +} + + +#define CASE_BRA_CONV(isa) case XZ_ID_ ## isa: size = isa ## _Convert(data, size, p->ip, p->encodeMode); break; + +static SizeT BraState_Filter(void *pp, Byte *data, SizeT size) +{ + CBraState *p = ((CBraState *)pp); + switch (p->methodId) + { + case XZ_ID_Delta: + if (p->encodeMode) + Delta_Encode(p->deltaState, p->delta, data, size); + else + Delta_Decode(p->deltaState, p->delta, data, size); + break; + case XZ_ID_X86: + size = x86_Convert(data, size, p->ip, &p->x86State, p->encodeMode); + break; + CASE_BRA_CONV(PPC) + CASE_BRA_CONV(IA64) + CASE_BRA_CONV(ARM) + CASE_BRA_CONV(ARMT) + CASE_BRA_CONV(SPARC) + } + p->ip += (UInt32)size; + return size; +} + + +static SRes BraState_Code2(void *pp, + Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, int srcWasFinished, + ECoderFinishMode finishMode, + // int *wasFinished + ECoderStatus *status) +{ + CBraState *p = ((CBraState *)pp); + SizeT destRem = *destLen; + SizeT srcRem = *srcLen; + UNUSED_VAR(finishMode); + + *destLen = 0; + *srcLen = 0; + // *wasFinished = False; + *status = CODER_STATUS_NOT_FINISHED; + + while (destRem > 0) + { + if (p->bufPos != p->bufConv) + { + size_t size = p->bufConv - p->bufPos; + if (size > destRem) + size = destRem; + memcpy(dest, p->buf + p->bufPos, size); + p->bufPos += size; + *destLen += size; + dest += size; + destRem -= size; + continue; + } + + p->bufTotal -= p->bufPos; + memmove(p->buf, p->buf + p->bufPos, p->bufTotal); + p->bufPos = 0; + p->bufConv = 0; + { + size_t size = BRA_BUF_SIZE - p->bufTotal; + if (size > srcRem) + size = srcRem; + memcpy(p->buf + p->bufTotal, src, size); + *srcLen += size; + src += size; + srcRem -= size; + p->bufTotal += size; + } + if (p->bufTotal == 0) + break; + + p->bufConv = BraState_Filter(pp, p->buf, p->bufTotal); + + if (p->bufConv == 0) + { + if (!srcWasFinished) + break; + p->bufConv = p->bufTotal; + } + } + + if (p->bufTotal == p->bufPos && srcRem == 0 && srcWasFinished) + { + *status = CODER_STATUS_FINISHED_WITH_MARK; + // *wasFinished = 1; + } + + return SZ_OK; +} + + +SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc); +SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc) +{ + CBraState *decoder; + if (id < XZ_ID_Delta || id > XZ_ID_SPARC) + return SZ_ERROR_UNSUPPORTED; + decoder = (CBraState *)p->p; + if (!decoder) + { + decoder = (CBraState *)ISzAlloc_Alloc(alloc, sizeof(CBraState)); + if (!decoder) + return SZ_ERROR_MEM; + p->p = decoder; + p->Free = BraState_Free; + p->SetProps = BraState_SetProps; + p->Init = BraState_Init; + p->Code2 = BraState_Code2; + p->Filter = BraState_Filter; + } + decoder->methodId = (UInt32)id; + decoder->encodeMode = encodeMode; + return SZ_OK; +} + + + +/* ---------- SbState ---------- */ + +#ifdef USE_SUBBLOCK + +static void SbState_Free(void *pp, ISzAllocPtr alloc) +{ + CSbDec *p = (CSbDec *)pp; + SbDec_Free(p); + ISzAlloc_Free(alloc, pp); +} + +static SRes SbState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAllocPtr alloc) +{ + UNUSED_VAR(pp); + UNUSED_VAR(props); + UNUSED_VAR(alloc); + return (propSize == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED; +} + +static void SbState_Init(void *pp) +{ + SbDec_Init((CSbDec *)pp); +} + +static SRes SbState_Code2(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + int srcWasFinished, ECoderFinishMode finishMode, + // int *wasFinished + ECoderStatus *status) +{ + CSbDec *p = (CSbDec *)pp; + SRes res; + UNUSED_VAR(srcWasFinished); + p->dest = dest; + p->destLen = *destLen; + p->src = src; + p->srcLen = *srcLen; + p->finish = finishMode; /* change it */ + res = SbDec_Decode((CSbDec *)pp); + *destLen -= p->destLen; + *srcLen -= p->srcLen; + // *wasFinished = (*destLen == 0 && *srcLen == 0); /* change it */ + *status = (*destLen == 0 && *srcLen == 0) ? + CODER_STATUS_FINISHED_WITH_MARK : + CODER_STATUS_NOT_FINISHED; + return res; +} + +static SRes SbState_SetFromMethod(IStateCoder *p, ISzAllocPtr alloc) +{ + CSbDec *decoder = (CSbDec *)p->p; + if (!decoder) + { + decoder = (CSbDec *)ISzAlloc_Alloc(alloc, sizeof(CSbDec)); + if (!decoder) + return SZ_ERROR_MEM; + p->p = decoder; + p->Free = SbState_Free; + p->SetProps = SbState_SetProps; + p->Init = SbState_Init; + p->Code2 = SbState_Code2; + p->Filter = NULL; + } + SbDec_Construct(decoder); + SbDec_SetAlloc(decoder, alloc); + return SZ_OK; +} + +#endif + + + +/* ---------- Lzma2 ---------- */ + +typedef struct +{ + CLzma2Dec decoder; + BoolInt outBufMode; +} CLzma2Dec_Spec; + + +static void Lzma2State_Free(void *pp, ISzAllocPtr alloc) +{ + CLzma2Dec_Spec *p = (CLzma2Dec_Spec *)pp; + if (p->outBufMode) + Lzma2Dec_FreeProbs(&p->decoder, alloc); + else + Lzma2Dec_Free(&p->decoder, alloc); + ISzAlloc_Free(alloc, pp); +} + +static SRes Lzma2State_SetProps(void *pp, const Byte *props, size_t propSize, ISzAllocPtr alloc) +{ + if (propSize != 1) + return SZ_ERROR_UNSUPPORTED; + { + CLzma2Dec_Spec *p = (CLzma2Dec_Spec *)pp; + if (p->outBufMode) + return Lzma2Dec_AllocateProbs(&p->decoder, props[0], alloc); + else + return Lzma2Dec_Allocate(&p->decoder, props[0], alloc); + } +} + +static void Lzma2State_Init(void *pp) +{ + Lzma2Dec_Init(&((CLzma2Dec_Spec *)pp)->decoder); +} + + +/* + if (outBufMode), then (dest) is not used. Use NULL. + Data is unpacked to (spec->decoder.decoder.dic) output buffer. +*/ + +static SRes Lzma2State_Code2(void *pp, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + int srcWasFinished, ECoderFinishMode finishMode, + // int *wasFinished, + ECoderStatus *status) +{ + CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)pp; + ELzmaStatus status2; + /* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */ + SRes res; + UNUSED_VAR(srcWasFinished); + if (spec->outBufMode) + { + SizeT dicPos = spec->decoder.decoder.dicPos; + SizeT dicLimit = dicPos + *destLen; + res = Lzma2Dec_DecodeToDic(&spec->decoder, dicLimit, src, srcLen, (ELzmaFinishMode)finishMode, &status2); + *destLen = spec->decoder.decoder.dicPos - dicPos; + } + else + res = Lzma2Dec_DecodeToBuf(&spec->decoder, dest, destLen, src, srcLen, (ELzmaFinishMode)finishMode, &status2); + // *wasFinished = (status2 == LZMA_STATUS_FINISHED_WITH_MARK); + // ECoderStatus values are identical to ELzmaStatus values of LZMA2 decoder + *status = (ECoderStatus)status2; + return res; +} + + +static SRes Lzma2State_SetFromMethod(IStateCoder *p, Byte *outBuf, size_t outBufSize, ISzAllocPtr alloc) +{ + CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)p->p; + if (!spec) + { + spec = (CLzma2Dec_Spec *)ISzAlloc_Alloc(alloc, sizeof(CLzma2Dec_Spec)); + if (!spec) + return SZ_ERROR_MEM; + p->p = spec; + p->Free = Lzma2State_Free; + p->SetProps = Lzma2State_SetProps; + p->Init = Lzma2State_Init; + p->Code2 = Lzma2State_Code2; + p->Filter = NULL; + Lzma2Dec_Construct(&spec->decoder); + } + spec->outBufMode = False; + if (outBuf) + { + spec->outBufMode = True; + spec->decoder.decoder.dic = outBuf; + spec->decoder.decoder.dicBufSize = outBufSize; + } + return SZ_OK; +} + + +static SRes Lzma2State_ResetOutBuf(IStateCoder *p, Byte *outBuf, size_t outBufSize) +{ + CLzma2Dec_Spec *spec = (CLzma2Dec_Spec *)p->p; + if ((spec->outBufMode && !outBuf) || (!spec->outBufMode && outBuf)) + return SZ_ERROR_FAIL; + if (outBuf) + { + spec->decoder.decoder.dic = outBuf; + spec->decoder.decoder.dicBufSize = outBufSize; + } + return SZ_OK; +} + + + +static void MixCoder_Construct(CMixCoder *p, ISzAllocPtr alloc) +{ + unsigned i; + p->alloc = alloc; + p->buf = NULL; + p->numCoders = 0; + + p->outBufSize = 0; + p->outBuf = NULL; + // p->SingleBufMode = False; + + for (i = 0; i < MIXCODER_NUM_FILTERS_MAX; i++) + p->coders[i].p = NULL; +} + + +static void MixCoder_Free(CMixCoder *p) +{ + unsigned i; + p->numCoders = 0; + for (i = 0; i < MIXCODER_NUM_FILTERS_MAX; i++) + { + IStateCoder *sc = &p->coders[i]; + if (sc->p) + { + sc->Free(sc->p, p->alloc); + sc->p = NULL; + } + } + if (p->buf) + { + ISzAlloc_Free(p->alloc, p->buf); + p->buf = NULL; /* 9.31: the BUG was fixed */ + } +} + +static void MixCoder_Init(CMixCoder *p) +{ + unsigned i; + for (i = 0; i < MIXCODER_NUM_FILTERS_MAX - 1; i++) + { + p->size[i] = 0; + p->pos[i] = 0; + p->finished[i] = 0; + } + for (i = 0; i < p->numCoders; i++) + { + IStateCoder *coder = &p->coders[i]; + coder->Init(coder->p); + p->results[i] = SZ_OK; + } + p->outWritten = 0; + p->wasFinished = False; + p->res = SZ_OK; + p->status = CODER_STATUS_NOT_SPECIFIED; +} + + +static SRes MixCoder_SetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId, Byte *outBuf, size_t outBufSize) +{ + IStateCoder *sc = &p->coders[coderIndex]; + p->ids[coderIndex] = methodId; + switch (methodId) + { + case XZ_ID_LZMA2: return Lzma2State_SetFromMethod(sc, outBuf, outBufSize, p->alloc); + #ifdef USE_SUBBLOCK + case XZ_ID_Subblock: return SbState_SetFromMethod(sc, p->alloc); + #endif + } + if (coderIndex == 0) + return SZ_ERROR_UNSUPPORTED; + return BraState_SetFromMethod(sc, methodId, 0, p->alloc); +} + + +static SRes MixCoder_ResetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 methodId, Byte *outBuf, size_t outBufSize) +{ + IStateCoder *sc = &p->coders[coderIndex]; + switch (methodId) + { + case XZ_ID_LZMA2: return Lzma2State_ResetOutBuf(sc, outBuf, outBufSize); + } + return SZ_ERROR_UNSUPPORTED; +} + + + +/* + if (destFinish) - then unpack data block is finished at (*destLen) position, + and we can return data that were not processed by filter + +output (status) can be : + CODER_STATUS_NOT_FINISHED + CODER_STATUS_FINISHED_WITH_MARK + CODER_STATUS_NEEDS_MORE_INPUT - not implemented still +*/ + +static SRes MixCoder_Code(CMixCoder *p, + Byte *dest, SizeT *destLen, int destFinish, + const Byte *src, SizeT *srcLen, int srcWasFinished, + ECoderFinishMode finishMode) +{ + SizeT destLenOrig = *destLen; + SizeT srcLenOrig = *srcLen; + + *destLen = 0; + *srcLen = 0; + + if (p->wasFinished) + return p->res; + + p->status = CODER_STATUS_NOT_FINISHED; + + // if (p->SingleBufMode) + if (p->outBuf) + { + SRes res; + SizeT destLen2, srcLen2; + int wasFinished; + + PRF_STR("------- MixCoder Single ----------"); + + srcLen2 = srcLenOrig; + destLen2 = destLenOrig; + + { + IStateCoder *coder = &p->coders[0]; + res = coder->Code2(coder->p, NULL, &destLen2, src, &srcLen2, srcWasFinished, finishMode, + // &wasFinished, + &p->status); + wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); + } + + p->res = res; + + /* + if (wasFinished) + p->status = CODER_STATUS_FINISHED_WITH_MARK; + else + { + if (res == SZ_OK) + if (destLen2 != destLenOrig) + p->status = CODER_STATUS_NEEDS_MORE_INPUT; + } + */ + + + *srcLen = srcLen2; + src += srcLen2; + p->outWritten += destLen2; + + if (res != SZ_OK || srcWasFinished || wasFinished) + p->wasFinished = True; + + if (p->numCoders == 1) + *destLen = destLen2; + else if (p->wasFinished) + { + unsigned i; + size_t processed = p->outWritten; + + for (i = 1; i < p->numCoders; i++) + { + IStateCoder *coder = &p->coders[i]; + processed = coder->Filter(coder->p, p->outBuf, processed); + if (wasFinished || (destFinish && p->outWritten == destLenOrig)) + processed = p->outWritten; + PRF_STR_INT("filter", i); + } + *destLen = processed; + } + return res; + } + + PRF_STR("standard mix"); + + if (p->numCoders != 1) + { + if (!p->buf) + { + p->buf = (Byte *)ISzAlloc_Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1)); + if (!p->buf) + return SZ_ERROR_MEM; + } + + finishMode = CODER_FINISH_ANY; + } + + for (;;) + { + BoolInt processed = False; + BoolInt allFinished = True; + SRes resMain = SZ_OK; + unsigned i; + + p->status = CODER_STATUS_NOT_FINISHED; + /* + if (p->numCoders == 1 && *destLen == destLenOrig && finishMode == LZMA_FINISH_ANY) + break; + */ + + for (i = 0; i < p->numCoders; i++) + { + SRes res; + IStateCoder *coder = &p->coders[i]; + Byte *dest2; + SizeT destLen2, srcLen2; // destLen2_Orig; + const Byte *src2; + int srcFinished2; + int encodingWasFinished; + ECoderStatus status2; + + if (i == 0) + { + src2 = src; + srcLen2 = srcLenOrig - *srcLen; + srcFinished2 = srcWasFinished; + } + else + { + size_t k = i - 1; + src2 = p->buf + (CODER_BUF_SIZE * k) + p->pos[k]; + srcLen2 = p->size[k] - p->pos[k]; + srcFinished2 = p->finished[k]; + } + + if (i == p->numCoders - 1) + { + dest2 = dest; + destLen2 = destLenOrig - *destLen; + } + else + { + if (p->pos[i] != p->size[i]) + continue; + dest2 = p->buf + (CODER_BUF_SIZE * i); + destLen2 = CODER_BUF_SIZE; + } + + // destLen2_Orig = destLen2; + + if (p->results[i] != SZ_OK) + { + if (resMain == SZ_OK) + resMain = p->results[i]; + continue; + } + + res = coder->Code2(coder->p, + dest2, &destLen2, + src2, &srcLen2, srcFinished2, + finishMode, + // &encodingWasFinished, + &status2); + + if (res != SZ_OK) + { + p->results[i] = res; + if (resMain == SZ_OK) + resMain = res; + } + + encodingWasFinished = (status2 == CODER_STATUS_FINISHED_WITH_MARK); + + if (!encodingWasFinished) + { + allFinished = False; + if (p->numCoders == 1 && res == SZ_OK) + p->status = status2; + } + + if (i == 0) + { + *srcLen += srcLen2; + src += srcLen2; + } + else + p->pos[(size_t)i - 1] += srcLen2; + + if (i == p->numCoders - 1) + { + *destLen += destLen2; + dest += destLen2; + } + else + { + p->size[i] = destLen2; + p->pos[i] = 0; + p->finished[i] = encodingWasFinished; + } + + if (destLen2 != 0 || srcLen2 != 0) + processed = True; + } + + if (!processed) + { + if (allFinished) + p->status = CODER_STATUS_FINISHED_WITH_MARK; + return resMain; + } + } +} + + +SRes Xz_ParseHeader(CXzStreamFlags *p, const Byte *buf) +{ + *p = (CXzStreamFlags)GetBe16(buf + XZ_SIG_SIZE); + if (CrcCalc(buf + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE) != + GetUi32(buf + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE)) + return SZ_ERROR_NO_ARCHIVE; + return XzFlags_IsSupported(*p) ? SZ_OK : SZ_ERROR_UNSUPPORTED; +} + +static BoolInt Xz_CheckFooter(CXzStreamFlags flags, UInt64 indexSize, const Byte *buf) +{ + return indexSize == (((UInt64)GetUi32(buf + 4) + 1) << 2) + && GetUi32(buf) == CrcCalc(buf + 4, 6) + && flags == GetBe16(buf + 8) + && buf[10] == XZ_FOOTER_SIG_0 + && buf[11] == XZ_FOOTER_SIG_1; +} + +#define READ_VARINT_AND_CHECK(buf, pos, size, res) \ + { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \ + if (s == 0) return SZ_ERROR_ARCHIVE; \ + pos += s; } + + +static BoolInt XzBlock_AreSupportedFilters(const CXzBlock *p) +{ + unsigned numFilters = XzBlock_GetNumFilters(p) - 1; + unsigned i; + { + const CXzFilter *f = &p->filters[numFilters]; + if (f->id != XZ_ID_LZMA2 || f->propsSize != 1 || f->props[0] > 40) + return False; + } + + for (i = 0; i < numFilters; i++) + { + const CXzFilter *f = &p->filters[i]; + if (f->id == XZ_ID_Delta) + { + if (f->propsSize != 1) + return False; + } + else if (f->id < XZ_ID_Delta + || f->id > XZ_ID_SPARC + || (f->propsSize != 0 && f->propsSize != 4)) + return False; + } + return True; +} + + +SRes XzBlock_Parse(CXzBlock *p, const Byte *header) +{ + unsigned pos; + unsigned numFilters, i; + unsigned headerSize = (unsigned)header[0] << 2; + + /* (headerSize != 0) : another code checks */ + + if (CrcCalc(header, headerSize) != GetUi32(header + headerSize)) + return SZ_ERROR_ARCHIVE; + + pos = 1; + p->flags = header[pos++]; + + p->packSize = (UInt64)(Int64)-1; + if (XzBlock_HasPackSize(p)) + { + READ_VARINT_AND_CHECK(header, pos, headerSize, &p->packSize); + if (p->packSize == 0 || p->packSize + headerSize >= (UInt64)1 << 63) + return SZ_ERROR_ARCHIVE; + } + + p->unpackSize = (UInt64)(Int64)-1; + if (XzBlock_HasUnpackSize(p)) + READ_VARINT_AND_CHECK(header, pos, headerSize, &p->unpackSize); + + numFilters = XzBlock_GetNumFilters(p); + for (i = 0; i < numFilters; i++) + { + CXzFilter *filter = p->filters + i; + UInt64 size; + READ_VARINT_AND_CHECK(header, pos, headerSize, &filter->id); + READ_VARINT_AND_CHECK(header, pos, headerSize, &size); + if (size > headerSize - pos || size > XZ_FILTER_PROPS_SIZE_MAX) + return SZ_ERROR_ARCHIVE; + filter->propsSize = (UInt32)size; + memcpy(filter->props, header + pos, (size_t)size); + pos += (unsigned)size; + + #ifdef XZ_DUMP + printf("\nf[%u] = %2X: ", i, (unsigned)filter->id); + { + unsigned i; + for (i = 0; i < size; i++) + printf(" %2X", filter->props[i]); + } + #endif + } + + if (XzBlock_HasUnsupportedFlags(p)) + return SZ_ERROR_UNSUPPORTED; + + while (pos < headerSize) + if (header[pos++] != 0) + return SZ_ERROR_ARCHIVE; + return SZ_OK; +} + + + + +static SRes XzDecMix_Init(CMixCoder *p, const CXzBlock *block, Byte *outBuf, size_t outBufSize) +{ + unsigned i; + BoolInt needReInit = True; + unsigned numFilters = XzBlock_GetNumFilters(block); + + if (numFilters == p->numCoders && ((p->outBuf && outBuf) || (!p->outBuf && !outBuf))) + { + needReInit = False; + for (i = 0; i < numFilters; i++) + if (p->ids[i] != block->filters[numFilters - 1 - i].id) + { + needReInit = True; + break; + } + } + + // p->SingleBufMode = (outBuf != NULL); + p->outBuf = outBuf; + p->outBufSize = outBufSize; + + // p->SingleBufMode = False; + // outBuf = NULL; + + if (needReInit) + { + MixCoder_Free(p); + for (i = 0; i < numFilters; i++) + { + RINOK(MixCoder_SetFromMethod(p, i, block->filters[numFilters - 1 - i].id, outBuf, outBufSize)); + } + p->numCoders = numFilters; + } + else + { + RINOK(MixCoder_ResetFromMethod(p, 0, block->filters[numFilters - 1].id, outBuf, outBufSize)); + } + + for (i = 0; i < numFilters; i++) + { + const CXzFilter *f = &block->filters[numFilters - 1 - i]; + IStateCoder *sc = &p->coders[i]; + RINOK(sc->SetProps(sc->p, f->props, f->propsSize, p->alloc)); + } + + MixCoder_Init(p); + return SZ_OK; +} + + + +void XzUnpacker_Init(CXzUnpacker *p) +{ + p->state = XZ_STATE_STREAM_HEADER; + p->pos = 0; + p->numStartedStreams = 0; + p->numFinishedStreams = 0; + p->numTotalBlocks = 0; + p->padSize = 0; + p->decodeOnlyOneBlock = 0; + + p->parseMode = False; + p->decodeToStreamSignature = False; + + // p->outBuf = NULL; + // p->outBufSize = 0; + p->outDataWritten = 0; +} + + +void XzUnpacker_SetOutBuf(CXzUnpacker *p, Byte *outBuf, size_t outBufSize) +{ + p->outBuf = outBuf; + p->outBufSize = outBufSize; +} + + +void XzUnpacker_Construct(CXzUnpacker *p, ISzAllocPtr alloc) +{ + MixCoder_Construct(&p->decoder, alloc); + p->outBuf = NULL; + p->outBufSize = 0; + XzUnpacker_Init(p); +} + + +void XzUnpacker_Free(CXzUnpacker *p) +{ + MixCoder_Free(&p->decoder); +} + + +void XzUnpacker_PrepareToRandomBlockDecoding(CXzUnpacker *p) +{ + p->indexSize = 0; + p->numBlocks = 0; + Sha256_Init(&p->sha); + p->state = XZ_STATE_BLOCK_HEADER; + p->pos = 0; + p->decodeOnlyOneBlock = 1; +} + + +static void XzUnpacker_UpdateIndex(CXzUnpacker *p, UInt64 packSize, UInt64 unpackSize) +{ + Byte temp[32]; + unsigned num = Xz_WriteVarInt(temp, packSize); + num += Xz_WriteVarInt(temp + num, unpackSize); + Sha256_Update(&p->sha, temp, num); + p->indexSize += num; + p->numBlocks++; +} + + + +SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, int srcFinished, + ECoderFinishMode finishMode, ECoderStatus *status) +{ + SizeT destLenOrig = *destLen; + SizeT srcLenOrig = *srcLen; + *destLen = 0; + *srcLen = 0; + *status = CODER_STATUS_NOT_SPECIFIED; + + for (;;) + { + SizeT srcRem; + + if (p->state == XZ_STATE_BLOCK) + { + SizeT destLen2 = destLenOrig - *destLen; + SizeT srcLen2 = srcLenOrig - *srcLen; + SRes res; + + ECoderFinishMode finishMode2 = finishMode; + BoolInt srcFinished2 = srcFinished; + BoolInt destFinish = False; + + if (p->block.packSize != (UInt64)(Int64)-1) + { + UInt64 rem = p->block.packSize - p->packSize; + if (srcLen2 >= rem) + { + srcFinished2 = True; + srcLen2 = (SizeT)rem; + } + if (rem == 0 && p->block.unpackSize == p->unpackSize) + return SZ_ERROR_DATA; + } + + if (p->block.unpackSize != (UInt64)(Int64)-1) + { + UInt64 rem = p->block.unpackSize - p->unpackSize; + if (destLen2 >= rem) + { + destFinish = True; + finishMode2 = CODER_FINISH_END; + destLen2 = (SizeT)rem; + } + } + + /* + if (srcLen2 == 0 && destLen2 == 0) + { + *status = CODER_STATUS_NOT_FINISHED; + return SZ_OK; + } + */ + + { + res = MixCoder_Code(&p->decoder, + (p->outBuf ? NULL : dest), &destLen2, destFinish, + src, &srcLen2, srcFinished2, + finishMode2); + + *status = p->decoder.status; + XzCheck_Update(&p->check, (p->outBuf ? p->outBuf + p->outDataWritten : dest), destLen2); + if (!p->outBuf) + dest += destLen2; + p->outDataWritten += destLen2; + } + + (*srcLen) += srcLen2; + src += srcLen2; + p->packSize += srcLen2; + (*destLen) += destLen2; + p->unpackSize += destLen2; + + RINOK(res); + + if (*status != CODER_STATUS_FINISHED_WITH_MARK) + { + if (p->block.packSize == p->packSize + && *status == CODER_STATUS_NEEDS_MORE_INPUT) + { + PRF_STR("CODER_STATUS_NEEDS_MORE_INPUT"); + *status = CODER_STATUS_NOT_SPECIFIED; + return SZ_ERROR_DATA; + } + + return SZ_OK; + } + { + XzUnpacker_UpdateIndex(p, XzUnpacker_GetPackSizeForIndex(p), p->unpackSize); + p->state = XZ_STATE_BLOCK_FOOTER; + p->pos = 0; + p->alignPos = 0; + *status = CODER_STATUS_NOT_SPECIFIED; + + if ((p->block.packSize != (UInt64)(Int64)-1 && p->block.packSize != p->packSize) + || (p->block.unpackSize != (UInt64)(Int64)-1 && p->block.unpackSize != p->unpackSize)) + { + PRF_STR("ERROR: block.size mismatch"); + return SZ_ERROR_DATA; + } + } + // continue; + } + + srcRem = srcLenOrig - *srcLen; + + // XZ_STATE_BLOCK_FOOTER can transit to XZ_STATE_BLOCK_HEADER without input bytes + if (srcRem == 0 && p->state != XZ_STATE_BLOCK_FOOTER) + { + *status = CODER_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + switch (p->state) + { + case XZ_STATE_STREAM_HEADER: + { + if (p->pos < XZ_STREAM_HEADER_SIZE) + { + if (p->pos < XZ_SIG_SIZE && *src != XZ_SIG[p->pos]) + return SZ_ERROR_NO_ARCHIVE; + if (p->decodeToStreamSignature) + return SZ_OK; + p->buf[p->pos++] = *src++; + (*srcLen)++; + } + else + { + RINOK(Xz_ParseHeader(&p->streamFlags, p->buf)); + p->numStartedStreams++; + p->indexSize = 0; + p->numBlocks = 0; + Sha256_Init(&p->sha); + p->state = XZ_STATE_BLOCK_HEADER; + p->pos = 0; + } + break; + } + + case XZ_STATE_BLOCK_HEADER: + { + if (p->pos == 0) + { + p->buf[p->pos++] = *src++; + (*srcLen)++; + if (p->buf[0] == 0) + { + if (p->decodeOnlyOneBlock) + return SZ_ERROR_DATA; + p->indexPreSize = 1 + Xz_WriteVarInt(p->buf + 1, p->numBlocks); + p->indexPos = p->indexPreSize; + p->indexSize += p->indexPreSize; + Sha256_Final(&p->sha, p->shaDigest); + Sha256_Init(&p->sha); + p->crc = CrcUpdate(CRC_INIT_VAL, p->buf, p->indexPreSize); + p->state = XZ_STATE_STREAM_INDEX; + break; + } + p->blockHeaderSize = ((UInt32)p->buf[0] << 2) + 4; + break; + } + + if (p->pos != p->blockHeaderSize) + { + UInt32 cur = p->blockHeaderSize - p->pos; + if (cur > srcRem) + cur = (UInt32)srcRem; + memcpy(p->buf + p->pos, src, cur); + p->pos += cur; + (*srcLen) += cur; + src += cur; + } + else + { + RINOK(XzBlock_Parse(&p->block, p->buf)); + if (!XzBlock_AreSupportedFilters(&p->block)) + return SZ_ERROR_UNSUPPORTED; + p->numTotalBlocks++; + p->state = XZ_STATE_BLOCK; + p->packSize = 0; + p->unpackSize = 0; + XzCheck_Init(&p->check, XzFlags_GetCheckType(p->streamFlags)); + if (p->parseMode) + { + p->headerParsedOk = True; + return SZ_OK; + } + RINOK(XzDecMix_Init(&p->decoder, &p->block, p->outBuf, p->outBufSize)); + } + break; + } + + case XZ_STATE_BLOCK_FOOTER: + { + if ((((unsigned)p->packSize + p->alignPos) & 3) != 0) + { + if (srcRem == 0) + { + *status = CODER_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + (*srcLen)++; + p->alignPos++; + if (*src++ != 0) + return SZ_ERROR_CRC; + } + else + { + UInt32 checkSize = XzFlags_GetCheckSize(p->streamFlags); + UInt32 cur = checkSize - p->pos; + if (cur != 0) + { + if (srcRem == 0) + { + *status = CODER_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (cur > srcRem) + cur = (UInt32)srcRem; + memcpy(p->buf + p->pos, src, cur); + p->pos += cur; + (*srcLen) += cur; + src += cur; + if (checkSize != p->pos) + break; + } + { + Byte digest[XZ_CHECK_SIZE_MAX]; + p->state = XZ_STATE_BLOCK_HEADER; + p->pos = 0; + if (XzCheck_Final(&p->check, digest) && memcmp(digest, p->buf, checkSize) != 0) + return SZ_ERROR_CRC; + if (p->decodeOnlyOneBlock) + { + *status = CODER_STATUS_FINISHED_WITH_MARK; + return SZ_OK; + } + } + } + break; + } + + case XZ_STATE_STREAM_INDEX: + { + if (p->pos < p->indexPreSize) + { + (*srcLen)++; + if (*src++ != p->buf[p->pos++]) + return SZ_ERROR_CRC; + } + else + { + if (p->indexPos < p->indexSize) + { + UInt64 cur = p->indexSize - p->indexPos; + if (srcRem > cur) + srcRem = (SizeT)cur; + p->crc = CrcUpdate(p->crc, src, srcRem); + Sha256_Update(&p->sha, src, srcRem); + (*srcLen) += srcRem; + src += srcRem; + p->indexPos += srcRem; + } + else if ((p->indexPos & 3) != 0) + { + Byte b = *src++; + p->crc = CRC_UPDATE_BYTE(p->crc, b); + (*srcLen)++; + p->indexPos++; + p->indexSize++; + if (b != 0) + return SZ_ERROR_CRC; + } + else + { + Byte digest[SHA256_DIGEST_SIZE]; + p->state = XZ_STATE_STREAM_INDEX_CRC; + p->indexSize += 4; + p->pos = 0; + Sha256_Final(&p->sha, digest); + if (memcmp(digest, p->shaDigest, SHA256_DIGEST_SIZE) != 0) + return SZ_ERROR_CRC; + } + } + break; + } + + case XZ_STATE_STREAM_INDEX_CRC: + { + if (p->pos < 4) + { + (*srcLen)++; + p->buf[p->pos++] = *src++; + } + else + { + const Byte *ptr = p->buf; + p->state = XZ_STATE_STREAM_FOOTER; + p->pos = 0; + if (CRC_GET_DIGEST(p->crc) != GetUi32(ptr)) + return SZ_ERROR_CRC; + } + break; + } + + case XZ_STATE_STREAM_FOOTER: + { + UInt32 cur = XZ_STREAM_FOOTER_SIZE - p->pos; + if (cur > srcRem) + cur = (UInt32)srcRem; + memcpy(p->buf + p->pos, src, cur); + p->pos += cur; + (*srcLen) += cur; + src += cur; + if (p->pos == XZ_STREAM_FOOTER_SIZE) + { + p->state = XZ_STATE_STREAM_PADDING; + p->numFinishedStreams++; + p->padSize = 0; + if (!Xz_CheckFooter(p->streamFlags, p->indexSize, p->buf)) + return SZ_ERROR_CRC; + } + break; + } + + case XZ_STATE_STREAM_PADDING: + { + if (*src != 0) + { + if (((UInt32)p->padSize & 3) != 0) + return SZ_ERROR_NO_ARCHIVE; + p->pos = 0; + p->state = XZ_STATE_STREAM_HEADER; + } + else + { + (*srcLen)++; + src++; + p->padSize++; + } + break; + } + + case XZ_STATE_BLOCK: break; /* to disable GCC warning */ + } + } + /* + if (p->state == XZ_STATE_FINISHED) + *status = CODER_STATUS_FINISHED_WITH_MARK; + return SZ_OK; + */ +} + + +SRes XzUnpacker_CodeFull(CXzUnpacker *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, + ECoderFinishMode finishMode, ECoderStatus *status) +{ + XzUnpacker_Init(p); + XzUnpacker_SetOutBuf(p, dest, *destLen); + + return XzUnpacker_Code(p, + NULL, destLen, + src, srcLen, True, + finishMode, status); +} + + +BoolInt XzUnpacker_IsBlockFinished(const CXzUnpacker *p) +{ + return (p->state == XZ_STATE_BLOCK_HEADER) && (p->pos == 0); +} + +BoolInt XzUnpacker_IsStreamWasFinished(const CXzUnpacker *p) +{ + return (p->state == XZ_STATE_STREAM_PADDING) && (((UInt32)p->padSize & 3) == 0); +} + +UInt64 XzUnpacker_GetExtraSize(const CXzUnpacker *p) +{ + UInt64 num = 0; + if (p->state == XZ_STATE_STREAM_PADDING) + num = p->padSize; + else if (p->state == XZ_STATE_STREAM_HEADER) + num = p->padSize + p->pos; + return num; +} + + + + + + + + + + + + + + + + + + + + + +#ifndef _7ZIP_ST +#include "MtDec.h" +#endif + + +void XzDecMtProps_Init(CXzDecMtProps *p) +{ + p->inBufSize_ST = 1 << 18; + p->outStep_ST = 1 << 20; + p->ignoreErrors = False; + + #ifndef _7ZIP_ST + p->numThreads = 1; + p->inBufSize_MT = 1 << 18; + p->memUseMax = sizeof(size_t) << 28; + #endif +} + + + +#ifndef _7ZIP_ST + +/* ---------- CXzDecMtThread ---------- */ + +typedef struct +{ + Byte *outBuf; + size_t outBufSize; + size_t outPreSize; + size_t inPreSize; + size_t inPreHeaderSize; + size_t blockPackSize_for_Index; // including block header and checksum. + size_t blockPackTotal; // including stream header, block header and checksum. + size_t inCodeSize; + size_t outCodeSize; + ECoderStatus status; + SRes codeRes; + BoolInt skipMode; + // BoolInt finishedWithMark; + EMtDecParseState parseState; + BoolInt parsing_Truncated; + BoolInt atBlockHeader; + CXzStreamFlags streamFlags; + // UInt64 numFinishedStreams + UInt64 numStreams; + UInt64 numTotalBlocks; + UInt64 numBlocks; + + BoolInt dec_created; + CXzUnpacker dec; + + Byte mtPad[1 << 7]; +} CXzDecMtThread; + +#endif + + +/* ---------- CXzDecMt ---------- */ + +typedef struct +{ + CAlignOffsetAlloc alignOffsetAlloc; + ISzAllocPtr allocMid; + + CXzDecMtProps props; + size_t unpackBlockMaxSize; + + ISeqInStream *inStream; + ISeqOutStream *outStream; + ICompressProgress *progress; + + BoolInt finishMode; + BoolInt outSize_Defined; + UInt64 outSize; + + UInt64 outProcessed; + UInt64 inProcessed; + UInt64 readProcessed; + BoolInt readWasFinished; + SRes readRes; + SRes writeRes; + + Byte *outBuf; + size_t outBufSize; + Byte *inBuf; + size_t inBufSize; + + CXzUnpacker dec; + + ECoderStatus status; + SRes codeRes; + + #ifndef _7ZIP_ST + BoolInt mainDecoderWasCalled; + // int statErrorDefined; + int finishedDecoderIndex; + + // global values that are used in Parse stage + CXzStreamFlags streamFlags; + // UInt64 numFinishedStreams + UInt64 numStreams; + UInt64 numTotalBlocks; + UInt64 numBlocks; + + // UInt64 numBadBlocks; + SRes mainErrorCode; // it's set to error code, if the size Code() output doesn't patch the size from Parsing stage + // it can be = SZ_ERROR_INPUT_EOF + // it can be = SZ_ERROR_DATA, in some another cases + BoolInt isBlockHeaderState_Parse; + BoolInt isBlockHeaderState_Write; + UInt64 outProcessed_Parse; + BoolInt parsing_Truncated; + + BoolInt mtc_WasConstructed; + CMtDec mtc; + CXzDecMtThread coders[MTDEC__THREADS_MAX]; + #endif + +} CXzDecMt; + + + +CXzDecMtHandle XzDecMt_Create(ISzAllocPtr alloc, ISzAllocPtr allocMid) +{ + CXzDecMt *p = (CXzDecMt *)ISzAlloc_Alloc(alloc, sizeof(CXzDecMt)); + if (!p) + return NULL; + + AlignOffsetAlloc_CreateVTable(&p->alignOffsetAlloc); + p->alignOffsetAlloc.baseAlloc = alloc; + p->alignOffsetAlloc.numAlignBits = 7; + p->alignOffsetAlloc.offset = 0; + + p->allocMid = allocMid; + + p->outBuf = NULL; + p->outBufSize = 0; + p->inBuf = NULL; + p->inBufSize = 0; + + XzUnpacker_Construct(&p->dec, &p->alignOffsetAlloc.vt); + + p->unpackBlockMaxSize = 0; + + XzDecMtProps_Init(&p->props); + + #ifndef _7ZIP_ST + p->mtc_WasConstructed = False; + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CXzDecMtThread *coder = &p->coders[i]; + coder->dec_created = False; + coder->outBuf = NULL; + coder->outBufSize = 0; + } + } + #endif + + return p; +} + + +#ifndef _7ZIP_ST + +static void XzDecMt_FreeOutBufs(CXzDecMt *p) +{ + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CXzDecMtThread *coder = &p->coders[i]; + if (coder->outBuf) + { + ISzAlloc_Free(p->allocMid, coder->outBuf); + coder->outBuf = NULL; + coder->outBufSize = 0; + } + } + p->unpackBlockMaxSize = 0; +} + +#endif + + + +static void XzDecMt_FreeSt(CXzDecMt *p) +{ + XzUnpacker_Free(&p->dec); + + if (p->outBuf) + { + ISzAlloc_Free(p->allocMid, p->outBuf); + p->outBuf = NULL; + } + p->outBufSize = 0; + + if (p->inBuf) + { + ISzAlloc_Free(p->allocMid, p->inBuf); + p->inBuf = NULL; + } + p->inBufSize = 0; +} + + +void XzDecMt_Destroy(CXzDecMtHandle pp) +{ + CXzDecMt *p = (CXzDecMt *)pp; + + XzDecMt_FreeSt(p); + + #ifndef _7ZIP_ST + + if (p->mtc_WasConstructed) + { + MtDec_Destruct(&p->mtc); + p->mtc_WasConstructed = False; + } + { + unsigned i; + for (i = 0; i < MTDEC__THREADS_MAX; i++) + { + CXzDecMtThread *t = &p->coders[i]; + if (t->dec_created) + { + // we don't need to free dict here + XzUnpacker_Free(&t->dec); + t->dec_created = False; + } + } + } + XzDecMt_FreeOutBufs(p); + + #endif + + ISzAlloc_Free(p->alignOffsetAlloc.baseAlloc, pp); +} + + + +#ifndef _7ZIP_ST + +static void XzDecMt_Callback_Parse(void *obj, unsigned coderIndex, CMtDecCallbackInfo *cc) +{ + CXzDecMt *me = (CXzDecMt *)obj; + CXzDecMtThread *coder = &me->coders[coderIndex]; + size_t srcSize = cc->srcSize; + + cc->srcSize = 0; + cc->outPos = 0; + cc->state = MTDEC_PARSE_CONTINUE; + + cc->canCreateNewThread = True; + + if (cc->startCall) + { + coder->outPreSize = 0; + coder->inPreSize = 0; + coder->inPreHeaderSize = 0; + coder->parseState = MTDEC_PARSE_CONTINUE; + coder->parsing_Truncated = False; + coder->skipMode = False; + coder->codeRes = SZ_OK; + coder->status = CODER_STATUS_NOT_SPECIFIED; + coder->inCodeSize = 0; + coder->outCodeSize = 0; + + coder->numStreams = me->numStreams; + coder->numTotalBlocks = me->numTotalBlocks; + coder->numBlocks = me->numBlocks; + + if (!coder->dec_created) + { + XzUnpacker_Construct(&coder->dec, &me->alignOffsetAlloc.vt); + coder->dec_created = True; + } + + XzUnpacker_Init(&coder->dec); + + if (me->isBlockHeaderState_Parse) + { + coder->dec.streamFlags = me->streamFlags; + coder->atBlockHeader = True; + XzUnpacker_PrepareToRandomBlockDecoding(&coder->dec); + } + else + { + coder->atBlockHeader = False; + me->isBlockHeaderState_Parse = True; + } + + coder->dec.numStartedStreams = me->numStreams; + coder->dec.numTotalBlocks = me->numTotalBlocks; + coder->dec.numBlocks = me->numBlocks; + } + + while (!coder->skipMode) + { + ECoderStatus status; + SRes res; + size_t srcSize2 = srcSize; + size_t destSize = (size_t)0 - 1; + + coder->dec.parseMode = True; + coder->dec.headerParsedOk = False; + + PRF_STR_INT("Parse", srcSize2); + + res = XzUnpacker_Code(&coder->dec, + NULL, &destSize, + cc->src, &srcSize2, cc->srcFinished, + CODER_FINISH_END, &status); + + // PRF(printf(" res = %d, srcSize2 = %d", res, (unsigned)srcSize2)); + + coder->codeRes = res; + coder->status = status; + cc->srcSize += srcSize2; + srcSize -= srcSize2; + coder->inPreHeaderSize += srcSize2; + coder->inPreSize = coder->inPreHeaderSize; + + if (res != SZ_OK) + { + cc->state = + coder->parseState = MTDEC_PARSE_END; + /* + if (res == SZ_ERROR_MEM) + return res; + return SZ_OK; + */ + return; // res; + } + + if (coder->dec.headerParsedOk) + { + const CXzBlock *block = &coder->dec.block; + if (XzBlock_HasUnpackSize(block) + // && block->unpackSize <= me->props.outBlockMax + && XzBlock_HasPackSize(block)) + { + { + if (block->unpackSize * 2 * me->mtc.numStartedThreads > me->props.memUseMax) + { + cc->state = MTDEC_PARSE_OVERFLOW; + return; // SZ_OK; + } + } + { + UInt64 packSize = block->packSize; + UInt64 packSizeAligned = packSize + ((0 - (unsigned)packSize) & 3); + UInt32 checkSize = XzFlags_GetCheckSize(coder->dec.streamFlags); + UInt64 blockPackSum = coder->inPreSize + packSizeAligned + checkSize; + // if (blockPackSum <= me->props.inBlockMax) + // unpackBlockMaxSize + { + coder->blockPackSize_for_Index = (size_t)(coder->dec.blockHeaderSize + packSize + checkSize); + coder->blockPackTotal = (size_t)blockPackSum; + coder->outPreSize = (size_t)block->unpackSize; + coder->streamFlags = coder->dec.streamFlags; + me->streamFlags = coder->dec.streamFlags; + coder->skipMode = True; + break; + } + } + } + } + else + // if (coder->inPreSize <= me->props.inBlockMax) + { + if (!cc->srcFinished) + return; // SZ_OK; + cc->state = + coder->parseState = MTDEC_PARSE_END; + return; // SZ_OK; + } + cc->state = MTDEC_PARSE_OVERFLOW; + return; // SZ_OK; + } + + // ---------- skipMode ---------- + { + UInt64 rem = coder->blockPackTotal - coder->inPreSize; + size_t cur = srcSize; + if (cur > rem) + cur = (size_t)rem; + cc->srcSize += cur; + coder->inPreSize += cur; + srcSize -= cur; + + if (coder->inPreSize == coder->blockPackTotal) + { + if (srcSize == 0) + { + if (!cc->srcFinished) + return; // SZ_OK; + cc->state = MTDEC_PARSE_END; + } + else if ((cc->src)[cc->srcSize] == 0) // we check control byte of next block + cc->state = MTDEC_PARSE_END; + else + { + cc->state = MTDEC_PARSE_NEW; + + { + size_t blockMax = me->unpackBlockMaxSize; + if (blockMax < coder->outPreSize) + blockMax = coder->outPreSize; + { + UInt64 required = (UInt64)blockMax * (me->mtc.numStartedThreads + 1) * 2; + if (me->props.memUseMax < required) + cc->canCreateNewThread = False; + } + } + + if (me->outSize_Defined) + { + // next block can be zero size + const UInt64 rem2 = me->outSize - me->outProcessed_Parse; + if (rem2 < coder->outPreSize) + { + coder->parsing_Truncated = True; + cc->state = MTDEC_PARSE_END; + } + me->outProcessed_Parse += coder->outPreSize; + } + } + } + else if (cc->srcFinished) + cc->state = MTDEC_PARSE_END; + else + return; // SZ_OK; + + coder->parseState = cc->state; + cc->outPos = coder->outPreSize; + + me->numStreams = coder->dec.numStartedStreams; + me->numTotalBlocks = coder->dec.numTotalBlocks; + me->numBlocks = coder->dec.numBlocks + 1; + return; // SZ_OK; + } +} + + +static SRes XzDecMt_Callback_PreCode(void *pp, unsigned coderIndex) +{ + CXzDecMt *me = (CXzDecMt *)pp; + CXzDecMtThread *coder = &me->coders[coderIndex]; + Byte *dest; + + if (!coder->dec.headerParsedOk) + return SZ_OK; + + dest = coder->outBuf; + + if (!dest || coder->outBufSize < coder->outPreSize) + { + if (dest) + { + ISzAlloc_Free(me->allocMid, dest); + coder->outBuf = NULL; + coder->outBufSize = 0; + } + { + size_t outPreSize = coder->outPreSize; + if (outPreSize == 0) + outPreSize = 1; + dest = (Byte *)ISzAlloc_Alloc(me->allocMid, outPreSize); + } + if (!dest) + return SZ_ERROR_MEM; + coder->outBuf = dest; + coder->outBufSize = coder->outPreSize; + + if (coder->outBufSize > me->unpackBlockMaxSize) + me->unpackBlockMaxSize = coder->outBufSize; + } + + // return SZ_ERROR_MEM; + + XzUnpacker_SetOutBuf(&coder->dec, coder->outBuf, coder->outBufSize); + + { + SRes res = XzDecMix_Init(&coder->dec.decoder, &coder->dec.block, coder->outBuf, coder->outBufSize); + // res = SZ_ERROR_UNSUPPORTED; // to test + coder->codeRes = res; + if (res != SZ_OK) + { + // if (res == SZ_ERROR_MEM) return res; + if (me->props.ignoreErrors && res != SZ_ERROR_MEM) + return SZ_OK; + return res; + } + } + + return SZ_OK; +} + + +static SRes XzDecMt_Callback_Code(void *pp, unsigned coderIndex, + const Byte *src, size_t srcSize, int srcFinished, + // int finished, int blockFinished, + UInt64 *inCodePos, UInt64 *outCodePos, int *stop) +{ + CXzDecMt *me = (CXzDecMt *)pp; + CXzDecMtThread *coder = &me->coders[coderIndex]; + + *inCodePos = coder->inCodeSize; + *outCodePos = coder->outCodeSize; + *stop = True; + + if (srcSize > coder->inPreSize - coder->inCodeSize) + return SZ_ERROR_FAIL; + + if (coder->inCodeSize < coder->inPreHeaderSize) + { + size_t step = coder->inPreHeaderSize - coder->inCodeSize; + if (step > srcSize) + step = srcSize; + src += step; + srcSize -= step; + coder->inCodeSize += step; + *inCodePos = coder->inCodeSize; + if (coder->inCodeSize < coder->inPreHeaderSize) + { + *stop = False; + return SZ_OK; + } + } + + if (!coder->dec.headerParsedOk) + return SZ_OK; + if (!coder->outBuf) + return SZ_OK; + + if (coder->codeRes == SZ_OK) + { + ECoderStatus status; + SRes res; + size_t srcProcessed = srcSize; + size_t outSizeCur = coder->outPreSize - coder->dec.outDataWritten; + + // PRF(printf("\nCallback_Code: Code %d %d\n", (unsigned)srcSize, (unsigned)outSizeCur)); + + res = XzUnpacker_Code(&coder->dec, + NULL, &outSizeCur, + src, &srcProcessed, srcFinished, + // coder->finishedWithMark ? CODER_FINISH_END : CODER_FINISH_ANY, + CODER_FINISH_END, + &status); + + // PRF(printf(" res = %d, srcSize2 = %d, outSizeCur = %d", res, (unsigned)srcProcessed, (unsigned)outSizeCur)); + + coder->codeRes = res; + coder->status = status; + coder->inCodeSize += srcProcessed; + coder->outCodeSize = coder->dec.outDataWritten; + *inCodePos = coder->inCodeSize; + *outCodePos = coder->outCodeSize; + + if (res == SZ_OK) + { + if (srcProcessed == srcSize) + *stop = False; + return SZ_OK; + } + } + + if (me->props.ignoreErrors && coder->codeRes != SZ_ERROR_MEM) + { + *inCodePos = coder->inPreSize; + *outCodePos = coder->outPreSize; + return SZ_OK; + } + return coder->codeRes; +} + + +#define XZDECMT_STREAM_WRITE_STEP (1 << 24) + +static SRes XzDecMt_Callback_Write(void *pp, unsigned coderIndex, + BoolInt needWriteToStream, + const Byte *src, size_t srcSize, BoolInt isCross, + // int srcFinished, + BoolInt *needContinue, + BoolInt *canRecode) +{ + CXzDecMt *me = (CXzDecMt *)pp; + const CXzDecMtThread *coder = &me->coders[coderIndex]; + + // PRF(printf("\nWrite processed = %d srcSize = %d\n", (unsigned)me->mtc.inProcessed, (unsigned)srcSize)); + + *needContinue = False; + *canRecode = True; + + if (!needWriteToStream) + return SZ_OK; + + if (!coder->dec.headerParsedOk || !coder->outBuf) + { + if (me->finishedDecoderIndex < 0) + me->finishedDecoderIndex = (int)coderIndex; + return SZ_OK; + } + + if (me->finishedDecoderIndex >= 0) + return SZ_OK; + + me->mtc.inProcessed += coder->inCodeSize; + + *canRecode = False; + + { + SRes res; + size_t size = coder->outCodeSize; + Byte *data = coder->outBuf; + + // we use in me->dec: sha, numBlocks, indexSize + + if (!me->isBlockHeaderState_Write) + { + XzUnpacker_PrepareToRandomBlockDecoding(&me->dec); + me->dec.decodeOnlyOneBlock = False; + me->dec.numStartedStreams = coder->dec.numStartedStreams; + me->dec.streamFlags = coder->streamFlags; + + me->isBlockHeaderState_Write = True; + } + + me->dec.numTotalBlocks = coder->dec.numTotalBlocks; + XzUnpacker_UpdateIndex(&me->dec, coder->blockPackSize_for_Index, coder->outPreSize); + + if (coder->outPreSize != size) + { + if (me->props.ignoreErrors) + { + memset(data + size, 0, coder->outPreSize - size); + size = coder->outPreSize; + } + // me->numBadBlocks++; + if (me->mainErrorCode == SZ_OK) + { + if ((int)coder->status == LZMA_STATUS_NEEDS_MORE_INPUT) + me->mainErrorCode = SZ_ERROR_INPUT_EOF; + else + me->mainErrorCode = SZ_ERROR_DATA; + } + } + + if (me->writeRes != SZ_OK) + return me->writeRes; + + res = SZ_OK; + { + if (me->outSize_Defined) + { + const UInt64 rem = me->outSize - me->outProcessed; + if (size > rem) + size = (SizeT)rem; + } + + for (;;) + { + size_t cur = size; + size_t written; + if (cur > XZDECMT_STREAM_WRITE_STEP) + cur = XZDECMT_STREAM_WRITE_STEP; + + written = ISeqOutStream_Write(me->outStream, data, cur); + + // PRF(printf("\nWritten ask = %d written = %d\n", (unsigned)cur, (unsigned)written)); + + me->outProcessed += written; + if (written != cur) + { + me->writeRes = SZ_ERROR_WRITE; + res = me->writeRes; + break; + } + data += cur; + size -= cur; + // PRF_STR_INT("Written size =", size); + if (size == 0) + break; + res = MtProgress_ProgressAdd(&me->mtc.mtProgress, 0, 0); + if (res != SZ_OK) + break; + } + } + + if (coder->codeRes != SZ_OK) + if (!me->props.ignoreErrors) + { + me->finishedDecoderIndex = (int)coderIndex; + return res; + } + + RINOK(res); + + if (coder->inPreSize != coder->inCodeSize + || coder->blockPackTotal != coder->inCodeSize) + { + me->finishedDecoderIndex = (int)coderIndex; + return SZ_OK; + } + + if (coder->parseState != MTDEC_PARSE_END) + { + *needContinue = True; + return SZ_OK; + } + } + + // (coder->state == MTDEC_PARSE_END) means that there are no other working threads + // so we can use mtc variables without lock + + PRF_STR_INT("Write MTDEC_PARSE_END", me->mtc.inProcessed); + + me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; + { + CXzUnpacker *dec = &me->dec; + + PRF_STR_INT("PostSingle", srcSize); + + { + size_t srcProcessed = srcSize; + ECoderStatus status; + size_t outSizeCur = 0; + SRes res; + + // dec->decodeOnlyOneBlock = False; + dec->decodeToStreamSignature = True; + + me->mainDecoderWasCalled = True; + + if (coder->parsing_Truncated) + { + me->parsing_Truncated = True; + return SZ_OK; + } + + /* + We have processed all xz-blocks of stream, + And xz unpacker is at XZ_STATE_BLOCK_HEADER state, where + (src) is a pointer to xz-Index structure. + We finish reading of current xz-Stream, including Zero padding after xz-Stream. + We exit, if we reach extra byte (first byte of new-Stream or another data). + But we don't update input stream pointer for that new extra byte. + If extra byte is not correct first byte of xz-signature, + we have SZ_ERROR_NO_ARCHIVE error here. + */ + + res = XzUnpacker_Code(dec, + NULL, &outSizeCur, + src, &srcProcessed, + me->mtc.readWasFinished, // srcFinished + CODER_FINISH_END, // CODER_FINISH_ANY, + &status); + + // res = SZ_ERROR_ARCHIVE; // for failure test + + me->status = status; + me->codeRes = res; + + if (isCross) + me->mtc.crossStart += srcProcessed; + + me->mtc.inProcessed += srcProcessed; + me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; + + srcSize -= srcProcessed; + src += srcProcessed; + + if (res != SZ_OK) + { + return SZ_OK; + // return res; + } + + if (dec->state == XZ_STATE_STREAM_HEADER) + { + *needContinue = True; + me->isBlockHeaderState_Parse = False; + me->isBlockHeaderState_Write = False; + + if (!isCross) + { + Byte *crossBuf = MtDec_GetCrossBuff(&me->mtc); + if (!crossBuf) + return SZ_ERROR_MEM; + if (srcSize != 0) + memcpy(crossBuf, src, srcSize); + me->mtc.crossStart = 0; + me->mtc.crossEnd = srcSize; + } + + PRF_STR_INT("XZ_STATE_STREAM_HEADER crossEnd = ", (unsigned)me->mtc.crossEnd); + + return SZ_OK; + } + + if (status != CODER_STATUS_NEEDS_MORE_INPUT || srcSize != 0) + { + return SZ_ERROR_FAIL; + } + + if (me->mtc.readWasFinished) + { + return SZ_OK; + } + } + + { + size_t inPos; + size_t inLim; + // const Byte *inData; + UInt64 inProgressPrev = me->mtc.inProcessed; + + // XzDecMt_Prepare_InBuf_ST(p); + Byte *crossBuf = MtDec_GetCrossBuff(&me->mtc); + if (!crossBuf) + return SZ_ERROR_MEM; + + inPos = 0; + inLim = 0; + + // inData = crossBuf; + + for (;;) + { + SizeT inProcessed; + SizeT outProcessed; + ECoderStatus status; + SRes res; + + if (inPos == inLim) + { + if (!me->mtc.readWasFinished) + { + inPos = 0; + inLim = me->mtc.inBufSize; + me->mtc.readRes = ISeqInStream_Read(me->inStream, (void *)crossBuf, &inLim); + me->mtc.readProcessed += inLim; + if (inLim == 0 || me->mtc.readRes != SZ_OK) + me->mtc.readWasFinished = True; + } + } + + inProcessed = inLim - inPos; + outProcessed = 0; + + res = XzUnpacker_Code(dec, + NULL, &outProcessed, + crossBuf + inPos, &inProcessed, + (inProcessed == 0), // srcFinished + CODER_FINISH_END, &status); + + me->codeRes = res; + me->status = status; + inPos += inProcessed; + me->mtc.inProcessed += inProcessed; + me->mtc.mtProgress.totalInSize = me->mtc.inProcessed; + + if (res != SZ_OK) + { + return SZ_OK; + // return res; + } + + if (dec->state == XZ_STATE_STREAM_HEADER) + { + *needContinue = True; + me->mtc.crossStart = inPos; + me->mtc.crossEnd = inLim; + me->isBlockHeaderState_Parse = False; + me->isBlockHeaderState_Write = False; + return SZ_OK; + } + + if (status != CODER_STATUS_NEEDS_MORE_INPUT) + return SZ_ERROR_FAIL; + + if (me->mtc.progress) + { + UInt64 inDelta = me->mtc.inProcessed - inProgressPrev; + if (inDelta >= (1 << 22)) + { + RINOK(MtProgress_Progress_ST(&me->mtc.mtProgress)); + inProgressPrev = me->mtc.inProcessed; + } + } + if (me->mtc.readWasFinished) + return SZ_OK; + } + } + } +} + + +#endif + + + +void XzStatInfo_Clear(CXzStatInfo *p) +{ + p->InSize = 0; + p->OutSize = 0; + + p->NumStreams = 0; + p->NumBlocks = 0; + + p->UnpackSize_Defined = False; + + p->NumStreams_Defined = False; + p->NumBlocks_Defined = False; + + p->DataAfterEnd = False; + p->DecodingTruncated = False; + + p->DecodeRes = SZ_OK; + p->ReadRes = SZ_OK; + p->ProgressRes = SZ_OK; + + p->CombinedRes = SZ_OK; + p->CombinedRes_Type = SZ_OK; +} + + + +/* + XzDecMt_Decode_ST() can return SZ_OK or the following errors + - SZ_ERROR_MEM for memory allocation error + - error from XzUnpacker_Code() function + - SZ_ERROR_WRITE for ISeqOutStream::Write(). stat->CombinedRes_Type = SZ_ERROR_WRITE in that case + - ICompressProgress::Progress() error, stat->CombinedRes_Type = SZ_ERROR_PROGRESS. + But XzDecMt_Decode_ST() doesn't return ISeqInStream::Read() errors. + ISeqInStream::Read() result is set to p->readRes. + also it can set stat->CombinedRes_Type to SZ_ERROR_WRITE or SZ_ERROR_PROGRESS. +*/ + +static SRes XzDecMt_Decode_ST(CXzDecMt *p + #ifndef _7ZIP_ST + , BoolInt tMode + #endif + , CXzStatInfo *stat) +{ + size_t outPos; + size_t inPos, inLim; + const Byte *inData; + UInt64 inPrev, outPrev; + + CXzUnpacker *dec; + + #ifndef _7ZIP_ST + if (tMode) + { + XzDecMt_FreeOutBufs(p); + tMode = MtDec_PrepareRead(&p->mtc); + } + #endif + + if (!p->outBuf || p->outBufSize != p->props.outStep_ST) + { + ISzAlloc_Free(p->allocMid, p->outBuf); + p->outBufSize = 0; + p->outBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.outStep_ST); + if (!p->outBuf) + return SZ_ERROR_MEM; + p->outBufSize = p->props.outStep_ST; + } + + if (!p->inBuf || p->inBufSize != p->props.inBufSize_ST) + { + ISzAlloc_Free(p->allocMid, p->inBuf); + p->inBufSize = 0; + p->inBuf = (Byte *)ISzAlloc_Alloc(p->allocMid, p->props.inBufSize_ST); + if (!p->inBuf) + return SZ_ERROR_MEM; + p->inBufSize = p->props.inBufSize_ST; + } + + dec = &p->dec; + dec->decodeToStreamSignature = False; + // dec->decodeOnlyOneBlock = False; + + XzUnpacker_SetOutBuf(dec, NULL, 0); + + inPrev = p->inProcessed; + outPrev = p->outProcessed; + + inPos = 0; + inLim = 0; + inData = NULL; + outPos = 0; + + for (;;) + { + SizeT outSize; + BoolInt finished; + ECoderFinishMode finishMode; + SizeT inProcessed; + ECoderStatus status; + SRes res; + + SizeT outProcessed; + + + + if (inPos == inLim) + { + #ifndef _7ZIP_ST + if (tMode) + { + inData = MtDec_Read(&p->mtc, &inLim); + inPos = 0; + if (inData) + continue; + tMode = False; + inLim = 0; + } + #endif + + if (!p->readWasFinished) + { + inPos = 0; + inLim = p->inBufSize; + inData = p->inBuf; + p->readRes = ISeqInStream_Read(p->inStream, (void *)p->inBuf, &inLim); + p->readProcessed += inLim; + if (inLim == 0 || p->readRes != SZ_OK) + p->readWasFinished = True; + } + } + + outSize = p->props.outStep_ST - outPos; + + finishMode = CODER_FINISH_ANY; + if (p->outSize_Defined) + { + const UInt64 rem = p->outSize - p->outProcessed; + if (outSize >= rem) + { + outSize = (SizeT)rem; + if (p->finishMode) + finishMode = CODER_FINISH_END; + } + } + + inProcessed = inLim - inPos; + outProcessed = outSize; + + res = XzUnpacker_Code(dec, p->outBuf + outPos, &outProcessed, + inData + inPos, &inProcessed, + (inPos == inLim), // srcFinished + finishMode, &status); + + p->codeRes = res; + p->status = status; + + inPos += inProcessed; + outPos += outProcessed; + p->inProcessed += inProcessed; + p->outProcessed += outProcessed; + + finished = ((inProcessed == 0 && outProcessed == 0) || res != SZ_OK); + + if (finished || outProcessed >= outSize) + if (outPos != 0) + { + const size_t written = ISeqOutStream_Write(p->outStream, p->outBuf, outPos); + // p->outProcessed += written; // 21.01: BUG fixed + if (written != outPos) + { + stat->CombinedRes_Type = SZ_ERROR_WRITE; + return SZ_ERROR_WRITE; + } + outPos = 0; + } + + if (p->progress && res == SZ_OK) + { + if (p->inProcessed - inPrev >= (1 << 22) || + p->outProcessed - outPrev >= (1 << 22)) + { + res = ICompressProgress_Progress(p->progress, p->inProcessed, p->outProcessed); + if (res != SZ_OK) + { + stat->CombinedRes_Type = SZ_ERROR_PROGRESS; + stat->ProgressRes = res; + return res; + } + inPrev = p->inProcessed; + outPrev = p->outProcessed; + } + } + + if (finished) + { + // p->codeRes is preliminary error from XzUnpacker_Code. + // and it can be corrected later as final result + // so we return SZ_OK here instead of (res); + return SZ_OK; + // return res; + } + } +} + + + +/* +XzStatInfo_SetStat() transforms + CXzUnpacker return code and status to combined CXzStatInfo results. + it can convert SZ_OK to SZ_ERROR_INPUT_EOF + it can convert SZ_ERROR_NO_ARCHIVE to SZ_OK and (DataAfterEnd = 1) +*/ + +static void XzStatInfo_SetStat(const CXzUnpacker *dec, + int finishMode, + // UInt64 readProcessed, + UInt64 inProcessed, + SRes res, // it's result from CXzUnpacker unpacker + ECoderStatus status, + BoolInt decodingTruncated, + CXzStatInfo *stat) +{ + UInt64 extraSize; + + stat->DecodingTruncated = (Byte)(decodingTruncated ? 1 : 0); + stat->InSize = inProcessed; + stat->NumStreams = dec->numStartedStreams; + stat->NumBlocks = dec->numTotalBlocks; + + stat->UnpackSize_Defined = True; + stat->NumStreams_Defined = True; + stat->NumBlocks_Defined = True; + + extraSize = XzUnpacker_GetExtraSize(dec); + + if (res == SZ_OK) + { + if (status == CODER_STATUS_NEEDS_MORE_INPUT) + { + // CODER_STATUS_NEEDS_MORE_INPUT is expected status for correct xz streams + // any extra data is part of correct data + extraSize = 0; + // if xz stream was not finished, then we need more data + if (!XzUnpacker_IsStreamWasFinished(dec)) + res = SZ_ERROR_INPUT_EOF; + } + else + { + // CODER_STATUS_FINISHED_WITH_MARK is not possible for multi stream xz decoding + // so he we have (status == CODER_STATUS_NOT_FINISHED) + // if (status != CODER_STATUS_FINISHED_WITH_MARK) + if (!decodingTruncated || finishMode) + res = SZ_ERROR_DATA; + } + } + else if (res == SZ_ERROR_NO_ARCHIVE) + { + /* + SZ_ERROR_NO_ARCHIVE is possible for 2 states: + XZ_STATE_STREAM_HEADER - if bad signature or bad CRC + XZ_STATE_STREAM_PADDING - if non-zero padding data + extraSize and inProcessed don't include "bad" byte + */ + // if (inProcessed == extraSize), there was no any good xz stream header, and we keep error + if (inProcessed != extraSize) // if there were good xz streams before error + { + // if (extraSize != 0 || readProcessed != inProcessed) + { + // he we suppose that all xz streams were finsihed OK, and we have + // some extra data after all streams + stat->DataAfterEnd = True; + res = SZ_OK; + } + } + } + + if (stat->DecodeRes == SZ_OK) + stat->DecodeRes = res; + + stat->InSize -= extraSize; +} + + + +SRes XzDecMt_Decode(CXzDecMtHandle pp, + const CXzDecMtProps *props, + const UInt64 *outDataSize, int finishMode, + ISeqOutStream *outStream, + // Byte *outBuf, size_t *outBufSize, + ISeqInStream *inStream, + // const Byte *inData, size_t inDataSize, + CXzStatInfo *stat, + int *isMT, + ICompressProgress *progress) +{ + CXzDecMt *p = (CXzDecMt *)pp; + #ifndef _7ZIP_ST + BoolInt tMode; + #endif + + XzStatInfo_Clear(stat); + + p->props = *props; + + p->inStream = inStream; + p->outStream = outStream; + p->progress = progress; + // p->stat = stat; + + p->outSize = 0; + p->outSize_Defined = False; + if (outDataSize) + { + p->outSize_Defined = True; + p->outSize = *outDataSize; + } + + p->finishMode = finishMode; + + // p->outSize = 457; p->outSize_Defined = True; p->finishMode = False; // for test + + p->writeRes = SZ_OK; + p->outProcessed = 0; + p->inProcessed = 0; + p->readProcessed = 0; + p->readWasFinished = False; + p->readRes = SZ_OK; + + p->codeRes = SZ_OK; + p->status = CODER_STATUS_NOT_SPECIFIED; + + XzUnpacker_Init(&p->dec); + + *isMT = False; + + /* + p->outBuf = NULL; + p->outBufSize = 0; + if (!outStream) + { + p->outBuf = outBuf; + p->outBufSize = *outBufSize; + *outBufSize = 0; + } + */ + + + #ifndef _7ZIP_ST + + p->isBlockHeaderState_Parse = False; + p->isBlockHeaderState_Write = False; + // p->numBadBlocks = 0; + p->mainErrorCode = SZ_OK; + p->mainDecoderWasCalled = False; + + tMode = False; + + if (p->props.numThreads > 1) + { + IMtDecCallback2 vt; + BoolInt needContinue; + SRes res; + // we just free ST buffers here + // but we still keep state variables, that was set in XzUnpacker_Init() + XzDecMt_FreeSt(p); + + p->outProcessed_Parse = 0; + p->parsing_Truncated = False; + + p->numStreams = 0; + p->numTotalBlocks = 0; + p->numBlocks = 0; + p->finishedDecoderIndex = -1; + + if (!p->mtc_WasConstructed) + { + p->mtc_WasConstructed = True; + MtDec_Construct(&p->mtc); + } + + p->mtc.mtCallback = &vt; + p->mtc.mtCallbackObject = p; + + p->mtc.progress = progress; + p->mtc.inStream = inStream; + p->mtc.alloc = &p->alignOffsetAlloc.vt; + // p->mtc.inData = inData; + // p->mtc.inDataSize = inDataSize; + p->mtc.inBufSize = p->props.inBufSize_MT; + // p->mtc.inBlockMax = p->props.inBlockMax; + p->mtc.numThreadsMax = p->props.numThreads; + + *isMT = True; + + vt.Parse = XzDecMt_Callback_Parse; + vt.PreCode = XzDecMt_Callback_PreCode; + vt.Code = XzDecMt_Callback_Code; + vt.Write = XzDecMt_Callback_Write; + + + res = MtDec_Code(&p->mtc); + + + stat->InSize = p->mtc.inProcessed; + + p->inProcessed = p->mtc.inProcessed; + p->readRes = p->mtc.readRes; + p->readWasFinished = p->mtc.readWasFinished; + p->readProcessed = p->mtc.readProcessed; + + tMode = True; + needContinue = False; + + if (res == SZ_OK) + { + if (p->mtc.mtProgress.res != SZ_OK) + { + res = p->mtc.mtProgress.res; + stat->ProgressRes = res; + stat->CombinedRes_Type = SZ_ERROR_PROGRESS; + } + else + needContinue = p->mtc.needContinue; + } + + if (!needContinue) + { + { + SRes codeRes; + BoolInt truncated = False; + ECoderStatus status; + const CXzUnpacker *dec; + + stat->OutSize = p->outProcessed; + + if (p->finishedDecoderIndex >= 0) + { + const CXzDecMtThread *coder = &p->coders[(unsigned)p->finishedDecoderIndex]; + codeRes = coder->codeRes; + dec = &coder->dec; + status = coder->status; + } + else if (p->mainDecoderWasCalled) + { + codeRes = p->codeRes; + dec = &p->dec; + status = p->status; + truncated = p->parsing_Truncated; + } + else + return SZ_ERROR_FAIL; + + if (p->mainErrorCode != SZ_OK) + stat->DecodeRes = p->mainErrorCode; + + XzStatInfo_SetStat(dec, p->finishMode, + // p->mtc.readProcessed, + p->mtc.inProcessed, + codeRes, status, + truncated, + stat); + } + + if (res == SZ_OK) + { + stat->ReadRes = p->mtc.readRes; + + if (p->writeRes != SZ_OK) + { + res = p->writeRes; + stat->CombinedRes_Type = SZ_ERROR_WRITE; + } + else if (p->mtc.readRes != SZ_OK + // && p->mtc.inProcessed == p->mtc.readProcessed + && stat->DecodeRes == SZ_ERROR_INPUT_EOF) + { + res = p->mtc.readRes; + stat->CombinedRes_Type = SZ_ERROR_READ; + } + else if (stat->DecodeRes != SZ_OK) + res = stat->DecodeRes; + } + + stat->CombinedRes = res; + if (stat->CombinedRes_Type == SZ_OK) + stat->CombinedRes_Type = res; + return res; + } + + PRF_STR("----- decoding ST -----"); + } + + #endif + + + *isMT = False; + + { + SRes res = XzDecMt_Decode_ST(p + #ifndef _7ZIP_ST + , tMode + #endif + , stat + ); + + #ifndef _7ZIP_ST + // we must set error code from MT decoding at first + if (p->mainErrorCode != SZ_OK) + stat->DecodeRes = p->mainErrorCode; + #endif + + XzStatInfo_SetStat(&p->dec, + p->finishMode, + // p->readProcessed, + p->inProcessed, + p->codeRes, p->status, + False, // truncated + stat); + + stat->ReadRes = p->readRes; + + if (res == SZ_OK) + { + if (p->readRes != SZ_OK + // && p->inProcessed == p->readProcessed + && stat->DecodeRes == SZ_ERROR_INPUT_EOF) + { + // we set read error as combined error, only if that error was the reason + // of decoding problem + res = p->readRes; + stat->CombinedRes_Type = SZ_ERROR_READ; + } + else if (stat->DecodeRes != SZ_OK) + res = stat->DecodeRes; + } + + stat->CombinedRes = res; + if (stat->CombinedRes_Type == SZ_OK) + stat->CombinedRes_Type = res; + return res; + } +} diff --git a/deps/LZMA-SDK/C/XzEnc.c b/deps/LZMA-SDK/C/XzEnc.c index 759ba670e..be174cccf 100644 --- a/deps/LZMA-SDK/C/XzEnc.c +++ b/deps/LZMA-SDK/C/XzEnc.c @@ -1,1330 +1,1330 @@ -/* XzEnc.c -- Xz Encode -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include -#include - -#include "7zCrc.h" -#include "Bra.h" -#include "CpuArch.h" - -#ifdef USE_SUBBLOCK -#include "Bcj3Enc.c" -#include "SbFind.c" -#include "SbEnc.c" -#endif - -#include "XzEnc.h" - -// #define _7ZIP_ST - -#ifndef _7ZIP_ST -#include "MtCoder.h" -#else -#define MTCODER__THREADS_MAX 1 -#define MTCODER__BLOCKS_MAX 1 -#endif - -#define XZ_GET_PAD_SIZE(dataSize) ((4 - ((unsigned)(dataSize) & 3)) & 3) - -/* max pack size for LZMA2 block + check-64bytrs: */ -#define XZ_GET_MAX_BLOCK_PACK_SIZE(unpackSize) ((unpackSize) + ((unpackSize) >> 10) + 16 + 64) - -#define XZ_GET_ESTIMATED_BLOCK_TOTAL_PACK_SIZE(unpackSize) (XZ_BLOCK_HEADER_SIZE_MAX + XZ_GET_MAX_BLOCK_PACK_SIZE(unpackSize)) - - -#define XzBlock_ClearFlags(p) (p)->flags = 0; -#define XzBlock_SetNumFilters(p, n) (p)->flags = (Byte)((p)->flags | ((n) - 1)); -#define XzBlock_SetHasPackSize(p) (p)->flags |= XZ_BF_PACK_SIZE; -#define XzBlock_SetHasUnpackSize(p) (p)->flags |= XZ_BF_UNPACK_SIZE; - - -static SRes WriteBytes(ISeqOutStream *s, const void *buf, size_t size) -{ - return (ISeqOutStream_Write(s, buf, size) == size) ? SZ_OK : SZ_ERROR_WRITE; -} - -static SRes WriteBytesUpdateCrc(ISeqOutStream *s, const void *buf, size_t size, UInt32 *crc) -{ - *crc = CrcUpdate(*crc, buf, size); - return WriteBytes(s, buf, size); -} - - -static SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s) -{ - UInt32 crc; - Byte header[XZ_STREAM_HEADER_SIZE]; - memcpy(header, XZ_SIG, XZ_SIG_SIZE); - header[XZ_SIG_SIZE] = (Byte)(f >> 8); - header[XZ_SIG_SIZE + 1] = (Byte)(f & 0xFF); - crc = CrcCalc(header + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE); - SetUi32(header + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE, crc); - return WriteBytes(s, header, XZ_STREAM_HEADER_SIZE); -} - - -static SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s) -{ - Byte header[XZ_BLOCK_HEADER_SIZE_MAX]; - - unsigned pos = 1; - unsigned numFilters, i; - header[pos++] = p->flags; - - if (XzBlock_HasPackSize(p)) pos += Xz_WriteVarInt(header + pos, p->packSize); - if (XzBlock_HasUnpackSize(p)) pos += Xz_WriteVarInt(header + pos, p->unpackSize); - numFilters = XzBlock_GetNumFilters(p); - - for (i = 0; i < numFilters; i++) - { - const CXzFilter *f = &p->filters[i]; - pos += Xz_WriteVarInt(header + pos, f->id); - pos += Xz_WriteVarInt(header + pos, f->propsSize); - memcpy(header + pos, f->props, f->propsSize); - pos += f->propsSize; - } - - while ((pos & 3) != 0) - header[pos++] = 0; - - header[0] = (Byte)(pos >> 2); - SetUi32(header + pos, CrcCalc(header, pos)); - return WriteBytes(s, header, pos + 4); -} - - - - -typedef struct -{ - size_t numBlocks; - size_t size; - size_t allocated; - Byte *blocks; -} CXzEncIndex; - - -static void XzEncIndex_Construct(CXzEncIndex *p) -{ - p->numBlocks = 0; - p->size = 0; - p->allocated = 0; - p->blocks = NULL; -} - -static void XzEncIndex_Init(CXzEncIndex *p) -{ - p->numBlocks = 0; - p->size = 0; -} - -static void XzEncIndex_Free(CXzEncIndex *p, ISzAllocPtr alloc) -{ - if (p->blocks) - { - ISzAlloc_Free(alloc, p->blocks); - p->blocks = NULL; - } - p->numBlocks = 0; - p->size = 0; - p->allocated = 0; -} - - -static SRes XzEncIndex_ReAlloc(CXzEncIndex *p, size_t newSize, ISzAllocPtr alloc) -{ - Byte *blocks = (Byte *)ISzAlloc_Alloc(alloc, newSize); - if (!blocks) - return SZ_ERROR_MEM; - if (p->size != 0) - memcpy(blocks, p->blocks, p->size); - if (p->blocks) - ISzAlloc_Free(alloc, p->blocks); - p->blocks = blocks; - p->allocated = newSize; - return SZ_OK; -} - - -static SRes XzEncIndex_PreAlloc(CXzEncIndex *p, UInt64 numBlocks, UInt64 unpackSize, UInt64 totalSize, ISzAllocPtr alloc) -{ - UInt64 pos; - { - Byte buf[32]; - unsigned pos2 = Xz_WriteVarInt(buf, totalSize); - pos2 += Xz_WriteVarInt(buf + pos2, unpackSize); - pos = numBlocks * pos2; - } - - if (pos <= p->allocated - p->size) - return SZ_OK; - { - UInt64 newSize64 = p->size + pos; - size_t newSize = (size_t)newSize64; - if (newSize != newSize64) - return SZ_ERROR_MEM; - return XzEncIndex_ReAlloc(p, newSize, alloc); - } -} - - -static SRes XzEncIndex_AddIndexRecord(CXzEncIndex *p, UInt64 unpackSize, UInt64 totalSize, ISzAllocPtr alloc) -{ - Byte buf[32]; - unsigned pos = Xz_WriteVarInt(buf, totalSize); - pos += Xz_WriteVarInt(buf + pos, unpackSize); - - if (pos > p->allocated - p->size) - { - size_t newSize = p->allocated * 2 + 16 * 2; - if (newSize < p->size + pos) - return SZ_ERROR_MEM; - RINOK(XzEncIndex_ReAlloc(p, newSize, alloc)); - } - memcpy(p->blocks + p->size, buf, pos); - p->size += pos; - p->numBlocks++; - return SZ_OK; -} - - -static SRes XzEncIndex_WriteFooter(const CXzEncIndex *p, CXzStreamFlags flags, ISeqOutStream *s) -{ - Byte buf[32]; - UInt64 globalPos; - UInt32 crc = CRC_INIT_VAL; - unsigned pos = 1 + Xz_WriteVarInt(buf + 1, p->numBlocks); - - globalPos = pos; - buf[0] = 0; - RINOK(WriteBytesUpdateCrc(s, buf, pos, &crc)); - RINOK(WriteBytesUpdateCrc(s, p->blocks, p->size, &crc)); - globalPos += p->size; - - pos = XZ_GET_PAD_SIZE(globalPos); - buf[1] = 0; - buf[2] = 0; - buf[3] = 0; - globalPos += pos; - - crc = CrcUpdate(crc, buf + 4 - pos, pos); - SetUi32(buf + 4, CRC_GET_DIGEST(crc)); - - SetUi32(buf + 8 + 4, (UInt32)(globalPos >> 2)); - buf[8 + 8] = (Byte)(flags >> 8); - buf[8 + 9] = (Byte)(flags & 0xFF); - SetUi32(buf + 8, CrcCalc(buf + 8 + 4, 6)); - buf[8 + 10] = XZ_FOOTER_SIG_0; - buf[8 + 11] = XZ_FOOTER_SIG_1; - - return WriteBytes(s, buf + 4 - pos, pos + 4 + 12); -} - - - -/* ---------- CSeqCheckInStream ---------- */ - -typedef struct -{ - ISeqInStream vt; - ISeqInStream *realStream; - const Byte *data; - UInt64 limit; - UInt64 processed; - int realStreamFinished; - CXzCheck check; -} CSeqCheckInStream; - -static void SeqCheckInStream_Init(CSeqCheckInStream *p, unsigned checkMode) -{ - p->limit = (UInt64)(Int64)-1; - p->processed = 0; - p->realStreamFinished = 0; - XzCheck_Init(&p->check, checkMode); -} - -static void SeqCheckInStream_GetDigest(CSeqCheckInStream *p, Byte *digest) -{ - XzCheck_Final(&p->check, digest); -} - -static SRes SeqCheckInStream_Read(const ISeqInStream *pp, void *data, size_t *size) -{ - CSeqCheckInStream *p = CONTAINER_FROM_VTBL(pp, CSeqCheckInStream, vt); - size_t size2 = *size; - SRes res = SZ_OK; - - if (p->limit != (UInt64)(Int64)-1) - { - UInt64 rem = p->limit - p->processed; - if (size2 > rem) - size2 = (size_t)rem; - } - if (size2 != 0) - { - if (p->realStream) - { - res = ISeqInStream_Read(p->realStream, data, &size2); - p->realStreamFinished = (size2 == 0) ? 1 : 0; - } - else - memcpy(data, p->data + (size_t)p->processed, size2); - XzCheck_Update(&p->check, data, size2); - p->processed += size2; - } - *size = size2; - return res; -} - - -/* ---------- CSeqSizeOutStream ---------- */ - -typedef struct -{ - ISeqOutStream vt; - ISeqOutStream *realStream; - Byte *outBuf; - size_t outBufLimit; - UInt64 processed; -} CSeqSizeOutStream; - -static size_t SeqSizeOutStream_Write(const ISeqOutStream *pp, const void *data, size_t size) -{ - CSeqSizeOutStream *p = CONTAINER_FROM_VTBL(pp, CSeqSizeOutStream, vt); - if (p->realStream) - size = ISeqOutStream_Write(p->realStream, data, size); - else - { - if (size > p->outBufLimit - (size_t)p->processed) - return 0; - memcpy(p->outBuf + (size_t)p->processed, data, size); - } - p->processed += size; - return size; -} - - -/* ---------- CSeqInFilter ---------- */ - -#define FILTER_BUF_SIZE (1 << 20) - -typedef struct -{ - ISeqInStream p; - ISeqInStream *realStream; - IStateCoder StateCoder; - Byte *buf; - size_t curPos; - size_t endPos; - int srcWasFinished; -} CSeqInFilter; - - -SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc); - -static SRes SeqInFilter_Init(CSeqInFilter *p, const CXzFilter *props, ISzAllocPtr alloc) -{ - if (!p->buf) - { - p->buf = (Byte *)ISzAlloc_Alloc(alloc, FILTER_BUF_SIZE); - if (!p->buf) - return SZ_ERROR_MEM; - } - p->curPos = p->endPos = 0; - p->srcWasFinished = 0; - RINOK(BraState_SetFromMethod(&p->StateCoder, props->id, 1, alloc)); - RINOK(p->StateCoder.SetProps(p->StateCoder.p, props->props, props->propsSize, alloc)); - p->StateCoder.Init(p->StateCoder.p); - return SZ_OK; -} - - -static SRes SeqInFilter_Read(const ISeqInStream *pp, void *data, size_t *size) -{ - CSeqInFilter *p = CONTAINER_FROM_VTBL(pp, CSeqInFilter, p); - size_t sizeOriginal = *size; - if (sizeOriginal == 0) - return SZ_OK; - *size = 0; - - for (;;) - { - if (!p->srcWasFinished && p->curPos == p->endPos) - { - p->curPos = 0; - p->endPos = FILTER_BUF_SIZE; - RINOK(ISeqInStream_Read(p->realStream, p->buf, &p->endPos)); - if (p->endPos == 0) - p->srcWasFinished = 1; - } - { - SizeT srcLen = p->endPos - p->curPos; - ECoderStatus status; - SRes res; - *size = sizeOriginal; - res = p->StateCoder.Code2(p->StateCoder.p, - (Byte *)data, size, - p->buf + p->curPos, &srcLen, - p->srcWasFinished, CODER_FINISH_ANY, - &status); - p->curPos += srcLen; - if (*size != 0 || srcLen == 0 || res != SZ_OK) - return res; - } - } -} - -static void SeqInFilter_Construct(CSeqInFilter *p) -{ - p->buf = NULL; - p->StateCoder.p = NULL; - p->p.Read = SeqInFilter_Read; -} - -static void SeqInFilter_Free(CSeqInFilter *p, ISzAllocPtr alloc) -{ - if (p->StateCoder.p) - { - p->StateCoder.Free(p->StateCoder.p, alloc); - p->StateCoder.p = NULL; - } - if (p->buf) - { - ISzAlloc_Free(alloc, p->buf); - p->buf = NULL; - } -} - - -/* ---------- CSbEncInStream ---------- */ - -#ifdef USE_SUBBLOCK - -typedef struct -{ - ISeqInStream vt; - ISeqInStream *inStream; - CSbEnc enc; -} CSbEncInStream; - -static SRes SbEncInStream_Read(const ISeqInStream *pp, void *data, size_t *size) -{ - CSbEncInStream *p = CONTAINER_FROM_VTBL(pp, CSbEncInStream, vt); - size_t sizeOriginal = *size; - if (sizeOriginal == 0) - return SZ_OK; - - for (;;) - { - if (p->enc.needRead && !p->enc.readWasFinished) - { - size_t processed = p->enc.needReadSizeMax; - RINOK(p->inStream->Read(p->inStream, p->enc.buf + p->enc.readPos, &processed)); - p->enc.readPos += processed; - if (processed == 0) - { - p->enc.readWasFinished = True; - p->enc.isFinalFinished = True; - } - p->enc.needRead = False; - } - - *size = sizeOriginal; - RINOK(SbEnc_Read(&p->enc, data, size)); - if (*size != 0 || !p->enc.needRead) - return SZ_OK; - } -} - -void SbEncInStream_Construct(CSbEncInStream *p, ISzAllocPtr alloc) -{ - SbEnc_Construct(&p->enc, alloc); - p->vt.Read = SbEncInStream_Read; -} - -SRes SbEncInStream_Init(CSbEncInStream *p) -{ - return SbEnc_Init(&p->enc); -} - -void SbEncInStream_Free(CSbEncInStream *p) -{ - SbEnc_Free(&p->enc); -} - -#endif - - - -/* ---------- CXzProps ---------- */ - - -void XzFilterProps_Init(CXzFilterProps *p) -{ - p->id = 0; - p->delta = 0; - p->ip = 0; - p->ipDefined = False; -} - -void XzProps_Init(CXzProps *p) -{ - p->checkId = XZ_CHECK_CRC32; - p->blockSize = XZ_PROPS__BLOCK_SIZE__AUTO; - p->numBlockThreads_Reduced = -1; - p->numBlockThreads_Max = -1; - p->numTotalThreads = -1; - p->reduceSize = (UInt64)(Int64)-1; - p->forceWriteSizesInHeader = 0; - // p->forceWriteSizesInHeader = 1; - - XzFilterProps_Init(&p->filterProps); - Lzma2EncProps_Init(&p->lzma2Props); -} - - -static void XzEncProps_Normalize_Fixed(CXzProps *p) -{ - UInt64 fileSize; - int t1, t1n, t2, t2r, t3; - { - CLzma2EncProps tp = p->lzma2Props; - if (tp.numTotalThreads <= 0) - tp.numTotalThreads = p->numTotalThreads; - Lzma2EncProps_Normalize(&tp); - t1n = tp.numTotalThreads; - } - - t1 = p->lzma2Props.numTotalThreads; - t2 = p->numBlockThreads_Max; - t3 = p->numTotalThreads; - - if (t2 > MTCODER__THREADS_MAX) - t2 = MTCODER__THREADS_MAX; - - if (t3 <= 0) - { - if (t2 <= 0) - t2 = 1; - t3 = t1n * t2; - } - else if (t2 <= 0) - { - t2 = t3 / t1n; - if (t2 == 0) - { - t1 = 1; - t2 = t3; - } - if (t2 > MTCODER__THREADS_MAX) - t2 = MTCODER__THREADS_MAX; - } - else if (t1 <= 0) - { - t1 = t3 / t2; - if (t1 == 0) - t1 = 1; - } - else - t3 = t1n * t2; - - p->lzma2Props.numTotalThreads = t1; - - t2r = t2; - - fileSize = p->reduceSize; - - if ((p->blockSize < fileSize || fileSize == (UInt64)(Int64)-1)) - p->lzma2Props.lzmaProps.reduceSize = p->blockSize; - - Lzma2EncProps_Normalize(&p->lzma2Props); - - t1 = p->lzma2Props.numTotalThreads; - - { - if (t2 > 1 && fileSize != (UInt64)(Int64)-1) - { - UInt64 numBlocks = fileSize / p->blockSize; - if (numBlocks * p->blockSize != fileSize) - numBlocks++; - if (numBlocks < (unsigned)t2) - { - t2r = (int)numBlocks; - if (t2r == 0) - t2r = 1; - t3 = t1 * t2r; - } - } - } - - p->numBlockThreads_Max = t2; - p->numBlockThreads_Reduced = t2r; - p->numTotalThreads = t3; -} - - -static void XzProps_Normalize(CXzProps *p) -{ - /* we normalize xzProps properties, but we normalize only some of CXzProps::lzma2Props properties. - Lzma2Enc_SetProps() will normalize lzma2Props later. */ - - if (p->blockSize == XZ_PROPS__BLOCK_SIZE__SOLID) - { - p->lzma2Props.lzmaProps.reduceSize = p->reduceSize; - p->numBlockThreads_Reduced = 1; - p->numBlockThreads_Max = 1; - if (p->lzma2Props.numTotalThreads <= 0) - p->lzma2Props.numTotalThreads = p->numTotalThreads; - return; - } - else - { - CLzma2EncProps *lzma2 = &p->lzma2Props; - if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) - { - // xz-auto - p->lzma2Props.lzmaProps.reduceSize = p->reduceSize; - - if (lzma2->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) - { - // if (xz-auto && lzma2-solid) - we use solid for both - p->blockSize = XZ_PROPS__BLOCK_SIZE__SOLID; - p->numBlockThreads_Reduced = 1; - p->numBlockThreads_Max = 1; - if (p->lzma2Props.numTotalThreads <= 0) - p->lzma2Props.numTotalThreads = p->numTotalThreads; - } - else - { - // if (xz-auto && (lzma2-auto || lzma2-fixed_) - // we calculate block size for lzma2 and use that block size for xz, lzma2 uses single-chunk per block - CLzma2EncProps tp = p->lzma2Props; - if (tp.numTotalThreads <= 0) - tp.numTotalThreads = p->numTotalThreads; - - Lzma2EncProps_Normalize(&tp); - - p->blockSize = tp.blockSize; // fixed or solid - p->numBlockThreads_Reduced = tp.numBlockThreads_Reduced; - p->numBlockThreads_Max = tp.numBlockThreads_Max; - if (lzma2->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) - lzma2->blockSize = tp.blockSize; // fixed or solid, LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID - if (lzma2->lzmaProps.reduceSize > tp.blockSize && tp.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) - lzma2->lzmaProps.reduceSize = tp.blockSize; - lzma2->numBlockThreads_Reduced = 1; - lzma2->numBlockThreads_Max = 1; - return; - } - } - else - { - // xz-fixed - // we can use xz::reduceSize or xz::blockSize as base for lzmaProps::reduceSize - - p->lzma2Props.lzmaProps.reduceSize = p->reduceSize; - { - UInt64 r = p->reduceSize; - if (r > p->blockSize || r == (UInt64)(Int64)-1) - r = p->blockSize; - lzma2->lzmaProps.reduceSize = r; - } - if (lzma2->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) - lzma2->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID; - else if (lzma2->blockSize > p->blockSize && lzma2->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) - lzma2->blockSize = p->blockSize; - - XzEncProps_Normalize_Fixed(p); - } - } -} - - -/* ---------- CLzma2WithFilters ---------- */ - -typedef struct -{ - CLzma2EncHandle lzma2; - CSeqInFilter filter; - - #ifdef USE_SUBBLOCK - CSbEncInStream sb; - #endif -} CLzma2WithFilters; - - -static void Lzma2WithFilters_Construct(CLzma2WithFilters *p) -{ - p->lzma2 = NULL; - SeqInFilter_Construct(&p->filter); - - #ifdef USE_SUBBLOCK - SbEncInStream_Construct(&p->sb, alloc); - #endif -} - - -static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p, ISzAllocPtr alloc, ISzAllocPtr bigAlloc) -{ - if (!p->lzma2) - { - p->lzma2 = Lzma2Enc_Create(alloc, bigAlloc); - if (!p->lzma2) - return SZ_ERROR_MEM; - } - return SZ_OK; -} - - -static void Lzma2WithFilters_Free(CLzma2WithFilters *p, ISzAllocPtr alloc) -{ - #ifdef USE_SUBBLOCK - SbEncInStream_Free(&p->sb); - #endif - - SeqInFilter_Free(&p->filter, alloc); - if (p->lzma2) - { - Lzma2Enc_Destroy(p->lzma2); - p->lzma2 = NULL; - } -} - - -typedef struct -{ - UInt64 unpackSize; - UInt64 totalSize; - size_t headerSize; -} CXzEncBlockInfo; - - -static SRes Xz_CompressBlock( - CLzma2WithFilters *lzmaf, - - ISeqOutStream *outStream, - Byte *outBufHeader, - Byte *outBufData, size_t outBufDataLimit, - - ISeqInStream *inStream, - // UInt64 expectedSize, - const Byte *inBuf, // used if (!inStream) - size_t inBufSize, // used if (!inStream), it's block size, props->blockSize is ignored - - const CXzProps *props, - ICompressProgress *progress, - int *inStreamFinished, /* only for inStream version */ - CXzEncBlockInfo *blockSizes, - ISzAllocPtr alloc, - ISzAllocPtr allocBig) -{ - CSeqCheckInStream checkInStream; - CSeqSizeOutStream seqSizeOutStream; - CXzBlock block; - unsigned filterIndex = 0; - CXzFilter *filter = NULL; - const CXzFilterProps *fp = &props->filterProps; - if (fp->id == 0) - fp = NULL; - - *inStreamFinished = False; - - RINOK(Lzma2WithFilters_Create(lzmaf, alloc, allocBig)); - - RINOK(Lzma2Enc_SetProps(lzmaf->lzma2, &props->lzma2Props)); - - XzBlock_ClearFlags(&block); - XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0)); - - if (fp) - { - filter = &block.filters[filterIndex++]; - filter->id = fp->id; - filter->propsSize = 0; - - if (fp->id == XZ_ID_Delta) - { - filter->props[0] = (Byte)(fp->delta - 1); - filter->propsSize = 1; - } - else if (fp->ipDefined) - { - Byte *ptr = filter->props; - SetUi32(ptr, fp->ip); - filter->propsSize = 4; - } - } - - { - CXzFilter *f = &block.filters[filterIndex++]; - f->id = XZ_ID_LZMA2; - f->propsSize = 1; - f->props[0] = Lzma2Enc_WriteProperties(lzmaf->lzma2); - } - - seqSizeOutStream.vt.Write = SeqSizeOutStream_Write; - seqSizeOutStream.realStream = outStream; - seqSizeOutStream.outBuf = outBufData; - seqSizeOutStream.outBufLimit = outBufDataLimit; - seqSizeOutStream.processed = 0; - - /* - if (expectedSize != (UInt64)(Int64)-1) - { - block.unpackSize = expectedSize; - if (props->blockSize != (UInt64)(Int64)-1) - if (expectedSize > props->blockSize) - block.unpackSize = props->blockSize; - XzBlock_SetHasUnpackSize(&block); - } - */ - - if (outStream) - { - RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.vt)); - } - - checkInStream.vt.Read = SeqCheckInStream_Read; - SeqCheckInStream_Init(&checkInStream, props->checkId); - - checkInStream.realStream = inStream; - checkInStream.data = inBuf; - checkInStream.limit = props->blockSize; - if (!inStream) - checkInStream.limit = inBufSize; - - if (fp) - { - #ifdef USE_SUBBLOCK - if (fp->id == XZ_ID_Subblock) - { - lzmaf->sb.inStream = &checkInStream.vt; - RINOK(SbEncInStream_Init(&lzmaf->sb)); - } - else - #endif - { - lzmaf->filter.realStream = &checkInStream.vt; - RINOK(SeqInFilter_Init(&lzmaf->filter, filter, alloc)); - } - } - - { - SRes res; - Byte *outBuf = NULL; - size_t outSize = 0; - BoolInt useStream = (fp || inStream); - // useStream = True; - - if (!useStream) - { - XzCheck_Update(&checkInStream.check, inBuf, inBufSize); - checkInStream.processed = inBufSize; - } - - if (!outStream) - { - outBuf = seqSizeOutStream.outBuf; // + (size_t)seqSizeOutStream.processed; - outSize = seqSizeOutStream.outBufLimit; // - (size_t)seqSizeOutStream.processed; - } - - res = Lzma2Enc_Encode2(lzmaf->lzma2, - outBuf ? NULL : &seqSizeOutStream.vt, - outBuf, - outBuf ? &outSize : NULL, - - useStream ? - (fp ? - ( - #ifdef USE_SUBBLOCK - (fp->id == XZ_ID_Subblock) ? &lzmaf->sb.vt: - #endif - &lzmaf->filter.p) : - &checkInStream.vt) : NULL, - - useStream ? NULL : inBuf, - useStream ? 0 : inBufSize, - - progress); - - if (outBuf) - seqSizeOutStream.processed += outSize; - - RINOK(res); - blockSizes->unpackSize = checkInStream.processed; - } - { - Byte buf[4 + 64]; - unsigned padSize = XZ_GET_PAD_SIZE(seqSizeOutStream.processed); - UInt64 packSize = seqSizeOutStream.processed; - - buf[0] = 0; - buf[1] = 0; - buf[2] = 0; - buf[3] = 0; - - SeqCheckInStream_GetDigest(&checkInStream, buf + 4); - RINOK(WriteBytes(&seqSizeOutStream.vt, buf + (4 - padSize), padSize + XzFlags_GetCheckSize((CXzStreamFlags)props->checkId))); - - blockSizes->totalSize = seqSizeOutStream.processed - padSize; - - if (!outStream) - { - seqSizeOutStream.outBuf = outBufHeader; - seqSizeOutStream.outBufLimit = XZ_BLOCK_HEADER_SIZE_MAX; - seqSizeOutStream.processed = 0; - - block.unpackSize = blockSizes->unpackSize; - XzBlock_SetHasUnpackSize(&block); - - block.packSize = packSize; - XzBlock_SetHasPackSize(&block); - - RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.vt)); - - blockSizes->headerSize = (size_t)seqSizeOutStream.processed; - blockSizes->totalSize += seqSizeOutStream.processed; - } - } - - if (inStream) - *inStreamFinished = checkInStream.realStreamFinished; - else - { - *inStreamFinished = False; - if (checkInStream.processed != inBufSize) - return SZ_ERROR_FAIL; - } - - return SZ_OK; -} - - - -typedef struct -{ - ICompressProgress vt; - ICompressProgress *progress; - UInt64 inOffset; - UInt64 outOffset; -} CCompressProgress_XzEncOffset; - - -static SRes CompressProgress_XzEncOffset_Progress(const ICompressProgress *pp, UInt64 inSize, UInt64 outSize) -{ - const CCompressProgress_XzEncOffset *p = CONTAINER_FROM_VTBL(pp, CCompressProgress_XzEncOffset, vt); - inSize += p->inOffset; - outSize += p->outOffset; - return ICompressProgress_Progress(p->progress, inSize, outSize); -} - - - - -typedef struct -{ - ISzAllocPtr alloc; - ISzAllocPtr allocBig; - - CXzProps xzProps; - UInt64 expectedDataSize; - - CXzEncIndex xzIndex; - - CLzma2WithFilters lzmaf_Items[MTCODER__THREADS_MAX]; - - size_t outBufSize; /* size of allocated outBufs[i] */ - Byte *outBufs[MTCODER__BLOCKS_MAX]; - - #ifndef _7ZIP_ST - unsigned checkType; - ISeqOutStream *outStream; - BoolInt mtCoder_WasConstructed; - CMtCoder mtCoder; - CXzEncBlockInfo EncBlocks[MTCODER__BLOCKS_MAX]; - #endif - -} CXzEnc; - - -static void XzEnc_Construct(CXzEnc *p) -{ - unsigned i; - - XzEncIndex_Construct(&p->xzIndex); - - for (i = 0; i < MTCODER__THREADS_MAX; i++) - Lzma2WithFilters_Construct(&p->lzmaf_Items[i]); - - #ifndef _7ZIP_ST - p->mtCoder_WasConstructed = False; - { - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - p->outBufs[i] = NULL; - p->outBufSize = 0; - } - #endif -} - - -static void XzEnc_FreeOutBufs(CXzEnc *p) -{ - unsigned i; - for (i = 0; i < MTCODER__BLOCKS_MAX; i++) - if (p->outBufs[i]) - { - ISzAlloc_Free(p->alloc, p->outBufs[i]); - p->outBufs[i] = NULL; - } - p->outBufSize = 0; -} - - -static void XzEnc_Free(CXzEnc *p, ISzAllocPtr alloc) -{ - unsigned i; - - XzEncIndex_Free(&p->xzIndex, alloc); - - for (i = 0; i < MTCODER__THREADS_MAX; i++) - Lzma2WithFilters_Free(&p->lzmaf_Items[i], alloc); - - #ifndef _7ZIP_ST - if (p->mtCoder_WasConstructed) - { - MtCoder_Destruct(&p->mtCoder); - p->mtCoder_WasConstructed = False; - } - XzEnc_FreeOutBufs(p); - #endif -} - - -CXzEncHandle XzEnc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig) -{ - CXzEnc *p = (CXzEnc *)ISzAlloc_Alloc(alloc, sizeof(CXzEnc)); - if (!p) - return NULL; - XzEnc_Construct(p); - XzProps_Init(&p->xzProps); - XzProps_Normalize(&p->xzProps); - p->expectedDataSize = (UInt64)(Int64)-1; - p->alloc = alloc; - p->allocBig = allocBig; - return p; -} - - -void XzEnc_Destroy(CXzEncHandle pp) -{ - CXzEnc *p = (CXzEnc *)pp; - XzEnc_Free(p, p->alloc); - ISzAlloc_Free(p->alloc, p); -} - - -SRes XzEnc_SetProps(CXzEncHandle pp, const CXzProps *props) -{ - CXzEnc *p = (CXzEnc *)pp; - p->xzProps = *props; - XzProps_Normalize(&p->xzProps); - return SZ_OK; -} - - -void XzEnc_SetDataSize(CXzEncHandle pp, UInt64 expectedDataSiize) -{ - CXzEnc *p = (CXzEnc *)pp; - p->expectedDataSize = expectedDataSiize; -} - - - - -#ifndef _7ZIP_ST - -static SRes XzEnc_MtCallback_Code(void *pp, unsigned coderIndex, unsigned outBufIndex, - const Byte *src, size_t srcSize, int finished) -{ - CXzEnc *me = (CXzEnc *)pp; - SRes res; - CMtProgressThunk progressThunk; - - Byte *dest = me->outBufs[outBufIndex]; - - UNUSED_VAR(finished) - - { - CXzEncBlockInfo *bInfo = &me->EncBlocks[outBufIndex]; - bInfo->totalSize = 0; - bInfo->unpackSize = 0; - bInfo->headerSize = 0; - } - - if (!dest) - { - dest = (Byte *)ISzAlloc_Alloc(me->alloc, me->outBufSize); - if (!dest) - return SZ_ERROR_MEM; - me->outBufs[outBufIndex] = dest; - } - - MtProgressThunk_CreateVTable(&progressThunk); - progressThunk.mtProgress = &me->mtCoder.mtProgress; - MtProgressThunk_Init(&progressThunk); - - { - CXzEncBlockInfo blockSizes; - int inStreamFinished; - - res = Xz_CompressBlock( - &me->lzmaf_Items[coderIndex], - - NULL, - dest, - dest + XZ_BLOCK_HEADER_SIZE_MAX, me->outBufSize - XZ_BLOCK_HEADER_SIZE_MAX, - - NULL, - // srcSize, // expectedSize - src, srcSize, - - &me->xzProps, - &progressThunk.vt, - &inStreamFinished, - &blockSizes, - me->alloc, - me->allocBig); - - if (res == SZ_OK) - me->EncBlocks[outBufIndex] = blockSizes; - - return res; - } -} - - -static SRes XzEnc_MtCallback_Write(void *pp, unsigned outBufIndex) -{ - CXzEnc *me = (CXzEnc *)pp; - - const CXzEncBlockInfo *bInfo = &me->EncBlocks[outBufIndex]; - const Byte *data = me->outBufs[outBufIndex]; - - RINOK(WriteBytes(me->outStream, data, bInfo->headerSize)); - - { - UInt64 totalPackFull = bInfo->totalSize + XZ_GET_PAD_SIZE(bInfo->totalSize); - RINOK(WriteBytes(me->outStream, data + XZ_BLOCK_HEADER_SIZE_MAX, (size_t)totalPackFull - bInfo->headerSize)); - } - - return XzEncIndex_AddIndexRecord(&me->xzIndex, bInfo->unpackSize, bInfo->totalSize, me->alloc); -} - -#endif - - - -SRes XzEnc_Encode(CXzEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress) -{ - CXzEnc *p = (CXzEnc *)pp; - - const CXzProps *props = &p->xzProps; - - XzEncIndex_Init(&p->xzIndex); - { - UInt64 numBlocks = 1; - UInt64 blockSize = props->blockSize; - - if (blockSize != XZ_PROPS__BLOCK_SIZE__SOLID - && props->reduceSize != (UInt64)(Int64)-1) - { - numBlocks = props->reduceSize / blockSize; - if (numBlocks * blockSize != props->reduceSize) - numBlocks++; - } - else - blockSize = (UInt64)1 << 62; - - RINOK(XzEncIndex_PreAlloc(&p->xzIndex, numBlocks, blockSize, XZ_GET_ESTIMATED_BLOCK_TOTAL_PACK_SIZE(blockSize), p->alloc)); - } - - RINOK(Xz_WriteHeader((CXzStreamFlags)props->checkId, outStream)); - - - #ifndef _7ZIP_ST - if (props->numBlockThreads_Reduced > 1) - { - IMtCoderCallback2 vt; - - if (!p->mtCoder_WasConstructed) - { - p->mtCoder_WasConstructed = True; - MtCoder_Construct(&p->mtCoder); - } - - vt.Code = XzEnc_MtCallback_Code; - vt.Write = XzEnc_MtCallback_Write; - - p->checkType = props->checkId; - p->xzProps = *props; - - p->outStream = outStream; - - p->mtCoder.allocBig = p->allocBig; - p->mtCoder.progress = progress; - p->mtCoder.inStream = inStream; - p->mtCoder.inData = NULL; - p->mtCoder.inDataSize = 0; - p->mtCoder.mtCallback = &vt; - p->mtCoder.mtCallbackObject = p; - - if ( props->blockSize == XZ_PROPS__BLOCK_SIZE__SOLID - || props->blockSize == XZ_PROPS__BLOCK_SIZE__AUTO) - return SZ_ERROR_FAIL; - - p->mtCoder.blockSize = (size_t)props->blockSize; - if (p->mtCoder.blockSize != props->blockSize) - return SZ_ERROR_PARAM; /* SZ_ERROR_MEM */ - - { - size_t destBlockSize = XZ_BLOCK_HEADER_SIZE_MAX + XZ_GET_MAX_BLOCK_PACK_SIZE(p->mtCoder.blockSize); - if (destBlockSize < p->mtCoder.blockSize) - return SZ_ERROR_PARAM; - if (p->outBufSize != destBlockSize) - XzEnc_FreeOutBufs(p); - p->outBufSize = destBlockSize; - } - - p->mtCoder.numThreadsMax = (unsigned)props->numBlockThreads_Max; - p->mtCoder.expectedDataSize = p->expectedDataSize; - - RINOK(MtCoder_Code(&p->mtCoder)); - } - else - #endif - { - int writeStartSizes; - CCompressProgress_XzEncOffset progress2; - Byte *bufData = NULL; - size_t bufSize = 0; - - progress2.vt.Progress = CompressProgress_XzEncOffset_Progress; - progress2.inOffset = 0; - progress2.outOffset = 0; - progress2.progress = progress; - - writeStartSizes = 0; - - if (props->blockSize != XZ_PROPS__BLOCK_SIZE__SOLID) - { - writeStartSizes = (props->forceWriteSizesInHeader > 0); - - if (writeStartSizes) - { - size_t t2; - size_t t = (size_t)props->blockSize; - if (t != props->blockSize) - return SZ_ERROR_PARAM; - t = XZ_GET_MAX_BLOCK_PACK_SIZE(t); - if (t < props->blockSize) - return SZ_ERROR_PARAM; - t2 = XZ_BLOCK_HEADER_SIZE_MAX + t; - if (!p->outBufs[0] || t2 != p->outBufSize) - { - XzEnc_FreeOutBufs(p); - p->outBufs[0] = (Byte *)ISzAlloc_Alloc(p->alloc, t2); - if (!p->outBufs[0]) - return SZ_ERROR_MEM; - p->outBufSize = t2; - } - bufData = p->outBufs[0] + XZ_BLOCK_HEADER_SIZE_MAX; - bufSize = t; - } - } - - for (;;) - { - CXzEncBlockInfo blockSizes; - int inStreamFinished; - - /* - UInt64 rem = (UInt64)(Int64)-1; - if (props->reduceSize != (UInt64)(Int64)-1 - && props->reduceSize >= progress2.inOffset) - rem = props->reduceSize - progress2.inOffset; - */ - - blockSizes.headerSize = 0; // for GCC - - RINOK(Xz_CompressBlock( - &p->lzmaf_Items[0], - - writeStartSizes ? NULL : outStream, - writeStartSizes ? p->outBufs[0] : NULL, - bufData, bufSize, - - inStream, - // rem, - NULL, 0, - - props, - progress ? &progress2.vt : NULL, - &inStreamFinished, - &blockSizes, - p->alloc, - p->allocBig)); - - { - UInt64 totalPackFull = blockSizes.totalSize + XZ_GET_PAD_SIZE(blockSizes.totalSize); - - if (writeStartSizes) - { - RINOK(WriteBytes(outStream, p->outBufs[0], blockSizes.headerSize)); - RINOK(WriteBytes(outStream, bufData, (size_t)totalPackFull - blockSizes.headerSize)); - } - - RINOK(XzEncIndex_AddIndexRecord(&p->xzIndex, blockSizes.unpackSize, blockSizes.totalSize, p->alloc)); - - progress2.inOffset += blockSizes.unpackSize; - progress2.outOffset += totalPackFull; - } - - if (inStreamFinished) - break; - } - } - - return XzEncIndex_WriteFooter(&p->xzIndex, (CXzStreamFlags)props->checkId, outStream); -} - - -#include "Alloc.h" - -SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, - const CXzProps *props, ICompressProgress *progress) -{ - SRes res; - CXzEncHandle xz = XzEnc_Create(&g_Alloc, &g_BigAlloc); - if (!xz) - return SZ_ERROR_MEM; - res = XzEnc_SetProps(xz, props); - if (res == SZ_OK) - res = XzEnc_Encode(xz, outStream, inStream, progress); - XzEnc_Destroy(xz); - return res; -} - - -SRes Xz_EncodeEmpty(ISeqOutStream *outStream) -{ - SRes res; - CXzEncIndex xzIndex; - XzEncIndex_Construct(&xzIndex); - res = Xz_WriteHeader((CXzStreamFlags)0, outStream); - if (res == SZ_OK) - res = XzEncIndex_WriteFooter(&xzIndex, (CXzStreamFlags)0, outStream); - XzEncIndex_Free(&xzIndex, NULL); // g_Alloc - return res; -} +/* XzEnc.c -- Xz Encode +2021-04-01 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include +#include + +#include "7zCrc.h" +#include "Bra.h" +#include "CpuArch.h" + +#ifdef USE_SUBBLOCK +#include "Bcj3Enc.c" +#include "SbFind.c" +#include "SbEnc.c" +#endif + +#include "XzEnc.h" + +// #define _7ZIP_ST + +#ifndef _7ZIP_ST +#include "MtCoder.h" +#else +#define MTCODER__THREADS_MAX 1 +#define MTCODER__BLOCKS_MAX 1 +#endif + +#define XZ_GET_PAD_SIZE(dataSize) ((4 - ((unsigned)(dataSize) & 3)) & 3) + +/* max pack size for LZMA2 block + check-64bytrs: */ +#define XZ_GET_MAX_BLOCK_PACK_SIZE(unpackSize) ((unpackSize) + ((unpackSize) >> 10) + 16 + 64) + +#define XZ_GET_ESTIMATED_BLOCK_TOTAL_PACK_SIZE(unpackSize) (XZ_BLOCK_HEADER_SIZE_MAX + XZ_GET_MAX_BLOCK_PACK_SIZE(unpackSize)) + + +#define XzBlock_ClearFlags(p) (p)->flags = 0; +#define XzBlock_SetNumFilters(p, n) (p)->flags = (Byte)((p)->flags | ((n) - 1)); +#define XzBlock_SetHasPackSize(p) (p)->flags |= XZ_BF_PACK_SIZE; +#define XzBlock_SetHasUnpackSize(p) (p)->flags |= XZ_BF_UNPACK_SIZE; + + +static SRes WriteBytes(ISeqOutStream *s, const void *buf, size_t size) +{ + return (ISeqOutStream_Write(s, buf, size) == size) ? SZ_OK : SZ_ERROR_WRITE; +} + +static SRes WriteBytesUpdateCrc(ISeqOutStream *s, const void *buf, size_t size, UInt32 *crc) +{ + *crc = CrcUpdate(*crc, buf, size); + return WriteBytes(s, buf, size); +} + + +static SRes Xz_WriteHeader(CXzStreamFlags f, ISeqOutStream *s) +{ + UInt32 crc; + Byte header[XZ_STREAM_HEADER_SIZE]; + memcpy(header, XZ_SIG, XZ_SIG_SIZE); + header[XZ_SIG_SIZE] = (Byte)(f >> 8); + header[XZ_SIG_SIZE + 1] = (Byte)(f & 0xFF); + crc = CrcCalc(header + XZ_SIG_SIZE, XZ_STREAM_FLAGS_SIZE); + SetUi32(header + XZ_SIG_SIZE + XZ_STREAM_FLAGS_SIZE, crc); + return WriteBytes(s, header, XZ_STREAM_HEADER_SIZE); +} + + +static SRes XzBlock_WriteHeader(const CXzBlock *p, ISeqOutStream *s) +{ + Byte header[XZ_BLOCK_HEADER_SIZE_MAX]; + + unsigned pos = 1; + unsigned numFilters, i; + header[pos++] = p->flags; + + if (XzBlock_HasPackSize(p)) pos += Xz_WriteVarInt(header + pos, p->packSize); + if (XzBlock_HasUnpackSize(p)) pos += Xz_WriteVarInt(header + pos, p->unpackSize); + numFilters = XzBlock_GetNumFilters(p); + + for (i = 0; i < numFilters; i++) + { + const CXzFilter *f = &p->filters[i]; + pos += Xz_WriteVarInt(header + pos, f->id); + pos += Xz_WriteVarInt(header + pos, f->propsSize); + memcpy(header + pos, f->props, f->propsSize); + pos += f->propsSize; + } + + while ((pos & 3) != 0) + header[pos++] = 0; + + header[0] = (Byte)(pos >> 2); + SetUi32(header + pos, CrcCalc(header, pos)); + return WriteBytes(s, header, pos + 4); +} + + + + +typedef struct +{ + size_t numBlocks; + size_t size; + size_t allocated; + Byte *blocks; +} CXzEncIndex; + + +static void XzEncIndex_Construct(CXzEncIndex *p) +{ + p->numBlocks = 0; + p->size = 0; + p->allocated = 0; + p->blocks = NULL; +} + +static void XzEncIndex_Init(CXzEncIndex *p) +{ + p->numBlocks = 0; + p->size = 0; +} + +static void XzEncIndex_Free(CXzEncIndex *p, ISzAllocPtr alloc) +{ + if (p->blocks) + { + ISzAlloc_Free(alloc, p->blocks); + p->blocks = NULL; + } + p->numBlocks = 0; + p->size = 0; + p->allocated = 0; +} + + +static SRes XzEncIndex_ReAlloc(CXzEncIndex *p, size_t newSize, ISzAllocPtr alloc) +{ + Byte *blocks = (Byte *)ISzAlloc_Alloc(alloc, newSize); + if (!blocks) + return SZ_ERROR_MEM; + if (p->size != 0) + memcpy(blocks, p->blocks, p->size); + if (p->blocks) + ISzAlloc_Free(alloc, p->blocks); + p->blocks = blocks; + p->allocated = newSize; + return SZ_OK; +} + + +static SRes XzEncIndex_PreAlloc(CXzEncIndex *p, UInt64 numBlocks, UInt64 unpackSize, UInt64 totalSize, ISzAllocPtr alloc) +{ + UInt64 pos; + { + Byte buf[32]; + unsigned pos2 = Xz_WriteVarInt(buf, totalSize); + pos2 += Xz_WriteVarInt(buf + pos2, unpackSize); + pos = numBlocks * pos2; + } + + if (pos <= p->allocated - p->size) + return SZ_OK; + { + UInt64 newSize64 = p->size + pos; + size_t newSize = (size_t)newSize64; + if (newSize != newSize64) + return SZ_ERROR_MEM; + return XzEncIndex_ReAlloc(p, newSize, alloc); + } +} + + +static SRes XzEncIndex_AddIndexRecord(CXzEncIndex *p, UInt64 unpackSize, UInt64 totalSize, ISzAllocPtr alloc) +{ + Byte buf[32]; + unsigned pos = Xz_WriteVarInt(buf, totalSize); + pos += Xz_WriteVarInt(buf + pos, unpackSize); + + if (pos > p->allocated - p->size) + { + size_t newSize = p->allocated * 2 + 16 * 2; + if (newSize < p->size + pos) + return SZ_ERROR_MEM; + RINOK(XzEncIndex_ReAlloc(p, newSize, alloc)); + } + memcpy(p->blocks + p->size, buf, pos); + p->size += pos; + p->numBlocks++; + return SZ_OK; +} + + +static SRes XzEncIndex_WriteFooter(const CXzEncIndex *p, CXzStreamFlags flags, ISeqOutStream *s) +{ + Byte buf[32]; + UInt64 globalPos; + UInt32 crc = CRC_INIT_VAL; + unsigned pos = 1 + Xz_WriteVarInt(buf + 1, p->numBlocks); + + globalPos = pos; + buf[0] = 0; + RINOK(WriteBytesUpdateCrc(s, buf, pos, &crc)); + RINOK(WriteBytesUpdateCrc(s, p->blocks, p->size, &crc)); + globalPos += p->size; + + pos = XZ_GET_PAD_SIZE(globalPos); + buf[1] = 0; + buf[2] = 0; + buf[3] = 0; + globalPos += pos; + + crc = CrcUpdate(crc, buf + 4 - pos, pos); + SetUi32(buf + 4, CRC_GET_DIGEST(crc)); + + SetUi32(buf + 8 + 4, (UInt32)(globalPos >> 2)); + buf[8 + 8] = (Byte)(flags >> 8); + buf[8 + 9] = (Byte)(flags & 0xFF); + SetUi32(buf + 8, CrcCalc(buf + 8 + 4, 6)); + buf[8 + 10] = XZ_FOOTER_SIG_0; + buf[8 + 11] = XZ_FOOTER_SIG_1; + + return WriteBytes(s, buf + 4 - pos, pos + 4 + 12); +} + + + +/* ---------- CSeqCheckInStream ---------- */ + +typedef struct +{ + ISeqInStream vt; + ISeqInStream *realStream; + const Byte *data; + UInt64 limit; + UInt64 processed; + int realStreamFinished; + CXzCheck check; +} CSeqCheckInStream; + +static void SeqCheckInStream_Init(CSeqCheckInStream *p, unsigned checkMode) +{ + p->limit = (UInt64)(Int64)-1; + p->processed = 0; + p->realStreamFinished = 0; + XzCheck_Init(&p->check, checkMode); +} + +static void SeqCheckInStream_GetDigest(CSeqCheckInStream *p, Byte *digest) +{ + XzCheck_Final(&p->check, digest); +} + +static SRes SeqCheckInStream_Read(const ISeqInStream *pp, void *data, size_t *size) +{ + CSeqCheckInStream *p = CONTAINER_FROM_VTBL(pp, CSeqCheckInStream, vt); + size_t size2 = *size; + SRes res = SZ_OK; + + if (p->limit != (UInt64)(Int64)-1) + { + UInt64 rem = p->limit - p->processed; + if (size2 > rem) + size2 = (size_t)rem; + } + if (size2 != 0) + { + if (p->realStream) + { + res = ISeqInStream_Read(p->realStream, data, &size2); + p->realStreamFinished = (size2 == 0) ? 1 : 0; + } + else + memcpy(data, p->data + (size_t)p->processed, size2); + XzCheck_Update(&p->check, data, size2); + p->processed += size2; + } + *size = size2; + return res; +} + + +/* ---------- CSeqSizeOutStream ---------- */ + +typedef struct +{ + ISeqOutStream vt; + ISeqOutStream *realStream; + Byte *outBuf; + size_t outBufLimit; + UInt64 processed; +} CSeqSizeOutStream; + +static size_t SeqSizeOutStream_Write(const ISeqOutStream *pp, const void *data, size_t size) +{ + CSeqSizeOutStream *p = CONTAINER_FROM_VTBL(pp, CSeqSizeOutStream, vt); + if (p->realStream) + size = ISeqOutStream_Write(p->realStream, data, size); + else + { + if (size > p->outBufLimit - (size_t)p->processed) + return 0; + memcpy(p->outBuf + (size_t)p->processed, data, size); + } + p->processed += size; + return size; +} + + +/* ---------- CSeqInFilter ---------- */ + +#define FILTER_BUF_SIZE (1 << 20) + +typedef struct +{ + ISeqInStream p; + ISeqInStream *realStream; + IStateCoder StateCoder; + Byte *buf; + size_t curPos; + size_t endPos; + int srcWasFinished; +} CSeqInFilter; + + +SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAllocPtr alloc); + +static SRes SeqInFilter_Init(CSeqInFilter *p, const CXzFilter *props, ISzAllocPtr alloc) +{ + if (!p->buf) + { + p->buf = (Byte *)ISzAlloc_Alloc(alloc, FILTER_BUF_SIZE); + if (!p->buf) + return SZ_ERROR_MEM; + } + p->curPos = p->endPos = 0; + p->srcWasFinished = 0; + RINOK(BraState_SetFromMethod(&p->StateCoder, props->id, 1, alloc)); + RINOK(p->StateCoder.SetProps(p->StateCoder.p, props->props, props->propsSize, alloc)); + p->StateCoder.Init(p->StateCoder.p); + return SZ_OK; +} + + +static SRes SeqInFilter_Read(const ISeqInStream *pp, void *data, size_t *size) +{ + CSeqInFilter *p = CONTAINER_FROM_VTBL(pp, CSeqInFilter, p); + size_t sizeOriginal = *size; + if (sizeOriginal == 0) + return SZ_OK; + *size = 0; + + for (;;) + { + if (!p->srcWasFinished && p->curPos == p->endPos) + { + p->curPos = 0; + p->endPos = FILTER_BUF_SIZE; + RINOK(ISeqInStream_Read(p->realStream, p->buf, &p->endPos)); + if (p->endPos == 0) + p->srcWasFinished = 1; + } + { + SizeT srcLen = p->endPos - p->curPos; + ECoderStatus status; + SRes res; + *size = sizeOriginal; + res = p->StateCoder.Code2(p->StateCoder.p, + (Byte *)data, size, + p->buf + p->curPos, &srcLen, + p->srcWasFinished, CODER_FINISH_ANY, + &status); + p->curPos += srcLen; + if (*size != 0 || srcLen == 0 || res != SZ_OK) + return res; + } + } +} + +static void SeqInFilter_Construct(CSeqInFilter *p) +{ + p->buf = NULL; + p->StateCoder.p = NULL; + p->p.Read = SeqInFilter_Read; +} + +static void SeqInFilter_Free(CSeqInFilter *p, ISzAllocPtr alloc) +{ + if (p->StateCoder.p) + { + p->StateCoder.Free(p->StateCoder.p, alloc); + p->StateCoder.p = NULL; + } + if (p->buf) + { + ISzAlloc_Free(alloc, p->buf); + p->buf = NULL; + } +} + + +/* ---------- CSbEncInStream ---------- */ + +#ifdef USE_SUBBLOCK + +typedef struct +{ + ISeqInStream vt; + ISeqInStream *inStream; + CSbEnc enc; +} CSbEncInStream; + +static SRes SbEncInStream_Read(const ISeqInStream *pp, void *data, size_t *size) +{ + CSbEncInStream *p = CONTAINER_FROM_VTBL(pp, CSbEncInStream, vt); + size_t sizeOriginal = *size; + if (sizeOriginal == 0) + return SZ_OK; + + for (;;) + { + if (p->enc.needRead && !p->enc.readWasFinished) + { + size_t processed = p->enc.needReadSizeMax; + RINOK(p->inStream->Read(p->inStream, p->enc.buf + p->enc.readPos, &processed)); + p->enc.readPos += processed; + if (processed == 0) + { + p->enc.readWasFinished = True; + p->enc.isFinalFinished = True; + } + p->enc.needRead = False; + } + + *size = sizeOriginal; + RINOK(SbEnc_Read(&p->enc, data, size)); + if (*size != 0 || !p->enc.needRead) + return SZ_OK; + } +} + +void SbEncInStream_Construct(CSbEncInStream *p, ISzAllocPtr alloc) +{ + SbEnc_Construct(&p->enc, alloc); + p->vt.Read = SbEncInStream_Read; +} + +SRes SbEncInStream_Init(CSbEncInStream *p) +{ + return SbEnc_Init(&p->enc); +} + +void SbEncInStream_Free(CSbEncInStream *p) +{ + SbEnc_Free(&p->enc); +} + +#endif + + + +/* ---------- CXzProps ---------- */ + + +void XzFilterProps_Init(CXzFilterProps *p) +{ + p->id = 0; + p->delta = 0; + p->ip = 0; + p->ipDefined = False; +} + +void XzProps_Init(CXzProps *p) +{ + p->checkId = XZ_CHECK_CRC32; + p->blockSize = XZ_PROPS__BLOCK_SIZE__AUTO; + p->numBlockThreads_Reduced = -1; + p->numBlockThreads_Max = -1; + p->numTotalThreads = -1; + p->reduceSize = (UInt64)(Int64)-1; + p->forceWriteSizesInHeader = 0; + // p->forceWriteSizesInHeader = 1; + + XzFilterProps_Init(&p->filterProps); + Lzma2EncProps_Init(&p->lzma2Props); +} + + +static void XzEncProps_Normalize_Fixed(CXzProps *p) +{ + UInt64 fileSize; + int t1, t1n, t2, t2r, t3; + { + CLzma2EncProps tp = p->lzma2Props; + if (tp.numTotalThreads <= 0) + tp.numTotalThreads = p->numTotalThreads; + Lzma2EncProps_Normalize(&tp); + t1n = tp.numTotalThreads; + } + + t1 = p->lzma2Props.numTotalThreads; + t2 = p->numBlockThreads_Max; + t3 = p->numTotalThreads; + + if (t2 > MTCODER__THREADS_MAX) + t2 = MTCODER__THREADS_MAX; + + if (t3 <= 0) + { + if (t2 <= 0) + t2 = 1; + t3 = t1n * t2; + } + else if (t2 <= 0) + { + t2 = t3 / t1n; + if (t2 == 0) + { + t1 = 1; + t2 = t3; + } + if (t2 > MTCODER__THREADS_MAX) + t2 = MTCODER__THREADS_MAX; + } + else if (t1 <= 0) + { + t1 = t3 / t2; + if (t1 == 0) + t1 = 1; + } + else + t3 = t1n * t2; + + p->lzma2Props.numTotalThreads = t1; + + t2r = t2; + + fileSize = p->reduceSize; + + if ((p->blockSize < fileSize || fileSize == (UInt64)(Int64)-1)) + p->lzma2Props.lzmaProps.reduceSize = p->blockSize; + + Lzma2EncProps_Normalize(&p->lzma2Props); + + t1 = p->lzma2Props.numTotalThreads; + + { + if (t2 > 1 && fileSize != (UInt64)(Int64)-1) + { + UInt64 numBlocks = fileSize / p->blockSize; + if (numBlocks * p->blockSize != fileSize) + numBlocks++; + if (numBlocks < (unsigned)t2) + { + t2r = (int)numBlocks; + if (t2r == 0) + t2r = 1; + t3 = t1 * t2r; + } + } + } + + p->numBlockThreads_Max = t2; + p->numBlockThreads_Reduced = t2r; + p->numTotalThreads = t3; +} + + +static void XzProps_Normalize(CXzProps *p) +{ + /* we normalize xzProps properties, but we normalize only some of CXzProps::lzma2Props properties. + Lzma2Enc_SetProps() will normalize lzma2Props later. */ + + if (p->blockSize == XZ_PROPS__BLOCK_SIZE__SOLID) + { + p->lzma2Props.lzmaProps.reduceSize = p->reduceSize; + p->numBlockThreads_Reduced = 1; + p->numBlockThreads_Max = 1; + if (p->lzma2Props.numTotalThreads <= 0) + p->lzma2Props.numTotalThreads = p->numTotalThreads; + return; + } + else + { + CLzma2EncProps *lzma2 = &p->lzma2Props; + if (p->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) + { + // xz-auto + p->lzma2Props.lzmaProps.reduceSize = p->reduceSize; + + if (lzma2->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) + { + // if (xz-auto && lzma2-solid) - we use solid for both + p->blockSize = XZ_PROPS__BLOCK_SIZE__SOLID; + p->numBlockThreads_Reduced = 1; + p->numBlockThreads_Max = 1; + if (p->lzma2Props.numTotalThreads <= 0) + p->lzma2Props.numTotalThreads = p->numTotalThreads; + } + else + { + // if (xz-auto && (lzma2-auto || lzma2-fixed_) + // we calculate block size for lzma2 and use that block size for xz, lzma2 uses single-chunk per block + CLzma2EncProps tp = p->lzma2Props; + if (tp.numTotalThreads <= 0) + tp.numTotalThreads = p->numTotalThreads; + + Lzma2EncProps_Normalize(&tp); + + p->blockSize = tp.blockSize; // fixed or solid + p->numBlockThreads_Reduced = tp.numBlockThreads_Reduced; + p->numBlockThreads_Max = tp.numBlockThreads_Max; + if (lzma2->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) + lzma2->blockSize = tp.blockSize; // fixed or solid, LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID + if (lzma2->lzmaProps.reduceSize > tp.blockSize && tp.blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) + lzma2->lzmaProps.reduceSize = tp.blockSize; + lzma2->numBlockThreads_Reduced = 1; + lzma2->numBlockThreads_Max = 1; + return; + } + } + else + { + // xz-fixed + // we can use xz::reduceSize or xz::blockSize as base for lzmaProps::reduceSize + + p->lzma2Props.lzmaProps.reduceSize = p->reduceSize; + { + UInt64 r = p->reduceSize; + if (r > p->blockSize || r == (UInt64)(Int64)-1) + r = p->blockSize; + lzma2->lzmaProps.reduceSize = r; + } + if (lzma2->blockSize == LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO) + lzma2->blockSize = LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID; + else if (lzma2->blockSize > p->blockSize && lzma2->blockSize != LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID) + lzma2->blockSize = p->blockSize; + + XzEncProps_Normalize_Fixed(p); + } + } +} + + +/* ---------- CLzma2WithFilters ---------- */ + +typedef struct +{ + CLzma2EncHandle lzma2; + CSeqInFilter filter; + + #ifdef USE_SUBBLOCK + CSbEncInStream sb; + #endif +} CLzma2WithFilters; + + +static void Lzma2WithFilters_Construct(CLzma2WithFilters *p) +{ + p->lzma2 = NULL; + SeqInFilter_Construct(&p->filter); + + #ifdef USE_SUBBLOCK + SbEncInStream_Construct(&p->sb, alloc); + #endif +} + + +static SRes Lzma2WithFilters_Create(CLzma2WithFilters *p, ISzAllocPtr alloc, ISzAllocPtr bigAlloc) +{ + if (!p->lzma2) + { + p->lzma2 = Lzma2Enc_Create(alloc, bigAlloc); + if (!p->lzma2) + return SZ_ERROR_MEM; + } + return SZ_OK; +} + + +static void Lzma2WithFilters_Free(CLzma2WithFilters *p, ISzAllocPtr alloc) +{ + #ifdef USE_SUBBLOCK + SbEncInStream_Free(&p->sb); + #endif + + SeqInFilter_Free(&p->filter, alloc); + if (p->lzma2) + { + Lzma2Enc_Destroy(p->lzma2); + p->lzma2 = NULL; + } +} + + +typedef struct +{ + UInt64 unpackSize; + UInt64 totalSize; + size_t headerSize; +} CXzEncBlockInfo; + + +static SRes Xz_CompressBlock( + CLzma2WithFilters *lzmaf, + + ISeqOutStream *outStream, + Byte *outBufHeader, + Byte *outBufData, size_t outBufDataLimit, + + ISeqInStream *inStream, + // UInt64 expectedSize, + const Byte *inBuf, // used if (!inStream) + size_t inBufSize, // used if (!inStream), it's block size, props->blockSize is ignored + + const CXzProps *props, + ICompressProgress *progress, + int *inStreamFinished, /* only for inStream version */ + CXzEncBlockInfo *blockSizes, + ISzAllocPtr alloc, + ISzAllocPtr allocBig) +{ + CSeqCheckInStream checkInStream; + CSeqSizeOutStream seqSizeOutStream; + CXzBlock block; + unsigned filterIndex = 0; + CXzFilter *filter = NULL; + const CXzFilterProps *fp = &props->filterProps; + if (fp->id == 0) + fp = NULL; + + *inStreamFinished = False; + + RINOK(Lzma2WithFilters_Create(lzmaf, alloc, allocBig)); + + RINOK(Lzma2Enc_SetProps(lzmaf->lzma2, &props->lzma2Props)); + + XzBlock_ClearFlags(&block); + XzBlock_SetNumFilters(&block, 1 + (fp ? 1 : 0)); + + if (fp) + { + filter = &block.filters[filterIndex++]; + filter->id = fp->id; + filter->propsSize = 0; + + if (fp->id == XZ_ID_Delta) + { + filter->props[0] = (Byte)(fp->delta - 1); + filter->propsSize = 1; + } + else if (fp->ipDefined) + { + Byte *ptr = filter->props; + SetUi32(ptr, fp->ip); + filter->propsSize = 4; + } + } + + { + CXzFilter *f = &block.filters[filterIndex++]; + f->id = XZ_ID_LZMA2; + f->propsSize = 1; + f->props[0] = Lzma2Enc_WriteProperties(lzmaf->lzma2); + } + + seqSizeOutStream.vt.Write = SeqSizeOutStream_Write; + seqSizeOutStream.realStream = outStream; + seqSizeOutStream.outBuf = outBufData; + seqSizeOutStream.outBufLimit = outBufDataLimit; + seqSizeOutStream.processed = 0; + + /* + if (expectedSize != (UInt64)(Int64)-1) + { + block.unpackSize = expectedSize; + if (props->blockSize != (UInt64)(Int64)-1) + if (expectedSize > props->blockSize) + block.unpackSize = props->blockSize; + XzBlock_SetHasUnpackSize(&block); + } + */ + + if (outStream) + { + RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.vt)); + } + + checkInStream.vt.Read = SeqCheckInStream_Read; + SeqCheckInStream_Init(&checkInStream, props->checkId); + + checkInStream.realStream = inStream; + checkInStream.data = inBuf; + checkInStream.limit = props->blockSize; + if (!inStream) + checkInStream.limit = inBufSize; + + if (fp) + { + #ifdef USE_SUBBLOCK + if (fp->id == XZ_ID_Subblock) + { + lzmaf->sb.inStream = &checkInStream.vt; + RINOK(SbEncInStream_Init(&lzmaf->sb)); + } + else + #endif + { + lzmaf->filter.realStream = &checkInStream.vt; + RINOK(SeqInFilter_Init(&lzmaf->filter, filter, alloc)); + } + } + + { + SRes res; + Byte *outBuf = NULL; + size_t outSize = 0; + BoolInt useStream = (fp || inStream); + // useStream = True; + + if (!useStream) + { + XzCheck_Update(&checkInStream.check, inBuf, inBufSize); + checkInStream.processed = inBufSize; + } + + if (!outStream) + { + outBuf = seqSizeOutStream.outBuf; // + (size_t)seqSizeOutStream.processed; + outSize = seqSizeOutStream.outBufLimit; // - (size_t)seqSizeOutStream.processed; + } + + res = Lzma2Enc_Encode2(lzmaf->lzma2, + outBuf ? NULL : &seqSizeOutStream.vt, + outBuf, + outBuf ? &outSize : NULL, + + useStream ? + (fp ? + ( + #ifdef USE_SUBBLOCK + (fp->id == XZ_ID_Subblock) ? &lzmaf->sb.vt: + #endif + &lzmaf->filter.p) : + &checkInStream.vt) : NULL, + + useStream ? NULL : inBuf, + useStream ? 0 : inBufSize, + + progress); + + if (outBuf) + seqSizeOutStream.processed += outSize; + + RINOK(res); + blockSizes->unpackSize = checkInStream.processed; + } + { + Byte buf[4 + 64]; + unsigned padSize = XZ_GET_PAD_SIZE(seqSizeOutStream.processed); + UInt64 packSize = seqSizeOutStream.processed; + + buf[0] = 0; + buf[1] = 0; + buf[2] = 0; + buf[3] = 0; + + SeqCheckInStream_GetDigest(&checkInStream, buf + 4); + RINOK(WriteBytes(&seqSizeOutStream.vt, buf + (4 - padSize), padSize + XzFlags_GetCheckSize((CXzStreamFlags)props->checkId))); + + blockSizes->totalSize = seqSizeOutStream.processed - padSize; + + if (!outStream) + { + seqSizeOutStream.outBuf = outBufHeader; + seqSizeOutStream.outBufLimit = XZ_BLOCK_HEADER_SIZE_MAX; + seqSizeOutStream.processed = 0; + + block.unpackSize = blockSizes->unpackSize; + XzBlock_SetHasUnpackSize(&block); + + block.packSize = packSize; + XzBlock_SetHasPackSize(&block); + + RINOK(XzBlock_WriteHeader(&block, &seqSizeOutStream.vt)); + + blockSizes->headerSize = (size_t)seqSizeOutStream.processed; + blockSizes->totalSize += seqSizeOutStream.processed; + } + } + + if (inStream) + *inStreamFinished = checkInStream.realStreamFinished; + else + { + *inStreamFinished = False; + if (checkInStream.processed != inBufSize) + return SZ_ERROR_FAIL; + } + + return SZ_OK; +} + + + +typedef struct +{ + ICompressProgress vt; + ICompressProgress *progress; + UInt64 inOffset; + UInt64 outOffset; +} CCompressProgress_XzEncOffset; + + +static SRes CompressProgress_XzEncOffset_Progress(const ICompressProgress *pp, UInt64 inSize, UInt64 outSize) +{ + const CCompressProgress_XzEncOffset *p = CONTAINER_FROM_VTBL(pp, CCompressProgress_XzEncOffset, vt); + inSize += p->inOffset; + outSize += p->outOffset; + return ICompressProgress_Progress(p->progress, inSize, outSize); +} + + + + +typedef struct +{ + ISzAllocPtr alloc; + ISzAllocPtr allocBig; + + CXzProps xzProps; + UInt64 expectedDataSize; + + CXzEncIndex xzIndex; + + CLzma2WithFilters lzmaf_Items[MTCODER__THREADS_MAX]; + + size_t outBufSize; /* size of allocated outBufs[i] */ + Byte *outBufs[MTCODER__BLOCKS_MAX]; + + #ifndef _7ZIP_ST + unsigned checkType; + ISeqOutStream *outStream; + BoolInt mtCoder_WasConstructed; + CMtCoder mtCoder; + CXzEncBlockInfo EncBlocks[MTCODER__BLOCKS_MAX]; + #endif + +} CXzEnc; + + +static void XzEnc_Construct(CXzEnc *p) +{ + unsigned i; + + XzEncIndex_Construct(&p->xzIndex); + + for (i = 0; i < MTCODER__THREADS_MAX; i++) + Lzma2WithFilters_Construct(&p->lzmaf_Items[i]); + + #ifndef _7ZIP_ST + p->mtCoder_WasConstructed = False; + { + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + p->outBufs[i] = NULL; + p->outBufSize = 0; + } + #endif +} + + +static void XzEnc_FreeOutBufs(CXzEnc *p) +{ + unsigned i; + for (i = 0; i < MTCODER__BLOCKS_MAX; i++) + if (p->outBufs[i]) + { + ISzAlloc_Free(p->alloc, p->outBufs[i]); + p->outBufs[i] = NULL; + } + p->outBufSize = 0; +} + + +static void XzEnc_Free(CXzEnc *p, ISzAllocPtr alloc) +{ + unsigned i; + + XzEncIndex_Free(&p->xzIndex, alloc); + + for (i = 0; i < MTCODER__THREADS_MAX; i++) + Lzma2WithFilters_Free(&p->lzmaf_Items[i], alloc); + + #ifndef _7ZIP_ST + if (p->mtCoder_WasConstructed) + { + MtCoder_Destruct(&p->mtCoder); + p->mtCoder_WasConstructed = False; + } + XzEnc_FreeOutBufs(p); + #endif +} + + +CXzEncHandle XzEnc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig) +{ + CXzEnc *p = (CXzEnc *)ISzAlloc_Alloc(alloc, sizeof(CXzEnc)); + if (!p) + return NULL; + XzEnc_Construct(p); + XzProps_Init(&p->xzProps); + XzProps_Normalize(&p->xzProps); + p->expectedDataSize = (UInt64)(Int64)-1; + p->alloc = alloc; + p->allocBig = allocBig; + return p; +} + + +void XzEnc_Destroy(CXzEncHandle pp) +{ + CXzEnc *p = (CXzEnc *)pp; + XzEnc_Free(p, p->alloc); + ISzAlloc_Free(p->alloc, p); +} + + +SRes XzEnc_SetProps(CXzEncHandle pp, const CXzProps *props) +{ + CXzEnc *p = (CXzEnc *)pp; + p->xzProps = *props; + XzProps_Normalize(&p->xzProps); + return SZ_OK; +} + + +void XzEnc_SetDataSize(CXzEncHandle pp, UInt64 expectedDataSiize) +{ + CXzEnc *p = (CXzEnc *)pp; + p->expectedDataSize = expectedDataSiize; +} + + + + +#ifndef _7ZIP_ST + +static SRes XzEnc_MtCallback_Code(void *pp, unsigned coderIndex, unsigned outBufIndex, + const Byte *src, size_t srcSize, int finished) +{ + CXzEnc *me = (CXzEnc *)pp; + SRes res; + CMtProgressThunk progressThunk; + + Byte *dest = me->outBufs[outBufIndex]; + + UNUSED_VAR(finished) + + { + CXzEncBlockInfo *bInfo = &me->EncBlocks[outBufIndex]; + bInfo->totalSize = 0; + bInfo->unpackSize = 0; + bInfo->headerSize = 0; + } + + if (!dest) + { + dest = (Byte *)ISzAlloc_Alloc(me->alloc, me->outBufSize); + if (!dest) + return SZ_ERROR_MEM; + me->outBufs[outBufIndex] = dest; + } + + MtProgressThunk_CreateVTable(&progressThunk); + progressThunk.mtProgress = &me->mtCoder.mtProgress; + MtProgressThunk_Init(&progressThunk); + + { + CXzEncBlockInfo blockSizes; + int inStreamFinished; + + res = Xz_CompressBlock( + &me->lzmaf_Items[coderIndex], + + NULL, + dest, + dest + XZ_BLOCK_HEADER_SIZE_MAX, me->outBufSize - XZ_BLOCK_HEADER_SIZE_MAX, + + NULL, + // srcSize, // expectedSize + src, srcSize, + + &me->xzProps, + &progressThunk.vt, + &inStreamFinished, + &blockSizes, + me->alloc, + me->allocBig); + + if (res == SZ_OK) + me->EncBlocks[outBufIndex] = blockSizes; + + return res; + } +} + + +static SRes XzEnc_MtCallback_Write(void *pp, unsigned outBufIndex) +{ + CXzEnc *me = (CXzEnc *)pp; + + const CXzEncBlockInfo *bInfo = &me->EncBlocks[outBufIndex]; + const Byte *data = me->outBufs[outBufIndex]; + + RINOK(WriteBytes(me->outStream, data, bInfo->headerSize)); + + { + UInt64 totalPackFull = bInfo->totalSize + XZ_GET_PAD_SIZE(bInfo->totalSize); + RINOK(WriteBytes(me->outStream, data + XZ_BLOCK_HEADER_SIZE_MAX, (size_t)totalPackFull - bInfo->headerSize)); + } + + return XzEncIndex_AddIndexRecord(&me->xzIndex, bInfo->unpackSize, bInfo->totalSize, me->alloc); +} + +#endif + + + +SRes XzEnc_Encode(CXzEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress) +{ + CXzEnc *p = (CXzEnc *)pp; + + const CXzProps *props = &p->xzProps; + + XzEncIndex_Init(&p->xzIndex); + { + UInt64 numBlocks = 1; + UInt64 blockSize = props->blockSize; + + if (blockSize != XZ_PROPS__BLOCK_SIZE__SOLID + && props->reduceSize != (UInt64)(Int64)-1) + { + numBlocks = props->reduceSize / blockSize; + if (numBlocks * blockSize != props->reduceSize) + numBlocks++; + } + else + blockSize = (UInt64)1 << 62; + + RINOK(XzEncIndex_PreAlloc(&p->xzIndex, numBlocks, blockSize, XZ_GET_ESTIMATED_BLOCK_TOTAL_PACK_SIZE(blockSize), p->alloc)); + } + + RINOK(Xz_WriteHeader((CXzStreamFlags)props->checkId, outStream)); + + + #ifndef _7ZIP_ST + if (props->numBlockThreads_Reduced > 1) + { + IMtCoderCallback2 vt; + + if (!p->mtCoder_WasConstructed) + { + p->mtCoder_WasConstructed = True; + MtCoder_Construct(&p->mtCoder); + } + + vt.Code = XzEnc_MtCallback_Code; + vt.Write = XzEnc_MtCallback_Write; + + p->checkType = props->checkId; + p->xzProps = *props; + + p->outStream = outStream; + + p->mtCoder.allocBig = p->allocBig; + p->mtCoder.progress = progress; + p->mtCoder.inStream = inStream; + p->mtCoder.inData = NULL; + p->mtCoder.inDataSize = 0; + p->mtCoder.mtCallback = &vt; + p->mtCoder.mtCallbackObject = p; + + if ( props->blockSize == XZ_PROPS__BLOCK_SIZE__SOLID + || props->blockSize == XZ_PROPS__BLOCK_SIZE__AUTO) + return SZ_ERROR_FAIL; + + p->mtCoder.blockSize = (size_t)props->blockSize; + if (p->mtCoder.blockSize != props->blockSize) + return SZ_ERROR_PARAM; /* SZ_ERROR_MEM */ + + { + size_t destBlockSize = XZ_BLOCK_HEADER_SIZE_MAX + XZ_GET_MAX_BLOCK_PACK_SIZE(p->mtCoder.blockSize); + if (destBlockSize < p->mtCoder.blockSize) + return SZ_ERROR_PARAM; + if (p->outBufSize != destBlockSize) + XzEnc_FreeOutBufs(p); + p->outBufSize = destBlockSize; + } + + p->mtCoder.numThreadsMax = (unsigned)props->numBlockThreads_Max; + p->mtCoder.expectedDataSize = p->expectedDataSize; + + RINOK(MtCoder_Code(&p->mtCoder)); + } + else + #endif + { + int writeStartSizes; + CCompressProgress_XzEncOffset progress2; + Byte *bufData = NULL; + size_t bufSize = 0; + + progress2.vt.Progress = CompressProgress_XzEncOffset_Progress; + progress2.inOffset = 0; + progress2.outOffset = 0; + progress2.progress = progress; + + writeStartSizes = 0; + + if (props->blockSize != XZ_PROPS__BLOCK_SIZE__SOLID) + { + writeStartSizes = (props->forceWriteSizesInHeader > 0); + + if (writeStartSizes) + { + size_t t2; + size_t t = (size_t)props->blockSize; + if (t != props->blockSize) + return SZ_ERROR_PARAM; + t = XZ_GET_MAX_BLOCK_PACK_SIZE(t); + if (t < props->blockSize) + return SZ_ERROR_PARAM; + t2 = XZ_BLOCK_HEADER_SIZE_MAX + t; + if (!p->outBufs[0] || t2 != p->outBufSize) + { + XzEnc_FreeOutBufs(p); + p->outBufs[0] = (Byte *)ISzAlloc_Alloc(p->alloc, t2); + if (!p->outBufs[0]) + return SZ_ERROR_MEM; + p->outBufSize = t2; + } + bufData = p->outBufs[0] + XZ_BLOCK_HEADER_SIZE_MAX; + bufSize = t; + } + } + + for (;;) + { + CXzEncBlockInfo blockSizes; + int inStreamFinished; + + /* + UInt64 rem = (UInt64)(Int64)-1; + if (props->reduceSize != (UInt64)(Int64)-1 + && props->reduceSize >= progress2.inOffset) + rem = props->reduceSize - progress2.inOffset; + */ + + blockSizes.headerSize = 0; // for GCC + + RINOK(Xz_CompressBlock( + &p->lzmaf_Items[0], + + writeStartSizes ? NULL : outStream, + writeStartSizes ? p->outBufs[0] : NULL, + bufData, bufSize, + + inStream, + // rem, + NULL, 0, + + props, + progress ? &progress2.vt : NULL, + &inStreamFinished, + &blockSizes, + p->alloc, + p->allocBig)); + + { + UInt64 totalPackFull = blockSizes.totalSize + XZ_GET_PAD_SIZE(blockSizes.totalSize); + + if (writeStartSizes) + { + RINOK(WriteBytes(outStream, p->outBufs[0], blockSizes.headerSize)); + RINOK(WriteBytes(outStream, bufData, (size_t)totalPackFull - blockSizes.headerSize)); + } + + RINOK(XzEncIndex_AddIndexRecord(&p->xzIndex, blockSizes.unpackSize, blockSizes.totalSize, p->alloc)); + + progress2.inOffset += blockSizes.unpackSize; + progress2.outOffset += totalPackFull; + } + + if (inStreamFinished) + break; + } + } + + return XzEncIndex_WriteFooter(&p->xzIndex, (CXzStreamFlags)props->checkId, outStream); +} + + +#include "Alloc.h" + +SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, + const CXzProps *props, ICompressProgress *progress) +{ + SRes res; + CXzEncHandle xz = XzEnc_Create(&g_Alloc, &g_BigAlloc); + if (!xz) + return SZ_ERROR_MEM; + res = XzEnc_SetProps(xz, props); + if (res == SZ_OK) + res = XzEnc_Encode(xz, outStream, inStream, progress); + XzEnc_Destroy(xz); + return res; +} + + +SRes Xz_EncodeEmpty(ISeqOutStream *outStream) +{ + SRes res; + CXzEncIndex xzIndex; + XzEncIndex_Construct(&xzIndex); + res = Xz_WriteHeader((CXzStreamFlags)0, outStream); + if (res == SZ_OK) + res = XzEncIndex_WriteFooter(&xzIndex, (CXzStreamFlags)0, outStream); + XzEncIndex_Free(&xzIndex, NULL); // g_Alloc + return res; +} diff --git a/deps/LZMA-SDK/C/XzEnc.h b/deps/LZMA-SDK/C/XzEnc.h index 529ac3fd8..0c29e7e1e 100644 --- a/deps/LZMA-SDK/C/XzEnc.h +++ b/deps/LZMA-SDK/C/XzEnc.h @@ -1,60 +1,60 @@ -/* XzEnc.h -- Xz Encode -2017-06-27 : Igor Pavlov : Public domain */ - -#ifndef __XZ_ENC_H -#define __XZ_ENC_H - -#include "Lzma2Enc.h" - -#include "Xz.h" - -EXTERN_C_BEGIN - - -#define XZ_PROPS__BLOCK_SIZE__AUTO LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO -#define XZ_PROPS__BLOCK_SIZE__SOLID LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID - - -typedef struct -{ - UInt32 id; - UInt32 delta; - UInt32 ip; - int ipDefined; -} CXzFilterProps; - -void XzFilterProps_Init(CXzFilterProps *p); - - -typedef struct -{ - CLzma2EncProps lzma2Props; - CXzFilterProps filterProps; - unsigned checkId; - UInt64 blockSize; - int numBlockThreads_Reduced; - int numBlockThreads_Max; - int numTotalThreads; - int forceWriteSizesInHeader; - UInt64 reduceSize; -} CXzProps; - -void XzProps_Init(CXzProps *p); - - -typedef void * CXzEncHandle; - -CXzEncHandle XzEnc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig); -void XzEnc_Destroy(CXzEncHandle p); -SRes XzEnc_SetProps(CXzEncHandle p, const CXzProps *props); -void XzEnc_SetDataSize(CXzEncHandle p, UInt64 expectedDataSiize); -SRes XzEnc_Encode(CXzEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress); - -SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, - const CXzProps *props, ICompressProgress *progress); - -SRes Xz_EncodeEmpty(ISeqOutStream *outStream); - -EXTERN_C_END - -#endif +/* XzEnc.h -- Xz Encode +2017-06-27 : Igor Pavlov : Public domain */ + +#ifndef __XZ_ENC_H +#define __XZ_ENC_H + +#include "Lzma2Enc.h" + +#include "Xz.h" + +EXTERN_C_BEGIN + + +#define XZ_PROPS__BLOCK_SIZE__AUTO LZMA2_ENC_PROPS__BLOCK_SIZE__AUTO +#define XZ_PROPS__BLOCK_SIZE__SOLID LZMA2_ENC_PROPS__BLOCK_SIZE__SOLID + + +typedef struct +{ + UInt32 id; + UInt32 delta; + UInt32 ip; + int ipDefined; +} CXzFilterProps; + +void XzFilterProps_Init(CXzFilterProps *p); + + +typedef struct +{ + CLzma2EncProps lzma2Props; + CXzFilterProps filterProps; + unsigned checkId; + UInt64 blockSize; + int numBlockThreads_Reduced; + int numBlockThreads_Max; + int numTotalThreads; + int forceWriteSizesInHeader; + UInt64 reduceSize; +} CXzProps; + +void XzProps_Init(CXzProps *p); + + +typedef void * CXzEncHandle; + +CXzEncHandle XzEnc_Create(ISzAllocPtr alloc, ISzAllocPtr allocBig); +void XzEnc_Destroy(CXzEncHandle p); +SRes XzEnc_SetProps(CXzEncHandle p, const CXzProps *props); +void XzEnc_SetDataSize(CXzEncHandle p, UInt64 expectedDataSiize); +SRes XzEnc_Encode(CXzEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress); + +SRes Xz_Encode(ISeqOutStream *outStream, ISeqInStream *inStream, + const CXzProps *props, ICompressProgress *progress); + +SRes Xz_EncodeEmpty(ISeqOutStream *outStream); + +EXTERN_C_END + +#endif diff --git a/deps/LZMA-SDK/C/XzIn.c b/deps/LZMA-SDK/C/XzIn.c index 54d81c4a4..84f868ec6 100644 --- a/deps/LZMA-SDK/C/XzIn.c +++ b/deps/LZMA-SDK/C/XzIn.c @@ -1,324 +1,325 @@ -/* XzIn.c - Xz input -2021-04-01 : Igor Pavlov : Public domain */ - -#include "Precomp.h" - -#include - -#include "7zCrc.h" -#include "CpuArch.h" -#include "Xz.h" - -/* -#define XZ_FOOTER_SIG_CHECK(p) (memcmp((p), XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) == 0) -*/ -#define XZ_FOOTER_SIG_CHECK(p) ((p)[0] == XZ_FOOTER_SIG_0 && (p)[1] == XZ_FOOTER_SIG_1) - - -SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream) -{ - Byte sig[XZ_STREAM_HEADER_SIZE]; - RINOK(SeqInStream_Read2(inStream, sig, XZ_STREAM_HEADER_SIZE, SZ_ERROR_NO_ARCHIVE)); - if (memcmp(sig, XZ_SIG, XZ_SIG_SIZE) != 0) - return SZ_ERROR_NO_ARCHIVE; - return Xz_ParseHeader(p, sig); -} - -#define READ_VARINT_AND_CHECK(buf, pos, size, res) \ - { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \ - if (s == 0) return SZ_ERROR_ARCHIVE; pos += s; } - -SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, BoolInt *isIndex, UInt32 *headerSizeRes) -{ - Byte header[XZ_BLOCK_HEADER_SIZE_MAX]; - unsigned headerSize; - *headerSizeRes = 0; - RINOK(SeqInStream_ReadByte(inStream, &header[0])); - headerSize = (unsigned)header[0]; - if (headerSize == 0) - { - *headerSizeRes = 1; - *isIndex = True; - return SZ_OK; - } - - *isIndex = False; - headerSize = (headerSize << 2) + 4; - *headerSizeRes = headerSize; - RINOK(SeqInStream_Read(inStream, header + 1, headerSize - 1)); - return XzBlock_Parse(p, header); -} - -#define ADD_SIZE_CHECK(size, val) \ - { UInt64 newSize = size + (val); if (newSize < size) return XZ_SIZE_OVERFLOW; size = newSize; } - -UInt64 Xz_GetUnpackSize(const CXzStream *p) -{ - UInt64 size = 0; - size_t i; - for (i = 0; i < p->numBlocks; i++) - ADD_SIZE_CHECK(size, p->blocks[i].unpackSize); - return size; -} - -UInt64 Xz_GetPackSize(const CXzStream *p) -{ - UInt64 size = 0; - size_t i; - for (i = 0; i < p->numBlocks; i++) - ADD_SIZE_CHECK(size, (p->blocks[i].totalSize + 3) & ~(UInt64)3); - return size; -} - -/* -SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream) -{ - return SeqInStream_Read(inStream, p->check, XzFlags_GetCheckSize(f)); -} -*/ - -static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAllocPtr alloc) -{ - size_t numBlocks, pos = 1; - UInt32 crc; - - if (size < 5 || buf[0] != 0) - return SZ_ERROR_ARCHIVE; - - size -= 4; - crc = CrcCalc(buf, size); - if (crc != GetUi32(buf + size)) - return SZ_ERROR_ARCHIVE; - - { - UInt64 numBlocks64; - READ_VARINT_AND_CHECK(buf, pos, size, &numBlocks64); - numBlocks = (size_t)numBlocks64; - if (numBlocks != numBlocks64 || numBlocks * 2 > size) - return SZ_ERROR_ARCHIVE; - } - - Xz_Free(p, alloc); - if (numBlocks != 0) - { - size_t i; - p->numBlocks = numBlocks; - p->blocks = (CXzBlockSizes *)ISzAlloc_Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks); - if (!p->blocks) - return SZ_ERROR_MEM; - for (i = 0; i < numBlocks; i++) - { - CXzBlockSizes *block = &p->blocks[i]; - READ_VARINT_AND_CHECK(buf, pos, size, &block->totalSize); - READ_VARINT_AND_CHECK(buf, pos, size, &block->unpackSize); - if (block->totalSize == 0) - return SZ_ERROR_ARCHIVE; - } - } - while ((pos & 3) != 0) - if (buf[pos++] != 0) - return SZ_ERROR_ARCHIVE; - return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; -} - -static SRes Xz_ReadIndex(CXzStream *p, ILookInStream *stream, UInt64 indexSize, ISzAllocPtr alloc) -{ - SRes res; - size_t size; - Byte *buf; - if (indexSize > ((UInt32)1 << 31)) - return SZ_ERROR_UNSUPPORTED; - size = (size_t)indexSize; - if (size != indexSize) - return SZ_ERROR_UNSUPPORTED; - buf = (Byte *)ISzAlloc_Alloc(alloc, size); - if (!buf) - return SZ_ERROR_MEM; - res = LookInStream_Read2(stream, buf, size, SZ_ERROR_UNSUPPORTED); - if (res == SZ_OK) - res = Xz_ReadIndex2(p, buf, size, alloc); - ISzAlloc_Free(alloc, buf); - return res; -} - -static SRes LookInStream_SeekRead_ForArc(ILookInStream *stream, UInt64 offset, void *buf, size_t size) -{ - RINOK(LookInStream_SeekTo(stream, offset)); - return LookInStream_Read(stream, buf, size); - /* return LookInStream_Read2(stream, buf, size, SZ_ERROR_NO_ARCHIVE); */ -} - -static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOffset, ISzAllocPtr alloc) -{ - UInt64 indexSize; - Byte buf[XZ_STREAM_FOOTER_SIZE]; - UInt64 pos = (UInt64)*startOffset; - - if ((pos & 3) != 0 || pos < XZ_STREAM_FOOTER_SIZE) - return SZ_ERROR_NO_ARCHIVE; - - pos -= XZ_STREAM_FOOTER_SIZE; - RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE)); - - if (!XZ_FOOTER_SIG_CHECK(buf + 10)) - { - UInt32 total = 0; - pos += XZ_STREAM_FOOTER_SIZE; - - for (;;) - { - size_t i; - #define TEMP_BUF_SIZE (1 << 10) - Byte temp[TEMP_BUF_SIZE]; - - i = (pos > TEMP_BUF_SIZE) ? TEMP_BUF_SIZE : (size_t)pos; - pos -= i; - RINOK(LookInStream_SeekRead_ForArc(stream, pos, temp, i)); - total += (UInt32)i; - for (; i != 0; i--) - if (temp[i - 1] != 0) - break; - if (i != 0) - { - if ((i & 3) != 0) - return SZ_ERROR_NO_ARCHIVE; - pos += i; - break; - } - if (pos < XZ_STREAM_FOOTER_SIZE || total > (1 << 16)) - return SZ_ERROR_NO_ARCHIVE; - } - - if (pos < XZ_STREAM_FOOTER_SIZE) - return SZ_ERROR_NO_ARCHIVE; - pos -= XZ_STREAM_FOOTER_SIZE; - RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE)); - if (!XZ_FOOTER_SIG_CHECK(buf + 10)) - return SZ_ERROR_NO_ARCHIVE; - } - - p->flags = (CXzStreamFlags)GetBe16(buf + 8); - - if (!XzFlags_IsSupported(p->flags)) - return SZ_ERROR_UNSUPPORTED; - - { - /* to eliminate GCC 6.3 warning: - dereferencing type-punned pointer will break strict-aliasing rules */ - const Byte *buf_ptr = buf; - if (GetUi32(buf_ptr) != CrcCalc(buf + 4, 6)) - return SZ_ERROR_ARCHIVE; - } - - indexSize = ((UInt64)GetUi32(buf + 4) + 1) << 2; - - if (pos < indexSize) - return SZ_ERROR_ARCHIVE; - - pos -= indexSize; - RINOK(LookInStream_SeekTo(stream, pos)); - RINOK(Xz_ReadIndex(p, stream, indexSize, alloc)); - - { - UInt64 totalSize = Xz_GetPackSize(p); - if (totalSize == XZ_SIZE_OVERFLOW - || totalSize >= ((UInt64)1 << 63) - || pos < totalSize + XZ_STREAM_HEADER_SIZE) - return SZ_ERROR_ARCHIVE; - pos -= (totalSize + XZ_STREAM_HEADER_SIZE); - RINOK(LookInStream_SeekTo(stream, pos)); - *startOffset = (Int64)pos; - } - { - CXzStreamFlags headerFlags; - CSecToRead secToRead; - SecToRead_CreateVTable(&secToRead); - secToRead.realStream = stream; - - RINOK(Xz_ReadHeader(&headerFlags, &secToRead.vt)); - return (p->flags == headerFlags) ? SZ_OK : SZ_ERROR_ARCHIVE; - } -} - - -/* ---------- Xz Streams ---------- */ - -void Xzs_Construct(CXzs *p) -{ - p->num = p->numAllocated = 0; - p->streams = 0; -} - -void Xzs_Free(CXzs *p, ISzAllocPtr alloc) -{ - size_t i; - for (i = 0; i < p->num; i++) - Xz_Free(&p->streams[i], alloc); - ISzAlloc_Free(alloc, p->streams); - p->num = p->numAllocated = 0; - p->streams = 0; -} - -UInt64 Xzs_GetNumBlocks(const CXzs *p) -{ - UInt64 num = 0; - size_t i; - for (i = 0; i < p->num; i++) - num += p->streams[i].numBlocks; - return num; -} - -UInt64 Xzs_GetUnpackSize(const CXzs *p) -{ - UInt64 size = 0; - size_t i; - for (i = 0; i < p->num; i++) - ADD_SIZE_CHECK(size, Xz_GetUnpackSize(&p->streams[i])); - return size; -} - -/* -UInt64 Xzs_GetPackSize(const CXzs *p) -{ - UInt64 size = 0; - size_t i; - for (i = 0; i < p->num; i++) - ADD_SIZE_CHECK(size, Xz_GetTotalSize(&p->streams[i])); - return size; -} -*/ - -SRes Xzs_ReadBackward(CXzs *p, ILookInStream *stream, Int64 *startOffset, ICompressProgress *progress, ISzAllocPtr alloc) -{ - Int64 endOffset = 0; - RINOK(ILookInStream_Seek(stream, &endOffset, SZ_SEEK_END)); - *startOffset = endOffset; - for (;;) - { - CXzStream st; - SRes res; - Xz_Construct(&st); - res = Xz_ReadBackward(&st, stream, startOffset, alloc); - st.startOffset = (UInt64)*startOffset; - RINOK(res); - if (p->num == p->numAllocated) - { - const size_t newNum = p->num + p->num / 4 + 1; - void *data = ISzAlloc_Alloc(alloc, newNum * sizeof(CXzStream)); - if (!data) - return SZ_ERROR_MEM; - p->numAllocated = newNum; - if (p->num != 0) - memcpy(data, p->streams, p->num * sizeof(CXzStream)); - ISzAlloc_Free(alloc, p->streams); - p->streams = (CXzStream *)data; - } - p->streams[p->num++] = st; - if (*startOffset == 0) - break; - RINOK(LookInStream_SeekTo(stream, (UInt64)*startOffset)); - if (progress && ICompressProgress_Progress(progress, (UInt64)(endOffset - *startOffset), (UInt64)(Int64)-1) != SZ_OK) - return SZ_ERROR_PROGRESS; - } - return SZ_OK; -} +/* XzIn.c - Xz input +2021-09-04 : Igor Pavlov : Public domain */ + +#include "Precomp.h" + +#include + +#include "7zCrc.h" +#include "CpuArch.h" +#include "Xz.h" + +/* +#define XZ_FOOTER_SIG_CHECK(p) (memcmp((p), XZ_FOOTER_SIG, XZ_FOOTER_SIG_SIZE) == 0) +*/ +#define XZ_FOOTER_SIG_CHECK(p) ((p)[0] == XZ_FOOTER_SIG_0 && (p)[1] == XZ_FOOTER_SIG_1) + + +SRes Xz_ReadHeader(CXzStreamFlags *p, ISeqInStream *inStream) +{ + Byte sig[XZ_STREAM_HEADER_SIZE]; + RINOK(SeqInStream_Read2(inStream, sig, XZ_STREAM_HEADER_SIZE, SZ_ERROR_NO_ARCHIVE)); + if (memcmp(sig, XZ_SIG, XZ_SIG_SIZE) != 0) + return SZ_ERROR_NO_ARCHIVE; + return Xz_ParseHeader(p, sig); +} + +#define READ_VARINT_AND_CHECK(buf, pos, size, res) \ + { unsigned s = Xz_ReadVarInt(buf + pos, size - pos, res); \ + if (s == 0) return SZ_ERROR_ARCHIVE; \ + pos += s; } + +SRes XzBlock_ReadHeader(CXzBlock *p, ISeqInStream *inStream, BoolInt *isIndex, UInt32 *headerSizeRes) +{ + Byte header[XZ_BLOCK_HEADER_SIZE_MAX]; + unsigned headerSize; + *headerSizeRes = 0; + RINOK(SeqInStream_ReadByte(inStream, &header[0])); + headerSize = (unsigned)header[0]; + if (headerSize == 0) + { + *headerSizeRes = 1; + *isIndex = True; + return SZ_OK; + } + + *isIndex = False; + headerSize = (headerSize << 2) + 4; + *headerSizeRes = headerSize; + RINOK(SeqInStream_Read(inStream, header + 1, headerSize - 1)); + return XzBlock_Parse(p, header); +} + +#define ADD_SIZE_CHECK(size, val) \ + { UInt64 newSize = size + (val); if (newSize < size) return XZ_SIZE_OVERFLOW; size = newSize; } + +UInt64 Xz_GetUnpackSize(const CXzStream *p) +{ + UInt64 size = 0; + size_t i; + for (i = 0; i < p->numBlocks; i++) + ADD_SIZE_CHECK(size, p->blocks[i].unpackSize); + return size; +} + +UInt64 Xz_GetPackSize(const CXzStream *p) +{ + UInt64 size = 0; + size_t i; + for (i = 0; i < p->numBlocks; i++) + ADD_SIZE_CHECK(size, (p->blocks[i].totalSize + 3) & ~(UInt64)3); + return size; +} + +/* +SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream) +{ + return SeqInStream_Read(inStream, p->check, XzFlags_GetCheckSize(f)); +} +*/ + +static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAllocPtr alloc) +{ + size_t numBlocks, pos = 1; + UInt32 crc; + + if (size < 5 || buf[0] != 0) + return SZ_ERROR_ARCHIVE; + + size -= 4; + crc = CrcCalc(buf, size); + if (crc != GetUi32(buf + size)) + return SZ_ERROR_ARCHIVE; + + { + UInt64 numBlocks64; + READ_VARINT_AND_CHECK(buf, pos, size, &numBlocks64); + numBlocks = (size_t)numBlocks64; + if (numBlocks != numBlocks64 || numBlocks * 2 > size) + return SZ_ERROR_ARCHIVE; + } + + Xz_Free(p, alloc); + if (numBlocks != 0) + { + size_t i; + p->numBlocks = numBlocks; + p->blocks = (CXzBlockSizes *)ISzAlloc_Alloc(alloc, sizeof(CXzBlockSizes) * numBlocks); + if (!p->blocks) + return SZ_ERROR_MEM; + for (i = 0; i < numBlocks; i++) + { + CXzBlockSizes *block = &p->blocks[i]; + READ_VARINT_AND_CHECK(buf, pos, size, &block->totalSize); + READ_VARINT_AND_CHECK(buf, pos, size, &block->unpackSize); + if (block->totalSize == 0) + return SZ_ERROR_ARCHIVE; + } + } + while ((pos & 3) != 0) + if (buf[pos++] != 0) + return SZ_ERROR_ARCHIVE; + return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; +} + +static SRes Xz_ReadIndex(CXzStream *p, ILookInStream *stream, UInt64 indexSize, ISzAllocPtr alloc) +{ + SRes res; + size_t size; + Byte *buf; + if (indexSize > ((UInt32)1 << 31)) + return SZ_ERROR_UNSUPPORTED; + size = (size_t)indexSize; + if (size != indexSize) + return SZ_ERROR_UNSUPPORTED; + buf = (Byte *)ISzAlloc_Alloc(alloc, size); + if (!buf) + return SZ_ERROR_MEM; + res = LookInStream_Read2(stream, buf, size, SZ_ERROR_UNSUPPORTED); + if (res == SZ_OK) + res = Xz_ReadIndex2(p, buf, size, alloc); + ISzAlloc_Free(alloc, buf); + return res; +} + +static SRes LookInStream_SeekRead_ForArc(ILookInStream *stream, UInt64 offset, void *buf, size_t size) +{ + RINOK(LookInStream_SeekTo(stream, offset)); + return LookInStream_Read(stream, buf, size); + /* return LookInStream_Read2(stream, buf, size, SZ_ERROR_NO_ARCHIVE); */ +} + +static SRes Xz_ReadBackward(CXzStream *p, ILookInStream *stream, Int64 *startOffset, ISzAllocPtr alloc) +{ + UInt64 indexSize; + Byte buf[XZ_STREAM_FOOTER_SIZE]; + UInt64 pos = (UInt64)*startOffset; + + if ((pos & 3) != 0 || pos < XZ_STREAM_FOOTER_SIZE) + return SZ_ERROR_NO_ARCHIVE; + + pos -= XZ_STREAM_FOOTER_SIZE; + RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE)); + + if (!XZ_FOOTER_SIG_CHECK(buf + 10)) + { + UInt32 total = 0; + pos += XZ_STREAM_FOOTER_SIZE; + + for (;;) + { + size_t i; + #define TEMP_BUF_SIZE (1 << 10) + Byte temp[TEMP_BUF_SIZE]; + + i = (pos > TEMP_BUF_SIZE) ? TEMP_BUF_SIZE : (size_t)pos; + pos -= i; + RINOK(LookInStream_SeekRead_ForArc(stream, pos, temp, i)); + total += (UInt32)i; + for (; i != 0; i--) + if (temp[i - 1] != 0) + break; + if (i != 0) + { + if ((i & 3) != 0) + return SZ_ERROR_NO_ARCHIVE; + pos += i; + break; + } + if (pos < XZ_STREAM_FOOTER_SIZE || total > (1 << 16)) + return SZ_ERROR_NO_ARCHIVE; + } + + if (pos < XZ_STREAM_FOOTER_SIZE) + return SZ_ERROR_NO_ARCHIVE; + pos -= XZ_STREAM_FOOTER_SIZE; + RINOK(LookInStream_SeekRead_ForArc(stream, pos, buf, XZ_STREAM_FOOTER_SIZE)); + if (!XZ_FOOTER_SIG_CHECK(buf + 10)) + return SZ_ERROR_NO_ARCHIVE; + } + + p->flags = (CXzStreamFlags)GetBe16(buf + 8); + + if (!XzFlags_IsSupported(p->flags)) + return SZ_ERROR_UNSUPPORTED; + + { + /* to eliminate GCC 6.3 warning: + dereferencing type-punned pointer will break strict-aliasing rules */ + const Byte *buf_ptr = buf; + if (GetUi32(buf_ptr) != CrcCalc(buf + 4, 6)) + return SZ_ERROR_ARCHIVE; + } + + indexSize = ((UInt64)GetUi32(buf + 4) + 1) << 2; + + if (pos < indexSize) + return SZ_ERROR_ARCHIVE; + + pos -= indexSize; + RINOK(LookInStream_SeekTo(stream, pos)); + RINOK(Xz_ReadIndex(p, stream, indexSize, alloc)); + + { + UInt64 totalSize = Xz_GetPackSize(p); + if (totalSize == XZ_SIZE_OVERFLOW + || totalSize >= ((UInt64)1 << 63) + || pos < totalSize + XZ_STREAM_HEADER_SIZE) + return SZ_ERROR_ARCHIVE; + pos -= (totalSize + XZ_STREAM_HEADER_SIZE); + RINOK(LookInStream_SeekTo(stream, pos)); + *startOffset = (Int64)pos; + } + { + CXzStreamFlags headerFlags; + CSecToRead secToRead; + SecToRead_CreateVTable(&secToRead); + secToRead.realStream = stream; + + RINOK(Xz_ReadHeader(&headerFlags, &secToRead.vt)); + return (p->flags == headerFlags) ? SZ_OK : SZ_ERROR_ARCHIVE; + } +} + + +/* ---------- Xz Streams ---------- */ + +void Xzs_Construct(CXzs *p) +{ + p->num = p->numAllocated = 0; + p->streams = 0; +} + +void Xzs_Free(CXzs *p, ISzAllocPtr alloc) +{ + size_t i; + for (i = 0; i < p->num; i++) + Xz_Free(&p->streams[i], alloc); + ISzAlloc_Free(alloc, p->streams); + p->num = p->numAllocated = 0; + p->streams = 0; +} + +UInt64 Xzs_GetNumBlocks(const CXzs *p) +{ + UInt64 num = 0; + size_t i; + for (i = 0; i < p->num; i++) + num += p->streams[i].numBlocks; + return num; +} + +UInt64 Xzs_GetUnpackSize(const CXzs *p) +{ + UInt64 size = 0; + size_t i; + for (i = 0; i < p->num; i++) + ADD_SIZE_CHECK(size, Xz_GetUnpackSize(&p->streams[i])); + return size; +} + +/* +UInt64 Xzs_GetPackSize(const CXzs *p) +{ + UInt64 size = 0; + size_t i; + for (i = 0; i < p->num; i++) + ADD_SIZE_CHECK(size, Xz_GetTotalSize(&p->streams[i])); + return size; +} +*/ + +SRes Xzs_ReadBackward(CXzs *p, ILookInStream *stream, Int64 *startOffset, ICompressProgress *progress, ISzAllocPtr alloc) +{ + Int64 endOffset = 0; + RINOK(ILookInStream_Seek(stream, &endOffset, SZ_SEEK_END)); + *startOffset = endOffset; + for (;;) + { + CXzStream st; + SRes res; + Xz_Construct(&st); + res = Xz_ReadBackward(&st, stream, startOffset, alloc); + st.startOffset = (UInt64)*startOffset; + RINOK(res); + if (p->num == p->numAllocated) + { + const size_t newNum = p->num + p->num / 4 + 1; + void *data = ISzAlloc_Alloc(alloc, newNum * sizeof(CXzStream)); + if (!data) + return SZ_ERROR_MEM; + p->numAllocated = newNum; + if (p->num != 0) + memcpy(data, p->streams, p->num * sizeof(CXzStream)); + ISzAlloc_Free(alloc, p->streams); + p->streams = (CXzStream *)data; + } + p->streams[p->num++] = st; + if (*startOffset == 0) + break; + RINOK(LookInStream_SeekTo(stream, (UInt64)*startOffset)); + if (progress && ICompressProgress_Progress(progress, (UInt64)(endOffset - *startOffset), (UInt64)(Int64)-1) != SZ_OK) + return SZ_ERROR_PROGRESS; + } + return SZ_OK; +} diff --git a/deps/LZMA-SDK/C/var_clang.mak b/deps/LZMA-SDK/C/var_clang.mak index ee265698e..a6df26e77 100644 --- a/deps/LZMA-SDK/C/var_clang.mak +++ b/deps/LZMA-SDK/C/var_clang.mak @@ -1,11 +1,11 @@ -PLATFORM= -O=b/c -IS_X64= -IS_X86= -IS_ARM64= -CROSS_COMPILE= -MY_ARCH= -USE_ASM= -CC=$(CROSS_COMPILE)clang -CXX=$(CROSS_COMPILE)clang++ -USE_CLANG=1 +PLATFORM= +O=b/c +IS_X64= +IS_X86= +IS_ARM64= +CROSS_COMPILE= +MY_ARCH= +USE_ASM= +CC=$(CROSS_COMPILE)clang +CXX=$(CROSS_COMPILE)clang++ +USE_CLANG=1 diff --git a/deps/LZMA-SDK/C/var_clang_arm64.mak b/deps/LZMA-SDK/C/var_clang_arm64.mak index 1e82d2eb6..4b3540969 100644 --- a/deps/LZMA-SDK/C/var_clang_arm64.mak +++ b/deps/LZMA-SDK/C/var_clang_arm64.mak @@ -1,11 +1,11 @@ -PLATFORM=arm64 -O=b/c_$(PLATFORM) -IS_X64= -IS_X86= -IS_ARM64=1 -CROSS_COMPILE= -MY_ARCH= -USE_ASM=1 -CC=$(CROSS_COMPILE)clang -CXX=$(CROSS_COMPILE)clang++ -USE_CLANG=1 +PLATFORM=arm64 +O=b/c_$(PLATFORM) +IS_X64= +IS_X86= +IS_ARM64=1 +CROSS_COMPILE= +MY_ARCH= +USE_ASM=1 +CC=$(CROSS_COMPILE)clang +CXX=$(CROSS_COMPILE)clang++ +USE_CLANG=1 diff --git a/deps/LZMA-SDK/C/var_clang_x64.mak b/deps/LZMA-SDK/C/var_clang_x64.mak index d9013e1cd..34e1b49c5 100644 --- a/deps/LZMA-SDK/C/var_clang_x64.mak +++ b/deps/LZMA-SDK/C/var_clang_x64.mak @@ -1,12 +1,11 @@ -PLATFORM=x64 -O=b/c_$(PLATFORM) -IS_X64=1 -IS_X86= -IS_ARM64= -CROSS_COMPILE= -MY_ARCH= -USE_ASM=1 -CC=$(CROSS_COMPILE)clang -CXX=$(CROSS_COMPILE)clang++ -USE_CLANG=1 - +PLATFORM=x64 +O=b/c_$(PLATFORM) +IS_X64=1 +IS_X86= +IS_ARM64= +CROSS_COMPILE= +MY_ARCH= +USE_ASM=1 +CC=$(CROSS_COMPILE)clang +CXX=$(CROSS_COMPILE)clang++ +USE_CLANG=1 diff --git a/deps/LZMA-SDK/C/var_clang_x86.mak b/deps/LZMA-SDK/C/var_clang_x86.mak index 9ab916a70..bd2317c29 100644 --- a/deps/LZMA-SDK/C/var_clang_x86.mak +++ b/deps/LZMA-SDK/C/var_clang_x86.mak @@ -1,12 +1,11 @@ -PLATFORM=x86 -O=b/c_$(PLATFORM) -IS_X64= -IS_X86=1 -IS_ARM64= -CROSS_COMPILE= -MY_ARCH=-m32 -USE_ASM=1 -CC=$(CROSS_COMPILE)clang -CXX=$(CROSS_COMPILE)clang++ -USE_CLANG=1 - +PLATFORM=x86 +O=b/c_$(PLATFORM) +IS_X64= +IS_X86=1 +IS_ARM64= +CROSS_COMPILE= +MY_ARCH=-m32 +USE_ASM=1 +CC=$(CROSS_COMPILE)clang +CXX=$(CROSS_COMPILE)clang++ +USE_CLANG=1 diff --git a/deps/LZMA-SDK/C/var_gcc.mak b/deps/LZMA-SDK/C/var_gcc.mak index 803c8de9d..664491cf2 100644 --- a/deps/LZMA-SDK/C/var_gcc.mak +++ b/deps/LZMA-SDK/C/var_gcc.mak @@ -1,12 +1,12 @@ -PLATFORM= -O=b/g -IS_X64= -IS_X86= -IS_ARM64= -CROSS_COMPILE= -MY_ARCH= -USE_ASM= -CC=$(CROSS_COMPILE)gcc -CXX=$(CROSS_COMPILE)g++ - -# -march=armv8-a+crc+crypto +PLATFORM= +O=b/g +IS_X64= +IS_X86= +IS_ARM64= +CROSS_COMPILE= +MY_ARCH= +USE_ASM= +CC=$(CROSS_COMPILE)gcc +CXX=$(CROSS_COMPILE)g++ + +# -march=armv8-a+crc+crypto diff --git a/deps/LZMA-SDK/C/var_gcc_arm64.mak b/deps/LZMA-SDK/C/var_gcc_arm64.mak index 562cfaa6d..4bbb687db 100644 --- a/deps/LZMA-SDK/C/var_gcc_arm64.mak +++ b/deps/LZMA-SDK/C/var_gcc_arm64.mak @@ -1,12 +1,12 @@ -PLATFORM=arm64 -O=b/g_$(PLATFORM) -IS_X64= -IS_X86= -IS_ARM64=1 -CROSS_COMPILE= -MY_ARCH=-mtune=cortex-a53 -USE_ASM=1 -CC=$(CROSS_COMPILE)gcc -CXX=$(CROSS_COMPILE)g++ - -# -march=armv8-a+crc+crypto +PLATFORM=arm64 +O=b/g_$(PLATFORM) +IS_X64= +IS_X86= +IS_ARM64=1 +CROSS_COMPILE= +MY_ARCH=-mtune=cortex-a53 +USE_ASM=1 +CC=$(CROSS_COMPILE)gcc +CXX=$(CROSS_COMPILE)g++ + +# -march=armv8-a+crc+crypto diff --git a/deps/LZMA-SDK/C/var_gcc_x64.mak b/deps/LZMA-SDK/C/var_gcc_x64.mak index 1b965b21b..1acf604f5 100644 --- a/deps/LZMA-SDK/C/var_gcc_x64.mak +++ b/deps/LZMA-SDK/C/var_gcc_x64.mak @@ -1,10 +1,10 @@ -PLATFORM=x64 -O=b/g_$(PLATFORM) -IS_X64=1 -IS_X86= -IS_ARM64= -CROSS_COMPILE= -MY_ARCH= -USE_ASM=1 -CC=$(CROSS_COMPILE)gcc -CXX=$(CROSS_COMPILE)g++ +PLATFORM=x64 +O=b/g_$(PLATFORM) +IS_X64=1 +IS_X86= +IS_ARM64= +CROSS_COMPILE= +MY_ARCH= +USE_ASM=1 +CC=$(CROSS_COMPILE)gcc +CXX=$(CROSS_COMPILE)g++ diff --git a/deps/LZMA-SDK/C/var_gcc_x86.mak b/deps/LZMA-SDK/C/var_gcc_x86.mak index 9eada64e1..f0718ec71 100644 --- a/deps/LZMA-SDK/C/var_gcc_x86.mak +++ b/deps/LZMA-SDK/C/var_gcc_x86.mak @@ -1,11 +1,10 @@ -PLATFORM=x86 -O=b/g_$(PLATFORM) -IS_X64= -IS_X86=1 -IS_ARM64= -CROSS_COMPILE= -MY_ARCH=-m32 -USE_ASM=1 -CC=$(CROSS_COMPILE)gcc -CXX=$(CROSS_COMPILE)g++ - +PLATFORM=x86 +O=b/g_$(PLATFORM) +IS_X64= +IS_X86=1 +IS_ARM64= +CROSS_COMPILE= +MY_ARCH=-m32 +USE_ASM=1 +CC=$(CROSS_COMPILE)gcc +CXX=$(CROSS_COMPILE)g++ diff --git a/deps/LZMA-SDK/C/var_mac_arm64.mak b/deps/LZMA-SDK/C/var_mac_arm64.mak index 0ba414230..adf5fa1d7 100644 --- a/deps/LZMA-SDK/C/var_mac_arm64.mak +++ b/deps/LZMA-SDK/C/var_mac_arm64.mak @@ -1,11 +1,11 @@ -PLATFORM=arm64 -O=b/m_$(PLATFORM) -IS_X64= -IS_X86= -IS_ARM64=1 -CROSS_COMPILE= -MY_ARCH=-arch arm64 -USE_ASM=1 -CC=$(CROSS_COMPILE)clang -CXX=$(CROSS_COMPILE)clang++ -USE_CLANG=1 +PLATFORM=arm64 +O=b/m_$(PLATFORM) +IS_X64= +IS_X86= +IS_ARM64=1 +CROSS_COMPILE= +MY_ARCH=-arch arm64 +USE_ASM=1 +CC=$(CROSS_COMPILE)clang +CXX=$(CROSS_COMPILE)clang++ +USE_CLANG=1 diff --git a/deps/LZMA-SDK/C/var_mac_x64.mak b/deps/LZMA-SDK/C/var_mac_x64.mak index 92b15c8b7..13d7aa7fe 100644 --- a/deps/LZMA-SDK/C/var_mac_x64.mak +++ b/deps/LZMA-SDK/C/var_mac_x64.mak @@ -1,11 +1,11 @@ -PLATFORM=x64 -O=b/m_$(PLATFORM) -IS_X64=1 -IS_X86= -IS_ARM64= -CROSS_COMPILE= -MY_ARCH=-arch x86_64 -USE_ASM= -CC=$(CROSS_COMPILE)clang -CXX=$(CROSS_COMPILE)clang++ -USE_CLANG=1 +PLATFORM=x64 +O=b/m_$(PLATFORM) +IS_X64=1 +IS_X86= +IS_ARM64= +CROSS_COMPILE= +MY_ARCH=-arch x86_64 +USE_ASM= +CC=$(CROSS_COMPILE)clang +CXX=$(CROSS_COMPILE)clang++ +USE_CLANG=1 diff --git a/deps/LZMA-SDK/C/warn_clang.mak b/deps/LZMA-SDK/C/warn_clang.mak index a299fbc4d..ed4f908f6 100644 --- a/deps/LZMA-SDK/C/warn_clang.mak +++ b/deps/LZMA-SDK/C/warn_clang.mak @@ -1,37 +1,37 @@ -CFLAGS_WARN_CLANG_3_8_UNIQ = \ - -Wno-reserved-id-macro \ - -Wno-old-style-cast \ - -Wno-c++11-long-long \ - -Wno-unused-macros \ - -CFLAGS_WARN_CLANG_3_8 = \ - $(CFLAGS_WARN_CLANG_3_8_UNIQ) \ - -Weverything \ - -Wno-extra-semi \ - -Wno-sign-conversion \ - -Wno-language-extension-token \ - -Wno-global-constructors \ - -Wno-non-virtual-dtor \ - -Wno-switch-enum \ - -Wno-covered-switch-default \ - -Wno-cast-qual \ - -Wno-padded \ - -Wno-exit-time-destructors \ - -Wno-weak-vtables \ - -CFLAGS_WARN_CLANG_12= $(CFLAGS_WARN_CLANG_3_8) \ - -Wno-extra-semi-stmt \ - -Wno-zero-as-null-pointer-constant \ - -Wno-deprecated-dynamic-exception-spec \ - -Wno-c++98-compat-pedantic \ - -Wno-atomic-implicit-seq-cst \ - -Wconversion \ - -Wno-sign-conversion \ - -CFLAGS_WARN_1 = \ - -Wno-deprecated-copy-dtor \ - - - - -CFLAGS_WARN = $(CFLAGS_WARN_CLANG_12) $(CFLAGS_WARN_1) +CFLAGS_WARN_CLANG_3_8_UNIQ = \ + -Wno-reserved-id-macro \ + -Wno-old-style-cast \ + -Wno-c++11-long-long \ + -Wno-unused-macros \ + +CFLAGS_WARN_CLANG_3_8 = \ + $(CFLAGS_WARN_CLANG_3_8_UNIQ) \ + -Weverything \ + -Wno-extra-semi \ + -Wno-sign-conversion \ + -Wno-language-extension-token \ + -Wno-global-constructors \ + -Wno-non-virtual-dtor \ + -Wno-switch-enum \ + -Wno-covered-switch-default \ + -Wno-cast-qual \ + -Wno-padded \ + -Wno-exit-time-destructors \ + -Wno-weak-vtables \ + +CFLAGS_WARN_CLANG_12= $(CFLAGS_WARN_CLANG_3_8) \ + -Wno-extra-semi-stmt \ + -Wno-zero-as-null-pointer-constant \ + -Wno-deprecated-dynamic-exception-spec \ + -Wno-c++98-compat-pedantic \ + -Wno-atomic-implicit-seq-cst \ + -Wconversion \ + -Wno-sign-conversion \ + +CFLAGS_WARN_1 = \ + -Wno-deprecated-copy-dtor \ + + + + +CFLAGS_WARN = $(CFLAGS_WARN_CLANG_12) $(CFLAGS_WARN_1) diff --git a/deps/LZMA-SDK/C/warn_clang_mac.mak b/deps/LZMA-SDK/C/warn_clang_mac.mak index cfbbda073..41044a2ce 100644 --- a/deps/LZMA-SDK/C/warn_clang_mac.mak +++ b/deps/LZMA-SDK/C/warn_clang_mac.mak @@ -1,37 +1,37 @@ -CFLAGS_WARN_CLANG_3_8_UNIQ = \ - -Wno-reserved-id-macro \ - -Wno-old-style-cast \ - -Wno-c++11-long-long \ - -Wno-unused-macros \ - -CFLAGS_WARN_CLANG_3_8 = \ - $(CFLAGS_WARN_CLANG_3_8_UNIQ) \ - -Weverything \ - -Wno-extra-semi \ - -Wno-sign-conversion \ - -Wno-language-extension-token \ - -Wno-global-constructors \ - -Wno-non-virtual-dtor \ - -Wno-switch-enum \ - -Wno-covered-switch-default \ - -Wno-cast-qual \ - -Wno-padded \ - -Wno-exit-time-destructors \ - -Wno-weak-vtables \ - -CFLAGS_WARN_CLANG_12= $(CFLAGS_WARN_CLANG_3_8) \ - -Wno-extra-semi-stmt \ - -Wno-zero-as-null-pointer-constant \ - -Wno-deprecated-dynamic-exception-spec \ - -Wno-c++98-compat-pedantic \ - -Wno-atomic-implicit-seq-cst \ - -Wconversion \ - -Wno-sign-conversion \ - -CFLAGS_WARN_MAC = \ - -Wno-poison-system-directories \ - -Wno-c++11-long-long \ - -Wno-atomic-implicit-seq-cst \ - - -CFLAGS_WARN = $(CFLAGS_WARN_CLANG_12) $(CFLAGS_WARN_MAC) +CFLAGS_WARN_CLANG_3_8_UNIQ = \ + -Wno-reserved-id-macro \ + -Wno-old-style-cast \ + -Wno-c++11-long-long \ + -Wno-unused-macros \ + +CFLAGS_WARN_CLANG_3_8 = \ + $(CFLAGS_WARN_CLANG_3_8_UNIQ) \ + -Weverything \ + -Wno-extra-semi \ + -Wno-sign-conversion \ + -Wno-language-extension-token \ + -Wno-global-constructors \ + -Wno-non-virtual-dtor \ + -Wno-switch-enum \ + -Wno-covered-switch-default \ + -Wno-cast-qual \ + -Wno-padded \ + -Wno-exit-time-destructors \ + -Wno-weak-vtables \ + +CFLAGS_WARN_CLANG_12= $(CFLAGS_WARN_CLANG_3_8) \ + -Wno-extra-semi-stmt \ + -Wno-zero-as-null-pointer-constant \ + -Wno-deprecated-dynamic-exception-spec \ + -Wno-c++98-compat-pedantic \ + -Wno-atomic-implicit-seq-cst \ + -Wconversion \ + -Wno-sign-conversion \ + +CFLAGS_WARN_MAC = \ + -Wno-poison-system-directories \ + -Wno-c++11-long-long \ + -Wno-atomic-implicit-seq-cst \ + + +CFLAGS_WARN = $(CFLAGS_WARN_CLANG_12) $(CFLAGS_WARN_MAC) diff --git a/deps/LZMA-SDK/C/warn_gcc.mak b/deps/LZMA-SDK/C/warn_gcc.mak index 3ae796480..7aab7a449 100644 --- a/deps/LZMA-SDK/C/warn_gcc.mak +++ b/deps/LZMA-SDK/C/warn_gcc.mak @@ -1,53 +1,51 @@ -CFLAGS_WARN_GCC_4_5 = \ - -CFLAGS_WARN_GCC_6 = \ - -Waddress \ - -Waggressive-loop-optimizations \ - -Wattributes \ - -Wbool-compare \ - -Wcast-align \ - -Wcomment \ - -Wdiv-by-zero \ - -Wduplicated-cond \ - -Wformat-contains-nul \ - -Winit-self \ - -Wint-to-pointer-cast \ - -Wunused \ - -Wunused-macros \ - -# -Wno-strict-aliasing - -CFLAGS_WARN_GCC_9 = \ - -Waddress \ - -Waddress-of-packed-member \ - -Waggressive-loop-optimizations \ - -Wattributes \ - -Wbool-compare \ - -Wbool-operation \ - -Wcast-align \ - -Wcast-align=strict \ - -Wcomment \ - -Wdangling-else \ - -Wdiv-by-zero \ - -Wduplicated-branches \ - -Wduplicated-cond \ - -Wformat-contains-nul \ - -Wimplicit-fallthrough=5 \ - -Winit-self \ - -Wint-in-bool-context \ - -Wint-to-pointer-cast \ - -Wunused \ - -Wunused-macros \ - -Wconversion \ - -# -Wno-sign-conversion \ - -CFLAGS_WARN_GCC_PPMD_UNALIGNED = \ - -Wno-strict-aliasing \ - - -CFLAGS_WARN = $(CFLAGS_WARN_GCC_9) \ - -# $(CFLAGS_WARN_GCC_PPMD_UNALIGNED) - - \ No newline at end of file +CFLAGS_WARN_GCC_4_5 = \ + +CFLAGS_WARN_GCC_6 = \ + -Waddress \ + -Waggressive-loop-optimizations \ + -Wattributes \ + -Wbool-compare \ + -Wcast-align \ + -Wcomment \ + -Wdiv-by-zero \ + -Wduplicated-cond \ + -Wformat-contains-nul \ + -Winit-self \ + -Wint-to-pointer-cast \ + -Wunused \ + -Wunused-macros \ + +# -Wno-strict-aliasing + +CFLAGS_WARN_GCC_9 = \ + -Waddress \ + -Waddress-of-packed-member \ + -Waggressive-loop-optimizations \ + -Wattributes \ + -Wbool-compare \ + -Wbool-operation \ + -Wcast-align \ + -Wcast-align=strict \ + -Wcomment \ + -Wdangling-else \ + -Wdiv-by-zero \ + -Wduplicated-branches \ + -Wduplicated-cond \ + -Wformat-contains-nul \ + -Wimplicit-fallthrough=5 \ + -Winit-self \ + -Wint-in-bool-context \ + -Wint-to-pointer-cast \ + -Wunused \ + -Wunused-macros \ + -Wconversion \ + +# -Wno-sign-conversion \ + +CFLAGS_WARN_GCC_PPMD_UNALIGNED = \ + -Wno-strict-aliasing \ + + +CFLAGS_WARN = $(CFLAGS_WARN_GCC_9) \ + +# $(CFLAGS_WARN_GCC_PPMD_UNALIGNED) diff --git a/deps/LZMA-SDK/DOC/7zC.txt b/deps/LZMA-SDK/DOC/7zC.txt index 49276787f..939b720f9 100644 --- a/deps/LZMA-SDK/DOC/7zC.txt +++ b/deps/LZMA-SDK/DOC/7zC.txt @@ -1,187 +1,187 @@ -7z ANSI-C Decoder 9.35 ----------------------- - -7z ANSI-C provides 7z/LZMA decoding. -7z ANSI-C version is simplified version ported from C++ code. - -LZMA is default and general compression method of 7z format -in 7-Zip compression program (www.7-zip.org). LZMA provides high -compression ratio and very fast decompression. - - -LICENSE -------- - -7z ANSI-C Decoder is part of the LZMA SDK. -LZMA SDK is written and placed in the public domain by Igor Pavlov. - -Files ---------------------- - -7zDecode.* - Low level 7z decoding -7zExtract.* - High level 7z decoding -7zHeader.* - .7z format constants -7zIn.* - .7z archive opening -7zItem.* - .7z structures -7zMain.c - Test application - - -How To Use ----------- - -You can create .7z archive with 7z.exe, 7za.exe or 7zr.exe: - - 7z.exe a archive.7z *.htm -r -mx -m0fb=255 - -If you have big number of files in archive, and you need fast extracting, -you can use partly-solid archives: - - 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K - -In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only -512KB for extracting one file from such archive. - - -Limitations of current version of 7z ANSI-C Decoder ---------------------------------------------------- - - - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive. - - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters. - - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names. - -These limitations will be fixed in future versions. - - -Using 7z ANSI-C Decoder Test application: ------------------------------------------ - -Usage: 7zDec - -: - e: Extract files from archive - l: List contents of archive - t: Test integrity of archive - -Example: - - 7zDec l archive.7z - -lists contents of archive.7z - - 7zDec e archive.7z - -extracts files from archive.7z to current folder. - - -How to use .7z Decoder ----------------------- - -Memory allocation -~~~~~~~~~~~~~~~~~ - -7z Decoder uses two memory pools: -1) Temporary pool -2) Main pool -Such scheme can allow you to avoid fragmentation of allocated blocks. - - -Steps for using 7z decoder --------------------------- - -Use code at 7zMain.c as example. - -1) Declare variables: - inStream /* implements ILookInStream interface */ - CSzArEx db; /* 7z archive database structure */ - ISzAlloc allocImp; /* memory functions for main pool */ - ISzAlloc allocTempImp; /* memory functions for temporary pool */ - -2) call CrcGenerateTable(); function to initialize CRC structures. - -3) call SzArEx_Init(&db); function to initialize db structures. - -4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive - -This function opens archive "inStream" and reads headers to "db". -All items in "db" will be allocated with "allocMain" functions. -SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions. - -5) List items or Extract items - - Listing code: - ~~~~~~~~~~~~~ - - Use SzArEx_GetFileNameUtf16 function. Look example code in C\Util\7z\7zMain.c file. - - - Extracting code: - ~~~~~~~~~~~~~~~~ - - SZ_RESULT SzAr_Extract( - CArchiveDatabaseEx *db, - ILookInStream *inStream, - UInt32 fileIndex, /* index of file */ - UInt32 *blockIndex, /* index of solid block */ - Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp); - - If you need to decompress more than one file, you can send these values from previous call: - blockIndex, - outBuffer, - outBufferSize, - You can consider "outBuffer" as cache of solid block. If your archive is solid, - it will increase decompression speed. - - After decompressing you must free "outBuffer": - allocImp.Free(outBuffer); - -6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db". - - - - -Memory requirements for .7z decoding ------------------------------------- - -Memory usage for Archive opening: - - Temporary pool: - - Memory for uncompressed .7z headers - - some other temporary blocks - - Main pool: - - Memory for database: - Estimated size of one file structures in solid archive: - - Size (4 or 8 Bytes) - - CRC32 (4 bytes) - - LastWriteTime (8 bytes) - - Some file information (4 bytes) - - File Name (variable length) + pointer + allocation structures - -Memory usage for archive Decompressing: - - Temporary pool: - - Memory for LZMA decompressing structures - - Main pool: - - Memory for decompressed solid block - - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these - temprorary buffers can be about 15% of solid block size. - - -7z Decoder doesn't allocate memory for compressed blocks. -Instead of this, you must allocate buffer with desired -size before calling 7z Decoder. Use 7zMain.c as example. - - -Defines -------- - -_SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr. - - ---- - -http://www.7-zip.org -http://www.7-zip.org/sdk.html -http://www.7-zip.org/support.html +7z ANSI-C Decoder 9.35 +---------------------- + +7z ANSI-C provides 7z/LZMA decoding. +7z ANSI-C version is simplified version ported from C++ code. + +LZMA is default and general compression method of 7z format +in 7-Zip compression program (www.7-zip.org). LZMA provides high +compression ratio and very fast decompression. + + +LICENSE +------- + +7z ANSI-C Decoder is part of the LZMA SDK. +LZMA SDK is written and placed in the public domain by Igor Pavlov. + +Files +--------------------- + +7zDecode.* - Low level 7z decoding +7zExtract.* - High level 7z decoding +7zHeader.* - .7z format constants +7zIn.* - .7z archive opening +7zItem.* - .7z structures +7zMain.c - Test application + + +How To Use +---------- + +You can create .7z archive with 7z.exe, 7za.exe or 7zr.exe: + + 7z.exe a archive.7z *.htm -r -mx -m0fb=255 + +If you have big number of files in archive, and you need fast extracting, +you can use partly-solid archives: + + 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K + +In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only +512KB for extracting one file from such archive. + + +Limitations of current version of 7z ANSI-C Decoder +--------------------------------------------------- + + - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive. + - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters. + - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names. + +These limitations will be fixed in future versions. + + +Using 7z ANSI-C Decoder Test application: +----------------------------------------- + +Usage: 7zDec + +: + e: Extract files from archive + l: List contents of archive + t: Test integrity of archive + +Example: + + 7zDec l archive.7z + +lists contents of archive.7z + + 7zDec e archive.7z + +extracts files from archive.7z to current folder. + + +How to use .7z Decoder +---------------------- + +Memory allocation +~~~~~~~~~~~~~~~~~ + +7z Decoder uses two memory pools: +1) Temporary pool +2) Main pool +Such scheme can allow you to avoid fragmentation of allocated blocks. + + +Steps for using 7z decoder +-------------------------- + +Use code at 7zMain.c as example. + +1) Declare variables: + inStream /* implements ILookInStream interface */ + CSzArEx db; /* 7z archive database structure */ + ISzAlloc allocImp; /* memory functions for main pool */ + ISzAlloc allocTempImp; /* memory functions for temporary pool */ + +2) call CrcGenerateTable(); function to initialize CRC structures. + +3) call SzArEx_Init(&db); function to initialize db structures. + +4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive + +This function opens archive "inStream" and reads headers to "db". +All items in "db" will be allocated with "allocMain" functions. +SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions. + +5) List items or Extract items + + Listing code: + ~~~~~~~~~~~~~ + + Use SzArEx_GetFileNameUtf16 function. Look example code in C\Util\7z\7zMain.c file. + + + Extracting code: + ~~~~~~~~~~~~~~~~ + + SZ_RESULT SzAr_Extract( + CArchiveDatabaseEx *db, + ILookInStream *inStream, + UInt32 fileIndex, /* index of file */ + UInt32 *blockIndex, /* index of solid block */ + Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ + size_t *outBufferSize, /* buffer size for output buffer */ + size_t *offset, /* offset of stream for required file in *outBuffer */ + size_t *outSizeProcessed, /* size of file in *outBuffer */ + ISzAlloc *allocMain, + ISzAlloc *allocTemp); + + If you need to decompress more than one file, you can send these values from previous call: + blockIndex, + outBuffer, + outBufferSize, + You can consider "outBuffer" as cache of solid block. If your archive is solid, + it will increase decompression speed. + + After decompressing you must free "outBuffer": + allocImp.Free(outBuffer); + +6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db". + + + + +Memory requirements for .7z decoding +------------------------------------ + +Memory usage for Archive opening: + - Temporary pool: + - Memory for uncompressed .7z headers + - some other temporary blocks + - Main pool: + - Memory for database: + Estimated size of one file structures in solid archive: + - Size (4 or 8 Bytes) + - CRC32 (4 bytes) + - LastWriteTime (8 bytes) + - Some file information (4 bytes) + - File Name (variable length) + pointer + allocation structures + +Memory usage for archive Decompressing: + - Temporary pool: + - Memory for LZMA decompressing structures + - Main pool: + - Memory for decompressed solid block + - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these + temprorary buffers can be about 15% of solid block size. + + +7z Decoder doesn't allocate memory for compressed blocks. +Instead of this, you must allocate buffer with desired +size before calling 7z Decoder. Use 7zMain.c as example. + + +Defines +------- + +_SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr. + + +--- + +http://www.7-zip.org +http://www.7-zip.org/sdk.html +http://www.7-zip.org/support.html diff --git a/deps/LZMA-SDK/DOC/7zFormat.txt b/deps/LZMA-SDK/DOC/7zFormat.txt index 9239e9355..74cdfa418 100644 --- a/deps/LZMA-SDK/DOC/7zFormat.txt +++ b/deps/LZMA-SDK/DOC/7zFormat.txt @@ -1,469 +1,469 @@ -7z Format description (18.06) ----------------------------- - -This file contains description of 7z archive format. -7z archive can contain files compressed with any method. -See "Methods.txt" for description for defined compressing methods. - - -Format structure Overview -------------------------- - -Some fields can be optional. - -Archive structure -~~~~~~~~~~~~~~~~~ -SignatureHeader -[PackedStreams] -[PackedStreamsForHeaders] -[ - Header - or - { - Packed Header - HeaderInfo - } -] - - - -Header structure -~~~~~~~~~~~~~~~~ -{ - ArchiveProperties - AdditionalStreams - { - PackInfo - { - PackPos - NumPackStreams - Sizes[NumPackStreams] - CRCs[NumPackStreams] - } - CodersInfo - { - NumFolders - Folders[NumFolders] - { - NumCoders - CodersInfo[NumCoders] - { - ID - NumInStreams; - NumOutStreams; - PropertiesSize - Properties[PropertiesSize] - } - NumBindPairs - BindPairsInfo[NumBindPairs] - { - InIndex; - OutIndex; - } - PackedIndices - } - UnPackSize[Folders][Folders.NumOutstreams] - CRCs[NumFolders] - } - SubStreamsInfo - { - NumUnPackStreamsInFolders[NumFolders]; - UnPackSizes[] - CRCs[] - } - } - MainStreamsInfo - { - (Same as in AdditionalStreams) - } - FilesInfo - { - NumFiles - Properties[] - { - ID - Size - Data - } - } -} - -HeaderInfo structure -~~~~~~~~~~~~~~~~~~~~ -{ - (Same as in AdditionalStreams) -} - - - -Notes about Notation and encoding ---------------------------------- - -7z uses little endian encoding. - -7z archive format has optional headers that are marked as -[] -Header -[] - -REAL_UINT64 means real UINT64. - -UINT64 means real UINT64 encoded with the following scheme: - - Size of encoding sequence depends from first byte: - First_Byte Extra_Bytes Value - (binary) - 0xxxxxxx : ( xxxxxxx ) - 10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y - 110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y - ... - 1111110x BYTE y[6] : ( x << (8 * 6)) + y - 11111110 BYTE y[7] : y - 11111111 BYTE y[8] : y - - - -Property IDs ------------- - -0x00 = kEnd - -0x01 = kHeader - -0x02 = kArchiveProperties - -0x03 = kAdditionalStreamsInfo -0x04 = kMainStreamsInfo -0x05 = kFilesInfo - -0x06 = kPackInfo -0x07 = kUnPackInfo -0x08 = kSubStreamsInfo - -0x09 = kSize -0x0A = kCRC - -0x0B = kFolder - -0x0C = kCodersUnPackSize -0x0D = kNumUnPackStream - -0x0E = kEmptyStream -0x0F = kEmptyFile -0x10 = kAnti - -0x11 = kName -0x12 = kCTime -0x13 = kATime -0x14 = kMTime -0x15 = kWinAttributes -0x16 = kComment - -0x17 = kEncodedHeader - -0x18 = kStartPos -0x19 = kDummy - - -7z format headers ------------------ - -SignatureHeader -~~~~~~~~~~~~~~~ - BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; - - ArchiveVersion - { - BYTE Major; // now = 0 - BYTE Minor; // now = 4 - }; - - UINT32 StartHeaderCRC; - - StartHeader - { - REAL_UINT64 NextHeaderOffset - REAL_UINT64 NextHeaderSize - UINT32 NextHeaderCRC - } - - -........................... - - -ArchiveProperties -~~~~~~~~~~~~~~~~~ -BYTE NID::kArchiveProperties (0x02) -for (;;) -{ - BYTE PropertyType; - if (aType == 0) - break; - UINT64 PropertySize; - BYTE PropertyData[PropertySize]; -} - - -Digests (NumStreams) -~~~~~~~~~~~~~~~~~~~~~ - BYTE AllAreDefined - if (AllAreDefined == 0) - { - for(NumStreams) - BIT Defined - } - UINT32 CRCs[NumDefined] - - -PackInfo -~~~~~~~~~~~~ - BYTE NID::kPackInfo (0x06) - UINT64 PackPos - UINT64 NumPackStreams - - [] - BYTE NID::kSize (0x09) - UINT64 PackSizes[NumPackStreams] - [] - - [] - BYTE NID::kCRC (0x0A) - PackStreamDigests[NumPackStreams] - [] - - BYTE NID::kEnd - - -Folder -~~~~~~ - UINT64 NumCoders; - for (NumCoders) - { - BYTE - { - 0:3 CodecIdSize - 4: Is Complex Coder - 5: There Are Attributes - 6: Reserved - 7: There are more alternative methods. (Not used anymore, must be 0). - } - BYTE CodecId[CodecIdSize] - if (Is Complex Coder) - { - UINT64 NumInStreams; - UINT64 NumOutStreams; - } - if (There Are Attributes) - { - UINT64 PropertiesSize - BYTE Properties[PropertiesSize] - } - } - - NumBindPairs = NumOutStreamsTotal - 1; - - for (NumBindPairs) - { - UINT64 InIndex; - UINT64 OutIndex; - } - - NumPackedStreams = NumInStreamsTotal - NumBindPairs; - if (NumPackedStreams > 1) - for(NumPackedStreams) - { - UINT64 Index; - }; - - - - -Coders Info -~~~~~~~~~~~ - - BYTE NID::kUnPackInfo (0x07) - - - BYTE NID::kFolder (0x0B) - UINT64 NumFolders - BYTE External - switch(External) - { - case 0: - Folders[NumFolders] - case 1: - UINT64 DataStreamIndex - } - - - BYTE ID::kCodersUnPackSize (0x0C) - for(Folders) - for(Folder.NumOutStreams) - UINT64 UnPackSize; - - - [] - BYTE NID::kCRC (0x0A) - UnPackDigests[NumFolders] - [] - - - - BYTE NID::kEnd - - - -SubStreams Info -~~~~~~~~~~~~~~ - BYTE NID::kSubStreamsInfo; (0x08) - - [] - BYTE NID::kNumUnPackStream; (0x0D) - UINT64 NumUnPackStreamsInFolders[NumFolders]; - [] - - - [] - BYTE NID::kSize (0x09) - UINT64 UnPackSizes[] - [] - - - [] - BYTE NID::kCRC (0x0A) - Digests[Number of streams with unknown CRC] - [] - - - BYTE NID::kEnd - - -Streams Info -~~~~~~~~~~~~ - - [] - PackInfo - [] - - - [] - CodersInfo - [] - - - [] - SubStreamsInfo - [] - - BYTE NID::kEnd - - -FilesInfo -~~~~~~~~~ - BYTE NID::kFilesInfo; (0x05) - UINT64 NumFiles - - for (;;) - { - BYTE PropertyType; - if (aType == 0) - break; - - UINT64 Size; - - switch(PropertyType) - { - kEmptyStream: (0x0E) - for(NumFiles) - BIT IsEmptyStream - - kEmptyFile: (0x0F) - for(EmptyStreams) - BIT IsEmptyFile - - kAnti: (0x10) - for(EmptyStreams) - BIT IsAntiFile - - case kCTime: (0x12) - case kATime: (0x13) - case kMTime: (0x14) - BYTE AllAreDefined - if (AllAreDefined == 0) - { - for(NumFiles) - BIT TimeDefined - } - BYTE External; - if(External != 0) - UINT64 DataIndex - [] - for(Definded Items) - REAL_UINT64 Time - [] - - kNames: (0x11) - BYTE External; - if(External != 0) - UINT64 DataIndex - [] - for(Files) - { - wchar_t Names[NameSize]; - wchar_t 0; - } - [] - - kAttributes: (0x15) - BYTE AllAreDefined - if (AllAreDefined == 0) - { - for(NumFiles) - BIT AttributesAreDefined - } - BYTE External; - if(External != 0) - UINT64 DataIndex - [] - for(Definded Attributes) - UINT32 Attributes - [] - } - } - - -Header -~~~~~~ - BYTE NID::kHeader (0x01) - - [] - ArchiveProperties - [] - - [] - BYTE NID::kAdditionalStreamsInfo; (0x03) - StreamsInfo - [] - - [] - BYTE NID::kMainStreamsInfo; (0x04) - StreamsInfo - [] - - [] - FilesInfo - [] - - BYTE NID::kEnd - - -HeaderInfo -~~~~~~~~~~ - [] - BYTE NID::kEncodedHeader; (0x17) - StreamsInfo for Encoded Header - [] - - ---- -End of document +7z Format description (18.06) +---------------------------- + +This file contains description of 7z archive format. +7z archive can contain files compressed with any method. +See "Methods.txt" for description for defined compressing methods. + + +Format structure Overview +------------------------- + +Some fields can be optional. + +Archive structure +~~~~~~~~~~~~~~~~~ +SignatureHeader +[PackedStreams] +[PackedStreamsForHeaders] +[ + Header + or + { + Packed Header + HeaderInfo + } +] + + + +Header structure +~~~~~~~~~~~~~~~~ +{ + ArchiveProperties + AdditionalStreams + { + PackInfo + { + PackPos + NumPackStreams + Sizes[NumPackStreams] + CRCs[NumPackStreams] + } + CodersInfo + { + NumFolders + Folders[NumFolders] + { + NumCoders + CodersInfo[NumCoders] + { + ID + NumInStreams; + NumOutStreams; + PropertiesSize + Properties[PropertiesSize] + } + NumBindPairs + BindPairsInfo[NumBindPairs] + { + InIndex; + OutIndex; + } + PackedIndices + } + UnPackSize[Folders][Folders.NumOutstreams] + CRCs[NumFolders] + } + SubStreamsInfo + { + NumUnPackStreamsInFolders[NumFolders]; + UnPackSizes[] + CRCs[] + } + } + MainStreamsInfo + { + (Same as in AdditionalStreams) + } + FilesInfo + { + NumFiles + Properties[] + { + ID + Size + Data + } + } +} + +HeaderInfo structure +~~~~~~~~~~~~~~~~~~~~ +{ + (Same as in AdditionalStreams) +} + + + +Notes about Notation and encoding +--------------------------------- + +7z uses little endian encoding. + +7z archive format has optional headers that are marked as +[] +Header +[] + +REAL_UINT64 means real UINT64. + +UINT64 means real UINT64 encoded with the following scheme: + + Size of encoding sequence depends from first byte: + First_Byte Extra_Bytes Value + (binary) + 0xxxxxxx : ( xxxxxxx ) + 10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y + 110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y + ... + 1111110x BYTE y[6] : ( x << (8 * 6)) + y + 11111110 BYTE y[7] : y + 11111111 BYTE y[8] : y + + + +Property IDs +------------ + +0x00 = kEnd + +0x01 = kHeader + +0x02 = kArchiveProperties + +0x03 = kAdditionalStreamsInfo +0x04 = kMainStreamsInfo +0x05 = kFilesInfo + +0x06 = kPackInfo +0x07 = kUnPackInfo +0x08 = kSubStreamsInfo + +0x09 = kSize +0x0A = kCRC + +0x0B = kFolder + +0x0C = kCodersUnPackSize +0x0D = kNumUnPackStream + +0x0E = kEmptyStream +0x0F = kEmptyFile +0x10 = kAnti + +0x11 = kName +0x12 = kCTime +0x13 = kATime +0x14 = kMTime +0x15 = kWinAttributes +0x16 = kComment + +0x17 = kEncodedHeader + +0x18 = kStartPos +0x19 = kDummy + + +7z format headers +----------------- + +SignatureHeader +~~~~~~~~~~~~~~~ + BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; + + ArchiveVersion + { + BYTE Major; // now = 0 + BYTE Minor; // now = 4 + }; + + UINT32 StartHeaderCRC; + + StartHeader + { + REAL_UINT64 NextHeaderOffset + REAL_UINT64 NextHeaderSize + UINT32 NextHeaderCRC + } + + +........................... + + +ArchiveProperties +~~~~~~~~~~~~~~~~~ +BYTE NID::kArchiveProperties (0x02) +for (;;) +{ + BYTE PropertyType; + if (aType == 0) + break; + UINT64 PropertySize; + BYTE PropertyData[PropertySize]; +} + + +Digests (NumStreams) +~~~~~~~~~~~~~~~~~~~~~ + BYTE AllAreDefined + if (AllAreDefined == 0) + { + for(NumStreams) + BIT Defined + } + UINT32 CRCs[NumDefined] + + +PackInfo +~~~~~~~~~~~~ + BYTE NID::kPackInfo (0x06) + UINT64 PackPos + UINT64 NumPackStreams + + [] + BYTE NID::kSize (0x09) + UINT64 PackSizes[NumPackStreams] + [] + + [] + BYTE NID::kCRC (0x0A) + PackStreamDigests[NumPackStreams] + [] + + BYTE NID::kEnd + + +Folder +~~~~~~ + UINT64 NumCoders; + for (NumCoders) + { + BYTE + { + 0:3 CodecIdSize + 4: Is Complex Coder + 5: There Are Attributes + 6: Reserved + 7: There are more alternative methods. (Not used anymore, must be 0). + } + BYTE CodecId[CodecIdSize] + if (Is Complex Coder) + { + UINT64 NumInStreams; + UINT64 NumOutStreams; + } + if (There Are Attributes) + { + UINT64 PropertiesSize + BYTE Properties[PropertiesSize] + } + } + + NumBindPairs = NumOutStreamsTotal - 1; + + for (NumBindPairs) + { + UINT64 InIndex; + UINT64 OutIndex; + } + + NumPackedStreams = NumInStreamsTotal - NumBindPairs; + if (NumPackedStreams > 1) + for(NumPackedStreams) + { + UINT64 Index; + }; + + + + +Coders Info +~~~~~~~~~~~ + + BYTE NID::kUnPackInfo (0x07) + + + BYTE NID::kFolder (0x0B) + UINT64 NumFolders + BYTE External + switch(External) + { + case 0: + Folders[NumFolders] + case 1: + UINT64 DataStreamIndex + } + + + BYTE ID::kCodersUnPackSize (0x0C) + for(Folders) + for(Folder.NumOutStreams) + UINT64 UnPackSize; + + + [] + BYTE NID::kCRC (0x0A) + UnPackDigests[NumFolders] + [] + + + + BYTE NID::kEnd + + + +SubStreams Info +~~~~~~~~~~~~~~ + BYTE NID::kSubStreamsInfo; (0x08) + + [] + BYTE NID::kNumUnPackStream; (0x0D) + UINT64 NumUnPackStreamsInFolders[NumFolders]; + [] + + + [] + BYTE NID::kSize (0x09) + UINT64 UnPackSizes[] + [] + + + [] + BYTE NID::kCRC (0x0A) + Digests[Number of streams with unknown CRC] + [] + + + BYTE NID::kEnd + + +Streams Info +~~~~~~~~~~~~ + + [] + PackInfo + [] + + + [] + CodersInfo + [] + + + [] + SubStreamsInfo + [] + + BYTE NID::kEnd + + +FilesInfo +~~~~~~~~~ + BYTE NID::kFilesInfo; (0x05) + UINT64 NumFiles + + for (;;) + { + BYTE PropertyType; + if (aType == 0) + break; + + UINT64 Size; + + switch(PropertyType) + { + kEmptyStream: (0x0E) + for(NumFiles) + BIT IsEmptyStream + + kEmptyFile: (0x0F) + for(EmptyStreams) + BIT IsEmptyFile + + kAnti: (0x10) + for(EmptyStreams) + BIT IsAntiFile + + case kCTime: (0x12) + case kATime: (0x13) + case kMTime: (0x14) + BYTE AllAreDefined + if (AllAreDefined == 0) + { + for(NumFiles) + BIT TimeDefined + } + BYTE External; + if(External != 0) + UINT64 DataIndex + [] + for(Definded Items) + REAL_UINT64 Time + [] + + kNames: (0x11) + BYTE External; + if(External != 0) + UINT64 DataIndex + [] + for(Files) + { + wchar_t Names[NameSize]; + wchar_t 0; + } + [] + + kAttributes: (0x15) + BYTE AllAreDefined + if (AllAreDefined == 0) + { + for(NumFiles) + BIT AttributesAreDefined + } + BYTE External; + if(External != 0) + UINT64 DataIndex + [] + for(Definded Attributes) + UINT32 Attributes + [] + } + } + + +Header +~~~~~~ + BYTE NID::kHeader (0x01) + + [] + ArchiveProperties + [] + + [] + BYTE NID::kAdditionalStreamsInfo; (0x03) + StreamsInfo + [] + + [] + BYTE NID::kMainStreamsInfo; (0x04) + StreamsInfo + [] + + [] + FilesInfo + [] + + BYTE NID::kEnd + + +HeaderInfo +~~~~~~~~~~ + [] + BYTE NID::kEncodedHeader; (0x17) + StreamsInfo for Encoded Header + [] + + +--- +End of document diff --git a/deps/LZMA-SDK/DOC/Methods.txt b/deps/LZMA-SDK/DOC/Methods.txt index 6d0641bae..d4a1b1dd4 100644 --- a/deps/LZMA-SDK/DOC/Methods.txt +++ b/deps/LZMA-SDK/DOC/Methods.txt @@ -1,173 +1,173 @@ -7-Zip method IDs for 7z and xz archives ---------------------------------------- - -Version: 18.06 -Date: 2018-06-30 - -Each compression or crypto method in 7z is associated with unique binary value (ID). -The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes). - -xz and 7z formats use same ID map. - -If you want to add some new ID, you have two ways: - 1) Write request for allocating IDs to 7-Zip developers. - 2) Generate 8-bytes ID: - - 3F ZZ ZZ ZZ ZZ ZZ MM MM - - 3F - Prefix for random IDs (1 byte) - ZZ ZZ ZZ ZZ ZZ - Developer ID (5 bytes). Use real random bytes. - - MM MM - Method ID (2 bytes) - - You can notify 7-Zip developers about your Developer ID / Method ID. - - Note: Use new ID, if old codec can not decode data encoded with new version. - - -List of defined IDs -------------------- - -00 - Copy - -03 - Delta -04 - BCJ (x86) -05 - PPC (big-endian) -06 - IA64 -07 - ARM (little-endian) -08 - ARMT (little-endian) -09 - SPARC - -21 - LZMA2 - -02.. - Common - 03 [Swap] - - 2 Swap2 - - 4 Swap4 - -03.. - 7z - 01 - - 01 - LZMA - - 03 - [Branch Codecs] - 01 - [x86 Codecs] - 03 - BCJ - 1B - BCJ2 (4 packed streams) - 02 - - 05 - PPC (big-endian) - 03 - - 01 - Alpha - 04 - - 01 - IA64 - 05 - - 01 - ARM (little-endian) - 06 - - 05 - M68 (big-endian) - 07 - - 01 - ARMT (little-endian) - 08 - - 05 - SPARC - - 04 - - 01 - PPMD - - 7F - - 01 - experimental method. - - -04.. - Misc codecs - - 00 - Reserved - - 01 - [Zip] - 00 - Copy (not used. Use {00} instead) - 01 - Shrink - 06 - Implode - 08 - Deflate - 09 - Deflate64 - 0A - Imploding - 0C - BZip2 (not used. Use {040202} instead) - 0E - LZMA (LZMA-zip) - 5F - xz - 60 - Jpeg - 61 - WavPack - 62 - PPMd (PPMd-zip) - 63 - wzAES - - 02 - - 02 - BZip2 - - 03 - [Rar] - 01 - Rar1 - 02 - Rar2 - 03 - Rar3 - 05 - Rar5 - - 04 - [Arj] - 01 - Arj(1,2,3) - 02 - Arj4 - - 05 - [Z] - - 06 - [Lzh] - - 07 - Reserved for 7z - - 08 - [Cab] - - 09 - [NSIS] - 01 - DeflateNSIS - 02 - BZip2NSIS - - F7 - External codecs (that are not included to 7-Zip) - - 0x xx - reserved - - 10 xx - reserved (LZHAM) - 01 - LZHAM - - 11 xx - reserved (Tino Reichardt) - 01 - ZSTD - 02 - BROTLI - 04 - LZ4 - 05 - LZ5 - 06 - LIZARD - - 12 xx - reserverd (Denis Anisimov) - - 01 - WavPack2 - FE - eSplitter - FF - RawSplitter - - -06.. - Crypto - - F0 - Ciphers without hashing algo - - 01 - [AES] - 0x - AES-128 - 4x - AES-192 - 8x - AES-256 - Cx - AES - - x0 - ECB - x1 - CBC - x2 - CFB - x3 - OFB - x4 - CTR - - F1 - Combine Ciphers - - 01 - [Zip] - 01 - ZipCrypto (Main Zip crypto algo) - - 03 - [RAR] - 02 - - 03 - Rar29AES (AES-128 + modified SHA-1) - - 07 - [7z] - 01 - 7zAES (AES-256 + SHA-256) - - ---- -End of document +7-Zip method IDs for 7z and xz archives +--------------------------------------- + +Version: 18.06 +Date: 2018-06-30 + +Each compression or crypto method in 7z is associated with unique binary value (ID). +The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes). + +xz and 7z formats use same ID map. + +If you want to add some new ID, you have two ways: + 1) Write request for allocating IDs to 7-Zip developers. + 2) Generate 8-bytes ID: + + 3F ZZ ZZ ZZ ZZ ZZ MM MM + + 3F - Prefix for random IDs (1 byte) + ZZ ZZ ZZ ZZ ZZ - Developer ID (5 bytes). Use real random bytes. + + MM MM - Method ID (2 bytes) + + You can notify 7-Zip developers about your Developer ID / Method ID. + + Note: Use new ID, if old codec can not decode data encoded with new version. + + +List of defined IDs +------------------- + +00 - Copy + +03 - Delta +04 - BCJ (x86) +05 - PPC (big-endian) +06 - IA64 +07 - ARM (little-endian) +08 - ARMT (little-endian) +09 - SPARC + +21 - LZMA2 + +02.. - Common + 03 [Swap] + - 2 Swap2 + - 4 Swap4 + +03.. - 7z + 01 - + 01 - LZMA + + 03 - [Branch Codecs] + 01 - [x86 Codecs] + 03 - BCJ + 1B - BCJ2 (4 packed streams) + 02 - + 05 - PPC (big-endian) + 03 - + 01 - Alpha + 04 - + 01 - IA64 + 05 - + 01 - ARM (little-endian) + 06 - + 05 - M68 (big-endian) + 07 - + 01 - ARMT (little-endian) + 08 - + 05 - SPARC + + 04 - + 01 - PPMD + + 7F - + 01 - experimental method. + + +04.. - Misc codecs + + 00 - Reserved + + 01 - [Zip] + 00 - Copy (not used. Use {00} instead) + 01 - Shrink + 06 - Implode + 08 - Deflate + 09 - Deflate64 + 0A - Imploding + 0C - BZip2 (not used. Use {040202} instead) + 0E - LZMA (LZMA-zip) + 5F - xz + 60 - Jpeg + 61 - WavPack + 62 - PPMd (PPMd-zip) + 63 - wzAES + + 02 - + 02 - BZip2 + + 03 - [Rar] + 01 - Rar1 + 02 - Rar2 + 03 - Rar3 + 05 - Rar5 + + 04 - [Arj] + 01 - Arj(1,2,3) + 02 - Arj4 + + 05 - [Z] + + 06 - [Lzh] + + 07 - Reserved for 7z + + 08 - [Cab] + + 09 - [NSIS] + 01 - DeflateNSIS + 02 - BZip2NSIS + + F7 - External codecs (that are not included to 7-Zip) + + 0x xx - reserved + + 10 xx - reserved (LZHAM) + 01 - LZHAM + + 11 xx - reserved (Tino Reichardt) + 01 - ZSTD + 02 - BROTLI + 04 - LZ4 + 05 - LZ5 + 06 - LIZARD + + 12 xx - reserverd (Denis Anisimov) + + 01 - WavPack2 + FE - eSplitter + FF - RawSplitter + + +06.. - Crypto + + F0 - Ciphers without hashing algo + + 01 - [AES] + 0x - AES-128 + 4x - AES-192 + 8x - AES-256 + Cx - AES + + x0 - ECB + x1 - CBC + x2 - CFB + x3 - OFB + x4 - CTR + + F1 - Combine Ciphers + + 01 - [Zip] + 01 - ZipCrypto (Main Zip crypto algo) + + 03 - [RAR] + 02 - + 03 - Rar29AES (AES-128 + modified SHA-1) + + 07 - [7z] + 01 - 7zAES (AES-256 + SHA-256) + + +--- +End of document diff --git a/deps/LZMA-SDK/DOC/installer.txt b/deps/LZMA-SDK/DOC/installer.txt index 70ad7dc6a..b99d21d24 100644 --- a/deps/LZMA-SDK/DOC/installer.txt +++ b/deps/LZMA-SDK/DOC/installer.txt @@ -1,166 +1,166 @@ -7-Zip for installers 9.38 -------------------------- - -7-Zip is a file archiver for Windows NT/2000/2003/2008/XP/Vista/7/8/10. - -7-Zip for installers is part of LZMA SDK. -LZMA SDK is written and placed in the public domain by Igor Pavlov. - -It's allowed to join 7-Zip SFX module with another software. -It's allowed to change resources of 7-Zip's SFX modules. - - -HOW to use ------------ - -7zr.exe is reduced version of 7za.exe of 7-Zip. -7zr.exe supports only format with these codecs: LZMA, LZMA2, BCJ, BCJ2, ARM, Copy. - -Example of compressing command for installation packages: - -7zr a archive.7z files - -7zSD.sfx is SFX module for installers. 7zSD.sfx uses msvcrt.dll. - -SFX modules for installers allow to create installation program. -Such module extracts archive to temp folder and then runs specified program and removes -temp files after program finishing. Self-extract archive for installers must be created -as joining 3 files: SFX_Module, Installer_Config, 7z_Archive. -Installer_Config is optional file. You can use the following command to create installer -self-extract archive: - -copy /b 7zSD.sfx + config.txt + archive.7z archive.exe - -The smallest installation package size can be achieved, if installation files was -uncompressed before including to 7z archive. - --y switch for installer module (at runtime) specifies quiet mode for extracting. - -Installer Config file format -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Config file contains commands for Installer. File begins from string -;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. File must be written -in UTF-8 encoding. File contains string pairs: - -ID_String="Value" - -ID_String Description - -Title Title for messages -BeginPrompt Begin Prompt message -Progress Value can be "yes" or "no". Default value is "yes". -RunProgram Command for executing. Default value is "setup.exe". - Substring %%T will be replaced with path to temporary - folder, where files were extracted -Directory Directory prefix for "RunProgram". Default value is ".\\" -ExecuteFile Name of file for executing -ExecuteParameters Parameters for "ExecuteFile" - - -You can omit any string pair. - -There are two ways to run program: RunProgram and ExecuteFile. -Use RunProgram, if you want to run some program from .7z archive. -Use ExecuteFile, if you want to open some document from .7z archive or -if you want to execute some command from Windows. - -If you use RunProgram and if you specify empty directory prefix: Directory="", -the system searches for the executable file in the following sequence: - -1. The directory from which the application (installer) loaded. -2. The temporary folder, where files were extracted. -3. The Windows system directory. - - -Config file Examples -~~~~~~~~~~~~~~~~~~~~ - -;!@Install@!UTF-8! -Title="7-Zip 4.00" -BeginPrompt="Do you want to install the 7-Zip 4.00?" -RunProgram="setup.exe" -;!@InstallEnd@! - - - -;!@Install@!UTF-8! -Title="7-Zip 4.00" -BeginPrompt="Do you want to install the 7-Zip 4.00?" -ExecuteFile="7zip.msi" -;!@InstallEnd@! - - - -;!@Install@!UTF-8! -Title="7-Zip 4.01 Update" -BeginPrompt="Do you want to install the 7-Zip 4.01 Update?" -ExecuteFile="msiexec.exe" -ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus" -;!@InstallEnd@! - - - -Small SFX modules for installers --------------------------------- - -7zS2.sfx - small SFX module (GUI version) -7zS2con.sfx - small SFX module (Console version) - -Small SFX modules support this codecs: LZMA, LZMA2, BCJ, BCJ2, ARM, COPY - -Small SFX module is similar to common SFX module for installers. -The difference (what's new in small version): - - Smaller size (30 KB vs 100 KB) - - C source code instead of Ñ++ - - No installer Configuration file - - No extracting progress window - - It decompresses solid 7z blocks (it can be whole 7z archive) to RAM. - So user that calls SFX installer must have free RAM of size of largest - solid 7z block (size of 7z archive at simplest case). - -How to use ----------- - -copy /b 7zS2.sfx + archive.7z sfx.exe - -When you run installer sfx module (sfx.exe) -1) It creates "7zNNNNNNNN" temp folder in system temp folder. -2) It extracts .7z archive to that folder -3) It executes one file from "7zNNNNNNNN" temp folder. -4) It removes "7zNNNNNNNN" temp folder - -You can send parameters to installer, and installer will transfer them to extracted .exe file. - -Small SFX uses 3 levels of priorities to select file to execute: - - 1) Files in root folder have higher priority than files in subfolders. - 2) File extension priorities (from high to low priority order): - bat, cmd, exe, inf, msi, cab (under Windows CE), html, htm - 3) File name priorities (from high to low priority order): - setup, install, run, start - -Windows CE (ARM) version of 7zS2.sfx is included to 7-Zip for Windows Mobile package. - - -Examples --------- - -1) To create compressed console 7-Zip: - -7zr a c.7z 7z.exe 7z.dll -mx -copy /b 7zS2con.sfx + c.7z 7zCompr.exe -7zCompr.exe b -md22 - - -2) To create compressed GUI 7-Zip: - -7zr a g.7z 7zg.exe 7z.dll -mx -copy /b 7zS2.sfx + g.7z 7zgCompr.exe -7zgCompr.exe b -md22 - - -3) To open some file: - -7zr a h.7z readme.txt -mx -copy /b 7zS2.sfx + h.7z 7zTxt.exe -7zTxt.exe +7-Zip for installers 9.38 +------------------------- + +7-Zip is a file archiver for Windows NT/2000/2003/2008/XP/Vista/7/8/10. + +7-Zip for installers is part of LZMA SDK. +LZMA SDK is written and placed in the public domain by Igor Pavlov. + +It's allowed to join 7-Zip SFX module with another software. +It's allowed to change resources of 7-Zip's SFX modules. + + +HOW to use +----------- + +7zr.exe is reduced version of 7za.exe of 7-Zip. +7zr.exe supports only format with these codecs: LZMA, LZMA2, BCJ, BCJ2, ARM, Copy. + +Example of compressing command for installation packages: + +7zr a archive.7z files + +7zSD.sfx is SFX module for installers. 7zSD.sfx uses msvcrt.dll. + +SFX modules for installers allow to create installation program. +Such module extracts archive to temp folder and then runs specified program and removes +temp files after program finishing. Self-extract archive for installers must be created +as joining 3 files: SFX_Module, Installer_Config, 7z_Archive. +Installer_Config is optional file. You can use the following command to create installer +self-extract archive: + +copy /b 7zSD.sfx + config.txt + archive.7z archive.exe + +The smallest installation package size can be achieved, if installation files was +uncompressed before including to 7z archive. + +-y switch for installer module (at runtime) specifies quiet mode for extracting. + +Installer Config file format +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Config file contains commands for Installer. File begins from string +;!@Install@!UTF-8! and ends with ;!@InstallEnd@!. File must be written +in UTF-8 encoding. File contains string pairs: + +ID_String="Value" + +ID_String Description + +Title Title for messages +BeginPrompt Begin Prompt message +Progress Value can be "yes" or "no". Default value is "yes". +RunProgram Command for executing. Default value is "setup.exe". + Substring %%T will be replaced with path to temporary + folder, where files were extracted +Directory Directory prefix for "RunProgram". Default value is ".\\" +ExecuteFile Name of file for executing +ExecuteParameters Parameters for "ExecuteFile" + + +You can omit any string pair. + +There are two ways to run program: RunProgram and ExecuteFile. +Use RunProgram, if you want to run some program from .7z archive. +Use ExecuteFile, if you want to open some document from .7z archive or +if you want to execute some command from Windows. + +If you use RunProgram and if you specify empty directory prefix: Directory="", +the system searches for the executable file in the following sequence: + +1. The directory from which the application (installer) loaded. +2. The temporary folder, where files were extracted. +3. The Windows system directory. + + +Config file Examples +~~~~~~~~~~~~~~~~~~~~ + +;!@Install@!UTF-8! +Title="7-Zip 4.00" +BeginPrompt="Do you want to install the 7-Zip 4.00?" +RunProgram="setup.exe" +;!@InstallEnd@! + + + +;!@Install@!UTF-8! +Title="7-Zip 4.00" +BeginPrompt="Do you want to install the 7-Zip 4.00?" +ExecuteFile="7zip.msi" +;!@InstallEnd@! + + + +;!@Install@!UTF-8! +Title="7-Zip 4.01 Update" +BeginPrompt="Do you want to install the 7-Zip 4.01 Update?" +ExecuteFile="msiexec.exe" +ExecuteParameters="/i 7zip.msi REINSTALL=ALL REINSTALLMODE=vomus" +;!@InstallEnd@! + + + +Small SFX modules for installers +-------------------------------- + +7zS2.sfx - small SFX module (GUI version) +7zS2con.sfx - small SFX module (Console version) + +Small SFX modules support this codecs: LZMA, LZMA2, BCJ, BCJ2, ARM, COPY + +Small SFX module is similar to common SFX module for installers. +The difference (what's new in small version): + - Smaller size (30 KB vs 100 KB) + - C source code instead of Ñ++ + - No installer Configuration file + - No extracting progress window + - It decompresses solid 7z blocks (it can be whole 7z archive) to RAM. + So user that calls SFX installer must have free RAM of size of largest + solid 7z block (size of 7z archive at simplest case). + +How to use +---------- + +copy /b 7zS2.sfx + archive.7z sfx.exe + +When you run installer sfx module (sfx.exe) +1) It creates "7zNNNNNNNN" temp folder in system temp folder. +2) It extracts .7z archive to that folder +3) It executes one file from "7zNNNNNNNN" temp folder. +4) It removes "7zNNNNNNNN" temp folder + +You can send parameters to installer, and installer will transfer them to extracted .exe file. + +Small SFX uses 3 levels of priorities to select file to execute: + + 1) Files in root folder have higher priority than files in subfolders. + 2) File extension priorities (from high to low priority order): + bat, cmd, exe, inf, msi, cab (under Windows CE), html, htm + 3) File name priorities (from high to low priority order): + setup, install, run, start + +Windows CE (ARM) version of 7zS2.sfx is included to 7-Zip for Windows Mobile package. + + +Examples +-------- + +1) To create compressed console 7-Zip: + +7zr a c.7z 7z.exe 7z.dll -mx +copy /b 7zS2con.sfx + c.7z 7zCompr.exe +7zCompr.exe b -md22 + + +2) To create compressed GUI 7-Zip: + +7zr a g.7z 7zg.exe 7z.dll -mx +copy /b 7zS2.sfx + g.7z 7zgCompr.exe +7zgCompr.exe b -md22 + + +3) To open some file: + +7zr a h.7z readme.txt -mx +copy /b 7zS2.sfx + h.7z 7zTxt.exe +7zTxt.exe diff --git a/deps/LZMA-SDK/DOC/lzma-history.txt b/deps/LZMA-SDK/DOC/lzma-history.txt index 3fc19fd8b..0963c7bf7 100644 --- a/deps/LZMA-SDK/DOC/lzma-history.txt +++ b/deps/LZMA-SDK/DOC/lzma-history.txt @@ -1,484 +1,520 @@ -HISTORY of the LZMA SDK ------------------------ - -21.02 alpha 2021-05-06 -------------------------- -- The command line version of 7-Zip for macOS was released. -- The speed for LZMA and LZMA2 decompression in arm64 versions for macOS and Linux - was increased by 20%-60%. - - -21.01 alpha 2021-03-09 -------------------------- -- The command line version of 7-Zip for Linux was released. -- The improvements for speed of ARM64 version using hardware CPU instructions - for AES, CRC-32, SHA-1 and SHA-256. -- Some bugs were fixed. - - -20.02 alpha 2020-08-08 -------------------------- -- The default number of LZMA2 chunks per solid block in 7z archive was increased to 64. - It allows to increase the compression speed for big 7z archives, if there is a big number - of CPU cores and threads. -- The speed of PPMd compressing/decompressing was increased for 7z archives. -- The new -ssp switch. If the switch -ssp is specified, 7-Zip doesn't allow the system - to modify "Last Access Time" property of source files for archiving and hashing operations. -- Some bugs were fixed. - - -20.00 alpha 2020-02-06 -------------------------- -- 7-Zip now supports new optional match finders for LZMA/LZMA2 compression: bt5 and hc5, - that can work faster than bt4 and hc4 match finders for the data with big redundancy. -- The compression ratio was improved for Fast and Fastest compression levels with the - following default settings: - - Fastest level (-mx1) : hc5 match finder with 256 KB dictionary. - - Fast level (-mx3) : hc5 match finder with 4 MB dictionary. -- Minor speed optimizations in multithreaded LZMA/LZMA2 compression for Normal/Maximum/Ultra - compression levels. - - -19.00 2019-02-21 -------------------------- -- Encryption strength for 7z archives was increased: - the size of random initialization vector was increased from 64-bit to 128-bit, - and the pseudo-random number generator was improved. -- The bug in 7zIn.c code was fixed. - - -18.06 2018-12-30 -------------------------- -- The speed for LZMA/LZMA2 compressing was increased by 3-10%, - and there are minor changes in compression ratio. -- Some bugs were fixed. -- The bug in 7-Zip 18.02-18.05 was fixed: - There was memory leak in multithreading xz decoder - XzDecMt_Decode(), - if xz stream contains only one block. -- The changes for MSVS compiler makefiles: - - the makefiles now use "PLATFORM" macroname with values (x64, x86, arm64) - instead of "CPU" macroname with values (AMD64, ARM64). - - the makefiles by default now use static version of the run-time library. - - -18.05 2018-04-30 -------------------------- -- The speed for LZMA/LZMA2 compressing was increased - by 8% for fastest/fast compression levels and - by 3% for normal/maximum compression levels. -- Previous versions of 7-Zip could work incorrectly in "Large memory pages" mode in - Windows 10 because of some BUG with "Large Pages" in Windows 10. - Now 7-Zip doesn't use "Large Pages" on Windows 10 up to revision 1709 (16299). -- The BUG was fixed in Lzma2Enc.c - Lzma2Enc_Encode2() function worked incorretly, - if (inStream == NULL) and the number of block threads is more than 1. - - -18.03 beta 2018-03-04 -------------------------- -- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm - for x64 with about 30% higher speed than main version of LZMA decoder written in C. -- The speed for single-thread LZMA/LZMA2 decoder written in C was increased by 3%. -- 7-Zip now can use multi-threading for 7z/LZMA2 decoding, - if there are multiple independent data chunks in LZMA2 stream. -- 7-Zip now can use multi-threading for xz decoding, - if there are multiple blocks in xz stream. - - -18.01 2019-01-28 -------------------------- -- The BUG in 17.01 - 18.00 beta was fixed: - XzDec.c : random block unpacking and XzUnpacker_IsBlockFinished() - didn't work correctly for xz archives without checksum (CRC). - - -18.00 beta 2019-01-10 -------------------------- -- The BUG in xz encoder was fixed: - There was memory leak of 16 KB for each file compressed with - xz compression method, if additional filter was used. - - -17.01 beta 2017-08-28 -------------------------- -- Minor speed optimization for LZMA2 (xz and 7z) multi-threading compression. - 7-Zip now uses additional memory buffers for multi-block LZMA2 compression. - CPU utilization was slightly improved. -- 7-zip now creates multi-block xz archives by default. Block size can be - specified with -ms[Size]{m|g} switch. -- xz decoder now can unpack random block from multi-block xz archives. -- 7-Zip command line: @listfile now doesn't work after -- switch. - Use -i@listfile before -- switch instead. -- The BUGs were fixed: - 7-Zip 17.00 beta crashed for commands that write anti-item to 7z archive. - - -17.00 beta 2017-04-29 -------------------------- -- NewHandler.h / NewHandler.cpp: - now it redefines operator new() only for old MSVC compilers (_MSC_VER < 1900). -- C/7zTypes.h : the names of variables in interface structures were changed (vt). -- Some bugs were fixed. 7-Zip could crash in some cases. -- Some internal changes in code. - - -16.04 2016-10-04 -------------------------- -- The bug was fixed in DllSecur.c. - - -16.03 2016-09-28 -------------------------- -- SFX modules now use some protection against DLL preloading attack. -- Some bugs in 7z code were fixed. - - -16.02 2016-05-21 -------------------------- -- The BUG in 16.00 - 16.01 was fixed: - Split Handler (SplitHandler.cpp) returned incorrect - total size value (kpidSize) for split archives. - - -16.01 2016-05-19 -------------------------- -- Some internal changes to reduce the number of compiler warnings. - - -16.00 2016-05-10 -------------------------- -- Some bugs were fixed. - - -15.12 2015-11-19 -------------------------- -- The BUG in C version of 7z decoder was fixed: - 7zDec.c : SzDecodeLzma2() - 7z decoder could mistakenly report about decoding error for some 7z archives - that use LZMA2 compression method. - The probability to get that mistaken decoding error report was about - one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size). -- The BUG (in 9.26-15.11) in C version of 7z decoder was fixed: - 7zArcIn.c : SzReadHeader2() - 7z decoder worked incorrectly for 7z archives that contain - empty solid blocks, that can be placed to 7z archive, if some file is - unavailable for reading during archive creation. - - -15.09 beta 2015-10-16 -------------------------- -- The BUG in LZMA / LZMA2 encoding code was fixed. - The BUG in LzFind.c::MatchFinder_ReadBlock() function. - If input data size is larger than (4 GiB - dictionary_size), - the following code worked incorrectly: - - LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions - for compressing from memory to memory. - That BUG is not related to LZMA encoder version that works via streams. - - LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, if - default value of chunk size (CLzma2EncProps::blockSize) is changed - to value larger than (4 GiB - dictionary_size). - - -9.38 beta 2015-01-03 -------------------------- -- The BUG in 9.31-9.37 was fixed: - IArchiveGetRawProps interface was disabled for 7z archives. -- The BUG in 9.26-9.36 was fixed: - Some code in CPP\7zip\Archive\7z\ worked correctly only under Windows. - - -9.36 beta 2014-12-26 -------------------------- -- The BUG in command line version was fixed: - 7-Zip created temporary archive in current folder during update archive - operation, if -w{Path} switch was not specified. - The fixed 7-Zip creates temporary archive in folder that contains updated archive. -- The BUG in 9.33-9.35 was fixed: - 7-Zip silently ignored file reading errors during 7z or gz archive creation, - and the created archive contained only part of file that was read before error. - The fixed 7-Zip stops archive creation and it reports about error. - - -9.35 beta 2014-12-07 -------------------------- -- 7zr.exe now support AES encryption. -- SFX mudules were added to LZMA SDK -- Some bugs were fixed. - - -9.21 beta 2011-04-11 -------------------------- -- New class FString for file names at file systems. -- Speed optimization in CRC code for big-endian CPUs. -- The BUG in Lzma2Dec.c was fixed: - Lzma2Decode function didn't work. - - -9.18 beta 2010-11-02 -------------------------- -- New small SFX module for installers (SfxSetup). - - -9.12 beta 2010-03-24 -------------------------- -- The BUG in LZMA SDK 9.* was fixed: LZMA2 codec didn't work, - if more than 10 threads were used (or more than 20 threads in some modes). - - -9.11 beta 2010-03-15 -------------------------- -- PPMd compression method support - - -9.09 2009-12-12 -------------------------- -- The bug was fixed: - Utf16_To_Utf8 funstions in UTFConvert.cpp and 7zMain.c - incorrectly converted surrogate characters (the code >= 0x10000) to UTF-8. -- Some bugs were fixed - - -9.06 2009-08-17 -------------------------- -- Some changes in ANSI-C 7z Decoder interfaces. - - -9.04 2009-05-30 -------------------------- -- LZMA2 compression method support -- xz format support - - -4.65 2009-02-03 -------------------------- -- Some minor fixes - - -4.63 2008-12-31 -------------------------- -- Some minor fixes - - -4.61 beta 2008-11-23 -------------------------- -- The bug in ANSI-C LZMA Decoder was fixed: - If encoded stream was corrupted, decoder could access memory - outside of allocated range. -- Some changes in ANSI-C 7z Decoder interfaces. -- LZMA SDK is placed in the public domain. - - -4.60 beta 2008-08-19 -------------------------- -- Some minor fixes. - - -4.59 beta 2008-08-13 -------------------------- -- The bug was fixed: - LZMA Encoder in fast compression mode could access memory outside of - allocated range in some rare cases. - - -4.58 beta 2008-05-05 -------------------------- -- ANSI-C LZMA Decoder was rewritten for speed optimizations. -- ANSI-C LZMA Encoder was included to LZMA SDK. -- C++ LZMA code now is just wrapper over ANSI-C code. - - -4.57 2007-12-12 -------------------------- -- Speed optimizations in Ñ++ LZMA Decoder. -- Small changes for more compatibility with some C/C++ compilers. - - -4.49 beta 2007-07-05 -------------------------- -- .7z ANSI-C Decoder: - - now it supports BCJ and BCJ2 filters - - now it supports files larger than 4 GB. - - now it supports "Last Write Time" field for files. -- C++ code for .7z archives compressing/decompressing from 7-zip - was included to LZMA SDK. - - -4.43 2006-06-04 -------------------------- -- Small changes for more compatibility with some C/C++ compilers. - - -4.42 2006-05-15 -------------------------- -- Small changes in .h files in ANSI-C version. - - -4.39 beta 2006-04-14 -------------------------- -- The bug in versions 4.33b:4.38b was fixed: - C++ version of LZMA encoder could not correctly compress - files larger than 2 GB with HC4 match finder (-mfhc4). - - -4.37 beta 2005-04-06 -------------------------- -- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. - - -4.35 beta 2005-03-02 -------------------------- -- The bug was fixed in C++ version of LZMA Decoder: - If encoded stream was corrupted, decoder could access memory - outside of allocated range. - - -4.34 beta 2006-02-27 -------------------------- -- Compressing speed and memory requirements for compressing were increased -- LZMA now can use only these match finders: HC4, BT2, BT3, BT4 - - -4.32 2005-12-09 -------------------------- -- Java version of LZMA SDK was included - - -4.30 2005-11-20 -------------------------- -- Compression ratio was improved in -a2 mode -- Speed optimizations for compressing in -a2 mode -- -fb switch now supports values up to 273 -- The bug in 7z_C (7zIn.c) was fixed: - It used Alloc/Free functions from different memory pools. - So if program used two memory pools, it worked incorrectly. -- 7z_C: .7z format supporting was improved -- LZMA# SDK (C#.NET version) was included - - -4.27 (Updated) 2005-09-21 -------------------------- -- Some GUIDs/interfaces in C++ were changed. - IStream.h: - ISequentialInStream::Read now works as old ReadPart - ISequentialOutStream::Write now works as old WritePart - - -4.27 2005-08-07 -------------------------- -- The bug in LzmaDecodeSize.c was fixed: - if _LZMA_IN_CB and _LZMA_OUT_READ were defined, - decompressing worked incorrectly. - - -4.26 2005-08-05 -------------------------- -- Fixes in 7z_C code and LzmaTest.c: - previous versions could work incorrectly, - if malloc(0) returns 0 - - -4.23 2005-06-29 -------------------------- -- Small fixes in C++ code - - -4.22 2005-06-10 -------------------------- -- Small fixes - - -4.21 2005-06-08 -------------------------- -- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed -- New additional version of ANSI-C LZMA Decoder with zlib-like interface: - - LzmaStateDecode.h - - LzmaStateDecode.c - - LzmaStateTest.c -- ANSI-C LZMA Decoder now can decompress files larger than 4 GB - - -4.17 2005-04-18 -------------------------- -- New example for RAM->RAM compressing/decompressing: - LZMA + BCJ (filter for x86 code): - - LzmaRam.h - - LzmaRam.cpp - - LzmaRamDecode.h - - LzmaRamDecode.c - - -f86 switch for lzma.exe - - -4.16 2005-03-29 -------------------------- -- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): - If _LZMA_OUT_READ was defined, and if encoded stream was corrupted, - decoder could access memory outside of allocated range. -- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster). - Old version of LZMA Decoder now is in file LzmaDecodeSize.c. - LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c -- Small speed optimization in LZMA C++ code -- filter for SPARC's code was added -- Simplified version of .7z ANSI-C Decoder was included - - -4.06 2004-09-05 -------------------------- -- The bug in v4.05 was fixed: - LZMA-Encoder didn't release output stream in some cases. - - -4.05 2004-08-25 -------------------------- -- Source code of filters for x86, IA-64, ARM, ARM-Thumb - and PowerPC code was included to SDK -- Some internal minor changes - - -4.04 2004-07-28 -------------------------- -- More compatibility with some C++ compilers - - -4.03 2004-06-18 -------------------------- -- "Benchmark" command was added. It measures compressing - and decompressing speed and shows rating values. - Also it checks hardware errors. - - -4.02 2004-06-10 -------------------------- -- C++ LZMA Encoder/Decoder code now is more portable - and it can be compiled by GCC on Linux. - - -4.01 2004-02-15 -------------------------- -- Some detection of data corruption was enabled. - LzmaDecode.c / RangeDecoderReadByte - ..... - { - rd->ExtraBytes = 1; - return 0xFF; - } - - -4.00 2004-02-13 -------------------------- -- Original version of LZMA SDK - - - -HISTORY of the LZMA -------------------- - 2001-2008: Improvements to LZMA compressing/decompressing code, - keeping compatibility with original LZMA format - 1996-2001: Development of LZMA compression format - - Some milestones: - - 2001-08-30: LZMA compression was added to 7-Zip - 1999-01-02: First version of 7-Zip was released - - -End of document +HISTORY of the LZMA SDK +----------------------- + +21.07 2021-12-26 +------------------------- +- New switches: -spm and -im!{file_path} to exclude directories from processing + for specified paths that don't contain path separator character at the end of path. +- The sorting order of files in archives was slightly changed to be more consistent + for cases where the name of some directory is the same as the prefix part of the name + of another directory or file. + + +21.06 2021-11-24 +------------------------- +- Bug in LZMA encoder in file LzmaEnc.c was fixed: + LzmaEnc_MemEncode(), LzmaEncode() and LzmaCompress() could work incorrectly, + if size value for output buffer is smaller than size required for all compressed data. + LzmaEnc_Encode() could work incorrectly, + if callback ISeqOutStream::Write() doesn't write all compressed data. + NCompress::NLzma::CEncoder::Code() could work incorrectly, + if callback ISequentialOutStream::Write() returns error code. +- Bug in versions 21.00-21.05 was fixed: + 7-Zip didn't set attributes of directories during archive extracting. + + +21.04 beta 2021-11-02 +------------------------- +- 7-Zip now reduces the number of working CPU threads for compression, + if RAM size is not enough for compression with big LZMA2 dictionary. +- 7-Zip now can create and check "file.sha256" text files that contain the list + of file names and SHA-256 checksums in format compatible with sha256sum program. + + +21.03 beta 2021-07-20 +------------------------- +- The maximum dictionary size for LZMA/LZMA2 compressing was increased to 4 GB (3840 MiB). +- Minor speed optimizations in LZMA/LZMA2 compressing. + + +21.02 alpha 2021-05-06 +------------------------- +- The command line version of 7-Zip for macOS was released. +- The speed for LZMA and LZMA2 decompression in arm64 versions for macOS and Linux + was increased by 20%-60%. + + +21.01 alpha 2021-03-09 +------------------------- +- The command line version of 7-Zip for Linux was released. +- The improvements for speed of ARM64 version using hardware CPU instructions + for AES, CRC-32, SHA-1 and SHA-256. +- Some bugs were fixed. + + +20.02 alpha 2020-08-08 +------------------------- +- The default number of LZMA2 chunks per solid block in 7z archive was increased to 64. + It allows to increase the compression speed for big 7z archives, if there is a big number + of CPU cores and threads. +- The speed of PPMd compressing/decompressing was increased for 7z archives. +- The new -ssp switch. If the switch -ssp is specified, 7-Zip doesn't allow the system + to modify "Last Access Time" property of source files for archiving and hashing operations. +- Some bugs were fixed. + + +20.00 alpha 2020-02-06 +------------------------- +- 7-Zip now supports new optional match finders for LZMA/LZMA2 compression: bt5 and hc5, + that can work faster than bt4 and hc4 match finders for the data with big redundancy. +- The compression ratio was improved for Fast and Fastest compression levels with the + following default settings: + - Fastest level (-mx1) : hc5 match finder with 256 KB dictionary. + - Fast level (-mx3) : hc5 match finder with 4 MB dictionary. +- Minor speed optimizations in multithreaded LZMA/LZMA2 compression for Normal/Maximum/Ultra + compression levels. + + +19.00 2019-02-21 +------------------------- +- Encryption strength for 7z archives was increased: + the size of random initialization vector was increased from 64-bit to 128-bit, + and the pseudo-random number generator was improved. +- The bug in 7zIn.c code was fixed. + + +18.06 2018-12-30 +------------------------- +- The speed for LZMA/LZMA2 compressing was increased by 3-10%, + and there are minor changes in compression ratio. +- Some bugs were fixed. +- The bug in 7-Zip 18.02-18.05 was fixed: + There was memory leak in multithreading xz decoder - XzDecMt_Decode(), + if xz stream contains only one block. +- The changes for MSVS compiler makefiles: + - the makefiles now use "PLATFORM" macroname with values (x64, x86, arm64) + instead of "CPU" macroname with values (AMD64, ARM64). + - the makefiles by default now use static version of the run-time library. + + +18.05 2018-04-30 +------------------------- +- The speed for LZMA/LZMA2 compressing was increased + by 8% for fastest/fast compression levels and + by 3% for normal/maximum compression levels. +- Previous versions of 7-Zip could work incorrectly in "Large memory pages" mode in + Windows 10 because of some BUG with "Large Pages" in Windows 10. + Now 7-Zip doesn't use "Large Pages" on Windows 10 up to revision 1709 (16299). +- The BUG was fixed in Lzma2Enc.c + Lzma2Enc_Encode2() function worked incorretly, + if (inStream == NULL) and the number of block threads is more than 1. + + +18.03 beta 2018-03-04 +------------------------- +- Asm\x86\LzmaDecOpt.asm: new optimized LZMA decoder written in asm + for x64 with about 30% higher speed than main version of LZMA decoder written in C. +- The speed for single-thread LZMA/LZMA2 decoder written in C was increased by 3%. +- 7-Zip now can use multi-threading for 7z/LZMA2 decoding, + if there are multiple independent data chunks in LZMA2 stream. +- 7-Zip now can use multi-threading for xz decoding, + if there are multiple blocks in xz stream. + + +18.01 2019-01-28 +------------------------- +- The BUG in 17.01 - 18.00 beta was fixed: + XzDec.c : random block unpacking and XzUnpacker_IsBlockFinished() + didn't work correctly for xz archives without checksum (CRC). + + +18.00 beta 2019-01-10 +------------------------- +- The BUG in xz encoder was fixed: + There was memory leak of 16 KB for each file compressed with + xz compression method, if additional filter was used. + + +17.01 beta 2017-08-28 +------------------------- +- Minor speed optimization for LZMA2 (xz and 7z) multi-threading compression. + 7-Zip now uses additional memory buffers for multi-block LZMA2 compression. + CPU utilization was slightly improved. +- 7-zip now creates multi-block xz archives by default. Block size can be + specified with -ms[Size]{m|g} switch. +- xz decoder now can unpack random block from multi-block xz archives. +- 7-Zip command line: @listfile now doesn't work after -- switch. + Use -i@listfile before -- switch instead. +- The BUGs were fixed: + 7-Zip 17.00 beta crashed for commands that write anti-item to 7z archive. + + +17.00 beta 2017-04-29 +------------------------- +- NewHandler.h / NewHandler.cpp: + now it redefines operator new() only for old MSVC compilers (_MSC_VER < 1900). +- C/7zTypes.h : the names of variables in interface structures were changed (vt). +- Some bugs were fixed. 7-Zip could crash in some cases. +- Some internal changes in code. + + +16.04 2016-10-04 +------------------------- +- The bug was fixed in DllSecur.c. + + +16.03 2016-09-28 +------------------------- +- SFX modules now use some protection against DLL preloading attack. +- Some bugs in 7z code were fixed. + + +16.02 2016-05-21 +------------------------- +- The BUG in 16.00 - 16.01 was fixed: + Split Handler (SplitHandler.cpp) returned incorrect + total size value (kpidSize) for split archives. + + +16.01 2016-05-19 +------------------------- +- Some internal changes to reduce the number of compiler warnings. + + +16.00 2016-05-10 +------------------------- +- Some bugs were fixed. + + +15.12 2015-11-19 +------------------------- +- The BUG in C version of 7z decoder was fixed: + 7zDec.c : SzDecodeLzma2() + 7z decoder could mistakenly report about decoding error for some 7z archives + that use LZMA2 compression method. + The probability to get that mistaken decoding error report was about + one error per 16384 solid blocks for solid blocks larger than 16 KB (compressed size). +- The BUG (in 9.26-15.11) in C version of 7z decoder was fixed: + 7zArcIn.c : SzReadHeader2() + 7z decoder worked incorrectly for 7z archives that contain + empty solid blocks, that can be placed to 7z archive, if some file is + unavailable for reading during archive creation. + + +15.09 beta 2015-10-16 +------------------------- +- The BUG in LZMA / LZMA2 encoding code was fixed. + The BUG in LzFind.c::MatchFinder_ReadBlock() function. + If input data size is larger than (4 GiB - dictionary_size), + the following code worked incorrectly: + - LZMA : LzmaEnc_MemEncode(), LzmaEncode() : LZMA encoding functions + for compressing from memory to memory. + That BUG is not related to LZMA encoder version that works via streams. + - LZMA2 : multi-threaded version of LZMA2 encoder worked incorrectly, if + default value of chunk size (CLzma2EncProps::blockSize) is changed + to value larger than (4 GiB - dictionary_size). + + +9.38 beta 2015-01-03 +------------------------- +- The BUG in 9.31-9.37 was fixed: + IArchiveGetRawProps interface was disabled for 7z archives. +- The BUG in 9.26-9.36 was fixed: + Some code in CPP\7zip\Archive\7z\ worked correctly only under Windows. + + +9.36 beta 2014-12-26 +------------------------- +- The BUG in command line version was fixed: + 7-Zip created temporary archive in current folder during update archive + operation, if -w{Path} switch was not specified. + The fixed 7-Zip creates temporary archive in folder that contains updated archive. +- The BUG in 9.33-9.35 was fixed: + 7-Zip silently ignored file reading errors during 7z or gz archive creation, + and the created archive contained only part of file that was read before error. + The fixed 7-Zip stops archive creation and it reports about error. + + +9.35 beta 2014-12-07 +------------------------- +- 7zr.exe now support AES encryption. +- SFX mudules were added to LZMA SDK +- Some bugs were fixed. + + +9.21 beta 2011-04-11 +------------------------- +- New class FString for file names at file systems. +- Speed optimization in CRC code for big-endian CPUs. +- The BUG in Lzma2Dec.c was fixed: + Lzma2Decode function didn't work. + + +9.18 beta 2010-11-02 +------------------------- +- New small SFX module for installers (SfxSetup). + + +9.12 beta 2010-03-24 +------------------------- +- The BUG in LZMA SDK 9.* was fixed: LZMA2 codec didn't work, + if more than 10 threads were used (or more than 20 threads in some modes). + + +9.11 beta 2010-03-15 +------------------------- +- PPMd compression method support + + +9.09 2009-12-12 +------------------------- +- The bug was fixed: + Utf16_To_Utf8 funstions in UTFConvert.cpp and 7zMain.c + incorrectly converted surrogate characters (the code >= 0x10000) to UTF-8. +- Some bugs were fixed + + +9.06 2009-08-17 +------------------------- +- Some changes in ANSI-C 7z Decoder interfaces. + + +9.04 2009-05-30 +------------------------- +- LZMA2 compression method support +- xz format support + + +4.65 2009-02-03 +------------------------- +- Some minor fixes + + +4.63 2008-12-31 +------------------------- +- Some minor fixes + + +4.61 beta 2008-11-23 +------------------------- +- The bug in ANSI-C LZMA Decoder was fixed: + If encoded stream was corrupted, decoder could access memory + outside of allocated range. +- Some changes in ANSI-C 7z Decoder interfaces. +- LZMA SDK is placed in the public domain. + + +4.60 beta 2008-08-19 +------------------------- +- Some minor fixes. + + +4.59 beta 2008-08-13 +------------------------- +- The bug was fixed: + LZMA Encoder in fast compression mode could access memory outside of + allocated range in some rare cases. + + +4.58 beta 2008-05-05 +------------------------- +- ANSI-C LZMA Decoder was rewritten for speed optimizations. +- ANSI-C LZMA Encoder was included to LZMA SDK. +- C++ LZMA code now is just wrapper over ANSI-C code. + + +4.57 2007-12-12 +------------------------- +- Speed optimizations in Ñ++ LZMA Decoder. +- Small changes for more compatibility with some C/C++ compilers. + + +4.49 beta 2007-07-05 +------------------------- +- .7z ANSI-C Decoder: + - now it supports BCJ and BCJ2 filters + - now it supports files larger than 4 GB. + - now it supports "Last Write Time" field for files. +- C++ code for .7z archives compressing/decompressing from 7-zip + was included to LZMA SDK. + + +4.43 2006-06-04 +------------------------- +- Small changes for more compatibility with some C/C++ compilers. + + +4.42 2006-05-15 +------------------------- +- Small changes in .h files in ANSI-C version. + + +4.39 beta 2006-04-14 +------------------------- +- The bug in versions 4.33b:4.38b was fixed: + C++ version of LZMA encoder could not correctly compress + files larger than 2 GB with HC4 match finder (-mfhc4). + + +4.37 beta 2005-04-06 +------------------------- +- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. + + +4.35 beta 2005-03-02 +------------------------- +- The bug was fixed in C++ version of LZMA Decoder: + If encoded stream was corrupted, decoder could access memory + outside of allocated range. + + +4.34 beta 2006-02-27 +------------------------- +- Compressing speed and memory requirements for compressing were increased +- LZMA now can use only these match finders: HC4, BT2, BT3, BT4 + + +4.32 2005-12-09 +------------------------- +- Java version of LZMA SDK was included + + +4.30 2005-11-20 +------------------------- +- Compression ratio was improved in -a2 mode +- Speed optimizations for compressing in -a2 mode +- -fb switch now supports values up to 273 +- The bug in 7z_C (7zIn.c) was fixed: + It used Alloc/Free functions from different memory pools. + So if program used two memory pools, it worked incorrectly. +- 7z_C: .7z format supporting was improved +- LZMA# SDK (C#.NET version) was included + + +4.27 (Updated) 2005-09-21 +------------------------- +- Some GUIDs/interfaces in C++ were changed. + IStream.h: + ISequentialInStream::Read now works as old ReadPart + ISequentialOutStream::Write now works as old WritePart + + +4.27 2005-08-07 +------------------------- +- The bug in LzmaDecodeSize.c was fixed: + if _LZMA_IN_CB and _LZMA_OUT_READ were defined, + decompressing worked incorrectly. + + +4.26 2005-08-05 +------------------------- +- Fixes in 7z_C code and LzmaTest.c: + previous versions could work incorrectly, + if malloc(0) returns 0 + + +4.23 2005-06-29 +------------------------- +- Small fixes in C++ code + + +4.22 2005-06-10 +------------------------- +- Small fixes + + +4.21 2005-06-08 +------------------------- +- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed +- New additional version of ANSI-C LZMA Decoder with zlib-like interface: + - LzmaStateDecode.h + - LzmaStateDecode.c + - LzmaStateTest.c +- ANSI-C LZMA Decoder now can decompress files larger than 4 GB + + +4.17 2005-04-18 +------------------------- +- New example for RAM->RAM compressing/decompressing: + LZMA + BCJ (filter for x86 code): + - LzmaRam.h + - LzmaRam.cpp + - LzmaRamDecode.h + - LzmaRamDecode.c + - -f86 switch for lzma.exe + + +4.16 2005-03-29 +------------------------- +- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): + If _LZMA_OUT_READ was defined, and if encoded stream was corrupted, + decoder could access memory outside of allocated range. +- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster). + Old version of LZMA Decoder now is in file LzmaDecodeSize.c. + LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c +- Small speed optimization in LZMA C++ code +- filter for SPARC's code was added +- Simplified version of .7z ANSI-C Decoder was included + + +4.06 2004-09-05 +------------------------- +- The bug in v4.05 was fixed: + LZMA-Encoder didn't release output stream in some cases. + + +4.05 2004-08-25 +------------------------- +- Source code of filters for x86, IA-64, ARM, ARM-Thumb + and PowerPC code was included to SDK +- Some internal minor changes + + +4.04 2004-07-28 +------------------------- +- More compatibility with some C++ compilers + + +4.03 2004-06-18 +------------------------- +- "Benchmark" command was added. It measures compressing + and decompressing speed and shows rating values. + Also it checks hardware errors. + + +4.02 2004-06-10 +------------------------- +- C++ LZMA Encoder/Decoder code now is more portable + and it can be compiled by GCC on Linux. + + +4.01 2004-02-15 +------------------------- +- Some detection of data corruption was enabled. + LzmaDecode.c / RangeDecoderReadByte + ..... + { + rd->ExtraBytes = 1; + return 0xFF; + } + + +4.00 2004-02-13 +------------------------- +- Original version of LZMA SDK + + + +HISTORY of the LZMA +------------------- + 2001-2008: Improvements to LZMA compressing/decompressing code, + keeping compatibility with original LZMA format + 1996-2001: Development of LZMA compression format + + Some milestones: + + 2001-08-30: LZMA compression was added to 7-Zip + 1999-01-02: First version of 7-Zip was released + + +End of document diff --git a/deps/LZMA-SDK/DOC/lzma-sdk.txt b/deps/LZMA-SDK/DOC/lzma-sdk.txt index b11716938..ed1a431ee 100644 --- a/deps/LZMA-SDK/DOC/lzma-sdk.txt +++ b/deps/LZMA-SDK/DOC/lzma-sdk.txt @@ -1,357 +1,404 @@ -LZMA SDK 21.02 --------------- - -LZMA SDK provides the documentation, samples, header files, -libraries, and tools you need to develop applications that -use 7z / LZMA / LZMA2 / XZ compression. - -LZMA is an improved version of famous LZ77 compression algorithm. -It was improved in way of maximum increasing of compression ratio, -keeping high decompression speed and low memory requirements for -decompressing. - -LZMA2 is a LZMA based compression method. LZMA2 provides better -multithreading support for compression than LZMA and some other improvements. - -7z is a file format for data compression and file archiving. -7z is a main file format for 7-Zip compression program (www.7-zip.org). -7z format supports different compression methods: LZMA, LZMA2 and others. -7z also supports AES-256 based encryption. - -XZ is a file format for data compression that uses LZMA2 compression. -XZ format provides additional features: SHA/CRC check, filters for -improved compression ratio, splitting to blocks and streams, - - - -LICENSE -------- - -LZMA SDK is written and placed in the public domain by Igor Pavlov. - -Some code in LZMA SDK is based on public domain code from another developers: - 1) PPMd var.H (2001): Dmitry Shkarin - 2) SHA-256: Wei Dai (Crypto++ library) - -Anyone is free to copy, modify, publish, use, compile, sell, or distribute the -original LZMA SDK code, either in source code form or as a compiled binary, for -any purpose, commercial or non-commercial, and by any means. - -LZMA SDK code is compatible with open source licenses, for example, you can -include it to GNU GPL or GNU LGPL code. - - -LZMA SDK Contents ------------------ - - Source code: - - - C / C++ / C# / Java - LZMA compression and decompression - - C / C++ - LZMA2 compression and decompression - - C / C++ - XZ compression and decompression - - C - 7z decompression - - C++ - 7z compression and decompression - - C - small SFXs for installers (7z decompression) - - C++ - SFXs and SFXs for installers (7z decompression) - - Precomiled binaries: - - - console programs for lzma / 7z / xz compression and decompression - - SFX modules for installers. - - -UNIX/Linux version ------------------- -To compile C++ version of file->file LZMA encoding, go to directory -CPP/7zip/Bundles/LzmaCon -and call make to recompile it: - make -f makefile.gcc clean all - -In some UNIX/Linux versions you must compile LZMA with static libraries. -To compile with static libraries, you can use -LIB = -lm -static - -Also you can use p7zip (port of 7-Zip for POSIX systems like Unix or Linux): - - http://p7zip.sourceforge.net/ - - -Files ------ - -DOC/7zC.txt - 7z ANSI-C Decoder description -DOC/7zFormat.txt - 7z Format description -DOC/installer.txt - information about 7-Zip for installers -DOC/lzma.txt - LZMA compression description -DOC/lzma-sdk.txt - LZMA SDK description (this file) -DOC/lzma-history.txt - history of LZMA SDK -DOC/lzma-specification.txt - Specification of LZMA -DOC/Methods.txt - Compression method IDs for .7z - -bin/installer/ - example script to create installer that uses SFX module, - -bin/7zdec.exe - simplified 7z archive decoder -bin/7zr.exe - 7-Zip console program (reduced version) -bin/x64/7zr.exe - 7-Zip console program (reduced version) (x64 version) -bin/lzma.exe - file->file LZMA encoder/decoder for Windows -bin/7zS2.sfx - small SFX module for installers (GUI version) -bin/7zS2con.sfx - small SFX module for installers (Console version) -bin/7zSD.sfx - SFX module for installers. - - -7zDec.exe ---------- -7zDec.exe is simplified 7z archive decoder. -It supports only LZMA, LZMA2, and PPMd methods. -7zDec decodes whole solid block from 7z archive to RAM. -The RAM consumption can be high. - - - - -Source code structure ---------------------- - - -Asm/ - asm files (optimized code for CRC calculation and Intel-AES encryption) - -C/ - C files (compression / decompression and other) - Util/ - 7z - 7z decoder program (decoding 7z files) - Lzma - LZMA program (file->file LZMA encoder/decoder). - LzmaLib - LZMA library (.DLL for Windows) - SfxSetup - small SFX module for installers - -CPP/ -- CPP files - - Common - common files for C++ projects - Windows - common files for Windows related code - - 7zip - files related to 7-Zip - - Archive - files related to archiving - - Common - common files for archive handling - 7z - 7z C++ Encoder/Decoder - - Bundles - Modules that are bundles of other modules (files) - - Alone7z - 7zr.exe: Standalone 7-Zip console program (reduced version) - Format7zExtractR - 7zxr.dll: Reduced version of 7z DLL: extracting from 7z/LZMA/BCJ/BCJ2. - Format7zR - 7zr.dll: Reduced version of 7z DLL: extracting/compressing to 7z/LZMA/BCJ/BCJ2 - LzmaCon - lzma.exe: LZMA compression/decompression - LzmaSpec - example code for LZMA Specification - SFXCon - 7zCon.sfx: Console 7z SFX module - SFXSetup - 7zS.sfx: 7z SFX module for installers - SFXWin - 7z.sfx: GUI 7z SFX module - - Common - common files for 7-Zip - - Compress - files for compression/decompression - - Crypto - files for encryption / decompression - - UI - User Interface files - - Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll - Common - Common UI files - Console - Code for console program (7z.exe) - Explorer - Some code from 7-Zip Shell extension - FileManager - Some GUI code from 7-Zip File Manager - GUI - Some GUI code from 7-Zip - - -CS/ - C# files - 7zip - Common - some common files for 7-Zip - Compress - files related to compression/decompression - LZ - files related to LZ (Lempel-Ziv) compression algorithm - LZMA - LZMA compression/decompression - LzmaAlone - file->file LZMA compression/decompression - RangeCoder - Range Coder (special code of compression/decompression) - -Java/ - Java files - SevenZip - Compression - files related to compression/decompression - LZ - files related to LZ (Lempel-Ziv) compression algorithm - LZMA - LZMA compression/decompression - RangeCoder - Range Coder (special code of compression/decompression) - - -Note: - Asm / C / C++ source code of LZMA SDK is part of 7-Zip's source code. - 7-Zip's source code can be downloaded from 7-Zip's SourceForge page: - - http://sourceforge.net/projects/sevenzip/ - - - -LZMA features -------------- - - Variable dictionary size (up to 1 GB) - - Estimated compressing speed: about 2 MB/s on 2 GHz CPU - - Estimated decompressing speed: - - 20-30 MB/s on modern 2 GHz cpu - - 1-2 MB/s on 200 MHz simple RISC cpu: (ARM, MIPS, PowerPC) - - Small memory requirements for decompressing (16 KB + DictionarySize) - - Small code size for decompressing: 5-8 KB - -LZMA decoder uses only integer operations and can be -implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions). - -Some critical operations that affect the speed of LZMA decompression: - 1) 32*16 bit integer multiply - 2) Mispredicted branches (penalty mostly depends from pipeline length) - 3) 32-bit shift and arithmetic operations - -The speed of LZMA decompressing mostly depends from CPU speed. -Memory speed has no big meaning. But if your CPU has small data cache, -overall weight of memory speed will slightly increase. - - -How To Use ----------- - -Using LZMA encoder/decoder executable --------------------------------------- - -Usage: LZMA inputFile outputFile [...] - - e: encode file - - d: decode file - - b: Benchmark. There are two tests: compressing and decompressing - with LZMA method. Benchmark shows rating in MIPS (million - instructions per second). Rating value is calculated from - measured speed and it is normalized with Intel's Core 2 results. - Also Benchmark checks possible hardware errors (RAM - errors in most cases). Benchmark uses these settings: - (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter. - Also you can change the number of iterations. Example for 30 iterations: - LZMA b 30 - Default number of iterations is 10. - - - - - -a{N}: set compression mode 0 = fast, 1 = normal - default: 1 (normal) - - d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB) - The maximum value for dictionary size is 1 GB = 2^30 bytes. - Dictionary size is calculated as DictionarySize = 2^N bytes. - For decompressing file compressed by LZMA method with dictionary - size D = 2^N you need about D bytes of memory (RAM). - - -fb{N}: set number of fast bytes - [5, 273], default: 128 - Usually big number gives a little bit better compression ratio - and slower compression process. - - -lc{N}: set number of literal context bits - [0, 8], default: 3 - Sometimes lc=4 gives gain for big files. - - -lp{N}: set number of literal pos bits - [0, 4], default: 0 - lp switch is intended for periodical data when period is - equal 2^N. For example, for 32-bit (4 bytes) - periodical data you can use lp=2. Often it's better to set lc0, - if you change lp switch. - - -pb{N}: set number of pos bits - [0, 4], default: 2 - pb switch is intended for periodical data - when period is equal 2^N. - - -mf{MF_ID}: set Match Finder. Default: bt4. - Algorithms from hc* group doesn't provide good compression - ratio, but they often works pretty fast in combination with - fast mode (-a0). - - Memory requirements depend from dictionary size - (parameter "d" in table below). - - MF_ID Memory Description - - bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing. - bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing. - bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing. - hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing. - - -eos: write End Of Stream marker. By default LZMA doesn't write - eos marker, since LZMA decoder knows uncompressed size - stored in .lzma file header. - - -si: Read data from stdin (it will write End Of Stream marker). - -so: Write data to stdout - - -Examples: - -1) LZMA e file.bin file.lzma -d16 -lc0 - -compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K) -and 0 literal context bits. -lc0 allows to reduce memory requirements -for decompression. - - -2) LZMA e file.bin file.lzma -lc0 -lp2 - -compresses file.bin to file.lzma with settings suitable -for 32-bit periodical data (for example, ARM or MIPS code). - -3) LZMA d file.lzma file.bin - -decompresses file.lzma to file.bin. - - -Compression ratio hints ------------------------ - -Recommendations ---------------- - -To increase the compression ratio for LZMA compressing it's desirable -to have aligned data (if it's possible) and also it's desirable to locate -data in such order, where code is grouped in one place and data is -grouped in other place (it's better than such mixing: code, data, code, -data, ...). - - -Filters -------- -You can increase the compression ratio for some data types, using -special filters before compressing. For example, it's possible to -increase the compression ratio on 5-10% for code for those CPU ISAs: -x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC. - -You can find C source code of such filters in C/Bra*.* files - -You can check the compression ratio gain of these filters with such -7-Zip commands (example for ARM code): -No filter: - 7z a a1.7z a.bin -m0=lzma - -With filter for little-endian ARM code: - 7z a a2.7z a.bin -m0=arm -m1=lzma - -It works in such manner: -Compressing = Filter_encoding + LZMA_encoding -Decompressing = LZMA_decoding + Filter_decoding - -Compressing and decompressing speed of such filters is very high, -so it will not increase decompressing time too much. -Moreover, it reduces decompression time for LZMA_decoding, -since compression ratio with filtering is higher. - -These filters convert CALL (calling procedure) instructions -from relative offsets to absolute addresses, so such data becomes more -compressible. - -For some ISAs (for example, for MIPS) it's impossible to get gain from such filter. - - - ---- - -http://www.7-zip.org -http://www.7-zip.org/sdk.html -http://www.7-zip.org/support.html +LZMA SDK 22.01 +-------------- + +LZMA SDK provides the documentation, samples, header files, +libraries, and tools you need to develop applications that +use 7z / LZMA / LZMA2 / XZ compression. + +LZMA is an improved version of famous LZ77 compression algorithm. +It was improved in way of maximum increasing of compression ratio, +keeping high decompression speed and low memory requirements for +decompressing. + +LZMA2 is a LZMA based compression method. LZMA2 provides better +multithreading support for compression than LZMA and some other improvements. + +7z is a file format for data compression and file archiving. +7z is a main file format for 7-Zip compression program (www.7-zip.org). +7z format supports different compression methods: LZMA, LZMA2 and others. +7z also supports AES-256 based encryption. + +XZ is a file format for data compression that uses LZMA2 compression. +XZ format provides additional features: SHA/CRC check, filters for +improved compression ratio, splitting to blocks and streams, + + + +LICENSE +------- + +LZMA SDK is written and placed in the public domain by Igor Pavlov. + +Some code in LZMA SDK is based on public domain code from another developers: + 1) PPMd var.H (2001): Dmitry Shkarin + 2) SHA-256: Wei Dai (Crypto++ library) + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute the +original LZMA SDK code, either in source code form or as a compiled binary, for +any purpose, commercial or non-commercial, and by any means. + +LZMA SDK code is compatible with open source licenses, for example, you can +include it to GNU GPL or GNU LGPL code. + + +LZMA SDK Contents +----------------- + + Source code: + + - C / C++ / C# / Java - LZMA compression and decompression + - C / C++ - LZMA2 compression and decompression + - C / C++ - XZ compression and decompression + - C - 7z decompression + - C++ - 7z compression and decompression + - C - small SFXs for installers (7z decompression) + - C++ - SFXs and SFXs for installers (7z decompression) + + Precomiled binaries: + + - console programs for lzma / 7z / xz compression and decompression + - SFX modules for installers. + + +UNIX/Linux version +------------------ +There are several otpions to compile 7-Zip with different compilers: gcc and clang. +Also 7-Zip code contains two versions for some critical parts of code: in C and in Assembeler. +So if you compile the version with Assembeler code, you will get faster 7-Zip binary. + +7-Zip's assembler code uses the following syntax for different platforms: + +1) x86 and x86-64 (AMD64): MASM syntax. + There are 2 programs that supports MASM syntax in Linux. +' 'Asmc Macro Assembler and JWasm. But JWasm now doesn't support some + cpu instructions used in 7-Zip. + So you must install Asmc Macro Assembler in Linux, if you want to compile fastest version + of 7-Zip x86 and x86-64: + https://github.com/nidud/asmc + +2) arm64: GNU assembler for ARM64 with preprocessor. + That systax of that arm64 assembler code in 7-Zip is supported by GCC and CLANG for ARM64. + +There are different binaries that can be compiled from 7-Zip source. +There are 2 main files in folder for compiling: + makefile - that can be used for compiling Windows version of 7-Zip with nmake command + makefile.gcc - that can be used for compiling Linux/macOS versions of 7-Zip with make command + +At first you must change the current folder to folder that contains `makefile.gcc`: + + cd CPP/7zip/Bundles/Alone7z + +Then you can compile `makefile.gcc` with the command: + + make -j -f makefile.gcc + +Also there are additional "*.mak" files in folder "CPP/7zip/" that can be used to compile +7-Zip binaries with optimized code and optimzing options. + +To compile with GCC without assembler: + cd CPP/7zip/Bundles/Alone7z + make -j -f ../../cmpl_gcc.mak + +To compile with CLANG without assembler: + make -j -f ../../cmpl_clang.mak + +To compile 7-Zip for x86-64 with asmc assembler: + make -j -f ../../cmpl_gcc_x64.mak + +To compile 7-Zip for arm64 with assembler: + make -j -f ../../cmpl_gcc_arm64.mak + +To compile 7-Zip for arm64 for macOS: + make -j -f ../../cmpl_mac_arm64.mak + +Also you can change some compiler options in the mak files: + cmpl_gcc.mak + var_gcc.mak + warn_gcc.mak + + + +Also you can use p7zip (port of 7-Zip for POSIX systems like Unix or Linux): + + http://p7zip.sourceforge.net/ + + +Files +----- + +DOC/7zC.txt - 7z ANSI-C Decoder description +DOC/7zFormat.txt - 7z Format description +DOC/installer.txt - information about 7-Zip for installers +DOC/lzma.txt - LZMA compression description +DOC/lzma-sdk.txt - LZMA SDK description (this file) +DOC/lzma-history.txt - history of LZMA SDK +DOC/lzma-specification.txt - Specification of LZMA +DOC/Methods.txt - Compression method IDs for .7z + +bin/installer/ - example script to create installer that uses SFX module, + +bin/7zdec.exe - simplified 7z archive decoder +bin/7zr.exe - 7-Zip console program (reduced version) +bin/x64/7zr.exe - 7-Zip console program (reduced version) (x64 version) +bin/lzma.exe - file->file LZMA encoder/decoder for Windows +bin/7zS2.sfx - small SFX module for installers (GUI version) +bin/7zS2con.sfx - small SFX module for installers (Console version) +bin/7zSD.sfx - SFX module for installers. + + +7zDec.exe +--------- +7zDec.exe is simplified 7z archive decoder. +It supports only LZMA, LZMA2, and PPMd methods. +7zDec decodes whole solid block from 7z archive to RAM. +The RAM consumption can be high. + + + + +Source code structure +--------------------- + + +Asm/ - asm files (optimized code for CRC calculation and Intel-AES encryption) + +C/ - C files (compression / decompression and other) + Util/ + 7z - 7z decoder program (decoding 7z files) + Lzma - LZMA program (file->file LZMA encoder/decoder). + LzmaLib - LZMA library (.DLL for Windows) + SfxSetup - small SFX module for installers + +CPP/ -- CPP files + + Common - common files for C++ projects + Windows - common files for Windows related code + + 7zip - files related to 7-Zip + + Archive - files related to archiving + + Common - common files for archive handling + 7z - 7z C++ Encoder/Decoder + + Bundles - Modules that are bundles of other modules (files) + + Alone7z - 7zr.exe: Standalone 7-Zip console program (reduced version) + Format7zExtractR - 7zxr.dll: Reduced version of 7z DLL: extracting from 7z/LZMA/BCJ/BCJ2. + Format7zR - 7zr.dll: Reduced version of 7z DLL: extracting/compressing to 7z/LZMA/BCJ/BCJ2 + LzmaCon - lzma.exe: LZMA compression/decompression + LzmaSpec - example code for LZMA Specification + SFXCon - 7zCon.sfx: Console 7z SFX module + SFXSetup - 7zS.sfx: 7z SFX module for installers + SFXWin - 7z.sfx: GUI 7z SFX module + + Common - common files for 7-Zip + + Compress - files for compression/decompression + + Crypto - files for encryption / decompression + + UI - User Interface files + + Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll + Common - Common UI files + Console - Code for console program (7z.exe) + Explorer - Some code from 7-Zip Shell extension + FileManager - Some GUI code from 7-Zip File Manager + GUI - Some GUI code from 7-Zip + + +CS/ - C# files + 7zip + Common - some common files for 7-Zip + Compress - files related to compression/decompression + LZ - files related to LZ (Lempel-Ziv) compression algorithm + LZMA - LZMA compression/decompression + LzmaAlone - file->file LZMA compression/decompression + RangeCoder - Range Coder (special code of compression/decompression) + +Java/ - Java files + SevenZip + Compression - files related to compression/decompression + LZ - files related to LZ (Lempel-Ziv) compression algorithm + LZMA - LZMA compression/decompression + RangeCoder - Range Coder (special code of compression/decompression) + + +Note: + Asm / C / C++ source code of LZMA SDK is part of 7-Zip's source code. + 7-Zip's source code can be downloaded from 7-Zip's SourceForge page: + + http://sourceforge.net/projects/sevenzip/ + + + +LZMA features +------------- + - Variable dictionary size (up to 1 GB) + - Estimated compressing speed: about 2 MB/s on 2 GHz CPU + - Estimated decompressing speed: + - 20-30 MB/s on modern 2 GHz cpu + - 1-2 MB/s on 200 MHz simple RISC cpu: (ARM, MIPS, PowerPC) + - Small memory requirements for decompressing (16 KB + DictionarySize) + - Small code size for decompressing: 5-8 KB + +LZMA decoder uses only integer operations and can be +implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions). + +Some critical operations that affect the speed of LZMA decompression: + 1) 32*16 bit integer multiply + 2) Mispredicted branches (penalty mostly depends from pipeline length) + 3) 32-bit shift and arithmetic operations + +The speed of LZMA decompressing mostly depends from CPU speed. +Memory speed has no big meaning. But if your CPU has small data cache, +overall weight of memory speed will slightly increase. + + +How To Use +---------- + +Using LZMA encoder/decoder executable +-------------------------------------- + +Usage: LZMA inputFile outputFile [...] + + e: encode file + + d: decode file + + b: Benchmark. There are two tests: compressing and decompressing + with LZMA method. Benchmark shows rating in MIPS (million + instructions per second). Rating value is calculated from + measured speed and it is normalized with Intel's Core 2 results. + Also Benchmark checks possible hardware errors (RAM + errors in most cases). Benchmark uses these settings: + (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter. + Also you can change the number of iterations. Example for 30 iterations: + LZMA b 30 + Default number of iterations is 10. + + + + + -a{N}: set compression mode 0 = fast, 1 = normal + default: 1 (normal) + + d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB) + The maximum value for dictionary size is 1 GB = 2^30 bytes. + Dictionary size is calculated as DictionarySize = 2^N bytes. + For decompressing file compressed by LZMA method with dictionary + size D = 2^N you need about D bytes of memory (RAM). + + -fb{N}: set number of fast bytes - [5, 273], default: 128 + Usually big number gives a little bit better compression ratio + and slower compression process. + + -lc{N}: set number of literal context bits - [0, 8], default: 3 + Sometimes lc=4 gives gain for big files. + + -lp{N}: set number of literal pos bits - [0, 4], default: 0 + lp switch is intended for periodical data when period is + equal 2^N. For example, for 32-bit (4 bytes) + periodical data you can use lp=2. Often it's better to set lc0, + if you change lp switch. + + -pb{N}: set number of pos bits - [0, 4], default: 2 + pb switch is intended for periodical data + when period is equal 2^N. + + -mf{MF_ID}: set Match Finder. Default: bt4. + Algorithms from hc* group doesn't provide good compression + ratio, but they often works pretty fast in combination with + fast mode (-a0). + + Memory requirements depend from dictionary size + (parameter "d" in table below). + + MF_ID Memory Description + + bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing. + bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing. + bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing. + hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing. + + -eos: write End Of Stream marker. By default LZMA doesn't write + eos marker, since LZMA decoder knows uncompressed size + stored in .lzma file header. + + -si: Read data from stdin (it will write End Of Stream marker). + -so: Write data to stdout + + +Examples: + +1) LZMA e file.bin file.lzma -d16 -lc0 + +compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K) +and 0 literal context bits. -lc0 allows to reduce memory requirements +for decompression. + + +2) LZMA e file.bin file.lzma -lc0 -lp2 + +compresses file.bin to file.lzma with settings suitable +for 32-bit periodical data (for example, ARM or MIPS code). + +3) LZMA d file.lzma file.bin + +decompresses file.lzma to file.bin. + + +Compression ratio hints +----------------------- + +Recommendations +--------------- + +To increase the compression ratio for LZMA compressing it's desirable +to have aligned data (if it's possible) and also it's desirable to locate +data in such order, where code is grouped in one place and data is +grouped in other place (it's better than such mixing: code, data, code, +data, ...). + + +Filters +------- +You can increase the compression ratio for some data types, using +special filters before compressing. For example, it's possible to +increase the compression ratio on 5-10% for code for those CPU ISAs: +x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC. + +You can find C source code of such filters in C/Bra*.* files + +You can check the compression ratio gain of these filters with such +7-Zip commands (example for ARM code): +No filter: + 7z a a1.7z a.bin -m0=lzma + +With filter for little-endian ARM code: + 7z a a2.7z a.bin -m0=arm -m1=lzma + +It works in such manner: +Compressing = Filter_encoding + LZMA_encoding +Decompressing = LZMA_decoding + Filter_decoding + +Compressing and decompressing speed of such filters is very high, +so it will not increase decompressing time too much. +Moreover, it reduces decompression time for LZMA_decoding, +since compression ratio with filtering is higher. + +These filters convert CALL (calling procedure) instructions +from relative offsets to absolute addresses, so such data becomes more +compressible. + +For some ISAs (for example, for MIPS) it's impossible to get gain from such filter. + + + +--- + +http://www.7-zip.org +http://www.7-zip.org/sdk.html +http://www.7-zip.org/support.html diff --git a/deps/LZMA-SDK/DOC/lzma-specification.txt b/deps/LZMA-SDK/DOC/lzma-specification.txt index b6796df75..ac0cce76a 100644 --- a/deps/LZMA-SDK/DOC/lzma-specification.txt +++ b/deps/LZMA-SDK/DOC/lzma-specification.txt @@ -1,1176 +1,1176 @@ -LZMA specification (DRAFT version) ----------------------------------- - -Author: Igor Pavlov -Date: 2015-06-14 - -This specification defines the format of LZMA compressed data and lzma file format. - -Notation --------- - -We use the syntax of C++ programming language. -We use the following types in C++ code: - unsigned - unsigned integer, at least 16 bits in size - int - signed integer, at least 16 bits in size - UInt64 - 64-bit unsigned integer - UInt32 - 32-bit unsigned integer - UInt16 - 16-bit unsigned integer - Byte - 8-bit unsigned integer - bool - boolean type with two possible values: false, true - - -lzma file format -================ - -The lzma file contains the raw LZMA stream and the header with related properties. - -The files in that format use ".lzma" extension. - -The lzma file format layout: - -Offset Size Description - - 0 1 LZMA model properties (lc, lp, pb) in encoded form - 1 4 Dictionary size (32-bit unsigned integer, little-endian) - 5 8 Uncompressed size (64-bit unsigned integer, little-endian) - 13 Compressed data (LZMA stream) - -LZMA properties: - - name Range Description - - lc [0, 8] the number of "literal context" bits - lp [0, 4] the number of "literal pos" bits - pb [0, 4] the number of "pos" bits -dictSize [0, 2^32 - 1] the dictionary size - -The following code encodes LZMA properties: - -void EncodeProperties(Byte *properties) -{ - properties[0] = (Byte)((pb * 5 + lp) * 9 + lc); - Set_UInt32_LittleEndian(properties + 1, dictSize); -} - -If the value of dictionary size in properties is smaller than (1 << 12), -the LZMA decoder must set the dictionary size variable to (1 << 12). - -#define LZMA_DIC_MIN (1 << 12) - - unsigned lc, pb, lp; - UInt32 dictSize; - UInt32 dictSizeInProperties; - - void DecodeProperties(const Byte *properties) - { - unsigned d = properties[0]; - if (d >= (9 * 5 * 5)) - throw "Incorrect LZMA properties"; - lc = d % 9; - d /= 9; - pb = d / 5; - lp = d % 5; - dictSizeInProperties = 0; - for (int i = 0; i < 4; i++) - dictSizeInProperties |= (UInt32)properties[i + 1] << (8 * i); - dictSize = dictSizeInProperties; - if (dictSize < LZMA_DIC_MIN) - dictSize = LZMA_DIC_MIN; - } - -If "Uncompressed size" field contains ones in all 64 bits, it means that -uncompressed size is unknown and there is the "end marker" in stream, -that indicates the end of decoding point. -In opposite case, if the value from "Uncompressed size" field is not -equal to ((2^64) - 1), the LZMA stream decoding must be finished after -specified number of bytes (Uncompressed size) is decoded. And if there -is the "end marker", the LZMA decoder must read that marker also. - - -The new scheme to encode LZMA properties ----------------------------------------- - -If LZMA compression is used for some another format, it's recommended to -use a new improved scheme to encode LZMA properties. That new scheme was -used in xz format that uses the LZMA2 compression algorithm. -The LZMA2 is a new compression algorithm that is based on the LZMA algorithm. - -The dictionary size in LZMA2 is encoded with just one byte and LZMA2 supports -only reduced set of dictionary sizes: - (2 << 11), (3 << 11), - (2 << 12), (3 << 12), - ... - (2 << 30), (3 << 30), - (2 << 31) - 1 - -The dictionary size can be extracted from encoded value with the following code: - - dictSize = (p == 40) ? 0xFFFFFFFF : (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)); - -Also there is additional limitation (lc + lp <= 4) in LZMA2 for values of -"lc" and "lp" properties: - - if (lc + lp > 4) - throw "Unsupported properties: (lc + lp) > 4"; - -There are some advantages for LZMA decoder with such (lc + lp) value -limitation. It reduces the maximum size of tables allocated by decoder. -And it reduces the complexity of initialization procedure, that can be -important to keep high speed of decoding of big number of small LZMA streams. - -It's recommended to use that limitation (lc + lp <= 4) for any new format -that uses LZMA compression. Note that the combinations of "lc" and "lp" -parameters, where (lc + lp > 4), can provide significant improvement in -compression ratio only in some rare cases. - -The LZMA properties can be encoded into two bytes in new scheme: - -Offset Size Description - - 0 1 The dictionary size encoded with LZMA2 scheme - 1 1 LZMA model properties (lc, lp, pb) in encoded form - - -The RAM usage -============= - -The RAM usage for LZMA decoder is determined by the following parts: - -1) The Sliding Window (from 4 KiB to 4 GiB). -2) The probability model counter arrays (arrays of 16-bit variables). -3) Some additional state variables (about 10 variables of 32-bit integers). - - -The RAM usage for Sliding Window --------------------------------- - -There are two main scenarios of decoding: - -1) The decoding of full stream to one RAM buffer. - - If we decode full LZMA stream to one output buffer in RAM, the decoder - can use that output buffer as sliding window. So the decoder doesn't - need additional buffer allocated for sliding window. - -2) The decoding to some external storage. - - If we decode LZMA stream to external storage, the decoder must allocate - the buffer for sliding window. The size of that buffer must be equal - or larger than the value of dictionary size from properties of LZMA stream. - -In this specification we describe the code for decoding to some external -storage. The optimized version of code for decoding of full stream to one -output RAM buffer can require some minor changes in code. - - -The RAM usage for the probability model counters ------------------------------------------------- - -The size of the probability model counter arrays is calculated with the -following formula: - -size_of_prob_arrays = 1846 + 768 * (1 << (lp + lc)) - -Each probability model counter is 11-bit unsigned integer. -If we use 16-bit integer variables (2-byte integers) for these probability -model counters, the RAM usage required by probability model counter arrays -can be estimated with the following formula: - - RAM = 4 KiB + 1.5 KiB * (1 << (lp + lc)) - -For example, for default LZMA parameters (lp = 0 and lc = 3), the RAM usage is - - RAM_lc3_lp0 = 4 KiB + 1.5 KiB * 8 = 16 KiB - -The maximum RAM state usage is required for decoding the stream with lp = 4 -and lc = 8: - - RAM_lc8_lp4 = 4 KiB + 1.5 KiB * 4096 = 6148 KiB - -If the decoder uses LZMA2's limited property condition -(lc + lp <= 4), the RAM usage will be not larger than - - RAM_lc_lp_4 = 4 KiB + 1.5 KiB * 16 = 28 KiB - - -The RAM usage for encoder -------------------------- - -There are many variants for LZMA encoding code. -These variants have different values for memory consumption. -Note that memory consumption for LZMA Encoder can not be -smaller than memory consumption of LZMA Decoder for same stream. - -The RAM usage required by modern effective implementation of -LZMA Encoder can be estimated with the following formula: - - Encoder_RAM_Usage = 4 MiB + 11 * dictionarySize. - -But there are some modes of the encoder that require less memory. - - -LZMA Decoding -============= - -The LZMA compression algorithm uses LZ-based compression with Sliding Window -and Range Encoding as entropy coding method. - - -Sliding Window --------------- - -LZMA uses Sliding Window compression similar to LZ77 algorithm. - -LZMA stream must be decoded to the sequence that consists -of MATCHES and LITERALS: - - - a LITERAL is a 8-bit character (one byte). - The decoder just puts that LITERAL to the uncompressed stream. - - - a MATCH is a pair of two numbers (DISTANCE-LENGTH pair). - The decoder takes one byte exactly "DISTANCE" characters behind - current position in the uncompressed stream and puts it to - uncompressed stream. The decoder must repeat it "LENGTH" times. - -The "DISTANCE" can not be larger than dictionary size. -And the "DISTANCE" can not be larger than the number of bytes in -the uncompressed stream that were decoded before that match. - -In this specification we use cyclic buffer to implement Sliding Window -for LZMA decoder: - -class COutWindow -{ - Byte *Buf; - UInt32 Pos; - UInt32 Size; - bool IsFull; - -public: - unsigned TotalPos; - COutStream OutStream; - - COutWindow(): Buf(NULL) {} - ~COutWindow() { delete []Buf; } - - void Create(UInt32 dictSize) - { - Buf = new Byte[dictSize]; - Pos = 0; - Size = dictSize; - IsFull = false; - TotalPos = 0; - } - - void PutByte(Byte b) - { - TotalPos++; - Buf[Pos++] = b; - if (Pos == Size) - { - Pos = 0; - IsFull = true; - } - OutStream.WriteByte(b); - } - - Byte GetByte(UInt32 dist) const - { - return Buf[dist <= Pos ? Pos - dist : Size - dist + Pos]; - } - - void CopyMatch(UInt32 dist, unsigned len) - { - for (; len > 0; len--) - PutByte(GetByte(dist)); - } - - bool CheckDistance(UInt32 dist) const - { - return dist <= Pos || IsFull; - } - - bool IsEmpty() const - { - return Pos == 0 && !IsFull; - } -}; - - -In another implementation it's possible to use one buffer that contains -Sliding Window and the whole data stream after uncompressing. - - -Range Decoder -------------- - -LZMA algorithm uses Range Encoding (1) as entropy coding method. - -LZMA stream contains just one very big number in big-endian encoding. -LZMA decoder uses the Range Decoder to extract a sequence of binary -symbols from that big number. - -The state of the Range Decoder: - -struct CRangeDecoder -{ - UInt32 Range; - UInt32 Code; - InputStream *InStream; - - bool Corrupted; -} - -The notes about UInt32 type for the "Range" and "Code" variables: - - It's possible to use 64-bit (unsigned or signed) integer type - for the "Range" and the "Code" variables instead of 32-bit unsigned, - but some additional code must be used to truncate the values to - low 32-bits after some operations. - - If the programming language does not support 32-bit unsigned integer type - (like in case of JAVA language), it's possible to use 32-bit signed integer, - but some code must be changed. For example, it's required to change the code - that uses comparison operations for UInt32 variables in this specification. - -The Range Decoder can be in some states that can be treated as -"Corruption" in LZMA stream. The Range Decoder uses the variable "Corrupted": - - (Corrupted == false), if the Range Decoder has not detected any corruption. - (Corrupted == true), if the Range Decoder has detected some corruption. - -The reference LZMA Decoder ignores the value of the "Corrupted" variable. -So it continues to decode the stream, even if the corruption can be detected -in the Range Decoder. To provide the full compatibility with output of the -reference LZMA Decoder, another LZMA Decoder implementations must also -ignore the value of the "Corrupted" variable. - -The LZMA Encoder is required to create only such LZMA streams, that will not -lead the Range Decoder to states, where the "Corrupted" variable is set to true. - -The Range Decoder reads first 5 bytes from input stream to initialize -the state: - -bool CRangeDecoder::Init() -{ - Corrupted = false; - Range = 0xFFFFFFFF; - Code = 0; - - Byte b = InStream->ReadByte(); - - for (int i = 0; i < 4; i++) - Code = (Code << 8) | InStream->ReadByte(); - - if (b != 0 || Code == Range) - Corrupted = true; - return b == 0; -} - -The LZMA Encoder always writes ZERO in initial byte of compressed stream. -That scheme allows to simplify the code of the Range Encoder in the -LZMA Encoder. If initial byte is not equal to ZERO, the LZMA Decoder must -stop decoding and report error. - -After the last bit of data was decoded by Range Decoder, the value of the -"Code" variable must be equal to 0. The LZMA Decoder must check it by -calling the IsFinishedOK() function: - - bool IsFinishedOK() const { return Code == 0; } - -If there is corruption in data stream, there is big probability that -the "Code" value will be not equal to 0 in the Finish() function. So that -check in the IsFinishedOK() function provides very good feature for -corruption detection. - -The value of the "Range" variable before each bit decoding can not be smaller -than ((UInt32)1 << 24). The Normalize() function keeps the "Range" value in -described range. - -#define kTopValue ((UInt32)1 << 24) - -void CRangeDecoder::Normalize() -{ - if (Range < kTopValue) - { - Range <<= 8; - Code = (Code << 8) | InStream->ReadByte(); - } -} - -Notes: if the size of the "Code" variable is larger than 32 bits, it's -required to keep only low 32 bits of the "Code" variable after the change -in Normalize() function. - -If the LZMA Stream is not corrupted, the value of the "Code" variable is -always smaller than value of the "Range" variable. -But the Range Decoder ignores some types of corruptions, so the value of -the "Code" variable can be equal or larger than value of the "Range" variable -for some "Corrupted" archives. - - -LZMA uses Range Encoding only with binary symbols of two types: - 1) binary symbols with fixed and equal probabilities (direct bits) - 2) binary symbols with predicted probabilities - -The DecodeDirectBits() function decodes the sequence of direct bits: - -UInt32 CRangeDecoder::DecodeDirectBits(unsigned numBits) -{ - UInt32 res = 0; - do - { - Range >>= 1; - Code -= Range; - UInt32 t = 0 - ((UInt32)Code >> 31); - Code += Range & t; - - if (Code == Range) - Corrupted = true; - - Normalize(); - res <<= 1; - res += t + 1; - } - while (--numBits); - return res; -} - - -The Bit Decoding with Probability Model ---------------------------------------- - -The task of Bit Probability Model is to estimate probabilities of binary -symbols. And then it provides the Range Decoder with that information. -The better prediction provides better compression ratio. -The Bit Probability Model uses statistical data of previous decoded -symbols. - -That estimated probability is presented as 11-bit unsigned integer value -that represents the probability of symbol "0". - -#define kNumBitModelTotalBits 11 - -Mathematical probabilities can be presented with the following formulas: - probability(symbol_0) = prob / 2048. - probability(symbol_1) = 1 - Probability(symbol_0) = - = 1 - prob / 2048 = - = (2048 - prob) / 2048 -where the "prob" variable contains 11-bit integer probability counter. - -It's recommended to use 16-bit unsigned integer type, to store these 11-bit -probability values: - -typedef UInt16 CProb; - -Each probability value must be initialized with value ((1 << 11) / 2), -that represents the state, where probabilities of symbols 0 and 1 -are equal to 0.5: - -#define PROB_INIT_VAL ((1 << kNumBitModelTotalBits) / 2) - -The INIT_PROBS macro is used to initialize the array of CProb variables: - -#define INIT_PROBS(p) \ - { for (unsigned i = 0; i < sizeof(p) / sizeof(p[0]); i++) p[i] = PROB_INIT_VAL; } - - -The DecodeBit() function decodes one bit. -The LZMA decoder provides the pointer to CProb variable that contains -information about estimated probability for symbol 0 and the Range Decoder -updates that CProb variable after decoding. The Range Decoder increases -estimated probability of the symbol that was decoded: - -#define kNumMoveBits 5 - -unsigned CRangeDecoder::DecodeBit(CProb *prob) -{ - unsigned v = *prob; - UInt32 bound = (Range >> kNumBitModelTotalBits) * v; - unsigned symbol; - if (Code < bound) - { - v += ((1 << kNumBitModelTotalBits) - v) >> kNumMoveBits; - Range = bound; - symbol = 0; - } - else - { - v -= v >> kNumMoveBits; - Code -= bound; - Range -= bound; - symbol = 1; - } - *prob = (CProb)v; - Normalize(); - return symbol; -} - - -The Binary Tree of bit model counters -------------------------------------- - -LZMA uses a tree of Bit model variables to decode symbol that needs -several bits for storing. There are two versions of such trees in LZMA: - 1) the tree that decodes bits from high bit to low bit (the normal scheme). - 2) the tree that decodes bits from low bit to high bit (the reverse scheme). - -Each binary tree structure supports different size of decoded symbol -(the size of binary sequence that contains value of symbol). -If that size of decoded symbol is "NumBits" bits, the tree structure -uses the array of (2 << NumBits) counters of CProb type. -But only ((2 << NumBits) - 1) items are used by encoder and decoder. -The first item (the item with index equal to 0) in array is unused. -That scheme with unused array's item allows to simplify the code. - -unsigned BitTreeReverseDecode(CProb *probs, unsigned numBits, CRangeDecoder *rc) -{ - unsigned m = 1; - unsigned symbol = 0; - for (unsigned i = 0; i < numBits; i++) - { - unsigned bit = rc->DecodeBit(&probs[m]); - m <<= 1; - m += bit; - symbol |= (bit << i); - } - return symbol; -} - -template -class CBitTreeDecoder -{ - CProb Probs[(unsigned)1 << NumBits]; - -public: - - void Init() - { - INIT_PROBS(Probs); - } - - unsigned Decode(CRangeDecoder *rc) - { - unsigned m = 1; - for (unsigned i = 0; i < NumBits; i++) - m = (m << 1) + rc->DecodeBit(&Probs[m]); - return m - ((unsigned)1 << NumBits); - } - - unsigned ReverseDecode(CRangeDecoder *rc) - { - return BitTreeReverseDecode(Probs, NumBits, rc); - } -}; - - -LZ part of LZMA ---------------- - -LZ part of LZMA describes details about the decoding of MATCHES and LITERALS. - - -The Literal Decoding --------------------- - -The LZMA Decoder uses (1 << (lc + lp)) tables with CProb values, where -each table contains 0x300 CProb values: - - CProb *LitProbs; - - void CreateLiterals() - { - LitProbs = new CProb[(UInt32)0x300 << (lc + lp)]; - } - - void InitLiterals() - { - UInt32 num = (UInt32)0x300 << (lc + lp); - for (UInt32 i = 0; i < num; i++) - LitProbs[i] = PROB_INIT_VAL; - } - -To select the table for decoding it uses the context that consists of -(lc) high bits from previous literal and (lp) low bits from value that -represents current position in outputStream. - -If (State > 7), the Literal Decoder also uses "matchByte" that represents -the byte in OutputStream at position the is the DISTANCE bytes before -current position, where the DISTANCE is the distance in DISTANCE-LENGTH pair -of latest decoded match. - -The following code decodes one literal and puts it to Sliding Window buffer: - - void DecodeLiteral(unsigned state, UInt32 rep0) - { - unsigned prevByte = 0; - if (!OutWindow.IsEmpty()) - prevByte = OutWindow.GetByte(1); - - unsigned symbol = 1; - unsigned litState = ((OutWindow.TotalPos & ((1 << lp) - 1)) << lc) + (prevByte >> (8 - lc)); - CProb *probs = &LitProbs[(UInt32)0x300 * litState]; - - if (state >= 7) - { - unsigned matchByte = OutWindow.GetByte(rep0 + 1); - do - { - unsigned matchBit = (matchByte >> 7) & 1; - matchByte <<= 1; - unsigned bit = RangeDec.DecodeBit(&probs[((1 + matchBit) << 8) + symbol]); - symbol = (symbol << 1) | bit; - if (matchBit != bit) - break; - } - while (symbol < 0x100); - } - while (symbol < 0x100) - symbol = (symbol << 1) | RangeDec.DecodeBit(&probs[symbol]); - OutWindow.PutByte((Byte)(symbol - 0x100)); - } - - -The match length decoding -------------------------- - -The match length decoder returns normalized (zero-based value) -length of match. That value can be converted to real length of the match -with the following code: - -#define kMatchMinLen 2 - - matchLen = len + kMatchMinLen; - -The match length decoder can return the values from 0 to 271. -And the corresponded real match length values can be in the range -from 2 to 273. - -The following scheme is used for the match length encoding: - - Binary encoding Binary Tree structure Zero-based match length - sequence (binary + decimal): - - 0 xxx LowCoder[posState] xxx - 1 0 yyy MidCoder[posState] yyy + 8 - 1 1 zzzzzzzz HighCoder zzzzzzzz + 16 - -LZMA uses bit model variable "Choice" to decode the first selection bit. - -If the first selection bit is equal to 0, the decoder uses binary tree - LowCoder[posState] to decode 3-bit zero-based match length (xxx). - -If the first selection bit is equal to 1, the decoder uses bit model - variable "Choice2" to decode the second selection bit. - - If the second selection bit is equal to 0, the decoder uses binary tree - MidCoder[posState] to decode 3-bit "yyy" value, and zero-based match - length is equal to (yyy + 8). - - If the second selection bit is equal to 1, the decoder uses binary tree - HighCoder to decode 8-bit "zzzzzzzz" value, and zero-based - match length is equal to (zzzzzzzz + 16). - -LZMA uses "posState" value as context to select the binary tree -from LowCoder and MidCoder binary tree arrays: - - unsigned posState = OutWindow.TotalPos & ((1 << pb) - 1); - -The full code of the length decoder: - -class CLenDecoder -{ - CProb Choice; - CProb Choice2; - CBitTreeDecoder<3> LowCoder[1 << kNumPosBitsMax]; - CBitTreeDecoder<3> MidCoder[1 << kNumPosBitsMax]; - CBitTreeDecoder<8> HighCoder; - -public: - - void Init() - { - Choice = PROB_INIT_VAL; - Choice2 = PROB_INIT_VAL; - HighCoder.Init(); - for (unsigned i = 0; i < (1 << kNumPosBitsMax); i++) - { - LowCoder[i].Init(); - MidCoder[i].Init(); - } - } - - unsigned Decode(CRangeDecoder *rc, unsigned posState) - { - if (rc->DecodeBit(&Choice) == 0) - return LowCoder[posState].Decode(rc); - if (rc->DecodeBit(&Choice2) == 0) - return 8 + MidCoder[posState].Decode(rc); - return 16 + HighCoder.Decode(rc); - } -}; - -The LZMA decoder uses two instances of CLenDecoder class. -The first instance is for the matches of "Simple Match" type, -and the second instance is for the matches of "Rep Match" type: - - CLenDecoder LenDecoder; - CLenDecoder RepLenDecoder; - - -The match distance decoding ---------------------------- - -LZMA supports dictionary sizes up to 4 GiB minus 1. -The value of match distance (decoded by distance decoder) can be -from 1 to 2^32. But the distance value that is equal to 2^32 is used to -indicate the "End of stream" marker. So real largest match distance -that is used for LZ-window match is (2^32 - 1). - -LZMA uses normalized match length (zero-based length) -to calculate the context state "lenState" do decode the distance value: - -#define kNumLenToPosStates 4 - - unsigned lenState = len; - if (lenState > kNumLenToPosStates - 1) - lenState = kNumLenToPosStates - 1; - -The distance decoder returns the "dist" value that is zero-based value -of match distance. The real match distance can be calculated with the -following code: - - matchDistance = dist + 1; - -The state of the distance decoder and the initialization code: - - #define kEndPosModelIndex 14 - #define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - #define kNumAlignBits 4 - - CBitTreeDecoder<6> PosSlotDecoder[kNumLenToPosStates]; - CProb PosDecoders[1 + kNumFullDistances - kEndPosModelIndex]; - CBitTreeDecoder AlignDecoder; - - void InitDist() - { - for (unsigned i = 0; i < kNumLenToPosStates; i++) - PosSlotDecoder[i].Init(); - AlignDecoder.Init(); - INIT_PROBS(PosDecoders); - } - -At first stage the distance decoder decodes 6-bit "posSlot" value with bit -tree decoder from PosSlotDecoder array. It's possible to get 2^6=64 different -"posSlot" values. - - unsigned posSlot = PosSlotDecoder[lenState].Decode(&RangeDec); - -The encoding scheme for distance value is shown in the following table: - -posSlot (decimal) / - zero-based distance (binary) - 0 0 - 1 1 - 2 10 - 3 11 - - 4 10 x - 5 11 x - 6 10 xx - 7 11 xx - 8 10 xxx - 9 11 xxx -10 10 xxxx -11 11 xxxx -12 10 xxxxx -13 11 xxxxx - -14 10 yy zzzz -15 11 yy zzzz -16 10 yyy zzzz -17 11 yyy zzzz -... -62 10 yyyyyyyyyyyyyyyyyyyyyyyyyy zzzz -63 11 yyyyyyyyyyyyyyyyyyyyyyyyyy zzzz - -where - "x ... x" means the sequence of binary symbols encoded with binary tree and - "Reverse" scheme. It uses separated binary tree for each posSlot from 4 to 13. - "y" means direct bit encoded with range coder. - "zzzz" means the sequence of four binary symbols encoded with binary - tree with "Reverse" scheme, where one common binary tree "AlignDecoder" - is used for all posSlot values. - -If (posSlot < 4), the "dist" value is equal to posSlot value. - -If (posSlot >= 4), the decoder uses "posSlot" value to calculate the value of - the high bits of "dist" value and the number of the low bits. - - If (4 <= posSlot < kEndPosModelIndex), the decoder uses bit tree decoders. - (one separated bit tree decoder per one posSlot value) and "Reverse" scheme. - In this implementation we use one CProb array "PosDecoders" that contains - all CProb variables for all these bit decoders. - - if (posSlot >= kEndPosModelIndex), the middle bits are decoded as direct - bits from RangeDecoder and the low 4 bits are decoded with a bit tree - decoder "AlignDecoder" with "Reverse" scheme. - -The code to decode zero-based match distance: - - unsigned DecodeDistance(unsigned len) - { - unsigned lenState = len; - if (lenState > kNumLenToPosStates - 1) - lenState = kNumLenToPosStates - 1; - - unsigned posSlot = PosSlotDecoder[lenState].Decode(&RangeDec); - if (posSlot < 4) - return posSlot; - - unsigned numDirectBits = (unsigned)((posSlot >> 1) - 1); - UInt32 dist = ((2 | (posSlot & 1)) << numDirectBits); - if (posSlot < kEndPosModelIndex) - dist += BitTreeReverseDecode(PosDecoders + dist - posSlot, numDirectBits, &RangeDec); - else - { - dist += RangeDec.DecodeDirectBits(numDirectBits - kNumAlignBits) << kNumAlignBits; - dist += AlignDecoder.ReverseDecode(&RangeDec); - } - return dist; - } - - - -LZMA Decoding modes -------------------- - -There are 2 types of LZMA streams: - -1) The stream with "End of stream" marker. -2) The stream without "End of stream" marker. - -And the LZMA Decoder supports 3 modes of decoding: - -1) The unpack size is undefined. The LZMA decoder stops decoding after - getting "End of stream" marker. - The input variables for that case: - - markerIsMandatory = true - unpackSizeDefined = false - unpackSize contains any value - -2) The unpack size is defined and LZMA decoder supports both variants, - where the stream can contain "End of stream" marker or the stream is - finished without "End of stream" marker. The LZMA decoder must detect - any of these situations. - The input variables for that case: - - markerIsMandatory = false - unpackSizeDefined = true - unpackSize contains unpack size - -3) The unpack size is defined and the LZMA stream must contain - "End of stream" marker - The input variables for that case: - - markerIsMandatory = true - unpackSizeDefined = true - unpackSize contains unpack size - - -The main loop of decoder ------------------------- - -The main loop of LZMA decoder: - -Initialize the LZMA state. -loop -{ - // begin of loop - Check "end of stream" conditions. - Decode Type of MATCH / LITERAL. - If it's LITERAL, decode LITERAL value and put the LITERAL to Window. - If it's MATCH, decode the length of match and the match distance. - Check error conditions, check end of stream conditions and copy - the sequence of match bytes from sliding window to current position - in window. - Go to begin of loop -} - -The reference implementation of LZMA decoder uses "unpackSize" variable -to keep the number of remaining bytes in output stream. So it reduces -"unpackSize" value after each decoded LITERAL or MATCH. - -The following code contains the "end of stream" condition check at the start -of the loop: - - if (unpackSizeDefined && unpackSize == 0 && !markerIsMandatory) - if (RangeDec.IsFinishedOK()) - return LZMA_RES_FINISHED_WITHOUT_MARKER; - -LZMA uses three types of matches: - -1) "Simple Match" - the match with distance value encoded with bit models. - -2) "Rep Match" - the match that uses the distance from distance - history table. - -3) "Short Rep Match" - the match of single byte length, that uses the latest - distance from distance history table. - -The LZMA decoder keeps the history of latest 4 match distances that were used -by decoder. That set of 4 variables contains zero-based match distances and -these variables are initialized with zero values: - - UInt32 rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0; - -The LZMA decoder uses binary model variables to select type of MATCH or LITERAL: - -#define kNumStates 12 -#define kNumPosBitsMax 4 - - CProb IsMatch[kNumStates << kNumPosBitsMax]; - CProb IsRep[kNumStates]; - CProb IsRepG0[kNumStates]; - CProb IsRepG1[kNumStates]; - CProb IsRepG2[kNumStates]; - CProb IsRep0Long[kNumStates << kNumPosBitsMax]; - -The decoder uses "state" variable value to select exact variable -from "IsRep", "IsRepG0", "IsRepG1" and "IsRepG2" arrays. -The "state" variable can get the value from 0 to 11. -Initial value for "state" variable is zero: - - unsigned state = 0; - -The "state" variable is updated after each LITERAL or MATCH with one of the -following functions: - -unsigned UpdateState_Literal(unsigned state) -{ - if (state < 4) return 0; - else if (state < 10) return state - 3; - else return state - 6; -} -unsigned UpdateState_Match (unsigned state) { return state < 7 ? 7 : 10; } -unsigned UpdateState_Rep (unsigned state) { return state < 7 ? 8 : 11; } -unsigned UpdateState_ShortRep(unsigned state) { return state < 7 ? 9 : 11; } - -The decoder calculates "state2" variable value to select exact variable from -"IsMatch" and "IsRep0Long" arrays: - -unsigned posState = OutWindow.TotalPos & ((1 << pb) - 1); -unsigned state2 = (state << kNumPosBitsMax) + posState; - -The decoder uses the following code flow scheme to select exact -type of LITERAL or MATCH: - -IsMatch[state2] decode - 0 - the Literal - 1 - the Match - IsRep[state] decode - 0 - Simple Match - 1 - Rep Match - IsRepG0[state] decode - 0 - the distance is rep0 - IsRep0Long[state2] decode - 0 - Short Rep Match - 1 - Rep Match 0 - 1 - - IsRepG1[state] decode - 0 - Rep Match 1 - 1 - - IsRepG2[state] decode - 0 - Rep Match 2 - 1 - Rep Match 3 - - -LITERAL symbol --------------- -If the value "0" was decoded with IsMatch[state2] decoding, we have "LITERAL" type. - -At first the LZMA decoder must check that it doesn't exceed -specified uncompressed size: - - if (unpackSizeDefined && unpackSize == 0) - return LZMA_RES_ERROR; - -Then it decodes literal value and puts it to sliding window: - - DecodeLiteral(state, rep0); - -Then the decoder must update the "state" value and "unpackSize" value; - - state = UpdateState_Literal(state); - unpackSize--; - -Then the decoder must go to the begin of main loop to decode next Match or Literal. - - -Simple Match ------------- - -If the value "1" was decoded with IsMatch[state2] decoding, -we have the "Simple Match" type. - -The distance history table is updated with the following scheme: - - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - -The zero-based length is decoded with "LenDecoder": - - len = LenDecoder.Decode(&RangeDec, posState); - -The state is update with UpdateState_Match function: - - state = UpdateState_Match(state); - -and the new "rep0" value is decoded with DecodeDistance: - - rep0 = DecodeDistance(len); - -That "rep0" will be used as zero-based distance for current match. - -If the value of "rep0" is equal to 0xFFFFFFFF, it means that we have -"End of stream" marker, so we can stop decoding and check finishing -condition in Range Decoder: - - if (rep0 == 0xFFFFFFFF) - return RangeDec.IsFinishedOK() ? - LZMA_RES_FINISHED_WITH_MARKER : - LZMA_RES_ERROR; - -If uncompressed size is defined, LZMA decoder must check that it doesn't -exceed that specified uncompressed size: - - if (unpackSizeDefined && unpackSize == 0) - return LZMA_RES_ERROR; - -Also the decoder must check that "rep0" value is not larger than dictionary size -and is not larger than the number of already decoded bytes: - - if (rep0 >= dictSize || !OutWindow.CheckDistance(rep0)) - return LZMA_RES_ERROR; - -Then the decoder must copy match bytes as described in -"The match symbols copying" section. - - -Rep Match ---------- - -If the LZMA decoder has decoded the value "1" with IsRep[state] variable, -we have "Rep Match" type. - -At first the LZMA decoder must check that it doesn't exceed -specified uncompressed size: - - if (unpackSizeDefined && unpackSize == 0) - return LZMA_RES_ERROR; - -Also the decoder must return error, if the LZ window is empty: - - if (OutWindow.IsEmpty()) - return LZMA_RES_ERROR; - -If the match type is "Rep Match", the decoder uses one of the 4 variables of -distance history table to get the value of distance for current match. -And there are 4 corresponding ways of decoding flow. - -The decoder updates the distance history with the following scheme -depending from type of match: - -- "Rep Match 0" or "Short Rep Match": - ; LZMA doesn't update the distance history - -- "Rep Match 1": - UInt32 dist = rep1; - rep1 = rep0; - rep0 = dist; - -- "Rep Match 2": - UInt32 dist = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = dist; - -- "Rep Match 3": - UInt32 dist = rep3; - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = dist; - -Then the decoder decodes exact subtype of "Rep Match" using "IsRepG0", "IsRep0Long", -"IsRepG1", "IsRepG2". - -If the subtype is "Short Rep Match", the decoder updates the state, puts -the one byte from window to current position in window and goes to next -MATCH/LITERAL symbol (the begin of main loop): - - state = UpdateState_ShortRep(state); - OutWindow.PutByte(OutWindow.GetByte(rep0 + 1)); - unpackSize--; - continue; - -In other cases (Rep Match 0/1/2/3), it decodes the zero-based -length of match with "RepLenDecoder" decoder: - - len = RepLenDecoder.Decode(&RangeDec, posState); - -Then it updates the state: - - state = UpdateState_Rep(state); - -Then the decoder must copy match bytes as described in -"The Match symbols copying" section. - - -The match symbols copying -------------------------- - -If we have the match (Simple Match or Rep Match 0/1/2/3), the decoder must -copy the sequence of bytes with calculated match distance and match length. -If uncompressed size is defined, LZMA decoder must check that it doesn't -exceed that specified uncompressed size: - - len += kMatchMinLen; - bool isError = false; - if (unpackSizeDefined && unpackSize < len) - { - len = (unsigned)unpackSize; - isError = true; - } - OutWindow.CopyMatch(rep0 + 1, len); - unpackSize -= len; - if (isError) - return LZMA_RES_ERROR; - -Then the decoder must go to the begin of main loop to decode next MATCH or LITERAL. - - - -NOTES ------ - -This specification doesn't describe the variant of decoder implementation -that supports partial decoding. Such partial decoding case can require some -changes in "end of stream" condition checks code. Also such code -can use additional status codes, returned by decoder. - -This specification uses C++ code with templates to simplify describing. -The optimized version of LZMA decoder doesn't need templates. -Such optimized version can use just two arrays of CProb variables: - 1) The dynamic array of CProb variables allocated for the Literal Decoder. - 2) The one common array that contains all other CProb variables. - - -References: - -1. G. N. N. Martin, Range encoding: an algorithm for removing redundancy - from a digitized message, Video & Data Recording Conference, - Southampton, UK, July 24-27, 1979. +LZMA specification (DRAFT version) +---------------------------------- + +Author: Igor Pavlov +Date: 2015-06-14 + +This specification defines the format of LZMA compressed data and lzma file format. + +Notation +-------- + +We use the syntax of C++ programming language. +We use the following types in C++ code: + unsigned - unsigned integer, at least 16 bits in size + int - signed integer, at least 16 bits in size + UInt64 - 64-bit unsigned integer + UInt32 - 32-bit unsigned integer + UInt16 - 16-bit unsigned integer + Byte - 8-bit unsigned integer + bool - boolean type with two possible values: false, true + + +lzma file format +================ + +The lzma file contains the raw LZMA stream and the header with related properties. + +The files in that format use ".lzma" extension. + +The lzma file format layout: + +Offset Size Description + + 0 1 LZMA model properties (lc, lp, pb) in encoded form + 1 4 Dictionary size (32-bit unsigned integer, little-endian) + 5 8 Uncompressed size (64-bit unsigned integer, little-endian) + 13 Compressed data (LZMA stream) + +LZMA properties: + + name Range Description + + lc [0, 8] the number of "literal context" bits + lp [0, 4] the number of "literal pos" bits + pb [0, 4] the number of "pos" bits +dictSize [0, 2^32 - 1] the dictionary size + +The following code encodes LZMA properties: + +void EncodeProperties(Byte *properties) +{ + properties[0] = (Byte)((pb * 5 + lp) * 9 + lc); + Set_UInt32_LittleEndian(properties + 1, dictSize); +} + +If the value of dictionary size in properties is smaller than (1 << 12), +the LZMA decoder must set the dictionary size variable to (1 << 12). + +#define LZMA_DIC_MIN (1 << 12) + + unsigned lc, pb, lp; + UInt32 dictSize; + UInt32 dictSizeInProperties; + + void DecodeProperties(const Byte *properties) + { + unsigned d = properties[0]; + if (d >= (9 * 5 * 5)) + throw "Incorrect LZMA properties"; + lc = d % 9; + d /= 9; + pb = d / 5; + lp = d % 5; + dictSizeInProperties = 0; + for (int i = 0; i < 4; i++) + dictSizeInProperties |= (UInt32)properties[i + 1] << (8 * i); + dictSize = dictSizeInProperties; + if (dictSize < LZMA_DIC_MIN) + dictSize = LZMA_DIC_MIN; + } + +If "Uncompressed size" field contains ones in all 64 bits, it means that +uncompressed size is unknown and there is the "end marker" in stream, +that indicates the end of decoding point. +In opposite case, if the value from "Uncompressed size" field is not +equal to ((2^64) - 1), the LZMA stream decoding must be finished after +specified number of bytes (Uncompressed size) is decoded. And if there +is the "end marker", the LZMA decoder must read that marker also. + + +The new scheme to encode LZMA properties +---------------------------------------- + +If LZMA compression is used for some another format, it's recommended to +use a new improved scheme to encode LZMA properties. That new scheme was +used in xz format that uses the LZMA2 compression algorithm. +The LZMA2 is a new compression algorithm that is based on the LZMA algorithm. + +The dictionary size in LZMA2 is encoded with just one byte and LZMA2 supports +only reduced set of dictionary sizes: + (2 << 11), (3 << 11), + (2 << 12), (3 << 12), + ... + (2 << 30), (3 << 30), + (2 << 31) - 1 + +The dictionary size can be extracted from encoded value with the following code: + + dictSize = (p == 40) ? 0xFFFFFFFF : (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)); + +Also there is additional limitation (lc + lp <= 4) in LZMA2 for values of +"lc" and "lp" properties: + + if (lc + lp > 4) + throw "Unsupported properties: (lc + lp) > 4"; + +There are some advantages for LZMA decoder with such (lc + lp) value +limitation. It reduces the maximum size of tables allocated by decoder. +And it reduces the complexity of initialization procedure, that can be +important to keep high speed of decoding of big number of small LZMA streams. + +It's recommended to use that limitation (lc + lp <= 4) for any new format +that uses LZMA compression. Note that the combinations of "lc" and "lp" +parameters, where (lc + lp > 4), can provide significant improvement in +compression ratio only in some rare cases. + +The LZMA properties can be encoded into two bytes in new scheme: + +Offset Size Description + + 0 1 The dictionary size encoded with LZMA2 scheme + 1 1 LZMA model properties (lc, lp, pb) in encoded form + + +The RAM usage +============= + +The RAM usage for LZMA decoder is determined by the following parts: + +1) The Sliding Window (from 4 KiB to 4 GiB). +2) The probability model counter arrays (arrays of 16-bit variables). +3) Some additional state variables (about 10 variables of 32-bit integers). + + +The RAM usage for Sliding Window +-------------------------------- + +There are two main scenarios of decoding: + +1) The decoding of full stream to one RAM buffer. + + If we decode full LZMA stream to one output buffer in RAM, the decoder + can use that output buffer as sliding window. So the decoder doesn't + need additional buffer allocated for sliding window. + +2) The decoding to some external storage. + + If we decode LZMA stream to external storage, the decoder must allocate + the buffer for sliding window. The size of that buffer must be equal + or larger than the value of dictionary size from properties of LZMA stream. + +In this specification we describe the code for decoding to some external +storage. The optimized version of code for decoding of full stream to one +output RAM buffer can require some minor changes in code. + + +The RAM usage for the probability model counters +------------------------------------------------ + +The size of the probability model counter arrays is calculated with the +following formula: + +size_of_prob_arrays = 1846 + 768 * (1 << (lp + lc)) + +Each probability model counter is 11-bit unsigned integer. +If we use 16-bit integer variables (2-byte integers) for these probability +model counters, the RAM usage required by probability model counter arrays +can be estimated with the following formula: + + RAM = 4 KiB + 1.5 KiB * (1 << (lp + lc)) + +For example, for default LZMA parameters (lp = 0 and lc = 3), the RAM usage is + + RAM_lc3_lp0 = 4 KiB + 1.5 KiB * 8 = 16 KiB + +The maximum RAM state usage is required for decoding the stream with lp = 4 +and lc = 8: + + RAM_lc8_lp4 = 4 KiB + 1.5 KiB * 4096 = 6148 KiB + +If the decoder uses LZMA2's limited property condition +(lc + lp <= 4), the RAM usage will be not larger than + + RAM_lc_lp_4 = 4 KiB + 1.5 KiB * 16 = 28 KiB + + +The RAM usage for encoder +------------------------- + +There are many variants for LZMA encoding code. +These variants have different values for memory consumption. +Note that memory consumption for LZMA Encoder can not be +smaller than memory consumption of LZMA Decoder for same stream. + +The RAM usage required by modern effective implementation of +LZMA Encoder can be estimated with the following formula: + + Encoder_RAM_Usage = 4 MiB + 11 * dictionarySize. + +But there are some modes of the encoder that require less memory. + + +LZMA Decoding +============= + +The LZMA compression algorithm uses LZ-based compression with Sliding Window +and Range Encoding as entropy coding method. + + +Sliding Window +-------------- + +LZMA uses Sliding Window compression similar to LZ77 algorithm. + +LZMA stream must be decoded to the sequence that consists +of MATCHES and LITERALS: + + - a LITERAL is a 8-bit character (one byte). + The decoder just puts that LITERAL to the uncompressed stream. + + - a MATCH is a pair of two numbers (DISTANCE-LENGTH pair). + The decoder takes one byte exactly "DISTANCE" characters behind + current position in the uncompressed stream and puts it to + uncompressed stream. The decoder must repeat it "LENGTH" times. + +The "DISTANCE" can not be larger than dictionary size. +And the "DISTANCE" can not be larger than the number of bytes in +the uncompressed stream that were decoded before that match. + +In this specification we use cyclic buffer to implement Sliding Window +for LZMA decoder: + +class COutWindow +{ + Byte *Buf; + UInt32 Pos; + UInt32 Size; + bool IsFull; + +public: + unsigned TotalPos; + COutStream OutStream; + + COutWindow(): Buf(NULL) {} + ~COutWindow() { delete []Buf; } + + void Create(UInt32 dictSize) + { + Buf = new Byte[dictSize]; + Pos = 0; + Size = dictSize; + IsFull = false; + TotalPos = 0; + } + + void PutByte(Byte b) + { + TotalPos++; + Buf[Pos++] = b; + if (Pos == Size) + { + Pos = 0; + IsFull = true; + } + OutStream.WriteByte(b); + } + + Byte GetByte(UInt32 dist) const + { + return Buf[dist <= Pos ? Pos - dist : Size - dist + Pos]; + } + + void CopyMatch(UInt32 dist, unsigned len) + { + for (; len > 0; len--) + PutByte(GetByte(dist)); + } + + bool CheckDistance(UInt32 dist) const + { + return dist <= Pos || IsFull; + } + + bool IsEmpty() const + { + return Pos == 0 && !IsFull; + } +}; + + +In another implementation it's possible to use one buffer that contains +Sliding Window and the whole data stream after uncompressing. + + +Range Decoder +------------- + +LZMA algorithm uses Range Encoding (1) as entropy coding method. + +LZMA stream contains just one very big number in big-endian encoding. +LZMA decoder uses the Range Decoder to extract a sequence of binary +symbols from that big number. + +The state of the Range Decoder: + +struct CRangeDecoder +{ + UInt32 Range; + UInt32 Code; + InputStream *InStream; + + bool Corrupted; +} + +The notes about UInt32 type for the "Range" and "Code" variables: + + It's possible to use 64-bit (unsigned or signed) integer type + for the "Range" and the "Code" variables instead of 32-bit unsigned, + but some additional code must be used to truncate the values to + low 32-bits after some operations. + + If the programming language does not support 32-bit unsigned integer type + (like in case of JAVA language), it's possible to use 32-bit signed integer, + but some code must be changed. For example, it's required to change the code + that uses comparison operations for UInt32 variables in this specification. + +The Range Decoder can be in some states that can be treated as +"Corruption" in LZMA stream. The Range Decoder uses the variable "Corrupted": + + (Corrupted == false), if the Range Decoder has not detected any corruption. + (Corrupted == true), if the Range Decoder has detected some corruption. + +The reference LZMA Decoder ignores the value of the "Corrupted" variable. +So it continues to decode the stream, even if the corruption can be detected +in the Range Decoder. To provide the full compatibility with output of the +reference LZMA Decoder, another LZMA Decoder implementations must also +ignore the value of the "Corrupted" variable. + +The LZMA Encoder is required to create only such LZMA streams, that will not +lead the Range Decoder to states, where the "Corrupted" variable is set to true. + +The Range Decoder reads first 5 bytes from input stream to initialize +the state: + +bool CRangeDecoder::Init() +{ + Corrupted = false; + Range = 0xFFFFFFFF; + Code = 0; + + Byte b = InStream->ReadByte(); + + for (int i = 0; i < 4; i++) + Code = (Code << 8) | InStream->ReadByte(); + + if (b != 0 || Code == Range) + Corrupted = true; + return b == 0; +} + +The LZMA Encoder always writes ZERO in initial byte of compressed stream. +That scheme allows to simplify the code of the Range Encoder in the +LZMA Encoder. If initial byte is not equal to ZERO, the LZMA Decoder must +stop decoding and report error. + +After the last bit of data was decoded by Range Decoder, the value of the +"Code" variable must be equal to 0. The LZMA Decoder must check it by +calling the IsFinishedOK() function: + + bool IsFinishedOK() const { return Code == 0; } + +If there is corruption in data stream, there is big probability that +the "Code" value will be not equal to 0 in the Finish() function. So that +check in the IsFinishedOK() function provides very good feature for +corruption detection. + +The value of the "Range" variable before each bit decoding can not be smaller +than ((UInt32)1 << 24). The Normalize() function keeps the "Range" value in +described range. + +#define kTopValue ((UInt32)1 << 24) + +void CRangeDecoder::Normalize() +{ + if (Range < kTopValue) + { + Range <<= 8; + Code = (Code << 8) | InStream->ReadByte(); + } +} + +Notes: if the size of the "Code" variable is larger than 32 bits, it's +required to keep only low 32 bits of the "Code" variable after the change +in Normalize() function. + +If the LZMA Stream is not corrupted, the value of the "Code" variable is +always smaller than value of the "Range" variable. +But the Range Decoder ignores some types of corruptions, so the value of +the "Code" variable can be equal or larger than value of the "Range" variable +for some "Corrupted" archives. + + +LZMA uses Range Encoding only with binary symbols of two types: + 1) binary symbols with fixed and equal probabilities (direct bits) + 2) binary symbols with predicted probabilities + +The DecodeDirectBits() function decodes the sequence of direct bits: + +UInt32 CRangeDecoder::DecodeDirectBits(unsigned numBits) +{ + UInt32 res = 0; + do + { + Range >>= 1; + Code -= Range; + UInt32 t = 0 - ((UInt32)Code >> 31); + Code += Range & t; + + if (Code == Range) + Corrupted = true; + + Normalize(); + res <<= 1; + res += t + 1; + } + while (--numBits); + return res; +} + + +The Bit Decoding with Probability Model +--------------------------------------- + +The task of Bit Probability Model is to estimate probabilities of binary +symbols. And then it provides the Range Decoder with that information. +The better prediction provides better compression ratio. +The Bit Probability Model uses statistical data of previous decoded +symbols. + +That estimated probability is presented as 11-bit unsigned integer value +that represents the probability of symbol "0". + +#define kNumBitModelTotalBits 11 + +Mathematical probabilities can be presented with the following formulas: + probability(symbol_0) = prob / 2048. + probability(symbol_1) = 1 - Probability(symbol_0) = + = 1 - prob / 2048 = + = (2048 - prob) / 2048 +where the "prob" variable contains 11-bit integer probability counter. + +It's recommended to use 16-bit unsigned integer type, to store these 11-bit +probability values: + +typedef UInt16 CProb; + +Each probability value must be initialized with value ((1 << 11) / 2), +that represents the state, where probabilities of symbols 0 and 1 +are equal to 0.5: + +#define PROB_INIT_VAL ((1 << kNumBitModelTotalBits) / 2) + +The INIT_PROBS macro is used to initialize the array of CProb variables: + +#define INIT_PROBS(p) \ + { for (unsigned i = 0; i < sizeof(p) / sizeof(p[0]); i++) p[i] = PROB_INIT_VAL; } + + +The DecodeBit() function decodes one bit. +The LZMA decoder provides the pointer to CProb variable that contains +information about estimated probability for symbol 0 and the Range Decoder +updates that CProb variable after decoding. The Range Decoder increases +estimated probability of the symbol that was decoded: + +#define kNumMoveBits 5 + +unsigned CRangeDecoder::DecodeBit(CProb *prob) +{ + unsigned v = *prob; + UInt32 bound = (Range >> kNumBitModelTotalBits) * v; + unsigned symbol; + if (Code < bound) + { + v += ((1 << kNumBitModelTotalBits) - v) >> kNumMoveBits; + Range = bound; + symbol = 0; + } + else + { + v -= v >> kNumMoveBits; + Code -= bound; + Range -= bound; + symbol = 1; + } + *prob = (CProb)v; + Normalize(); + return symbol; +} + + +The Binary Tree of bit model counters +------------------------------------- + +LZMA uses a tree of Bit model variables to decode symbol that needs +several bits for storing. There are two versions of such trees in LZMA: + 1) the tree that decodes bits from high bit to low bit (the normal scheme). + 2) the tree that decodes bits from low bit to high bit (the reverse scheme). + +Each binary tree structure supports different size of decoded symbol +(the size of binary sequence that contains value of symbol). +If that size of decoded symbol is "NumBits" bits, the tree structure +uses the array of (2 << NumBits) counters of CProb type. +But only ((2 << NumBits) - 1) items are used by encoder and decoder. +The first item (the item with index equal to 0) in array is unused. +That scheme with unused array's item allows to simplify the code. + +unsigned BitTreeReverseDecode(CProb *probs, unsigned numBits, CRangeDecoder *rc) +{ + unsigned m = 1; + unsigned symbol = 0; + for (unsigned i = 0; i < numBits; i++) + { + unsigned bit = rc->DecodeBit(&probs[m]); + m <<= 1; + m += bit; + symbol |= (bit << i); + } + return symbol; +} + +template +class CBitTreeDecoder +{ + CProb Probs[(unsigned)1 << NumBits]; + +public: + + void Init() + { + INIT_PROBS(Probs); + } + + unsigned Decode(CRangeDecoder *rc) + { + unsigned m = 1; + for (unsigned i = 0; i < NumBits; i++) + m = (m << 1) + rc->DecodeBit(&Probs[m]); + return m - ((unsigned)1 << NumBits); + } + + unsigned ReverseDecode(CRangeDecoder *rc) + { + return BitTreeReverseDecode(Probs, NumBits, rc); + } +}; + + +LZ part of LZMA +--------------- + +LZ part of LZMA describes details about the decoding of MATCHES and LITERALS. + + +The Literal Decoding +-------------------- + +The LZMA Decoder uses (1 << (lc + lp)) tables with CProb values, where +each table contains 0x300 CProb values: + + CProb *LitProbs; + + void CreateLiterals() + { + LitProbs = new CProb[(UInt32)0x300 << (lc + lp)]; + } + + void InitLiterals() + { + UInt32 num = (UInt32)0x300 << (lc + lp); + for (UInt32 i = 0; i < num; i++) + LitProbs[i] = PROB_INIT_VAL; + } + +To select the table for decoding it uses the context that consists of +(lc) high bits from previous literal and (lp) low bits from value that +represents current position in outputStream. + +If (State > 7), the Literal Decoder also uses "matchByte" that represents +the byte in OutputStream at position the is the DISTANCE bytes before +current position, where the DISTANCE is the distance in DISTANCE-LENGTH pair +of latest decoded match. + +The following code decodes one literal and puts it to Sliding Window buffer: + + void DecodeLiteral(unsigned state, UInt32 rep0) + { + unsigned prevByte = 0; + if (!OutWindow.IsEmpty()) + prevByte = OutWindow.GetByte(1); + + unsigned symbol = 1; + unsigned litState = ((OutWindow.TotalPos & ((1 << lp) - 1)) << lc) + (prevByte >> (8 - lc)); + CProb *probs = &LitProbs[(UInt32)0x300 * litState]; + + if (state >= 7) + { + unsigned matchByte = OutWindow.GetByte(rep0 + 1); + do + { + unsigned matchBit = (matchByte >> 7) & 1; + matchByte <<= 1; + unsigned bit = RangeDec.DecodeBit(&probs[((1 + matchBit) << 8) + symbol]); + symbol = (symbol << 1) | bit; + if (matchBit != bit) + break; + } + while (symbol < 0x100); + } + while (symbol < 0x100) + symbol = (symbol << 1) | RangeDec.DecodeBit(&probs[symbol]); + OutWindow.PutByte((Byte)(symbol - 0x100)); + } + + +The match length decoding +------------------------- + +The match length decoder returns normalized (zero-based value) +length of match. That value can be converted to real length of the match +with the following code: + +#define kMatchMinLen 2 + + matchLen = len + kMatchMinLen; + +The match length decoder can return the values from 0 to 271. +And the corresponded real match length values can be in the range +from 2 to 273. + +The following scheme is used for the match length encoding: + + Binary encoding Binary Tree structure Zero-based match length + sequence (binary + decimal): + + 0 xxx LowCoder[posState] xxx + 1 0 yyy MidCoder[posState] yyy + 8 + 1 1 zzzzzzzz HighCoder zzzzzzzz + 16 + +LZMA uses bit model variable "Choice" to decode the first selection bit. + +If the first selection bit is equal to 0, the decoder uses binary tree + LowCoder[posState] to decode 3-bit zero-based match length (xxx). + +If the first selection bit is equal to 1, the decoder uses bit model + variable "Choice2" to decode the second selection bit. + + If the second selection bit is equal to 0, the decoder uses binary tree + MidCoder[posState] to decode 3-bit "yyy" value, and zero-based match + length is equal to (yyy + 8). + + If the second selection bit is equal to 1, the decoder uses binary tree + HighCoder to decode 8-bit "zzzzzzzz" value, and zero-based + match length is equal to (zzzzzzzz + 16). + +LZMA uses "posState" value as context to select the binary tree +from LowCoder and MidCoder binary tree arrays: + + unsigned posState = OutWindow.TotalPos & ((1 << pb) - 1); + +The full code of the length decoder: + +class CLenDecoder +{ + CProb Choice; + CProb Choice2; + CBitTreeDecoder<3> LowCoder[1 << kNumPosBitsMax]; + CBitTreeDecoder<3> MidCoder[1 << kNumPosBitsMax]; + CBitTreeDecoder<8> HighCoder; + +public: + + void Init() + { + Choice = PROB_INIT_VAL; + Choice2 = PROB_INIT_VAL; + HighCoder.Init(); + for (unsigned i = 0; i < (1 << kNumPosBitsMax); i++) + { + LowCoder[i].Init(); + MidCoder[i].Init(); + } + } + + unsigned Decode(CRangeDecoder *rc, unsigned posState) + { + if (rc->DecodeBit(&Choice) == 0) + return LowCoder[posState].Decode(rc); + if (rc->DecodeBit(&Choice2) == 0) + return 8 + MidCoder[posState].Decode(rc); + return 16 + HighCoder.Decode(rc); + } +}; + +The LZMA decoder uses two instances of CLenDecoder class. +The first instance is for the matches of "Simple Match" type, +and the second instance is for the matches of "Rep Match" type: + + CLenDecoder LenDecoder; + CLenDecoder RepLenDecoder; + + +The match distance decoding +--------------------------- + +LZMA supports dictionary sizes up to 4 GiB minus 1. +The value of match distance (decoded by distance decoder) can be +from 1 to 2^32. But the distance value that is equal to 2^32 is used to +indicate the "End of stream" marker. So real largest match distance +that is used for LZ-window match is (2^32 - 1). + +LZMA uses normalized match length (zero-based length) +to calculate the context state "lenState" do decode the distance value: + +#define kNumLenToPosStates 4 + + unsigned lenState = len; + if (lenState > kNumLenToPosStates - 1) + lenState = kNumLenToPosStates - 1; + +The distance decoder returns the "dist" value that is zero-based value +of match distance. The real match distance can be calculated with the +following code: + + matchDistance = dist + 1; + +The state of the distance decoder and the initialization code: + + #define kEndPosModelIndex 14 + #define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + #define kNumAlignBits 4 + + CBitTreeDecoder<6> PosSlotDecoder[kNumLenToPosStates]; + CProb PosDecoders[1 + kNumFullDistances - kEndPosModelIndex]; + CBitTreeDecoder AlignDecoder; + + void InitDist() + { + for (unsigned i = 0; i < kNumLenToPosStates; i++) + PosSlotDecoder[i].Init(); + AlignDecoder.Init(); + INIT_PROBS(PosDecoders); + } + +At first stage the distance decoder decodes 6-bit "posSlot" value with bit +tree decoder from PosSlotDecoder array. It's possible to get 2^6=64 different +"posSlot" values. + + unsigned posSlot = PosSlotDecoder[lenState].Decode(&RangeDec); + +The encoding scheme for distance value is shown in the following table: + +posSlot (decimal) / + zero-based distance (binary) + 0 0 + 1 1 + 2 10 + 3 11 + + 4 10 x + 5 11 x + 6 10 xx + 7 11 xx + 8 10 xxx + 9 11 xxx +10 10 xxxx +11 11 xxxx +12 10 xxxxx +13 11 xxxxx + +14 10 yy zzzz +15 11 yy zzzz +16 10 yyy zzzz +17 11 yyy zzzz +... +62 10 yyyyyyyyyyyyyyyyyyyyyyyyyy zzzz +63 11 yyyyyyyyyyyyyyyyyyyyyyyyyy zzzz + +where + "x ... x" means the sequence of binary symbols encoded with binary tree and + "Reverse" scheme. It uses separated binary tree for each posSlot from 4 to 13. + "y" means direct bit encoded with range coder. + "zzzz" means the sequence of four binary symbols encoded with binary + tree with "Reverse" scheme, where one common binary tree "AlignDecoder" + is used for all posSlot values. + +If (posSlot < 4), the "dist" value is equal to posSlot value. + +If (posSlot >= 4), the decoder uses "posSlot" value to calculate the value of + the high bits of "dist" value and the number of the low bits. + + If (4 <= posSlot < kEndPosModelIndex), the decoder uses bit tree decoders. + (one separated bit tree decoder per one posSlot value) and "Reverse" scheme. + In this implementation we use one CProb array "PosDecoders" that contains + all CProb variables for all these bit decoders. + + if (posSlot >= kEndPosModelIndex), the middle bits are decoded as direct + bits from RangeDecoder and the low 4 bits are decoded with a bit tree + decoder "AlignDecoder" with "Reverse" scheme. + +The code to decode zero-based match distance: + + unsigned DecodeDistance(unsigned len) + { + unsigned lenState = len; + if (lenState > kNumLenToPosStates - 1) + lenState = kNumLenToPosStates - 1; + + unsigned posSlot = PosSlotDecoder[lenState].Decode(&RangeDec); + if (posSlot < 4) + return posSlot; + + unsigned numDirectBits = (unsigned)((posSlot >> 1) - 1); + UInt32 dist = ((2 | (posSlot & 1)) << numDirectBits); + if (posSlot < kEndPosModelIndex) + dist += BitTreeReverseDecode(PosDecoders + dist - posSlot, numDirectBits, &RangeDec); + else + { + dist += RangeDec.DecodeDirectBits(numDirectBits - kNumAlignBits) << kNumAlignBits; + dist += AlignDecoder.ReverseDecode(&RangeDec); + } + return dist; + } + + + +LZMA Decoding modes +------------------- + +There are 2 types of LZMA streams: + +1) The stream with "End of stream" marker. +2) The stream without "End of stream" marker. + +And the LZMA Decoder supports 3 modes of decoding: + +1) The unpack size is undefined. The LZMA decoder stops decoding after + getting "End of stream" marker. + The input variables for that case: + + markerIsMandatory = true + unpackSizeDefined = false + unpackSize contains any value + +2) The unpack size is defined and LZMA decoder supports both variants, + where the stream can contain "End of stream" marker or the stream is + finished without "End of stream" marker. The LZMA decoder must detect + any of these situations. + The input variables for that case: + + markerIsMandatory = false + unpackSizeDefined = true + unpackSize contains unpack size + +3) The unpack size is defined and the LZMA stream must contain + "End of stream" marker + The input variables for that case: + + markerIsMandatory = true + unpackSizeDefined = true + unpackSize contains unpack size + + +The main loop of decoder +------------------------ + +The main loop of LZMA decoder: + +Initialize the LZMA state. +loop +{ + // begin of loop + Check "end of stream" conditions. + Decode Type of MATCH / LITERAL. + If it's LITERAL, decode LITERAL value and put the LITERAL to Window. + If it's MATCH, decode the length of match and the match distance. + Check error conditions, check end of stream conditions and copy + the sequence of match bytes from sliding window to current position + in window. + Go to begin of loop +} + +The reference implementation of LZMA decoder uses "unpackSize" variable +to keep the number of remaining bytes in output stream. So it reduces +"unpackSize" value after each decoded LITERAL or MATCH. + +The following code contains the "end of stream" condition check at the start +of the loop: + + if (unpackSizeDefined && unpackSize == 0 && !markerIsMandatory) + if (RangeDec.IsFinishedOK()) + return LZMA_RES_FINISHED_WITHOUT_MARKER; + +LZMA uses three types of matches: + +1) "Simple Match" - the match with distance value encoded with bit models. + +2) "Rep Match" - the match that uses the distance from distance + history table. + +3) "Short Rep Match" - the match of single byte length, that uses the latest + distance from distance history table. + +The LZMA decoder keeps the history of latest 4 match distances that were used +by decoder. That set of 4 variables contains zero-based match distances and +these variables are initialized with zero values: + + UInt32 rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0; + +The LZMA decoder uses binary model variables to select type of MATCH or LITERAL: + +#define kNumStates 12 +#define kNumPosBitsMax 4 + + CProb IsMatch[kNumStates << kNumPosBitsMax]; + CProb IsRep[kNumStates]; + CProb IsRepG0[kNumStates]; + CProb IsRepG1[kNumStates]; + CProb IsRepG2[kNumStates]; + CProb IsRep0Long[kNumStates << kNumPosBitsMax]; + +The decoder uses "state" variable value to select exact variable +from "IsRep", "IsRepG0", "IsRepG1" and "IsRepG2" arrays. +The "state" variable can get the value from 0 to 11. +Initial value for "state" variable is zero: + + unsigned state = 0; + +The "state" variable is updated after each LITERAL or MATCH with one of the +following functions: + +unsigned UpdateState_Literal(unsigned state) +{ + if (state < 4) return 0; + else if (state < 10) return state - 3; + else return state - 6; +} +unsigned UpdateState_Match (unsigned state) { return state < 7 ? 7 : 10; } +unsigned UpdateState_Rep (unsigned state) { return state < 7 ? 8 : 11; } +unsigned UpdateState_ShortRep(unsigned state) { return state < 7 ? 9 : 11; } + +The decoder calculates "state2" variable value to select exact variable from +"IsMatch" and "IsRep0Long" arrays: + +unsigned posState = OutWindow.TotalPos & ((1 << pb) - 1); +unsigned state2 = (state << kNumPosBitsMax) + posState; + +The decoder uses the following code flow scheme to select exact +type of LITERAL or MATCH: + +IsMatch[state2] decode + 0 - the Literal + 1 - the Match + IsRep[state] decode + 0 - Simple Match + 1 - Rep Match + IsRepG0[state] decode + 0 - the distance is rep0 + IsRep0Long[state2] decode + 0 - Short Rep Match + 1 - Rep Match 0 + 1 - + IsRepG1[state] decode + 0 - Rep Match 1 + 1 - + IsRepG2[state] decode + 0 - Rep Match 2 + 1 - Rep Match 3 + + +LITERAL symbol +-------------- +If the value "0" was decoded with IsMatch[state2] decoding, we have "LITERAL" type. + +At first the LZMA decoder must check that it doesn't exceed +specified uncompressed size: + + if (unpackSizeDefined && unpackSize == 0) + return LZMA_RES_ERROR; + +Then it decodes literal value and puts it to sliding window: + + DecodeLiteral(state, rep0); + +Then the decoder must update the "state" value and "unpackSize" value; + + state = UpdateState_Literal(state); + unpackSize--; + +Then the decoder must go to the begin of main loop to decode next Match or Literal. + + +Simple Match +------------ + +If the value "1" was decoded with IsMatch[state2] decoding, +we have the "Simple Match" type. + +The distance history table is updated with the following scheme: + + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + +The zero-based length is decoded with "LenDecoder": + + len = LenDecoder.Decode(&RangeDec, posState); + +The state is update with UpdateState_Match function: + + state = UpdateState_Match(state); + +and the new "rep0" value is decoded with DecodeDistance: + + rep0 = DecodeDistance(len); + +That "rep0" will be used as zero-based distance for current match. + +If the value of "rep0" is equal to 0xFFFFFFFF, it means that we have +"End of stream" marker, so we can stop decoding and check finishing +condition in Range Decoder: + + if (rep0 == 0xFFFFFFFF) + return RangeDec.IsFinishedOK() ? + LZMA_RES_FINISHED_WITH_MARKER : + LZMA_RES_ERROR; + +If uncompressed size is defined, LZMA decoder must check that it doesn't +exceed that specified uncompressed size: + + if (unpackSizeDefined && unpackSize == 0) + return LZMA_RES_ERROR; + +Also the decoder must check that "rep0" value is not larger than dictionary size +and is not larger than the number of already decoded bytes: + + if (rep0 >= dictSize || !OutWindow.CheckDistance(rep0)) + return LZMA_RES_ERROR; + +Then the decoder must copy match bytes as described in +"The match symbols copying" section. + + +Rep Match +--------- + +If the LZMA decoder has decoded the value "1" with IsRep[state] variable, +we have "Rep Match" type. + +At first the LZMA decoder must check that it doesn't exceed +specified uncompressed size: + + if (unpackSizeDefined && unpackSize == 0) + return LZMA_RES_ERROR; + +Also the decoder must return error, if the LZ window is empty: + + if (OutWindow.IsEmpty()) + return LZMA_RES_ERROR; + +If the match type is "Rep Match", the decoder uses one of the 4 variables of +distance history table to get the value of distance for current match. +And there are 4 corresponding ways of decoding flow. + +The decoder updates the distance history with the following scheme +depending from type of match: + +- "Rep Match 0" or "Short Rep Match": + ; LZMA doesn't update the distance history + +- "Rep Match 1": + UInt32 dist = rep1; + rep1 = rep0; + rep0 = dist; + +- "Rep Match 2": + UInt32 dist = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = dist; + +- "Rep Match 3": + UInt32 dist = rep3; + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = dist; + +Then the decoder decodes exact subtype of "Rep Match" using "IsRepG0", "IsRep0Long", +"IsRepG1", "IsRepG2". + +If the subtype is "Short Rep Match", the decoder updates the state, puts +the one byte from window to current position in window and goes to next +MATCH/LITERAL symbol (the begin of main loop): + + state = UpdateState_ShortRep(state); + OutWindow.PutByte(OutWindow.GetByte(rep0 + 1)); + unpackSize--; + continue; + +In other cases (Rep Match 0/1/2/3), it decodes the zero-based +length of match with "RepLenDecoder" decoder: + + len = RepLenDecoder.Decode(&RangeDec, posState); + +Then it updates the state: + + state = UpdateState_Rep(state); + +Then the decoder must copy match bytes as described in +"The Match symbols copying" section. + + +The match symbols copying +------------------------- + +If we have the match (Simple Match or Rep Match 0/1/2/3), the decoder must +copy the sequence of bytes with calculated match distance and match length. +If uncompressed size is defined, LZMA decoder must check that it doesn't +exceed that specified uncompressed size: + + len += kMatchMinLen; + bool isError = false; + if (unpackSizeDefined && unpackSize < len) + { + len = (unsigned)unpackSize; + isError = true; + } + OutWindow.CopyMatch(rep0 + 1, len); + unpackSize -= len; + if (isError) + return LZMA_RES_ERROR; + +Then the decoder must go to the begin of main loop to decode next MATCH or LITERAL. + + + +NOTES +----- + +This specification doesn't describe the variant of decoder implementation +that supports partial decoding. Such partial decoding case can require some +changes in "end of stream" condition checks code. Also such code +can use additional status codes, returned by decoder. + +This specification uses C++ code with templates to simplify describing. +The optimized version of LZMA decoder doesn't need templates. +Such optimized version can use just two arrays of CProb variables: + 1) The dynamic array of CProb variables allocated for the Literal Decoder. + 2) The one common array that contains all other CProb variables. + + +References: + +1. G. N. N. Martin, Range encoding: an algorithm for removing redundancy + from a digitized message, Video & Data Recording Conference, + Southampton, UK, July 24-27, 1979. diff --git a/deps/LZMA-SDK/DOC/lzma.txt b/deps/LZMA-SDK/DOC/lzma.txt index 1f92142ea..a65988fe0 100644 --- a/deps/LZMA-SDK/DOC/lzma.txt +++ b/deps/LZMA-SDK/DOC/lzma.txt @@ -1,328 +1,328 @@ -LZMA compression ----------------- -Version: 9.35 - -This file describes LZMA encoding and decoding functions written in C language. - -LZMA is an improved version of famous LZ77 compression algorithm. -It was improved in way of maximum increasing of compression ratio, -keeping high decompression speed and low memory requirements for -decompressing. - -Note: you can read also LZMA Specification (lzma-specification.txt from LZMA SDK) - -Also you can look source code for LZMA encoding and decoding: - C/Util/Lzma/LzmaUtil.c - - -LZMA compressed file format ---------------------------- -Offset Size Description - 0 1 Special LZMA properties (lc,lp, pb in encoded form) - 1 4 Dictionary size (little endian) - 5 8 Uncompressed size (little endian). -1 means unknown size - 13 Compressed data - - - -ANSI-C LZMA Decoder -~~~~~~~~~~~~~~~~~~~ - -Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58. -If you want to use old interfaces you can download previous version of LZMA SDK -from sourceforge.net site. - -To use ANSI-C LZMA Decoder you need the following files: -1) LzmaDec.h + LzmaDec.c + 7zTypes.h + Precomp.h + Compiler.h - -Look example code: - C/Util/Lzma/LzmaUtil.c - - -Memory requirements for LZMA decoding -------------------------------------- - -Stack usage of LZMA decoding function for local variables is not -larger than 200-400 bytes. - -LZMA Decoder uses dictionary buffer and internal state structure. -Internal state structure consumes - state_size = (4 + (1.5 << (lc + lp))) KB -by default (lc=3, lp=0), state_size = 16 KB. - - -How To decompress data ----------------------- - -LZMA Decoder (ANSI-C version) now supports 2 interfaces: -1) Single-call Decompressing -2) Multi-call State Decompressing (zlib-like interface) - -You must use external allocator: -Example: -void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); } -void SzFree(void *p, void *address) { p = p; free(address); } -ISzAlloc alloc = { SzAlloc, SzFree }; - -You can use p = p; operator to disable compiler warnings. - - -Single-call Decompressing -------------------------- -When to use: RAM->RAM decompressing -Compile files: LzmaDec.h + LzmaDec.c + 7zTypes.h -Compile defines: no defines -Memory Requirements: - - Input buffer: compressed size - - Output buffer: uncompressed size - - LZMA Internal Structures: state_size (16 KB for default settings) - -Interface: - int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc); - In: - dest - output data - destLen - output data size - src - input data - srcLen - input data size - propData - LZMA properties (5 bytes) - propSize - size of propData buffer (5 bytes) - finishMode - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - Decode just destLen bytes. - LZMA_FINISH_END - Stream must be finished after (*destLen). - You can use LZMA_FINISH_END, when you know that - current output buffer covers last bytes of stream. - alloc - Memory allocator. - - Out: - destLen - processed output size - srcLen - processed input size - - Output: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). - - If LZMA decoder sees end_marker before reaching output limit, it returns OK result, - and output value of destLen will be less than output buffer size limit. - - You can use multiple checks to test data integrity after full decompression: - 1) Check Result and "status" variable. - 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. - 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. - You must use correct finish mode in that case. */ - - -Multi-call State Decompressing (zlib-like interface) ----------------------------------------------------- - -When to use: file->file decompressing -Compile files: LzmaDec.h + LzmaDec.c + 7zTypes.h - -Memory Requirements: - - Buffer for input stream: any size (for example, 16 KB) - - Buffer for output stream: any size (for example, 16 KB) - - LZMA Internal Structures: state_size (16 KB for default settings) - - LZMA dictionary (dictionary size is encoded in LZMA properties header) - -1) read LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header: - unsigned char header[LZMA_PROPS_SIZE + 8]; - ReadFile(inFile, header, sizeof(header) - -2) Allocate CLzmaDec structures (state + dictionary) using LZMA properties - - CLzmaDec state; - LzmaDec_Constr(&state); - res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc); - if (res != SZ_OK) - return res; - -3) Init LzmaDec structure before any new LZMA stream. And call LzmaDec_DecodeToBuf in loop - - LzmaDec_Init(&state); - for (;;) - { - ... - int res = LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode); - ... - } - - -4) Free all allocated structures - LzmaDec_Free(&state, &g_Alloc); - -Look example code: - C/Util/Lzma/LzmaUtil.c - - -How To compress data --------------------- - -Compile files: - 7zTypes.h - Threads.h - LzmaEnc.h - LzmaEnc.c - LzFind.h - LzFind.c - LzFindMt.h - LzFindMt.c - LzHash.h - -Memory Requirements: - - (dictSize * 11.5 + 6 MB) + state_size - -Lzma Encoder can use two memory allocators: -1) alloc - for small arrays. -2) allocBig - for big arrays. - -For example, you can use Large RAM Pages (2 MB) in allocBig allocator for -better compression speed. Note that Windows has bad implementation for -Large RAM Pages. -It's OK to use same allocator for alloc and allocBig. - - -Single-call Compression with callbacks --------------------------------------- - -Look example code: - C/Util/Lzma/LzmaUtil.c - -When to use: file->file compressing - -1) you must implement callback structures for interfaces: -ISeqInStream -ISeqOutStream -ICompressProgress -ISzAlloc - -static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } -static void SzFree(void *p, void *address) { p = p; MyFree(address); } -static ISzAlloc g_Alloc = { SzAlloc, SzFree }; - - CFileSeqInStream inStream; - CFileSeqOutStream outStream; - - inStream.funcTable.Read = MyRead; - inStream.file = inFile; - outStream.funcTable.Write = MyWrite; - outStream.file = outFile; - - -2) Create CLzmaEncHandle object; - - CLzmaEncHandle enc; - - enc = LzmaEnc_Create(&g_Alloc); - if (enc == 0) - return SZ_ERROR_MEM; - - -3) initialize CLzmaEncProps properties; - - LzmaEncProps_Init(&props); - - Then you can change some properties in that structure. - -4) Send LZMA properties to LZMA Encoder - - res = LzmaEnc_SetProps(enc, &props); - -5) Write encoded properties to header - - Byte header[LZMA_PROPS_SIZE + 8]; - size_t headerSize = LZMA_PROPS_SIZE; - UInt64 fileSize; - int i; - - res = LzmaEnc_WriteProperties(enc, header, &headerSize); - fileSize = MyGetFileLength(inFile); - for (i = 0; i < 8; i++) - header[headerSize++] = (Byte)(fileSize >> (8 * i)); - MyWriteFileAndCheck(outFile, header, headerSize) - -6) Call encoding function: - res = LzmaEnc_Encode(enc, &outStream.funcTable, &inStream.funcTable, - NULL, &g_Alloc, &g_Alloc); - -7) Destroy LZMA Encoder Object - LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc); - - -If callback function return some error code, LzmaEnc_Encode also returns that code -or it can return the code like SZ_ERROR_READ, SZ_ERROR_WRITE or SZ_ERROR_PROGRESS. - - -Single-call RAM->RAM Compression --------------------------------- - -Single-call RAM->RAM Compression is similar to Compression with callbacks, -but you provide pointers to buffers instead of pointers to stream callbacks: - -SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, - const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, - ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); - -Return code: - SZ_OK - OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_PARAM - Incorrect paramater - SZ_ERROR_OUTPUT_EOF - output buffer overflow - SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) - - - -Defines -------- - -_LZMA_SIZE_OPT - Enable some optimizations in LZMA Decoder to get smaller executable code. - -_LZMA_PROB32 - It can increase the speed on some 32-bit CPUs, but memory usage for - some structures will be doubled in that case. - -_LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler and long is 32-bit. - -_LZMA_NO_SYSTEM_SIZE_T - Define it if you don't want to use size_t type. - - -_7ZIP_PPMD_SUPPPORT - Define it if you don't want to support PPMD method in AMSI-C .7z decoder. - - -C++ LZMA Encoder/Decoder -~~~~~~~~~~~~~~~~~~~~~~~~ -C++ LZMA code use COM-like interfaces. So if you want to use it, -you can study basics of COM/OLE. -C++ LZMA code is just wrapper over ANSI-C code. - - -C++ Notes -~~~~~~~~~~~~~~~~~~~~~~~~ -If you use some C++ code folders in 7-Zip (for example, C++ code for .7z handling), -you must check that you correctly work with "new" operator. -7-Zip can be compiled with MSVC 6.0 that doesn't throw "exception" from "new" operator. -So 7-Zip uses "CPP\Common\NewHandler.cpp" that redefines "new" operator: -operator new(size_t size) -{ - void *p = ::malloc(size); - if (p == 0) - throw CNewException(); - return p; -} -If you use MSCV that throws exception for "new" operator, you can compile without -"NewHandler.cpp". So standard exception will be used. Actually some code of -7-Zip catches any exception in internal code and converts it to HRESULT code. -So you don't need to catch CNewException, if you call COM interfaces of 7-Zip. - ---- - -http://www.7-zip.org -http://www.7-zip.org/sdk.html -http://www.7-zip.org/support.html +LZMA compression +---------------- +Version: 9.35 + +This file describes LZMA encoding and decoding functions written in C language. + +LZMA is an improved version of famous LZ77 compression algorithm. +It was improved in way of maximum increasing of compression ratio, +keeping high decompression speed and low memory requirements for +decompressing. + +Note: you can read also LZMA Specification (lzma-specification.txt from LZMA SDK) + +Also you can look source code for LZMA encoding and decoding: + C/Util/Lzma/LzmaUtil.c + + +LZMA compressed file format +--------------------------- +Offset Size Description + 0 1 Special LZMA properties (lc,lp, pb in encoded form) + 1 4 Dictionary size (little endian) + 5 8 Uncompressed size (little endian). -1 means unknown size + 13 Compressed data + + + +ANSI-C LZMA Decoder +~~~~~~~~~~~~~~~~~~~ + +Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58. +If you want to use old interfaces you can download previous version of LZMA SDK +from sourceforge.net site. + +To use ANSI-C LZMA Decoder you need the following files: +1) LzmaDec.h + LzmaDec.c + 7zTypes.h + Precomp.h + Compiler.h + +Look example code: + C/Util/Lzma/LzmaUtil.c + + +Memory requirements for LZMA decoding +------------------------------------- + +Stack usage of LZMA decoding function for local variables is not +larger than 200-400 bytes. + +LZMA Decoder uses dictionary buffer and internal state structure. +Internal state structure consumes + state_size = (4 + (1.5 << (lc + lp))) KB +by default (lc=3, lp=0), state_size = 16 KB. + + +How To decompress data +---------------------- + +LZMA Decoder (ANSI-C version) now supports 2 interfaces: +1) Single-call Decompressing +2) Multi-call State Decompressing (zlib-like interface) + +You must use external allocator: +Example: +void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); } +void SzFree(void *p, void *address) { p = p; free(address); } +ISzAlloc alloc = { SzAlloc, SzFree }; + +You can use p = p; operator to disable compiler warnings. + + +Single-call Decompressing +------------------------- +When to use: RAM->RAM decompressing +Compile files: LzmaDec.h + LzmaDec.c + 7zTypes.h +Compile defines: no defines +Memory Requirements: + - Input buffer: compressed size + - Output buffer: uncompressed size + - LZMA Internal Structures: state_size (16 KB for default settings) + +Interface: + int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAlloc *alloc); + In: + dest - output data + destLen - output data size + src - input data + srcLen - input data size + propData - LZMA properties (5 bytes) + propSize - size of propData buffer (5 bytes) + finishMode - It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - Decode just destLen bytes. + LZMA_FINISH_END - Stream must be finished after (*destLen). + You can use LZMA_FINISH_END, when you know that + current output buffer covers last bytes of stream. + alloc - Memory allocator. + + Out: + destLen - processed output size + srcLen - processed input size + + Output: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). + + If LZMA decoder sees end_marker before reaching output limit, it returns OK result, + and output value of destLen will be less than output buffer size limit. + + You can use multiple checks to test data integrity after full decompression: + 1) Check Result and "status" variable. + 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. + 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. + You must use correct finish mode in that case. */ + + +Multi-call State Decompressing (zlib-like interface) +---------------------------------------------------- + +When to use: file->file decompressing +Compile files: LzmaDec.h + LzmaDec.c + 7zTypes.h + +Memory Requirements: + - Buffer for input stream: any size (for example, 16 KB) + - Buffer for output stream: any size (for example, 16 KB) + - LZMA Internal Structures: state_size (16 KB for default settings) + - LZMA dictionary (dictionary size is encoded in LZMA properties header) + +1) read LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header: + unsigned char header[LZMA_PROPS_SIZE + 8]; + ReadFile(inFile, header, sizeof(header) + +2) Allocate CLzmaDec structures (state + dictionary) using LZMA properties + + CLzmaDec state; + LzmaDec_Constr(&state); + res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc); + if (res != SZ_OK) + return res; + +3) Init LzmaDec structure before any new LZMA stream. And call LzmaDec_DecodeToBuf in loop + + LzmaDec_Init(&state); + for (;;) + { + ... + int res = LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, + const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode); + ... + } + + +4) Free all allocated structures + LzmaDec_Free(&state, &g_Alloc); + +Look example code: + C/Util/Lzma/LzmaUtil.c + + +How To compress data +-------------------- + +Compile files: + 7zTypes.h + Threads.h + LzmaEnc.h + LzmaEnc.c + LzFind.h + LzFind.c + LzFindMt.h + LzFindMt.c + LzHash.h + +Memory Requirements: + - (dictSize * 11.5 + 6 MB) + state_size + +Lzma Encoder can use two memory allocators: +1) alloc - for small arrays. +2) allocBig - for big arrays. + +For example, you can use Large RAM Pages (2 MB) in allocBig allocator for +better compression speed. Note that Windows has bad implementation for +Large RAM Pages. +It's OK to use same allocator for alloc and allocBig. + + +Single-call Compression with callbacks +-------------------------------------- + +Look example code: + C/Util/Lzma/LzmaUtil.c + +When to use: file->file compressing + +1) you must implement callback structures for interfaces: +ISeqInStream +ISeqOutStream +ICompressProgress +ISzAlloc + +static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); } +static void SzFree(void *p, void *address) { p = p; MyFree(address); } +static ISzAlloc g_Alloc = { SzAlloc, SzFree }; + + CFileSeqInStream inStream; + CFileSeqOutStream outStream; + + inStream.funcTable.Read = MyRead; + inStream.file = inFile; + outStream.funcTable.Write = MyWrite; + outStream.file = outFile; + + +2) Create CLzmaEncHandle object; + + CLzmaEncHandle enc; + + enc = LzmaEnc_Create(&g_Alloc); + if (enc == 0) + return SZ_ERROR_MEM; + + +3) initialize CLzmaEncProps properties; + + LzmaEncProps_Init(&props); + + Then you can change some properties in that structure. + +4) Send LZMA properties to LZMA Encoder + + res = LzmaEnc_SetProps(enc, &props); + +5) Write encoded properties to header + + Byte header[LZMA_PROPS_SIZE + 8]; + size_t headerSize = LZMA_PROPS_SIZE; + UInt64 fileSize; + int i; + + res = LzmaEnc_WriteProperties(enc, header, &headerSize); + fileSize = MyGetFileLength(inFile); + for (i = 0; i < 8; i++) + header[headerSize++] = (Byte)(fileSize >> (8 * i)); + MyWriteFileAndCheck(outFile, header, headerSize) + +6) Call encoding function: + res = LzmaEnc_Encode(enc, &outStream.funcTable, &inStream.funcTable, + NULL, &g_Alloc, &g_Alloc); + +7) Destroy LZMA Encoder Object + LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc); + + +If callback function return some error code, LzmaEnc_Encode also returns that code +or it can return the code like SZ_ERROR_READ, SZ_ERROR_WRITE or SZ_ERROR_PROGRESS. + + +Single-call RAM->RAM Compression +-------------------------------- + +Single-call RAM->RAM Compression is similar to Compression with callbacks, +but you provide pointers to buffers instead of pointers to stream callbacks: + +SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen, + const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark, + ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig); + +Return code: + SZ_OK - OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_PARAM - Incorrect paramater + SZ_ERROR_OUTPUT_EOF - output buffer overflow + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) + + + +Defines +------- + +_LZMA_SIZE_OPT - Enable some optimizations in LZMA Decoder to get smaller executable code. + +_LZMA_PROB32 - It can increase the speed on some 32-bit CPUs, but memory usage for + some structures will be doubled in that case. + +_LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler and long is 32-bit. + +_LZMA_NO_SYSTEM_SIZE_T - Define it if you don't want to use size_t type. + + +_7ZIP_PPMD_SUPPPORT - Define it if you don't want to support PPMD method in AMSI-C .7z decoder. + + +C++ LZMA Encoder/Decoder +~~~~~~~~~~~~~~~~~~~~~~~~ +C++ LZMA code use COM-like interfaces. So if you want to use it, +you can study basics of COM/OLE. +C++ LZMA code is just wrapper over ANSI-C code. + + +C++ Notes +~~~~~~~~~~~~~~~~~~~~~~~~ +If you use some C++ code folders in 7-Zip (for example, C++ code for .7z handling), +you must check that you correctly work with "new" operator. +7-Zip can be compiled with MSVC 6.0 that doesn't throw "exception" from "new" operator. +So 7-Zip uses "CPP\Common\NewHandler.cpp" that redefines "new" operator: +operator new(size_t size) +{ + void *p = ::malloc(size); + if (p == 0) + throw CNewException(); + return p; +} +If you use MSCV that throws exception for "new" operator, you can compile without +"NewHandler.cpp". So standard exception will be used. Actually some code of +7-Zip catches any exception in internal code and converts it to HRESULT code. +So you don't need to catch CNewException, if you call COM interfaces of 7-Zip. + +--- + +http://www.7-zip.org +http://www.7-zip.org/sdk.html +http://www.7-zip.org/support.html diff --git a/deps/OpenCL-Headers/CL/cl.h b/deps/OpenCL-Headers/CL/cl.h index 32ae73fc5..c2cdb4008 100644 --- a/deps/OpenCL-Headers/CL/cl.h +++ b/deps/OpenCL-Headers/CL/cl.h @@ -1,29 +1,17 @@ /******************************************************************************* - * Copyright (c) 2008-2019 The Khronos Group Inc. + * Copyright (c) 2008-2020 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. ******************************************************************************/ #ifndef __OPENCL_CL_H @@ -50,6 +38,7 @@ typedef struct _cl_sampler * cl_sampler; typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ typedef cl_ulong cl_bitfield; +typedef cl_ulong cl_properties; typedef cl_bitfield cl_device_type; typedef cl_uint cl_platform_info; typedef cl_uint cl_device_info; @@ -69,7 +58,7 @@ typedef cl_bitfield cl_device_affinity_domain; typedef intptr_t cl_context_properties; typedef cl_uint cl_context_info; #ifdef CL_VERSION_2_0 -typedef cl_bitfield cl_queue_properties; +typedef cl_properties cl_queue_properties; #endif typedef cl_uint cl_command_queue_info; typedef cl_uint cl_channel_order; @@ -116,9 +105,16 @@ typedef cl_uint cl_event_info; typedef cl_uint cl_command_type; typedef cl_uint cl_profiling_info; #ifdef CL_VERSION_2_0 -typedef cl_bitfield cl_sampler_properties; +typedef cl_properties cl_sampler_properties; typedef cl_uint cl_kernel_exec_info; #endif +#ifdef CL_VERSION_3_0 +typedef cl_bitfield cl_device_atomic_capabilities; +typedef cl_bitfield cl_device_device_enqueue_capabilities; +typedef cl_uint cl_khronos_vendor_id; +typedef cl_properties cl_mem_properties; +typedef cl_uint cl_version; +#endif typedef struct _cl_image_format { cl_channel_order image_channel_order; @@ -138,22 +134,37 @@ typedef struct _cl_image_desc { cl_uint num_mip_levels; cl_uint num_samples; #ifdef CL_VERSION_2_0 -#ifdef __GNUC__ - __extension__ /* Prevents warnings about anonymous union in -pedantic builds */ +#if defined(__GNUC__) + __extension__ /* Prevents warnings about anonymous union in -pedantic builds */ #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__STDC__) #pragma warning( push ) -#pragma warning( disable : 4201 ) /* Prevents warning about nameless struct/union in /W4 /Za builds */ +#pragma warning( disable : 4201 ) /* Prevents warning about nameless struct/union in /W4 builds */ #endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc11-extensions" /* Prevents warning about nameless union being C11 extension*/ +#endif +#if defined(_MSC_VER) && defined(__STDC__) + /* Anonymous unions are not supported in /Za builds */ +#else union { +#endif #endif cl_mem buffer; #ifdef CL_VERSION_2_0 +#if defined(_MSC_VER) && defined(__STDC__) + /* Anonymous unions are not supported in /Za builds */ +#else cl_mem mem_object; }; -#ifdef _MSC_VER +#endif +#if defined(_MSC_VER) && !defined(__STDC__) #pragma warning( pop ) #endif +#ifdef __clang__ +#pragma clang diagnostic pop +#endif #endif } cl_image_desc; @@ -168,6 +179,17 @@ typedef struct _cl_buffer_region { #endif +#ifdef CL_VERSION_3_0 + +#define CL_NAME_VERSION_MAX_NAME_SIZE 64 + +typedef struct _cl_name_version { + cl_version version; + char name[CL_NAME_VERSION_MAX_NAME_SIZE]; +} cl_name_version; + +#endif + /******************************************************************************/ /* Error Codes */ @@ -266,6 +288,10 @@ typedef struct _cl_buffer_region { #ifdef CL_VERSION_2_1 #define CL_PLATFORM_HOST_TIMER_RESOLUTION 0x0905 #endif +#ifdef CL_VERSION_3_0 +#define CL_PLATFORM_NUMERIC_VERSION 0x0906 +#define CL_PLATFORM_EXTENSIONS_WITH_VERSION 0x0907 +#endif /* cl_device_type - bitfield */ #define CL_DEVICE_TYPE_DEFAULT (1 << 0) @@ -385,6 +411,24 @@ typedef struct _cl_buffer_region { #define CL_DEVICE_MAX_NUM_SUB_GROUPS 0x105C #define CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS 0x105D #endif +#ifdef CL_VERSION_3_0 +#define CL_DEVICE_NUMERIC_VERSION 0x105E +#define CL_DEVICE_EXTENSIONS_WITH_VERSION 0x1060 +#define CL_DEVICE_ILS_WITH_VERSION 0x1061 +#define CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION 0x1062 +#define CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES 0x1063 +#define CL_DEVICE_ATOMIC_FENCE_CAPABILITIES 0x1064 +#define CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT 0x1065 +#define CL_DEVICE_OPENCL_C_ALL_VERSIONS 0x1066 +#define CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x1067 +#define CL_DEVICE_WORK_GROUP_COLLECTIVE_FUNCTIONS_SUPPORT 0x1068 +#define CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT 0x1069 +/* 0x106A to 0x106E - Reserved for upcoming KHR extension */ +#define CL_DEVICE_OPENCL_C_FEATURES 0x106F +#define CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES 0x1070 +#define CL_DEVICE_PIPE_SUPPORT 0x1071 +#define CL_DEVICE_LATEST_CONFORMANCE_VERSION_PASSED 0x1072 +#endif /* cl_device_fp_config - bitfield */ #define CL_FP_DENORM (1 << 0) @@ -478,6 +522,9 @@ typedef struct _cl_buffer_region { #ifdef CL_VERSION_2_1 #define CL_QUEUE_DEVICE_DEFAULT 0x1095 #endif +#ifdef CL_VERSION_3_0 +#define CL_QUEUE_PROPERTIES_ARRAY 0x1098 +#endif /* cl_mem_flags and cl_svm_mem_flags - bitfield */ #define CL_MEM_READ_WRITE (1 << 0) @@ -586,6 +633,9 @@ typedef struct _cl_buffer_region { #ifdef CL_VERSION_2_0 #define CL_MEM_USES_SVM_POINTER 0x1109 #endif +#ifdef CL_VERSION_3_0 +#define CL_MEM_PROPERTIES 0x110A +#endif /* cl_image_info */ #define CL_IMAGE_FORMAT 0x1110 @@ -602,12 +652,14 @@ typedef struct _cl_buffer_region { #define CL_IMAGE_NUM_SAMPLES 0x111A #endif -#ifdef CL_VERSION_2_0 /* cl_pipe_info */ +#ifdef CL_VERSION_2_0 #define CL_PIPE_PACKET_SIZE 0x1120 #define CL_PIPE_MAX_PACKETS 0x1121 - +#endif +#ifdef CL_VERSION_3_0 +#define CL_PIPE_PROPERTIES 0x1122 #endif /* cl_addressing_mode */ @@ -637,6 +689,9 @@ typedef struct _cl_buffer_region { #define CL_SAMPLER_LOD_MIN 0x1156 #define CL_SAMPLER_LOD_MAX 0x1157 #endif +#ifdef CL_VERSION_3_0 +#define CL_SAMPLER_PROPERTIES 0x1158 +#endif /* cl_map_flags - bitfield */ #define CL_MAP_READ (1 << 0) @@ -701,10 +756,6 @@ typedef struct _cl_buffer_region { #ifdef CL_VERSION_1_2 #define CL_KERNEL_ATTRIBUTES 0x1195 #endif -#ifdef CL_VERSION_2_1 -#define CL_KERNEL_MAX_NUM_SUB_GROUPS 0x11B9 -#define CL_KERNEL_COMPILE_NUM_SUB_GROUPS 0x11BA -#endif #ifdef CL_VERSION_1_2 @@ -766,6 +817,8 @@ typedef struct _cl_buffer_region { #define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE 0x2033 #define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE 0x2034 #define CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT 0x11B8 +#define CL_KERNEL_MAX_NUM_SUB_GROUPS 0x11B9 +#define CL_KERNEL_COMPILE_NUM_SUB_GROUPS 0x11BA #endif @@ -823,6 +876,9 @@ typedef struct _cl_buffer_region { #define CL_COMMAND_SVM_MAP 0x120C #define CL_COMMAND_SVM_UNMAP 0x120D #endif +#ifdef CL_VERSION_3_0 +#define CL_COMMAND_SVM_MIGRATE_MEM 0x120E +#endif /* command execution status */ #define CL_COMPLETE 0x0 @@ -830,11 +886,9 @@ typedef struct _cl_buffer_region { #define CL_SUBMITTED 0x2 #define CL_QUEUED 0x3 -#ifdef CL_VERSION_1_1 - /* cl_buffer_create_type */ +#ifdef CL_VERSION_1_1 #define CL_BUFFER_CREATE_TYPE_REGION 0x1220 - #endif /* cl_profiling_info */ @@ -846,8 +900,62 @@ typedef struct _cl_buffer_region { #define CL_PROFILING_COMMAND_COMPLETE 0x1284 #endif +/* cl_device_atomic_capabilities - bitfield */ +#ifdef CL_VERSION_3_0 +#define CL_DEVICE_ATOMIC_ORDER_RELAXED (1 << 0) +#define CL_DEVICE_ATOMIC_ORDER_ACQ_REL (1 << 1) +#define CL_DEVICE_ATOMIC_ORDER_SEQ_CST (1 << 2) +#define CL_DEVICE_ATOMIC_SCOPE_WORK_ITEM (1 << 3) +#define CL_DEVICE_ATOMIC_SCOPE_WORK_GROUP (1 << 4) +#define CL_DEVICE_ATOMIC_SCOPE_DEVICE (1 << 5) +#define CL_DEVICE_ATOMIC_SCOPE_ALL_DEVICES (1 << 6) +#endif + +/* cl_device_device_enqueue_capabilities - bitfield */ +#ifdef CL_VERSION_3_0 +#define CL_DEVICE_QUEUE_SUPPORTED (1 << 0) +#define CL_DEVICE_QUEUE_REPLACEABLE_DEFAULT (1 << 1) +#endif + +/* cl_khronos_vendor_id */ +#define CL_KHRONOS_VENDOR_ID_CODEPLAY 0x10004 + +#ifdef CL_VERSION_3_0 + +/* cl_version */ +#define CL_VERSION_MAJOR_BITS (10) +#define CL_VERSION_MINOR_BITS (10) +#define CL_VERSION_PATCH_BITS (12) + +#define CL_VERSION_MAJOR_MASK ((1 << CL_VERSION_MAJOR_BITS) - 1) +#define CL_VERSION_MINOR_MASK ((1 << CL_VERSION_MINOR_BITS) - 1) +#define CL_VERSION_PATCH_MASK ((1 << CL_VERSION_PATCH_BITS) - 1) + +#define CL_VERSION_MAJOR(version) \ + ((version) >> (CL_VERSION_MINOR_BITS + CL_VERSION_PATCH_BITS)) + +#define CL_VERSION_MINOR(version) \ + (((version) >> CL_VERSION_PATCH_BITS) & CL_VERSION_MINOR_MASK) + +#define CL_VERSION_PATCH(version) ((version) & CL_VERSION_PATCH_MASK) + +#define CL_MAKE_VERSION(major, minor, patch) \ + ((((major) & CL_VERSION_MAJOR_MASK) \ + << (CL_VERSION_MINOR_BITS + CL_VERSION_PATCH_BITS)) | \ + (((minor) & CL_VERSION_MINOR_MASK) << CL_VERSION_PATCH_BITS) | \ + ((patch) & CL_VERSION_PATCH_MASK)) + +#endif + /********************************************************************************************************/ +/* CL_NO_PROTOTYPES implies CL_NO_CORE_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_CORE_PROTOTYPES) +#define CL_NO_CORE_PROTOTYPES +#endif + +#if !defined(CL_NO_CORE_PROTOTYPES) + /* Platform API */ extern CL_API_ENTRY cl_int CL_API_CALL clGetPlatformIDs(cl_uint num_entries, @@ -946,6 +1054,16 @@ clGetContextInfo(cl_context context, void * param_value, size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; +#ifdef CL_VERSION_3_0 + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetContextDestructorCallback(cl_context context, + void (CL_CALLBACK* pfn_notify)(cl_context context, + void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_3_0; + +#endif + /* Command Queue APIs */ #ifdef CL_VERSION_2_0 @@ -1014,6 +1132,27 @@ clCreatePipe(cl_context context, #endif +#ifdef CL_VERSION_3_0 + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateBufferWithProperties(cl_context context, + const cl_mem_properties * properties, + cl_mem_flags flags, + size_t size, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_3_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateImageWithProperties(cl_context context, + const cl_mem_properties * properties, + cl_mem_flags flags, + const cl_image_format * image_format, + const cl_image_desc * image_desc, + void * host_ptr, + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_3_0; + +#endif + extern CL_API_ENTRY cl_int CL_API_CALL clRetainMemObject(cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; @@ -1186,11 +1325,11 @@ clLinkProgram(cl_context context, #ifdef CL_VERSION_2_2 -extern CL_API_ENTRY cl_int CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_2_2_DEPRECATED cl_int CL_API_CALL clSetProgramReleaseCallback(cl_program program, void (CL_CALLBACK * pfn_notify)(cl_program program, void * user_data), - void * user_data) CL_API_SUFFIX__VERSION_2_2; + void * user_data) CL_API_SUFFIX__VERSION_2_2_DEPRECATED; extern CL_API_ENTRY cl_int CL_API_CALL clSetProgramSpecializationConstant(cl_program program, @@ -1385,8 +1524,8 @@ extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadBufferRect(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, - const size_t * buffer_offset, - const size_t * host_offset, + const size_t * buffer_origin, + const size_t * host_origin, const size_t * region, size_t buffer_row_pitch, size_t buffer_slice_pitch, @@ -1416,8 +1555,8 @@ extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteBufferRect(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, - const size_t * buffer_offset, - const size_t * host_offset, + const size_t * buffer_origin, + const size_t * host_origin, const size_t * region, size_t buffer_row_pitch, size_t buffer_slice_pitch, @@ -1732,11 +1871,11 @@ clGetExtensionFunctionAddressForPlatform(cl_platform_id platform, clSetCommandQueueProperty(cl_command_queue command_queue, cl_command_queue_properties properties, cl_bool enable, - cl_command_queue_properties * old_properties) CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED; + cl_command_queue_properties * old_properties) CL_API_SUFFIX__VERSION_1_0_DEPRECATED; #endif /* CL_USE_DEPRECATED_OPENCL_1_0_APIS */ /* Deprecated OpenCL 1.1 APIs */ -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateImage2D(cl_context context, cl_mem_flags flags, const cl_image_format * image_format, @@ -1744,9 +1883,9 @@ clCreateImage2D(cl_context context, size_t image_height, size_t image_row_pitch, void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateImage3D(cl_context context, cl_mem_flags flags, const cl_image_format * image_format, @@ -1756,46 +1895,48 @@ clCreateImage3D(cl_context context, size_t image_row_pitch, size_t image_slice_pitch, void * host_ptr, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueMarker(cl_command_queue command_queue, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + cl_event * event) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueWaitForEvents(cl_command_queue command_queue, cl_uint num_events, - const cl_event * event_list) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; + const cl_event * event_list) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL -clEnqueueBarrier(cl_command_queue command_queue) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL +clEnqueueBarrier(cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL -clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL +clUnloadCompiler(void) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED void * CL_API_CALL -clGetExtensionFunctionAddress(const char * func_name) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED void * CL_API_CALL +clGetExtensionFunctionAddress(const char * func_name) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; /* Deprecated OpenCL 2.0 APIs */ -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_command_queue CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_command_queue CL_API_CALL clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED; + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_sampler CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_sampler CL_API_CALL clCreateSampler(cl_context context, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED; + cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2_DEPRECATED; -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int CL_API_CALL +extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_2_DEPRECATED cl_int CL_API_CALL clEnqueueTask(cl_command_queue command_queue, cl_kernel kernel, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED; + cl_event * event) CL_API_SUFFIX__VERSION_1_2_DEPRECATED; + +#endif /* !defined(CL_NO_CORE_PROTOTYPES) */ #ifdef __cplusplus } diff --git a/deps/OpenCL-Headers/CL/cl_d3d10.h b/deps/OpenCL-Headers/CL/cl_d3d10.h index d5960a43f..3d8fe1312 100644 --- a/deps/OpenCL-Headers/CL/cl_d3d10.h +++ b/deps/OpenCL-Headers/CL/cl_d3d10.h @@ -1,131 +1,241 @@ -/********************************************************************************** - * Copyright (c) 2008-2015 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#ifndef OPENCL_CL_D3D10_H_ +#define OPENCL_CL_D3D10_H_ + +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ + +#if defined(_MSC_VER) +#if _MSC_VER >=1500 +#pragma warning( push ) +#pragma warning( disable : 4201 ) +#pragma warning( disable : 5105 ) +#endif +#endif +#include +#if defined(_MSC_VER) +#if _MSC_VER >=1500 +#pragma warning( pop ) +#endif +#endif -/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ +#include -#ifndef __OPENCL_CL_D3D10_H -#define __OPENCL_CL_D3D10_H +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif -#include -#include -#include +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif #ifdef __cplusplus extern "C" { #endif -/****************************************************************************** - * cl_khr_d3d10_sharing */ +/*************************************************************** +* cl_khr_d3d10_sharing +***************************************************************/ #define cl_khr_d3d10_sharing 1 +#define CL_KHR_D3D10_SHARING_EXTENSION_NAME \ + "cl_khr_d3d10_sharing" -typedef cl_uint cl_d3d10_device_source_khr; -typedef cl_uint cl_d3d10_device_set_khr; +typedef cl_uint cl_d3d10_device_source_khr; +typedef cl_uint cl_d3d10_device_set_khr; -/******************************************************************************/ +/* Error codes */ +#define CL_INVALID_D3D10_DEVICE_KHR -1002 +#define CL_INVALID_D3D10_RESOURCE_KHR -1003 +#define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004 +#define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005 -/* Error Codes */ -#define CL_INVALID_D3D10_DEVICE_KHR -1002 -#define CL_INVALID_D3D10_RESOURCE_KHR -1003 -#define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004 -#define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005 +/* cl_d3d10_device_source_khr */ +#define CL_D3D10_DEVICE_KHR 0x4010 +#define CL_D3D10_DXGI_ADAPTER_KHR 0x4011 -/* cl_d3d10_device_source_nv */ -#define CL_D3D10_DEVICE_KHR 0x4010 -#define CL_D3D10_DXGI_ADAPTER_KHR 0x4011 - -/* cl_d3d10_device_set_nv */ -#define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012 -#define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013 +/* cl_d3d10_device_set_khr */ +#define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012 +#define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013 /* cl_context_info */ -#define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014 -#define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C +#define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014 +#define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C /* cl_mem_info */ -#define CL_MEM_D3D10_RESOURCE_KHR 0x4015 +#define CL_MEM_D3D10_RESOURCE_KHR 0x4015 /* cl_image_info */ -#define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016 +#define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016 /* cl_command_type */ -#define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017 -#define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018 +#define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017 +#define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018 -/******************************************************************************/ -typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)( - cl_platform_id platform, +typedef cl_int (CL_API_CALL * +clGetDeviceIDsFromD3D10KHR_fn)( + cl_platform_id platform, cl_d3d10_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d10_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)( - cl_context context, - cl_mem_flags flags, - ID3D10Buffer * resource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)( - cl_context context, - cl_mem_flags flags, - ID3D10Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)( - cl_context context, - cl_mem_flags flags, - ID3D10Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)( + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem (CL_API_CALL * +clCreateFromD3D10BufferKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer* resource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem (CL_API_CALL * +clCreateFromD3D10Texture2DKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem (CL_API_CALL * +clCreateFromD3D10Texture3DKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireD3D10ObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseD3D10ObjectsKHR_fn)( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)( +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D10KHR( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Buffer* resource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D10Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D10ObjectsKHR( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D10ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_sharing_format_query_d3d10 +***************************************************************/ +#define cl_intel_sharing_format_query_d3d10 1 +#define CL_INTEL_SHARING_FORMAT_QUERY_D3D10_EXTENSION_NAME \ + "cl_intel_sharing_format_query_d3d10" + +/* when cl_khr_d3d10_sharing is supported */ + +typedef cl_int (CL_API_CALL * +clGetSupportedD3D10TextureFormatsINTEL_fn)( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + DXGI_FORMAT* d3d10_formats, + cl_uint* num_texture_formats) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedD3D10TextureFormatsINTEL( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + DXGI_FORMAT* d3d10_formats, + cl_uint* num_texture_formats) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif -#endif /* __OPENCL_CL_D3D10_H */ - +#endif /* OPENCL_CL_D3D10_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_d3d11.h b/deps/OpenCL-Headers/CL/cl_d3d11.h index 39f907239..6a6af21dc 100644 --- a/deps/OpenCL-Headers/CL/cl_d3d11.h +++ b/deps/OpenCL-Headers/CL/cl_d3d11.h @@ -1,131 +1,243 @@ -/********************************************************************************** - * Copyright (c) 2008-2015 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#ifndef OPENCL_CL_D3D11_H_ +#define OPENCL_CL_D3D11_H_ + +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ + +#if defined(_MSC_VER) +#if _MSC_VER >=1500 +#pragma warning( push ) +#pragma warning( disable : 4201 ) +#pragma warning( disable : 5105 ) +#endif +#endif +#include +#if defined(_MSC_VER) +#if _MSC_VER >=1500 +#pragma warning( pop ) +#endif +#endif -/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ +#include -#ifndef __OPENCL_CL_D3D11_H -#define __OPENCL_CL_D3D11_H +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif -#include -#include -#include +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif #ifdef __cplusplus extern "C" { #endif -/****************************************************************************** - * cl_khr_d3d11_sharing */ +/*************************************************************** +* cl_khr_d3d11_sharing +***************************************************************/ #define cl_khr_d3d11_sharing 1 +#define CL_KHR_D3D11_SHARING_EXTENSION_NAME \ + "cl_khr_d3d11_sharing" -typedef cl_uint cl_d3d11_device_source_khr; -typedef cl_uint cl_d3d11_device_set_khr; +typedef cl_uint cl_d3d11_device_source_khr; +typedef cl_uint cl_d3d11_device_set_khr; -/******************************************************************************/ +/* Error codes */ +#define CL_INVALID_D3D11_DEVICE_KHR -1006 +#define CL_INVALID_D3D11_RESOURCE_KHR -1007 +#define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008 +#define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009 -/* Error Codes */ -#define CL_INVALID_D3D11_DEVICE_KHR -1006 -#define CL_INVALID_D3D11_RESOURCE_KHR -1007 -#define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008 -#define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009 +/* cl_d3d11_device_source_khr */ +#define CL_D3D11_DEVICE_KHR 0x4019 +#define CL_D3D11_DXGI_ADAPTER_KHR 0x401A -/* cl_d3d11_device_source */ -#define CL_D3D11_DEVICE_KHR 0x4019 -#define CL_D3D11_DXGI_ADAPTER_KHR 0x401A - -/* cl_d3d11_device_set */ -#define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B -#define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C +/* cl_d3d11_device_set_khr */ +#define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B +#define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C /* cl_context_info */ -#define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D -#define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D +#define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D +#define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D /* cl_mem_info */ -#define CL_MEM_D3D11_RESOURCE_KHR 0x401E +#define CL_MEM_D3D11_RESOURCE_KHR 0x401E /* cl_image_info */ -#define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F +#define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F /* cl_command_type */ -#define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020 -#define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021 +#define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020 +#define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021 -/******************************************************************************/ -typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)( - cl_platform_id platform, +typedef cl_int (CL_API_CALL * +clGetDeviceIDsFromD3D11KHR_fn)( + cl_platform_id platform, cl_d3d11_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d11_device_set_khr d3d_device_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferKHR_fn)( - cl_context context, - cl_mem_flags flags, - ID3D11Buffer * resource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)( - cl_context context, - cl_mem_flags flags, - ID3D11Texture2D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)( - cl_context context, - cl_mem_flags flags, - ID3D11Texture3D * resource, - UINT subresource, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)( + void* d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem (CL_API_CALL * +clCreateFromD3D11BufferKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer* resource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem (CL_API_CALL * +clCreateFromD3D11Texture2DKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem (CL_API_CALL * +clCreateFromD3D11Texture3DKHR_fn)( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireD3D11ObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseD3D11ObjectsKHR_fn)( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)( +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, + cl_d3d11_device_source_khr d3d_device_source, + void* d3d_object, + cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11BufferKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Buffer* resource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture2DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture2D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11Texture3DKHR( + cl_context context, + cl_mem_flags flags, + ID3D11Texture3D* resource, + UINT subresource, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireD3D11ObjectsKHR( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseD3D11ObjectsKHR( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_sharing_format_query_d3d11 +***************************************************************/ +#define cl_intel_sharing_format_query_d3d11 1 +#define CL_INTEL_SHARING_FORMAT_QUERY_D3D11_EXTENSION_NAME \ + "cl_intel_sharing_format_query_d3d11" + +/* when cl_khr_d3d11_sharing is supported */ + +typedef cl_int (CL_API_CALL * +clGetSupportedD3D11TextureFormatsINTEL_fn)( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint plane, + cl_uint num_entries, + DXGI_FORMAT* d3d11_formats, + cl_uint* num_texture_formats) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedD3D11TextureFormatsINTEL( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint plane, + cl_uint num_entries, + DXGI_FORMAT* d3d11_formats, + cl_uint* num_texture_formats) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif -#endif /* __OPENCL_CL_D3D11_H */ - +#endif /* OPENCL_CL_D3D11_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_dx9_media_sharing.h b/deps/OpenCL-Headers/CL/cl_dx9_media_sharing.h index 2729e8b9e..e7f8c452e 100644 --- a/deps/OpenCL-Headers/CL/cl_dx9_media_sharing.h +++ b/deps/OpenCL-Headers/CL/cl_dx9_media_sharing.h @@ -1,132 +1,350 @@ -/********************************************************************************** - * Copyright (c) 2008-2015 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#ifndef OPENCL_CL_DX9_MEDIA_SHARING_H_ +#define OPENCL_CL_DX9_MEDIA_SHARING_H_ -/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ -#ifndef __OPENCL_CL_DX9_MEDIA_SHARING_H -#define __OPENCL_CL_DX9_MEDIA_SHARING_H +#if defined(_WIN32) +#if defined(_MSC_VER) +#if _MSC_VER >=1500 +#pragma warning( push ) +#pragma warning( disable : 4201 ) +#pragma warning( disable : 5105 ) +#endif +#endif +#include +#if defined(_MSC_VER) +#if _MSC_VER >=1500 +#pragma warning( pop ) +#endif +#endif +#endif #include -#include + +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif + +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif #ifdef __cplusplus extern "C" { #endif -/******************************************************************************/ -/* cl_khr_dx9_media_sharing */ +/*************************************************************** +* cl_khr_dx9_media_sharing +***************************************************************/ #define cl_khr_dx9_media_sharing 1 +#define CL_KHR_DX9_MEDIA_SHARING_EXTENSION_NAME \ + "cl_khr_dx9_media_sharing" typedef cl_uint cl_dx9_media_adapter_type_khr; typedef cl_uint cl_dx9_media_adapter_set_khr; - + #if defined(_WIN32) -#include -typedef struct _cl_dx9_surface_info_khr -{ - IDirect3DSurface9 *resource; +typedef struct _cl_dx9_surface_info_khr { + IDirect3DSurface9* resource; HANDLE shared_handle; } cl_dx9_surface_info_khr; -#endif +#endif /* defined(_WIN32) */ -/******************************************************************************/ - -/* Error Codes */ -#define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 -#define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 -#define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 -#define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 +/* Error codes */ +#define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 +#define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 +#define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 +#define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 /* cl_media_adapter_type_khr */ -#define CL_ADAPTER_D3D9_KHR 0x2020 -#define CL_ADAPTER_D3D9EX_KHR 0x2021 -#define CL_ADAPTER_DXVA_KHR 0x2022 +#define CL_ADAPTER_D3D9_KHR 0x2020 +#define CL_ADAPTER_D3D9EX_KHR 0x2021 +#define CL_ADAPTER_DXVA_KHR 0x2022 /* cl_media_adapter_set_khr */ -#define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 -#define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 +#define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 +#define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 /* cl_context_info */ -#define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 -#define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 -#define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 +#define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 +#define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 +#define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 /* cl_mem_info */ -#define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 -#define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 +#define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 +#define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 /* cl_image_info */ -#define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A +#define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A /* cl_command_type */ -#define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B -#define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C - -/******************************************************************************/ - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( - cl_platform_id platform, - cl_uint num_media_adapters, - cl_dx9_media_adapter_type_khr * media_adapter_type, - void * media_adapters, - cl_dx9_media_adapter_set_khr media_adapter_set, - cl_uint num_entries, - cl_device_id * devices, - cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)( - cl_context context, - cl_mem_flags flags, +#define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B +#define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C + + +typedef cl_int (CL_API_CALL * +clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr* media_adapter_type, + void* media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem (CL_API_CALL * +clCreateFromDX9MediaSurfaceKHR_fn)( + cl_context context, + cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, + void* surface_info, + cl_uint plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireDX9MediaSurfacesKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseDX9MediaSurfacesKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, + cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr* media_adapter_type, + void* media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromDX9MediaSurfaceKHR( + cl_context context, + cl_mem_flags flags, cl_dx9_media_adapter_type_khr adapter_type, - void * surface_info, - cl_uint plane, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; + void* surface_info, + cl_uint plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)( +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireDX9MediaSurfacesKHR( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)( +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseDX9MediaSurfacesKHR( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_2; + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_dx9_media_sharing +***************************************************************/ +#define cl_intel_dx9_media_sharing 1 +#define CL_INTEL_DX9_MEDIA_SHARING_EXTENSION_NAME \ + "cl_intel_dx9_media_sharing" + +typedef cl_uint cl_dx9_device_source_intel; +typedef cl_uint cl_dx9_device_set_intel; + +/* Error codes */ +#define CL_INVALID_DX9_DEVICE_INTEL -1010 +#define CL_INVALID_DX9_RESOURCE_INTEL -1011 +#define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL -1012 +#define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL -1013 + +/* cl_dx9_device_source_intel */ +#define CL_D3D9_DEVICE_INTEL 0x4022 +#define CL_D3D9EX_DEVICE_INTEL 0x4070 +#define CL_DXVA_DEVICE_INTEL 0x4071 + +/* cl_dx9_device_set_intel */ +#define CL_PREFERRED_DEVICES_FOR_DX9_INTEL 0x4024 +#define CL_ALL_DEVICES_FOR_DX9_INTEL 0x4025 + +/* cl_context_info */ +#define CL_CONTEXT_D3D9_DEVICE_INTEL 0x4026 +#define CL_CONTEXT_D3D9EX_DEVICE_INTEL 0x4072 +#define CL_CONTEXT_DXVA_DEVICE_INTEL 0x4073 + +/* cl_mem_info */ +#define CL_MEM_DX9_RESOURCE_INTEL 0x4027 +#define CL_MEM_DX9_SHARED_HANDLE_INTEL 0x4074 + +/* cl_image_info */ +#define CL_IMAGE_DX9_PLANE_INTEL 0x4075 + +/* cl_command_type */ +#define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL 0x402A +#define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL 0x402B + + +typedef cl_int (CL_API_CALL * +clGetDeviceIDsFromDX9INTEL_fn)( + cl_platform_id platform, + cl_dx9_device_source_intel dx9_device_source, + void* dx9_object, + cl_dx9_device_set_intel dx9_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_mem (CL_API_CALL * +clCreateFromDX9MediaSurfaceINTEL_fn)( + cl_context context, + cl_mem_flags flags, + IDirect3DSurface9* resource, + HANDLE sharedHandle, + UINT plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireDX9ObjectsINTEL_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseDX9ObjectsINTEL_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetDeviceIDsFromDX9INTEL( + cl_platform_id platform, + cl_dx9_device_source_intel dx9_device_source, + void* dx9_object, + cl_dx9_device_set_intel dx9_device_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromDX9MediaSurfaceINTEL( + cl_context context, + cl_mem_flags flags, + IDirect3DSurface9* resource, + HANDLE sharedHandle, + UINT plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireDX9ObjectsINTEL( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseDX9ObjectsINTEL( + cl_command_queue command_queue, + cl_uint num_objects, + cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_1; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_sharing_format_query_dx9 +***************************************************************/ +#define cl_intel_sharing_format_query_dx9 1 +#define CL_INTEL_SHARING_FORMAT_QUERY_DX9_EXTENSION_NAME \ + "cl_intel_sharing_format_query_dx9" + +/* when cl_khr_dx9_media_sharing or cl_intel_dx9_media_sharing is supported */ + +typedef cl_int (CL_API_CALL * +clGetSupportedDX9MediaSurfaceFormatsINTEL_fn)( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint plane, + cl_uint num_entries, + D3DFORMAT* dx9_formats, + cl_uint* num_surface_formats) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedDX9MediaSurfaceFormatsINTEL( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint plane, + cl_uint num_entries, + D3DFORMAT* dx9_formats, + cl_uint* num_surface_formats) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif -#endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */ - +#endif /* OPENCL_CL_DX9_MEDIA_SHARING_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_dx9_media_sharing_intel.h b/deps/OpenCL-Headers/CL/cl_dx9_media_sharing_intel.h index 737e68564..f6518d7f6 100644 --- a/deps/OpenCL-Headers/CL/cl_dx9_media_sharing_intel.h +++ b/deps/OpenCL-Headers/CL/cl_dx9_media_sharing_intel.h @@ -1,182 +1,18 @@ -/********************************************************************************** - * Copyright (c) 2008-2019 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2020 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ -/*****************************************************************************\ - -Copyright (c) 2013-2019 Intel Corporation All Rights Reserved. - -THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE -MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -File Name: cl_dx9_media_sharing_intel.h - -Abstract: - -Notes: - -\*****************************************************************************/ - -#ifndef __OPENCL_CL_DX9_MEDIA_SHARING_INTEL_H -#define __OPENCL_CL_DX9_MEDIA_SHARING_INTEL_H - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*************************************** -* cl_intel_dx9_media_sharing extension * -****************************************/ - -#define cl_intel_dx9_media_sharing 1 - -typedef cl_uint cl_dx9_device_source_intel; -typedef cl_uint cl_dx9_device_set_intel; - -/* error codes */ -#define CL_INVALID_DX9_DEVICE_INTEL -1010 -#define CL_INVALID_DX9_RESOURCE_INTEL -1011 -#define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL -1012 -#define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL -1013 - -/* cl_dx9_device_source_intel */ -#define CL_D3D9_DEVICE_INTEL 0x4022 -#define CL_D3D9EX_DEVICE_INTEL 0x4070 -#define CL_DXVA_DEVICE_INTEL 0x4071 - -/* cl_dx9_device_set_intel */ -#define CL_PREFERRED_DEVICES_FOR_DX9_INTEL 0x4024 -#define CL_ALL_DEVICES_FOR_DX9_INTEL 0x4025 - -/* cl_context_info */ -#define CL_CONTEXT_D3D9_DEVICE_INTEL 0x4026 -#define CL_CONTEXT_D3D9EX_DEVICE_INTEL 0x4072 -#define CL_CONTEXT_DXVA_DEVICE_INTEL 0x4073 - -/* cl_mem_info */ -#define CL_MEM_DX9_RESOURCE_INTEL 0x4027 -#define CL_MEM_DX9_SHARED_HANDLE_INTEL 0x4074 - -/* cl_image_info */ -#define CL_IMAGE_DX9_PLANE_INTEL 0x4075 - -/* cl_command_type */ -#define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL 0x402A -#define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL 0x402B -/******************************************************************************/ - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceIDsFromDX9INTEL( - cl_platform_id platform, - cl_dx9_device_source_intel dx9_device_source, - void* dx9_object, - cl_dx9_device_set_intel dx9_device_set, - cl_uint num_entries, - cl_device_id* devices, - cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL* clGetDeviceIDsFromDX9INTEL_fn)( - cl_platform_id platform, - cl_dx9_device_source_intel dx9_device_source, - void* dx9_object, - cl_dx9_device_set_intel dx9_device_set, - cl_uint num_entries, - cl_device_id* devices, - cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromDX9MediaSurfaceINTEL( - cl_context context, - cl_mem_flags flags, - IDirect3DSurface9* resource, - HANDLE sharedHandle, - UINT plane, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)( - cl_context context, - cl_mem_flags flags, - IDirect3DSurface9* resource, - HANDLE sharedHandle, - UINT plane, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireDX9ObjectsINTEL( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; - -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseDX9ObjectsINTEL( - cl_command_queue command_queue, - cl_uint num_objects, - cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)( - cl_command_queue command_queue, - cl_uint num_objects, - cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_1; - -#ifdef __cplusplus -} -#endif - -#endif /* __OPENCL_CL_DX9_MEDIA_SHARING_INTEL_H */ - + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#include +#pragma message("The Intel DX9 media sharing extensions have been moved into cl_dx9_media_sharing.h. Please include cl_dx9_media_sharing.h directly.") diff --git a/deps/OpenCL-Headers/CL/cl_egl.h b/deps/OpenCL-Headers/CL/cl_egl.h index bc4d998eb..e2db9025d 100644 --- a/deps/OpenCL-Headers/CL/cl_egl.h +++ b/deps/OpenCL-Headers/CL/cl_egl.h @@ -1,132 +1,167 @@ /******************************************************************************* - * Copyright (c) 2008-2019 The Khronos Group Inc. + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. ******************************************************************************/ -#ifndef __OPENCL_CL_EGL_H -#define __OPENCL_CL_EGL_H +#ifndef OPENCL_CL_EGL_H_ +#define OPENCL_CL_EGL_H_ + +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ #include +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif + +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif + #ifdef __cplusplus extern "C" { #endif +/*************************************************************** +* cl_khr_egl_image +***************************************************************/ +#define cl_khr_egl_image 1 +#define CL_KHR_EGL_IMAGE_EXTENSION_NAME \ + "cl_khr_egl_image" /* Command type for events created with clEnqueueAcquireEGLObjectsKHR */ -#define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F -#define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D -#define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E +#define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F +#define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D +#define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E /* Error type for clCreateFromEGLImageKHR */ -#define CL_INVALID_EGL_OBJECT_KHR -1093 -#define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092 +#define CL_INVALID_EGL_OBJECT_KHR -1093 +#define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092 /* CLeglImageKHR is an opaque handle to an EGLImage */ -typedef void* CLeglImageKHR; +typedef void* CLeglImageKHR; /* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ -typedef void* CLeglDisplayKHR; - -/* CLeglSyncKHR is an opaque handle to an EGLSync object */ -typedef void* CLeglSyncKHR; +typedef void* CLeglDisplayKHR; /* properties passed to clCreateFromEGLImageKHR */ -typedef intptr_t cl_egl_image_properties_khr; +typedef intptr_t cl_egl_image_properties_khr; -#define cl_khr_egl_image 1 +typedef cl_mem (CL_API_CALL * +clCreateFromEGLImageKHR_fn)( + cl_context context, + CLeglDisplayKHR egldisplay, + CLeglImageKHR eglimage, + cl_mem_flags flags, + const cl_egl_image_properties_khr* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; -extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromEGLImageKHR(cl_context context, - CLeglDisplayKHR egldisplay, - CLeglImageKHR eglimage, - cl_mem_flags flags, - const cl_egl_image_properties_khr * properties, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)( - cl_context context, - CLeglDisplayKHR egldisplay, - CLeglImageKHR eglimage, - cl_mem_flags flags, - const cl_egl_image_properties_khr * properties, - cl_int * errcode_ret); +typedef cl_int (CL_API_CALL * +clEnqueueAcquireEGLObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseEGLObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromEGLImageKHR( + cl_context context, + CLeglDisplayKHR egldisplay, + CLeglImageKHR eglimage, + cl_mem_flags flags, + const cl_egl_image_properties_khr* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireEGLObjectsKHR(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)( +clEnqueueAcquireEGLObjectsKHR( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); - + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseEGLObjectsKHR(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)( +clEnqueueReleaseEGLObjectsKHR( cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ +/*************************************************************** +* cl_khr_egl_event +***************************************************************/ #define cl_khr_egl_event 1 +#define CL_KHR_EGL_EVENT_EXTENSION_NAME \ + "cl_khr_egl_event" + +/* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ +/* type CLeglDisplayKHR */ + +/* CLeglSyncKHR is an opaque handle to an EGLSync object */ +typedef void* CLeglSyncKHR; + + +typedef cl_event (CL_API_CALL * +clCreateEventFromEGLSyncKHR_fn)( + cl_context context, + CLeglSyncKHR sync, + CLeglDisplayKHR display, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_event CL_API_CALL -clCreateEventFromEGLSyncKHR(cl_context context, - CLeglSyncKHR sync, - CLeglDisplayKHR display, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)( - cl_context context, - CLeglSyncKHR sync, +clCreateEventFromEGLSyncKHR( + cl_context context, + CLeglSyncKHR sync, CLeglDisplayKHR display, - cl_int * errcode_ret); + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif -#endif /* __OPENCL_CL_EGL_H */ +#endif /* OPENCL_CL_EGL_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_ext.h b/deps/OpenCL-Headers/CL/cl_ext.h index 7f82e92a7..12ebd0437 100644 --- a/deps/OpenCL-Headers/CL/cl_ext.h +++ b/deps/OpenCL-Headers/CL/cl_ext.h @@ -1,750 +1,3277 @@ /******************************************************************************* - * Copyright (c) 2008-2019 The Khronos Group Inc. + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. ******************************************************************************/ -/* cl_ext.h contains OpenCL extensions which don't have external */ -/* (OpenGL, D3D) dependencies. */ +#ifndef OPENCL_CL_EXT_H_ +#define OPENCL_CL_EXT_H_ + +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ + +#include + +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif -#ifndef __CL_EXT_H -#define __CL_EXT_H +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif #ifdef __cplusplus extern "C" { #endif -#include +/*************************************************************** +* cl_khr_command_buffer +***************************************************************/ +#define cl_khr_command_buffer 1 +#define CL_KHR_COMMAND_BUFFER_EXTENSION_NAME \ + "cl_khr_command_buffer" + +typedef cl_bitfield cl_device_command_buffer_capabilities_khr; +typedef struct _cl_command_buffer_khr* cl_command_buffer_khr; +typedef cl_uint cl_sync_point_khr; +typedef cl_uint cl_command_buffer_info_khr; +typedef cl_uint cl_command_buffer_state_khr; +typedef cl_properties cl_command_buffer_properties_khr; +typedef cl_bitfield cl_command_buffer_flags_khr; +typedef cl_properties cl_ndrange_kernel_command_properties_khr; +typedef struct _cl_mutable_command_khr* cl_mutable_command_khr; -/* cl_khr_fp64 extension - no extension #define since it has no functions */ -/* CL_DEVICE_DOUBLE_FP_CONFIG is defined in CL.h for OpenCL >= 120 */ +/* cl_device_info */ +#define CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR 0x12A9 +#define CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR 0x12AA + +/* cl_device_command_buffer_capabilities_khr - bitfield */ +#define CL_COMMAND_BUFFER_CAPABILITY_KERNEL_PRINTF_KHR (1 << 0) +#define CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR (1 << 1) +#define CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR (1 << 2) +#define CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR (1 << 3) + +/* cl_command_buffer_properties_khr */ +#define CL_COMMAND_BUFFER_FLAGS_KHR 0x1293 + +/* cl_command_buffer_flags_khr - bitfield */ +#define CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR (1 << 0) + +/* Error codes */ +#define CL_INVALID_COMMAND_BUFFER_KHR -1138 +#define CL_INVALID_SYNC_POINT_WAIT_LIST_KHR -1139 +#define CL_INCOMPATIBLE_COMMAND_QUEUE_KHR -1140 + +/* cl_command_buffer_info_khr */ +#define CL_COMMAND_BUFFER_QUEUES_KHR 0x1294 +#define CL_COMMAND_BUFFER_NUM_QUEUES_KHR 0x1295 +#define CL_COMMAND_BUFFER_REFERENCE_COUNT_KHR 0x1296 +#define CL_COMMAND_BUFFER_STATE_KHR 0x1297 +#define CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR 0x1298 +#define CL_COMMAND_BUFFER_CONTEXT_KHR 0x1299 + +/* cl_command_buffer_state_khr */ +#define CL_COMMAND_BUFFER_STATE_RECORDING_KHR 0 +#define CL_COMMAND_BUFFER_STATE_EXECUTABLE_KHR 1 +#define CL_COMMAND_BUFFER_STATE_PENDING_KHR 2 +#define CL_COMMAND_BUFFER_STATE_INVALID_KHR 3 + +/* cl_command_type */ +#define CL_COMMAND_COMMAND_BUFFER_KHR 0x12A8 + + +typedef cl_command_buffer_khr (CL_API_CALL * +clCreateCommandBufferKHR_fn)( + cl_uint num_queues, + const cl_command_queue* queues, + const cl_command_buffer_properties_khr* properties, + cl_int* errcode_ret) ; + +typedef cl_int (CL_API_CALL * +clFinalizeCommandBufferKHR_fn)( + cl_command_buffer_khr command_buffer) ; + +typedef cl_int (CL_API_CALL * +clRetainCommandBufferKHR_fn)( + cl_command_buffer_khr command_buffer) ; + +typedef cl_int (CL_API_CALL * +clReleaseCommandBufferKHR_fn)( + cl_command_buffer_khr command_buffer) ; + +typedef cl_int (CL_API_CALL * +clEnqueueCommandBufferKHR_fn)( + cl_uint num_queues, + cl_command_queue* queues, + cl_command_buffer_khr command_buffer, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +typedef cl_int (CL_API_CALL * +clCommandBarrierWithWaitListKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandCopyBufferKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t size, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandCopyBufferRectKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandCopyBufferToImageKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t* dst_origin, + const size_t* region, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandCopyImageKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandCopyImageToBufferKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* region, + size_t dst_offset, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandFillBufferKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem buffer, + const void* pattern, + size_t pattern_size, + size_t offset, + size_t size, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandFillImageKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem image, + const void* fill_color, + const size_t* origin, + const size_t* region, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clCommandNDRangeKernelKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + const cl_ndrange_kernel_command_properties_khr* properties, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + const size_t* local_work_size, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; + +typedef cl_int (CL_API_CALL * +clGetCommandBufferInfoKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_command_buffer_info_khr param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_command_buffer_khr CL_API_CALL +clCreateCommandBufferKHR( + cl_uint num_queues, + const cl_command_queue* queues, + const cl_command_buffer_properties_khr* properties, + cl_int* errcode_ret) ; -#if CL_TARGET_OPENCL_VERSION <= 110 -#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 -#endif +extern CL_API_ENTRY cl_int CL_API_CALL +clFinalizeCommandBufferKHR( + cl_command_buffer_khr command_buffer) ; -/* cl_khr_fp16 extension - no extension #define since it has no functions */ -#define CL_DEVICE_HALF_FP_CONFIG 0x1033 +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainCommandBufferKHR( + cl_command_buffer_khr command_buffer) ; -/* Memory object destruction - * - * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR - * - * Registers a user callback function that will be called when the memory object is deleted and its resources - * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback - * stack associated with memobj. The registered user callback functions are called in the reverse order in - * which they were registered. The user callback functions are called and then the memory object is deleted - * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be - * notified when the memory referenced by host_ptr, specified when the memory object is created and used as - * the storage bits for the memory object, can be reused or freed. - * - * The application may not call CL api's with the cl_mem object passed to the pfn_notify. - * - * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) - * before using. - */ -#define cl_APPLE_SetMemObjectDestructor 1 -cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem memobj, - void (* pfn_notify)(cl_mem memobj, void * user_data), - void * user_data) CL_EXT_SUFFIX__VERSION_1_0; +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseCommandBufferKHR( + cl_command_buffer_khr command_buffer) ; +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueCommandBufferKHR( + cl_uint num_queues, + cl_command_queue* queues, + cl_command_buffer_khr command_buffer, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; -/* Context Logging Functions - * - * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext(). - * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) - * before using. - * - * clLogMessagesToSystemLog forwards on all log messages to the Apple System Logger - */ -#define cl_APPLE_ContextLoggingFunctions 1 -extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * errstr, - const void * private_info, - size_t cb, - void * user_data) CL_EXT_SUFFIX__VERSION_1_0; - -/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */ -extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * errstr, - const void * private_info, - size_t cb, - void * user_data) CL_EXT_SUFFIX__VERSION_1_0; - -/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */ -extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * errstr, - const void * private_info, - size_t cb, - void * user_data) CL_EXT_SUFFIX__VERSION_1_0; - - -/************************ -* cl_khr_icd extension * -************************/ -#define cl_khr_icd 1 +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandBarrierWithWaitListKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -/* cl_platform_info */ -#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandCopyBufferKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + size_t src_offset, + size_t dst_offset, + size_t size, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -/* Additional Error Codes */ -#define CL_PLATFORM_NOT_FOUND_KHR -1001 +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandCopyBufferRectKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + size_t src_row_pitch, + size_t src_slice_pitch, + size_t dst_row_pitch, + size_t dst_slice_pitch, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; extern CL_API_ENTRY cl_int CL_API_CALL -clIcdGetPlatformIDsKHR(cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms); +clCommandCopyBufferToImageKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_buffer, + cl_mem dst_image, + size_t src_offset, + const size_t* dst_origin, + const size_t* region, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -typedef CL_API_ENTRY cl_int -(CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(cl_uint num_entries, - cl_platform_id * platforms, - cl_uint * num_platforms); +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandCopyImageKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + const size_t* src_origin, + const size_t* dst_origin, + const size_t* region, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandCopyImageToBufferKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_buffer, + const size_t* src_origin, + const size_t* region, + size_t dst_offset, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -/******************************* - * cl_khr_il_program extension * - *******************************/ -#define cl_khr_il_program 1 +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandFillBufferKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem buffer, + const void* pattern, + size_t pattern_size, + size_t offset, + size_t size, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -/* New property to clGetDeviceInfo for retrieving supported intermediate - * languages - */ -#define CL_DEVICE_IL_VERSION_KHR 0x105B +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandFillImageKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + cl_mem image, + const void* fill_color, + const size_t* origin, + const size_t* region, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -/* New property to clGetProgramInfo for retrieving for retrieving the IL of a - * program - */ -#define CL_PROGRAM_IL_KHR 0x1169 +extern CL_API_ENTRY cl_int CL_API_CALL +clCommandNDRangeKernelKHR( + cl_command_buffer_khr command_buffer, + cl_command_queue command_queue, + const cl_ndrange_kernel_command_properties_khr* properties, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + const size_t* local_work_size, + cl_uint num_sync_points_in_wait_list, + const cl_sync_point_khr* sync_point_wait_list, + cl_sync_point_khr* sync_point, + cl_mutable_command_khr* mutable_handle) ; -extern CL_API_ENTRY cl_program CL_API_CALL -clCreateProgramWithILKHR(cl_context context, - const void * il, - size_t length, - cl_int * errcode_ret); - -typedef CL_API_ENTRY cl_program -(CL_API_CALL *clCreateProgramWithILKHR_fn)(cl_context context, - const void * il, - size_t length, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; - -/* Extension: cl_khr_image2d_from_buffer - * - * This extension allows a 2D image to be created from a cl_mem buffer without - * a copy. The type associated with a 2D image created from a buffer in an - * OpenCL program is image2d_t. Both the sampler and sampler-less read_image - * built-in functions are supported for 2D images and 2D images created from - * a buffer. Similarly, the write_image built-ins are also supported for 2D - * images created from a buffer. - * - * When the 2D image from buffer is created, the client must specify the - * width, height, image format (i.e. channel order and channel data type) - * and optionally the row pitch. - * - * The pitch specified must be a multiple of - * CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR pixels. - * The base address of the buffer must be aligned to - * CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR pixels. - */ +extern CL_API_ENTRY cl_int CL_API_CALL +clGetCommandBufferInfoKHR( + cl_command_buffer_khr command_buffer, + cl_command_buffer_info_khr param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; -#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR 0x104A -#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR 0x104B +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ +/*************************************************************** +* cl_khr_command_buffer_multi_device +***************************************************************/ +#define cl_khr_command_buffer_multi_device 1 +#define CL_KHR_COMMAND_BUFFER_MULTI_DEVICE_EXTENSION_NAME \ + "cl_khr_command_buffer_multi_device" -/************************************** - * cl_khr_initialize_memory extension * - **************************************/ +typedef cl_bitfield cl_platform_command_buffer_capabilities_khr; -#define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x2030 +/* cl_platform_info */ +#define CL_PLATFORM_COMMAND_BUFFER_CAPABILITIES_KHR 0x0908 +/* cl_platform_command_buffer_capabilities_khr - bitfield */ +#define CL_COMMAND_BUFFER_PLATFORM_UNIVERSAL_SYNC_KHR (1 << 0) +#define CL_COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR (1 << 1) +#define CL_COMMAND_BUFFER_PLATFORM_AUTOMATIC_REMAP_KHR (1 << 2) -/************************************** - * cl_khr_terminate_context extension * - **************************************/ +/* cl_device_info */ +#define CL_DEVICE_COMMAND_BUFFER_NUM_SYNC_DEVICES_KHR 0x12AB +#define CL_DEVICE_COMMAND_BUFFER_SYNC_DEVICES_KHR 0x12AC + +/* cl_device_command_buffer_capabilities_khr - bitfield */ +#define CL_COMMAND_BUFFER_CAPABILITY_MULTIPLE_QUEUE_KHR (1 << 4) + +/* cl_command_buffer_flags_khr - bitfield */ +#define CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR (1 << 2) + + +typedef cl_command_buffer_khr (CL_API_CALL * +clRemapCommandBufferKHR_fn)( + cl_command_buffer_khr command_buffer, + cl_bool automatic, + cl_uint num_queues, + const cl_command_queue* queues, + cl_uint num_handles, + const cl_mutable_command_khr* handles, + cl_mutable_command_khr* handles_ret, + cl_int* errcode_ret) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_command_buffer_khr CL_API_CALL +clRemapCommandBufferKHR( + cl_command_buffer_khr command_buffer, + cl_bool automatic, + cl_uint num_queues, + const cl_command_queue* queues, + cl_uint num_handles, + const cl_mutable_command_khr* handles, + cl_mutable_command_khr* handles_ret, + cl_int* errcode_ret) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_command_buffer_mutable_dispatch +***************************************************************/ +#define cl_khr_command_buffer_mutable_dispatch 1 +#define CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_NAME \ + "cl_khr_command_buffer_mutable_dispatch" + +typedef cl_uint cl_command_buffer_structure_type_khr; +typedef cl_bitfield cl_mutable_dispatch_fields_khr; +typedef cl_uint cl_mutable_command_info_khr; +typedef struct _cl_mutable_dispatch_arg_khr { + cl_uint arg_index; + size_t arg_size; + const void* arg_value; +} cl_mutable_dispatch_arg_khr; +typedef struct _cl_mutable_dispatch_exec_info_khr { + cl_uint param_name; + size_t param_value_size; + const void* param_value; +} cl_mutable_dispatch_exec_info_khr; +typedef struct _cl_mutable_dispatch_config_khr { + cl_command_buffer_structure_type_khr type; + const void* next; + cl_mutable_command_khr command; + cl_uint num_args; + cl_uint num_svm_args; + cl_uint num_exec_infos; + cl_uint work_dim; + const cl_mutable_dispatch_arg_khr* arg_list; + const cl_mutable_dispatch_arg_khr* arg_svm_list; + const cl_mutable_dispatch_exec_info_khr* exec_info_list; + const size_t* global_work_offset; + const size_t* global_work_size; + const size_t* local_work_size; +} cl_mutable_dispatch_config_khr; +typedef struct _cl_mutable_base_config_khr { + cl_command_buffer_structure_type_khr type; + const void* next; + cl_uint num_mutable_dispatch; + const cl_mutable_dispatch_config_khr* mutable_dispatch_list; +} cl_mutable_base_config_khr; + +/* cl_command_buffer_flags_khr - bitfield */ +#define CL_COMMAND_BUFFER_MUTABLE_KHR (1 << 1) + +/* Error codes */ +#define CL_INVALID_MUTABLE_COMMAND_KHR -1141 -#define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x2031 -#define CL_CONTEXT_TERMINATE_KHR 0x2032 +/* cl_device_info */ +#define CL_DEVICE_MUTABLE_DISPATCH_CAPABILITIES_KHR 0x12B0 + +/* cl_ndrange_kernel_command_properties_khr */ +#define CL_MUTABLE_DISPATCH_UPDATABLE_FIELDS_KHR 0x12B1 + +/* cl_mutable_dispatch_fields_khr - bitfield */ +#define CL_MUTABLE_DISPATCH_GLOBAL_OFFSET_KHR (1 << 0) +#define CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR (1 << 1) +#define CL_MUTABLE_DISPATCH_LOCAL_SIZE_KHR (1 << 2) +#define CL_MUTABLE_DISPATCH_ARGUMENTS_KHR (1 << 3) +#define CL_MUTABLE_DISPATCH_EXEC_INFO_KHR (1 << 4) + +/* cl_mutable_command_info_khr */ +#define CL_MUTABLE_COMMAND_COMMAND_QUEUE_KHR 0x12A0 +#define CL_MUTABLE_COMMAND_COMMAND_BUFFER_KHR 0x12A1 +#define CL_MUTABLE_COMMAND_COMMAND_TYPE_KHR 0x12AD +#define CL_MUTABLE_DISPATCH_PROPERTIES_ARRAY_KHR 0x12A2 +#define CL_MUTABLE_DISPATCH_KERNEL_KHR 0x12A3 +#define CL_MUTABLE_DISPATCH_DIMENSIONS_KHR 0x12A4 +#define CL_MUTABLE_DISPATCH_GLOBAL_WORK_OFFSET_KHR 0x12A5 +#define CL_MUTABLE_DISPATCH_GLOBAL_WORK_SIZE_KHR 0x12A6 +#define CL_MUTABLE_DISPATCH_LOCAL_WORK_SIZE_KHR 0x12A7 + +/* cl_command_buffer_structure_type_khr */ +#define CL_STRUCTURE_TYPE_MUTABLE_BASE_CONFIG_KHR 0 +#define CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR 1 + + +typedef cl_int (CL_API_CALL * +clUpdateMutableCommandsKHR_fn)( + cl_command_buffer_khr command_buffer, + const cl_mutable_base_config_khr* mutable_config) ; + +typedef cl_int (CL_API_CALL * +clGetMutableCommandInfoKHR_fn)( + cl_mutable_command_khr command, + cl_mutable_command_info_khr param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -#define cl_khr_terminate_context 1 extern CL_API_ENTRY cl_int CL_API_CALL -clTerminateContextKHR(cl_context context) CL_EXT_SUFFIX__VERSION_1_2; +clUpdateMutableCommandsKHR( + cl_command_buffer_khr command_buffer, + const cl_mutable_base_config_khr* mutable_config) ; -typedef CL_API_ENTRY cl_int -(CL_API_CALL *clTerminateContextKHR_fn)(cl_context context) CL_EXT_SUFFIX__VERSION_1_2; +extern CL_API_ENTRY cl_int CL_API_CALL +clGetMutableCommandInfoKHR( + cl_mutable_command_khr command, + cl_mutable_command_info_khr param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_fp64 +***************************************************************/ +#define cl_khr_fp64 1 +#define CL_KHR_FP64_EXTENSION_NAME \ + "cl_khr_fp64" + +#if !defined(CL_VERSION_1_2) +/* cl_device_info - defined in CL.h for OpenCL 1.2 and newer */ +#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 + +#endif /* !defined(CL_VERSION_1_2) */ + +/*************************************************************** +* cl_khr_fp16 +***************************************************************/ +#define cl_khr_fp16 1 +#define CL_KHR_FP16_EXTENSION_NAME \ + "cl_khr_fp16" +/* cl_device_info */ +#define CL_DEVICE_HALF_FP_CONFIG 0x1033 -/* - * Extension: cl_khr_spir - * - * This extension adds support to create an OpenCL program object from a - * Standard Portable Intermediate Representation (SPIR) instance - */ +/*************************************************************** +* cl_APPLE_SetMemObjectDestructor +***************************************************************/ +#define cl_APPLE_SetMemObjectDestructor 1 +#define CL_APPLE_SETMEMOBJECTDESTRUCTOR_EXTENSION_NAME \ + "cl_APPLE_SetMemObjectDestructor" -#define CL_DEVICE_SPIR_VERSIONS 0x40E0 -#define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1 +typedef cl_int (CL_API_CALL * +clSetMemObjectDestructorAPPLE_fn)( + cl_mem memobj, + void (CL_CALLBACK* pfn_notify)(cl_mem memobj, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_1_0; -/***************************************** - * cl_khr_create_command_queue extension * - *****************************************/ -#define cl_khr_create_command_queue 1 +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -typedef cl_bitfield cl_queue_properties_khr; +extern CL_API_ENTRY cl_int CL_API_CALL +clSetMemObjectDestructorAPPLE( + cl_mem memobj, + void (CL_CALLBACK* pfn_notify)(cl_mem memobj, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_1_0; -extern CL_API_ENTRY cl_command_queue CL_API_CALL -clCreateCommandQueueWithPropertiesKHR(cl_context context, - cl_device_id device, - const cl_queue_properties_khr* properties, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_APPLE_ContextLoggingFunctions +***************************************************************/ +#define cl_APPLE_ContextLoggingFunctions 1 +#define CL_APPLE_CONTEXTLOGGINGFUNCTIONS_EXTENSION_NAME \ + "cl_APPLE_ContextLoggingFunctions" + + +typedef void (CL_API_CALL * +clLogMessagesToSystemLogAPPLE_fn)( + const char* errstr, + const void* private_info, + size_t cb, + void* user_data) CL_API_SUFFIX__VERSION_1_0; + +typedef void (CL_API_CALL * +clLogMessagesToStdoutAPPLE_fn)( + const char* errstr, + const void* private_info, + size_t cb, + void* user_data) CL_API_SUFFIX__VERSION_1_0; -typedef CL_API_ENTRY cl_command_queue -(CL_API_CALL *clCreateCommandQueueWithPropertiesKHR_fn)(cl_context context, - cl_device_id device, - const cl_queue_properties_khr* properties, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; +typedef void (CL_API_CALL * +clLogMessagesToStderrAPPLE_fn)( + const char* errstr, + const void* private_info, + size_t cb, + void* user_data) CL_API_SUFFIX__VERSION_1_0; +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -/****************************************** -* cl_nv_device_attribute_query extension * -******************************************/ +extern CL_API_ENTRY void CL_API_CALL +clLogMessagesToSystemLogAPPLE( + const char* errstr, + const void* private_info, + size_t cb, + void* user_data) CL_API_SUFFIX__VERSION_1_0; -/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */ -#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 -#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 -#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 -#define CL_DEVICE_WARP_SIZE_NV 0x4003 -#define CL_DEVICE_GPU_OVERLAP_NV 0x4004 -#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 -#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 +extern CL_API_ENTRY void CL_API_CALL +clLogMessagesToStdoutAPPLE( + const char* errstr, + const void* private_info, + size_t cb, + void* user_data) CL_API_SUFFIX__VERSION_1_0; +extern CL_API_ENTRY void CL_API_CALL +clLogMessagesToStderrAPPLE( + const char* errstr, + const void* private_info, + size_t cb, + void* user_data) CL_API_SUFFIX__VERSION_1_0; -/********************************* -* cl_amd_device_attribute_query * -*********************************/ +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ -#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036 +/*************************************************************** +* cl_khr_icd +***************************************************************/ +#define cl_khr_icd 1 +#define CL_KHR_ICD_EXTENSION_NAME \ + "cl_khr_icd" +/* cl_platform_info */ +#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 -/********************************* -* cl_arm_printf extension -*********************************/ +/* Error codes */ +#define CL_PLATFORM_NOT_FOUND_KHR -1001 -#define CL_PRINTF_CALLBACK_ARM 0x40B0 -#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1 +typedef cl_int (CL_API_CALL * +clIcdGetPlatformIDsKHR_fn)( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) ; -/*********************************** -* cl_ext_device_fission extension -***********************************/ -#define cl_ext_device_fission 1 +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1; +clIcdGetPlatformIDsKHR( + cl_uint num_entries, + cl_platform_id* platforms, + cl_uint* num_platforms) ; -typedef CL_API_ENTRY cl_int -(CL_API_CALL *clReleaseDeviceEXT_fn)(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1; +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1; +/*************************************************************** +* cl_khr_il_program +***************************************************************/ +#define cl_khr_il_program 1 +#define CL_KHR_IL_PROGRAM_EXTENSION_NAME \ + "cl_khr_il_program" -typedef CL_API_ENTRY cl_int -(CL_API_CALL *clRetainDeviceEXT_fn)(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1; +/* cl_device_info */ +#define CL_DEVICE_IL_VERSION_KHR 0x105B -typedef cl_ulong cl_device_partition_property_ext; -extern CL_API_ENTRY cl_int CL_API_CALL -clCreateSubDevicesEXT(cl_device_id in_device, - const cl_device_partition_property_ext * properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1; +/* cl_program_info */ +#define CL_PROGRAM_IL_KHR 0x1169 -typedef CL_API_ENTRY cl_int -(CL_API_CALL * clCreateSubDevicesEXT_fn)(cl_device_id in_device, - const cl_device_partition_property_ext * properties, - cl_uint num_entries, - cl_device_id * out_devices, - cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1; -/* cl_device_partition_property_ext */ -#define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050 -#define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051 -#define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052 -#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053 - -/* clDeviceGetInfo selectors */ -#define CL_DEVICE_PARENT_DEVICE_EXT 0x4054 -#define CL_DEVICE_PARTITION_TYPES_EXT 0x4055 -#define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056 -#define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057 -#define CL_DEVICE_PARTITION_STYLE_EXT 0x4058 - -/* error codes */ -#define CL_DEVICE_PARTITION_FAILED_EXT -1057 -#define CL_INVALID_PARTITION_COUNT_EXT -1058 -#define CL_INVALID_PARTITION_NAME_EXT -1059 - -/* CL_AFFINITY_DOMAINs */ -#define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1 -#define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2 -#define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3 -#define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4 -#define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10 -#define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100 - -/* cl_device_partition_property_ext list terminators */ -#define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0) -#define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0) -#define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1) - - -/*********************************** - * cl_ext_migrate_memobject extension definitions - ***********************************/ -#define cl_ext_migrate_memobject 1 +typedef cl_program (CL_API_CALL * +clCreateProgramWithILKHR_fn)( + cl_context context, + const void* il, + size_t length, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; -typedef cl_bitfield cl_mem_migration_flags_ext; +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -#define CL_MIGRATE_MEM_OBJECT_HOST_EXT 0x1 +extern CL_API_ENTRY cl_program CL_API_CALL +clCreateProgramWithILKHR( + cl_context context, + const void* il, + size_t length, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; -#define CL_COMMAND_MIGRATE_MEM_OBJECT_EXT 0x4040 +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ -extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueMigrateMemObjectEXT(cl_command_queue command_queue, - cl_uint num_mem_objects, - const cl_mem * mem_objects, - cl_mem_migration_flags_ext flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); +/*************************************************************** +* cl_khr_image2d_from_buffer +***************************************************************/ +#define cl_khr_image2d_from_buffer 1 +#define CL_KHR_IMAGE2D_FROM_BUFFER_EXTENSION_NAME \ + "cl_khr_image2d_from_buffer" -typedef CL_API_ENTRY cl_int -(CL_API_CALL *clEnqueueMigrateMemObjectEXT_fn)(cl_command_queue command_queue, - cl_uint num_mem_objects, - const cl_mem * mem_objects, - cl_mem_migration_flags_ext flags, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event); +/* cl_device_info */ +#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR 0x104A +#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR 0x104B + +/*************************************************************** +* cl_khr_initialize_memory +***************************************************************/ +#define cl_khr_initialize_memory 1 +#define CL_KHR_INITIALIZE_MEMORY_EXTENSION_NAME \ + "cl_khr_initialize_memory" + +/* Interop tokens */ +#define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x2030 + +/*************************************************************** +* cl_khr_terminate_context +***************************************************************/ +#define cl_khr_terminate_context 1 +#define CL_KHR_TERMINATE_CONTEXT_EXTENSION_NAME \ + "cl_khr_terminate_context" +typedef cl_bitfield cl_device_terminate_capability_khr; -/********************************* -* cl_qcom_ext_host_ptr extension -*********************************/ -#define cl_qcom_ext_host_ptr 1 +/* cl_device_info */ +#define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x2031 + +/* cl_context_properties */ +#define CL_CONTEXT_TERMINATE_KHR 0x2032 + +/* cl_device_terminate_capability_khr */ +#define CL_DEVICE_TERMINATE_CAPABILITY_CONTEXT_KHR (1 << 0) -#define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29) +/* Error codes */ +#define CL_CONTEXT_TERMINATED_KHR -1121 -#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0 -#define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1 -#define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2 -#define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3 -#define CL_MEM_HOST_UNCACHED_QCOM 0x40A4 -#define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5 -#define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6 -#define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7 -typedef cl_uint cl_image_pitch_info_qcom; +typedef cl_int (CL_API_CALL * +clTerminateContextKHR_fn)( + cl_context context) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_int CL_API_CALL -clGetDeviceImageInfoQCOM(cl_device_id device, - size_t image_width, - size_t image_height, - const cl_image_format *image_format, - cl_image_pitch_info_qcom param_name, - size_t param_value_size, - void *param_value, - size_t *param_value_size_ret); +clTerminateContextKHR( + cl_context context) CL_API_SUFFIX__VERSION_1_2; -typedef struct _cl_mem_ext_host_ptr -{ - /* Type of external memory allocation. */ - /* Legal values will be defined in layered extensions. */ - cl_uint allocation_type; +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ - /* Host cache policy for this external memory allocation. */ - cl_uint host_cache_policy; +/*************************************************************** +* cl_khr_spir +***************************************************************/ +#define cl_khr_spir 1 +#define CL_KHR_SPIR_EXTENSION_NAME \ + "cl_khr_spir" -} cl_mem_ext_host_ptr; +/* cl_device_info */ +#define CL_DEVICE_SPIR_VERSIONS 0x40E0 +/* cl_program_binary_type */ +#define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1 -/******************************************* -* cl_qcom_ext_host_ptr_iocoherent extension -********************************************/ +/*************************************************************** +* cl_khr_create_command_queue +***************************************************************/ +#define cl_khr_create_command_queue 1 +#define CL_KHR_CREATE_COMMAND_QUEUE_EXTENSION_NAME \ + "cl_khr_create_command_queue" -/* Cache policy specifying io-coherence */ -#define CL_MEM_HOST_IOCOHERENT_QCOM 0x40A9 +typedef cl_properties cl_queue_properties_khr; -/********************************* -* cl_qcom_ion_host_ptr extension -*********************************/ +typedef cl_command_queue (CL_API_CALL * +clCreateCommandQueueWithPropertiesKHR_fn)( + cl_context context, + cl_device_id device, + const cl_queue_properties_khr* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; -#define CL_MEM_ION_HOST_PTR_QCOM 0x40A8 +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -typedef struct _cl_mem_ion_host_ptr -{ - /* Type of external memory allocation. */ - /* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */ - cl_mem_ext_host_ptr ext_host_ptr; +extern CL_API_ENTRY cl_command_queue CL_API_CALL +clCreateCommandQueueWithPropertiesKHR( + cl_context context, + cl_device_id device, + const cl_queue_properties_khr* properties, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; - /* ION file descriptor */ - int ion_filedesc; +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ - /* Host pointer to the ION allocated memory */ - void* ion_hostptr; +/*************************************************************** +* cl_nv_device_attribute_query +***************************************************************/ +#define cl_nv_device_attribute_query 1 +#define CL_NV_DEVICE_ATTRIBUTE_QUERY_EXTENSION_NAME \ + "cl_nv_device_attribute_query" -} cl_mem_ion_host_ptr; +/* cl_device_info */ +#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 +#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 +#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 +#define CL_DEVICE_WARP_SIZE_NV 0x4003 +#define CL_DEVICE_GPU_OVERLAP_NV 0x4004 +#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 +#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 + +/*************************************************************** +* cl_amd_device_attribute_query +***************************************************************/ +#define cl_amd_device_attribute_query 1 +#define CL_AMD_DEVICE_ATTRIBUTE_QUERY_EXTENSION_NAME \ + "cl_amd_device_attribute_query" +/* cl_device_info */ +#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036 +#define CL_DEVICE_TOPOLOGY_AMD 0x4037 +#define CL_DEVICE_BOARD_NAME_AMD 0x4038 +#define CL_DEVICE_GLOBAL_FREE_MEMORY_AMD 0x4039 +#define CL_DEVICE_SIMD_PER_COMPUTE_UNIT_AMD 0x4040 +#define CL_DEVICE_SIMD_WIDTH_AMD 0x4041 +#define CL_DEVICE_SIMD_INSTRUCTION_WIDTH_AMD 0x4042 +#define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043 +#define CL_DEVICE_GLOBAL_MEM_CHANNELS_AMD 0x4044 +#define CL_DEVICE_GLOBAL_MEM_CHANNEL_BANKS_AMD 0x4045 +#define CL_DEVICE_GLOBAL_MEM_CHANNEL_BANK_WIDTH_AMD 0x4046 +#define CL_DEVICE_LOCAL_MEM_SIZE_PER_COMPUTE_UNIT_AMD 0x4047 +#define CL_DEVICE_LOCAL_MEM_BANKS_AMD 0x4048 +#define CL_DEVICE_THREAD_TRACE_SUPPORTED_AMD 0x4049 +#define CL_DEVICE_GFXIP_MAJOR_AMD 0x404A +#define CL_DEVICE_GFXIP_MINOR_AMD 0x404B +#define CL_DEVICE_AVAILABLE_ASYNC_QUEUES_AMD 0x404C +#define CL_DEVICE_PREFERRED_WORK_GROUP_SIZE_AMD 0x4030 +#define CL_DEVICE_MAX_WORK_GROUP_SIZE_AMD 0x4031 +#define CL_DEVICE_PREFERRED_CONSTANT_BUFFER_SIZE_AMD 0x4033 +#define CL_DEVICE_PCIE_ID_AMD 0x4034 + +/*************************************************************** +* cl_arm_printf +***************************************************************/ +#define cl_arm_printf 1 +#define CL_ARM_PRINTF_EXTENSION_NAME \ + "cl_arm_printf" + +/* cl_context_properties */ +#define CL_PRINTF_CALLBACK_ARM 0x40B0 +#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1 + +/*************************************************************** +* cl_ext_device_fission +***************************************************************/ +#define cl_ext_device_fission 1 +#define CL_EXT_DEVICE_FISSION_EXTENSION_NAME \ + "cl_ext_device_fission" + +typedef cl_ulong cl_device_partition_property_ext; + +/* Error codes */ +#define CL_DEVICE_PARTITION_FAILED_EXT -1057 +#define CL_INVALID_PARTITION_COUNT_EXT -1058 +#define CL_INVALID_PARTITION_NAME_EXT -1059 -/********************************* -* cl_qcom_android_native_buffer_host_ptr extension -*********************************/ +/* cl_device_info */ +#define CL_DEVICE_PARENT_DEVICE_EXT 0x4054 +#define CL_DEVICE_PARTITION_TYPES_EXT 0x4055 +#define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056 +#define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057 +#define CL_DEVICE_PARTITION_STYLE_EXT 0x4058 -#define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6 +/* cl_device_partition_property_ext */ +#define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050 +#define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051 +#define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052 +#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053 + +/* cl_device_partition_property_ext - affinity domains */ +#define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1 +#define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2 +#define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3 +#define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4 +#define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10 +#define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100 + +/* cl_device_partition_property_ext - list terminators */ +#define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext)0) +#define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext)0) +#define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext)0 - 1) + + +typedef cl_int (CL_API_CALL * +clReleaseDeviceEXT_fn)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_int (CL_API_CALL * +clRetainDeviceEXT_fn)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_int (CL_API_CALL * +clCreateSubDevicesEXT_fn)( + cl_device_id in_device, + const cl_device_partition_property_ext* properties, + cl_uint num_entries, + cl_device_id* out_devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) -typedef struct _cl_mem_android_native_buffer_host_ptr -{ - /* Type of external memory allocation. */ - /* Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. */ - cl_mem_ext_host_ptr ext_host_ptr; +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseDeviceEXT( + cl_device_id device) CL_API_SUFFIX__VERSION_1_1; - /* Virtual pointer to the android native buffer */ - void* anb_ptr; +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainDeviceEXT( + cl_device_id device) CL_API_SUFFIX__VERSION_1_1; -} cl_mem_android_native_buffer_host_ptr; +extern CL_API_ENTRY cl_int CL_API_CALL +clCreateSubDevicesEXT( + cl_device_id in_device, + const cl_device_partition_property_ext* properties, + cl_uint num_entries, + cl_device_id* out_devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_ext_migrate_memobject +***************************************************************/ +#define cl_ext_migrate_memobject 1 +#define CL_EXT_MIGRATE_MEMOBJECT_EXTENSION_NAME \ + "cl_ext_migrate_memobject" +typedef cl_bitfield cl_mem_migration_flags_ext; -/****************************************** - * cl_img_yuv_image extension * - ******************************************/ +/* cl_mem_migration_flags_ext */ +#define CL_MIGRATE_MEM_OBJECT_HOST_EXT (1 << 0) -/* Image formats used in clCreateImage */ -#define CL_NV21_IMG 0x40D0 -#define CL_YV12_IMG 0x40D1 +/* cl_command_type */ +#define CL_COMMAND_MIGRATE_MEM_OBJECT_EXT 0x4040 -/****************************************** - * cl_img_cached_allocations extension * - ******************************************/ +typedef cl_int (CL_API_CALL * +clEnqueueMigrateMemObjectEXT_fn)( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_mem_migration_flags_ext flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; -/* Flag values used by clCreateBuffer */ -#define CL_MEM_USE_UNCACHED_CPU_MEMORY_IMG (1 << 26) -#define CL_MEM_USE_CACHED_CPU_MEMORY_IMG (1 << 27) +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMigrateMemObjectEXT( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_mem_migration_flags_ext flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_ext_cxx_for_opencl +***************************************************************/ +#define cl_ext_cxx_for_opencl 1 +#define CL_EXT_CXX_FOR_OPENCL_EXTENSION_NAME \ + "cl_ext_cxx_for_opencl" -/****************************************** - * cl_img_use_gralloc_ptr extension * - ******************************************/ -#define cl_img_use_gralloc_ptr 1 +/* cl_device_info */ +#define CL_DEVICE_CXX_FOR_OPENCL_NUMERIC_VERSION_EXT 0x4230 -/* Flag values used by clCreateBuffer */ -#define CL_MEM_USE_GRALLOC_PTR_IMG (1 << 28) +/*************************************************************** +* cl_qcom_ext_host_ptr +***************************************************************/ +#define cl_qcom_ext_host_ptr 1 +#define CL_QCOM_EXT_HOST_PTR_EXTENSION_NAME \ + "cl_qcom_ext_host_ptr" -/* To be used by clGetEventInfo: */ -#define CL_COMMAND_ACQUIRE_GRALLOC_OBJECTS_IMG 0x40D2 -#define CL_COMMAND_RELEASE_GRALLOC_OBJECTS_IMG 0x40D3 +typedef cl_uint cl_image_pitch_info_qcom; +typedef struct _cl_mem_ext_host_ptr { + cl_uint allocation_type; + cl_uint host_cache_policy; +} cl_mem_ext_host_ptr; + +/* cl_mem_flags */ +#define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29) + +/* cl_device_info */ +#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0 +#define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1 + +/* cl_image_pitch_info_qcom */ +#define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2 +#define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3 -/* Error code from clEnqueueReleaseGrallocObjectsIMG */ -#define CL_GRALLOC_RESOURCE_NOT_ACQUIRED_IMG 0x40D4 +/* cl_uint host_cache_policy */ +#define CL_MEM_HOST_UNCACHED_QCOM 0x40A4 +#define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5 +#define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6 +#define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7 + + +typedef cl_int (CL_API_CALL * +clGetDeviceImageInfoQCOM_fn)( + cl_device_id device, + size_t image_width, + size_t image_height, + const cl_image_format* image_format, + cl_image_pitch_info_qcom param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireGrallocObjectsIMG(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clGetDeviceImageInfoQCOM( + cl_device_id device, + size_t image_width, + size_t image_height, + const cl_image_format* image_format, + cl_image_pitch_info_qcom param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_qcom_ext_host_ptr_iocoherent +***************************************************************/ +#define cl_qcom_ext_host_ptr_iocoherent 1 +#define CL_QCOM_EXT_HOST_PTR_IOCOHERENT_EXTENSION_NAME \ + "cl_qcom_ext_host_ptr_iocoherent" + +/* cl_uint host_cache_policy */ +#define CL_MEM_HOST_IOCOHERENT_QCOM 0x40A9 + +/*************************************************************** +* cl_qcom_ion_host_ptr +***************************************************************/ +#define cl_qcom_ion_host_ptr 1 +#define CL_QCOM_ION_HOST_PTR_EXTENSION_NAME \ + "cl_qcom_ion_host_ptr" + +/* type cl_mem_ext_host_ptr */ +typedef struct _cl_mem_ion_host_ptr { + cl_mem_ext_host_ptr ext_host_ptr; + int ion_filedesc; + void* ion_hostptr; +} cl_mem_ion_host_ptr; + +/* cl_uint allocation_type */ +#define CL_MEM_ION_HOST_PTR_QCOM 0x40A8 + +/*************************************************************** +* cl_qcom_android_native_buffer_host_ptr +***************************************************************/ +#define cl_qcom_android_native_buffer_host_ptr 1 +#define CL_QCOM_ANDROID_NATIVE_BUFFER_HOST_PTR_EXTENSION_NAME \ + "cl_qcom_android_native_buffer_host_ptr" + +/* type cl_mem_ext_host_ptr */ +typedef struct _cl_mem_android_native_buffer_host_ptr { + cl_mem_ext_host_ptr ext_host_ptr; + void* anb_ptr; +} cl_mem_android_native_buffer_host_ptr; + +/* cl_uint allocation_type */ +#define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6 + +/*************************************************************** +* cl_img_yuv_image +***************************************************************/ +#define cl_img_yuv_image 1 +#define CL_IMG_YUV_IMAGE_EXTENSION_NAME \ + "cl_img_yuv_image" + +/* cl_channel_order */ +#define CL_NV21_IMG 0x40D0 +#define CL_YV12_IMG 0x40D1 + +/*************************************************************** +* cl_img_cached_allocations +***************************************************************/ +#define cl_img_cached_allocations 1 +#define CL_IMG_CACHED_ALLOCATIONS_EXTENSION_NAME \ + "cl_img_cached_allocations" + +/* cl_mem_flags */ +#define CL_MEM_USE_UNCACHED_CPU_MEMORY_IMG (1 << 26) +#define CL_MEM_USE_CACHED_CPU_MEMORY_IMG (1 << 27) + +/*************************************************************** +* cl_img_use_gralloc_ptr +***************************************************************/ +#define cl_img_use_gralloc_ptr 1 +#define CL_IMG_USE_GRALLOC_PTR_EXTENSION_NAME \ + "cl_img_use_gralloc_ptr" + +/* Error codes */ +#define CL_GRALLOC_RESOURCE_NOT_ACQUIRED_IMG 0x40D4 +#define CL_INVALID_GRALLOC_OBJECT_IMG 0x40D5 + +/* cl_mem_flags */ +#define CL_MEM_USE_GRALLOC_PTR_IMG (1 << 28) + +/* cl_command_type */ +#define CL_COMMAND_ACQUIRE_GRALLOC_OBJECTS_IMG 0x40D2 +#define CL_COMMAND_RELEASE_GRALLOC_OBJECTS_IMG 0x40D3 + + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireGrallocObjectsIMG_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseGrallocObjectsIMG_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseGrallocObjectsIMG(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clEnqueueAcquireGrallocObjectsIMG( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseGrallocObjectsIMG( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_img_generate_mipmap +***************************************************************/ +#define cl_img_generate_mipmap 1 +#define CL_IMG_GENERATE_MIPMAP_EXTENSION_NAME \ + "cl_img_generate_mipmap" + +typedef cl_uint cl_mipmap_filter_mode_img; + +/* cl_mipmap_filter_mode_img */ +#define CL_MIPMAP_FILTER_ANY_IMG 0x0 +#define CL_MIPMAP_FILTER_BOX_IMG 0x1 + +/* cl_command_type */ +#define CL_COMMAND_GENERATE_MIPMAP_IMG 0x40D6 + + +typedef cl_int (CL_API_CALL * +clEnqueueGenerateMipmapIMG_fn)( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + cl_mipmap_filter_mode_img mipmap_filter_mode, + const size_t* array_region, + const size_t* mip_region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -/********************************* -* cl_khr_subgroups extension -*********************************/ +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueGenerateMipmapIMG( + cl_command_queue command_queue, + cl_mem src_image, + cl_mem dst_image, + cl_mipmap_filter_mode_img mipmap_filter_mode, + const size_t* array_region, + const size_t* mip_region, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_img_mem_properties +***************************************************************/ +#define cl_img_mem_properties 1 +#define CL_IMG_MEM_PROPERTIES_EXTENSION_NAME \ + "cl_img_mem_properties" + +/* cl_mem_properties */ +#define CL_MEM_ALLOC_FLAGS_IMG 0x40D7 + +/* cl_mem_alloc_flags_img */ +#define CL_MEM_ALLOC_RELAX_REQUIREMENTS_IMG (1 << 0) + +/*************************************************************** +* cl_khr_subgroups +***************************************************************/ #define cl_khr_subgroups 1 +#define CL_KHR_SUBGROUPS_EXTENSION_NAME \ + "cl_khr_subgroups" #if !defined(CL_VERSION_2_1) -/* For OpenCL 2.1 and newer, cl_kernel_sub_group_info is declared in CL.h. - In hindsight, there should have been a khr suffix on this type for - the extension, but keeping it un-suffixed to maintain backwards - compatibility. */ +/* defined in CL.h for OpenCL 2.1 and newer */ typedef cl_uint cl_kernel_sub_group_info; -#endif + +#endif /* !defined(CL_VERSION_2_1) */ /* cl_kernel_sub_group_info */ -#define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR 0x2033 -#define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR 0x2034 - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetKernelSubGroupInfoKHR(cl_kernel in_kernel, - cl_device_id in_device, - cl_kernel_sub_group_info param_name, - size_t input_value_size, - const void * input_value, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED; - -typedef CL_API_ENTRY cl_int -(CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel in_kernel, - cl_device_id in_device, - cl_kernel_sub_group_info param_name, - size_t input_value_size, - const void * input_value, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED; - - -/********************************* -* cl_khr_mipmap_image extension -*********************************/ +#define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR 0x2033 +#define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR 0x2034 -/* cl_sampler_properties */ -#define CL_SAMPLER_MIP_FILTER_MODE_KHR 0x1155 -#define CL_SAMPLER_LOD_MIN_KHR 0x1156 -#define CL_SAMPLER_LOD_MAX_KHR 0x1157 +typedef cl_int (CL_API_CALL * +clGetKernelSubGroupInfoKHR_fn)( + cl_kernel in_kernel, + cl_device_id in_device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_2_0_DEPRECATED; -/********************************* -* cl_khr_priority_hints extension -*********************************/ -/* This extension define is for backwards compatibility. - It shouldn't be required since this extension has no new functions. */ +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetKernelSubGroupInfoKHR( + cl_kernel in_kernel, + cl_device_id in_device, + cl_kernel_sub_group_info param_name, + size_t input_value_size, + const void* input_value, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_2_0_DEPRECATED; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_mipmap_image +***************************************************************/ +#define cl_khr_mipmap_image 1 +#define CL_KHR_MIPMAP_IMAGE_EXTENSION_NAME \ + "cl_khr_mipmap_image" + +/* cl_sampler_properties */ +#define CL_SAMPLER_MIP_FILTER_MODE_KHR 0x1155 +#define CL_SAMPLER_LOD_MIN_KHR 0x1156 +#define CL_SAMPLER_LOD_MAX_KHR 0x1157 + +/*************************************************************** +* cl_khr_priority_hints +***************************************************************/ #define cl_khr_priority_hints 1 +#define CL_KHR_PRIORITY_HINTS_EXTENSION_NAME \ + "cl_khr_priority_hints" -typedef cl_uint cl_queue_priority_khr; +/* To be used by clGetEventInfo */ +typedef cl_uint cl_queue_priority_khr; -/* cl_command_queue_properties */ -#define CL_QUEUE_PRIORITY_KHR 0x1096 +/* cl_queue_properties */ +#define CL_QUEUE_PRIORITY_KHR 0x1096 /* cl_queue_priority_khr */ -#define CL_QUEUE_PRIORITY_HIGH_KHR (1<<0) -#define CL_QUEUE_PRIORITY_MED_KHR (1<<1) -#define CL_QUEUE_PRIORITY_LOW_KHR (1<<2) - +#define CL_QUEUE_PRIORITY_HIGH_KHR (1 << 0) +#define CL_QUEUE_PRIORITY_MED_KHR (1 << 1) +#define CL_QUEUE_PRIORITY_LOW_KHR (1 << 2) -/********************************* -* cl_khr_throttle_hints extension -*********************************/ -/* This extension define is for backwards compatibility. - It shouldn't be required since this extension has no new functions. */ +/*************************************************************** +* cl_khr_throttle_hints +***************************************************************/ #define cl_khr_throttle_hints 1 +#define CL_KHR_THROTTLE_HINTS_EXTENSION_NAME \ + "cl_khr_throttle_hints" -typedef cl_uint cl_queue_throttle_khr; +/* To be used by clGetEventInfo */ +typedef cl_uint cl_queue_throttle_khr; -/* cl_command_queue_properties */ -#define CL_QUEUE_THROTTLE_KHR 0x1097 +/* cl_queue_properties */ +#define CL_QUEUE_THROTTLE_KHR 0x1097 /* cl_queue_throttle_khr */ -#define CL_QUEUE_THROTTLE_HIGH_KHR (1<<0) -#define CL_QUEUE_THROTTLE_MED_KHR (1<<1) -#define CL_QUEUE_THROTTLE_LOW_KHR (1<<2) - +#define CL_QUEUE_THROTTLE_HIGH_KHR (1 << 0) +#define CL_QUEUE_THROTTLE_MED_KHR (1 << 1) +#define CL_QUEUE_THROTTLE_LOW_KHR (1 << 2) -/********************************* +/*************************************************************** * cl_khr_subgroup_named_barrier -*********************************/ -/* This extension define is for backwards compatibility. - It shouldn't be required since this extension has no new functions. */ +***************************************************************/ #define cl_khr_subgroup_named_barrier 1 +#define CL_KHR_SUBGROUP_NAMED_BARRIER_EXTENSION_NAME \ + "cl_khr_subgroup_named_barrier" /* cl_device_info */ -#define CL_DEVICE_MAX_NAMED_BARRIER_COUNT_KHR 0x2035 +#define CL_DEVICE_MAX_NAMED_BARRIER_COUNT_KHR 0x2035 +/*************************************************************** +* cl_khr_extended_versioning +***************************************************************/ +#define cl_khr_extended_versioning 1 +#define CL_KHR_EXTENDED_VERSIONING_EXTENSION_NAME \ + "cl_khr_extended_versioning" -/********************************** - * cl_arm_import_memory extension * - **********************************/ -#define cl_arm_import_memory 1 +#define CL_VERSION_MAJOR_BITS_KHR 10 +#define CL_VERSION_MINOR_BITS_KHR 10 +#define CL_VERSION_PATCH_BITS_KHR 12 -typedef intptr_t cl_import_properties_arm; +#define CL_VERSION_MAJOR_MASK_KHR ((1 << CL_VERSION_MAJOR_BITS_KHR) - 1) +#define CL_VERSION_MINOR_MASK_KHR ((1 << CL_VERSION_MINOR_BITS_KHR) - 1) +#define CL_VERSION_PATCH_MASK_KHR ((1 << CL_VERSION_PATCH_BITS_KHR) - 1) -/* Default and valid proporties name for cl_arm_import_memory */ -#define CL_IMPORT_TYPE_ARM 0x40B2 +#define CL_VERSION_MAJOR_KHR(version) ((version) >> (CL_VERSION_MINOR_BITS_KHR + CL_VERSION_PATCH_BITS_KHR)) +#define CL_VERSION_MINOR_KHR(version) (((version) >> CL_VERSION_PATCH_BITS_KHR) & CL_VERSION_MINOR_MASK_KHR) +#define CL_VERSION_PATCH_KHR(version) ((version) & CL_VERSION_PATCH_MASK_KHR) -/* Host process memory type default value for CL_IMPORT_TYPE_ARM property */ -#define CL_IMPORT_TYPE_HOST_ARM 0x40B3 +#define CL_MAKE_VERSION_KHR(major, minor, patch) \ + ((((major) & CL_VERSION_MAJOR_MASK_KHR) << (CL_VERSION_MINOR_BITS_KHR + CL_VERSION_PATCH_BITS_KHR)) | \ + (((minor) & CL_VERSION_MINOR_MASK_KHR) << CL_VERSION_PATCH_BITS_KHR) | \ + ((patch) & CL_VERSION_PATCH_MASK_KHR)) -/* DMA BUF memory type value for CL_IMPORT_TYPE_ARM property */ -#define CL_IMPORT_TYPE_DMA_BUF_ARM 0x40B4 +#define CL_NAME_VERSION_MAX_NAME_SIZE_KHR 64 -/* Protected DMA BUF memory type value for CL_IMPORT_TYPE_ARM property */ -#define CL_IMPORT_TYPE_PROTECTED_ARM 0x40B5 +typedef cl_uint cl_version_khr; +typedef struct _cl_name_version_khr { + cl_version_khr version; + char name[CL_NAME_VERSION_MAX_NAME_SIZE_KHR]; +} cl_name_version_khr; -/* This extension adds a new function that allows for direct memory import into - * OpenCL via the clImportMemoryARM function. - * - * Memory imported through this interface will be mapped into the device's page - * tables directly, providing zero copy access. It will never fall back to copy - * operations and aliased buffers. - * - * Types of memory supported for import are specified as additional extension - * strings. - * - * This extension produces cl_mem allocations which are compatible with all other - * users of cl_mem in the standard API. - * - * This extension maps pages with the same properties as the normal buffer creation - * function clCreateBuffer. - */ -extern CL_API_ENTRY cl_mem CL_API_CALL -clImportMemoryARM( cl_context context, - cl_mem_flags flags, - const cl_import_properties_arm *properties, - void *memory, - size_t size, - cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0; +/* cl_platform_info */ +#define CL_PLATFORM_NUMERIC_VERSION_KHR 0x0906 +#define CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR 0x0907 +/* cl_device_info */ +#define CL_DEVICE_NUMERIC_VERSION_KHR 0x105E +#define CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR 0x105F +#define CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR 0x1060 +#define CL_DEVICE_ILS_WITH_VERSION_KHR 0x1061 +#define CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR 0x1062 + +/*************************************************************** +* cl_khr_device_uuid +***************************************************************/ +#define cl_khr_device_uuid 1 +#define CL_KHR_DEVICE_UUID_EXTENSION_NAME \ + "cl_khr_device_uuid" + +/* Size Constants */ +#define CL_UUID_SIZE_KHR 16 +#define CL_LUID_SIZE_KHR 8 -/****************************************** - * cl_arm_shared_virtual_memory extension * - ******************************************/ -#define cl_arm_shared_virtual_memory 1 +/* cl_device_info */ +#define CL_DEVICE_UUID_KHR 0x106A +#define CL_DRIVER_UUID_KHR 0x106B +#define CL_DEVICE_LUID_VALID_KHR 0x106C +#define CL_DEVICE_LUID_KHR 0x106D +#define CL_DEVICE_NODE_MASK_KHR 0x106E + +/*************************************************************** +* cl_khr_pci_bus_info +***************************************************************/ +#define cl_khr_pci_bus_info 1 +#define CL_KHR_PCI_BUS_INFO_EXTENSION_NAME \ + "cl_khr_pci_bus_info" + +typedef struct _cl_device_pci_bus_info_khr { + cl_uint pci_domain; + cl_uint pci_bus; + cl_uint pci_device; + cl_uint pci_function; +} cl_device_pci_bus_info_khr; + +/* cl_device_info */ +#define CL_DEVICE_PCI_BUS_INFO_KHR 0x410F + +/*************************************************************** +* cl_khr_suggested_local_work_size +***************************************************************/ +#define cl_khr_suggested_local_work_size 1 +#define CL_KHR_SUGGESTED_LOCAL_WORK_SIZE_EXTENSION_NAME \ + "cl_khr_suggested_local_work_size" + + +typedef cl_int (CL_API_CALL * +clGetKernelSuggestedLocalWorkSizeKHR_fn)( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + size_t* suggested_local_work_size) CL_API_SUFFIX__VERSION_3_0; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetKernelSuggestedLocalWorkSizeKHR( + cl_command_queue command_queue, + cl_kernel kernel, + cl_uint work_dim, + const size_t* global_work_offset, + const size_t* global_work_size, + size_t* suggested_local_work_size) CL_API_SUFFIX__VERSION_3_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_integer_dot_product +***************************************************************/ +#define cl_khr_integer_dot_product 1 +#define CL_KHR_INTEGER_DOT_PRODUCT_EXTENSION_NAME \ + "cl_khr_integer_dot_product" + +typedef cl_bitfield cl_device_integer_dot_product_capabilities_khr; +typedef struct _cl_device_integer_dot_product_acceleration_properties_khr { + cl_bool signed_accelerated; + cl_bool unsigned_accelerated; + cl_bool mixed_signedness_accelerated; + cl_bool accumulating_saturating_signed_accelerated; + cl_bool accumulating_saturating_unsigned_accelerated; + cl_bool accumulating_saturating_mixed_signedness_accelerated; +} cl_device_integer_dot_product_acceleration_properties_khr; + +/* cl_device_integer_dot_product_capabilities_khr */ +#define CL_DEVICE_INTEGER_DOT_PRODUCT_INPUT_4x8BIT_PACKED_KHR (1 << 0) +#define CL_DEVICE_INTEGER_DOT_PRODUCT_INPUT_4x8BIT_KHR (1 << 1) + +/* cl_device_info */ +#define CL_DEVICE_INTEGER_DOT_PRODUCT_CAPABILITIES_KHR 0x1073 +#define CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_8BIT_KHR 0x1074 +#define CL_DEVICE_INTEGER_DOT_PRODUCT_ACCELERATION_PROPERTIES_4x8BIT_PACKED_KHR 0x1075 + +/*************************************************************** +* cl_khr_external_memory +***************************************************************/ +#define cl_khr_external_memory 1 +#define CL_KHR_EXTERNAL_MEMORY_EXTENSION_NAME \ + "cl_khr_external_memory" + +typedef cl_uint cl_external_memory_handle_type_khr; + +/* cl_platform_info */ +#define CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR 0x2044 + +/* cl_device_info */ +#define CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR 0x204F + +/* cl_mem_properties */ +#define CL_DEVICE_HANDLE_LIST_KHR 0x2051 +#define CL_DEVICE_HANDLE_LIST_END_KHR 0 -/* Used by clGetDeviceInfo */ -#define CL_DEVICE_SVM_CAPABILITIES_ARM 0x40B6 +/* cl_command_type */ +#define CL_COMMAND_ACQUIRE_EXTERNAL_MEM_OBJECTS_KHR 0x2047 +#define CL_COMMAND_RELEASE_EXTERNAL_MEM_OBJECTS_KHR 0x2048 -/* Used by clGetMemObjectInfo */ -#define CL_MEM_USES_SVM_POINTER_ARM 0x40B7 -/* Used by clSetKernelExecInfoARM: */ -#define CL_KERNEL_EXEC_INFO_SVM_PTRS_ARM 0x40B8 -#define CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM_ARM 0x40B9 +typedef cl_int (CL_API_CALL * +clEnqueueAcquireExternalMemObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_3_0; -/* To be used by clGetEventInfo: */ -#define CL_COMMAND_SVM_FREE_ARM 0x40BA -#define CL_COMMAND_SVM_MEMCPY_ARM 0x40BB -#define CL_COMMAND_SVM_MEMFILL_ARM 0x40BC -#define CL_COMMAND_SVM_MAP_ARM 0x40BD -#define CL_COMMAND_SVM_UNMAP_ARM 0x40BE +typedef cl_int (CL_API_CALL * +clEnqueueReleaseExternalMemObjectsKHR_fn)( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_3_0; -/* Flag values returned by clGetDeviceInfo with CL_DEVICE_SVM_CAPABILITIES_ARM as the param_name. */ -#define CL_DEVICE_SVM_COARSE_GRAIN_BUFFER_ARM (1 << 0) -#define CL_DEVICE_SVM_FINE_GRAIN_BUFFER_ARM (1 << 1) -#define CL_DEVICE_SVM_FINE_GRAIN_SYSTEM_ARM (1 << 2) -#define CL_DEVICE_SVM_ATOMICS_ARM (1 << 3) +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) -/* Flag values used by clSVMAllocARM: */ -#define CL_MEM_SVM_FINE_GRAIN_BUFFER_ARM (1 << 10) -#define CL_MEM_SVM_ATOMICS_ARM (1 << 11) +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueAcquireExternalMemObjectsKHR( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_3_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReleaseExternalMemObjectsKHR( + cl_command_queue command_queue, + cl_uint num_mem_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_3_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_external_memory_dma_buf +***************************************************************/ +#define cl_khr_external_memory_dma_buf 1 +#define CL_KHR_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME \ + "cl_khr_external_memory_dma_buf" + +/* cl_external_memory_handle_type_khr */ +#define CL_EXTERNAL_MEMORY_HANDLE_DMA_BUF_KHR 0x2067 + +/*************************************************************** +* cl_khr_external_memory_dx +***************************************************************/ +#define cl_khr_external_memory_dx 1 +#define CL_KHR_EXTERNAL_MEMORY_DX_EXTENSION_NAME \ + "cl_khr_external_memory_dx" + +/* cl_external_memory_handle_type_khr */ +#define CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KHR 0x2063 +#define CL_EXTERNAL_MEMORY_HANDLE_D3D11_TEXTURE_KMT_KHR 0x2064 +#define CL_EXTERNAL_MEMORY_HANDLE_D3D12_HEAP_KHR 0x2065 +#define CL_EXTERNAL_MEMORY_HANDLE_D3D12_RESOURCE_KHR 0x2066 + +/*************************************************************** +* cl_khr_external_memory_opaque_fd +***************************************************************/ +#define cl_khr_external_memory_opaque_fd 1 +#define CL_KHR_EXTERNAL_MEMORY_OPAQUE_FD_EXTENSION_NAME \ + "cl_khr_external_memory_opaque_fd" + +/* cl_external_memory_handle_type_khr */ +#define CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR 0x2060 + +/*************************************************************** +* cl_khr_external_memory_win32 +***************************************************************/ +#define cl_khr_external_memory_win32 1 +#define CL_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME \ + "cl_khr_external_memory_win32" + +/* cl_external_memory_handle_type_khr */ +#define CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR 0x2061 +#define CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR 0x2062 + +/*************************************************************** +* cl_khr_external_semaphore +***************************************************************/ +#define cl_khr_external_semaphore 1 +#define CL_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME \ + "cl_khr_external_semaphore" + +typedef struct _cl_semaphore_khr * cl_semaphore_khr; +typedef cl_uint cl_external_semaphore_handle_type_khr; + +/* cl_platform_info */ +#define CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR 0x2037 +#define CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR 0x2038 -typedef cl_bitfield cl_svm_mem_flags_arm; -typedef cl_uint cl_kernel_exec_info_arm; -typedef cl_bitfield cl_device_svm_capabilities_arm; +/* cl_device_info */ +#define CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR 0x204D +#define CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR 0x204E + +/* cl_semaphore_properties_khr */ +#define CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR 0x203F +#define CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR 0 + + +typedef cl_int (CL_API_CALL * +clGetSemaphoreHandleForTypeKHR_fn)( + cl_semaphore_khr sema_object, + cl_device_id device, + cl_external_semaphore_handle_type_khr handle_type, + size_t handle_size, + void* handle_ptr, + size_t* handle_size_ret) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSemaphoreHandleForTypeKHR( + cl_semaphore_khr sema_object, + cl_device_id device, + cl_external_semaphore_handle_type_khr handle_type, + size_t handle_size, + void* handle_ptr, + size_t* handle_size_ret) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_external_semaphore_dx_fence +***************************************************************/ +#define cl_khr_external_semaphore_dx_fence 1 +#define CL_KHR_EXTERNAL_SEMAPHORE_DX_FENCE_EXTENSION_NAME \ + "cl_khr_external_semaphore_dx_fence" + +/* cl_external_semaphore_handle_type_khr */ +#define CL_SEMAPHORE_HANDLE_D3D12_FENCE_KHR 0x2059 + +/*************************************************************** +* cl_khr_external_semaphore_opaque_fd +***************************************************************/ +#define cl_khr_external_semaphore_opaque_fd 1 +#define CL_KHR_EXTERNAL_SEMAPHORE_OPAQUE_FD_EXTENSION_NAME \ + "cl_khr_external_semaphore_opaque_fd" + +/* cl_external_semaphore_handle_type_khr */ +#define CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR 0x2055 + +/*************************************************************** +* cl_khr_external_semaphore_sync_fd +***************************************************************/ +#define cl_khr_external_semaphore_sync_fd 1 +#define CL_KHR_EXTERNAL_SEMAPHORE_SYNC_FD_EXTENSION_NAME \ + "cl_khr_external_semaphore_sync_fd" + +/* cl_external_semaphore_handle_type_khr */ +#define CL_SEMAPHORE_HANDLE_SYNC_FD_KHR 0x2058 + +/*************************************************************** +* cl_khr_external_semaphore_win32 +***************************************************************/ +#define cl_khr_external_semaphore_win32 1 +#define CL_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME \ + "cl_khr_external_semaphore_win32" + +/* cl_external_semaphore_handle_type_khr */ +#define CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR 0x2056 +#define CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR 0x2057 + +/*************************************************************** +* cl_khr_semaphore +***************************************************************/ +#define cl_khr_semaphore 1 +#define CL_KHR_SEMAPHORE_EXTENSION_NAME \ + "cl_khr_semaphore" + +/* type cl_semaphore_khr */ +typedef cl_properties cl_semaphore_properties_khr; +typedef cl_uint cl_semaphore_info_khr; +typedef cl_uint cl_semaphore_type_khr; +typedef cl_ulong cl_semaphore_payload_khr; + +/* cl_semaphore_type */ +#define CL_SEMAPHORE_TYPE_BINARY_KHR 1 + +/* cl_platform_info */ +#define CL_PLATFORM_SEMAPHORE_TYPES_KHR 0x2036 + +/* cl_device_info */ +#define CL_DEVICE_SEMAPHORE_TYPES_KHR 0x204C + +/* cl_semaphore_info_khr */ +#define CL_SEMAPHORE_CONTEXT_KHR 0x2039 +#define CL_SEMAPHORE_REFERENCE_COUNT_KHR 0x203A +#define CL_SEMAPHORE_PROPERTIES_KHR 0x203B +#define CL_SEMAPHORE_PAYLOAD_KHR 0x203C + +/* cl_semaphore_info_khr or cl_semaphore_properties_khr */ +#define CL_SEMAPHORE_TYPE_KHR 0x203D +/* enum CL_DEVICE_HANDLE_LIST_KHR */ +/* enum CL_DEVICE_HANDLE_LIST_END_KHR */ + +/* cl_command_type */ +#define CL_COMMAND_SEMAPHORE_WAIT_KHR 0x2042 +#define CL_COMMAND_SEMAPHORE_SIGNAL_KHR 0x2043 + +/* Error codes */ +#define CL_INVALID_SEMAPHORE_KHR -1142 + + +typedef cl_semaphore_khr (CL_API_CALL * +clCreateSemaphoreWithPropertiesKHR_fn)( + cl_context context, + const cl_semaphore_properties_khr* sema_props, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueWaitSemaphoresKHR_fn)( + cl_command_queue command_queue, + cl_uint num_sema_objects, + const cl_semaphore_khr* sema_objects, + const cl_semaphore_payload_khr* sema_payload_list, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueSignalSemaphoresKHR_fn)( + cl_command_queue command_queue, + cl_uint num_sema_objects, + const cl_semaphore_khr* sema_objects, + const cl_semaphore_payload_khr* sema_payload_list, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clGetSemaphoreInfoKHR_fn)( + cl_semaphore_khr sema_object, + cl_semaphore_info_khr param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clReleaseSemaphoreKHR_fn)( + cl_semaphore_khr sema_object) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clRetainSemaphoreKHR_fn)( + cl_semaphore_khr sema_object) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_semaphore_khr CL_API_CALL +clCreateSemaphoreWithPropertiesKHR( + cl_context context, + const cl_semaphore_properties_khr* sema_props, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; -extern CL_API_ENTRY void * CL_API_CALL -clSVMAllocARM(cl_context context, - cl_svm_mem_flags_arm flags, - size_t size, - cl_uint alignment) CL_EXT_SUFFIX__VERSION_1_2; +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWaitSemaphoresKHR( + cl_command_queue command_queue, + cl_uint num_sema_objects, + const cl_semaphore_khr* sema_objects, + const cl_semaphore_payload_khr* sema_payload_list, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueSignalSemaphoresKHR( + cl_command_queue command_queue, + cl_uint num_sema_objects, + const cl_semaphore_khr* sema_objects, + const cl_semaphore_payload_khr* sema_payload_list, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSemaphoreInfoKHR( + cl_semaphore_khr sema_object, + cl_semaphore_info_khr param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseSemaphoreKHR( + cl_semaphore_khr sema_object) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainSemaphoreKHR( + cl_semaphore_khr sema_object) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_arm_import_memory +***************************************************************/ +#define cl_arm_import_memory 1 +#define CL_ARM_IMPORT_MEMORY_EXTENSION_NAME \ + "cl_arm_import_memory" + +typedef intptr_t cl_import_properties_arm; + +/* cl_import_properties_arm */ +#define CL_IMPORT_TYPE_ARM 0x40B2 +#define CL_IMPORT_TYPE_HOST_ARM 0x40B3 +#define CL_IMPORT_TYPE_DMA_BUF_ARM 0x40B4 +#define CL_IMPORT_TYPE_PROTECTED_ARM 0x40B5 +#define CL_IMPORT_TYPE_ANDROID_HARDWARE_BUFFER_ARM 0x41E2 +#define CL_IMPORT_DMA_BUF_DATA_CONSISTENCY_WITH_HOST_ARM 0x41E3 +#define CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM SIZE_MAX +#define CL_IMPORT_ANDROID_HARDWARE_BUFFER_PLANE_INDEX_ARM 0x41EF +#define CL_IMPORT_ANDROID_HARDWARE_BUFFER_LAYER_INDEX_ARM 0x41F0 + + +typedef cl_mem (CL_API_CALL * +clImportMemoryARM_fn)( + cl_context context, + cl_mem_flags flags, + const cl_import_properties_arm* properties, + void* memory, + size_t size, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_mem CL_API_CALL +clImportMemoryARM( + cl_context context, + cl_mem_flags flags, + const cl_import_properties_arm* properties, + void* memory, + size_t size, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_arm_shared_virtual_memory +***************************************************************/ +#define cl_arm_shared_virtual_memory 1 +#define CL_ARM_SHARED_VIRTUAL_MEMORY_EXTENSION_NAME \ + "cl_arm_shared_virtual_memory" + +typedef cl_bitfield cl_svm_mem_flags_arm; +typedef cl_uint cl_kernel_exec_info_arm; +typedef cl_bitfield cl_device_svm_capabilities_arm; + +/* cl_device_info */ +#define CL_DEVICE_SVM_CAPABILITIES_ARM 0x40B6 + +/* cl_mem_info */ +#define CL_MEM_USES_SVM_POINTER_ARM 0x40B7 + +/* cl_kernel_exec_info_arm */ +#define CL_KERNEL_EXEC_INFO_SVM_PTRS_ARM 0x40B8 +#define CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM_ARM 0x40B9 + +/* cl_command_type */ +#define CL_COMMAND_SVM_FREE_ARM 0x40BA +#define CL_COMMAND_SVM_MEMCPY_ARM 0x40BB +#define CL_COMMAND_SVM_MEMFILL_ARM 0x40BC +#define CL_COMMAND_SVM_MAP_ARM 0x40BD +#define CL_COMMAND_SVM_UNMAP_ARM 0x40BE + +/* cl_device_svm_capabilities_arm */ +#define CL_DEVICE_SVM_COARSE_GRAIN_BUFFER_ARM (1 << 0) +#define CL_DEVICE_SVM_FINE_GRAIN_BUFFER_ARM (1 << 1) +#define CL_DEVICE_SVM_FINE_GRAIN_SYSTEM_ARM (1 << 2) +#define CL_DEVICE_SVM_ATOMICS_ARM (1 << 3) + +/* cl_svm_mem_flags_arm */ +#define CL_MEM_SVM_FINE_GRAIN_BUFFER_ARM (1 << 10) +#define CL_MEM_SVM_ATOMICS_ARM (1 << 11) + + +typedef void* (CL_API_CALL * +clSVMAllocARM_fn)( + cl_context context, + cl_svm_mem_flags_arm flags, + size_t size, + cl_uint alignment) CL_API_SUFFIX__VERSION_1_2; + +typedef void (CL_API_CALL * +clSVMFreeARM_fn)( + cl_context context, + void* svm_pointer) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueSVMFreeARM_fn)( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + void* svm_pointers[], + void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void * svm_pointers[], void *user_data), + void* user_data, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueSVMMemcpyARM_fn)( + cl_command_queue command_queue, + cl_bool blocking_copy, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueSVMMemFillARM_fn)( + cl_command_queue command_queue, + void* svm_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueSVMMapARM_fn)( + cl_command_queue command_queue, + cl_bool blocking_map, + cl_map_flags flags, + void* svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueSVMUnmapARM_fn)( + cl_command_queue command_queue, + void* svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clSetKernelArgSVMPointerARM_fn)( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clSetKernelExecInfoARM_fn)( + cl_kernel kernel, + cl_kernel_exec_info_arm param_name, + size_t param_value_size, + const void* param_value) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY void* CL_API_CALL +clSVMAllocARM( + cl_context context, + cl_svm_mem_flags_arm flags, + size_t size, + cl_uint alignment) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY void CL_API_CALL -clSVMFreeARM(cl_context context, - void * svm_pointer) CL_EXT_SUFFIX__VERSION_1_2; +clSVMFreeARM( + cl_context context, + void* svm_pointer) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMFreeARM(cl_command_queue command_queue, - cl_uint num_svm_pointers, - void * svm_pointers[], - void (CL_CALLBACK * pfn_free_func)(cl_command_queue queue, - cl_uint num_svm_pointers, - void * svm_pointers[], - void * user_data), - void * user_data, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clEnqueueSVMFreeARM( + cl_command_queue command_queue, + cl_uint num_svm_pointers, + void* svm_pointers[], + void (CL_CALLBACK* pfn_free_func)(cl_command_queue queue, cl_uint num_svm_pointers, void * svm_pointers[], void *user_data), + void* user_data, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMemcpyARM(cl_command_queue command_queue, - cl_bool blocking_copy, - void * dst_ptr, - const void * src_ptr, - size_t size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clEnqueueSVMMemcpyARM( + cl_command_queue command_queue, + cl_bool blocking_copy, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMemFillARM(cl_command_queue command_queue, - void * svm_ptr, - const void * pattern, - size_t pattern_size, - size_t size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clEnqueueSVMMemFillARM( + cl_command_queue command_queue, + void* svm_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMMapARM(cl_command_queue command_queue, - cl_bool blocking_map, - cl_map_flags flags, - void * svm_ptr, - size_t size, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clEnqueueSVMMapARM( + cl_command_queue command_queue, + cl_bool blocking_map, + cl_map_flags flags, + void* svm_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueSVMUnmapARM(cl_command_queue command_queue, - void * svm_ptr, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_EXT_SUFFIX__VERSION_1_2; +clEnqueueSVMUnmapARM( + cl_command_queue command_queue, + void* svm_ptr, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clSetKernelArgSVMPointerARM(cl_kernel kernel, - cl_uint arg_index, - const void * arg_value) CL_EXT_SUFFIX__VERSION_1_2; +clSetKernelArgSVMPointerARM( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL -clSetKernelExecInfoARM(cl_kernel kernel, - cl_kernel_exec_info_arm param_name, - size_t param_value_size, - const void * param_value) CL_EXT_SUFFIX__VERSION_1_2; +clSetKernelExecInfoARM( + cl_kernel kernel, + cl_kernel_exec_info_arm param_name, + size_t param_value_size, + const void* param_value) CL_API_SUFFIX__VERSION_1_2; -/******************************** - * cl_arm_get_core_id extension * - ********************************/ +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ -#ifdef CL_VERSION_1_2 +/*************************************************************** +* cl_arm_get_core_id +***************************************************************/ +#if defined(CL_VERSION_1_2) #define cl_arm_get_core_id 1 +#define CL_ARM_GET_CORE_ID_EXTENSION_NAME \ + "cl_arm_get_core_id" + +/* cl_device_info */ +#define CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM 0x40BF + +#endif /* defined(CL_VERSION_1_2) */ + +/*************************************************************** +* cl_arm_job_slot_selection +***************************************************************/ +#define cl_arm_job_slot_selection 1 +#define CL_ARM_JOB_SLOT_SELECTION_EXTENSION_NAME \ + "cl_arm_job_slot_selection" + +/* cl_device_info */ +#define CL_DEVICE_JOB_SLOTS_ARM 0x41E0 + +/* cl_queue_properties */ +#define CL_QUEUE_JOB_SLOT_ARM 0x41E1 + +/*************************************************************** +* cl_arm_scheduling_controls +***************************************************************/ +#define cl_arm_scheduling_controls 1 +#define CL_ARM_SCHEDULING_CONTROLS_EXTENSION_NAME \ + "cl_arm_scheduling_controls" + +/* Types */ +typedef cl_bitfield cl_device_scheduling_controls_capabilities_arm; + +/* cl_device_scheduling_controls_capabilities_arm */ +#define CL_DEVICE_SCHEDULING_KERNEL_BATCHING_ARM (1 << 0) +#define CL_DEVICE_SCHEDULING_WORKGROUP_BATCH_SIZE_ARM (1 << 1) +#define CL_DEVICE_SCHEDULING_WORKGROUP_BATCH_SIZE_MODIFIER_ARM (1 << 2) +#define CL_DEVICE_SCHEDULING_DEFERRED_FLUSH_ARM (1 << 3) +#define CL_DEVICE_SCHEDULING_REGISTER_ALLOCATION_ARM (1 << 4) +#define CL_DEVICE_SCHEDULING_WARP_THROTTLING_ARM (1 << 5) +#define CL_DEVICE_SCHEDULING_COMPUTE_UNIT_BATCH_QUEUE_SIZE_ARM (1 << 6) + +/* cl_device_info */ +#define CL_DEVICE_SCHEDULING_CONTROLS_CAPABILITIES_ARM 0x41E4 +#define CL_DEVICE_SUPPORTED_REGISTER_ALLOCATIONS_ARM 0x41EB +#define CL_DEVICE_MAX_WARP_COUNT_ARM 0x41EA + +/* cl_kernel_exec_info */ +#define CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_ARM 0x41E5 +#define CL_KERNEL_EXEC_INFO_WORKGROUP_BATCH_SIZE_MODIFIER_ARM 0x41E6 +#define CL_KERNEL_EXEC_INFO_WARP_COUNT_LIMIT_ARM 0x41E8 +#define CL_KERNEL_EXEC_INFO_COMPUTE_UNIT_MAX_QUEUED_BATCHES_ARM 0x41F1 + +/* cl_kernel_info */ +#define CL_KERNEL_MAX_WARP_COUNT_ARM 0x41E9 + +/* cl_queue_properties */ +#define CL_QUEUE_KERNEL_BATCHING_ARM 0x41E7 +#define CL_QUEUE_DEFERRED_FLUSH_ARM 0x41EC + +/*************************************************************** +* cl_arm_controlled_kernel_termination +***************************************************************/ +#define cl_arm_controlled_kernel_termination 1 +#define CL_ARM_CONTROLLED_KERNEL_TERMINATION_EXTENSION_NAME \ + "cl_arm_controlled_kernel_termination" + +/* Types */ +typedef cl_bitfield cl_device_controlled_termination_capabilities_arm; + +/* Error codes */ +#define CL_COMMAND_TERMINATED_ITSELF_WITH_FAILURE_ARM -1108 + +/* cl_device_controlled_termination_capabilities_arm */ +#define CL_DEVICE_CONTROLLED_TERMINATION_SUCCESS_ARM (1 << 0) +#define CL_DEVICE_CONTROLLED_TERMINATION_FAILURE_ARM (1 << 1) +#define CL_DEVICE_CONTROLLED_TERMINATION_QUERY_ARM (1 << 2) + +/* cl_device_info */ +#define CL_DEVICE_CONTROLLED_TERMINATION_CAPABILITIES_ARM 0x41EE + +/* cl_event_info */ +#define CL_EVENT_COMMAND_TERMINATION_REASON_ARM 0x41ED + +/* cl_command_termination_reason_arm */ +#define CL_COMMAND_TERMINATION_COMPLETION_ARM 0 +#define CL_COMMAND_TERMINATION_CONTROLLED_SUCCESS_ARM 1 +#define CL_COMMAND_TERMINATION_CONTROLLED_FAILURE_ARM 2 +#define CL_COMMAND_TERMINATION_ERROR_ARM 3 + +/*************************************************************** +* cl_arm_protected_memory_allocation +***************************************************************/ +#define cl_arm_protected_memory_allocation 1 +#define CL_ARM_PROTECTED_MEMORY_ALLOCATION_EXTENSION_NAME \ + "cl_arm_protected_memory_allocation" + +#define CL_MEM_PROTECTED_ALLOC_ARM ((cl_bitfield)1 << 36) + +/*************************************************************** +* cl_intel_exec_by_local_thread +***************************************************************/ +#define cl_intel_exec_by_local_thread 1 +#define CL_INTEL_EXEC_BY_LOCAL_THREAD_EXTENSION_NAME \ + "cl_intel_exec_by_local_thread" + +/* cl_command_queue_properties - bitfield */ +#define CL_QUEUE_THREAD_LOCAL_EXEC_ENABLE_INTEL ((cl_bitfield)1 << 31) + +/*************************************************************** +* cl_intel_device_attribute_query +***************************************************************/ +#define cl_intel_device_attribute_query 1 +#define CL_INTEL_DEVICE_ATTRIBUTE_QUERY_EXTENSION_NAME \ + "cl_intel_device_attribute_query" + +typedef cl_bitfield cl_device_feature_capabilities_intel; + +/* cl_device_feature_capabilities_intel */ +#define CL_DEVICE_FEATURE_FLAG_DP4A_INTEL (1 << 0) +#define CL_DEVICE_FEATURE_FLAG_DPAS_INTEL (1 << 1) + +/* cl_device_info */ +#define CL_DEVICE_IP_VERSION_INTEL 0x4250 +#define CL_DEVICE_ID_INTEL 0x4251 +#define CL_DEVICE_NUM_SLICES_INTEL 0x4252 +#define CL_DEVICE_NUM_SUB_SLICES_PER_SLICE_INTEL 0x4253 +#define CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL 0x4254 +#define CL_DEVICE_NUM_THREADS_PER_EU_INTEL 0x4255 +#define CL_DEVICE_FEATURE_CAPABILITIES_INTEL 0x4256 + +/*************************************************************** +* cl_intel_device_partition_by_names +***************************************************************/ +#define cl_intel_device_partition_by_names 1 +#define CL_INTEL_DEVICE_PARTITION_BY_NAMES_EXTENSION_NAME \ + "cl_intel_device_partition_by_names" + +#define CL_DEVICE_PARTITION_BY_NAMES_INTEL 0x4052 +#define CL_PARTITION_BY_NAMES_LIST_END_INTEL -1 + +/*************************************************************** +* cl_intel_accelerator +***************************************************************/ +#define cl_intel_accelerator 1 +#define CL_INTEL_ACCELERATOR_EXTENSION_NAME \ + "cl_intel_accelerator" + +typedef struct _cl_accelerator_intel* cl_accelerator_intel; +typedef cl_uint cl_accelerator_type_intel; +typedef cl_uint cl_accelerator_info_intel; + +/* cl_accelerator_info_intel */ +#define CL_ACCELERATOR_DESCRIPTOR_INTEL 0x4090 +#define CL_ACCELERATOR_REFERENCE_COUNT_INTEL 0x4091 +#define CL_ACCELERATOR_CONTEXT_INTEL 0x4092 +#define CL_ACCELERATOR_TYPE_INTEL 0x4093 + +/* Error codes */ +#define CL_INVALID_ACCELERATOR_INTEL -1094 +#define CL_INVALID_ACCELERATOR_TYPE_INTEL -1095 +#define CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL -1096 +#define CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL -1097 + + +typedef cl_accelerator_intel (CL_API_CALL * +clCreateAcceleratorINTEL_fn)( + cl_context context, + cl_accelerator_type_intel accelerator_type, + size_t descriptor_size, + const void* descriptor, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clGetAcceleratorInfoINTEL_fn)( + cl_accelerator_intel accelerator, + cl_accelerator_info_intel param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clRetainAcceleratorINTEL_fn)( + cl_accelerator_intel accelerator) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clReleaseAcceleratorINTEL_fn)( + cl_accelerator_intel accelerator) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_accelerator_intel CL_API_CALL +clCreateAcceleratorINTEL( + cl_context context, + cl_accelerator_type_intel accelerator_type, + size_t descriptor_size, + const void* descriptor, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetAcceleratorInfoINTEL( + cl_accelerator_intel accelerator, + cl_accelerator_info_intel param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clRetainAcceleratorINTEL( + cl_accelerator_intel accelerator) CL_API_SUFFIX__VERSION_1_2; + +extern CL_API_ENTRY cl_int CL_API_CALL +clReleaseAcceleratorINTEL( + cl_accelerator_intel accelerator) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_motion_estimation +***************************************************************/ +#define cl_intel_motion_estimation 1 +#define CL_INTEL_MOTION_ESTIMATION_EXTENSION_NAME \ + "cl_intel_motion_estimation" + +typedef struct _cl_motion_estimation_desc_intel { + cl_uint mb_block_type; + cl_uint subpixel_mode; + cl_uint sad_adjust_mode; + cl_uint search_path_type; +} cl_motion_estimation_desc_intel; + +/* cl_accelerator_type_intel */ +#define CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL 0x0 + +/* cl_uint mb_block_type */ +#define CL_ME_MB_TYPE_16x16_INTEL 0x0 +#define CL_ME_MB_TYPE_8x8_INTEL 0x1 +#define CL_ME_MB_TYPE_4x4_INTEL 0x2 + +/* cl_uint subpixel_mode */ +#define CL_ME_SUBPIXEL_MODE_INTEGER_INTEL 0x0 +#define CL_ME_SUBPIXEL_MODE_HPEL_INTEL 0x1 +#define CL_ME_SUBPIXEL_MODE_QPEL_INTEL 0x2 + +/* cl_uint sad_adjust_mode */ +#define CL_ME_SAD_ADJUST_MODE_NONE_INTEL 0x0 +#define CL_ME_SAD_ADJUST_MODE_HAAR_INTEL 0x1 + +/* cl_uint search_path_type */ +#define CL_ME_SEARCH_PATH_RADIUS_2_2_INTEL 0x0 +#define CL_ME_SEARCH_PATH_RADIUS_4_4_INTEL 0x1 +#define CL_ME_SEARCH_PATH_RADIUS_16_12_INTEL 0x5 + +/*************************************************************** +* cl_intel_advanced_motion_estimation +***************************************************************/ +#define cl_intel_advanced_motion_estimation 1 +#define CL_INTEL_ADVANCED_MOTION_ESTIMATION_EXTENSION_NAME \ + "cl_intel_advanced_motion_estimation" + +/* cl_device_info */ +#define CL_DEVICE_ME_VERSION_INTEL 0x407E + +#define CL_ME_VERSION_LEGACY_INTEL 0x0 +#define CL_ME_VERSION_ADVANCED_VER_1_INTEL 0x1 +#define CL_ME_VERSION_ADVANCED_VER_2_INTEL 0x2 + +#define CL_ME_CHROMA_INTRA_PREDICT_ENABLED_INTEL 0x1 +#define CL_ME_LUMA_INTRA_PREDICT_ENABLED_INTEL 0x2 + +#define CL_ME_SKIP_BLOCK_TYPE_16x16_INTEL 0x0 +#define CL_ME_SKIP_BLOCK_TYPE_8x8_INTEL 0x1 + +#define CL_ME_COST_PENALTY_NONE_INTEL 0x0 +#define CL_ME_COST_PENALTY_LOW_INTEL 0x1 +#define CL_ME_COST_PENALTY_NORMAL_INTEL 0x2 +#define CL_ME_COST_PENALTY_HIGH_INTEL 0x3 + +#define CL_ME_COST_PRECISION_QPEL_INTEL 0x0 +#define CL_ME_COST_PRECISION_HPEL_INTEL 0x1 +#define CL_ME_COST_PRECISION_PEL_INTEL 0x2 +#define CL_ME_COST_PRECISION_DPEL_INTEL 0x3 + +#define CL_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL 0x0 +#define CL_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 +#define CL_ME_LUMA_PREDICTOR_MODE_DC_INTEL 0x2 +#define CL_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL 0x3 +#define CL_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL 0x4 +#define CL_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL 0x4 +#define CL_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL 0x5 +#define CL_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL 0x6 +#define CL_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL 0x7 +#define CL_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL 0x8 + +#define CL_ME_CHROMA_PREDICTOR_MODE_DC_INTEL 0x0 +#define CL_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 +#define CL_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL 0x2 +#define CL_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL 0x3 + +#define CL_ME_FORWARD_INPUT_MODE_INTEL 0x1 +#define CL_ME_BACKWARD_INPUT_MODE_INTEL 0x2 +#define CL_ME_BIDIRECTION_INPUT_MODE_INTEL 0x3 + +#define CL_ME_BIDIR_WEIGHT_QUARTER_INTEL 16 +#define CL_ME_BIDIR_WEIGHT_THIRD_INTEL 21 +#define CL_ME_BIDIR_WEIGHT_HALF_INTEL 32 +#define CL_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL 43 +#define CL_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL 48 + +/*************************************************************** +* cl_intel_simultaneous_sharing +***************************************************************/ +#define cl_intel_simultaneous_sharing 1 +#define CL_INTEL_SIMULTANEOUS_SHARING_EXTENSION_NAME \ + "cl_intel_simultaneous_sharing" -/* Device info property for bitfield of cores present */ -#define CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM 0x40BF +/* cl_device_info */ +#define CL_DEVICE_SIMULTANEOUS_INTEROPS_INTEL 0x4104 +#define CL_DEVICE_NUM_SIMULTANEOUS_INTEROPS_INTEL 0x4105 + +/*************************************************************** +* cl_intel_egl_image_yuv +***************************************************************/ +#define cl_intel_egl_image_yuv 1 +#define CL_INTEL_EGL_IMAGE_YUV_EXTENSION_NAME \ + "cl_intel_egl_image_yuv" + +/* cl_egl_image_properties_khr */ +#define CL_EGL_YUV_PLANE_INTEL 0x4107 + +/*************************************************************** +* cl_intel_packed_yuv +***************************************************************/ +#define cl_intel_packed_yuv 1 +#define CL_INTEL_PACKED_YUV_EXTENSION_NAME \ + "cl_intel_packed_yuv" + +/* cl_channel_order */ +#define CL_YUYV_INTEL 0x4076 +#define CL_UYVY_INTEL 0x4077 +#define CL_YVYU_INTEL 0x4078 +#define CL_VYUY_INTEL 0x4079 + +/*************************************************************** +* cl_intel_required_subgroup_size +***************************************************************/ +#define cl_intel_required_subgroup_size 1 +#define CL_INTEL_REQUIRED_SUBGROUP_SIZE_EXTENSION_NAME \ + "cl_intel_required_subgroup_size" + +/* cl_device_info */ +#define CL_DEVICE_SUB_GROUP_SIZES_INTEL 0x4108 + +/* cl_kernel_work_group_info */ +#define CL_KERNEL_SPILL_MEM_SIZE_INTEL 0x4109 + +/* cl_kernel_sub_group_info */ +#define CL_KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL 0x410A + +/*************************************************************** +* cl_intel_driver_diagnostics +***************************************************************/ +#define cl_intel_driver_diagnostics 1 +#define CL_INTEL_DRIVER_DIAGNOSTICS_EXTENSION_NAME \ + "cl_intel_driver_diagnostics" + +typedef cl_uint cl_diagnostics_verbose_level; + +/* cl_context_properties */ +#define CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL 0x4106 +#define CL_CONTEXT_DIAGNOSTICS_LEVEL_ALL_INTEL 0xff +#define CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL (1 << 0) +#define CL_CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL (1 << 1) +#define CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL (1 << 2) + +/*************************************************************** +* cl_intel_planar_yuv +***************************************************************/ +#define cl_intel_planar_yuv 1 +#define CL_INTEL_PLANAR_YUV_EXTENSION_NAME \ + "cl_intel_planar_yuv" + +/* cl_channel_order */ +#define CL_NV12_INTEL 0x410E + +/* cl_mem_flags */ +#define CL_MEM_NO_ACCESS_INTEL (1 << 24) +#define CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL (1 << 25) + +/* cl_device_info */ +#define CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL 0x417E +#define CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL 0x417F + +/*************************************************************** +* cl_intel_device_side_avc_motion_estimation +***************************************************************/ +#define cl_intel_device_side_avc_motion_estimation 1 +#define CL_INTEL_DEVICE_SIDE_AVC_MOTION_ESTIMATION_EXTENSION_NAME \ + "cl_intel_device_side_avc_motion_estimation" + +/* cl_device_info */ +#define CL_DEVICE_AVC_ME_VERSION_INTEL 0x410B +#define CL_DEVICE_AVC_ME_SUPPORTS_TEXTURE_SAMPLER_USE_INTEL 0x410C +#define CL_DEVICE_AVC_ME_SUPPORTS_PREEMPTION_INTEL 0x410D + +/* returned by CL_DEVICE_AVC_ME_VERSION_INTEL */ +#define CL_AVC_ME_VERSION_0_INTEL 0x0 +#define CL_AVC_ME_VERSION_1_INTEL 0x1 + +/* Inter macro-block major shape values */ +#define CL_AVC_ME_MAJOR_16x16_INTEL 0x0 +#define CL_AVC_ME_MAJOR_16x8_INTEL 0x1 +#define CL_AVC_ME_MAJOR_8x16_INTEL 0x2 +#define CL_AVC_ME_MAJOR_8x8_INTEL 0x3 + +/* Inter macro-block minor shape values */ +#define CL_AVC_ME_MINOR_8x8_INTEL 0x0 +#define CL_AVC_ME_MINOR_8x4_INTEL 0x1 +#define CL_AVC_ME_MINOR_4x8_INTEL 0x2 +#define CL_AVC_ME_MINOR_4x4_INTEL 0x3 + +/* Inter macro-block major direction values */ +#define CL_AVC_ME_MAJOR_FORWARD_INTEL 0x0 +#define CL_AVC_ME_MAJOR_BACKWARD_INTEL 0x1 +#define CL_AVC_ME_MAJOR_BIDIRECTIONAL_INTEL 0x2 + +/* Inter (IME) partition mask values */ +#define CL_AVC_ME_PARTITION_MASK_ALL_INTEL 0x0 +#define CL_AVC_ME_PARTITION_MASK_16x16_INTEL 0x7E +#define CL_AVC_ME_PARTITION_MASK_16x8_INTEL 0x7D +#define CL_AVC_ME_PARTITION_MASK_8x16_INTEL 0x7B +#define CL_AVC_ME_PARTITION_MASK_8x8_INTEL 0x77 +#define CL_AVC_ME_PARTITION_MASK_8x4_INTEL 0x6F +#define CL_AVC_ME_PARTITION_MASK_4x8_INTEL 0x5F +#define CL_AVC_ME_PARTITION_MASK_4x4_INTEL 0x3F + +/* Search window configuration */ +#define CL_AVC_ME_SEARCH_WINDOW_EXHAUSTIVE_INTEL 0x0 +#define CL_AVC_ME_SEARCH_WINDOW_SMALL_INTEL 0x1 +#define CL_AVC_ME_SEARCH_WINDOW_TINY_INTEL 0x2 +#define CL_AVC_ME_SEARCH_WINDOW_EXTRA_TINY_INTEL 0x3 +#define CL_AVC_ME_SEARCH_WINDOW_DIAMOND_INTEL 0x4 +#define CL_AVC_ME_SEARCH_WINDOW_LARGE_DIAMOND_INTEL 0x5 +#define CL_AVC_ME_SEARCH_WINDOW_RESERVED0_INTEL 0x6 +#define CL_AVC_ME_SEARCH_WINDOW_RESERVED1_INTEL 0x7 +#define CL_AVC_ME_SEARCH_WINDOW_CUSTOM_INTEL 0x8 +#define CL_AVC_ME_SEARCH_WINDOW_16x12_RADIUS_INTEL 0x9 +#define CL_AVC_ME_SEARCH_WINDOW_4x4_RADIUS_INTEL 0x2 +#define CL_AVC_ME_SEARCH_WINDOW_2x2_RADIUS_INTEL 0xa + +/* SAD adjustment mode */ +#define CL_AVC_ME_SAD_ADJUST_MODE_NONE_INTEL 0x0 +#define CL_AVC_ME_SAD_ADJUST_MODE_HAAR_INTEL 0x2 + +/* Pixel resolution */ +#define CL_AVC_ME_SUBPIXEL_MODE_INTEGER_INTEL 0x0 +#define CL_AVC_ME_SUBPIXEL_MODE_HPEL_INTEL 0x1 +#define CL_AVC_ME_SUBPIXEL_MODE_QPEL_INTEL 0x3 + +/* Cost precision values */ +#define CL_AVC_ME_COST_PRECISION_QPEL_INTEL 0x0 +#define CL_AVC_ME_COST_PRECISION_HPEL_INTEL 0x1 +#define CL_AVC_ME_COST_PRECISION_PEL_INTEL 0x2 +#define CL_AVC_ME_COST_PRECISION_DPEL_INTEL 0x3 + +/* Inter bidirectional weights */ +#define CL_AVC_ME_BIDIR_WEIGHT_QUARTER_INTEL 0x10 +#define CL_AVC_ME_BIDIR_WEIGHT_THIRD_INTEL 0x15 +#define CL_AVC_ME_BIDIR_WEIGHT_HALF_INTEL 0x20 +#define CL_AVC_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL 0x2B +#define CL_AVC_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL 0x30 + +/* Inter border reached values */ +#define CL_AVC_ME_BORDER_REACHED_LEFT_INTEL 0x0 +#define CL_AVC_ME_BORDER_REACHED_RIGHT_INTEL 0x2 +#define CL_AVC_ME_BORDER_REACHED_TOP_INTEL 0x4 +#define CL_AVC_ME_BORDER_REACHED_BOTTOM_INTEL 0x8 + +/* Inter skip block partition type */ +#define CL_AVC_ME_SKIP_BLOCK_PARTITION_16x16_INTEL 0x0 +#define CL_AVC_ME_SKIP_BLOCK_PARTITION_8x8_INTEL 0x4000 + +/* Inter skip motion vector mask */ +#define CL_AVC_ME_SKIP_BLOCK_16x16_FORWARD_ENABLE_INTEL (0x1 << 24) +#define CL_AVC_ME_SKIP_BLOCK_16x16_BACKWARD_ENABLE_INTEL (0x2 << 24) +#define CL_AVC_ME_SKIP_BLOCK_16x16_DUAL_ENABLE_INTEL (0x3 << 24) +#define CL_AVC_ME_SKIP_BLOCK_8x8_FORWARD_ENABLE_INTEL (0x55 << 24) +#define CL_AVC_ME_SKIP_BLOCK_8x8_BACKWARD_ENABLE_INTEL (0xAA << 24) +#define CL_AVC_ME_SKIP_BLOCK_8x8_DUAL_ENABLE_INTEL (0xFF << 24) +#define CL_AVC_ME_SKIP_BLOCK_8x8_0_FORWARD_ENABLE_INTEL (0x1 << 24) +#define CL_AVC_ME_SKIP_BLOCK_8x8_0_BACKWARD_ENABLE_INTEL (0x2 << 24) +#define CL_AVC_ME_SKIP_BLOCK_8x8_1_FORWARD_ENABLE_INTEL (0x1 << 26) +#define CL_AVC_ME_SKIP_BLOCK_8x8_1_BACKWARD_ENABLE_INTEL (0x2 << 26) +#define CL_AVC_ME_SKIP_BLOCK_8x8_2_FORWARD_ENABLE_INTEL (0x1 << 28) +#define CL_AVC_ME_SKIP_BLOCK_8x8_2_BACKWARD_ENABLE_INTEL (0x2 << 28) +#define CL_AVC_ME_SKIP_BLOCK_8x8_3_FORWARD_ENABLE_INTEL (0x1 << 30) +#define CL_AVC_ME_SKIP_BLOCK_8x8_3_BACKWARD_ENABLE_INTEL (0x2 << 30) + +/* Block based skip type values */ +#define CL_AVC_ME_BLOCK_BASED_SKIP_4x4_INTEL 0x00 +#define CL_AVC_ME_BLOCK_BASED_SKIP_8x8_INTEL 0x80 + +/* cl_intel_device_side_avc_motion_estimation.?? */ +#define CL_AVC_ME_INTRA_16x16_INTEL 0x0 +#define CL_AVC_ME_INTRA_8x8_INTEL 0x1 +#define CL_AVC_ME_INTRA_4x4_INTEL 0x2 + +/* Luma intra partition mask values */ +#define CL_AVC_ME_INTRA_LUMA_PARTITION_MASK_16x16_INTEL 0x6 +#define CL_AVC_ME_INTRA_LUMA_PARTITION_MASK_8x8_INTEL 0x5 +#define CL_AVC_ME_INTRA_LUMA_PARTITION_MASK_4x4_INTEL 0x3 + +/* Intra neighbor availability mask values */ +#define CL_AVC_ME_INTRA_NEIGHBOR_LEFT_MASK_ENABLE_INTEL 0x60 +#define CL_AVC_ME_INTRA_NEIGHBOR_UPPER_MASK_ENABLE_INTEL 0x10 +#define CL_AVC_ME_INTRA_NEIGHBOR_UPPER_RIGHT_MASK_ENABLE_INTEL 0x8 +#define CL_AVC_ME_INTRA_NEIGHBOR_UPPER_LEFT_MASK_ENABLE_INTEL 0x4 + +/* Luma intra modes */ +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL 0x0 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_DC_INTEL 0x2 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL 0x3 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL 0x4 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL 0x4 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL 0x5 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL 0x6 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL 0x7 +#define CL_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL 0x8 + +/* Chroma intra modes */ +#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_DC_INTEL 0x0 +#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 +#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL 0x2 +#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL 0x3 + +/* Reference image select values */ +#define CL_AVC_ME_FRAME_FORWARD_INTEL 0x1 +#define CL_AVC_ME_FRAME_BACKWARD_INTEL 0x2 +#define CL_AVC_ME_FRAME_DUAL_INTEL 0x3 + +/* Slice type values */ +#define CL_AVC_ME_SLICE_TYPE_PRED_INTEL 0x0 +#define CL_AVC_ME_SLICE_TYPE_BPRED_INTEL 0x1 +#define CL_AVC_ME_SLICE_TYPE_INTRA_INTEL 0x2 + +/* Interlaced image field polarity values */ +#define CL_AVC_ME_INTERLACED_SCAN_TOP_FIELD_INTEL 0x0 +#define CL_AVC_ME_INTERLACED_SCAN_BOTTOM_FIELD_INTEL 0x1 + +/*************************************************************** +* cl_intel_unified_shared_memory +***************************************************************/ +#define cl_intel_unified_shared_memory 1 +#define CL_INTEL_UNIFIED_SHARED_MEMORY_EXTENSION_NAME \ + "cl_intel_unified_shared_memory" + +typedef cl_bitfield cl_device_unified_shared_memory_capabilities_intel; +typedef cl_properties cl_mem_properties_intel; +typedef cl_bitfield cl_mem_alloc_flags_intel; +typedef cl_uint cl_mem_info_intel; +typedef cl_uint cl_unified_shared_memory_type_intel; +typedef cl_uint cl_mem_advice_intel; + +/* cl_device_info */ +#define CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL 0x4190 +#define CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL 0x4191 +#define CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL 0x4192 +#define CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL 0x4193 +#define CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL 0x4194 + +/* cl_unified_shared_memory_capabilities_intel - bitfield */ +#define CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL (1 << 0) +#define CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL (1 << 1) +#define CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS_INTEL (1 << 2) +#define CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS_INTEL (1 << 3) + +/* cl_mem_properties_intel */ +#define CL_MEM_ALLOC_FLAGS_INTEL 0x4195 + +/* cl_mem_alloc_flags_intel - bitfield */ +#define CL_MEM_ALLOC_WRITE_COMBINED_INTEL (1 << 0) +#define CL_MEM_ALLOC_INITIAL_PLACEMENT_DEVICE_INTEL (1 << 1) +#define CL_MEM_ALLOC_INITIAL_PLACEMENT_HOST_INTEL (1 << 2) + +/* cl_mem_alloc_info_intel */ +#define CL_MEM_ALLOC_TYPE_INTEL 0x419A +#define CL_MEM_ALLOC_BASE_PTR_INTEL 0x419B +#define CL_MEM_ALLOC_SIZE_INTEL 0x419C +#define CL_MEM_ALLOC_DEVICE_INTEL 0x419D + +/* cl_unified_shared_memory_type_intel */ +#define CL_MEM_TYPE_UNKNOWN_INTEL 0x4196 +#define CL_MEM_TYPE_HOST_INTEL 0x4197 +#define CL_MEM_TYPE_DEVICE_INTEL 0x4198 +#define CL_MEM_TYPE_SHARED_INTEL 0x4199 + +/* cl_kernel_exec_info */ +#define CL_KERNEL_EXEC_INFO_INDIRECT_HOST_ACCESS_INTEL 0x4200 +#define CL_KERNEL_EXEC_INFO_INDIRECT_DEVICE_ACCESS_INTEL 0x4201 +#define CL_KERNEL_EXEC_INFO_INDIRECT_SHARED_ACCESS_INTEL 0x4202 +#define CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL 0x4203 + +/* cl_command_type */ +#define CL_COMMAND_MEMFILL_INTEL 0x4204 +#define CL_COMMAND_MEMCPY_INTEL 0x4205 +#define CL_COMMAND_MIGRATEMEM_INTEL 0x4206 +#define CL_COMMAND_MEMADVISE_INTEL 0x4207 + + +typedef void* (CL_API_CALL * +clHostMemAllocINTEL_fn)( + cl_context context, + const cl_mem_properties_intel* properties, + size_t size, + cl_uint alignment, + cl_int* errcode_ret) ; + +typedef void* (CL_API_CALL * +clDeviceMemAllocINTEL_fn)( + cl_context context, + cl_device_id device, + const cl_mem_properties_intel* properties, + size_t size, + cl_uint alignment, + cl_int* errcode_ret) ; + +typedef void* (CL_API_CALL * +clSharedMemAllocINTEL_fn)( + cl_context context, + cl_device_id device, + const cl_mem_properties_intel* properties, + size_t size, + cl_uint alignment, + cl_int* errcode_ret) ; + +typedef cl_int (CL_API_CALL * +clMemFreeINTEL_fn)( + cl_context context, + void* ptr) ; + +typedef cl_int (CL_API_CALL * +clMemBlockingFreeINTEL_fn)( + cl_context context, + void* ptr) ; + +typedef cl_int (CL_API_CALL * +clGetMemAllocInfoINTEL_fn)( + cl_context context, + const void* ptr, + cl_mem_info_intel param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +typedef cl_int (CL_API_CALL * +clSetKernelArgMemPointerINTEL_fn)( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) ; + +typedef cl_int (CL_API_CALL * +clEnqueueMemFillINTEL_fn)( + cl_command_queue command_queue, + void* dst_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +typedef cl_int (CL_API_CALL * +clEnqueueMemcpyINTEL_fn)( + cl_command_queue command_queue, + cl_bool blocking, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +typedef cl_int (CL_API_CALL * +clEnqueueMemAdviseINTEL_fn)( + cl_command_queue command_queue, + const void* ptr, + size_t size, + cl_mem_advice_intel advice, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY void* CL_API_CALL +clHostMemAllocINTEL( + cl_context context, + const cl_mem_properties_intel* properties, + size_t size, + cl_uint alignment, + cl_int* errcode_ret) ; + +extern CL_API_ENTRY void* CL_API_CALL +clDeviceMemAllocINTEL( + cl_context context, + cl_device_id device, + const cl_mem_properties_intel* properties, + size_t size, + cl_uint alignment, + cl_int* errcode_ret) ; + +extern CL_API_ENTRY void* CL_API_CALL +clSharedMemAllocINTEL( + cl_context context, + cl_device_id device, + const cl_mem_properties_intel* properties, + size_t size, + cl_uint alignment, + cl_int* errcode_ret) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clMemFreeINTEL( + cl_context context, + void* ptr) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clMemBlockingFreeINTEL( + cl_context context, + void* ptr) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetMemAllocInfoINTEL( + cl_context context, + const void* ptr, + cl_mem_info_intel param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; -#endif /* CL_VERSION_1_2 */ +extern CL_API_ENTRY cl_int CL_API_CALL +clSetKernelArgMemPointerINTEL( + cl_kernel kernel, + cl_uint arg_index, + const void* arg_value) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMemFillINTEL( + cl_command_queue command_queue, + void* dst_ptr, + const void* pattern, + size_t pattern_size, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMemcpyINTEL( + cl_command_queue command_queue, + cl_bool blocking, + void* dst_ptr, + const void* src_ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMemAdviseINTEL( + cl_command_queue command_queue, + const void* ptr, + size_t size, + cl_mem_advice_intel advice, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +#if defined(CL_VERSION_1_2) +/* Requires OpenCL 1.2 for cl_mem_migration_flags: */ + +typedef cl_int (CL_API_CALL * +clEnqueueMigrateMemINTEL_fn)( + cl_command_queue command_queue, + const void* ptr, + size_t size, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMigrateMemINTEL( + cl_command_queue command_queue, + const void* ptr, + size_t size, + cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +#endif /* defined(CL_VERSION_1_2) */ + +/* deprecated, use clEnqueueMemFillINTEL instead */ + +typedef cl_int (CL_API_CALL * +clEnqueueMemsetINTEL_fn)( + cl_command_queue command_queue, + void* dst_ptr, + cl_int value, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueMemsetINTEL( + cl_command_queue command_queue, + void* dst_ptr, + cl_int value, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_mem_alloc_buffer_location +***************************************************************/ +#define cl_intel_mem_alloc_buffer_location 1 +#define CL_INTEL_MEM_ALLOC_BUFFER_LOCATION_EXTENSION_NAME \ + "cl_intel_mem_alloc_buffer_location" + +/* cl_mem_properties_intel */ +#define CL_MEM_ALLOC_BUFFER_LOCATION_INTEL 0x419E + +/* cl_mem_alloc_info_intel */ +/* enum CL_MEM_ALLOC_BUFFER_LOCATION_INTEL */ + +/*************************************************************** +* cl_intel_create_buffer_with_properties +***************************************************************/ +#define cl_intel_create_buffer_with_properties 1 +#define CL_INTEL_CREATE_BUFFER_WITH_PROPERTIES_EXTENSION_NAME \ + "cl_intel_create_buffer_with_properties" + +/* type cl_mem_properties_intel */ + + +typedef cl_mem (CL_API_CALL * +clCreateBufferWithPropertiesINTEL_fn)( + cl_context context, + const cl_mem_properties_intel* properties, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateBufferWithPropertiesINTEL( + cl_context context, + const cl_mem_properties_intel* properties, + cl_mem_flags flags, + size_t size, + void* host_ptr, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_program_scope_host_pipe +***************************************************************/ +#define cl_intel_program_scope_host_pipe 1 +#define CL_INTEL_PROGRAM_SCOPE_HOST_PIPE_EXTENSION_NAME \ + "cl_intel_program_scope_host_pipe" + +/* clGetEventInfo response when param_name is CL_EVENT_COMMAND_TYPE */ +#define CL_COMMAND_READ_HOST_PIPE_INTEL 0x4214 +#define CL_COMMAND_WRITE_HOST_PIPE_INTEL 0x4215 + +/* clGetProgramInfo param_name */ +#define CL_PROGRAM_NUM_HOST_PIPES_INTEL 0x4216 +#define CL_PROGRAM_HOST_PIPE_NAMES_INTEL 0x4217 + + +typedef cl_int (CL_API_CALL * +clEnqueueReadHostPipeINTEL_fn)( + cl_command_queue command_queue, + cl_program program, + const char* pipe_symbol, + cl_bool blocking_read, + void* ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clEnqueueWriteHostPipeINTEL_fn)( + cl_command_queue command_queue, + cl_program program, + const char* pipe_symbol, + cl_bool blocking_write, + const void* ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueReadHostPipeINTEL( + cl_command_queue command_queue, + cl_program program, + const char* pipe_symbol, + cl_bool blocking_read, + void* ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL +clEnqueueWriteHostPipeINTEL( + cl_command_queue command_queue, + cl_program program, + const char* pipe_symbol, + cl_bool blocking_write, + const void* ptr, + size_t size, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_mem_channel_property +***************************************************************/ +#define cl_intel_mem_channel_property 1 +#define CL_INTEL_MEM_CHANNEL_PROPERTY_EXTENSION_NAME \ + "cl_intel_mem_channel_property" + +/* cl_mem_properties_intel */ +#define CL_MEM_CHANNEL_INTEL 0x4213 + +/*************************************************************** +* cl_intel_mem_force_host_memory +***************************************************************/ +#define cl_intel_mem_force_host_memory 1 +#define CL_INTEL_MEM_FORCE_HOST_MEMORY_EXTENSION_NAME \ + "cl_intel_mem_force_host_memory" + +/* cl_mem_flags */ +#define CL_MEM_FORCE_HOST_MEMORY_INTEL (1 << 20) + +/*************************************************************** +* cl_intel_command_queue_families +***************************************************************/ +#define cl_intel_command_queue_families 1 +#define CL_INTEL_COMMAND_QUEUE_FAMILIES_EXTENSION_NAME \ + "cl_intel_command_queue_families" + +typedef cl_bitfield cl_command_queue_capabilities_intel; + +#define CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL 64 + +typedef struct _cl_queue_family_properties_intel { + cl_command_queue_properties properties; + cl_command_queue_capabilities_intel capabilities; + cl_uint count; + char name[CL_QUEUE_FAMILY_MAX_NAME_SIZE_INTEL]; +} cl_queue_family_properties_intel; + +/* cl_device_info */ +#define CL_DEVICE_QUEUE_FAMILY_PROPERTIES_INTEL 0x418B + +/* cl_queue_properties */ +#define CL_QUEUE_FAMILY_INTEL 0x418C +#define CL_QUEUE_INDEX_INTEL 0x418D + +/* cl_command_queue_capabilities_intel */ +#define CL_QUEUE_DEFAULT_CAPABILITIES_INTEL 0 +#define CL_QUEUE_CAPABILITY_CREATE_SINGLE_QUEUE_EVENTS_INTEL (1 << 0) +#define CL_QUEUE_CAPABILITY_CREATE_CROSS_QUEUE_EVENTS_INTEL (1 << 1) +#define CL_QUEUE_CAPABILITY_SINGLE_QUEUE_EVENT_WAIT_LIST_INTEL (1 << 2) +#define CL_QUEUE_CAPABILITY_CROSS_QUEUE_EVENT_WAIT_LIST_INTEL (1 << 3) +#define CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_INTEL (1 << 8) +#define CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_RECT_INTEL (1 << 9) +#define CL_QUEUE_CAPABILITY_MAP_BUFFER_INTEL (1 << 10) +#define CL_QUEUE_CAPABILITY_FILL_BUFFER_INTEL (1 << 11) +#define CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_INTEL (1 << 12) +#define CL_QUEUE_CAPABILITY_MAP_IMAGE_INTEL (1 << 13) +#define CL_QUEUE_CAPABILITY_FILL_IMAGE_INTEL (1 << 14) +#define CL_QUEUE_CAPABILITY_TRANSFER_BUFFER_IMAGE_INTEL (1 << 15) +#define CL_QUEUE_CAPABILITY_TRANSFER_IMAGE_BUFFER_INTEL (1 << 16) +#define CL_QUEUE_CAPABILITY_MARKER_INTEL (1 << 24) +#define CL_QUEUE_CAPABILITY_BARRIER_INTEL (1 << 25) +#define CL_QUEUE_CAPABILITY_KERNEL_INTEL (1 << 26) + +/*************************************************************** +* cl_intel_queue_no_sync_operations +***************************************************************/ +#define cl_intel_queue_no_sync_operations 1 +#define CL_INTEL_QUEUE_NO_SYNC_OPERATIONS_EXTENSION_NAME \ + "cl_intel_queue_no_sync_operations" + +/* cl_command_queue_properties */ +#define CL_QUEUE_NO_SYNC_OPERATIONS_INTEL (1 << 29) + +/*************************************************************** +* cl_intel_sharing_format_query +***************************************************************/ +#define cl_intel_sharing_format_query 1 +#define CL_INTEL_SHARING_FORMAT_QUERY_EXTENSION_NAME \ + "cl_intel_sharing_format_query" + +/*************************************************************** +* cl_ext_image_requirements_info +***************************************************************/ +#if defined(CL_VERSION_3_0) + +#define cl_ext_image_requirements_info 1 +#define CL_EXT_IMAGE_REQUIREMENTS_INFO_EXTENSION_NAME \ + "cl_ext_image_requirements_info" + +/* Types */ +typedef cl_uint cl_image_requirements_info_ext; + +/* cl_image_requirements_info_ext */ +#define CL_IMAGE_REQUIREMENTS_BASE_ADDRESS_ALIGNMENT_EXT 0x1292 +#define CL_IMAGE_REQUIREMENTS_ROW_PITCH_ALIGNMENT_EXT 0x1290 +#define CL_IMAGE_REQUIREMENTS_SIZE_EXT 0x12B2 +#define CL_IMAGE_REQUIREMENTS_MAX_WIDTH_EXT 0x12B3 +#define CL_IMAGE_REQUIREMENTS_MAX_HEIGHT_EXT 0x12B4 +#define CL_IMAGE_REQUIREMENTS_MAX_DEPTH_EXT 0x12B5 +#define CL_IMAGE_REQUIREMENTS_MAX_ARRAY_SIZE_EXT 0x12B6 + +/* Enqueued Commands APIs */ + +typedef cl_int (CL_API_CALL * +clGetImageRequirementsInfoEXT_fn)( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + cl_image_requirements_info_ext param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_3_0; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetImageRequirementsInfoEXT( + cl_context context, + const cl_mem_properties* properties, + cl_mem_flags flags, + const cl_image_format* image_format, + const cl_image_desc* image_desc, + cl_image_requirements_info_ext param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_3_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +#endif /* defined(CL_VERSION_3_0) */ + +/*************************************************************** +* cl_ext_image_from_buffer +***************************************************************/ +#if defined(CL_VERSION_3_0) + +#define cl_ext_image_from_buffer 1 +#define CL_EXT_IMAGE_FROM_BUFFER_EXTENSION_NAME \ + "cl_ext_image_from_buffer" + +/* cl_image_requirements_info_ext */ +#define CL_IMAGE_REQUIREMENTS_SLICE_PITCH_ALIGNMENT_EXT 0x1291 + +#endif /* defined(CL_VERSION_3_0) */ + +/*************************************************************** +* cl_loader_info +***************************************************************/ +#define cl_loader_info 1 +#define CL_LOADER_INFO_EXTENSION_NAME \ + "cl_loader_info" + +typedef cl_uint cl_icdl_info; + +/* cl_icdl_info */ +#define CL_ICDL_OCL_VERSION 1 +#define CL_ICDL_VERSION 2 +#define CL_ICDL_NAME 3 +#define CL_ICDL_VENDOR 4 + + +typedef cl_int (CL_API_CALL * +clGetICDLoaderInfoOCLICD_fn)( + cl_icdl_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetICDLoaderInfoOCLICD( + cl_icdl_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_depth_images +***************************************************************/ +#define cl_khr_depth_images 1 +#define CL_KHR_DEPTH_IMAGES_EXTENSION_NAME \ + "cl_khr_depth_images" + +#if !defined(CL_VERSION_1_2) +/* cl_channel_order - defined in CL.h for OpenCL 1.2 (?) and newer */ +#define CL_DEPTH 0x10BD + +#endif /* !defined(CL_VERSION_1_2) */ + +/*************************************************************** +* cl_ext_float_atomics +***************************************************************/ +#define cl_ext_float_atomics 1 +#define CL_EXT_FLOAT_ATOMICS_EXTENSION_NAME \ + "cl_ext_float_atomics" + +typedef cl_bitfield cl_device_fp_atomic_capabilities_ext; + +/* cl_device_fp_atomic_capabilities_ext */ +#define CL_DEVICE_GLOBAL_FP_ATOMIC_LOAD_STORE_EXT (1 << 0) +#define CL_DEVICE_GLOBAL_FP_ATOMIC_ADD_EXT (1 << 1) +#define CL_DEVICE_GLOBAL_FP_ATOMIC_MIN_MAX_EXT (1 << 2) +#define CL_DEVICE_LOCAL_FP_ATOMIC_LOAD_STORE_EXT (1 << 16) +#define CL_DEVICE_LOCAL_FP_ATOMIC_ADD_EXT (1 << 17) +#define CL_DEVICE_LOCAL_FP_ATOMIC_MIN_MAX_EXT (1 << 18) + +/* cl_device_info */ +#define CL_DEVICE_SINGLE_FP_ATOMIC_CAPABILITIES_EXT 0x4231 +#define CL_DEVICE_DOUBLE_FP_ATOMIC_CAPABILITIES_EXT 0x4232 +#define CL_DEVICE_HALF_FP_ATOMIC_CAPABILITIES_EXT 0x4233 + +/*************************************************************** +* cl_intel_create_mem_object_properties +***************************************************************/ +#define cl_intel_create_mem_object_properties 1 +#define CL_INTEL_CREATE_MEM_OBJECT_PROPERTIES_EXTENSION_NAME \ + "cl_intel_create_mem_object_properties" + +/* cl_mem_properties */ +#define CL_MEM_LOCALLY_UNCACHED_RESOURCE_INTEL 0x4218 +#define CL_MEM_DEVICE_ID_INTEL 0x4219 + +/*************************************************************** +* cl_pocl_content_size +***************************************************************/ +#define cl_pocl_content_size 1 +#define CL_POCL_CONTENT_SIZE_EXTENSION_NAME \ + "cl_pocl_content_size" + + +typedef cl_int (CL_API_CALL * +clSetContentSizeBufferPoCL_fn)( + cl_mem buffer, + cl_mem content_size_buffer) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clSetContentSizeBufferPoCL( + cl_mem buffer, + cl_mem content_size_buffer) CL_API_SUFFIX__VERSION_1_0; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif - -#endif /* __CL_EXT_H */ +#endif /* OPENCL_CL_EXT_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_ext_intel.h b/deps/OpenCL-Headers/CL/cl_ext_intel.h index 9d1e4b587..a7ae87a34 100644 --- a/deps/OpenCL-Headers/CL/cl_ext_intel.h +++ b/deps/OpenCL-Headers/CL/cl_ext_intel.h @@ -1,423 +1,19 @@ /******************************************************************************* - * Copyright (c) 2008-2019 The Khronos Group Inc. + * Copyright (c) 2008-2020 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ******************************************************************************/ -/*****************************************************************************\ -Copyright (c) 2013-2019 Intel Corporation All Rights Reserved. - -THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE -MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -File Name: cl_ext_intel.h - -Abstract: - -Notes: - -\*****************************************************************************/ - -#ifndef __CL_EXT_INTEL_H -#define __CL_EXT_INTEL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*************************************** -* cl_intel_thread_local_exec extension * -****************************************/ - -#define cl_intel_thread_local_exec 1 - -#define CL_QUEUE_THREAD_LOCAL_EXEC_ENABLE_INTEL (((cl_bitfield)1) << 31) - -/*********************************************** -* cl_intel_device_partition_by_names extension * -************************************************/ - -#define cl_intel_device_partition_by_names 1 - -#define CL_DEVICE_PARTITION_BY_NAMES_INTEL 0x4052 -#define CL_PARTITION_BY_NAMES_LIST_END_INTEL -1 - -/************************************************ -* cl_intel_accelerator extension * -* cl_intel_motion_estimation extension * -* cl_intel_advanced_motion_estimation extension * -*************************************************/ - -#define cl_intel_accelerator 1 -#define cl_intel_motion_estimation 1 -#define cl_intel_advanced_motion_estimation 1 - -typedef struct _cl_accelerator_intel* cl_accelerator_intel; -typedef cl_uint cl_accelerator_type_intel; -typedef cl_uint cl_accelerator_info_intel; - -typedef struct _cl_motion_estimation_desc_intel { - cl_uint mb_block_type; - cl_uint subpixel_mode; - cl_uint sad_adjust_mode; - cl_uint search_path_type; -} cl_motion_estimation_desc_intel; - -/* error codes */ -#define CL_INVALID_ACCELERATOR_INTEL -1094 -#define CL_INVALID_ACCELERATOR_TYPE_INTEL -1095 -#define CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL -1096 -#define CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL -1097 - -/* cl_accelerator_type_intel */ -#define CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL 0x0 - -/* cl_accelerator_info_intel */ -#define CL_ACCELERATOR_DESCRIPTOR_INTEL 0x4090 -#define CL_ACCELERATOR_REFERENCE_COUNT_INTEL 0x4091 -#define CL_ACCELERATOR_CONTEXT_INTEL 0x4092 -#define CL_ACCELERATOR_TYPE_INTEL 0x4093 - -/* cl_motion_detect_desc_intel flags */ -#define CL_ME_MB_TYPE_16x16_INTEL 0x0 -#define CL_ME_MB_TYPE_8x8_INTEL 0x1 -#define CL_ME_MB_TYPE_4x4_INTEL 0x2 - -#define CL_ME_SUBPIXEL_MODE_INTEGER_INTEL 0x0 -#define CL_ME_SUBPIXEL_MODE_HPEL_INTEL 0x1 -#define CL_ME_SUBPIXEL_MODE_QPEL_INTEL 0x2 - -#define CL_ME_SAD_ADJUST_MODE_NONE_INTEL 0x0 -#define CL_ME_SAD_ADJUST_MODE_HAAR_INTEL 0x1 - -#define CL_ME_SEARCH_PATH_RADIUS_2_2_INTEL 0x0 -#define CL_ME_SEARCH_PATH_RADIUS_4_4_INTEL 0x1 -#define CL_ME_SEARCH_PATH_RADIUS_16_12_INTEL 0x5 - -#define CL_ME_SKIP_BLOCK_TYPE_16x16_INTEL 0x0 -#define CL_ME_CHROMA_INTRA_PREDICT_ENABLED_INTEL 0x1 -#define CL_ME_LUMA_INTRA_PREDICT_ENABLED_INTEL 0x2 -#define CL_ME_SKIP_BLOCK_TYPE_8x8_INTEL 0x4 - -#define CL_ME_FORWARD_INPUT_MODE_INTEL 0x1 -#define CL_ME_BACKWARD_INPUT_MODE_INTEL 0x2 -#define CL_ME_BIDIRECTION_INPUT_MODE_INTEL 0x3 - -#define CL_ME_BIDIR_WEIGHT_QUARTER_INTEL 16 -#define CL_ME_BIDIR_WEIGHT_THIRD_INTEL 21 -#define CL_ME_BIDIR_WEIGHT_HALF_INTEL 32 -#define CL_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL 43 -#define CL_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL 48 - -#define CL_ME_COST_PENALTY_NONE_INTEL 0x0 -#define CL_ME_COST_PENALTY_LOW_INTEL 0x1 -#define CL_ME_COST_PENALTY_NORMAL_INTEL 0x2 -#define CL_ME_COST_PENALTY_HIGH_INTEL 0x3 - -#define CL_ME_COST_PRECISION_QPEL_INTEL 0x0 -#define CL_ME_COST_PRECISION_HPEL_INTEL 0x1 -#define CL_ME_COST_PRECISION_PEL_INTEL 0x2 -#define CL_ME_COST_PRECISION_DPEL_INTEL 0x3 - -#define CL_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL 0x0 -#define CL_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 -#define CL_ME_LUMA_PREDICTOR_MODE_DC_INTEL 0x2 -#define CL_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL 0x3 - -#define CL_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL 0x4 -#define CL_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL 0x4 -#define CL_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL 0x5 -#define CL_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL 0x6 -#define CL_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL 0x7 -#define CL_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL 0x8 - -#define CL_ME_CHROMA_PREDICTOR_MODE_DC_INTEL 0x0 -#define CL_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 -#define CL_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL 0x2 -#define CL_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL 0x3 - -/* cl_device_info */ -#define CL_DEVICE_ME_VERSION_INTEL 0x407E - -#define CL_ME_VERSION_LEGACY_INTEL 0x0 -#define CL_ME_VERSION_ADVANCED_VER_1_INTEL 0x1 -#define CL_ME_VERSION_ADVANCED_VER_2_INTEL 0x2 - -extern CL_API_ENTRY cl_accelerator_intel CL_API_CALL -clCreateAcceleratorINTEL( - cl_context context, - cl_accelerator_type_intel accelerator_type, - size_t descriptor_size, - const void* descriptor, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_accelerator_intel (CL_API_CALL *clCreateAcceleratorINTEL_fn)( - cl_context context, - cl_accelerator_type_intel accelerator_type, - size_t descriptor_size, - const void* descriptor, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clGetAcceleratorInfoINTEL( - cl_accelerator_intel accelerator, - cl_accelerator_info_intel param_name, - size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetAcceleratorInfoINTEL_fn)( - cl_accelerator_intel accelerator, - cl_accelerator_info_intel param_name, - size_t param_value_size, - void* param_value, - size_t* param_value_size_ret) CL_EXT_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clRetainAcceleratorINTEL( - cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clRetainAcceleratorINTEL_fn)( - cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; - -extern CL_API_ENTRY cl_int CL_API_CALL -clReleaseAcceleratorINTEL( - cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clReleaseAcceleratorINTEL_fn)( - cl_accelerator_intel accelerator) CL_EXT_SUFFIX__VERSION_1_2; - -/****************************************** -* cl_intel_simultaneous_sharing extension * -*******************************************/ - -#define cl_intel_simultaneous_sharing 1 - -#define CL_DEVICE_SIMULTANEOUS_INTEROPS_INTEL 0x4104 -#define CL_DEVICE_NUM_SIMULTANEOUS_INTEROPS_INTEL 0x4105 - -/*********************************** -* cl_intel_egl_image_yuv extension * -************************************/ - -#define cl_intel_egl_image_yuv 1 - -#define CL_EGL_YUV_PLANE_INTEL 0x4107 - -/******************************** -* cl_intel_packed_yuv extension * -*********************************/ - -#define cl_intel_packed_yuv 1 - -#define CL_YUYV_INTEL 0x4076 -#define CL_UYVY_INTEL 0x4077 -#define CL_YVYU_INTEL 0x4078 -#define CL_VYUY_INTEL 0x4079 - -/******************************************** -* cl_intel_required_subgroup_size extension * -*********************************************/ - -#define cl_intel_required_subgroup_size 1 - -#define CL_DEVICE_SUB_GROUP_SIZES_INTEL 0x4108 -#define CL_KERNEL_SPILL_MEM_SIZE_INTEL 0x4109 -#define CL_KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL 0x410A - -/**************************************** -* cl_intel_driver_diagnostics extension * -*****************************************/ - -#define cl_intel_driver_diagnostics 1 - -typedef cl_uint cl_diagnostics_verbose_level; - -#define CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL 0x4106 - -#define CL_CONTEXT_DIAGNOSTICS_LEVEL_ALL_INTEL ( 0xff ) -#define CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL ( 1 ) -#define CL_CONTEXT_DIAGNOSTICS_LEVEL_BAD_INTEL ( 1 << 1 ) -#define CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL ( 1 << 2 ) - -/******************************** -* cl_intel_planar_yuv extension * -*********************************/ - -#define CL_NV12_INTEL 0x410E - -#define CL_MEM_NO_ACCESS_INTEL ( 1 << 24 ) -#define CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL ( 1 << 25 ) - -#define CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL 0x417E -#define CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL 0x417F - -/******************************************************* -* cl_intel_device_side_avc_motion_estimation extension * -********************************************************/ - -#define CL_DEVICE_AVC_ME_VERSION_INTEL 0x410B -#define CL_DEVICE_AVC_ME_SUPPORTS_TEXTURE_SAMPLER_USE_INTEL 0x410C -#define CL_DEVICE_AVC_ME_SUPPORTS_PREEMPTION_INTEL 0x410D - -#define CL_AVC_ME_VERSION_0_INTEL 0x0; // No support. -#define CL_AVC_ME_VERSION_1_INTEL 0x1; // First supported version. - -#define CL_AVC_ME_MAJOR_16x16_INTEL 0x0 -#define CL_AVC_ME_MAJOR_16x8_INTEL 0x1 -#define CL_AVC_ME_MAJOR_8x16_INTEL 0x2 -#define CL_AVC_ME_MAJOR_8x8_INTEL 0x3 - -#define CL_AVC_ME_MINOR_8x8_INTEL 0x0 -#define CL_AVC_ME_MINOR_8x4_INTEL 0x1 -#define CL_AVC_ME_MINOR_4x8_INTEL 0x2 -#define CL_AVC_ME_MINOR_4x4_INTEL 0x3 - -#define CL_AVC_ME_MAJOR_FORWARD_INTEL 0x0 -#define CL_AVC_ME_MAJOR_BACKWARD_INTEL 0x1 -#define CL_AVC_ME_MAJOR_BIDIRECTIONAL_INTEL 0x2 - -#define CL_AVC_ME_PARTITION_MASK_ALL_INTEL 0x0 -#define CL_AVC_ME_PARTITION_MASK_16x16_INTEL 0x7E -#define CL_AVC_ME_PARTITION_MASK_16x8_INTEL 0x7D -#define CL_AVC_ME_PARTITION_MASK_8x16_INTEL 0x7B -#define CL_AVC_ME_PARTITION_MASK_8x8_INTEL 0x77 -#define CL_AVC_ME_PARTITION_MASK_8x4_INTEL 0x6F -#define CL_AVC_ME_PARTITION_MASK_4x8_INTEL 0x5F -#define CL_AVC_ME_PARTITION_MASK_4x4_INTEL 0x3F - -#define CL_AVC_ME_SEARCH_WINDOW_EXHAUSTIVE_INTEL 0x0 -#define CL_AVC_ME_SEARCH_WINDOW_SMALL_INTEL 0x1 -#define CL_AVC_ME_SEARCH_WINDOW_TINY_INTEL 0x2 -#define CL_AVC_ME_SEARCH_WINDOW_EXTRA_TINY_INTEL 0x3 -#define CL_AVC_ME_SEARCH_WINDOW_DIAMOND_INTEL 0x4 -#define CL_AVC_ME_SEARCH_WINDOW_LARGE_DIAMOND_INTEL 0x5 -#define CL_AVC_ME_SEARCH_WINDOW_RESERVED0_INTEL 0x6 -#define CL_AVC_ME_SEARCH_WINDOW_RESERVED1_INTEL 0x7 -#define CL_AVC_ME_SEARCH_WINDOW_CUSTOM_INTEL 0x8 -#define CL_AVC_ME_SEARCH_WINDOW_16x12_RADIUS_INTEL 0x9 -#define CL_AVC_ME_SEARCH_WINDOW_4x4_RADIUS_INTEL 0x2 -#define CL_AVC_ME_SEARCH_WINDOW_2x2_RADIUS_INTEL 0xa - -#define CL_AVC_ME_SAD_ADJUST_MODE_NONE_INTEL 0x0 -#define CL_AVC_ME_SAD_ADJUST_MODE_HAAR_INTEL 0x2 - -#define CL_AVC_ME_SUBPIXEL_MODE_INTEGER_INTEL 0x0 -#define CL_AVC_ME_SUBPIXEL_MODE_HPEL_INTEL 0x1 -#define CL_AVC_ME_SUBPIXEL_MODE_QPEL_INTEL 0x3 - -#define CL_AVC_ME_COST_PRECISION_QPEL_INTEL 0x0 -#define CL_AVC_ME_COST_PRECISION_HPEL_INTEL 0x1 -#define CL_AVC_ME_COST_PRECISION_PEL_INTEL 0x2 -#define CL_AVC_ME_COST_PRECISION_DPEL_INTEL 0x3 - -#define CL_AVC_ME_BIDIR_WEIGHT_QUARTER_INTEL 0x10 -#define CL_AVC_ME_BIDIR_WEIGHT_THIRD_INTEL 0x15 -#define CL_AVC_ME_BIDIR_WEIGHT_HALF_INTEL 0x20 -#define CL_AVC_ME_BIDIR_WEIGHT_TWO_THIRD_INTEL 0x2B -#define CL_AVC_ME_BIDIR_WEIGHT_THREE_QUARTER_INTEL 0x30 - -#define CL_AVC_ME_BORDER_REACHED_LEFT_INTEL 0x0 -#define CL_AVC_ME_BORDER_REACHED_RIGHT_INTEL 0x2 -#define CL_AVC_ME_BORDER_REACHED_TOP_INTEL 0x4 -#define CL_AVC_ME_BORDER_REACHED_BOTTOM_INTEL 0x8 - -#define CL_AVC_ME_SKIP_BLOCK_PARTITION_16x16_INTEL 0x0 -#define CL_AVC_ME_SKIP_BLOCK_PARTITION_8x8_INTEL 0x4000 - -#define CL_AVC_ME_SKIP_BLOCK_16x16_FORWARD_ENABLE_INTEL ( 0x1 << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_16x16_BACKWARD_ENABLE_INTEL ( 0x2 << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_16x16_DUAL_ENABLE_INTEL ( 0x3 << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_FORWARD_ENABLE_INTEL ( 0x55 << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_BACKWARD_ENABLE_INTEL ( 0xAA << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_DUAL_ENABLE_INTEL ( 0xFF << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_0_FORWARD_ENABLE_INTEL ( 0x1 << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_0_BACKWARD_ENABLE_INTEL ( 0x2 << 24 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_1_FORWARD_ENABLE_INTEL ( 0x1 << 26 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_1_BACKWARD_ENABLE_INTEL ( 0x2 << 26 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_2_FORWARD_ENABLE_INTEL ( 0x1 << 28 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_2_BACKWARD_ENABLE_INTEL ( 0x2 << 28 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_3_FORWARD_ENABLE_INTEL ( 0x1 << 30 ) -#define CL_AVC_ME_SKIP_BLOCK_8x8_3_BACKWARD_ENABLE_INTEL ( 0x2 << 30 ) - -#define CL_AVC_ME_BLOCK_BASED_SKIP_4x4_INTEL 0x00 -#define CL_AVC_ME_BLOCK_BASED_SKIP_8x8_INTEL 0x80 - -#define CL_AVC_ME_INTRA_16x16_INTEL 0x0 -#define CL_AVC_ME_INTRA_8x8_INTEL 0x1 -#define CL_AVC_ME_INTRA_4x4_INTEL 0x2 - -#define CL_AVC_ME_INTRA_LUMA_PARTITION_MASK_16x16_INTEL 0x6 -#define CL_AVC_ME_INTRA_LUMA_PARTITION_MASK_8x8_INTEL 0x5 -#define CL_AVC_ME_INTRA_LUMA_PARTITION_MASK_4x4_INTEL 0x3 - -#define CL_AVC_ME_INTRA_NEIGHBOR_LEFT_MASK_ENABLE_INTEL 0x60 -#define CL_AVC_ME_INTRA_NEIGHBOR_UPPER_MASK_ENABLE_INTEL 0x10 -#define CL_AVC_ME_INTRA_NEIGHBOR_UPPER_RIGHT_MASK_ENABLE_INTEL 0x8 -#define CL_AVC_ME_INTRA_NEIGHBOR_UPPER_LEFT_MASK_ENABLE_INTEL 0x4 - -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_INTEL 0x0 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_DC_INTEL 0x2 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_LEFT_INTEL 0x3 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_DIAGONAL_DOWN_RIGHT_INTEL 0x4 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_PLANE_INTEL 0x4 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_RIGHT_INTEL 0x5 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_DOWN_INTEL 0x6 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_VERTICAL_LEFT_INTEL 0x7 -#define CL_AVC_ME_LUMA_PREDICTOR_MODE_HORIZONTAL_UP_INTEL 0x8 -#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_DC_INTEL 0x0 -#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_HORIZONTAL_INTEL 0x1 -#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_VERTICAL_INTEL 0x2 -#define CL_AVC_ME_CHROMA_PREDICTOR_MODE_PLANE_INTEL 0x3 - -#define CL_AVC_ME_FRAME_FORWARD_INTEL 0x1 -#define CL_AVC_ME_FRAME_BACKWARD_INTEL 0x2 -#define CL_AVC_ME_FRAME_DUAL_INTEL 0x3 - -#define CL_AVC_ME_SLICE_TYPE_PRED_INTEL 0x0 -#define CL_AVC_ME_SLICE_TYPE_BPRED_INTEL 0x1 -#define CL_AVC_ME_SLICE_TYPE_INTRA_INTEL 0x2 - -#define CL_AVC_ME_INTERLACED_SCAN_TOP_FIELD_INTEL 0x0 -#define CL_AVC_ME_INTERLACED_SCAN_BOTTOM_FIELD_INTEL 0x1 - -#ifdef __cplusplus -} -#endif - -#endif /* __CL_EXT_INTEL_H */ +#include +#pragma message("The Intel extensions have been moved into cl_ext.h. Please include cl_ext.h directly.") diff --git a/deps/OpenCL-Headers/CL/cl_gl.h b/deps/OpenCL-Headers/CL/cl_gl.h index fbdaf6297..f88348e25 100644 --- a/deps/OpenCL-Headers/CL/cl_gl.h +++ b/deps/OpenCL-Headers/CL/cl_gl.h @@ -1,171 +1,372 @@ -/********************************************************************************** - * Copyright (c) 2008-2019 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -#ifndef __OPENCL_CL_GL_H -#define __OPENCL_CL_GL_H + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#ifndef OPENCL_CL_GL_H_ +#define OPENCL_CL_GL_H_ + +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ #include -#ifdef __cplusplus -extern "C" { +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES #endif -typedef cl_uint cl_gl_object_type; -typedef cl_uint cl_gl_texture_info; -typedef cl_uint cl_gl_platform_info; -typedef struct __GLsync *cl_GLsync; - -/* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */ -#define CL_GL_OBJECT_BUFFER 0x2000 -#define CL_GL_OBJECT_TEXTURE2D 0x2001 -#define CL_GL_OBJECT_TEXTURE3D 0x2002 -#define CL_GL_OBJECT_RENDERBUFFER 0x2003 -#ifdef CL_VERSION_1_2 -#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E -#define CL_GL_OBJECT_TEXTURE1D 0x200F -#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 -#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES #endif -/* cl_gl_texture_info */ -#define CL_GL_TEXTURE_TARGET 0x2004 -#define CL_GL_MIPMAP_LEVEL 0x2005 -#ifdef CL_VERSION_1_2 -#define CL_GL_NUM_SAMPLES 0x2012 +#ifdef __cplusplus +extern "C" { #endif +/*************************************************************** +* cl_khr_gl_sharing +***************************************************************/ +#define cl_khr_gl_sharing 1 +#define CL_KHR_GL_SHARING_EXTENSION_NAME \ + "cl_khr_gl_sharing" + +typedef cl_uint cl_gl_context_info; + +/* Error codes */ +#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 + +/* cl_gl_context_info */ +#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 +#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 + +/* Additional cl_context_properties */ +#define CL_GL_CONTEXT_KHR 0x2008 +#define CL_EGL_DISPLAY_KHR 0x2009 +#define CL_GLX_DISPLAY_KHR 0x200A +#define CL_WGL_HDC_KHR 0x200B +#define CL_CGL_SHAREGROUP_KHR 0x200C + +typedef cl_uint cl_gl_object_type; +typedef cl_uint cl_gl_texture_info; +typedef cl_uint cl_gl_platform_info; + +/* cl_gl_object_type */ +#define CL_GL_OBJECT_BUFFER 0x2000 +#define CL_GL_OBJECT_TEXTURE2D 0x2001 +#define CL_GL_OBJECT_TEXTURE3D 0x2002 +#define CL_GL_OBJECT_RENDERBUFFER 0x2003 + +#if defined(CL_VERSION_1_2) +/* cl_gl_object_type */ +#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E +#define CL_GL_OBJECT_TEXTURE1D 0x200F +#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 +#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 + +#endif /* defined(CL_VERSION_1_2) */ + +/* cl_gl_texture_info */ +#define CL_GL_TEXTURE_TARGET 0x2004 +#define CL_GL_MIPMAP_LEVEL 0x2005 + + +typedef cl_int (CL_API_CALL * +clGetGLContextInfoKHR_fn)( + const cl_context_properties* properties, + cl_gl_context_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem (CL_API_CALL * +clCreateFromGLBuffer_fn)( + cl_context context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetGLContextInfoKHR( + const cl_context_properties* properties, + cl_gl_context_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLBuffer(cl_context context, - cl_mem_flags flags, - cl_GLuint bufobj, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; +clCreateFromGLBuffer( + cl_context context, + cl_mem_flags flags, + cl_GLuint bufobj, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; -#ifdef CL_VERSION_1_2 +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +#if defined(CL_VERSION_1_2) + +typedef cl_mem (CL_API_CALL * +clCreateFromGLTexture_fn)( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLTexture(cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; +clCreateFromGLTexture( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; -#endif +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +#endif /* defined(CL_VERSION_1_2) */ + + +typedef cl_mem (CL_API_CALL * +clCreateFromGLRenderbuffer_fn)( + cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clGetGLObjectInfo_fn)( + cl_mem memobj, + cl_gl_object_type* gl_object_type, + cl_GLuint* gl_object_name) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clGetGLTextureInfo_fn)( + cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireGLObjects_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseGLObjects_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_mem CL_API_CALL -clCreateFromGLRenderbuffer(cl_context context, - cl_mem_flags flags, - cl_GLuint renderbuffer, - cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; +clCreateFromGLRenderbuffer( + cl_context context, + cl_mem_flags flags, + cl_GLuint renderbuffer, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLObjectInfo(cl_mem memobj, - cl_gl_object_type * gl_object_type, - cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0; +clGetGLObjectInfo( + cl_mem memobj, + cl_gl_object_type* gl_object_type, + cl_GLuint* gl_object_name) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLTextureInfo(cl_mem memobj, - cl_gl_texture_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; +clGetGLTextureInfo( + cl_mem memobj, + cl_gl_texture_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueAcquireGLObjects(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; +clEnqueueAcquireGLObjects( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL -clEnqueueReleaseGLObjects(cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem * mem_objects, - cl_uint num_events_in_wait_list, - const cl_event * event_wait_list, - cl_event * event) CL_API_SUFFIX__VERSION_1_0; - - -/* Deprecated OpenCL 1.1 APIs */ -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL -clCreateFromGLTexture2D(cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL -clCreateFromGLTexture3D(cl_context context, - cl_mem_flags flags, - cl_GLenum target, - cl_GLint miplevel, - cl_GLuint texture, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; - -/* cl_khr_gl_sharing extension */ +clEnqueueReleaseGLObjects( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_0; -#define cl_khr_gl_sharing 1 +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/* OpenCL 1.0 APIs that were deprecated in OpenCL 1.2 */ + +typedef cl_mem (CL_API_CALL * +clCreateFromGLTexture2D_fn)( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef cl_mem (CL_API_CALL * +clCreateFromGLTexture3D_fn)( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture2D( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromGLTexture3D( + cl_context context, + cl_mem_flags flags, + cl_GLenum target, + cl_GLint miplevel, + cl_GLuint texture, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_gl_event +***************************************************************/ +#define cl_khr_gl_event 1 +#define CL_KHR_GL_EVENT_EXTENSION_NAME \ + "cl_khr_gl_event" -typedef cl_uint cl_gl_context_info; +typedef struct __GLsync * cl_GLsync; -/* Additional Error Codes */ -#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 +/* cl_command_type */ +#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D -/* cl_gl_context_info */ -#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 -#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 -/* Additional cl_context_properties */ -#define CL_GL_CONTEXT_KHR 0x2008 -#define CL_EGL_DISPLAY_KHR 0x2009 -#define CL_GLX_DISPLAY_KHR 0x200A -#define CL_WGL_HDC_KHR 0x200B -#define CL_CGL_SHAREGROUP_KHR 0x200C +typedef cl_event (CL_API_CALL * +clCreateEventFromGLsyncKHR_fn)( + cl_context context, + cl_GLsync sync, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; + +#if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_event CL_API_CALL +clCreateEventFromGLsyncKHR( + cl_context context, + cl_GLsync sync, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; + +#endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_khr_gl_depth_images +***************************************************************/ +#define cl_khr_gl_depth_images 1 +#define CL_KHR_GL_DEPTH_IMAGES_EXTENSION_NAME \ + "cl_khr_gl_depth_images" + +#if !defined(CL_VERSION_1_2) +/* cl_channel_order - defined in CL.h for OpenCL 1.2 and newer */ +#define CL_DEPTH_STENCIL 0x10BE + +#endif /* !defined(CL_VERSION_1_2) */ + +#if !defined(CL_VERSION_1_2) +/* cl_channel_type - defined in CL.h for OpenCL 1.2 and newer */ +#define CL_UNORM_INT24 0x10DF + +#endif /* !defined(CL_VERSION_1_2) */ + +/*************************************************************** +* cl_khr_gl_msaa_sharing +***************************************************************/ +#define cl_khr_gl_msaa_sharing 1 +#define CL_KHR_GL_MSAA_SHARING_EXTENSION_NAME \ + "cl_khr_gl_msaa_sharing" + +/* cl_gl_texture_info */ +#define CL_GL_NUM_SAMPLES 0x2012 + +/*************************************************************** +* cl_intel_sharing_format_query_gl +***************************************************************/ +#define cl_intel_sharing_format_query_gl 1 +#define CL_INTEL_SHARING_FORMAT_QUERY_GL_EXTENSION_NAME \ + "cl_intel_sharing_format_query_gl" + +/* when cl_khr_gl_sharing is supported */ + +typedef cl_int (CL_API_CALL * +clGetSupportedGLTextureFormatsINTEL_fn)( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_GLenum* gl_formats, + cl_uint* num_texture_formats) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_int CL_API_CALL -clGetGLContextInfoKHR(const cl_context_properties * properties, - cl_gl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( - const cl_context_properties * properties, - cl_gl_context_info param_name, - size_t param_value_size, - void * param_value, - size_t * param_value_size_ret); +clGetSupportedGLTextureFormatsINTEL( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint num_entries, + cl_GLenum* gl_formats, + cl_uint* num_texture_formats) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif -#endif /* __OPENCL_CL_GL_H */ +#endif /* OPENCL_CL_GL_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_gl_ext.h b/deps/OpenCL-Headers/CL/cl_gl_ext.h index c26d31abe..b5da13eb6 100644 --- a/deps/OpenCL-Headers/CL/cl_gl_ext.h +++ b/deps/OpenCL-Headers/CL/cl_gl_ext.h @@ -1,52 +1,18 @@ -/********************************************************************************** - * Copyright (c) 2008-2019 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2021 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ - -#ifndef __OPENCL_CL_GL_EXT_H -#define __OPENCL_CL_GL_EXT_H - -#ifdef __cplusplus -extern "C" { -#endif + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ #include - -/* - * cl_khr_gl_event extension - */ -#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D - -extern CL_API_ENTRY cl_event CL_API_CALL -clCreateEventFromGLsyncKHR(cl_context context, - cl_GLsync cl_GLsync, - cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1; - -#ifdef __cplusplus -} -#endif - -#endif /* __OPENCL_CL_GL_EXT_H */ +#pragma message("The extensions in cl_gl_ext.h have been moved into cl_gl.h. Please include cl_gl.h directly.") diff --git a/deps/OpenCL-Headers/CL/cl_half.h b/deps/OpenCL-Headers/CL/cl_half.h new file mode 100644 index 000000000..ecc422332 --- /dev/null +++ b/deps/OpenCL-Headers/CL/cl_half.h @@ -0,0 +1,440 @@ +/******************************************************************************* + * Copyright (c) 2019-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +/** + * This is a header-only utility library that provides OpenCL host code with + * routines for converting to/from cl_half values. + * + * Example usage: + * + * #include + * ... + * cl_half h = cl_half_from_float(0.5f, CL_HALF_RTE); + * cl_float f = cl_half_to_float(h); + */ + +#ifndef OPENCL_CL_HALF_H +#define OPENCL_CL_HALF_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Rounding mode used when converting to cl_half. + */ +typedef enum +{ + CL_HALF_RTE, // round to nearest even + CL_HALF_RTZ, // round towards zero + CL_HALF_RTP, // round towards positive infinity + CL_HALF_RTN, // round towards negative infinity +} cl_half_rounding_mode; + + +/* Private utility macros. */ +#define CL_HALF_EXP_MASK 0x7C00 +#define CL_HALF_MAX_FINITE_MAG 0x7BFF + + +/* + * Utility to deal with values that overflow when converting to half precision. + */ +static inline cl_half cl_half_handle_overflow(cl_half_rounding_mode rounding_mode, + uint16_t sign) +{ + if (rounding_mode == CL_HALF_RTZ) + { + // Round overflow towards zero -> largest finite number (preserving sign) + return (sign << 15) | CL_HALF_MAX_FINITE_MAG; + } + else if (rounding_mode == CL_HALF_RTP && sign) + { + // Round negative overflow towards positive infinity -> most negative finite number + return (1 << 15) | CL_HALF_MAX_FINITE_MAG; + } + else if (rounding_mode == CL_HALF_RTN && !sign) + { + // Round positive overflow towards negative infinity -> largest finite number + return CL_HALF_MAX_FINITE_MAG; + } + + // Overflow to infinity + return (sign << 15) | CL_HALF_EXP_MASK; +} + +/* + * Utility to deal with values that underflow when converting to half precision. + */ +static inline cl_half cl_half_handle_underflow(cl_half_rounding_mode rounding_mode, + uint16_t sign) +{ + if (rounding_mode == CL_HALF_RTP && !sign) + { + // Round underflow towards positive infinity -> smallest positive value + return (sign << 15) | 1; + } + else if (rounding_mode == CL_HALF_RTN && sign) + { + // Round underflow towards negative infinity -> largest negative value + return (sign << 15) | 1; + } + + // Flush to zero + return (sign << 15); +} + + +/** + * Convert a cl_float to a cl_half. + */ +static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode rounding_mode) +{ + // Type-punning to get direct access to underlying bits + union + { + cl_float f; + uint32_t i; + } f32; + f32.f = f; + + // Extract sign bit + uint16_t sign = f32.i >> 31; + + // Extract FP32 exponent and mantissa + uint32_t f_exp = (f32.i >> (CL_FLT_MANT_DIG - 1)) & 0xFF; + uint32_t f_mant = f32.i & ((1 << (CL_FLT_MANT_DIG - 1)) - 1); + + // Remove FP32 exponent bias + int32_t exp = f_exp - CL_FLT_MAX_EXP + 1; + + // Add FP16 exponent bias + uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1); + + // Position of the bit that will become the FP16 mantissa LSB + uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG; + + // Check for NaN / infinity + if (f_exp == 0xFF) + { + if (f_mant) + { + // NaN -> propagate mantissa and silence it + uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); + h_mant |= 0x200; + return (sign << 15) | CL_HALF_EXP_MASK | h_mant; + } + else + { + // Infinity -> zero mantissa + return (sign << 15) | CL_HALF_EXP_MASK; + } + } + + // Check for zero + if (!f_exp && !f_mant) + { + return (sign << 15); + } + + // Check for overflow + if (exp >= CL_HALF_MAX_EXP) + { + return cl_half_handle_overflow(rounding_mode, sign); + } + + // Check for underflow + if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) + { + return cl_half_handle_underflow(rounding_mode, sign); + } + + // Check for value that will become denormal + if (exp < -14) + { + // Denormal -> include the implicit 1 from the FP32 mantissa + h_exp = 0; + f_mant |= 1 << (CL_FLT_MANT_DIG - 1); + + // Mantissa shift amount depends on exponent + lsb_pos = -exp + (CL_FLT_MANT_DIG - 25); + } + + // Generate FP16 mantissa by shifting FP32 mantissa + uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); + + // Check whether we need to round + uint32_t halfway = 1 << (lsb_pos - 1); + uint32_t mask = (halfway << 1) - 1; + switch (rounding_mode) + { + case CL_HALF_RTE: + if ((f_mant & mask) > halfway) + { + // More than halfway -> round up + h_mant += 1; + } + else if ((f_mant & mask) == halfway) + { + // Exactly halfway -> round to nearest even + if (h_mant & 0x1) + h_mant += 1; + } + break; + case CL_HALF_RTZ: + // Mantissa has already been truncated -> do nothing + break; + case CL_HALF_RTP: + if ((f_mant & mask) && !sign) + { + // Round positive numbers up + h_mant += 1; + } + break; + case CL_HALF_RTN: + if ((f_mant & mask) && sign) + { + // Round negative numbers down + h_mant += 1; + } + break; + } + + // Check for mantissa overflow + if (h_mant & 0x400) + { + h_exp += 1; + h_mant = 0; + } + + return (sign << 15) | (h_exp << 10) | h_mant; +} + + +/** + * Convert a cl_double to a cl_half. + */ +static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rounding_mode) +{ + // Type-punning to get direct access to underlying bits + union + { + cl_double d; + uint64_t i; + } f64; + f64.d = d; + + // Extract sign bit + uint16_t sign = f64.i >> 63; + + // Extract FP64 exponent and mantissa + uint64_t d_exp = (f64.i >> (CL_DBL_MANT_DIG - 1)) & 0x7FF; + uint64_t d_mant = f64.i & (((uint64_t)1 << (CL_DBL_MANT_DIG - 1)) - 1); + + // Remove FP64 exponent bias + int64_t exp = d_exp - CL_DBL_MAX_EXP + 1; + + // Add FP16 exponent bias + uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1); + + // Position of the bit that will become the FP16 mantissa LSB + uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG; + + // Check for NaN / infinity + if (d_exp == 0x7FF) + { + if (d_mant) + { + // NaN -> propagate mantissa and silence it + uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); + h_mant |= 0x200; + return (sign << 15) | CL_HALF_EXP_MASK | h_mant; + } + else + { + // Infinity -> zero mantissa + return (sign << 15) | CL_HALF_EXP_MASK; + } + } + + // Check for zero + if (!d_exp && !d_mant) + { + return (sign << 15); + } + + // Check for overflow + if (exp >= CL_HALF_MAX_EXP) + { + return cl_half_handle_overflow(rounding_mode, sign); + } + + // Check for underflow + if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) + { + return cl_half_handle_underflow(rounding_mode, sign); + } + + // Check for value that will become denormal + if (exp < -14) + { + // Include the implicit 1 from the FP64 mantissa + h_exp = 0; + d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1); + + // Mantissa shift amount depends on exponent + lsb_pos = (uint32_t)(-exp + (CL_DBL_MANT_DIG - 25)); + } + + // Generate FP16 mantissa by shifting FP64 mantissa + uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); + + // Check whether we need to round + uint64_t halfway = (uint64_t)1 << (lsb_pos - 1); + uint64_t mask = (halfway << 1) - 1; + switch (rounding_mode) + { + case CL_HALF_RTE: + if ((d_mant & mask) > halfway) + { + // More than halfway -> round up + h_mant += 1; + } + else if ((d_mant & mask) == halfway) + { + // Exactly halfway -> round to nearest even + if (h_mant & 0x1) + h_mant += 1; + } + break; + case CL_HALF_RTZ: + // Mantissa has already been truncated -> do nothing + break; + case CL_HALF_RTP: + if ((d_mant & mask) && !sign) + { + // Round positive numbers up + h_mant += 1; + } + break; + case CL_HALF_RTN: + if ((d_mant & mask) && sign) + { + // Round negative numbers down + h_mant += 1; + } + break; + } + + // Check for mantissa overflow + if (h_mant & 0x400) + { + h_exp += 1; + h_mant = 0; + } + + return (sign << 15) | (h_exp << 10) | h_mant; +} + + +/** + * Convert a cl_half to a cl_float. + */ +static inline cl_float cl_half_to_float(cl_half h) +{ + // Type-punning to get direct access to underlying bits + union + { + cl_float f; + uint32_t i; + } f32; + + // Extract sign bit + uint16_t sign = h >> 15; + + // Extract FP16 exponent and mantissa + uint16_t h_exp = (h >> (CL_HALF_MANT_DIG - 1)) & 0x1F; + uint16_t h_mant = h & 0x3FF; + + // Remove FP16 exponent bias + int32_t exp = h_exp - CL_HALF_MAX_EXP + 1; + + // Add FP32 exponent bias + uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1; + + // Check for NaN / infinity + if (h_exp == 0x1F) + { + if (h_mant) + { + // NaN -> propagate mantissa and silence it + uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG); + f_mant |= 0x400000; + f32.i = (sign << 31) | 0x7F800000 | f_mant; + return f32.f; + } + else + { + // Infinity -> zero mantissa + f32.i = (sign << 31) | 0x7F800000; + return f32.f; + } + } + + // Check for zero / denormal + if (h_exp == 0) + { + if (h_mant == 0) + { + // Zero -> zero exponent + f_exp = 0; + } + else + { + // Denormal -> normalize it + // - Shift mantissa to make most-significant 1 implicit + // - Adjust exponent accordingly + uint32_t shift = 0; + while ((h_mant & 0x400) == 0) + { + h_mant <<= 1; + shift++; + } + h_mant &= 0x3FF; + f_exp -= shift - 1; + } + } + + f32.i = (sign << 31) | (f_exp << 23) | (h_mant << 13); + return f32.f; +} + + +#undef CL_HALF_EXP_MASK +#undef CL_HALF_MAX_FINITE_MAG + + +#ifdef __cplusplus +} +#endif + + +#endif /* OPENCL_CL_HALF_H */ diff --git a/deps/OpenCL-Headers/CL/cl_icd.h b/deps/OpenCL-Headers/CL/cl_icd.h new file mode 100644 index 000000000..360b87030 --- /dev/null +++ b/deps/OpenCL-Headers/CL/cl_icd.h @@ -0,0 +1,1294 @@ +/******************************************************************************* + * Copyright (c) 2019-2020 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#ifndef OPENCL_CL_ICD_H +#define OPENCL_CL_ICD_H + +#include +#include +#include +#include + +#if defined(_WIN32) +#include +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains pointer type definitions for each of the CL API calls as + * well as a type definition for the dispatch table used by the Khronos ICD + * loader (see cl_khr_icd extension specification for background). + */ + +/* API function pointer definitions */ + +// Platform APIs +typedef cl_int(CL_API_CALL *cl_api_clGetPlatformIDs)( + cl_uint num_entries, cl_platform_id *platforms, + cl_uint *num_platforms) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetPlatformInfo)( + cl_platform_id platform, cl_platform_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Device APIs +typedef cl_int(CL_API_CALL *cl_api_clGetDeviceIDs)( + cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, + cl_device_id *devices, cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetDeviceInfo)( + cl_device_id device, cl_device_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clCreateSubDevices)( + cl_device_id in_device, + const cl_device_partition_property *partition_properties, + cl_uint num_entries, cl_device_id *out_devices, cl_uint *num_devices); + +typedef cl_int(CL_API_CALL *cl_api_clRetainDevice)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseDevice)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clCreateSubDevices; +typedef void *cl_api_clRetainDevice; +typedef void *cl_api_clReleaseDevice; + +#endif + +// Context APIs +typedef cl_context(CL_API_CALL *cl_api_clCreateContext)( + const cl_context_properties *properties, cl_uint num_devices, + const cl_device_id *devices, + void(CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), + void *user_data, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_context(CL_API_CALL *cl_api_clCreateContextFromType)( + const cl_context_properties *properties, cl_device_type device_type, + void(CL_CALLBACK *pfn_notify)(const char *, const void *, size_t, void *), + void *user_data, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clRetainContext)( + cl_context context) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseContext)( + cl_context context) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetContextInfo)( + cl_context context, cl_context_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Command Queue APIs +typedef cl_command_queue(CL_API_CALL *cl_api_clCreateCommandQueue)( + cl_context context, cl_device_id device, + cl_command_queue_properties properties, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_2_0 + +typedef +cl_command_queue(CL_API_CALL *cl_api_clCreateCommandQueueWithProperties)( + cl_context /* context */, cl_device_id /* device */, + const cl_queue_properties * /* properties */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; + +#else + +typedef void *cl_api_clCreateCommandQueueWithProperties; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clRetainCommandQueue)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseCommandQueue)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetCommandQueueInfo)( + cl_command_queue command_queue, cl_command_queue_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Memory Object APIs +typedef cl_mem(CL_API_CALL *cl_api_clCreateBuffer)( + cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_mem(CL_API_CALL *cl_api_clCreateImage)( + cl_context context, cl_mem_flags flags, const cl_image_format *image_format, + const cl_image_desc *image_desc, void *host_ptr, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clCreateImage; + +#endif + +#ifdef CL_VERSION_3_0 + +typedef cl_mem(CL_API_CALL *cl_api_clCreateBufferWithProperties)( + cl_context context, const cl_mem_properties *properties, cl_mem_flags flags, + size_t size, void *host_ptr, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_3_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateImageWithProperties)( + cl_context context, const cl_mem_properties *properties, cl_mem_flags flags, + const cl_image_format *image_format, const cl_image_desc *image_desc, + void *host_ptr, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_3_0; + +typedef cl_int(CL_API_CALL* cl_api_clSetContextDestructorCallback)( + cl_context context, + void(CL_CALLBACK* pfn_notify)(cl_context context, void* user_data), + void* user_data) CL_API_SUFFIX__VERSION_3_0; + +#else + +typedef void *cl_api_clCreateBufferWithProperties; +typedef void *cl_api_clCreateImageWithProperties; +typedef void *cl_api_clSetContextDestructorCallback; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clRetainMemObject)( + cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseMemObject)( + cl_mem memobj) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetSupportedImageFormats)( + cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, + cl_uint num_entries, cl_image_format *image_formats, + cl_uint *num_image_formats) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetMemObjectInfo)( + cl_mem memobj, cl_mem_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetImageInfo)( + cl_mem image, cl_image_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_2_0 + +typedef cl_mem(CL_API_CALL *cl_api_clCreatePipe)( + cl_context /* context */, cl_mem_flags /* flags */, + cl_uint /* pipe_packet_size */, cl_uint /* pipe_max_packets */, + const cl_pipe_properties * /* properties */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetPipeInfo)( + cl_mem /* pipe */, cl_pipe_info /* param_name */, + size_t /* param_value_size */, void * /* param_value */, + size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_2_0; + +typedef void *(CL_API_CALL *cl_api_clSVMAlloc)( + cl_context /* context */, cl_svm_mem_flags /* flags */, size_t /* size */, + unsigned int /* alignment */)CL_API_SUFFIX__VERSION_2_0; + +typedef void(CL_API_CALL *cl_api_clSVMFree)( + cl_context /* context */, + void * /* svm_pointer */) CL_API_SUFFIX__VERSION_2_0; + +#else + +typedef void *cl_api_clCreatePipe; +typedef void *cl_api_clGetPipeInfo; +typedef void *cl_api_clSVMAlloc; +typedef void *cl_api_clSVMFree; + +#endif + +// Sampler APIs +typedef cl_sampler(CL_API_CALL *cl_api_clCreateSampler)( + cl_context context, cl_bool normalized_coords, + cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clRetainSampler)( + cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseSampler)( + cl_sampler sampler) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetSamplerInfo)( + cl_sampler sampler, cl_sampler_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_2_0 + +typedef +cl_sampler(CL_API_CALL *cl_api_clCreateSamplerWithProperties)( + cl_context /* context */, + const cl_sampler_properties * /* sampler_properties */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; + +#else + +typedef void *cl_api_clCreateSamplerWithProperties; + +#endif + +// Program Object APIs +typedef cl_program(CL_API_CALL *cl_api_clCreateProgramWithSource)( + cl_context context, cl_uint count, const char **strings, + const size_t *lengths, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_program(CL_API_CALL *cl_api_clCreateProgramWithBinary)( + cl_context context, cl_uint num_devices, const cl_device_id *device_list, + const size_t *lengths, const unsigned char **binaries, + cl_int *binary_status, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef +cl_program(CL_API_CALL *cl_api_clCreateProgramWithBuiltInKernels)( + cl_context context, cl_uint num_devices, const cl_device_id *device_list, + const char *kernel_names, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clCreateProgramWithBuiltInKernels; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clRetainProgram)( + cl_program program) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseProgram)( + cl_program program) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clBuildProgram)( + cl_program program, cl_uint num_devices, const cl_device_id *device_list, + const char *options, + void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), + void *user_data) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clCompileProgram)( + cl_program program, cl_uint num_devices, const cl_device_id *device_list, + const char *options, cl_uint num_input_headers, + const cl_program *input_headers, const char **header_include_names, + void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), + void *user_data) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_program(CL_API_CALL *cl_api_clLinkProgram)( + cl_context context, cl_uint num_devices, const cl_device_id *device_list, + const char *options, cl_uint num_input_programs, + const cl_program *input_programs, + void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), + void *user_data, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clCompileProgram; +typedef void *cl_api_clLinkProgram; + +#endif + +#ifdef CL_VERSION_2_2 + +typedef +cl_int(CL_API_CALL *cl_api_clSetProgramSpecializationConstant)( + cl_program program, cl_uint spec_id, size_t spec_size, + const void *spec_value) CL_API_SUFFIX__VERSION_2_2; + +typedef cl_int(CL_API_CALL *cl_api_clSetProgramReleaseCallback)( + cl_program program, + void(CL_CALLBACK *pfn_notify)(cl_program program, void *user_data), + void *user_data) CL_API_SUFFIX__VERSION_2_2; + +#else + +typedef void *cl_api_clSetProgramSpecializationConstant; +typedef void *cl_api_clSetProgramReleaseCallback; + +#endif + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clUnloadPlatformCompiler)( + cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clUnloadPlatformCompiler; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clGetProgramInfo)( + cl_program program, cl_program_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetProgramBuildInfo)( + cl_program program, cl_device_id device, cl_program_build_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Kernel Object APIs +typedef cl_kernel(CL_API_CALL *cl_api_clCreateKernel)( + cl_program program, const char *kernel_name, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clCreateKernelsInProgram)( + cl_program program, cl_uint num_kernels, cl_kernel *kernels, + cl_uint *num_kernels_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clRetainKernel)( + cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseKernel)( + cl_kernel kernel) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clSetKernelArg)( + cl_kernel kernel, cl_uint arg_index, size_t arg_size, + const void *arg_value) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetKernelInfo)( + cl_kernel kernel, cl_kernel_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clGetKernelArgInfo)( + cl_kernel kernel, cl_uint arg_indx, cl_kernel_arg_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clGetKernelArgInfo; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clGetKernelWorkGroupInfo)( + cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_2_0 + +typedef cl_int(CL_API_CALL *cl_api_clSetKernelArgSVMPointer)( + cl_kernel /* kernel */, cl_uint /* arg_index */, + const void * /* arg_value */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clSetKernelExecInfo)( + cl_kernel /* kernel */, cl_kernel_exec_info /* param_name */, + size_t /* param_value_size */, + const void * /* param_value */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetKernelSubGroupInfoKHR)( + cl_kernel /* in_kernel */, cl_device_id /*in_device*/, + cl_kernel_sub_group_info /* param_name */, size_t /*input_value_size*/, + const void * /*input_value*/, size_t /*param_value_size*/, + void * /*param_value*/, + size_t * /*param_value_size_ret*/) CL_API_SUFFIX__VERSION_2_0; + +#else + +typedef void *cl_api_clSetKernelArgSVMPointer; +typedef void *cl_api_clSetKernelExecInfo; +typedef void *cl_api_clGetKernelSubGroupInfoKHR; + +#endif + +// Event Object APIs +typedef cl_int(CL_API_CALL *cl_api_clWaitForEvents)( + cl_uint num_events, const cl_event *event_list) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetEventInfo)( + cl_event event, cl_event_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clRetainEvent)(cl_event event) + CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseEvent)(cl_event event) + CL_API_SUFFIX__VERSION_1_0; + +// Profiling APIs +typedef cl_int(CL_API_CALL *cl_api_clGetEventProfilingInfo)( + cl_event event, cl_profiling_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +// Flush and Finish APIs +typedef cl_int(CL_API_CALL *cl_api_clFlush)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clFinish)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_0; + +// Enqueued Commands APIs +typedef cl_int(CL_API_CALL *cl_api_clEnqueueReadBuffer)( + cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, + size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_1 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueReadBufferRect)( + cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, + const size_t *buffer_origin, const size_t *host_origin, + const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, + size_t host_row_pitch, size_t host_slice_pitch, void *ptr, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_1; + +#else + +typedef void *cl_api_clEnqueueReadBufferRect; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueWriteBuffer)( + cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, + size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_1 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueWriteBufferRect)( + cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, + const size_t *buffer_origin, const size_t *host_origin, + const size_t *region, size_t buffer_row_pitch, size_t buffer_slice_pitch, + size_t host_row_pitch, size_t host_slice_pitch, const void *ptr, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_1; + +#else + +typedef void *cl_api_clEnqueueWriteBufferRect; + +#endif + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueFillBuffer)( + cl_command_queue command_queue, cl_mem buffer, const void *pattern, + size_t pattern_size, size_t offset, size_t cb, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clEnqueueFillBuffer; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyBuffer)( + cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, + size_t src_offset, size_t dst_offset, size_t cb, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_1 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyBufferRect)( + cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, + const size_t *src_origin, const size_t *dst_origin, const size_t *region, + size_t src_row_pitch, size_t src_slice_pitch, size_t dst_row_pitch, + size_t dst_slice_pitch, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_1; + +#else + +typedef void *cl_api_clEnqueueCopyBufferRect; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueReadImage)( + cl_command_queue command_queue, cl_mem image, cl_bool blocking_read, + const size_t *origin, const size_t *region, size_t row_pitch, + size_t slice_pitch, void *ptr, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueWriteImage)( + cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, + const size_t *origin, const size_t *region, size_t input_row_pitch, + size_t input_slice_pitch, const void *ptr, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueFillImage)( + cl_command_queue command_queue, cl_mem image, const void *fill_color, + const size_t origin[3], const size_t region[3], + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clEnqueueFillImage; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyImage)( + cl_command_queue command_queue, cl_mem src_image, cl_mem dst_image, + const size_t *src_origin, const size_t *dst_origin, const size_t *region, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyImageToBuffer)( + cl_command_queue command_queue, cl_mem src_image, cl_mem dst_buffer, + const size_t *src_origin, const size_t *region, size_t dst_offset, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueCopyBufferToImage)( + cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image, + size_t src_offset, const size_t *dst_origin, const size_t *region, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef void *(CL_API_CALL *cl_api_clEnqueueMapBuffer)( + cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, + cl_map_flags map_flags, size_t offset, size_t cb, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event, cl_int *errcode_ret)CL_API_SUFFIX__VERSION_1_0; + +typedef void *(CL_API_CALL *cl_api_clEnqueueMapImage)( + cl_command_queue command_queue, cl_mem image, cl_bool blocking_map, + cl_map_flags map_flags, const size_t *origin, const size_t *region, + size_t *image_row_pitch, size_t *image_slice_pitch, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event, cl_int *errcode_ret)CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueUnmapMemObject)( + cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueMigrateMemObjects)( + cl_command_queue command_queue, cl_uint num_mem_objects, + const cl_mem *mem_objects, cl_mem_migration_flags flags, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clEnqueueMigrateMemObjects; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueNDRangeKernel)( + cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, + const size_t *global_work_offset, const size_t *global_work_size, + const size_t *local_work_size, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueTask)( + cl_command_queue command_queue, cl_kernel kernel, + cl_uint num_events_in_wait_list, const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueNativeKernel)( + cl_command_queue command_queue, void(CL_CALLBACK *user_func)(void *), + void *args, size_t cb_args, cl_uint num_mem_objects, const cl_mem *mem_list, + const void **args_mem_loc, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +#ifdef CL_VERSION_1_2 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueMarkerWithWaitList)( + cl_command_queue command_queue, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueBarrierWithWaitList)( + cl_command_queue command_queue, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +typedef void *( + CL_API_CALL *cl_api_clGetExtensionFunctionAddressForPlatform)( + cl_platform_id platform, + const char *function_name)CL_API_SUFFIX__VERSION_1_2; + +#else + +typedef void *cl_api_clEnqueueMarkerWithWaitList; +typedef void *cl_api_clEnqueueBarrierWithWaitList; +typedef void *cl_api_clGetExtensionFunctionAddressForPlatform; + +#endif + +// Shared Virtual Memory APIs + +#ifdef CL_VERSION_2_0 + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMFree)( + cl_command_queue /* command_queue */, cl_uint /* num_svm_pointers */, + void ** /* svm_pointers */, + void(CL_CALLBACK *pfn_free_func)(cl_command_queue /* queue */, + cl_uint /* num_svm_pointers */, + void ** /* svm_pointers[] */, + void * /* user_data */), + void * /* user_data */, cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMemcpy)( + cl_command_queue /* command_queue */, cl_bool /* blocking_copy */, + void * /* dst_ptr */, const void * /* src_ptr */, size_t /* size */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMemFill)( + cl_command_queue /* command_queue */, void * /* svm_ptr */, + const void * /* pattern */, size_t /* pattern_size */, size_t /* size */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMap)( + cl_command_queue /* command_queue */, cl_bool /* blocking_map */, + cl_map_flags /* map_flags */, void * /* svm_ptr */, size_t /* size */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMUnmap)( + cl_command_queue /* command_queue */, void * /* svm_ptr */, + cl_uint /* num_events_in_wait_list */, + const cl_event * /* event_wait_list */, + cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; + +#else + +typedef void *cl_api_clEnqueueSVMFree; +typedef void *cl_api_clEnqueueSVMMemcpy; +typedef void *cl_api_clEnqueueSVMMemFill; +typedef void *cl_api_clEnqueueSVMMap; +typedef void *cl_api_clEnqueueSVMUnmap; + +#endif + +// Deprecated APIs +typedef cl_int(CL_API_CALL *cl_api_clSetCommandQueueProperty)( + cl_command_queue command_queue, cl_command_queue_properties properties, + cl_bool enable, cl_command_queue_properties *old_properties) + CL_API_SUFFIX__VERSION_1_0_DEPRECATED; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateImage2D)( + cl_context context, cl_mem_flags flags, const cl_image_format *image_format, + size_t image_width, size_t image_height, size_t image_row_pitch, + void *host_ptr, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateImage3D)( + cl_context context, cl_mem_flags flags, const cl_image_format *image_format, + size_t image_width, size_t image_height, size_t image_depth, + size_t image_row_pitch, size_t image_slice_pitch, void *host_ptr, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef cl_int(CL_API_CALL *cl_api_clUnloadCompiler)(void) + CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueMarker)( + cl_command_queue command_queue, + cl_event *event) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueWaitForEvents)( + cl_command_queue command_queue, cl_uint num_events, + const cl_event *event_list) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueBarrier)( + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +typedef void *(CL_API_CALL *cl_api_clGetExtensionFunctionAddress)( + const char *function_name)CL_API_SUFFIX__VERSION_1_1_DEPRECATED; + +// GL and other APIs +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLBuffer)( + cl_context context, cl_mem_flags flags, cl_GLuint bufobj, + int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLTexture)( + cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, + cl_GLuint texture, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLTexture2D)( + cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, + cl_GLuint texture, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLTexture3D)( + cl_context context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, + cl_GLuint texture, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromGLRenderbuffer)( + cl_context context, cl_mem_flags flags, cl_GLuint renderbuffer, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetGLObjectInfo)( + cl_mem memobj, cl_gl_object_type *gl_object_type, + cl_GLuint *gl_object_name) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clGetGLTextureInfo)( + cl_mem memobj, cl_gl_texture_info param_name, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueAcquireGLObjects)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueReleaseGLObjects)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +/* cl_khr_gl_sharing */ +typedef cl_int(CL_API_CALL *cl_api_clGetGLContextInfoKHR)( + const cl_context_properties *properties, cl_gl_context_info param_name, + size_t param_value_size, void *param_value, size_t *param_value_size_ret); + +/* cl_khr_gl_event */ +typedef cl_event(CL_API_CALL *cl_api_clCreateEventFromGLsyncKHR)( + cl_context context, cl_GLsync sync, cl_int *errcode_ret); + +#if defined(_WIN32) + +/* cl_khr_d3d10_sharing */ + +typedef cl_int(CL_API_CALL *cl_api_clGetDeviceIDsFromD3D10KHR)( + cl_platform_id platform, cl_d3d10_device_source_khr d3d_device_source, + void *d3d_object, cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, cl_device_id *devices, + cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D10BufferKHR)( + cl_context context, cl_mem_flags flags, ID3D10Buffer *resource, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D10Texture2DKHR)( + cl_context context, cl_mem_flags flags, ID3D10Texture2D *resource, + UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D10Texture3DKHR)( + cl_context context, cl_mem_flags flags, ID3D10Texture3D *resource, + UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0; + +typedef +cl_int(CL_API_CALL *cl_api_clEnqueueAcquireD3D10ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +typedef +cl_int(CL_API_CALL *cl_api_clEnqueueReleaseD3D10ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_0; + +extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromD3D10KHR( + cl_platform_id platform, cl_d3d10_device_source_khr d3d_device_source, + void *d3d_object, cl_d3d10_device_set_khr d3d_device_set, + cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D10BufferKHR(cl_context context, cl_mem_flags flags, + ID3D10Buffer *resource, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10Texture2DKHR( + cl_context context, cl_mem_flags flags, ID3D10Texture2D *resource, + UINT subresource, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D10Texture3DKHR( + cl_context context, cl_mem_flags flags, ID3D10Texture3D *resource, + UINT subresource, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireD3D10ObjectsKHR( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseD3D10ObjectsKHR( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +/* cl_khr_d3d11_sharing */ +typedef cl_int(CL_API_CALL *cl_api_clGetDeviceIDsFromD3D11KHR)( + cl_platform_id platform, cl_d3d11_device_source_khr d3d_device_source, + void *d3d_object, cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, cl_device_id *devices, + cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D11BufferKHR)( + cl_context context, cl_mem_flags flags, ID3D11Buffer *resource, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D11Texture2DKHR)( + cl_context context, cl_mem_flags flags, ID3D11Texture2D *resource, + UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromD3D11Texture3DKHR)( + cl_context context, cl_mem_flags flags, ID3D11Texture3D *resource, + UINT subresource, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef +cl_int(CL_API_CALL *cl_api_clEnqueueAcquireD3D11ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +typedef +cl_int(CL_API_CALL *cl_api_clEnqueueReleaseD3D11ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +/* cl_khr_dx9_media_sharing */ +typedef +cl_int(CL_API_CALL *cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR)( + cl_platform_id platform, cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr *media_adapters_type, void *media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, cl_uint num_entries, + cl_device_id *devices, cl_uint *num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromDX9MediaSurfaceKHR)( + cl_context context, cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, void *surface_info, + cl_uint plane, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef +cl_int(CL_API_CALL *cl_api_clEnqueueAcquireDX9MediaSurfacesKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +typedef +cl_int(CL_API_CALL *cl_api_clEnqueueReleaseDX9MediaSurfacesKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_1_2; + +/* cl_khr_d3d11_sharing */ +extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromD3D11KHR( + cl_platform_id platform, cl_d3d11_device_source_khr d3d_device_source, + void *d3d_object, cl_d3d11_device_set_khr d3d_device_set, + cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL +clCreateFromD3D11BufferKHR(cl_context context, cl_mem_flags flags, + ID3D11Buffer *resource, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11Texture2DKHR( + cl_context context, cl_mem_flags flags, ID3D11Texture2D *resource, + UINT subresource, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromD3D11Texture3DKHR( + cl_context context, cl_mem_flags flags, ID3D11Texture3D *resource, + UINT subresource, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireD3D11ObjectsKHR( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseD3D11ObjectsKHR( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +/* cl_khr_dx9_media_sharing */ +extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromDX9MediaAdapterKHR( + cl_platform_id platform, cl_uint num_media_adapters, + cl_dx9_media_adapter_type_khr *media_adapter_type, void *media_adapters, + cl_dx9_media_adapter_set_khr media_adapter_set, cl_uint num_entries, + cl_device_id *devices, cl_uint *num_devices); + +extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromDX9MediaSurfaceKHR( + cl_context context, cl_mem_flags flags, + cl_dx9_media_adapter_type_khr adapter_type, void *surface_info, + cl_uint plane, cl_int *errcode_ret); + +extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireDX9MediaSurfacesKHR( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseDX9MediaSurfacesKHR( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +#else + +/* cl_khr_d3d10_sharing */ +typedef void *cl_api_clGetDeviceIDsFromD3D10KHR; +typedef void *cl_api_clCreateFromD3D10BufferKHR; +typedef void *cl_api_clCreateFromD3D10Texture2DKHR; +typedef void *cl_api_clCreateFromD3D10Texture3DKHR; +typedef void *cl_api_clEnqueueAcquireD3D10ObjectsKHR; +typedef void *cl_api_clEnqueueReleaseD3D10ObjectsKHR; + +/* cl_khr_d3d11_sharing */ +typedef void *cl_api_clGetDeviceIDsFromD3D11KHR; +typedef void *cl_api_clCreateFromD3D11BufferKHR; +typedef void *cl_api_clCreateFromD3D11Texture2DKHR; +typedef void *cl_api_clCreateFromD3D11Texture3DKHR; +typedef void *cl_api_clEnqueueAcquireD3D11ObjectsKHR; +typedef void *cl_api_clEnqueueReleaseD3D11ObjectsKHR; + +/* cl_khr_dx9_media_sharing */ +typedef void *cl_api_clCreateFromDX9MediaSurfaceKHR; +typedef void *cl_api_clEnqueueAcquireDX9MediaSurfacesKHR; +typedef void *cl_api_clEnqueueReleaseDX9MediaSurfacesKHR; +typedef void *cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR; + +#endif + +/* OpenCL 1.1 */ + +#ifdef CL_VERSION_1_1 + +typedef cl_int(CL_API_CALL *cl_api_clSetEventCallback)( + cl_event /* event */, cl_int /* command_exec_callback_type */, + void(CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), + void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_mem(CL_API_CALL *cl_api_clCreateSubBuffer)( + cl_mem /* buffer */, cl_mem_flags /* flags */, + cl_buffer_create_type /* buffer_create_type */, + const void * /* buffer_create_info */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +typedef +cl_int(CL_API_CALL *cl_api_clSetMemObjectDestructorCallback)( + cl_mem /* memobj */, + void(CL_CALLBACK * /*pfn_notify*/)(cl_mem /* memobj */, + void * /*user_data*/), + void * /*user_data */) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_event(CL_API_CALL *cl_api_clCreateUserEvent)( + cl_context /* context */, + cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; + +typedef cl_int(CL_API_CALL *cl_api_clSetUserEventStatus)( + cl_event /* event */, + cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; + +#else + +typedef void *cl_api_clSetEventCallback; +typedef void *cl_api_clCreateSubBuffer; +typedef void *cl_api_clSetMemObjectDestructorCallback; +typedef void *cl_api_clCreateUserEvent; +typedef void *cl_api_clSetUserEventStatus; + +#endif + +typedef cl_int(CL_API_CALL *cl_api_clCreateSubDevicesEXT)( + cl_device_id in_device, + const cl_device_partition_property_ext *partition_properties, + cl_uint num_entries, cl_device_id *out_devices, cl_uint *num_devices); + +typedef cl_int(CL_API_CALL *cl_api_clRetainDeviceEXT)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_0; + +typedef cl_int(CL_API_CALL *cl_api_clReleaseDeviceEXT)( + cl_device_id device) CL_API_SUFFIX__VERSION_1_0; + +/* cl_khr_egl_image */ +typedef cl_mem(CL_API_CALL *cl_api_clCreateFromEGLImageKHR)( + cl_context context, CLeglDisplayKHR display, CLeglImageKHR image, + cl_mem_flags flags, const cl_egl_image_properties_khr *properties, + cl_int *errcode_ret); + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueAcquireEGLObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueReleaseEGLObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem *mem_objects, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, cl_event *event); + +/* cl_khr_egl_event */ +typedef cl_event(CL_API_CALL *cl_api_clCreateEventFromEGLSyncKHR)( + cl_context context, CLeglSyncKHR sync, CLeglDisplayKHR display, + cl_int *errcode_ret); + +#ifdef CL_VERSION_2_1 + +typedef cl_int(CL_API_CALL *cl_api_clSetDefaultDeviceCommandQueue)( + cl_context context, cl_device_id device, + cl_command_queue command_queue) CL_API_SUFFIX__VERSION_2_1; + +typedef cl_program(CL_API_CALL *cl_api_clCreateProgramWithIL)( + cl_context context, const void *il, size_t length, + cl_int *errcode_ret) CL_API_SUFFIX__VERSION_2_1; + +typedef cl_int(CL_API_CALL *cl_api_clGetKernelSubGroupInfo)( + cl_kernel kernel, cl_device_id device, cl_kernel_sub_group_info param_name, + size_t input_value_size, const void *input_value, size_t param_value_size, + void *param_value, size_t *param_value_size_ret) CL_API_SUFFIX__VERSION_2_1; + +typedef cl_kernel(CL_API_CALL *cl_api_clCloneKernel)( + cl_kernel source_kernel, cl_int *errcode_ret) CL_API_SUFFIX__VERSION_2_1; + +typedef cl_int(CL_API_CALL *cl_api_clEnqueueSVMMigrateMem)( + cl_command_queue command_queue, cl_uint num_svm_pointers, + const void **svm_pointers, const size_t *sizes, + cl_mem_migration_flags flags, cl_uint num_events_in_wait_list, + const cl_event *event_wait_list, + cl_event *event) CL_API_SUFFIX__VERSION_2_1; + +typedef cl_int(CL_API_CALL *cl_api_clGetDeviceAndHostTimer)( + cl_device_id device, cl_ulong *device_timestamp, + cl_ulong *host_timestamp) CL_API_SUFFIX__VERSION_2_1; + +typedef cl_int(CL_API_CALL *cl_api_clGetHostTimer)( + cl_device_id device, cl_ulong *host_timestamp) CL_API_SUFFIX__VERSION_2_1; + +#else + +typedef void *cl_api_clSetDefaultDeviceCommandQueue; +typedef void *cl_api_clCreateProgramWithIL; +typedef void *cl_api_clGetKernelSubGroupInfo; +typedef void *cl_api_clCloneKernel; +typedef void *cl_api_clEnqueueSVMMigrateMem; +typedef void *cl_api_clGetDeviceAndHostTimer; +typedef void *cl_api_clGetHostTimer; + +#endif + +/* Vendor dispatch table structure */ + +typedef struct _cl_icd_dispatch { + /* OpenCL 1.0 */ + cl_api_clGetPlatformIDs clGetPlatformIDs; + cl_api_clGetPlatformInfo clGetPlatformInfo; + cl_api_clGetDeviceIDs clGetDeviceIDs; + cl_api_clGetDeviceInfo clGetDeviceInfo; + cl_api_clCreateContext clCreateContext; + cl_api_clCreateContextFromType clCreateContextFromType; + cl_api_clRetainContext clRetainContext; + cl_api_clReleaseContext clReleaseContext; + cl_api_clGetContextInfo clGetContextInfo; + cl_api_clCreateCommandQueue clCreateCommandQueue; + cl_api_clRetainCommandQueue clRetainCommandQueue; + cl_api_clReleaseCommandQueue clReleaseCommandQueue; + cl_api_clGetCommandQueueInfo clGetCommandQueueInfo; + cl_api_clSetCommandQueueProperty clSetCommandQueueProperty; + cl_api_clCreateBuffer clCreateBuffer; + cl_api_clCreateImage2D clCreateImage2D; + cl_api_clCreateImage3D clCreateImage3D; + cl_api_clRetainMemObject clRetainMemObject; + cl_api_clReleaseMemObject clReleaseMemObject; + cl_api_clGetSupportedImageFormats clGetSupportedImageFormats; + cl_api_clGetMemObjectInfo clGetMemObjectInfo; + cl_api_clGetImageInfo clGetImageInfo; + cl_api_clCreateSampler clCreateSampler; + cl_api_clRetainSampler clRetainSampler; + cl_api_clReleaseSampler clReleaseSampler; + cl_api_clGetSamplerInfo clGetSamplerInfo; + cl_api_clCreateProgramWithSource clCreateProgramWithSource; + cl_api_clCreateProgramWithBinary clCreateProgramWithBinary; + cl_api_clRetainProgram clRetainProgram; + cl_api_clReleaseProgram clReleaseProgram; + cl_api_clBuildProgram clBuildProgram; + cl_api_clUnloadCompiler clUnloadCompiler; + cl_api_clGetProgramInfo clGetProgramInfo; + cl_api_clGetProgramBuildInfo clGetProgramBuildInfo; + cl_api_clCreateKernel clCreateKernel; + cl_api_clCreateKernelsInProgram clCreateKernelsInProgram; + cl_api_clRetainKernel clRetainKernel; + cl_api_clReleaseKernel clReleaseKernel; + cl_api_clSetKernelArg clSetKernelArg; + cl_api_clGetKernelInfo clGetKernelInfo; + cl_api_clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo; + cl_api_clWaitForEvents clWaitForEvents; + cl_api_clGetEventInfo clGetEventInfo; + cl_api_clRetainEvent clRetainEvent; + cl_api_clReleaseEvent clReleaseEvent; + cl_api_clGetEventProfilingInfo clGetEventProfilingInfo; + cl_api_clFlush clFlush; + cl_api_clFinish clFinish; + cl_api_clEnqueueReadBuffer clEnqueueReadBuffer; + cl_api_clEnqueueWriteBuffer clEnqueueWriteBuffer; + cl_api_clEnqueueCopyBuffer clEnqueueCopyBuffer; + cl_api_clEnqueueReadImage clEnqueueReadImage; + cl_api_clEnqueueWriteImage clEnqueueWriteImage; + cl_api_clEnqueueCopyImage clEnqueueCopyImage; + cl_api_clEnqueueCopyImageToBuffer clEnqueueCopyImageToBuffer; + cl_api_clEnqueueCopyBufferToImage clEnqueueCopyBufferToImage; + cl_api_clEnqueueMapBuffer clEnqueueMapBuffer; + cl_api_clEnqueueMapImage clEnqueueMapImage; + cl_api_clEnqueueUnmapMemObject clEnqueueUnmapMemObject; + cl_api_clEnqueueNDRangeKernel clEnqueueNDRangeKernel; + cl_api_clEnqueueTask clEnqueueTask; + cl_api_clEnqueueNativeKernel clEnqueueNativeKernel; + cl_api_clEnqueueMarker clEnqueueMarker; + cl_api_clEnqueueWaitForEvents clEnqueueWaitForEvents; + cl_api_clEnqueueBarrier clEnqueueBarrier; + cl_api_clGetExtensionFunctionAddress clGetExtensionFunctionAddress; + cl_api_clCreateFromGLBuffer clCreateFromGLBuffer; + cl_api_clCreateFromGLTexture2D clCreateFromGLTexture2D; + cl_api_clCreateFromGLTexture3D clCreateFromGLTexture3D; + cl_api_clCreateFromGLRenderbuffer clCreateFromGLRenderbuffer; + cl_api_clGetGLObjectInfo clGetGLObjectInfo; + cl_api_clGetGLTextureInfo clGetGLTextureInfo; + cl_api_clEnqueueAcquireGLObjects clEnqueueAcquireGLObjects; + cl_api_clEnqueueReleaseGLObjects clEnqueueReleaseGLObjects; + cl_api_clGetGLContextInfoKHR clGetGLContextInfoKHR; + + /* cl_khr_d3d10_sharing */ + cl_api_clGetDeviceIDsFromD3D10KHR clGetDeviceIDsFromD3D10KHR; + cl_api_clCreateFromD3D10BufferKHR clCreateFromD3D10BufferKHR; + cl_api_clCreateFromD3D10Texture2DKHR clCreateFromD3D10Texture2DKHR; + cl_api_clCreateFromD3D10Texture3DKHR clCreateFromD3D10Texture3DKHR; + cl_api_clEnqueueAcquireD3D10ObjectsKHR clEnqueueAcquireD3D10ObjectsKHR; + cl_api_clEnqueueReleaseD3D10ObjectsKHR clEnqueueReleaseD3D10ObjectsKHR; + + /* OpenCL 1.1 */ + cl_api_clSetEventCallback clSetEventCallback; + cl_api_clCreateSubBuffer clCreateSubBuffer; + cl_api_clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback; + cl_api_clCreateUserEvent clCreateUserEvent; + cl_api_clSetUserEventStatus clSetUserEventStatus; + cl_api_clEnqueueReadBufferRect clEnqueueReadBufferRect; + cl_api_clEnqueueWriteBufferRect clEnqueueWriteBufferRect; + cl_api_clEnqueueCopyBufferRect clEnqueueCopyBufferRect; + + /* cl_ext_device_fission */ + cl_api_clCreateSubDevicesEXT clCreateSubDevicesEXT; + cl_api_clRetainDeviceEXT clRetainDeviceEXT; + cl_api_clReleaseDeviceEXT clReleaseDeviceEXT; + + /* cl_khr_gl_event */ + cl_api_clCreateEventFromGLsyncKHR clCreateEventFromGLsyncKHR; + + /* OpenCL 1.2 */ + cl_api_clCreateSubDevices clCreateSubDevices; + cl_api_clRetainDevice clRetainDevice; + cl_api_clReleaseDevice clReleaseDevice; + cl_api_clCreateImage clCreateImage; + cl_api_clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels; + cl_api_clCompileProgram clCompileProgram; + cl_api_clLinkProgram clLinkProgram; + cl_api_clUnloadPlatformCompiler clUnloadPlatformCompiler; + cl_api_clGetKernelArgInfo clGetKernelArgInfo; + cl_api_clEnqueueFillBuffer clEnqueueFillBuffer; + cl_api_clEnqueueFillImage clEnqueueFillImage; + cl_api_clEnqueueMigrateMemObjects clEnqueueMigrateMemObjects; + cl_api_clEnqueueMarkerWithWaitList clEnqueueMarkerWithWaitList; + cl_api_clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList; + cl_api_clGetExtensionFunctionAddressForPlatform + clGetExtensionFunctionAddressForPlatform; + cl_api_clCreateFromGLTexture clCreateFromGLTexture; + + /* cl_khr_d3d11_sharing */ + cl_api_clGetDeviceIDsFromD3D11KHR clGetDeviceIDsFromD3D11KHR; + cl_api_clCreateFromD3D11BufferKHR clCreateFromD3D11BufferKHR; + cl_api_clCreateFromD3D11Texture2DKHR clCreateFromD3D11Texture2DKHR; + cl_api_clCreateFromD3D11Texture3DKHR clCreateFromD3D11Texture3DKHR; + cl_api_clCreateFromDX9MediaSurfaceKHR clCreateFromDX9MediaSurfaceKHR; + cl_api_clEnqueueAcquireD3D11ObjectsKHR clEnqueueAcquireD3D11ObjectsKHR; + cl_api_clEnqueueReleaseD3D11ObjectsKHR clEnqueueReleaseD3D11ObjectsKHR; + + /* cl_khr_dx9_media_sharing */ + cl_api_clGetDeviceIDsFromDX9MediaAdapterKHR + clGetDeviceIDsFromDX9MediaAdapterKHR; + cl_api_clEnqueueAcquireDX9MediaSurfacesKHR + clEnqueueAcquireDX9MediaSurfacesKHR; + cl_api_clEnqueueReleaseDX9MediaSurfacesKHR + clEnqueueReleaseDX9MediaSurfacesKHR; + + /* cl_khr_egl_image */ + cl_api_clCreateFromEGLImageKHR clCreateFromEGLImageKHR; + cl_api_clEnqueueAcquireEGLObjectsKHR clEnqueueAcquireEGLObjectsKHR; + cl_api_clEnqueueReleaseEGLObjectsKHR clEnqueueReleaseEGLObjectsKHR; + + /* cl_khr_egl_event */ + cl_api_clCreateEventFromEGLSyncKHR clCreateEventFromEGLSyncKHR; + + /* OpenCL 2.0 */ + cl_api_clCreateCommandQueueWithProperties clCreateCommandQueueWithProperties; + cl_api_clCreatePipe clCreatePipe; + cl_api_clGetPipeInfo clGetPipeInfo; + cl_api_clSVMAlloc clSVMAlloc; + cl_api_clSVMFree clSVMFree; + cl_api_clEnqueueSVMFree clEnqueueSVMFree; + cl_api_clEnqueueSVMMemcpy clEnqueueSVMMemcpy; + cl_api_clEnqueueSVMMemFill clEnqueueSVMMemFill; + cl_api_clEnqueueSVMMap clEnqueueSVMMap; + cl_api_clEnqueueSVMUnmap clEnqueueSVMUnmap; + cl_api_clCreateSamplerWithProperties clCreateSamplerWithProperties; + cl_api_clSetKernelArgSVMPointer clSetKernelArgSVMPointer; + cl_api_clSetKernelExecInfo clSetKernelExecInfo; + + /* cl_khr_sub_groups */ + cl_api_clGetKernelSubGroupInfoKHR clGetKernelSubGroupInfoKHR; + + /* OpenCL 2.1 */ + cl_api_clCloneKernel clCloneKernel; + cl_api_clCreateProgramWithIL clCreateProgramWithIL; + cl_api_clEnqueueSVMMigrateMem clEnqueueSVMMigrateMem; + cl_api_clGetDeviceAndHostTimer clGetDeviceAndHostTimer; + cl_api_clGetHostTimer clGetHostTimer; + cl_api_clGetKernelSubGroupInfo clGetKernelSubGroupInfo; + cl_api_clSetDefaultDeviceCommandQueue clSetDefaultDeviceCommandQueue; + + /* OpenCL 2.2 */ + cl_api_clSetProgramReleaseCallback clSetProgramReleaseCallback; + cl_api_clSetProgramSpecializationConstant clSetProgramSpecializationConstant; + + /* OpenCL 3.0 */ + cl_api_clCreateBufferWithProperties clCreateBufferWithProperties; + cl_api_clCreateImageWithProperties clCreateImageWithProperties; + cl_api_clSetContextDestructorCallback clSetContextDestructorCallback; + +} cl_icd_dispatch; + +#ifdef __cplusplus +} +#endif + +#endif /* #ifndef OPENCL_CL_ICD_H */ diff --git a/deps/OpenCL-Headers/CL/cl_layer.h b/deps/OpenCL-Headers/CL/cl_layer.h new file mode 100644 index 000000000..acaa6c2a5 --- /dev/null +++ b/deps/OpenCL-Headers/CL/cl_layer.h @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2008-2023 The Khronos Group Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ + +#ifndef OPENCL_CL_LAYER_H_ +#define OPENCL_CL_LAYER_H_ + +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ + +#include + +#include + +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif + +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*************************************************************** +* cl_loader_layers +***************************************************************/ +#define cl_loader_layers 1 +#define CL_LOADER_LAYERS_EXTENSION_NAME \ + "cl_loader_layers" + +typedef cl_uint cl_layer_info; +typedef cl_uint cl_layer_api_version; + +/* cl_layer_info */ +#define CL_LAYER_API_VERSION 0x4240 +#define CL_LAYER_NAME 0x4241 + +/* Misc API enums */ +#define CL_LAYER_API_VERSION_100 100 + + +typedef cl_int (CL_API_CALL * +clGetLayerInfo_fn)( + cl_layer_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +typedef cl_int (CL_API_CALL * +clInitLayer_fn)( + cl_uint num_entries, + const cl_icd_dispatch* target_dispatch, + cl_uint* num_entries_ret, + const cl_icd_dispatch** layer_dispatch_ret) ; + +/* +** The function pointer typedefs prefixed with "pfn_" are provided for +** compatibility with earlier versions of the headers. New code is +** encouraged to use the function pointer typedefs that are suffixed with +** "_fn" instead, for consistency. +*/ + +typedef cl_int (CL_API_CALL * +pfn_clGetLayerInfo)( + cl_layer_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +typedef cl_int (CL_API_CALL * +pfn_clInitLayer)( + cl_uint num_entries, + const cl_icd_dispatch* target_dispatch, + cl_uint* num_entries_ret, + const cl_icd_dispatch** layer_dispatch_ret) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetLayerInfo( + cl_layer_info param_name, + size_t param_value_size, + void* param_value, + size_t* param_value_size_ret) ; + +extern CL_API_ENTRY cl_int CL_API_CALL +clInitLayer( + cl_uint num_entries, + const cl_icd_dispatch* target_dispatch, + cl_uint* num_entries_ret, + const cl_icd_dispatch** layer_dispatch_ret) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +#ifdef __cplusplus +} +#endif + +#endif /* OPENCL_CL_LAYER_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_platform.h b/deps/OpenCL-Headers/CL/cl_platform.h index 7f4ddea5b..e7a0d6f47 100644 --- a/deps/OpenCL-Headers/CL/cl_platform.h +++ b/deps/OpenCL-Headers/CL/cl_platform.h @@ -1,30 +1,18 @@ -/********************************************************************************** - * Copyright (c) 2008-2018 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2020 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ #ifndef __CL_PLATFORM_H #define __CL_PLATFORM_H @@ -36,13 +24,25 @@ extern "C" { #endif #if defined(_WIN32) - #define CL_API_ENTRY - #define CL_API_CALL __stdcall - #define CL_CALLBACK __stdcall + #if !defined(CL_API_ENTRY) + #define CL_API_ENTRY + #endif + #if !defined(CL_API_CALL) + #define CL_API_CALL __stdcall + #endif + #if !defined(CL_CALLBACK) + #define CL_CALLBACK __stdcall + #endif #else - #define CL_API_ENTRY - #define CL_API_CALL - #define CL_CALLBACK + #if !defined(CL_API_ENTRY) + #define CL_API_ENTRY + #endif + #if !defined(CL_API_CALL) + #define CL_API_CALL + #endif + #if !defined(CL_CALLBACK) + #define CL_CALLBACK + #endif #endif /* @@ -53,74 +53,99 @@ extern "C" { * deprecation but is deprecated in versions later than 1.1. */ -#define CL_EXTENSION_WEAK_LINK -#define CL_API_SUFFIX__VERSION_1_0 -#define CL_EXT_SUFFIX__VERSION_1_0 -#define CL_API_SUFFIX__VERSION_1_1 -#define CL_EXT_SUFFIX__VERSION_1_1 -#define CL_API_SUFFIX__VERSION_1_2 -#define CL_EXT_SUFFIX__VERSION_1_2 -#define CL_API_SUFFIX__VERSION_2_0 -#define CL_EXT_SUFFIX__VERSION_2_0 -#define CL_API_SUFFIX__VERSION_2_1 -#define CL_EXT_SUFFIX__VERSION_2_1 -#define CL_API_SUFFIX__VERSION_2_2 -#define CL_EXT_SUFFIX__VERSION_2_2 +#ifndef CL_API_SUFFIX_USER +#define CL_API_SUFFIX_USER +#endif + +#ifndef CL_API_PREFIX_USER +#define CL_API_PREFIX_USER +#endif + +#define CL_API_SUFFIX_COMMON CL_API_SUFFIX_USER +#define CL_API_PREFIX_COMMON CL_API_PREFIX_USER + +#define CL_API_SUFFIX__VERSION_1_0 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__VERSION_1_1 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__VERSION_1_2 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__VERSION_2_0 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__VERSION_2_1 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__VERSION_2_2 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__VERSION_3_0 CL_API_SUFFIX_COMMON +#define CL_API_SUFFIX__EXPERIMENTAL CL_API_SUFFIX_COMMON #ifdef __GNUC__ - #define CL_EXT_SUFFIX_DEPRECATED __attribute__((deprecated)) - #define CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX_DEPRECATED __attribute__((deprecated)) + #define CL_API_PREFIX_DEPRECATED #elif defined(_WIN32) - #define CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX_DEPRECATED __declspec(deprecated) + #define CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX_DEPRECATED __declspec(deprecated) #else - #define CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS - #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED - #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED + #define CL_API_SUFFIX__VERSION_1_0_DEPRECATED CL_API_SUFFIX_COMMON + #define CL_API_PREFIX__VERSION_1_0_DEPRECATED CL_API_PREFIX_COMMON #else - #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX__VERSION_1_0_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX__VERSION_1_0_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS - #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED - #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED + #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED CL_API_SUFFIX_COMMON + #define CL_API_PREFIX__VERSION_1_1_DEPRECATED CL_API_PREFIX_COMMON #else - #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX__VERSION_1_1_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX__VERSION_1_1_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS - #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED - #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED + #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED CL_API_SUFFIX_COMMON + #define CL_API_PREFIX__VERSION_1_2_DEPRECATED CL_API_PREFIX_COMMON #else - #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX__VERSION_1_2_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX__VERSION_1_2_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS - #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED - #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED + #define CL_API_SUFFIX__VERSION_2_0_DEPRECATED CL_API_SUFFIX_COMMON + #define CL_API_PREFIX__VERSION_2_0_DEPRECATED CL_API_PREFIX_COMMON #else - #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX__VERSION_2_0_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX__VERSION_2_0_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS - #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED - #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED + #define CL_API_SUFFIX__VERSION_2_1_DEPRECATED CL_API_SUFFIX_COMMON + #define CL_API_PREFIX__VERSION_2_1_DEPRECATED CL_API_PREFIX_COMMON +#else + #define CL_API_SUFFIX__VERSION_2_1_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX__VERSION_2_1_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED +#endif + +#ifdef CL_USE_DEPRECATED_OPENCL_2_2_APIS + #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED CL_API_SUFFIX_COMMON + #define CL_API_PREFIX__VERSION_2_2_DEPRECATED CL_API_PREFIX_COMMON #else - #define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED CL_EXT_SUFFIX_DEPRECATED - #define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED CL_EXT_PREFIX_DEPRECATED + #define CL_API_SUFFIX__VERSION_2_2_DEPRECATED CL_API_SUFFIX_COMMON CL_API_SUFFIX_DEPRECATED + #define CL_API_PREFIX__VERSION_2_2_DEPRECATED CL_API_PREFIX_COMMON CL_API_PREFIX_DEPRECATED #endif #if (defined (_WIN32) && defined(_MSC_VER)) +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wlanguage-extension-token" +#endif + +/* intptr_t is used in cl.h and provided by stddef.h in Visual C++, but not in clang */ +/* stdint.h was missing before Visual Studio 2010, include it for later versions and for clang */ +#if defined(__clang__) || _MSC_VER >= 1600 + #include +#endif + /* scalar types */ typedef signed __int8 cl_char; typedef unsigned __int8 cl_uchar; @@ -135,6 +160,10 @@ typedef unsigned __int16 cl_half; typedef float cl_float; typedef double cl_double; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + /* Macro names and corresponding values defined by OpenCL */ #define CL_CHAR_BIT 8 #define CL_SCHAR_MAX 127 @@ -355,7 +384,9 @@ typedef unsigned int cl_GLenum; /* Define basic vector types */ #if defined( __VEC__ ) - #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ + #if !defined(__clang__) + #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ + #endif typedef __vector unsigned char __cl_uchar16; typedef __vector signed char __cl_char16; typedef __vector unsigned short __cl_ushort8; @@ -479,27 +510,28 @@ typedef unsigned int cl_GLenum; #if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define __CL_HAS_ANON_STRUCT__ 1 #define __CL_ANON_STRUCT__ -#elif defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) +#elif defined(_WIN32) && defined(_MSC_VER) && !defined(__STDC__) +#define __CL_HAS_ANON_STRUCT__ 1 +#define __CL_ANON_STRUCT__ +#elif defined(__GNUC__) && ! defined(__STRICT_ANSI__) +#define __CL_HAS_ANON_STRUCT__ 1 +#define __CL_ANON_STRUCT__ __extension__ +#elif defined(__clang__) #define __CL_HAS_ANON_STRUCT__ 1 #define __CL_ANON_STRUCT__ __extension__ -#elif defined( _WIN32) && defined(_MSC_VER) - #if _MSC_VER >= 1500 - /* Microsoft Developer Studio 2008 supports anonymous structs, but - * complains by default. */ - #define __CL_HAS_ANON_STRUCT__ 1 - #define __CL_ANON_STRUCT__ - /* Disable warning C4201: nonstandard extension used : nameless - * struct/union */ - #pragma warning( push ) - #pragma warning( disable : 4201 ) - #endif #else #define __CL_HAS_ANON_STRUCT__ 0 #define __CL_ANON_STRUCT__ #endif +#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ + /* Disable warning C4201: nonstandard extension used : nameless struct/union */ + #pragma warning( push ) + #pragma warning( disable : 4201 ) +#endif + /* Define alignment keys */ -#if defined( __GNUC__ ) +#if defined( __GNUC__ ) || defined(__INTEGRITY) #define CL_ALIGNED(_x) __attribute__ ((aligned(_x))) #elif defined( _WIN32) && (_MSC_VER) /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */ @@ -1373,12 +1405,8 @@ typedef union } #endif -#undef __CL_HAS_ANON_STRUCT__ -#undef __CL_ANON_STRUCT__ -#if defined( _WIN32) && defined(_MSC_VER) - #if _MSC_VER >=1500 +#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ #pragma warning( pop ) - #endif #endif #endif /* __CL_PLATFORM_H */ diff --git a/deps/OpenCL-Headers/CL/cl_va_api_media_sharing_intel.h b/deps/OpenCL-Headers/CL/cl_va_api_media_sharing_intel.h index 934f3f52a..767da05fc 100644 --- a/deps/OpenCL-Headers/CL/cl_va_api_media_sharing_intel.h +++ b/deps/OpenCL-Headers/CL/cl_va_api_media_sharing_intel.h @@ -1,73 +1,95 @@ -/********************************************************************************** - * Copyright (c) 2008-2019 The Khronos Group Inc. +/******************************************************************************* + * Copyright (c) 2008-2023 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - **********************************************************************************/ -/*****************************************************************************\ - -Copyright (c) 2013-2019 Intel Corporation All Rights Reserved. - -THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE -MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ******************************************************************************/ -File Name: cl_va_api_media_sharing_intel.h +#ifndef OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H_ +#define OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H_ -Abstract: +/* +** This header is generated from the Khronos OpenCL XML API Registry. +*/ -Notes: - -\*****************************************************************************/ +#include +#include -#ifndef __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H -#define __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H +/* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) +#define CL_NO_EXTENSION_PROTOTYPES +#endif -#include -#include -#include +/* CL_NO_EXTENSION_PROTOTYPES implies + CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and + CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif +#if defined(CL_NO_EXTENSION_PROTOTYPES) && \ + !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) +#define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES +#endif #ifdef __cplusplus extern "C" { #endif -/****************************************** -* cl_intel_va_api_media_sharing extension * -*******************************************/ +/*************************************************************** +* cl_intel_sharing_format_query_va_api +***************************************************************/ +#define cl_intel_sharing_format_query_va_api 1 +#define CL_INTEL_SHARING_FORMAT_QUERY_VA_API_EXTENSION_NAME \ + "cl_intel_sharing_format_query_va_api" +/* when cl_intel_va_api_media_sharing is supported */ + +typedef cl_int (CL_API_CALL * +clGetSupportedVA_APIMediaSurfaceFormatsINTEL_fn)( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint plane, + cl_uint num_entries, + VAImageFormat* va_api_formats, + cl_uint* num_surface_formats) ; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) + +extern CL_API_ENTRY cl_int CL_API_CALL +clGetSupportedVA_APIMediaSurfaceFormatsINTEL( + cl_context context, + cl_mem_flags flags, + cl_mem_object_type image_type, + cl_uint plane, + cl_uint num_entries, + VAImageFormat* va_api_formats, + cl_uint* num_surface_formats) ; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ + +/*************************************************************** +* cl_intel_va_api_media_sharing +***************************************************************/ #define cl_intel_va_api_media_sharing 1 +#define CL_INTEL_VA_API_MEDIA_SHARING_EXTENSION_NAME \ + "cl_intel_va_api_media_sharing" + +typedef cl_uint cl_va_api_device_source_intel; +typedef cl_uint cl_va_api_device_set_intel; -/* error codes */ +/* Error codes */ #define CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL -1098 #define CL_INVALID_VA_API_MEDIA_SURFACE_INTEL -1099 #define CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL -1100 @@ -93,80 +115,85 @@ extern "C" { #define CL_COMMAND_ACQUIRE_VA_API_MEDIA_SURFACES_INTEL 0x409A #define CL_COMMAND_RELEASE_VA_API_MEDIA_SURFACES_INTEL 0x409B -typedef cl_uint cl_va_api_device_source_intel; -typedef cl_uint cl_va_api_device_set_intel; + +typedef cl_int (CL_API_CALL * +clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)( + cl_platform_id platform, + cl_va_api_device_source_intel media_adapter_type, + void* media_adapter, + cl_va_api_device_set_intel media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_mem (CL_API_CALL * +clCreateFromVA_APIMediaSurfaceINTEL_fn)( + cl_context context, + cl_mem_flags flags, + VASurfaceID* surface, + cl_uint plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +typedef cl_int (CL_API_CALL * +clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)( + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDsFromVA_APIMediaAdapterINTEL( - cl_platform_id platform, - cl_va_api_device_source_intel media_adapter_type, - void* media_adapter, - cl_va_api_device_set_intel media_adapter_set, - cl_uint num_entries, - cl_device_id* devices, - cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL * clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn)( - cl_platform_id platform, + cl_platform_id platform, cl_va_api_device_source_intel media_adapter_type, - void* media_adapter, - cl_va_api_device_set_intel media_adapter_set, - cl_uint num_entries, - cl_device_id* devices, - cl_uint* num_devices) CL_EXT_SUFFIX__VERSION_1_2; + void* media_adapter, + cl_va_api_device_set_intel media_adapter_set, + cl_uint num_entries, + cl_device_id* devices, + cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromVA_APIMediaSurfaceINTEL( - cl_context context, - cl_mem_flags flags, - VASurfaceID* surface, - cl_uint plane, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_mem (CL_API_CALL * clCreateFromVA_APIMediaSurfaceINTEL_fn)( - cl_context context, - cl_mem_flags flags, - VASurfaceID* surface, - cl_uint plane, - cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2; + cl_context context, + cl_mem_flags flags, + VASurfaceID* surface, + cl_uint plane, + cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireVA_APIMediaSurfacesINTEL( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseVA_APIMediaSurfacesINTEL( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; - -typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn)( - cl_command_queue command_queue, - cl_uint num_objects, - const cl_mem* mem_objects, - cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, - cl_event* event) CL_EXT_SUFFIX__VERSION_1_2; + cl_command_queue command_queue, + cl_uint num_objects, + const cl_mem* mem_objects, + cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, + cl_event* event) CL_API_SUFFIX__VERSION_1_2; + +#endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ #ifdef __cplusplus } #endif -#endif /* __OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H */ - +#endif /* OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H_ */ diff --git a/deps/OpenCL-Headers/CL/cl_version.h b/deps/OpenCL-Headers/CL/cl_version.h index bb766cb9b..3844938d5 100644 --- a/deps/OpenCL-Headers/CL/cl_version.h +++ b/deps/OpenCL-Headers/CL/cl_version.h @@ -1,29 +1,17 @@ /******************************************************************************* - * Copyright (c) 2018 The Khronos Group Inc. + * Copyright (c) 2018-2020 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. ******************************************************************************/ #ifndef __CL_VERSION_H @@ -31,22 +19,26 @@ /* Detect which version to target */ #if !defined(CL_TARGET_OPENCL_VERSION) -#pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)") -#define CL_TARGET_OPENCL_VERSION 220 +#pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)") +#define CL_TARGET_OPENCL_VERSION 300 #endif #if CL_TARGET_OPENCL_VERSION != 100 && \ CL_TARGET_OPENCL_VERSION != 110 && \ CL_TARGET_OPENCL_VERSION != 120 && \ CL_TARGET_OPENCL_VERSION != 200 && \ CL_TARGET_OPENCL_VERSION != 210 && \ - CL_TARGET_OPENCL_VERSION != 220 -#pragma message("cl_version: CL_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220). Defaulting to 220 (OpenCL 2.2)") + CL_TARGET_OPENCL_VERSION != 220 && \ + CL_TARGET_OPENCL_VERSION != 300 +#pragma message("cl_version: CL_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300). Defaulting to 300 (OpenCL 3.0)") #undef CL_TARGET_OPENCL_VERSION -#define CL_TARGET_OPENCL_VERSION 220 +#define CL_TARGET_OPENCL_VERSION 300 #endif /* OpenCL Version */ +#if CL_TARGET_OPENCL_VERSION >= 300 && !defined(CL_VERSION_3_0) +#define CL_VERSION_3_0 1 +#endif #if CL_TARGET_OPENCL_VERSION >= 220 && !defined(CL_VERSION_2_2) #define CL_VERSION_2_2 1 #endif @@ -67,6 +59,9 @@ #endif /* Allow deprecated APIs for older OpenCL versions. */ +#if CL_TARGET_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS) +#define CL_USE_DEPRECATED_OPENCL_2_2_APIS +#endif #if CL_TARGET_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) #define CL_USE_DEPRECATED_OPENCL_2_1_APIS #endif diff --git a/deps/OpenCL-Headers/CL/opencl.h b/deps/OpenCL-Headers/CL/opencl.h index 143d1d2dc..ef8dd1e03 100644 --- a/deps/OpenCL-Headers/CL/opencl.h +++ b/deps/OpenCL-Headers/CL/opencl.h @@ -1,33 +1,19 @@ /******************************************************************************* - * Copyright (c) 2008-2015 The Khronos Group Inc. + * Copyright (c) 2008-2021 The Khronos Group Inc. * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and/or associated documentation files (the - * "Materials"), to deal in the Materials without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Materials, and to - * permit persons to whom the Materials are furnished to do so, subject to - * the following conditions: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Materials. + * http://www.apache.org/licenses/LICENSE-2.0 * - * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS - * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS - * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - * https://www.khronos.org/registry/ - * - * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. ******************************************************************************/ -/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ - #ifndef __OPENCL_H #define __OPENCL_H @@ -37,7 +23,6 @@ extern "C" { #include #include -#include #include #ifdef __cplusplus diff --git a/deps/OpenCL-Headers/LICENSE b/deps/OpenCL-Headers/LICENSE index 020ce65fc..d64569567 100644 --- a/deps/OpenCL-Headers/LICENSE +++ b/deps/OpenCL-Headers/LICENSE @@ -1,25 +1,202 @@ -Copyright (c) 2008-2015 The Khronos Group Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and/or associated documentation files (the -"Materials"), to deal in the Materials without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Materials, and to -permit persons to whom the Materials are furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Materials. - -MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS -KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS -SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - https://www.khronos.org/registry/ - -THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/deps/OpenCL-Headers/README.md b/deps/OpenCL-Headers/README.md index 757e56e15..89a3ea999 100644 --- a/deps/OpenCL-Headers/README.md +++ b/deps/OpenCL-Headers/README.md @@ -9,17 +9,54 @@ https://github.com/KhronosGroup/OpenCL-Headers Issues, proposed fixes for issues, and other suggested changes should be created using Github. +## Build instructions + +> While the OpenCL Headers can be built and installed in isolation, it is part of the [OpenCL SDK](https://github.com/KhronosGroup/OpenCL-SDK). If looking for streamlined build experience and a complete development package, refer to the SDK build instructions instead of the following guide. + +### Dependencies + +- The OpenCL Headers CMake package support uses CMake for its build system. +If CMake is not provided by your build system or OS package manager, please consult the [CMake website](https://cmake.org). + +### Example Build +While the headers may just be copied as-is, this repository also contains a +CMake script with an install rule to allow for packaging the headers. + +```bash +cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/chosen/install/prefix +cmake --build build --target install +``` + +### Example Use + +Example CMake invocation + +```bash +cmake -D CMAKE_PREFIX_PATH=/chosen/install/prefix /path/to/opencl/app +``` + +and sample `CMakeLists.txt` + +```cmake +cmake_minimum_required(VERSION 3.0) +cmake_policy(VERSION 3.0...3.18.4) +project(proj) +add_executable(app main.cpp) +find_package(OpenCLHeaders REQUIRED) +target_link_libraries(app PRIVATE OpenCL::Headers) +``` + ## Branch Structure The OpenCL API headers in this repository are Unified headers and are designed -to work with all released OpenCL versions. This differs from previous OpenCL +to work with all released OpenCL versions. This differs from previous OpenCL API headers, where version-specific API headers either existed in separate branches, or in separate folders in a branch. ## Compiling for a Specific OpenCL Version By default, the OpenCL API headers in this repository are for the latest -OpenCL version (currently OpenCL 2.2). To use these API headers to target +OpenCL version (currently OpenCL 3.0). To use these API headers to target a different OpenCL version, an application may `#define` the preprocessor value `CL_TARGET_OPENCL_VERSION` before including the OpenCL API headers. The `CL_TARGET_OPENCL_VERSION` is a three digit decimal value representing @@ -28,11 +65,39 @@ the OpenCL API version. For example, to enforce usage of no more than the OpenCL 1.2 APIs, you may include the OpenCL API headers as follows: -``` +```c #define CL_TARGET_OPENCL_VERSION 120 #include ``` +## Controlling Function Prototypes + +By default, the OpenCL API headers in this repository declare function +prototypes for every known core OpenCL API and OpenCL extension API. If this is +not desired, the declared function prototypes can be controlled by the following +preprocessor defines: + +* `CL_NO_PROTOTYPES`: No function prototypes will be declared. This control + applies to core OpenCL APIs and OpenCL extension APIs. +* `CL_NO_CORE_PROTOTYPES`: No function prototypes will be declared for core + OpenCL APIs. +* `CL_NO_EXTENSION_PROTOTYPES`: No function prototypes will be declared for + OpenCL extension APIs. This control applies to all OpenCL extension APIs. +* `CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES`: No function prototypes will be + declared for OpenCL extension APIs that are in the ICD dispatch table for + historical reasons. +* `CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES`: No function prototypes will be + declared for OpenCL extension APIs that are not in the ICD dispatch table. + +For example, to declare function prototypes for core OpenCL 3.0 APIs only, you +may include the OpenCL API headers as follows: + +```c +#define CL_TARGET_OPENCL_VERSION 300 +#define CL_NO_EXTENSION_PROTOTYPES +#include +``` + ## Directory Structure ``` diff --git a/deps/unrar/UnRAR.vcxproj b/deps/unrar/UnRAR.vcxproj index 512bcf15d..b55873e37 100644 --- a/deps/unrar/UnRAR.vcxproj +++ b/deps/unrar/UnRAR.vcxproj @@ -1,279 +1,279 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {95CC809B-03FC-4EDB-BB20-FD07A698C05F} - UnRAR - Win32Proj - 8.1 - - - - Application - v140_xp - MultiByte - true - - - Application - v140_xp - MultiByte - - - Application - v140_xp - MultiByte - false - - - Application - v140_xp - MultiByte - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>14.0.24720.0 - - - build\unrar32\$(Configuration)\ - build\unrar32\$(Configuration)\obj\ - true - false - - - build\unrar64\$(Configuration)\ - build\unrar64\$(Configuration)\obj\ - true - false - - - build\unrar32\$(Configuration)\ - build\unrar32\$(Configuration)\obj\ - false - false - - - build\unrar64\$(Configuration)\ - build\unrar64\$(Configuration)\obj\ - false - false - - - - /MP %(AdditionalOptions) - Disabled - UNRAR;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - false - Use - rar.hpp - Level3 - ProgramDatabase - StdCall - 4007;4996;%(DisableSpecificWarnings) - NoExtensions - - - true - Console - MachineX86 - - - - - X64 - - - /MP %(AdditionalOptions) - Disabled - UNRAR;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - false - Use - rar.hpp - Level3 - ProgramDatabase - StdCall - 4007;4996;%(DisableSpecificWarnings) - NotSet - - - true - Console - MachineX64 - - - - - /MP %(AdditionalOptions) - MaxSpeed - true - Neither - true - false - UNRAR;%(PreprocessorDefinitions) - false - MultiThreaded - Default - true - true - NoExtensions - Precise - false - Use - rar.hpp - Level3 - ProgramDatabase - StdCall - 4007;4996;%(DisableSpecificWarnings) - - - true - Console - true - true - - MachineX86 - - - - - X64 - - - /MP %(AdditionalOptions) - MinSpace - true - Neither - true - false - UNRAR;%(PreprocessorDefinitions) - false - false - MultiThreaded - true - true - false - Use - rar.hpp - Level3 - ProgramDatabase - StdCall - 4007;4996;%(DisableSpecificWarnings) - NotSet - - - true - Console - true - true - - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {95CC809B-03FC-4EDB-BB20-FD07A698C05F} + UnRAR + Win32Proj + 8.1 + + + + Application + v140_xp + MultiByte + true + + + Application + v140_xp + MultiByte + + + Application + v140_xp + MultiByte + false + + + Application + v140_xp + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.24720.0 + + + build\unrar32\$(Configuration)\ + build\unrar32\$(Configuration)\obj\ + true + false + + + build\unrar64\$(Configuration)\ + build\unrar64\$(Configuration)\obj\ + true + false + + + build\unrar32\$(Configuration)\ + build\unrar32\$(Configuration)\obj\ + false + false + + + build\unrar64\$(Configuration)\ + build\unrar64\$(Configuration)\obj\ + false + false + + + + /MP %(AdditionalOptions) + Disabled + UNRAR;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebug + false + Use + rar.hpp + Level3 + ProgramDatabase + StdCall + 4007;4996;%(DisableSpecificWarnings) + NoExtensions + + + true + Console + MachineX86 + + + + + X64 + + + /MP %(AdditionalOptions) + Disabled + UNRAR;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebug + false + Use + rar.hpp + Level3 + ProgramDatabase + StdCall + 4007;4996;%(DisableSpecificWarnings) + NotSet + + + true + Console + MachineX64 + + + + + /MP %(AdditionalOptions) + MaxSpeed + true + Neither + true + false + UNRAR;%(PreprocessorDefinitions) + false + MultiThreaded + Default + true + true + NoExtensions + Precise + false + Use + rar.hpp + Level3 + ProgramDatabase + StdCall + 4007;4996;%(DisableSpecificWarnings) + + + true + Console + true + true + + MachineX86 + + + + + X64 + + + /MP %(AdditionalOptions) + MinSpace + true + Neither + true + false + UNRAR;%(PreprocessorDefinitions) + false + false + MultiThreaded + true + true + false + Use + rar.hpp + Level3 + ProgramDatabase + StdCall + 4007;4996;%(DisableSpecificWarnings) + NotSet + + + true + Console + true + true + + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/deps/unrar/UnRARDll.vcxproj b/deps/unrar/UnRARDll.vcxproj index ec5c17b00..d96e4d1c1 100644 --- a/deps/unrar/UnRARDll.vcxproj +++ b/deps/unrar/UnRARDll.vcxproj @@ -1,420 +1,420 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - release_nocrypt - Win32 - - - release_nocrypt - x64 - - - Release - Win32 - - - Release - x64 - - - - UnRAR - {E815C46C-36C4-499F-BBC2-E772C6B17971} - UnRAR - Win32Proj - 8.1 - - - - DynamicLibrary - v140_xp - MultiByte - true - - - DynamicLibrary - v140_xp - MultiByte - true - - - DynamicLibrary - v140_xp - MultiByte - - - DynamicLibrary - v140_xp - MultiByte - false - - - DynamicLibrary - v140_xp - MultiByte - false - - - DynamicLibrary - v140_xp - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>14.0.24720.0 - - - build\unrardll32\$(Configuration)\ - build\unrardll32\$(Configuration)\obj\ - true - true - - - build\unrardll64\$(Configuration)\ - build\unrardll64\$(Configuration)\obj\ - true - true - - - build\unrardll32\$(Configuration)\ - build\unrardll32\$(Configuration)\obj\ - false - true - - - build\unrardll64\$(Configuration)\ - build\unrardll64\$(Configuration)\obj\ - false - true - - - build\unrardll32\$(Configuration)\ - build\unrardll32\$(Configuration)\obj\ - false - true - - - build\unrardll64\$(Configuration)\ - build\unrardll64\$(Configuration)\obj\ - false - true - - - - /MP %(AdditionalOptions) - Disabled - RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) - false - Sync - EnableFastChecks - MultiThreadedDebug - 4Bytes - false - Use - rar.hpp - Level3 - ProgramDatabase - Cdecl - 4007;4996;%(DisableSpecificWarnings) - NoExtensions - - - $(OutDir)unrar.dll - dll.def - true - Console - MachineX86 - - - - - X64 - - - /MP %(AdditionalOptions) - Disabled - RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) - false - Sync - EnableFastChecks - MultiThreadedDebug - 4Bytes - false - Use - rar.hpp - Level3 - ProgramDatabase - Cdecl - 4007;4996;%(DisableSpecificWarnings) - NotSet - - - $(OutDir)unrar.dll - dll.def - true - Console - MachineX64 - - - - - /MP %(AdditionalOptions) - MaxSpeed - true - Neither - true - false - RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) - false - Sync - MultiThreaded - 4Bytes - true - true - NoExtensions - Precise - false - Use - rar.hpp - Level3 - ProgramDatabase - Cdecl - 4007;4996;%(DisableSpecificWarnings) - - - /SAFESEH %(AdditionalOptions) - $(OutDir)unrar.dll - dll.def - true - Console - true - true - - MachineX86 - - - - - X64 - - - /MP %(AdditionalOptions) - MaxSpeed - true - Neither - true - false - RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) - false - false - Sync - MultiThreaded - 4Bytes - true - true - false - Use - rar.hpp - Level3 - ProgramDatabase - Cdecl - 4007;4996;%(DisableSpecificWarnings) - NotSet - - - $(OutDir)unrar.dll - dll.def - true - Console - true - true - - MachineX64 - - - - - /MP %(AdditionalOptions) - MaxSpeed - true - Neither - true - false - RARDLL;UNRAR;SILENT;RAR_NOCRYPT;%(PreprocessorDefinitions) - false - Sync - MultiThreaded - 4Bytes - true - true - NoExtensions - Precise - false - Use - rar.hpp - Level3 - ProgramDatabase - Cdecl - 4007;4996;%(DisableSpecificWarnings) - - - /SAFESEH %(AdditionalOptions) - $(OutDir)unrar.dll - dll_nocrypt.def - true - Console - true - true - - MachineX86 - - - - - X64 - - - /MP %(AdditionalOptions) - MaxSpeed - true - Neither - true - false - RARDLL;UNRAR;SILENT;RAR_NOCRYPT;%(PreprocessorDefinitions) - false - false - Sync - MultiThreaded - 4Bytes - true - true - false - Use - rar.hpp - Level3 - ProgramDatabase - StdCall - 4007;4996;%(DisableSpecificWarnings) - NotSet - - - $(OutDir)unrar.dll - dll_nocrypt.def - true - Console - true - true - - MachineX64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + release_nocrypt + Win32 + + + release_nocrypt + x64 + + + Release + Win32 + + + Release + x64 + + + + UnRAR + {E815C46C-36C4-499F-BBC2-E772C6B17971} + UnRAR + Win32Proj + 8.1 + + + + DynamicLibrary + v140_xp + MultiByte + true + + + DynamicLibrary + v140_xp + MultiByte + true + + + DynamicLibrary + v140_xp + MultiByte + + + DynamicLibrary + v140_xp + MultiByte + false + + + DynamicLibrary + v140_xp + MultiByte + false + + + DynamicLibrary + v140_xp + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>14.0.24720.0 + + + build\unrardll32\$(Configuration)\ + build\unrardll32\$(Configuration)\obj\ + true + true + + + build\unrardll64\$(Configuration)\ + build\unrardll64\$(Configuration)\obj\ + true + true + + + build\unrardll32\$(Configuration)\ + build\unrardll32\$(Configuration)\obj\ + false + true + + + build\unrardll64\$(Configuration)\ + build\unrardll64\$(Configuration)\obj\ + false + true + + + build\unrardll32\$(Configuration)\ + build\unrardll32\$(Configuration)\obj\ + false + true + + + build\unrardll64\$(Configuration)\ + build\unrardll64\$(Configuration)\obj\ + false + true + + + + /MP %(AdditionalOptions) + Disabled + RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) + false + Sync + EnableFastChecks + MultiThreadedDebug + Default + false + Use + rar.hpp + Level3 + ProgramDatabase + Cdecl + 4007;4996;%(DisableSpecificWarnings) + NoExtensions + + + $(OutDir)unrar.dll + dll.def + true + Console + MachineX86 + + + + + X64 + + + /MP %(AdditionalOptions) + Disabled + RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) + false + Sync + EnableFastChecks + MultiThreadedDebug + Default + false + Use + rar.hpp + Level3 + ProgramDatabase + Cdecl + 4007;4996;%(DisableSpecificWarnings) + NotSet + + + $(OutDir)unrar.dll + dll.def + true + Console + MachineX64 + + + + + /MP %(AdditionalOptions) + MaxSpeed + true + Neither + true + false + RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) + false + Sync + MultiThreaded + Default + true + true + NoExtensions + Precise + false + Use + rar.hpp + Level3 + ProgramDatabase + Cdecl + 4007;4996;%(DisableSpecificWarnings) + + + /SAFESEH %(AdditionalOptions) + $(OutDir)unrar.dll + dll.def + true + Console + true + true + + MachineX86 + + + + + X64 + + + /MP %(AdditionalOptions) + MaxSpeed + true + Neither + true + false + RARDLL;UNRAR;SILENT;%(PreprocessorDefinitions) + false + false + Sync + MultiThreaded + Default + true + true + false + Use + rar.hpp + Level3 + ProgramDatabase + Cdecl + 4007;4996;%(DisableSpecificWarnings) + NotSet + + + $(OutDir)unrar.dll + dll.def + true + Console + true + true + + MachineX64 + + + + + /MP %(AdditionalOptions) + MaxSpeed + true + Neither + true + false + RARDLL;UNRAR;SILENT;RAR_NOCRYPT;%(PreprocessorDefinitions) + false + Sync + MultiThreaded + Default + true + true + NoExtensions + Precise + false + Use + rar.hpp + Level3 + ProgramDatabase + Cdecl + 4007;4996;%(DisableSpecificWarnings) + + + /SAFESEH %(AdditionalOptions) + $(OutDir)unrar.dll + dll_nocrypt.def + true + Console + true + true + + MachineX86 + + + + + X64 + + + /MP %(AdditionalOptions) + MaxSpeed + true + Neither + true + false + RARDLL;UNRAR;SILENT;RAR_NOCRYPT;%(PreprocessorDefinitions) + false + false + Sync + MultiThreaded + Default + true + true + false + Use + rar.hpp + Level3 + ProgramDatabase + StdCall + 4007;4996;%(DisableSpecificWarnings) + NotSet + + + $(OutDir)unrar.dll + dll_nocrypt.def + true + Console + true + true + + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/deps/unrar/acknow.txt b/deps/unrar/acknow.txt index 60a772fa1..b8d35a6aa 100644 --- a/deps/unrar/acknow.txt +++ b/deps/unrar/acknow.txt @@ -1,92 +1,59 @@ - ACKNOWLEDGMENTS - -* We used "Screaming Fast Galois Field Arithmetic Using Intel - SIMD Instructions" paper by James S. Plank, Kevin M. Greenan - and Ethan L. Miller to improve Reed-Solomon coding performance. - Also we are grateful to Artem Drobanov and Bulat Ziganshin - for samples and ideas allowed to make Reed-Solomon coding - more efficient. - -* RAR text compression algorithm is based on Dmitry Shkarin PPMII - and Dmitry Subbotin carryless rangecoder public domain source code. - You may find it in ftp.elf.stuba.sk/pub/pc/pack. - -* RAR encryption includes parts of code from Szymon Stefanek - and Brian Gladman AES implementations also as Steve Reid SHA-1 source. - - --------------------------------------------------------------------------- - Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. - All rights reserved. - - LICENSE TERMS - - The free distribution and use of this software in both source and binary - form is allowed (with or without changes) provided that: - - 1. distributions of this source code include the above copyright - notice, this list of conditions and the following disclaimer; - - 2. distributions in binary form include the above copyright - notice, this list of conditions and the following disclaimer - in the documentation and/or other associated materials; - - 3. the copyright holder's name is not used to endorse products - built using this software without specific written permission. - - ALTERNATIVELY, provided that this notice is retained in full, this product - may be distributed under the terms of the GNU General Public License (GPL), - in which case the provisions of the GPL apply INSTEAD OF those given above. - - DISCLAIMER - - This software is provided 'as is' with no explicit or implied warranties - in respect of its properties, including, but not limited to, correctness - and/or fitness for purpose. - --------------------------------------------------------------------------- - - Source code of this package also as other cryptographic technology - and computing project related links are available on Brian Gladman's - web site: http://www.gladman.me.uk - -* RAR uses CRC32 function based on Intel Slicing-by-8 algorithm. - Original Intel Slicing-by-8 code is available here: - - https://sourceforge.net/projects/slicing-by-8/ - - Original Intel Slicing-by-8 code is licensed under BSD License - available at http://www.opensource.org/licenses/bsd-license.html - - Copyright (c) 2004-2006 Intel Corporation. - All Rights Reserved - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with - the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - -* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ), - designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn - and Christian Winnerlein. - -* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed - to significantly improve RAR compression and speed. + ACKNOWLEDGMENTS + +* We used "Screaming Fast Galois Field Arithmetic Using Intel + SIMD Instructions" paper by James S. Plank, Kevin M. Greenan + and Ethan L. Miller to improve Reed-Solomon coding performance. + Also we are grateful to Artem Drobanov and Bulat Ziganshin + for samples and ideas allowed to make Reed-Solomon coding + more efficient. + +* RAR4 text compression algorithm is based on Dmitry Shkarin PPMII + and Dmitry Subbotin carryless rangecoder public domain source code. + You can find it in ftp.elf.stuba.sk/pub/pc/pack. + +* RAR encryption includes parts of public domain code + from Szymon Stefanek AES and Steve Reid SHA-1 implementations. + +* With exception of SFX modules, RAR uses CRC32 function based + on Intel Slicing-by-8 algorithm. Original Intel Slicing-by-8 code + is available here: + + https://sourceforge.net/projects/slicing-by-8/ + + Original Intel Slicing-by-8 code is licensed under BSD License + available at http://www.opensource.org/licenses/bsd-license.html + + Copyright (c) 2004-2006 Intel Corporation. + All Rights Reserved + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with + the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ), + designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn + and Christian Winnerlein. + +* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed + to significantly improve RAR compression and speed. diff --git a/deps/unrar/archive.cpp b/deps/unrar/archive.cpp index 8c5a1da81..25f0c3b79 100644 --- a/deps/unrar/archive.cpp +++ b/deps/unrar/archive.cpp @@ -3,15 +3,15 @@ #include "arccmt.cpp" -Archive::Archive(RAROptions *InitCmd) +Archive::Archive(CommandData *InitCmd) { Cmd=NULL; // Just in case we'll have an exception in 'new' below. DummyCmd=(InitCmd==NULL); - Cmd=DummyCmd ? (new RAROptions):InitCmd; + Cmd=DummyCmd ? (new CommandData):InitCmd; OpenShared=Cmd->OpenShared; - Format=RARFMT15; + Format=RARFMT_NONE; Solid=false; Volume=false; MainComment=false; @@ -31,9 +31,9 @@ Archive::Archive(RAROptions *InitCmd) NextBlockPos=0; - memset(&MainHead,0,sizeof(MainHead)); - memset(&CryptHead,0,sizeof(CryptHead)); - memset(&EndArcHead,0,sizeof(EndArcHead)); + MainHead.Reset(); + CryptHead={}; + EndArcHead.Reset(); VolNumber=0; VolWrite=0; @@ -231,7 +231,7 @@ bool Archive::IsArchive(bool EnableBroken) // first file header to set "comment" flag when reading service header. // Unless we are in silent mode, we need to know about presence of comment // immediately after IsArchive call. - if (HeadersLeft && (!SilentOpen || !Encrypted)) + if (HeadersLeft && (!SilentOpen || !Encrypted) && IsSeekable()) { int64 SavePos=Tell(); int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos; diff --git a/deps/unrar/archive.hpp b/deps/unrar/archive.hpp index d9518f1dc..35a399bca 100644 --- a/deps/unrar/archive.hpp +++ b/deps/unrar/archive.hpp @@ -32,8 +32,8 @@ class Archive:public File size_t ReadHeader14(); size_t ReadHeader15(); size_t ReadHeader50(); - void ProcessExtra50(RawRead *Raw,size_t ExtraSize,BaseBlock *bb); - void RequestArcPassword(); + void ProcessExtra50(RawRead *Raw,size_t ExtraSize,const BaseBlock *bb); + void RequestArcPassword(RarCheckPassword *SelPwd); void UnexpEndArcMsg(); void BrokenHeaderMsg(); void UnkEncVerMsg(const wchar *Name,const wchar *Info); @@ -45,7 +45,7 @@ class Archive:public File #endif ComprDataIO SubDataIO; bool DummyCmd; - RAROptions *Cmd; + CommandData *Cmd; RarTime LatestTime; @@ -58,7 +58,7 @@ class Archive:public File bool ProhibitQOpen; #endif public: - Archive(RAROptions *InitCmd=NULL); + Archive(CommandData *InitCmd=NULL); ~Archive(); static RARFORMAT IsSignature(const byte *D,size_t Size); bool IsArchive(bool EnableBroken); @@ -83,7 +83,7 @@ class Archive:public File const wchar *Name,uint Flags); bool ReadSubData(Array *UnpData,File *DestFile,bool TestMode); HEADER_TYPE GetHeaderType() {return CurHeaderType;} - RAROptions* GetRAROptions() {return Cmd;} + CommandData* GetCommandData() {return Cmd;} void SetSilentOpen(bool Mode) {SilentOpen=Mode;} #if 0 void GetRecoveryInfo(bool Required,int64 *Size,int *Percent); diff --git a/deps/unrar/arcread.cpp b/deps/unrar/arcread.cpp index d1df6c041..86488cd49 100644 --- a/deps/unrar/arcread.cpp +++ b/deps/unrar/arcread.cpp @@ -100,6 +100,9 @@ void Archive::UnexpEndArcMsg() // If block positions are equal to file size, this is not an error. // It can happen when we reached the end of older RAR 1.5 archive, // which did not have the end of archive block. + // We can't replace this check by checking that read size is exactly 0 + // in the beginning of file header, because in this case the read position + // still can be beyond the end of archive. if (CurBlockPos!=ArcSize || NextBlockPos!=ArcSize) { uiMsg(UIERROR_UNEXPEOF,FileName); @@ -145,7 +148,7 @@ size_t Archive::ReadHeader15() #ifdef RAR_NOCRYPT // For rarext.dll and unrar_nocrypt.dll. return 0; #else - RequestArcPassword(); + RequestArcPassword(NULL); byte Salt[SIZE_SALT30]; if (Read(Salt,SIZE_SALT30)!=SIZE_SALT30) @@ -251,7 +254,11 @@ size_t Archive::ReadHeader15() hd->SplitAfter=(hd->Flags & LHD_SPLIT_AFTER)!=0; hd->Encrypted=(hd->Flags & LHD_PASSWORD)!=0; hd->SaltSet=(hd->Flags & LHD_SALT)!=0; + + // RAR versions earlier than 2.0 do not set the solid flag + // in file header. They use only a global solid archive flag. hd->Solid=FileBlock && (hd->Flags & LHD_SOLID)!=0; + hd->SubBlock=!FileBlock && (hd->Flags & LHD_SOLID)!=0; hd->Dir=(hd->Flags & LHD_WINDOWMASK)==LHD_DIRECTORY; hd->WinSize=hd->Dir ? 0:0x10000<<((hd->Flags & LHD_WINDOWMASK)>>5); @@ -558,6 +565,13 @@ size_t Archive::ReadHeader50() return 0; #else + if (Cmd->SkipEncrypted) + { + uiMsg(UIMSG_SKIPENCARC,FileName); + FailedHeaderDecryption=true; // Suppress error messages and quit quietly. + return 0; + } + byte HeadersInitV[SIZE_INITV]; if (Read(HeadersInitV,SIZE_INITV)!=SIZE_INITV) { @@ -570,14 +584,20 @@ size_t Archive::ReadHeader50() // in -p to not stop batch processing for encrypted archives. bool GlobalPassword=Cmd->Password.IsSet() || uiIsGlobalPasswordSet(); + RarCheckPassword CheckPwd; + if (CryptHead.UsePswCheck && !BrokenHeader) + CheckPwd.Set(CryptHead.Salt,HeadersInitV,CryptHead.Lg2Count,CryptHead.PswCheck); + while (true) // Repeat the password prompt for wrong passwords. { - RequestArcPassword(); + RequestArcPassword(CheckPwd.IsSet() ? &CheckPwd:NULL); byte PswCheck[SIZE_PSWCHECK]; HeadersCrypt.SetCryptKeys(false,CRYPT_RAR50,&Cmd->Password,CryptHead.Salt,HeadersInitV,CryptHead.Lg2Count,NULL,PswCheck); - // Verify password validity. - if (CryptHead.UsePswCheck && memcmp(PswCheck,CryptHead.PswCheck,SIZE_PSWCHECK)!=0) + // Verify password validity. If header is damaged, we cannot rely on + // password check value, because it can be damaged too. + if (CryptHead.UsePswCheck && !BrokenHeader && + memcmp(PswCheck,CryptHead.PswCheck,SIZE_PSWCHECK)!=0) { if (GlobalPassword) // For -p or Ctrl+P. { @@ -843,8 +863,6 @@ size_t Archive::ReadHeader50() hd->Dir=(hd->FileFlags & FHFL_DIRECTORY)!=0; hd->WinSize=hd->Dir ? 0:size_t(0x20000)<<((CompInfo>>10)&0xf); - hd->CryptMethod=hd->Encrypted ? CRYPT_RAR50:CRYPT_NONE; - char FileName[NM*4]; size_t ReadNameSize=Min(NameSize,ASIZE(FileName)-1); Raw.GetB((byte *)FileName,ReadNameSize); @@ -868,20 +886,6 @@ size_t Archive::ReadHeader50() if (!FileBlock && hd->CmpName(SUBHEAD_TYPE_CMT)) MainComment=true; -#if 0 - // For RAR5 format we read the user specified recovery percent here. - // It would be useful to do it for shell extension too, so we display - // the correct recovery record size in archive properties. But then - // we would need to include the entire recovery record processing - // code to shell extension, which is not done now. - if (!FileBlock && hd->CmpName(SUBHEAD_TYPE_RR) && hd->SubData.Size()>0) - { - RecoveryPercent=hd->SubData[0]; - RSBlockHeader Header; - GetRRInfo(this,&Header); - RecoverySize=Header.RecSectionSize*Header.RecCount; - } -#endif if (BadCRC) // Add the file name to broken header message displayed above. uiMsg(UIERROR_FHEADERBROKEN,Archive::FileName,hd->FileName); @@ -904,7 +908,7 @@ size_t Archive::ReadHeader50() #if !defined(RAR_NOCRYPT) -void Archive::RequestArcPassword() +void Archive::RequestArcPassword(RarCheckPassword *CheckPwd) { if (!Cmd->Password.IsSet()) { @@ -934,7 +938,7 @@ void Archive::RequestArcPassword() ErrHandler.Exit(RARX_USERBREAK); } #else - if (!uiGetPassword(UIPASSWORD_ARCHIVE,FileName,&Cmd->Password)) + if (!uiGetPassword(UIPASSWORD_ARCHIVE,FileName,&Cmd->Password,CheckPwd)) { Close(); uiMsg(UIERROR_INCERRCOUNT); // Prevent archive deleting if delete after extraction is on. @@ -947,7 +951,7 @@ void Archive::RequestArcPassword() #endif -void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,BaseBlock *bb) +void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,const BaseBlock *bb) { // Read extra data from the end of block skipping any fields before it. size_t ExtraStart=Raw->Size()-ExtraSize; @@ -970,22 +974,57 @@ void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,BaseBlock *bb) if (bb->HeaderType==HEAD_MAIN) { MainHeader *hd=(MainHeader *)bb; - if (FieldType==MHEXTRA_LOCATOR) + switch(FieldType) { - hd->Locator=true; - uint Flags=(uint)Raw->GetV(); - if ((Flags & MHEXTRA_LOCATOR_QLIST)!=0) - { - uint64 Offset=Raw->GetV(); - if (Offset!=0) // 0 means that reserved space was not enough to write the offset. - hd->QOpenOffset=Offset+CurBlockPos; - } - if ((Flags & MHEXTRA_LOCATOR_RR)!=0) - { - uint64 Offset=Raw->GetV(); - if (Offset!=0) // 0 means that reserved space was not enough to write the offset. - hd->RROffset=Offset+CurBlockPos; - } + case MHEXTRA_LOCATOR: + { + hd->Locator=true; + uint Flags=(uint)Raw->GetV(); + if ((Flags & MHEXTRA_LOCATOR_QLIST)!=0) + { + uint64 Offset=Raw->GetV(); + if (Offset!=0) // 0 means that reserved space was not enough to write the offset. + hd->QOpenOffset=Offset+CurBlockPos; + } + if ((Flags & MHEXTRA_LOCATOR_RR)!=0) + { + uint64 Offset=Raw->GetV(); + if (Offset!=0) // 0 means that reserved space was not enough to write the offset. + hd->RROffset=Offset+CurBlockPos; + } + } + break; + case MHEXTRA_METADATA: + { + uint Flags=(uint)Raw->GetV(); + if ((Flags & MHEXTRA_METADATA_NAME)!=0) + { + uint64 NameSize=Raw->GetV(); + if (NameSize<0x10000) // Prevent excessive allocation. + { + std::vector NameU((size_t)NameSize); // UTF-8 name. + Raw->GetB(&NameU[0],(size_t)NameSize); + // If starts from 0, the name was longer than reserved space + // when saving this extra field. + if (NameU[0]!=0) + { + NameU.push_back(0); + std::vector NameW(NameU.size()*4); + UtfToWide(&NameU[0],&NameW[0],NameW.size()); + hd->OrigName.assign(&NameW[0]); + } + } + } + if ((Flags & MHEXTRA_METADATA_CTIME)!=0) + if ((Flags & MHEXTRA_METADATA_UNIXTIME)!=0) + if ((Flags & MHEXTRA_METADATA_UNIX_NS)!=0) + hd->OrigTime.SetUnixNS(Raw->Get8()); + else + hd->OrigTime.SetUnix((time_t)Raw->Get4()); + else + hd->OrigTime.SetWin(Raw->Get8()); + } + break; } } @@ -1441,7 +1480,9 @@ bool Archive::ReadSubData(Array *UnpData,File *DestFile,bool TestMode) { if (SubHead.UnpSize>0x1000000) { - // So huge allocation must never happen in valid archives. + // Prevent the excessive allocation. When reading to memory, normally + // this function operates with reasonably small blocks, such as + // the archive comment, NTFS ACL or "Zone.Identifier" NTFS stream. uiMsg(UIERROR_SUBHEADERUNKNOWN,FileName); return false; } diff --git a/deps/unrar/array.hpp b/deps/unrar/array.hpp index 20d258d5b..ac786f710 100644 --- a/deps/unrar/array.hpp +++ b/deps/unrar/array.hpp @@ -10,7 +10,6 @@ template class Array size_t BufSize; size_t AllocSize; size_t MaxSize; - bool Secure; // Clean memory if true. public: Array(); Array(size_t Size); @@ -24,14 +23,13 @@ template class Array void Alloc(size_t Items); void Reset(); void SoftReset(); - void operator = (Array &Src); + Array& operator = (const Array &Src); void Push(T Item); void Append(T *Item,size_t Count); T* Addr(size_t Item) {return Buffer+Item;} void SetMaxSize(size_t Size) {MaxSize=Size;} T* Begin() {return Buffer;} T* End() {return Buffer==NULL ? NULL:Buffer+BufSize;} - void SetSecure() {Secure=true;} }; @@ -41,7 +39,6 @@ template void Array::CleanData() BufSize=0; AllocSize=0; MaxSize=0; - Secure=false; } @@ -71,11 +68,7 @@ template Array::Array(const Array &Src) template Array::~Array() { if (Buffer!=NULL) - { - if (Secure) - cleandata(Buffer,AllocSize*sizeof(T)); free(Buffer); - } } @@ -111,25 +104,9 @@ template void Array::Add(size_t Items) size_t Suggested=AllocSize+AllocSize/4+32; size_t NewSize=Max(BufSize,Suggested); - T *NewBuffer; - if (Secure) - { - NewBuffer=(T *)malloc(NewSize*sizeof(T)); - if (NewBuffer==NULL) - ErrHandler.MemoryError(); - if (Buffer!=NULL) - { - memcpy(NewBuffer,Buffer,AllocSize*sizeof(T)); - cleandata(Buffer,AllocSize*sizeof(T)); - free(Buffer); - } - } - else - { - NewBuffer=(T *)realloc(Buffer,NewSize*sizeof(T)); - if (NewBuffer==NULL) - ErrHandler.MemoryError(); - } + T *NewBuffer=(T *)realloc(Buffer,NewSize*sizeof(T)); + if (NewBuffer==NULL) + ErrHandler.MemoryError(); Buffer=NewBuffer; AllocSize=NewSize; } @@ -165,12 +142,13 @@ template void Array::SoftReset() } -template void Array::operator =(Array &Src) +template Array& Array::operator =(const Array &Src) { Reset(); Alloc(Src.BufSize); if (Src.BufSize!=0) memcpy((void *)Buffer,(void *)Src.Buffer,Src.BufSize*sizeof(T)); + return *this; } diff --git a/deps/unrar/blake2s.hpp b/deps/unrar/blake2s.hpp index f88ef3780..06e396a77 100644 --- a/deps/unrar/blake2s.hpp +++ b/deps/unrar/blake2s.hpp @@ -20,10 +20,15 @@ enum blake2s_constant // 'new' operator. struct blake2s_state { - enum { BLAKE_ALIGNMENT = 64 }; + // Use constexpr instead of enums, because otherwise clang -std=c++20 + // issues a warning about "arithmetic between different enumeration types" + // in ubuf[BLAKE_DATA_SIZE + BLAKE_ALIGNMENT] declaration. + static constexpr size_t BLAKE_ALIGNMENT = 64; // buffer and uint32 h[8], t[2], f[2]; - enum { BLAKE_DATA_SIZE = 48 + 2 * BLAKE2S_BLOCKBYTES }; + // 2 * BLAKE2S_BLOCKBYTES is the buf size in blake2_code_20140114.zip. + // It might differ in later versions. + static constexpr size_t BLAKE_DATA_SIZE = 48 + 2 * BLAKE2S_BLOCKBYTES; byte ubuf[BLAKE_DATA_SIZE + BLAKE_ALIGNMENT]; diff --git a/deps/unrar/cmddata.cpp b/deps/unrar/cmddata.cpp index 455a07b2c..3a4ab99eb 100644 --- a/deps/unrar/cmddata.cpp +++ b/deps/unrar/cmddata.cpp @@ -26,9 +26,10 @@ void CommandData::Init() FileArgs.Reset(); ExclArgs.Reset(); InclArgs.Reset(); - StoreArgs.Reset(); ArcNames.Reset(); - NextVolSizes.Reset(); + StoreArgs.Reset(); + Password.Clean(); + NextVolSizes.clear(); } @@ -108,6 +109,11 @@ void CommandData::ParseArg(wchar *Arg) // 'S' can contain SFX name, which case is important in Unix. if (*Command!='I' && *Command!='S') wcsupper(Command); + if (*Command=='P') // Enforce -idq for print command. + { + MsgStream=MSG_ERRONLY; + SetConsoleMsgStream(MSG_ERRONLY); + } } else if (*ArcName==0) @@ -309,6 +315,21 @@ void CommandData::ProcessSwitch(const wchar *Switch) case 'I': IgnoreGeneralAttr=true; break; + case 'M': + switch(toupperw(Switch[2])) + { + case 0: + case 'S': + ArcMetadata=ARCMETA_SAVE; + break; + case 'R': + ArcMetadata=ARCMETA_RESTORE; + break; + default: + BadSwitch(Switch); + break; + } + break; case 'N': // Reserved for archive name. break; case 'O': @@ -373,6 +394,9 @@ void CommandData::ProcessSwitch(const wchar *Switch) case '3': ExclPath=EXCL_ABSPATH; break; + case '4': + wcsncpyz(ExclArcPath,Switch+3,ASIZE(ExclArcPath)); + break; } break; default: @@ -399,13 +423,15 @@ void CommandData::ProcessSwitch(const wchar *Switch) EncryptHeaders=true; if (Switch[2]!=0) { + if (wcslen(Switch+2)>=MAXPASSWORD) + uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1); Password.Set(Switch+2); cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0])); } else if (!Password.IsSet()) { - uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password); + uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password,NULL); eprintf(L"\n"); } break; @@ -561,6 +587,10 @@ void CommandData::ProcessSwitch(const wchar *Switch) break; case 'D': break; + case 'E': + if (toupperw(Switch[2])=='S' && Switch[3]==0) + SkipEncrypted=true; + break; case 'S': { wchar StoreNames[1024]; @@ -648,6 +678,10 @@ void CommandData::ProcessSwitch(const wchar *Switch) AllowIncompatNames=true; break; #endif + case 'P': + wcsncpyz(ExtrPath,Switch+2,ASIZE(ExtrPath)); + AddEndSlash(ExtrPath,ASIZE(ExtrPath)); + break; case 'R': Overwrite=OVERWRITE_AUTORENAME; break; @@ -667,11 +701,13 @@ void CommandData::ProcessSwitch(const wchar *Switch) case 'P': if (Switch[1]==0) { - uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password); + uiGetPassword(UIPASSWORD_GLOBAL,NULL,&Password,NULL); eprintf(L"\n"); } else { + if (wcslen(Switch+1)>=MAXPASSWORD) + uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1); Password.Set(Switch+1); cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0])); } @@ -752,6 +788,10 @@ void CommandData::ProcessSwitch(const wchar *Switch) case 'D': Solid|=SOLID_VOLUME_DEPENDENT; break; + case 'I': + ProhibitConsoleInput(); + wcsncpyz(UseStdin,Switch[2] ? Switch+2:L"stdin",ASIZE(UseStdin)); + break; case 'L': if (IsDigit(Switch[2])) FileSizeLess=atoilw(Switch+2); @@ -935,7 +975,7 @@ void CommandData::ProcessCommand() wcsncpyz(ArcName,Name,ASIZE(ArcName)); } - if (wcschr(L"AFUMD",*Command)==NULL) + if (wcschr(L"AFUMD",*Command)==NULL && *UseStdin==0) { if (GenerateArcName) { diff --git a/deps/unrar/cmddata.hpp b/deps/unrar/cmddata.hpp index 719b4007e..0feb404b3 100644 --- a/deps/unrar/cmddata.hpp +++ b/deps/unrar/cmddata.hpp @@ -2,7 +2,7 @@ #define _RAR_CMDDATA_ -#define DefaultStoreList L"7z;ace;arj;bz2;cab;gz;jpeg;jpg;lha;lz;lzh;mp3;rar;taz;tgz;xz;z;zip;zipx" +#define DefaultStoreList L"7z;ace;arj;bz2;cab;gz;jpeg;jpg;lha;lz;lzh;mp3;rar;taz;tbz;tbz2;tgz;txz;xz;z;zip;zipx;zst;tzst" enum RAR_CMD_LIST_MODE {RCLM_AUTO,RCLM_REJECT_LISTS,RCLM_ACCEPT_LISTS}; @@ -50,7 +50,7 @@ class CommandData:public RAROptions bool GetArcName(wchar *Name,int MaxSize); bool CheckWinSize(); - int GetRecoverySize(const wchar *Str,int DefSize); + int GetRecoverySize(const wchar *CmdStr,const wchar *Value,int DefSize); #ifndef SFX_MODULE void ReportWrongSwitches(RARFORMAT Format); @@ -65,6 +65,10 @@ class CommandData:public RAROptions StringList InclArgs; StringList ArcNames; StringList StoreArgs; + + SecPassword Password; + + std::vector NextVolSizes; }; #endif diff --git a/deps/unrar/cmdfilter.cpp b/deps/unrar/cmdfilter.cpp index d6517ceb7..e0add14bf 100644 --- a/deps/unrar/cmdfilter.cpp +++ b/deps/unrar/cmdfilter.cpp @@ -262,6 +262,8 @@ bool CommandData::TimeCheck(RarTime &ftm,RarTime &ftc,RarTime &fta) // Return 'true' if we need to exclude the file from processing. bool CommandData::SizeCheck(int64 Size) { + if (Size==INT64NDF) // If called from archive formats like bzip2, not storing the file size. + return false; if (FileSizeLess!=INT64NDF && Size>=FileSizeLess) return true; if (FileSizeMore!=INT64NDF && Size<=FileSizeMore) @@ -287,8 +289,8 @@ int CommandData::IsProcessFile(FileHeader &FileHead,bool *ExactMatch,int MatchTy return 0; if ((FileHead.FileAttr & ExclFileAttr)!=0 || FileHead.Dir && ExclDir) return 0; - if (InclAttrSet && (!FileHead.Dir && (FileHead.FileAttr & InclFileAttr)==0 || - FileHead.Dir && !InclDir)) + if (InclAttrSet && (FileHead.FileAttr & InclFileAttr)==0 && + (!FileHead.Dir || !InclDir)) return 0; if (!Dir && SizeCheck(FileHead.UnpSize)) return 0; diff --git a/deps/unrar/cmdmix.cpp b/deps/unrar/cmdmix.cpp index 3990cc189..6bd1e1ac0 100644 --- a/deps/unrar/cmdmix.cpp +++ b/deps/unrar/cmdmix.cpp @@ -61,14 +61,14 @@ void CommandData::OutHelp(RAR_EXIT ExitCode) MUNRARTitle1,MRARTitle2,MCHelpCmd,MCHelpCmdE,MCHelpCmdL, MCHelpCmdP,MCHelpCmdT,MCHelpCmdV,MCHelpCmdX,MCHelpSw,MCHelpSwm, MCHelpSwAT,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,MCHelpSwAI,MCHelpSwAP, - MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU, - MCHelpSwDH,MCHelpSwEP,MCHelpSwEP3,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR, - MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwN,MCHelpSwNa,MCHelpSwNal, - MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOR,MCHelpSwOW,MCHelpSwP, - MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSL,MCHelpSwSM, - MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU, - MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal, - MCHelpSwY + MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,MCHelpSwDH,MCHelpSwEP, + MCHelpSwEP3,MCHelpSwEP4,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR, + MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwME,MCHelpSwN,MCHelpSwNa, + MCHelpSwNal,MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOP,MCHelpSwOR, + MCHelpSwOW,MCHelpSwP,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSI, + MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO, + MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX, + MCHelpSwXa,MCHelpSwXal,MCHelpSwY #endif }; @@ -92,6 +92,13 @@ void CommandData::OutHelp(RAR_EXIT ExitCode) if (Found) continue; #endif +#ifdef _UNIX + if (CmpMSGID(Help[I],MRARTitle2)) + { + mprintf(St(MFwrSlTitle2)); + continue; + } +#endif #if !defined(_UNIX) && !defined(_WIN_ALL) if (CmpMSGID(Help[I],MCHelpSwOW)) continue; diff --git a/deps/unrar/compress.hpp b/deps/unrar/compress.hpp index 73f7ee41a..4ef8570f4 100644 --- a/deps/unrar/compress.hpp +++ b/deps/unrar/compress.hpp @@ -17,6 +17,7 @@ class PackDef static const uint MAX_INC_LZ_MATCH = MAX_LZ_MATCH + 3; static const uint MAX3_LZ_MATCH = 0x101; // Maximum match length for RAR v3. + static const uint MAX3_INC_LZ_MATCH = MAX3_LZ_MATCH + 3; static const uint LOW_DIST_REP_COUNT = 16; static const uint NC = 306; /* alphabet = {0, 1, 2, ..., NC - 1} */ diff --git a/deps/unrar/consio.cpp b/deps/unrar/consio.cpp index fedd5c05c..fa35d6146 100644 --- a/deps/unrar/consio.cpp +++ b/deps/unrar/consio.cpp @@ -3,6 +3,7 @@ static MESSAGE_TYPE MsgStream=MSG_STDOUT; static RAR_CHARSET RedirectCharset=RCH_DEFAULT; +static bool ProhibitInput=false; const int MaxMsgSize=2*NM+2048; @@ -61,6 +62,12 @@ void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset) } +void ProhibitConsoleInput() +{ + ProhibitInput=true; +} + + #ifndef SILENT static void cvt_wprintf(FILE *dest,const wchar *fmt,va_list arglist) { @@ -141,28 +148,56 @@ void eprintf(const wchar *fmt,...) #ifndef SILENT +static void QuitIfInputProhibited() +{ + // We cannot handle user prompts if -si is used to read file or archive data + // from stdin. + if (ProhibitInput) + { + mprintf(St(MStdinNoInput)); + ErrHandler.Exit(RARX_FATAL); + } +} + + static void GetPasswordText(wchar *Str,uint MaxLength) { if (MaxLength==0) return; + QuitIfInputProhibited(); if (StdinRedirected) getwstr(Str,MaxLength); // Read from pipe or redirected file. else { #ifdef _WIN_ALL HANDLE hConIn=GetStdHandle(STD_INPUT_HANDLE); - HANDLE hConOut=GetStdHandle(STD_OUTPUT_HANDLE); - DWORD ConInMode,ConOutMode; - DWORD Read=0; + DWORD ConInMode; GetConsoleMode(hConIn,&ConInMode); - GetConsoleMode(hConOut,&ConOutMode); - SetConsoleMode(hConIn,ENABLE_LINE_INPUT); - SetConsoleMode(hConOut,ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT); + SetConsoleMode(hConIn,ENABLE_LINE_INPUT); // Remove ENABLE_ECHO_INPUT. + // We prefer ReadConsole to ReadFile, so we can read Unicode input. + DWORD Read=0; ReadConsole(hConIn,Str,MaxLength-1,&Read,NULL); Str[Read]=0; SetConsoleMode(hConIn,ConInMode); - SetConsoleMode(hConOut,ConOutMode); + + // If entered password is longer than MAXPASSWORD and truncated, + // read its unread part anyway, so it isn't read later as the second + // password for -p switch. Low level FlushConsoleInputBuffer doesn't help + // for high level ReadConsole, which in line input mode seems to store + // the rest of string in its own internal buffer. + if (wcschr(Str,'\r')==NULL) // If '\r' is missing, the password was truncated. + while (true) + { + wchar Trail[64]; + DWORD TrailRead=0; + // Use ASIZE(Trail)-1 to reserve the space for trailing 0. + ReadConsole(hConIn,Trail,ASIZE(Trail)-1,&TrailRead,NULL); + Trail[TrailRead]=0; + if (TrailRead==0 || wcschr(Trail,'\r')!=NULL) + break; + } + #else char StrA[MAXPASSWORD*4]; // "*4" for multibyte UTF-8 characters. #if defined(_EMX) || defined (__VMS) @@ -190,16 +225,21 @@ bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword * while (true) { - if (!StdinRedirected) +// if (!StdinRedirected) if (Type==UIPASSWORD_GLOBAL) eprintf(L"\n%s: ",St(MAskPsw)); else eprintf(St(MAskPswFor),FileName); - wchar PlainPsw[MAXPASSWORD]; + wchar PlainPsw[MAXPASSWORD+1]; GetPasswordText(PlainPsw,ASIZE(PlainPsw)); if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL) return false; + if (wcslen(PlainPsw)>=MAXPASSWORD) + { + PlainPsw[MAXPASSWORD-1]=0; + uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1); + } if (!StdinRedirected && Type==UIPASSWORD_GLOBAL) { eprintf(St(MReAskPsw)); @@ -229,6 +269,8 @@ bool getwstr(wchar *str,size_t n) // Print buffered prompt title function before waiting for input. fflush(stderr); + QuitIfInputProhibited(); + *str=0; #if defined(_WIN_ALL) // fgetws does not work well with non-English text in Windows, @@ -240,6 +282,7 @@ bool getwstr(wchar *str,size_t n) Array StrA(n*4); // Up to 4 UTF-8 characters per wchar_t. File SrcFile; SrcFile.SetHandleType(FILE_HANDLESTD); + SrcFile.SetLineInputMode(true); int ReadSize=SrcFile.Read(&StrA[0],StrA.Size()-1); if (ReadSize<=0) { diff --git a/deps/unrar/consio.hpp b/deps/unrar/consio.hpp index 903dc21a4..bf97289e7 100644 --- a/deps/unrar/consio.hpp +++ b/deps/unrar/consio.hpp @@ -4,6 +4,7 @@ void InitConsole(); void SetConsoleMsgStream(MESSAGE_TYPE MsgStream); void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset); +void ProhibitConsoleInput(); void OutComment(const wchar *Comment,size_t Size); #ifndef SILENT diff --git a/deps/unrar/crc.cpp b/deps/unrar/crc.cpp index cf23bbf4f..0c6aef160 100644 --- a/deps/unrar/crc.cpp +++ b/deps/unrar/crc.cpp @@ -14,6 +14,12 @@ #include "rar.hpp" +#ifndef SFX_MODULE +// User suggested to avoid BSD license in SFX module, so they do not need +// to include the license to SFX archive. +#define USE_SLICING +#endif + static uint crc_tables[8][256]; // Tables for Slicing-by-8. @@ -37,6 +43,7 @@ static void InitTables() { InitCRC32(crc_tables[0]); +#ifdef USE_SLICING for (uint I=0;I<256;I++) // Build additional lookup tables. { uint C=crc_tables[0][I]; @@ -46,6 +53,7 @@ static void InitTables() crc_tables[J][I]=C; } } +#endif } @@ -55,6 +63,7 @@ uint CRC32(uint StartCRC,const void *Addr,size_t Size) { byte *Data=(byte *)Addr; +#ifdef USE_SLICING // Align Data to 8 for better performance. for (;Size>0 && ((size_t)Data & 7);Size--,Data++) StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8); @@ -77,6 +86,7 @@ uint CRC32(uint StartCRC,const void *Addr,size_t Size) crc_tables[1][(byte)(NextData >> 16)] ^ crc_tables[0][(byte)(NextData >> 24)]; } +#endif for (;Size>0;Size--,Data++) // Process left data. StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8); @@ -100,3 +110,164 @@ ushort Checksum14(ushort StartCRC,const void *Addr,size_t Size) #endif +#if 0 +static uint64 crc64_tables[8][256]; // Tables for Slicing-by-8 for CRC64. + +void InitCRC64(uint64 *CRCTab) +{ + const uint64 poly=INT32TO64(0xC96C5795, 0xD7870F42); // 0xC96C5795D7870F42; + for (uint I=0;I<256;I++) + { + uint64 C=I; + for (uint J=0;J<8;J++) + C=(C & 1) ? (C>>1)^poly: (C>>1); + CRCTab[I]=C; + } +} + + +static void InitTables64() +{ + InitCRC64(crc64_tables[0]); + + for (uint I=0;I<256;I++) // Build additional lookup tables. + { + uint64 C=crc64_tables[0][I]; + for (uint J=1;J<8;J++) + { + C=crc64_tables[0][(byte)C]^(C>>8); + crc64_tables[J][I]=C; + } + } +} + + +// We cannot place the intialization to CRC64(), because we use this function +// in multithreaded mode and it conflicts with multithreading. +struct CallInitCRC64 {CallInitCRC64() {InitTables64();}} static CallInit64; + +uint64 CRC64(uint64 StartCRC,const void *Addr,size_t Size) +{ + byte *Data=(byte *)Addr; + + // Align Data to 8 for better performance. + for (;Size>0 && ((size_t)Data & 7)!=0;Size--,Data++) + StartCRC=crc64_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8); + + for (byte *DataEnd=Data+Size/8*8; Data> 8 ) ] ^ + crc64_tables[ 5 ] [ ( byte ) (Index >> 16 ) ] ^ + crc64_tables[ 4 ] [ ( byte ) (Index >> 24 ) ] ^ + crc64_tables[ 3 ] [ ( byte ) (Index >> 32 ) ] ^ + crc64_tables[ 2 ] [ ( byte ) (Index >> 40 ) ] ^ + crc64_tables[ 1 ] [ ( byte ) (Index >> 48 ) ] ^ + crc64_tables[ 0 ] [ ( byte ) (Index >> 56 ) ] ; + } + + for (Size%=8;Size>0;Size--,Data++) // Process left data. + StartCRC=crc64_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8); + + return StartCRC; +} + + +#if 0 +static void TestCRC(); +struct TestCRCStruct {TestCRCStruct() {TestCRC();exit(0);}} GlobalTesCRC; + +void TestCRC() +{ + const uint FirstSize=300; + byte b[FirstSize]; + + if ((CRC32(0xffffffff,(byte*)"testtesttest",12)^0xffffffff)==0x44608e84) + mprintf(L"\nCRC32 test1 OK"); + else + mprintf(L"\nCRC32 test1 FAILED"); + + if (CRC32(0,(byte*)"te\x80st",5)==0xB2E5C5AE) + mprintf(L"\nCRC32 test2 OK"); + else + mprintf(L"\nCRC32 test2 FAILED"); + + for (uint I=0;I<14;I++) // Check for possible int sign extension. + b[I]=(byte)0x7f+I; + if ((CRC32(0xffffffff,b,14)^0xffffffff)==0x1DFA75DA) + mprintf(L"\nCRC32 test3 OK"); + else + mprintf(L"\nCRC32 test3 FAILED"); + + for (uint I=0;IIsSet() || Method==CRYPT_NONE) + if (Method==CRYPT_NONE || !Password->IsSet()) return false; CryptData::Method=Method; wchar PwdW[MAXPASSWORD]; Password->Get(PwdW,ASIZE(PwdW)); + PwdW[Min(MAXPASSWORD_RAR,MAXPASSWORD)-1]=0; // For compatibility with existing archives. + char PwdA[MAXPASSWORD]; WideToChar(PwdW,PwdA,ASIZE(PwdA)); + PwdA[Min(MAXPASSWORD_RAR,MAXPASSWORD)-1]=0; // For compatibility with existing archives. switch(Method) { diff --git a/deps/unrar/crypt.hpp b/deps/unrar/crypt.hpp index ebbad96ed..8f22bea21 100644 --- a/deps/unrar/crypt.hpp +++ b/deps/unrar/crypt.hpp @@ -30,6 +30,18 @@ class CryptData uint Lg2Count; // Log2 of PBKDF2 repetition count. byte PswCheckValue[SHA256_DIGEST_SIZE]; byte HashKeyValue[SHA256_DIGEST_SIZE]; + + KDF5CacheItem() {Clean();} + ~KDF5CacheItem() {Clean();} + + void Clean() + { + cleandata(Salt,sizeof(Salt)); + cleandata(Key,sizeof(Key)); + cleandata(&Lg2Count,sizeof(Lg2Count)); + cleandata(PswCheckValue,sizeof(PswCheckValue)); + cleandata(HashKeyValue,sizeof(HashKeyValue)); + } }; struct KDF3CacheItem @@ -39,6 +51,17 @@ class CryptData byte Key[16]; byte Init[16]; bool SaltPresent; + + KDF3CacheItem() {Clean();} + ~KDF3CacheItem() {Clean();} + + void Clean() + { + cleandata(Salt,sizeof(Salt)); + cleandata(Key,sizeof(Key)); + cleandata(Init,sizeof(Init)); + cleandata(&SaltPresent,sizeof(SaltPresent)); + } }; @@ -77,7 +100,6 @@ class CryptData ushort Key15[4]; public: CryptData(); - ~CryptData(); bool SetCryptKeys(bool Encrypt,CRYPT_METHOD Method,SecPassword *Password, const byte *Salt,const byte *InitV,uint Lg2Cnt, byte *HashKey,byte *PswCheck); @@ -89,6 +111,54 @@ class CryptData static void SetSalt(byte *Salt,size_t SaltSize); }; + +class CheckPassword +{ + public: + enum CONFIDENCE {CONFIDENCE_HIGH,CONFIDENCE_MEDIUM,CONFIDENCE_LOW}; + virtual CONFIDENCE GetConfidence()=0; + virtual bool Check(SecPassword *Password)=0; +}; + +class RarCheckPassword:public CheckPassword +{ + private: + CryptData *Crypt; + uint Lg2Count; + byte Salt[SIZE_SALT50]; + byte InitV[SIZE_INITV]; + byte PswCheck[SIZE_PSWCHECK]; + public: + RarCheckPassword() + { + Crypt=NULL; + } + ~RarCheckPassword() + { + delete Crypt; + } + void Set(byte *Salt,byte *InitV,uint Lg2Count,byte *PswCheck) + { + if (Crypt==NULL) + Crypt=new CryptData; + memcpy(this->Salt,Salt,sizeof(this->Salt)); + memcpy(this->InitV,InitV,sizeof(this->InitV)); + this->Lg2Count=Lg2Count; + memcpy(this->PswCheck,PswCheck,sizeof(this->PswCheck)); + } + bool IsSet() {return Crypt!=NULL;} + + // RAR5 provides the higly reliable 64 bit password verification value. + CONFIDENCE GetConfidence() {return CONFIDENCE_HIGH;} + + bool Check(SecPassword *Password) + { + byte PswCheck[SIZE_PSWCHECK]; + Crypt->SetCryptKeys(false,CRYPT_RAR50,Password,Salt,InitV,Lg2Count,NULL,PswCheck); + return memcmp(PswCheck,this->PswCheck,sizeof(this->PswCheck))==0; + } +}; + void GetRnd(byte *RndBuf,size_t BufSize); void hmac_sha256(const byte *Key,size_t KeyLength,const byte *Data, diff --git a/deps/unrar/crypt3.cpp b/deps/unrar/crypt3.cpp index fe3bf97b8..e6e3a82cb 100644 --- a/deps/unrar/crypt3.cpp +++ b/deps/unrar/crypt3.cpp @@ -18,8 +18,9 @@ void CryptData::SetKey30(bool Encrypt,SecPassword *Password,const wchar *PwdW,co if (!Cached) { byte RawPsw[2*MAXPASSWORD+SIZE_SALT30]; - WideToRaw(PwdW,RawPsw,ASIZE(RawPsw)); - size_t RawLength=2*wcslen(PwdW); + size_t PswLength=wcslen(PwdW); + size_t RawLength=2*PswLength; + WideToRaw(PwdW,PswLength,RawPsw,RawLength); if (Salt!=NULL) { memcpy(RawPsw+RawLength,Salt,SIZE_SALT30); diff --git a/deps/unrar/crypt5.cpp b/deps/unrar/crypt5.cpp index 7562469f3..5ed65af81 100644 --- a/deps/unrar/crypt5.cpp +++ b/deps/unrar/crypt5.cpp @@ -21,7 +21,7 @@ static void hmac_sha256(const byte *Key,size_t KeyLength,const byte *Data, sha256_context ICtx; if (ICtxOpt!=NULL && *SetIOpt) - ICtx=*ICtxOpt; // Use already calculated first block context. + ICtx=*ICtxOpt; // Use already calculated the first block context. else { // This calculation is the same for all iterations with same password. @@ -90,10 +90,10 @@ void pbkdf2(const byte *Pwd, size_t PwdLength, byte SaltData[MaxSalt+4]; memcpy(SaltData, Salt, Min(SaltLength,MaxSalt)); - SaltData[SaltLength + 0] = 0; // Salt concatenated to 1. - SaltData[SaltLength + 1] = 0; - SaltData[SaltLength + 2] = 0; - SaltData[SaltLength + 3] = 1; + SaltData[SaltLength + 0] = 0; // Block index appened to salt. + SaltData[SaltLength + 1] = 0; // + SaltData[SaltLength + 2] = 0; // Since we do not request the key width + SaltData[SaltLength + 3] = 1; // exceeding HMAC width, it is always 1. // First iteration: HMAC of password, salt and block index (1). byte U1[SHA256_DIGEST_SIZE]; @@ -140,7 +140,7 @@ void CryptData::SetKey50(bool Encrypt,SecPassword *Password,const wchar *PwdW, for (uint I=0;ILg2Count==Lg2Cnt && Item->Pwd==*Password && + if (Item->Pwd==*Password && Item->Lg2Count==Lg2Cnt && memcmp(Item->Salt,Salt,SIZE_SALT50)==0) { memcpy(Key,Item->Key,sizeof(Key)); diff --git a/deps/unrar/dll.def b/deps/unrar/dll.def index 3c9a2c83a..a7241141a 100644 --- a/deps/unrar/dll.def +++ b/deps/unrar/dll.def @@ -1,13 +1,13 @@ -EXPORTS - RAROpenArchive - RAROpenArchiveEx - RARCloseArchive - RARReadHeader - RARReadHeaderEx - RARProcessFile - RARProcessFileW - RARSetCallback - RARSetChangeVolProc - RARSetProcessDataProc - RARSetPassword - RARGetDllVersion +EXPORTS + RAROpenArchive + RAROpenArchiveEx + RARCloseArchive + RARReadHeader + RARReadHeaderEx + RARProcessFile + RARProcessFileW + RARSetCallback + RARSetChangeVolProc + RARSetProcessDataProc + RARSetPassword + RARGetDllVersion diff --git a/deps/unrar/dll.rc b/deps/unrar/dll.rc index 8dd505da0..ff610c835 100644 --- a/deps/unrar/dll.rc +++ b/deps/unrar/dll.rc @@ -1,28 +1,28 @@ -#include -#include - -VS_VERSION_INFO VERSIONINFO -FILEVERSION 6, 1, 100, 3756 -PRODUCTVERSION 6, 1, 100, 3756 -FILEOS VOS__WINDOWS32 -FILETYPE VFT_APP -{ - BLOCK "StringFileInfo" - { - BLOCK "040904E4" - { - VALUE "CompanyName", "Alexander Roshal\0" - VALUE "ProductName", "RAR decompression library\0" - VALUE "FileDescription", "RAR decompression library\0" - VALUE "FileVersion", "6.1.0\0" - VALUE "ProductVersion", "6.1.0\0" - VALUE "LegalCopyright", "Copyright © Alexander Roshal 1993-2021\0" - VALUE "OriginalFilename", "Unrar.dll\0" - } - } - BLOCK "VarFileInfo" - { - VALUE "Translation", 0x0409, 0x04E4 - } -} - +#include +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION 6, 22, 1, 865 +PRODUCTVERSION 6, 22, 1, 865 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + VALUE "CompanyName", "Alexander Roshal\0" + VALUE "ProductName", "RAR decompression library\0" + VALUE "FileDescription", "RAR decompression library\0" + VALUE "FileVersion", "6.22.1\0" + VALUE "ProductVersion", "6.22.1\0" + VALUE "LegalCopyright", "Copyright © Alexander Roshal 1993-2023\0" + VALUE "OriginalFilename", "Unrar.dll\0" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04E4 + } +} + diff --git a/deps/unrar/dll_nocrypt.def b/deps/unrar/dll_nocrypt.def index d473e978e..f7037ea4c 100644 --- a/deps/unrar/dll_nocrypt.def +++ b/deps/unrar/dll_nocrypt.def @@ -1,13 +1,13 @@ -EXPORTS - RAROpenArchive - RAROpenArchiveEx - RARCloseArchive - RARReadHeader - RARReadHeaderEx - RARProcessFile - RARProcessFileW - RARSetCallback - RARSetChangeVolProc - RARSetProcessDataProc -; RARSetPassword - RARGetDllVersion +EXPORTS + RAROpenArchive + RAROpenArchiveEx + RARCloseArchive + RARReadHeader + RARReadHeaderEx + RARProcessFile + RARProcessFileW + RARSetCallback + RARSetChangeVolProc + RARSetProcessDataProc +; RARSetPassword + RARGetDllVersion diff --git a/deps/unrar/encname.cpp b/deps/unrar/encname.cpp index 84731a71e..e1ba1ed70 100644 --- a/deps/unrar/encname.cpp +++ b/deps/unrar/encname.cpp @@ -20,8 +20,6 @@ void EncodeFileName::Decode(char *Name,size_t NameSize,byte *EncName,size_t EncS { if (FlagBits==0) { - if (EncPos>=EncSize) - break; Flags=EncName[EncPos++]; FlagBits=8; } diff --git a/deps/unrar/encname.hpp b/deps/unrar/encname.hpp index 538bcb699..c6b4ed44d 100644 --- a/deps/unrar/encname.hpp +++ b/deps/unrar/encname.hpp @@ -4,9 +4,8 @@ class EncodeFileName { private: - void AddFlags(int Value); + void AddFlags(byte Value,byte *EncName); - byte *EncName; byte Flags; uint FlagBits; size_t FlagsPos; diff --git a/deps/unrar/errhnd.cpp b/deps/unrar/errhnd.cpp index 18e91973e..97193e5ac 100644 --- a/deps/unrar/errhnd.cpp +++ b/deps/unrar/errhnd.cpp @@ -169,10 +169,13 @@ void ErrorHandler::OpenErrorMsg(const wchar *FileName) void ErrorHandler::OpenErrorMsg(const wchar *ArcName,const wchar *FileName) { - Wait(); // Keep GUI responsive if many files cannot be opened when archiving. uiMsg(UIERROR_FILEOPEN,ArcName,FileName); SysErrMsg(); SetErrorCode(RARX_OPEN); + + // Keep GUI responsive if many files cannot be opened when archiving. + // Call after SysErrMsg to avoid modifying the error code and SysErrMsg text. + Wait(); } @@ -367,7 +370,7 @@ bool ErrorHandler::GetSysErrMsg(wchar *Msg,size_t Size) void ErrorHandler::SysErrMsg() { -#if !defined(SFX_MODULE) && !defined(SILENT) +#ifndef SILENT wchar Msg[1024]; if (!GetSysErrMsg(Msg,ASIZE(Msg))) return; diff --git a/deps/unrar/extinfo.cpp b/deps/unrar/extinfo.cpp index 5cb90a408..0f25f3124 100644 --- a/deps/unrar/extinfo.cpp +++ b/deps/unrar/extinfo.cpp @@ -112,6 +112,68 @@ static bool LinkInPath(const wchar *Name) } +// Delete symbolic links in file path, if any, and replace them by directories. +// Prevents extracting files outside of destination folder with symlink chains. +bool LinksToDirs(const wchar *SrcName,const wchar *SkipPart,std::wstring &LastChecked) +{ + // Unlike Unix, Windows doesn't expand lnk1 in symlink targets like + // "lnk1/../dir", but converts the path to "dir". In Unix we need to call + // this function to prevent placing unpacked files outside of destination + // folder if previously we unpacked "dir/lnk1" -> "..", + // "dir/lnk2" -> "lnk1/.." and "dir/lnk2/anypath/poc.txt". + // We may still need this function to prevent abusing symlink chains + // in link source path if we remove detection of such chains + // in IsRelativeSymlinkSafe. This function seems to make other symlink + // related safety checks redundant, but for now we prefer to keep them too. + // + // 2022.12.01: the performance impact is minimized after adding the check + // against the previous path and enabling this verification only after + // extracting a symlink with ".." in target. So we enabled it for Windows + // as well for extra safety. +//#ifdef _UNIX + wchar Path[NM]; + if (wcslen(SrcName)>=ASIZE(Path)) + return false; // It should not be that long, skip. + wcsncpyz(Path,SrcName,ASIZE(Path)); + + size_t SkipLength=wcslen(SkipPart); + + if (SkipLength>0 && wcsncmp(Path,SkipPart,SkipLength)!=0) + SkipLength=0; // Parameter validation, not really needed now. + + // Do not check parts already checked in previous path to improve performance. + for (uint I=0;Path[I]!=0 && ISkipLength) + SkipLength=I; + + wchar *Name=Path; + if (SkipLength>0) + { + // Avoid converting symlinks in destination path part specified by user. + Name+=SkipLength; + while (IsPathDiv(*Name)) + Name++; + } + + for (wchar *s=Path+wcslen(Path)-1;s>Name;s--) + if (IsPathDiv(*s)) + { + *s=0; + FindData FD; + if (FindFile::FastFind(Path,&FD,true) && FD.IsLink) +#ifdef _WIN_ALL + if (!DelDir(Path)) +#else + if (!DelFile(Path)) +#endif + return false; // Couldn't delete the symlink to replace it with directory. + } + LastChecked=SrcName; +//#endif + return true; +} + + bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *PrepSrcName,const wchar *TargetName) { // Catch root dir based /path/file paths also as stuff like \\?\. @@ -131,10 +193,14 @@ bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *Pr UpLevels++; TargetName++; } - // If link target includes "..", it must not have another links - // in the path, because they can bypass our safety check. For example, + // If link target includes "..", it must not have another links in its + // source path, because they can bypass our safety check. For example, // suppose we extracted "lnk1" -> "." first and "lnk1/lnk2" -> ".." next - // or "dir/lnk1" -> ".." first and "dir/lnk1/lnk2" -> ".." next. + // or "dir/lnk1" -> ".." first, "dir/lnk1/lnk2" -> ".." next and + // file "dir/lnk1/lnk2/poc.txt" last. + // Do not confuse with link chains in target, this is in link source path. + // It is important for Windows too, though this check can be omitted + // if LinksToDirs is invoked in Windows as well. if (UpLevels>0 && LinkInPath(PrepSrcName)) return false; @@ -160,15 +226,26 @@ bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *Pr } -bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName) +bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName,bool &UpLink) { + // Returning true in Uplink indicates that link target might include ".." + // and enables additional checks. It is ok to falsely return true here, + // as it implies only the minor performance penalty. But we shall always + // return true for links with ".." in target for security reason. + + UpLink=true; // Assume the target might include potentially unsafe "..". +#if defined(SAVE_LINKS) && defined(_UNIX) || defined(_WIN_ALL) + if (Arc.Format==RARFMT50) // For RAR5 archives we can check RedirName for both Unix and Windows. + UpLink=wcsstr(Arc.FileHead.RedirName,L"..")!=NULL; +#endif + #if defined(SAVE_LINKS) && defined(_UNIX) // For RAR 3.x archives we process links even in test mode to skip link data. if (Arc.Format==RARFMT15) - return ExtractUnixLink30(Cmd,DataIO,Arc,LinkName); + return ExtractUnixLink30(Cmd,DataIO,Arc,LinkName,UpLink); if (Arc.Format==RARFMT50) return ExtractUnixLink50(Cmd,LinkName,&Arc.FileHead); -#elif defined _WIN_ALL +#elif defined(_WIN_ALL) // RAR 5.0 archives store link information in file header, so there is // no need to additionally test it if we do not create a file. if (Arc.Format==RARFMT50) diff --git a/deps/unrar/extinfo.hpp b/deps/unrar/extinfo.hpp index f3c7511b4..d8551d463 100644 --- a/deps/unrar/extinfo.hpp +++ b/deps/unrar/extinfo.hpp @@ -1,8 +1,9 @@ #ifndef _RAR_EXTINFO_ #define _RAR_EXTINFO_ +bool LinksToDirs(const wchar *SrcName,const wchar *SkipPart,std::wstring &LastChecked); bool IsRelativeSymlinkSafe(CommandData *Cmd,const wchar *SrcName,const wchar *PrepSrcName,const wchar *TargetName); -bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName); +bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName,bool &UpLink); #ifdef _UNIX void SetUnixOwner(Archive &Arc,const wchar *FileName); #endif diff --git a/deps/unrar/extract.cpp b/deps/unrar/extract.cpp index dc824aa97..4d9e51202 100644 --- a/deps/unrar/extract.cpp +++ b/deps/unrar/extract.cpp @@ -5,10 +5,30 @@ CmdExtract::CmdExtract(CommandData *Cmd) CmdExtract::Cmd=Cmd; *ArcName=0; - *DestFileName=0; + ArcAnalyzed=false; + Analyze=new AnalyzeData; + memset(Analyze,0,sizeof(*Analyze)); + TotalFileCount=0; + + // Common for all archives involved. Set here instead of DoExtract() + // to use in unrar.dll too. Allows to avoid LinksToDirs() calls + // and save CPU time in no symlinks including ".." in target were extracted. +#if defined(_WIN_ALL) + // We can't expand symlink path components in another symlink target + // in Windows. We can't create symlinks in Android now. Even though we do not + // really need LinksToDirs() calls in these systems, we still call it + // for extra safety, but only if symlink with ".." in target was extracted. + ConvertSymlinkPaths=false; +#else + // We enable it by default in Unix to care about the case when several + // archives are unpacked to same directory with several independent RAR runs. + // Worst case performance penalty for a lot of small files seems to be ~3%. + ConvertSymlinkPaths=true; +#endif + Unp=new Unpack(&DataIO); #ifdef RAR_SMP Unp->SetThreads(Cmd->Threads); @@ -18,7 +38,26 @@ CmdExtract::CmdExtract(CommandData *Cmd) CmdExtract::~CmdExtract() { + FreeAnalyzeData(); delete Unp; + delete Analyze; +} + + +void CmdExtract::FreeAnalyzeData() +{ + for (size_t I=0;ICommand[0]); - FindData FD; - while (Cmd->GetArcName(ArcName,ASIZE(ArcName))) - if (FindFile::FastFind(ArcName,&FD)) - DataIO.TotalArcSize+=FD.Size; + if (*Cmd->UseStdin==0) + { + FindData FD; + while (Cmd->GetArcName(ArcName,ASIZE(ArcName))) + if (FindFile::FastFind(ArcName,&FD)) + DataIO.TotalArcSize+=FD.Size; + } Cmd->ArcNames.Rewind(); while (Cmd->GetArcName(ArcName,ASIZE(ArcName))) @@ -49,8 +91,7 @@ void CmdExtract::DoExtract() if (Code!=EXTRACT_ARC_REPEAT) break; } - if (FindFile::FastFind(ArcName,&FD)) - DataIO.ProcessedArcSize+=FD.Size; + DataIO.ProcessedArcSize+=DataIO.LastArcSize; } // Clean user entered password. Not really required, just for extra safety. @@ -82,7 +123,7 @@ void CmdExtract::DoExtract() void CmdExtract::ExtractArchiveInit(Archive &Arc) { - DataIO.UnpArcSize=Arc.FileLength(); + DataIO.AdjustTotalArcSize(&Arc); FileCount=0; MatchedArgs=0; @@ -98,15 +139,33 @@ void CmdExtract::ExtractArchiveInit(Archive &Arc) AllMatchesExact=true; AnySolidDataUnpackedWell=false; + ArcAnalyzed=false; + StartTime.SetCurrentTime(); + + LastCheckedSymlink.clear(); } EXTRACT_ARC_CODE CmdExtract::ExtractArchive() { Archive Arc(Cmd); - if (!Arc.WOpen(ArcName)) - return EXTRACT_ARC_NEXT; + if (*Cmd->UseStdin!=0) + { + Arc.SetHandleType(FILE_HANDLESTD); +#ifdef USE_QOPEN + Arc.SetProhibitQOpen(true); +#endif + } + else + { +#if defined(_WIN_ALL) && !defined(SFX_MODULE) // WinRAR GUI code also resets the cache. + if (*Cmd->Command=='T' || Cmd->Test) + ResetFileCache(ArcName); // Reset the file cache when testing an archive. +#endif + if (!Arc.WOpen(ArcName)) + return EXTRACT_ARC_NEXT; + } if (!Arc.IsArchive(true)) { @@ -155,20 +214,33 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive() } #endif + Arc.ViewComment(); // Must be before possible EXTRACT_ARC_REPEAT. + int64 VolumeSetSize=0; // Total size of volumes after the current volume. +#ifndef SFX_MODULE + if (!ArcAnalyzed && *Cmd->UseStdin==0) + { + AnalyzeArchive(Arc.FileName,Arc.Volume,Arc.NewNumbering); + ArcAnalyzed=true; // Avoid repeated analysis on EXTRACT_ARC_REPEAT. + } +#endif + if (Arc.Volume) { #ifndef SFX_MODULE // Try to speed up extraction for independent solid volumes by starting // extraction from non-first volume if we can. - if (!UseExactVolName && Arc.Solid && DetectStartVolume(Arc.FileName,Arc.NewNumbering)) + if (*Analyze->StartName!=0) { + wcsncpyz(ArcName,Analyze->StartName,ASIZE(ArcName)); + *Analyze->StartName=0; + UseExactVolName=true; return EXTRACT_ARC_REPEAT; } #endif - + // Calculate the total size of all accessible volumes. // This size is necessary to display the correct total progress indicator. @@ -203,7 +275,13 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive() else uiStartArchiveExtract(!Cmd->Test,ArcName); - Arc.ViewComment(); +#ifndef SFX_MODULE + if (Analyze->StartPos!=0) + { + Arc.Seek(Analyze->StartPos,SEEK_SET); + Analyze->StartPos=0; + } +#endif while (1) @@ -216,14 +294,11 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive() if (Repeat) { // If we started extraction from not first volume and need to - // restart it from first, we must correct DataIO.TotalArcSize - // for correct total progress display. We subtract the size - // of current volume and all volumes after it and add the size - // of new (first) volume. - FindData OldArc,NewArc; - if (FindFile::FastFind(Arc.FileName,&OldArc) && - FindFile::FastFind(ArcName,&NewArc)) - DataIO.TotalArcSize-=VolumeSetSize+OldArc.Size-NewArc.Size; + // restart it from first, we must set DataIO.TotalArcSize to size + // of new first volume to display the total progress correctly. + FindData NewArc; + if (FindFile::FastFind(ArcName,&NewArc)) + DataIO.TotalArcSize=NewArc.Size; return EXTRACT_ARC_REPEAT; } else @@ -262,7 +337,14 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) return false; HEADER_TYPE HeaderType=Arc.GetHeaderType(); - if (HeaderType!=HEAD_FILE) + if (HeaderType==HEAD_FILE) + { + // Unlike Arc.FileName, ArcName might store an old volume name here. + if (Analyze->EndPos!=0 && Analyze->EndPos==Arc.CurBlockPos && + (*Analyze->EndName==0 || wcscmp(Analyze->EndName,Arc.FileName)==0)) + return false; + } + else { #ifndef SFX_MODULE if (Arc.Format==RARFMT15 && HeaderType==HEAD3_OLDSERVICE && PrevProcessed) @@ -305,6 +387,9 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) if (Arc.FileHead.UnpSize<0) Arc.FileHead.UnpSize=0; + // 2022.03.20: We might remove this check in the future. + // It duplicates Analyze->EndPos and Analyze->EndName in all cases except + // volumes on removable media. if (!Cmd->Recurse && MatchedArgs>=Cmd->FileArgs.ItemsCount() && AllMatchesExact) return false; @@ -403,7 +488,39 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) FirstFile=false; #endif - if (MatchFound || (SkipSolid=Arc.Solid)!=0) + bool RefTarget=false; + if (!MatchFound) + for (size_t I=0;ITest) // While harmless, it is useless for 't'. + { + // If reference source isn't selected, but target is selected, + // we unpack the source under the temporary name and then rename + // or copy it to target name. We do not unpack it under the target + // name immediately, because the same source can be used by multiple + // targets and it is possible that first target isn't unpacked + // for some reason. Also targets might have associated service blocks + // like ACLs. All this would complicate processing a lot. + wcsncpyz(DestFileName,*Cmd->TempPath!=0 ? Cmd->TempPath:Cmd->ExtrPath,ASIZE(DestFileName)); + AddEndSlash(DestFileName,ASIZE(DestFileName)); + wcsncatz(DestFileName,L"__tmp_reference_source_",ASIZE(DestFileName)); + MkTemp(DestFileName,ASIZE(DestFileName)); + MatchedRef->TmpName=wcsdup(DestFileName); + } + RefTarget=true; // Need it even for 't' to test the reference source. + break; + } + + if (Arc.FileHead.Encrypted && Cmd->SkipEncrypted) + if (Arc.Solid) + return false; // Abort the entire extraction for solid archive. + else + MatchFound=false; // Skip only the current file for non-solid archive. + + if (MatchFound || RefTarget || (SkipSolid=Arc.Solid)!=0) { // First common call of uiStartFileExtract. It is done before overwrite // prompts, so if SkipSolid state is changed below, we'll need to make @@ -411,7 +528,8 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) if (!uiStartFileExtract(ArcFileName,!Cmd->Test,Cmd->Test && Command!='I',SkipSolid)) return false; - ExtrPrepareName(Arc,ArcFileName,DestFileName,ASIZE(DestFileName)); + if (!RefTarget) + ExtrPrepareName(Arc,ArcFileName,DestFileName,ASIZE(DestFileName)); // DestFileName can be set empty in case of excessive -ap switch. ExtrFile=!SkipSolid && *DestFileName!=0 && !Arc.FileHead.SplitBefore; @@ -448,9 +566,13 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) return !Arc.Solid; // Can try extracting next file only in non-solid archive. } - while (true) // Repeat the password prompt for wrong and empty passwords. + if (Arc.FileHead.Encrypted) { - if (Arc.FileHead.Encrypted) + RarCheckPassword CheckPwd; + if (Arc.Format==RARFMT50 && Arc.FileHead.UsePswCheck && !Arc.BrokenHeader) + CheckPwd.Set(Arc.FileHead.Salt,Arc.FileHead.InitV,Arc.FileHead.Lg2Count,Arc.FileHead.PswCheck); + + while (true) // Repeat the password prompt for wrong and empty passwords. { // Stop archive extracting if user cancelled a password prompt. #ifdef RARDLL @@ -460,77 +582,83 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) return false; } #else - if (!ExtrGetPassword(Arc,ArcFileName)) + if (!ExtrGetPassword(Arc,ArcFileName,CheckPwd.IsSet() ? &CheckPwd:NULL)) { PasswordCancelled=true; return false; } #endif - } - - // Set a password before creating the file, so we can skip creating - // in case of wrong password. - SecPassword FilePassword=Cmd->Password; -#if defined(_WIN_ALL) && !defined(SFX_MODULE) - ConvertDosPassword(Arc,FilePassword); -#endif - byte PswCheck[SIZE_PSWCHECK]; - DataIO.SetEncryption(false,Arc.FileHead.CryptMethod,&FilePassword, - Arc.FileHead.SaltSet ? Arc.FileHead.Salt:NULL, - Arc.FileHead.InitV,Arc.FileHead.Lg2Count, - Arc.FileHead.HashKey,PswCheck); - - // If header is damaged, we cannot rely on password check value, - // because it can be damaged too. - if (Arc.FileHead.Encrypted && Arc.FileHead.UsePswCheck && - memcmp(Arc.FileHead.PswCheck,PswCheck,SIZE_PSWCHECK)!=0 && - !Arc.BrokenHeader) - { - if (GlobalPassword) // For -p or Ctrl+P to avoid the infinite loop. - { - // This message is used by Android GUI to reset cached passwords. - // Update appropriate code if changed. - uiMsg(UIERROR_BADPSW,Arc.FileName,ArcFileName); - } - else // For passwords entered manually. + // Set a password before creating the file, so we can skip creating + // in case of wrong password. + SecPassword FilePassword=Cmd->Password; + #if defined(_WIN_ALL) && !defined(SFX_MODULE) + ConvertDosPassword(Arc,FilePassword); + #endif + + byte PswCheck[SIZE_PSWCHECK]; + DataIO.SetEncryption(false,Arc.FileHead.CryptMethod,&FilePassword, + Arc.FileHead.SaltSet ? Arc.FileHead.Salt:NULL, + Arc.FileHead.InitV,Arc.FileHead.Lg2Count, + Arc.FileHead.HashKey,PswCheck); + + // If header is damaged, we cannot rely on password check value, + // because it can be damaged too. + if (Arc.FileHead.UsePswCheck && !Arc.BrokenHeader && + memcmp(Arc.FileHead.PswCheck,PswCheck,SIZE_PSWCHECK)!=0) { - // This message is used by Android GUI and Windows GUI and SFX to - // reset cached passwords. Update appropriate code if changed. - uiMsg(UIWAIT_BADPSW,Arc.FileName,ArcFileName); - Cmd->Password.Clean(); - - // Avoid new requests for unrar.dll to prevent the infinite loop - // if app always returns the same password. -#ifndef RARDLL - continue; // Request a password again. -#endif + if (GlobalPassword) // For -p or Ctrl+P to avoid the infinite loop. + { + // This message is used by Android GUI to reset cached passwords. + // Update appropriate code if changed. + uiMsg(UIERROR_BADPSW,Arc.FileName,ArcFileName); + } + else // For passwords entered manually. + { + // This message is used by Android GUI and Windows GUI and SFX to + // reset cached passwords. Update appropriate code if changed. + uiMsg(UIWAIT_BADPSW,Arc.FileName,ArcFileName); + Cmd->Password.Clean(); + + // Avoid new requests for unrar.dll to prevent the infinite loop + // if app always returns the same password. + #ifndef RARDLL + continue; // Request a password again. + #endif + } + #ifdef RARDLL + // If we already have ERAR_EOPEN as result of missing volume, + // we should not replace it with less precise ERAR_BAD_PASSWORD. + if (Cmd->DllError!=ERAR_EOPEN) + Cmd->DllError=ERAR_BAD_PASSWORD; + #endif + ErrHandler.SetErrorCode(RARX_BADPWD); + ExtrFile=false; } -#ifdef RARDLL - // If we already have ERAR_EOPEN as result of missing volume, - // we should not replace it with less precise ERAR_BAD_PASSWORD. - if (Cmd->DllError!=ERAR_EOPEN) - Cmd->DllError=ERAR_BAD_PASSWORD; -#endif - ErrHandler.SetErrorCode(RARX_BADPWD); - ExtrFile=false; + break; } - break; } + else + DataIO.SetEncryption(false,CRYPT_NONE,NULL,NULL,NULL,0,NULL,NULL); #ifdef RARDLL if (*Cmd->DllDestName!=0) wcsncpyz(DestFileName,Cmd->DllDestName,ASIZE(DestFileName)); #endif + if (ExtrFile && Command!='P' && !Cmd->Test && !Cmd->AbsoluteLinks && + ConvertSymlinkPaths) + ExtrFile=LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink); + File CurFile; bool LinkEntry=Arc.FileHead.RedirType!=FSREDIR_NONE; - if (LinkEntry && Arc.FileHead.RedirType!=FSREDIR_FILECOPY) + if (LinkEntry && (Arc.FileHead.RedirType!=FSREDIR_FILECOPY)) { if (ExtrFile && Command!='P' && !Cmd->Test) { - // Overwrite prompt for symbolic and hard links. + // Overwrite prompt for symbolic and hard links and when we move + // a temporary file to the file reference instead of copying it. bool UserReject=false; if (FileExist(DestFileName) && !UserReject) FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime); @@ -632,7 +760,7 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) uint64 Preallocated=0; if (!TestMode && !Arc.BrokenHeader && Arc.FileHead.UnpSize>1000000 && - Arc.FileHead.PackSize*1024>Arc.FileHead.UnpSize && + Arc.FileHead.PackSize*1024>Arc.FileHead.UnpSize && Arc.IsSeekable() && (Arc.FileHead.UnpSize<100000000 || Arc.FileLength()>Arc.FileHead.PackSize)) { CurFile.Prealloc(Arc.FileHead.UnpSize); @@ -650,23 +778,51 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) if (Type==FSREDIR_HARDLINK || Type==FSREDIR_FILECOPY) { + wchar RedirName[NM]; + + // 2022.11.15: Might be needed when unpacking WinRAR 5.0 links with + // Unix RAR. WinRAR 5.0 used \ path separators here, when beginning + // from 5.10 even Windows version uses / internally and converts + // them to \ when reading FHEXTRA_REDIR. + // We must perform this conversion before ConvertPath call, + // so paths mixing different slashes like \dir1/dir2\file are + // processed correctly. + SlashToNative(Arc.FileHead.RedirName,RedirName,ASIZE(RedirName)); + + ConvertPath(RedirName,RedirName,ASIZE(RedirName)); + wchar NameExisting[NM]; - ExtrPrepareName(Arc,Arc.FileHead.RedirName,NameExisting,ASIZE(NameExisting)); + ExtrPrepareName(Arc,RedirName,NameExisting,ASIZE(NameExisting)); if (FileCreateMode && *NameExisting!=0) // *NameExisting can be 0 in case of excessive -ap switch. if (Type==FSREDIR_HARDLINK) LinkSuccess=ExtractHardlink(Cmd,DestFileName,NameExisting,ASIZE(NameExisting)); else - LinkSuccess=ExtractFileCopy(CurFile,Arc.FileName,DestFileName,NameExisting,ASIZE(NameExisting)); + LinkSuccess=ExtractFileCopy(CurFile,Arc.FileName,RedirName,DestFileName,NameExisting,ASIZE(NameExisting),Arc.FileHead.UnpSize); } else if (Type==FSREDIR_UNIXSYMLINK || Type==FSREDIR_WINSYMLINK || Type==FSREDIR_JUNCTION) { if (FileCreateMode) - LinkSuccess=ExtractSymlink(Cmd,DataIO,Arc,DestFileName); + { + bool UpLink; + LinkSuccess=ExtractSymlink(Cmd,DataIO,Arc,DestFileName,UpLink); + ConvertSymlinkPaths|=LinkSuccess && UpLink; + + // We do not actually need to reset the cache here if we cache + // only the single last checked path, because at this point + // it will always contain the link own path and link can't + // overwrite its parent folder. But if we ever decide to cache + // several already checked paths, we'll need to reset them here. + // Otherwise if no files were created in one of such paths, + // let's say because of file create error, it might be possible + // to overwrite the path with link and avoid checks. We keep this + // code here as a reminder in case of possible modifications. + LastCheckedSymlink.clear(); // Reset cache for safety reason. + } } else { - uiMsg(UIERROR_UNKNOWNEXTRA,Arc.FileName,DestFileName); + uiMsg(UIERROR_UNKNOWNEXTRA,Arc.FileName,ArcFileName); LinkSuccess=false; } @@ -690,6 +846,7 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) Unp->Init(Arc.FileHead.WinSize,Arc.FileHead.Solid); Unp->SetDestSize(Arc.FileHead.UnpSize); #ifndef SFX_MODULE + // RAR 1.3 - 1.5 archives do not set per file solid flag. if (Arc.Format!=RARFMT50 && Arc.FileHead.UnpVer<=15) Unp->DoUnpack(15,FileCount>1 && Arc.Solid); else @@ -847,22 +1004,64 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize) } -bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize) +bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,const wchar *RedirName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize,int64 UnpSize) { - SlashToNative(NameExisting,NameExisting,NameExistingSize); // Not needed for RAR 5.1+ archives. - File Existing; - if (!Existing.WOpen(NameExisting)) + if (!Existing.Open(NameExisting)) { - uiMsg(UIERROR_FILECOPY,ArcName,NameExisting,NameNew); - uiMsg(UIERROR_FILECOPYHINT,ArcName); + bool OpenFailed=true; + // If we couldn't find the existing file, check if match is present + // in temporary reference sources list. + for (size_t I=0;IDllError=ERAR_EREFERENCE; + Cmd->DllError=ERAR_EREFERENCE; #endif - return false; + return false; + } } - Array Buffer(0x100000); + Array Buffer(0x100000); int64 CopySize=0; while (true) @@ -871,6 +1070,10 @@ bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar * int ReadSize=Existing.Read(&Buffer[0],Buffer.Size()); if (ReadSize==0) break; + // Update only the current file progress in WinRAR, set the total to 0 + // to keep it as is. It looks better for WinRAR. + uiExtractProgress(CopySize,UnpSize,0,0); + New.Write(&Buffer[0],ReadSize); CopySize+=ReadSize; } @@ -881,6 +1084,16 @@ bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar * void CmdExtract::ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize) { + if (Cmd->Test) + { + // Destination name conversion isn't needed for simple archive test. + // This check also allows to avoid issuing "Attempting to correct... + // Renaming..." messages in MakeNameCompatible() below for problematic + // names like aux.txt when testing an archive. + wcsncpyz(DestName,ArcFileName,DestSize); + return; + } + wcsncpyz(DestName,Cmd->ExtrPath,DestSize); if (*Cmd->ExtrPath!=0) @@ -888,6 +1101,8 @@ void CmdExtract::ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *De wchar LastChar=*PointToLastChar(Cmd->ExtrPath); // We need IsPathDiv check here to correctly handle Unix forward slash // in the end of destination path in Windows: rar x arc dest/ + // so we call IsPathDiv first instead of just calling AddEndSlash, + // which checks for only one type of path separator. // IsDriveDiv is needed for current drive dir: rar x arc d: if (!IsPathDiv(LastChar) && !IsDriveDiv(LastChar)) { @@ -919,19 +1134,13 @@ void CmdExtract::ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *De #endif #ifndef SFX_MODULE - size_t ArcPathLength=wcslen(Cmd->ArcPath); + wchar *ArcPath=*Cmd->ExclArcPath!=0 ? Cmd->ExclArcPath:Cmd->ArcPath; + size_t ArcPathLength=wcslen(ArcPath); if (ArcPathLength>0) { size_t NameLength=wcslen(ArcFileName); - - // Earlier we compared lengths only here, but then noticed a cosmetic bug - // in WinRAR. When extracting a file reference from subfolder with - // "Extract relative paths", so WinRAR sets ArcPath, if reference target - // is missing, error message removed ArcPath both from reference and target - // names. If target was stored in another folder, its name looked wrong. - if (NameLength>=ArcPathLength && - wcsnicompc(Cmd->ArcPath,ArcFileName,ArcPathLength)==0 && - (IsPathDiv(Cmd->ArcPath[ArcPathLength-1]) || + if (NameLength>=ArcPathLength && wcsnicompc(ArcPath,ArcFileName,ArcPathLength)==0 && + (IsPathDiv(ArcPath[ArcPathLength-1]) || IsPathDiv(ArcFileName[ArcPathLength]) || ArcFileName[ArcPathLength]==0)) { ArcFileName+=Min(ArcPathLength,NameLength); @@ -964,7 +1173,7 @@ void CmdExtract::ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *De // Must do after Cmd->ArcPath processing above, so file name and arc path // trailing spaces are in sync. if (!Cmd->AllowIncompatNames) - MakeNameCompatible(DestName); + MakeNameCompatible(DestName,DestSize); #endif wchar DiskLetter=toupperw(DestName[0]); @@ -1018,18 +1227,14 @@ bool CmdExtract::ExtrDllGetPassword() #ifndef RARDLL -bool CmdExtract::ExtrGetPassword(Archive &Arc,const wchar *ArcFileName) +bool CmdExtract::ExtrGetPassword(Archive &Arc,const wchar *ArcFileName,RarCheckPassword *CheckPwd) { if (!Cmd->Password.IsSet()) { - if (!uiGetPassword(UIPASSWORD_FILE,ArcFileName,&Cmd->Password)/* || !Cmd->Password.IsSet()*/) + if (!uiGetPassword(UIPASSWORD_FILE,ArcFileName,&Cmd->Password,CheckPwd)/* || !Cmd->Password.IsSet()*/) { // Suppress "test is ok" message if user cancelled the password prompt. -// 2019.03.23: If some archives are tested ok and prompt is cancelled for others, -// do we really need to suppress "test is ok"? Also if we set an empty password -// and "Use for all archives" in WinRAR Ctrl+P and skip some encrypted archives. -// We commented out this UIERROR_INCERRCOUNT for now. -// uiMsg(UIERROR_INCERRCOUNT); + uiMsg(UIERROR_INCERRCOUNT); return false; } Cmd->ManualPassword=true; @@ -1044,7 +1249,7 @@ bool CmdExtract::ExtrGetPassword(Archive &Arc,const wchar *ArcFileName) case -1: ErrHandler.Exit(RARX_USERBREAK); case 2: - if (!uiGetPassword(UIPASSWORD_FILE,ArcFileName,&Cmd->Password)) + if (!uiGetPassword(UIPASSWORD_FILE,ArcFileName,&Cmd->Password,CheckPwd)) return false; break; case 3: @@ -1120,6 +1325,8 @@ void CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName) DirExist=FileExist(DestFileName) && IsDir(GetFileAttr(DestFileName)); if (!DirExist) { + if (!Cmd->AbsoluteLinks && ConvertSymlinkPaths) + LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink); CreatePath(DestFileName,true,Cmd->DisableNames); MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); } @@ -1201,6 +1408,8 @@ bool CmdExtract::ExtrCreateFile(Archive &Arc,File &CurFile) MakeNameUsable(DestFileName,true); + if (!Cmd->AbsoluteLinks && ConvertSymlinkPaths) + LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink); CreatePath(DestFileName,true,Cmd->DisableNames); if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true)) { @@ -1247,31 +1456,59 @@ bool CmdExtract::CheckUnpVer(Archive &Arc,const wchar *ArcFileName) #ifndef SFX_MODULE -// To speed up solid volumes extraction, try to find a non-first start volume, -// which still allows to unpack all files. It is possible for independent -// solid volumes with solid statistics reset in the beginning. -bool CmdExtract::DetectStartVolume(const wchar *VolName,bool NewNumbering) +// Find non-matched reference sources in solid and non-solid archives. +// Detect the optimal start position for semi-solid archives +// and optimal start volume for independent solid volumes. +// +// Alternatively we could collect references while extracting an archive +// and perform the second extraction pass for references only. +// But it would be slower for solid archives than scaning headers +// in first pass and extracting everything in second, as implemented now. +// +void CmdExtract::AnalyzeArchive(const wchar *ArcName,bool Volume,bool NewNumbering) { + FreeAnalyzeData(); // If processing non-first archive in multiple archives set. + wchar *ArgName=Cmd->FileArgs.GetString(); Cmd->FileArgs.Rewind(); if (ArgName!=NULL && (wcscmp(ArgName,L"*")==0 || wcscmp(ArgName,L"*.*")==0)) - return false; // No need to check further for * and *.* masks. + return; // No need to check further for * and *.* masks. - wchar StartName[NM]; - *StartName=0; - // Start search from first volume if all volumes preceding current are available. wchar NextName[NM]; - GetFirstVolIfFullSet(VolName,NewNumbering,NextName,ASIZE(NextName)); + if (Volume) + GetFirstVolIfFullSet(ArcName,NewNumbering,NextName,ASIZE(NextName)); + else + wcsncpyz(NextName,ArcName,ASIZE(NextName)); + + bool MatchFound=false; + bool PrevMatched=false; + bool OpenNext=false; + + bool FirstVolume=true; + + // We shall set FirstFile once for all volumes and not for each volume. + // So we do not reuse the outdated Analyze->StartPos from previous volume + // if extracted file resides completely in the beginning of current one. + bool FirstFile=true; - bool Matched=false; - while (!Matched) + while (true) { Archive Arc(Cmd); - if (!Arc.Open(NextName) || !Arc.IsArchive(false) || !Arc.Volume) + if (!Arc.Open(NextName) || !Arc.IsArchive(false)) + { + if (OpenNext) + { + // If we couldn't open trailing volumes, we can't set early exit + // parameters. It is possible that some volume are on removable media + // and will be provided by user when extracting. + *Analyze->EndName=0; + Analyze->EndPos=0; + } break; + } - bool OpenNext=false; + OpenNext=false; while (Arc.ReadHeader()>0) { Wait(); @@ -1284,17 +1521,88 @@ bool CmdExtract::DetectStartVolume(const wchar *VolName,bool NewNumbering) } if (HeaderType==HEAD_FILE) { + if ((Arc.Format==RARFMT14 || Arc.Format==RARFMT15) && Arc.FileHead.UnpVer<=15) + { + // RAR versions earlier than 2.0 do not set per file solid flag. + // They have only the global archive solid flag, so we can't + // reliably analyze them here. + OpenNext=false; + break; + } + if (!Arc.FileHead.SplitBefore) { - if (!Arc.FileHead.Solid) // Can start extraction from here. - wcsncpyz(StartName,NextName,ASIZE(StartName)); + if (!MatchFound && !Arc.FileHead.Solid) // Can start extraction from here. + { + // We would gain nothing and unnecessarily complicate extraction + // if we set StartName for first volume or StartPos for first + // archived file. + if (!FirstVolume) + wcsncpyz(Analyze->StartName,NextName,ASIZE(Analyze->StartName)); + + // We shall set FirstFile once for all volumes for this code + // to work properly. Alternatively we could append + // "|| Analyze->StartPos!=0" to the condition, so we do not reuse + // the outdated Analyze->StartPos value from previous volume. + if (!FirstFile) + Analyze->StartPos=Arc.CurBlockPos; + } if (Cmd->IsProcessFile(Arc.FileHead,NULL,MATCH_WILDSUBPATH,0,NULL,0)!=0) { - Matched=true; // First matched file found, must stop further scan. - break; + MatchFound = true; + PrevMatched = true; + + // Reset the previously set early exit position, if any, because + // we found a new matched file. + Analyze->EndPos=0; + + // Matched file reference pointing at maybe non-matched source file. + // Even though we know RedirName, we can't check if source file + // is certainly non-matched, because it can be filtered out by + // date or attributes, which we do not know here. + if (Arc.FileHead.RedirType==FSREDIR_FILECOPY) + { + bool AlreadyAdded=false; + for (size_t I=0;IEndName,NextName,ASIZE(Analyze->EndName)); + Analyze->EndPos=Arc.CurBlockPos; + } + PrevMatched=false; } } + + FirstFile=false; if (Arc.FileHead.SplitAfter) { OpenNext=true; // Allow open next volume. @@ -1305,16 +1613,25 @@ bool CmdExtract::DetectStartVolume(const wchar *VolName,bool NewNumbering) } Arc.Close(); - if (!OpenNext) - break; + if (Volume && OpenNext) + { + NextVolumeName(NextName,ASIZE(NextName),!Arc.NewNumbering); + FirstVolume=false; - NextVolumeName(NextName,ASIZE(NextName),!Arc.NewNumbering); + // Needed for multivolume archives. Added in case some 'break' + // will quit early from loop above, so we do not set it in the loop. + // Now it can happen for hypothetical archive without file records + // and with HEAD_ENDARC record. + FirstFile=false; + } + else + break; } - bool NewStartFound=wcscmp(VolName,StartName)!=0; - if (NewStartFound) // Found a new volume to start extraction. - wcsncpyz(ArcName,StartName,ASIZE(ArcName)); - - return NewStartFound; + + // If file references are present, we can't reliably skip in semi-solid + // archives, because reference source can be present in skipped data. + if (RefList.Size()!=0) + memset(Analyze,0,sizeof(*Analyze)); } #endif diff --git a/deps/unrar/extract.hpp b/deps/unrar/extract.hpp index 159759b56..18396c5b9 100644 --- a/deps/unrar/extract.hpp +++ b/deps/unrar/extract.hpp @@ -6,13 +6,32 @@ enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT}; class CmdExtract { private: + struct ExtractRef + { + wchar *RefName; + wchar *TmpName; + uint64 RefCount; + }; + Array RefList; + + struct AnalyzeData + { + wchar StartName[NM]; + uint64 StartPos; + wchar EndName[NM]; + uint64 EndPos; + } *Analyze; + + bool ArcAnalyzed; + + void FreeAnalyzeData(); EXTRACT_ARC_CODE ExtractArchive(); - bool ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize); + bool ExtractFileCopy(File &New,wchar *ArcName,const wchar *RedirName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize,int64 UnpSize); void ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize); #ifdef RARDLL bool ExtrDllGetPassword(); #else - bool ExtrGetPassword(Archive &Arc,const wchar *ArcFileName); + bool ExtrGetPassword(Archive &Arc,const wchar *ArcFileName,RarCheckPassword *CheckPwd); #endif #if defined(_WIN_ALL) && !defined(SFX_MODULE) void ConvertDosPassword(Archive &Arc,SecPassword &DestPwd); @@ -21,7 +40,7 @@ class CmdExtract bool ExtrCreateFile(Archive &Arc,File &CurFile); bool CheckUnpVer(Archive &Arc,const wchar *ArcFileName); #ifndef SFX_MODULE - bool DetectStartVolume(const wchar *VolName,bool NewNumbering); + void AnalyzeArchive(const wchar *ArcName,bool Volume,bool NewNumbering); void GetFirstVolIfFullSet(const wchar *SrcName,bool NewNumbering,wchar *DestName,size_t DestSize); #endif @@ -52,6 +71,15 @@ class CmdExtract bool PrevProcessed; // If previous file was successfully extracted or tested. wchar DestFileName[NM]; bool PasswordCancelled; + + // In Windows it is set to true if at least one symlink with ".." + // in target was extracted. + bool ConvertSymlinkPaths; + + // Last path checked for symlinks. We use it to improve the performance, + // so we do not check recently checked folders again. + std::wstring LastCheckedSymlink; + #if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SILENT) bool Fat32,NotFat32; #endif diff --git a/deps/unrar/filcreat.cpp b/deps/unrar/filcreat.cpp index 620bee813..d58e4f6fe 100644 --- a/deps/unrar/filcreat.cpp +++ b/deps/unrar/filcreat.cpp @@ -1,9 +1,9 @@ #include "rar.hpp" // If NewFile==NULL, we delete created file after user confirmation. -// It is useful we we need to overwrite an existing folder or file, +// It is useful if we need to overwrite an existing folder or file, // but need user confirmation for that. -bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize, +bool FileCreate(CommandData *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize, bool *UserReject,int64 FileSize,RarTime *FileTime,bool WriteOnly) { if (UserReject!=NULL) @@ -44,7 +44,9 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize, } // Try to truncate the existing file first instead of delete, - // so we preserve existing file permissions such as NTFS permissions. + // so we preserve existing file permissions, such as NTFS permissions, + // also as "Compressed" attribute and hard links. In GUI version we avoid + // deleting an existing file for non-.rar archive formats as well. uint FileMode=WriteOnly ? FMF_WRITE|FMF_SHAREREAD:FMF_UPDATE|FMF_SHAREREAD; if (NewFile!=NULL && NewFile->Create(Name,FileMode)) return true; diff --git a/deps/unrar/filcreat.hpp b/deps/unrar/filcreat.hpp index 44f801d4e..456a4a4a1 100644 --- a/deps/unrar/filcreat.hpp +++ b/deps/unrar/filcreat.hpp @@ -1,7 +1,7 @@ #ifndef _RAR_FILECREATE_ #define _RAR_FILECREATE_ -bool FileCreate(RAROptions *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize, +bool FileCreate(CommandData *Cmd,File *NewFile,wchar *Name,size_t MaxNameSize, bool *UserReject,int64 FileSize=INT64NDF, RarTime *FileTime=NULL,bool WriteOnly=false); diff --git a/deps/unrar/file.cpp b/deps/unrar/file.cpp index 5a8099ec5..7bf60fd4e 100644 --- a/deps/unrar/file.cpp +++ b/deps/unrar/file.cpp @@ -7,6 +7,7 @@ File::File() NewFile=false; LastWrite=false; HandleType=FILE_HANDLENORMAL; + LineInput=false; SkipClose=false; ErrorType=FILE_SUCCESS; OpenShared=false; @@ -14,11 +15,11 @@ File::File() AllowExceptions=true; PreserveAtime=false; #ifdef _WIN_ALL - NoSequentialRead=false; CreateMode=FMF_UNDEFINED; #endif ReadErrorMode=FREM_ASK; TruncatedAfterReadError=false; + CurFilePos=0; } @@ -58,7 +59,7 @@ bool File::Open(const wchar *Name,uint Mode) uint ShareMode=(Mode & FMF_OPENEXCLUSIVE) ? 0 : FILE_SHARE_READ; if (OpenShared) ShareMode|=FILE_SHARE_WRITE; - uint Flags=NoSequentialRead ? 0:FILE_FLAG_SEQUENTIAL_SCAN; + uint Flags=FILE_FLAG_SEQUENTIAL_SCAN; FindData FD; if (PreserveAtime) Access|=FILE_WRITE_ATTRIBUTES; // Needed to preserve atime. @@ -379,10 +380,11 @@ int File::Read(void *Data,size_t Size) if (ReadErrorMode==FREM_IGNORE) FilePos=Tell(); - int ReadSize; + int TotalRead=0; while (true) { - ReadSize=DirectRead(Data,Size); + int ReadSize=DirectRead(Data,Size); + if (ReadSize==-1) { ErrorType=FILE_READERROR; @@ -396,6 +398,8 @@ int File::Read(void *Data,size_t Size) size_t SizeToRead=Min(Size-I,512); int ReadCode=DirectRead(Data,SizeToRead); ReadSize+=(ReadCode==-1) ? 512:ReadCode; + if (ReadSize!=-1) + TotalRead+=ReadSize; } } else @@ -415,9 +419,28 @@ int File::Read(void *Data,size_t Size) ErrHandler.ReadError(FileName); } } + TotalRead+=ReadSize; // If ReadSize is -1, TotalRead is also set to -1 here. + + if (HandleType==FILE_HANDLESTD && !LineInput && ReadSize>0 && (uint)ReadSize0) // Can be -1 for error and AllowExceptions disabled. + CurFilePos+=TotalRead; + return TotalRead; // It can return -1 only if AllowExceptions is disabled. } @@ -499,6 +522,36 @@ bool File::RawSeek(int64 Offset,int Method) { if (hFile==FILE_BAD_HANDLE) return true; + if (!IsSeekable()) // To extract archives from stdin with -si. + { + // We tried to dynamically allocate 32 KB buffer here, but it improved + // speed in Windows 10 by mere ~1.5%. + byte Buf[4096]; + if (Method==SEEK_CUR || Method==SEEK_SET && Offset>=CurFilePos) + { + uint64 SkipSize=Method==SEEK_CUR ? Offset:Offset-CurFilePos; + while (SkipSize>0) // Reading to emulate seek forward. + { + int ReadSize=Read(Buf,(size_t)Min(SkipSize,ASIZE(Buf))); + if (ReadSize<=0) + return false; + SkipSize-=ReadSize; + CurFilePos+=ReadSize; + } + return true; + } + // May need it in FileLength() in Archive::UnexpEndArcMsg() when unpacking + // RAR 4.x archives without the end of archive block created with -en. + if (Method==SEEK_END) + { + int ReadSize; + while ((ReadSize=Read(Buf,ASIZE(Buf)))>0) + CurFilePos+=ReadSize; + return true; + } + + return false; // Backward seek on unseekable file. + } if (Offset<0 && Method!=SEEK_SET) { Offset=(Method==SEEK_CUR ? Tell():FileLength())+Offset; @@ -533,6 +586,8 @@ int64 File::Tell() ErrHandler.SeekError(FileName); else return -1; + if (!IsSeekable()) + return CurFilePos; #ifdef _WIN_ALL LONG HighDist=0; uint LowDist=SetFilePointer(hFile,0,&HighDist,FILE_CURRENT); @@ -683,17 +738,40 @@ void File::SetCloseFileTimeByName(const wchar *Name,RarTime *ftm,RarTime *fta) } -void File::GetOpenFileTime(RarTime *ft) +#ifdef _UNIX +void File::StatToRarTime(struct stat &st,RarTime *ftm,RarTime *ftc,RarTime *fta) { -#ifdef _WIN_ALL - FILETIME FileTime; - GetFileTime(hFile,NULL,NULL,&FileTime); - ft->SetWinFT(&FileTime); +#ifdef UNIX_TIME_NS +#if defined(_APPLE) + if (ftm!=NULL) ftm->SetUnixNS(st.st_mtimespec.tv_sec*(uint64)1000000000+st.st_mtimespec.tv_nsec); + if (ftc!=NULL) ftc->SetUnixNS(st.st_ctimespec.tv_sec*(uint64)1000000000+st.st_ctimespec.tv_nsec); + if (fta!=NULL) fta->SetUnixNS(st.st_atimespec.tv_sec*(uint64)1000000000+st.st_atimespec.tv_nsec); +#else + if (ftm!=NULL) ftm->SetUnixNS(st.st_mtim.tv_sec*(uint64)1000000000+st.st_mtim.tv_nsec); + if (ftc!=NULL) ftc->SetUnixNS(st.st_ctim.tv_sec*(uint64)1000000000+st.st_ctim.tv_nsec); + if (fta!=NULL) fta->SetUnixNS(st.st_atim.tv_sec*(uint64)1000000000+st.st_atim.tv_nsec); +#endif +#else + if (ftm!=NULL) ftm->SetUnix(st.st_mtime); + if (ftc!=NULL) ftc->SetUnix(st.st_ctime); + if (fta!=NULL) fta->SetUnix(st.st_atime); #endif -#if defined(_UNIX) || defined(_EMX) +} +#endif + + +void File::GetOpenFileTime(RarTime *ftm,RarTime *ftc,RarTime *fta) +{ +#ifdef _WIN_ALL + FILETIME ctime,atime,mtime; + GetFileTime(hFile,&ctime,&atime,&mtime); + if (ftm!=NULL) ftm->SetWinFT(&mtime); + if (ftc!=NULL) ftc->SetWinFT(&ctime); + if (fta!=NULL) fta->SetWinFT(&atime); +#elif defined(_UNIX) struct stat st; fstat(GetFD(),&st); - ft->SetUnix(st.st_mtime); + StatToRarTime(st,ftm,ftc,fta); #endif } diff --git a/deps/unrar/file.hpp b/deps/unrar/file.hpp index 1c436d4ef..5f55de960 100644 --- a/deps/unrar/file.hpp +++ b/deps/unrar/file.hpp @@ -14,8 +14,6 @@ #define FILE_BAD_HANDLE NULL #endif -class RAROptions; - enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD}; enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR}; @@ -59,6 +57,16 @@ class File FileHandle hFile; bool LastWrite; FILE_HANDLETYPE HandleType; + + // If we read the user input in console prompts from stdin, we shall + // process the available line immediately, not waiting for rest of data. + // Otherwise apps piping user responses to multiple Ask() prompts can + // hang if no more data is available yet and pipe isn't closed. + // If we read RAR archive or other file data from stdin, we shall collect + // the entire requested block as long as pipe isn't closed, so we get + // complete archive headers, not split between different reads. + bool LineInput; + bool SkipClose; FILE_READ_ERROR_MODE ReadErrorMode; bool NewFile; @@ -70,12 +78,17 @@ class File #endif bool PreserveAtime; bool TruncatedAfterReadError; + + int64 CurFilePos; // Used for forward seeks in stdin files. protected: bool OpenShared; // Set by 'Archive' class. public: wchar FileName[NM]; FILE_ERRORTYPE ErrorType; + + byte *SeekBuf; // To read instead of seek for stdin files. + static const size_t SeekBufSize=0x10000; public: File(); virtual ~File(); @@ -106,11 +119,16 @@ class File void SetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL); void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL); static void SetCloseFileTimeByName(const wchar *Name,RarTime *ftm,RarTime *fta); - void GetOpenFileTime(RarTime *ft); +#ifdef _UNIX + static void StatToRarTime(struct stat &st,RarTime *ftm,RarTime *ftc,RarTime *fta); +#endif + void GetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL); virtual bool IsOpened() {return hFile!=FILE_BAD_HANDLE;} // 'virtual' for MultiFile class. int64 FileLength(); void SetHandleType(FILE_HANDLETYPE Type) {HandleType=Type;} + void SetLineInputMode(bool Mode) {LineInput=Mode;} FILE_HANDLETYPE GetHandleType() {return HandleType;} + bool IsSeekable() {return HandleType!=FILE_HANDLESTD;} bool IsDevice(); static bool RemoveCreated(); FileHandle GetHandle() {return hFile;} @@ -119,9 +137,6 @@ class File int64 Copy(File &Dest,int64 Length=INT64NDF); void SetAllowDelete(bool Allow) {AllowDelete=Allow;} void SetExceptions(bool Allow) {AllowExceptions=Allow;} -#ifdef _WIN_ALL - void RemoveSequentialFlag() {NoSequentialRead=true;} -#endif void SetPreserveAtime(bool Preserve) {PreserveAtime=Preserve;} bool IsTruncatedAfterReadError() {return TruncatedAfterReadError;} #ifdef _UNIX diff --git a/deps/unrar/filefn.cpp b/deps/unrar/filefn.cpp index bab7c7384..aaef305b8 100644 --- a/deps/unrar/filefn.cpp +++ b/deps/unrar/filefn.cpp @@ -320,7 +320,6 @@ bool SetFileAttr(const wchar *Name,uint Attr) } -#if 0 wchar *MkTemp(wchar *Name,size_t MaxSize) { size_t Length=wcslen(Name); @@ -354,7 +353,6 @@ wchar *MkTemp(wchar *Name,size_t MaxSize) } return Name; } -#endif #if !defined(SFX_MODULE) @@ -397,7 +395,11 @@ void CalcFileSum(File *SrcFile,uint *CRC32,byte *Blake2,uint Threads,int64 Size, { #ifndef SILENT if ((Flags & CALCFSUM_SHOWPROGRESS)!=0) - uiExtractProgress(TotalRead,FileLength,TotalRead,FileLength); + { + // Update only the current file progress in WinRAR, set the total to 0 + // to keep it as is. It looks better for WinRAR. + uiExtractProgress(TotalRead,FileLength,0,0); + } else { if ((Flags & CALCFSUM_SHOWPERCENT)!=0) @@ -517,6 +519,18 @@ bool SetFileCompression(const wchar *Name,bool State) CloseHandle(hFile); return RetCode!=0; } + + +void ResetFileCache(const wchar *Name) +{ + // To reset file cache in Windows it is enough to open it with + // FILE_FLAG_NO_BUFFERING and then close it. + HANDLE hSrc=CreateFile(Name,GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL,OPEN_EXISTING,FILE_FLAG_NO_BUFFERING,NULL); + if (hSrc!=INVALID_HANDLE_VALUE) + CloseHandle(hSrc); +} #endif diff --git a/deps/unrar/filefn.hpp b/deps/unrar/filefn.hpp index 78735fee9..53d86653f 100644 --- a/deps/unrar/filefn.hpp +++ b/deps/unrar/filefn.hpp @@ -27,9 +27,7 @@ bool IsDeleteAllowed(uint FileAttr); void PrepareToDelete(const wchar *Name); uint GetFileAttr(const wchar *Name); bool SetFileAttr(const wchar *Name,uint Attr); -#if 0 wchar* MkTemp(wchar *Name,size_t MaxSize); -#endif enum CALCFSUM_FLAGS {CALCFSUM_SHOWTEXT=1,CALCFSUM_SHOWPERCENT=2,CALCFSUM_SHOWPROGRESS=4,CALCFSUM_CURPOS=8}; @@ -41,6 +39,7 @@ bool DelDir(const wchar *Name); #if defined(_WIN_ALL) && !defined(SFX_MODULE) bool SetFileCompression(const wchar *Name,bool State); +void ResetFileCache(const wchar *Name); #endif diff --git a/deps/unrar/find.cpp b/deps/unrar/find.cpp index b22f82d8f..c9f2c5768 100644 --- a/deps/unrar/find.cpp +++ b/deps/unrar/find.cpp @@ -117,7 +117,7 @@ bool FindFile::FastFind(const wchar *FindMask,FindData *fd,bool GetSymLink) if (hFind==INVALID_HANDLE_VALUE) return false; FindClose(hFind); -#else +#elif defined(_UNIX) char FindMaskA[NM]; WideToChar(FindMask,FindMaskA,ASIZE(FindMaskA)); @@ -143,15 +143,7 @@ bool FindFile::FastFind(const wchar *FindMask,FindData *fd,bool GetSymLink) fd->FileAttr=st.st_mode; fd->Size=st.st_size; -#ifdef UNIX_TIME_NS - fd->mtime.SetUnixNS(st.st_mtim.tv_sec*(uint64)1000000000+st.st_mtim.tv_nsec); - fd->atime.SetUnixNS(st.st_atim.tv_sec*(uint64)1000000000+st.st_atim.tv_nsec); - fd->ctime.SetUnixNS(st.st_ctim.tv_sec*(uint64)1000000000+st.st_ctim.tv_nsec); -#else - fd->mtime.SetUnix(st.st_mtime); - fd->atime.SetUnix(st.st_atime); - fd->ctime.SetUnix(st.st_ctime); -#endif + File::StatToRarTime(st,&fd->mtime,&fd->ctime,&fd->atime); wcsncpyz(fd->Name,FindMask,ASIZE(fd->Name)); #endif diff --git a/deps/unrar/getbits.cpp b/deps/unrar/getbits.cpp index e4db2695f..8805f2787 100644 --- a/deps/unrar/getbits.cpp +++ b/deps/unrar/getbits.cpp @@ -5,7 +5,7 @@ BitInput::BitInput(bool AllocBuffer) ExternalBuffer=false; if (AllocBuffer) { - // getbits32 attempts to read data from InAddr, ... InAddr+3 positions. + // getbits*() attempt to read data from InAddr, ... InAddr+3 positions. // So let's allocate 3 additional bytes for situation, when we need to // read only 1 byte from the last position of buffer and avoid a crash // from access to next 3 bytes, which contents we do not need. diff --git a/deps/unrar/getbits.hpp b/deps/unrar/getbits.hpp index 7fbdfdf30..00acbea94 100644 --- a/deps/unrar/getbits.hpp +++ b/deps/unrar/getbits.hpp @@ -4,7 +4,7 @@ class BitInput { public: - enum BufferSize {MAX_SIZE=0x50000}; // Size of input buffer. + enum BufferSize {MAX_SIZE=0x8000}; // Size of input buffer. int InAddr; // Curent byte position in the buffer. int InBit; // Current bit position in the current byte. @@ -28,26 +28,38 @@ class BitInput InAddr+=Bits>>3; InBit=Bits&7; } - + // Return 16 bits from current position in the buffer. // Bit at (InAddr,InBit) has the highest position in returning data. uint getbits() { +#if defined(LITTLE_ENDIAN) && defined(ALLOW_MISALIGNED) + uint32 BitField=*(uint32*)(InBuf+InAddr); + BitField=ByteSwap32(BitField); + BitField >>= (16-InBit); +#else uint BitField=(uint)InBuf[InAddr] << 16; BitField|=(uint)InBuf[InAddr+1] << 8; BitField|=(uint)InBuf[InAddr+2]; BitField >>= (8-InBit); +#endif return BitField & 0xffff; } + // Return 32 bits from current position in the buffer. // Bit at (InAddr,InBit) has the highest position in returning data. uint getbits32() { +#if defined(LITTLE_ENDIAN) && defined(ALLOW_MISALIGNED) + uint32 BitField=*(uint32*)(InBuf+InAddr); + BitField=ByteSwap32(BitField); +#else uint BitField=(uint)InBuf[InAddr] << 24; BitField|=(uint)InBuf[InAddr+1] << 16; BitField|=(uint)InBuf[InAddr+2] << 8; BitField|=(uint)InBuf[InAddr+3]; +#endif BitField <<= InBit; BitField|=(uint)InBuf[InAddr+4] >> (8-InBit); return BitField & 0xffffffff; diff --git a/deps/unrar/global.cpp b/deps/unrar/global.cpp index 3975813a9..771f00016 100644 --- a/deps/unrar/global.cpp +++ b/deps/unrar/global.cpp @@ -1,6 +1,6 @@ #define INCLUDEGLOBAL -#if defined(__BORLANDC__) || defined(_MSC_VER) +#ifdef _MSC_VER #pragma hdrstop #endif diff --git a/deps/unrar/hardlinks.cpp b/deps/unrar/hardlinks.cpp index 40cc0aa49..171b5fa08 100644 --- a/deps/unrar/hardlinks.cpp +++ b/deps/unrar/hardlinks.cpp @@ -1,7 +1,5 @@ bool ExtractHardlink(CommandData *Cmd,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize) { - SlashToNative(NameExisting,NameExisting,NameExistingSize); // Not needed for RAR 5.1+ archives. - if (!FileExist(NameExisting)) { uiMsg(UIERROR_HLINKCREATE,NameNew); diff --git a/deps/unrar/hash.cpp b/deps/unrar/hash.cpp index a4559e05c..106cc6083 100644 --- a/deps/unrar/hash.cpp +++ b/deps/unrar/hash.cpp @@ -26,7 +26,7 @@ void HashValue::Init(HASH_TYPE Type) } -bool HashValue::operator == (const HashValue &cmp) +bool HashValue::operator == (const HashValue &cmp) const { if (Type==HASH_NONE || cmp.Type==HASH_NONE) return true; diff --git a/deps/unrar/hash.hpp b/deps/unrar/hash.hpp index b7d879f66..6315680e7 100644 --- a/deps/unrar/hash.hpp +++ b/deps/unrar/hash.hpp @@ -6,8 +6,14 @@ enum HASH_TYPE {HASH_NONE,HASH_RAR14,HASH_CRC32,HASH_BLAKE2}; struct HashValue { void Init(HASH_TYPE Type); - bool operator == (const HashValue &cmp); - bool operator != (const HashValue &cmp) {return !(*this==cmp);} + + // Use the const member, so types on both sides of "==" match. + // Otherwise clang -std=c++20 issues "ambiguity is between a regular call + // to this operator and a call with the argument order reversed" warning. + bool operator == (const HashValue &cmp) const; + + // Not actually used now. Const member for same reason as operator == above. + bool operator != (const HashValue &cmp) const {return !(*this==cmp);} HASH_TYPE Type; union diff --git a/deps/unrar/headers.cpp b/deps/unrar/headers.cpp index b042dc393..b441376c5 100644 --- a/deps/unrar/headers.cpp +++ b/deps/unrar/headers.cpp @@ -49,13 +49,5 @@ FileHeader& FileHeader::operator = (FileHeader &hd) void MainHeader::Reset() { - HighPosAV=0; - PosAV=0; - CommentInHeader=false; - PackComment=false; - Locator=false; - QOpenOffset=0; - QOpenMaxSize=0; - RROffset=0; - RRMaxSize=0; + *this={}; } diff --git a/deps/unrar/headers.hpp b/deps/unrar/headers.hpp index 6af453a9d..0941220f5 100644 --- a/deps/unrar/headers.hpp +++ b/deps/unrar/headers.hpp @@ -6,7 +6,7 @@ #define SIZEOF_MAINHEAD3 13 // Size of RAR 4.x main archive header. #define SIZEOF_FILEHEAD14 21 // Size of RAR 1.4 file header. #define SIZEOF_FILEHEAD3 32 // Size of RAR 3.0 file header. -#define SIZEOF_SHORTBLOCKHEAD 7 +#define SIZEOF_SHORTBLOCKHEAD 7 // Smallest RAR 4.x block size. #define SIZEOF_LONGBLOCKHEAD 11 #define SIZEOF_SUBBLOCKHEAD 14 #define SIZEOF_COMMHEAD 13 @@ -162,12 +162,16 @@ struct MainHeader:BaseBlock ushort HighPosAV; uint PosAV; bool CommentInHeader; - bool PackComment; // For RAR 1.4 archive format only. + bool PackComment; // For RAR 1.4 archive format only. bool Locator; - uint64 QOpenOffset; // Offset of quick list record. - uint64 QOpenMaxSize; // Maximum size of QOpen offset in locator extra field. - uint64 RROffset; // Offset of recovery record. - uint64 RRMaxSize; // Maximum size of RR offset in locator extra field. + uint64 QOpenOffset; // Offset of quick list record. + uint64 QOpenMaxSize; // Maximum size of QOpen offset in locator extra field. + uint64 RROffset; // Offset of recovery record. + uint64 RRMaxSize; // Maximum size of RR offset in locator extra field. + size_t MetaNameMaxSize; // Maximum size of archive name in metadata extra field. + std::wstring OrigName; // Original archive name. + RarTime OrigTime; // Original archive time. + void Reset(); }; @@ -230,7 +234,7 @@ struct FileHeader:BlockHeader bool LargeFile; // 'true' for HEAD_SERVICE block, which is a child of preceding file block. - // RAR 4.x uses 'solid' flag to indicate child subheader blocks in archives. + // RAR 4.x uses 'solid' flag to indicate children subheader blocks in archives. bool SubBlock; HOST_SYSTEM_TYPE HSType; diff --git a/deps/unrar/headers5.hpp b/deps/unrar/headers5.hpp index 9ea8d979a..50f5955d1 100644 --- a/deps/unrar/headers5.hpp +++ b/deps/unrar/headers5.hpp @@ -59,11 +59,18 @@ // Main header extra field values. #define MHEXTRA_LOCATOR 0x01 // Position of quick list and other blocks. +#define MHEXTRA_METADATA 0x02 // Archive metadata. // Flags for MHEXTRA_LOCATOR. #define MHEXTRA_LOCATOR_QLIST 0x01 // Quick open offset is present. #define MHEXTRA_LOCATOR_RR 0x02 // Recovery record offset is present. +// Flags for MHEXTRA_METADATA. +#define MHEXTRA_METADATA_NAME 0x01 // Archive name is present. +#define MHEXTRA_METADATA_CTIME 0x02 // Archive creation time is present. +#define MHEXTRA_METADATA_UNIXTIME 0x04 // Use Unix nanosecond time format. +#define MHEXTRA_METADATA_UNIX_NS 0x08 // Unix format with nanosecond precision. + // File and service header extra field values. #define FHEXTRA_CRYPT 0x01 // Encryption parameters. #define FHEXTRA_HASH 0x02 // File hash. diff --git a/deps/unrar/isnt.cpp b/deps/unrar/isnt.cpp index 6fadec049..31da8c158 100644 --- a/deps/unrar/isnt.cpp +++ b/deps/unrar/isnt.cpp @@ -13,6 +13,7 @@ DWORD WinNT() dwPlatformId=WinVer.dwPlatformId; dwMajorVersion=WinVer.dwMajorVersion; dwMinorVersion=WinVer.dwMinorVersion; + } DWORD Result=0; if (dwPlatformId==VER_PLATFORM_WIN32_NT) @@ -21,4 +22,102 @@ DWORD WinNT() return Result; } -#endif + + +// Replace it with documented Windows 11 check when available. +#include +#include +#pragma comment(lib, "wbemuuid.lib") + +static bool WMI_IsWindows10() +{ + IWbemLocator *pLoc = NULL; + + HRESULT hres = CoCreateInstance(CLSID_WbemLocator,0,CLSCTX_INPROC_SERVER, + IID_IWbemLocator,(LPVOID *)&pLoc); + + if (FAILED(hres)) + return false; + + IWbemServices *pSvc = NULL; + + BSTR bstr_root_cimv2 = SysAllocString(L"ROOT\\CIMV2"); + + hres = pLoc->ConnectServer(bstr_root_cimv2,NULL,NULL,NULL,0,0,0,&pSvc); + + if (FAILED(hres)) + { + pLoc->Release(); + return false; + } + + hres = CoSetProxyBlanket(pSvc,RPC_C_AUTHN_WINNT,RPC_C_AUTHZ_NONE,NULL, + RPC_C_AUTHN_LEVEL_CALL,RPC_C_IMP_LEVEL_IMPERSONATE,NULL,EOAC_NONE); + + if (FAILED(hres)) + { + pSvc->Release(); + pLoc->Release(); + return false; + } + + IEnumWbemClassObject *pEnumerator = NULL; + + BSTR bstr_wql = SysAllocString(L"WQL"); + BSTR bstr_sql = SysAllocString(L"SELECT * FROM Win32_OperatingSystem"); + + hres = pSvc->ExecQuery(bstr_wql, bstr_sql, + WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); + + if (FAILED(hres)) + { + pSvc->Release(); + pLoc->Release(); + return false; + } + + IWbemClassObject *pclsObj = NULL; + ULONG uReturn = 0; + + bool Win10=false; + while (pEnumerator!=NULL) + { + HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); + + if (uReturn==0) + break; + + VARIANT vtProp; + + hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0); + Win10|=wcsstr(vtProp.bstrVal,L"Windows 10")!=NULL; + VariantClear(&vtProp); + + pclsObj->Release(); + } + + pSvc->Release(); + pLoc->Release(); + pEnumerator->Release(); + + return Win10; +} + + +// Replace it with actual check when available. +bool IsWindows11OrGreater() +{ + static bool IsSet=false,IsWin11=false; + if (!IsSet) + { + OSVERSIONINFO WinVer; + WinVer.dwOSVersionInfoSize=sizeof(WinVer); + GetVersionEx(&WinVer); + IsWin11=WinVer.dwMajorVersion>10 || + WinVer.dwMajorVersion==10 && WinVer.dwBuildNumber >= 22000 && !WMI_IsWindows10(); + IsSet=true; + } + return IsWin11; +} + +#endif // _WIN_ALL diff --git a/deps/unrar/isnt.hpp b/deps/unrar/isnt.hpp index 85790da46..fed0b5173 100644 --- a/deps/unrar/isnt.hpp +++ b/deps/unrar/isnt.hpp @@ -10,4 +10,7 @@ enum WINNT_VERSION { DWORD WinNT(); +// Replace it with actual check when available. +bool IsWindows11OrGreater(); + #endif diff --git a/deps/unrar/list.cpp b/deps/unrar/list.cpp index 476fd3c65..e4444e13a 100644 --- a/deps/unrar/list.cpp +++ b/deps/unrar/list.cpp @@ -1,6 +1,6 @@ #include "rar.hpp" -static void ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bool Technical,bool Bare); +static void ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bool Technical,bool Bare,bool DisableNames); static void ListSymLink(Archive &Arc); static void ListFileAttr(uint A,HOST_SYSTEM_TYPE HostType,wchar *AttrStr,size_t AttrSize); static void ListOldSubHeader(Archive &Arc); @@ -22,9 +22,6 @@ void ListArchive(CommandData *Cmd) Cmd->Password.Clean(); // Clean user entered password before processing next archive. Archive Arc(Cmd); -#ifdef _WIN_ALL - Arc.RemoveSequentialFlag(); -#endif if (!Arc.WOpen(ArcName)) continue; bool FileMatched=true; @@ -39,6 +36,7 @@ void ListArchive(CommandData *Cmd) { Arc.ViewComment(); mprintf(L"\n%s: %s",St(MListArchive),Arc.FileName); + mprintf(L"\n%s: ",St(MListDetails)); uint SetCount=0; const wchar *Fmt=Arc.Format==RARFMT14 ? L"RAR 1.4":(Arc.Format==RARFMT15 ? L"RAR 4":L"RAR 5"); @@ -64,6 +62,16 @@ void ListArchive(CommandData *Cmd) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListLock)); if (Arc.Encrypted) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListEncHead)); + + if (!Arc.MainHead.OrigName.empty()) + mprintf(L"\n%s: %s",St(MOrigName),Arc.MainHead.OrigName.c_str()); + if (Arc.MainHead.OrigTime.IsSet()) + { + wchar DateStr[50]; + Arc.MainHead.OrigTime.GetText(DateStr,ASIZE(DateStr),Technical); + mprintf(L"\n%s: %s",St(MOriginalTime),DateStr); + } + mprintf(L"\n"); } @@ -95,7 +103,7 @@ void ListArchive(CommandData *Cmd) FileMatched=Cmd->IsProcessFile(Arc.FileHead,NULL,MATCH_WILDSUBPATH,0,NULL,0)!=0; if (FileMatched) { - ListFileHeader(Arc,Arc.FileHead,TitleShown,Verbose,Technical,Bare); + ListFileHeader(Arc,Arc.FileHead,TitleShown,Verbose,Technical,Bare,Cmd->DisableNames); if (!Arc.FileHead.SplitBefore) { TotalUnpSize+=Arc.FileHead.UnpSize; @@ -108,7 +116,7 @@ void ListArchive(CommandData *Cmd) if (FileMatched && !Bare) { if (Technical && ShowService) - ListFileHeader(Arc,Arc.SubHead,TitleShown,Verbose,true,false); + ListFileHeader(Arc,Arc.SubHead,TitleShown,Verbose,true,false,Cmd->DisableNames); } break; } @@ -188,31 +196,37 @@ enum LISTCOL_TYPE { }; -void ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bool Technical,bool Bare) +void ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bool Technical,bool Bare,bool DisableNames) { - wchar *Name=hd.FileName; - RARFORMAT Format=Arc.Format; - - if (Bare) - { - mprintf(L"%s\n",Name); - return; - } - - if (!TitleShown && !Technical) + if (!TitleShown && !Technical && !Bare) { if (Verbose) { mprintf(L"\n%ls",St(MListTitleV)); - mprintf(L"\n----------- --------- -------- ----- ---------- ----- -------- ----"); + if (!DisableNames) + mprintf(L"\n----------- --------- -------- ----- ---------- ----- -------- ----"); } else { mprintf(L"\n%ls",St(MListTitleL)); - mprintf(L"\n----------- --------- ---------- ----- ----"); + if (!DisableNames) + mprintf(L"\n----------- --------- ---------- ----- ----"); } + // Must be set even in DisableNames mode to suppress "0 files" output + // unless no files are matched. TitleShown=true; } + if (DisableNames) + return; + + wchar *Name=hd.FileName; + RARFORMAT Format=Arc.Format; + + if (Bare) + { + mprintf(L"%s\n",Name); + return; + } wchar UnpSizeText[30],PackSizeText[30]; if (hd.UnpSize==INT64NDF) @@ -304,17 +318,21 @@ void ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bo mprintf(L"\n%12ls: %ls",St(MListPacked),PackSizeText); mprintf(L"\n%12ls: %ls",St(MListRatio),RatioStr); } + bool WinTitles=false; +#ifdef _WIN_ALL + WinTitles=true; +#endif if (hd.mtime.IsSet()) - mprintf(L"\n%12ls: %ls",St(MListMtime),DateStr); + mprintf(L"\n%12ls: %ls",St(WinTitles ? MListModified:MListMtime),DateStr); if (hd.ctime.IsSet()) { hd.ctime.GetText(DateStr,ASIZE(DateStr),true); - mprintf(L"\n%12ls: %ls",St(MListCtime),DateStr); + mprintf(L"\n%12ls: %ls",St(WinTitles ? MListCreated:MListCtime),DateStr); } if (hd.atime.IsSet()) { hd.atime.GetText(DateStr,ASIZE(DateStr),true); - mprintf(L"\n%12ls: %ls",St(MListAtime),DateStr); + mprintf(L"\n%12ls: %ls",St(WinTitles ? MListAccessed:MListAtime),DateStr); } mprintf(L"\n%12ls: %ls",St(MListAttr),AttrStr); if (hd.FileHash.Type==HASH_CRC32) @@ -370,15 +388,16 @@ void ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bo { mprintf(L"\n%12ls: ",L"Unix owner"); if (*hd.UnixOwnerName!=0) - mprintf(L"%ls:",GetWide(hd.UnixOwnerName)); + mprintf(L"%ls",GetWide(hd.UnixOwnerName)); + else + if (hd.UnixOwnerNumeric) + mprintf(L"#%d",hd.UnixOwnerID); + mprintf(L":"); if (*hd.UnixGroupName!=0) mprintf(L"%ls",GetWide(hd.UnixGroupName)); - if ((*hd.UnixOwnerName!=0 || *hd.UnixGroupName!=0) && (hd.UnixOwnerNumeric || hd.UnixGroupNumeric)) - mprintf(L" "); - if (hd.UnixOwnerNumeric) - mprintf(L"#%d:",hd.UnixOwnerID); - if (hd.UnixGroupNumeric) - mprintf(L"#%d:",hd.UnixGroupID); + else + if (hd.UnixGroupNumeric) + mprintf(L"#%d",hd.UnixGroupID); } mprintf(L"\n"); diff --git a/deps/unrar/loclang.hpp b/deps/unrar/loclang.hpp index a1cd544a3..8c7c08814 100644 --- a/deps/unrar/loclang.hpp +++ b/deps/unrar/loclang.hpp @@ -28,6 +28,7 @@ #define MRARTitle1 L"\nUsage: rar - - " #define MUNRARTitle1 L"\nUsage: unrar - - " #define MRARTitle2 L"\n <@listfiles...> " +#define MFwrSlTitle2 L"\n <@listfiles...> " #define MCHelpCmd L"\n\n" #define MCHelpCmdA L"\n a Add files to archive" #define MCHelpCmdC L"\n c Add archive comment" @@ -58,6 +59,7 @@ #define MCHelpSwAD L"\n ad[1,2] Alternate destination path" #define MCHelpSwAG L"\n ag[format] Generate archive name using the current date" #define MCHelpSwAI L"\n ai Ignore file attributes" +#define MCHelpSwAM L"\n am[s,r] Archive name and time [save, restore]" #define MCHelpSwAO L"\n ao Add files with Archive attribute set" #define MCHelpSwAP L"\n ap Set path inside archive" #define MCHelpSwAS L"\n as Synchronize archive contents" @@ -72,11 +74,11 @@ #define MCHelpSwDW L"\n dw Wipe files after archiving" #define MCHelpSwEa L"\n e[+] Set file exclude and include attributes" #define MCHelpSwED L"\n ed Do not add empty directories" -#define MCHelpSwEN L"\n en Do not put 'end of archive' block" #define MCHelpSwEP L"\n ep Exclude paths from names" #define MCHelpSwEP1 L"\n ep1 Exclude base directory from names" #define MCHelpSwEP2 L"\n ep2 Expand paths to full" #define MCHelpSwEP3 L"\n ep3 Expand paths to full including the drive letter" +#define MCHelpSwEP4 L"\n ep4 Exclude the path prefix from names" #define MCHelpSwF L"\n f Freshen files" #define MCHelpSwHP L"\n hp[password] Encrypt both file data and headers" #define MCHelpSwHT L"\n ht[b|c] Select hash type [BLAKE2,CRC32] for file checksum" @@ -95,6 +97,7 @@ #define MCHelpSwMA L"\n ma[4|5] Specify a version of archiving format" #define MCHelpSwMC L"\n mc Set advanced compression parameters" #define MCHelpSwMD L"\n md[k,m,g] Dictionary size in KB, MB or GB" +#define MCHelpSwME L"\n me[par] Set encryption parameters" #define MCHelpSwMS L"\n ms[ext;ext] Specify file types to store" #define MCHelpSwMT L"\n mt Set the number of threads" #define MCHelpSwN L"\n n Additionally filter included files" @@ -106,11 +109,11 @@ #define MCHelpSwOI L"\n oi[0-4][:min] Save identical files as references" #define MCHelpSwOL L"\n ol[a] Process symbolic links as the link [absolute paths]" #define MCHelpSwONI L"\n oni Allow potentially incompatible names" +#define MCHelpSwOP L"\n op Set the output path for extracted files" #define MCHelpSwOR L"\n or Rename files automatically" #define MCHelpSwOS L"\n os Save NTFS streams" #define MCHelpSwOW L"\n ow Save or restore file owner and group" #define MCHelpSwP L"\n p[password] Set password" -#define MCHelpSwPm L"\n p- Do not query password" #define MCHelpSwQO L"\n qo[-|+] Add quick open information [none|force]" #define MCHelpSwR L"\n r Recurse subdirectories" #define MCHelpSwRm L"\n r- Disable recursion" @@ -272,6 +275,9 @@ #define MListMtime L"mtime" #define MListCtime L"ctime" #define MListAtime L"atime" +#define MListModified L"Modified" +#define MListCreated L"Created" +#define MListAccessed L"Accessed" #define MListAttr L"Attributes" #define MListFlags L"Flags" #define MListCompInfo L"Compression" @@ -385,3 +391,11 @@ #define MErrReadTrunc L"\n%s is archived incompletely because of read error.\n" #define MErrReadCount L"\n%u files are archived incompletely because of read errors." #define MDirNameExists L"\nDirectory with such name already exists" +#define MStdinNoInput L"\nKeyboard input is not allowed when reading data from stdin" +#define MTruncPsw L"\nPassword exceeds the maximum allowed length of %u characters and will be truncated." +#define MAdjustValue L"\nAdjusting %s value to %s." +#define MOpFailed L"\nOperation failed" +#define MSkipEncArc L"\nSkipping the encrypted archive %s" +#define MOrigName L"Original name" +#define MOriginalTime L"Original time" +#define MFileRenamed L"\n%s is renamed to %s" diff --git a/deps/unrar/makefile b/deps/unrar/makefile index 214f87ef3..55af49bef 100644 --- a/deps/unrar/makefile +++ b/deps/unrar/makefile @@ -123,10 +123,10 @@ UNRAR_OBJ=filestr.o recvol.o rs.o scantree.o qopen.o LIB_OBJ=filestr.o scantree.o dll.o qopen.o OBJECTS=rar.o strlist.o strfn.o pathfn.o smallfn.o global.o file.o filefn.o filcreat.o \ - archive.o arcread.o unicode.o system.o isnt.o crypt.o crc.o rawread.o encname.o \ + archive.o arcread.o unicode.o system.o crypt.o crc.o rawread.o encname.o \ resource.o match.o timefn.o rdwrfn.o consio.o options.o errhnd.o rarvm.o secpassword.o \ rijndael.o getbits.o sha1.o sha256.o blake2s.o hash.o extinfo.o extract.o volume.o \ - list.o find.o unpack.o headers.o threadpool.o rs16.o cmddata.o ui.o + list.o find.o unpack.o headers.o threadpool.o rs16.o cmddata.o ui.o .cpp.o: $(COMPILE) -D$(WHAT) -c $< @@ -142,20 +142,23 @@ clean: @rm -f $(OBJECTS) $(UNRAR_OBJ) $(LIB_OBJ) @rm -f unrar libunrar.* -unrar: clean $(OBJECTS) $(UNRAR_OBJ) +# We removed 'clean' from dependencies, because it prevented parallel +# 'make -Jn' builds. + +unrar: $(OBJECTS) $(UNRAR_OBJ) @rm -f unrar $(LINK) -o unrar $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS) $(STRIP) unrar sfx: WHAT=SFX_MODULE -sfx: clean $(OBJECTS) +sfx: $(OBJECTS) @rm -f default.sfx $(LINK) -o default.sfx $(LDFLAGS) $(OBJECTS) $(STRIP) default.sfx lib: WHAT=RARDLL lib: CXXFLAGS+=$(LIBFLAGS) -lib: clean $(OBJECTS) $(LIB_OBJ) +lib: $(OBJECTS) $(LIB_OBJ) @rm -f libunrar.* $(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ) $(AR) rcs libunrar.a $(OBJECTS) $(LIB_OBJ) diff --git a/deps/unrar/model.cpp b/deps/unrar/model.cpp index 3aa29b245..e4f9e3c53 100644 --- a/deps/unrar/model.cpp +++ b/deps/unrar/model.cpp @@ -532,13 +532,15 @@ inline bool RARPPM_CONTEXT::decodeSymbol2(ModelPPM *Model) Model->Coder.SubRange.LowCount=HiCnt; Model->Coder.SubRange.HighCount=Model->Coder.SubRange.scale; i=NumStats-Model->NumMasked; - pps--; + + // 2022.12.02: we removed pps-- here and changed the code below to avoid + // "array subscript -1 is outside array bounds" warning in some compilers. do { - pps++; if (pps>=ps+ASIZE(ps)) // Extra safety check. return false; Model->CharMask[(*pps)->Symbol]=Model->EscCount; + pps++; } while ( --i ); psee2c->Summ += Model->Coder.SubRange.scale; Model->NumMasked = NumStats; @@ -566,17 +568,14 @@ void ModelPPM::CleanUp() } -bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar,byte *hcppm) +bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar) { int MaxOrder=UnpackRead->GetChar(); bool Reset=(MaxOrder & 0x20)!=0; int MaxMB; if (Reset) - { MaxMB=UnpackRead->GetChar(); - if (MaxMB>128) return(false); - } else if (SubAlloc.GetAllocatedMemory()==0) return(false); @@ -593,7 +592,6 @@ bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar,byte *hcppm) SubAlloc.StopSubAllocator(); return(false); } - SubAlloc.SetHeapStartFixed(hcppm); SubAlloc.StartSubAllocator(MaxMB+1); StartModelRare(MaxOrder); } diff --git a/deps/unrar/model.hpp b/deps/unrar/model.hpp index c7444de33..52abc89b3 100644 --- a/deps/unrar/model.hpp +++ b/deps/unrar/model.hpp @@ -115,7 +115,7 @@ class ModelPPM : RARPPM_DEF public: ModelPPM(); void CleanUp(); // reset PPM variables after data error - bool DecodeInit(Unpack *UnpackRead,int &EscChar,byte *hcppm); + bool DecodeInit(Unpack *UnpackRead,int &EscChar); int DecodeChar(); }; diff --git a/deps/unrar/options.cpp b/deps/unrar/options.cpp index 40323be82..22ae27ce2 100644 --- a/deps/unrar/options.cpp +++ b/deps/unrar/options.cpp @@ -6,14 +6,6 @@ RAROptions::RAROptions() } -RAROptions::~RAROptions() -{ - // It is important for security reasons, so we do not have the unnecessary - // password data left in memory. - memset(this,0,sizeof(RAROptions)); -} - - void RAROptions::Init() { memset(this,0,sizeof(RAROptions)); diff --git a/deps/unrar/options.hpp b/deps/unrar/options.hpp index 993b21963..e249eb599 100644 --- a/deps/unrar/options.hpp +++ b/deps/unrar/options.hpp @@ -45,6 +45,12 @@ enum OVERWRITE_MODE OVERWRITE_FORCE_ASK }; +enum ARC_METADATA +{ + ARCMETA_NONE=0, + ARCMETA_SAVE, // -ams + ARCMETA_RESTORE // -amr +}; enum QOPEN_MODE { QOPEN_NONE, QOPEN_AUTO, QOPEN_ALWAYS }; @@ -84,11 +90,12 @@ struct FilterMode #define MAX_GENERATE_MASK 128 +// Here we store simple data types, which we can clear and move all together +// quickly. Rest of data types goes to CommandData. class RAROptions { public: RAROptions(); - ~RAROptions(); void Init(); uint ExclFileAttr; @@ -116,9 +123,10 @@ class RAROptions RAR_CHARSET ErrlogCharset; RAR_CHARSET RedirectCharset; - wchar ArcPath[NM]; - SecPassword Password; + wchar ArcPath[NM]; // For -ap. + wchar ExclArcPath[NM]; // For -ep4 switch. bool EncryptHeaders; + bool SkipEncrypted; bool ManualPassword; // Password entered manually during operation, might need to clean for next archive. @@ -130,6 +138,7 @@ class RAROptions HASH_TYPE HashType; int Recovery; int RecVolNumber; + ARC_METADATA ArcMetadata; bool DisablePercentage; bool DisableCopyright; bool DisableDone; @@ -145,7 +154,6 @@ class RAROptions PATH_EXCL_MODE ExclPath; RECURSE_MODE Recurse; int64 VolSize; - Array NextVolSizes; uint CurVolNum; bool AllYes; bool VerboseOutput; // -iv, display verbose output, used only in "WinRAR t" now. @@ -195,7 +203,11 @@ class RAROptions EXTTIME_MODE xctime; EXTTIME_MODE xatime; bool PreserveAtime; - wchar CompressStdin[NM]; + + // Read data from stdin and store in archive under a name specified here + // when archiving. Read an archive from stdin if any non-empty string + // is specified here when extracting. + wchar UseStdin[NM]; uint Threads; // We use it to init hash even if RAR_SMP is not defined. diff --git a/deps/unrar/os.hpp b/deps/unrar/os.hpp index dadec759a..8b2cdc42d 100644 --- a/deps/unrar/os.hpp +++ b/deps/unrar/os.hpp @@ -13,6 +13,8 @@ #endif #include +#include +#include #if defined(_WIN_ALL) || defined(_EMX) @@ -36,12 +38,23 @@ // re-definition warnings in third party projects. #ifndef UNICODE #define UNICODE +#define _UNICODE // Set _T() macro to convert from narrow to wide strings. #endif -#undef WINVER + +#ifdef _WIN32_WINNT #undef _WIN32_WINNT -#define WINVER 0x0501 -#define _WIN32_WINNT 0x0501 +#endif + +#if 0 +// 2021.09.05: Allow newer Vista+ APIs like IFileOpenDialog for WinRAR, +// but still keep SFX modules XP compatible. +#define WINVER _WIN32_WINNT_VISTA +#define _WIN32_WINNT _WIN32_WINNT_VISTA +#else +#define WINVER _WIN32_WINNT_WINXP +#define _WIN32_WINNT _WIN32_WINNT_WINXP +#endif #if !defined(ZIPSFX) #define RAR_SMP @@ -73,14 +86,14 @@ #include #endif #ifdef _MSC_VER - #if _MSC_VER<1500 - #define for if (0) ; else for - #endif #include #include - #define USE_SSE - #define SSE_ALIGNMENT 16 + // Use SSE only for x86/x64, not ARM Windows. + #if defined(_M_IX86) || defined(_M_X64) + #define USE_SSE + #define SSE_ALIGNMENT 16 + #endif #else #include #endif // _MSC_VER @@ -96,7 +109,6 @@ #include #include - #define SAVE_LINKS #define ENABLE_ACCESS @@ -212,7 +224,8 @@ #endif #endif -#if _POSIX_C_SOURCE >= 200809L +// Unlike Apple x64, utimensat shall be available in all Apple M1 systems. +#if _POSIX_C_SOURCE >= 200809L || defined(__APPLE__) && defined(__arm64__) #define UNIX_TIME_NS // Nanosecond time precision in Unix. #endif diff --git a/deps/unrar/pathfn.cpp b/deps/unrar/pathfn.cpp index 41594bf95..50b6b29da 100644 --- a/deps/unrar/pathfn.cpp +++ b/deps/unrar/pathfn.cpp @@ -5,7 +5,7 @@ wchar* PointToName(const wchar *Path) for (int I=(int)wcslen(Path)-1;I>=0;I--) if (IsPathDiv(Path[I])) return (wchar*)&Path[I+1]; - return (wchar*)((*Path && IsDriveDiv(Path[1])) ? Path+2:Path); + return (wchar*)((*Path!=0 && IsDriveDiv(Path[1])) ? Path+2:Path); } @@ -31,11 +31,17 @@ wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath,size_t DestSize) const wchar *s=DestPtr; if (s[0]!=0 && IsDriveDiv(s[1])) s+=2; - if (s[0]=='\\' && s[1]=='\\') + + // Skip UNC Windows \\server\share\ or Unix //server/share/ + if (IsPathDiv(s[0]) && IsPathDiv(s[1])) { - const wchar *Slash=wcschr(s+2,'\\'); - if (Slash!=NULL && (Slash=wcschr(Slash+1,'\\'))!=NULL) - s=Slash+1; + uint SlashCount=0; + for (const wchar *t=s+2;*t!=0;t++) + if (IsPathDiv(*t) && ++SlashCount==2) + { + s=t+1; // Found two more path separators after leading two. + break; + } } for (const wchar *t=s;*t!=0;t++) if (IsPathDiv(*t)) @@ -184,7 +190,9 @@ void MakeName(const wchar *Path,const wchar *Name,wchar *Pathname,size_t MaxSize // the temporary buffer instead of constructing the name in 'Pathname'. wchar OutName[NM]; wcsncpyz(OutName,Path,ASIZE(OutName)); - AddEndSlash(OutName,ASIZE(OutName)); + // Do not add slash to d:, we want to allow relative paths like d:filename. + if (!IsDriveLetter(Path) || Path[2]!=0) + AddEndSlash(OutName,ASIZE(OutName)); wcsncatz(OutName,Name,ASIZE(OutName)); wcsncpyz(Pathname,OutName,MaxSize); } @@ -317,6 +325,9 @@ void GetConfigName(const wchar *Name,wchar *FullName,size_t MaxSize,bool CheckEx // of file name if numeric part is missing. wchar* GetVolNumPart(const wchar *ArcName) { + // We do not want to increment any characters in path component. + ArcName=PointToName(ArcName); + if (*ArcName==0) return (wchar *)ArcName; @@ -340,7 +351,7 @@ wchar* GetVolNumPart(const wchar *ArcName) { // Validate the first numeric part only if it has a dot somewhere // before it. - wchar *Dot=wcschr(PointToName(ArcName),'.'); + const wchar *Dot=wcschr(ArcName,'.'); if (Dot!=NULL && Dot|\"")==NULL; } -void MakeNameUsable(char *Name,bool Extended) -{ -#ifdef _WIN_ALL - // In Windows we also need to convert characters not defined in current - // code page. This double conversion changes them to '?', which is - // catched by code below. - size_t NameLength=strlen(Name); - wchar NameW[NM]; - CharToWide(Name,NameW,ASIZE(NameW)); - WideToChar(NameW,Name,NameLength+1); - Name[NameLength]=0; -#endif - for (char *s=Name;*s!=0;s=charnext(s)) - { - if (strchr(Extended ? "?*<>|\"":"?*",*s)!=NULL || Extended && (byte)*s<32) - *s='_'; -#ifdef _EMX - if (*s=='=') - *s='_'; -#endif -#ifndef _UNIX - if (s-Name>1 && *s==':') - *s='_'; - // Remove ' ' and '.' before path separator, but allow .\ and ..\. - if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1])) - *s='_'; -#endif - } -} void MakeNameUsable(wchar *Name,bool Extended) @@ -469,7 +469,27 @@ void MakeNameUsable(wchar *Name,bool Extended) { if (wcschr(Extended ? L"?*<>|\"":L"?*",*s)!=NULL || Extended && (uint)*s<32) *s='_'; -#ifndef _UNIX +#ifdef _UNIX + // We were asked to apply Windows-like conversion in Linux in case + // files are unpacked to Windows share. This code is invoked only + // if file failed to be created, so it doesn't affect extraction + // of Unix compatible names to native Unix drives. + if (Extended) + { + // Windows shares in Unix do not allow the drive letter, + // so unlike Windows version, we check all characters here. + if (*s==':') + *s='_'; + + // No spaces or dots before the path separator are allowed on Windows + // shares. But they are allowed and automtically removed at the end of + // file or folder name, so it is useless to replace them here. + // Since such files or folders are created successfully, a supposed + // conversion here would never be invoked. + if ((*s==' ' || *s=='.') && IsPathDiv(s[1])) + *s='_'; + } +#else if (s-Name>1 && *s==':') *s='_'; #if 0 // We already can create such files. @@ -692,7 +712,8 @@ static void GenArcName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,u wchar Mask[MAX_GENERATE_MASK]; wcsncpyz(Mask,*GenerateMask!=0 ? GenerateMask:L"yyyymmddhhmmss",ASIZE(Mask)); - bool QuoteMode=false,Hours=false; + bool QuoteMode=false; + uint MAsMinutes=0; // By default we treat 'M' as months. for (uint I=0;Mask[I]!=0;I++) { if (Mask[I]=='{' || Mask[I]=='}') @@ -704,13 +725,16 @@ static void GenArcName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,u continue; int CurChar=toupperw(Mask[I]); if (CurChar=='H') - Hours=true; + MAsMinutes=2; // Treat next two 'M' after 'H' as minutes. + if (CurChar=='D' || CurChar=='Y') + MAsMinutes=0; // Treat 'M' in HHDDMMYY and HHYYMMDD as month. - if (Hours && CurChar=='M') + if (MAsMinutes>0 && CurChar=='M') { // Replace minutes with 'I'. We use 'M' both for months and minutes, - // so we treat as minutes only those 'M' which are found after hours. + // so we treat as minutes only those 'M', which are found after hours. Mask[I]='I'; + MAsMinutes--; } if (CurChar=='N') { @@ -774,7 +798,9 @@ static void GenArcName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,u const wchar *MaskChars=L"YMDHISWAEN"; + // How many times every modifier character was encountered in the mask. int CField[sizeof(Field)/sizeof(Field[0])]; + memset(CField,0,sizeof(CField)); QuoteMode=false; for (uint I=0;Mask[I]!=0;I++) @@ -816,13 +842,22 @@ static void GenArcName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,u { size_t FieldPos=ChPtr-MaskChars; int CharPos=(int)strlen(Field[FieldPos])-CField[FieldPos]--; - if (FieldPos==1 && toupperw(Mask[I+1])=='M' && toupperw(Mask[I+2])=='M') + + // CField[FieldPos] shall have exactly 3 "MMM" symbols, so we do not + // repeat the month name in case "MMMMMMMM" mask. But since we + // decremented CField[FieldPos] above, we compared it with 2. + if (FieldPos==1 && CField[FieldPos]==2 && + toupperw(Mask[I+1])=='M' && toupperw(Mask[I+2])=='M') { wcsncpyz(DateText+J,GetMonthName(rlt.Month-1),ASIZE(DateText)-J); J=wcslen(DateText); I+=2; continue; } + // If CharPos is negative, we have more modifier characters than + // matching time data. We prefer to issue a modifier character + // instead of repeating time data from beginning, so user can notice + // excessive modifiers added by mistake. if (CharPos<0) DateText[J]=Mask[I]; else @@ -985,9 +1020,9 @@ void ConvertToPrecomposed(wchar *Name,size_t NameSize) } -// Remove trailing spaces and dots in file name and in dir names in path. -void MakeNameCompatible(wchar *Name) +void MakeNameCompatible(wchar *Name,size_t MaxSize) { + // Remove trailing spaces and dots in file name and in dir names in path. int Src=0,Dest=0; while (true) { @@ -1005,5 +1040,47 @@ void MakeNameCompatible(wchar *Name) Src++; Dest++; } + + // Rename reserved device names, such as aux.txt to _aux.txt. + // We check them in path components too, where they are also prohibited. + for (uint I=0;Name[I]!=0;I++) + if (I==0 || I>0 && IsPathDiv(Name[I-1])) + { + static const wchar *Devices[]={L"CON",L"PRN",L"AUX",L"NUL",L"COM#",L"LPT#"}; + wchar *s=Name+I; + bool MatchFound=false; + for (uint J=0;JI+1) // I+1, because we do not move the trailing 0. + memmove(s+1,s,(MaxSize-I-1)*sizeof(*s)); + *s='_'; +#ifndef SFX_MODULE + uiMsg(UIMSG_CORRECTINGNAME,nullptr); + uiMsg(UIERROR_RENAMING,nullptr,OrigName,Name); +#endif + } + } } #endif + + diff --git a/deps/unrar/pathfn.hpp b/deps/unrar/pathfn.hpp index 63813d8a4..62cae0ad2 100644 --- a/deps/unrar/pathfn.hpp +++ b/deps/unrar/pathfn.hpp @@ -29,7 +29,6 @@ void GetConfigName(const wchar *Name,wchar *FullName,size_t MaxSize,bool CheckEx wchar* GetVolNumPart(const wchar *ArcName); void NextVolumeName(wchar *ArcName,uint MaxLength,bool OldNumbering); bool IsNameUsable(const wchar *Name); -void MakeNameUsable(char *Name,bool Extended); void MakeNameUsable(wchar *Name,bool Extended); void UnixSlashToDos(const char *SrcName,char *DestName,size_t MaxLength); @@ -70,7 +69,8 @@ void GenerateArchiveName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask #ifdef _WIN_ALL bool GetWinLongPath(const wchar *Src,wchar *Dest,size_t MaxSize); void ConvertToPrecomposed(wchar *Name,size_t NameSize); -void MakeNameCompatible(wchar *Name); +void MakeNameCompatible(wchar *Name,size_t MaxSize); #endif + #endif diff --git a/deps/unrar/qopen.cpp b/deps/unrar/qopen.cpp index 43346b061..d906d06bd 100644 --- a/deps/unrar/qopen.cpp +++ b/deps/unrar/qopen.cpp @@ -97,7 +97,7 @@ void QuickOpen::Load(uint64 BlockPos) if (Arc->SubHead.Encrypted) { - RAROptions *Cmd=Arc->GetRAROptions(); + CommandData *Cmd=Arc->GetCommandData(); #ifndef RAR_NOCRYPT if (Cmd->Password.IsSet()) Crypt.SetCryptKeys(false,CRYPT_RAR50,&Cmd->Password,Arc->SubHead.Salt, diff --git a/deps/unrar/rar.hpp b/deps/unrar/rar.hpp index 3f7414c87..67edb6735 100644 --- a/deps/unrar/rar.hpp +++ b/deps/unrar/rar.hpp @@ -12,10 +12,12 @@ #include "version.hpp" #include "rardefs.hpp" #include "rarlang.hpp" +#include "rawint.hpp" #include "unicode.hpp" #include "errhnd.hpp" #include "secpassword.hpp" #include "array.hpp" +#include "strlist.hpp" #include "timefn.hpp" #include "sha1.hpp" #include "sha256.hpp" @@ -28,13 +30,11 @@ #include "headers.hpp" #include "pathfn.hpp" #include "strfn.hpp" -#include "strlist.hpp" #ifdef _WIN_ALL #include "isnt.hpp" #endif #include "file.hpp" #include "crc.hpp" -#include "ui.hpp" #include "filefn.hpp" #include "filestr.hpp" #include "find.hpp" @@ -47,11 +47,11 @@ #include "archive.hpp" #include "match.hpp" #include "cmddata.hpp" +#include "ui.hpp" #include "filcreat.hpp" #include "consio.hpp" #include "system.hpp" #include "log.hpp" -#include "rawint.hpp" #include "rawread.hpp" #include "encname.hpp" #include "resource.hpp" diff --git a/deps/unrar/rardefs.hpp b/deps/unrar/rardefs.hpp index 095792a03..6858d39c1 100644 --- a/deps/unrar/rardefs.hpp +++ b/deps/unrar/rardefs.hpp @@ -9,9 +9,13 @@ #define ASIZE(x) (sizeof(x)/sizeof(x[0])) -// MAXPASSWORD is expected to be multiple of CRYPTPROTECTMEMORY_BLOCK_SIZE (16) -// for CryptProtectMemory in SecPassword. -#define MAXPASSWORD 128 +// MAXPASSWORD and MAXPASSWORD_RAR are expected to be multiple of +// CRYPTPROTECTMEMORY_BLOCK_SIZE (16) for CryptProtectMemory in SecPassword. +// We allow a larger MAXPASSWORD to unpack archives with lengthy passwords +// in non-RAR formats in GUI versions. For RAR format we set MAXPASSWORD_RAR +// to 128 for compatibility and because it is enough for AES-256. +#define MAXPASSWORD 512 +#define MAXPASSWORD_RAR 128 #define MAXSFXSIZE 0x200000 diff --git a/deps/unrar/rawint.hpp b/deps/unrar/rawint.hpp index 303798886..c8cd86fc7 100644 --- a/deps/unrar/rawint.hpp +++ b/deps/unrar/rawint.hpp @@ -84,7 +84,7 @@ inline uint32 RawGetBE4(const byte *m) { #if defined(USE_MEM_BYTESWAP) && defined(_MSC_VER) return _byteswap_ulong(*(uint32 *)m); -#elif defined(USE_MEM_BYTESWAP) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 2) +#elif defined(USE_MEM_BYTESWAP) && (defined(__clang__) || defined(__GNUC__)) return __builtin_bswap32(*(uint32 *)m); #else return uint32(m[0]<<24) | uint32(m[1]<<16) | uint32(m[2]<<8) | m[3]; @@ -97,7 +97,7 @@ inline void RawPutBE4(uint32 i,byte *mem) { #if defined(USE_MEM_BYTESWAP) && defined(_MSC_VER) *(uint32*)mem = _byteswap_ulong(i); -#elif defined(USE_MEM_BYTESWAP) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 2) +#elif defined(USE_MEM_BYTESWAP) && (defined(__clang__) || defined(__GNUC__)) *(uint32*)mem = __builtin_bswap32(i); #else mem[0]=byte(i>>24); @@ -112,7 +112,7 @@ inline uint32 ByteSwap32(uint32 i) { #ifdef _MSC_VER return _byteswap_ulong(i); -#elif (__GNUC__ > 3) && (__GNUC_MINOR__ > 2) +#elif defined(__clang__) || defined(__GNUC__) return __builtin_bswap32(i); #else return (rotl32(i,24)&0xFF00FF00)|(rotl32(i,8)&0x00FF00FF); diff --git a/deps/unrar/rdwrfn.cpp b/deps/unrar/rdwrfn.cpp index 5c85753da..1b8219acf 100644 --- a/deps/unrar/rdwrfn.cpp +++ b/deps/unrar/rdwrfn.cpp @@ -16,6 +16,7 @@ void ComprDataIO::Init() UnpackFromMemory=false; UnpackToMemory=false; UnpPackedSize=0; + UnpPackedLeft=0; ShowProgress=true; TestMode=false; SkipUnpCRC=false; @@ -35,7 +36,9 @@ void ComprDataIO::Init() SubHead=NULL; SubHeadPos=NULL; CurrentCommand=0; - ProcessedArcSize=TotalArcSize=0; + ProcessedArcSize=0; + LastArcSize=0; + TotalArcSize=0; } @@ -75,10 +78,10 @@ int ComprDataIO::UnpRead(byte *Addr,size_t Count) } else { - size_t SizeToRead=((int64)Count>UnpPackedSize) ? (size_t)UnpPackedSize:Count; + size_t SizeToRead=((int64)Count>UnpPackedLeft) ? (size_t)UnpPackedLeft:Count; if (SizeToRead > 0) { - if (UnpVolume && Decryption && (int64)Count>UnpPackedSize) + if (UnpVolume && Decryption && (int64)Count>UnpPackedLeft) { // We need aligned blocks for decryption and we want "Keep broken // files" to work efficiently with missing encrypted volumes. @@ -109,7 +112,7 @@ int ComprDataIO::UnpRead(byte *Addr,size_t Count) ReadAddr+=ReadSize; Count-=ReadSize; #endif - UnpPackedSize-=ReadSize; + UnpPackedLeft-=ReadSize; // Do not ask for next volume if we read something from current volume. // If next volume is missing, we need to process all data from current @@ -118,7 +121,7 @@ int ComprDataIO::UnpRead(byte *Addr,size_t Count) // we ask for next volume also if we have non-aligned encryption block. // Since we adjust data size for decryption earlier above, // it does not hurt "Keep broken files" mode efficiency. - if (UnpVolume && UnpPackedSize == 0 && + if (UnpVolume && UnpPackedLeft == 0 && (ReadSize==0 || Decryption && (TotalRead & CRYPT_BLOCK_MASK) != 0) ) { #ifndef NOVOLUME @@ -134,7 +137,7 @@ int ComprDataIO::UnpRead(byte *Addr,size_t Count) } Archive *SrcArc=(Archive *)SrcFile; if (SrcArc!=NULL) - ShowUnpRead(SrcArc->CurBlockPos+CurUnpRead,UnpArcSize); + ShowUnpRead(SrcArc->NextBlockPos-UnpPackedSize+CurUnpRead,TotalArcSize); if (ReadSize!=-1) { ReadSize=TotalRead; @@ -148,18 +151,11 @@ int ComprDataIO::UnpRead(byte *Addr,size_t Count) } -#if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) -// Disable the run time stack check for unrar.dll, so we can manipulate -// with ProcessDataProc call type below. Run time check would intercept -// a wrong ESP before we restore it. -#pragma runtime_checks( "s", off ) -#endif - void ComprDataIO::UnpWrite(byte *Addr,size_t Count) { #ifdef RARDLL - RAROptions *Cmd=((Archive *)SrcFile)->GetRAROptions(); + CommandData *Cmd=((Archive *)SrcFile)->GetCommandData(); if (Cmd->DllOpMode!=RAR_SKIP) { if (Cmd->Callback!=NULL && @@ -167,28 +163,7 @@ void ComprDataIO::UnpWrite(byte *Addr,size_t Count) ErrHandler.Exit(RARX_USERBREAK); if (Cmd->ProcessDataProc!=NULL) { - // Here we preserve ESP value. It is necessary for those developers, - // who still define ProcessDataProc callback as "C" type function, - // even though in year 2001 we announced in unrar.dll whatsnew.txt - // that it will be PASCAL type (for compatibility with Visual Basic). -#if defined(_MSC_VER) -#ifndef _WIN_64 - __asm mov ebx,esp -#endif -#elif defined(_WIN_ALL) && defined(__BORLANDC__) - _EBX=_ESP; -#endif int RetCode=Cmd->ProcessDataProc(Addr,(int)Count); - - // Restore ESP after ProcessDataProc with wrongly defined calling - // convention broken it. -#if defined(_MSC_VER) -#ifndef _WIN_64 - __asm mov esp,ebx -#endif -#elif defined(_WIN_ALL) && defined(__BORLANDC__) - _ESP=_EBX; -#endif if (RetCode==0) ErrHandler.Exit(RARX_USERBREAK); } @@ -216,11 +191,6 @@ void ComprDataIO::UnpWrite(byte *Addr,size_t Count) Wait(); } -#if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) -// Restore the run time stack check for unrar.dll. -#pragma runtime_checks( "s", restore ) -#endif - @@ -230,15 +200,11 @@ void ComprDataIO::ShowUnpRead(int64 ArcPos,int64 ArcSize) { if (ShowProgress && SrcFile!=NULL) { - if (TotalArcSize!=0) - { - // important when processing several archives or multivolume archive - ArcSize=TotalArcSize; - ArcPos+=ProcessedArcSize; - } + // Important when processing several archives or multivolume archive. + ArcPos+=ProcessedArcSize; Archive *SrcArc=(Archive *)SrcFile; - RAROptions *Cmd=SrcArc->GetRAROptions(); + CommandData *Cmd=SrcArc->GetCommandData(); int CurPercent=ToPercent(ArcPos,ArcSize); if (!Cmd->DisablePercentage && CurPercent!=LastPercent) @@ -333,3 +299,37 @@ void ComprDataIO::SetUnpackFromMemory(byte *Addr,uint Size) UnpackFromMemoryAddr=Addr; UnpackFromMemorySize=Size; } + +// Extraction progress is based on the position in archive and we adjust +// the total archives size here, so trailing blocks do not prevent progress +// reaching 100% at the end of extraction. Alternatively we could print "100%" +// after completing the entire archive extraction, but then we would need +// to take into account possible messages like the checksum error after +// last file percent progress. +void ComprDataIO::AdjustTotalArcSize(Archive *Arc) +{ + // If we know a position of QO or RR blocks, use them to adjust the total + // packed size to beginning of these blocks. Earlier we already calculated + // the total size based on entire archive sizes. We also set LastArcSize + // to start of first trailing block, to add it later to ProcessedArcSize. + int64 ArcLength=Arc->IsSeekable() ? Arc->FileLength() : 0; + if (Arc->MainHead.QOpenOffset!=0) // QO is always preceding RR record. + LastArcSize=Arc->MainHead.QOpenOffset; + else + if (Arc->MainHead.RROffset!=0) + LastArcSize=Arc->MainHead.RROffset; + else + { + // If neither QO nor RR are found, exclude the approximate size of + // end of archive block. + // We select EndBlock to be larger than typical 8 bytes HEAD_ENDARC, + // but to not exceed the smallest 22 bytes HEAD_FILE with 1 byte file + // name, so we do not have two files with 100% at the end of archive. + const uint EndBlock=23; + + if (ArcLength>EndBlock) + LastArcSize=ArcLength-EndBlock; + } + + TotalArcSize-=ArcLength-LastArcSize; +} diff --git a/deps/unrar/rdwrfn.hpp b/deps/unrar/rdwrfn.hpp index 24c09eec4..f708bf4a9 100644 --- a/deps/unrar/rdwrfn.hpp +++ b/deps/unrar/rdwrfn.hpp @@ -1,6 +1,7 @@ #ifndef _RAR_DATAIO_ #define _RAR_DATAIO_ +class Archive; class CmdAdd; class Unpack; class ArcFileSearch; @@ -29,6 +30,7 @@ class ComprDataIO byte *UnpWrAddr; int64 UnpPackedSize; + int64 UnpPackedLeft; bool ShowProgress; bool TestMode; @@ -61,7 +63,7 @@ class ComprDataIO void UnpWrite(byte *Addr,size_t Count); void EnableShowProgress(bool Show) {ShowProgress=Show;} void GetUnpackedData(byte **Data,size_t *Size); - void SetPackedSizeToRead(int64 Size) {UnpPackedSize=Size;} + void SetPackedSizeToRead(int64 Size) {UnpPackedSize=UnpPackedLeft=Size;} void SetTestMode(bool Mode) {TestMode=Mode;} void SetSkipUnpCRC(bool Skip) {SkipUnpCRC=Skip;} void SetNoFileHeader(bool Mode) {NoFileHeader=Mode;} @@ -76,12 +78,12 @@ class ComprDataIO void SetUnpackToMemory(byte *Addr,uint Size); void SetUnpackFromMemory(byte *Addr,uint Size); void SetCurrentCommand(wchar Cmd) {CurrentCommand=Cmd;} + void AdjustTotalArcSize(Archive *Arc); bool PackVolume; bool UnpVolume; bool NextVolumeMissing; - int64 UnpArcSize; int64 CurPackRead,CurPackWrite,CurUnpRead,CurUnpWrite; @@ -89,6 +91,9 @@ class ComprDataIO // Used to calculate the total operation progress. int64 ProcessedArcSize; + // Last extracted archive size up to QO or RR block. + int64 LastArcSize; + int64 TotalArcSize; DataHash PackedDataHash; // Packed write and unpack read hash. diff --git a/deps/unrar/recvol.cpp b/deps/unrar/recvol.cpp index adf584044..b17820711 100644 --- a/deps/unrar/recvol.cpp +++ b/deps/unrar/recvol.cpp @@ -5,7 +5,7 @@ -bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent) +bool RecVolumesRestore(CommandData *Cmd,const wchar *Name,bool Silent) { Archive Arc(Cmd); if (!Arc.Open(Name)) @@ -42,7 +42,7 @@ bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent) } -void RecVolumesTest(RAROptions *Cmd,Archive *Arc,const wchar *Name) +void RecVolumesTest(CommandData *Cmd,Archive *Arc,const wchar *Name) { wchar RevName[NM]; *RevName=0; diff --git a/deps/unrar/recvol.hpp b/deps/unrar/recvol.hpp index 06510a211..4a6d663ff 100644 --- a/deps/unrar/recvol.hpp +++ b/deps/unrar/recvol.hpp @@ -14,11 +14,11 @@ class RecVolumes3 ThreadPool *RSThreadPool; #endif public: - RecVolumes3(RAROptions *Cmd,bool TestOnly); + RecVolumes3(CommandData *Cmd,bool TestOnly); ~RecVolumes3(); - void Make(RAROptions *Cmd,wchar *ArcName); - bool Restore(RAROptions *Cmd,const wchar *Name,bool Silent); - void Test(RAROptions *Cmd,const wchar *Name); + void Make(CommandData *Cmd,wchar *ArcName); + bool Restore(CommandData *Cmd,const wchar *Name,bool Silent); + void Test(CommandData *Cmd,const wchar *Name); }; @@ -48,8 +48,8 @@ struct RecRSThreadData class RecVolumes5 { private: - void ProcessRS(RAROptions *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode); - void ProcessRS(RAROptions *Cmd,uint MaxRead,bool Encode); + void ProcessRS(CommandData *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode); + void ProcessRS(CommandData *Cmd,uint MaxRead,bool Encode); uint ReadHeader(File *RecFile,bool FirstRev); Array RecItems; @@ -76,13 +76,13 @@ class RecVolumes5 public: // 'public' only because called from thread functions. void ProcessAreaRS(RecRSThreadData *td); public: - RecVolumes5(RAROptions *Cmd,bool TestOnly); + RecVolumes5(CommandData *Cmd,bool TestOnly); ~RecVolumes5(); - bool Restore(RAROptions *Cmd,const wchar *Name,bool Silent); - void Test(RAROptions *Cmd,const wchar *Name); + bool Restore(CommandData *Cmd,const wchar *Name,bool Silent); + void Test(CommandData *Cmd,const wchar *Name); }; -bool RecVolumesRestore(RAROptions *Cmd,const wchar *Name,bool Silent); -void RecVolumesTest(RAROptions *Cmd,Archive *Arc,const wchar *Name); +bool RecVolumesRestore(CommandData *Cmd,const wchar *Name,bool Silent); +void RecVolumesTest(CommandData *Cmd,Archive *Arc,const wchar *Name); #endif diff --git a/deps/unrar/recvol3.cpp b/deps/unrar/recvol3.cpp index 9fb846a28..ecf6dd35e 100644 --- a/deps/unrar/recvol3.cpp +++ b/deps/unrar/recvol3.cpp @@ -36,7 +36,7 @@ THREAD_PROC(RSDecodeThread) } #endif -RecVolumes3::RecVolumes3(RAROptions *Cmd,bool TestOnly) +RecVolumes3::RecVolumes3(CommandData *Cmd,bool TestOnly) { memset(SrcFile,0,sizeof(SrcFile)); if (TestOnly) @@ -99,7 +99,7 @@ static bool IsNewStyleRev(const wchar *Name) } -bool RecVolumes3::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) +bool RecVolumes3::Restore(CommandData *Cmd,const wchar *Name,bool Silent) { wchar ArcName[NM]; wcsncpyz(ArcName,Name,ASIZE(ArcName)); @@ -497,7 +497,7 @@ void RSEncode::DecodeBuf() } -void RecVolumes3::Test(RAROptions *Cmd,const wchar *Name) +void RecVolumes3::Test(CommandData *Cmd,const wchar *Name) { if (!IsNewStyleRev(Name)) // RAR 3.0 name#_#_#.rev do not include CRC32. { diff --git a/deps/unrar/recvol5.cpp b/deps/unrar/recvol5.cpp index 3c524d8ee..2d9c94711 100644 --- a/deps/unrar/recvol5.cpp +++ b/deps/unrar/recvol5.cpp @@ -1,6 +1,10 @@ static const uint MaxVolumes=65535; -RecVolumes5::RecVolumes5(RAROptions *Cmd,bool TestOnly) +// We select this limit arbitrarily, to prevent user creating too many +// rev files by mistake. +#define MAX_REV_TO_DATA_RATIO 10 // 1000% of rev files. + +RecVolumes5::RecVolumes5(CommandData *Cmd,bool TestOnly) { RealBuf=NULL; RealReadBuffer=NULL; @@ -66,7 +70,7 @@ THREAD_PROC(RecThreadRS) #endif -void RecVolumes5::ProcessRS(RAROptions *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode) +void RecVolumes5::ProcessRS(CommandData *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode) { /* RSCoder16 RS; @@ -137,7 +141,7 @@ void RecVolumes5::ProcessAreaRS(RecRSThreadData *td) -bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) +bool RecVolumes5::Restore(CommandData *Cmd,const wchar *Name,bool Silent) { wchar ArcName[NM]; wcsncpyz(ArcName,Name,ASIZE(ArcName)); @@ -145,13 +149,16 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) wchar *Num=GetVolNumPart(ArcName); while (Num>ArcName && IsDigit(*(Num-1))) Num--; - if (Num==ArcName) + if (Num<=PointToName(ArcName)) return false; // Numeric part is missing or entire volume name is numeric, not possible for RAR or REV volume. wcsncpyz(Num,L"*.*",ASIZE(ArcName)-(Num-ArcName)); wchar FirstVolName[NM]; *FirstVolName=0; + wchar LongestRevName[NM]; + *LongestRevName=0; + int64 RecFileSize=0; FindFile VolFind; @@ -164,7 +171,7 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) Archive *Vol=new Archive(Cmd); int ItemPos=-1; - if (Vol->WOpen(fd.Name)) + if (!fd.IsDir && Vol->WOpen(fd.Name)) { if (CmpExt(fd.Name,L"rev")) { @@ -176,6 +183,9 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) ItemPos=RecNum; FoundRecVolumes++; + + if (wcslen(fd.Name)>wcslen(LongestRevName)) + wcsncpyz(LongestRevName,fd.Name,ASIZE(LongestRevName)); } } else @@ -231,6 +241,15 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) if (FoundRecVolumes==0) return false; + // If we did not find even a single .rar volume, create .rar volume name + // based on the longest .rev file name. Use longest .rev, so we have + // enough space for volume number. + if (*FirstVolName==0) + { + SetExt(LongestRevName,L"rar",ASIZE(LongestRevName)); + VolNameToFirstName(LongestRevName,FirstVolName,ASIZE(FirstVolName),true); + } + uiMsg(UIMSG_RECVOLCALCCHECKSUM); MissingVolumes=0; @@ -301,7 +320,7 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) Item->f=NULL; } - if ((Item->New=(Item->f==NULL))) // Additional parentheses to avoid GCC warning. + if ((Item->New=(Item->f==NULL))==true) { wcsncpyz(Item->Name,FirstVolName,ASIZE(Item->Name)); uiMsg(UIMSG_CREATING,Item->Name); @@ -316,7 +335,6 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) } NewVol->Prealloc(Item->FileSize); Item->f=NewVol; - Item->New=true; } NextVolumeName(FirstVolName,ASIZE(FirstVolName),false); } @@ -346,13 +364,11 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) RecBufferSize&=~(SSE_ALIGNMENT-1); // Align for SSE. #endif - uint *Data=new uint[TotalCount]; - RSCoder16 RS; if (!RS.Init(DataCount,RecCount,ValidFlags)) { + uiMsg(UIERROR_OPFAILED); delete[] ValidFlags; - delete[] Data; return false; // Should not happen, we check parameter validity above. } @@ -415,7 +431,6 @@ bool RecVolumes5::Restore(RAROptions *Cmd,const wchar *Name,bool Silent) RecItems[I].f->Close(); delete[] ValidFlags; - delete[] Data; #if !defined(SILENT) if (!Cmd->DisablePercentage) mprintf(L"\b\b\b\b100%%"); @@ -479,7 +494,7 @@ uint RecVolumes5::ReadHeader(File *RecFile,bool FirstRev) } -void RecVolumes5::Test(RAROptions *Cmd,const wchar *Name) +void RecVolumes5::Test(CommandData *Cmd,const wchar *Name) { wchar VolName[NM]; wcsncpyz(VolName,Name,ASIZE(VolName)); diff --git a/deps/unrar/rijndael.cpp b/deps/unrar/rijndael.cpp index cbb1722fd..02c4d147b 100644 --- a/deps/unrar/rijndael.cpp +++ b/deps/unrar/rijndael.cpp @@ -1,22 +1,40 @@ -/*************************************************************************** - * This code is based on public domain Szymon Stefanek AES implementation: * - * http://www.pragmaware.net/software/rijndael/index.php * - * * - * Dynamic tables generation is based on the Brian Gladman work: * - * http://fp.gladman.plus.com/cryptography_technology/rijndael * - ***************************************************************************/ +/************************************************************************** + * This code is based on Szymon Stefanek public domain AES implementation * + **************************************************************************/ #include "rar.hpp" #ifdef USE_SSE #include #endif -// not thread-safe ? -//static byte S[256],S5[256],rcon[30]; -//static byte T1[256][4],T2[256][4],T3[256][4],T4[256][4]; -//static byte T5[256][4],T6[256][4],T7[256][4],T8[256][4]; -//static byte U1[256][4],U2[256][4],U3[256][4],U4[256][4]; - +static byte S[256]= +{ + 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, + 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, + 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, + 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, + 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, + 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, + 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, + 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, + 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, + 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, + 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, + 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, + 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, + 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, + 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, + 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22 +}; + +static byte S5[256]; + +// Round constants. 10 items are used by AES-128, 8 by AES-192, 7 by AES-256. +static byte rcon[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36}; + +static byte T1[256][4],T2[256][4],T3[256][4],T4[256][4]; +static byte T5[256][4],T6[256][4],T7[256][4],T8[256][4]; +static byte U1[256][4],U2[256][4],U3[256][4],U4[256][4]; inline void Xor128(void *dest,const void *arg1,const void *arg2) { @@ -64,7 +82,7 @@ inline void Copy128(byte *dest,const byte *src) Rijndael::Rijndael() { - //if (S[0]==0) + if (S5[0]==0) GenerateTables(); CBCMode = true; // Always true for RAR. } @@ -72,18 +90,20 @@ Rijndael::Rijndael() void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVector) { -#ifdef USE_SSE - // Check SSE here instead of constructor, so if object is a part of some - // structure memset'ed before use, this variable is not lost. + // Check SIMD here instead of constructor, so if object is a part of some + // structure memset'ed before use, these variables are not lost. +#if defined(USE_SSE) int CPUInfo[4]; - __cpuid(CPUInfo, 0x80000000); // Get the maximum supported cpuid function. - if ((CPUInfo[0] & 0x7fffffff)>=1) + __cpuid(CPUInfo, 0); + if (CPUInfo[0]>=1) // Check the maximum supported cpuid function. { __cpuid(CPUInfo, 1); AES_NI=(CPUInfo[2] & 0x2000000)!=0; } else - AES_NI=0; + AES_NI=false; +#elif defined(USE_NEON) + AES_Neon=(getauxval(AT_HWCAP) & HWCAP_AES)!=0; #endif // Other developers asked us to initialize it to suppress "may be used @@ -123,18 +143,25 @@ void Rijndael::Init(bool Encrypt,const byte *key,uint keyLen,const byte * initVe keyEncToDec(); } + void Rijndael::blockEncrypt(const byte *input,size_t inputLen,byte *outBuffer) { if (inputLen <= 0) return; size_t numBlocks = inputLen/16; -#ifdef USE_SSE +#if defined(USE_SSE) if (AES_NI) { blockEncryptSSE(input,numBlocks,outBuffer); return; } +#elif defined(USE_NEON) + if (AES_Neon) + { + blockEncryptNeon(input,numBlocks,outBuffer); + return; + } #endif byte *prevBlock = m_initVector; @@ -221,6 +248,40 @@ void Rijndael::blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffe } #endif + +#ifdef USE_NEON +void Rijndael::blockEncryptNeon(const byte *input,size_t numBlocks,byte *outBuffer) +{ + byte *prevBlock = m_initVector; + while (numBlocks > 0) + { + byte block[16]; + if (CBCMode) + vst1q_u8(block, veorq_u8(vld1q_u8(prevBlock), vld1q_u8(input))); + else + vst1q_u8(block, vld1q_u8(input)); + + uint8x16_t data = vld1q_u8(block); + for (uint i = 0; i < m_uRounds-1; i++) + { + data = vaeseq_u8(data, vld1q_u8((byte *)m_expandedKey[i])); + data = vaesmcq_u8(data); + } + data = vaeseq_u8(data, vld1q_u8((byte *)(m_expandedKey[m_uRounds-1]))); + data = veorq_u8(data, vld1q_u8((byte *)(m_expandedKey[m_uRounds]))); + vst1q_u8(outBuffer, data); + + prevBlock=outBuffer; + + outBuffer += 16; + input += 16; + numBlocks--; + } + vst1q_u8(m_initVector, vld1q_u8(prevBlock)); + return; +} +#endif + void Rijndael::blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer) { @@ -228,12 +289,18 @@ void Rijndael::blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer) return; size_t numBlocks=inputLen/16; -#ifdef USE_SSE +#if defined(USE_SSE) if (AES_NI) { blockDecryptSSE(input,numBlocks,outBuffer); return; } +#elif defined(USE_NEON) + if (AES_Neon) + { + blockDecryptNeon(input,numBlocks,outBuffer); + return; + } #endif byte block[16], iv[4][4]; @@ -325,6 +392,41 @@ void Rijndael::blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuf #endif +#ifdef USE_NEON +void Rijndael::blockDecryptNeon(const byte *input, size_t numBlocks, byte *outBuffer) +{ + byte iv[16]; + memcpy(iv,m_initVector,16); + + while (numBlocks > 0) + { + uint8x16_t data = vld1q_u8(input); + + for (int i=m_uRounds-1; i>0; i--) + { + data = vaesdq_u8(data, vld1q_u8((byte *)m_expandedKey[i+1])); + data = vaesimcq_u8(data); + } + + data = vaesdq_u8(data, vld1q_u8((byte *)m_expandedKey[1])); + data = veorq_u8(data, vld1q_u8((byte *)m_expandedKey[0])); + + if (CBCMode) + data = veorq_u8(data, vld1q_u8(iv)); + + vst1q_u8(iv, vld1q_u8(input)); + vst1q_u8(outBuffer, data); + + input += 16; + outBuffer += 16; + numBlocks--; + } + + memcpy(m_initVector,iv,16); +} +#endif + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ALGORITHM ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -417,51 +519,40 @@ void Rijndael::keyEncToDec() } -#define ff_poly 0x011b -#define ff_hi 0x80 - -#define FFinv(x) ((x) ? pow[255 - log[x]]: 0) - -#define FFmul02(x) (x ? pow[log[x] + 0x19] : 0) -#define FFmul03(x) (x ? pow[log[x] + 0x01] : 0) -#define FFmul09(x) (x ? pow[log[x] + 0xc7] : 0) -#define FFmul0b(x) (x ? pow[log[x] + 0x68] : 0) -#define FFmul0d(x) (x ? pow[log[x] + 0xee] : 0) -#define FFmul0e(x) (x ? pow[log[x] + 0xdf] : 0) -#define fwd_affine(x) \ - (w = (uint)x, w ^= (w<<1)^(w<<2)^(w<<3)^(w<<4), (byte)(0x63^(w^(w>>8)))) +static byte gmul(byte a, byte b) // Galois field "peasant's algorithm" multiplication. +{ + const byte poly=0x1b; // Lower byte of AES 0x11b irreducible polynomial. + byte result = 0; + while (b>0) + { + if ((b & 1) != 0) + result ^= a; + a = (a & 0x80) ? (a<<1)^poly : a<<1; + b >>= 1; + } + return result; +} -#define inv_affine(x) \ - (w = (uint)x, w = (w<<1)^(w<<3)^(w<<6), (byte)(0x05^(w^(w>>8)))) +// 2021-09-24: changed to slower and simpler code without interim tables. +// It is still fast enough for our purpose. void Rijndael::GenerateTables() { - unsigned char pow[512],log[256]; - int i = 0, w = 1; - do - { - pow[i] = (byte)w; - pow[i + 255] = (byte)w; - log[w] = (byte)i++; - w ^= (w << 1) ^ (w & ff_hi ? ff_poly : 0); - } while (w != 1); - - for (int i = 0,w = 1; i < sizeof(rcon)/sizeof(rcon[0]); i++) - { - rcon[i] = w; - w = (w << 1) ^ (w & ff_hi ? ff_poly : 0); - } - for(int i = 0; i < 256; ++i) + for (int I=0;I<256;I++) + S5[S[I]]=I; + + for (int I=0;I<256;I++) { - unsigned char b=S[i]=fwd_affine(FFinv((byte)i)); - T1[i][1]=T1[i][2]=T2[i][2]=T2[i][3]=T3[i][0]=T3[i][3]=T4[i][0]=T4[i][1]=b; - T1[i][0]=T2[i][1]=T3[i][2]=T4[i][3]=FFmul02(b); - T1[i][3]=T2[i][0]=T3[i][1]=T4[i][2]=FFmul03(b); - S5[i] = b = FFinv(inv_affine((byte)i)); - U1[b][3]=U2[b][0]=U3[b][1]=U4[b][2]=T5[i][3]=T6[i][0]=T7[i][1]=T8[i][2]=FFmul0b(b); - U1[b][1]=U2[b][2]=U3[b][3]=U4[b][0]=T5[i][1]=T6[i][2]=T7[i][3]=T8[i][0]=FFmul09(b); - U1[b][2]=U2[b][3]=U3[b][0]=U4[b][1]=T5[i][2]=T6[i][3]=T7[i][0]=T8[i][1]=FFmul0d(b); - U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[i][0]=T6[i][1]=T7[i][2]=T8[i][3]=FFmul0e(b); + byte s=S[I]; + T1[I][1]=T1[I][2]=T2[I][2]=T2[I][3]=T3[I][0]=T3[I][3]=T4[I][0]=T4[I][1]=s; + T1[I][0]=T2[I][1]=T3[I][2]=T4[I][3]=gmul(s,2); + T1[I][3]=T2[I][0]=T3[I][1]=T4[I][2]=gmul(s,3); + + byte b=S5[I]; + U1[b][3]=U2[b][0]=U3[b][1]=U4[b][2]=T5[I][3]=T6[I][0]=T7[I][1]=T8[I][2]=gmul(b,0xb); + U1[b][1]=U2[b][2]=U3[b][3]=U4[b][0]=T5[I][1]=T6[I][2]=T7[I][3]=T8[I][0]=gmul(b,0x9); + U1[b][2]=U2[b][3]=U3[b][0]=U4[b][1]=T5[I][2]=T6[I][3]=T7[I][0]=T8[I][1]=gmul(b,0xd); + U1[b][0]=U2[b][1]=U3[b][2]=U4[b][3]=T5[I][0]=T6[I][1]=T7[I][2]=T8[I][3]=gmul(b,0xe); } } diff --git a/deps/unrar/rijndael.hpp b/deps/unrar/rijndael.hpp index 33537d890..96e1d0d14 100644 --- a/deps/unrar/rijndael.hpp +++ b/deps/unrar/rijndael.hpp @@ -2,11 +2,7 @@ #define _RIJNDAEL_H_ /************************************************************************** - * This code is based on Szymon Stefanek AES implementation: * - * http://www.esat.kuleuven.ac.be/~rijmen/rijndael/rijndael-cpplib.tar.gz * - * * - * Dynamic tables generation is based on the Brian Gladman's work: * - * http://fp.gladman.plus.com/cryptography_technology/rijndael * + * This code is based on Szymon Stefanek public domain AES implementation * **************************************************************************/ #define _MAX_KEY_COLUMNS (256/32) @@ -22,6 +18,16 @@ class Rijndael bool AES_NI; #endif +#ifdef USE_NEON + // Set "crypto" attribute as replacement of -march=armv8-a+crypto switch. + __attribute__((target("crypto"))) + void blockEncryptNeon(const byte *input,size_t numBlocks,byte *outBuffer); + __attribute__((target("crypto"))) + void blockDecryptNeon(const byte *input, size_t numBlocks, byte *outBuffer); + + bool AES_Neon; +#endif + void keySched(byte key[_MAX_KEY_COLUMNS][4]); void keyEncToDec(); void GenerateTables(); @@ -33,11 +39,6 @@ class Rijndael int m_uRounds; byte m_initVector[MAX_IV_SIZE]; byte m_expandedKey[_MAX_ROUNDS+1][4][4]; - - byte S[256],S5[256],rcon[30]; - byte T1[256][4],T2[256][4],T3[256][4],T4[256][4]; - byte T5[256][4],T6[256][4],T7[256][4],T8[256][4]; - byte U1[256][4],U2[256][4],U3[256][4],U4[256][4]; public: Rijndael(); void Init(bool Encrypt,const byte *key,uint keyLen,const byte *initVector); diff --git a/deps/unrar/rs16.cpp b/deps/unrar/rs16.cpp index bc8dd0937..f5c7ccac1 100644 --- a/deps/unrar/rs16.cpp +++ b/deps/unrar/rs16.cpp @@ -95,7 +95,9 @@ bool RSCoder16::Init(uint DataCount, uint RecCount, bool *ValidityFlags) if (NE > ValidECC || NE == 0 || ValidECC == 0) return false; } - if (ND + NR > gfSize || NR > ND || ND == 0 || NR == 0) + + // 2021.09.01 - we allowed RR and REV >100%, so no more NR > ND check. + if (ND + NR > gfSize || /*NR > ND ||*/ ND == 0 || NR == 0) return false; delete[] MX; diff --git a/deps/unrar/savepos.hpp b/deps/unrar/savepos.hpp deleted file mode 100644 index 1f8353f65..000000000 --- a/deps/unrar/savepos.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _RAR_SAVEPOS_ -#define _RAR_SAVEPOS_ - -class SaveFilePos -{ - private: - File *SaveFile; - int64 SavePos; - public: - SaveFilePos(File &Src) - { - SaveFile=&Src; - SavePos=Src.Tell(); - } - ~SaveFilePos() - { - // Unless the file is already closed either by current exception - // processing or intentionally by external code. - if (SaveFile->IsOpened()) - { - try - { - SaveFile->Seek(SavePos,SEEK_SET); - } - catch(RAR_EXIT) - { - // Seek() can throw an exception and it terminates process - // if we are already processing another exception. Also in C++ 11 - // an exception in destructor always terminates process unless - // we mark destructor with noexcept(false). So we do not want to - // throw here. To prevent data loss we do not want to continue - // execution after seek error, so we close the file. - // Any next access to this file will return an error. - SaveFile->Close(); - } - } - } -}; - -#endif diff --git a/deps/unrar/scantree.cpp b/deps/unrar/scantree.cpp index a13a3ebce..03c830e71 100644 --- a/deps/unrar/scantree.cpp +++ b/deps/unrar/scantree.cpp @@ -215,10 +215,23 @@ bool ScanTree::GetNextMask() UnixSlashToDos(CurMask,CurMask,ASIZE(CurMask)); #endif - // We wish to scan entire disk if mask like c:\ is specified - // regardless of recursion mode. Use c:\*.* mask when need to scan only - // the root directory. - ScanEntireDisk=IsDriveLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0; + /* + We prefer to scan entire disk if mask like \\server\share\ or c:\ + is specified regardless of recursion mode. Use \\server\share\*.* + or c:\*.* mask to scan only the root directory. + */ + if (CurMask[0]=='\\' && CurMask[1]=='\\') + { + const wchar *Slash=wcschr(CurMask+2,'\\'); + if (Slash!=NULL) + { + Slash=wcschr(Slash+1,'\\'); + ScanEntireDisk=Slash!=NULL && *(Slash+1)==0; + } + } + else + ScanEntireDisk=IsDriveLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0; + wchar *Name=PointToName(CurMask); if (*Name==0) diff --git a/deps/unrar/secpassword.cpp b/deps/unrar/secpassword.cpp index b99e53af0..42ed47d5e 100644 --- a/deps/unrar/secpassword.cpp +++ b/deps/unrar/secpassword.cpp @@ -56,7 +56,6 @@ static CryptLoader GlobalCryptLoader; SecPassword::SecPassword() { - CrossProcess=false; Set(L""); } @@ -70,7 +69,8 @@ SecPassword::~SecPassword() void SecPassword::Clean() { PasswordSet=false; - cleandata(Password,sizeof(Password)); + if (Password.size()>0) + cleandata(&Password[0],Password.size()); } @@ -104,7 +104,7 @@ void SecPassword::Process(const wchar *Src,size_t SrcSize,wchar *Dst,size_t DstS // Source string can be shorter than destination as in case when we process // -p parameter, so we need to take into account both sizes. memcpy(Dst,Src,Min(SrcSize,DstSize)*sizeof(*Dst)); - SecHideData(Dst,DstSize*sizeof(*Dst),Encode,CrossProcess); + SecHideData(Dst,DstSize*sizeof(*Dst),Encode,false); } @@ -112,7 +112,7 @@ void SecPassword::Get(wchar *Psw,size_t MaxSize) { if (PasswordSet) { - Process(Password,ASIZE(Password),Psw,MaxSize,false); + Process(&Password[0],Password.size(),Psw,MaxSize,false); Psw[MaxSize-1]=0; } else @@ -124,15 +124,14 @@ void SecPassword::Get(wchar *Psw,size_t MaxSize) void SecPassword::Set(const wchar *Psw) { - if (*Psw==0) - { - PasswordSet=false; - memset(Password,0,sizeof(Password)); - } - else + // Eliminate any traces of previously stored password for security reason + // in case it was longer than new one. + Clean(); + + if (*Psw!=0) { PasswordSet=true; - Process(Psw,wcslen(Psw)+1,Password,ASIZE(Password),true); + Process(Psw,wcslen(Psw)+1,&Password[0],Password.size(),true); } } @@ -163,6 +162,9 @@ bool SecPassword::operator == (SecPassword &psw) } +// Set CrossProcess to true if we need to pass a password to another process. +// We use CrossProcess when transferring parameters to UAC elevated WinRAR +// and Windows GUI SFX modules. void SecHideData(void *Data,size_t DataSize,bool Encode,bool CrossProcess) { // CryptProtectMemory is not available in UWP and CryptProtectData diff --git a/deps/unrar/secpassword.hpp b/deps/unrar/secpassword.hpp index 375d3887a..5284bce12 100644 --- a/deps/unrar/secpassword.hpp +++ b/deps/unrar/secpassword.hpp @@ -8,10 +8,7 @@ class SecPassword private: void Process(const wchar *Src,size_t SrcSize,wchar *Dst,size_t DstSize,bool Encode); - wchar Password[MAXPASSWORD]; - - // It is important to have this 'bool' value, so if our object is cleaned - // with memset as a part of larger structure, it is handled correctly. + std::vector Password = std::vector(MAXPASSWORD); bool PasswordSet; public: SecPassword(); @@ -22,10 +19,6 @@ class SecPassword bool IsSet() {return PasswordSet;} size_t Length(); bool operator == (SecPassword &psw); - - // Set to true if we need to pass a password to another process. - // We use it when transferring parameters to UAC elevated WinRAR. - bool CrossProcess; }; diff --git a/deps/unrar/strfn.cpp b/deps/unrar/strfn.cpp index 8904b9072..7617f7a59 100644 --- a/deps/unrar/strfn.cpp +++ b/deps/unrar/strfn.cpp @@ -121,48 +121,26 @@ wchar* RemoveLF(wchar *Str) } -unsigned char loctolower(unsigned char ch) -{ -#if defined(_WIN_ALL) - // Convert to LPARAM first to avoid a warning in 64 bit mode. - // Convert to uintptr_t to avoid Clang/win error: cast to 'char *' from smaller integer type 'unsigned char' [-Werror,-Wint-to-pointer-cast] - return (int)(LPARAM)CharLowerA((LPSTR)(uintptr_t)ch); -#else - return tolower(ch); -#endif -} - - -unsigned char loctoupper(unsigned char ch) -{ -#if defined(_WIN_ALL) - // Convert to LPARAM first to avoid a warning in 64 bit mode. - // Convert to uintptr_t to avoid Clang/win error: cast to 'char *' from smaller integer type 'unsigned char' [-Werror,-Wint-to-pointer-cast] - return (int)(LPARAM)CharUpperA((LPSTR)(uintptr_t)ch); -#else - return toupper(ch); -#endif -} - - -// toupper with English only results if English input is provided. -// It avoids Turkish (small i) -> (big I with dot) conversion problem. -// We do not define 'ch' as 'int' to avoid necessity to cast all +#if defined(SFX_MODULE) +// char version of etoupperw. Used in console SFX module only. +// Fast toupper for English only input and output. Additionally to speed, +// it also avoids Turkish small i to big I with dot conversion problem. +// We do not define 'c' as 'int' to avoid necessity to cast all // signed chars passed to this function to unsigned char. -unsigned char etoupper(unsigned char ch) +unsigned char etoupper(unsigned char c) { - if (ch=='i') - return 'I'; - return toupper(ch); + return c>='a' && c<='z' ? c-'a'+'A' : c; } +#endif -// Unicode version of etoupper. -wchar etoupperw(wchar ch) +// Fast toupper for English only input and output. Additionally to speed, +// it also avoids Turkish small i to big I with dot conversion problem. +// We do not define 'c' as 'int' to avoid necessity to cast all +// signed wchars passed to this function to unsigned char. +wchar etoupperw(wchar c) { - if (ch=='i') - return 'I'; - return toupperw(ch); + return c>='a' && c<='z' ? c-'a'+'A' : c; } @@ -379,6 +357,32 @@ void itoa(int64 n,wchar *Str,size_t MaxSize) } +// Convert the number to string using thousand separators. +void fmtitoa(int64 n,wchar *Str,size_t MaxSize) +{ + static wchar ThSep=0; // Thousands separator. +#ifdef _WIN_ALL + wchar Info[10]; + if (!ThSep!=0 && GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_STHOUSAND,Info,ASIZE(Info))>0) + ThSep=*Info; +#elif defined(_UNIX) + ThSep=*localeconv()->thousands_sep; +#endif + if (ThSep==0) // If failed to detect the actual separator value. + ThSep=' '; + wchar RawText[30]; // 20 characters are enough for largest unsigned 64 bit int. + itoa(n,RawText,ASIZE(RawText)); + uint S=0,D=0,L=wcslen(RawText)%3; + while (RawText[S]!=0 && D+1=7) { diff --git a/deps/unrar/threadmisc.cpp b/deps/unrar/threadmisc.cpp index 742eda41d..7a6ec7822 100644 --- a/deps/unrar/threadmisc.cpp +++ b/deps/unrar/threadmisc.cpp @@ -149,3 +149,5 @@ uint GetNumberOfThreads() return NumCPU; } + + diff --git a/deps/unrar/timefn.cpp b/deps/unrar/timefn.cpp index e86d41a11..0abf49de9 100644 --- a/deps/unrar/timefn.cpp +++ b/deps/unrar/timefn.cpp @@ -273,12 +273,12 @@ void RarTime::SetAgeText(const wchar *TimeText) uint Seconds=0,Value=0; for (uint I=0;TimeText[I]!=0;I++) { - int Ch=TimeText[I]; + wchar Ch=TimeText[I]; if (IsDigit(Ch)) Value=Value*10+Ch-'0'; else { - switch(etoupper(Ch)) + switch(etoupperw(Ch)) { case 'D': Seconds+=Value*24*3600; diff --git a/deps/unrar/timefn.hpp b/deps/unrar/timefn.hpp index 527136164..49b61e85d 100644 --- a/deps/unrar/timefn.hpp +++ b/deps/unrar/timefn.hpp @@ -22,6 +22,17 @@ class RarTime // Internal time representation in 1/TICKS_PER_SECOND since 01.01.1601. // We use nanoseconds here to handle the high precision Unix time. + // It allows dates up to July 2185. + // + // If we'll ever need to extend the date range, we can define a lower + // precision Windows version of TICKS_PER_SECOND. But then Unix and Windows + // versions can differ in least significant digits of "lt" time output + // for Unix archives. + // Alternatively we can introduce 'bool HighPrecision' set to true + // in SetUnixNS() and TicksPerSecond() instead of constant above. + // It might be more reliable than defining TicksPerSecond variable, + // which wouldn't survive memset of any structure hosting RarTime. + // We would need to eliminate all such memsets in the entire code first. uint64 itime; public: // RarLocalTime::Reminder precision. Must be equal to TICKS_PER_SECOND. diff --git a/deps/unrar/ui.hpp b/deps/unrar/ui.hpp index 2654387c2..5def26df1 100644 --- a/deps/unrar/ui.hpp +++ b/deps/unrar/ui.hpp @@ -39,7 +39,7 @@ enum UIMESSAGE_CODE { UIERROR_UOWNERBROKEN, UIERROR_UOWNERGETOWNERID, UIERROR_UOWNERGETGROUPID, UIERROR_UOWNERSET, UIERROR_ULINKREAD, UIERROR_ULINKEXIST, UIERROR_OPENPRESERVEATIME, UIERROR_READERRTRUNCATED, UIERROR_READERRCOUNT, - UIERROR_DIRNAMEEXISTS, + UIERROR_DIRNAMEEXISTS,UIERROR_TRUNCPSW,UIERROR_ADJUSTVALUE, UIMSG_FIRST, UIMSG_STRING, UIMSG_BUILD, UIMSG_RRSEARCH, UIMSG_ANALYZEFILEDATA, @@ -49,6 +49,7 @@ enum UIMESSAGE_CODE { UIMSG_CORRECTINGNAME, UIMSG_BADARCHIVE, UIMSG_CREATING, UIMSG_RENAMING, UIMSG_RECVOLCALCCHECKSUM, UIMSG_RECVOLFOUND, UIMSG_RECVOLMISSING, UIMSG_MISSINGVOL, UIMSG_RECONSTRUCTING, UIMSG_CHECKSUM, UIMSG_FAT32SIZE, + UIMSG_SKIPENCARC, UIMSG_FILERENAME, UIWAIT_FIRST, UIWAIT_DISKFULLNEXT, UIWAIT_FCREATEERROR, UIWAIT_BADPSW, @@ -76,7 +77,7 @@ enum UIASKREP_RESULT { }; UIASKREP_RESULT uiAskReplace(wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags); -UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags); +UIASKREP_RESULT uiAskReplaceEx(CommandData *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags); void uiInit(SOUND_NOTIFY_MODE Sound); @@ -87,7 +88,7 @@ void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize); enum UIPASSWORD_TYPE {UIPASSWORD_GLOBAL,UIPASSWORD_FILE,UIPASSWORD_ARCHIVE}; -bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password); +bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password,CheckPassword *CheckPwd); bool uiIsGlobalPasswordSet(); enum UIALARM_TYPE {UIALARM_ERROR, UIALARM_INFO, UIALARM_QUESTION}; @@ -144,30 +145,31 @@ class uiMsgStore // Templates recognize usual NULL as integer, not wchar*. #define UINULL ((wchar *)NULL) -inline void uiMsg(UIMESSAGE_CODE Code) +inline void uiMsgBase(uiMsgStore &Store) { - uiMsgStore Store(Code); - Store.Msg(); + // Called last, when no parameters are left. } -template void uiMsg(UIMESSAGE_CODE Code,T1 a1) +template void uiMsgBase(uiMsgStore &Store,T1&& a1,TN&&... aN) { - uiMsgStore Store(Code); + // Process first parameter and pass the rest to same uiMsgBase. Store< void uiMsg(UIMESSAGE_CODE Code,T1 a1,T2 a2) -{ - uiMsgStore Store(Code); - Store< void uiMsg(UIMESSAGE_CODE code,T1 a1,T2 a2,T3 a3) +// Use variadic templates. +// +// We must pass variable parameters by reference, so no temporary copies are +// created for custom string objects like CStringBase in 7-Zip decompression +// code. Such temporary copies would be destroyed inside of recursive +// uiMsgBase calls, leaving us with Str[] items pointing at released memory. +// Since we pass integer values as well, we can't use & references +// and must resort to && rvalue references. +template void uiMsg(UIMESSAGE_CODE Code,TN&&... aN) { - uiMsgStore Store(code); - Store<Overwrite==OVERWRITE_NONE) return UIASKREP_R_SKIP; diff --git a/deps/unrar/uiconsole.cpp b/deps/unrar/uiconsole.cpp index ceae1a7c5..b1ac51322 100644 --- a/deps/unrar/uiconsole.cpp +++ b/deps/unrar/uiconsole.cpp @@ -71,7 +71,10 @@ bool uiStartFileExtract(const wchar *FileName,bool Extract,bool Test,bool Skip) void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize) { - int CurPercent=ToPercent(CurSize,TotalSize); + // We set the total size to 0 to update only the current progress and keep + // the total progress intact in WinRAR. Unlike WinRAR, console RAR has only + // the total progress and updates it with current values in such case. + int CurPercent=TotalSize!=0 ? ToPercent(CurSize,TotalSize) : ToPercent(CurFileSize,TotalFileSize); mprintf(L"\b\b\b\b%3d%%",CurPercent); } @@ -247,6 +250,9 @@ void uiMsgStore::Msg() mprintf(L"\n"); // Needed when called from CmdExtract::ExtractCurrentFile. break; #ifndef SFX_MODULE + case UIERROR_OPFAILED: + Log(NULL,St(MOpFailed)); + break; case UIERROR_NEWRARFORMAT: Log(Str[0],St(MNewRarFormat)); break; @@ -256,6 +262,7 @@ void uiMsgStore::Msg() break; case UIERROR_MISSINGVOL: Log(Str[0],St(MAbsNextVol),Str[0]); + mprintf(L" "); // For progress percent. break; #ifndef SFX_MODULE case UIERROR_NEEDPREVVOL: @@ -329,6 +336,13 @@ void uiMsgStore::Msg() case UIERROR_DIRNAMEEXISTS: Log(NULL,St(MDirNameExists)); break; + case UIERROR_TRUNCPSW: + eprintf(St(MTruncPsw),Num[0]); + eprintf(L"\n"); + break; + case UIERROR_ADJUSTVALUE: + Log(NULL,St(MAdjustValue),Str[0],Str[1]); + break; #ifndef SFX_MODULE case UIMSG_STRING: @@ -369,6 +383,9 @@ void uiMsgStore::Msg() mprintf(St(MFAT32Size)); mprintf(L" "); // For progress percent. break; + case UIMSG_SKIPENCARC: + Log(NULL,St(MSkipEncArc),Str[0]); + break; @@ -379,7 +396,8 @@ void uiMsgStore::Msg() } -bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password) +bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName, + SecPassword *Password,CheckPassword *CheckPwd) { // Unlike GUI we cannot provide Cancel button here, so we use the empty // password to abort. Otherwise user not knowing a password would need to diff --git a/deps/unrar/uisilent.cpp b/deps/unrar/uisilent.cpp index 1df097566..815588574 100644 --- a/deps/unrar/uisilent.cpp +++ b/deps/unrar/uisilent.cpp @@ -33,7 +33,8 @@ void uiMsgStore::Msg() } -bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password) +bool uiGetPassword(UIPASSWORD_TYPE Type,const wchar *FileName, + SecPassword *Password,CheckPassword *CheckPwd) { return false; } diff --git a/deps/unrar/ulinks.cpp b/deps/unrar/ulinks.cpp index d198f2e06..141a97fec 100644 --- a/deps/unrar/ulinks.cpp +++ b/deps/unrar/ulinks.cpp @@ -50,7 +50,28 @@ static bool IsFullPath(const char *PathA) // Unix ASCII version. } -bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName) +// For security purpose we prefer to be sure that CharToWide completed +// successfully and even if it truncated a string for some reason, +// it didn't affect the number of path related characters we analyze +// in IsRelativeSymlinkSafe later. +// This check is likely to be excessive, but let's keep it anyway. +static bool SafeCharToWide(const char *Src,wchar *Dest,size_t DestSize) +{ + if (!CharToWide(Src,Dest,DestSize) || *Dest==0) + return false; + uint SrcChars=0,DestChars=0; + for (uint I=0;Src[I]!=0;I++) + if (Src[I]=='/' || Src[I]=='.') + SrcChars++; + for (uint I=0;Dest[I]!=0;I++) + if (Dest[I]=='/' || Dest[I]=='.') + DestChars++; + return SrcChars==DestChars; +} + + +static bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc, + const wchar *LinkName,bool &UpLink) { char Target[NM]; if (IsLink(Arc.FileHead.FileAttr)) @@ -72,21 +93,22 @@ bool ExtractUnixLink30(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const w return true; wchar TargetW[NM]; - CharToWide(Target,TargetW,ASIZE(TargetW)); - // Check for *TargetW==0 to catch CharToWide failure. + if (!SafeCharToWide(Target,TargetW,ASIZE(TargetW))) + return false; // Use Arc.FileHead.FileName instead of LinkName, since LinkName // can include the destination path as a prefix, which can // confuse IsRelativeSymlinkSafe algorithm. - if (!Cmd->AbsoluteLinks && (*TargetW==0 || IsFullPath(TargetW) || + if (!Cmd->AbsoluteLinks && (IsFullPath(TargetW) || !IsRelativeSymlinkSafe(Cmd,Arc.FileHead.FileName,LinkName,TargetW))) return false; + UpLink=strstr(Target,"..")!=NULL; return UnixSymlink(Cmd,Target,LinkName,&Arc.FileHead.mtime,&Arc.FileHead.atime); } return false; } -bool ExtractUnixLink50(CommandData *Cmd,const wchar *Name,FileHeader *hd) +static bool ExtractUnixLink50(CommandData *Cmd,const wchar *Name,FileHeader *hd) { char Target[NM]; WideToChar(hd->RedirName,Target,ASIZE(Target)); @@ -100,11 +122,15 @@ bool ExtractUnixLink50(CommandData *Cmd,const wchar *Name,FileHeader *hd) return false; DosSlashToUnix(Target,Target,ASIZE(Target)); } + + wchar TargetW[NM]; + if (!SafeCharToWide(Target,TargetW,ASIZE(TargetW))) + return false; // Use hd->FileName instead of LinkName, since LinkName can include // the destination path as a prefix, which can confuse // IsRelativeSymlinkSafe algorithm. - if (!Cmd->AbsoluteLinks && (IsFullPath(Target) || - !IsRelativeSymlinkSafe(Cmd,hd->FileName,Name,hd->RedirName))) + if (!Cmd->AbsoluteLinks && (IsFullPath(TargetW) || + !IsRelativeSymlinkSafe(Cmd,hd->FileName,Name,TargetW))) return false; return UnixSymlink(Cmd,Target,Name,&hd->mtime,&hd->atime); } diff --git a/deps/unrar/unicode.cpp b/deps/unrar/unicode.cpp index 641f6c892..73b09bb22 100644 --- a/deps/unrar/unicode.cpp +++ b/deps/unrar/unicode.cpp @@ -229,10 +229,11 @@ void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success) #endif -// SrcSize is in wide characters, not in bytes. -byte* WideToRaw(const wchar *Src,byte *Dest,size_t SrcSize) +// SrcSize is source data size in wide characters, not in bytes. +// DestSize is the maximum allowed destination size. +byte* WideToRaw(const wchar *Src,size_t SrcSize,byte *Dest,size_t DestSize) { - for (size_t I=0;I>8); @@ -601,59 +602,6 @@ char* SupportDBCS::charnext(const char *s) // to break string processing loops. return (char *)(IsLeadByte[(byte)*s] && s[1]!=0 ? s+2:s+1); } - - -size_t SupportDBCS::strlend(const char *s) -{ - size_t Length=0; - while (*s!=0) - { - if (IsLeadByte[(byte)*s]) - s+=2; - else - s++; - Length++; - } - return(Length); -} - - -char* SupportDBCS::strchrd(const char *s, int c) -{ - while (*s!=0) - if (IsLeadByte[(byte)*s]) - s+=2; - else - if (*s==c) - return((char *)s); - else - s++; - return(NULL); -} - - -void SupportDBCS::copychrd(char *dest,const char *src) -{ - dest[0]=src[0]; - if (IsLeadByte[(byte)src[0]]) - dest[1]=src[1]; -} - - -char* SupportDBCS::strrchrd(const char *s, int c) -{ - const char *found=NULL; - while (*s!=0) - if (IsLeadByte[(byte)*s]) - s+=2; - else - { - if (*s==c) - found=s; - s++; - } - return((char *)found); -} #endif diff --git a/deps/unrar/unicode.hpp b/deps/unrar/unicode.hpp index 031ac09ab..9bfd9c5dc 100644 --- a/deps/unrar/unicode.hpp +++ b/deps/unrar/unicode.hpp @@ -7,7 +7,7 @@ bool WideToChar(const wchar *Src,char *Dest,size_t DestSize); bool CharToWide(const char *Src,wchar *Dest,size_t DestSize); -byte* WideToRaw(const wchar *Src,byte *Dest,size_t SrcSize); +byte* WideToRaw(const wchar *Src,size_t SrcSize,byte *Dest,size_t DestSize); wchar* RawToWide(const byte *Src,wchar *Dest,size_t DestSize); void WideToUtf(const wchar *Src,char *Dest,size_t DestSize); size_t WideToUtfSize(const wchar *Src); @@ -33,34 +33,19 @@ class SupportDBCS public: SupportDBCS(); void Init(); - char* charnext(const char *s); - size_t strlend(const char *s); - char *strchrd(const char *s, int c); - char *strrchrd(const char *s, int c); - void copychrd(char *dest,const char *src); bool IsLeadByte[256]; bool DBCSMode; }; - extern SupportDBCS gdbcs; inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);} -inline size_t strlend(const char *s) {return (uint)(gdbcs.DBCSMode ? gdbcs.strlend(s):strlen(s));} -inline char* strchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strchrd(s,c):strchr(s,c));} -inline char* strrchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strrchrd(s,c):strrchr(s,c));} -inline void copychrd(char *dest,const char *src) {if (gdbcs.DBCSMode) gdbcs.copychrd(dest,src); else *dest=*src;} -inline bool IsDBCSMode() {return(gdbcs.DBCSMode);} -inline void InitDBCS() {gdbcs.Init();} +inline bool IsDBCSMode() {return gdbcs.DBCSMode;} #else #define charnext(s) ((s)+1) -#define strlend strlen -#define strchrd strchr -#define strrchrd strrchr -#define IsDBCSMode() (true) -inline void copychrd(char *dest,const char *src) {*dest=*src;} +#define IsDBCSMode() (false) #endif diff --git a/deps/unrar/unpack.cpp b/deps/unrar/unpack.cpp index 5f577d85d..1597505ea 100644 --- a/deps/unrar/unpack.cpp +++ b/deps/unrar/unpack.cpp @@ -16,7 +16,7 @@ #include "unpack50frag.cpp" Unpack::Unpack(ComprDataIO *DataIO) -:Inp(false),VMCodeInp(false) +:Inp(true),VMCodeInp(true) { UnpIO=DataIO; Window=NULL; @@ -49,8 +49,8 @@ Unpack::~Unpack() { InitFilters30(false); - //if (Window!=NULL) - // free(Window); + if (Window!=NULL) + free(Window); #ifdef RAR_SMP delete UnpThreadPool; delete[] ReadBufMT; @@ -117,7 +117,7 @@ void Unpack::Init(size_t WinSize,bool Solid) if (Grow && Fragmented) throw std::bad_alloc(); - byte *NewWindow=Fragmented ? NULL : (byte *)hcwin; + byte *NewWindow=Fragmented ? NULL : (byte *)malloc(WinSize); if (NewWindow==NULL) if (Grow || WinSize<0x1000000) @@ -130,7 +130,7 @@ void Unpack::Init(size_t WinSize,bool Solid) { if (Window!=NULL) // If allocated by preceding files. { - //free(Window); + free(Window); Window=NULL; } FragWindow.Init(WinSize); @@ -141,7 +141,7 @@ void Unpack::Init(size_t WinSize,bool Solid) { // Clean the window to generate the same output when unpacking corrupt // RAR files, which may access unused areas of sliding dictionary. - //memset(NewWindow,0,WinSize); + memset(NewWindow,0,WinSize); // If Window is not NULL, it means that window size has grown. // In solid streams we need to copy data to a new window in such case. @@ -151,8 +151,8 @@ void Unpack::Init(size_t WinSize,bool Solid) for (size_t I=1;I<=MaxWinSize;I++) NewWindow[(UnpPtr-I)&(WinSize-1)]=Window[(UnpPtr-I)&(MaxWinSize-1)]; - //if (Window!=NULL) - // free(Window); + if (Window!=NULL) + free(Window); Window=NewWindow; } @@ -324,7 +324,7 @@ void Unpack::MakeDecodeTables(byte *LengthTable,DecodeTable *Dec,uint Size) Dec->QuickBits=MAX_QUICK_DECODE_BITS; break; default: - Dec->QuickBits=MAX_QUICK_DECODE_BITS-3; + Dec->QuickBits=MAX_QUICK_DECODE_BITS>3 ? MAX_QUICK_DECODE_BITS-3 : 0; break; } diff --git a/deps/unrar/unpack.hpp b/deps/unrar/unpack.hpp index f76ddcc86..3e23cd320 100644 --- a/deps/unrar/unpack.hpp +++ b/deps/unrar/unpack.hpp @@ -23,8 +23,8 @@ // allocation. Must be equal or larger than MAX_ANALYZE_SIZE. #define MAX_FILTER_BLOCK_SIZE 0x400000 -// Write data in 4 MB or smaller blocks. Must not exceed PACK_MAX_WRITE, -// so we keep a number of buffered filters in unpacker reasonable. +// Write data in 4 MB or smaller blocks. Must not exceed PACK_MAX_READ, +// so we keep the number of buffered filters in unpacker reasonable. #define UNPACK_MAX_WRITE 0x400000 // Decode compressed bit fields to alphabet numbers. @@ -93,17 +93,17 @@ struct UnpackBlockTables #ifdef RAR_SMP enum UNP_DEC_TYPE { - UNPDT_LITERAL,UNPDT_MATCH,UNPDT_FULLREP,UNPDT_REP,UNPDT_FILTER + UNPDT_LITERAL=0,UNPDT_MATCH,UNPDT_FULLREP,UNPDT_REP,UNPDT_FILTER }; struct UnpackDecodedItem { - UNP_DEC_TYPE Type; + byte Type; // 'byte' instead of enum type to reduce memory use. ushort Length; union { uint Distance; - byte Literal[4]; + byte Literal[8]; // Store up to 8 chars here to speed up extraction. }; }; diff --git a/deps/unrar/unpack30.cpp b/deps/unrar/unpack30.cpp index 346bcf970..7c2adfab2 100644 --- a/deps/unrar/unpack30.cpp +++ b/deps/unrar/unpack30.cpp @@ -55,7 +55,7 @@ void Unpack::Unpack29(bool Solid) if (!UnpReadBuf30()) break; } - if (((WrPtr-UnpPtr) & MaxWinMask)<260 && WrPtr!=UnpPtr) + if (((WrPtr-UnpPtr) & MaxWinMask)<=MAX3_INC_LZ_MATCH && WrPtr!=UnpPtr) { UnpWriteBuf30(); if (WrittenFileSize>DestUnpSize) @@ -637,7 +637,7 @@ bool Unpack::ReadTables30() if (BitField & 0x8000) { UnpBlockType=BLOCK_PPM; - return(PPM.DecodeInit(this,PPMEscChar,hcppm)); + return(PPM.DecodeInit(this,PPMEscChar)); } UnpBlockType=BLOCK_LZ; diff --git a/deps/unrar/unpack50.cpp b/deps/unrar/unpack50.cpp index 99119507f..e040907c2 100644 --- a/deps/unrar/unpack50.cpp +++ b/deps/unrar/unpack50.cpp @@ -42,7 +42,7 @@ void Unpack::Unpack5(bool Solid) break; } - if (((WriteBorder-UnpPtr) & MaxWinMask)DestUnpSize) @@ -93,7 +93,7 @@ void Unpack::Unpack5(bool Solid) } else { - Distance+=Inp.getbits32()>>(32-DBits); + Distance+=Inp.getbits()>>(16-DBits); Inp.addbits(DBits); } } diff --git a/deps/unrar/unpack50mt.cpp b/deps/unrar/unpack50mt.cpp index 691ac8e99..82c9c4a8c 100644 --- a/deps/unrar/unpack50mt.cpp +++ b/deps/unrar/unpack50mt.cpp @@ -345,7 +345,7 @@ void Unpack::UnpackDecode(UnpackThreadData &D) if (D.DecodedSize>1) { UnpackDecodedItem *PrevItem=CurItem-1; - if (PrevItem->Type==UNPDT_LITERAL && PrevItem->Length<3) + if (PrevItem->Type==UNPDT_LITERAL && PrevItem->LengthLiteral)-1) { PrevItem->Length++; PrevItem->Literal[PrevItem->Length]=(byte)MainSlot; @@ -388,7 +388,7 @@ void Unpack::UnpackDecode(UnpackThreadData &D) } else { - Distance+=D.Inp.getbits32()>>(32-DBits); + Distance+=D.Inp.getbits()>>(16-DBits); D.Inp.addbits(DBits); } } @@ -451,7 +451,7 @@ bool Unpack::ProcessDecoded(UnpackThreadData &D) while (ItemDestUnpSize) @@ -461,10 +461,10 @@ bool Unpack::ProcessDecoded(UnpackThreadData &D) if (Item->Type==UNPDT_LITERAL) { #if defined(LITTLE_ENDIAN) && defined(ALLOW_MISALIGNED) - if (Item->Length==3 && UnpPtrLength==7 && UnpPtrLiteral; - UnpPtr+=4; + *(uint64 *)(Window+UnpPtr)=*(uint64 *)(Item->Literal); + UnpPtr+=8; } else #endif @@ -559,7 +559,7 @@ bool Unpack::UnpackLargeBlock(UnpackThreadData &D) break; } } - if (((WriteBorder-UnpPtr) & MaxWinMask)DestUnpSize) diff --git a/deps/unrar/version.hpp b/deps/unrar/version.hpp index 922c67ed8..9af752ed0 100644 --- a/deps/unrar/version.hpp +++ b/deps/unrar/version.hpp @@ -1,6 +1,6 @@ #define RARVER_MAJOR 6 -#define RARVER_MINOR 1 -#define RARVER_BETA 0 -#define RARVER_DAY 7 -#define RARVER_MONTH 4 -#define RARVER_YEAR 2021 +#define RARVER_MINOR 22 +#define RARVER_BETA 1 +#define RARVER_DAY 14 +#define RARVER_MONTH 5 +#define RARVER_YEAR 2023 diff --git a/deps/unrar/volume.cpp b/deps/unrar/volume.cpp index 001a9673a..4924d8d0e 100644 --- a/deps/unrar/volume.cpp +++ b/deps/unrar/volume.cpp @@ -1,15 +1,15 @@ #include "rar.hpp" #ifdef RARDLL -static bool DllVolChange(RAROptions *Cmd,wchar *NextName,size_t NameSize); -static bool DllVolNotify(RAROptions *Cmd,wchar *NextName); +static bool DllVolChange(CommandData *Cmd,wchar *NextName,size_t NameSize); +static bool DllVolNotify(CommandData *Cmd,wchar *NextName); #endif bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Command) { - RAROptions *Cmd=Arc.GetRAROptions(); + CommandData *Cmd=Arc.GetCommandData(); HEADER_TYPE HeaderType=Arc.GetHeaderType(); FileHeader *hd=HeaderType==HEAD_SERVICE ? &Arc.SubHead:&Arc.FileHead; @@ -25,10 +25,12 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma uiMsg(UIERROR_CHECKSUMPACKED, Arc.FileName, hd->FileName); } + bool PrevVolEncrypted=Arc.Encrypted; + int64 PosBeforeClose=Arc.Tell(); if (DataIO!=NULL) - DataIO->ProcessedArcSize+=Arc.FileLength(); + DataIO->ProcessedArcSize+=DataIO->LastArcSize; Arc.Close(); @@ -40,12 +42,20 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma #if !defined(SFX_MODULE) && !defined(RARDLL) bool RecoveryDone=false; #endif - bool FailedOpen=false,OldSchemeTested=false; + bool OldSchemeTested=false; + bool FailedOpen=false; // No more next volume open attempts if true. #if !defined(SILENT) // In -vp mode we force the pause before next volume even if it is present // and even if we are on the hard disk. It is important when user does not // want to process partially downloaded volumes preliminary. + // 2022.01.11: In WinRAR 6.10 beta versions we tried to ignore VolumePause + // if we could open the next volume with FMF_OPENEXCLUSIVE. But another + // developer asked us to return the previous behavior and always prompt + // for confirmation. They want to control when unrar continues, because + // the next file might not be fully decoded yet. They write chunks of data + // and then close the file again until the next chunk comes in. + if (Cmd->VolumePause && !uiAskNextVolume(NextName,ASIZE(NextName))) FailedOpen=true; #endif @@ -127,6 +137,16 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma return false; #endif + if (Arc.Encrypted!=PrevVolEncrypted) + { + // There is no legitimate reason for encrypted header state to be + // changed in the middle of volume sequence. So we abort here to prevent + // replacing an encrypted header volume to unencrypted and adding + // unexpected files by third party to encrypted extraction. + uiMsg(UIERROR_BADARCHIVE,Arc.FileName); + ErrHandler.Exit(RARX_FATAL); + } + if (SplitHeader) Arc.SearchBlock(HeaderType); else @@ -151,10 +171,9 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma DataIO->UnpVolume=hd->SplitAfter; DataIO->SetPackedSizeToRead(hd->PackSize); } -#ifdef SFX_MODULE - DataIO->UnpArcSize=Arc.FileLength(); -#endif - + + DataIO->AdjustTotalArcSize(&Arc); + // Reset the size of packed data read from current volume. It is used // to display the total progress and preceding volumes are already // compensated with ProcessedArcSize, so we need to reset this variable. @@ -171,14 +190,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Comma #ifdef RARDLL -#if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) -// Disable the run time stack check for unrar.dll, so we can manipulate -// with ChangeVolProc call type below. Run time check would intercept -// a wrong ESP before we restore it. -#pragma runtime_checks( "s", off ) -#endif - -bool DllVolChange(RAROptions *Cmd,wchar *NextName,size_t NameSize) +bool DllVolChange(CommandData *Cmd,wchar *NextName,size_t NameSize) { bool DllVolChanged=false,DllVolAborted=false; @@ -212,28 +224,7 @@ bool DllVolChange(RAROptions *Cmd,wchar *NextName,size_t NameSize) { char NextNameA[NM]; WideToChar(NextName,NextNameA,ASIZE(NextNameA)); - // Here we preserve ESP value. It is necessary for those developers, - // who still define ChangeVolProc callback as "C" type function, - // even though in year 2001 we announced in unrar.dll whatsnew.txt - // that it will be PASCAL type (for compatibility with Visual Basic). -#if defined(_MSC_VER) -#ifndef _WIN_64 - __asm mov ebx,esp -#endif -#elif defined(_WIN_ALL) && defined(__BORLANDC__) - _EBX=_ESP; -#endif int RetCode=Cmd->ChangeVolProc(NextNameA,RAR_VOL_ASK); - - // Restore ESP after ChangeVolProc with wrongly defined calling - // convention broken it. -#if defined(_MSC_VER) -#ifndef _WIN_64 - __asm mov esp,ebx -#endif -#elif defined(_WIN_ALL) && defined(__BORLANDC__) - _ESP=_EBX; -#endif if (RetCode==0) DllVolAborted=true; else @@ -255,7 +246,7 @@ bool DllVolChange(RAROptions *Cmd,wchar *NextName,size_t NameSize) #ifdef RARDLL -bool DllVolNotify(RAROptions *Cmd,wchar *NextName) +bool DllVolNotify(CommandData *Cmd,wchar *NextName) { char NextNameA[NM]; WideToChar(NextName,NextNameA,ASIZE(NextNameA)); @@ -268,21 +259,10 @@ bool DllVolNotify(RAROptions *Cmd,wchar *NextName) } if (Cmd->ChangeVolProc!=NULL) { -#if defined(_WIN_ALL) && !defined(_MSC_VER) && !defined(__MINGW32__) - _EBX=_ESP; -#endif int RetCode=Cmd->ChangeVolProc(NextNameA,RAR_VOL_NOTIFY); -#if defined(_WIN_ALL) && !defined(_MSC_VER) && !defined(__MINGW32__) - _ESP=_EBX; -#endif if (RetCode==0) return false; } return true; } - -#if defined(RARDLL) && defined(_MSC_VER) && !defined(_WIN_64) -// Restore the run time stack check for unrar.dll. -#pragma runtime_checks( "s", restore ) -#endif #endif diff --git a/deps/unrar/volume.hpp b/deps/unrar/volume.hpp index 2d6a6d5c1..4ada10910 100644 --- a/deps/unrar/volume.hpp +++ b/deps/unrar/volume.hpp @@ -1,10 +1,7 @@ #ifndef _RAR_VOLUME_ #define _RAR_VOLUME_ -void SplitArchive(Archive &Arc,FileHeader *fh,int64 *HeaderPos, - ComprDataIO *DataIO); bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName, wchar Command); -void SetVolWrite(Archive &Dest,int64 VolSize); #endif diff --git a/deps/unrar/win32stm.cpp b/deps/unrar/win32stm.cpp index eaa43be2d..048fd86b6 100644 --- a/deps/unrar/win32stm.cpp +++ b/deps/unrar/win32stm.cpp @@ -111,16 +111,23 @@ void ExtractStreams(Archive &Arc,const wchar *FileName,bool TestMode) wcsncatz(FullName,StreamName,ASIZE(FullName)); + FindData fd; - bool Found=FindFile::FastFind(FileName,&fd); + bool HostFound=FindFile::FastFind(FileName,&fd); if ((fd.FileAttr & FILE_ATTRIBUTE_READONLY)!=0) SetFileAttr(FileName,fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); File CurFile; - if (CurFile.WCreate(FullName) && Arc.ReadSubData(NULL,&CurFile,false)) - CurFile.Close(); + + if (CurFile.WCreate(FullName)) + { + if (Arc.ReadSubData(NULL,&CurFile,false)) + CurFile.Close(); + } + + // Restoring original file timestamps. File HostFile; - if (Found && HostFile.Open(FileName,FMF_OPENSHARED|FMF_UPDATE)) + if (HostFound && HostFile.Open(FileName,FMF_OPENSHARED|FMF_UPDATE)) SetFileTime(HostFile.GetHandle(),&fd.ftCreationTime,&fd.ftLastAccessTime, &fd.ftLastWriteTime); diff --git a/deps/zlib/contrib/minizip/mztools.c b/deps/zlib/contrib/minizip/mztools.c index 96891c2e0..5808aac95 100644 --- a/deps/zlib/contrib/minizip/mztools.c +++ b/deps/zlib/contrib/minizip/mztools.c @@ -38,7 +38,7 @@ uLong* bytesRecovered; FILE* fpZip = fopen(file, "rb"); FILE* fpOut = fopen(fileOut, "wb"); FILE* fpOutCD = fopen(fileOutTmp, "wb"); - if (fpZip != NULL && fpOut != NULL) { + if (fpZip != NULL && fpOut != NULL && fpOutCD !=NULL) { int entries = 0; uLong totalBytes = 0; char header[30]; diff --git a/docs/changes.txt b/docs/changes.txt index c3e15d15c..bef9dd64d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -4,14 +4,20 @@ ## Algorithms ## +- Added hash-mode: 1Password, mobilekeychain (1Password 8) +- Added hash-mode: Adobe AEM (SSPR, SHA-256 with Salt) +- Added hash-mode: Adobe AEM (SSPR, SHA-512 with Salt) - Added hash-mode: Anope IRC Services (enc_sha256) -- Added hash-mode: BLAKE2s-256 - Added hash-mode: Bisq .wallet (scrypt) - Added hash-mode: Bitcoin raw private key (P2PKH) - Added hash-mode: Bitcoin raw private key (P2SH(P2WPKH)) - Added hash-mode: Bitcoin raw private key (P2WPKH, Bech32) +- Added hash-mode: BLAKE2s-256 +- Added hash-mode: CubeCart (Whirlpool($salt.$pass.$salt) - Added hash-mode: Dahua NVR/DVR/HVR (md5($salt1.strtoupper(md5($salt2.$pass)))) - Added hash-mode: DANE RFC7929/RFC8162 SHA2-256 +- Added hash-mode: Dogechain.info Wallet +- Added hash-mode: Empire CMS (Admin password) - Added hash-mode: ENCsecurity Datavault (MD5/keychain) - Added hash-mode: ENCsecurity Datavault (MD5/no keychain) - Added hash-mode: ENCsecurity Datavault (PBKDF2/keychain) @@ -19,14 +25,41 @@ - Added hash-mode: GPG (AES-128/AES-256 (SHA-1($pass))) - Added hash-mode: GPG (AES-128/AES-256 (SHA-256($pass))) - Added hash-mode: GPG (AES-128/AES-256 (SHA-512($pass))) +- Added hash-mode: GPG (CAST5 (SHA-1($pass))) +- Added hash-mode: Kerberos 5, etype 17, AS-REP +- Added hash-mode: Kerberos 5, etype 18, AS-REP +- Added hash-mode: MetaMask Mobile Wallet - Added hash-mode: MetaMask Wallet (short hash, plaintext check) +- Added hash-mode: NetIQ SSPR (MD5) +- Added hash-mode: NetIQ SSPR (PBKDF2WithHmacSHA1) +- Added hash-mode: NetIQ SSPR (PBKDF2WithHmacSHA256) +- Added hash-mode: NetIQ SSPR (PBKDF2WithHmacSHA512) +- Added hash-mode: NetIQ SSPR (SHA1) +- Added hash-mode: NetIQ SSPR (SHA-1 with Salt) +- Added hash-mode: NetIQ SSPR (SHA-256 with Salt) +- Added hash-mode: NetIQ SSPR (SHA-512 with Salt) +- Added hash-mode: RSA Security Analytics / NetWitness (sha256) - Added hash-mode: SecureCRT MasterPassphrase v2 - Added hash-mode: Veeam VB - Added hash-mode: bcrypt(sha256($pass)) - Added hash-mode: HMAC-RIPEMD160 (key = $pass) - Added hash-mode: HMAC-RIPEMD160 (key = $salt) +- Added hash-mode: md5($salt1.sha1($salt2.$pass)) +- Added hash-mode: md5(md5($pass.$salt)) - Added hash-mode: md5(md5($salt).md5(md5($pass))) - Added hash-mode: Domain Cached Credentials (DCC), MS Cache (NT) +- Added hash-mode: md5(md5(md5($pass).$salt1).$salt2) +- Added hash-mode: md5(md5(md5($pass)).$salt) +- Added hash-mode: md5(sha1($pass.$salt)) +- Added hash-mode: md5(sha1($salt.$pass)) +- Added hash-mode: sha512(sha512($pass).$salt) +- Added hash-mode: sha512(sha512_bin($pass).$salt) + +## +## Features +## + +- Added new feature (-Y) that creates N virtual instances for each device in your system at the cost of N times the device memory consumption ## ## Performance @@ -39,23 +72,66 @@ ## - Fixed keys extraction in luks2hashcat - now extracts all active keys -- Prevent Hashcat from hanging by checking during startup that the output file is a named pipe +- Prevent Hashcat from hanging by checking during startup whether the output file is a named pipe - Fixed debug mode 5 by adding the missing colon between original-word and finding-rule -- Skip generated rule that was the result of chaining rule operation and caused this generated rule to exceed the maximum number of function calls +- Skip chained generated rules that exceed the maximum number of function calls - Fixed incorrect plaintext check for 25400 and 26610. Increased plaintext check to 32 bytes to prevent false positives. +- Fixed bug in --stdout that caused certain rules to malfunction +- Fixed bug in 18400 module_hash_encode +- Fixed bug in 26900 module_hash_encode +- Fixed bug in 29600 module OPTS_TYPE setting +- Fixed bug in grep out-of-memory workaround on Unit Test +- Fixed bug in input_tokenizer when TOKEN_ATTR_FIXED_LENGTH is used and refactor modules +- Fixed a bug in all SCRYPT-based hash modes with Apple Metal +- Added verification of token buffer length when using TOKEN_ATTR_FIXED_LENGTH +- Fixed build failed for 4410 with vector width > 1 +- Fixed build failed for 10700 optimized with Apple Metal +- Fixed build failed for 13772 and 13773 with Apple Metal +- Fixed build failed for 18400 with Apple Metal +- Fixed build failed for 18600 with Apple Metal +- Fixed build failure for almost all hash modes that make use of hc_swap64 and/or hc_swap64_S with Apple Metal +- Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 +- Fixed incompatible pointer types (salt1 and salt2 buf) in 3730 a3 kernel +- Fixed minimum password length in module of hash-mode 28200 +- Fixed maximum password length in module/test_module of hash-mode 2410 +- Handle signed/unsigned PDF permission P value for all PDF hash-modes +- Fixed minimum password length in module of hash-mode 29800 +- Fixed maximum password length in module/test_module of hash-mode 2400 +- Fixed buffer overflow on module_26600.c / module_hash_encode() +- Fixed bug in 23800/unrar with Apple Silicon +- Fixed vector datatypes usage for HIP +- Fixed out-of-boundary read when a fast hash defines a kernel_loops_min value higher than the amplifiers provided by the user ## ## Technical ## -- AMD Driver: Updated requirements for AMD Windows drivers to "AMD Adrenalin Edition" (Adrenalin 22.5.1 exactly) +- AMD Driver: Updated requirements for AMD Windows drivers to "AMD Adrenalin Edition" (23.7.2 or later) and "AMD HIP SDK" (23.Q3 or later) - Apple Driver: Automatically enable GPU support on Apple OpenCL instead of CPU support - Apple Driver: Updated requirements to use Apple OpenCL API to macOS 13.0 - use -- Backend Checks: Described workaround in error message when detecting more than 64 backend devices +- Backend Checks: Describe workaround in error message when detecting more than 64 backend devices +- Brain: Added sanity check and corresponding error message for invalid --brain-port values +- Dependencies: Updated LZMA SDK to 22.01 +- Dependencies: Updated unrar source to 6.2.7 +- Building: Support building windows binaries on macOS using MinGW +- Dependencies: Updated OpenCL-Headers to v2023.04.17 +- Documents: Updated BUILD.md and added BUILD_macOS.md (containing instructions for building windows binaries on macOS) - Modules: Added support for non-zero IVs for -m 6800 (Lastpass). Also added `tools/lastpass2hashcat.py` +- Open Document Format: Added support for small documents with content length < 1024 - Status Code: Add specific return code for self-test fail (-11) -- SCRYPT: Increase buffer sizes in module for hash mode 8900 to allow longer SCRYPT digests -- Unicode: Update UTF8 to UTF16 conversion to match RFC 3629 +- Scrypt: Increase buffer sizes in module for hash mode 8900 to allow longer scrypt digests +- Unicode: Update UTF-8 to UTF-16 conversion to match RFC 3629 +- User Options: Added error message when mixing --username and --show to warn users of exponential delay +- MetaMask: update extraction tool to support MetaMask Mobile wallets +- SecureCRT MasterPassphrase v2: update module, pure kernels and test unit. Add optimized kernels. +- Metal Backend: added workaround to prevent 'Infinite Loop' bug when build kernels +- Metal Backend: allow use of devices with Metal if runtime version is >= 200 +- Metal Backend: disable Metal devices only if at least one OpenCL device is active +- User Options: added --metal-compiler-runtime option +- Hardware Monitor: avoid sprintf in src/ext_iokit.c +- Help: show supported hash-modes only with -hh +- Makefile: prevent make failure with Apple Silicon in case of partial rebuild +- Rules: Rename best64.rule to best66.rule and remove the unknown section from it * changes v6.2.5 -> v6.2.6 @@ -90,16 +166,17 @@ ## - Added new backend support for Metal, the OpenCL replacement API on Apple -- Added support to building universal macOS binary on Apple Silicon -- Added support to use --debug-mode in attack-mode 9 (Association Attack) +- Added support for building universal macOS binary on Apple Silicon +- Added support for using --debug-mode in attack-mode 9 (association attack) - Added hex encoding format for --separator option - Added password candidates range to --status-json output - Added parameter to Bitwarden mode for second iteration count -- Added support to use 'John the Ripper' hash format with hash-type 13100 -- Added support to use 'John the Ripper' hash format with hash-type 18200 -- Added the hash extraction scripts from the tools folder also to beta/release versions +- Added support for using 'John the Ripper' hash format with hash-type 13100 +- Added support for using 'John the Ripper' hash format with hash-type 18200 +- Added hash extraction scripts from the tools folder to beta/release versions - Added user advice if a hash throws 'token length exception' - Added tunings/ folder in order to replace hashcat.hctune. Configuration files with *.hctune suffix are automatically load on startup +- Added link to 'ubernoob' documentation when no parameters are supplied on Windows ## ## Bugs @@ -153,7 +230,7 @@ - Hardware Monitor: Add support for GPU device utilization readings using iokit on Apple Silicon (OpenCL and Metal) - Hash Info: show more information (Updated Hash-Format. Added Autodetect, Self-Test, Potfile and Plaintext encoding) - HIP Backend: moved functions to ext_hip.c/ext_hiprtc.c and includes to ext_hip.h/ext_hiprtc.h -- HIP Backend: removed unused functions from hiprtc to workaroung missing function symbols on windows dll +- HIP Backend: removed unused functions from hiprtc to workaround missing function symbols on windows dll - Kernels: Refactored standard kernel declaration to use a structure holding u32/u64 attributes to reduce the number of attributes - Kernels: Refactored standard kernel includes, KERN_ATTR macros and RC4 cipher functions, in order to support Apple Metal runtime - Kernels: Set the default Address Space Qualifier for any pointer, in order to support Apple Metal runtime @@ -179,7 +256,7 @@ - Rules: Add support to include source wordlist in debugging format - Rules: Update hand-written rulesets to covers years up to 2029 - Status code: updated negative status code (added kernel create failure and resync) -- Status code: updated negative status code, usefull in Unit tests engine (test.sh) +- Status code: updated negative status code, useful in Unit tests engine (test.sh) - Terminal: Increased size of hash name column in `--help` and `--identify` options - Terminal: Limit output length of example hash in --example-hash mode to 200. Use --mach to see full example hash - Terminal: show empty OpenCL platforms only in backend information mode @@ -591,7 +668,7 @@ - Building: Fixed build warnings on macOS for unrar sources - Building: Fixed test for DARWIN_VERSION in Makefile - Commandline Options: Removed option --example-hashes, now an alias of --hash-info -- Compute API: Skipping devices instead of stop if error occured in initialization +- Compute API: Skipping devices instead of stop if error occurred in initialization - Documentation: Added 3rd party licenses to docs/license_libs - Hash-Mode 8900 (Scrypt): Changed default benchmark scrypt parameters from 1k:1:1 to 16k:8:1 (default) - Hash-Mode 11600 (7-Zip): Improved memory handling (alloc and free) for the hook function @@ -657,7 +734,7 @@ - Hcchr Files: Renamed some .charset files into .hcchr files - Hash-Mode 21200 (md5(sha1($salt).md5($pass))): Improved speed by using pre-computed SHA1 - OpenCL Devices: Utilize PCI domain to improve alias device detection -- OpenCL Kernels: Added datatypes to literals of enum costants +- OpenCL Kernels: Added datatypes to literals of enum constants - OpenCL Kernels: Added pure kernels for hash-mode 600 (BLAKE2b-512) - OpenCL Runtime: Add some unstable warnings for some SHA512 based algorithms on AMD GPU on macOS - OpenCL Runtime: Reinterpret return code CL_DEVICE_NOT_FOUND from clGetDeviceIDs() as non-fatal @@ -790,7 +867,7 @@ - Bitcoin Wallet: Be more user friendly by allowing a larger data range for ckey and public_key - Brain: Added new parameter --brain-server-timer to specify seconds between scheduled backups -- Building: Fix for library compilation failure due to multiple defenition of sbob_xx64() +- Building: Fix for library compilation failure due to multiple definition of sbob_xx64() - Cracking bcrypt and Password Safe v2: Use feedback from the compute API backend to dynamically calculate optimal thread count - Dictstat: On Windows, the st_ino attribute in the stat struct is not set, which can lead to invalid cache hits. Added the filename to the database entry. - Documents: Added README on how to build hashcat on Cygwin, MSYS2 and WSL @@ -828,7 +905,7 @@ ## Technical ## -- Backend Interface: Added new options --backend-ignore-cuda and --backend-ingore-opencl to prevent CUDA and/or OpenCL API from being used +- Backend Interface: Added new options --backend-ignore-cuda and --backend-ignore-opencl to prevent CUDA and/or OpenCL API from being used - Binary Distribution: Removed 32-bit binary executables - Building: On macOS, switch from ar to /usr/bin/ar to improve building compatibility - Building: Skipping Travis/Appveyor build for non-code changes @@ -1186,7 +1263,7 @@ - Added option --optimized-kernel-enable to use faster kernels but limit the maximum supported password- and salt-length - Added self-test functionality to detect broken OpenCL runtimes on startup - Added option --self-test-disable to disable self-test functionality on startup -- Added option --wordlist-autohex-disable to disable the automatical conversion of $HEX[] words from the word list +- Added option --wordlist-autohex-disable to disable the automatic conversion of $HEX[] words from the word list - Added option --example-hashes to show an example hash for each hash-mode - Removed option --weak-hash-check (zero-length password check) to increase startup time, it also causes many Trap 6 error on macOS @@ -1203,7 +1280,7 @@ - Fixed a buffer overflow in mangle_dupechar_last function - Fixed a calculation error in get_power() leading to errors of type "BUG pw_add()!!" -- Fixed a memory problem that occured when the OpenCL folder was not found and e.g. the shared and session folder were the same +- Fixed a memory problem that occurred when the OpenCL folder was not found and e.g. the shared and session folder were the same - Fixed a missing barrier() call in the RACF OpenCL kernel - Fixed a missing salt length value in benchmark mode for SIP - Fixed an integer overflow in hash buffer size calculation @@ -1388,7 +1465,7 @@ - Added support for filtering hccapx message pairs using --hccapx-message-pair - Added support for parsing 7-Zip hashes with LZMA/LZMA2 compression indicator set to a non-zero value - Added support for decompressing LZMA1/LZMA2 data for -m 11600 = 7-Zip to validate the CRC -- Added support for automatic merge of LM halfes in case --show and --left is used +- Added support for automatic merge of LM halves in case --show and --left is used - Added support for showing all user names with --show and --left if --username was specified - Added support for GPU temperature management on cygwin build @@ -1463,7 +1540,7 @@ - Hardware Management: Bring back kernel exec timeout detection for NVidia on user request - Hardware Monitor: Fixed several memory leaks in case hash-file writing (caused by --remove) failed - Hardware Monitor: Fixed several memory leaks in case no hardware monitor sensor is found -- Hardware Monitor: In case NVML initialization failed, do not try to initialiaze NVAPI or XNVCTRL because they both depend on NVML +- Hardware Monitor: In case NVML initialization failed, do not try to initialize NVAPI or XNVCTRL because they both depend on NVML - Hash Parsing: Added additional bound checks for the SIP digest authentication (MD5) parser (-m 11400) - Hash Parsing: Make sure that all files are correctly closed whenever a hash file parsing error occurs - Helper: Added functions to check existence, type, read- and write-permissions and rewrite sources to use them instead of stat() @@ -1500,7 +1577,7 @@ ## Features ## -- Files: Use $HEX[...] in case the password includes the separater character, increases potfile reading performance +- Files: Use $HEX[...] in case the password includes the separator character, increases potfile reading performance - Files: If the user specifies a folder to scan for wordlists instead of directly a wordlist, then ignore the hidden files - Loopback: Include passwords for removed hashes present in the potfile to next loopback iteration - New option --progress-only: Quickly provides ideal progress step size and time to process on the user hashes and selected options, then quit @@ -1607,9 +1684,9 @@ The CLI (hashcat.bin or hashcat.exe) works as before but from a technical perspe ## Bugs ## -- Custom charset from file parsing code did not return an error if an error occured +- Custom charset from file parsing code did not return an error if an error occurred - Fix some clSetKernelArg() size error that caused slow modes to not work anymore in -a 1 mode -- Hash-mode 11600 = (7-Zip): Depending on input hash a clEnqueueReadBuffer(): CL_INVALID_VALUE error occured +- Hash-mode 11600 = (7-Zip): Depending on input hash a clEnqueueReadBuffer(): CL_INVALID_VALUE error occurred - Hash-mode 22 = Juniper Netscreen/SSG (ScreenOS): Fix salt length for -m 22 in benchmark mode - Hash-Mode 5500 = NetNTLMv1 + ESS: Fix loading of NetNTLMv1 + SSP hash - Hash-mode 6000 = RipeMD160: Fix typo in array index number @@ -1682,12 +1759,12 @@ The CLI (hashcat.bin or hashcat.exe) works as before but from a technical perspe - Error handling (startup): Added some missing returncode checks to get_exec_path() - Fanspeed: Check both fanpolicy and fanspeed returncode and disable retain support if any of them fail - Fanspeed: Minimum fanspeed for retain support increased to 33%, same as NV uses as default on windows -- Fanspeed: Reset PID controler settings to what they were initially +- Fanspeed: Reset PID controller settings to what they were initially - Fanspeed: Set fan speed to default on quit - File handling: Do a single write test (for files to be written later) directly on startup - File locking: Use same locking mechanism in potfile as in outfile - Hardware management: Fixed calling conventions for ADL, NvAPI and NVML on windows -- Hardware management: Improved checking for successfull load of the NVML API +- Hardware management: Improved checking for successful load of the NVML API - Hardware management: In case fanspeed can not be set, disable --gpu-temp-retain automatically - Hardware management: In case of initialization error show it only once to the user on startup - Hardware management: Refactored all code to return returncode (0 or -1) instead of data for more easy error handling @@ -1791,7 +1868,7 @@ The CLI (hashcat.bin or hashcat.exe) works as before but from a technical perspe * changes v2.01 -> v3.00: -This release markes the fusion of "hashcat" and "oclHashcat" into "hashcat". +This release marks the fusion of "hashcat" and "oclHashcat" into "hashcat". It combines all features of all hashcat projects in one project. ## @@ -1876,7 +1953,7 @@ It combines all features of all hashcat projects in one project. - Fixed a bug in line counter: conditional jump or move depends on an uninitialised value - Fixed a bug in rule-engine for NVidia devices: code for left- and right-shift were switched - Fixed a bug in dive.rule: rules were not updated after the function 'x' was renamed to 'O' -- Fixed a bug in memory allocation "OpenCL -4 error": used unitialized value in a special situation +- Fixed a bug in memory allocation "OpenCL -4 error": used uninitialized value in a special situation - Fixed a bug in memory handling: heap buffer overflow - Fixed a bug in memory handling: out of bounds access - Fixed a bug in implementation of DCC2: forced default iteration count for hashes to 10240 diff --git a/docs/credits.txt b/docs/credits.txt index bb0f95a7d..f126840c8 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -85,4 +85,4 @@ Brandon Chalk (@brandoncasaba) Jamie Riden * Web2py pbkdf2-sha512 plugin -!!! All the package maintainer of hashcat !!! +!!! All the package maintainers of hashcat !!! diff --git a/docs/hashcat-brain.md b/docs/hashcat-brain.md index ec2dc1e09..727a1fe04 100644 --- a/docs/hashcat-brain.md +++ b/docs/hashcat-brain.md @@ -203,7 +203,7 @@ Each password candidate creates a hash of 8 bytes that has to be transferred, lo So let's assume a candidate list size of 8,000,000,000. That doesn't sound like too much - especially if you want to work with rules and masks. It should be clear that using the hashcat brain against a raw MD5 is not very efficient. But now things become interesting, because of some unexpected effects that kick in. -Imagine you have a salted MD5 list, let's say VBULL which is a fast hash (not a slow hash) - and you have many of them. In thise case, each of the salts starts to work for us. +Imagine you have a salted MD5 list, let's say VBULL which is a fast hash (not a slow hash) - and you have many of them. In this case, each of the salts starts to work for us. Yes, you read that right - the more salts, the better!! diff --git a/docs/license_libs/OPENCL_HEADERS_LICENSE.txt b/docs/license_libs/OPENCL_HEADERS_LICENSE.txt index 020ce65fc..d64569567 100644 --- a/docs/license_libs/OPENCL_HEADERS_LICENSE.txt +++ b/docs/license_libs/OPENCL_HEADERS_LICENSE.txt @@ -1,25 +1,202 @@ -Copyright (c) 2008-2015 The Khronos Group Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and/or associated documentation files (the -"Materials"), to deal in the Materials without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Materials, and to -permit persons to whom the Materials are furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Materials. - -MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS -KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS -SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - https://www.khronos.org/registry/ - -THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/license_libs/XXHASH_LICENSE.txt b/docs/license_libs/XXHASH_LICENSE.txt index 7de801ed1..6bc30a1bc 100644 --- a/docs/license_libs/XXHASH_LICENSE.txt +++ b/docs/license_libs/XXHASH_LICENSE.txt @@ -1,7 +1,9 @@ xxHash Library -Copyright (c) 2012-2014, Yann Collet +Copyright (c) 2012-2020 Yann Collet All rights reserved. +BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/docs/performance.txt b/docs/performance.txt index 6b728243a..6cf9e8d1c 100644 --- a/docs/performance.txt +++ b/docs/performance.txt @@ -1,10 +1,10 @@ Performance Notes: ================== -- Always Use the latest display driver -- To significantly improve performance use -w 3 +- Always use the latest display driver +- To significantly improve performance, use -w 3 - Cracking with a mask with a fixed prefix can be slow. - Consider instead using a mode with salt as a prefix and set salt to that fixed prefix. + Instead, consider using a mode with salt as a prefix and set salt to that fixed prefix. Also read this: diff --git a/docs/readme.txt b/docs/readme.txt index 5b0cb84ca..e5fd69f25 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -11,7 +11,7 @@ hashcat v6.2.6 ============== AMD GPUs on Linux require "AMDGPU" (21.50 or later) and "ROCm" (5.0 or later) -AMD GPUs on Windows require "AMD Adrenalin Edition" (Adrenalin 22.5.1 exactly) +AMD GPUs on Windows require "AMD Adrenalin Edition" (23.7.2 or later) and "AMD HIP SDK" (23.Q3 or later) Intel CPUs require "OpenCL Runtime for Intel Core and Intel Xeon Processors" (16.1.1 or later) NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or later) @@ -69,6 +69,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Keccak-384 - Keccak-512 - Whirlpool +- CubeCart (Whirlpool($salt.$pass.$salt)) - SipHash - md5(utf16le($pass)) - sha1(utf16le($pass)) @@ -85,14 +86,20 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - md5($salt.md5($salt.$pass)) - md5($salt.sha1($salt.$pass)) - md5($salt.utf16le($pass)) +- md5($salt1.sha1($salt2.$pass)) - md5($salt1.strtoupper(md5($salt2.$pass))) - md5(md5($pass)) - md5(md5($pass).md5($salt)) +- md5(md5($pass.$salt)) - md5(md5(md5($pass))) +- md5(md5(md5($pass)).$salt) +- md5(md5(md5($pass).$salt1).$salt2) - md5(sha1($pass)) - md5(sha1($pass).$salt) - md5(sha1($pass).md5($pass).sha1($pass)) +- md5(sha1($pass.$salt)) - md5(sha1($salt).md5($pass)) +- md5(sha1($salt.$pass)) - md5(strtoupper(md5($pass))) - md5(utf16le($pass).$salt) - sha1($pass.$salt) @@ -100,6 +107,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - sha1($salt.$pass.$salt) - sha1($salt.sha1($pass)) - sha1($salt.sha1($pass.$salt)) +- sha1($salt.sha1(utf16le($username).':'.utf16le($pass))) - sha1($salt.utf16le($pass)) - sha1($salt1.$pass.$salt2) - sha1(CX) @@ -128,6 +136,8 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - sha512($pass.$salt) - sha512($salt.$pass) - sha512($salt.utf16le($pass)) +- sha512(sha512($pass).$salt) +- sha512(sha512_bin($pass).$salt) - sha512(utf16le($pass).$salt) - HMAC-MD5 (key = $pass) - HMAC-MD5 (key = $salt) @@ -191,9 +201,11 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Kerberos 5, etype 17, TGS-REP - Kerberos 5, etype 17, Pre-Auth - Kerberos 5, etype 17, DB +- Kerberos 5, etype 17, AS-REP - Kerberos 5, etype 18, TGS-REP - Kerberos 5, etype 18, Pre-Auth - Kerberos 5, etype 18, DB +- Kerberos 5, etype 18, AS-REP - Kerberos 5, etype 23, AS-REQ Pre-Auth - Kerberos 5, etype 23, TGS-REP - Kerberos 5, etype 23, AS-REP @@ -246,7 +258,6 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - bcrypt $2*$, Blowfish (Unix) - md5crypt, MD5 (Unix), Cisco-IOS $1$ (MD5) - descrypt, DES (Unix), Traditional DES -- sha1($salt.sha1(utf16le($username).':'.utf16le($pass))) - sha256crypt $5$, SHA256 (Unix) - sha512crypt $6$, SHA512 (Unix) - SQLCipher @@ -286,8 +297,19 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - SAP CODVN F/G (PASSCODE) - SAP CODVN F/G (PASSCODE) from RFC_READ_TABLE - SAP CODVN H (PWDSALTEDHASH) iSSHA-1 +- RSA Security Analytics / NetWitness (sha256) +- Adobe AEM (SSPR, SHA-256 with Salt) +- Adobe AEM (SSPR, SHA-512 with Salt) - PeopleSoft - PeopleSoft PS_TOKEN +- NetIQ SSPR (MD5) +- NetIQ SSPR (PBKDF2WithHmacSHA1) +- NetIQ SSPR (PBKDF2WithHmacSHA256) +- NetIQ SSPR (PBKDF2WithHmacSHA512) +- NetIQ SSPR (SHA-1 with Salt) +- NetIQ SSPR (SHA-256 with Salt) +- NetIQ SSPR (SHA-512 with Salt) +- NetIQ SSPR (SHA1) - SolarWinds Orion - SolarWinds Orion v2 - SolarWinds Serv-U @@ -336,6 +358,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Apple iWork - 1Password, agilekeychain - 1Password, cloudkeychain +- 1Password, mobilekeychain (1Password 8) - Password Safe v2 - Password Safe v3 - LastPass + LastPass sniffed @@ -347,8 +370,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Mozilla key4.db - Apple Keychain - 7-Zip -- RAR3-hp -- RAR3-p +- RAR3 - RAR5 - PKZIP - PKZIP Master Key @@ -372,6 +394,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - MediaWiki B type - Redmine - Umbraco HMAC-SHA1 +- Empire CMS (Admin password) - Joomla < 2.5.18 - OpenCart - PrestaShop @@ -405,6 +428,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - GPG (AES-128/AES-256 (SHA-1($pass))) - GPG (AES-128/AES-256 (SHA-512($pass))) - GPG (AES-128/AES-256 (SHA-256($pass))) +- GPG (CAST5 (SHA-1($pass))) - RSA/DSA/EC/OpenSSH Private Keys ($0$) - RSA/DSA/EC/OpenSSH Private Keys ($6$) - RSA/DSA/EC/OpenSSH Private Keys ($1, $3$) @@ -418,16 +442,23 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Skype - Anope IRC Services (enc_sha256) - Terra Station Wallet (AES256-CBC(PBKDF2($pass))) +- MetaMask Mobile Wallet - MetaMask Wallet (needs all data, checks AES-GCM tag) - MetaMask Wallet (short hash, plaintext check) - Bisq .wallet (scrypt) - BitShares v0.x - sha512(sha512_bin(pass)) -- Bitcoin WIF private key (P2PKH) -- Bitcoin WIF private key (P2WPKH, Bech32) -- Bitcoin WIF private key (P2SH(P2WPKH)) -- Bitcoin raw private key (P2PKH) -- Bitcoin raw private key (P2WPKH, Bech32) -- Bitcoin raw private key (P2SH(P2WPKH)) +- Bitcoin WIF private key (P2PKH), compressed +- Bitcoin WIF private key (P2PKH), uncompressed +- Bitcoin WIF private key (P2WPKH, Bech32), compressed +- Bitcoin WIF private key (P2WPKH, Bech32), uncompressed +- Bitcoin WIF private key (P2SH(P2WPKH)), compressed +- Bitcoin WIF private key (P2SH(P2WPKH)), uncompressed +- Bitcoin raw private key (P2PKH), compressed +- Bitcoin raw private key (P2PKH), uncompressed +- Bitcoin raw private key (P2WPKH, Bech32), compressed +- Bitcoin raw private key (P2WPKH, Bech32), uncompressed +- Bitcoin raw private key (P2SH(P2WPKH)), compressed +- Bitcoin raw private key (P2SH(P2WPKH)), uncompressed - Bitcoin/Litecoin wallet.dat - Electrum Wallet (Salt-Type 1-3) - Electrum Wallet (Salt-Type 4) @@ -435,6 +466,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Blockchain, My Wallet - Blockchain, My Wallet, V2 - Blockchain, My Wallet, Second Password (SHA256) +- Dogechain.info Wallet - Stargazer Stellar Wallet XLM - Ethereum Pre-Sale Wallet, PBKDF2-HMAC-SHA256 - Ethereum Wallet, PBKDF2-HMAC-SHA256 diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index fa403c580..7ad527905 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -425,9 +425,9 @@ _hashcat () local HIDDEN_FILES_AGGRESSIVE="${HIDDEN_FILES}|hcmask|hcchr" local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' - local SHORT_OPTS="-m -a -V -h -b -t -T -o -p -c -d -D -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z -M" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-inverse --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --deprecated-check-disable --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --hash-info --backend-ignore-cuda --backend-ignore-opencl --backend-ignore-hip --backend-ignore-metal --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-func-sel --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --multiply-accel-disable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password --identify" - local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --markov-hcstat2 --markov-threshold --runtime --session --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-func-sel --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-server-timer --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist" + local SHORT_OPTS="-m -a -V -h -b -t -T -o -p -c -d -D -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z -M -Y" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-inverse --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --deprecated-check-disable --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --hash-info --backend-ignore-cuda --backend-ignore-opencl --backend-ignore-hip --backend-ignore-metal --backend-info --backend-devices --backend-devices-virtual --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-func-sel --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --multiply-accel-disable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password --identify" + local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --markov-hcstat2 --markov-threshold --runtime --session --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --backend-devices-virtual --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-func-sel --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-server-timer --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist" COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" diff --git a/include/backend.h b/include/backend.h index 3ab906e94..117452740 100644 --- a/include/backend.h +++ b/include/backend.h @@ -39,6 +39,8 @@ int backend_session_update_combinator (hashcat_ctx_t *hashcat_ctx); int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx); int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l, const u32 css_cnt_r); +u32 backend_device_idx_real_from_virtual (const u32 device_idx, const u32 backend_devices_virtual); + void generate_source_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file); void generate_cached_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *cache_dir, const char *device_name_chksum, char *cached_file, bool is_metal); void generate_source_kernel_shared_filename (char *shared_dir, char *source_file); @@ -48,6 +50,8 @@ void generate_cached_kernel_mp_filename (const u32 opti_type, const u64 opts void generate_source_kernel_amp_filename (const u32 attack_kern, char *shared_dir, char *source_file); void generate_cached_kernel_amp_filename (const u32 attack_kern, char *cache_dir, const char *device_name_chksum, char *cached_file, bool is_metal); +bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources); + int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw); int copy_pws_idx (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, u64 gidd, const u64 cnt, pw_idx_t *dest); diff --git a/include/common.h b/include/common.h index a91f46e37..8fdd49bcb 100644 --- a/include/common.h +++ b/include/common.h @@ -76,7 +76,7 @@ #endif /* The C++ standard denies redefinition of keywords, -but this is nededed for VS compiler which doesn't have inline keyword but has __inline +but this is needed for VS compiler which doesn't have inline keyword but has __inline */ #ifndef __cplusplus #if defined (_MSC_VER) diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 232aa3714..1b26018f0 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -212,11 +212,11 @@ typedef struct ADLThermalControllerInfo { /// Must be set to the size of the structure int iSize; -/// Possible valies: \ref ADL_DL_THERMAL_DOMAIN_OTHER or \ref ADL_DL_THERMAL_DOMAIN_GPU. +/// Possible values: \ref ADL_DL_THERMAL_DOMAIN_OTHER or \ref ADL_DL_THERMAL_DOMAIN_GPU. int iThermalDomain; /// GPU 0, 1, etc. int iDomainIndex; -/// Possible valies: \ref ADL_DL_THERMAL_FLAG_INTERRUPT or \ref ADL_DL_THERMAL_FLAG_FANCONTROL +/// Possible values: \ref ADL_DL_THERMAL_FLAG_INTERRUPT or \ref ADL_DL_THERMAL_FLAG_FANCONTROL int iFlags; } ADLThermalControllerInfo; @@ -269,7 +269,7 @@ typedef struct ADLFanSpeedValue { /// Must be set to the size of the structure int iSize; -/// Possible valies: \ref ADL_DL_FANCTRL_SPEED_TYPE_PERCENT or \ref ADL_DL_FANCTRL_SPEED_TYPE_RPM +/// Possible values: \ref ADL_DL_FANCTRL_SPEED_TYPE_PERCENT or \ref ADL_DL_FANCTRL_SPEED_TYPE_RPM int iSpeedType; /// Fan speed value int iFanSpeed; diff --git a/include/ext_cuda.h b/include/ext_cuda.h index f809a1ae3..316d11085 100644 --- a/include/ext_cuda.h +++ b/include/ext_cuda.h @@ -675,10 +675,10 @@ typedef enum CUjit_option_enum CU_JIT_FAST_COMPILE, /** - * Array of device symbol names that will be relocated to the corresponing + * Array of device symbol names that will be relocated to the corresponding * host addresses stored in ::CU_JIT_GLOBAL_SYMBOL_ADDRESSES.\n * Must contain ::CU_JIT_GLOBAL_SYMBOL_COUNT entries.\n - * When loding a device module, driver will relocate all encountered + * When loading a device module, driver will relocate all encountered * unresolved symbols to the host addresses.\n * It is only allowed to register symbols that correspond to unresolved * global variables.\n diff --git a/include/ext_hip.h b/include/ext_hip.h index 950b100c0..dd18d3775 100644 --- a/include/ext_hip.h +++ b/include/ext_hip.h @@ -152,7 +152,7 @@ typedef enum __HIP_NODISCARD hipError_t { ///< hipStreamEndCapture in a different thread. hipErrorGraphExecUpdateFailure = 910, ///< This error indicates that the graph update ///< not performed because it included changes which - ///< violated constraintsspecific to instantiated graph + ///< violated constraints specific to instantiated graph ///< update. hipErrorUnknown = 999, //< Unknown error. // HSA Runtime Error Codes start here. @@ -216,7 +216,7 @@ typedef enum hipDeviceAttribute_t { ///< Use cudaDeviceGetTexture1DLinearMaxWidth() instead on Cuda. hipDeviceAttributeMaxTexture1DMipmap, ///< Cuda only. Maximum size of 1D mipmapped texture. hipDeviceAttributeMaxTexture2DWidth, ///< Maximum dimension width of 2D texture. - hipDeviceAttributeMaxTexture2DHeight, ///< Maximum dimension hight of 2D texture. + hipDeviceAttributeMaxTexture2DHeight, ///< Maximum dimension height of 2D texture. hipDeviceAttributeMaxTexture2DGather, ///< Cuda only. Maximum dimensions of 2D texture if gather operations performed. hipDeviceAttributeMaxTexture2DLayered, ///< Cuda only. Maximum dimensions of 2D layered texture. hipDeviceAttributeMaxTexture2DLinear, ///< Cuda only. Maximum dimensions (width, height, pitch) of 2D textures bound to pitched memory. @@ -258,7 +258,7 @@ typedef enum hipDeviceAttribute_t { hipDeviceAttributeTextureAlignment, ///< Alignment requirement for textures hipDeviceAttributeTexturePitchAlignment, ///< Pitch alignment requirement for 2D texture references bound to pitched memory; hipDeviceAttributeTotalConstantMemory, ///< Constant memory size in bytes. - hipDeviceAttributeTotalGlobalMem, ///< Global memory available on devicice. + hipDeviceAttributeTotalGlobalMem, ///< Global memory available on device. hipDeviceAttributeUnifiedAddressing, ///< Cuda only. An unified address space shared with the host. hipDeviceAttributeUuid, ///< Cuda only. Unique ID in 16 byte. hipDeviceAttributeWarpSize, ///< Warp size in threads. @@ -315,7 +315,7 @@ typedef enum hipDeviceAttribute_t { /** Disable event's capability to record timing information. May improve performance.*/ #define hipEventDisableTiming 0x2 -/** Event can support IPC. Warnig: It is not supported in HIP.*/ +/** Event can support IPC. Warning: It is not supported in HIP.*/ #define hipEventInterprocess 0x4 /** Use a device-scope release when recording this event. This flag is useful to obtain more diff --git a/include/ext_iokit.h b/include/ext_iokit.h index 180be3ef9..36676c948 100644 --- a/include/ext_iokit.h +++ b/include/ext_iokit.h @@ -9,6 +9,9 @@ #if defined(__APPLE__) #include +// kIOMasterPortDefault/kIOMainPortDefault is 0 +static const mach_port_t hc_IOMasterPortDefault = 0; + // Apple SMC Keys #define HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT "SGHT" #define HM_IOKIT_SMC_CPU_PROXIMITY "TC0P" diff --git a/include/memory.h b/include/memory.h index 92252d3db..465d7e265 100644 --- a/include/memory.h +++ b/include/memory.h @@ -18,4 +18,7 @@ void *hcrealloc (void *ptr, const size_t oldsz, const size_t addsz); char *hcstrdup (const char *s); void hcfree (void *ptr); +void *hcmalloc_aligned (const size_t sz, const int align); +void hcfree_aligned (void *ptr); + #endif // HC_MEMORY_H diff --git a/include/sort_r.h b/include/sort_r.h index 28e523aeb..79bd8ab65 100644 --- a/include/sort_r.h +++ b/include/sort_r.h @@ -20,7 +20,7 @@ void sort_r(void *base, size_t nel, size_t width, int (*compar)(const void *_a, const void *_b, void *_arg), void *arg); -Slightly modified to work with hashcat to no falsly detect _SORT_R_LINUX with mingw +Slightly modified to work with hashcat to no falsely detect _SORT_R_LINUX with mingw */ diff --git a/include/types.h b/include/types.h index 506fc07ea..0a7179af6 100644 --- a/include/types.h +++ b/include/types.h @@ -17,11 +17,7 @@ #include #include #include - -// workaround to get the rid of "redefinition of typedef 'Byte'" build warning -#if !defined (__APPLE__) -#include "zlib.h" -#endif +#include #if !defined(__MACTYPES__) #define __MACTYPES__ @@ -628,6 +624,7 @@ typedef enum user_options_defaults ADVICE_DISABLE = false, ATTACK_MODE = ATTACK_MODE_STRAIGHT, AUTODETECT = false, + BACKEND_DEVICES_VIRTUAL = 1, BENCHMARK_ALL = false, BENCHMARK = false, BITMAP_MAX = 18, @@ -673,6 +670,7 @@ typedef enum user_options_defaults MARKOV_DISABLE = false, MARKOV_INVERSE = false, MARKOV_THRESHOLD = 0, + METAL_COMPILER_RUNTIME = 120, NONCE_ERROR_CORRECTIONS = 8, BACKEND_IGNORE_CUDA = false, BACKEND_IGNORE_HIP = false, @@ -713,7 +711,7 @@ typedef enum user_options_defaults STATUS_TIMER = 10, STDIN_TIMEOUT_ABORT = 120, STDOUT_FLAG = false, - USAGE = false, + USAGE = 0, USERNAME = false, VERSION = false, VERACRYPT_PIM_START = 485, @@ -728,6 +726,7 @@ typedef enum user_options_map IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', IDX_BACKEND_DEVICES = 'd', + IDX_BACKEND_DEVICES_VIRTUAL = 'Y', IDX_BACKEND_IGNORE_CUDA = 0xff01, IDX_BACKEND_IGNORE_HIP = 0xff02, IDX_BACKEND_IGNORE_METAL = 0xff03, @@ -791,56 +790,57 @@ typedef enum user_options_map IDX_MARKOV_HCSTAT2 = 0xff2d, IDX_MARKOV_INVERSE = 0xff2e, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff2f, + IDX_METAL_COMPILER_RUNTIME = 0xff2f, + IDX_NONCE_ERROR_CORRECTIONS = 0xff30, IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPTIMIZED_KERNEL_ENABLE = 'O', IDX_MULTIPLY_ACCEL_DISABLE = 'M', - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff30, - IDX_OUTFILE_CHECK_DIR = 0xff31, - IDX_OUTFILE_CHECK_TIMER = 0xff32, - IDX_OUTFILE_FORMAT = 0xff33, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff31, + IDX_OUTFILE_CHECK_DIR = 0xff32, + IDX_OUTFILE_CHECK_TIMER = 0xff33, + IDX_OUTFILE_FORMAT = 0xff34, IDX_OUTFILE = 'o', - IDX_POTFILE_DISABLE = 0xff34, - IDX_POTFILE_PATH = 0xff35, - IDX_PROGRESS_ONLY = 0xff36, - IDX_QUIET = 0xff37, - IDX_REMOVE = 0xff38, - IDX_REMOVE_TIMER = 0xff39, - IDX_RESTORE = 0xff3a, - IDX_RESTORE_DISABLE = 0xff3b, - IDX_RESTORE_FILE_PATH = 0xff3c, + IDX_POTFILE_DISABLE = 0xff35, + IDX_POTFILE_PATH = 0xff36, + IDX_PROGRESS_ONLY = 0xff37, + IDX_QUIET = 0xff38, + IDX_REMOVE = 0xff39, + IDX_REMOVE_TIMER = 0xff3a, + IDX_RESTORE = 0xff3b, + IDX_RESTORE_DISABLE = 0xff3c, + IDX_RESTORE_FILE_PATH = 0xff3d, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff3d, - IDX_RP_GEN_FUNC_MIN = 0xff3e, - IDX_RP_GEN_FUNC_SEL = 0xff3f, + IDX_RP_GEN_FUNC_MAX = 0xff3e, + IDX_RP_GEN_FUNC_MIN = 0xff3f, + IDX_RP_GEN_FUNC_SEL = 0xff40, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff40, + IDX_RP_GEN_SEED = 0xff41, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff41, - IDX_SCRYPT_TMTO = 0xff42, + IDX_RUNTIME = 0xff42, + IDX_SCRYPT_TMTO = 0xff43, IDX_SEGMENT_SIZE = 'c', - IDX_SELF_TEST_DISABLE = 0xff43, + IDX_SELF_TEST_DISABLE = 0xff44, IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff44, - IDX_SHOW = 0xff45, + IDX_SESSION = 0xff45, + IDX_SHOW = 0xff46, IDX_SKIP = 's', IDX_SLOW_CANDIDATES = 'S', - IDX_SPEED_ONLY = 0xff46, - IDX_SPIN_DAMP = 0xff47, - IDX_STATUS = 0xff48, - IDX_STATUS_JSON = 0xff49, - IDX_STATUS_TIMER = 0xff4a, - IDX_STDOUT_FLAG = 0xff4b, - IDX_STDIN_TIMEOUT_ABORT = 0xff4c, - IDX_TRUECRYPT_KEYFILES = 0xff4d, - IDX_USERNAME = 0xff4e, - IDX_VERACRYPT_KEYFILES = 0xff4f, - IDX_VERACRYPT_PIM_START = 0xff50, - IDX_VERACRYPT_PIM_STOP = 0xff51, + IDX_SPEED_ONLY = 0xff47, + IDX_SPIN_DAMP = 0xff48, + IDX_STATUS = 0xff49, + IDX_STATUS_JSON = 0xff4a, + IDX_STATUS_TIMER = 0xff4b, + IDX_STDOUT_FLAG = 0xff4c, + IDX_STDIN_TIMEOUT_ABORT = 0xff4d, + IDX_TRUECRYPT_KEYFILES = 0xff4e, + IDX_USERNAME = 0xff4f, + IDX_VERACRYPT_KEYFILES = 0xff50, + IDX_VERACRYPT_PIM_START = 0xff51, + IDX_VERACRYPT_PIM_STOP = 0xff52, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff52, + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff53, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; @@ -1073,6 +1073,7 @@ typedef struct hashconfig bool forced_jit_compile; u32 pwdump_column; + } hashconfig_t; typedef struct pw_pre @@ -1876,6 +1877,7 @@ typedef struct backend_ctx int backend_device_from_opencl_platform[CL_PLATFORMS_MAX][DEVICES_MAX]; // from opencl device index to backend device index (by platform) int backend_devices_cnt; + int backend_devices_virtual; int backend_devices_active; int cuda_devices_cnt; @@ -2307,6 +2309,7 @@ typedef struct user_options bool remove_timer_chgd; bool rp_gen_seed_chgd; bool runtime_chgd; + bool metal_compiler_runtime_chgd; bool segment_size_chgd; bool workload_profile_chgd; bool skip_chgd; @@ -2359,7 +2362,6 @@ typedef struct user_options bool status_json; bool stdout_flag; bool stdin_timeout_abort_chgd; - bool usage; bool username; bool veracrypt_pim_start_chgd; bool veracrypt_pim_stop_chgd; @@ -2396,6 +2398,7 @@ typedef struct user_options const char *rule_buf_r; const char *session; u32 attack_mode; + u32 backend_devices_virtual; u32 backend_info; u32 bitmap_max; u32 bitmap_min; @@ -2430,10 +2433,12 @@ typedef struct user_options u32 rp_gen_func_min; u32 rp_gen_seed; u32 runtime; + u32 metal_compiler_runtime; u32 scrypt_tmto; u32 segment_size; u32 status_timer; u32 stdin_timeout_abort; + u32 usage; u32 veracrypt_pim_start; u32 veracrypt_pim_stop; u32 workload_profile; diff --git a/layouts/da.hckmap b/layouts/da.hckmap new file mode 100644 index 000000000..d3a513454 --- /dev/null +++ b/layouts/da.hckmap @@ -0,0 +1,97 @@ +½ ` +1 1 +2 2 +3 3 +4 4 +5 5 +6 6 +7 7 +8 8 +9 9 +0 0 ++ - +´ = +q q +w w +e e +r r +t t +y y +u u +i i +o o +p p +Ã¥ [ +¨ ] +a a +s s +d d +f f +g g +h h +j j +k k +l l +æ ; +ø ' +' \ +< \ +z z +x x +c c +v v +b b +n n +m m +, , +. . +- / + +§ ~ +! ! +" @ +# # +¤ $ +% % +& ^ +/ & +( * +) ( += ) +? _ +` + +Q Q +W W +E E +R R +T T +Y Y +U U +I I +O O +P P +Ã… { +^ } +A A +S S +D D +F F +G G +H H +J J +K K +L L +Æ : +Ø " +* | +> | +Z Z +X X +C C +V V +B B +N N +M M +; < +: > +_ ? diff --git a/rules/Incisive-leetspeak.rule b/rules/Incisive-leetspeak.rule index 010a618e1..d3435a96f 100644 --- a/rules/Incisive-leetspeak.rule +++ b/rules/Incisive-leetspeak.rule @@ -1,15487 +1,15487 @@ sa@ -sa@sb6 -sa@sb6sc{ -sa@sb6sc{se3 -sa@sb6sc{se3sg9 -sa@sb6sc{se3sg9si! -sa@sb6sc{se3sg9si!so0 -sa@sb6sc{se3sg9si!so0sq9 -sa@sb6sc{se3sg9si!so0sq9ss$ -sa@sb6sc{se3sg9si!so0sq9ss$st+ -sa@sb6sc{se3sg9si!so0sq9ss$st+sx% -sa@sb6sc{se3sg9si!so0sq9ss$st7 -sa@sb6sc{se3sg9si!so0sq9ss$st7sx% -sa@sb6sc{se3sg9si!so0sq9ss$sx% -sa@sb6sc{se3sg9si!so0sq9ss5 -sa@sb6sc{se3sg9si!so0sq9ss5st+ -sa@sb6sc{se3sg9si!so0sq9ss5st+sx% -sa@sb6sc{se3sg9si!so0sq9ss5st7 -sa@sb6sc{se3sg9si!so0sq9ss5st7sx% -sa@sb6sc{se3sg9si!so0sq9ss5sx% -sa@sb6sc{se3sg9si!so0sq9st+ -sa@sb6sc{se3sg9si!so0sq9st+sx% -sa@sb6sc{se3sg9si!so0sq9st7 -sa@sb6sc{se3sg9si!so0sq9st7sx% -sa@sb6sc{se3sg9si!so0sq9sx% -sa@sb6sc{se3sg9si!so0ss$ -sa@sb6sc{se3sg9si!so0ss$st+ -sa@sb6sc{se3sg9si!so0ss$st+sx% -sa@sb6sc{se3sg9si!so0ss$st7 -sa@sb6sc{se3sg9si!so0ss$st7sx% -sa@sb6sc{se3sg9si!so0ss$sx% -sa@sb6sc{se3sg9si!so0ss5 -sa@sb6sc{se3sg9si!so0ss5st+ -sa@sb6sc{se3sg9si!so0ss5st+sx% -sa@sb6sc{se3sg9si!so0ss5st7 -sa@sb6sc{se3sg9si!so0ss5st7sx% -sa@sb6sc{se3sg9si!so0ss5sx% -sa@sb6sc{se3sg9si!so0st+ -sa@sb6sc{se3sg9si!so0st+sx% -sa@sb6sc{se3sg9si!so0st7 -sa@sb6sc{se3sg9si!so0st7sx% -sa@sb6sc{se3sg9si!so0sx% -sa@sb6sc{se3sg9si!sq9 -sa@sb6sc{se3sg9si!sq9ss$ -sa@sb6sc{se3sg9si!sq9ss$st+ -sa@sb6sc{se3sg9si!sq9ss$st+sx% -sa@sb6sc{se3sg9si!sq9ss$st7 -sa@sb6sc{se3sg9si!sq9ss$st7sx% -sa@sb6sc{se3sg9si!sq9ss$sx% -sa@sb6sc{se3sg9si!sq9ss5 -sa@sb6sc{se3sg9si!sq9ss5st+ -sa@sb6sc{se3sg9si!sq9ss5st+sx% -sa@sb6sc{se3sg9si!sq9ss5st7 -sa@sb6sc{se3sg9si!sq9ss5st7sx% -sa@sb6sc{se3sg9si!sq9ss5sx% -sa@sb6sc{se3sg9si!sq9st+ -sa@sb6sc{se3sg9si!sq9st+sx% -sa@sb6sc{se3sg9si!sq9st7 -sa@sb6sc{se3sg9si!sq9st7sx% -sa@sb6sc{se3sg9si!sq9sx% -sa@sb6sc{se3sg9si!ss$ -sa@sb6sc{se3sg9si!ss$st+ -sa@sb6sc{se3sg9si!ss$st+sx% -sa@sb6sc{se3sg9si!ss$st7 -sa@sb6sc{se3sg9si!ss$st7sx% -sa@sb6sc{se3sg9si!ss$sx% -sa@sb6sc{se3sg9si!ss5 -sa@sb6sc{se3sg9si!ss5st+ -sa@sb6sc{se3sg9si!ss5st+sx% -sa@sb6sc{se3sg9si!ss5st7 -sa@sb6sc{se3sg9si!ss5st7sx% -sa@sb6sc{se3sg9si!ss5sx% -sa@sb6sc{se3sg9si!st+ -sa@sb6sc{se3sg9si!st+sx% -sa@sb6sc{se3sg9si!st7 -sa@sb6sc{se3sg9si!st7sx% -sa@sb6sc{se3sg9si!sx% -sa@sb6sc{se3sg9si1 -sa@sb6sc{se3sg9si1so0 -sa@sb6sc{se3sg9si1so0sq9 -sa@sb6sc{se3sg9si1so0sq9ss$ -sa@sb6sc{se3sg9si1so0sq9ss$st+ -sa@sb6sc{se3sg9si1so0sq9ss$st+sx% -sa@sb6sc{se3sg9si1so0sq9ss$st7 -sa@sb6sc{se3sg9si1so0sq9ss$st7sx% -sa@sb6sc{se3sg9si1so0sq9ss$sx% -sa@sb6sc{se3sg9si1so0sq9ss5 -sa@sb6sc{se3sg9si1so0sq9ss5st+ -sa@sb6sc{se3sg9si1so0sq9ss5st+sx% -sa@sb6sc{se3sg9si1so0sq9ss5st7 -sa@sb6sc{se3sg9si1so0sq9ss5st7sx% -sa@sb6sc{se3sg9si1so0sq9ss5sx% -sa@sb6sc{se3sg9si1so0sq9st+ -sa@sb6sc{se3sg9si1so0sq9st+sx% -sa@sb6sc{se3sg9si1so0sq9st7 -sa@sb6sc{se3sg9si1so0sq9st7sx% -sa@sb6sc{se3sg9si1so0sq9sx% -sa@sb6sc{se3sg9si1so0ss$ -sa@sb6sc{se3sg9si1so0ss$st+ -sa@sb6sc{se3sg9si1so0ss$st+sx% -sa@sb6sc{se3sg9si1so0ss$st7 -sa@sb6sc{se3sg9si1so0ss$st7sx% -sa@sb6sc{se3sg9si1so0ss$sx% -sa@sb6sc{se3sg9si1so0ss5 -sa@sb6sc{se3sg9si1so0ss5st+ -sa@sb6sc{se3sg9si1so0ss5st+sx% -sa@sb6sc{se3sg9si1so0ss5st7 -sa@sb6sc{se3sg9si1so0ss5st7sx% -sa@sb6sc{se3sg9si1so0ss5sx% -sa@sb6sc{se3sg9si1so0st+ -sa@sb6sc{se3sg9si1so0st+sx% -sa@sb6sc{se3sg9si1so0st7 -sa@sb6sc{se3sg9si1so0st7sx% -sa@sb6sc{se3sg9si1so0sx% -sa@sb6sc{se3sg9si1sq9 -sa@sb6sc{se3sg9si1sq9ss$ -sa@sb6sc{se3sg9si1sq9ss$st+ -sa@sb6sc{se3sg9si1sq9ss$st+sx% -sa@sb6sc{se3sg9si1sq9ss$st7 -sa@sb6sc{se3sg9si1sq9ss$st7sx% -sa@sb6sc{se3sg9si1sq9ss$sx% -sa@sb6sc{se3sg9si1sq9ss5 -sa@sb6sc{se3sg9si1sq9ss5st+ -sa@sb6sc{se3sg9si1sq9ss5st+sx% -sa@sb6sc{se3sg9si1sq9ss5st7 -sa@sb6sc{se3sg9si1sq9ss5st7sx% -sa@sb6sc{se3sg9si1sq9ss5sx% -sa@sb6sc{se3sg9si1sq9st+ -sa@sb6sc{se3sg9si1sq9st+sx% -sa@sb6sc{se3sg9si1sq9st7 -sa@sb6sc{se3sg9si1sq9st7sx% -sa@sb6sc{se3sg9si1sq9sx% -sa@sb6sc{se3sg9si1ss$ -sa@sb6sc{se3sg9si1ss$st+ -sa@sb6sc{se3sg9si1ss$st+sx% -sa@sb6sc{se3sg9si1ss$st7 -sa@sb6sc{se3sg9si1ss$st7sx% -sa@sb6sc{se3sg9si1ss$sx% -sa@sb6sc{se3sg9si1ss5 -sa@sb6sc{se3sg9si1ss5st+ -sa@sb6sc{se3sg9si1ss5st+sx% -sa@sb6sc{se3sg9si1ss5st7 -sa@sb6sc{se3sg9si1ss5st7sx% -sa@sb6sc{se3sg9si1ss5sx% -sa@sb6sc{se3sg9si1st+ -sa@sb6sc{se3sg9si1st+sx% -sa@sb6sc{se3sg9si1st7 -sa@sb6sc{se3sg9si1st7sx% -sa@sb6sc{se3sg9si1sx% -sa@sb6sc{se3sg9so0 -sa@sb6sc{se3sg9so0sq9 -sa@sb6sc{se3sg9so0sq9ss$ -sa@sb6sc{se3sg9so0sq9ss$st+ -sa@sb6sc{se3sg9so0sq9ss$st+sx% -sa@sb6sc{se3sg9so0sq9ss$st7 -sa@sb6sc{se3sg9so0sq9ss$st7sx% -sa@sb6sc{se3sg9so0sq9ss$sx% -sa@sb6sc{se3sg9so0sq9ss5 -sa@sb6sc{se3sg9so0sq9ss5st+ -sa@sb6sc{se3sg9so0sq9ss5st+sx% -sa@sb6sc{se3sg9so0sq9ss5st7 -sa@sb6sc{se3sg9so0sq9ss5st7sx% -sa@sb6sc{se3sg9so0sq9ss5sx% -sa@sb6sc{se3sg9so0sq9st+ -sa@sb6sc{se3sg9so0sq9st+sx% -sa@sb6sc{se3sg9so0sq9st7 -sa@sb6sc{se3sg9so0sq9st7sx% -sa@sb6sc{se3sg9so0sq9sx% -sa@sb6sc{se3sg9so0ss$ -sa@sb6sc{se3sg9so0ss$st+ -sa@sb6sc{se3sg9so0ss$st+sx% -sa@sb6sc{se3sg9so0ss$st7 -sa@sb6sc{se3sg9so0ss$st7sx% -sa@sb6sc{se3sg9so0ss$sx% -sa@sb6sc{se3sg9so0ss5 -sa@sb6sc{se3sg9so0ss5st+ -sa@sb6sc{se3sg9so0ss5st+sx% -sa@sb6sc{se3sg9so0ss5st7 -sa@sb6sc{se3sg9so0ss5st7sx% -sa@sb6sc{se3sg9so0ss5sx% -sa@sb6sc{se3sg9so0st+ -sa@sb6sc{se3sg9so0st+sx% -sa@sb6sc{se3sg9so0st7 -sa@sb6sc{se3sg9so0st7sx% -sa@sb6sc{se3sg9so0sx% -sa@sb6sc{se3sg9sq9 -sa@sb6sc{se3sg9sq9ss$ -sa@sb6sc{se3sg9sq9ss$st+ -sa@sb6sc{se3sg9sq9ss$st+sx% -sa@sb6sc{se3sg9sq9ss$st7 -sa@sb6sc{se3sg9sq9ss$st7sx% -sa@sb6sc{se3sg9sq9ss$sx% -sa@sb6sc{se3sg9sq9ss5 -sa@sb6sc{se3sg9sq9ss5st+ -sa@sb6sc{se3sg9sq9ss5st+sx% -sa@sb6sc{se3sg9sq9ss5st7 -sa@sb6sc{se3sg9sq9ss5st7sx% -sa@sb6sc{se3sg9sq9ss5sx% -sa@sb6sc{se3sg9sq9st+ -sa@sb6sc{se3sg9sq9st+sx% -sa@sb6sc{se3sg9sq9st7 -sa@sb6sc{se3sg9sq9st7sx% -sa@sb6sc{se3sg9sq9sx% -sa@sb6sc{se3sg9ss$ -sa@sb6sc{se3sg9ss$st+ -sa@sb6sc{se3sg9ss$st+sx% -sa@sb6sc{se3sg9ss$st7 -sa@sb6sc{se3sg9ss$st7sx% -sa@sb6sc{se3sg9ss$sx% -sa@sb6sc{se3sg9ss5 -sa@sb6sc{se3sg9ss5st+ -sa@sb6sc{se3sg9ss5st+sx% -sa@sb6sc{se3sg9ss5st7 -sa@sb6sc{se3sg9ss5st7sx% -sa@sb6sc{se3sg9ss5sx% -sa@sb6sc{se3sg9st+ -sa@sb6sc{se3sg9st+sx% -sa@sb6sc{se3sg9st7 -sa@sb6sc{se3sg9st7sx% -sa@sb6sc{se3sg9sx% -sa@sb6sc{se3si! -sa@sb6sc{se3si!so0 -sa@sb6sc{se3si!so0sq9 -sa@sb6sc{se3si!so0sq9ss$ -sa@sb6sc{se3si!so0sq9ss$st+ -sa@sb6sc{se3si!so0sq9ss$st+sx% -sa@sb6sc{se3si!so0sq9ss$st7 -sa@sb6sc{se3si!so0sq9ss$st7sx% -sa@sb6sc{se3si!so0sq9ss$sx% -sa@sb6sc{se3si!so0sq9ss5 -sa@sb6sc{se3si!so0sq9ss5st+ -sa@sb6sc{se3si!so0sq9ss5st+sx% -sa@sb6sc{se3si!so0sq9ss5st7 -sa@sb6sc{se3si!so0sq9ss5st7sx% -sa@sb6sc{se3si!so0sq9ss5sx% -sa@sb6sc{se3si!so0sq9st+ -sa@sb6sc{se3si!so0sq9st+sx% -sa@sb6sc{se3si!so0sq9st7 -sa@sb6sc{se3si!so0sq9st7sx% -sa@sb6sc{se3si!so0sq9sx% -sa@sb6sc{se3si!so0ss$ -sa@sb6sc{se3si!so0ss$st+ -sa@sb6sc{se3si!so0ss$st+sx% -sa@sb6sc{se3si!so0ss$st7 -sa@sb6sc{se3si!so0ss$st7sx% -sa@sb6sc{se3si!so0ss$sx% -sa@sb6sc{se3si!so0ss5 -sa@sb6sc{se3si!so0ss5st+ -sa@sb6sc{se3si!so0ss5st+sx% -sa@sb6sc{se3si!so0ss5st7 -sa@sb6sc{se3si!so0ss5st7sx% -sa@sb6sc{se3si!so0ss5sx% -sa@sb6sc{se3si!so0st+ -sa@sb6sc{se3si!so0st+sx% -sa@sb6sc{se3si!so0st7 -sa@sb6sc{se3si!so0st7sx% -sa@sb6sc{se3si!so0sx% -sa@sb6sc{se3si!sq9 -sa@sb6sc{se3si!sq9ss$ -sa@sb6sc{se3si!sq9ss$st+ -sa@sb6sc{se3si!sq9ss$st+sx% -sa@sb6sc{se3si!sq9ss$st7 -sa@sb6sc{se3si!sq9ss$st7sx% -sa@sb6sc{se3si!sq9ss$sx% -sa@sb6sc{se3si!sq9ss5 -sa@sb6sc{se3si!sq9ss5st+ -sa@sb6sc{se3si!sq9ss5st+sx% -sa@sb6sc{se3si!sq9ss5st7 -sa@sb6sc{se3si!sq9ss5st7sx% -sa@sb6sc{se3si!sq9ss5sx% -sa@sb6sc{se3si!sq9st+ -sa@sb6sc{se3si!sq9st+sx% -sa@sb6sc{se3si!sq9st7 -sa@sb6sc{se3si!sq9st7sx% -sa@sb6sc{se3si!sq9sx% -sa@sb6sc{se3si!ss$ -sa@sb6sc{se3si!ss$st+ -sa@sb6sc{se3si!ss$st+sx% -sa@sb6sc{se3si!ss$st7 -sa@sb6sc{se3si!ss$st7sx% -sa@sb6sc{se3si!ss$sx% -sa@sb6sc{se3si!ss5 -sa@sb6sc{se3si!ss5st+ -sa@sb6sc{se3si!ss5st+sx% -sa@sb6sc{se3si!ss5st7 -sa@sb6sc{se3si!ss5st7sx% -sa@sb6sc{se3si!ss5sx% -sa@sb6sc{se3si!st+ -sa@sb6sc{se3si!st+sx% -sa@sb6sc{se3si!st7 -sa@sb6sc{se3si!st7sx% -sa@sb6sc{se3si!sx% -sa@sb6sc{se3si1 -sa@sb6sc{se3si1so0 -sa@sb6sc{se3si1so0sq9 -sa@sb6sc{se3si1so0sq9ss$ -sa@sb6sc{se3si1so0sq9ss$st+ -sa@sb6sc{se3si1so0sq9ss$st+sx% -sa@sb6sc{se3si1so0sq9ss$st7 -sa@sb6sc{se3si1so0sq9ss$st7sx% -sa@sb6sc{se3si1so0sq9ss$sx% -sa@sb6sc{se3si1so0sq9ss5 -sa@sb6sc{se3si1so0sq9ss5st+ -sa@sb6sc{se3si1so0sq9ss5st+sx% -sa@sb6sc{se3si1so0sq9ss5st7 -sa@sb6sc{se3si1so0sq9ss5st7sx% -sa@sb6sc{se3si1so0sq9ss5sx% -sa@sb6sc{se3si1so0sq9st+ -sa@sb6sc{se3si1so0sq9st+sx% -sa@sb6sc{se3si1so0sq9st7 -sa@sb6sc{se3si1so0sq9st7sx% -sa@sb6sc{se3si1so0sq9sx% -sa@sb6sc{se3si1so0ss$ -sa@sb6sc{se3si1so0ss$st+ -sa@sb6sc{se3si1so0ss$st+sx% -sa@sb6sc{se3si1so0ss$st7 -sa@sb6sc{se3si1so0ss$st7sx% -sa@sb6sc{se3si1so0ss$sx% -sa@sb6sc{se3si1so0ss5 -sa@sb6sc{se3si1so0ss5st+ -sa@sb6sc{se3si1so0ss5st+sx% -sa@sb6sc{se3si1so0ss5st7 -sa@sb6sc{se3si1so0ss5st7sx% -sa@sb6sc{se3si1so0ss5sx% -sa@sb6sc{se3si1so0st+ -sa@sb6sc{se3si1so0st+sx% -sa@sb6sc{se3si1so0st7 -sa@sb6sc{se3si1so0st7sx% -sa@sb6sc{se3si1so0sx% -sa@sb6sc{se3si1sq9 -sa@sb6sc{se3si1sq9ss$ -sa@sb6sc{se3si1sq9ss$st+ -sa@sb6sc{se3si1sq9ss$st+sx% -sa@sb6sc{se3si1sq9ss$st7 -sa@sb6sc{se3si1sq9ss$st7sx% -sa@sb6sc{se3si1sq9ss$sx% -sa@sb6sc{se3si1sq9ss5 -sa@sb6sc{se3si1sq9ss5st+ -sa@sb6sc{se3si1sq9ss5st+sx% -sa@sb6sc{se3si1sq9ss5st7 -sa@sb6sc{se3si1sq9ss5st7sx% -sa@sb6sc{se3si1sq9ss5sx% -sa@sb6sc{se3si1sq9st+ -sa@sb6sc{se3si1sq9st+sx% -sa@sb6sc{se3si1sq9st7 -sa@sb6sc{se3si1sq9st7sx% -sa@sb6sc{se3si1sq9sx% -sa@sb6sc{se3si1ss$ -sa@sb6sc{se3si1ss$st+ -sa@sb6sc{se3si1ss$st+sx% -sa@sb6sc{se3si1ss$st7 -sa@sb6sc{se3si1ss$st7sx% -sa@sb6sc{se3si1ss$sx% -sa@sb6sc{se3si1ss5 -sa@sb6sc{se3si1ss5st+ -sa@sb6sc{se3si1ss5st+sx% -sa@sb6sc{se3si1ss5st7 -sa@sb6sc{se3si1ss5st7sx% -sa@sb6sc{se3si1ss5sx% -sa@sb6sc{se3si1st+ -sa@sb6sc{se3si1st+sx% -sa@sb6sc{se3si1st7 -sa@sb6sc{se3si1st7sx% -sa@sb6sc{se3si1sx% -sa@sb6sc{se3so0 -sa@sb6sc{se3so0sq9 -sa@sb6sc{se3so0sq9ss$ -sa@sb6sc{se3so0sq9ss$st+ -sa@sb6sc{se3so0sq9ss$st+sx% -sa@sb6sc{se3so0sq9ss$st7 -sa@sb6sc{se3so0sq9ss$st7sx% -sa@sb6sc{se3so0sq9ss$sx% -sa@sb6sc{se3so0sq9ss5 -sa@sb6sc{se3so0sq9ss5st+ -sa@sb6sc{se3so0sq9ss5st+sx% -sa@sb6sc{se3so0sq9ss5st7 -sa@sb6sc{se3so0sq9ss5st7sx% -sa@sb6sc{se3so0sq9ss5sx% -sa@sb6sc{se3so0sq9st+ -sa@sb6sc{se3so0sq9st+sx% -sa@sb6sc{se3so0sq9st7 -sa@sb6sc{se3so0sq9st7sx% -sa@sb6sc{se3so0sq9sx% -sa@sb6sc{se3so0ss$ -sa@sb6sc{se3so0ss$st+ -sa@sb6sc{se3so0ss$st+sx% -sa@sb6sc{se3so0ss$st7 -sa@sb6sc{se3so0ss$st7sx% -sa@sb6sc{se3so0ss$sx% -sa@sb6sc{se3so0ss5 -sa@sb6sc{se3so0ss5st+ -sa@sb6sc{se3so0ss5st+sx% -sa@sb6sc{se3so0ss5st7 -sa@sb6sc{se3so0ss5st7sx% -sa@sb6sc{se3so0ss5sx% -sa@sb6sc{se3so0st+ -sa@sb6sc{se3so0st+sx% -sa@sb6sc{se3so0st7 -sa@sb6sc{se3so0st7sx% -sa@sb6sc{se3so0sx% -sa@sb6sc{se3sq9 -sa@sb6sc{se3sq9ss$ -sa@sb6sc{se3sq9ss$st+ -sa@sb6sc{se3sq9ss$st+sx% -sa@sb6sc{se3sq9ss$st7 -sa@sb6sc{se3sq9ss$st7sx% -sa@sb6sc{se3sq9ss$sx% -sa@sb6sc{se3sq9ss5 -sa@sb6sc{se3sq9ss5st+ -sa@sb6sc{se3sq9ss5st+sx% -sa@sb6sc{se3sq9ss5st7 -sa@sb6sc{se3sq9ss5st7sx% -sa@sb6sc{se3sq9ss5sx% -sa@sb6sc{se3sq9st+ -sa@sb6sc{se3sq9st+sx% -sa@sb6sc{se3sq9st7 -sa@sb6sc{se3sq9st7sx% -sa@sb6sc{se3sq9sx% -sa@sb6sc{se3ss$ -sa@sb6sc{se3ss$st+ -sa@sb6sc{se3ss$st+sx% -sa@sb6sc{se3ss$st7 -sa@sb6sc{se3ss$st7sx% -sa@sb6sc{se3ss$sx% -sa@sb6sc{se3ss5 -sa@sb6sc{se3ss5st+ -sa@sb6sc{se3ss5st+sx% -sa@sb6sc{se3ss5st7 -sa@sb6sc{se3ss5st7sx% -sa@sb6sc{se3ss5sx% -sa@sb6sc{se3st+ -sa@sb6sc{se3st+sx% -sa@sb6sc{se3st7 -sa@sb6sc{se3st7sx% -sa@sb6sc{se3sx% -sa@sb6sc{sg9 -sa@sb6sc{sg9si! -sa@sb6sc{sg9si!so0 -sa@sb6sc{sg9si!so0sq9 -sa@sb6sc{sg9si!so0sq9ss$ -sa@sb6sc{sg9si!so0sq9ss$st+ -sa@sb6sc{sg9si!so0sq9ss$st+sx% -sa@sb6sc{sg9si!so0sq9ss$st7 -sa@sb6sc{sg9si!so0sq9ss$st7sx% -sa@sb6sc{sg9si!so0sq9ss$sx% -sa@sb6sc{sg9si!so0sq9ss5 -sa@sb6sc{sg9si!so0sq9ss5st+ -sa@sb6sc{sg9si!so0sq9ss5st+sx% -sa@sb6sc{sg9si!so0sq9ss5st7 -sa@sb6sc{sg9si!so0sq9ss5st7sx% -sa@sb6sc{sg9si!so0sq9ss5sx% -sa@sb6sc{sg9si!so0sq9st+ -sa@sb6sc{sg9si!so0sq9st+sx% -sa@sb6sc{sg9si!so0sq9st7 -sa@sb6sc{sg9si!so0sq9st7sx% -sa@sb6sc{sg9si!so0sq9sx% -sa@sb6sc{sg9si!so0ss$ -sa@sb6sc{sg9si!so0ss$st+ -sa@sb6sc{sg9si!so0ss$st+sx% -sa@sb6sc{sg9si!so0ss$st7 -sa@sb6sc{sg9si!so0ss$st7sx% -sa@sb6sc{sg9si!so0ss$sx% -sa@sb6sc{sg9si!so0ss5 -sa@sb6sc{sg9si!so0ss5st+ -sa@sb6sc{sg9si!so0ss5st+sx% -sa@sb6sc{sg9si!so0ss5st7 -sa@sb6sc{sg9si!so0ss5st7sx% -sa@sb6sc{sg9si!so0ss5sx% -sa@sb6sc{sg9si!so0st+ -sa@sb6sc{sg9si!so0st+sx% -sa@sb6sc{sg9si!so0st7 -sa@sb6sc{sg9si!so0st7sx% -sa@sb6sc{sg9si!so0sx% -sa@sb6sc{sg9si!sq9 -sa@sb6sc{sg9si!sq9ss$ -sa@sb6sc{sg9si!sq9ss$st+ -sa@sb6sc{sg9si!sq9ss$st+sx% -sa@sb6sc{sg9si!sq9ss$st7 -sa@sb6sc{sg9si!sq9ss$st7sx% -sa@sb6sc{sg9si!sq9ss$sx% -sa@sb6sc{sg9si!sq9ss5 -sa@sb6sc{sg9si!sq9ss5st+ -sa@sb6sc{sg9si!sq9ss5st+sx% -sa@sb6sc{sg9si!sq9ss5st7 -sa@sb6sc{sg9si!sq9ss5st7sx% -sa@sb6sc{sg9si!sq9ss5sx% -sa@sb6sc{sg9si!sq9st+ -sa@sb6sc{sg9si!sq9st+sx% -sa@sb6sc{sg9si!sq9st7 -sa@sb6sc{sg9si!sq9st7sx% -sa@sb6sc{sg9si!sq9sx% -sa@sb6sc{sg9si!ss$ -sa@sb6sc{sg9si!ss$st+ -sa@sb6sc{sg9si!ss$st+sx% -sa@sb6sc{sg9si!ss$st7 -sa@sb6sc{sg9si!ss$st7sx% -sa@sb6sc{sg9si!ss$sx% -sa@sb6sc{sg9si!ss5 -sa@sb6sc{sg9si!ss5st+ -sa@sb6sc{sg9si!ss5st+sx% -sa@sb6sc{sg9si!ss5st7 -sa@sb6sc{sg9si!ss5st7sx% -sa@sb6sc{sg9si!ss5sx% -sa@sb6sc{sg9si!st+ -sa@sb6sc{sg9si!st+sx% -sa@sb6sc{sg9si!st7 -sa@sb6sc{sg9si!st7sx% -sa@sb6sc{sg9si!sx% -sa@sb6sc{sg9si1 -sa@sb6sc{sg9si1so0 -sa@sb6sc{sg9si1so0sq9 -sa@sb6sc{sg9si1so0sq9ss$ -sa@sb6sc{sg9si1so0sq9ss$st+ -sa@sb6sc{sg9si1so0sq9ss$st+sx% -sa@sb6sc{sg9si1so0sq9ss$st7 -sa@sb6sc{sg9si1so0sq9ss$st7sx% -sa@sb6sc{sg9si1so0sq9ss$sx% -sa@sb6sc{sg9si1so0sq9ss5 -sa@sb6sc{sg9si1so0sq9ss5st+ -sa@sb6sc{sg9si1so0sq9ss5st+sx% -sa@sb6sc{sg9si1so0sq9ss5st7 -sa@sb6sc{sg9si1so0sq9ss5st7sx% -sa@sb6sc{sg9si1so0sq9ss5sx% -sa@sb6sc{sg9si1so0sq9st+ -sa@sb6sc{sg9si1so0sq9st+sx% -sa@sb6sc{sg9si1so0sq9st7 -sa@sb6sc{sg9si1so0sq9st7sx% -sa@sb6sc{sg9si1so0sq9sx% -sa@sb6sc{sg9si1so0ss$ -sa@sb6sc{sg9si1so0ss$st+ -sa@sb6sc{sg9si1so0ss$st+sx% -sa@sb6sc{sg9si1so0ss$st7 -sa@sb6sc{sg9si1so0ss$st7sx% -sa@sb6sc{sg9si1so0ss$sx% -sa@sb6sc{sg9si1so0ss5 -sa@sb6sc{sg9si1so0ss5st+ -sa@sb6sc{sg9si1so0ss5st+sx% -sa@sb6sc{sg9si1so0ss5st7 -sa@sb6sc{sg9si1so0ss5st7sx% -sa@sb6sc{sg9si1so0ss5sx% -sa@sb6sc{sg9si1so0st+ -sa@sb6sc{sg9si1so0st+sx% -sa@sb6sc{sg9si1so0st7 -sa@sb6sc{sg9si1so0st7sx% -sa@sb6sc{sg9si1so0sx% -sa@sb6sc{sg9si1sq9 -sa@sb6sc{sg9si1sq9ss$ -sa@sb6sc{sg9si1sq9ss$st+ -sa@sb6sc{sg9si1sq9ss$st+sx% -sa@sb6sc{sg9si1sq9ss$st7 -sa@sb6sc{sg9si1sq9ss$st7sx% -sa@sb6sc{sg9si1sq9ss$sx% -sa@sb6sc{sg9si1sq9ss5 -sa@sb6sc{sg9si1sq9ss5st+ -sa@sb6sc{sg9si1sq9ss5st+sx% -sa@sb6sc{sg9si1sq9ss5st7 -sa@sb6sc{sg9si1sq9ss5st7sx% -sa@sb6sc{sg9si1sq9ss5sx% -sa@sb6sc{sg9si1sq9st+ -sa@sb6sc{sg9si1sq9st+sx% -sa@sb6sc{sg9si1sq9st7 -sa@sb6sc{sg9si1sq9st7sx% -sa@sb6sc{sg9si1sq9sx% -sa@sb6sc{sg9si1ss$ -sa@sb6sc{sg9si1ss$st+ -sa@sb6sc{sg9si1ss$st+sx% -sa@sb6sc{sg9si1ss$st7 -sa@sb6sc{sg9si1ss$st7sx% -sa@sb6sc{sg9si1ss$sx% -sa@sb6sc{sg9si1ss5 -sa@sb6sc{sg9si1ss5st+ -sa@sb6sc{sg9si1ss5st+sx% -sa@sb6sc{sg9si1ss5st7 -sa@sb6sc{sg9si1ss5st7sx% -sa@sb6sc{sg9si1ss5sx% -sa@sb6sc{sg9si1st+ -sa@sb6sc{sg9si1st+sx% -sa@sb6sc{sg9si1st7 -sa@sb6sc{sg9si1st7sx% -sa@sb6sc{sg9si1sx% -sa@sb6sc{sg9so0 -sa@sb6sc{sg9so0sq9 -sa@sb6sc{sg9so0sq9ss$ -sa@sb6sc{sg9so0sq9ss$st+ -sa@sb6sc{sg9so0sq9ss$st+sx% -sa@sb6sc{sg9so0sq9ss$st7 -sa@sb6sc{sg9so0sq9ss$st7sx% -sa@sb6sc{sg9so0sq9ss$sx% -sa@sb6sc{sg9so0sq9ss5 -sa@sb6sc{sg9so0sq9ss5st+ -sa@sb6sc{sg9so0sq9ss5st+sx% -sa@sb6sc{sg9so0sq9ss5st7 -sa@sb6sc{sg9so0sq9ss5st7sx% -sa@sb6sc{sg9so0sq9ss5sx% -sa@sb6sc{sg9so0sq9st+ -sa@sb6sc{sg9so0sq9st+sx% -sa@sb6sc{sg9so0sq9st7 -sa@sb6sc{sg9so0sq9st7sx% -sa@sb6sc{sg9so0sq9sx% -sa@sb6sc{sg9so0ss$ -sa@sb6sc{sg9so0ss$st+ -sa@sb6sc{sg9so0ss$st+sx% -sa@sb6sc{sg9so0ss$st7 -sa@sb6sc{sg9so0ss$st7sx% -sa@sb6sc{sg9so0ss$sx% -sa@sb6sc{sg9so0ss5 -sa@sb6sc{sg9so0ss5st+ -sa@sb6sc{sg9so0ss5st+sx% -sa@sb6sc{sg9so0ss5st7 -sa@sb6sc{sg9so0ss5st7sx% -sa@sb6sc{sg9so0ss5sx% -sa@sb6sc{sg9so0st+ -sa@sb6sc{sg9so0st+sx% -sa@sb6sc{sg9so0st7 -sa@sb6sc{sg9so0st7sx% -sa@sb6sc{sg9so0sx% -sa@sb6sc{sg9sq9 -sa@sb6sc{sg9sq9ss$ -sa@sb6sc{sg9sq9ss$st+ -sa@sb6sc{sg9sq9ss$st+sx% -sa@sb6sc{sg9sq9ss$st7 -sa@sb6sc{sg9sq9ss$st7sx% -sa@sb6sc{sg9sq9ss$sx% -sa@sb6sc{sg9sq9ss5 -sa@sb6sc{sg9sq9ss5st+ -sa@sb6sc{sg9sq9ss5st+sx% -sa@sb6sc{sg9sq9ss5st7 -sa@sb6sc{sg9sq9ss5st7sx% -sa@sb6sc{sg9sq9ss5sx% -sa@sb6sc{sg9sq9st+ -sa@sb6sc{sg9sq9st+sx% -sa@sb6sc{sg9sq9st7 -sa@sb6sc{sg9sq9st7sx% -sa@sb6sc{sg9sq9sx% -sa@sb6sc{sg9ss$ -sa@sb6sc{sg9ss$st+ -sa@sb6sc{sg9ss$st+sx% -sa@sb6sc{sg9ss$st7 -sa@sb6sc{sg9ss$st7sx% -sa@sb6sc{sg9ss$sx% -sa@sb6sc{sg9ss5 -sa@sb6sc{sg9ss5st+ -sa@sb6sc{sg9ss5st+sx% -sa@sb6sc{sg9ss5st7 -sa@sb6sc{sg9ss5st7sx% -sa@sb6sc{sg9ss5sx% -sa@sb6sc{sg9st+ -sa@sb6sc{sg9st+sx% -sa@sb6sc{sg9st7 -sa@sb6sc{sg9st7sx% -sa@sb6sc{sg9sx% -sa@sb6sc{si! -sa@sb6sc{si!so0 -sa@sb6sc{si!so0sq9 -sa@sb6sc{si!so0sq9ss$ -sa@sb6sc{si!so0sq9ss$st+ -sa@sb6sc{si!so0sq9ss$st+sx% -sa@sb6sc{si!so0sq9ss$st7 -sa@sb6sc{si!so0sq9ss$st7sx% -sa@sb6sc{si!so0sq9ss$sx% -sa@sb6sc{si!so0sq9ss5 -sa@sb6sc{si!so0sq9ss5st+ -sa@sb6sc{si!so0sq9ss5st+sx% -sa@sb6sc{si!so0sq9ss5st7 -sa@sb6sc{si!so0sq9ss5st7sx% -sa@sb6sc{si!so0sq9ss5sx% -sa@sb6sc{si!so0sq9st+ -sa@sb6sc{si!so0sq9st+sx% -sa@sb6sc{si!so0sq9st7 -sa@sb6sc{si!so0sq9st7sx% -sa@sb6sc{si!so0sq9sx% -sa@sb6sc{si!so0ss$ -sa@sb6sc{si!so0ss$st+ -sa@sb6sc{si!so0ss$st+sx% -sa@sb6sc{si!so0ss$st7 -sa@sb6sc{si!so0ss$st7sx% -sa@sb6sc{si!so0ss$sx% -sa@sb6sc{si!so0ss5 -sa@sb6sc{si!so0ss5st+ -sa@sb6sc{si!so0ss5st+sx% -sa@sb6sc{si!so0ss5st7 -sa@sb6sc{si!so0ss5st7sx% -sa@sb6sc{si!so0ss5sx% -sa@sb6sc{si!so0st+ -sa@sb6sc{si!so0st+sx% -sa@sb6sc{si!so0st7 -sa@sb6sc{si!so0st7sx% -sa@sb6sc{si!so0sx% -sa@sb6sc{si!sq9 -sa@sb6sc{si!sq9ss$ -sa@sb6sc{si!sq9ss$st+ -sa@sb6sc{si!sq9ss$st+sx% -sa@sb6sc{si!sq9ss$st7 -sa@sb6sc{si!sq9ss$st7sx% -sa@sb6sc{si!sq9ss$sx% -sa@sb6sc{si!sq9ss5 -sa@sb6sc{si!sq9ss5st+ -sa@sb6sc{si!sq9ss5st+sx% -sa@sb6sc{si!sq9ss5st7 -sa@sb6sc{si!sq9ss5st7sx% -sa@sb6sc{si!sq9ss5sx% -sa@sb6sc{si!sq9st+ -sa@sb6sc{si!sq9st+sx% -sa@sb6sc{si!sq9st7 -sa@sb6sc{si!sq9st7sx% -sa@sb6sc{si!sq9sx% -sa@sb6sc{si!ss$ -sa@sb6sc{si!ss$st+ -sa@sb6sc{si!ss$st+sx% -sa@sb6sc{si!ss$st7 -sa@sb6sc{si!ss$st7sx% -sa@sb6sc{si!ss$sx% -sa@sb6sc{si!ss5 -sa@sb6sc{si!ss5st+ -sa@sb6sc{si!ss5st+sx% -sa@sb6sc{si!ss5st7 -sa@sb6sc{si!ss5st7sx% -sa@sb6sc{si!ss5sx% -sa@sb6sc{si!st+ -sa@sb6sc{si!st+sx% -sa@sb6sc{si!st7 -sa@sb6sc{si!st7sx% -sa@sb6sc{si!sx% -sa@sb6sc{si1 -sa@sb6sc{si1so0 -sa@sb6sc{si1so0sq9 -sa@sb6sc{si1so0sq9ss$ -sa@sb6sc{si1so0sq9ss$st+ -sa@sb6sc{si1so0sq9ss$st+sx% -sa@sb6sc{si1so0sq9ss$st7 -sa@sb6sc{si1so0sq9ss$st7sx% -sa@sb6sc{si1so0sq9ss$sx% -sa@sb6sc{si1so0sq9ss5 -sa@sb6sc{si1so0sq9ss5st+ -sa@sb6sc{si1so0sq9ss5st+sx% -sa@sb6sc{si1so0sq9ss5st7 -sa@sb6sc{si1so0sq9ss5st7sx% -sa@sb6sc{si1so0sq9ss5sx% -sa@sb6sc{si1so0sq9st+ -sa@sb6sc{si1so0sq9st+sx% -sa@sb6sc{si1so0sq9st7 -sa@sb6sc{si1so0sq9st7sx% -sa@sb6sc{si1so0sq9sx% -sa@sb6sc{si1so0ss$ -sa@sb6sc{si1so0ss$st+ -sa@sb6sc{si1so0ss$st+sx% -sa@sb6sc{si1so0ss$st7 -sa@sb6sc{si1so0ss$st7sx% -sa@sb6sc{si1so0ss$sx% -sa@sb6sc{si1so0ss5 -sa@sb6sc{si1so0ss5st+ -sa@sb6sc{si1so0ss5st+sx% -sa@sb6sc{si1so0ss5st7 -sa@sb6sc{si1so0ss5st7sx% -sa@sb6sc{si1so0ss5sx% -sa@sb6sc{si1so0st+ -sa@sb6sc{si1so0st+sx% -sa@sb6sc{si1so0st7 -sa@sb6sc{si1so0st7sx% -sa@sb6sc{si1so0sx% -sa@sb6sc{si1sq9 -sa@sb6sc{si1sq9ss$ -sa@sb6sc{si1sq9ss$st+ -sa@sb6sc{si1sq9ss$st+sx% -sa@sb6sc{si1sq9ss$st7 -sa@sb6sc{si1sq9ss$st7sx% -sa@sb6sc{si1sq9ss$sx% -sa@sb6sc{si1sq9ss5 -sa@sb6sc{si1sq9ss5st+ -sa@sb6sc{si1sq9ss5st+sx% -sa@sb6sc{si1sq9ss5st7 -sa@sb6sc{si1sq9ss5st7sx% -sa@sb6sc{si1sq9ss5sx% -sa@sb6sc{si1sq9st+ -sa@sb6sc{si1sq9st+sx% -sa@sb6sc{si1sq9st7 -sa@sb6sc{si1sq9st7sx% -sa@sb6sc{si1sq9sx% -sa@sb6sc{si1ss$ -sa@sb6sc{si1ss$st+ -sa@sb6sc{si1ss$st+sx% -sa@sb6sc{si1ss$st7 -sa@sb6sc{si1ss$st7sx% -sa@sb6sc{si1ss$sx% -sa@sb6sc{si1ss5 -sa@sb6sc{si1ss5st+ -sa@sb6sc{si1ss5st+sx% -sa@sb6sc{si1ss5st7 -sa@sb6sc{si1ss5st7sx% -sa@sb6sc{si1ss5sx% -sa@sb6sc{si1st+ -sa@sb6sc{si1st+sx% -sa@sb6sc{si1st7 -sa@sb6sc{si1st7sx% -sa@sb6sc{si1sx% -sa@sb6sc{so0 -sa@sb6sc{so0sq9 -sa@sb6sc{so0sq9ss$ -sa@sb6sc{so0sq9ss$st+ -sa@sb6sc{so0sq9ss$st+sx% -sa@sb6sc{so0sq9ss$st7 -sa@sb6sc{so0sq9ss$st7sx% -sa@sb6sc{so0sq9ss$sx% -sa@sb6sc{so0sq9ss5 -sa@sb6sc{so0sq9ss5st+ -sa@sb6sc{so0sq9ss5st+sx% -sa@sb6sc{so0sq9ss5st7 -sa@sb6sc{so0sq9ss5st7sx% -sa@sb6sc{so0sq9ss5sx% -sa@sb6sc{so0sq9st+ -sa@sb6sc{so0sq9st+sx% -sa@sb6sc{so0sq9st7 -sa@sb6sc{so0sq9st7sx% -sa@sb6sc{so0sq9sx% -sa@sb6sc{so0ss$ -sa@sb6sc{so0ss$st+ -sa@sb6sc{so0ss$st+sx% -sa@sb6sc{so0ss$st7 -sa@sb6sc{so0ss$st7sx% -sa@sb6sc{so0ss$sx% -sa@sb6sc{so0ss5 -sa@sb6sc{so0ss5st+ -sa@sb6sc{so0ss5st+sx% -sa@sb6sc{so0ss5st7 -sa@sb6sc{so0ss5st7sx% -sa@sb6sc{so0ss5sx% -sa@sb6sc{so0st+ -sa@sb6sc{so0st+sx% -sa@sb6sc{so0st7 -sa@sb6sc{so0st7sx% -sa@sb6sc{so0sx% -sa@sb6sc{sq9 -sa@sb6sc{sq9ss$ -sa@sb6sc{sq9ss$st+ -sa@sb6sc{sq9ss$st+sx% -sa@sb6sc{sq9ss$st7 -sa@sb6sc{sq9ss$st7sx% -sa@sb6sc{sq9ss$sx% -sa@sb6sc{sq9ss5 -sa@sb6sc{sq9ss5st+ -sa@sb6sc{sq9ss5st+sx% -sa@sb6sc{sq9ss5st7 -sa@sb6sc{sq9ss5st7sx% -sa@sb6sc{sq9ss5sx% -sa@sb6sc{sq9st+ -sa@sb6sc{sq9st+sx% -sa@sb6sc{sq9st7 -sa@sb6sc{sq9st7sx% -sa@sb6sc{sq9sx% -sa@sb6sc{ss$ -sa@sb6sc{ss$st+ -sa@sb6sc{ss$st+sx% -sa@sb6sc{ss$st7 -sa@sb6sc{ss$st7sx% -sa@sb6sc{ss$sx% -sa@sb6sc{ss5 -sa@sb6sc{ss5st+ -sa@sb6sc{ss5st+sx% -sa@sb6sc{ss5st7 -sa@sb6sc{ss5st7sx% -sa@sb6sc{ss5sx% -sa@sb6sc{st+ -sa@sb6sc{st+sx% -sa@sb6sc{st7 -sa@sb6sc{st7sx% -sa@sb6sc{sx% -sa@sb6sc< -sa@sb6sc*73 -$2^r -$2^x'6 -$2c$H -$2d -$2dD4 -$2dD5 -$2dD6 -$2dD7 -$2d] -$2i2a -$2i57 -$2i6R -$2i6a -$2i8B -$2l -$2o0p -$2o2T -$2o62 -$2o67 -$2o6F -$2o8b -$2o9 -$2q -$2r -$2sbR -$2sqrt -$2t -$2tO62 -$2O24O64 -$2O32 -$2O42O16 -$2O51 -$2O53 -$2O61 -$2O73 -$2O74O04 -$2O82 -$2OA2 -$2z3 -$2z4 -$2{ +$2 $! +$2 $" +$2 $% +$2 $* +$2 $0 +$2 $0 $0 $0 +$2 $0 $0 $1 +$2 $0 $0 $2 +$2 $0 $0 $3 +$2 $0 $0 $4 +$2 $0 $0 $5 +$2 $0 $0 $6 +$2 $0 $0 $7 +$2 $0 $0 $8 +$2 $0 $0 $9 +$2 $0 $1 $0 +$2 $0 $1 $1 +$2 $0 $1 $2 +$2 $0 $1 $3 +$2 $0 $1 $4 +$2 $0 $1 $5 +$2 $0 $1 $6 +$2 $0 $1 $7 +$2 $0 $1 $8 +$2 $0 $1 $9 +$2 $0 $2 $0 +$2 $0 $2 $1 +$2 $0 $2 $2 +$2 $0 $2 $3 +$2 $0 $2 $4 +$2 $0 $2 $5 +$2 $0 $2 $6 +$2 $0 $2 $7 +$2 $0 $2 $8 +$2 $0 $2 $9 +$2 $1 +$2 $2 +$2 $2 $2 +$2 $3 +$2 $3 $4 +$2 $4 +$2 $5 +$2 $6 +$2 $7 +$2 $8 +$2 $9 +$2 $U +$2 $] +$2 $d +$2 $i +$2 $k +$2 $m $e +$2 $o +$2 $u +$2 $x +$2 *03 $i +$2 *14 +$2 *30 +$2 *32 +$2 *52 +$2 *57 +$2 *68 +$2 *78 +$2 *81 +$2 +3 +$2 +4 +$2 +7 +$2 -3 +$2 -9 +$2 @u +$2 C +$2 D4 +$2 L1 +$2 L5 Z1 +$2 R1 +$2 R3 +$2 R6 +$2 T0 +$2 Z2 *29 +$2 Z3 +$2 Z4 +$2 Z5 D9 +$2 [ z3 +$2 ^4 +$2 ^> *73 +$2 ^r +$2 ^x '6 +$2 c $H +$2 d +$2 d D4 +$2 d D5 +$2 d D6 +$2 d D7 +$2 d ] +$2 i2a +$2 i57 +$2 i6R +$2 i6a +$2 i8B +$2 l +$2 o0p +$2 o2T +$2 o62 +$2 o67 +$2 o6F +$2 o8b +$2 o9 +$2 q +$2 r +$2 sbR +$2 sqr t +$2 t +$2 t O62 +$2 O24 O64 +$2 O32 +$2 O42 O16 +$2 O51 +$2 O53 +$2 O61 +$2 O73 +$2 O74 O04 +$2 O82 +$2 OA2 +$2 z3 +$2 z4 +$2 { $3 -$3$% -$3$* -$3$0 -$3$0$0$0 -$3$1 -$3$2 -$3$2$1 -$3$3 -$3$3$3 -$3$4 -$3$4$5 -$3$5 -$3$6 -$3$7 -$3$8 -$3$9 -$3$d -$3$f -$3$i -$3$j -$3$k -$3*12 -$3*57 -$3*74 -$3*97 -$3+2 -$3+5 -$3+8 -$3-8 -$3-9*57 -$3@e -$3@o -$3C -$3D2 -$3D3 -$3D4z1 -$3DA -$3L0 -$3T2 -$3Z3 -$3Z4 -$3Z5 -$3^5T7 -$3^N -$3^d -$3c -$3d -$3dD4 -$3dD5 -$3dD6 -$3dD7 -$3dZ1 -$3d] -$3dO58 -$3f -$3i1a -$3i2h*41 -$3i3f -$3i66 -$3i6@ -$3i7< -$3i7y -$3i8< -$3k -$3o4/ -$3o4g -$3o58 -$3o62 -$3o6= -$3o6z -$3r -$3s5aO12 -$3sfs -$3snk -$3srl -$3szb -$3t -$3t^q -$3ti9? -$3u -$3O02 -$3O09 -$3O28 -$3O42u -$3O61 -$3O71 -$3O92 -$3z2 -$3{ +$3 $% +$3 $* +$3 $0 +$3 $0 $0 $0 +$3 $1 +$3 $2 +$3 $2 $1 +$3 $3 +$3 $3 $3 +$3 $4 +$3 $4 $5 +$3 $5 +$3 $6 +$3 $7 +$3 $8 +$3 $9 +$3 $d +$3 $f +$3 $i +$3 $j +$3 $k +$3 *12 +$3 *57 +$3 *74 +$3 *97 +$3 +2 +$3 +5 +$3 +8 +$3 -8 +$3 -9 *57 +$3 @e +$3 @o +$3 C +$3 D2 +$3 D3 +$3 D4 z1 +$3 DA +$3 L0 +$3 T2 +$3 Z3 +$3 Z4 +$3 Z5 +$3 ^5 T7 +$3 ^N +$3 ^d +$3 c +$3 d +$3 d D4 +$3 d D5 +$3 d D6 +$3 d D7 +$3 d Z1 +$3 d ] +$3 d O58 +$3 f +$3 i1a +$3 i2h *41 +$3 i3f +$3 i66 +$3 i6@ +$3 i7< +$3 i7y +$3 i8< +$3 k +$3 o4/ +$3 o4g +$3 o58 +$3 o62 +$3 o6= +$3 o6z +$3 r +$3 s5a O12 +$3 sfs +$3 snk +$3 srl +$3 szb +$3 t +$3 t ^q +$3 t i9? +$3 u +$3 O02 +$3 O09 +$3 O28 +$3 O42 u +$3 O61 +$3 O71 +$3 O92 +$3 z2 +$3 { $4 -$4$0 -$4$0$0$0 -$4$1 -$4$2 -$4$3 -$4$3$2$1 -$4$4 -$4$4$4 -$4$5 -$4$5$6 -$4$6 -$4$7 -$4$8 -$4$9 -$4$M$e -$4$a$l$l -$4$e$v$e$r -$4$f$r$e$e -$4$l$i$f$e -$4$m$e -$4$m$y -$4$u -$4$u$s -$4'8 -$4*85 -$4*86 -$4*89 -$4+0 -$4+2 -$4+8 -$4+9 -$4-7 -$4-8 -$4-9 -$4@5t -$4D7 -$4D9 -$4DA -$4L0Z1 -$4L4$q -$4R0'7 -$4T5 -$4Z3 -$4Z4 -$4Z5 -$4^& -$4^2o60 -$4^c -$4^r -$4d -$4dD4 -$4dD5 -$4dD6 -$4dD7 -$4d] -$4dO49 -$4i5- -$4i5N+7 -$4i5q*15 -$4i5r -$4i8! -$4k -$4o0E -$4o2YO46 -$4o2o -$4o4o -$4o5dO54 -$4o5gZ3 -$4o7R -$4q -$4qq -$4r -$4sdr -$4sma@r -$4sr1 -$4sxm -$4t -$4O02 -$4O13 -$4O21 -$4O23 -$4O35i3b -$4O47 -$4O62 -$4O81 -$4O82 -$4z3 -$4{ -$5 -$5$0 -$5$0$0$0 -$5$1 -$5$2 -$5$3 -$5$4 -$5$4$3$2$1 -$5$5 -$5$5$5 -$5$6 -$5$6$7 -$5$7 -$5$8 -$5$9 -$5*56 -$5*57 -$5*73OA2 -$5*75O63 -$5+1 -$5+5 -$5-1 -$5-7 -$5-8 -$5@6 -$5@w -$5CZ5 -$5D8 -$5DA -$5L8+3 -$5R0 -$5R4 -$5T6 -$5Z1*30 -$5Z3 -$5Z3L4 -$5Z4 -$5Z5O56 -$5[ -$5^$ -$5^+ -$5^j -$5d -$5dD4 -$5dD5 -$5dD6 -$5dD7 -$5d] -$5fL1 -$5i2! -$5i2E -$5i5b*24 -$5i6 -$5i9% -$5l -$5o4- -$5o5l -$5o65 -$5o66 -$5o7o -$5p1O53 -$5q -$5sk1 -$5skw -$5sr#O12 -$5t -$5O21 -$5O32 -$5O41 -$5O51 -$5O52 -$5O91 -$5OB1OB1 -$5z1 -$5z2 -$6 -$6$- -$6$0 -$6$0$0$0 -$6$1 -$6$2 -$6$3 -$6$3sys -$6$4 -$6$5 -$6$5$4$3$2$1 -$6$6 -$6$6$6 -$6$7 -$6$7$8 -$6$8 -$6$9 -$6$B -$6$V -$6$m -$6'4Z5 -$6*05 -$6*57 -$6*9B -$6+4@k -$6+7 -$6+8 -$6-0 -$6-2 -$6-8 -$6-9 -$6@o -$6D6 -$6L1 -$6L5c -$6R1 -$6T2 -$6T3 -$6Z1i4c -$6Z3 -$6Z4 -$6Z5 -$6[ -$6^6o1Q -$6^H -$6c -$6d -$6dD4 -$6dD5 -$6dD6 -$6dD7 -$6d] -$6i0D -$6i1DT4 -$6i2j -$6i39 -$6i7ao6< -$6i7g -$6i8t -$6k -$6o2Z -$6o2r -$6o4D -$6r -$6r+5 -$6s19 -$6svV -$6sw' -$6O05 -$6O16 -$6O23 -$6O26 -$6O34c -$6O53 -$6O61O62 -$6O62 -$6O73 -$6OB4 -$6z4 -$6{ +$4 $0 +$4 $0 $0 $0 +$4 $1 +$4 $2 +$4 $3 +$4 $3 $2 $1 +$4 $4 +$4 $4 $4 +$4 $5 +$4 $5 $6 +$4 $6 +$4 $7 +$4 $8 +$4 $9 +$4 $M $e +$4 $a $l $l +$4 $e $v $e $r +$4 $f $r $e $e +$4 $l $i $f $e +$4 $m $e +$4 $m $y +$4 $u +$4 $u $s +$4 '8 +$4 *85 +$4 *86 +$4 *89 +$4 +0 +$4 +2 +$4 +8 +$4 +9 +$4 -7 +$4 -8 +$4 -9 +$4 @5 t +$4 D7 +$4 D9 +$4 DA +$4 L0 Z1 +$4 L4 $q +$4 R0 '7 +$4 T5 +$4 Z3 +$4 Z4 +$4 Z5 +$4 ^& +$4 ^2 o60 +$4 ^c +$4 ^r +$4 d +$4 d D4 +$4 d D5 +$4 d D6 +$4 d D7 +$4 d ] +$4 d O49 +$4 i5- +$4 i5N +7 +$4 i5q *15 +$4 i5r +$4 i8! +$4 k +$4 o0E +$4 o2Y O46 +$4 o2o +$4 o4o +$4 o5d O54 +$4 o5g Z3 +$4 o7R +$4 q +$4 q q +$4 r +$4 sdr +$4 sma @r +$4 sr1 +$4 sxm +$4 t +$4 O02 +$4 O13 +$4 O21 +$4 O23 +$4 O35 i3b +$4 O47 +$4 O62 +$4 O81 +$4 O82 +$4 z3 +$4 { +$5 +$5 $0 +$5 $0 $0 $0 +$5 $1 +$5 $2 +$5 $3 +$5 $4 +$5 $4 $3 $2 $1 +$5 $5 +$5 $5 $5 +$5 $6 +$5 $6 $7 +$5 $7 +$5 $8 +$5 $9 +$5 *56 +$5 *57 +$5 *73 OA2 +$5 *75 O63 +$5 +1 +$5 +5 +$5 -1 +$5 -7 +$5 -8 +$5 @6 +$5 @w +$5 C Z5 +$5 D8 +$5 DA +$5 L8 +3 +$5 R0 +$5 R4 +$5 T6 +$5 Z1 *30 +$5 Z3 +$5 Z3 L4 +$5 Z4 +$5 Z5 O56 +$5 [ +$5 ^$ +$5 ^+ +$5 ^j +$5 d +$5 d D4 +$5 d D5 +$5 d D6 +$5 d D7 +$5 d ] +$5 f L1 +$5 i2! +$5 i2E +$5 i5b *24 +$5 i6 +$5 i9% +$5 l +$5 o4- +$5 o5l +$5 o65 +$5 o66 +$5 o7o +$5 p1 O53 +$5 q +$5 sk1 +$5 skw +$5 sr# O12 +$5 t +$5 O21 +$5 O32 +$5 O41 +$5 O51 +$5 O52 +$5 O91 +$5 OB1 OB1 +$5 z1 +$5 z2 +$6 +$6 $- +$6 $0 +$6 $0 $0 $0 +$6 $1 +$6 $2 +$6 $3 +$6 $3 sys +$6 $4 +$6 $5 +$6 $5 $4 $3 $2 $1 +$6 $6 +$6 $6 $6 +$6 $7 +$6 $7 $8 +$6 $8 +$6 $9 +$6 $B +$6 $V +$6 $m +$6 '4 Z5 +$6 *05 +$6 *57 +$6 *9B +$6 +4 @k +$6 +7 +$6 +8 +$6 -0 +$6 -2 +$6 -8 +$6 -9 +$6 @o +$6 D6 +$6 L1 +$6 L5 c +$6 R1 +$6 T2 +$6 T3 +$6 Z1 i4c +$6 Z3 +$6 Z4 +$6 Z5 +$6 [ +$6 ^6 o1Q +$6 ^H +$6 c +$6 d +$6 d D4 +$6 d D5 +$6 d D6 +$6 d D7 +$6 d ] +$6 i0D +$6 i1D T4 +$6 i2j +$6 i39 +$6 i7a o6< +$6 i7g +$6 i8t +$6 k +$6 o2Z +$6 o2r +$6 o4D +$6 r +$6 r +5 +$6 s19 +$6 svV +$6 sw' +$6 O05 +$6 O16 +$6 O23 +$6 O26 +$6 O34 c +$6 O53 +$6 O61 O62 +$6 O62 +$6 O73 +$6 OB4 +$6 z4 +$6 { $7 -$7$0 -$7$0$0$0 -$7$1 -$7$2 -$7$3 -$7$4 -$7$5 -$7$6 -$7$7 -$7$7$7 -$7$8 -$7$8$9 -$7$9 -$7$b -$7$e-2 -$7$j -$7$n -$7'6$t -$7*47O61 -$7*51O31 -$7*64 -$7*87 -$7*98 -$7+1 -$7+3 -$7+A -$7-7 -$7@b -$7@i -$7C -$7D2 -$7L0 -$7L1 -$7R7 -$7Z3 -$7Z4 -$7Z5 -$7[ -$7^4 -$7d -$7dD4 -$7dD5 -$7dD6 -$7dD7 -$7d] -$7dO62 -$7i0x -$7i2\O03 -$7i63 -$7k -$7l-0 -$7o0Z -$7o0ksmc -$7o1A -$7o61 -$7o6T -$7p2 -$7s4_ -$7sgc -$7t+0 -$7O03*20 -$7O46'5 -$7O52 -$7O54 -$7O62 -$7O82 -$7O95 -$7OB3 -$7z1 -$7z2 -$7z5 -$7z5O08 -$8 -$8$+ -$8$/ -$8$0 -$8$0$0$0 -$8$1 -$8$2 -$8$3 -$8$4 -$8$5 -$8$6 -$8$7 -$8$8 -$8$8$8 -$8$9 -$8$d -$8$p -$8*01$? -$8*04 -$8*13 -$8*23 -$8*62 -$8*68 -$8*75 -$8*78 -$8*A5 -$8+0*43 -$8-5 -$8-7 -$8@f -$8@m -$8@y -$8D2 -$8D4 -$8DB -$8L1 -$8R1 -$8T2 -$8T8T4 -$8Z3 -$8Z5 -$8^b -$8c -$8d -$8dD4 -$8dD5 -$8dD6 -$8dD7 -$8d] -$8i3N -$8i4e -$8o0dO42 -$8o1u -$8o4cL6 -$8o88 -$8q -$8r -$8s61 -$8s9a -$8t -$8u -$8O23 -$8O42 -$8O46z2 -$8O63 -$8O83 -$8O83-7 -$8O92 -$8z1c -$8z1l -$8z2 -$8z3 -$8{ -$9 -$9$% -$9$0 -$9$0$0$0 -$9$1 -$9$2 -$9$3 -$9$4 -$9$5 -$9$6 -$9$7 -$9$8 -$9$9 -$9$9$9 -$9$O -$9$g -$9$i -$9*01 -$9*04 -$9*12 -$9*14 -$9*15 -$9*20 -$9+4 -$9-4 -$9-6 -$9-8 -$9@8 -$9@g -$9D5 -$9L1 -$9R5 -$9R8 -$9T2 -$9Z3 -$9Z4 -$9Z5 -$9[ -$9^# -$9^D -$9^g -$9^i -$9^l -$9d -$9dD4 -$9dD5 -$9dD6 -$9dD7 -$9d] -$9f+2 -$9i5. -$9i8k -$9i95 -$9l -$9o0% -$9o2yt -$9o5V -$9o5it -$9o76 -$9o84 -$9q -$9r -$9t -$9O04 -$9O07 -$9O25R5 -$9O53 -$9O65 -$9O72 -$9OA2 -$9OB1 -$9z1 -$9z3 -$9z3O35 -$9{ +$7 $0 +$7 $0 $0 $0 +$7 $1 +$7 $2 +$7 $3 +$7 $4 +$7 $5 +$7 $6 +$7 $7 +$7 $7 $7 +$7 $8 +$7 $8 $9 +$7 $9 +$7 $b +$7 $e -2 +$7 $j +$7 $n +$7 '6 $t +$7 *47 O61 +$7 *51 O31 +$7 *64 +$7 *87 +$7 *98 +$7 +1 +$7 +3 +$7 +A +$7 -7 +$7 @b +$7 @i +$7 C +$7 D2 +$7 L0 +$7 L1 +$7 R7 +$7 Z3 +$7 Z4 +$7 Z5 +$7 [ +$7 ^4 +$7 d +$7 d D4 +$7 d D5 +$7 d D6 +$7 d D7 +$7 d ] +$7 d O62 +$7 i0x +$7 i2\ O03 +$7 i63 +$7 k +$7 l -0 +$7 o0Z +$7 o0k smc +$7 o1A +$7 o61 +$7 o6T +$7 p2 +$7 s4_ +$7 sgc +$7 t +0 +$7 O03 *20 +$7 O46 '5 +$7 O52 +$7 O54 +$7 O62 +$7 O82 +$7 O95 +$7 OB3 +$7 z1 +$7 z2 +$7 z5 +$7 z5 O08 +$8 +$8 $+ +$8 $/ +$8 $0 +$8 $0 $0 $0 +$8 $1 +$8 $2 +$8 $3 +$8 $4 +$8 $5 +$8 $6 +$8 $7 +$8 $8 +$8 $8 $8 +$8 $9 +$8 $d +$8 $p +$8 *01 $? +$8 *04 +$8 *13 +$8 *23 +$8 *62 +$8 *68 +$8 *75 +$8 *78 +$8 *A5 +$8 +0 *43 +$8 -5 +$8 -7 +$8 @f +$8 @m +$8 @y +$8 D2 +$8 D4 +$8 DB +$8 L1 +$8 R1 +$8 T2 +$8 T8 T4 +$8 Z3 +$8 Z5 +$8 ^b +$8 c +$8 d +$8 d D4 +$8 d D5 +$8 d D6 +$8 d D7 +$8 d ] +$8 i3N +$8 i4e +$8 o0d O42 +$8 o1u +$8 o4c L6 +$8 o88 +$8 q +$8 r +$8 s61 +$8 s9a +$8 t +$8 u +$8 O23 +$8 O42 +$8 O46 z2 +$8 O63 +$8 O83 +$8 O83 -7 +$8 O92 +$8 z1 c +$8 z1 l +$8 z2 +$8 z3 +$8 { +$9 +$9 $% +$9 $0 +$9 $0 $0 $0 +$9 $1 +$9 $2 +$9 $3 +$9 $4 +$9 $5 +$9 $6 +$9 $7 +$9 $8 +$9 $9 +$9 $9 $9 +$9 $O +$9 $g +$9 $i +$9 *01 +$9 *04 +$9 *12 +$9 *14 +$9 *15 +$9 *20 +$9 +4 +$9 -4 +$9 -6 +$9 -8 +$9 @8 +$9 @g +$9 D5 +$9 L1 +$9 R5 +$9 R8 +$9 T2 +$9 Z3 +$9 Z4 +$9 Z5 +$9 [ +$9 ^# +$9 ^D +$9 ^g +$9 ^i +$9 ^l +$9 d +$9 d D4 +$9 d D5 +$9 d D6 +$9 d D7 +$9 d ] +$9 f +2 +$9 i5. +$9 i8k +$9 i95 +$9 l +$9 o0% +$9 o2y t +$9 o5V +$9 o5i t +$9 o76 +$9 o84 +$9 q +$9 r +$9 t +$9 O04 +$9 O07 +$9 O25 R5 +$9 O53 +$9 O65 +$9 O72 +$9 OA2 +$9 OB1 +$9 z1 +$9 z3 +$9 z3 O35 +$9 { $: -$:$) -$:$1 -$:'7 -$:+0 -$:C -$:D2 -$:D4 -$:R0 -$:T6 -$:Z1 -$:Z2 -$:c -$:d -$:o6( -$:r -$:s:%t +$: $) +$: $1 +$: '7 +$: +0 +$: C +$: D2 +$: D4 +$: R0 +$: T6 +$: Z1 +$: Z2 +$: c +$: d +$: o6( +$: r +$: s:% t $; -$;$) -$;$/ -$;$7 -$;$; -$;*01 -$;*61 -$;-7 -$;D9O81 -$;R4 -$;T0 -$;Z2 -$;Z3o2% -$;[ -$;^no4w -$;o7$ -$;o7i -$;u -$;O02 -$;z4 +$; $) +$; $/ +$; $7 +$; $; +$; *01 +$; *61 +$; -7 +$; D9 O81 +$; R4 +$; T0 +$; Z2 +$; Z3 o2% +$; [ +$; ^n o4w +$; o7$ +$; o7i +$; u +$; O02 +$; z4 $< -$<$1 -$<$3 -$<$uo61 -$<'6o2& -$<*12 -$<*46 -$ -$ +$< c +$< o98 +$< r $= -$=$) -$=$9 -$=*43 -$=@ou -$=T5 -$=Z1 -$=Z2l -$=Z3t -$=^\ -$=i5f -$=i5l -$=l -$=lO01 -$=o3y -$=O02 -$=O31 +$= $) +$= $9 +$= *43 +$= @o u +$= T5 +$= Z1 +$= Z2 l +$= Z3 t +$= ^\ +$= i5f +$= i5l +$= l +$= l O01 +$= o3y +$= O02 +$= O31 $> -$>$D*18 -$>$a -$>*27^b -$>D1 -$>Z4 -$>k +$> $D *18 +$> $a +$> *27 ^b +$> D1 +$> Z4 +$> k $? -$?$! -$?$2 -$?*06 -$?*34 -$?*35 -$?*47sfx -$?*62 -$?*87 -$?+5 -$?+6 -$?D5 -$?L4 -$?L8 -$?Z1 -$?Z2 -$?Z3u -$?Z4 -$?[ -$?^! -$?^n -$?^z -$?d -$?i3| -$?q -$?O26 -$?O45 -$?O52 -$?O63 +$? $! +$? $2 +$? *06 +$? *34 +$? *35 +$? *47 sfx +$? *62 +$? *87 +$? +5 +$? +6 +$? D5 +$? L4 +$? L8 +$? Z1 +$? Z2 +$? Z3 u +$? Z4 +$? [ +$? ^! +$? ^n +$? ^z +$? d +$? i3| +$? q +$? O26 +$? O45 +$? O52 +$? O63 $@ -$@$g$m$a$i$l$.$c$o$m -$@$g$m$x$.$d$e -$@$m$a$i$l$.$r$u -$@$y$a$n$d$e$x$.$r$u -$@*76i2M -$@-1^t -$@@i -$@L4 -$@L6 -$@T6 -$@Z1 -$@Z2 -$@Z3 -$@c -$@d -$@i61 -$@o3bO06 -$@o58 -$@t -$@tD4 -$@O02 -$@O12 +$@ $g $m $a $i $l $. $c $o $m +$@ $g $m $x $. $d $e +$@ $m $a $i $l $. $r $u +$@ $y $a $n $d $e $x $. $r $u +$@ *76 i2M +$@ -1 ^t +$@ @i +$@ L4 +$@ L6 +$@ T6 +$@ Z1 +$@ Z2 +$@ Z3 +$@ c +$@ d +$@ i61 +$@ o3b O06 +$@ o58 +$@ t +$@ t D4 +$@ O02 +$@ O12 $A -$A$Y -$A$a -$A$v -$A*54sl* -$A*58O58 -$A+7 -$ACD2 -$AD6 -$AL6 -$AR8@M -$AT2 -$AZ1 -$AZ1r -$AZ3 -$A[ -$A^< -$Ac -$Ak -$Al -$AO16Z3 -$AO24u -$A{ +$A $Y +$A $a +$A $v +$A *54 sl* +$A *58 O58 +$A +7 +$A C D2 +$A D6 +$A L6 +$A R8 @M +$A T2 +$A Z1 +$A Z1 r +$A Z3 +$A [ +$A ^< +$A c +$A k +$A l +$A O16 Z3 +$A O24 u +$A { $B -$B$1 -$B$G -$B$J -$B$e -$B*72 -$B-3 -$BL1 -$BR4O43 -$BZ1 -$BZ2 -$B^*C -$Bi0L -$Bk@8 -$Bl -$BsjBL5 -$BO19c -$BO46 +$B $1 +$B $G +$B $J +$B $e +$B *72 +$B -3 +$B L1 +$B R4 O43 +$B Z1 +$B Z2 +$B ^* C +$B i0L +$B k @8 +$B l +$B sjB L5 +$B O19 c +$B O46 $C -$C$D -$C$R -$C-1 -$CZ1 -$CZ1i2G -$Ci1S -$Cr -$CO12 -$CO18 -$CO91 -$Cz1 +$C $D +$C $R +$C -1 +$C Z1 +$C Z1 i2G +$C i1S +$C r +$C O12 +$C O18 +$C O91 +$C z1 $D -$D$E -$D$I -$D$S -$D$r -$D+0 -$DD1 -$DZ1 -$D^S -$Dc -$Di1nT5 -$Dt -$Du -$DOA3iA( -$Dz2O05 -$Dz4z5 +$D $E +$D $I +$D $S +$D $r +$D +0 +$D D1 +$D Z1 +$D ^S +$D c +$D i1n T5 +$D t +$D u +$D OA3 iA( +$D z2 O05 +$D z4 z5 $E -$E*65 -$E*76o0C -$E+4 -$E-6 -$ED4-3 -$ED8 -$EZ1 -$E[c -$Eo0S -$EtO04 -$EO25 -$EO32 -$EO38 -$E{$S +$E *65 +$E *76 o0C +$E +4 +$E -6 +$E D4 -3 +$E D8 +$E Z1 +$E [ c +$E o0S +$E t O04 +$E O25 +$E O32 +$E O38 +$E { $S $F -$F$C -$F$M -$F$U -$F$m -$F*23 -$F+7 -$FL6o40 -$FR2Z1 -$F[ -$Fo7r -$Fo9w$c -$Ft -$Fu -$FO13 -$FO32*67 -$FO34 -$FO36 +$F $C +$F $M +$F $U +$F $m +$F *23 +$F +7 +$F L6 o40 +$F R2 Z1 +$F [ +$F o7r +$F o9w $c +$F t +$F u +$F O13 +$F O32 *67 +$F O34 +$F O36 $G -$G$A -$G$E -$G$R -$G*09 -$G*75 -$GC$s -$GD5 -$GR8[ -$GZ2 -$GZ5*14 -$G^2 -$Gc -$Gc-0 -$Gi6D -$GlO37 -$Gr -$Gs5D+4 -$Gss3 -$GO02 +$G $A +$G $E +$G $R +$G *09 +$G *75 +$G C $s +$G D5 +$G R8 [ +$G Z2 +$G Z5 *14 +$G ^2 +$G c +$G c -0 +$G i6D +$G l O37 +$G r +$G s5D +4 +$G ss3 +$G O02 $H -$H$t*30 -$H+0 -$H+5 -$H-5o4L -$HD3 -$HTAO62 -$HZ1 -$H^)R5 -$Hi31Z2 -$Hls2f -$Ho0lZ3 -$HsaA -$HsmA$7 +$H $t *30 +$H +0 +$H +5 +$H -5 o4L +$H D3 +$H TA O62 +$H Z1 +$H ^) R5 +$H i31 Z2 +$H l s2f +$H o0l Z3 +$H saA +$H smA $7 $I -$I$! -$I$G -$I$L -$I$Qo1$ -$I$p -$I*10*24 -$I*24 -$I-3u -$I@c -$IT6 -$IZ1 -$IZ2 -$I^R -$Ic -$Ii68O34 -$Il -$Io1_ -$Io79 -$IO08$p -$IO27 -$IO45 -$IO63O31 +$I $! +$I $G +$I $L +$I $Q o1$ +$I $p +$I *10 *24 +$I *24 +$I -3 u +$I @c +$I T6 +$I Z1 +$I Z2 +$I ^R +$I c +$I i68 O34 +$I l +$I o1_ +$I o79 +$I O08 $p +$I O27 +$I O45 +$I O63 O31 $J -$J$B -$J$O -$J$jl -$J*64[ -$J*80 -$J+0^f -$J+2O38 -$JL5 -$J[ -$Jo1iZ1 -$Jo1o -$Js3Y -$JO58 -$JO63 +$J $B +$J $O +$J $j l +$J *64 [ +$J *80 +$J +0 ^f +$J +2 O38 +$J L5 +$J [ +$J o1i Z1 +$J o1o +$J s3Y +$J O58 +$J O63 $K -$K$! -$K$A -$K$Q -$K$l -$K$s -$KD3 -$KT5 -$KZ1 -$KZ1R2 -$K[ -$K^M -$KcoAC -$KcO34 -$Ki6F -$Ki6V -$Kl -$Ko5B -$Kr -$KsbC -$Kt -$Ku^K -$KO17 -$KO18 -$KO32 -$KO52 -$K{T4 +$K $! +$K $A +$K $Q +$K $l +$K $s +$K D3 +$K T5 +$K Z1 +$K Z1 R2 +$K [ +$K ^M +$K c oAC +$K c O34 +$K i6F +$K i6V +$K l +$K o5B +$K r +$K sbC +$K t +$K u ^K +$K O17 +$K O18 +$K O32 +$K O52 +$K { T4 $L -$L$n -$L*16 -$L+0 -$LC -$LT6 -$LZ1 -$LZ2 -$L^%z1 -$L^\ -$Lk^_ -$Lo1n} -$Lro7e -$Lt -$LO12 -$LO1A -$LO63 -$LO68 -$LO73 -$Lz2 +$L $n +$L *16 +$L +0 +$L C +$L T6 +$L Z1 +$L Z2 +$L ^% z1 +$L ^\ +$L k ^_ +$L o1n } +$L r o7e +$L t +$L O12 +$L O1A +$L O63 +$L O68 +$L O73 +$L z2 $M -$M$* -$M$B -$M$L -$M$W -$M+0 -$M+7 -$MD3 -$MZ1 -$MZ2 -$M[-7 -$M^m -$Mc -$Mc@K -$Ml -$Ms2e[ -$MO04 -$MO12 -$MO27 -$MO51 +$M $* +$M $B +$M $L +$M $W +$M +0 +$M +7 +$M D3 +$M Z1 +$M Z2 +$M [ -7 +$M ^m +$M c +$M c @K +$M l +$M s2e [ +$M O04 +$M O12 +$M O27 +$M O51 $N -$N$q*40 -$N'6^m -$N*47 -$N*65 -$N@h'7 -$ND4 -$NT0 -$Nc -$Ni3RO04 -$Ni78 -$Nl{ -$No2F*02 -$No62 -$No8ssiu -$Nr -$Nu -$NO27 -$N{ -$N}Z1 +$N $q *40 +$N '6 ^m +$N *47 +$N *65 +$N @h '7 +$N D4 +$N T0 +$N c +$N i3R O04 +$N i78 +$N l { +$N o2F *02 +$N o62 +$N o8s siu +$N r +$N u +$N O27 +$N { +$N } Z1 $O -$O$K -$O*18 -$O*5BO1A -$O*86 -$OD4 -$OL6 -$OZ1 -$O^3-0 -$OO24 -$OO45o6e -$OO53 -$O{ +$O $K +$O *18 +$O *5B O1A +$O *86 +$O D4 +$O L6 +$O Z1 +$O ^3 -0 +$O O24 +$O O45 o6e +$O O53 +$O { $P -$P$# -$P$D -$P$E -$P$I -$P$s -$P*36O06 -$P*43$H -$P-1$O -$PD0O17 -$PD1 -$PL9 -$PR1^a -$P^No72 -$P^^ -$Pi3zl -$PlO41 -$Po6. -$Pp1o2w -$Pq -$PO26 -$PO64 -$P{o31 +$P $# +$P $D +$P $E +$P $I +$P $s +$P *36 O06 +$P *43 $H +$P -1 $O +$P D0 O17 +$P D1 +$P L9 +$P R1 ^a +$P ^N o72 +$P ^^ +$P i3z l +$P l O41 +$P o6. +$P p1 o2w +$P q +$P O26 +$P O64 +$P { o31 $Q -$QD3 -$QD5O14 -$QL1*40 -$QR4 -$QZ1 -$QZ3 -$Qc -$Qo2yO3B -$QO04$1 -$QO31T0 +$Q D3 +$Q D5 O14 +$Q L1 *40 +$Q R4 +$Q Z1 +$Q Z3 +$Q c +$Q o2y O3B +$Q O04 $1 +$Q O31 T0 $R -$R$#*03 -$R$1c -$R*06 -$R@oc -$RL0 -$RT3$O -$RZ2] -$Rc -$Ri6& -$Ru -$RO23 -$RO41 -$RO92 -$Rz5 -$R}o11 +$R $# *03 +$R $1 c +$R *06 +$R @o c +$R L0 +$R T3 $O +$R Z2 ] +$R c +$R i6& +$R u +$R O23 +$R O41 +$R O92 +$R z5 +$R } o11 $S -$S$V -$S$y -$S*51O46 -$S-4*60 -$SD3 -$SKC -$SL5*34 -$SZ1 -$SZ1soA -$SZ2 -$S^]o0N -$S^p -$Si5' -$Sl -$Ssn8 -$SssPc -$SO12 -$SO74 -$S{ +$S $V +$S $y +$S *51 O46 +$S -4 *60 +$S D3 +$S K C +$S L5 *34 +$S Z1 +$S Z1 soA +$S Z2 +$S ^] o0N +$S ^p +$S i5' +$S l +$S sn8 +$S ssP c +$S O12 +$S O74 +$S { $T -$T'8Z2 -$T*62 -$T*87u -$T@2 -$TC$O -$TL6 -$TZ1 -$T[ -$T^vRA -$Tl -$To0Q -$To13 -$Tp1O18 -$TO03 -$TO31 -$TO32 -$TO52 -$Tz1 +$T '8 Z2 +$T *62 +$T *87 u +$T @2 +$T C $O +$T L6 +$T Z1 +$T [ +$T ^v RA +$T l +$T o0Q +$T o13 +$T p1 O18 +$T O03 +$T O31 +$T O32 +$T O52 +$T z1 $U -$U$R -$U*27O26 -$UD5 -$UR5T6 -$UT4 -$U[ -$Uc -$Ui41 -$Uu[ -$Uz1 +$U $R +$U *27 O26 +$U D5 +$U R5 T6 +$U T4 +$U [ +$U c +$U i41 +$U u [ +$U z1 $V -$V$6 -$V$8 -$V$C -$V$T -$VZ1 -$VZ1'8 -$Vc'9 -$Vi15o7H -$Vi6% -$Vl -$Vo5F^? -$Vr -$Vu +$V $6 +$V $8 +$V $C +$V $T +$V Z1 +$V Z1 '8 +$V c '9 +$V i15 o7H +$V i6% +$V l +$V o5F ^? +$V r +$V u $W -$W$8 -$W$I -$W$K -$W$S -$W*65 -$WD4 -$WL8 -$WZ1 -$W^wr -$Wc -$Wl -$Wo5- -$WrK -$WO35L2 -$Wz1 +$W $8 +$W $I +$W $K +$W $S +$W *65 +$W D4 +$W L8 +$W Z1 +$W ^w r +$W c +$W l +$W o5- +$W r K +$W O35 L2 +$W z1 $X -$X$2 -$X$Y -$X$x -$X*41$a -$X-7D0 -$XZ1 -$XZ2 -$XZ3s4/ -$X[ -$X^3 -$X^S -$X^v -$Xi0:o62 -$Xo1m -$Xt -$XO62 -$Xz1 +$X $2 +$X $Y +$X $x +$X *41 $a +$X -7 D0 +$X Z1 +$X Z2 +$X Z3 s4/ +$X [ +$X ^3 +$X ^S +$X ^v +$X i0: o62 +$X o1m +$X t +$X O62 +$X z1 $Y -$Y$2 -$Y$= -$Y*67 -$Y+3l -$YL6 -$YL7 -$YL8 -$YT1 -$Y[$N -$Y^V -$Yc -$Yfz3 -$Yu[ -$YO08 -$YO0A$u -$YO24C -$YO36 -$YO41 -$YO42 -$Yz2O64 +$Y $2 +$Y $= +$Y *67 +$Y +3 l +$Y L6 +$Y L7 +$Y L8 +$Y T1 +$Y [ $N +$Y ^V +$Y c +$Y f z3 +$Y u [ +$Y O08 +$Y O0A $u +$Y O24 C +$Y O36 +$Y O41 +$Y O42 +$Y z2 O64 $Z -$Z$3R6 -$Z$5 -$Z$9OA5 -$Z*76 -$Z*80 -$ZD2 -$ZD5 -$ZZ1 -$ZZ1T8 -$ZZ2 -$Z[ -$Z^0 -$Z^1*15 -$Z^V*26 -$Z^g$A -$Zc -$Zd -$Zi0Z -$Zo09 -$Zt -$ZO05L1 -$Zz4 +$Z $3 R6 +$Z $5 +$Z $9 OA5 +$Z *76 +$Z *80 +$Z D2 +$Z D5 +$Z Z1 +$Z Z1 T8 +$Z Z2 +$Z [ +$Z ^0 +$Z ^1 *15 +$Z ^V *26 +$Z ^g $A +$Z c +$Z d +$Z i0Z +$Z o09 +$Z t +$Z O05 L1 +$Z z4 $[ -$[*05$; -$[C -$[L4 -$[Z1 -$[Z2 -$[Z4 -$[[ -$[t +$[ *05 $; +$[ C +$[ L4 +$[ Z1 +$[ Z2 +$[ Z4 +$[ [ +$[ t $\ -$\@a -$\L2*20 -$\Z1 -$\l -$\o0J -$\t -$\u +$\ @a +$\ L2 *20 +$\ Z1 +$\ l +$\ o0J +$\ t +$\ u $] -$]+1 -$]-0 -$][ -$]^?o6= -$]i3[ -$]i6: -$]o4[ -$]o55 -$]O32 -$]z1 -$^$^ -$^+9+0 -$^@j -$^R8i07 -$^Z2 -$^Z2} -$^Z3 -$^i4 ^r -$^l -$^{*12 +$] +1 +$] -0 +$] [ +$] ^? o6= +$] i3[ +$] i6: +$] o4[ +$] o55 +$] O32 +$] z1 +$^ $^ +$^ +9 +0 +$^ @j +$^ R8 i07 +$^ Z2 +$^ Z2 } +$^ Z3 +$^ i4 ^r +$^ l +$^ { *12 $_ -$_$+ -$_$0 -$_$? -$_$_ -$_$i -$_$p -$_$r -$_$s -$_$t -$_$x -$_+0o6m -$_-0 -$_@0 -$_Z2 -$_Z3si? -$_[ -$_[[ -$_d -$_d] -$_i0mk -$_i1U -$_i6i -$_l -$_o96 -$_s_Y -$_smz -$_t -$_O13 -$_O25 -$_O41 -$_O53 -$_O75 -$_z3 -$_{ +$_ $+ +$_ $0 +$_ $? +$_ $_ +$_ $i +$_ $p +$_ $r +$_ $s +$_ $t +$_ $x +$_ +0 o6m +$_ -0 +$_ @0 +$_ Z2 +$_ Z3 si? +$_ [ +$_ [ [ +$_ d +$_ d ] +$_ i0m k +$_ i1U +$_ i6i +$_ l +$_ o96 +$_ s_Y +$_ smz +$_ t +$_ O13 +$_ O25 +$_ O41 +$_ O53 +$_ O75 +$_ z3 +$_ { $` -$`$1 -$`-1 -$`R5o5Z -$`Z1 -$`Z2 -$`c -$`l -$`o0h -$`o64z4 -$`u -$`O02 -$`O05 -$`{i2k +$` $1 +$` -1 +$` o5Z +$` Z1 +$` Z2 +$` c +$` l +$` o0h +$` o64 z4 +$` u +$` O02 +$` O05 +$` { i2k $a -$a$ -$a$3 -$a$6 -$a$b -$a$b$c -$a$b$c$d -$a$b$c$d$e -$a$bt -$a$f -$a$p -$a*01 -$a*16 -$a*26 -$a*28 -$a*38 -$a*73O03 -$a*81 -$a+0 -$a+0u -$a+2 -$a+3 -$a+7 -$a-5 -$aD4 -$aDA -$aR2 -$aT3 -$aT5 -$aZ1 -$aZ2 -$aZ4Z5 -$a^A -$a^D^1 -$a^kt -$af -$ai02 -$ai2q -$ai5r -$ai6p -$ao1ep1 -$ao3+ -$ao3dC -$ao6E -$ao7f -$aoB8 -$ap1 -$aq -$assj -$aswc -$au -$au$3 -$auO43 -$aO02 -$aO31 -$aO45 -$aO54 -$aO67 -$aO73 -$aO85 -$aO91 -$aOB1 -$aOB3 -$aOB4 -$az1*47 -$az2 -$az3 -$az4 +$a $ +$a $3 +$a $6 +$a $b +$a $b $c +$a $b $c $d +$a $b $c $d $e +$a $b t +$a $f +$a $p +$a *01 +$a *16 +$a *26 +$a *28 +$a *38 +$a *73 O03 +$a *81 +$a +0 +$a +0 u +$a +2 +$a +3 +$a +7 +$a -5 +$a D4 +$a DA +$a R2 +$a T3 +$a T5 +$a Z1 +$a Z2 +$a Z4 Z5 +$a ^A +$a ^D ^1 +$a ^k t +$a f +$a i02 +$a i2q +$a i5r +$a i6p +$a o1e p1 +$a o3+ +$a o3d C +$a o6E +$a o7f +$a oB8 +$a p1 +$a q +$a ssj +$a swc +$a u +$a u $3 +$a u O43 +$a O02 +D3 $a +$a O45 +$a O54 +$a O67 +$a O73 +$a O85 +D9 $a +$a OB1 +$a OB3 +$a OB4 +$a z1 *47 +$a z2 +$a z3 +$a z4 $b -$b$. -$b$1 -$b$4 -$b$a -$b$b -$b$d -$b$l -$b$t -$b$u -$b$wr -$b$y -$b*02 -$b*34 -$b*56 -$b*58 -$b*69 -$b*73 -$b+6 -$b-1 -$b@0 -$bL3o0k -$bL5 -$bL7O15 -$bT0 -$bZ3 -$bZ5 -$b[ -$b[R2 -$b^[s2H -$b^` -$b^a -$b^h -$b^p -$bf -$bi1r -$bi5p -$bo3b^A -$bo3t -$bp1 -$br -$brq -$bsaF -$bsbf -$bshb -$bt -$buo4# -$bO13 -$bO35 -$bO45 -$bO56 -$bO72 -$bOA3 -$bOA4 -$bz2 -$b{ -$b{i2G +$b $. +$b $1 +$b $4 +$b $a +$b $b +$b $d +$b $l +$b $t +$b $u +$b $w r +$b $y +$b *02 +$b *34 +$b *56 +$b *58 +$b *69 +$b *73 +$b +6 +$b -1 +$b @0 +$b L3 o0k +$b L5 +$b L7 O15 +$b T0 +$b Z3 +$b Z5 +$b [ +$b [ R2 +$b ^[ s2H +$b ^` +$b ^a +$b ^h +$b ^p +$b f +$b i1r +$b i5p +$b o3b ^A +$b o3t +$b p1 +$b r +$b r q +$b saF +$b sbf +$b shb +$b t +$b u o4# +$b O13 +$b O35 +$b O45 +$b O56 +$b O72 +$b OA3 +$b OA4 +$b z2 +$b { +$b { i2G $c -$c$b -$c$e -$c$t -$c$w -$c*67 -$c*72^: -$c+7 -$c+B -$cD2 -$cL6 -$cT0 -$cZ1 -$cZ2 -$c[ -$c[*56 -$c^?o3Q -$c^G$z -$c^Pk -$c^t -$cci4C -$cfc -$ci2c -$ci6h -$cl -$co1UT7 -$co4n -$co8i -$coARiBs -$csmw$4 -$ct -$cO06 -$cO24 -$cO29 -$cO36 -$cO73 -$cz1 -$cz2R0 -$cz5 +$c $b +$c $e +$c $t +$c $w +$c *67 +$c *72 ^: +$c +7 +$c +B +$c D2 +$c L6 +$c T0 +$c Z1 +$c Z2 +$c [ +$c [ *56 +$c ^? o3Q +$c ^G $z +$c ^P k +$c ^t +$c c i4C +$c f c +$c i2c +$c i6h +$c l +$c o1U T7 +$c o4n +$c o8i +$c oAR iBs +$c smw $4 +$c t +$c O06 +$c O24 +$c O29 +$c O36 +$c O73 +$c z1 +$c z2 R0 +$c z5 $d -$d$ -$d$. -$d$4 -$d$b -$d$k -$d$t -$d$w -$d*19 -$d*21 -$d*23 -$d*57 -$d*61 -$d*69 -$d+3 -$d+6 -$d-5 -$d@. -$d@p -$dD1 -$dD5 -$dD6 -$dR0 -$dR3Z2 -$dZ2 -$d^d -$d^l -$dc+0 -$dcZ1 -$dd -$di0^ -$di0t -$di4 -$di7a -$dl -$do0kZ5 -$do0p -$do11 -$do41 -$do6t -$dstm -$dO02 -$dO45p1 -$dO52 -$dO75 -$dO95 -$dO96 -$dOA6 -$dz1 -$dz4 -$d{^o +$d $ +$d $. +$d $4 +$d $b +$d $k +$d $t +$d $w +$d *19 +$d *21 +$d *23 +$d *57 +$d *61 +$d *69 +$d +3 +$d +6 +$d -5 +$d @. +$d @p +$d D1 +$d D5 +$d D6 +$d R0 +$d R3 Z2 +$d Z2 +$d ^d +$d ^l +$d c +0 +$d c Z1 +$d d +$d i0^ +$d i0t +$d i4 +$d i7a +$d l +$d o0k Z5 +$d o0p +$d o11 +$d o41 +$d o6t +$d stm +$d O02 +$d O45 p1 +$d O52 +$d O75 +$d O95 +$d O96 +$d OA6 +$d z1 +$d z4 +$d { ^o $e $e $d -$e$c -$e$l -$e$m -$e$n -$e$q -$e$qk -$e$r -$e$w -$e*53 -$e*67 -$e*73 -$e+0 -$e+B -$e-2*34 -$eD8 -$eL8 -$eR3 -$eT2 -$eZ1 -$eZ2 -$eZ2o7- -$eZ3 -$eZ4 -$e[ -$e[u -$e^*i2> -$e^3$7 -$e^E -$e^H -$e^d -$e^g -$e^}k -$ei0p*52 -$ei9_ -$el -$eo0F -$eo0d -$eo0p -$eo4I -$eo4l -$eo5% -$eo8v -$eo9k -$eo9l -$ep1 -$er -$esm6 -$esmp -$eO02sz$ -$eO25 -$eO28i3c -$eO53 -$eO71 -$eO93 +$e $c +$e $l +$e $m +$e $n +$e $q +$e $q k +$e $r +$e $w +$e *53 +$e *67 +$e *73 +$e +0 +$e +B +$e -2 *34 +$e D8 +$e L8 +$e R3 +$e T2 +$e Z1 +$e Z2 +$e Z2 o7- +$e Z3 +$e Z4 +$e [ +$e [ u +$e ^* i2> +$e ^3 $7 +$e ^E +$e ^H +$e ^d +$e ^g +$e ^} k +$e i0p *52 +$e i9_ +$e l +$e o0F +$e o0d +$e o0p +$e o4I +$e o4l +$e o5% +$e o8v +$e o9k +$e o9l +$e p1 +$e r +$e sm6 +$e smp +$e O02 sz$ +$e O25 +$e O28 i3c +$e O53 +$e O71 +$e O93 z2 -$ez4 +$e z4 $f -$f$1 -$f$j -$f$u -$f*25 -$f*32 -$f*34 -$f*79 -$f*96 -$f+1 -$f-3 -$f-5 -$f@t -$fK$2 -$fL6 -$fZ1 -$fZ1O57 -$fZ2 -$f^= -$f^f -$f^q'B -$f^v -$fc -$fi4u -$fi8r -$fl -$fo1e -$fo8/O01 -$fq -$fs39 -$fO05 -$fO28D3 -$fO52 -$fO62 -$fO82 -$fO91 -$fOB1 +$f $1 +$f $j +$f $u +$f *25 +$f *32 +$f *34 +$f *79 +$f *96 +$f +1 +$f -3 +$f -5 +$f @t +$f K $2 +$f L6 +$f Z1 +$f Z1 O57 +$f Z2 +$f ^= +$f ^f +$f ^q 'B +$f ^v +$f c +$f i4u +$f i8r +$f l +$f o1e +$f o8/ O01 +$f q +$f s39 +$f O05 +$f O28 D3 +$f O52 +$f O62 +$f O82 +$f O91 +$f OB1 $g -$g$N -$g$n -$g$o -$g$s -$g*36 -$g*54 -$g+4 -$g+6 -$g-0 -$gK+6 -$gZ1 -$gZ2 -$gZ3o5o -$gZ4 -$g^3 -$g^Ko0_ -$g^S -$g^U -$g^sz2 -$g^t -$g^vO31 -$gd -$gfo4# -$gi0r -$gi2p*91 -$gi2u -$gi3@i0$ -$gi5 @6 -$gi5; -$gi7VR9 -$gl -$go06 -$go0ht -$go2) -$gr -$gsaI -$gsr( -$gsutO47 -$gt -$gu -$gO34 -$gO36 -$gO37 -$gO43 -$gO52 -$gO73 -$gO83O52 -$gz2 -$gz3 +$g $N +$g $n +$g $o +$g $s +$g *36 +$g *54 +$g +4 +$g +6 +$g -0 +$g K +6 +$g Z1 +$g Z2 +$g Z3 o5o +$g Z4 +$g ^3 +$g ^K o0_ +$g ^S +$g ^U +$g ^s z2 +$g ^t +$g ^v O31 +$g d +$g f o4# +$g i0r +$g i2p *91 +$g i2u +$g i3@ i0$ +$g i5 @6 +$g i5; +$g i7V R9 +$g l +$g o06 +$g o0h t +$g o2) +$g r +$g saI +$g sr( +$g sut O47 +$g t +$g u +$g O34 +$g O36 +$g O37 +$g O43 +$g O52 +$g O73 +$g O83 O52 +$g z2 +$g z3 $h -$h$ -$h$5 -$h$g -$h$k -$h$x -$h$z -$h*02 -$h*37 -$h*50*25 -$h*54 -$h*71 -$h-3 -$h-5t -$hD3 -$hL8 -$hZ1i1g -$hZ2 -$hZ2L5 -$hZ3 -$h[ -$h[O13 -$h^T -$h^aslI -$hc -$hd -$hi2t -$hi4X -$hi6t*67 -$hi8% -$hi92O49 -$hl -$hlT1 -$ho1h -$hr -$hr$y -$hsd1 -$hO12 -$hO41 -$hO53 -$h}K +$h $ +$h $5 +$h $g +$h $k +$h $x +$h $z +$h *02 +$h *37 +$h *50 *25 +$h *54 +$h *71 +$h -3 +$h -5 t +$h D3 +$h L8 +$h Z1 i1g +$h Z2 +$h Z2 L5 +$h Z3 +$h [ +$h [ O13 +$h ^T +$h ^a slI +$h c +$h d +$h i2t +$h i4X +$h i6t *67 +$h i8% +$h i92 O49 +$h l +$h l T1 +$h o1h +$h r +$h r $y +$h sd1 +$h O12 +$h O41 +$h O53 +$h } K $i $i $n $g -$i$*z1 -$i$F$F -$i$d -$i$n -$i*10O41 -$i*41 -$i*60D2 -$i*62 -$i*79 -$i*86 -$i*89 -$i*A4 -$i+3 -$i+6 -$i+6l -$i+9 -$i-0 -$i-7 -$i-9 -$i@a -$iD2 -$iR0 -$iZ1 -$iZ2O15 -$i^d -$i^ki75 -$i^p -$id -$ii3 -$ii8d -$io2% -$io2S -$io5V -$iq -$ir -$it -$iu -$iO09 -$iO12 -$iO13 -$iO36 -$iO54 -$iO62 -$iO73 -$iO92 -$iz2*17 -$i{ +$i $* z1 +$i $F $F +$i $d +$i $n +$i *10 O41 +$i *41 +$i *60 D2 +$i *62 +$i *79 +$i *86 +$i *89 +$i *A4 +$i +3 +$i +6 +$i +6 l +$i +9 +$i -0 +$i -7 +$i -9 +$i @a +$i D2 +$i R0 +$i Z1 +$i Z2 O15 +$i ^d +$i ^k i75 +$i ^p +$i d +$i i3 +$i i8d +$i o2% +$i o2S +$i o5V +$i q +$i r +$i t +$i u +$i O09 +$i O12 +$i O13 +$i O36 +$i O54 +$i O62 +$i O73 +$i O92 +$i z2 *17 +$i { $j -$j$3 -$j$F -$j$o -$j*02 -$j*07 -$j*68 -$j-4^? -$j-7 -$jZ1 -$jZ2 -$j[ -$j^2 -$j^k -$j^s -$jc -$ji49$u -$ji5n^0 -$jo17 -$joAn -$jp1 -$jr -$jsik -$jt -$ju -$jO12 -$jO62 -$jz2 -$jz3 -$j{ +$j $3 +$j $F +$j $o +$j *02 +$j *07 +$j *68 +$j -4 ^? +$j -7 +$j Z1 +$j Z2 +$j [ +$j ^2 +$j ^k +$j ^s +$j c +$j i49 $u +$j i5n ^0 +$j o17 +$j oAn +$j p1 +$j r +$j sik +$j t +$j u +$j O12 +$j O62 +$j z2 +$j z3 +$j { $k -$k$4 -$k$d -$k$e -$k$k -$k$y -$k*54 -$k*57 -$k*67 -$k+0 -$k+8 -$k@5 -$k@6 -$kC -$kD3u -$kD5O26 -$kR4 -$kR7 -$k[ -$k^3 -$k^D +$k $4 +$k $d +$k $e +$k $k +$k $y +$k *54 +$k *57 +$k *67 +$k +0 +$k +8 +$k @5 +$k @6 +$k C +$k D3 u +$k D5 O26 +$k R4 +$k R7 +$k [ +$k ^3 +$k ^D ^_ -$k^m -$ki5f -$ki8o -$ko78 -$ko7n -$kp1 -$kp1O26 -$ks17 -$kt -$kO13 -$kO53 -$kO73 -$kO92 -$k{ +$k ^m +$k i5f +$k i8o +$k o78 +$k o7n +$k p1 +$k p1 O26 +$k s17 +$k t +$k O13 +$k O53 +$k O73 +$k O92 +$k { $l -$l$g -$l$v -$l$y -$l$z -$l*23 -$l*43 -$l*53*32 -$l*57 -$l+1 -$l-0 -$l-4Z2 -$l-5 -$l-6 -$lC*21 -$lD4 -$lZ1 -$lZ2 -$lZ4 -$l[ -$l^O -$l^a -$l^b -$ld -$li78R9 -$li83 -$lk -$lo5p^k -$lq -$lu -$lu$C -$lO4B -$lO62 -$lO92 -$lz3 -$lz5 -$l{ +$l $g +$l $v +$l $y +$l $z +$l *23 +$l *43 +$l *53 *32 +$l *57 +$l +1 +$l -0 +$l -4 Z2 +$l -5 +$l -6 +$l C *21 +$l D4 +$l Z1 +$l Z2 +$l Z4 +$l [ +$l ^O +$l ^a +$l ^b +$l d +$l i78 R9 +$l i83 +$l k +$l o5p ^k +$l q +$l u +$l u $C +$l O4B +$l O62 +$l O92 +$l z3 +$l z5 +$l { $m -$m$0 -$m$1c -$m$E -$m$b -$m$e -$m$oZ2 -$m$p -$m$qR7 -$m$w -$m$x -$m'BO05 -$m*28 -$m*43 -$m*71z1 -$m*86 -$m+4 -$m+5 -$m+6 -$m-0 -$m-1 -$m-2 -$m-6 -$mCi4E -$mT0 -$mZ1 -$mZ2 -$mZ5 -$m^+ -$m^1 -$m^6 -$m^? -$m^i -$md -$mf -$mi1P*83 -$mi1\ -$mi2i -$mi7g -$mk -$ml^k -$mo0g -$mo2r -$mo37 -$mo5F -$mo8ul -$ms17 -$ms24 -$mt -$mu^C -$mO04 -$mO05 -$mO16 -$mO18 -$mO32 -$mO34 -$mO43 -$mO57 -$mO72 -$mOA4 -$mz1 -$mz4z3 -$m{k -$m{t +$m $0 +$m $1 c +$m $E +$m $b +$m $e +$m $o Z2 +$m $p +$m $q R7 +$m $w +$m $x +$m 'B O05 +$m *28 +$m *43 +$m *71 z1 +$m *86 +$m +4 +$m +5 +$m +6 +$m -0 +$m -1 +$m -2 +$m -6 +$m C i4E +$m T0 +$m Z1 +$m Z2 +$m Z5 +$m ^+ +$m ^1 +$m ^6 +$m ^? +$m ^i +$m d +$m f +$m i1P *83 +$m i1\ +$m i2i +$m i7g +$m k +$m l ^k +$m o0g +$m o2r +$m o37 +$m o5F +$m o8u l +$m s17 +$m s24 +$m t +$m u ^C +$m O04 +$m O05 +$m O16 +$m O18 +$m O32 +$m O34 +$m O43 +$m O57 +$m O72 +$m OA4 +$m z1 +$m z4 z3 +$m { k +$m { t $n -$n$a -$n$b -$n$qO47 -$n*07 -$n*15*12 -$n*24 -$n*24Z4 -$n*27 -$n*83z4 -$n*93'4 -$n+0 -$n+7 -$n-7 -$n@0 -$nC -$nD2 -$nL1 -$nT5 -$nZ2 -$nZ3 -$nZ5O7B -$n[$z -$n[L2 -$n^C -$n^I*36 -$n^f*23 -$ni0R -$ni3+ -$ni3p -$ni5e -$nk -$nl -$no00O46 -$no2- -$no4_ -$no7l -$no9e -$nq -$nO14^3 -$nO51 -$nO65 -$nO71 -$nO82 -$nO93 +$n $a +$n $b +$n $q O47 +$n *07 +$n *15 *12 +$n *24 +$n *24 Z4 +$n *27 +$n *83 z4 +$n *93 '4 +$n +0 +$n +7 +$n -7 +$n @0 +$n C +$n D2 +$n L1 +$n T5 +$n Z2 +$n Z3 +$n Z5 O7B +$n [ $z +$n [ L2 +$n ^C +$n ^I *36 +$n ^f *23 +$n i0R +$n i3+ +$n i3p +$n i5e +$n k +$n l +$n o00 O46 +$n o2- +$n o4_ +$n o7l +$n o9e +$n q +$n O14 ^3 +$n O51 +$n O65 +$n O71 +$n O82 +$n O93 $o -$o$O -$o$h -$o$ni4Y -$o$s -$o$x -$o*03 -$o*46O43 -$o*82 -$o+4 -$o+8 -$o@1 -$oT0 -$oT7 -$oZ1 -$oZ2 -$o^C -$o^si0c -$oc -$od -$oi1 -$oi6O -$ok -$oo0v -$oo6g -$oo6w -$or -$osbf -$ou -$oO04'5 -$oO05 -$oO12 -$oO13 -$oO15 -$oO29 -$oO42sk$ -$oO65 -$oO71 -$oO87 -$oz3 -$oz4 +$o $O +$o $h +$o $n i4Y +$o $s +$o $x +$o *03 +$o *46 O43 +$o *82 +$o +4 +$o +8 +$o @1 +$o T0 +$o T7 +$o Z1 +$o Z2 +$o ^C +$o ^s i0c +$o c +$o d +$o i1 +$o i6O +$o k +$o o0v +$o o6g +$o o6w +$o r +$o sbf +$o u +$o O04 '5 +$o O05 +$o O12 +$o O13 +$o O15 +$o O29 +$o O42 sk$ +$o O65 +$o O71 +$o O87 +$o z3 +$o z4 $p -$p$0 -$p$k -$p$l -$p*04 -$p*05 -$p*27 -$p*34i9d -$p*42 -$p*61 -$p*64 -$p*73 -$p*86 -$p+0 -$p-4 -$pD2 -$pD3 -$pL6 -$pR1 -$pZ1 -$pZ2 -$pZ5 -$p^9 -$p^V -$pi4t -$pi7q -$pl -$po0b -$po29 -$pr -$psph -$pu-5 -$pO4A@p -$pO51[ -$pO75 -$pO87 -$pO92 -$pz5 -$p{sdo +$p $0 +$p $k +$p $l +$p *04 +$p *05 +$p *27 +$p *34 i9d +$p *42 +$p *61 +$p *64 +$p *73 +$p *86 +$p +0 +$p -4 +$p D2 +$p D3 +$p L6 +$p R1 +$p Z1 +$p Z2 +$p Z5 +$p ^9 +$p ^V +$p i4t +$p i7q +$p l +$p o0b +$p o29 +$p r +$p sph +$p u -5 +$p O4A @p +$p O51 [ +$p O75 +$p O87 +$p O92 +$p z5 +$p { sdo $q -$q$Q -$q$a -$q$w -$q*02 -$q*34 -$q+0O02 -$q+5f -$q-0 -$q-7 -$qD2 -$qKr -$qL6 -$qL7 -$qLA -$qT0@T -$qZ1 -$qZ2 -$qZ2o2+ -$qZ2u -$qZ3 -$qZ4 -$qZ5 -$q^pT6 -$qcO21 -$qd -$qi1= -$qi3JZ1 -$qk -$qkl -$qsq# -$qt -$qO15 -$qO31 -$qO43 -$qz1^n -$qz2 -$qz2^# +$q $Q +$q $a +$q $w +$q *02 +$q *34 +$q +0 O02 +$q +5 f +$q -0 +$q -7 +$q D2 +$q K r +$q L6 +$q L7 +$q LA +$q T0 @T +$q Z1 +$q Z2 +$q Z2 o2+ +$q Z2 u +$q Z3 +$q Z4 +$q Z5 +$q ^p T6 +$q c O21 +$q d +$q i1= +$q i3J Z1 +$q k +$q k l +$q sq# +$q t +$q O15 +$q O31 +$q O43 +$q z1 ^n +$q z2 +$q z2 ^# $r -$r$! -$r$0 -$r$8 -$r$a -$r$n -$r$p -$r'9 -$r*21 -$r*24 -$r*74o2V -$r*78 -$r*98 -$r*A9 -$r+0 -$r+6 -$r-1 -$r-4z2 -$r-8 -$r-A -$rL5 -$rL8 -$rR1 -$rZ1 -$rZ1T6 -$r^J -$r^p -$r^q -$ri2fZ5 -$ri4E -$ri6Do6v -$ri6n -$ri7t -$ri8jshR -$rl -$ro10 -$ro6 -$ro7- -$roAg -$rsnR -$rO31 -$rO46d -$rOB4 -$rz1 -$rz1l +$r $! +$r $0 +$r $8 +$r $a +$r $n +$r $p +$r '9 +$r *21 +$r *24 +$r *74 o2V +$r *78 +$r *98 +$r *A9 +$r +0 +$r +6 +$r -1 +$r -4 z2 +$r -8 +$r -A +$r L5 +$r L8 +$r R1 +$r Z1 +$r Z1 T6 +$r ^J +$r ^p +$r ^q +$r i2f Z5 +$r i4E +$r i6D o6v +$r i6n +$r i7t +$r i8j shR +$r l +$r o10 +$r o6 +$r o7- +$r oAg +$r snR +$r O31 +$r O46 d +$r OB4 +$r z1 +$r z1 l $s -$s$ -$s$1 -$s$4 -$s$j -$s$m -$s$u -$s*01 -$s*17 -$s*20z3 -$s*21 -$s*31 -$s*56 -$s*68 -$s*75t -$s+3 -$s+4 -$s-1 -$s-2 -$s-5 -$s-6 -$s-7 -$s-8 -$s@y -$sC -$sD7 -$sL7s1_ -$sR7^T -$sT4 -$sZ1 -$sZ2 -$sZ3 -$s[O32 +$s $ +$s $1 +$s $4 +$s $j +$s $m +$s $u +$s *01 +$s *17 +$s *20 z3 +$s *21 +$s *31 +$s *56 +$s *68 +$s *75 t +$s +3 +$s +4 +$s -1 +$s -2 +$s -5 +$s -6 +$s -7 +$s -8 +$s @y +$s C +$s D7 +$s L7 s1_ +$s R7 ^T +$s T4 +$s Z1 +$s Z2 +$s Z3 +$s [ O32 z5 -$s^1 -$s^b -$s^fr -$s^k -$sc -$si0h -$si3t -$si52 -$si6V -$siAi -$so13 -$so1bl -$so2b -$so5J -$so7m -$so9*'A -$sr -$ssr4$7 -$st -$su -$sO34 -$sO43 -$sO53 -$sO64 -$sO82 -$sO83 -$sO87 -$sO94 -$sz1 -$sz1u -$sz4z5 +$s ^1 +$s ^b +$s ^f r +$s ^k +$s c +$s i0h +$s i3t +$s i52 +$s i6V +$s iAi +$s o13 +$s o1b l +$s o2b +$s o5J +$s o7m +$s o9* 'A +$s r +$s sr4 $7 +$s t +$s u +$s O34 +$s O43 +$s O53 +$s O64 +$s O82 +$s O83 +$s O87 +$s O94 +$s z1 +$s z1 u +$s z4 z5 $t -$t$# -$t$7 -$t$b -$t$c -$t$g -$t$h -$t*03 -$t*13 -$t*25 -$t*57 -$t*86 -$t*91 -$t+7 -$t+9 -$tZ1 -$tZ2 -$t^3 -$t^n -$t^p -$tc -$tco6y -$ti2$o4f -$ti4C -$ti4f -$ti7a -$tk -$to1J -$to6k -$to6w -$tsbL -$tu -$tuO01 -$tO02 -$tO04 -$tO08 -$tO09c -$tO42 -$tO51 -$tO85 -$tz1 -$tz4 +$t $# +$t $7 +$t $b +$t $c +$t $g +$t $h +$t *03 +$t *13 +$t *25 +$t *57 +$t *86 +$t *91 +$t +7 +$t +9 +$t Z1 +$t Z2 +$t ^3 +$t ^n +$t ^p +$t c +$t c o6y +$t i2$ o4f +$t i4C +$t i4f +$t i7a +$t k +$t o1J +$t o6k +$t o6w +$t sbL +$t u +$t u O01 +$t O02 +$t O04 +$t O08 +$t O09 c +$t O42 +$t O51 +$t O85 +$t z1 +$t z4 $u -$u$$ -$u$8 -$u$r -$u$w -$u*30 -$u*43i4D -$u-1 -$u-6 -$u@k -$uD9 -$uL6 -$uZ1 -$uZ2 -$u[ -$u^1i36 -$u^8 -$u^? -$u^Xz2 -$u^g -$u^i -$u^l*25 -$ud -$udO58 -$ui0y -$ui5- -$ui7'O69 -$ukK -$uo1r -$uo3w -$uo4o -$uo7u -$uq -$ur -$us5,O67 -$usma -$ut -$utr -$uO12 -$uO34 -$uO39 -$uO41$= -$uO43 -$uO52 -$uO62 -$uO65 -$uO72 -$uO9B -$uz1 -$uz5-3 +$u $$ +$u $8 +$u $r +$u $w +$u *30 +$u *43 i4D +$u -1 +$u -6 +$u @k +$u D9 +$u L6 +$u Z1 +$u Z2 +$u [ +$u ^1 i36 +$u ^8 +$u ^? +$u ^X z2 +$u ^g +$u ^i +$u ^l *25 +$u d +$u d O58 +$u i0y +$u i5- +$u i7' O69 +$u k K +$u o1r +$u o3w +$u o4o +$u o7u +$u q +$u r +$u s5, O67 +$u sma +$u t +$u t r +$u O12 +$u O34 +$u O39 +$u O41 $= +$u O43 +$u O52 +$u O62 +$u O65 +$u O72 +$u O9B +$u z1 +$u z5 -3 $v -$v$&^I -$v$+ -$v$3u -$v$6 -$v$P -$v$i -$v$l -$v*16 -$v*43 -$v*62k -$v*81O58 -$v+0 -$v-5 -$v-6o8> -$v-7O69 -$vD3 -$vD5 -$vD7 -$vD7O21 -$vL5 -$vL6 -$vZ1 -$vZ2 -$vZ3 -$v^* -$v^> -$v^w^G -$vdO5B -$vo3s -$vp1 -$vri0r -$vstk -$vO13 -$vO24 -$vO38 -$vO83 -$vz1o6G +$v $& ^I +$v $+ +$v $3 u +$v $6 +$v $P +$v $i +$v $l +$v *16 +$v *43 +$v *62 k +$v *81 O58 +$v +0 +$v -5 +$v -6 o8> +$v -7 O69 +$v D3 +$v D5 +$v D7 +$v D7 O21 +$v L5 +$v L6 +$v Z1 +$v Z2 +$v Z3 +$v ^* +$v ^> +$v ^w ^G +$v d O5B +$v o3s +$v p1 +$v r i0r +$v stk +$v O13 +$v O24 +$v O38 +$v O83 +$v z1 o6G $w -$w$e -$w$q -$w*21 -$w*31 -$w*43 -$w*45 -$w*86 -$w+4 -$w@! -$w@g -$wC -$wD8 -$wZ1 -$wZ4 -$w[ -$wcz2 -$wi0q -$wi1I -$wi2d -$wi6q -$wi7_ -$wi9q -$wo4m -$wo6a -$wo7m -$wp1 -$wq -$wr-4 -$wsF[O36 -$wu -$wO18 -$wO37 -$wO67-4 -$wz2 -$wz3 -$w{[ +$w $e +$w $q +$w *21 +$w *31 +$w *43 +$w *45 +$w *86 +$w +4 +$w @! +$w @g +$w C +$w D8 +$w Z1 +$w Z4 +$w [ +$w c z2 +$w i0q +$w i1I +$w i2d +$w i6q +$w i7_ +$w i9q +$w o4m +$w o6a +$w o7m +$w p1 +$w q +$w r -4 +$w sF[ O36 +$w u +$w O18 +$w O37 +$w O67 -4 +$w z2 +$w z3 +$w { [ $x -$x$? -$x$g -$x$g*41 -$x$hO69 -$x$i -$x$p -$x$s -$x$t -$x$x$x -$x'AC -$x*20r -$x*31 -$x*45 -$x*62^) -$x*65 -$x*71 -$x*78 -$x+5 -$x+A*A0 -$x-6 -$x@c -$xD2 -$xD5 -$xD5t -$xD6 -$xR4-2 -$xR6 -$xZ1 -$xZ3 -$xZ4 -$xZ5 -$x^! -$x^S -$x^b -$x^j -$x^o -$x^v -$xf -$xi1)o5n -$xi1H -$xi6d -$xk -$xl -$xo1m -$xp1 -$xp1o2i -$xq -$xsw0 -$xt -$xO21@v -$xO25 -$xO32 -$xO37 -$xO45 -$xO64 -$xO71 -$xO76 -$xO92 -$xO93 -$xz4 -$x{ +$x $? +$x $g +$x $g *41 +$x $h O69 +$x $i +$x $p +$x $s +$x $t +$x $x $x +$x 'A C +$x *20 r +$x *31 +$x *45 +$x *62 ^) +$x *65 +$x *71 +$x *78 +$x +5 +$x +A *A0 +$x -6 +$x @c +$x D2 +$x D5 +$x D5 t +$x D6 +$x R4 -2 +$x R6 +$x Z1 +$x Z3 +$x Z4 +$x Z5 +$x ^! +$x ^S +$x ^b +$x ^j +$x ^o +$x ^v +$x f +$x i1) o5n +$x i1H +$x i6d +$x k +$x l +$x o1m +$x p1 +$x p1 o2i +$x q +$x sw0 +$x t +$x O21 @v +$x O25 +$x O32 +$x O37 +$x O45 +$x O64 +$x O71 +$x O76 +$x O92 +$x O93 +$x z4 +$x { $y -$y$a -$y$s -$y*16*13 -$y*81 -$y+0 -$y+3 -$y+6 -$y+6T6 -$y+7 -$y@n -$y@nO07 -$y@q -$yD1 -$yD5d -$yD8 -$yL8 -$yZ1 -$yZ2 -$yZ4 -$y^i -$yf -$yi19'5 -$yi20 -$yi3R -$yi6m -$yk -$yo4f -$yo5x -$yp1 -$yq -$yt -$yO04 -$yO07 -$yO23 -$yO27i1p -$yO53 -$yz2 +$y $a +$y $s +$y *16 *13 +$y *81 +$y +0 +$y +3 +$y +6 +$y +6 T6 +$y +7 +$y @n +$y @n O07 +$y @q +$y D1 +$y D5 d +$y D8 +$y L8 +$y Z1 +$y Z2 +$y Z4 +$y ^i +$y f +$y i19 '5 +$y i20 +$y i3R +$y i6m +$y k +$y o4f +$y o5x +$y p1 +$y q +$y t +$y O04 +$y O07 +$y O23 +$y O27 i1p +$y O53 +$y z2 $z -$z$2 -$z$dZ1 -$z$o -$z$x -$z*23 -$z*37 -$z*43 -$z*72 -$z+4z3 -$z+5 -$z-2 -$z-4 -$z@s -$zC -$zD4 -$zR0D5 -$zR5 -$zT0 -$zZ1 -$zZ2 -$zZ3 -$zZ3'6 -$zZ3Z4 -$z^- -$z^l -$z^v -$z^x -$zd -$zf -$zi1l -$zl -$zo00T0 -$zo3 -$zp1T4 -$zq -$zsAS -$zsc^ -$zsry -$zssc -$zu -$zuD2 -$zO06 -$zO24 -$zO43 -$zO63 -$zO83 -$zO95 -$zOA2 -$zOB2 -$zz1 -$zz1O36 -$zz2^o -$zz5 -$z{ +$z $2 +$z $d Z1 +$z $o +$z $x +$z *23 +$z *37 +$z *43 +$z *72 +$z +4 z3 +$z +5 +$z -2 +$z -4 +$z @s +$z C +$z D4 +$z R0 D5 +$z R5 +$z T0 +$z Z1 +$z Z2 +$z Z3 +$z Z3 '6 +$z Z3 Z4 +$z ^- +$z ^l +$z ^v +$z ^x +$z d +$z f +$z i1l +$z l +$z o00 +$z o3 +$z p1 T4 +$z q +$z sAS +$z sc^ +$z sry +$z ssc +$z u +$z u D2 +$z O06 +$z O24 +$z O43 +$z O63 +$z O83 +$z O95 +$z OA2 +$z OB2 +$z z1 +$z z1 O36 +$z z2 ^o +$z z5 +$z { ${ -${K -${L4 -${L5 -${L8 -${o70sr@ +${ K +${ L4 +${ L5 +${ L8 +${ o70 sr@ $| -$|$* -$|L0 -$|u +$| $* +$| L0 +$| u $} -$}$o -$}+0 -$}+5 -$}+A -$}c -$}kO01 -$}l -$}lr -$}t -$}z2r -'1+0z4 -'1Z4 -'1Z5 -'1p3 -'1z4Z4 -'2+0p4 -'2L1 -'2Z4 -'2Z4z2 -'2Z5$o -'2[p3 -'2i0Dp2 -'2k -'2o0< -'2o0> -'2p2 -'2p3 -'2z2 -'2z3 -'2z3+2 -'2z4 -'2z5 +$} $o +$} +0 +$} +5 +$} +A +$} c +$} k O01 +$} l +$} l r +$} t +$} z2 r +'1 +0 z4 +'1 Z4 +'1 Z5 +'1 p3 +'1 z4 Z4 +'2 +0 p4 +'2 L1 +'2 Z4 +'2 Z4 z2 +'2 Z5 $o +'2 [ p3 +'2 i0D p2 +'2 k +'2 o0< +'2 o0> +'2 p2 +'2 p3 +'2 z2 +'2 z3 +'2 z3 +2 +'2 z4 +'2 z5 '3 -'3$L -'3$S -'3$g -'3+2 -'3Z2 -'3Z3 -'3Z5 -'3[ -'3[$f -'3^0^3 -'3^a -'3^p -'3d -'3p2 -'3q -'3qd -'3sjX -'3t -'3tq -'3us1= -'3z1 -'3z3 -'3z4 -'3z5 -'3z5z4 -'3z5} +'3 $L +'3 $S +'3 $g +'3 +2 +'3 Z2 +'3 Z3 +'3 Z5 +'3 [ +'3 [ $f +'3 ^0 ^3 +'3 ^a +'3 ^p +'3 d +'3 p2 +'3 q +'3 q d +'3 sjX +'3 t +'3 t q +'3 u s1= +'3 z1 +'3 z3 +'3 z4 +'3 z5 +'3 z5 z4 +'3 z5 } '4 -'4$ -'4$0 -'4$m -'4$o -'4+0 -'4+1 -'4+2^! -'4@q^J -'4T2$q -'4Z1 -'4Z2 -'4Z3 -'4Z5 -'4Z5Z3 -'4[ -'4^8 -'4^L -'4^P -'4^S -'4^d -'4^l -'4c -'4d[ -'4dt -'4f -'4i11*02 -'4i1f -'4i2: -'4i3t -'4o0$ -'4o04 -'4o1m -'4o3' -'4o3S -'4p1 -'4p2+9 -'4q^? -'4r -'4s1* -'4s2R -'4s5? -'4uR3 -'4z1q -'4z2 -'4z4 -'4z5 +'4 $ +'4 $0 +'4 $m +'4 $o +'4 +0 +'4 +1 +'4 +2 ^! +'4 @q ^J +'4 T2 $q +'4 Z1 +'4 Z2 +'4 Z3 +'4 Z5 +'4 Z5 Z3 +'4 [ +'4 ^8 +'4 ^L +'4 ^P +'4 ^S +'4 ^d +'4 ^l +'4 c +'4 d [ +'4 d t +'4 f +'4 i11 *02 +'4 i1f +'4 i2: +'4 i3t +'4 o0$ +'4 o04 +'4 o1m +'4 o3' +'4 o3S +'4 p1 +'4 p2 +9 +'4 q ^? +'4 r +'4 s1* +'4 s2R +'4 s5? +'4 u R3 +'4 z1 q +'4 z2 +'4 z4 +'4 z5 '5 -'5$& -'5$1 -'5$1@0 -'5$2 -'5$3 -'5$3L5 -'5$7 -'5$: -'5$I -'5$\*10 -'5$e-5 -'5$i -'5$kz1 -'5$r -'5$x -'5*13 -'5*14*20 -'5+3 -'5+4 -'5-1 -'5C -'5L3Z1 -'5L4O21 -'5Z1 -'5Z2@d -'5Z3 -'5Z4 -'5Z5 -'5Z5T9 -'5Z5O31 -'5[ -'5^9 -'5^F -'5^b -'5^i -'5^z -'5c$R -'5c@r -'5d -'5d^B -'5f -'5i1l -'5i2. -'5i2l -'5i3e -'5i3r -'5l -'5o0b -'5o0d -'5o0i -'5o0m -'5o1g -'5o25 -'5o2Wo21 -'5o2k -'5o2z -'5o3k -'5o4& -'5o4d -'5q -'5s1N -'5s1i -'5sL7 -'5sgm -'5shH -'5t -'5O01Z2 -'5O02 -'5z1 -'5z2 -'5z4 -'5z5 +'5 $& +'5 $1 +'5 $1 @0 +'5 $2 +'5 $3 +'5 $3 L5 +'5 $7 +'5 $: +'5 $I +'5 $\ *10 +'5 $e -5 +'5 $i +'5 $k z1 +'5 $r +'5 $x +'5 *13 +'5 *14 *20 +'5 +3 +'5 +4 +'5 -1 +'5 C +'5 L3 Z1 +'5 L4 O21 +'5 Z1 +'5 Z2 @d +'5 Z3 +'5 Z4 +'5 Z5 +'5 Z5 T9 +'5 Z5 O31 +'5 [ +'5 ^9 +'5 ^F +'5 ^b +'5 ^i +'5 ^z +'5 c $R +'5 c @r +'5 d +'5 d ^B +'5 f +'5 i1l +'5 i2. +'5 i2l +'5 i3e +'5 i3r +'5 l +'5 o0b +'5 o0d +'5 o0i +'5 o0m +'5 o1g +'5 o25 +'5 o21 +'5 o2k +'5 o2z +'5 o3k +'5 o4& +'5 o4d +'5 q +'5 s1N +'5 s1i +'5 sL7 +'5 sgm +'5 shH +'5 t +'5 O01 Z2 +'5 O02 +'5 z1 +'5 z2 +'5 z4 +'5 z5 '6 -'6$ -'6$, -'6$0 -'6$2 -'6$7 -'6$9 -'6$Q -'6$i -'6$k -'6$k^w -'6$kz3 -'6$l -'6$p -'6$r -'6*03 -'6*21u -'6*51 -'6*54 -'6+1 -'6+3 -'6+4c -'6-1 -'6@3 -'6@4 -'6@Z -'6D1 -'6D1o0K -'6D2 -'6L0 -'6L1s61 -'6L2 -'6R2sob -'6R5 -'6T0o5* -'6T1 -'6Z1 -'6Z1$} -'6Z2 -'6Z3 -'6Z4*64 -'6Z5 -'6[ -'6^2 -'6^G -'6^L -'6^O -'6^a -'6^h -'6^j -'6^lD1 -'6^p -'6^w -'6^yz3 -'6c -'6cZ1 -'6d -'6dz1 -'6fO45 -'6i1* -'6i23^, -'6i3- -'6i3m -'6i3r -'6i4g -'6i4p -'6i5% -'6i5r -'6l -'6o0*} -'6o1l -'6o3P -'6o3e -'6o3t -'6o4O -'6o5% -'6o5V -'6o5` -'6o5l -'6p2 -'6q -'6s0g -'6sfs -'6shb -'6sjv -'6snG -'6sqg -'6O13 -'6z1 -'6z1z3 -'6z2 -'6z3o1s -'6z4o9o -'6z5 +'6 $ +'6 $, +'6 $0 +'6 $2 +'6 $7 +'6 $9 +'6 $Q +'6 $i +'6 $k +'6 $k ^w +'6 $k z3 +'6 $l +'6 $p +'6 $r +'6 *03 +'6 *21 u +'6 *51 +'6 *54 +'6 +1 +'6 +3 +'6 +4 c +'6 -1 +'6 @3 +'6 @4 +'6 @Z +'6 D1 +'6 D1 o0K +'6 D2 +'6 L0 +'6 L1 s61 +'6 L2 +'6 R2 sob +'6 R5 +'6 T0 o5* +'6 T1 +'6 Z1 +'6 Z1 $} +'6 Z2 +'6 Z3 +'6 Z4 *64 +'6 Z5 +'6 [ +'6 ^2 +'6 ^G +'6 ^L +'6 ^O +'6 ^a +'6 ^h +'6 ^j +'6 ^l D1 +'6 ^p +'6 ^w +'6 ^y z3 +'6 c +'6 c Z1 +'6 d +'6 d z1 +'6 f O45 +'6 i1* +'6 i23 ^, +'6 i3- +'6 i3m +'6 i3r +'6 i4g +'6 i4p +'6 i5% +'6 i5r +'6 l +'6 o0* } +'6 o1l +'6 o3P +'6 o3e +'6 o3t +'6 o4O +'6 o5% +'6 o5V +'6 o5` +'6 o5l +'6 p2 +'6 q +'6 s0g +'6 sfs +'6 shb +'6 sjv +'6 snG +'6 sqg +'6 O13 +'6 z1 +'6 z1 z3 +'6 z2 +'6 z3 o1s +'6 z4 o9o +'6 z5 '7 -'7$! -'7$* -'7$*D4 -'7$. -'7$1 -'7$8 -'7$9 -'7$J -'7$P -'7$T^s -'7$U -'7$e -'7$n -'7$s -'7$t -'7*30 -'7*46 -'7+0+4 -'7+5 -'7+6 -'7-3 -'7-4 -'7-5 -'7C -'7C-5 -'7D4 -'7R5 -'7R5o2c -'7T3 -'7Z1 -'7Z1T0 -'7Z2 -'7Z3 -'7Z4 -'7Z5 -'7[*41 -'7]*14 -'7^ -'7^< -'7^@ -'7^C -'7^D -'7^T -'7^[ -'7^n -'7^tsxt -'7c -'7cO01 -'7d -'7f -'7i0Ad -'7i29 -'7i4; -'7i5_ -'7i6+ -'7l -'7o0b -'7o11-6 -'7o1n -'7o3 -'7o3g -'7o5. -'7o59 -'7o6! -'7o6w{ -'7o6z -'7q -'7s1- -'7s6/ -'7saZ -'7sat -'7sdr -'7sfn -'7srv -'7u -'7ud -'7O13$s -'7O51 -'7z4z5 -'7} +'7 $! +'7 $* +'7 $* D4 +'7 $. +'7 $1 +'7 $8 +'7 $9 +'7 $J +'7 $P +'7 $T ^s +'7 $U +'7 $e +'7 $n +'7 $s +'7 $t +'7 *30 +'7 *46 +'7 +0 +4 +'7 +5 +'7 +6 +'7 -3 +'7 -4 +'7 -5 +'7 C +'7 C -5 +'7 D4 +'7 R5 +'7 R5 o2c +'7 T3 +'7 Z1 +'7 Z1 T0 +'7 Z2 +'7 Z3 +'7 Z4 +'7 Z5 +'7 [ *41 +'7 ] *14 +'7 ^ +'7 ^< +'7 ^@ +'7 ^C +'7 ^D +'7 ^T +'7 ^[ +'7 ^n +'7 ^t sxt +'7 c +'7 c O01 +'7 d +'7 f +'7 i0A d +'7 i29 +'7 i4; +'7 i5_ +'7 i6+ +'7 l +'7 o0b +'7 o11 -6 +'7 o1n +'7 o3 +'7 o3g +'7 o5. +'7 o59 +'7 o6! +'7 o6w { +'7 o6z +'7 q +'7 s1- +'7 s6/ +'7 saZ +'7 sat +'7 sdr +'7 sfn +'7 srv +'7 u +'7 u d +'7 O13 $s +'7 O51 +'7 z4 z5 +'7 } '8 -'8$, -'8$0 -'8$@ -'8$K -'8$N -'8$Q -'8$a -'8$h -'8$i -'8$s -'8$y -'8*02 -'8*12 -'8*32 -'8*56 -'8*70 -'8*74 -'8+0 -'8+3s2+ -'8+6 -'8-2 -'8-5 -'8-6 -'8@p -'8@z@g -'8CO43 -'8D4+6 -'8Ko5p -'8L3 -'8R2 -'8T7 -'8Z1 -'8Z2 -'8Z4 -'8Z5 -'8[ -'8[L6 -'8^4 -'8^R -'8^a -'8^t -'8^|z2 -'8c -'8d -'8dz2 -'8i02 -'8i1. -'8i2d -'8i4_ -'8i4u -'8i4{ -'8i52 -'8i5e -'8i6P -'8i6j -'8i7_ -'8i7w -'8o0E -'8o12 -'8o2tD1 -'8o34 -'8o7/ -'8o7; -'8o7a -'8s 5 -'8s2<$, -'8siz -'8t -'8u -'8O51 -'8O61 -'8z1 -'8z1O12 +'8 $, +'8 $0 +'8 $@ +'8 $K +'8 $N +'8 $Q +'8 $a +'8 $h +'8 $i +'8 $s +'8 $y +'8 *02 +'8 *12 +'8 *32 +'8 *56 +'8 *70 +'8 *74 +'8 +0 +'8 +3 s2+ +'8 +6 +'8 -2 +'8 -5 +'8 -6 +'8 @p +'8 @z @g +'8 C O43 +'8 D4 +6 +'8 K o5p +'8 L3 +'8 R2 +'8 T7 +'8 Z1 +'8 Z2 +'8 Z4 +'8 Z5 +'8 [ +'8 [ L6 +'8 ^4 +'8 ^R +'8 ^a +'8 ^t +'8 ^| z2 +'8 c +'8 d +'8 d z2 +'8 i02 +'8 i1. +'8 i2d +'8 i4_ +'8 i4u +'8 i4{ +'8 i52 +'8 i5e +'8 i6P +'8 i6j +'8 i7_ +'8 i7w +'8 o0E +'8 o12 +'8 o2t D1 +'8 o34 +'8 o7/ +'8 o7; +'8 o7a +'8 s 5 +'8 s2< $, +'8 siz +'8 t +'8 u +'8 O51 +'8 O61 +'8 z1 +'8 z1 O12 '9 -'9$' -'9$. -'9$1 -'9$2 -'9$B -'9$D+1 -'9$M -'9$c -'9$h -'9$k -'9$r -'9*08 -'9*53 -'9*76 -'9*83 -'9*85 -'9+0 -'9+2 -'9-2 -'9-3 -'9-4 -'9-6 -'9@a -'9D2 -'9D4 -'9R8 -'9T2 -'9T4 -'9T5 -'9T8 -'9Z1 -'9Z2 -'9Z3 -'9Z5 -'9[ -'9^1 -'9^d -'9^e@c -'9^k -'9c -'9i1t -'9i2l -'9i3n -'9i4 -'9i45 -'9i50 -'9i7w -'9i8K -'9i8e -'9i8r -'9i8t -'9l -'9o2l -'9o2z -'9o4. -'9o4h -'9o4j -'9o5j -'9o6m -'9o7n -'9o7s -'9o7y -'9q -'9r -'9sah -'9se2 -'9sfg -'9u -'9O06 -'9O43 -'9O61 -'9z2 +'9 $' +'9 $. +'9 $1 +'9 $2 +'9 $B +'9 $D +1 +'9 $M +'9 $c +'9 $h +'9 $k +'9 $r +'9 *08 +'9 *53 +'9 *76 +'9 *83 +'9 *85 +'9 +0 +'9 +2 +'9 -2 +'9 -3 +'9 -4 +'9 -6 +'9 @a +'9 D2 +'9 D4 +'9 R8 +'9 T2 +'9 T4 +'9 T5 +'9 T8 +'9 Z1 +'9 Z2 +'9 Z3 +'9 Z5 +'9 [ +'9 ^1 +'9 ^d +'9 ^e @c +'9 ^k +'9 c +'9 i1t +'9 i2l +'9 i3n +'9 i4 +'9 i45 +'9 i50 +'9 i7w +'9 i8K +'9 i8e +'9 i8r +'9 i8t +'9 l +'9 o2l +'9 o2z +'9 o4. +'9 o4h +'9 o4j +'9 o5j +'9 o6m +'9 o7n +'9 o7s +'9 o7y +'9 q +'9 r +'9 sah +'9 se2 +'9 sfg +'9 u +'9 O06 +'9 O43 +'9 O61 +'9 z2 'A -'A$-[ -'A$7 -'A$? -'A$a -'A$e -'A$k -'A$w -'A+1 -'A+2 -'A+3 -'A+7 -'A@a -'AD1 -'AD3 -'AD7 -'AL1 -'AR9 -'AT5 -'AT8 -'AT9 -'AZ1 -'A^T -'A^t -'Ac -'Ai7s -'Ai81 -'Ai9 -'Al -'Ao3k -'Ao43 -'Ao7b -'Ao7h -'Ao7l -'Ao8ml -'Ao9q -'Ap1 -'Aq -'As97 -'At -'AO41 -'AO42 -'AO43 -'AO52 -'AO62+6 +'A $- [ +'A $7 +'A $? +'A $a +'A $e +'A $k +'A $w +'A +1 +'A +2 +'A +3 +'A +7 +'A @a +'A D1 +'A D3 +'A D7 +'A L1 +'A R9 +'A T5 +'A T8 +'A T9 +'A Z1 +'A ^T +'A ^t +'A c +'A i7s +'A i81 +'A i9 +'A l +'A o3k +'A o43 +'A o7b +'A o7h +'A o7l +'A o8m l +'A o9q +'A p1 +'A q +'A s97 +'A t +'A O41 +'A O42 +'A O43 +'A O52 +'A O62 +6 'B -'B$4 -'B$6 -'B$8 -'B$I -'B$\*5B -'B$c -'B$e -'B$l -'B$m -'B*23 -'B*35 -'B*97 -'B+5 -'B+7 -'B+A -'B@y -'BD3 -'BD4 -'BT1 -'BT7 -'BZ1[ -'BZ2 -'B[R1 -'B^1 -'Bk -'Bl -'Bo00 -'Bo6? -'Bo6l -'Bo8f -'Bo9. -'Bo9@ -'Bo9i -'Br -'Bsoa -'Bt -'BO36 -'BO51 -'BO71 -'BO72 -'Bz5 -*01$f -*01*41 -*01*53R6 -*01*65R7 -*01*83 -*01+1 -*01L1 -*01L5 -*01R0 -*01Z2^g -*01[$t -*01[i6v -*01^*i3g -*01^0 -*01^O -*01^R -*01^v -*01d$k -*01i11 -*01i3-[ -*01o3v+4 -*01o6! -*01o7) -*01o8s -*01s x[ -*01s81 -*01scx -*01soi -*01sx5 -*01t*51 -*01O42 -*01O61 -*01z4] -*01z5 -*01{$6 +'B $4 +'B $6 +'B $8 +'B $I +'B $\ *5B +'B $c +'B $e +'B $l +'B $m +'B *23 +'B *35 +'B *97 +'B +5 +'B +7 +'B +A +'B @y +'B D3 +'B D4 +'B T1 +'B T7 +'B Z1 [ +'B Z2 +'B [ R1 +'B ^1 +'B k +'B l +'B o00 +'B o6? +'B o6l +'B o8f +'B o9. +'B o9@ +'B o9i +'B r +'B soa +'B t +'B O36 +'B O51 +'B O71 +'B O72 +'B z5 +*01 $f +*01 *41 +*01 *53 R6 +*01 *65 R7 +*01 *83 +*01 +1 +*01 L1 +*01 L5 +*01 R0 +*01 Z2 ^g +*01 [ $t +*01 [ i6v +*01 ^* i3g +*01 ^0 +*01 ^O +*01 ^R +*01 ^v +*01 d $k +*01 i11 +*01 i3- [ +*01 o3v +4 +*01 o6! +*01 o7) +*01 o8s +*01 s x [ +*01 s81 +*01 scx +*01 soi +*01 sx5 +*01 t *51 +*01 O42 +*01 O61 +*01 z4 ] +*01 z5 +*01 { $6 *02 -*02$d -*02$g -*02$i -*02*06 -*02*10$K -*02*57sdl -*02*97 -*02+5 -*02+9 -*02D3 -*02L3 -*02R4 -*02T6 -*02T7 -*02Z2 -*02[ -*02^0 -*02^b -*02^f -*02^j -*02^s*24 -*02^y -*02i0s -*02i1L-2 -*02i1isih -*02i3& -*02i3\ -*02i3p -*02k*13 -*02o1a -*02o20 -*02o2w -*02o2z -*02o3a -*02o3e -*02o3m -*02o51 -*02o5_ -*02o6M -*02o7Yl -*02q -*02s0P*17 -*02scl -*02O21 -*02O24 -*02O42 -*02O63 -*02z2 +*02 $d +*02 $g +*02 $i +*02 *06 +*02 *10 $K +*02 *57 sdl +*02 *97 +*02 +5 +*02 +9 +*02 D3 +*02 L3 +*02 R4 +*02 T6 +*02 T7 +*02 Z2 +*02 [ +*02 ^0 +*02 ^b +*02 ^f +*02 ^j +*02 ^s *24 +*02 ^y +*02 i0s +*02 i1L -2 +*02 i1i sih +*02 i3& +*02 i3\ +*02 i3p +*02 k *13 +*02 o1a +*02 o20 +*02 o2w +*02 o2z +*02 o3a +*02 o3e +*02 o3m +*02 o51 +*02 o5_ +*02 o6M +*02 o7Y l +*02 q +*02 s0P *17 +*02 scl +*02 O21 +*02 O24 +*02 O42 +*02 O63 +*02 z2 *03 -*03$c*51 -*03$r -*03$t -*03$w -*03'5 -*03*05 -*03*36 -*03*41 -*03*47 -*03+1o2r -*03CZ4 -*03D1 -*03R3 -*03T8*70 -*03Z3O07 -*03^O -*03^a -*03i1b -*03i1r -*03i3e -*03l+0 -*03o0h -*03o0l -*03o0p -*03o1! -*03o1t -*03o1y[ -*03o2P -*03o3a -*03o3t -*03o3w -*03o5_ -*03q -*03r^z -*03sbe -*03sjx -*03snti1; -*03sqt -*03O34 -*03O43 -*03z3 +*03 $c *51 +*03 $r +*03 $t +*03 $w +*03 '5 +*03 *05 +*03 *36 +*03 *41 +*03 *47 +*03 +1 o2r +*03 C Z4 +*03 D1 +*03 R3 +*03 T8 *70 +*03 Z3 O07 +*03 ^O +*03 ^a +*03 i1b +*03 i1r +*03 i3e +*03 l +0 +*03 o0h +*03 o0l +*03 o0p +*03 o1! +*03 o1t +*03 o1y [ +*03 o2P +*03 o3a +*03 o3t +*03 o3w +*03 o5_ +*03 q +*03 r ^z +*03 sbe +*03 sjx +*03 snt i1; +*03 sqt +*03 O34 +*03 O43 +*03 z3 *04 -*04$5 -*04$nO41 -*04$pZ1 -*04$y*53 -*04*07 -*04*17 -*04*31Z2 -*04*73 -*04+3 -*04+4 -*04+6 -*04+8D0 -*04D1 -*04T0 -*04T6 -*04Z1 -*04[ -*04^# -*04^9 -*04i0K*43 -*04i0m -*04i3R -*04i4t -*04l -*04li6* -*04o0`O23 -*04o0t -*04o41 -*04oAw[ -*04smv -*04son -*04sry] -*04u -*04O07p3 -*04O32 -*04z4 -*04{ +*04 $5 +*04 $n O41 +*04 $p Z1 +*04 $y *53 +*04 *07 +*04 *17 +*04 *31 Z2 +*04 *73 +*04 +3 +*04 +4 +*04 +6 +*04 +8 D0 +*04 D1 +*04 T0 +*04 T6 +*04 Z1 +*04 [ +*04 ^# +*04 ^9 +*04 i0K *43 +*04 i0m +*04 i3R +*04 i4t +*04 l +*04 l i6* +*04 o0` O23 +*04 o0t +*04 o41 +*04 oAw [ +*04 smv +*04 son +*04 sry ] +*04 u +*04 O07 p3 +*04 O32 +*04 z4 +*04 { *05 -*05$@ -*05'5 -*05*12 -*05*26 -*05+3 -*05-1 -*05K -*05R1 -*05R4*06 -*05T1 -*05T6 -*05Z1 -*05Z1i5i -*05[ -*05]-5 -*05^(z1 -*05^o -*05^r -*05^y -*05c -*05d -*05i01 -*05i1y -*05i3#^` -*05l -*05o00 -*05o0r -*05o2f -*05o4i -*05o5B -*05q -*05r -*05saC -*05uD0 -*05O02 -*05O03 -*05O21 -*05O35 -*05O45 -*05O52Z1 -*05z2*39 +*05 $@ +*05 '5 +*05 *12 +*05 *26 +*05 +3 +*05 -1 +*05 K +*05 R1 +*05 R4 *06 +*05 T1 +*05 T6 +*05 Z1 +*05 Z1 i5i +*05 [ +*05 ] -5 +*05 ^( z1 +*05 ^o +*05 ^r +*05 ^y +*05 c +*05 d +*05 i01 +*05 i1y +*05 i3# ^` +*05 l +*05 o00 +*05 o0r +*05 o2f +*05 o4i +*05 o5B +*05 q +*05 r +*05 saC +*05 u D0 +*05 O02 +*05 O03 +*05 O21 +*05 O35 +*05 O45 +*05 O52 Z1 +*05 z2 *39 *06 -*06$) -*06$1 -*06$6'5 -*06'6 -*06*15 -*06*67 -*06*87 -*06+6 -*06D2 -*06D3sMf -*06R0 -*06R7 -*06T4 -*06T6 -*06^h -*06^w -*06d -*06i6y -*06l -*06o2y -*06o3m -*06o4k -*06o4m -*06o5j -*06o69 -*06s7A -*06t -*06O02 -*06O34 -*06O41 -*06z1 +*06 $) +*06 $1 +*06 $6 '5 +*06 '6 +*06 *15 +*06 *67 +*06 *87 +*06 +6 +*06 D2 +*06 D3 sMf +*06 R0 +*06 R7 +*06 T4 +*06 T6 +*06 ^h +*06 ^w +*06 d +*06 i6y +*06 l +*06 o2y +*06 o3m +*06 o4k +*06 o4m +*06 o5j +*06 o69 +*06 s7A +*06 t +*06 O02 +*06 O34 +*06 O41 +*06 z1 *07 -*07$g -*07$p -*07*18 -*07*24T1 -*07*53O31 -*07+0 -*07-4z2 -*07D2 -*07D6 -*07R7 -*07c -*07i8b[ -*07O04O31 -*07O58 -*07z4 +*07 $g +*07 $p +*07 *18 +*07 *24 T1 +*07 *53 O31 +*07 +0 +*07 -4 z2 +*07 D2 +*07 D6 +*07 R7 +*07 c +*07 i8b [ +*07 O04 O31 +*07 O58 +*07 z4 *08 -*08'5 -*08D6 -*08T0*13 -*08Z1s1( -*08[ -*08i7t -*08O06 -*08O45 -*08O47 +*08 '5 +*08 D6 +*08 T0 *13 +*08 Z1 s1( +*08 [ +*08 i7t +*08 O06 +*08 O45 +*08 O47 *09 -*09'6 -*09*91 -*09*97 -*09l[ -*09o6@ -*09s86 -*09O03 -*09O34 -*0ALBO06 -*0A[ -*0At -*0AO7A -*0Bl -*0BO08 -*0BO74 -*10$6{ -*10*30z3 -*10*42 -*10+4i1: -*10-8 -*10R1 -*10Z2d -*10^9 -*10^a -*10^q -*10i03 -*10i1b -*10i2b -*10i38 -*10i3r -*10i4{ -*10lz2 -*10o1. -*10o2Xi7; -*10o4wZ1 -*10o4z -*10rD3 -*10tO81 -*10O04@t -*10O19 -*10{c +*09 '6 +*09 *91 +*09 *97 +*09 l [ +*09 o6@ +*09 s86 +*09 O03 +*09 O34 +*0A LB O06 +*0A [ +*0A t +*0A O7A +*0B l +*0B O08 +*0B O74 +*10 $6 { +*10 *30 z3 +*10 *42 +*10 +4 i1: +*10 -8 +*10 R1 +*10 Z2 d +*10 ^9 +*10 ^a +*10 ^q +*10 i03 +*10 i1b +*10 i2b +*10 i38 +*10 i3r +*10 i4{ +*10 l z2 +*10 o1. +*10 o2X i7; +*10 o4w Z1 +*10 o4z +*10 r D3 +*10 t O81 +*10 O04 @t +*10 O19 +*10 { c *12 -*12$ -*12$! -*12$4 -*12$= -*12$Ku -*12$R -*12'5 -*12*68 -*12+1 -*12K -*12R3 -*12Z2 -*12[^R -*12[o6o -*12^'^, -*12^0 -*12^P -*12^k -*12dO6B -*12f -*12i0o -*12i1; -*12i1g -*12i2-*43 -*12i2p -*12i4! -*12kss2 -*12l -*12lk -*12o0D -*12o1b -*12o1j -*12o2y -*12p1 -*12s34 -*12sma -*12snp -*12uf -*12O42$v -*12z3 -*12} -*12}i01 +*12 $ +*12 $! +*12 $4 +*12 $= +*12 $K u +*12 $R +*12 '5 +*12 *68 +*12 +1 +*12 K +*12 R3 +*12 Z2 +*12 [ ^R +*12 [ o6o +*12 ^' ^, +*12 ^0 +*12 ^P +*12 ^k +*12 d O6B +*12 f +*12 i0o +*12 i1; +*12 i1g +*12 i2- *43 +*12 i2p +*12 i4! +*12 k ss2 +*12 l +*12 l k +*12 o0D +*12 o1b +*12 o1j +*12 o2y +*12 p1 +*12 s34 +*12 sma +*12 snp +*12 u f +*12 O42 $v +*12 z3 +*12 } +*12 } i01 *13 -*13$8 -*13$M -*13$q -*13*04 -*13*26 -*13*42 -*13*45R1 -*13*65 -*13D1 -*13D9 -*13KO31 -*13Z1[ -*13[p1 -*13^*i3p -*13^/*72 -*13^8 -*13^T -*13^u -*13^z -*13c -*13dO52 -*13i4y -*13i5u -*13i64 -*13k -*13o0f -*13o2- -*13o4B -*13p1 -*13s73 -*13sau -*13sbci1& -*13sc2 -*13svr -*13O03i0q -*13O12 -*13O43 -*13z1*16 -*13z2 -*13z5 -*13{i0t +*13 $8 +*13 $M +*13 $q +*13 *04 +*13 *26 +*13 *42 +*13 *45 R1 +*13 *65 +*13 D1 +*13 D9 +*13 K O31 +*13 Z1 [ +*13 [ p1 +*13 ^* i3p +*13 ^/ *72 +*13 ^8 +*13 ^T +*13 ^u +*13 ^z +*13 c +*13 d O52 +*13 i4y +*13 i5u +*13 i64 +*13 k +*13 o0f +*13 o2- +*13 o4B +*13 p1 +*13 s73 +*13 sau +*13 sbc i1& +*13 sc2 +*13 svr +*13 O03 i0q +*13 O12 +*13 O43 +*13 z1 *16 +*13 z2 +*13 z5 +*13 { i0t *14 -*14$7 -*14'5q -*14*27] -*14*34 -*14+3i2w -*14-2 -*14-2$i -*14C -*14C*10 -*14R2 -*14R3 -*14Z1 -*14Z2 -*14Z3*36 -*14^1 -*14^f -*14^q -*14^t -*14c -*14i0m -*14i2- -*14i2v -*14o1! -*14o1X -*14o5z -*14o9z -*14q'6 -*14svm -*14O02 -*14z1i0T -*14z2+7 -*14z5 -*14} -*14}i38 +*14 $7 +*14 '5 q +*14 *27 ] +*14 *34 +*14 +3 i2w +*14 -2 +*14 -2 $i +*14 C +*14 C *10 +*14 R2 +*14 R3 +*14 Z1 +*14 Z2 +*14 Z3 *36 +*14 ^1 +*14 ^f +*14 ^q +*14 ^t +*14 c +*14 i0m +*14 i2- +*14 i2v +*14 o1! +*14 o1X +*14 o5z +*14 o9z +*14 q '6 +*14 svm +*14 O02 +*14 z1 i0T +*14 z2 +7 +*14 z5 +*14 } +*14 } i38 *15 -*15$' -*15$9Z1 -*15$n -*15$p -*15$t -*15$u -*15*10 -*15*23 -*15*41*43 -*15+3 -*15D1 -*15T4 -*15Z1 -*15Z2o86 -*15] -*15^H -*15^p*71 -*15f -*15i1^o7f -*15ki3u -*15o1u -*15o5 -*15p1 -*15snpr -*15uO01 -*15O04@5 -*15O13 -*15O34 -*15O42 -*15z2'6 -*15} +*15 $' +*15 $9 Z1 +*15 $n +*15 $p +*15 $t +*15 $u +*15 *10 +*15 *23 +*15 *41 *43 +*15 +3 +*15 D1 +*15 T4 +*15 Z1 +*15 Z2 o86 +*15 ] +*15 ^H +*15 ^p *71 +*15 f +*15 i1^ o7f +*15 k i3u +*15 o1u +*15 o5 +*15 p1 +*15 snp r +*15 u O01 +*15 O04 @5 +*15 O13 +*15 O34 +*15 O42 +*15 z2 '6 +*15 } *16 -*16$R -*16$d -*16'7 -*16*05 -*16*05*30 -*16*23 -*16*47 -*16*48 -*16D5u -*16] -*16^1 -*16i5a -*16o1y -*16o27 -*16o3/^C -*16o5s -*16o5w -*16r -*16snp -*16O03 -*16O04D0 -*16O43 -*16z2 +*16 $R +*16 $d +*16 '7 +*16 *05 +*16 *05 *30 +*16 *23 +*16 *47 +*16 *48 +*16 D5 u +*16 ] +*16 ^1 +*16 i5a +*16 o1y +*16 o27 +*16 o3/ ^C +*16 o5s +*16 o5w +*16 r +*16 snp +*16 O03 +*16 O04 D0 +*16 O43 +*16 z2 *17 -*17$y -*17'6 -*17*73 -*17+7 -*17+7z2 -*17-8 -*17Z2D1 -*17Z3 -*17Z5 -*17i13$5 -*17i5N*56 -*17r -*17O06 -*17O12 -*17O15 -*17O42 -*17O51 +*17 $y +*17 '6 +*17 *73 +*17 +7 +*17 +7 z2 +*17 -8 +*17 Z2 D1 +*17 Z3 +*17 Z5 +*17 i13 $5 +*17 i5N *56 +*17 r +*17 O06 +*17 O12 +*17 O15 +*17 O42 +*17 O51 *18 -*18@sO05 -*18D7 -*18D8 -*18^& -*18^} -*18l -*18o5g -*18O03 -*18O62 -*18O75 +*18 @s O05 +*18 D7 +*18 D8 +*18 ^& +*18 ^} +*18 l +*18 o5g +*18 O03 +*18 O62 +*18 O75 *19 -*19$2 -*19i6Y -*19O08-4 -*19O41 -*19z3O07 -*1A'A -*1AO03'9 -*1AOA1 -*1BO01 -*1BO17 -*20$$Z1 -*20$/ -*20$2 -*20$9+4 -*20'4 -*20*03 -*20*14c -*20*43 -*20*50 -*20+2 -*20-0 -*20@p*27 -*20D5 -*20Z3*71 -*20^1 -*20c -*20d$7 -*20i3i -*20o0l -*20o2. -*20o3i -*20o4 -*20o5X -*20o5s -*20o6 -*20o7R -*20oBm*A7 -*20p1 -*20p2O14 -*20r -*20s29 -*20s4q -*20s52 -*20s9! -*20slm^9 -*20sri -*20svt -*20syt -*20td -*20O05o3U -*20O18O06 -*20O23 -*20O32 -*20O41 -*20O41[ -*20O71 -*20z4$z -*20} -*20}u -*21*02z5 -*21*03 -*21*13 -*21*20 -*21*28 -*21*36 -*21*56 -*21*72 -*21*78 -*21+4l -*21-3 -*21C -*21D3*42 -*21R0 -*21Z1} -*21^ -*21^6*61 -*21^j -*21i0m -*21i4t -*21i5 -*21i50 -*21i61 -*21i8| -*21kd -*21o0m -*21o1e -*21o2g -*21o61 -*21sdEO24 -*21suo -*21O25 -*21O25^p -*21O31c -*21O41 -*21z1O42 -*21z2 -*21z4 +*19 $2 +*19 i6Y +*19 O08 -4 +*19 O41 +*19 z3 O07 +*1A 'A +*1A O03 '9 +*1A OA1 +*1B O01 +*1B O17 +*20 $$ Z1 +*20 $/ +*20 $2 +*20 $9 +4 +*20 '4 +*20 *03 +*20 *14 c +*20 *43 +*20 *50 +*20 +2 +*20 -0 +*20 @p *27 +*20 D5 +*20 Z3 *71 +*20 ^1 +*20 c +*20 d $7 +*20 i3i +*20 o0l +*20 o2. +*20 o3i +*20 o4 +*20 o5X +*20 o5s +*20 o6 +*20 o7R +*20 oBm *A7 +*20 p1 +*20 p2 O14 +*20 r +*20 s29 +*20 s4q +*20 s52 +*20 s9! +*20 slm ^9 +*20 sri +*20 svt +*20 syt +*20 t d +*20 O05 o3U +*20 O18 O06 +*20 O23 +*20 O32 +*20 O41 +*20 O41 [ +*20 O71 +*20 z4 $z +*20 } +*20 } u +*21 *02 z5 +*21 *03 +*21 *13 +*21 *20 +*21 *28 +*21 *36 +*21 *56 +*21 *72 +*21 *78 +*21 +4 l +*21 -3 +*21 C +*21 D3 *42 +*21 R0 +*21 Z1 } +*21 ^ +*21 ^6 *61 +*21 ^j +*21 i0m +*21 i4t +*21 i5 +*21 i50 +*21 i61 +*21 i8| +*21 k d +*21 o0m +*21 o1e +*21 o2g +*21 o61 +*21 sdE O24 +*21 suo +*21 O25 +*21 O25 ^p +*21 O31 c +*21 O41 +*21 z1 O42 +*21 z2 +*21 z4 *23 -*23$* -*23$+i3# -*23$ir -*23$k -*23'5i1x -*23*05 -*23*31 -*23*86 -*23-6 -*23C -*23Kd -*23Z4*61 -*23^' -*23c -*23i0F -*23i1/ -*23i2-} -*23i3/$j -*23k -*23o0j -*23o1d -*23o2e -*23o3q -*23o3y -*23o4_ -*23t -*23O03 -*23O19i1H -*23O42 -*23O51 -*23z3 -*23z4o1= -*23} +*23 $* +*23 $+ i3# +*23 $i r +*23 $k +*23 '5 i1x +*23 *05 +*23 *31 +*23 *86 +*23 -6 +*23 C +*23 K d +*23 Z4 *61 +*23 ^' +*23 c +*23 i0F +*23 i1/ +*23 i2- } +*23 i3/ $j +*23 k +*23 o0j +*23 o1d +*23 o2e +*23 o3q +*23 o3y +*23 o4_ +*23 t +*23 O03 +*23 O19 i1H +*23 O42 +*23 O51 +*23 z3 +*23 z4 o1= +*23 } *24 -*24$m -*24*15 -*24*30 -*24*37c -*24*70] -*24+2 -*24-0 -*24-4 -*24D2 -*24K -*24R3 -*24Z2 -*24]p1 -*24^K -*24^O -*24^d -*24co29 -*24f -*24i3Tz2 -*24i3a$p -*24i6^ -*24o2L -*24o2x -*24o31 -*24o5K -*24src -*24O14L2 -*24z2 +*24 $m +*24 *15 +*24 *30 +*24 *37 c +*24 *70 ] +*24 +2 +*24 -0 +*24 -4 +*24 D2 +*24 K +*24 R3 +*24 Z2 +*24 ] p1 +*24 ^K +*24 ^O +*24 ^d +*24 c o29 +*24 f +*24 i3T z2 +*24 i3a $p +*24 i6^ +*24 o2L +*24 o2x +*24 o31 +*24 o5K +*24 src +*24 O14 L2 +*24 z2 *25 -*25$0O63 -*25$r -*25'5 -*25*13c -*25*24*10 -*25*40 -*25*42R5 -*25*45$p -*25*54 -*25*84'7 -*25+2 -*25+5 -*25+8^0 -*25-7O03 -*25D1 -*25D4o3m -*25R5 -*25T0 -*25T5 -*25Z1[ -*25Z3 -*25^2 -*25^a -*25^d -*25^m$% -*25i5a -*25lO32 -*25o0B -*25o0m -*25o2p -*25o4C -*25ssv -*25z2 -*25z2r -*25z2O41 +*25 $0 O63 +*25 $r +*25 '5 +*25 *13 c +*25 *24 *10 +*25 *40 +*25 *42 R5 +*25 *45 $p +*25 *54 +*25 *84 '7 +*25 +2 +*25 +5 +*25 +8 ^0 +*25 -7 O03 +*25 D1 +*25 D4 o3m +*25 R5 +*25 T0 +*25 T5 +*25 Z1 [ +*25 Z3 +*25 ^2 +*25 ^a +*25 ^d +*25 ^m $% +*25 i5a +*25 l O32 +*25 o0B +*25 o0m +*25 o2p +*25 o4C +*25 ssv +*25 z2 +*25 z2 r +*25 z2 O41 *26 -*26'5 -*26*37] -*26*48 -*26+4z1 -*26-2$5 -*26D2Z2 -*26D3 -*26D6 -*26T6O15 -*26^f -*26i4 -*26l^" -*26o33 -*26o5[Z1 -*26r -*26t$< -*26u -*26O06o28 -*26O41z4 -*26O62 -*26z1 -*26z2 +*26 '5 +*26 *37 ] +*26 *48 +*26 +4 z1 +*26 -2 $5 +*26 D2 Z2 +*26 D3 +*26 D6 +*26 T6 O15 +*26 ^f +*26 i4 +*26 l ^" +*26 o33 +*26 o5[ Z1 +*26 r +*26 t $< +*26 u +*26 O06 o28 +*26 O41 z4 +*26 O62 +*26 z1 +*26 z2 *27 -*27$y -*27*65 -*27*74 -*27*76 -*27D2 -*27^2 -*27i55 -*27k -*27o2n -*27O07Z2 -*27O12 -*27O15f -*27O26D5 -*27O43^p -*27O52 -*27z2 +*27 $y +*27 *65 +*27 *74 +*27 *76 +*27 D2 +*27 ^2 +*27 i55 +*27 k +*27 o2n +*27 O07 Z2 +*27 O12 +*27 O15 f +*27 O26 D5 +*27 O43 ^p +*27 O52 +*27 z2 *28 -*28'7 -*28T1 -*28T2 -*28c -*28o2. -*28O05 -*28z2seb -*28z3 +*28 '7 +*28 T1 +*28 T2 +*28 c +*28 o2. +*28 O05 +*28 z2 seb +*28 z3 *29 -*29T0O04 -*29s4wO13 -*29O03 -*29O04 -*29O04o0m -*29O14 -*2A^U -*2AO06 -*2BDA -*2BO14 -*30$*K -*30$z -*30*02 -*30*43 -*30+3 -*30-0 -*30-2 -*30-4 -*30-9 -*30C -*30D3T8 -*30R5 -*30R6 -*30T1 -*30Z1o59 -*30Z2 -*30[ -*30[f -*30^$ -*30^3 -*30^T -*30^g^j -*30^h -*30c -*30dK -*30f -*30i1Q -*30i2p -*30o2y -*30o82 -*30p1 -*30sdD -*30u -*30u{ -*30O23 -*30O26 -*30O27o4R -*30O32 -*30O41 -*30z2 -*30z2Z1 -*30z4 -*30{*35 -*30{O53 -*31$$ -*31$5O2A -*31$_ -*31$bsby -*31$r -*31'8 -*31'A -*31*20 -*31*34 -*31*74 -*31*91 -*31+2 -*31-0] -*31D2 -*31D4 -*31L6Z2 -*31T3 -*31Z3 -*31Z4 -*31Z5 -*31^i -*31^m -*31^t -*31f -*31i1a -*31i1j -*31i3& -*31i3n -*31i43 -*31i4d -*31l -*31o1u -*31o32 -*31o3^ -*31o3j -*31q -*31r -*31sg' -*31snsT6 -*31tk -*31O02 -*31O24 -*31O29 -*31O32 -*31z1c -*31z3L2 -*31z4 -*32$6 -*32$g*41 -*32'9 -*32*04 -*32*25 -*32*34 -*32*43*16 -*32*45 -*32*67 -*32+5 -*32+Az1 -*32-2 -*32-8 -*32D6 -*32D7 -*32R5 -*32T0 -*32T7 -*32Z1 -*32Z1O18 -*32Z2 -*32^3c -*32^A -*32^I -*32^s -*32d -*32dt -*32i05 -*32i1\*52 -*32i1u -*32i4s -*32i6_ -*32i7yc -*32i9n -*32l -*32o2c -*32o3h -*32o7y -*32r -*32s9* -*32O38 -*32O74 -*32z1 +*29 T0 O04 +*29 s4w O13 +*29 O03 +*29 O04 +*29 O04 o0m +*29 O14 +*2A ^U +*2A O06 +*2B DA +*2B O14 +*30 $* K +*30 $z +*30 *02 +*30 *43 +*30 +3 +*30 -0 +*30 -2 +*30 -4 +*30 -9 +*30 C +*30 D3 T8 +*30 R5 +*30 R6 +*30 T1 +*30 Z1 o59 +*30 Z2 +*30 [ +*30 [ f +*30 ^$ +*30 ^3 +*30 ^T +*30 ^g ^j +*30 ^h +*30 c +*30 d K +*30 f +*30 i1Q +*30 i2p +*30 o2y +*30 o82 +*30 p1 +*30 sdD +*30 u +*30 u { +*30 O23 +*30 O26 +*30 O27 o4R +*30 O32 +*30 O41 +*30 z2 +*30 z2 Z1 +*30 z4 +*30 { *35 +*30 { O53 +*31 $$ +*31 $5 O2A +*31 $_ +*31 $b sby +*31 $r +*31 '8 +*31 'A +*31 *20 +*31 *34 +*31 *74 +*31 *91 +*31 +2 +*31 -0 ] +*31 D2 +*31 D4 +*31 L6 Z2 +*31 T3 +*31 Z3 +*31 Z4 +*31 Z5 +*31 ^i +*31 ^m +*31 ^t +*31 f +*31 i1a +*31 i1j +*31 i3& +*31 i3n +*31 i43 +*31 i4d +*31 l +*31 o1u +*31 o32 +*31 o3^ +*31 o3j +*31 q +*31 r +*31 sg' +*31 sns T6 +*31 t k +*31 O02 +*31 O24 +*31 O29 +*31 O32 +*31 z1 c +*31 z3 L2 +*31 z4 +*32 $6 +*32 $g *41 +*32 '9 +*32 *04 +*32 *25 +*32 *34 +*32 *43 *16 +*32 *45 +*32 *67 +*32 +5 +*32 +A z1 +*32 -2 +*32 -8 +*32 D6 +*32 D7 +*32 R5 +*32 T0 +*32 T7 +*32 Z1 +*32 Z1 O18 +*32 Z2 +*32 ^3 c +*32 ^A +*32 ^I +*32 ^s +*32 d +*32 d t +*32 i05 +*32 i1\ *52 +*32 i1u +*32 i4s +*32 i6_ +*32 i7y c +*32 i9n +*32 l +*32 o2c +*32 o3h +*32 o7y +*32 r +*32 s9* +*32 O38 +*32 O74 +*32 z1 *34 -*34$6 -*34$c -*34$n -*34$y -*34*62 -*34*74 -*34+0 -*34+3 -*34+5 -*34D7 -*34K} -*34]$m -*34^M -*34^Z -*34^m^, -*34^p -*34^x -*34i1R$h -*34i2 -1 -*34i3ni1| -*34i5- -*34i5T -*34i6tz1 -*34l -*34o0z -*34o2t -*34o2x -*34o3h -*34o3r -*34o4d -*34p1} -*34q -*34r -*34sd>c -*34sdg -*34sl+ -*34sm_ -*34ur -*34O13stc -*34O51 -*34O52 -*34z3 -*34} +*34 $6 +*34 $c +*34 $n +*34 $y +*34 *62 +*34 *74 +*34 +0 +*34 +3 +*34 +5 +*34 D7 +*34 K } +*34 ] $m +*34 ^M +*34 ^Z +*34 ^m ^, +*34 ^p +*34 ^x +*34 i1R $h +*34 i2 -1 +*34 i3n i1| +*34 i5- +*34 i5T +*34 i6t z1 +*34 l +*34 o0z +*34 o2t +*34 o2x +*34 o3h +*34 o3r +*34 o4d +*34 p1 } +*34 q +*34 r +*34 sd> c +*34 sdg +*34 sl+ +*34 sm_ +*34 u r +*34 O13 stc +*34 O51 +*34 O52 +*34 z3 +*34 } *35 -*35$9 -*35*04 -*35*24 -*35*31 -*35*41 -*35*50+5 -*35*54 -*35*56 -*35+1 -*35+4 -*35D2 -*35L2 -*35L3 -*35R4 -*35Z2 -*35^# -*35^& -*35^< -*35^_ -*35^c -*35^g -*35^h -*35^v$a -*35i3i -*35o0X -*35o2m -*35o3( -*35o5q -*35o6M -*35o7A -*35q -*35r -*35t -*35ti5g -*35O12 -*35O23 -*35O43 +*35 $9 +*35 *04 +*35 *24 +*35 *31 +*35 *41 +*35 *50 +5 +*35 *54 +*35 *56 +*35 +1 +*35 +4 +*35 D2 +*35 L2 +*35 L3 +*35 R4 +*35 Z2 +*35 ^# +*35 ^& +*35 ^< +*35 ^_ +*35 ^c +*35 ^g +*35 ^h +*35 ^v $a +*35 i3i +*35 o0X +*35 o2m +*35 o3( +*35 o5q +*35 o6M +*35 o7A +*35 q +*35 r +*35 t +*35 t i5g +*35 O12 +*35 O23 +*35 O43 *36 -*36$1O48 -*36'6 -*36*13O62 -*36*17 -*36*19 -*36*26 -*36*50 -*36+4o4z -*36+5-0 -*36D3[ -*36D5 -*36R0D3 -*36T9 -*36Z1Z1 -*36Z2*21 -*36[*05 -*36^Bl -*36^m -*36c -*36i1w -*36i5^i8- -*36o0B -*36o3g -*36o50z2 -*36o55 -*36O04 -*36O32 -*36O62 -*36z1L3 -*36{ +*36 $1 O48 +*36 '6 +*36 *13 O62 +*36 *17 +*36 *19 +*36 *26 +*36 *50 +*36 o4z +*36 +5 -0 +*36 D3 [ +*36 D5 +*36 R0 D3 +*36 T9 +*36 Z1 Z1 +*36 Z2 *21 +*36 [ *05 +*36 ^B l +*36 ^m +*36 c +*36 i1w +*36 i5^ i8- +*36 o0B +*36 o3g +*36 o50 z2 +*36 o55 +*36 O04 +*36 O32 +*36 O62 +*36 z1 L3 +*36 { *37 -*37$4 -*37$A -*37$k -*37$z -*37*05 -*37*14 -*37*32 -*37*87 -*37c -*37i5<*30 -*37O12 -*37O13 -*37O25 -*37z5O32 -*37{z2 +*37 $4 +*37 $A +*37 $k +*37 $z +*37 *05 +*37 *14 +*37 *32 +*37 *87 +*37 c +*37 i5< *30 +*37 O12 +*37 O13 +*37 O25 +*37 z5 O32 +*37 { z2 *38 -*38'A -*38@rO32 -*38D0 -*38O23 -*38O26 -*38O57 -*39'A -*39+5 -*39+8O38 -*39D3-5 -*39L3O05 -*39o58 -*39O04 -*39O32 -*3A'8 -*3A-0O05 -*3AO08 -*3AO24 -*3AO36 -*3AO38z5 -*3B'8 -*3BTBO28 -*3Bl -*3BO09i18 -*3BO37 -*40$jO02 -*40$l -*40$s -*40'9 -*40*02 -*40*06 -*40*12 -*40*15 -*40*34 -*40*35z1 -*40*54 -*40*57 -*40*96 -*40D3 -*40D4 -*40D6O41 -*40Z1$h -*40^g -*40c -*40i0b -*40i4C -*40i8j -*40o0B -*40o3n -*40o5m -*40o7y -*40p1 -*40q -*40t -*40O24 -*40O27 -*40O34 -*40O34u -*40O42 -*40O42O61 -*40O45 -*40O75O24 -*40z1 -*40z2D5 -*40}$8 -*40}z2 -*41$) -*41$s -*41$z -*41*16 -*41*32 -*41*47 -*41*86 -*41+0^G -*41-0 -*41D1 -*41Z1*04 -*41^2^k -*41^j -*41^v -*41c] -*41d -*41f -*41i68 -*41k{ -*41o2zu -*41o5t -*41o82 -*41q -*41O14f -*41O21 -*41O32 -*41O34 -*41O37 -*41O47 -*41z2 -*41z3 -*41z3O61 -*41z4'8 -*41}} -*42$0 -*42$g -*42$rZ2 -*42$s -*42*14i0Y -*42*21 -*42*41 -*42*64 -*42*B6 -*42+6 -*42R0 -*42R5 -*42R6 -*42T0 -*42Z1D1 -*42]^g -*42^S -*42^f -*42^g -*42^k -*42^w -*42d -*42dc -*42li5n -*42o4aZ4 -*42r -*42skL -*42t -*42O3A -*42O46 -*42z1 -*42} -*43$" -*43$- -*43$3 -*43$a -*43$e -*43*01} -*43*12 -*43*48 -*43*52 -*43+2 -*43-0 -*43-6 -*43D2 -*43K*35 -*43R3 -*43T6 -*43[{ -*43]*20 -*43^7O18 -*43^8'5 -*43^y*23 -*43i2b -*43i2f -*43k -*43o4l -*43o9p -*43s25 -*43skC -*43suo -*43t-5 -*43t{ -*43O53 -*43z1 -*43z4 +*38 'A +*38 @r O32 +*38 D0 +*38 O23 +*38 O26 +*38 O57 +*39 'A +*39 +5 +*39 +8 O38 +*39 D3 -5 +*39 L3 O05 +*39 o58 +*39 O04 +*39 O32 +*3A '8 +*3A -0 O05 +*3A O08 +*3A O24 +*3A O36 +*3A O38 z5 +*3B '8 +*3B TB O28 +*3B l +*3B O09 i18 +*3B O37 +*40 $j O02 +*40 $l +*40 $s +*40 '9 +*40 *02 +*40 *06 +*40 *12 +*40 *15 +*40 *34 +*40 *35 z1 +*40 *54 +*40 *57 +*40 *96 +*40 D3 +*40 D4 +*40 D6 O41 +*40 Z1 $h +*40 ^g +*40 c +*40 i0b +*40 i4C +*40 i8j +*40 o0B +*40 o3n +*40 o5m +*40 o7y +*40 p1 +*40 q +*40 t +*40 O24 +*40 O27 +*40 O34 +*40 O34 u +*40 O42 +*40 O42 O61 +*40 O45 +*40 O75 O24 +*40 z1 +*40 z2 D5 +*40 } $8 +*40 } z2 +*41 $) +*41 $s +*41 $z +*41 *16 +*41 *32 +*41 *47 +*41 *86 +*41 +0 ^G +*41 -0 +*41 D1 +*41 Z1 *04 +*41 ^2 ^k +*41 ^j +*41 ^v +*41 c ] +*41 d +*41 f +*41 i68 +*41 k { +*41 o2z u +*41 o5t +*41 o82 +*41 q +*41 O14 f +*41 O21 +*41 O32 +*41 O34 +*41 O37 +*41 O47 +*41 z2 +*41 z3 +*41 z3 O61 +*41 z4 '8 +*41 } } +*42 $0 +*42 $g +*42 $r Z2 +*42 $s +*42 *14 i0Y +*42 *21 +*42 *41 +*42 *64 +*42 *B6 +*42 +6 +*42 R0 +*42 R5 +*42 R6 +*42 T0 +*42 Z1 D1 +*42 ] ^g +*42 ^S +*42 ^f +*42 ^g +*42 ^k +*42 ^w +*42 d +*42 d c +*42 l i5n +*42 o4a Z4 +*42 r +*42 skL +*42 t +*42 O3A +*42 O46 +*42 z1 +*42 } +*43 $" +*43 $- +*43 $3 +*43 $a +*43 $e +*43 *01 } +*43 *12 +*43 *48 +*43 *52 +*43 +2 +*43 -0 +*43 -6 +*43 D2 +*43 K *35 +*43 R3 +*43 T6 +*43 [ { +*43 ] *20 +*43 ^7 O18 +*43 ^8 '5 +*43 ^y *23 +*43 i2b +*43 i2f +*43 k +*43 o4l +*43 o9p +*43 s25 +*43 skC +*43 suo +*43 t -5 +*43 t { +*43 O53 +*43 z1 +*43 z4 *45 -*45$1-4 -*45$8 -*45*03 -*45*35 -*45*62 -*45*71 -*45-2 -*45-7 -*45-7^0 -*45D0 -*45R4 -*45Z1 -*45Z2 -*45^1 -*45^p -*45i1,Z2 -*45i8' -*45o0g -*45o0n -*45o2y -*45o39 -*45o3g -*45o4M -*45o4h -*45o69 -*45o6` -*45p1 -*45r -*45s2_ -*45sl8 -*45so9 -*45u -*45O04 -*45O08z4 -*45O32 -*45O52} -*45z1 -*45z2{ -*45{*25 +*45 $1 -4 +*45 $8 +*45 *03 +*45 *35 +*45 *62 +*45 *71 +*45 -2 +*45 -7 +*45 -7 ^0 +*45 D0 +*45 R4 +*45 Z1 +*45 Z2 +*45 ^1 +*45 ^p +*45 i1, Z2 +*45 i8' +*45 o0g +*45 o0n +*45 o2y +*45 o39 +*45 o3g +*45 o4M +*45 o4h +*45 o69 +*45 o6` +*45 p1 +*45 r +*45 s2_ +*45 sl8 +*45 so9 +*45 u +*45 O04 +*45 O08 z4 +*45 O32 +*45 O52 } +*45 z1 +*45 z2 { +*45 { *25 *46 -*46$_D4 -*46$d -*46$v -*46'6 -*46*16 -*46*23 -*46*25 -*46*60 -*46+4 -*46-4 -*46-7 -*46D1 -*46D4 -*46L7 -*46T0 -*46T5 -*46Z1 -*46[ -*46] -*46^P -*46i58 -*46i5L$9 -*46i5] -*46i5g -*46l -*46o2d -*46o54 -*46o7E -*46s6b -*46O05 -*46O24] -*46O34$C -*46{ -*46}'6 +*46 $_ D4 +*46 $d +*46 $v +*46 '6 +*46 *16 +*46 *23 +*46 *25 +*46 *60 +*46 +4 +*46 -4 +*46 -7 +*46 D1 +*46 D4 +*46 L7 +*46 T0 +*46 T5 +*46 Z1 +*46 [ +*46 ] +*46 ^P +*46 i58 +*46 i5L $9 +*46 i5] +*46 i5g +*46 l +*46 o2d +*46 o54 +*46 o7E +*46 s6b +*46 O05 +*46 O24 ] +*46 O34 $C +*46 { +*46 } '6 *47 -*47$t -*47*34 -*47*36 -*47*58 -*47*65 -*47*67 -*47*75 -*47-9 -*47C*81 -*47Co2q -*47D4 -*47L1O06 -*47T4 -*47Z1 -*47Z1O71 -*47o4v -*47z3 +*47 $t +*47 *34 +*47 *36 +*47 *58 +*47 *65 +*47 *67 +*47 *75 +*47 -9 +*47 C *81 +*47 C o2q +*47 D4 +*47 L1 O06 +*47 T4 +*47 Z1 +*47 Z1 O71 +*47 o4v +*47 z3 *48 -*48'6+5 -*48*08 -*48*86 -*48T7 -*48Z1 -*48[ -*48^9 -*48i2nO52 -*48l -*48tD1 -*48O07 -*48O43 -*48O43C -*48z1 +*48 '6 +5 +*48 *08 +*48 *86 +*48 T7 +*48 Z1 +*48 [ +*48 ^9 +*48 i2n O52 +*48 l +*48 t D1 +*48 O07 +*48 O43 +*48 O43 C +*48 z1 *49 -*49$RO29 -*49'9 -*49^, -*49swh -*49O14 -*49O24 -*49O47L4 -*49O53 +*49 $R O29 +*49 '9 +*49 ^, +*49 swh +*49 O14 +*49 O24 +*49 O47 L4 +*49 O53 *4A -*4A*74O65 -*4Bi8/k -*4BO16 -*4BO19 -*4BO63 -*50$0Z1 -*50$e -*50*02 -*50*25^_ -*50*31 -*50*41 -*50+0 -*50+2 -*50+3{ -*50-4 -*50L5 -*50R5 -*50Z1O32 -*50Z4O4B -*50cK -*50i0B -*50o0[ -*50o34 -*50o3j -*50o3l -*50o3t -*50o6L -*50to6Z -*50u -*50O16 -*50O18 -*50O23 -*50O26 -*50O32 -*50O43 -*50O51 -*50O53 -*50O56 -*50z1 -*50{ -*51$D -*51$z -*51*14 -*51*25] -*51*31 -*51*37 -*51*52 -*51*54 -*51+1 -*51-0 -*51-3 -*51C -*51D1*12 -*51D2 -*51K -*51KR6 -*51R1 -*51T6 -*51Z1O53 -*51Z3O23 -*51[ -*51^' -*51^H+7 -*51^o -*51i0d -*51i1g -*51o71D5 -*51rK -*51O32*30 -*51O35 -*51{ -*51{+6 -*52$3 -*52$9 -*52$?*63 -*52$e -*52'6 -*52*24 -*52*53u -*52*70 -*52+1 -*52+6 -*52L0 -*52Z1 -*52Z2 -*52[k -*52^b -*52^p -*52c] -*52d -*52i13^J -*52o3k -*52o5 -*52o5B -*52s3vD1 -*52se0 -*52shl -*52srd] -*52O04 -*52O12 -*52O13p1 -*52O56 -*52O61 -*52z1 -*53$L -*53$N -*53$` -*53$g -*53$y -*53'5saj -*53*12 -*53*12L5 -*53*20 -*53*46 -*53*50 -*53*72z2 -*53+0 -*53+8 -*53-4 -*53-7 -*53@z*35 -*53C -*53D3 -*53L7u -*53R5 -*53R6 -*53T4 -*53T5 -*53[ -*53] -*53^d -*53f -*53i32 -*53o0z -*53o1$ -*53o15 -*53o8o -*53p1 -*53p2 -*53s5s -*53sbm -*53sbn -*53smb -*53sun -*53sur -*53t^m -*53O13 -*53O52T5 -*53O5B -*53OB2 -*53z1 -*54$3 -*54'B -*54*35t -*54*71'5 -*54*74 -*54*86 -*54+0 -*54+7 -*54-4 -*54-8 -*54C -*54D2 -*54D6$n -*54D7 -*54^0 -*54^9{ -*54^Z -*54^b -*54^c'7 -*54c -*54i1L -*54i35$a -*54i6t -*54l -*54o0K -*54o3 -*54o3l -*54o4q -*54o5m -*54o6h -*54o7_ -*54rZ4 -*54svN -*54syn -*54usBN -*54O12 -*54O23 -*54O52@p -*54O64 -*54} +*4A *74 O65 +*4B i8/ k +*4B O16 +*4B O19 +*4B O63 +*50 $0 Z1 +*50 $e +*50 *02 +*50 *25 ^_ +*50 *31 +*50 *41 +*50 +0 +*50 +2 +*50 +3 { +*50 -4 +*50 L5 +*50 R5 +*50 Z1 O32 +*50 Z4 O4B +*50 c K +*50 i0B +*50 o0[ +*50 o34 +*50 o3j +*50 o3l +*50 o3t +*50 o6L +*50 t o6Z +*50 u +*50 O16 +*50 O18 +*50 O23 +*50 O26 +*50 O32 +*50 O43 +*50 O51 +*50 O53 +*50 O56 +*50 z1 +*50 { +*51 $D +*51 $z +*51 *14 +*51 *25 ] +*51 *31 +*51 *37 +*51 *52 +*51 *54 +*51 +1 +*51 -0 +*51 -3 +*51 C +*51 D1 *12 +*51 D2 +*51 K +*51 K R6 +*51 R1 +*51 T6 +*51 Z1 O53 +*51 Z3 O23 +*51 [ +*51 ^' +*51 ^H +7 +*51 ^o +*51 i0d +*51 i1g +*51 o71 D5 +*51 r K +*51 O32 *30 +*51 O35 +*51 { +*51 { +6 +*52 $3 +*52 $9 +*52 $? *63 +*52 $e +*52 '6 +*52 *24 +*52 *53 u +*52 *70 +*52 +1 +*52 +6 +*52 L0 +*52 Z1 +*52 Z2 +*52 [ k +*52 ^b +*52 ^p +*52 c ] +*52 d +*52 i13 ^J +*52 o3k +*52 o5 +*52 o5B +*52 s3v D1 +*52 se0 +*52 shl +*52 srd ] +*52 O04 +*52 O12 +*52 O13 p1 +*52 O56 +*52 O61 +*52 z1 +*53 $L +*53 $N +*53 $` +*53 $g +*53 $y +*53 '5 saj +*53 *12 +*53 *12 L5 +*53 *20 +*53 *46 +*53 *50 +*53 *72 z2 +*53 +0 +*53 +8 +*53 -4 +*53 -7 +*53 @z *35 +*53 C +*53 D3 +*53 L7 u +*53 R5 +*53 R6 +*53 T4 +*53 T5 +*53 [ +*53 ] +*53 ^d +*53 f +*53 i32 +*53 o0z +*53 o1$ +*53 o15 +*53 o8o +*53 p1 +*53 p2 +*53 s5s +*53 sbm +*53 sbn +*53 smb +*53 sun +*53 sur +*53 t ^m +*53 O13 +*53 O52 T5 +*53 O5B +*53 OB2 +*53 z1 +*54 $3 +*54 'B +*54 *35 t +*54 *71 '5 +*54 *74 +*54 *86 +*54 +0 +*54 +7 +*54 -4 +*54 -8 +*54 C +*54 D2 +*54 D6 $n +*54 D7 +*54 ^0 +*54 ^9 { +*54 ^Z +*54 ^b +*54 ^c '7 +*54 c +*54 i1L +*54 i35 $a +*54 i6t +*54 l +*54 o0K +*54 o3 +*54 o3l +*54 o4q +*54 o5m +*54 o6h +*54 o7_ +*54 r Z4 +*54 svN +*54 syn +*54 u sBN +*54 O12 +*54 O23 +*54 O52 @p +*54 O64 +*54 } *56 -*56$1 -*56$3 -*56$4 -*56'7 -*56'A -*56*12z3 -*56*13u -*56*30 -*56*76 -*56*81O03 -*56*85 -*56+4 -*56+5 -*56-4 -*56-6 -*56Cz3 -*56D0 -*56L0L5 -*56R4 -*56Z2 -*56^a -*56^l -*56l -*56o2l -*56o5d -*56o5j -*56o69 -*56o6b -*56o6q -*56r -*56s40 -*56se2 -*56sgo -*56O0Ap3 -*56}-6 +*56 $1 +*56 $3 +*56 $4 +*56 '7 +*56 'A +*56 *12 z3 +*56 *13 u +*56 *30 +*56 *76 +*56 *81 O03 +*56 *85 +*56 +4 +*56 +5 +*56 -4 +*56 -6 +*56 C z3 +*56 D0 +*56 L0 L5 +*56 R4 +*56 Z2 +*56 ^a +*56 ^l +*56 l +*56 o2l +*56 o5d +*56 o5j +*56 o69 +*56 o6b +*56 o6q +*56 r +*56 s40 +*56 se2 +*56 sgo +*56 O0A p3 +*56 } -6 *57 -*57$% -*57$0 -*57$9 -*57$a -*57$n -*57$oO56 -*57*06 -*57*25 -*57*36] -*57*46 -*57D8 -*57T5D3 -*57Z1 -*57Z2o4( -*57c -*57cD6 -*57i3s -*57i8b -*57i9mO18 -*57o0C -*57o5R -*57o7a -*57o7s -*57p1 -*57O06 -*57O16 -*57O32 -*57} +*57 $% +*57 $0 +*57 $9 +*57 $a +*57 $n +*57 $o O56 +*57 *06 +*57 *25 +*57 *36 ] +*57 *46 +*57 D8 +*57 T5 D3 +*57 Z1 +*57 Z2 o4( +*57 c +*57 c D6 +*57 i3s +*57 i8b +*57 i9m O18 +*57 o0C +*57 o5R +*57 o7a +*57 o7s +*57 p1 +*57 O06 +*57 O16 +*57 O32 +*57 } *58 -*58'8 -*58*76 -*58D4 -*58D5s13 -*58D7 -*58]{ -*58l -*58o5M -*58O06 -*58O25Z1 -*58O91 +*58 '8 +*58 *76 +*58 D4 +*58 D5 s13 +*58 D7 +*58 ] { +*58 l +*58 o5M +*58 O06 +*58 O25 Z1 +*58 O91 *59 -*59*56^_ -*59C^$ -*59D2 -*59Z1O53 -*59i6Vk -*59o0!} -*59o90 -*59O25 -*59O27 -*59O42 +*59 *56 ^_ +*59 C ^$ +*59 D2 +*59 Z1 O53 +*59 i6V k +*59 o0! } +*59 o90 +*59 O25 +*59 O27 +*59 O42 *5A -*5AO06 -*5AO08D2 -*5AO36 -*5AO45Z2 -*5AO53@M -*5AO73 -*60$3 -*60$s -*60*02 -*60*07 -*60*54 -*60-1 -*60-5 -*60-8 -*60C -*60Co2k -*60D0 -*60D1 -*60D6 -*60^A -*60^S -*60c -*60kT5 -*60o3R -*60o6l -*60O03 -*60O34u -*60O35 -*60O51 -*60O54 -*60z2O65 -*60}D4 -*61$[o8e -*61'4 -*61'5 -*61*21 -*61-1 -*61-4 -*61@c$] -*61D1 -*61D6 -*61T0 -*61T2 -*61^3*43 -*61^R -*61^l -*61i6n -*61o6* -*61o6O -*61o6g -*61o7u -*61sd{O52 -*61O03k -*61O12 -*61O21*13 -*61O54 -*61O61+6 -*62*46o18 -*62*52 -*62*73 -*62+2 -*62-0 -*62-2 -*62T9O35 -*62^Lz1 -*62i0z -*62i8q -*62l -*62o12 -*62o2k -*62o2s -*62o61} -*62O01r -*62O02 -*62O03 -*62O32 -*62O38 -*62O43D4 -*62O45 -*62O46 -*62O51 -*62z3 -*63$j -*63+1 -*63+7 -*63D3 -*63D7 -*63L6O62 -*63T2 -*63Z1 -*63Z3 -*63]'5 -*63^Gi0b -*63csv# -*63i2| -*63i5"*49 -*63o1l -*63o3q -*63o4h -*63o5t -*63o6^ -*63slp -*63u -*63uo2` -*63O53 -*63} -*64$x -*64'5 -*64*20 -*64*34 -*64*65[ -*64D0+1 -*64K -*64R3 -*64^cO26 -*64^j -*64^r -*64o3`$P -*64o3i -*64o66 -*64O43@p -*64O53 -*64O61 -*64O72 -*64O73 -*65$! -*65$n -*65'9 -*65*35 -*65*51 -*65*73 -*65*8A -*65+3 -*65-5 -*65D3 -*65R3 -*65Z3 -*65[{ -*65^+ -*65^S -*65^z -*65i4h -*65i66 -*65i7w -*65l$* -*65o0r -*65o2t*24 -*65o67 -*65o6` -*65O14Z1 -*65O42 -*65O65 +*5A O06 +O08 D2 +*5A O36 +*5A O45 Z2 +*5A O53 @M +*5A O73 +*60 $3 +*60 $s +*60 *02 +*60 *07 +*60 *54 +*60 -1 +*60 -5 +*60 -8 +*60 C +*60 C o2k +*60 D0 +*60 D1 +*60 D6 +*60 ^A +*60 ^S +*60 c +*60 k T5 +*60 o3R +*60 o6l +*60 O03 +*60 O34 u +*60 O35 +*60 O51 +*60 O54 +*60 z2 O65 +*60 } D4 +*61 $[ o8e +*61 '4 +*61 '5 +*61 *21 +*61 -1 +*61 -4 +*61 @c $] +*61 D1 +*61 D6 +*61 T0 +*61 T2 +*61 ^3 *43 +*61 ^R +*61 ^l +*61 i6n +*61 o6* +*61 o6O +*61 o6g +*61 o7u +*61 sd{ O52 +*61 O03 k +*61 O12 +*61 O21 *13 +*61 O54 +*61 O61 +6 +*62 *46 o18 +*62 *52 +*62 *73 +*62 +2 +*62 -0 +*62 -2 +*62 T9 O35 +*62 ^L z1 +*62 i0z +*62 i8q +*62 l +*62 o12 +*62 o2k +*62 o2s +*62 o61 } +*62 O01 r +*62 O02 +*62 O03 +*62 O32 +*62 O38 +*62 O43 D4 +*62 O45 +*62 O46 +*62 O51 +*62 z3 +*63 $j +*63 +1 +*63 +7 +*63 D3 +*63 D7 +*63 L6 O62 +*63 T2 +*63 Z1 +*63 Z3 +*63 ] '5 +*63 ^G i0b +*63 c sv# +*63 i2| +*63 i5" *49 +*63 o1l +*63 o3q +*63 o4h +*63 o5t +*63 o6^ +*63 slp +*63 u +*63 u o2` +*63 O53 +*63 } +*64 $x +*64 '5 +*64 *20 +*64 *34 +*64 *65 [ +*64 D0 +1 +*64 K +*64 R3 +*64 ^c O26 +*64 ^j +*64 ^r +*64 o3` $P +*64 o3i +*64 o66 +*64 O43 @p +*64 O53 +*64 O61 +*64 O72 +*64 O73 +*65 $! +*65 $n +*65 '9 +*65 *35 +*65 *51 +*65 *73 +*65 *8A +*65 +3 +*65 -5 +*65 D3 +*65 R3 +*65 Z3 +*65 [ { +*65 ^+ +*65 ^S +*65 ^z +*65 i4h +*65 i66 +*65 i7w +*65 l $* +*65 o0r +*65 o2t *24 +*65 o67 +*65 o6` +*65 O14 Z1 +*65 O42 +*65 O65 *67 -*67$1 -*67$e -*67'7scu -*67*56 -*67*86 -*67-5 -*67@b -*67D9 -*67K -*67R4 -*67T3 -*67Z2 -*67^V -*67c -*67i20i6v -*67i65 -*67i6; -*67k -*67o4Z -*67o6- -*67o75 -*67o7r -*67r -*67s- -*67s1/ +*67 $1 +*67 $e +*67 '7 scu +*67 *56 +*67 *86 +*67 -5 +*67 @b +*67 D9 +*67 K +*67 R4 +*67 T3 +*67 Z2 +*67 ^V +*67 c +*67 i20 i6v +*67 i65 +*67 i6; +*67 k +*67 o4Z +*67 o6- +*67 o75 +*67 o7r +*67 r +*67 s- +*67 s1/ *68 -*68*20 -*68*B3*85 -*68-6 -*68D6 -*68Z1 -*68o0k -*68o6r -*68q -*68O42 -*68O43^j -*68O52{ +*68 *20 +*68 *B3 *85 +*68 -6 +*68 D6 +*68 Z1 +*68 o0k +*68 o6r +*68 q +*68 O42 +*68 O43 ^j +*68 O52 { *69 -*69'8 -*69'A -*69o67 -*69o95 -*69O92 -*6A$GO18 -*6AD7 -*6As70O34 -*6AO37 -*6AO94 -*6BO16 -*6BO84 -*70$"^! -*70$2 -*70'5 -*70*05 -*70*2A -*70+9O56 -*70T1L0 -*70^Q -*70i4g -*70t -*70O01 -*70O05o28 -*70O52*41 -*70O53 -*70O72 -*70z1 -*71'7 -*71'9 -*71*29 -*71*62 -*71-7 -*71Cl -*71D2r -*71D6 -*71[ -*71c -*71cO38 -*71i7+ -*71o4= -*71o68 -*71O02 -*71O03 -*71O04 -*71O13 -*71O35 -*71O54Z3 -*72$q -*72'4 -*72'6 -*72-2 -*72-4 -*72D7 -*72i3r -*72i7sz2 -*72o3w -*72o7r -*72o8h -*72s32 -*72O03 -*72O23 -*72O28+3 -*72O39 -*72O53 -*72O59 -*72O73 -*73$_ -*73$g -*73$m -*73*02o6k -*73*72C -*73D1 -*73L5 -*73[ -*73^s -*73^z -*73o0d -*73o3m -*73o5zO03 -*73r -*73O04 -*73O21 -*73O31 -*73O38^y -*73O62 -*73O74 -*73O7A -*73O96 -*74$k -*74+4 -*74+5 -*74-3 -*74D1 -*74L5 -*74Z2 -*74Z3 -*74i57 -*74i5_ -*74i5r -*74k -*74k$8 -*74o5 -*74o85 -*74o9- -*74s6a -*74sds -*74uO72 -*74O31 -*74O34 -*74O54 -*74O56 -*74O64 -*74O6A -*74O6B -*75$5 -*75$m -*75@?'7 -*75D1 -*75D4 -*75D6 -*75T5 -*75[ -*75i3|^W -*75i6e -*75o0J -*75o1h -*75o6e -*75o7R -*75o87 -*75sGwO41 -*75si^ -*75t -*75u*76 -*75O47Z1 -*75O53R5 -*75{ -*76$5 -*76$h -*76$o -*76'8 -*76'B -*76*31 -*76*34 -*76*36 -*76*47 -*76+5 -*76+6 -*76+6O42 -*76+7 -*76+8 -*76-9 -*76]sti -*76^2 -*76d -*76i44 -*76i5 -*76i6r -*76i7e -*76i7u -*76l -*76o2r -*76o5t -*76o6F -*76o6a -*76o6g -*76o7! -*76s17 -*76s51 -*76scv -*76O1Ad -*76O21 -*76O41 -*76O42 -*76O52 -*76O63Z4 -*76O72$t -*76O74 -*76z1 -*76} +*69 '8 +*69 'A +*69 o67 +*69 o95 +*69 O92 +*6A $G O18 +*6A D7 +*6A s70 O34 +*6A O37 +*6A O94 +*6B O16 +*6B O84 +*70 $" ^! +*70 $2 +*70 '5 +*70 *05 +*70 *2A +*70 +9 O56 +*70 T1 L0 +*70 ^Q +*70 i4g +*70 t +*70 O01 +O05 o28 +*70 O52 *41 +*70 O53 +*70 O72 +*70 z1 +*71 '7 +*71 '9 +*71 *29 +*71 *62 +*71 -7 +*71 l +*71 D2 r +*71 D6 +*71 [ +*71 c +*71 c O38 +*71 i7+ +*71 o4= +*71 o68 +*71 O02 +*71 O03 +*71 O04 +*71 O13 +*71 O35 +*71 O54 Z3 +*72 $q +*72 '4 +*72 '6 +*72 -2 +*72 -4 +*72 D7 +*72 i3r +*72 i7s z2 +*72 o3w +*72 o7r +*72 o8h +*72 s32 +*72 O03 +*72 O23 +*72 O28 +3 +*72 O39 +*72 O53 +*72 O59 +*72 O73 +*73 $_ +*73 $g +*73 $m +*73 *02 o6k +*73 *72 C +*73 D1 +*73 L5 +*73 [ +*73 ^s +*73 ^z +*73 o0d +*73 o3m +*73 o5z O03 +*73 r +*73 O04 +*73 O21 +*73 O31 +*73 O38 ^y +*73 O62 +*73 O74 +*73 O7A +*73 O96 +*74 $k +*74 +4 +*74 +5 +*74 -3 +*74 D1 +*74 L5 +*74 Z2 +*74 Z3 +*74 i57 +*74 i5_ +*74 i5r +*74 k +*74 k $8 +*74 o5 +*74 o85 +*74 o9- +*74 s6a +*74 sds +*74 u O72 +*74 O31 +*74 O34 +*74 O54 +*74 O56 +*74 O64 +*74 O6A +*74 O6B +*75 $5 +*75 $m +*75 @? '7 +*75 D1 +*75 D4 +*75 D6 +*75 T5 +*75 [ +*75 i3| ^W +*75 i6e +*75 o0J +*75 o1h +*75 o6e +*75 o7R +*75 o87 +*75 sGw O41 +*75 si^ +*75 t +*75 u *76 +*75 O47 Z1 +*75 O53 R5 +*75 { +*76 $5 +*76 $h +*76 $o +*76 '8 +*76 'B +*76 *31 +*76 *34 +*76 *36 +*76 *47 +*76 +5 +*76 +6 +*76 +6 O42 +*76 +7 +*76 +8 +*76 -9 +*76 ] sti +*76 ^2 +*76 d +*76 i44 +*76 i5 +*76 i6r +*76 i7e +*76 i7u +*76 l +*76 o2r +*76 o5t +*76 o6F +*76 o6a +*76 o6g +*76 o7! +*76 s17 +*76 s51 +*76 scv +*76 O1A d +*76 O21 +*76 O41 +*76 O42 +*76 O52 +*76 O63 Z4 +*76 O72 $t +*76 O74 +*76 z1 +*76 } *78 -*78$6 -*78$9 -*78$a -*78$w -*78'9 -*78*31 -*78*62 -*78+6 -*78-6 -*78-A -*78T3 -*78Z1 -*78^n -*78i6k -*78o4! -*78s71 -*78O31 -*78O53 -*78O62 +*78 $6 +*78 $9 +*78 $a +*78 $w +*78 '9 +*78 *31 +*78 *62 +*78 +6 +*78 -6 +*78 -A +*78 T3 +*78 Z1 +*78 ^n +*78 i6k +*78 o4! +*78 s71 +*78 O31 +*78 O53 +*78 O62 *79 -*79'A -*79*95 -*79-8 -*79-9 -*79i9n -*79O36+7 -*79O81 +*79 'A +*79 *95 +*79 -8 +*79 -9 +*79 i9n +*79 O36 +7 +*79 O81 *7A -*7A'A -*7AD4'5 -*7AO53 -*7AO62 -*7AO64 -*7AO92 -*7BO17 -*7BO27 -*7BO64 -*80'6 -*80*38 -*80Z4O47 -*80o79 -*80O04 -*80O28D3 -*80O31 -*80O36 -*80O45l -*81$f -*81'8 -*81+8 -*81T6o8$ -*81t'7 -*81tO27 -*82$:*41 -*82'A -*82T5 -*82T8O38 -*82i3l -*82l -*82o84 -*82O06 -*82O39 -*82O45 -*82O72 -*82O81 -*83'5 -*83*47 -*83+3 -*83D5 -*83Z1O54 -*83i54 -*83o1} -*83O04 -*83O54 -*83O59 -*83O64-7 -*83O81 -*84'6 -*84D8 -*84^s'8 -*84i6c -*84o84 -*84u -*84O06 -*84O23 -*84O53 -*84O5A -*85'6 -*85'7 -*85*63 -*85+1D8 -*85+5 -*85D8 -*85Z1 -*85^"} -*85i7e -*85O23 -*85O42 -*86$3 -*86$r -*86'8 -*86*50 -*86*70O64 -*86*95 -*86+7 -*86D3 -*86R0 -*86o0]i3x -*86o30 -*86o5 -*86o7j -*86o8s -*86sr5 -*86O14 -*86O34 -*86O41 -*86O57-8 -*87$1 -*87*36 -*87+8 -*87c -*87i88 -*87o0p -*87o76 -*87o7z -*87o81 -*87o8A -*87s81 -*87sti -*87O26t -*87O72^x -*87{t +*7A 'A +D4 '5 +*7A O53 +*7A O62 +*7A O64 +*7A O92 +*7B O17 +*7B O27 +*7B O64 +*80 '6 +*80 *38 +*80 Z4 O47 +*80 o79 +*80 O04 +*80 O28 D3 +*80 O31 +*80 O36 +*80 O45 l +*81 $f +*81 '8 +*81 +8 +*81 T6 o8$ +*81 t '7 +*81 t O27 +*82 $: *41 +*82 'A +*82 T5 +*82 T8 O38 +*82 i3l +*82 l +*82 o84 +*82 O06 +*82 O39 +*82 O45 +*82 O72 +*82 O81 +*83 '5 +*83 *47 +*83 +3 +*83 D5 +*83 Z1 O54 +*83 i54 +*83 o1} +*83 O04 +*83 O54 +*83 O59 +*83 O64 -7 +*83 O81 +*84 '6 +*84 D8 +*84 ^s '8 +*84 i6c +*84 o84 +*84 u +*84 O06 +*84 O23 +*84 O53 +*84 O5A +*85 '6 +*85 '7 +*85 *63 +*85 +1 D8 +*85 +5 +*85 D8 +*85 Z1 +*85 ^" } +*85 i7e +*85 O23 +*85 O42 +*86 $3 +*86 $r +*86 '8 +*86 *50 +*86 *70 O64 +*86 *95 +*86 +7 +*86 D3 +*86 R0 +*86 o0] i3x +*86 o30 +*86 o5 +*86 o7j +*86 o8s +*86 sr5 +*86 O14 +*86 O34 +*86 O41 +*86 O57 -8 +*87 $1 +*87 *36 +*87 +8 +*87 c +*87 i88 +*87 o0p +*87 o76 +*87 o7z +*87 o81 +*87 o8A +*87 s81 +*87 sti +*87 O26 t +*87 O72 ^x +*87 { t *89 -*89'5$g -*89+8 -*89-7 -*89D5 -*89Z1 -*89[ -*89^q -*89o7p -*89O18 -*89O46'9 -*89O63O04 -*89} +'5 $g +*89 +8 +*89 -7 +*89 D5 +*89 Z1 +*89 [ +*89 ^q +*89 o7p +*89 O18 +*89 O46 '9 +*89 O63 O04 +*89 } *8A -*8AD8 -*8AoB3 -*8As6VO54 -*8At -*8AO38d -*8B*BA -*8Bur -*8BO38 -*8BO64 -*90L0 -*90i1t*14 -*90o9D -*90O1A -*90O26 -*91*37 -*91R3 -*91R8 -*91o1a -*91oA7 -*91O43 -*91O67 -*92$g'5 -*92'9 -*92t -*92O18 -*92O46 -*92O56 -*92O57 -*92O58 -*93'9 -*93cO56 -*93O07 -*93O21 -*93O48 -*94'8 -*94*89^T -*94o0t -*94uO56 -*94O06 -*94O34 -*94O61 -*94O73 -*94O85Z1 -*95*27 -*95*5A -*95*87 -*95o93 -*95uD8 -*95O19u -*95O76 -*96D7 -*96O02 -*96O15 -*96O52 -*97$q -*97*21 -*97*32O34 -*97D1 -*97c -*97i1FO62 -*97o93 -*97o95 -*97syi -*97u -*97O07 -*97O36 -*98$eO52 -*98'9 -*98*85 -*98+0 -*98+1 -*98+9 -*98D9*32 -*98^1 -*98o7 -*98o8_ -*98O71 -*9A$3 -*9A$mO83 -*9A*89 -*9Ao9J -*9As1c -*9AO46saC -*9AO73 -*9B*68 -*9BL2L3 -*9B^gO2A -*9BO62 -*A0$:DA -*A0'6 -*A0*5AO46 -*A0-7'5 -*A0O4B -*A0O56 -*A0O69O5A -*A0{ -*A1'6 -*A1D1 -*A1RA -*A1O07 -*A1O16 -*A1O59t -*A1O83 +*8A D8 +*8A oB3 +*8A s6V O54 +*8A t +*8A O38 d +*8B *BA +*8B u r +*8B O38 +*8B O64 +*90 L0 +*90 i1t *14 +*90 o9D +*90 O1A +*90 O26 +*91 *37 +*91 R3 +*91 R8 +*91 o1a +*91 oA7 +*91 O43 +*91 O67 +*92 $g '5 +*92 '9 +*92 t +*92 O18 +*92 O46 +*92 O56 +*92 O57 +*92 O58 +*93 '9 +*93 c O56 +*93 O07 +*93 O21 +*93 O48 +*94 '8 +*94 *89 ^T +*94 o0t +*94 u O56 +*94 O06 +*94 O34 +*94 O61 +*94 O73 +*94 O85 Z1 +*95 *27 +*95 *5A +*95 *87 +*95 o93 +*95 u D8 +*95 O19 u +*95 O76 +*96 D7 +*96 O02 +*96 O15 +*96 O52 +*97 $q +*97 *21 +*97 *32 O34 +*97 D1 +*97 c +*97 i1F O62 +*97 o93 +*97 o95 +*97 syi +*97 u +*97 O07 +*97 O36 +*98 $e O52 +O81 '9 +*98 *85 +*98 +0 +*98 +1 +*98 +9 +*98 D9 *32 +*98 ^1 +*98 o7 +*98 o8_ +*98 O71 +*9A $3 +$m O83 +*9A *89 +*9A o9J +*9A s1c +*9A O46 saC +*9A O73 +*9B *68 +*9B L2 L3 +*9B ^g O2A +*9B O62 +*A0 $: DA +*A0 '6 +*A0 *5A O46 +*A0 '5 +*A0 O4B +*A0 O56 +*A0 O69 O5A +*A0 { +*A1 '6 +*A1 D1 +*A1 RA +*A1 O07 +*A1 O16 +*A1 O59 t +*A1 O83 *A2 -*A2'8 -*A2O38z2 -*A2O49 -*A2O76 -*A3'7 -*A3i9YO52 -*A3O06 -*A3O75 -*A3O93 -*A4'9 -*A4'A-4 -*A4R8 -*A4O05 -*A4O86 -*A5*B7'8 -*A5o2n -*A5O3A$I -*A5O76 -*A6'7 -*A6*A9 -*A6l -*A6O26 -*A6O42 -*A7'8 -*A7[ -*A7^C -*A8[ -*A8l -*A8oAe -*A8s0x -*A8O35 +*A2 '8 +*A2 O38 z2 +*A2 O49 +*A2 O76 +*A3 '7 +*A3 i9Y O52 +*A3 O06 +*A3 O75 +*A3 O93 +*A4 '9 +*A4 'A -4 +*A4 R8 +*A4 O05 +*A4 O86 +*A5 *B7 '8 +*A5 o2n +*A5 O3A $I +*A5 O76 +*A6 '7 +*A6 *A9 +*A6 l +*A6 O26 +*A6 O42 +*A7 '8 +*A7 [ +*A7 ^C +*A8 [ +*A8 l +*A8 oAe +*A8 s0x +*A8 O35 *A9 -*A9'AZ2 -*A9o9n -*A9oA2 -*A9s05 -*A9O52 +*A9 'A Z2 +*A9 o9n +*A9 oA2 +*A9 s05 +*A9 O52 *AB -*ABT7'A -*ABO68+6 -*B0$3'6 -*B0'8 -*B1'6$R -*B1O03 -*B1O45 -*B2'7 -*B2'8 -*B4'7 -*B5o8HR8 -*B5O76 -*B5OA1 -*B6'7[ -*B6^lO69 +T7 'A +*AB O68 +6 +*B0 $3 '6 +*B0 '8 +*B1 '6 $R +*B1 O03 +*B1 O45 +*B2 '7 +*B2 '8 +*B4 '7 +*B5 o8H R8 +*B5 O76 +*B5 OA1 +*B6 '7 [ +*B6 ^l O69 *B7 -*B7'8 -*B7O85 -*B8*A9 -*B8f'A -*B9'A -*B9*30i4l -*B9o2o -*B9s29 -*B9O65 -*BAD9 -*BAc -*BAiA_ -*BAO02 -*BAO83 +*B7 '8 +*B7 O85 +*B8 *A9 +*B8 f 'A +*B9 'A +*B9 *30 i4l +*B9 o2o +*B9 s29 +*B9 O65 +*BA D9 +*BA c +*BA iA_ +*BA O02 +*BA O83 +0 -+0$! -+0$$ -+0$1o2k -+0$2 -+0$= -+0$C -+0$V -+0$` -+0$d -+0$i -+0$j -+0$l -+0$s -+0'2 -+0'5 -+0'5k -+0'6 -+0'7 -+0'B -+0*05 -+0*08 -+0*18 -+0*20 -+0*31 -+0*32 -+0*32} -+0*37 -+0*58 -+0*86 -+0+0 -+0+0+0 -+0+0+0+0 -+0+1 -+0+1+2 -+0+1+2+3 -+0+3 -+0+6 -+0-1 -+0-3 -+0@t -+0@z -+0C -+0D2 -+0D3 -+0D4 -+0D8 -+0L4 -+0L5t -+0L7 -+0R1 -+0R4 -+0R6 -+0T2 -+0Z1 -+0Z2 -+0Z5@j -+0^$ -+0^% -+0^/ -+0^1 -+0^3 -+0^9 -+0^B -+0^L -+0^N -+0^a -+0^g -+0^i -+0^p -+0^r -+0f -+0i0z -+0i1l -+0i2j -+0i4z -+0i5t -+0i6+ -+0i64O3A -+0i6J -+0i6v -+0l -+0o1i -+0o2q -+0o33 -+0o3v -+0o44 -+0o4i -+0o4o -+0o5P -+0o5t -+0o6& -+0o64 -+0o7n -+0o83 -+0o8m -+0p1 -+0p2'6 -+0q -+0qo3R -+0s1y+1 -+0s23 -+0s4k -+0s7S -+0sc. -+0ssW -+0t -+0O12 -+0O12R8 -+0O13 -+0O24 -+0O25 -+0O25D3 -+0O38Z4 -+0O42 -+0O51@m -+0O52 -+0O53O73 -+0O56 -+0O72 -+0O82 -+0O92 -+0OA1 -+0OB3O19 -+0z1 -+0z2 -+0z3 -+0z4 -+0z5 -+0z5@x -+0{Z3 -+0} -+0}o6Q ++0 $! ++0 $$ ++0 $1 o2k ++0 $2 ++0 $= ++0 $C ++0 $V ++0 $` ++0 $d ++0 $i ++0 $j ++0 $l ++0 $s ++0 '2 ++0 '5 ++0 '5 k ++0 '6 ++0 '7 ++0 'B ++0 *05 ++0 *08 ++0 *18 ++0 *20 ++0 *31 ++0 *32 ++0 *32 } ++0 *37 ++0 *58 ++0 *86 ++0 +0 ++0 +0 +0 ++0 +0 +0 +0 ++0 +1 ++0 +1 +2 ++0 +1 +2 +3 ++0 +3 ++0 +6 ++0 -1 ++0 -3 ++0 @t ++0 @z ++0 C ++0 D2 ++0 D3 ++0 D4 ++0 D8 ++0 L4 ++0 L5 t ++0 L7 ++0 R1 ++0 R4 ++0 R6 ++0 T2 ++0 Z1 ++0 Z2 ++0 Z5 @j ++0 ^$ ++0 ^% ++0 ^/ ++0 ^1 ++0 ^3 ++0 ^9 ++0 ^B ++0 ^L ++0 ^N ++0 ^a ++0 ^g ++0 ^i ++0 ^p ++0 ^r ++0 f ++0 i0z ++0 i1l ++0 i2j ++0 i4z ++0 i5t ++0 i6+ ++0 i64 O3A ++0 i6J ++0 i6v ++0 l ++0 o1i ++0 o2q ++0 o33 ++0 o3v ++0 o44 ++0 o4i ++0 o4o ++0 o5P ++0 o5t ++0 o6& ++0 o64 ++0 o7n ++0 o83 ++0 o8m ++0 p1 ++0 p2 '6 ++0 q ++0 q o3R ++0 s1y +1 ++0 s23 ++0 s4k ++0 s7S ++0 sc. ++0 ssW ++0 t ++0 O12 ++0 O12 R8 ++0 O13 ++0 O24 ++0 O25 ++0 O25 D3 ++0 O38 Z4 ++0 O42 ++0 O51 @m ++0 O52 ++0 O53 O73 ++0 O56 ++0 O72 ++0 O82 ++0 O92 ++0 OA1 ++0 OB3 O19 ++0 z1 ++0 z2 ++0 z3 ++0 z4 ++0 z5 ++0 z5 @x ++0 { Z3 ++0 } ++0 } o6Q +1 -+1$' -+1$0 -+1$5 -+1$f -+1$h -+1$i -+1$j -+1$n -+1$p -+1$s -+1$t -+1'2 -+1'5 -+1'7 -+1'B -+1*04slk -+1*06 -+1*14 -+1*91 -+1+1 -+1+1+1 -+1+1+1+1 -+1+2 -+1+2+3 -+1+2+3+4 -+1+3 -+1-4 -+1-5 -+1-8 -+1@B -+1@a -+1CO14 -+1D4-6 -+1D4d -+1D7 -+1D9 -+1KZ2 -+1L2O29 -+1L7 -+1R0 -+1R1 -+1R4 -+1T2 -+1Z1 -+1Z1D3 -+1Z1O01 -+1Z2 -+1Z4 -+1[ -+1^= -+1^DsG! -+1^J -+1^b -+1^e -+1^l -+1^n -+1^z -+1c -+1csrD -+1du -+1f -+1i0h -+1i0i -+1i18 -+1i1l -+1i1u -+1i22 -+1i24 -+1i2g -+1i2xZ1 -+1i3}$< -+1i4X -+1i4a -+1i76 -+1l -+1li5a -+1o0& -+1o0' -+1o0A -+1o0a -+1o0b -+1o0f -+1o0r -+1o25 -+1o2b -+1o2g -+1o3o -+1o8A -+1o8wO12 -+1p1 -+1s.qo2w -+1s0Q -+1sbq -+1sel -+1skw -+1smd -+1srg -+1szl -+1t -+1O23 -+1O24 -+1O28 -+1O42-3 -+1O45 -+1O52 -+1O62 -+1O63 -+1O67[ -+1O92 -+1z1 -+1z2 -+1z3 -+1z4o69 -+1z5O82 -+1{ -+1} ++1 $' ++1 $0 ++1 $5 ++1 $f ++1 $h ++1 $i ++1 $j ++1 $n ++1 $p ++1 $s ++1 $t ++1 '2 ++1 '5 ++1 '7 ++1 'B ++1 *04 slk ++1 *06 ++1 *14 ++1 *91 ++1 +1 ++1 +1 +1 ++1 +1 +1 +1 ++1 +2 ++1 +2 +3 ++1 +2 +3 +4 ++1 +3 ++1 -4 ++1 -5 ++1 -8 ++1 @B ++1 @a ++1 C O14 ++1 D4 -6 ++1 D4 d ++1 D7 ++1 D9 ++1 K Z2 ++1 L2 O29 ++1 L7 ++1 R0 ++1 R1 ++1 R4 ++1 T2 ++1 Z1 ++1 Z1 D3 ++1 Z1 O01 ++1 Z2 ++1 Z4 ++1 [ ++1 ^= ++1 ^D sG! ++1 ^J ++1 ^b ++1 ^e ++1 ^l ++1 ^n ++1 ^z ++1 c ++1 c srD ++1 d u ++1 f ++1 i0h ++1 i0i ++1 i18 ++1 i1l ++1 i1u ++1 i22 ++1 i24 ++1 i2g ++1 i2x Z1 ++1 i3} $< ++1 i4X ++1 i4a ++1 i76 ++1 l ++1 l i5a ++1 o0& ++1 o0' ++1 o0A ++1 o0a ++1 o0b ++1 o0f ++1 o0r ++1 o25 ++1 o2b ++1 o2g ++1 o3o ++1 o8A ++1 o8w O12 ++1 p1 ++1 s.q o2w ++1 s0Q ++1 sbq ++1 sel ++1 skw ++1 smd ++1 srg ++1 szl ++1 t ++1 O23 ++1 O24 ++1 O28 ++1 O42 -3 ++1 O45 ++1 O52 ++1 O62 ++1 O63 ++1 O67 [ ++1 O92 ++1 z1 ++1 z2 ++1 z3 ++1 z4 o69 ++1 z5 O82 ++1 { ++1 } +2 -+2$ -+2$+ -+2$6 -+2$7T7 -+2$Mt -+2$W -+2$f -+2$iq -+2$it -+2$w -+2$y^d -+2'4 -+2*02 -+2*30 -+2*32 -+2*62O5B -+2*75 -+2+0 -+2+2 -+2+2+2 -+2+2+2+2 -+2+3 -+2+3+4 -+2+3+4+5 -+2+5 -+2@0 -+2D1 -+2D3 -+2D5 -+2D5*79 -+2L2 -+2L5 -+2L6u -+2T1d -+2T5z3 -+2Z2 -+2Z3 -+2Z3i22 -+2^# -+2^8 -+2^h -+2^u -+2c -+2d -+2f -+2i2K -+2i2d -+2i4?*53 -+2iA5O38 -+2l -+2l$% -+2li0D -+2o0* -+2o0z -+2o1b -+2o4A -+2o71 -+2oAs -+2p1O23 -+2q -+2sCy -+2sGq -+2sgb -+2sui -+2t*57 -+2up1 -+2O02 -+2O39t -+2O41 -+2O57 -+2z1 -+2z2 -+2z3*08 -+2z3*57 -+2z3D4 -+2z3t -+2z4 -+2z5O81 ++2 $ ++2 $+ ++2 $6 ++2 $7 T7 ++2 $M t ++2 $W ++2 $f ++2 $i q ++2 $i t ++2 $w ++2 $y ^d ++2 '4 ++2 *02 ++2 *30 ++2 *32 ++2 *62 O5B ++2 *75 ++2 +0 ++2 +2 ++2 +2 +2 ++2 +2 +2 +2 ++2 +3 ++2 +3 +4 ++2 +3 +4 +5 ++2 +5 ++2 @0 ++2 D1 ++2 D3 ++2 D5 ++2 D5 *79 ++2 L2 ++2 L5 ++2 L6 u ++2 T1 d ++2 T5 z3 ++2 Z2 ++2 Z3 ++2 Z3 i22 ++2 ^# ++2 ^8 ++2 ^h ++2 ^u ++2 c ++2 d ++2 f ++2 i2K ++2 i2d ++2 i4? *53 ++2 iA5 O38 ++2 l ++2 l $% ++2 l i0D ++2 o0* ++2 o0z ++2 o1b ++2 o4A ++2 o71 ++2 oAs ++2 p1 O23 ++2 q ++2 sCy ++2 sGq ++2 sgb ++2 sui ++2 t *57 ++2 u p1 ++2 O02 ++2 O39 t ++2 O41 ++2 O57 ++2 z1 ++2 z2 ++2 z3 *08 ++2 z3 *57 ++2 z3 D4 ++2 z3 t ++2 z4 ++2 z5 O81 +3 -+3$! -+3$. -+3$1 -+3$4 -+3$4D5 -+3$7-6 -+3$Ri2D -+3$Y -+3$c} -+3$m -+3$v -+3$w -+3'9 -+3*12 -+3*34r -+3*42 -+3*62 -+3+3 -+3+3+3 -+3+3+3+3 -+3+4 -+3+4+5 -+3+4+5+6 -+3+5 -+3+6 -+3-1 -+3-2 -+3@1 -+3@t -+3@v -+3@vo33 -+3D5o5e -+3D6 -+3K -+3R4z3 -+3R5sc6 -+3T5 -+3Z1 -+3Z1R6 -+3Z2 -+3Z2o1u -+3Z4 -+3^- -+3^2 -+3^G -+3^W} -+3^b -+3^d -+3^m -+3^p -+3c -+3i04 -+3i1L -+3i1m -+3i20 -+3i2Ac -+3i2| -+3i4a -+3i4e -+3i4k -+3k*23 -+3o0c -+3o0d -+3o1O -+3o1q -+3o2+ -+3o4_ -+3o4i -+3o5, -+3o6e -+3o8a -+3p1 -+3r -+3s1d -+3sjLZ1 -+3sl0 -+3snz -+3soe -+3spjo6q -+3ssv -+3stg -+3suf -+3ts27 -+3u -+3O03$w -+3O06Z4 -+3O12 -+3O47 -+3O53 -+3O71 -+3z1+2 -+3z1@6 -+3z2 -+3z3o33 -+3z4 -+3{ -+3{K ++3 $! ++3 $. ++3 $1 ++3 $4 ++3 $4 D5 ++3 $7 -6 ++3 $R i2D ++3 $Y ++3 $c } ++3 $m ++3 $v ++3 $w ++3 '9 ++3 *12 ++3 *34 r ++3 *42 ++3 *62 ++3 +3 ++3 +3 +3 ++3 +3 +3 +3 ++3 +4 ++3 +4 +5 ++3 +4 +5 +6 ++3 +5 ++3 +6 ++3 -1 ++3 -2 ++3 @1 ++3 @t ++3 @v ++3 @v o33 ++3 D5 o5e ++3 D6 ++3 K ++3 R4 z3 ++3 R5 sc6 ++3 T5 ++3 Z1 ++3 Z1 R6 ++3 Z2 ++3 Z2 o1u ++3 Z4 ++3 ^- ++3 ^2 ++3 ^G ++3 ^W } ++3 ^b ++3 ^d ++3 ^m ++3 ^p ++3 c ++3 i04 ++3 i1L ++3 i1m ++3 i20 ++3 i2A c ++3 i2| ++3 i4a ++3 i4e ++3 i4k ++3 k *23 ++3 o0c ++3 o0d ++3 o1O ++3 o1q ++3 o2+ ++3 o4_ ++3 o4i ++3 o5, ++3 o6e ++3 o8a ++3 p1 ++3 r ++3 s1d ++3 sjL Z1 ++3 sl0 ++3 snz ++3 soe ++3 spj o6q ++3 ssv ++3 stg ++3 suf ++3 t s27 ++3 u ++3 O03 $w ++3 O06 Z4 ++3 O12 ++3 O47 ++3 O53 ++3 O71 ++3 z1 +2 ++3 z1 @6 ++3 z2 ++3 z3 o33 ++3 z4 ++3 { ++3 { K +4 -+4$$u -+4$0 -+4$5 -+4$G -+4$N -+4$ZO58 -+4$_'6 -+4$a -+4$g[ -+4$k -+4$u -+4$v -+4'4l -+4'9 -+4*02 -+4*04z2 -+4*23 -+4*24O03 -+4*25 -+4*40 -+4*86 -+4+0 -+4+1 -+4+4 -+4+4+4 -+4+4+4+4 -+4+5 -+4+5+6 -+4+5+6+7 -+4-1Z2 -+4-2Z3 -+4@a -+4@y -+4C -+4C$O -+4D3 -+4D5 -+4L5 -+4L7 -+4R1o0L -+4T5 -+4Z1 -+4Z2 -+4Z2*52 -+4Z3 -+4Z4 -+4Z5O58 -+4[ -+4^c^S -+4c -+4d -+4i03C -+4i1lD3 -+4i2P -+4i44 -+4i4TO01 -+4i4b -+4i4z -+4i66 -+4o0m -+4o0t -+4o0z -+4o2; -+4o3g -+4o5y -+4o97 -+4q -+4qO53 -+4r -+4s.z -+4sK9 -+4seg -+4so5 -+4srB -+4t -+4O03 -+4O54 -+4O57 -+4O62 -+4O74 -+4O84 -+4z1 -+4z3 -+4z4 -+4{ -+4} ++4 $$ u ++4 $0 ++4 $5 ++4 $G ++4 $N ++4 $Z O58 ++4 $_ '6 ++4 $a ++4 $g [ ++4 $k ++4 $u ++4 $v +'4 l ++4 '9 ++4 *02 ++4 *04 z2 ++4 *23 +*24 O03 ++4 *25 ++4 *40 ++4 *86 ++4 +0 ++4 +1 ++4 +4 ++4 +4 +4 ++4 +4 +4 +4 ++4 +5 ++4 +5 +6 ++4 +5 +6 +7 ++4 -1 Z2 ++4 -2 Z3 ++4 @a ++4 @y ++4 C ++4 C $O ++4 D3 ++4 D5 ++4 L5 ++4 L7 ++4 R1 o0L ++4 T5 ++4 Z1 ++4 Z2 ++4 Z2 *52 ++4 Z3 ++4 Z4 ++4 Z5 O58 ++4 [ ++4 ^c ^S ++4 c ++4 d ++4 i03 C ++4 i1l D3 ++4 i2P ++4 i44 ++4 i4T O01 ++4 i4b ++4 i4z ++4 i66 ++4 o0m ++4 o0t ++4 o0z ++4 o2; ++4 o3g ++4 o5y ++4 o97 ++4 q ++4 q O53 ++4 r ++4 s.z ++4 sK9 ++4 seg ++4 so5 ++4 srB ++4 t ++4 O03 ++4 O54 ++4 O57 ++4 O62 ++4 O74 ++4 O84 ++4 z1 ++4 z3 ++4 z4 ++4 { ++4 } +5 -+5$- -+5$4 -+5$D -+5$I -+5$`R8 -+5$g -+5$u -+5$xO06 -+5$y -+5$z^X -+5'6 -+5'8 -+5'9 -+5*35 -+5*54 -+5*60 -+5*65 -+5*78 -+5*79 -+5+0D5 -+5+0^r -+5+5 -+5+5+5 -+5+5+5+5 -+5+6 -+5+6+7 -+5+6+7+8 -+5+7 -+5-0 -+5-4 -+5-6 -+5-7 -+5@6 -+5D1 -+5D2O41 -+5D4 -+5D6 -+5L0 -+5L6 -+5T3 -+5T4 -+5T4z4 -+5T7 -+5Z1 -+5Z2 -+5Z3 -+5Z4 -+5[-2 -+5[Z4 -+5] -+5]i3x -+5^# -+5^2 -+5^6 -+5^C -+5^K -+5^] -+5^g -+5^ri2o -+5^w -+5c -+5d -+5dO75 -+5f -+5i3/Z1 -+5i3o -+5i51 -+5i5z -+5ko0j -+5l -+5o0N -+5o2q -+5o37 -+5o3k -+5o4 -+5o47 -+5o4v -+5o79 -+5o94 -+5o9y -+5r -+5s36 -+5s6a -+5s6b -+5sfm$f -+5t -+5O04 -+5O62 -+5O63 -+5z1 -+5z1D4 -+5z2 -+5z4 -+5{ ++5 $- ++5 $4 ++5 $D ++5 $I ++5 $` R8 ++5 $g ++5 $u +$x O06 ++5 $y ++5 $z ^X ++5 '6 ++5 '8 ++5 '9 ++5 *35 ++5 *54 ++5 *60 ++5 *65 ++5 *78 ++5 *79 ++0 D5 ++5 +0 ^r ++5 +5 ++5 +5 +5 ++5 +5 +5 +5 ++5 +6 ++5 +6 +7 ++5 +6 +7 +8 ++5 +7 ++5 -0 ++5 -4 ++5 -6 ++5 -7 ++5 @6 ++5 D1 ++5 D2 O41 ++5 D4 ++5 D6 ++5 L0 ++5 L6 ++5 T3 ++5 T4 ++5 T4 z4 ++5 T7 ++5 Z1 ++5 Z2 ++5 Z3 ++5 Z4 ++5 [ -2 ++5 [ Z4 ++5 ] ++5 ] i3x ++5 ^# ++5 ^2 ++5 ^6 ++5 ^C ++5 ^K ++5 ^] ++5 ^g ++5 ^r i2o ++5 ^w ++5 c ++5 d ++5 d O75 ++5 f ++5 i3/ Z1 ++5 i3o ++5 i51 ++5 i5z ++5 k o0j ++5 l ++5 o0N ++5 o2q ++5 o37 ++5 o3k ++5 o4 ++5 o47 ++5 o4v ++5 o79 ++5 o94 ++5 o9y ++5 r ++5 s36 ++5 s6a ++5 s6b ++5 sfm $f ++5 t ++5 O04 ++5 O62 ++5 O63 ++5 z1 ++5 z1 D4 ++5 z2 ++5 z4 ++5 { +6 -+6$! -+6$& -+6$+ -+6$0 -+6$7 -+6$; -+6$@ -+6$A -+6$L -+6$U -+6$b -+6$e -+6$p -+6$u -+6'9 -+6'A -+6*02 -+6*14 -+6*43 -+6*57 -+6*60 -+6*63 -+6*73 -+6*83D3 -+6+1 -+6+4 -+6+6 -+6+6+6 -+6+6+6+6 -+6+7 -+6+7+8 -+6+7+8+9 -+6-5 -+6-7 -+6@d -+6@p -+6@u -+6D2 -+6D4 -+6D7 -+6D8 -+6R2 -+6R5 -+6T7 -+6Z1 -+6Z1i4c -+6Z2 -+6Z3 -+6Z4 -+6Z5 -+6[ -+6^*'5 -+6^- -+6^S -+6^a -+6^p -+6c -+6c^M -+6d -+6i3_ -+6i3j -+6i4. -+6i5 -+6i5m -+6i64 -+6i7u -+6k -+6l -+6l*32 -+6o2s -+6o5w -+6o7. -+6o77 -+6o78 -+6o92 -+6s3* -+6s57 -+6s87 -+6skP -+6slK -+6slg -+6u -+6O02 -+6O06o03 -+6O12 -+6O21[ -+6O31 -+6O32 -+6O42 -+6O51 -+6O73 -+6O74 -+6O76 -+6z1 -+6z1{ -+6z2 -+6{ ++6 $! ++6 $& ++6 $+ ++6 $0 ++6 $7 ++6 $; ++6 $@ ++6 $A ++6 $L ++6 $U ++6 $b ++6 $e ++6 $p ++6 $u ++6 '9 ++6 'A ++6 *02 ++6 *14 ++6 *43 ++6 *57 ++6 *60 ++6 *63 ++6 *73 ++6 *83 D3 ++6 +1 ++6 +4 ++6 +6 ++6 +6 +6 ++6 +6 +6 +6 ++6 +7 ++6 +7 +8 ++6 +7 +8 +9 ++6 -5 ++6 -7 ++6 @d ++6 @p ++6 @u ++6 D2 ++6 D4 ++6 D7 ++6 D8 ++6 R2 ++6 R5 ++6 T7 ++6 Z1 ++6 Z1 i4c ++6 Z2 ++6 Z3 ++6 Z4 ++6 Z5 ++6 [ +^* '5 ++6 ^- ++6 ^S ++6 ^a ++6 ^p ++6 c ++6 c ^M ++6 d ++6 i3_ ++6 i3j ++6 i4. ++6 i5 ++6 i5m ++6 i64 ++6 i7u ++6 k ++6 l ++6 l *32 ++6 o2s ++6 o5w ++6 o7. ++6 o77 ++6 o78 ++6 o92 ++6 s3* ++6 s57 ++6 s87 ++6 skP ++6 slK ++6 slg ++6 u ++6 O02 +O06 o03 ++6 O12 ++6 O21 [ ++6 O31 ++6 O32 ++6 O42 ++6 O51 ++6 O73 ++6 O74 ++6 O76 ++6 z1 ++6 z1 { ++6 z2 ++6 { +7 -+7$% -+7$0 -+7$3 -+7$4 -+7$P -+7$a -+7$bi18 -+7$bO4A -+7$g -+7'9 -+7*07 -+7*13+0 -+7*56[ -+7*57 -+7*59 -+7*98 -+7+7 -+7+7+7 -+7+7+7+7 -+7+7@. -+7+8 -+7+8+9 -+7-1 -+7-5 -+7-6 -+7-8 -+7-8O31 -+7@0 -+7@R -+7@k -+7@o -+7@r -+7D1 -+7D2 -+7R3 -+7R5 -+7R6 -+7T2 -+7Z1 -+7Z1*30 -+7Z1swg -+7Z2 -+7Z2L5 -+7[ -+7^, -+7^b -+7^o -+7^w -+7c -+7f -+7i1p -+7i34 -+7i4/ -+7i5j -+7i6y -+7i7& -+7i7S -+7i7_ -+7i7f -+7l -+7o3"C -+7o3< -+7o46 -+7o54 -+7o6_ -+7o6x -+7o6y -+7o83 -+7oB}*68 -+7p1 -+7r -+7r[ -+7s0sR5 -+7s7r -+7sfb -+7skD -+7u -+7O0BT4 -+7O12 -+7O24 -+7O27O43 -+7O32D2 -+7O41 -+7O48$u -+7O82 -+7OA2 -+7z2^) -+7z3 -+7} ++7 $% ++7 $0 ++7 $3 ++7 $4 ++7 $P ++7 $a ++7 $b i18 ++7 $b O4A ++7 $g ++7 '9 ++7 *07 ++7 *13 +0 ++7 *56 [ ++7 *57 ++7 *59 ++7 *98 ++7 +7 ++7 +7 +7 ++7 +7 +7 +7 ++7 +7 @. ++7 +8 ++7 +8 +9 ++7 -1 ++7 -5 ++7 -6 ++7 -8 ++7 -8 O31 ++7 @0 ++7 @R ++7 @k ++7 @o ++7 @r ++7 D1 ++7 D2 ++7 R3 ++7 R5 ++7 R6 ++7 T2 ++7 Z1 ++7 Z1 *30 ++7 Z1 swg ++7 Z2 ++7 Z2 L5 ++7 [ ++7 ^, ++7 ^b ++7 ^o ++7 ^w ++7 c ++7 f ++7 i1p ++7 i34 ++7 i4/ ++7 i5j ++7 i6y ++7 i7& ++7 i7S ++7 i7_ ++7 i7f ++7 l ++7 o3" C ++7 o3< ++7 o46 ++7 o54 ++7 o6_ ++7 o6x ++7 o6y ++7 o83 ++7 oB} *68 ++7 p1 ++7 r ++7 r [ ++7 s0s R5 ++7 s7r ++7 sfb ++7 skD ++7 u ++7 O0B T4 ++7 O12 ++7 O24 ++7 O27 O43 ++7 O32 D2 ++7 O41 ++7 O48 $u ++7 O82 ++7 OA2 ++7 z2 ^) ++7 z3 ++7 } +8 -+8$g -+8$m -+8'9 -+8*70 -+8*78 -+8*9A -+8+6 -+8+8 -+8+8+8 -+8+8+8+8 -+8+9 -+8+A -+8-2u -+8-6 -+8-7 -+8-9 -+8@9 -+8C+6 -+8D4 -+8R6 -+8R7 -+8T2 -+8Z1 -+8Z2 -+8^a -+8c -+8i7- -+8l -+8o0y -+8o13 -+8o4l -+8o5s -+8o6B -+8o6a -+8o7_ -+8o7b -+8s_ -+8sjs -+8spi -+8u -+8O08 -+8O17 -+8O21 -+8O26 -+8O42 -+8O47T6 -+8O52 -+8O53p1 -+8z1 -+8} ++8 $g ++8 $m ++8 '9 ++8 *70 ++8 *78 ++8 *9A ++8 +6 ++8 +8 ++8 +8 +8 ++8 +8 +8 +8 ++8 +9 ++8 +A ++8 -2 u ++8 -6 ++8 -7 ++8 -9 ++8 @9 ++8 C +6 ++8 D4 ++8 R6 ++8 R7 ++8 T2 ++8 Z1 ++8 Z2 ++8 ^a ++8 c ++8 i7- ++8 l ++8 o0y ++8 o13 ++8 o4l ++8 o5s ++8 o6B ++8 o6a ++8 o7_ ++8 o7b ++8 s_ ++8 sjs ++8 spi ++8 u ++8 O08 ++8 O17 ++8 O21 ++8 O26 ++8 O42 ++8 O47 T6 ++8 O52 ++8 O53 p1 ++8 z1 ++8 } +9 -+9$8D8 -+9$B -+9$a -+9'A -+9+0 -+9+6 -+9+7 -+9+9 -+9+9+9 -+9+9+9+9 -+9-8Z1 -+9D0+6 -+9D3 -+9D5 -+9D5z1 -+9D7 -+9D8 -+9R1 -+9Z1 -+9Z2 -+9Z2OA2 -+9[ -+9c -+9i6s$2 -+9i8d -+9i91 -+9l -+9o0IO15 -+9o0l -+9o43 -+9o76 -+9o83 -+9o8i -+9o8j -+9u -+9O15 -+9O19 -+9O23 -+9O37Z5 -+9O45 -+9O72 -+9OA4 ++9 $8 D8 ++9 $B ++9 $a ++9 'A ++9 +0 ++9 +6 ++9 +7 ++9 +9 ++9 +9 +9 ++9 +9 +9 +9 ++9 -8 Z1 ++9 D0 +6 ++9 D3 ++9 D5 ++9 D5 z1 ++9 D7 ++9 D8 ++9 R1 ++9 Z1 ++9 Z2 ++9 Z2 OA2 ++9 [ ++9 c ++9 i6s $2 ++9 i8d ++9 i91 ++9 l ++9 o0I O15 ++9 o0l ++9 o43 ++9 o76 ++9 o83 ++9 o8i ++9 o8j ++9 u ++9 O15 ++9 O19 ++9 O23 ++9 O37 Z5 ++9 O45 ++9 O72 ++9 OA4 +A -+A$! -+A$9 -+A*8A -+A*9A -+AD4 -+ADB -+AR5'9 -+AR9 -+AZ2 -+A^5c -+At -+AO62 -+AO82 -+AO91 ++A $! ++A $9 ++A *8A ++A *9A ++A D4 ++A DB +R5 '9 ++A R9 ++A Z2 ++A ^5 c ++A t ++A O62 ++A O82 ++A O91 +B -+B$3 -+B*9A -+B+5O0A -+B@2 -+B@8 -+B[ -+Bl -+Bo10 -+BO02 -+BO62 -+BO73 -+BO92 ++B $3 ++B *9A ++B +5 O0A ++B @2 ++B @8 ++B [ ++B l ++B o10 ++B O02 ++B O62 ++B O73 ++B O92 -0 --0$) --0$1 --0$? --0$E --0$K --0$P --0$` --0$a --0$b@4 --0$c --0$e --0$f --0$n --0$p --0$u --0$z --0'4z1 --0'7 --0'8O41 --0'A --0*02 --0*02[ --0*04 --0*05D0 --0*21 --0*31 --0*52 --0*63 --0*64 --0+2 --0+2s1q --0+3 --0+6 --0+7 --0+8 --0-0 --0-0-0 --0-0-0-0 --0-1 --0-1-2 --0-1-2-3 --0-2^B --0-5 --0-7 --0@2 --0@z --0C --0C*34 --0CT0 --0D1 --0D7 --0K --0L7 --0R3 --0R5O12 --0Z1 --0Z2 --0Z3 --0Z3*6A --0Z4 --0^& --0^+ --0^2 --0^5 --0^9 --0^; --0^;*56 --0^< --0^= --0^[ --0^d --0^g*02 --0^pO12 --0^u --0c --0d --0f --0f*56 --0i0C --0i18 --0i1l --0i1r --0i2n --0i2t --0i3j --0i3t --0i52 --0i57t --0i7s --0i7}O61 --0k --0kD2 --0l --0l$; --0lO24 --0o0fq --0o1wz3 --0o2H --0o3Z --0o3c --0o4=O3A --0o4f --0o52 --0o6p --0o7w --0o7z --0o8a --0o9b --0p2 --0p4 --0q --0r --0sao --0spH --0spm --0ss#l --0st2 --0t --0t^T --0O12 --0O13 --0O16 --0O18^e --0O23 --0O24 --0O25 --0O26 --0O4A --0O52sfT --0O53 --0O56 --0O84 --0z1 --0z1u --0z2 --0z2z4 --0z3 --0z3z2 --0z4 --0{ +-0 $) +-0 $1 +-0 $? +-0 $E +-0 $K +-0 $P +-0 $` +-0 $a +-0 $b @4 +-0 $c +-0 $e +-0 $f +-0 $n +-0 $p +-0 $u +-0 $z +-0 '4 z1 +-0 '7 +-0 '8 O41 +-0 'A +-0 *02 +-0 *02 [ +-0 *04 +-0 *05 D0 +-0 *21 +-0 *31 +-0 *52 +-0 *63 +-0 *64 +-0 +2 +-0 +2 s1q +-0 +3 +-0 +6 +-0 +7 +-0 +8 +-0 -0 +-0 -0 -0 +-0 -0 -0 -0 +-0 -1 +-0 -1 -2 +-0 -1 -2 -3 +-0 -2 ^B +-0 -5 +-0 -7 +-0 @2 +-0 @z +-0 C +-0 C *34 +-0 C T0 +-0 D1 +-0 D7 +-0 K +-0 L7 +-0 R3 +-0 R5 O12 +-0 Z1 +-0 Z2 +-0 Z3 +-0 Z3 *6A +-0 Z4 +-0 ^& +-0 ^+ +-0 ^2 +-0 ^5 +-0 ^9 +-0 ^; +-0 ^; *56 +-0 ^< +-0 ^= +-0 ^[ +-0 ^d +-0 ^g *02 +-0 ^p O12 +-0 ^u +-0 c +-0 d +-0 f +-0 f *56 +-0 i0C +-0 i18 +-0 i1l +-0 i1r +-0 i2n +-0 i2t +-0 i3j +-0 i3t +-0 i52 +-0 i57 t +-0 i7s +-0 i7} O61 +-0 k +-0 k D2 +-0 l +-0 l $; +-0 l O24 +o0f q +-0 o1w z3 +-0 o2H +-0 o3Z +-0 o3c +-0 o4= O3A +-0 o4f +-0 o52 +-0 o6p +-0 o7w +-0 o7z +-0 o8a +-0 o9b +-0 p2 +-0 p4 +-0 q +-0 r +-0 sao +-0 spH +-0 spm +-0 ss# l +-0 st2 +-0 t +-0 t ^T +-0 O12 +-0 O13 +-0 O16 +-0 O18 ^e +-0 O23 +-0 O24 +-0 O25 +-0 O26 +-0 O4A +-0 O52 sfT +-0 O53 +-0 O56 +-0 O84 +-0 z1 +-0 z1 u +-0 z2 +-0 z2 z4 +-0 z3 +-0 z3 z2 +-0 z4 +-0 { -1 --1$3 --1$5 --1$7 --1$8 --1$; --1$R@R --1$q --1$r --1$v --1$x --1'7 --1'A --1*12 --1*13 --1*20 --1*23 --1*27 --1*31r --1*43 --1*52K --1*90 --1*91 --1+2 --1-1 --1-1-1 --1-1-1-1 --1-2 --1-2-3 --1-2-3-4 --1-5 --1@2 --1@6 --1@v --1C --1C-2 --1DA --1K{ --1L0 --1R0 --1T2 --1T5+6 --1Z4 --1Z5i05 --1[-5 --1[Z2 --1[z4 --1^0 --1^3 --1^8 --1^A --1^i --1^n --1c --1d --1i0P --1i1l --1i2Oi0g --1i2R --1i5d --1i62 --1i82 --1l --1o01 --1o08 --1o0T --1o0t --1o3P --1o7m --1r --1ro3/ --1s9s --1sfr --1skv --1skx --1sly --1ssik --1t --1to3l --1u --1O07i1_ --1O23 --1O32 --1O37^b --1O73 --1z1 --1z2 --1z3 --1z5 --1} --1}*50 --1}i5` +-1 $3 +-1 $5 +-1 $7 +-1 $8 +-1 $; +-1 @R +-1 $q +-1 $r +-1 $v +-1 $x +-1 '7 +-1 'A +-1 *12 +-1 *13 +-1 *20 +-1 *23 +-1 *27 +-1 *31 r +-1 *43 +-1 *52 K +-1 *90 +-1 *91 +-1 +2 +-1 -1 +-1 -1 -1 +-1 -1 -1 -1 +-1 -2 +-1 -2 -3 +-1 -2 -3 -4 +-1 -5 +-1 @2 +-1 @6 +-1 @v +-1 C +-1 C -2 +-1 DA +-1 K { +-1 L0 +-1 R0 +-1 T2 +-1 T5 +6 +-1 Z4 +-1 Z5 i05 +-1 [ -5 +-1 [ Z2 +-1 [ z4 +-1 ^0 +-1 ^3 +-1 ^8 +-1 ^A +-1 ^i +-1 ^n +-1 c +-1 d +-1 i0P +-1 i1l +-1 i2O i0g +-1 i2R +-1 i5d +-1 i62 +-1 i82 +-1 l +-1 o01 +-1 o08 +-1 o0T +-1 o0t +-1 o3P +-1 o7m +-1 r +-1 r o3/ +-1 s9s +-1 sfr +-1 skv +-1 skx +-1 sly +-1 ssi k +-1 t +-1 t o3l +-1 u +-1 O07 i1_ +-1 O23 +-1 O32 +-1 O37 ^b +-1 O73 +-1 z1 +-1 z2 +-1 z3 +-1 z5 +-1 } +-1 } *50 +-1 } i5` -2 --2$3 --2$4 --2$7 --2$8 --2$< --2$K --2$c --2$cO42 --2$hO54 --2'7 --2'A --2*05 --2*10 --2*23 --2*26 --2*52 --2*75c --2-2 --2-2-2 --2-2-2-2 --2-3 --2-3-4 --2-3-4-5 --2-6 --2-8 --2@1o4h --2@6 --2@8 --2D0*54 --2D1 --2L0 --2L1 --2L2 --2L3 --2R0 --2R1 --2R4 --2R4^d --2R6 --2T4 --2Z1 --2Z2 --2Z3 --2Z4q --2^C --2^c --2^g --2^k --2^p --2^s} --2d --2f --2f[ --2i0m --2i14 --2i2xT3 --2i3 --2i3b --2i3h --2i3l --2i6u --2i7b --2l --2l+7 --2o04 --2o0G --2o0T --2o0d --2o0g --2o1[ --2o1dZ1 --2o1k --2o33z2 --2o3P --2o3j --2o3x --2o40 --2o4y --2o5a --2o7* --2o7A --2o7G --2o7r --2p1O83 --2q --2q+0 --2r --2rz1 --2s7i --2scu*03 --2sdy --2si5 --2sw;D2 --2u --2u*31 --2O47 --2O52 --2O53 --2O53z2 --2O54swc --2z1Z1 --2z2 --2{ +-2 $3 +-2 $4 +-2 $7 +-2 $8 +-2 $< +-2 $K +-2 $c +-2 $c O42 +-2 $h O54 +-2 '7 +-2 'A +-2 *05 +-2 *10 +-2 *23 +-2 *26 +-2 *52 +-2 *75 c +-2 -2 +-2 -2 -2 +-2 -2 -2 -2 +-2 -3 +-2 -3 -4 +-2 -3 -4 -5 +-2 -6 +-2 -8 +-2 @1 o4h +-2 @6 +-2 @8 +-2 D0 *54 +-2 D1 +-2 L0 +-2 L1 +-2 L2 +-2 L3 +-2 R0 +-2 R1 +-2 R4 +-2 R4 ^d +-2 R6 +-2 T4 +-2 Z1 +-2 Z2 +-2 Z3 +-2 Z4 q +-2 ^C +-2 ^c +-2 ^g +-2 ^k +-2 ^p +-2 ^s } +-2 d +-2 f +-2 f [ +-2 i0m +-2 i14 +-2 i2x T3 +-2 i3 +-2 i3b +-2 i3h +-2 i3l +-2 i6u +-2 i7b +-2 l +-2 l +7 +-2 o04 +-2 o0G +-2 o0T +-2 o0d +-2 o0g +-2 o1[ +-2 o1d Z1 +-2 o1k +-2 o33 z2 +-2 o3P +-2 o3j +-2 o3x +-2 o40 +-2 o4y +-2 o5a +-2 o7* +-2 o7A +-2 o7G +-2 o7r +-2 p1 O83 +-2 q +-2 q +0 +-2 r +-2 r z1 +-2 s7i +-2 scu *03 +-2 sdy +-2 si5 +sw; D2 +-2 u +-2 u *31 +-2 O47 +-2 O52 +-2 O53 +-2 O53 z2 +-2 O54 swc +-2 z1 Z1 +-2 z2 +-2 { -3 --3$#o86 --3$, --3$4 --3$9 --3$: --3$=O05 --3$I^N --3$b --3$k --3$tt --3$zi2p --3'6 --3'7u --3*16 --3*20 --3*24 --3*32sr1 --3*43 --3*45 --3*57 --3*64 --3*65 --3*82 --3+1 --3+2 --3+4 --3+6 --3-0 --3-1 --3-3 --3-3-3 --3-3-3-3 --3-4 --3-4-5 --3-4-5-6 --3@1 --3@3 --3@8 --3@g --3D2 --3D2u --3D3i0F --3D4Z2 --3D6 --3D7 --3L2 --3T3u --3T6 --3Z2 --3Z3 --3^$ --3^8 --3^b --3^g --3^oo7k --3^r --3^u --3^v --3d --3do1f --3fO12 --3i18l --3i33 --3i34 --3i4z*63 --3i5/ --3i5k --3i5s --3i5v --3k --3ks4| --3l --3o0G --3o0W --3o0a --3o1W --3o2a-6 --3o4. --3o4@ --3o4e --3o4i --3o4k --3o4s --3o97 --3p1O72 --3q --3r --3s0b --3sCg --3sTB --3sfk --3smu --3ssp --3t$n --3ui2D --3O02 --3O35*43 --3O41 --3O51 --3O52 --3O63$9 --3O72 --3O86'8 --3OB2^9 --3z1 --3z2 --3z2i0c --3z3 --3z4 --3z4s/4 --3z5'9 --3{ +-3 $# o86 +-3 $, +-3 $4 +-3 $9 +-3 $: +-3 $= O05 +-3 $I ^N +-3 $b +-3 $k +-3 $t t +-3 $z i2p +-3 '6 +-3 '7 u +-3 *16 +-3 *20 +-3 *24 +-3 *32 sr1 +-3 *43 +-3 *45 +-3 *57 +-3 *64 +-3 *65 +-3 *82 +-3 +1 +-3 +2 +-3 +4 +-3 +6 +-3 -0 +-3 -1 +-3 -3 +-3 -3 -3 +-3 -3 -3 -3 +-3 -4 +-3 -4 -5 +-3 -4 -5 -6 +-3 @1 +-3 @3 +-3 @8 +-3 @g +-3 D2 +-3 D2 u +D3 i0F +-3 D4 Z2 +-3 D6 +-3 D7 +-3 L2 +-3 u +-3 T6 +-3 Z2 +-3 Z3 +-3 ^$ +-3 ^8 +-3 ^b +-3 ^g +-3 ^o o7k +-3 ^r +-3 ^u +-3 ^v +-3 d +-3 d o1f +-3 f O12 +-3 i18 l +-3 i33 +-3 i34 +-3 i4z *63 +-3 i5/ +-3 i5k +-3 i5s +-3 i5v +-3 k +-3 k s4| +-3 l +-3 o0G +-3 o0W +-3 o0a +-3 o1W +-3 o2a -6 +-3 o4. +-3 o4@ +-3 o4e +-3 o4i +-3 o4k +-3 o4s +-3 o97 +-3 p1 O72 +-3 q +-3 r +-3 s0b +-3 sCg +-3 sTB +-3 sfk +-3 smu +-3 ssp +-3 t $n +-3 u i2D +-3 O02 +-3 O35 *43 +-3 O41 +-3 O51 +-3 O52 +-3 O63 $9 +-3 O72 +-3 '8 +-3 OB2 ^9 +-3 z1 +-3 z2 +-3 z2 i0c +-3 z3 +-3 z4 +-3 z4 s/4 +-3 z5 '9 +-3 { -4 --4$! --4$* --4$- --4$a{ --4$xo6K --4'6 --4*02 --4*14 --4*26 --4*34 --4*40 --4*42 --4*42O42 --4*45 --4+3 --4-0'7 --4-1 --4-2 --4-4 --4-4-4 --4-4-4-4 --4-5 --4-5-6 --4-5-6-7 --4-8 --4@m --4D2 --4D5 --4D5L6 --4D6 --4D7 --4L4 --4L5+5 --4Z1 --4Z1o61 --4Z1z2 --4Z2O78 --4Z3 --4[Z5 --4[^I --4]-1 --4^$ --4^4D4 --4^h --4^j --4^r --4c --4i0l --4i27O4A --4i5d --4i64 --4k --4l --4o05 --4o0G --4o0P --4o0dz2 --4o28 --4o2B --4o2t --4o52 --4o5k --4o67 --4o7e --4p1 --4s0M --4s2m --4s7 --4se. --4t --4u --4O03 --4O12 --4O14$m --4O26$B --4O31 --4O45^D --4O63 --4O75 --4O82 --4z1 --4z3 --4z4 --4} +-4 $! +-4 $* +-4 $- +-4 $a { +-4 $x o6K +-4 '6 +-4 *02 +-4 *14 +-4 *26 +-4 *34 +-4 *40 +-4 *42 +-4 *42 O42 +-4 *45 +-4 +3 +-4 -0 '7 +-4 -1 +-4 -2 +-4 -4 +-4 -4 -4 +-4 -4 -4 -4 +-4 -5 +-4 -5 -6 +-4 -5 -6 -7 +-4 -8 +-4 @m +-4 D2 +-4 D5 +-4 D5 L6 +-4 D6 +-4 D7 +-4 L4 +-4 L5 +5 +-4 Z1 +-4 Z1 o61 +-4 Z1 z2 +-4 Z2 O78 +-4 Z3 +-4 [ Z5 +-4 [ ^I +-4 ] -1 +-4 ^$ +-4 ^4 D4 +-4 ^h +-4 ^j +-4 ^r +-4 c +-4 i0l +-4 i27 O4A +-4 i5d +-4 i64 +-4 k +-4 l +-4 o05 +-4 o0G +-4 o0P +-4 o0d z2 +-4 o28 +-4 o2B +-4 o2t +-4 o52 +-4 o5k +-4 o67 +-4 o7e +-4 p1 +-4 s0M +-4 s2m +-4 s7 +-4 se. +-4 t +-4 u +-4 O03 +-4 O12 +-4 O14 $m +-4 O26 $B +-4 O31 +-4 O45 ^D +-4 O63 +-4 O75 +-4 O82 +-4 z1 +-4 z3 +-4 z4 +-4 } -5 --5$! --5$% --5$* --5$1 --5$2 --5$3 --5$? --5$I} --5$K --5$M --5$S --5$j --5$m --5$t --5$u --5'6 --5'9 --5*16 --5*21d --5*25l --5*46 --5*50K --5*62'6 --5*68 --5*74 --5*75*56 --5*79 --5+2 --5+3 --5+4 --5+8 --5-5 --5-5-5 --5-5-5-5 --5-6 --5-6-7 --5-6-7-8 --5-9 --5@0 --5@3 --5@7 --5@a --5C --5D1 --5D2 --5D3 --5D3sw7 --5D4 --5D6 --5L0+1 --5R3+3 --5R5+1 --5T0 --5T2 --5T3 --5Z1 --5Z1R6 --5Z2 --5Z3 --5Z3O43 --5Z4 --5[ --5[d --5^RO41 --5^UsrM --5^n --5c --5cZ1 --5d --5i19 --5i3g --5i4Mi0` --5i5n --5i5t^_ --5i7e --5i7o --5k --5l --5o0G --5o19 --5o1_ --5o2[ --5o2bD4 --5o3_ --5o61 --5o62 --5o6= --5o6g --5o8* --5r[ --5s6v --5sb- --5sjy --5srot --5suVc --5t --5O02 --5O03 --5O05 --5O42L4 --5O81 --5z2 --5z2{ --5z3 --5z3Z1 --5{ --5} +-5 $! +-5 $% +-5 $* +-5 $1 +-5 $2 +-5 $3 +-5 $? +-5 $I } +-5 $K +-5 $M +-5 $S +-5 $j +-5 $m +-5 $t +-5 $u +-5 '6 +-5 '9 +-5 *16 +-5 *21 d +-5 *25 l +-5 *46 +-5 *50 K +-5 *62 '6 +-5 *68 +-5 *74 +-5 *75 *56 +-5 *79 +-5 +2 +-5 +3 +-5 +4 +-5 +8 +-5 -5 +-5 -5 -5 +-5 -5 -5 -5 +-5 -6 +-5 -6 -7 +-5 -6 -7 -8 +-5 -9 +-5 @0 +-5 @3 +-5 @7 +-5 @a +-5 C +-5 D1 +-5 D2 +-5 D3 +-5 D3 sw7 +-5 D4 +-5 D6 +-5 L0 +1 +-5 R3 +3 +-5 R5 +1 +-5 T0 +-5 T2 +-5 T3 +-5 Z1 +-5 Z1 R6 +-5 Z2 +-5 Z3 +-5 Z3 O43 +-5 Z4 +-5 [ +-5 [ d +-5 ^R O41 +-5 ^U srM +-5 ^n +-5 c +-5 c Z1 +-5 d +-5 i19 +-5 i3g +-5 i4M i0` +-5 i5n +-5 i5t ^_ +-5 i7e +-5 i7o +-5 k +-5 l +-5 o0G +-5 o19 +-5 o1_ +-5 o2[ +-5 o2b D4 +-5 o3_ +-5 o61 +-5 o62 +-5 o6= +-5 o6g +-5 o8* +-5 r [ +-5 s6v +-5 sb- +-5 sjy +-5 sro t +-5 suV c +-5 t +-5 O02 +-5 O03 +-5 O05 +-5 O42 L4 +-5 O81 +-5 z2 +-5 z2 { +-5 z3 +-5 z3 Z1 +-5 { +-5 } -6 --6$4 --6$7 --6$8 --6$p-2 --6$x --6$z --6'7i3i --6*20 --6*24D0 --6*63 --6*67 --6*70 --6*85 --6+0 --6-0O51 --6-3 --6-6 --6-6-6 --6-6-6-6 --6-7 --6-7-8 --6-7-8-9 --6-8 --6-9 --64 --6@_ --6C --6D4 --6L0 --6L1o0j --6L5 --6L6 --6R4 --6R6u --6T0 --6T2 --6T7 --6Z1 --6Z2 --6Z2*68 --6Z4 --6[ --6]O74 --6^# --6^& --6^@ --6^a --6^k --6^r --6c --6ci6f --6d --6dO48 --6i06 --6i0f'9 --6i45 --6i4j --6i5, --6i5r --6i62 --6i7d --6i82 --6ki6x --6l --6o3l --6o56 --6o5t --6o5z --6o7r --6u --6uL2 --6O03 --6O04 --6O05 --6O13 --6O23 --6O31 --6O34T3 --6O51 --6O51T1 --6O65i4u --6O72 --6O75 --6O82 --6O84 --6z1 --6z1O73 --6} +-6 $4 +-6 $7 +-6 $8 +-6 $p -2 +-6 $x +-6 $z +-6 '7 i3i +-6 *20 +-6 *24 D0 +-6 *63 +-6 *67 +-6 *70 +-6 *85 +-6 +0 +-6 -0 O51 +-6 -3 +-6 -6 +-6 -6 -6 +-6 -6 -6 -6 +-6 -7 +-6 -7 -8 +-6 -7 -8 -9 +-6 -8 +-6 -9 +-6 @_ +-6 C +-6 D4 +-6 L0 +-6 L1 o0j +-6 L5 +-6 L6 +-6 R4 +-6 R6 u +-6 T0 +-6 T2 +-6 T7 +-6 Z1 +-6 Z2 +-6 Z2 *68 +-6 Z4 +-6 [ +-6 ] O74 +-6 ^# +-6 ^& +-6 ^@ +-6 ^a +-6 ^k +-6 ^r +-6 c +-6 c i6f +-6 d +-6 d O48 +-6 i06 +-6 i0f '9 +-6 i45 +-6 i4j +-6 i5, +-6 i5r +-6 i62 +-6 i7d +-6 i82 +-6 k i6x +-6 l +-6 o3l +-6 o56 +-6 o5t +-6 o5z +-6 o7r +-6 u +-6 u L2 +-6 O03 +-6 O04 +-6 O05 +-6 O13 +-6 O23 +-6 O31 +-6 O34 T3 +-6 O51 +-6 O51 T1 +-6 O65 i4u +-6 O72 +-6 O75 +-6 O82 +-6 O84 +-6 z1 +-6 z1 O73 +-6 } -7 --7$! --7$% --7$+ --7$0 --7$5 --7$9 --7$? --7$R --7$a --7$b --7$v --7'A --7*06u --7*43 --7*68 --7*70o10 --7*72 --7*73 --7*73z3 --7*76 --7*87 --7+9 --7-3 --7-3Z1 --7-7 --7-7-7 --7-7-7-7 --7-8 --7-8-9 --7-9 --7@j --7D4 --7D6 --7D8 --7R2 --7T4 --7Z1 --7Z2 --7Z3 --7[ --7^3 --7c --7ci6_ --7i0j --7i1R --7i4; --7i4w^7 --7i4x --7i59 --7i68 --7i7,t --7i7oO43 --7i7t --7i8+O06 --7l --7o14 --7o1@ --7o5# --7o5g --7o6- --7o6. --7o69 --7o6b --7o77i5I --7o8! --7o80 --7s4$ --7sull --7t --7u --7O03 --7O04$B --7O05D4 --7O26i4s --7O79 --7O94 --7z1 --7z1D2 --7z2 --7{Z1 --7} +-7 $! +-7 $% +-7 $+ +-7 $0 +-7 $5 +-7 $9 +-7 $? +-7 $R +-7 $a +-7 $b +-7 $v +-7 'A +-7 *06 u +-7 *43 +-7 *68 +-7 *70 o10 +-7 *72 +-7 *73 +-7 *73 z3 +-7 *76 +-7 *87 +-7 +9 +-7 -3 +-7 -3 Z1 +-7 -7 +-7 -7 -7 +-7 -7 -7 -7 +-7 -8 +-7 -8 -9 +-7 -9 +-7 @j +-7 D4 +-7 D6 +-7 D8 +-7 R2 +-7 T4 +-7 Z1 +-7 Z2 +-7 Z3 +-7 [ +-7 ^3 +-7 c +-7 c i6_ +-7 i0j +-7 i1R +-7 i4; +-7 i4w ^7 +-7 i4x +-7 i59 +-7 i68 +-7 i7, t +-7 i7o O43 +-7 i7t +-7 i8+ O06 +-7 l +-7 o14 +-7 o1@ +-7 o5# +-7 o5g +-7 o6- +-7 o6. +-7 o69 +-7 o6b +o77 i5I +-7 o8! +-7 o80 +-7 s4$ +-7 sul l +-7 t +-7 u +-7 O03 +-7 O04 $B +-7 O05 D4 +-7 O26 i4s +-7 O79 +-7 O94 +-7 z1 +-7 z1 D2 +-7 z2 +-7 { Z1 +-7 } -8 --8$! --8$% --8$5+A --8$8 --8$VO3A --8$f --8$n^O --8$s --8$w --8$y --8'8$I --8*53 --8*57 --8*76 --8*7BO62 --8*8A --8*BA --8+2 --8+4 --8+6 --8+9 --8-0 --8-3 --8-8 --8-8-8 --8-8-8-8 --8-9 --84 --8@k --8@u --8@uO12 --8D6 --8D7 --8DA --8R7 --8T4 --8Z1 --8Z2 --8[ --8[l --8c --8i2[ --8i8Qc --8l --8o3b --8o4b --8o5d --8o66 --8o6b --8o7f --8o9l --8oB3 --8q --8t --8O04 --8O12c --8O16 --8O25c --8O62 --8O91 --8z2 +-8 $! +-8 $% +-8 $5 +A +-8 $8 +-8 $V O3A +-8 $f +-8 $n ^O +-8 $s +-8 $w +-8 $y +'8 $I +-8 *53 +-8 *57 +-8 *76 +-8 *7B O62 +-8 *8A +-8 *BA +-8 +2 +-8 +4 +-8 +6 +-8 +9 +-8 -0 +-8 -3 +-8 -8 +-8 -8 -8 +-8 -8 -8 -8 +-8 -9 +-8 @k +-8 @u +-8 @u O12 +-8 D6 +-8 D7 +-8 DA +-8 R7 +-8 T4 +-8 Z1 +-8 Z2 +-8 [ +-8 [ l +-8 c +-8 i2[ +-8 i8Q c +-8 l +-8 o3b +-8 o4b +-8 o5d +-8 o66 +-8 o6b +-8 o7f +-8 o9l +-8 oB3 +-8 q +-8 t +-8 O04 +-8 O12 c +-8 O16 +-8 O25 c +-8 O62 +-8 O91 +-8 z2 -9 --9$! --9$5 --9*01 --9*56 --9*98 --9+0 --9-0 --9-4 --9-7'8 --9-9 --9-9-9 --9-9-9-9 --9D1 --9D4Z1 --9D7 --9L9 --9R8 --9T2 --9Z1 --9Z1-6 --9Z2 --9^1 --9^5O64 --9i6- --9l --9o64 --9o7b --9s09 --9s25 --9s4F --9s91 --9s9e --9u --9uO24 --9O02t --9O15o2* --9O16^p --9O17 --9O25 --9O35^f --9O41 --9O71+3 --9O92D0 --9O93$c --9OA2 --9} +-9 $! +-9 $5 +-9 *01 +-9 *56 +-9 *98 +-9 +0 +-9 -0 +-9 -4 +-7 '8 +-9 -9 +-9 -9 -9 +-9 -9 -9 -9 +-9 D1 +-9 D4 Z1 +-9 D7 +-9 L9 +-9 R8 +-9 T2 +-9 Z1 +-9 Z1 -6 +-9 Z2 +-9 ^1 +-9 ^5 O64 +-9 i6- +-9 l +-9 o64 +-9 o7b +-9 s09 +-9 s25 +-9 s4F +-9 s91 +-9 s9e +-9 u +-9 u O24 +-9 O02 t +-9 O15 o2* +-9 O16 ^p +-9 O17 +-9 O25 +-9 O35 ^f +-9 O41 +-9 O71 +3 +-9 O92 D0 +-9 O93 $c +-9 OA2 +-9 } -A --A*A8 --A+9 --ALA --AZ1 --Ai82 --Ao93 --AoB8 --AO01 --AO35 +-A *A8 +-A +9 +-A LA +-A Z1 +-A i82 +-A o93 +-A oB8 +-A O01 +-A O35 -B --B$3 --B$9 --B+A --B-8 --B-9 --B-A --BD7 --BZ1 --Bl --Bs21 --BO28'8 +-B $3 +-B $9 +-B +A +-B -8 +-B -9 +-B -A +-B D7 +-B Z1 +-B l +-B s21 +-B O28 '8 : -@ $sO62 -@ '9 -@ t -@ O49 -@!+5 -@#o88 -@*D3 +@ $s O62 +@ '9 +@ t +@ O49 +@! +5 +@# o88 +@* D3 @, -@.D6 -@.i5+ -@.t +@. D6 +@. i5+ +@. t @0 -@0$$ -@0+6R3 -@0+9 -@0-2 -@0@r -@0CC -@0D6 -@0T2 -@0Z1 -@0^4 -@0c -@0o4Y -@0o4x-7 -@0o8FO16 -@0s3- -@0s78 -@0O32 +@0 $$ +@0 +6 R3 +@0 +9 +@0 -2 +@0 @r +@0 C +@0 D6 +@0 T2 +@0 Z1 +@0 ^4 +@0 c +@0 o4Y +@0 o4x -7 +@0 o8F O16 +@0 s3- +@0 s78 +@0 O32 @1 -@1$5 -@1*9BO92 -@1+4o1@ -@1+6 -@1-5 -@1Z2 -@1Z3^S -@1Z5r -@1^a -@1d*13 -@1l -@1o5- -@1o64 -@1s3; -@1O42 -@1z1O23 -@1z3c +@1 $5 +@1 *9B O92 +@1 +4 o1@ +@1 +6 +@1 -5 +@1 Z2 +@1 Z3 ^S +@1 Z5 r +@1 ^a +@1 d *13 +@1 l +@1 o5- +@1 o64 +@1 s3; +@1 O42 +@1 z1 O23 +@1 z3 c @2 -@2$ -@2$1 -@2$5 -@2+2 -@2T7u -@2^7Z1 -@2^l -@2^n -@2i62u -@2l -@2l$x -@2o2e -@2o94 -@2oB9 -@2O42 -@2O71 -@2z1 +@2 $ +@2 $1 +@2 $5 +@2 +2 +@2 u +@2 ^7 Z1 +@2 ^l +@2 ^n +@2 i62 u +@2 l +@2 l $x +@2 o2e +@2 o94 +@2 oB9 +@2 O42 +@2 O71 +@2 z1 @3 -@3$9 -@3'A -@3*50 -@3-0c -@3Z1s52 -@3Z1z3 -@3i03 -@3i0y -@3o07 -@3se9 -@3z1 -@3z2 -@3z5q +@3 $9 +@3 'A +@3 *50 +@3 -0 c +@3 Z1 s52 +@3 Z1 z3 +@3 i03 +@3 i0y +@3 o07 +@3 se9 +@3 z1 +@3 z2 +@3 z5 q @4 -@4$_ -@4'6 -@4'A -@4-7'9 -@4D5 -@4L3r -@4[ -@4^K -@4d -@4l -@4O31 -@4O35 -@4O61c -@4O63C +@4 $_ +@4 '6 +@4 'A +@4 -7 '9 +@4 D5 +@4 L3 r +@4 [ +@4 ^K +@4 d +@4 l +@4 O31 +@4 O35 +@4 O61 c +@4 O63 C @5 -@5$ -@5$7 -@5+2 -@5+8'B -@5D2 -@5R3 -@5T4'8 -@5Z1L2 -@5^9 -@5^G+0 -@5^d -@5^j -@5^l -@5dO62 -@5o1e -@5o3r -@5O12Z3 -@5O25T0 -@5O43 +@5 $ +@5 $7 +@5 +2 +@5 +8 'B +@5 D2 +@5 R3 +@5 T4 '8 +@5 Z1 L2 +@5 ^9 +@5 ^G +0 +@5 ^d +@5 ^j +@5 ^l +@5 d O62 +@5 o1e +@5 o3r +@5 O12 Z3 +@5 O25 T0 +@5 O43 @6 -@6$! -@6$T'8 -@6'6 -@6*24[ -@6+8 -@6C -@6D4 -@6L2 -@6Z2 -@6i7_ -@6o57 -@6o5> -@6o5j[ -@6t -@6O31 +@6 $! +@6 $T '8 +@6 '6 +@6 *24 [ +@6 +8 +@6 C +@6 D4 +@6 L2 +@6 Z2 +@6 i7_ +@6 o57 +@6 o5> +@6 o5j [ +@6 t +@6 O31 @7 -@7$2 -@7'9 -@7+1 -@7+6 -@7@D -@7Z2*37 -@7[ -@7i42 -@7o1b -@7o3w -@7p1 -@7s50 -@7O04u -@7O26z1 -@7z1 -@7z4 +@7 $2 +@7 '9 +@7 +1 +@7 +6 +@7 @D +@7 Z2 *37 +@7 [ +@7 i42 +@7 o1b +@7 o3w +@7 p1 +@7 s50 +@7 O04 u +@7 O26 z1 +@7 z1 +@7 z4 @8 -@8'8 -@8+4s0A -@8@v -@8Z2O2A -@8^3 -@8i40 -@8i45C -@8i5V -@8o65 -@8t -@8z2 +@8 '8 +@8 +4 s0A +@8 @v +@8 Z2 O2A +@8 ^3 +@8 i40 +@8 i45 C +@8 i5V +@8 o65 +@8 t +@8 z2 @9 -@9$1 -@9'7 -@9D0Z3 -@9L2 -@9L4 -@9L5 -@9R1 -@9Z3 -@9[ -@9c -@9i3- -@9p1 -@9O53 -@9O65$1 -@9O92 -@9z1c -@9z4 -@@^f^7 -@BZ5 -@Do3) -@DO34 -@Fshr -@FO13 -@H'6^F -@H@1u -@Il -@Jc -@L[ -@Mi0D -@Mu +@9 $1 +@9 '7 +@9 D0 Z3 +@9 L2 +@9 L4 +@9 L5 +@9 R1 +@9 Z3 +@9 [ +@9 c +@9 i3- +@9 p1 +@9 O53 +@9 O65 $1 +@9 O92 +@9 z1 c +@9 z4 +@@ ^f ^7 +@B Z5 +@D o3) +@D O34 +@F shr +@F O13 +@H '6 ^F +@H @1 u +@I l +@J c +@L [ +@M i0D +@M u @N -@OO13 -@Qt -@XO04 +@O O13 +@Q t +@X O04 @a -@a$1 -@a$c -@a-3 -@aT0 -@ai7e -@al -@ao1g -@asw0 -@az2 -@az2O03 +@a $1 +@a $c +@a -3 +@a T0 +@a i7e +@a l +@a o1g +@a sw0 +@a z2 +@a z2 O03 @b -@b$Q -@bD1 -@b[z5 -@bcl -@bi0eO04 -@bi52 -@bs7b +@b $Q +@b D1 +@b [ z5 +@b l +@b i0e O04 +@b i52 +@b s7b @c -@c^O -@ct +@c ^O +@c t @d -@d'3Z5 -@d+2 -@d-0 -@dT3 -@dZ2i2v -@d[ -@di1q -@do6# -@du+1 -@dz3 +@d '3 Z5 +@d +2 +@d -0 +@d T3 +@d Z2 i2v +@d [ +@d i1q +@d o6# +@d u +1 +@d z3 @e -@ed -@ei6g'5 -@eo2j -@eo36i3d -@eo7k -@eO12 -@eO72 +@e d +@e '5 +@e o2j +@e o36 i3d +@e o7k +@e O12 +@e O72 @f -@f-2 -@fL4 -@fZ5 -@f[ -@f^# -@fd -@fz1 -@f{Z1 -@g'7 -@g*19O03 -@g*73 -@g+1 -@gC -@gD1 -@gZ2 -@gO05 -@gO61 +@f -2 +@f L4 +@f Z5 +@f [ +@f ^# +@f d +@f z1 +@f { Z1 +@g '7 +@g *19 O03 +@g *73 +@g +1 +@g C +@g D1 +@g Z2 +@g O05 +@g O61 @h -@h$4 -@h-2 -@h-3 -@h-7 -@hZ1 -@h[ -@h^a -@h^s -@hi2Z^H -@hi6sD5 -@hlp1 -@ho4g -@hO36 -@hO41 -@hO54 -@hO63 +@h $4 +@h -2 +@h -3 +@h -7 +@h Z1 +@h [ +@h ^a +@h ^s +@h i2Z ^H +@h i6s D5 +@h l p1 +@h o4g +@h O36 +@h O41 +@h O54 +@h O63 @i -@i$a -@i'9c -@i*06 -@iD1Z1 -@iD3 -@iR1 -@iZ1 -@ic -@il -@io4e -@itu -@iO36^g -@iz1 -@iz2O26 +@i $a +@i '9 c +@i *06 +@i D1 Z1 +@i D3 +@i R1 +@i Z1 +@i c +@i l +@i o4e +@i u +@i O36 ^g +@i z1 +@i z2 O26 @j -@j-0 -@jZ4 -@j^a -@jc -@jO32 +@j -0 +@j Z4 +@j ^a +@j c +@j O32 @k -@k*31L0 -@kD3 -@kD5 -@kR1 -@kZ1 -@kZ4t -@k^j -@k^w-1 -@kco3L -@kO46 -@kO53-3 -@kO67 -@l$c -@l'6 -@l'9 -@lT3-1 -@l^f -@li0nt -@li2E -@lO42 -@lz1 -@lz2O07 +@k *31 L0 +@k D3 +@k D5 +@k R1 +@k Z1 +@k Z4 t +@k ^j +@k ^w -1 +@k c o3L +@k O46 +@k O53 -3 +@k O67 +@l $c +@l '6 +@l '9 +@l T3 -1 +@l ^f +@l i0n t +@l i2E +@l O42 +@l z1 +@l z2 O07 @m -@m*27 -@m-1 -@m-4^4 -@mD2 -@mT3o2y -@mT6-2 -@mZ2L2 -@mi0T -@mi0d -@mqz4 -@mO24 +@m *27 +@m -1 +@m -4 ^4 +@m D2 +@m T3 o2y +@m T6 -2 +@m Z2 L2 +@m i0T +@m i0d +@m q z4 +@m O24 @n -@n$8Z3 -@n+3 -@n-3 -@n-5 -@nZ2 -@n[ -@n^m -@nl+7 -@np1 -@nsbd -@nO56 -@n}i7r +@n $8 Z3 +@n +3 +@n -3 +@n -5 +@n Z2 +@n [ +@n ^m +@n l +7 +@n p1 +@n sbd +@n O56 +@n } i7r @o -@o$t -@o'4 -@o'7 -@o+6 -@o@i -@o^Z -@oi1s -@oi5z -@oO12 -@oO25 -@oOA2O52 -@o} -@p-2i2l -@p-3 -@pO23 -@pO31 -@pO53 +@o $t +@o '4 +@o '7 +@o +6 +@o @i +@o ^Z +@o i1s +@o i5z +@o O12 +@o O25 +@o OA2 O52 +@o } +@p -2 i2l +@p -3 +@p O23 +@p O31 +@p O53 @q @r -@r$g -@r'5 -@r+8 -@r-7D3 -@rD2 -@r^$L9 -@r^n -@rl -@ro1s -@rO02Z3 -@rO09 -@rO16O32 -@rO41 -@rO48 -@rO71 +@r $g +@r '5 +@r +8 +@r -7 D3 +@r D2 +@r ^$ L9 +@r ^n +@r l +@r o1s +@r O02 Z3 +@r O09 +@r O16 O32 +@r O41 +@r O48 +@r O71 @s -@s*7AO39 -@sD6 -@s^l -@si1Ho1n -@sl -@ssix -@ssux -@su -@sO07 -@sO35 -@t+3o2t -@t+8 -@t-1 -@t@d -@tR1 -@t^c -@tc$d -@tp1 -@tqO64 -@t} -@u+2[ -@uR4 -@uZ4 -@ul -@uo3c -@uo53 -@uO12 -@uz1 +@s *7A O39 +@s D6 +@s ^l +@s i1H o1n +@s l +@s six +@s sux +@s u +@s O07 +@s O35 +@t +3 o2t +@t +8 +@t -1 +@t @d +@t R1 +@t ^c +@t c $d +@t p1 +@t q O64 +@t } +@u +2 [ +@u R4 +@u Z4 +@u l +@u o3c +@u o53 +@u O12 +@u z1 @v -@v$a -@v'6 -@v+0 -@vZ1$p -@v[ -@vk^w -@vo5g -@vz2O13 -@w[ -@wd -@wO02 -@wz1 +@v $a +@v '6 +@v +0 +@v Z1 $p +@v [ +@v k ^w +@v o5g +@v z2 O13 +@w [ +@w d +@w O02 +@w z1 @x -@x[ -@xc -@xO41o2X +@x [ +@x c +@x O41 o2X @y -@y$rO01 -@y'5R1 -@y^"O05 -@y^G -@y^i -@yi4- -@yo3" -@yO81R8 -@z$! -@z$8 -@z*04[ -@zD5 -@zo43 -@zrO07 -@zO31 -@zO53 -@zz1 +@y $r O01 +@y '5 R1 +@y ^" O05 +@y ^G +@y ^i +@y i4- +@y o3" +@y O81 R8 +@z $! +@z $8 +@z *04 [ +@z D5 +@z o43 +@z r O07 +@z O31 +@z O53 +@z z1 C -C$* -C$1 -C$5 -C$5z4 -C$? -C$E -C$F'8 -C$X -C$a@l -C$f^8 -C$g^9 -C$l -C$lsVu -C$m$? -C$m*15 -C$s -C$x -C'3 -C'5u -C*05^P -C*61 -C*71 -C+1 -C+2 -C+4 -C+5 -C+6 -C+7 -C+9O34 -C+AO53 -C-1 -C-2 -C-4 -C-5 -C-7 -C-9 -C@2o2f -C@g -CCi6Z -CD3 -CD4 -CD5 -CD9-5 -CL1Z1 -CL4 -CL5 -CR0 -CR1 -CR2R8 -CR4 -CT1 -CT3 -CT3sJw -CT4 -CT5 -CT7 -CT8 -CT8o1+ -CT9 -CTA -CZ2 -CZ2q -CZ3 -CZ3-5 -CZ3^% -CZ4 -CZ4O38 -CZ5 -C[+6 -C^0 -C^4z2 -C^5 -C^7 -C^G -C^Hi1/ -C^S -C^To1F -C^W -C^X -C^_ -C^a -C^g -C^k -C^l'6 -C^m -C^w -C^y -C^|i3$ -Cd -Cf -Ci0& -Ci18 -Ci1s -Ci20$a -Ci21 -Ci2I[ -Ci2cr -Ci3-sY| -Ci32'A -Ci3<$E -Ci4P -Ci64 -Ci9v -CiBiO37 -Ck -Ck$2 -Co0P -Co0R -Co1" -Co17 -Co1K] -Co1S -Co1Y -Co1a -Co1e -Co1i -Co1o -Co2 -Co2! -Co2( -Co21 -Co2V -Co2a -Co2i -Co2uz3 -Co31 -Co3D -Co3GC -Co3Sz1 -Co3d -Co4! -Co4$ -Co4( -Co4F -Co4b -Co5S -Co60 -Co6: -Co7( -Co77 -Cp1r -Cq -Cr -Cr$h -Cs.n -Cs04 -Cs29 -Cs49 -Cs4K -Cs4b -Cs5PD0 -Cs62 -Cs7?Z1 -Cs8M -CsMz -Csg5 -Csi2 -Csj'*52 -CsjyR5 -CssN -CuD9 -CO01-5 -CO02 -CO03q -CO04 -CO04O19 -CO12 -CO12^c -CO15 -CO25 -CO31[ -CO42 -CO42T3 -CO48 -CO52 -CO53 -CO73 -CO92 -Cz1 -Cz1'8 -Cz2 -Cz2o04 -Cz2O36 -Cz3O52 -Cz3z2 -Cz4 -C} -D0$) -D0$+ -D0$q -D0$t -D0'B -D0*01} -D0*14 -D0*30t -D0-0z5 -D0@7 -D0@8Z2 -D0@e$& -D0@x -D0D1k -D0L4D1 -D0R0Z5 -D0R2t -D0R4 -D0RA -D0T7O24 -D0Z1sbj -D0^" -D0^/ -D0^G -D0^N -D0^V -D0^u -D0i1 -D0i1V -D0i1h -D0i2m -D0i3m -D0i4o -D0i5ZO3A -D0i5x -D0k -D0kt -D0o0k -D0o1M -D0o1mz3 -D0o2R -D0o2eO35 -D0o3m -D0o3n -D0o3p -D0o4e -D0o6W -D0oB2 -D0p1O15 -D0p1O21 -D0p1z5 -D0s30 -D0s30z3 -D0s4C -D0s7b -D0s9A -D0s@# -D0se6 -D0seh -D0sfw -D0skv -D0smd -D0spe -D0u^E -D0O13 -D0O43 -D0O47 -D0O56 -D0O91c -D0z4o5' -D0} -D0}*54 +C $* +C $1 +C $5 +C $5 z4 +C $? +C $E +C $F '8 +C $X +C $a @l +C $f ^8 +C $g ^9 +C $l +C $l sVu +C $m $? +C $m *15 +C $s +C $x +C '3 +'5 u +C *05 ^P +C *61 +C *71 +C +1 +C +2 +C +4 +C +5 +C +6 +C +7 +C +9 O34 +C +A O53 +C -1 +C -2 +C -4 +C -5 +C -7 +C -9 +C @2 o2f +C @g +C i6Z +C D3 +C D4 +C D5 +C D9 -5 +C L1 Z1 +C L4 +C L5 +C R0 +C R1 +C R2 R8 +C R4 +C T1 +C T3 +C T3 sJw +C T4 +C T5 +C T7 +C T8 +C T8 o1+ +C T9 +C TA +C Z2 +C Z2 q +C Z3 +C Z3 -5 +C Z3 ^% +C Z4 +C Z4 O38 +C Z5 +C [ +6 +C ^0 +C ^4 z2 +C ^5 +C ^7 +C ^G +C ^H i1/ +C ^S +C ^T o1F +C ^W +C ^X +C ^_ +C ^a +C ^g +C ^k +C ^l '6 +C ^m +C ^w +C ^y +C ^| i3$ +C d +C f +C i0& +C i18 +C i1s +C i20 $a +C i21 +C i2I [ +C i2c r +C i3- sY| +C i32 'A +C i3< $E +C i4P +C i64 +C i9v +C iBi O37 +C k +C k $2 +C o0P +C o0R +C o1" +C o17 +C o1K ] +C o1S +C o1Y +C o1a +C o1e +C o1i +C o1o +C o2 +C o2! +C o2( +C o21 +C o2V +C o2a +C o2i +C o2u z3 +C o31 +C o3D +C o3G +C o3S z1 +C o3d +C o4! +C o4$ +C o4( +C o4F +C o4b +C o5S +C o60 +C o6: +C o7( +C o77 +C p1 r +C q +C r +C r $h +C s.n +C s04 +C s29 +C s49 +C s4K +C s4b +C s5P D0 +C s62 +C s7? Z1 +C s8M +C sMz +C sg5 +C si2 +C sj' *52 +C sjy R5 +C ssN +u D9 +C O01 -5 +C O02 +C O03 q +C O04 +C O04 O19 +C O12 +C O12 ^c +C O15 +C O25 +C O31 [ +C O42 +C O42 T3 +C O48 +C O52 +C O53 +C O73 +C O92 +C z1 +C z1 '8 +C z2 +C z2 o04 +C z2 O36 +C z3 O52 +C z3 z2 +C z4 +C } +D0 $) +D0 $q +D0 $t +D0 'B +D0 *01 } +D0 *14 +D0 *30 t +D0 -0 z5 +D0 @8 Z2 +D0 @e $& +D0 D1 k +D0 L4 D1 +D0 R0 Z5 +D0 R2 t +D0 R4 +D0 RA +D0 T7 O24 +D0 Z1 sbj +D0 ^" +o0/ +o0G +D0 ^N +o0V +o0u +D0 i1 +D0 i1V +D0 i1h +D0 i2m +D0 i3m +D0 i4o +D0 i5Z O3A +D0 i5x +D0 k +D0 k t +D0 o0k +D0 o1M +D0 o1m z3 +D0 o2R +D0 o2e O35 +D0 o3m +D0 o3n +D0 o3p +D0 o4e +D0 o6W +D0 oB2 +D0 p1 O15 +D0 p1 O21 +D0 p1 z5 +D0 s30 +D0 s30 z3 +D0 s4C +D0 s7b +D0 s9A +D0 s@# +D0 se6 +D0 seh +D0 sfw +D0 skv +D0 smd +D0 spe +D0 u ^E +D0 O13 +D0 O43 +D0 O47 +D0 O56 +D0 O91 c +D0 z4 o5' +D0 } +D0 } *54 D1 -D1$$ -D1$0 -D1$1 -D1$3 -D1$L -D1$^[ -D1$l -D1$m -D1$r -D1$u -D1'6-3 -D1'7 -D1'A -D1*10Z2 -D1*13 -D1*21 -D1+0 -D1+3 -D1+5 -D1@o -D1C -D1D2 -D1D2^I -D1D4 -D1D5 -D1K -D1L0 -D1L1 -D1L2@9 -D1L3 -D1R0 -D1T1 -D1T2 -D1T3 -D1Z1 -D1Z2O54 -D1Z4 -D1^% -D1^0 -D1^2 -D1^4 -D1^5 -D1^7 -D1^;i2P -D1^N -D1^Q -D1^U -D1^b -D1^d -D1^g -D1^p -D1^s -D1^sz2 -D1^t -D1^u -D1^v -D1fr -D1i0/ -D1i0Z-5 -D1i0h -D1i2t -D1i3! -D1i3K -D1i4p -D1i5+ -D1i5nO53 -D1i8yO23 -D1k -D1l -D1o1d -D1o2c -D1o2g -D1o2h -D1o3O -D1o3Y -D1o4?Z1 -D1o5h -D1o79l -D1o7o -D1p1 -D1p1i4- -D1q -D1r{ -D1sds -D1si6 -D1sih -D1sn_ -D1sv[ -D1t -D1u -D1usD4 -D1O24 -D1O27 -D1O72 -D1O91 -D1z1 -D1z2 -D1z4 -D1z4@4 +D1 $$ +D1 $0 +D1 $1 +D1 $3 +D1 $L +D1 $^ [ +D1 $l +D1 $m +D1 $r +D1 $u +D1 '6 -3 +D1 '7 +D1 'A +D1 *10 Z2 +D1 *13 +D1 *21 +D1 +0 +D1 +3 +D1 +5 +D1 @o +D1 C +D1 D2 +D1 D2 ^I +D1 D4 +D1 D5 +D1 K +D1 L0 +D1 L1 +D1 L2 @9 +D1 L3 +D1 R0 +D1 T1 +D1 T2 +D1 T3 +D1 Z1 +D1 Z2 O54 +D1 Z4 +D1 ^% +D1 ^0 +D1 ^2 +D1 ^4 +D1 ^5 +D1 ^7 +D1 ^; i2P +D1 ^N +D1 ^Q +D1 ^U +D1 ^b +D1 ^d +D1 ^g +D1 ^p +D1 ^s +D1 ^s z2 +D1 ^t +D1 ^u +D1 ^v +D1 f +D1 i0/ +D1 i0Z -5 +D1 i0h +D1 i2t +D1 i3! +D1 i3K +D1 i4p +D1 i5+ +D1 i5n O53 +D1 i8y O23 +D1 k +D1 l +D1 o1d +D1 o2c +D1 o2g +D1 o2h +D1 o3O +D1 o3Y +D1 o4? Z1 +D1 o5h +D1 o79 l +D1 o7o +D1 p1 +D1 p1 i4- +D1 q +D1 r { +D1 sds +D1 si6 +D1 sih +D1 sn_ +D1 sv[ +D1 t +D1 u +D1 u sD4 +D1 O24 +D1 O27 +D1 O72 +D1 O91 +D1 z1 +D1 z2 +D1 z4 +D1 z4 @4 D2 -D2$$ -D2$$u -D2$+D0 -D2$, -D2$. -D2$0 -D2$1 -D2$; -D2$@ -D2$IZ1 -D2$S -D2$` -D2$f -D2$l -D2$mo5: -D2$o -D2$t -D2$w -D2'6 -D2'7 -D2'A -D2*02 -D2*46 -D2*53 -D2+3 -D2+5i5# -D2-5 -D2-6 -D2@c -D2@iO32 -D2@n -D2C -D2D2 -D2D3 -D2L2 -D2R1 -D2R4 -D2R6 -D2T0 -D2T3 -D2T4 -D2T5 -D2T6 -D2T6sdy -D2Z1p1 -D2Z2 -D2Z4 -D2^, -D2^1 -D2^6 -D2^B -D2^N -D2^ar -D2^f -D2^m -D2c -D2c$N -D2cL3 -D2d -D2di1g -D2do5e -D2i49 -D2i5C -D2i6r -D2i6u -D2i7i -D2l -D2o0: -D2o0D -D2o0l -D2o1l{ -D2o1o -D2o2S -D2o4 -D2o6 -D2o6B -D2o6h -D2o6y -D2o7q -D2s1` -D2s3- -D2sgc -D2sgy -D2sm1 -D2soV -D2suq -D2t -D2tZ3 -D2u -D2u'4 -D2O07 -D2O14Z4 -D2O32z2 -D2O34-1 -D2O45 -D2O53 -D2O73 -D2O84 -D2z1 -D2z1u -D2z2 -D2z4 -D2z4u -D2} +D2 $$ +D2 $$ u +D2 $+ D0 +D2 $, +D2 $. +D2 $1 +D2 $; +D2 $@ +D2 $I Z1 +D2 $S +D2 $` +D2 $f +D2 $l +D2 $m o5: +D2 $o +D2 $t +D2 $w +D2 '6 +D2 '7 +D2 'A +D2 *02 +D2 *46 +D2 *53 +D2 +3 +D2 +5 i5# +D2 -5 +D2 -6 +D2 @c +D2 @i O32 +D2 @n +D2 C +D2 D2 +D2 D3 +D2 L2 +D2 R1 +D2 R4 +D2 R6 +D2 T0 +D2 T3 +D2 T4 +D2 T5 +D2 T6 +D2 T6 sdy +D2 Z1 p1 +D2 Z2 +D2 Z4 +D2 ^, +D2 ^1 +D2 ^6 +D2 ^B +D2 ^N +D2 ^a r +D2 ^f +D2 ^m +D2 c +D2 c $N +D2 c L3 +D2 d +D2 d i1g +D2 d o5e +D2 i49 +D2 i5C +D2 i6r +D2 i6u +D2 i7i +D2 l +D2 o0: +D2 o0D +D2 o0l +D2 o1l { +D2 o1o +D2 o2S +D2 o4 +D2 o6 +D2 o6B +D2 o6h +D2 o6y +D2 o7q +D2 s1` +D2 s3- +D2 sgc +D2 sgy +D2 sm1 +D2 soV +D2 suq +D2 t +D2 t Z3 +D2 u +D2 u '4 +D2 O07 +D2 O14 Z4 +D2 O32 z2 +D2 O34 -1 +D2 O45 +D2 O53 +D2 O73 +D2 O84 +D2 z1 +D2 z1 u +D2 z2 +D2 z4 +D2 z4 u +D2 } D3 -D3$ -D3$* -D3$. -D3$0 -D3$2 -D3$? -D3$H -D3$X -D3$a -D3$b -D3$g -D3$w -D3$x -D3$z -D3'7 -D3'B -D3*34 -D3*4AO06 -D3*51 -D3*56 -D3*56k -D3+1 -D3+4Z5 -D3+6 -D3+6} -D3+AO64 -D3-1 -D3-1c -D3-6 -D3-8 -D3@6 -D3@d -D3@j^A -D3@t -D3C$1 -D3D8 -D3DBO07 -D3R0 -D3R2 -D3R3 -D3T3 -D3T5 -D3Z1o1q -D3Z3 -D3Z4^H -D3] -D3^6 -D3^8 -D3^J -D3^O -D3^c -D3^eo2. -D3^i*42 -D3^p -D3^z -D3c -D3csAl -D3d -D3d*30 -D3i0' -D3i0L -D3i0i -D3i2. -D3i24 -D3i3_ -D3i4* -D3i4k -D3i4m -D3i5n -D3k -D3l -D3l$n -D3o0N -D3o0S -D3o0b -D3o0hs!n -D3o13 -D3o1g -D3o1h -D3o1z[ -D3o2_ -D3o33[ -D3o3hd -D3o3jZ2 -D3o55 -D3o5t -D3o6n -D3o71O54 -D3o8i -D3o8y -D3p1+6 -D3q -D3s3 -D3s9D -D3sao -D3sbz -D3sea -D3slWO65 -D3t -D3tZ1 -D3u$4 -D3O32C -D3O41^s -D3O47 -D3O71 -D3OA1D4 -D3OA1O54 -D3z1 -D3z2 -D3z3 -D3z3t -D3z4 -D3z5 +D3 $ +D3 $* +D3 $. +D3 $0 +D3 $2 +D3 $? +D3 $H +D3 $X +D3 $b +D3 $g +D3 $w +D3 $x +D3 $z +D3 '7 +D3 'B +D3 *34 +D3 *4A O06 +D3 *51 +D3 *56 +D3 *56 k +D3 +1 +D3 +4 Z5 +D3 +6 +D3 +6 } +D3 +A O64 +D3 -1 +D3 -1 c +D3 -6 +D3 -8 +D3 @6 +D3 @d +D3 @j ^A +D3 @t +D3 C $1 +D3 D8 +D3 DB O07 +D3 R0 +D3 R2 +D3 R3 +D3 T3 +D3 T5 +D3 Z1 o1q +D3 Z3 +D3 Z4 ^H +D3 ] +D3 ^6 +D3 ^8 +D3 ^J +D3 ^O +D3 ^c +D3 ^e o2. +D3 ^i *42 +D3 ^p +D3 ^z +D3 c +D3 c sAl +D3 d +D3 d *30 +D3 i0' +D3 i0L +D3 i0i +D3 i2. +D3 i24 +D3 i3_ +D3 i4* +D3 i4k +D3 i4m +D3 i5n +D3 k +D3 l +D3 l $n +D3 o0N +D3 o0S +D3 o0b +D3 o0h s!n +D3 o13 +D3 o1g +D3 o1h +D3 o1z [ +D3 o2_ +D3 o33 [ +D3 o3h d +D3 o3j Z2 +D3 o55 +D3 o5t +D3 o6n +D3 o71 O54 +D3 o8i +D3 o8y +D3 p1 +6 +D3 q +D3 s3 +D3 s9D +D3 sao +D3 sbz +D3 sea +D3 slW O65 +D3 t +D3 t Z1 +D3 u $4 +D3 O32 C +D3 O41 ^s +D3 O47 +D3 O71 +D3 OA1 D4 +D3 OA1 O54 +D3 z1 +D3 z2 +D3 z3 +D3 z3 t +D3 z4 +D3 z5 D4 -D4$# -D4$$ -D4$&-0 -D4$0 -D4$1 -D4$Q -D4$So1* -D4$` -D4$cc -D4$f -D4$q -D4$u -D4'7 -D4'7C -D4*14 -D4*15 -D4*21T4 -D4*25 -D4*62 -D4*85 -D4+3 -D4-7 -D4-B -D4@h -D4D1$/ -D4D2{ -D4D7 -D4L5 -D4L6 -D4R3 -D4T1 -D4T5 -D4T6 -D4Z1 -D4Z2D0 -D4Z3O32 -D4[$y -D4]o6m -D4^0*20 -D4^A -D4^K -D4^X -D4^Y -D4^p -D4^q -D4^x -D4^z -D4f -D4i20 -D4i3l -D4i4C -D4i6s -D4i7u -D4kL7 -D4l*87 -D4o0b -D4o0g -D4o0m -D4o13 -D4o2b -D4o4 -D4o4/ -D4o4@s9R -D4o4p -D4o4} -D4o5+D4 -D4o5_T0 -D4o5k -D4o7b -D4o7o -D4o83 -D4p1 -D4q -D4r -D4s.? -D4s3v -D4sahK -D4sg -D4sg- -D4sj# -D4sj9^H -D4skD -D4ssx -D4stG -D4sxp -D4t -D4t{ -D4O02 -D4O31Z5 -D4O32Z4 -D4O65 -D4OB1O04 -D4z1O62 -D4z1} -D4z2^h -D4z4i9a -D4{O21 -D4} +D4 $# +D4 $$ +D4 $& -0 +D4 $0 +D4 $1 +D4 $Q +D4 $S o1* +D4 $` +D4 $c c +D4 $f +D4 $q +D4 $u +D4 '7 +D4 '7 C +D4 *14 +D4 *15 +D4 *21 T4 +D4 *25 +D4 *62 +D4 *85 +D4 +3 +D4 -7 +D4 -B +D4 @h +D4 D1 $/ +D4 D2 { +D4 D7 +D4 L5 +D4 L6 +D4 R3 +D4 T1 +D4 T5 +D4 T6 +D4 Z1 +D4 Z2 D0 +D4 Z3 O32 +D4 [ $y +D4 ] o6m +D4 ^0 *20 +D4 ^A +D4 ^K +D4 ^X +D4 ^Y +D4 ^p +D4 ^q +D4 ^x +D4 ^z +D4 f +D4 i20 +D4 i3l +D4 i4C +D4 i6s +D4 i7u +D4 k L7 +D4 l *87 +D4 o0b +D4 o0g +D4 o0m +D4 o13 +D4 o2b +D4 o4 +D4 o4/ +D4 o4@ s9R +D4 o4p +D4 o4} +D4 o5+ D4 +D4 o5_ T0 +D4 o5k +D4 o7b +D4 o7o +D4 o83 +D4 p1 +D4 q +D4 r +D4 s.? +D4 s3v +D4 sah K +D4 sg +D4 sg- +D4 sj# +D4 sj9 ^H +D4 skD +D4 ssx +D4 stG +D4 sxp +D4 t +D4 t { +D4 O02 +D4 O31 Z5 +D4 O32 Z4 +D4 O65 +D4 OB1 O04 +D4 z1 O62 +D4 z1 } +D4 z2 ^h +D4 z4 i9a +D4 { O21 +D4 } D5 -D5$" -D5$1 -D5$1T6 -D5$7 -D5$R -D5$a -D5$i -D5$w -D5'B -D5*12 -D5*24 -D5*41 -D5*45 -D5*46 -D5*57 -D5*65 -D5+6 -D5-1i83 -D5-8 -D5@9z1 -D5@i -D5@k -D5@r -D5D7 -D5DA -D5K*43 -D5K+2 -D5L4 -D5L8 -D5R1 -D5R4 -D5T0 -D5Z2*05 -D5[$z -D5^) -D5^6 -D5^: -D5^J -D5^g -D5^o -D5d -D5i0p -D5i1j -D5i2 -D5i3o-3 -D5i4B -D5i6f -D5i72 -D5i7c -D5l -D5o0- -D5o0H -D5o1a -D5o2_ -D5o3%Z1 -D5o3q -D5o4# -D5o4+ -D5o4l -D5o57R6 -D5o5 -Kz2O23 -Kz3$3 -Kz4 -K{ -K{z2 -K} -K}o5v -K}} -L0$(Z2 -L0$O[ -L0$g -L0$l -L0*13T1 -L0+1 -L0+2 -L0+3o0$ -L0+4o5K -L0-5 -L0-7 -L0L0 -L0L1 -L0L5 -L0R0 -L0T0s67 -L0T2 -L0Z1 -L0Z2Z2 -L0Z5 -L0[o78 -L0^K -L0^f -L0^h -L0^sl -L0^w -L0^z -L0c -L0dO19 -L0i0O -L0i2/$i -L0i60 -L0l'7 -L0o1. -L0o21 -L0o21z1 -L0o2a -L0o4D -L0o56 -L0o5c -L0p1 -L0s6u -L0sdu -L0u -L0O02^A -L0O05$D -L0O12 -L0O14i14 -L0O14u -L0O16 -L0O17 -L0O26 -L0O31 -L0O41 -L0O46 -L0O51 -L0O53 -L0z1 -L0z2 -L0z3i8U -L0{ -L0} +DB $4 +DB $6 +DB $7 +DB $e +C 'B +DB D0 +DB l +DB l +A +DB oB! +DB s68 +DB O05 +DB O06 +DB O13 +DB O15 +DB O62 +DB O64 +DB O71 +DB O76 O41 +DB O91 +K $$ +K $0 z1 +K $2 +K $9 +K $G +K $H c +K $c +K $d i1: +K $e +K $f +K $g +K $h +K $i +K $j s-a +K $q +K $s +K $z [ +K *13 +K *16 +K *25 *30 +K *32 +K *43 +K *53 O41 +K *54 +K *62 z3 +K +1 +K +1 *50 +K +2 +K -5 *43 +K C ^c +K R3 +K T0 o6m +K Z1 +K Z1 R4 +K Z1 i6- +K Z2 +K Z3 +K Z4 +K Z4 *15 +K Z5 +K [ +K [ } +K ^0 +K ^0 +0 +K ^2 +K ^= +K ^H +K ^K +K ^S +K ^S i5w +K ^_ +K ^f +K ^g +K ^l +K ^o $z +K ^y +K c +K c i00 +K d u +K d O0B +K f +K i04 l +K i05 +K i0J +K i0x z1 +K i2- R4 +K i2F +K i37 +K i3N +K i3m +K i3t +K i4a l +K i4s +K i6s +K k $d +K k o4p +K o1F *74 +K o1i +K o2$ +K o2- +K o25 +K o3- +K o34 +K o3d +K o40 +K o40 Z1 +K o48 +K o56 +K o5o +K o5r i6= +K o5y +K o82 +K p1 c +K p2 O1A +K q +K r *46 +K r p1 +K se4 i4+ +K ser +K sex +K srp o4d +K szs +K t +K t *45 +K u Z1 +K u r +K O03 p1 +K O21 +K O32 +K O42 +K z1 +K z2 +K z2 R7 +K z2 i5> +K z2 O23 +K z3 $3 +K z4 +K { +K { z2 +K } +K } o5v +K } } +L0 $( Z2 +$O [ +L0 $g +L0 $l +L0 *13 T1 +L0 +1 +L0 +2 ++3 o0$ +L0 +4 o5K +L0 -5 +L0 -7 +L0 L0 +L0 L1 +L0 L5 +L0 R0 +L0 T0 s67 +L0 T2 +L0 Z1 +L0 Z2 Z2 +L0 Z5 +[ o78 +L0 ^K +L0 ^f +L0 ^h +L0 ^s l +L0 ^w +L0 ^z +L0 c +L0 d O19 +L0 i0O +L0 i2/ $i +L0 i60 +L0 l '7 +L0 o1. +L0 o21 +L0 o21 z1 +L0 o2a +L0 o4D +L0 o56 +L0 o5c +L0 p1 +L0 s6u +L0 sdu +L0 u +L0 O02 ^A +L0 O05 $D +L0 O12 +L0 O14 i14 +L0 O14 u +L0 O16 +L0 O17 +L0 O26 +L0 O31 +L0 O41 +L0 O46 +L0 O51 +L0 O53 +L0 z1 +L0 z2 +L0 z3 i8U +L0 { +L0 } L1 -L1$3R1 -L1$M$d -L1$d -L1$xO19 -L1'3 -L1*15 -L1*62 -L1*79D6 -L1+1 -L1+7 -L1-0 -L1-4 -L1-7 -L1D5'9 -L1R0 -L1R1 -L1R5 -L1T0 -L1Z1+5 -L1Z5O52 -L1[ -L1^Z*45 -L1^o -L1^r*7A -L1i0L -L1i0h -L1i0z -L1i27 -L1i2f -L1i3e -L1i4d -L1o0L -L1o1ti4b -L1o25 -L1o2n -L1o8`O67 -L1p1o3w -L1qz5 -L1s#U -L1sa3 -L1sw@'6 -L1t -L1O23 -L1O26 -L1O35 -L1O41 -L1O42 -L1O52 -L1z1 -L1z1*58 -L1z4^ -L1{ -L1{z4 +L1 $3 R1 +L1 $M $d +L1 $d +L1 $x O19 +L1 '3 +L1 *15 +L1 *62 +L1 *79 D6 +L1 +1 +L1 +7 +L1 -0 +L1 -4 +L1 -7 +L1 D5 '9 +L1 R0 +L1 R1 +L1 R5 +L1 T0 +L1 Z1 +5 +L1 Z5 O52 +L1 [ +L1 ^Z *45 +L1 ^o +L1 ^r *7A +L1 i0L +L1 i0h +L1 i0z +L1 i27 +L1 i2f +L1 i3e +L1 i4d +L1 o0L +o1t i4b +L1 o25 +L1 o2n +L1 o8` O67 +L1 p1 o3w +L1 q z5 +L1 s#U +L1 sa3 +L1 sw@ '6 +L1 t +L1 O23 +L1 O26 +L1 O35 +L1 O41 +L1 O42 +L1 O52 +L1 z1 +L1 z1 *58 +L1 z4 ^ +L1 { +L1 { z4 L2 -L2$-i4e -L2$7O26 -L2$al -L2'4z3 -L2'5i3d -L2*14$/ -L2*23d -L2*3AO34 -L2+5 -L2-1 -L2@3 -L2@9 -L2@l -L2@mR3 -L2D3 -L2L4 -L2L7D0 -L2LAO49 -L2R2 -L2R4 -L2T1 -L2Z1 -L2Z2 -L2Z5 -L2^b -L2i2vi2s -L2i3l -L2o6`$8 -L2o7a -L2p1 -L2r -L2r$; -L2s6u -L2s9d -L2sd_C -L2sds -L2t -L2u -L2O02 -L2O02Z1 -L2O38$Q -L2z2 -L2z3 -L2} +L2 $- i4e +L2 $7 O26 +L2 $a l +L2 '4 z3 +L2 '5 i3d +L2 *14 $/ +L2 *23 d +L2 *3A O34 +L2 +5 +L2 -1 +L2 @3 +L2 @9 +L2 @l +L2 @m R3 +L2 D3 +L2 L4 +L2 L7 D0 +L2 LA O49 +L2 R2 +L2 R4 +L2 T1 +L2 Z1 +L2 Z2 +L2 Z5 +L2 ^b +L2 i2v i2s +L2 i3l +L2 o6` $8 +L2 o7a +L2 p1 +L2 r +L2 r $; +L2 s6u +L2 s9d +L2 sd_ C +L2 sds +L2 t +L2 u +L2 O02 +L2 O02 Z1 +L2 O38 $Q +L2 z2 +L2 z3 +L2 } L3 -L3$a-1 -L3$q -L3$v[ -L3*32 -L3*35 -L3*79 -L3+0'6 -L3+1 -L3+2$4 -L3+3 -L3+3$l -L3+4 -L3+5 -L3-4 -L3-4$e -L3-5 -L3-6 -L3-8O24 -L3@6 -L3@z -L3C^T -L3Ko3c -L3L1 -L3R3 -L3Z1 -L3Z3 -L3Z4O67 -L3[ -L3^E -L3^H -L3^J -L3c^d -L3d -L3i4; -L3i4k -L3l -L3o0[ -L3o56 -L3sb` -L3sl` -L3slkT0 -L3swjO32 -L3O02 -L3O34Z4 -L3O52 -L3O62 -L3z1 -L3z2saV -L3z4 -L3{ -L3} +L3 $a -1 +L3 $q +L3 $v [ +L3 *32 +L3 *35 +L3 *79 +L3 +0 '6 +L3 +1 +L3 +2 $4 +L3 +3 +L3 +3 $l +L3 +4 +L3 +5 +L3 -4 +L3 -4 $e +L3 -5 +L3 -6 +L3 -8 O24 +L3 @6 +L3 @z +L3 C ^T +L3 K o3c +L3 L1 +L3 R3 +L3 Z1 +L3 Z3 +L3 Z4 O67 +L3 [ +L3 ^E +L3 ^H +L3 ^J +L3 c ^d +L3 d +L3 i4; +L3 i4k +L3 l +L3 o0[ +L3 o56 +L3 sb` +L3 sl` +L3 slk T0 +L3 swj O32 +L3 O02 +L3 O34 Z4 +L3 O52 +L3 O62 +L3 z1 +L3 z2 saV +L3 z4 +L3 { +L3 } L4 -L4$3 -L4'5 -L4'6 -L4*14 -L4+5o49 -L4-6 -L4@0 -L4D3 -L4L4 -L4R0 -L4T1-5 -L4Z1 -L4Z2 -L4Z3 -L4Z4 -L4[ -L4^aO16 -L4^e -L4i0X -L4i2Wo4z -L4i2a -L4l -L4o2a@< -L4r -L4tD2 -L4u -L4u$O -L4O04 -L4O37-3 -L4z1 +L4 $3 +L4 '5 +L4 '6 +L4 *14 ++5 o49 +L4 -6 +L4 @0 +L4 D3 +L4 L4 +L4 R0 +L4 T1 -5 +L4 Z1 +L4 Z2 +L4 Z3 +L4 Z4 +L4 [ +L4 ^a O16 +L4 ^e +L4 i0X +L4 i2W o4z +L4 i2a +L4 l +L4 o2a @< +L4 r +L4 t D2 +L4 u +L4 u $O +L4 O04 +L4 O37 -3 +L4 z1 L5 -L5$3 -L5$j -L5$n -L5$y -L5'7 -L5*02 -L5*21 -L5*23] -L5*34 -L5*39c -L5-2 -L5-5 -L5@9 -L5D0 -L5L5 -L5R1 -L5R5 -L5Z1 -L5Z1O62 -L5Z2 -L5Z3 -L5^G -L5^G} -L5^d -L5c -L5d -L5i4 +1 -L5i5h -L5i5o -L5i6g -L5l -L5o0W -L5o3 z2 -L5o3d -L5o6k -L5o6s -L5seo -L5sgw -L5st6R5 -L5t -L5O04 -L5O32 -L5O62 -L5z1 -L5{*30 -L5{i5# +L5 $3 +L5 $j +L5 $n +L5 $y +L5 '7 +L5 *02 +L5 *21 +L5 *23 ] +L5 *34 +L5 *39 c +L5 -2 +L5 -5 +L5 @9 +L5 D0 +L5 L5 +L5 R1 +L5 R5 +L5 Z1 +L5 Z1 O62 +L5 Z2 +L5 Z3 +L5 ^G +L5 ^G } +L5 ^d +L5 c +L5 d +L5 i4 +1 +L5 i5h +L5 i5o +L5 i6g +L5 l +L5 o0W +L5 o3 z2 +L5 o3d +L5 o6k +L5 o6s +L5 seo +L5 sgw +L5 st6 R5 +L5 t +L5 O04 +L5 O32 +L5 O62 +L5 z1 +L5 { *30 +L5 { i5# L6 -L6$* -L6$2 -L6$6L5 -L6$MT7 -L6$e -L6$h -L6$pO17 -L6$x -L6$y -L6'9 -L6*2A -L6*50] -L6+4 -L6+6'9 -L6D3 -L6D5 -L6L7 -L6R3 -L6R6 -L6Z1 -L6Z2 -L6[ -L6^VK -L6^a -L6^u$k -L6o2g -L6o9!Z2 -L6r -L6s61 -L6tT4 -L6O06 -L6O35$_ -L6O4B -L6O56sm2 -L6O71 -L6O72 -L6z1R0 +L6 $* +L6 $2 +L6 $6 L5 +L6 $M T7 +L6 $e +L6 $h +L6 $p O17 +L6 $x +L6 $y +L6 '9 +L6 *2A +L6 *50 ] +L6 +4 +L6 +6 '9 +L6 D3 +L6 D5 +L6 L7 +L6 R3 +L6 R6 +L6 Z1 +L6 Z2 +L6 [ +L6 ^V K +L6 ^a +L6 ^u $k +L6 o2g +L6 o9! Z2 +L6 r +L6 s61 +L6 t T4 +L6 O06 +L6 O35 $_ +L6 O4B +L6 O56 sm2 +L6 O71 +L6 O72 +L6 z1 R0 L7 -L7$4 -L7$j -L7$k -L7$r -L7$u -L7'8 -L7'9 -L7*03*38 -L7*13 -L7*17 -L7*47 -L7*63 -L7*67 -L7-1 -L7@3 -L7@9[ -L7R7 -L7Z1k -L7c -L7i6d -L7i75 -L7l -L7o07 -L7o6. -L7o6h -L7ri0x -L7sj=} -L7t -L7tT1 -L7O07 -L7O15 -L7O24d -L7O31 -L7O52 -L7O74 -L7O82 +L7 $4 +L7 $j +L7 $k +L7 $r +L7 $u +L7 '8 +L7 '9 +L7 *03 *38 +L7 *13 +L7 *17 +L7 *47 +L7 *63 +L7 *67 +L7 -1 +L7 @3 +L7 @9 [ +L7 R7 +L7 Z1 k +L7 c +L7 i6d +L7 i75 +L7 l +L7 o07 +L7 o6. +L7 o6h +L7 r i0x +L7 sj= } +L7 t +L7 t T1 +L7 O07 +L7 O15 +L7 O24 d +L7 O31 +L7 O52 +L7 O74 +L7 O82 L8 -L8$UO45 -L8'9 -L8*08 -L8*52 -L8+8 -L8Z2 -L8i2{ -L8i8m -L8s5s -L8sp` -L8O17 -L8O21 -L8O25 -L8O31 -L8O35 -L8O61O05 -L8O92 -L8{ -L8{*78 +$U O45 +L8 '9 +L8 *08 +L8 *52 +L8 +8 +L8 Z2 +L8 i2{ +L8 i8m +L8 s5s +L8 sp` +L8 O17 +L8 O21 +L8 O25 +L8 O31 +L8 O35 +L8 O61 O05 +L8 O92 +L8 { +L8 { *78 L9 -L9Z1 -L9[ -L9^jO58 -L9l -L9O24 -L9O35 -L9O42 -L9O62 -L9O6AZ1 -L9O72 -L9O82u +L9 Z1 +L9 [ +L9 ^j O58 +L9 l +L9 O24 +L9 O35 +L9 O42 +L9 O62 +L9 O6A Z1 +L9 O72 +L9 O82 u LA -LA*B5'8 -LAZ4O95 -LAZ5O4A -LAcO25 -LAi7eO85 -LAo4N@3 -LAO05 -LAO3BZ1 -LAO82 -LBshqO58 -LBO02 -LBO13O63 -LBO53 -LBO92 +*B5 '8 +LA Z4 O95 +LA Z5 O4A +LA c O25 +LA i7e O85 +LA o4N @3 +LA O05 +LA O3B Z1 +LA O82 +LB shq O58 +LB O02 +LB O13 O63 +LB O53 +LB O92 R0 -R0$!*06 -R0$3 -R0$8 -R0$m -R0$n -R0$o -R0'1 -R0'3 -R0'4 -R0*06 -R0*08 -R0*09 -R0*37 -R0+3 -R0+3t -R0-6 -R0-7 -R0@d -R0@e -R0C -R0D1i1I -R0D5 -R0D6 -R0K -R0L3 -R0R2 -R0T1*17 -R0Z1 -R0Z2 -R0Z4+1 -R0Z5 -R0[o58 -R0^# -R0^1 -R0^2 -R0^4 -R0^9 -R0^B -R0^D -R0^E -R0^T -R0^g -R0^s -R0^y -R0i0u -R0i1% -R0i15 -R0i16 -R0i1e -R0i2a -R0i4b -R0k*16 -R0l -R0o1 -R0o1L -R0o1r -R0o22 -R0o3$ -R0o5M -R0p1 -R0p2 -R0p5 -R0q -R0r -R0shd -R0u -R0O12$z -R0O12c -R0O13 -R0O24 -R0O26z1 -R0O35 -R0z1 -R0z1D2 -R0z2 -R0z2spt -R0z3 -R0z3C -R0z4 -R0z4+0 -R0z5 -R0z5O72 -R0} -R0}*38 +R0 $! *06 +R0 $3 +R0 $8 +R0 $m +R0 $n +R0 $o +R0 '1 +R0 '3 +R0 '4 +R0 *06 +R0 *08 +R0 *09 +R0 *37 +R0 +3 +R0 +3 t +R0 -6 +R0 -7 +R0 @d +R0 @e +R0 C +R0 D1 i1I +R0 D5 +R0 D6 +R0 K +R0 L3 +R0 R2 +R0 T1 *17 +R0 Z1 +R0 Z2 +R0 Z4 +1 +R0 Z5 +[ o58 +R0 ^# +R0 ^1 +R0 ^2 +R0 ^4 +R0 ^9 +R0 ^B +R0 ^D +R0 ^E +R0 ^T +R0 ^g +R0 ^s +R0 ^y +R0 i0u +R0 i1% +R0 i15 +R0 i16 +R0 i1e +R0 i2a +R0 i4b +R0 k *16 +R0 l +R0 o1 +R0 o1L +R0 o1r +R0 o22 +R0 o3$ +R0 o5M +R0 p1 +R0 p2 +R0 p5 +R0 q +R0 r +R0 shd +R0 u +R0 O12 $z +R0 O12 c +R0 O13 +R0 O24 +R0 O26 z1 +R0 O35 +R0 z1 +R0 z1 D2 +R0 z2 +R0 z2 spt +R0 z3 +R0 z3 C +R0 z4 +R0 z4 +0 +R0 z5 +R0 z5 O72 +R0 } +R0 } *38 R1 -R1$! -R1$$^> -R1$0 -R1$5 -R1$7 -R1$c -R1$u -R1$x*48 -R1'4 -R1'7 -R1*03 -R1*12 -R1+4 -R1-3 -R1-5 -R1-7 -R1@"+3 -R1@d -R1@i -R1C -R1Co0Q -R1D7 -R1L5i2m -R1L8k -R1R0{ -R1R2 -R1R3 -R1R4 -R1Z4 -R1Z4i4% -R1[] -R1] -R1^4 -R1^>i6l -R1^g -R1^p -R1^r -R1c -R1d -R1f -R1i01 -R1i03O49 -R1i1P -R1i3" -R1i5& -R1o07 -R1o0P -R1o0e -R1o2h -R1o3i -R1o4B -R1r -R1s9) -R1se< -R1sedO35 -R1sfn -R1shc -R1sx" -R1t -R1O02O76 -R1O03'5 -R1O23 -R1O28 -R1O42 -R1O53 -R1z2 -R1z3l -R1z4 -R1z5 -R1}k +R1 $! +R1 $$ ^> +R1 $0 +R1 $5 +R1 $7 +R1 $c +R1 $u +R1 $x *48 +R1 '4 +R1 '7 +R1 *03 +R1 *12 +R1 +4 +R1 -3 +R1 -5 +R1 -7 +R1 @" +3 +R1 @d +R1 @i +R1 C +R1 C o0Q +R1 D7 +R1 L5 i2m +R1 L8 k +R1 R0 { +R1 R2 +R1 R3 +R1 R4 +R1 Z4 +R1 Z4 i4% +R1 [ ] +R1 ] +R1 ^4 +R1 ^> i6l +R1 ^g +R1 ^p +R1 ^r +R1 c +R1 d +R1 f +R1 i01 +R1 i03 O49 +R1 i1P +R1 i3" +R1 i5& +R1 o07 +R1 o0P +R1 o0e +R1 o2h +R1 o3i +R1 o4B +R1 r +R1 s9) +R1 se< +R1 sed O35 +R1 sfn +R1 shc +R1 sx" +R1 t +R1 O02 O76 +R1 O03 '5 +R1 O23 +R1 O28 +R1 O42 +R1 O53 +R1 z2 +R1 z3 l +R1 z4 +R1 z5 +R1 } k R2 -R2$+@6 -R2$N -R2$Z+3 -R2*24 -R2*57O15 -R2*61 -R2*70O39 -R2+1 -R2+3 -R2-9O16 -R2@9 -R2D2^b -R2KZ1 -R2L1 -R2L7 -R2T2 -R2Z2Z5 -R2Z2O19 -R2^ -R2^V -R2^b -R2^d -R2d -R2f -R2i00 -R2i28 -R2l -R2o2n^c -R2o4(s(1 -R2o5o -R2o5v -R2r -R2u -R2O21@p -R2O41 -R2O51 -R2O62 -R2{^7 -R2} +R2 $+ @6 +R2 $N +R2 $Z +3 +R2 *24 +R2 *57 O15 +R2 *61 +R2 *70 O39 +R2 +1 +R2 +3 +R2 -9 O16 +R2 @9 +D2 ^b +R2 K Z1 +R2 L1 +R2 L7 +R2 T2 +R2 Z2 Z5 +R2 Z2 O19 +R2 ^ +R2 ^V +R2 ^b +R2 ^d +R2 d +R2 f +R2 i00 +R2 i28 +R2 l +o2n ^c +R2 o4( s(1 +R2 o5o +R2 o5v +R2 r +R2 u +R2 O21 @p +R2 O41 +R2 O51 +R2 O62 +R2 { ^7 +R2 } R3 -R3$m -R3$rO3B -R3$v -R3'4^z -R3'6 -R3*30 -R3*40 -R3+1 -R3+5 -R3+6 -R3-4 -R3-4o26 -R3-5 -R3-7 -R3@4t -R3@a -R3D5 -R3D9Z1 -R3K -R3Kd -R3L0 -R3L4 -R3Z1^M -R3Z2 -R3Z4 -R3Z5 -R3[ -R3^0 -R3^6 -R3^Wz1 -R3i1i -R3i3# -R3i4t -R3l*46 -R3o1g -R3o1t -R3o2c -R3o47 -R3p1 -R3q -R3qD6 -R3s1j -R3sd<$7 -R3t -R3t-4 -R3O21 -R3O32q -R3O54 -R3O73 -R3z1 -R3z2 +R3 $m +R3 $r O3B +R3 $v +R3 '4 ^z +R3 '6 +R3 *30 +R3 *40 +R3 +1 +R3 +5 +R3 +6 +R3 -4 +R3 -4 o26 +R3 -5 +R3 -7 +R3 @4 t +R3 @a +R3 D5 +R3 D9 Z1 +R3 K +R3 K d +R3 L0 +R3 L4 +R3 Z1 ^M +R3 Z2 +R3 Z4 +R3 Z5 +R3 [ +R3 ^0 +R3 ^6 +R3 ^W z1 +R3 i1i +R3 i3# +R3 i4t +R3 l *46 +R3 o1g +R3 o1t +R3 o2c +R3 o47 +R3 p1 +R3 q +R3 q D6 +R3 s1j +R3 sd< $7 +R3 t +R3 t -4 +R3 O21 +R3 O32 q +R3 O54 +R3 O73 +R3 z1 +R3 z2 R4 -R4$2 -R4$2s7Y -R4$9 -R4$?C -R4$o -R4$v -R4$x -R4'5^l -R4*30 -R4*41 -R4*45R4 -R4*64 -R4*74z2 -R4*87[ -R4+4 -R4+6-5 -R4-5 -R4-5o3o -R4@z+0 -R4D1 -R4D8O23 -R4L0R0 -R4R2 -R4R5 -R4RA -R4T0D2 -R4T5 -R4Z1 -R4Z2 -R4Z2-6 -R4Z3 -R4Z4 -R4Z4D1 -R4^T*03 -R4^Z -R4^_ -R4^e -R4^l -R4d -R4f -R4i0s -R4i2W -R4i2b -R4i2u -R4i3i -R4i45 -R4o0Yi3f -R4o27D0 -R4o2y -R4o59 -R4o7/ -R4oAk{ -R4r -R4s20 -R4s9H -R4smD -R4ss) -R4t -R4O02 -R4O04 -R4O21 -R4O39$r -R4O41@K -R4O53 -R4O56 -R4O57 -R4O63 -R4z1 -R4z3 +R4 $2 +R4 $2 s7Y +R4 $9 +R4 $? C +R4 $o +R4 $v +R4 $x +R4 '5 ^l +R4 *30 +R4 *41 +R4 *45 R4 +R4 *64 +R4 *74 z2 +R4 *87 [ +R4 +4 +R4 +6 -5 +R4 -5 +R4 -5 o3o +R4 @z +0 +R4 D1 +R4 D8 O23 +R4 L0 R0 +R4 R2 +R4 R5 +R4 RA +R4 T0 D2 +R4 T5 +R4 Z1 +R4 Z2 +R4 Z2 -6 +R4 Z3 +R4 Z4 +R4 Z4 D1 +R4 ^T *03 +R4 ^Z +R4 ^_ +R4 ^e +R4 ^l +R4 d +R4 f +R4 i0s +R4 i2W +R4 i2b +R4 i2u +R4 i3i +R4 i45 +R4 o0Y i3f +R4 o27 D0 +R4 o2y +R4 o59 +R4 o7/ +R4 oAk { +R4 r +R4 s20 +R4 s9H +R4 smD +R4 ss) +R4 t +R4 O02 +R4 O04 +R4 O21 +R4 O39 $r +R4 O41 @K +R4 O53 +R4 O56 +R4 O57 +R4 O63 +R4 z1 +R4 z3 R5 -R5$! -R5$-i1( -R5$4 -R5$b -R5$n -R5$v -R5*34 -R5*41Z2 -R5*53 -R5*64O63 -R5*65K -R5+1 -R5+2 -R5-4 -R5@pl -R5D4 -R5K -R5LB -R5R6 -R5T5o64 -R5Z1 -R5Z1O21 -R5Z2 -R5Z3o6> -R5Z4 -R5Z5 -R5[O04 -R5^5i5 -R5^> -R5^_O1B -R5^k -R5^v -R5co36 -R5i1b -R5i2I -R5i2o -R5i5= -R5i5T -R5k -R5l -R5o3Bz2 -R5o3h -R5o6Y$a -R5s1n -R5s1z -R5s2* -R5sd4 -R5se7 -R5sjxz3 -R5st3 -R5st9 -R5u -R5O04 -R5O05 -R5O31 -R5O4As4a -R5O51ssS -R5O63 -R5z1 -R5z1sl2 -R5z1O67 -R5z2 -R5z4O74 +R5 $! +R5 $- i1( +R5 $4 +R5 $b +R5 $n +R5 $v +R5 *34 +R5 *41 Z2 +R5 *53 +R5 *64 O63 +R5 *65 K +R5 +1 +R5 +2 +R5 -4 +R5 @p l +R5 D4 +R5 K +R5 LB +R5 R6 +R5 T5 o64 +R5 Z1 +R5 Z1 O21 +R5 Z2 +R5 Z3 o6> +R5 Z4 +R5 Z5 +R5 [ O04 +R5 ^5 i5 +R5 ^> +R5 ^_ O1B +R5 ^k +R5 ^v +R5 c o36 +R5 i1b +R5 i2I +R5 i2o +R5 i5= +R5 i5T +R5 k +R5 l +R5 o3B z2 +R5 o3h +R5 o6Y $a +R5 s1n +R5 s1z +R5 s2* +R5 sd4 +R5 se7 +R5 sjx z3 +R5 st3 +R5 st9 +R5 u +R5 O04 +R5 O05 +R5 O31 +R5 O4A s4a +R5 O51 ssS +R5 O63 +R5 z1 +R5 z1 sl2 +R5 z1 O67 +R5 z2 +R5 z4 O74 R6 -R6$-r -R6$4 -R6$z -R6*23 -R6*65 -R6*72^N -R6+4 -R6+5 -R6-3 -R6-4*07 -R6-7 -R6@. -R6C*64 -R6D1 -R6D2 -R6D5 -R6L2O62 -R6L6o55 -R6R0 -R6R2 -R6R7 -R6Z1[ -R6Z3 -R6Z4 -R6Z4C -R6[ -R6[$5 -R6^7{ -R6^P -R6^S -R6^p -R6i3a -R6i4LO32 -R6i52 -R6i6A -R6i74 -R6o1y -R6o3g -R6o4d -R6o5: -R6o5a -R6r -R6sc4 -R6ss8 -R6t -R6uo2M -R6O06 -R6O15 -R6O21{ -R6O24 -R6O36 -R6O41 -R6O75 -R6O76 -R6z2 -R6z2*17 -R6z3O18 +R6 $- r +R6 $4 +R6 $z +R6 *23 +R6 *65 +R6 *72 ^N +R6 +4 +R6 +5 +R6 -3 +R6 -4 *07 +R6 -7 +R6 @. +R6 C *64 +R6 D1 +R6 D2 +R6 D5 +R6 L2 O62 +R6 L6 o55 +R6 R0 +R6 R2 +R6 R7 +R6 Z1 [ +R6 Z3 +R6 Z4 +R6 Z4 C +R6 [ +R6 [ $5 +R6 ^7 { +R6 ^P +R6 ^S +R6 ^p +R6 i3a +R6 i4L O32 +R6 i52 +R6 i6A +R6 i74 +R6 o1y +R6 o3g +R6 o4d +R6 o5: +R6 o5a +R6 r +R6 sc4 +R6 ss8 +R6 t +R6 u o2M +R6 O06 +R6 O15 +R6 O21 { +R6 O24 +R6 O36 +R6 O41 +R6 O75 +R6 O76 +R6 z2 +R6 z2 *17 +R6 z3 O18 R7 -R7$x -R7'8 -R7*02 -R7*56 -R7*67 -R7*85z1 -R7*97 -R7+8o7V -R7+9 -R7-5 -R7-6 -R7-Ai80 -R7@E -R7@m -R7@n -R7@v -R7CO05 -R7D3[ -R7T0z4 -R7T4 -R7Z1 -R7Z2 -R7Z3 -R7[ -R7i2F -R7i6V -R7i75 -R7l -R7o0K -R7o0Ml -R7o6 -R7o6@r -R7o6G -R7o88 -R7qO19 -R7sgs -R7syi -R7t -R7O05 -R7O08z5 -R7O12-0 -R7O14 -R7O23d -R7O34 -R7O41 -R7O43 -R7O61 -R7O81 -R7z1 +R7 $x +R7 '8 +R7 *02 +R7 *56 +R7 *67 +R7 *85 z1 +R7 *97 ++8 o7V +R7 +9 +R7 -5 +R7 -6 +R7 -A i80 +R7 @E +R7 @m +R7 @n +R7 @v +R7 C O05 +R7 D3 [ +R7 T0 z4 +R7 T4 +R7 Z1 +R7 Z2 +R7 Z3 +R7 [ +R7 i2F +R7 i6V +R7 i75 +R7 l +R7 o0K +R7 o0M l +R7 o6 +R7 o6@ r +R7 o6G +R7 o88 +R7 q O19 +R7 sgs +R7 syi +R7 t +R7 O05 +R7 O08 z5 +R7 O12 -0 +R7 O14 +R7 O23 d +R7 O34 +R7 O41 +R7 O43 +R7 O61 +R7 O81 +R7 z1 R8 -R8$1 -R8$xO72 -R8-5 -R8D1 -R8R7 -R8Z1 -R8i83 -R8o0a -R8o7eO25 -R8o7x -R8O04 -R8O07 -R8O07z3 -R8O16 -R8O17 -R8O25 -R8O25$3 -R8O31 -R8O32 -R8O34 -R8O43O32 -R8O63@8 -R8z2 +R8 $1 +$x O72 +R8 -5 +R8 D1 +R8 R7 +R8 Z1 +R8 i83 +R8 o0a +R8 o7e O25 +R8 o7x +R8 O04 +R8 O07 +R8 O07 z3 +R8 O16 +R8 O17 +R8 O25 +R8 O25 $3 +R8 O31 +R8 O32 +R8 O34 +R8 O43 O32 +R8 O63 @8 +R8 z2 R9 -R9$0i2s -R9$9 -R9$yO06 -R9*25 -R9*36 -R9*39 -R9-9 -R9D7 -R9R4 -R9Z1 -R9[ -R9u -R9O02 -R9O08 -R9O14 -R9O19$r -R9O24o68 -R9O25 -RA$0 -RA+1O82 -RAD3O75 -RA[ -RAi9XO37 -RAO73 -RAO74z1 -RAOA2O16 -RBD8*02 -RBO02 -RBO09 -RBO74 +R9 $0 i2s +R9 $9 +R9 $y O06 +R9 *25 +R9 *36 +R9 *39 +R9 -9 +R9 D7 +R9 R4 +R9 Z1 +R9 [ +R9 u +R9 O02 +R9 O08 +R9 O14 +R9 O19 $r +R9 O24 o68 +R9 O25 +RA $0 +RA +1 O82 +RA D3 O75 +RA [ +RA i9X O37 +RA O73 +RA O74 z1 +RA OA2 O16 +RB D8 *02 +RB O02 +RB O09 +RB O74 T0 -T0$+ -T0$6 -T0$9 -T0$D -T0$V -T0$Y -T0$b^P -T0$h -T0$j -T0$k -T0$n -T0$o$s -T0$rs7# -T0$s -T0$x -T0'6 -T0'9 -T0*02 -T0*03 -T0*07O21 -T0*43 -T0*9A -T0+5 -T0+6 -T0+7 -T0-4 -T0D3 -T0D6 -T0D8D5 -T0D9 -T0L3 -T0L4 -T0L7 -T0R5 -T0T2 -T0T3 -T0T5 -T0T9 -T0^! -T0^A -T0^D -T0^F -T0^K -T0^S -T0^e -T0d -T0d[ -T0i0? -T0i1O^u -T0i1r -T0i2!k -T0i2d -T0i2p -T0i3: -T0i3m -T0i3s -T0i3u -T0i3y -T0i5H-5 -T0i6_ -T0i7_ -T0i85 -T0i8= -T0o2@i6/ -T0o2B -T0o2M -T0o2S -T0o3L -T0o3v -T0o4O -T0o4r -T0o5q -T0o6r -T0o6s -T0o7 -T0o8C -T0o9A -T0q -T0r*06 -T0s3! -T0sM -T0se4 -T0sgK -T0so -T0spR -T0sr@ -T0st5 -T0std -T0stj -T0t -T0uo6k -T0O06 -T0O12 -T0O13^1 -T0O16 -T0O17 -T0O47 -T0O63 -T0O73@D -T0O74 -T0z2@0 -T0{ +T0 $+ +T0 $6 +T0 $9 +T0 $D +T0 $V +T0 $Y +T0 $b ^P +T0 $h +T0 $j +T0 $k +T0 $n +T0 $o $s +T0 $r s7# +T0 $s +T0 $x +T0 '6 +T0 '9 +T0 *02 +T0 *03 +T0 *07 O21 +T0 *43 +T0 *9A +T0 +5 +T0 +6 +T0 +7 +T0 -4 +T0 D3 +T0 D6 +T0 D8 D5 +T0 D9 +T0 L3 +T0 L4 +T0 L7 +T0 R5 +T0 T2 +T0 T3 +T0 T5 +T0 T9 +T0 ^! +T0 ^A +T0 ^D +T0 ^F +T0 ^K +T0 ^S +T0 ^e +T0 d +T0 d [ +T0 i0? +T0 i1O ^u +T0 i1r +T0 i2! k +T0 i2d +T0 i2p +T0 i3: +T0 i3m +T0 i3s +T0 i3u +T0 i3y +T0 i5H -5 +T0 i6_ +T0 i7_ +T0 i85 +T0 i8= +T0 o2@ i6/ +T0 o2B +T0 o2M +T0 o2S +T0 o3L +T0 o3v +T0 o4O +T0 o4r +T0 o5q +T0 o6r +T0 o6s +T0 o7 +T0 o8C +T0 o9A +T0 q +T0 r *06 +T0 s3! +T0 sM +T0 se4 +T0 sgK +T0 so +T0 spR +T0 sr@ +T0 st5 +T0 std +T0 stj +T0 t +u o6k +T0 O06 +T0 O12 +T0 O13 ^1 +T0 O16 +T0 O17 +T0 O47 +T0 O63 +T0 O73 @D +T0 O74 +T0 z2 @0 +T0 { T1 -T1$' -T1$2Z4 -T1$6 -T1$6O56 -T1$_$W -T1$i -T1$l*63 -T1$qR3 -T1$w -T1'7 -T1'8 -T1'9 -T1*01$n -T1*34o1_ -T1+0 -T1+4 -T1+6 -T1+7 -T1+BO29 -T1-3 -T1@R -T1K -T1T0 -T1T3 -T1T3T5 -T1T3T5T7 -T1T3T5T7T9 -T1T3T5T7T9TB -T1T6 -T1T7 -T1Z1i0S -T1Z4O75 -T1Z5i8) -T1Z5sS7 -T1[ -T1^W -T1^o -T1d -T1f -T1i0@z2 -T1i3m -T1k -T1kC -T1o0' -T1o2g -T1o2w -T1o4w -T1o6- -T1o75@R -T1r -T1sAP+1 -T1sbN -T1si' -T1sr[^x -T1t -T1O15p2 -T1O42 -T1O54 -T1O57 -T1O89c -T1z1 -T1z5 +T1 $' +T1 $2 Z4 +T1 $6 +T1 $6 O56 +T1 $_ $W +T1 $i +T1 $l *63 +T1 $q R3 +T1 $w +T1 '7 +T1 '8 +T1 '9 +T1 *01 $n +*34 o1_ +T1 +0 +T1 +4 +T1 +6 +T1 +7 +T1 +B O29 +T1 -3 +T1 @R +T1 K +T1 T0 +T1 T3 +T1 T3 T5 +T1 T3 T5 T7 +T1 T3 T5 T7 T9 +T1 T3 T5 T7 T9 TB +T1 T6 +T1 T7 +T1 Z1 i0S +T1 Z4 O75 +T1 Z5 i8) +T1 Z5 sS7 +T1 [ +T1 ^W +T1 ^o +T1 d +T1 f +T1 i0@ z2 +T1 i3m +T1 k +k C +T1 o0' +T1 o2g +T1 o2w +T1 o4w +T1 o6- +T1 o75 @R +T1 r +T1 sAP +1 +T1 sbN +T1 si' +T1 sr[ ^x +T1 t +T1 O15 p2 +T1 O42 +T1 O54 +T1 O57 +O89 c +T1 z1 +T1 z5 T2 -T2$! -T2$2 -T2$bo5& -T2'4 -T2'7 -T2*03 -T2*57 -T2-0 -T2@aO64 -T2CD6 -T2D1^) -T2D7 -T2T4 -T2T5 -T2T6 -T2Z1 -T2]$8 -T2^< -T2^Q -T2^` -T2^w -T2d -T2f -T2i00*57 -T2i3m -T2i59 -T2k -T2o06i0* -T2o0V -T2o1A'8 -T2o38 -T2o3P -T2o3o -T2o6! -T2o94u -T2r -T2s03 -T2sA8K -T2sx3 -T2t -T2O02 -T2O41o49 -T2O52*52 -T2O57 -T2O62 -T2z1 +T2 $! +T2 $2 +T2 $b o5& +T2 '4 +T2 '7 +T2 *03 +T2 *57 +T2 -0 +T2 @a O64 +C D6 +T2 D1 ^) +T2 D7 +T2 T4 +T2 T5 +T2 T6 +T2 Z1 +T2 ] $8 +T2 ^< +T2 ^Q +T2 ^` +T2 ^w +T2 d +T2 f +T2 i00 *57 +T2 i3m +T2 i59 +T2 k +T2 o06 i0* +T2 o0V +T2 o1A '8 +T2 o38 +T2 o3P +T2 o3o +T2 o6! +o94 u +T2 r +T2 s03 +T2 sA8 K +T2 sx3 +T2 t +T2 O02 +T2 O41 o49 +T2 O52 *52 +T2 O57 +T2 O62 +T2 z1 T3 -T3$" -T3$1 -T3$4 -T3$D -T3$l -T3$t -T3'5^\ -T3'9 -T3*45^9 -T3+0 -T3-5O63 -T3D6 -T3D7 -T3L0 -T3L3'6 -T3R1O12 -T3T5 -T3T6 -T3T8 -T3Z2 -T3Z3 -T3[ -T3[o3i -T3[O27 -T3^! -T3^% -T3^H -T3^K-0 -T3^oz3 -T3ci4G -T3i3- -T3i3f -T3iBgO17 -T3o0p -T3o1n^t -T3o2C -T3o3iu -T3o4` -T3o71 -T3p1 -T3qL1 -T3qs7b -T3r -T3s0@ -T3si1 -T3smA -T3sr2 -T3tO27 -T3O12 -T3O43 -T3O53 -T3z2 -T3z2$9 -T3} +T3 $" +T3 $1 +T3 $4 +T3 $D +T3 $l +T3 $t +T3 '5 ^\ +T3 '9 +T3 *45 ^9 +T3 +0 +T3 -5 O63 +T3 D6 +T3 D7 +T3 L0 +T3 L3 '6 +T3 R1 O12 +T3 T5 +T3 T6 +T3 T8 +T3 Z2 +T3 Z3 +T3 [ +T3 [ o3i +T3 [ O27 +T3 ^! +T3 ^% +T3 ^H +T3 ^K -0 +T3 ^o z3 +c i4G +T3 i3- +T3 i3f +T3 iBg O17 +T3 o0p +T3 o1n ^t +T3 o2C +o3i u +T3 o4` +T3 o71 +T3 p1 +T3 q L1 +T3 q s7b +T3 r +T3 s0@ +T3 si1 +T3 smA +T3 sr2 +T3 t O27 +T3 O12 +T3 O43 +T3 O53 +T3 z2 +T3 z2 $9 +T3 } T4 -T4$1 -T4$3 -T4$5 -T4$y -T4'8 -T4'A -T4+2 -T4+4 -T4-5 -T4-6 -T4@6 -T4D5 -T4D7 -T4R4 -T4T3 -T4T5 -T4T6T8 -T4TB -T4Z1 -T4Z2 -T4Z4 -T4Z5 -T4[ -T4^2 -T4i3"+3 -T4i4! -T4i4;^4 -T4k -T4o0H -T4o0R -T4o0n -T4o0s -T4o2s -T4o5i -T4o6t -T4o9x -T4p1 -T4r -T4rz1 -T4s2u -T4s32 -T4s3H -T4s4t -T4sIs -T4sTIR6 -T4sau -T4tr -T4O02 -T4O31^7 -T4O36 -T4O54 -T4O56u -T4z3 +T4 $1 +T4 $3 +T4 $5 +T4 $y +T4 '8 +T4 'A +T4 +2 +T4 +4 +T4 -5 +T4 -6 +T4 @6 +T4 D5 +T4 D7 +T4 R4 +T4 T3 +T4 T5 +T4 T6 T8 +T4 TB +T4 Z1 +T4 Z2 +T4 Z4 +T4 Z5 +T4 [ +T4 ^2 +T4 i3" +3 +T4 i4! +T4 i4; ^4 +T4 k +T4 o0H +T4 o0R +T4 o0n +T4 o0s +T4 o2s +T4 o5i +T4 o6t +T4 o9x +T4 p1 +T4 r +T4 r z1 +T4 s2u +T4 s32 +T4 s3H +T4 s4t +T4 sIs +T4 sTI R6 +T4 sau +T4 t r +T4 O02 +T4 O31 ^7 +T4 O36 +T4 O54 +O56 u +T4 z3 T5 -T5$3 -T5$9 -T5$G -T5$e -T5$m*13 -T5$p -T5'6 -T5'B -T5*43 -T5*45 -T5*45T1 -T5*52Z3 -T5*67 -T5*71*92 -T5+6 -T5-0 -T5-3 -T5-6 -T5D1 -T5D3s85 -T5D4 -T5K -T5L5 -T5L9O13 -T5T7 -T5Z1 -T5Z2 -T5[ -T5^. -T5^6 -T5^I -T5^[ -T5^e -T5i0p -T5i11O23 -T5i6Y -T5o0S -T5o1& -T5o2K -T5o4_ -T5p1r -T5s+3 -T5s0+ -T5s2b -T5shn -T5O13 -T5O25u -T5O61 -T5O62 -T5O6A -T5O76 -T5{ -T5} +T5 $3 +T5 $9 +T5 $G +T5 $e +T5 $m *13 +T5 $p +T5 '6 +T5 'B +T5 *43 +T5 *45 +T5 *45 T1 +T5 *52 Z3 +T5 *67 +T5 *71 *92 +T5 +6 +T5 -0 +T5 -3 +T5 -6 +T5 D1 +T5 D3 s85 +T5 D4 +T5 K +T5 L5 +T5 L9 O13 +T5 T7 +T5 Z1 +T5 Z2 +T5 [ +T5 ^. +T5 ^6 +T5 ^I +T5 ^[ +T5 ^e +T5 i0p +T5 i11 O23 +T5 i6Y +T5 o0S +T5 o1& +T5 o2K +T5 o4_ +T5 p1 r +T5 s+3 +T5 s0+ +T5 s2b +T5 shn +T5 O13 +O25 u +T5 O61 +T5 O62 +T5 O6A +T5 O76 +T5 { +T5 } T6 -T6$9 -T6$T -T6$W -T6$Y -T6$a -T6$t -T6'7 -T6'9 -T6*23 -T6*74c -T6+2o5k -T6-7 -T6@h -T6D1 -T6D8 -T6L2*20 -T6R0 -T6T0 -T6T5 -T6T7 -T6T9 -T6Z1 -T6Z1o0l -T6Z2 -T6Z3 -T6[ -T6^2 -T6^9 -T6^V] -T6i0@ -T6i0N -T6o0f -T6o2m -T6o3fs4b -T6o53 -T6o56 -T6s7)@l -T6O02 -T6O12 -T6O14 -T6O24T3 -T6O71 -T6O72 -T6O83 +T6 $9 +T6 $T +T6 $W +T6 $Y +T6 $a +T6 $t +T6 '7 +T6 '9 +T6 *23 +*74 c +T6 +2 o5k +T6 -7 +T6 @h +T6 D1 +T6 D8 +T6 L2 *20 +T6 R0 +T6 T0 +T6 T5 +T6 T7 +T6 T9 +T6 Z1 +T6 Z1 o0l +T6 Z2 +T6 Z3 +T6 [ +T6 ^2 +T6 ^9 +T6 ^V ] +T6 i0@ +T6 i0N +T6 o0f +T6 o2m +T6 o3f s4b +T6 o53 +T6 o56 +T6 s7) @l +T6 O02 +T6 O12 +T6 O14 +T6 O24 T3 +T6 O71 +T6 O72 +T6 O83 T7 -T7$*Z1 -T7$-$m -T7$0 -T7$3 -T7$7 -T7$_ -T7$i -T7$w[ -T7+6t -T7@8 -T7L6O74 -T7RA -T7T0 -T7T2 -T7T3 -T7T4 -T7T8 -T7^1 -T7^2 -T7^Kz1 -T7cO39 -T7i2V -T7i2z -T7o0= -T7o22 -T7o3k -T7o49 -T7o5xu -T7o5z -T7s 6 -T7s6fs4] -T7sgp -T7sjnu -T7t -T7O05 -T7O05o47 -T7O24 +T7 $* Z1 +T7 $- $m +T7 $0 +T7 $3 +T7 $7 +T7 $_ +T7 $i +T7 $w [ +T7 +6 t +T7 @8 +T7 L6 O74 +T7 RA +T7 T0 +T7 T2 +T7 T3 +T7 T4 +T7 T8 +T7 ^1 +T7 ^2 +T7 ^K z1 +c O39 +T7 i2V +T7 i2z +T7 o0= +T7 o22 +T7 o3k +T7 o49 +o5x u +T7 o5z +T7 s 6 +T7 s6f s4] +T7 sgp +T7 sjn u +T7 t +T7 O05 +T7 O05 o47 +T7 O24 T8 -T8$1 -T8$dO52 -T8-7D4 -T8D2 -T8D5sKp -T8D6 -T8i4 -T8o04 -T8o11l -T8o9,O62 -T8s1f -T8sdn -T8t -T8O02 -T8O31 -T8O84o7v -T8}T8 +T8 $1 +T8 $d O52 +T8 -7 D4 +T8 D2 +T8 D5 sKp +T8 D6 +T8 i4 +T8 o04 +o11 l +T8 o9, O62 +T8 s1f +T8 sdn +T8 t +T8 O02 +T8 O31 +T8 O84 o7v +T8 } T8 T9 -T9*41 -T9*61 -T9T4 -T9T8 -T9i3' -T9o7f -T9o8#^v -T9o96[ -T9O13 -T9O14 -T9O23O51 -T9O27 -T9O71$1 +T9 *41 +T9 *61 +T9 T4 +T9 T8 +T9 i3' +T9 o7f +T9 o8# ^v +o96 [ +T9 O13 +T9 O14 +T9 O23 O51 +T9 O27 +T9 O71 $1 TA -TA'B -TARADB -TAT0 -TAZ3O05 -TAt -TAO02 -TAO25 -TAO53O41 -TAO61t +TA 'B +TA RA DB +TA T0 +TA Z3 O05 +TA t +TA O02 +TA O25 +TA O53 O41 +TA O61 t TB -TB*A1*8B -TBiBRk -TBs, -TBO05 -TBO17i4n -TBO19 +TB *A1 *8B +TB iBR k +TB s, +TB O05 +TB O17 i4n +TB O19 TC Z1 -Z1$ -Z1$! -Z1$% -Z1$& -Z1$&O52 -Z1$,O54 -Z1$- -Z1$. -Z1$0 -Z1$1 -Z1$1*21 -Z1$2 -Z1$3 -Z1$3i7e -Z1$6 -Z1$7 -Z1$8 -Z1$8O16 -Z1$9 -Z1$=O16 -Z1$A -Z1$D -Z1$Wu -Z1$Xi5' -Z1$b -Z1$c -Z1$e -Z1$g -Z1$j -Z1$k -Z1$l -Z1$n -Z1$o -Z1$o^" -Z1$oi7r -Z1$p -Z1$q -Z1$w -Z1'5-3 -Z1'9+3 -Z1*04 -Z1*06 -Z1*07 -Z1*0A[ -Z1*12*24 -Z1*14$j -Z1*15o3i -Z1*21 -Z1*24 -Z1*25D3 -Z1*31 -Z1*32 -Z1*34 -Z1*35 -Z1*38 -Z1*48O32 -Z1*50 -Z1*51 -Z1*52 -Z1*52K -Z1*56i5m -Z1*56ssu -Z1*57 -Z1*58 -Z1*59 -Z1*63 -Z1*68 -Z1*68i5< -Z1*69l -Z1*74 -Z1*85-6 -Z1*97 -Z1*A8 -Z1+0z1 -Z1+1 -Z1+1*31 -Z1+2 -Z1+4 -Z1+5 -Z1+7D4 -Z1+7o0a -Z1+7o5- -Z1+8 -Z1+8o7u -Z1+9 -Z1+9i85 -Z1-0 -Z1-0-0 -Z1-0@t -Z1-0u -Z1-1+7 -Z1-2 -Z1-2L6 -Z1-3 -Z1-4 -Z1-4t -Z1-5 -Z1-6 -Z1-6^* -Z1-A -Z1-A+B -Z1@6-2 -Z1@a -Z1@zO04 -Z1D1R4 -Z1D3+5 -Z1D3T1 -Z1D4 -Z1D5 -Z1D7sUE -Z1L0 -Z1L4O65 -Z1L5o2l -Z1R0o1i -Z1R1 -Z1R2$c -Z1R4 -Z1R6z1 -Z1R7D4 -Z1T1 -Z1T4 -Z1T5 -Z1T5^A -Z1T6sbK -Z1Z1sCk -Z1Z5 -Z1[ -Z1[i2< -Z1[O31 -Z1^" -Z1^$ -Z1^0 -Z1^2 -Z1^4 -Z1^4D4 -Z1^7*14 -Z1^8 -Z1^9O46 -Z1^B -Z1^D -Z1^P -Z1^U -Z1^W -Z1^X -Z1^\ -Z1^c -Z1^e -Z1^g -Z1^li4b -Z1^n -Z1^o -Z1^p -Z1^q -Z1^s -Z1^v*91 -Z1^| -Z1c -Z1c*73 -Z1c+3 -Z1cD7 -Z1d -Z1dO56 -Z1dO65 -Z1dO75 -Z1fO38 -Z1fO5A -Z1i0k -Z1i13D3 -Z1i1e -Z1i1j -Z1i1l -Z1i1p -Z1i2- -Z1i21 -Z1i2Z -Z1i2a -Z1i2c -Z1i2v -Z1i38 -Z1i3: -Z1i3I -Z1i3s -Z1i41 -Z1i43 -Z1i48 -Z1i4K -Z1i4] -Z1i4a[ -Z1i4bO18 -Z1i4eO71 -Z1i4h-3 -Z1i4s -Z1i4t -Z1i4y -Z1i5! -Z1i5- -Z1i56 -Z1i58 -Z1i5= -Z1i5O -Z1i5e -Z1i5p -Z1i5t -Z1i6& -Z1i6/ -Z1i62 -Z1i64 -Z1i69 -Z1i6L -Z1i6e -Z1i6f -Z1i6x -Z1i7% -Z1i71 -Z1i7N -Z1i7R[ -Z1i7mo6M -Z1i7n -Z1i7o -Z1i7r -Z1i7t -Z1i80 -Z1i81 -Z1i88 -Z1i8j -Z1i8v -Z1i8x -Z1i91 -Z1i93 -Z1i9s -Z1iA7 -Z1k -Z1ki3v -Z1l^D -Z1o04 -Z1o07 -Z1o0E -Z1o0F -Z1o0I -Z1o0K -Z1o0] -Z1o0b -Z1o0dO32 -Z1o0qi48 -Z1o0t -Z1o0v -Z1o15$b -Z1o17 -Z1o1Lo1c -Z1o1b -Z1o2A -Z1o2` -Z1o2o -Z1o2s -Z1o2u -Z1o3! -Z1o31 -Z1o39 -Z1o3:O37 -Z1o3n -Z1o3t -Z1o3v -Z1o4! -Z1o4/ -Z1o43l -Z1o44slF -Z1o49 -Z1o4a -Z1o4h -Z1o4n -Z1o5% -Z1o5- -Z1o54 -Z1o59 -Z1o5@ -Z1o5C -Z1o5_ -Z1o5c -Z1o6= -Z1o6F -Z1o6p -Z1o6t -Z1o7,{ -Z1o75 -Z1o7Ez2 -Z1o7e -Z1o7i -Z1o7p -Z1o7z -Z1o80T0 -Z1o9?O46 -Z1o9_ -Z1p2'A -Z1p2O13 -Z1q -Z1q'9 -Z1r -Z1r*24 -Z1s!T -Z1s0, -Z1s0a -Z1s2- -Z1s2^ -Z1s38 -Z1s3q -Z1s6) -Z1s64 -Z1s8* -Z1s9& -Z1s90 -Z1s@a -Z1sBHD6 -Z1sHW -Z1sa? -Z1sb+ -Z1sca -Z1sdu -Z1se7 -Z1seb -Z1seu -Z1sfjO43 -Z1sjB -Z1sjv -Z1sk -Z1sleO71 -Z1smN -Z1sn. -Z1sn5 -Z1snl -Z1so' -Z1soO -Z1sou -Z1srz -Z1ss& -Z1ssB -Z1stb -Z1stn -Z1sua -Z1svb -Z1sxt -Z1syh -Z1sz7 -Z1t -Z1t[ -Z1tr -Z1tO28 -Z1u -Z1u{ -Z1O03 -Z1O05 -Z1O12spu -Z1O13f -Z1O15 -Z1O15sbg -Z1O16 -Z1O16D5 -Z1O17 -Z1O21*01 -Z1O23z3 -Z1O24 -Z1O25t -Z1O27c -Z1O28 -Z1O32 -Z1O32^r -Z1O38 -Z1O42 -Z1O42d -Z1O43 -Z1O46$m -Z1O47 -Z1O52i0Z -Z1O54 -Z1O56 -Z1O57 -Z1O57c -Z1O62 -Z1O64 -Z1O72o48 -Z1O73 -Z1O74 -Z1O85 -Z1O95O42 -Z1OA2O17 -Z1OA3 -Z1OB2 -Z1z1 -Z1z1$s -Z1z1*09 -Z1z1p1 -Z1z2D7 -Z1z3 -Z1z5O25 -Z1{ -Z1{T1 -Z1}o12 +Z1 $ +Z1 $! +Z1 $% +Z1 $& +Z1 $& O52 +Z1 $, O54 +Z1 $- +Z1 $. +Z1 $0 +Z1 $1 +Z1 $1 *21 +Z1 $2 +Z1 $3 +Z1 $3 i7e +Z1 $6 +Z1 $7 +Z1 $8 +Z1 $8 O16 +Z1 $9 +Z1 $= O16 +Z1 $A +Z1 $D +Z1 $W u +Z1 $X i5' +Z1 $b +Z1 $c +Z1 $e +Z1 $g +Z1 $j +Z1 $k +Z1 $l +Z1 $n +Z1 $o +Z1 $o ^" +Z1 $o i7r +Z1 $p +Z1 $q +Z1 $w +Z1 '5 -3 +Z1 '9 +3 +Z1 *04 +Z1 *06 +Z1 *07 +Z1 *0A [ +Z1 *12 *24 +Z1 *14 $j +Z1 *15 o3i +Z1 *21 +Z1 *24 +Z1 *25 D3 +Z1 *31 +Z1 *32 +Z1 *34 +Z1 *35 +Z1 *38 +Z1 *48 O32 +Z1 *50 +Z1 *51 +Z1 *52 +Z1 *52 K +Z1 *56 i5m +Z1 *56 ssu +Z1 *57 +Z1 *58 +Z1 *59 +Z1 *63 +Z1 *68 +Z1 *68 i5< +Z1 *69 l +Z1 *74 +Z1 *85 -6 +Z1 *97 +Z1 *A8 +Z1 +0 z1 +Z1 +1 +Z1 +1 *31 +Z1 +2 +Z1 +4 +Z1 +5 +Z1 +7 D4 +Z1 +7 o0a +Z1 +7 o5- +Z1 +8 +Z1 +8 o7u +Z1 +9 +Z1 +9 i85 +Z1 -0 +Z1 -0 -0 +Z1 -0 @t +Z1 -0 u +Z1 -1 +7 +Z1 -2 +Z1 -2 L6 +Z1 -3 +Z1 -4 +Z1 -4 t +Z1 -5 +Z1 -6 +Z1 -6 ^* +Z1 -A +Z1 -A +B +Z1 @6 -2 +Z1 @a +Z1 @z O04 +Z1 D1 R4 +Z1 D3 +5 +Z1 D3 T1 +Z1 D4 +Z1 D5 +Z1 D7 sUE +Z1 L0 +Z1 L4 O65 +Z1 L5 o2l +Z1 R0 o1i +Z1 R1 +Z1 R2 $c +Z1 R4 +Z1 R6 z1 +Z1 R7 D4 +Z1 T1 +Z1 T4 +Z1 T5 +Z1 T5 ^A +Z1 T6 sbK +Z1 Z1 sCk +Z1 Z5 +Z1 [ +Z1 [ i2< +Z1 [ O31 +Z1 ^" +Z1 ^$ +Z1 ^0 +Z1 ^2 +Z1 ^4 +Z1 ^4 D4 +Z1 ^7 *14 +Z1 ^8 +Z1 ^9 O46 +Z1 ^B +Z1 ^D +Z1 ^P +Z1 ^U +Z1 ^W +Z1 ^X +Z1 ^\ +Z1 ^c +Z1 ^e +Z1 ^g +Z1 ^l i4b +Z1 ^n +Z1 ^o +Z1 ^p +Z1 ^q +Z1 ^s +Z1 ^v *91 +Z1 ^| +Z1 c +Z1 c *73 +Z1 c +3 +Z1 c D7 +Z1 d +Z1 d O56 +Z1 d O65 +Z1 d O75 +Z1 f O38 +Z1 f O5A +Z1 i0k +Z1 i13 D3 +Z1 i1e +Z1 i1j +Z1 i1l +Z1 i1p +Z1 i2- +Z1 i21 +Z1 i2Z +Z1 i2a +Z1 i2c +Z1 i2v +Z1 i38 +Z1 i3: +Z1 i3I +Z1 i3s +Z1 i41 +Z1 i43 +Z1 i48 +Z1 i4K +Z1 i4] +Z1 i4a [ +Z1 i4b O18 +Z1 i4e O71 +Z1 i4h -3 +Z1 i4s +Z1 i4t +Z1 i4y +Z1 i5! +Z1 i5- +Z1 i56 +Z1 i58 +Z1 i5= +Z1 i5O +Z1 i5e +Z1 i5p +Z1 i5t +Z1 i6& +Z1 i6/ +Z1 i62 +Z1 i64 +Z1 i69 +Z1 i6L +Z1 i6e +Z1 i6f +Z1 i6x +Z1 i7% +Z1 i71 +Z1 i7N +Z1 i7R [ +Z1 i7m o6M +Z1 i7n +Z1 i7o +Z1 i7r +Z1 i7t +Z1 i80 +Z1 i81 +Z1 i88 +Z1 i8j +Z1 i8v +Z1 i8x +Z1 i91 +Z1 i93 +Z1 i9s +Z1 iA7 +Z1 k +Z1 k i3v +Z1 l ^D +Z1 o04 +Z1 o07 +Z1 o0E +Z1 o0F +Z1 o0I +Z1 o0K +Z1 o0] +Z1 o0b +Z1 o0d O32 +Z1 o0q i48 +Z1 o0t +Z1 o0v +Z1 o15 $b +Z1 o17 +Z1 o1c +Z1 o1b +Z1 o2A +Z1 o2` +Z1 o2o +Z1 o2s +Z1 o2u +Z1 o3! +Z1 o31 +Z1 o39 +Z1 o3: O37 +Z1 o3n +Z1 o3t +Z1 o3v +Z1 o4! +Z1 o4/ +Z1 o43 l +Z1 o44 slF +Z1 o49 +Z1 o4a +Z1 o4h +Z1 o4n +Z1 o5% +Z1 o5- +Z1 o54 +Z1 o59 +Z1 o5@ +Z1 o5C +Z1 o5_ +Z1 o5c +Z1 o6= +Z1 o6F +Z1 o6p +Z1 o6t +Z1 o7, { +Z1 o75 +Z1 o7E z2 +Z1 o7e +Z1 o7i +Z1 o7p +Z1 o7z +Z1 o80 T0 +Z1 o9? O46 +Z1 o9_ +Z1 p2 'A +Z1 p2 O13 +Z1 q +Z1 q '9 +Z1 r +Z1 r *24 +Z1 s!T +Z1 s0, +Z1 s0a +Z1 s2- +Z1 s2^ +Z1 s38 +Z1 s3q +Z1 s6) +Z1 s64 +Z1 s8* +Z1 s9& +Z1 s90 +Z1 s@a +Z1 sBH D6 +Z1 sHW +Z1 sa? +Z1 sb+ +Z1 sca +Z1 sdu +Z1 se7 +Z1 seb +Z1 seu +Z1 sfj O43 +Z1 sjB +Z1 sjv +Z1 sk +Z1 sle O71 +Z1 smN +Z1 sn. +Z1 sn5 +Z1 snl +Z1 so' +Z1 soO +Z1 sou +Z1 srz +Z1 ss& +Z1 ssB +Z1 stb +Z1 stn +Z1 sua +Z1 svb +Z1 sxt +Z1 syh +Z1 sz7 +Z1 t +Z1 t [ +Z1 t r +Z1 t O28 +Z1 u +Z1 u { +Z1 O03 +Z1 O05 +Z1 O12 spu +Z1 O13 f +Z1 O15 +Z1 O15 sbg +Z1 O16 +Z1 O16 D5 +Z1 O17 +Z1 O21 *01 +Z1 O23 z3 +Z1 O24 +Z1 O25 t +Z1 O27 c +Z1 O28 +Z1 O32 +Z1 O32 ^r +Z1 O38 +Z1 O42 +Z1 O42 d +Z1 O43 +Z1 O46 $m +Z1 O47 +Z1 O52 i0Z +Z1 O54 +Z1 O56 +Z1 O57 +Z1 O57 c +Z1 O62 +Z1 O64 +Z1 O72 o48 +Z1 O73 +Z1 O74 +Z1 O85 +Z1 O95 O42 +Z1 OA2 O17 +Z1 OA3 +Z1 OB2 +Z1 z1 +Z1 z1 $s +Z1 z1 *09 +Z1 z1 p1 +Z1 z2 D7 +Z1 z3 +Z1 z5 O25 +Z1 { +Z1 { T1 +Z1 } o12 Z2 -Z2$! -Z2$'C -Z2$* -Z2$+ -Z2$. -Z2$.[ -Z2$/ -Z2$1 -Z2$2 -Z2$3 -Z2$4 -Z2$5 -Z2$6 -Z2$7 -Z2$8 -Z2$9 -Z2$9k -Z2$<$3 -Z2$M -Z2$O -Z2$b -Z2$d -Z2$e -Z2$eR5 -Z2$f^h -Z2$h -Z2$ho5[ -Z2$k -Z2$v -Z2$x -Z2$y{ -Z2$z -Z2'4q -Z2'6i4P -Z2'8u -Z2*02 -Z2*05 -Z2*06 -Z2*14 -Z2*15o0( -Z2*16 -Z2*17 -Z2*18*49 -Z2*20O14 -Z2*23 -Z2*24 -Z2*26 -Z2*27 -Z2*30 -Z2*31*21 -Z2*31r -Z2*37 -Z2*38 -Z2*42-5 -Z2*45 -Z2*45k -Z2*47 -Z2*48D4 -Z2*4AO05 -Z2*50[ -Z2*51 -Z2*53 -Z2*56su% -Z2*63 -Z2*63-5 -Z2*64 -Z2*64o4a -Z2*65 -Z2*67 -Z2*68 -Z2*73Z1 -Z2*79o70 -Z2*82O37 -Z2*85 -Z2*90$e -Z2*93 -Z2*94 -Z2+0 -Z2+2 -Z2+3 -Z2+4 -Z2+4l -Z2+5 -Z2+6 -Z2+6} -Z2+7 -Z2+7o50 -Z2+8 -Z2+9 -Z2+AD0 -Z2-0 -Z2-2 -Z2-3 -Z2-4 -Z2-4i38 -Z2-6 -Z2-7 -Z2-7L0 -Z2-8 -Z2-9 -Z2-A -Z2-AT0 -Z2@1u -Z2@4 -Z2@5 -Z2@b*74 -Z2C -Z2CZ2 -Z2D1 -Z2D2+7 -Z2D2c -Z2D5 -Z2L1 -Z2L2 -Z2L3 -Z2L4^3 -Z2L6 -Z2L9 -Z2R0-0 -Z2R1 -Z2R2u -Z2R3 -Z2R4 -Z2R4{ -Z2R5 -Z2R9 -Z2T0 -Z2T0o8n -Z2T2 -Z2T5 -Z2Z1O48 -Z2Z4r -Z2Z4O75 -Z2[ -Z2[t -Z2^$ -Z2^)*36 -Z2^, -Z2^3 -Z2^5 -Z2^6 -Z2^7O52 -Z2^@ -Z2^A -Z2^H -Z2^V -Z2^Wi3] -Z2^Y -Z2^_ -Z2^a -Z2^j -Z2^l -Z2^q -Z2^t -Z2^u -Z2^v^d -Z2^{o5& -Z2c -Z2c$z -Z2cD1 -Z2cz1 -Z2cz2 -Z2d -Z2i1n -Z2i1} -Z2i2G*75 -Z2i3, -Z2i3d -Z2i3w] -Z2i3y -Z2i4- -Z2i4e -Z2i4j] -Z2i5(O27 -Z2i5f -Z2i5r -Z2i5x -Z2i6-+9 -Z2i6. -Z2i60 -Z2i6n -Z2i6x -Z2i78 -Z2i7Y -Z2i7d -Z2i7u -Z2i88 -Z2i8o -Z2i8v -Z2k -Z2k*07 -Z2l -Z2o02R8 -Z2o0D -Z2o0K -Z2o0P -Z2o0_ -Z2o0a -Z2o0d -Z2o0h -Z2o0j -Z2o0o -Z2o0po1] -Z2o1- -Z2o1n -Z2o21 -Z2o29D1 -Z2o2bO01 -Z2o2d -Z2o2m -Z2o2s-7 -Z2o2y -Z2o3 -Z2o30 -Z2o3l -Z2o3u -Z2o3u*10 -Z2o4- -Z2o46 -Z2o4H -Z2o4_ -Z2o4h -Z2o5F -Z2o5L -Z2o5\ -Z2o5b -Z2o5ml -Z2o67 -Z2o68-4 -Z2o6no4* -Z2o70 -Z2o73 -Z2o76 -Z2o7N -Z2o7s -Z2o8# -Z2o8B -Z2o8_ -Z2o8h -Z2o8n -Z2o8o -Z2o8p -Z2o8s -Z2o8t -Z2o9m -Z2oAwO24 -Z2oBhO56 -Z2r -Z2r*46 -Z2rZ2 -Z2r^3 -Z2ri67 -Z2s06 -Z2s0R -Z2s1- -Z2s1t -Z2s1z -Z2s27 -Z2s5+ -Z2s52 -Z2s59 -Z2s5C -Z2s5b -Z2s85 -Z2s9fO31 -Z2s9j -Z2sa? -Z2saI -Z2se7 -Z2sfh -Z2sft -Z2sgx -Z2sgz -Z2shql -Z2shr -Z2shv -Z2si9 -Z2sipO19 -Z2slS -Z2slx -Z2smn -Z2ss+ -Z2ss5 -Z2svwO54 -Z2t -Z2ti5N -Z2u -Z2O02 -Z2O02s8K -Z2O03 -Z2O06 -Z2O08 -Z2O12 -Z2O12Z1 -Z2O12u -Z2O12O23 -Z2O13 -Z2O14^u -Z2O21 -Z2O23 -Z2O25 -Z2O26 -Z2O27 -Z2O28 -Z2O2A -Z2O31 -Z2O32 -Z2O32se# -Z2O35 -Z2O3A -Z2O43$7 -Z2O49 -Z2O49Z4 -Z2O4B -Z2O53[ -Z2O56 -Z2O64 -Z2O72 -Z2O82 -Z2O83 -Z2O84 -Z2O93-A -Z2O94 -Z2O94D7 -Z2O95 -Z2O96 -Z2OB5 -Z2z1 -Z2z1T0 -Z2z1O25 -Z2z1O73 -Z2z2 -Z2{+4 -Z2{o13 -Z2{u +Z2 $! +Z2 $' C +Z2 $* +Z2 $+ +Z2 $. +Z2 $. [ +Z2 $/ +Z2 $1 +Z2 $2 +Z2 $3 +Z2 $4 +Z2 $5 +Z2 $6 +Z2 $7 +Z2 $8 +Z2 $9 +Z2 $9 k +Z2 $< $3 +Z2 $M +Z2 $O +Z2 $b +Z2 $d +Z2 $e +Z2 $e R5 +Z2 $f ^h +Z2 $h +Z2 $h o5[ +Z2 $k +Z2 $v +Z2 $x +Z2 $y { +Z2 $z +Z2 '4 q +Z2 '6 i4P +Z2 '8 u +Z2 *02 +Z2 *05 +Z2 *06 +Z2 *14 +Z2 *15 o0( +Z2 *16 +Z2 *17 +Z2 *18 *49 +Z2 *20 O14 +Z2 *23 +Z2 *24 +Z2 *26 +Z2 *27 +Z2 *30 +Z2 *31 *21 +Z2 *31 r +Z2 *37 +Z2 *38 +Z2 *42 -5 +Z2 *45 +Z2 *45 k +Z2 *47 +Z2 *48 D4 +Z2 *4A O05 +Z2 *50 [ +Z2 *51 +Z2 *53 +Z2 *56 su% +Z2 *63 +Z2 *63 -5 +Z2 *64 +Z2 *64 o4a +Z2 *65 +Z2 *67 +Z2 *68 +Z2 *73 Z1 +Z2 *79 o70 +Z2 *82 O37 +Z2 *85 +Z2 *90 $e +Z2 *93 +Z2 *94 +Z2 +0 +Z2 +2 +Z2 +3 +Z2 +4 +Z2 +4 l +Z2 +5 +Z2 +6 +Z2 +6 } +Z2 +7 +Z2 +7 o50 +Z2 +8 +Z2 +9 +Z2 +A D0 +Z2 -0 +Z2 -2 +Z2 -3 +Z2 -4 +Z2 -4 i38 +Z2 -6 +Z2 -7 +Z2 -7 L0 +Z2 -8 +Z2 -9 +Z2 -A +Z2 -A T0 +Z2 @1 u +Z2 @4 +Z2 @5 +Z2 @b *74 +Z2 D1 +Z2 D2 +7 +Z2 D2 c +Z2 D5 +Z2 L1 +Z2 L2 +Z2 L3 +Z2 L4 ^3 +Z2 L6 +Z2 L9 +Z2 R0 -0 +Z2 R1 +Z2 R2 u +Z2 R3 +Z2 R4 +Z2 R4 { +Z2 R5 +Z2 R9 +Z2 T0 +Z2 T0 o8n +Z2 T2 +Z2 T5 +Z2 Z1 O48 +Z2 Z4 r +Z2 Z4 O75 +Z2 [ +Z2 [ t +Z2 ^$ +Z2 ^) *36 +Z2 ^, +Z2 ^3 +Z2 ^5 +Z2 ^6 +Z2 ^7 O52 +Z2 ^@ +Z2 ^A +Z2 ^H +Z2 ^V +Z2 ^W i3] +Z2 ^Y +Z2 ^_ +Z2 ^a +Z2 ^j +Z2 ^l +Z2 ^q +Z2 ^t +Z2 ^u +Z2 ^v ^d +Z2 ^{ o5& +Z2 c +Z2 c $z +Z2 c D1 +Z2 c z1 +Z2 c z2 +Z2 d +Z2 i1n +Z2 i1} +Z2 i2G *75 +Z2 i3, +Z2 i3d +Z2 i3w ] +Z2 i3y +Z2 i4- +Z2 i4e +Z2 i4j ] +Z2 i5( O27 +Z2 i5f +Z2 i5r +Z2 i5x +Z2 i6- +9 +Z2 i6. +Z2 i60 +Z2 i6n +Z2 i6x +Z2 i78 +Z2 i7Y +Z2 i7d +Z2 i7u +Z2 i88 +Z2 i8o +Z2 i8v +Z2 k +Z2 k *07 +Z2 l +Z2 o02 R8 +Z2 o0D +Z2 o0K +Z2 o0P +Z2 o0_ +Z2 o0a +Z2 o0d +Z2 o0h +Z2 o0j +Z2 o0o +Z2 o0p o1] +Z2 o1- +Z2 o1n +Z2 o21 +Z2 o29 D1 +Z2 o2b O01 +Z2 o2d +Z2 o2m +Z2 o2s -7 +Z2 o2y +Z2 o3 +Z2 o30 +Z2 o3l +Z2 o3u +Z2 o3u *10 +Z2 o4- +Z2 o46 +Z2 o4H +Z2 o4_ +Z2 o4h +Z2 o5F +Z2 o5L +Z2 o5\ +Z2 o5b +Z2 o5m l +Z2 o67 +Z2 o68 -4 +Z2 o6n o4* +Z2 o70 +Z2 o73 +Z2 o76 +Z2 o7N +Z2 o7s +Z2 o8# +Z2 o8B +Z2 o8_ +Z2 o8h +Z2 o8n +Z2 o8o +Z2 o8p +Z2 o8s +Z2 o8t +Z2 o9m +Z2 oAw O24 +Z2 oBh O56 +Z2 r +Z2 r *46 +Z2 r Z2 +Z2 r ^3 +Z2 r i67 +Z2 s06 +Z2 s0R +Z2 s1- +Z2 s1t +Z2 s1z +Z2 s27 +Z2 s5+ +Z2 s52 +Z2 s59 +Z2 s5C +Z2 s5b +Z2 s85 +Z2 s9f O31 +Z2 s9j +Z2 sa? +Z2 saI +Z2 se7 +Z2 sfh +Z2 sft +Z2 sgx +Z2 sgz +Z2 shq l +Z2 shr +Z2 shv +Z2 si9 +Z2 sip O19 +Z2 slS +Z2 slx +Z2 smn +Z2 ss+ +Z2 ss5 +Z2 svw O54 +Z2 t +Z2 t i5N +Z2 u +Z2 O02 +Z2 O02 s8K +Z2 O03 +Z2 O06 +Z2 O08 +Z2 O12 +Z2 O12 Z1 +Z2 O12 u +Z2 O12 O23 +Z2 O13 +Z2 O14 ^u +Z2 O21 +Z2 O23 +Z2 O25 +Z2 O26 +Z2 O27 +Z2 O28 +Z2 O2A +Z2 O31 +Z2 O32 +Z2 O32 se# +Z2 O35 +Z2 O3A +Z2 O43 $7 +Z2 O49 +Z2 O49 Z4 +Z2 O4B +Z2 O53 [ +Z2 O56 +Z2 O64 +Z2 O72 +Z2 O82 +Z2 O83 +Z2 O84 +Z2 O93 -A +Z2 O94 +Z2 O94 D7 +Z2 O95 +Z2 O96 +Z2 OB5 +Z2 z1 +Z2 z1 T0 +Z2 z1 O25 +Z2 z1 O73 +Z2 z2 +Z2 { +4 +Z2 { o13 +Z2 { u Z3 -Z3$- -Z3$0 -Z3$1 -Z3$1t -Z3$3 -Z3$5 -Z3$7 -Z3$9 -Z3$?O56 -Z3$J[ -Z3$SO75 -Z3$br -Z3$gO62 -Z3$l -Z3$mO37 -Z3$nT2 -Z3$o*16 -Z3$q -Z3$s+4 -Z3$v -Z3$z -Z3$} -Z3'2$5 -Z3*06 -Z3*0B -Z3*13 -Z3*16 -Z3*25 -Z3*2A -Z3*30 -Z3*34 -Z3*35 -Z3*37 -Z3*38 -Z3*41o3v -Z3*49 -Z3*50 -Z3*54 -Z3*57 -Z3*59O71 -Z3*63*72 -Z3*65L6 -Z3*68 -Z3*6B -Z3*70 -Z3*82c -Z3*96D5 -Z3*A0 -Z3+0 -Z3+1 -Z3+2 -Z3+3l -Z3+4 -Z3+5 -Z3+5O6A -Z3+6 -Z3+7 -Z3+9 -Z3+A -Z3-0 -Z3-0O59 -Z3-1 -Z3-1r -Z3-4 -Z3-4o1A -Z3-5 -Z3-6 -Z3-6-9 -Z3-6O76 -Z3-7 -Z3-8 -Z3-9 -Z3-9OB5 -Z3-A -Z3-B -Z3@z+2 -Z3C -Z3CO02 -Z3D1 -Z3D2 -Z3D3 -Z3D6 -Z3D7 -Z3L1 -Z3L3 -Z3L5z1 -Z3L6 -Z3R0 -Z3R0s5p -Z3R1 -Z3R2l -Z3R5 -Z3RA -Z3T0 -Z3T1 -Z3T2 -Z3T2D1 -Z3T3*69 -Z3T3O02 -Z3T6O28 -Z3T7 -Z3TA'9 -Z3TB -Z3Z3*36 -Z3Z3O56 -Z3Z4[ -Z3Z5 -Z3Z5t -Z3[ -Z3[-9 -Z3[D3 -Z3[Z5 -Z3[^u -Z3[{ -Z3]i7a -Z3^$} -Z3^0 -Z3^3 -Z3^3t -Z3^8 -Z3^> -Z3^J -Z3^J'7 -Z3^a -Z3^c -Z3^e -Z3^pO62 -Z3^r -Z3^x*02 -Z3c -Z3c*40 -Z3cO85 -Z3cz1 -Z3d -Z3i0U -Z3i1+ -Z3i1o -Z3i2B -Z3i2S -Z3i3Q[ -Z3i3p -Z3i43 -Z3i4k*41 -Z3i4k*7B -Z3i6L -Z3i6q -Z3i7x -Z3k -Z3k*42 -Z3k} -Z3l -Z3o0d -Z3o0i -Z3o0j -Z3o0m -Z3o14 -Z3o1U -Z3o2e -Z3o2ll -Z3o2n -Z3o2o -Z3o30 -Z3o3ui45 -Z3o4a -Z3o4l -Z3o4t -Z3o4uD5 -Z3o5. -Z3o5E -Z3o5i -Z3o5o -Z3o5s -Z3o6* -Z3o6,O46 -Z3o6C -Z3o6K -Z3o6k -Z3o6s+7 -Z3o6w -Z3o7o -Z3o92*83 -Z3o9h -Z3o9r -Z3p2 -Z3p3 -Z3r -Z3rO32 -Z3s0u -Z3s1] -Z3s39 -Z3s57[ -Z3s6T -Z3s6l -Z3s7B -Z3s9k -Z3sab -Z3scw] -Z3sdz -Z3sd|O13 -Z3segsvt -Z3sjf+4 -Z3slz -Z3sn+ -Z3soaO59 -Z3soe -Z3spb -Z3ssz -Z3stf -Z3su- -Z3sy7 -Z3tO61 -Z3u -Z3u$\ -Z3uo4a -Z3uO01 -Z3O03$) -Z3O03^; -Z3O04 -Z3O05 -Z3O06s1n -Z3O12O56 -Z3O13-2 -Z3O13^7 -Z3O16z3 -Z3O1B -Z3O23 -Z3O23l -Z3O2A$d -Z3O2B-4 -Z3O34 -Z3O34^5 -Z3O36 -Z3O4B -Z3O51 -Z3O53 -Z3O53r -Z3O54 -Z3O57sAS -Z3O63o6f -Z3O65$X -Z3O74 -Z3O75T0 -Z3O79c -Z3O83 -Z3O92 -Z3OA1 -Z3OB2 -Z3OB4 -Z3OB7$1 -Z3z3 -Z3{ -Z3} +Z3 $- +Z3 $0 +Z3 $1 +Z3 $1 t +Z3 $3 +Z3 $5 +Z3 $7 +Z3 $9 +Z3 $? O56 +Z3 $J [ +Z3 $S O75 +Z3 $b r +Z3 $g O62 +Z3 $l +Z3 $m O37 +Z3 $n T2 +Z3 $o *16 +Z3 $q +Z3 $s +4 +Z3 $v +Z3 $z +Z3 $} +Z3 '2 $5 +Z3 *06 +Z3 *0B +Z3 *13 +Z3 *16 +Z3 *25 +Z3 *2A +Z3 *30 +Z3 *34 +Z3 *35 +Z3 *37 +Z3 *38 +Z3 *41 o3v +Z3 *49 +Z3 *50 +Z3 *54 +Z3 *57 +Z3 *59 O71 +Z3 *63 *72 +Z3 *65 L6 +Z3 *68 +Z3 *6B +Z3 *70 +Z3 *82 c +Z3 *96 D5 +Z3 *A0 +Z3 +0 +Z3 +1 +Z3 +2 +Z3 +3 l +Z3 +4 +Z3 +5 +Z3 +5 O6A +Z3 +6 +Z3 +7 +Z3 +9 +Z3 +A +Z3 -0 +Z3 -0 O59 +Z3 -1 +Z3 -1 r +Z3 -4 +Z3 -4 o1A +Z3 -5 +Z3 -6 +Z3 -6 -9 +Z3 -6 O76 +Z3 -7 +Z3 -8 +Z3 -9 +Z3 -9 OB5 +Z3 -A +Z3 -B +Z3 @z +2 +Z3 C O02 +Z3 D1 +Z3 D2 +Z3 D3 +Z3 D6 +Z3 D7 +Z3 L1 +Z3 L3 +Z3 L5 z1 +Z3 L6 +Z3 R0 +Z3 R0 s5p +Z3 R1 +Z3 R2 l +Z3 R5 +Z3 RA +Z3 T0 +Z3 T1 +Z3 T2 +Z3 T2 D1 +Z3 T3 *69 +Z3 T3 O02 +Z3 T6 O28 +Z3 T7 +Z3 '9 +Z3 TB +Z3 Z3 *36 +Z3 Z3 O56 +Z3 Z4 [ +Z3 Z5 +Z3 Z5 t +Z3 [ +Z3 [ -9 +Z3 [ D3 +Z3 [ Z5 +Z3 [ ^u +Z3 [ { +Z3 ] i7a +Z3 ^$ } +Z3 ^0 +Z3 ^3 +Z3 ^3 t +Z3 ^8 +Z3 ^> +Z3 ^J +Z3 ^J '7 +Z3 ^a +Z3 ^c +Z3 ^e +Z3 ^p O62 +Z3 ^r +Z3 ^x *02 +Z3 c +Z3 c *40 +Z3 c O85 +Z3 c z1 +Z3 d +Z3 i0U +Z3 i1+ +Z3 i1o +Z3 i2B +Z3 i2S +Z3 i3Q [ +Z3 i3p +Z3 i43 +Z3 i4k *41 +Z3 i4k *7B +Z3 i6L +Z3 i6q +Z3 i7x +Z3 k +Z3 k *42 +Z3 k } +Z3 l +Z3 o0d +Z3 o0i +Z3 o0j +Z3 o0m +Z3 o14 +Z3 o1U +Z3 o2e +Z3 o2l l +Z3 o2n +Z3 o2o +Z3 o30 +Z3 o3u i45 +Z3 o4a +Z3 o4l +Z3 o4t +Z3 o4u D5 +Z3 o5. +Z3 o5E +Z3 o5i +Z3 o5o +Z3 o5s +Z3 o6* +Z3 o6, O46 +Z3 o6C +Z3 o6K +Z3 o6k +Z3 o6s +7 +Z3 o6w +Z3 o7o +Z3 o92 *83 +Z3 o9h +Z3 o9r +Z3 p2 +Z3 p3 +Z3 r +Z3 r O32 +Z3 s0u +Z3 s1] +Z3 s39 +Z3 s57 [ +Z3 s6T +Z3 s6l +Z3 s7B +Z3 s9k +Z3 sab +Z3 scw ] +Z3 sdz +Z3 sd| O13 +Z3 seg svt +Z3 sjf +4 +Z3 slz +Z3 sn+ +Z3 soa O59 +Z3 soe +Z3 spb +Z3 ssz +Z3 stf +Z3 su- +Z3 sy7 +Z3 t O61 +Z3 u +Z3 u $\ +Z3 u o4a +Z3 u O01 +Z3 O03 $) +Z3 O03 ^; +Z3 O04 +Z3 O05 +Z3 O06 s1n +Z3 O12 O56 +Z3 O13 -2 +Z3 O13 ^7 +Z3 O16 z3 +Z3 O1B +Z3 O23 +Z3 O23 l +Z3 O2A $d +Z3 O2B -4 +Z3 O34 +Z3 O34 ^5 +Z3 O36 +Z3 O4B +Z3 O51 +Z3 O53 +Z3 O53 r +Z3 O54 +Z3 O57 sAS +Z3 O63 o6f +Z3 O65 $X +Z3 O74 +Z3 O75 T0 +Z3 O79 c +Z3 O83 +Z3 O92 +Z3 OA1 +Z3 OB2 +Z3 OB4 +Z3 OB7 $1 +Z3 z3 +Z3 { +Z3 } Z4 -Z4$1 -Z4$4 -Z4$7 -Z4$9 -Z4$ -[$? -[$@ -[$A -[$B -[$D -[$E -[$L -[$N -[$V+2 -[$X -[$^ -[$` -[$a -[$a*53 -[$b -[$d -[$dz3 -[$f -[$fz4 -[$g -[$i -[$k -[$n -[$nK -[$o -[$o^? -[$r -[$ru -[$s -[$v -[$y -[$} -['5smj -['6 -['6sJc -['8T7 -['8^g -['A -[*02 -[*03 -[*05 -[*09 -[*12 -[*16 -[*23 -[*25 -[*31 -[*40k -[*51*40 -[*54+2 -[*67 -[*70 -[*83 -[+0z2 -[+1 -[+2 -[+4 -[+9 -[-0 -[-1 -[-2 -[-2o6k -[-3 -[-4u -[-5} -[-8 -[-9T0 -[-A -[@0 -[@4 -[@9 -[@B -[@e -[@h -[@i -[C -[Ci5y -[D0z4 -[D1 -[D3R0 -[D4 -[D4$U -[D4d -[K*15 -[L1 -[L6 -[R0 -[R1 -[R1i0R -[R2Z1 -[R2d -[R3 -[R3Z1 -[R3c -[R3shf -[R7 -[T1 -[T8 -[T8+7 -[T8^N -[T8si[ -[Z1 -[Z1o9q -[Z2 -[Z2R8 -[Z2Z5 -[Z2^1 -[Z2i02 -[Z2o4' -[Z3 -[Z3*52 -[Z3o56 -[Z4 -[Z4Z5 -[Z4i0k -[Z4z1 -[Z5 -[Z5o68 -[Z5z1 -[[ -[[ $1 -[[[ -[[[ $1 -[[[[ -[[[[ $1 -[[[[[ -[[[[[c -[[[[c -[[[c -[[c -[[o71 -[[O43 -[^% -[^& -[^- -[^0Z2 -[^= -[^C*31 -[^I-1 -[^L -[^Ll -[^LO27 -[^O -[^P -[^V'6 -[^X*12 -[^a -[^g -[^g'7 -[^h+2 -[^j -[^p -[^vD1 -[^} -[c -[c$J -[c*31 -[d -[f -[fi4G -[i0Ei0E -[i0PO62 -[i0l -[i0x -[i1# -[i11 -[i15 -[i1G -[i1P -[i1Z -[i1[ -[i1d -[i1e -[i1w -[i1y -[i1z -[i21 -[i2Z -[i2a -[i2j -[i2k -[i2q -[i2x -[i3& -[i3- -[i31 -[i33 -[i39 -[i3GR7 -[i4* -[i4, -[i41D6 -[i45 -[i4= -[i4HO29 -[i4b -[i4i -[i4l -[i4n -[i4r -[i4vZ1 -[i5 -[i5* -[i5- -[i58 -[i5i -[i5s -[i5y -[i6= -[i6A -[i6_ -[i6fl -[i6i -[i6o -[i7k -[i7p -[i7x -[i8e -[i8g -[i95 -[kR5 -[lT7 -[li1e -[lswn -[o0" -[o0/ -[o04 -[o0> -[o0F -[o0N -[o0S -[o0W -[o0d -[o0l -[o0n -[o0q -[o0z -[o1 -[o1& -[o10 -[o17 -[o1g -[o1ni3A -[o1o -[o1t -[o1y -[o2 -[o23i32 -[o2; -[o2A -[o2G -[o2WC -[o2Y -[o2d -[o2q -[o2t -[o2uZ1 -[o2v -[o2z -[o2}r -[o3 -[o3+ -[o33 -[o3I -[o3J -[o3U -[o3_ -[o3a -[o3c -[o3d -[o3j -[o3l -[o3psgs -[o3r -[o3s -[o3z -[o4 -[o4% -[o4+ -[o41 -[o4WC -[o4j -[o4s -[o4t -[o4tO23 -[o4u -[o4w -[o5) -[o56 -[o5f -[o5g -[o5i -[o5li0r -[o5n -[o5u -[o6 -[o6/ -[o68 -[o6g -[o7H -[o7i -[o7n -[o9> -[oA4} -[p1^} -[p1sc2 -[p1O63 -[p2 -[p2O24 -[p3 -[p4 -[p5 -[q -[qo4m -[qO27 -[qO2A -[qz4 -[r -[r*20 -[rz3 -[r} -[s-g -[s07 -[s0p -[s7+ -[s8T -[s9Uo0^ -[sLe -[sWi -[sa@ -[sat -[scb -[sez -[sez$u -[sh1 -[shG -[sj6 -[slt -[snwr -[sqE -[srz -[ss? -[st -[sts -[sv9 -[swL -[sxc -[sz6 -[sz8 -[sz9 -[szp -[t*42 -[tz2 -[t} -[u -[ui2A -[uo5g -[O02z2 -[O12 -[O13$m -[O15 -[O15s6K -[O17 -[O21 -[O21d -[O23sa+ -[O24 -[O24$v -[O25 -[O26 -[O31 -[O32 -[O34 -[O34s4d -[O37O41 -[O41u -[O42 -[O43Z2 -[O45 -[O45$L -[O45z2 -[O51 -[O51o1_ -[O52$z -[O53 -[O64 -[O6A -[O71O05 -[O73 -[O74c -[O93O34 -[z1 -[z1-4 -[z1o2D -[z2 -[z2^1 -[z2^k -[z2i49 -[z2l -[z3 -[z3*48 -[z3*79 -[z3R0 -[z3Z2 -[z4 -[z4+5 -[z4} -[z5 -[z5*19 -[z5seb -[z5O67 -[{ -[{*35 -[{D1 -[{Z4 -[{u -[}^K -[}o3u +[ $ +[ $# ^Q +[ $% +[ $- +[ $2 +[ $2 O0B +[ $3 +[ $4 +[ $4 K +[ $7 o4j +[ $7 O45 +[ $8 +[ $< +[ $> +[ $@ +[ $B +[ $D +[ $E +[ $L +[ $N +[ $V +2 +[ $^ +[ $` +[ $a +[ $a *53 +[ $d +[ $d z3 +[ $f +[ $f z4 +[ $g +[ $i +[ $n +[ $n K +[ $o +[ $o ^? +[ $r +[ $r u +[ $s +[ $v +[ $y +[ $} +[ '5 smj +[ '6 +[ '6 sJc +[ '8 T7 +[ '8 ^g +[ 'A +[ *02 +[ *03 +[ *05 +[ *09 +[ *12 +[ *16 +[ *23 +[ *25 +[ *31 +[ *40 k +[ *51 *40 +[ *54 +2 +[ *67 +[ *70 +[ *83 +[ +0 z2 +[ +1 +[ +2 +[ +4 +[ +9 +[ -0 +[ -1 +[ -2 +[ -2 o6k +[ -3 +[ -4 u +[ -5 } +[ -8 +[ -9 T0 +[ -A +[ @0 +[ @4 +[ @B +[ @e +[ @i +[ C +[ C i5y +[ D0 z4 +[ D1 +[ D3 R0 +[ D4 +[ D4 $U +[ D4 d +[ K *15 +[ L1 +[ L6 +[ R0 +[ R1 +[ R1 i0R +[ R2 Z1 +[ R2 d +[ R3 +[ R3 Z1 +[ R3 c +[ R3 shf +[ R7 +[ T1 +[ T8 +[ T8 +7 +[ T8 ^N +[ T8 si[ +[ Z1 o9q +[ Z2 +[ Z2 R8 +[ Z2 Z5 +[ Z2 ^1 +[ Z2 i02 +[ Z2 o4' +[ Z3 +[ Z3 *52 +[ Z3 o56 +[ Z4 +[ Z4 Z5 +[ Z4 i0k +[ Z4 z1 +[ Z5 +[ Z5 o68 +[ Z5 z1 +[ [ +[ [ $1 +[ [ [ +[ [ [ $1 +[ [ [ [ +[ [ [ [ $1 +[ [ [ [ [ +[ [ [ [ [ c +[ [ [ [ c +[ [ [ c +[ [ c +[ [ o71 +[ [ O43 +o0% +o0& +o0- +[ ^0 Z2 +o0= +[ ^C *31 +[ ^I -1 +o0L +[ ^L l +[ ^L O27 +o0O +o0P +[ ^V '6 +[ ^X *12 +o0a +o0g +[ ^g '7 +[ ^h +2 +[ ^j +o0p +[ ^v D1 +[ ^} +[ c +[ c $J +[ c *31 +[ d +[ f +[ f i4G +[ i0E i0E +[ i0P O62 +[ i0l +[ i0x +[ i1# +[ i11 +[ i15 +[ i1G +[ i1P +[ i1Z +[ i1[ +[ i1d +[ i1e +[ i1w +[ i1y +[ i1z +[ i21 +[ i2Z +[ i2a +[ i2j +[ i2k +[ i2q +[ i2x +[ i3& +[ i3- +[ i31 +[ i33 +[ i39 +[ i3G R7 +[ i4* +[ i4, +[ i41 D6 +[ i45 +[ i4= +[ i4H O29 +[ i4b +[ i4i +[ i4l +[ i4n +[ i4r +[ i4v Z1 +[ i5 +[ i5* +[ i5- +[ i58 +[ i5i +[ i5s +[ i5y +[ i6= +[ i6A +[ i6_ +[ i6f l +[ i6i +[ i6o +[ i7k +[ i7p +[ i7x +[ i8e +[ i8g +[ i95 +[ k R5 +[ l T7 +[ l i1e +[ l swn +[ o0" +[ o0/ +[ o04 +[ o0> +[ o0F +[ o0N +[ o0S +[ o0W +[ o0d +[ o0l +[ o0n +[ o0q +[ o0z +[ o1 +[ o1& +[ o10 +[ o17 +[ o1g +[ o1n i3A +[ o1o +[ o1t +[ o1y +[ o2 +[ o23 i32 +[ o2; +[ o2A +[ o2G +[ o2W C +[ o2Y +[ o2d +[ o2q +[ o2t +[ o2u Z1 +[ o2v +[ o2z +[ o2} r +[ o3 +[ o3+ +[ o33 +[ o3I +[ o3J +[ o3U +[ o3_ +[ o3a +[ o3c +[ o3d +[ o3j +[ o3l +[ o3p sgs +[ o3r +[ o3s +[ o3z +[ o4 +[ o4% +[ o4+ +[ o41 +[ o4W C +[ o4j +[ o4s +[ o4t +[ o4t O23 +[ o4u +[ o4w +[ o5) +[ o56 +[ o5f +[ o5g +[ o5i +[ o5l i0r +[ o5n +[ o5u +[ o6 +[ o6/ +[ o68 +[ o6g +[ o7H +[ o7i +[ o7n +[ o9> +[ oA4 } +[ p1 ^} +[ p1 sc2 +[ p1 O63 +[ p2 +[ p2 O24 +[ p3 +[ p4 +[ p5 +[ q +[ q o4m +[ q O27 +[ q O2A +[ q z4 +[ r +[ r *20 +[ r z3 +[ r } +[ s-g +[ s07 +[ s0p +[ s7+ +[ s8T +[ s9U o0^ +[ sLe +[ sWi +[ sa@ +[ sat +[ scb +[ sez +[ sez $u +[ sh1 +[ shG +[ sj6 +[ slt +[ snw r +[ sqE +[ srz +[ ss? +[ st +[ sts +[ sv9 +[ swL +[ sxc +[ sz6 +[ sz8 +[ sz9 +[ szp +[ t *42 +[ t z2 +[ t } +[ u +[ u i2A +[ u o5g +[ O02 z2 +[ O12 +[ O13 $m +[ O15 +[ O15 s6K +[ O17 +[ O21 +[ O21 d +[ O23 sa+ +[ O24 +[ O24 $v +[ O25 +[ O26 +[ O31 +[ O32 +[ O34 +[ O34 s4d +[ O37 O41 +[ O41 u +[ O42 +[ O43 Z2 +[ O45 +[ O45 $L +[ O45 z2 +[ O51 +[ O51 o1_ +[ O52 $z +[ O53 +[ O64 +[ O6A +[ O71 O05 +[ O73 +[ O74 c +[ O93 O34 +[ z1 +[ z1 -4 +[ z1 o2D +[ z2 +[ z2 ^1 +[ z2 ^k +[ z2 i49 +[ z2 l +[ z3 +[ z3 *48 +[ z3 *79 +[ z3 R0 +[ z3 Z2 +[ z4 +[ z4 +5 +[ z4 } +[ z5 +[ z5 *19 +[ z5 seb +[ z5 O67 +[ { +[ { *35 +[ { D1 +[ { Z4 +[ { u +[ } ^K +[ } o3u ] -]$!Z3 -]$+ -]$: -]$C*17 -]$a{ -]$of -]$q^Q -]*10i0c -]*13 -]*13] -]*13z5 -]*16 -]*35 -]*36O43 -]*60 -]*64o5w -]*8BO63 -]+2*26 -]-1 -]-4 -]-4} -]D0u -]D1f -]D3R0 -]K -]KD5 -]Kp1 -]KO01 -]Kz2 -]T4 -]Z1^f -]Z2o5- -]Z3 -]Z3i6j -]Z4k -]] -]]] -]]]] -]]]]] -]]]]]c -]]]]c -]]]c -]]c -]^#u -]^( -]^5f -]^7 -]^F -]^ashm -]^nsmk -]^r -]^s -]c -]cD6 -]cT6 -]di4^ -]du -]f -]fO51 -]i00^< -]i26 -]i28*42 -]i2a -]i3'Z2 -]i31 -]i3= -]i3s -]i4_ -]iAh -]o0kz2 -]o1r -]o32Z3 -]o3W -]o3_ -]o3z -]o55d -]o56 -]o5g -]o5l -]o5r -]o5x -]o5yZ1 -]o6g -]p1 -]p2 -]p2O49 -]p2z2 -]q^z -]qd -]r -]rZ5 -]s2oK -]sau -]shW -]shf -]si7k -]sm9 -]snl -]stf -]stw -]uZ1 -]uZ5 -]uo42 -]ur -]uz5 -]O01} -]O02t -]O64+6 -]O71i0Z -]OB8Z3 -]z2 -]z3 -]z3{ -]z4 -]z4$f -]z5 -]z5+2 -]{*56 -]{r -]} +] $! Z3 +] $+ +] $: +] $C *17 +] $a { +] $o f +] $q ^Q +] *10 i0c +] *13 +] *13 ] +] *13 z5 +] *16 +] *35 +] *36 O43 +] *60 +] *64 o5w +] *8B O63 +] +2 *26 +] -1 +] -4 +] -4 } +] D0 u +] D1 f +] D3 R0 +] K +] K D5 +] K p1 +] K O01 +] K z2 +] T4 +] Z1 ^f +] Z2 o5- +] Z3 +] Z3 i6j +] Z4 k +] ] +] ] ] +] ] ] ] +] ] ] ] ] +] ] ] ] ] c +] ] ] ] c +] ] ] c +] ] c +] ^# u +] ^( +] ^5 f +] ^7 +] ^F +] ^a shm +] ^n smk +] ^r +] ^s +] c +] c D6 +] c T6 +] d i4^ +] d u +] f +] f O51 +] i00 ^< +] i26 +] i28 *42 +] i2a +] i3' Z2 +] i31 +] i3= +] i3s +] i4_ +] iAh +] o0k z2 +] o1r +] o32 Z3 +] o3W +] o3_ +] o3z +] o55 d +] o56 +] o5g +] o5l +] o5r +] o5x +] o5y Z1 +] o6g +] p1 +] p2 +] p2 O49 +] p2 z2 +] q ^z +] q d +] r +] r Z5 +] s2o K +] sau +] shW +] shf +] si7 k +] sm9 +] snl +] stf +] stw +] u Z1 +] u Z5 +] u o42 +] u r +] u z5 +] O01 } +] O02 t +] O64 +6 +] O71 i0Z +] OB8 Z3 +] z2 +] z3 +] z3 { +] z4 +] z4 $f +] z5 +] z5 +2 +] { *56 +] { r +] } ^ -^ $ -^ $Ho2* -^ *20 -^ +3^1 -^ ^ -^ ^-i1$ -^ ^OR1 -^ ^i -^ ^x -^ i1B -^ i2 -^ o4< -^ o5xT1 -^ r -^ s31 -^ O24 -^ z3 -^ z4 -^ z5 -^ } +^ $ +^ $H o2* +^ *20 +^ +3 ^1 +^ ^ +^ ^- i1$ +^ ^O R1 +^ ^i +^ ^x +^ i1B +^ i2 +^ o4< +^ o5x T1 +^ r +^ s31 +^ O24 +^ z3 +^ z4 +^ z5 +^ } ^! -^!$! -^!$$ -^!$3T6 -^!$As!Q -^!$z -^!*40 -^!+4 -^!@6o36 -^!C -^!Z3{ +^! $! +^! $$ +^! $3 T6 +^! $A s!Q +^! $z +^! *40 +^! +4 +^! @6 o36 +^! C +^! Z3 { z3 -^!^1 -^!^\ -^!^ji7i -^!d -^!i4/ -^!i78 -^!ss\ -^!O18 -^!O71 -^!z1 -^!z2 -^!z3*38 -^!z5'A +^! ^1 +^! ^\ +^! ^j i7i +^! d +^! i4/ +^! i78 +^! ss\ +^! O18 +^! O71 +^! z1 +^! z2 +^! z3 *38 +^! z5 'A ^" -^"$" -^"$ki4Y -^"'5 -^"Cs1o -^"D4 -^"R3 -^"^\ -^"^j -^"^o] -^"i3p -^"sie$0 -^"O0A$= -^"z3 +^" $" +^" $k i4Y +^" '5 +^" C s1o +^" D4 +^" R3 +^" ^\ +^" ^j +^" ^o ] +^" i3p +^" sie $0 +^" O0A $= +^" z3 ^# -^#$# -^#$1 -^#$@ -^#$p -^#*24 -^#*24$1 -^#*30 -^#*57o6" -^#*B7$0 -^#+7 -^#D6 -^#R3^& -^#T2 -^#^)o2f -^#^+ -^#^@ -^#^@^! -^#i1k -^#i2#$j -^#l -^#r -^#scm -^#sgw -^#O52 -^#O75 -^#z1 -^#} +^# $# +^# $1 +^# $@ +^# $p +^# *24 +^# *24 $1 +^# *30 +^# *57 o6" +^# *B7 $0 +^# +7 +^# D6 +^# R3 ^& +^# T2 +^# ^) o2f +^# ^+ +^# ^@ +^# ^@ ^! +^# i1k +^# i2# $j +^# l +^# r +^# scm +^# sgw +^# O52 +^# O75 +^# z1 +^# } ^$ -^$$$ -^$$1 -^$$9 -^$$? -^$*02 -^$+1i3l -^$-5$y -^$^#^@^! -^$^$ -^$^w-5 -^$d -^$i3l -^$o1p -^$o2D -^$qo4i -^$ss$ -^$tZ1 -^$tz3 -^$z4 -^$z5 +^$ $$ +^$ $1 +^$ $9 +^$ $? +^$ *02 +^$ +1 i3l +^$ -5 $y +^$ ^# ^@ ^! +^$ ^$ +^$ ^w -5 +^$ d +^$ i3l +^$ o1p +^$ o2D +^$ q o4i +^$ ss$ +^$ t Z1 +^$ t z3 +^$ z4 +^$ z5 ^% -^%$/ -^%$g$g -^%*01K -^%*12 -^%+6O52 -^%-1 -^%R4 -^%] -^%^$ -^%^$^#^@^! -^%^O -^%i4M -^%sj8 -^%ti6g -^%z1 -^%z2 -^%z5 +^% $/ +^% $g $g +^% *01 K +^% *12 +^% +6 O52 +^% -1 +^% R4 +^% ] +^% ^$ +^% ^$ ^# ^@ ^! +^% ^O +^% i4M +^% sj8 +^% t i6g +^% z1 +^% z2 +^% z5 ^& -^&$2 -^&$; -^&'6 -^&^#*72 -^&c -^&d -^&i12*58 -^&i68^4 -^&i8j -^&o9| -^&u -^&z2 -^&} +^& $2 +^& $; +^& '6 +^& ^# *72 +^& c +^& d +^& i12 *58 +^& i68 ^4 +^& i8j +^& o9| +^& u +^& z2 +^& } ^' -^'@5 -^'R6 -^'Z4 -^'] -^'^<-7 -^'i1H -^'p2 -^'O51 -^'z1o6k -^'z3 +^' @5 +^' R6 +^' Z4 +^' ] +^' ^< -7 +^' i1H +^' p2 +^' O51 +^' z1 o6k +^' z3 ^( -^($#O0B -^($) -^(*25 -^(-0*48 -^(D1 -^(i3) -^(o7) -^(q -^(q[ -^(r -^(O06z1 -^(} +^( $# O0B +^( $) +^( *25 +^( -0 *48 +^( D1 +^( i3) +^( o7) +^( q +^( q [ +^( r +^( O06 z1 +^( } ^) -^)$m -^)*25 -^)L6 -^)T4 -^)Z2 -^)i6ho5_ -^)O23 -^)z1 +^) $m +^) *25 +^) L6 +^) T4 +^) Z2 +^) i6h o5_ +^) O23 +^) z1 ^* -^*$* -^*$- -^**31 -^**61$v -^*+1 -^*C -^*D1l -^*K -^*R1 -^*] -^*^* -^*^^ -^*d -^*o4z -^*r -^*ss# -^*O17 -^*O51 -^*z5 +^* $* +^* $- +^* *31 +^* *61 $v +^* +1 +^* C +^* D1 l +^* K +^* R1 +^* ] +^* ^* +^* ^^ +^* d +^* o4z +^* r +^* ss# +^* O17 +^* O51 +^* z5 ^+ -^+$+ -^+$N -^+$q -^+'3 -^+*13 -^+-4 -^+Z1 -^+Z4D9 -^+^1 -^+^a -^+^f -^+^j -^+d -^+i0m -^+i1/ -^+lq -^+sdmo5( -^+u -^+O13 -^+O23 -^+z1 -^+z2 -^+z5 +^+ $+ +^+ $N +^+ $q +^+ '3 +^+ *13 +^+ -4 +^+ Z1 +^+ Z4 D9 +^+ ^1 +^+ ^a +^+ ^f +^+ ^j +^+ d +^+ i0m +^+ i1/ +^+ l q +^+ sdm o5( +^+ u +^+ O13 +^+ O23 +^+ z1 +^+ z2 +^+ z5 ^, -^,$, -^,$z'8 -^,*28} -^,^- -^,^0o5a -^,c -^,r -^,z3 +^, $, +^, $z '8 +^, *28 } +^, ^- +^, ^0 o5a +^, c +^, r +^, z3 ^- -^-$, -^-$@ -^-*63^e -^-+5$5 -^--5 -^-C -^-D3 -^-^+ -^-^4 -^-^6 -^-^A -^-^T -^-^_ -^-^b -^-^g -^-^j -^-^p -^-d -^-i1Z -^-l -^-o0wi58 -^-o7v$w -^-s-m -^-z3 -^-z4 -^-} +^- $, +^- $@ +^- *63 ^e +^- +5 $5 +^- -5 +^- C +^- D3 +^- ^+ +^- ^4 +^- ^6 +^- ^A +^- ^T +^- ^_ +^- ^b +^- ^g +^- ^j +^- ^p +^- d +^- i1Z +^- l +^- o0w i58 +^- o7v $w +^- s-m +^- z3 +^- z4 +^- } ^. -^.$? -^.*03$p -^.-1 -^.^, -^.^1 -^.^a -^.^f -^.^t -^.d -^.i0m -^.l -^.O16z2 -^.O26 -^.z1 -^.z2 -^.z4 +^. $? +^. *03 $p +^. -1 +^. ^, +^. ^1 +^. ^a +^. ^f +^. ^t +^. d +^. i0m +^. l +^. O16 z2 +^. O26 +^. z1 +^. z2 +^. z4 ^/ -^/$/ -^/+2Z1 -^/^7 -^/c -^/d} -^/i1s^P -^/i2c -^/o1$ -^/r -^/z1 -^/z2 -^/z4 -^/z4c +^/ $/ +^/ +2 Z1 +^/ ^7 +^/ c +^/ d } +^/ i1s ^P +^/ i2c +^/ o1$ +^/ r +^/ z1 +^/ z2 +^/ z4 +^/ z4 c ^0 -^0$0 -^0$: -^0$c -^0*05 -^0*20 -^0*32*31 -^0*34 -^0*70 -^0+4 -^0-4 -^0-5 -^0@l -^0L4 -^0R5 -^0T1 -^0T4O24 -^0Z1sh> -^0Z1} -^0^0 -^0^0^0^2 -^0^1 -^0^1^0^2 -^0^2 -^0^3 -^0^4 -^0^5 -^0^6 -^0^6^9^1 -^0^7 -^0^7^9^1 -^0^8 -^0^8^9^1 -^0^9 -^0^9^9^1 -^0^J -^0^L -^0^a -^0^b -^0^c -^0^d -^0^e -^0^f -^0^k -^0^s -^0c -^0d -^0lZ2 -^0o6- -^0r -^0u'9 -^0O12 -^0O63 -^0z2 -^0z3 -^0z5 -^0} -^0}z2 +^0 $0 +^0 $: +^0 $c +^0 *05 +^0 *20 +^0 *32 *31 +^0 *34 +^0 *70 +^0 +4 +^0 -4 +^0 -5 +^0 @l +^0 L4 +^0 R5 +^0 T1 +^0 T4 O24 +^0 Z1 sh> +^0 Z1 } +^0 ^0 +^0 ^0 ^0 ^2 +^0 ^1 +^0 ^1 ^0 ^2 +^0 ^2 +^0 ^3 +^0 ^4 +^0 ^5 +^0 ^6 +^0 ^6 ^9 ^1 +^0 ^7 +^0 ^7 ^9 ^1 +^0 ^8 +^0 ^8 ^9 ^1 +^0 ^9 +^0 ^9 ^9 ^1 +^0 ^J +^0 ^L +^0 ^a +^0 ^b +^0 ^c +^0 ^d +^0 ^e +^0 ^f +^0 ^k +^0 ^s +^0 c +^0 d +^0 l Z2 +^0 o6- +^0 r +^0 u '9 +^0 O12 +^0 O63 +^0 z2 +^0 z3 +^0 z5 +^0 } +^0 } z2 ^1 -^1$" -^1$* -^1$+ -^1$0 -^1$1 -^1$2 -^1$2$3 -^1$@ -^1'8 -^1'9 -^1*01$0 -^1*06 -^1*15 -^1*28 -^1*32 -^1*36 -^1*50 -^1*64 -^1+8^J -^1-1 -^1-1O65 -^1-3u -^1-9 -^1D4 -^1R8 -^1T5 -^1T7 -^1Z1 -^1Z3 -^1Z4 -^1^! -^1^0 -^1^0^0^2 -^1^1 -^1^2 -^1^3 -^1^4 -^1^5 -^1^6 -^1^6^9^1 -^1^7 -^1^7^9^1 -^1^7i4v -^1^8 -^1^8^9^1 -^1^9 -^1^9^9^1 -^1^a -^1^b -^1^c -^1^d -^1^e -^1^e^h^t -^1^f -^1c -^1d -^1i0r -^1o1f -^1o1i -^1o20 -^1o3w -^1o4C -^1o4n -^1o5l -^1o63 -^1oA%O76 -^1r*02 -^1s8x -^1O52 -^1O56 -^1O73 -^1z2 -^1z2O68 -^1z3 -^1z3-0 -^1z3} -^1z4 -^1z5 -^1{+5 +^1 $" +^1 $* +^1 $+ +^1 $0 +^1 $1 +^1 $2 +^1 $2 $3 +^1 $@ +^1 '8 +^1 '9 +^1 *01 $0 +^1 *06 +^1 *15 +^1 *28 +^1 *32 +^1 *36 +^1 *50 +^1 *64 +^1 +8 ^J +^1 -1 +^1 -1 O65 +^1 -3 u +^1 -9 +^1 D4 +^1 R8 +^1 T5 +^1 T7 +^1 Z1 +^1 Z3 +^1 Z4 +^1 ^! +^1 ^0 +^1 ^0 ^0 ^2 +^1 ^1 +^1 ^2 +^1 ^3 +^1 ^4 +^1 ^5 +^1 ^6 +^1 ^6 ^9 ^1 +^1 ^7 +^1 ^7 ^9 ^1 +^1 ^7 i4v +^1 ^8 +^1 ^8 ^9 ^1 +^1 ^9 +^1 ^9 ^9 ^1 +^1 ^a +^1 ^b +^1 ^c +^1 ^d +^1 ^e +^1 ^e ^h ^t +^1 ^f +^1 c +^1 d +^1 i0r +^1 o1f +^1 o1i +^1 o20 +^1 o3w +^1 o4C +^1 o4n +^1 o5l +^1 o63 +^1 oA% O76 +^1 r *02 +^1 s8x +^1 O52 +^1 O56 +^1 O73 +^1 z2 +^1 z2 O68 +^1 z3 +^1 z3 -0 +^1 z3 } +^1 z4 +^1 z5 +^1 { +5 ^2 -^2$$ -^2$* -^2$2 -^2$Io4q -^2*02z2 -^2*0A -^2*31 -^2*35 -^2*47 -^2*71 -^2+8D2 -^2C -^2D4 -^2D5 -^2Z2 -^2^0 -^2^0^0^2 -^2^1 -^2^1$3 -^2^1$3$4 -^2^1$3$4$5 -^2^2 -^2^3 -^2^4 -^2^5 -^2^6 -^2^6^9^1 -^2^7 -^2^7^9^1 -^2^8 -^2^8^9^1 -^2^9 -^2^9^9^1 -^2^A -^2^L -^2^a -^2^b -^2^c -^2^d -^2^e -^2^f -^2c -^2cD7 -^2d -^2i2K -^2i42 -^2i5d -^2i6a -^2i74t -^2o1M -^2o1Z -^2o42 -^2o4l -^2o7d@7 -^2o8} -^2O26f -^2O53 -^2O59l -^2O85 -^2z2 -^2z5 +^2 $$ +^2 $* +^2 $2 +^2 $I o4q +^2 *02 z2 +^2 *0A +^2 *31 +^2 *35 +^2 *47 +^2 *71 +^2 +8 D2 +^2 C +^2 D4 +^2 D5 +^2 Z2 +^2 ^0 +^2 ^0 ^0 ^2 +^2 ^1 +^2 ^1 $3 +^2 ^1 $3 $4 +^2 ^1 $3 $4 $5 +^2 ^2 +^2 ^3 +^2 ^4 +^2 ^5 +^2 ^6 +^2 ^6 ^9 ^1 +^2 ^7 +^2 ^7 ^9 ^1 +^2 ^8 +^2 ^8 ^9 ^1 +^2 ^9 +^2 ^9 ^9 ^1 +^2 ^A +^2 ^L +^2 ^a +^2 ^b +^2 ^c +^2 ^d +^2 ^e +^2 ^f +^2 c +^2 c D7 +^2 d +^2 i2K +^2 i42 +^2 i5d +^2 i6a +^2 i74 t +^2 o1M +^2 o1Z +^2 o42 +^2 o4l +^2 o7d @7 +^2 o8} +^2 O26 f +^2 O53 +^2 O59 l +^2 O85 +^2 z2 +^2 z5 ^3 -^3$3 -^3$N -^3$j -^3*02 -^3*54 -^3*94'7 -^3-5 -^3-6 -^3@m -^3D5^, -^3R1 -^3Z1 -^3^0 -^3^0^0^2 -^3^1 -^3^2 -^3^2^1 -^3^2^1$3$2$1 -^3^2^1$4$5 -^3^2^1$4$5$6 -^3^3 -^3^4 -^3^5 -^3^6 -^3^6^9^1 -^3^7 -^3^7^9^1 -^3^8 -^3^8^9^1 -^3^9 -^3^9^9^1 -^3^< -^3^R -^3^]^e -^3^a -^3^b -^3^c -^3^d -^3^e -^3^f -^3^wsna -^3c -^3d -^3f^< -^3i0(} -^3i5t -^3i68 -^3o1G^i -^3o1e -^3o2x -^3r*06 -^3st^ -^3tO74 -^3O12 -^3O14 -^3O23 -^3O36 -^3O37o16 -^3O57 -^3OA5 -^3z2 -^3z4 -^3z5 -^3z5Z1 -^3{T3 -^3}$6 +^3 $3 +^3 $N +^3 $j +^3 *02 +^3 *54 +^3 *94 '7 +^3 -5 +^3 -6 +^3 @m +^3 D5 ^, +^3 R1 +^3 Z1 +^3 ^0 +^3 ^0 ^0 ^2 +^3 ^1 +^3 ^2 +^3 ^2 ^1 +^3 ^2 ^1 $3 $2 $1 +^3 ^2 ^1 $4 $5 +^3 ^2 ^1 $4 $5 $6 +^3 ^3 +^3 ^4 +^3 ^5 +^3 ^6 +^3 ^6 ^9 ^1 +^3 ^7 +^3 ^7 ^9 ^1 +^3 ^8 +^3 ^8 ^9 ^1 +^3 ^9 +^3 ^9 ^9 ^1 +^3 ^< +^3 ^R +^3 ^] ^e +^3 ^a +^3 ^b +^3 ^c +^3 ^d +^3 ^e +^3 ^f +^3 ^w sna +^3 c +^3 d +^3 f ^< +^3 i0( } +^3 i5t +^3 i68 +^3 o1G ^i +^3 o1e +^3 o2x +^3 r *06 +^3 st^ +^3 t O74 +^3 O12 +^3 O14 +^3 O23 +^3 O36 +^3 O37 o16 +^3 O57 +^3 OA5 +^3 z2 +^3 z4 +^3 z5 +^3 z5 Z1 +^3 { T3 +^3 } $6 ^4 -^4$! -^4$4 -^4$b -^4$s -^4*14 -^4+8c -^4-8 -^4C -^4K^k -^4T1 -^4^/ -^4^0 -^4^0^0^2 -^4^1 -^4^2 -^4^3 -^4^3^2^1 -^4^4 -^4^5 -^4^6 -^4^6^9^1 -^4^7 -^4^7^9^1 -^4^8 -^4^8^9^1 -^4^9 -^4^9^9^1 -^4^I -^4^a -^4^b -^4^c -^4^d -^4^e -^4^f -^4d -^4i1e -^4i6/ -^4i8;o2& -^4o3x -^4o5? -^4o62 -^4rc -^4sb1 -^4sd -^4t^i -^4uD6 -^4O23 -^4O2A -^4O31 -^4O35 -^4O52u -^4O62 -^4O78 -^4z2 -^4z3 -^4} +^4 $! +^4 $4 +^4 $b +^4 $s +^4 *14 +^4 +8 c +^4 -8 +^4 C +^4 K ^k +^4 T1 +^4 ^/ +^4 ^0 +^4 ^0 ^0 ^2 +^4 ^1 +^4 ^2 +^4 ^3 +^4 ^3 ^2 ^1 +^4 ^4 +^4 ^5 +^4 ^6 +^4 ^6 ^9 ^1 +^4 ^7 +^4 ^7 ^9 ^1 +^4 ^8 +^4 ^8 ^9 ^1 +^4 ^9 +^4 ^9 ^9 ^1 +^4 ^I +^4 ^a +^4 ^b +^4 ^c +^4 ^d +^4 ^e +^4 ^f +^4 d +^4 i1e +^4 i6/ +^4 i8; o2& +^4 o3x +^4 o5? +^4 o62 +^4 r c +^4 sb1 +^4 sd +^4 t ^i +^4 u D6 +^4 O23 +^4 O2A +^4 O31 +^4 O35 +^4 O52 u +^4 O62 +^4 O78 +^4 z2 +^4 z3 +^4 } ^5 -^5$1 -^5$4 -^5$5 -^5*31 -^5*40 -^5*41 -^5+1 -^5@3L3 -^5D7 -^5L0$q -^5R2 -^5R3 -^5R6 -^5Z1 -^5^0 -^5^0^0^2 -^5^1 -^5^2 -^5^3 -^5^4 -^5^4^3^2^1 -^5^5 -^5^6 -^5^6^9^1 -^5^7 -^5^7^9^1 -^5^8 -^5^8^9^1 -^5^9 -^5^9^9^1 -^5^9O47 -^5^U -^5^a -^5^b -^5^c -^5^d -^5^e -^5^f -^5d -^5f'9 -^5i0$ -^5i51o3d -^5l -^5o2BZ2 -^5o5F -^5r -^5s!f -^5s4r -^5t -^5O27o3K -^5z1*26 -^5z2 -^5z3 -^5z4^> +^5 $1 +^5 $4 +^5 $5 +^5 *31 +^5 *40 +^5 *41 +^5 +1 +^5 @3 L3 +^5 D7 +^5 L0 $q +^5 R2 +^5 R3 +^5 R6 +^5 Z1 +^5 ^0 +^5 ^0 ^0 ^2 +^5 ^1 +^5 ^2 +^5 ^3 +^5 ^4 +^5 ^4 ^3 ^2 ^1 +^5 ^5 +^5 ^6 +^5 ^6 ^9 ^1 +^5 ^7 +^5 ^7 ^9 ^1 +^5 ^8 +^5 ^8 ^9 ^1 +^5 ^9 +^5 ^9 ^9 ^1 +^5 ^9 O47 +^5 ^U +^5 ^a +^5 ^b +^5 ^c +^5 ^d +^5 ^e +^5 ^f +^5 d +^5 f '9 +^5 i0$ +^5 i51 o3d +^5 l +^5 o2B Z2 +^5 o5F +^5 r +^5 s!f +^5 s4r +^5 t +^5 O27 o3K +^5 z1 *26 +^5 z2 +^5 z3 +^5 z4 ^> ^6 -^6$2 -^6$6 -^6$k -^6$yi1Y -^6'8 -^6*07 -^6*12 -^6*41c -^6*52 -^6-1 -^6D2 -^6K -^6L1 -^6L3*38 -^6T1 -^6T2 -^6Z1 -^6Z2} -^6Z3 -^6^0 -^6^0^0^2 -^6^1 -^6^2 -^6^3 -^6^4 -^6^5 -^6^5^4^3^2^1 -^6^6 -^6^6^9^1 -^6^7 -^6^7^9^1 -^6^8 -^6^8^9^1 -^6^9 -^6^9^9^1 -^6^a -^6^b -^6^c -^6^d -^6^e -^6^f -^6^o -^6d -^6i1b -^6i3 -^6i42 -^6l -^6o07@5 -^6o3a -^6t -^6t^7 -^6O12 -^6O15 -^6O42^g -^6O56 -^6z2 -^6z5 -^6} +^6 $2 +^6 $6 +^6 $k +^6 $y i1Y +^6 '8 +^6 *07 +^6 *12 +^6 *41 c +^6 *52 +^6 -1 +^6 D2 +^6 K +^6 L1 +^6 L3 *38 +^6 T1 +^6 T2 +^6 Z1 +^6 Z2 } +^6 Z3 +^6 ^0 +^6 ^0 ^0 ^2 +^6 ^1 +^6 ^2 +^6 ^3 +^6 ^4 +^6 ^5 +^6 ^5 ^4 ^3 ^2 ^1 +^6 ^6 +^6 ^6 ^9 ^1 +^6 ^7 +^6 ^7 ^9 ^1 +^6 ^8 +^6 ^8 ^9 ^1 +^6 ^9 +^6 ^9 ^9 ^1 +^6 ^a +^6 ^b +^6 ^c +^6 ^d +^6 ^e +^6 ^f +^6 ^o +^6 d +^6 i1b +^6 i3 +^6 i42 +^6 l +^6 o07 @5 +^6 o3a +^6 t +^6 t ^7 +^6 O12 +^6 O15 +^6 O42 ^g +^6 O56 +^6 z2 +^6 z5 +^6 } ^7 -^7$+ -^7$7 -^7$fO53 -^7$h -^7'9 -^7*09 -^7*27 -^7*35 -^7*43 -^7+6 -^7-2 -^7-2$7 -^7-3 -^7@0 -^7L3Z1 -^7R3s80 -^7Z3 -^7Z3t -^7^0 -^7^0^0^2 -^7^1 -^7^2 -^7^3 -^7^4 -^7^5 -^7^6 -^7^6^9^1 -^7^7 -^7^7^9^1 -^7^8 -^7^8^9^1 -^7^9 -^7^9^9^1 -^7^a -^7^b -^7^c -^7^d -^7^e -^7^f -^7c -^7d -^7o2n -^7o3# -^7q -^7r -^7s2sl -^7s7] -^7sc% -^7tz3 -^7O27 -^7O32 -^7O62 -^7z1o6, -^7z1t -^7z2 -^7z4 -^7z5 -^7} +^7 $+ +^7 $7 +^7 $f O53 +^7 $h +^7 '9 +^7 *09 +^7 *27 +^7 *35 +^7 *43 +^7 +6 +^7 -2 +^7 -2 $7 +^7 -3 +^7 @0 +^7 L3 Z1 +^7 R3 s80 +^7 Z3 +^7 Z3 t +^7 ^0 +^7 ^0 ^0 ^2 +^7 ^1 +^7 ^2 +^7 ^3 +^7 ^4 +^7 ^5 +^7 ^6 +^7 ^6 ^9 ^1 +^7 ^7 +^7 ^7 ^9 ^1 +^7 ^8 +^7 ^8 ^9 ^1 +^7 ^9 +^7 ^9 ^9 ^1 +^7 ^a +^7 ^b +^7 ^c +^7 ^d +^7 ^e +^7 ^f +^7 c +^7 d +^7 o2n +^7 o3# +^7 q +^7 r +^7 s2s l +^7 s7] +^7 sc% +^7 t z3 +^7 O27 +^7 O32 +^7 O62 +^7 z1 o6, +^7 z1 t +^7 z2 +^7 z4 +^7 z5 +^7 } ^8 -^8$(*86 -^8$6 -^8$8 -^8$9 -^8$CT6 -^8$I -^8$j -^8$w -^8'7 -^8*41 -^8+1 -^8+7 -^8+8o68 -^8-9 -^8D1c -^8R1 -^8T1 -^8^0 -^8^0^0^2 -^8^1 -^8^2 -^8^3 -^8^4 -^8^5 -^8^6 -^8^6^9^1 -^8^7 -^8^7^9^1 -^8^8 -^8^8^9^1 -^8^9 -^8^9^9^1 -^8^a -^8^b -^8^c -^8^d -^8^e -^8^f -^8^i -^8d -^8i3F -^8i4d -^8k^8 -^8l -^8r -^8sod -^8t -^8O36 -^8O4AZ1 -^8O53 -^8O62 -^8O93 -^8z1@3 -^8z2 -^8z3o7x -^8z4 -^8z5 -^8} +^8 $( *86 +^8 $6 +^8 $8 +^8 $9 +^8 $C T6 +^8 $I +^8 $j +^8 $w +^8 '7 +^8 *41 +^8 +1 +^8 +7 +^8 +8 o68 +^8 -9 +^8 D1 c +^8 R1 +^8 T1 +^8 ^0 +^8 ^0 ^0 ^2 +^8 ^1 +^8 ^2 +^8 ^3 +^8 ^4 +^8 ^5 +^8 ^6 +^8 ^6 ^9 ^1 +^8 ^7 +^8 ^7 ^9 ^1 +^8 ^8 +^8 ^8 ^9 ^1 +^8 ^9 +^8 ^9 ^9 ^1 +^8 ^a +^8 ^b +^8 ^c +^8 ^d +^8 ^e +^8 ^f +^8 ^i +^8 d +^8 i3F +^8 i4d +^8 k ^8 +^8 l +^8 r +^8 sod +^8 t +^8 O36 +^8 O4A Z1 +^8 O53 +^8 O62 +^8 O93 +^8 z1 @3 +^8 z2 +^8 z3 o7x +^8 z4 +^8 z5 +^8 } ^9 -^9$+ -^9$0 -^9$9 -^9$G -^9$x -^9*24 -^9*53 -^9+7 -^9-2 -^9L1 -^9R5R6 -^9R6i0^ -^9T5 -^9Z1 -^9^# -^9^0 -^9^0^0^2 -^9^1 -^9^2 -^9^3 -^9^4 -^9^5 -^9^6 -^9^6^9^1 -^9^7 -^9^7^9^1 -^9^8 -^9^8^9^1 -^9^9 -^9^9^9^1 -^9^a -^9^b -^9^c -^9^d -^9^e -^9^f -^9c -^9d -^9dz2 -^9i1- -^9i1b -^9i7HO35 -^9o3a -^9o5n -^9o6s -^9o70 -^9o87 -^9q+6 -^9t -^9O31 -^9z2 -^9z2D5 -^9z4 +^9 $+ +^9 $0 +^9 $9 +^9 $G +^9 $x +^9 *24 +^9 *53 +^9 +7 +^9 -2 +^9 L1 +^9 R5 R6 +^9 R6 i0^ +^9 T5 +^9 Z1 +^9 ^# +^9 ^0 +^9 ^0 ^0 ^2 +^9 ^1 +^9 ^2 +^9 ^3 +^9 ^4 +^9 ^5 +^9 ^6 +^9 ^6 ^9 ^1 +^9 ^7 +^9 ^7 ^9 ^1 +^9 ^8 +^9 ^8 ^9 ^1 +^9 ^9 +^9 ^9 ^9 ^1 +^9 ^a +^9 ^b +^9 ^c +^9 ^d +^9 ^e +^9 ^f +^9 c +^9 d +^9 d z2 +^9 i1- +^9 i1b +^9 i7H O35 +^9 o3a +^9 o5n +^9 o6s +^9 o70 +^9 o87 +^9 q +6 +^9 t +^9 O31 +^9 z2 +^9 z2 D5 +^9 z4 ^: -^:$! -^:$h -^:-4t -^:C -^:Ki7T -^:^K -^:^T*27 -^:lr -^:o48 -^:rL2 -^:t -^:z1 -^:z4i4O +^: $! +^: $h +^: -4 t +^: C +^: K i7T +^: ^K +^: ^T *27 +^: l r +^: o48 +^: r L2 +^: t +^: z1 +^: z4 i4O ^; -^;$2Z1 -^;$; -^;*63 -^;+6Z2 -^;D6 -^;R9 -^;^R^0 -^;^s -^;^| -^;c -^;i1> -^;p2O67 -^;soM -^;u -^;OB8O07 -^;z5 +^; $2 Z1 +^; $; +^; *63 +^; +6 Z2 +^; D6 +^; R9 +^; ^R ^0 +^; ^s +^; ^| +^; c +^; i1> +^; p2 O67 +^; soM +^; u +^; OB8 O07 +^; z5 ^< -^<$2 -^<$> -^<*74T3 -^<+5+6 -^ +^< *74 T3 +^< +5 +6 +^< C +5 +^< Z1 +^< i2l z2 +^< t ^D +^< u +^< O16 +^< z1 ^= -^=$0 -^=$= -^=$p -^=*24 -^=T6 -^=Z1 -^=^e -^=i40 -^=l -^=o2 -^=O19c -^=z1 -^=z2 +^= $0 +^= $= +^= $p +^= *24 +^= T6 +^= Z1 +^= ^e +^= i40 +^= l +^= o2 +^= O19 c +^= z1 +^= z2 ^> -^>$* -^>$1o7X -^>$A -^>*03-3 -^>*15 -^>D3$j -^>D4*13 -^>Z3+2 -^>Z5O64 -^>^L -^>i6u -^>o71 -^>O82 +^> $* +^> $1 o7X +^> $A +^> *03 -3 +^> *15 +^> D3 $j +^> D4 *13 +^> Z3 +2 +^> Z5 O64 +^> ^L +^> i6u +^> o71 +^> O82 ^? -^?$t*53 -^?*52 -^?^k -^?i0? -^?i6kO26 -^?l -^?o64 -^?O21 -^?z1-6 -^?z2 -^?z3 +^? $t *53 +^? *52 +^? ^k +^? i0? +^? i6k O26 +^? l +^? o64 +^? O21 +^? z1 -6 +^? z2 +^? z3 ^@ -^@$4 -^@$@ -^@$E$s -^@$e -^@$y -^@'4 -^@'7 -^@+1 -^@-1 -^@Z3O46 -^@^! -^@^!$!$@ -^@^p -^@cZ1 -^@u -^@O15 -^@O71 -^@z1 -^@z1O15 -^@z2 +^@ $4 +^@ $@ +^@ $E $s +^@ $e +^@ $y +^@ '4 +^@ '7 +^@ +1 +^@ -1 +^@ Z3 O46 +^@ ^! +^@ ^! $! $@ +^@ ^p +^@ c Z1 +^@ u +^@ O15 +^@ O71 +^@ z1 +^@ z1 O15 +^@ z2 ^A -^A$6 -^A'5 -^A*56 -^A+1 -^A+6 -^AD3 -^AD4 -^AK$M -^AT5 -^AZ1 -^A^? -^A^L -^A^[ -^A^`^v -^A^{o6/ -^Af -^Ai0W -^Al -^Ao01$5 -^Ao1h -^Ao8^ -^AoAa -^At -^AO21 -^AO32 -^AO38 -^AO63 -^Az1 -^Az2 -^A}^+ +^A $6 +^A '5 +^A *56 +^A +1 +^A +6 +^A D3 +^A D4 +^A K $M +^A T5 +^A Z1 +^A ^? +^A ^L +^A ^[ +^A ^` ^v +^A ^{ o6/ +^A f +^A i0W +^A l +^A o01 $5 +^A o1h +^A o8^ +^A oAa +^A t +^A O21 +^A O32 +^A O38 +^A O63 +^A z1 +^A z2 +^A } ^+ ^B -^B$. -^B$` -^B$j -^B+5 -^B^:z1 -^B^D -^B^V -^B^[T5 -^B^n+1 -^Bd -^Bi0o -^Bo3r -^Bs52 -^Bu -^BO04z3 -^BO32 -^BO35 -^BO3B -^BO42l -^BO67O04 -^Bz1 -^Bz2 +^B $. +^B $` +^B $j +^B +5 +^B ^: z1 +^B ^D +^B ^V +^B ^[ T5 +^B ^n +1 +^B d +^B i0o +^B o3r +^B s52 +^B u +^B O04 z3 +^B O32 +^B O35 +^B O3B +^B O42 l +^B O67 O04 +^B z1 +^B z2 ^C -^C'5 -^C*17-2 -^C*A6 -^C+1 -^C+2 -^CC -^CC*53 -^CZ2 -^C] -^C^! -^Ci58 -^Ci63 -^Ci6r -^Co1a -^Co2u -^Co7\ -^Cp1 -^CscK -^Ct -^Cu -^CO32 +^C '5 +^C *17 -2 +^C *A6 +^C +1 +^C +2 +^C C +^C C *53 +^C Z2 +^C ] +^C ^! +^C i58 +^C i63 +^C i6r +^C o1a +^C o2u +^C o7\ +^C p1 +^C scK +^C t +^C u +^C O32 ^D -^D$7 -^D$m -^D'5 -^D'6 -^D*37L6 -^D*86 -^D-5 -^D@m -^DR3+4 -^DZ1D4 -^D^Fo1y -^Dd -^Di0O -^Di1j -^Do3n -^DO43 -^DO45 -^Dz1 -^Dz2 -^D}R3 +^D $7 +^D $m +^D '5 +^D '6 +^D *37 L6 +^D *86 +^D -5 +^D @m +^D R3 +4 +^D Z1 D4 +^D ^F o1y +^D d +^D i0O +^D i1j +^D o3n +^D O43 +^D O45 +^D z1 +^D z2 +^D } R3 ^E -^E*23 -^E*27 -^E*43 -^E-1 -^E-5 -^ED3 -^EZ1sl# -^E^1 -^E^D -^Ei0_i6o -^Ei1l -^Ei5pO72 -^Ei6k -^Ek -^Eo1fO45 -^Eo38 -^Eo4e -^ErO06 -^Eu -^EO06o01 -^EO51 -^Ez2 -^E} +^E *23 +^E *27 +^E *43 +^E -1 +^E -5 +^E D3 +^E Z1 sl# +^E ^1 +^E ^D +^E i0_ i6o +^E i1l +^E i5p O72 +^E i6k +^E k +^E o1f O45 +^E o38 +^E o4e +^E r O06 +^E u +^E O06 o01 +^E O51 +^E z2 +^E } ^F -^F'4z3 -^F*13 -^F*46 -^F-5l -^FD3 -^FT1$x -^FcO26 -^Fi0B -^Fl -^Fo1l -^Fu -^FO25 -^FO28 -^Fz2 -^F} +^F '4 z3 +^F *13 +^F *46 +^F -5 l +^F D3 +^F T1 $x +^F c O26 +^F i0B +^F l +^F o1l +^F u +^F O25 +^F O28 +^F z2 +^F } ^G -^G$R -^G+7i7' -^G-4 -^G-7 -^GD3 -^GZ2 -^G^M -^Gi5? -^Gl -^Go5i -^Gp1O58 -^Gu -^GO57 -^GO71 -^Gz1 -^Gz1+1 -^Gz2 +^G $R +^G +7 i7' +^G -4 +^G -7 +^G D3 +^G Z2 +^G ^M +^G i5? +^G l +^G o5i +^G p1 O58 +^G u +^G O57 +^G O71 +^G z1 +^G z1 +1 +^G z2 ^H -^H$! -^H'7 -^H*54 -^H*63 -^H*79L1 -^HT4O56 -^H^C -^H^Dser -^H^R -^Hi5` -^Ho3z -^Ho6O -^Hq*63 -^Hu -^HO14 -^HO29 -^HO35c -^HO72l -^Hz1 -^H} +^H $! +^H '7 +^H *54 +^H *63 +^H *79 L1 +^H T4 O56 +^H ^C +^H ^D ser +^H ^R +^H i5` +^H o3z +^H o6O +^H q *63 +^H u +^H O14 +^H O29 +^H O35 c +^H O72 l +^H z1 +^H } ^I -^I'6 -^I*56 -^I-4 -^ID4 -^IZ3o5b -^I^+ -^Ii0S -^Ii5_ -^Il -^Io4m -^Io7gz1 -^Ip1O32 -^It -^Iu -^IO18 -^IO1B -^IO27 -^Iz2 +^I '6 +^I *56 +^I -4 +^I D4 +^I Z3 o5b +^I ^+ +^I i0S +^I i5_ +^I l +^I o4m +^I o7g z1 +^I p1 O32 +^I t +^I u +^I O18 +^I O1B +^I O27 +^I z2 ^J -^J$'+3 -^J$0 -^J$w -^J'6 -^J+6 -^J-1 -^JZ1 -^JZ5 -^J^J -^Ji2) -^Jl -^Jo7N -^JuD3 -^Jz2 +^J $' +3 +^J $0 +^J $w +^J '6 +^J +6 +^J -1 +^J Z1 +^J Z5 +^J ^J +^J i2) +^J l +^J o7N +^J u D3 +^J z2 ^K -^K$k -^K'A -^K-2 -^KD4 -^KL4 -^KT2 -^KZ2 -^KZ2$m -^K^$ -^K^J -^K^T -^Ki03C -^Ki1e -^Ki71 -^Kl -^Kl$Y -^KO13 -^KO24 -^KO34 -^KO42 -^Kz1 -^K}C +^K $k +^K 'A +^K -2 +^K D4 +^K L4 +^K T2 +^K Z2 +^K Z2 $m +^K ^$ +^K ^J +^K ^T +^K i03 C +^K i1e +^K i71 +^K l +^K l $Y +^K O13 +^K O24 +^K O34 +^K O42 +^K z1 +^K } C ^L -^L$4 -^L$8 -^L$T -^L$i -^L*60 -^L+3 -^L-1 -^L@f -^LR7i3( -^L^B -^Lu -^LO19 -^Lz1 -^L} +^L $4 +^L $8 +^L $T +^L $i +^L *60 +^L +3 +^L -1 +^L @f +^L R7 i3( +^L ^B +^L u +^L O19 +^L z1 +^L } ^M -^M$! -^M$D -^M*09 -^M*14$j -^M*46 -^M*71 -^M+1 -^M+4 -^M-1 -^M-5 -^MD4 -^MD6 -^MZ2 -^M^A -^M^G -^M^H -^M^W -^Md -^Mi6i -^Msg -^Mt -^MO13z2 -^MO18 -^MO36 -^MO42 -^MO43 -^MO69 -^Mz1 +^M $! +^M $D +^M *09 +^M *14 $j +^M *46 +^M *71 +^M +1 +^M +4 +^M -1 +^M -5 +^M D4 +^M D6 +^M Z2 +^M ^A +^M ^G +^M ^H +^M ^W +^M d +^M i6i +^M sg +^M t +^M O13 z2 +^M O18 +^M O36 +^M O42 +^M O43 +^M O69 +^M z1 ^N -^N$H -^N$L -^N$h -^N*06O52 -^N+4 -^N^Z -^Ni7[ -^Nl -^No1m -^Np2'5 -^Ns8P+5 -^NO02$x -^NO63 -^Nz1 -^N} +^N $H +^N $L +^N $h +^N *06 O52 +^N +4 +^N ^Z +^N i7[ +^N l +^N o1m +^N p2 '5 +^N s8P +5 +^N O02 $x +^N O63 +^N z1 +^N } ^O -^O$4 -^O$i -^O*17 -^O+5 -^O+6 -^OL3*04 -^OT2 -^O^M -^Oi0}z3 -^Oi5! -^Ol -^Op1 -^Ou -^OO52 -^OO84 -^Oz2 -^Oz4 +^O $4 +^O $i +^O *17 +^O +5 +^O +6 +^O L3 *04 +^O T2 +^O ^M +^O i0} z3 +^O i5! +^O l +^O p1 +^O u +^O O52 +^O O84 +^O z2 +^O z4 ^P -^P$3 -^P$9 -^P$f -^P*42 -^PD7-4 -^PR1 -^PZ2o5| -^P^4 -^P^= -^P^L -^P^M -^Pc -^Pls.y -^Po27sP. -^Po5d -^Po84 -^PO31 -^Pz1 +^P $3 +^P $9 +^P $f +^P *42 +^P D7 -4 +^P R1 +^P Z2 o5| +^P ^4 +^P ^= +^P ^L +^P ^M +^P c +^P l s.y +^P o27 sP. +^P o5d +^P o84 +^P O31 +^P z1 ^Q -^Q-2 -^Q^X -^Q^f{ -^Qi10 -^Qi5& -^Qi5I -^Qi6k -^Ql -^Qr -^Qt -^Qu*34 -^QO16d -^QO43 +^Q -2 +^Q ^X +^Q ^f { +^Q i10 +^Q i5& +^Q i5I +^Q i6k +^Q l +^Q r +^Q t +^Q u *34 +^Q O16 d +^Q O43 ^R -^R$' -^R$R -^R'2p2 -^R*18c -^R*67 -^R@3sRt -^R@z -^RD3 -^RD4 -^RD7 -^RT3 -^RZ1 -^R^D -^Rd -^Rl -^Rq -^RO25 -^RO37 -^Rz1 -^Rz2 +^R $' +^R $R +^R '2 p2 +^R *18 c +^R *67 +^R @3 sRt +^R @z +^R D3 +^R D4 +^R D7 +^R T3 +^R Z1 +^R ^D +^R d +^R l +^R q +^R O25 +^R O37 +^R z1 +^R z2 ^S -^S$S -^S*34O3A -^S*56L7 -^S+1 -^S+3 -^SC -^SD2 -^SR4 -^SZ1*26 -^SZ2 -^S] -^S^F -^S^J -^S^N -^Si4Sk -^SiA*O06 -^Sp1 -^SqTA -^Sr -^St -^St+8 -^Su -^SO12 -^SO14 -^SO64Z1 -^Sz1 -^Sz2 -^Sz3 +^S $S +^S *34 O3A +^S *56 L7 +^S +1 +^S +3 +^S C +^S D2 +^S R4 +^S Z1 *26 +^S Z2 +^S ] +^S ^F +^S ^J +^S ^N +^S i4S k +^S iA* O06 +^S p1 +^S q TA +^S r +^S t +^S t +8 +^S u +^S O12 +^S O14 +^S O64 Z1 +^S z1 +^S z2 +^S z3 ^T -^T$' -^T$) -^T$1 -^T$p -^T'8O41 -^TT1 -^TZ1 -^TZ4-6 -^TZ5 -^T^C -^T^J -^T^Q -^Ti0P -^To0sD5 -^To4n -^To7tiAC -^TO1B -^Tz1 +^T $' +^T $) +^T $1 +^T $p +^T '8 O41 +^T T1 +^T Z1 +^T Z4 -6 +^T Z5 +^T ^C +^T ^J +^T ^Q +^T i0P +^T o0s D5 +^T o4n +^T o7t iAC +^T O1B +^T z1 ^U -^U'3 -^U*35+5 -^Ui63 -^UlO41 -^UqO65 -^Ut -^Ut^v +^U '3 +^U *35 +5 +^U i63 +^U l O41 +^U q O65 +^U t +^U t ^v ^V -^V$R -^V$v -^V$z -^V'5 -^V'8 -^V*15o5T -^V*75^r -^V+3 -^VD4 -^VR1 -^V^= -^V^B -^Vi0i -^Vi1c -^VO06O45 -^VO12 -^VO15 -^VO31 -^VO74O05 -^Vz3 +^V $R +^V $v +^V $z +^V '5 +^V '8 +^V *15 o5T +^V *75 ^r +^V +3 +^V D4 +^V R1 +^V ^= +^V ^B +^V i0i +^V i1c +^V O06 O45 +^V O12 +^V O15 +^V O31 +^V O74 O05 +^V z3 ^W -^W$Lo01 -^W'4 -^W*14 -^W*40 -^W*52 -^W*64 -^W-3i77 -^WL3C -^WT1 -^WZ2 -^W^_ -^Wi5j -^Wi8BO05 -^Wo19K -^Wp1 -^WO15 -^Wz1 -^Wz2 -^Wz5 -^W} +^W $L o01 +^W '4 +^W *14 +^W *40 +^W *52 +^W *64 +^W -3 i77 +^W L3 C +^W T1 +^W Z2 +^W ^_ +^W i5j +^W i8B O05 +^W o19 K +^W p1 +^W O15 +^W z1 +^W z2 +^W z5 +^W } ^X -^X'7 -^X*28 -^X+5 -^X-4 -^XK$2 -^X] -^X^B*4A -^Xi4K -^Xi6r -^Xo1i -^Xo4j^i -^Xu -^XO13+4 -^XO31 -^Xz1 +^X '7 +^X *28 +^X +5 +^X -4 +^X K $2 +^X ] +^X ^B *4A +^X i4K +^X i6r +^X o1i +^X o4j ^i +^X u +^X O13 +4 +^X O31 +^X z1 ^Y -^Y$s+A -^Y*32 -^Y*64 -^YD2 -^YL0 -^Y^_+4 -^Y^yZ1 -^Yi5f -^Yo2b -^Yo5d -^YslK^y -^YO23 -^Yz2 -^Yz4 -^Yz5 +^Y $s +A +^Y *32 +^Y *64 +^Y D2 +^Y L0 +^Y ^_ +4 +^Y ^y Z1 +^Y i5f +^Y o2b +^Y o5d +^Y slK ^y +^Y O23 +^Y z2 +^Y z4 +^Y z5 ^Z -^Z$" -^Z$tz4 -^Z*68 -^Z+3 -^ZL0 -^ZZ4O75 -^Z^B -^Z^M -^Zi4R -^Zi4X -^Zl -^Zp1O14 -^Zsef -^ZO31 -^Zz2 -^Zz3-7 -^[$] -^[*30 -^[C -^[L2{ -^[i5X-1 -^[l -^[o1oo5# -^[o7VZ1 -^[s3[ -^[s[do6a -^[z1L4 +^Z $" +^Z $t z4 +^Z *68 +^Z +3 +^Z L0 +^Z Z4 O75 +^Z ^B +^Z ^M +^Z i4R +^Z i4X +^Z l +^Z p1 O14 +^Z sef +^Z O31 +^Z z2 +^Z z3 -7 +^[ $] +^[ *30 +^[ C +^[ L2 { +^[ i5X -1 +^[ l +^[ o1o o5# +^[ o7V Z1 +^[ s3[ +^[ s[d o6a +^[ z1 L4 ^\ -^\D6 -^\R1 -^\R2o2j -^\Z3 -^\^' -^\o69O04 -^\sr5 -^\O32p1 -^\z1T1 -^\z3 -^\} +^\ D6 +^\ R1 +^\ o2j +^\ Z3 +^\ ^' +^\ o69 O04 +^\ sr5 +^\ O32 p1 +^\ z1 +^\ z3 +^\ } ^] -^]$: -^]$Ll -^]$[ -^]*27t -^]-2 -^]K -^]L0 -^]t -^]O18 -^]O42 -^]z2 +^] $: +^] $L l +^] $[ +^] *27 t +^] -2 +^] K +^] L0 +^] t +^] O18 +^] O42 +^] z2 ^^ -^^$i -^^'5 -^^*85*35 -^^+1i6M -^^D2 -^^^Oz1 -^^i64*57 -^^sx! -^^z1 -^^z3 -^_$3 -^_$6 -^_$Q -^_$_ -^_*32 -^_-1 -^_-6 -^_T1 -^_T4 -^_T6 -^_^\ -^_^_ -^_^a -^_^z -^_d -^_i04 -^_l -^_r -^_O12 -^_O13 -^_z2 -^_z3 +^^ $i +^^ '5 +^^ *85 *35 +^^ +1 i6M +^^ D2 +^^ ^O z1 +^^ i64 *57 +^^ sx! +^^ z1 +^^ z3 +^_ $3 +^_ $6 +^_ $Q +^_ $_ +^_ *32 +^_ -1 +^_ -6 +^_ T1 +^_ T4 +^_ T6 +^_ ^\ +^_ ^_ +^_ ^a +^_ ^z +^_ d +^_ i04 +^_ l +^_ r +^_ O12 +^_ O13 +^_ z2 +^_ z3 ^` -^`$g'6 -^`+0o18 -^`-2 -^`L0 -^`^k -^`i2! -^`o4% -^`o5di2" -^`o6!Z1 -^`q -^`t -^`z1 -^`z2 -^`} +^` $g '6 +^` +0 o18 +^` -2 +^` L0 +^` ^k +^` i2! +^` o4% +^` o5d i2" +^` o6! Z1 +^` q +^` t +^` z1 +^` z2 +^` } ^a -^a$6l -^a$v -^a'B -^a*15 -^a*20 -^a*24 -^a*97 -^aD9 -^aK -^aZ1 -^aZ3l -^aZ4Z3 -^a^0 -^a^1 -^a^2 -^a^3 -^a^4 -^a^5 -^a^6 -^a^7 -^a^8 -^a^9 -^a^R -^a^V -^a^a -^a^b -^a^c -^a^d -^a^e -^a^f -^a^h -^a^k -^a^n -^a^p -^ad -^ai1; -^ai3. -^ai3l -^ai49 -^ao2i -^ao3z -^aO12 -^aO21 -^aO31 -^aO41 -^aO47 -^aO49 -^aO51o0t -^aO61 -^az1} -^az2 -^az3 -^az5 -^a} +^a $6 l +^a $v +^a 'B +^a *15 +^a *20 +^a *24 +^a *97 +^a D9 +^a K +^a Z1 +^a Z3 l +^a Z4 Z3 +^a ^0 +^a ^1 +^a ^2 +^a ^3 +^a ^4 +^a ^5 +^a ^6 +^a ^7 +^a ^8 +^a ^9 +^a ^R +^a ^V +^a ^a +^a ^b +^a ^c +^a ^d +^a ^e +^a ^f +^a ^h +^a ^k +^a ^n +^a ^p +^a d +^a i1; +^a i3. +^a i3l +^a i49 +^a o2i +^a o3z +^a O12 +^a O21 +^a O31 +^a O41 +^a O47 +^a O49 +^a O51 o0t +^a O61 +^a z1 } +^a z2 +^a z3 +^a z5 +^a } ^b -^b$* -^b$j*35 -^b'A -^b*24 -^b*30 -^b*64 -^b+1 -^b-2 -^b-3 -^b-5s9l -^b-7 -^bC+6 -^bD4 -^bR8 -^bT1 -^bZ2 -^b^0 -^b^1 -^b^2 -^b^3 -^b^4 -^b^5 -^b^7 -^b^8 -^b^a -^b^b -^b^c -^b^d -^b^e -^b^f -^b^m -^bd -^bi2/o2u -^bo2n -^bo7! -^bo8* -^bs93 -^bsrz -^bO25 -^bO35 -^bO52 -^bO56 -^bz2*56 -^bz3 -^bz3c -^bz4*06 +^b $* +^b $j *35 +^b 'A +^b *24 +^b *30 +^b *64 +^b +1 +^b -2 +^b -3 +^b -5 s9l +^b -7 +^b C +6 +^b D4 +^b R8 +^b T1 +^b Z2 +^b ^0 +^b ^1 +^b ^2 +^b ^3 +^b ^4 +^b ^5 +^b ^7 +^b ^8 +^b ^a +^b ^b +^b ^c +^b ^d +^b ^e +^b ^f +^b ^m +^b d +^b i2/ o2u +^b o2n +^b o7! +^b o8* +^b s93 +^b srz +^b O25 +^b O35 +^b O52 +^b O56 +^b z2 *56 +^b z3 +^b z3 c +^b z4 *06 ^c -^c$2 -^c$m -^c$z -^c'9 -^c*01+0 -^c*12 -^c*16 -^c*20 -^c*30 -^c*40{ -^c+1 -^c-1 -^c-7r -^cD3 -^cD5 -^cL4 -^cR4 -^cZ3^R -^c^0 -^c^1 -^c^2 -^c^3 -^c^4 -^c^5 -^c^6 -^c^7 -^c^8 -^c^9 -^c^F -^c^a -^c^b -^c^c -^c^d -^c^e -^c^f -^c^g -^c^p -^cc -^ci1j -^ci3t -^ci58z1 -^ci5u -^co5cT1 -^co6< -^cp1 -^cp2 -^ctO32 -^cO13 -^cO4B -^cO56 -^cO75 -^cO82 -^cz5 -^c} +^c $2 +^c $m +^c $z +^c '9 +^c *01 +0 +^c *12 +^c *16 +^c *20 +^c *30 +^c *40 { +^c +1 +^c -1 +^c -7 r +^c D3 +^c D5 +^c L4 +^c R4 +^c Z3 ^R +^c ^0 +^c ^1 +^c ^2 +^c ^3 +^c ^4 +^c ^5 +^c ^6 +^c ^7 +^c ^8 +^c ^9 +^c ^F +^c ^a +^c ^b +^c ^c +^c ^d +^c ^e +^c ^f +^c ^g +^c ^p +^c c +^c i1j +^c i3t +^c i58 z1 +^c i5u +^c o5c T1 +^c o6< +^c p1 +^c p2 +^c t O32 +^c O13 +^c O4B +^c O56 +^c O75 +^c O82 +^c z5 +^c } ^d -^d$ -^d$4 -^d$D -^d$h -^d*0A -^d*40 -^d*56 -^d-3 -^d-5 -^dC -^dD4 -^dK -^dKi6k -^dL1 -^dT1 -^dZ4 -^d^0 -^d^1 -^d^2 -^d^3 -^d^4 -^d^5 -^d^6 -^d^7 -^d^8 -^d^9 -^d^a -^d^b -^d^c -^d^d -^d^e -^d^f -^d^h -^di0l -^di1l -^di1s -^di31 -^di48 -^di4=O34 -^di8d -^dl^0 -^do2. -^do3sK -^do4h -^do4r -^do64 -^dp1 -^drk -^ds4b -^dsf5 -^dt$C -^dO13 -^dO31 -^dO32 -^dO32Z2 -^dO42 -^dO51 -^dO63-6 -^dz2 -^dz3 -^dz5 +^d $ +^d $4 +^d $D +^d $h +^d *0A +^d *40 +^d *56 +^d -3 +^d -5 +^d C +^d D4 +^d K +^d K i6k +^d L1 +^d T1 +^d Z4 +^d ^0 +^d ^1 +^d ^2 +^d ^3 +^d ^4 +^d ^5 +^d ^6 +^d ^7 +^d ^8 +^d ^9 +^d ^a +^d ^b +^d ^c +^d ^d +^d ^e +^d ^f +^d ^h +^d i0l +^d i1l +^d i1s +^d i31 +^d i48 +^d i4= O34 +^d i8d +^d l ^0 +^d o2. +^d o3s K +^d o4h +^d o4r +^d o64 +^d p1 +^d r k +^d s4b +^d sf5 +^d t $C +^d O13 +^d O31 +^d O32 +^d O32 Z2 +^d O42 +^d O51 +^d O63 -6 +^d z2 +^d z3 +^d z5 ^e -^e$7 -^e$V -^e'8 -^e*16 -^e*25 -^e+3 -^e+6 -^e-9 -^eL2 -^eR7 -^eZ2 -^eZ4+A -^e^0 -^e^1 -^e^2 -^e^3 -^e^5 -^e^6 -^e^7 -^e^8 -^e^9 -^e^a -^e^b -^e^c -^e^d -^e^e -^e^f -^e^h^t -^e^h^t^e^v^o^l^i -^e^p -^e^v^o^l^i -^e^w -^ec -^ed -^ei0V -^ei0l -^ei6\*36 -^eo5y -^er -^eud -^eO12 -^eO21 -^eO31 -^eO45 -^eO46 -^eO51 -^eO57 -^eO71 -^ez2 +^e $7 +^e $V +^e '8 +^e *16 +^e *25 +^e +3 +^e +6 +^e -9 +^e L2 +^e R7 +^e Z2 +^e Z4 +A +^e ^0 +^e ^1 +^e ^2 +^e ^3 +^e ^5 +^e ^6 +^e ^7 +^e ^8 +^e ^9 +^e ^a +^e ^b +^e ^c +^e ^d +^e ^e +^e ^f +^e ^h ^t +^e ^h ^t ^e ^v ^o ^l ^i +^e ^p +^e ^v ^o ^l ^i +^e ^w +^e c +^e d +^e i0V +^e i0l +^e i6\ *36 +^e o5y +^e r +^e u d +^e O12 +^e O21 +^e O31 +^e O45 +^e O46 +^e O51 +^e O57 +^e O71 +^e z2 ^f -^f$^ -^f$b -^f$r -^f$v -^f'7 -^f'7$s -^f'A -^f*08 -^f*18 -^f*21 -^f+1 -^f-1^V -^f-5 -^fD7 -^fZ1 -^fZ3 -^f^0 -^f^1 -^f^2 -^f^3 -^f^4 -^f^5 -^f^6 -^f^7 -^f^8 -^f^9 -^f^C -^f^N+7 -^f^V -^f^a -^f^b -^f^c -^f^d -^f^e -^f^f -^fd -^fi2jr -^fs62 -^fO49 -^fO51 -^fO58o2u -^fO61 -^fO75 -^fz2 -^fz3 -^fz4k -^fz5 -^f{*14 +^f $^ +^f $b +^f $r +^f $v +^f '7 +^f '7 $s +^f 'A +^f *08 +^f *18 +^f *21 +^f +1 +^f -1 ^V +^f -5 +^f D7 +^f Z1 +^f Z3 +^f ^0 +^f ^1 +^f ^2 +^f ^3 +^f ^4 +^f ^5 +^f ^6 +^f ^7 +^f ^8 +^f ^9 +^f ^C +^f ^N +7 +^f ^V +^f ^a +^f ^b +^f ^c +^f ^d +^f ^e +^f ^f +^f d +^f i2j r +^f s62 +^f O49 +^f O51 +^f O58 o2u +^f O61 +^f O75 +^f z2 +^f z3 +^f z4 +^f z5 +^f { *14 ^g -^g$& -^g$7 -^g$; -^g$s -^g$t -^g'4 -^g'6 -^g*05 -^g*65 -^g-6 -^g-8 -^g@a -^gD4 -^gD8 -^gL1 -^gL2 -^gT1 -^gT3s0v -^gT6i1w -^gZ3 -^g^h -^g^s -^g^w -^gi4g -^gi60^^ -^go52 -^go67 -^go78 -^gp1 -^gsSo -^gsmj -^gt -^guZ1 -^gO23 -^gO29p1 -^gO31 -^gO32 -^gO36 -^gO49 -^gO52 -^gO59 -^gO5A -^gO65 -^gz3 -^gz4 -^g{Z3 +^g $& +^g $7 +^g $; +^g $s +^g $t +^g '4 +^g '6 +^g *05 +^g *65 +^g -6 +^g -8 +^g @a +^g D4 +^g D8 +^g L1 +^g L2 +^g T1 +^g T3 s0v +^g T6 i1w +^g Z3 +^g ^h +^g ^s +^g ^w +^g i4g +^g i60 ^^ +^g o52 +^g o67 +^g o78 +^g p1 +^g sSo +^g smj +^g t +^g u Z1 +^g O23 +^g O29 p1 +^g O31 +^g O32 +^g O36 +^g O49 +^g O52 +^g O59 +^g O5A +^g O65 +^g z3 +^g z4 +^g { Z3 ^h -^h$ -^h$m -^h$pz1 -^h'6 -^h'9 -^h'A -^h*32 -^h+5 -^hD3 -^hD7 -^hZ1 -^hZ2$y -^h^$ -^h^P -^h^P} -^h^a -^h^m -^h^o -^h^r -^hc -^ho1c -^ho23 -^ho2h -^ho2t -^ho2y -^ho4 -^ho5. -^hr -^hsn4*31 -^ht -^hO16 -^hO34 -^hO51 -^hO62 -^hO91 -^hz2 -^hz4 -^h} +^h $ +^h $m +^h $p z1 +^h '6 +^h '9 +^h 'A +^h *32 +^h +5 +^h D3 +^h D7 +^h Z1 +^h Z2 $y +^h ^$ +^h ^P +^h ^P } +^h ^a +^h ^m +^h ^o +^h ^r +^h c +^h o1c +^h o23 +^h o2h +^h o2t +^h o2y +^h o4 +^h o5. +^h r +^h sn4 *31 +^h t +^h O16 +^h O34 +^h O51 +^h O62 +^h O91 +^h z2 +^h z4 +^h } ^i -^i*03 -^i*37*57 -^i*52*02 -^i*70c -^i-0^l -^i-3 -^i-5 -^i@8 -^iD6K -^iR2 -^iT3z4 -^iT4 -^iZ1 -^iZ2 -^i^M -^i^O -^i^f -^i^g -^i^m -^i^n -^i^s -^i^x -^i^{o6c -^id -^ii0N -^ii3( -^ii8u -^io0LZ3 -^io2:*31 -^io2g -^io4_ -^io57 -^is1l -^isv5 -^isxh -^iO12 -^iO15 -^iO21 -^iO23 -^iO25 -^iO36 -^iO54 -^iz1 -^iz2 -^iz3 -^iz5 -^i} +^i *03 +^i *37 *57 +^i *52 *02 +^i *70 c +^i -0 ^l +^i -3 +^i -5 +^i @8 +^i D6 K +^i R2 +^i T3 z4 +^i T4 +^i Z1 +^i Z2 +^i ^M +^i ^O +^i ^f +^i ^g +^i ^m +^i ^n +^i ^s +^i ^x +^i ^{ o6c +^i d +^i i0N +^i i3( +^i i8u +^i o0L Z3 +^i o2: *31 +^i o2g +^i o4_ +^i o57 +^i s1l +^i sv5 +^i sxh +^i O12 +^i O15 +^i O21 +^i O23 +^i O25 +^i O36 +^i O54 +^i z1 +^i z2 +^i z3 +^i z5 +^i } ^j -^j$s -^j$y -^j*24 -^j*41 -^j*54 -^j*59O46 -^j+1 -^j+2 -^jR5o3l -^jZ1i2e -^jZ3 -^j^` -^j^b+2 -^j^r -^jc -^ji0h -^ji2=R1 -^jo4c -^jo51 -^jo8JO39 -^jp1 -^jrO05 -^juz1 -^jO14 -^jO21 -^jO21T5 -^jO24i09 -^jO25'5 -^jO32 -^jO34 -^jO51 -^jO62 -^jO74+7 -^jz1 -^jz2O38 +^j $s +^j $y +^j *24 +^j *41 +^j *54 +^j *59 O46 +^j +1 +^j +2 +^j R5 o3l +^j Z1 i2e +^j Z3 +^j ^` +^j ^b +2 +^j ^r +^j c +^j i0h +^j i2= R1 +^j o4c +^j o51 +^j o8J O39 +^j p1 +^j r O05 +^j u z1 +^j O14 +^j O21 +^j O21 T5 +^j O24 i09 +^j O25 '5 +^j O32 +^j O34 +^j O51 +^j O62 +^j O74 +7 +^j z1 +^j z2 O38 ^k -^k$$ -^k$a -^k$b -^k$t -^k'4 -^k'7 -^k*06$i -^k*13 -^k*14 -^k*78 -^k+3 -^k+6 -^k@t -^kD6 -^kL4 -^kR3 -^kZ2-3 -^k^" -^k^2 -^k^w -^kd -^ki11 -^ki1i -^ki2c -^ko1u -^ko6u -^ks1a -^ksfF -^kt -^ku -^kO13 -^kO15 -^kO32 -^kO42 -^kO46 -^kO53 -^kz1 -^kz3 -^kz4 -^k} +^k $$ +^k $a +^k $b +^k $t +^k '4 +^k '7 +^k *06 $i +^k *13 +^k *14 +^k *78 +^k +3 +^k +6 +^k @t +^k D6 +^k L4 +^k R3 +^k Z2 -3 +^k ^" +^k ^2 +^k ^w +^k d +^k i11 +^k i1i +^k i2c +^k o1u +^k o6u +^k s1a +^k sfF +^k t +^k u +^k O13 +^k O15 +^k O32 +^k O42 +^k O46 +^k O53 +^k z1 +^k z3 +^k z4 +^k } ^l -^l$1 -^l'9 -^l*03 -^l*04 -^l*20 -^l*51 -^l*56 -^l+1 -^l+7+6 -^l-3 -^l-8 -^l@d -^lD2 -^lR8 -^l] -^l^J -^l^a -^l^k -^l^l^a^4 -^l^o -^l^r -^l^s -^lc -^lcZ3 -^li3l -^li5v -^li7h -^li9n -^lo3 -^lo3o -^lo4h -^lO32 -^lO36 -^lO41 -^lO53 -^lz1 -^lz3 +^l $1 +^l '9 +^l *03 +^l *04 +^l *20 +^l *51 +^l *56 +^l +1 +^l +7 +6 +^l -3 +^l -8 +^l @d +^l D2 +^l R8 +^l ] +^l ^J +^l ^a +^l ^k +^l ^l ^a ^4 +^l ^o +^l ^r +^l ^s +^l c +^l c Z3 +^l i3l +^l i5v +^l i7h +^l i9n +^l o3 +^l o3o +^l o4h +^l O32 +^l O36 +^l O41 +^l O53 +^l z1 +^l z3 ^m -^m$X -^m$z -^m*04 -^m*06 -^m*08 -^m*34 -^m*53 -^m*63 -^m-2 -^m-4 -^m-7 -^mD4 -^mD5z1 -^mL5 -^mT5$p -^m^S -^m^a^i -^m^k -^m^m -^m^v -^mcO62 -^md -^mi1a -^mi3- -^mi6O -^mo2i -^mo3i -^mo3n -^mo4l -^mo58 -^mo85 -^msrw -^mst% -^mt -^mO12 -^mO13 -^mO15 -^mO24 -^mO32 -^mO58 -^mz2 -^mz3 -^mz4 -^mz5 +^m $X +^m $z +^m *04 +^m *06 +^m *08 +^m *34 +^m *53 +^m *63 +^m -2 +^m -4 +^m -7 +^m D4 +^m D5 z1 +^m L5 +^m T5 $p +^m ^S +^m ^a ^i +^m ^k +^m ^m +^m ^v +^m c O62 +^m d +^m i1a +^m i3- +^m i6O +^m o2i +^m o3i +^m o3n +^m o4l +^m o58 +^m o85 +^m srw +^m st% +^m t +^m O12 +^m O13 +^m O15 +^m O24 +^m O32 +^m O58 +^m z2 +^m z3 +^m z4 +^m z5 ^n -^n$1 -^n$D*76 -^n'4 -^n*03 -^n*42Z2 -^n+0$5 -^n+3 -^n-1 -^nD2R1 -^nD4 -^nK -^nL1 -^nR2 -^n^n -^n^t -^nd -^nf -^ni0b -^ni1d -^ni2^ -^ni4U{ -^nkr -^no1I -^no5,o6P -^nslo -^nstk -^nt -^nto78 -^nO25 -^nO31 -^nO32 -^nO34$G -^nz2 -^nz2^x -^nz3o9v -^nz5 -^n{Z1 +^n $1 +^n $D *76 +^n '4 +^n *03 +^n *42 Z2 +^n +0 $5 +^n +3 +^n -1 +^n D2 R1 +^n D4 +^n K +^n L1 +^n R2 +^n ^n +^n ^t +^n d +^n f +^n i0b +^n i1d +^n i2^ +^n i4U { +^n k r +^n o1I +^n o5, o6P +^n slo +^n stk +^n t +^n t o78 +^n O25 +^n O31 +^n O32 +^n O34 $G +^n z2 +^n z2 ^x +^n z3 o9v +^n z5 +^n { Z1 ^o -^o$9o6n -^o$mz2 -^o$p -^o$v -^o'8 -^o*25f -^o*28O2A -^o*30 -^o*58 -^o+1 -^o+6 -^o-3 -^o-6 -^oC^t -^oD3 -^oKo5; -^oL0 -^oL7 -^oR2 -^oZ2*10 -^oZ2{ -^o^D -^o^K -^o^^ -^o^c -^o^p -^o^s -^od -^oi1' -^oi1Dr -^oi2Y -^oi3k -^oi44u -^ok'6 -^oo98 -^os1dD4 -^osat -^oslt -^oO12 -^oO28 -^oz1 -^oz1o0G -^oz2 -^oz2o5l -^oz3*64 -^o} +^o $9 o6n +^o $m z2 +^o $p +^o $v +^o '8 +^o *25 f +^o *28 O2A +^o *30 +^o *58 +^o +1 +^o +6 +^o -3 +^o -6 +^o C ^t +^o D3 +^o K o5; +^o L0 +^o L7 +^o R2 +^o Z2 *10 +^o Z2 { +^o ^D +^o ^K +^o ^^ +^o ^c +^o ^p +^o ^s +^o d +^o i1' +^o i1D r +^o i2Y +^o i3k +^o i44 u +^o k '6 +^o o98 +^o s1d D4 +^o sat +^o slt +^o O12 +^o O28 +^o z1 +^o z1 o0G +^o z2 +^o z2 o5l +^o z3 *64 +^o } ^p -^p$p -^p'5 -^p'A -^p*04o0F -^p*12 -^p*20 -^p*40 -^p+9 -^p-2 -^p-7 -^p@dT2 -^p@m -^pK -^pL3 -^pR6 -^pZ2 -^p^f -^p^m -^pcz1 -^pi0$r -^pi0R -^pi2YO36 -^po0iO52 -^po1k -^pp2sfi -^psx- -^pt -^pt^| -^pu -^pO15 -^pO34 -^pO52 -^pO68 -^pz1 -^pz2 -^pz3 -^p} +^p $p +^p '5 +^p 'A +^p *04 o0F +^p *12 +^p *20 +^p *40 +^p +9 +^p -2 +^p -7 +^p @d T2 +^p @m +^p K +^p L3 +^p R6 +^p Z2 +^p ^f +^p ^m +^p c z1 +^p i0$ r +^p i0R +^p i2Y O36 +^p o0i O52 +^p o1k +^p p2 sfi +^p sx- +^p t +^p t ^| +^p u +^p O15 +^p O34 +^p O52 +^p O68 +^p z1 +^p z2 +^p z3 +^p } ^q -^q$2 -^q$N -^q$a -^q'5 -^q*01o0j -^q*14 -^q*57 -^q+1 -^q-3 -^qK -^qR4R4 -^qT5 -^q^g -^q^n -^qc -^qo5C -^qp1 -^qr -^qtO39 -^qO48 -^qz1 -^qz1$4 -^qz2 -^qz2+5 -^qz2T1 -^qz5 -^q} +^q $2 +^q $N +^q $a +^q '5 +^q *01 o0j +^q *14 +^q *57 +^q +1 +^q -3 +^q K +^q R4 R4 +^q T5 +^q ^g +^q ^n +^q c +^q o5C +^q p1 +^q r +^q t O39 +^q O48 +^q z1 +^q z1 $4 +^q z2 +^q z2 +5 +^q z2 T1 +^q z5 +^q } ^r -^r$Y -^r'5 -^r'8 -^r'B -^r*03 -^r*45 -^r*67 -^r+5 -^r-2 -^r@i -^r@k -^rD5 -^rK -^rZ1 -^r^`i1J -^r^x -^ri0D -^ri18 -^ri1t -^ri4f -^ri4y -^ro0uO62 -^ro81 -^rrZ3 -^rsli -^rstm -^ru -^rO16 -^rO16o2x -^rO72O38 -^rO92 -^rz2 +^r $Y +^r '5 +^r '8 +^r 'B +^r *03 +^r *45 +^r *67 +^r +5 +^r -2 +^r @i +^r @k +^r D5 +^r K +^r Z1 +^r ^` i1J +^r ^x +^r i0D +^r i18 +^r i1t +^r i4f +^r i4y +^r o0u O62 +^r o81 +^r r Z3 +^r sli +^r stm +^r u +^r O16 +^r O16 o2x +^r O72 O38 +^r O92 +^r z2 ^s -^s$# -^s$9 -^s$b -^s$d -^s'6 -^s'A -^s*15 -^s*23 -^s*41 -^s*42 -^s*62 -^s*65 -^s+2 -^s+3skc -^s+7 -^s+7i3\ -^s-1 -^s-3 -^s@g -^s@t -^sCr -^sD4 -^sD4i38 -^sD6 -^sR3 -^sT5 -^sT6 -^sZ2O26 -^sZ3 -^s^)-7 -^s^F -^s^L -^s^V -^s^Y -^s^a -^s^c -^s^gu -^si0h -^si1j -^si2a -^si87O49 -^si9y -^sl -^so2y -^sp1 -^sr -^ssl3 -^sslzz3 -^sspe -^ssr/ -^sO13 -^sO14 -^sO26 -^sO43Z1 -^sO52 -^sO63 -^sO82 -^sz1 -^s} +^s $# +^s $9 +^s $b +^s $d +^s '6 +^s 'A +^s *15 +^s *23 +^s *41 +^s *42 +^s *62 +^s *65 +^s +2 +^s +3 skc +^s +7 +^s +7 i3\ +^s -1 +^s -3 +^s @g +^s @t +^s C r +^s D4 +^s D4 i38 +^s D6 +^s R3 +^s T5 +^s T6 +^s Z2 O26 +^s Z3 +^s ^) -7 +^s ^F +^s ^L +^s ^V +^s ^Y +^s ^a +^s ^c +^s ^g u +^s i0h +^s i1j +^s i2a +^s i87 O49 +^s i9y +^s l +^s o2y +^s p1 +^s r +^s sl3 +^s slz z3 +^s spe +^s sr/ +^s O13 +^s O14 +^s O26 +^s O43 Z1 +^s O52 +^s O63 +^s O82 +^s z1 +^s } ^t -^t$. -^t$i -^t'5 -^t'7 -^t'8 -^t*04 -^t*15 -^t*23 -^t*34 -^t*65 -^t+1 -^t+3 -^t-1 -^t-2 -^t-6O45 -^t-7+8 -^t@t -^tC -^tZ1 -^tZ3'6 -^t^/ -^t^s -^t^s^1 -^t^u -^td -^tfO08 -^ti0a -^ti5t -^tl -^to14 -^to3R -^to3^ -^tsd -^tsmt*21 -^tt -^tuz2 -^tO12 -^tO13 -^tO24 -^tO37 -^tO43 -^tO45 -^tz1 -^tz5 +^t $. +^t $i +^t '5 +^t '7 +^t '8 +^t *04 +^t *15 +^t *23 +^t *34 +^t *65 +^t +1 +^t +3 +^t -1 +^t -2 +^t -6 O45 +^t -7 +8 +^t @t +^t C +^t Z1 +^t Z3 '6 +^t ^/ +^t ^s +^t ^s ^1 +^t ^u +^t d +^t f O08 +^t i0a +^t i5t +^t l +^t o14 +^t o3R +^t o3^ +^t sd +^t smt *21 +^t t +^t u z2 +^t O12 +^t O13 +^t O24 +^t O37 +^t O43 +^t O45 +^t z1 +^t z5 ^u -^u$+ -^u$2 -^u$4 -^u'A -^u*04 -^u*31 -^u*71 -^uD5 -^u^0 -^u^D -^u^N -^u^S -^u^n -^u^t -^u^y -^ui4P -^ul -^ur -^uO15 -^uO53 -^uz1 -^uz5 +^u $+ +^u $2 +^u $4 +^u 'A +^u *04 +^u *31 +^u *71 +^u D5 +^u ^0 +^u ^D +^u ^N +^u ^S +^u ^n +^u ^t +^u ^y +^u i4P +^u l +^u r +^u O15 +^u O53 +^u z1 +^u z5 ^v -^v$5 -^v'6 -^v'9i8t -^v*27 -^v*31 -^v*54 -^v+2 -^v+7 -^v-1@5 -^v-3 -^v-6 -^v@3 -^vD3 -^vR1 -^v^S -^v^T -^v^u -^v^} -^vd -^vi0d -^vl -^vo2C -^vo48 -^vo9(O56 +^v $5 +^v '6 +^v '9 i8t +^v *27 +^v *31 +^v *54 +^v +2 +^v +7 +^v -1 @5 +^v -3 +^v -6 +^v @3 +^v D3 +^v R1 +^v ^S +^v ^T +^v ^u +^v ^} +^v d +^v i0d +^v l +^v o2C +^v o48 +^v o9( O56 slr -^vO13 -^vO14 -^vO16 -^vO49 -^vO58 -^vO62 -^vz1 -^vz1D2 -^vz2 -^vz4 -^v} +^v O13 +^v O14 +^v O16 +^v O49 +^v O58 +^v O62 +^v z1 +^v z1 D2 +^v z2 +^v z4 +^v } ^w -^w$m -^w$w -^w*37 -^w*64^` -^w+4z2 -^w@msc6 -^wD3 -^wR1 -^wR6 -^w^M -^w^_ -^w^t -^w^w -^wd -^wf -^wi1r -^wi7Z -^wo2_ -^wo3I -^wsil -^wsnXO51 -^wto3B -^wO15@x -^wO34 -^wz2 -^wz2*25 +^w $m +^w $w +^w *37 +^w *64 ^` +^w +4 z2 +^w @m sc6 +^w D3 +^w R1 +^w R6 +^w ^M +^w ^_ +^w ^t +^w ^w +^w d +^w f +^w i1r +^w i7Z +^w o2_ +^w o3I +^w sil +^w snX O51 +^w t o3B +^w O15 @x +^w O34 +^w z2 +^w z2 *25 ^x -^x$x -^x$y -^x$} -^x'7 -^x'8 -^x*09 -^x*17^k -^x*20 -^x+5 -^x+6s59 -^x-1 -^xD2 -^xD7 -^xR1 -^xZ1 -^x]o1o -^x]} -^x^Xo5v -^x^r -^x^{ -^xi0t -^xi2&z2 -^xi5N -^xk*35 -^xl -^xo0\i3? -^xo4m -^xp1 -^xsq3 -^xu$q -^xO13 -^xO31 -^xO4B -^xO54 -^xO58 -^xO73 -^xz1 -^xz2 -^xz3 -^xz5 -^x}u +^x $x +^x $y +^x $} +^x '7 +^x '8 +^x *09 +^x *17 ^k +^x *20 +^x +5 +^x +6 s59 +^x -1 +^x D2 +^x D7 +^x R1 +^x Z1 +^x ] o1o +^x ] } +^x ^X o5v +^x ^r +^x ^{ +^x i0t +^x i2& z2 +^x i5N +^x k *35 +^x l +^x o0\ i3? +^x o4m +^x p1 +^x sq3 +^x u $q +^x O13 +^x O31 +^x O4B +^x O54 +^x O58 +^x O73 +^x z1 +^x z2 +^x z3 +^x z5 +^x } u ^y -^y$j -^y$y -^y'3 -^y*07i4= -^y*57 -^y+7l -^y-2 -^yL0 -^yZ1 -^yZ1TA -^y^! -^y^T -^y^m -^y^m^4 -^y^m^e^v^o^l^i -^y^o -^y^s -^yi1@ -^yi1n -^yi3_ -^yi5wO13 -^yi6U -^yi8O -^yo1k -^yp1 -^ys5e -^yO32 -^yO41 -^yO49 -^yz1 -^yz2 -^yz5 -^y} +^y $j +^y $y +^y '3 +^y *07 i4= +^y *57 +^y +7 l +^y -2 +^y L0 +^y Z1 +^y Z1 TA +^y ^! +^y ^T +^y ^m +^y ^m ^4 +^y ^m ^e ^v ^o ^l ^i +^y ^o +^y ^s +^y i1@ +^y i1n +^y i3_ +^y i5w O13 +^y i6U +^y i8O +^y o1k +^y p1 +^y s5e +^y O32 +^y O41 +^y O49 +^y z1 +^y z2 +^y z5 +^y } ^z -^z$z -^z'9 -^z*13 -^z*53 -^z+6T5 -^z+7 -^z-1 -^z-6 -^z@e -^z@hT8 -^z@t -^zZ1O31 -^z^4 -^z^s -^zi4_ -^zi6T -^zi8z -^zo6R -^zr -^zO13 -^zO23 -^zO24 -^zO42 -^zO59 -^zz2 -^zz2*23 -^z} +^z $z +^z '9 +^z *13 +^z *53 +^z +6 T5 +^z +7 +^z -1 +^z -6 +^z @e +^z @h T8 +^z @t +^z Z1 O31 +^z ^4 +^z ^s +^z i4_ +^z i6T +^z i8z +^z o6R +^z r +^z O13 +^z O23 +^z O24 +^z O42 +^z O59 +^z z2 +^z z2 *23 +^z } ^{ -^{$} -^{c +^{ $} +^{ c ^| -^|$+^Q -^|$ki4p -^|$r -^|T6 -^|T7 -^|z1*50 +^| $+ ^Q +^| $k i4p +^| $r +^| T6 +^| T7 +^| z1 *50 ^} -^}$bi0< -^}L2^- -^}^BL2 -^}^O -^}i8, -^}t -^}z4 +^} $b i0< +^} L2 ^- +^} ^B L2 +^} ^O +^} i8, +^} t +^} z4 c c $0 $1 c $1 $2 @@ -15714,5098 +15690,5096 @@ c T4 c T5 c T6 c T7 -c$ -c$! -c$!$1 -c$!$@ -c$!$@$# -c$!d -c$!d] -c$!o4a -c$" -c$# -c$#d -c$$ -c$$d -c$&d -c$&d] -c$) -c$* -c$*$*^*^* -c$*d -c$*d] -c$+ -c$+d -c$+d] -c$- -c$-d -c$-d] -c$. -c$0$0 -c$0$0$0 -c$0$0$1 -c$0$0$7 -c$0$2 -c$0$3 -c$0$4 -c$0$5 -c$0$6 -c$0$7 -c$0$8 -c$0$9 -c$0$9$8 -c$0$9$8$7 -c$0$9$8$7$6 -c$0$9$8$7$6$5 -c$0d -c$0d] -c$1$! -c$1$0 -c$1$1 -c$1$1$1 -c$1$2$3$4 -c$1$2$3$4$5 -c$1$2$3$4$5$6 -c$1$2$3$a$b$c -c$1$2$a$b -c$1$3 -c$1$4 -c$1$5 -c$1$6 -c$1$7 -c$1$8 -c$1$9 -c$1$9$6$0 -c$1$9$6$1 -c$1$9$6$2 -c$1$9$6$3 -c$1$9$6$4 -c$1$9$6$5 -c$1$9$6$6 -c$1$9$6$7 -c$1$9$6$8 -c$1$9$6$9 -c$1$9$7$0 -c$1$9$7$1 -c$1$9$7$2 -c$1$9$7$3 -c$1$9$7$4 -c$1$9$7$5 -c$1$9$7$6 -c$1$9$7$7 -c$1$9$7$8 -c$1$9$7$9 -c$1$9$8$0 -c$1$9$8$1 -c$1$9$8$2 -c$1$9$8$3 -c$1$9$8$4 -c$1$9$8$5 -c$1$9$8$6 -c$1$9$8$7 -c$1$9$8$8 -c$1$9$8$9 -c$1$9$9$0 -c$1$9$9$1 -c$1$9$9$2 -c$1$9$9$3 -c$1$9$9$4 -c$1$9$9$5 -c$1$9$9$6 -c$1$9$9$7 -c$1$9$9$8 -c$1$9$9$9 -c$1$s$t -c$1d -c$1d] -c$2 -c$2$0 -c$2$0$0$0 -c$2$0$0$1 -c$2$0$0$2 -c$2$0$0$3 -c$2$0$0$4 -c$2$0$0$5 -c$2$0$0$6 -c$2$0$0$7 -c$2$0$0$8 -c$2$0$0$9 -c$2$0$1$0 -c$2$0$1$1 -c$2$0$1$2 -c$2$0$1$3 -c$2$0$1$4 -c$2$0$1$5 -c$2$0$1$6 -c$2$0$1$7 -c$2$0$1$8 -c$2$0$1$9 -c$2$0$2$0 -c$2$0$2$1 -c$2$0$2$2 -c$2$0$2$3 -c$2$0$2$4 -c$2$0$2$5 -c$2$0$2$6 -c$2$0$2$7 -c$2$0$2$8 -c$2$0$2$9 -c$2$1 -c$2$2 -c$2$2$2 -c$2$3 -c$2$3$4 -c$2$4 -c$2$5 -c$2$6 -c$2$7 -c$2$8 -c$2$9 -c$2$k -c$2$m$e -c$2$u -c$2d -c$2d] -c$2z3 -c$3$0 -c$3$1 -c$3$2 -c$3$2$1 -c$3$3 -c$3$3$3 -c$3$4 -c$3$4$5 -c$3$5 -c$3$6 -c$3$7 -c$3$8 -c$3$9 -c$3d -c$3d] -c$4 -c$4$0 -c$4$1 -c$4$2 -c$4$3 -c$4$3$2$1 -c$4$4 -c$4$4$4 -c$4$5 -c$4$5$6 -c$4$6 -c$4$7 -c$4$8 -c$4$9 -c$4$M$e -c$4$U -c$4$a$l$l -c$4$e$v$e$r -c$4$f$r$e$e -c$4$l$i$f$e -c$4$m$e -c$4$u -c$4$u$s -c$4d -c$4d] -c$5 -c$5$0 -c$5$1 -c$5$2 -c$5$3 -c$5$4 -c$5$4$3$2$1 -c$5$5 -c$5$5$5 -c$5$6 -c$5$6$7 -c$5$7 -c$5$8 -c$5$9 -c$5d -c$6$0 -c$6$1 -c$6$2 -c$6$3 -c$6$4 -c$6$5 -c$6$5$4$3$2$1 -c$6$6 -c$6$6$6 -c$6$7 -c$6$7$8 -c$6$8 -c$6$9 -c$6d -c$6d] -c$7 -c$7$0 -c$7$1 -c$7$2 -c$7$3 -c$7$4 -c$7$5 -c$7$6 -c$7$7 -c$7$7$7 -c$7$8 -c$7$8$9 -c$7$9 -c$7T3 -c$7d -c$7d] -c$8$0 -c$8$1 -c$8$2 -c$8$3 -c$8$4 -c$8$5 -c$8$6 -c$8$7 -c$8$8 -c$8$8$8 -c$8$9 -c$8d -c$8d] -c$9 -c$9$0 -c$9$1 -c$9$2 -c$9$3 -c$9$4 -c$9$5 -c$9$6 -c$9$7 -c$9$8 -c$9$9 -c$9$9$9 -c$9d -c$9d] -c$:$) -c$; -c$? -c$A -c$D -c$G -c$H -c$I -c$L -c$M -c$N -c$R -c$U -c$X -c$Z -c$[ -c$^ -c$_ -c$_d -c$_d] -c$a$b -c$a$b$c -c$e -c$k -c$l -c$m$e -c$v -c$x -c$x$x$x -c${ -c'3z5 -c'5 -c'7Z1 -c'9T3 -c'B -c*21 -c*24T0 -c*25O13 -c*40t -c*46 -c*52+0 -c*58 -c*65o65 -c*68 -c*70 -c*83 -c*8A -c*A8O86 -c+0 -c+2 -c+3 -c+4 -c+5 -c+7 -c+7L3 -c+A -c-0$= -c-1 -c-2 -c-3 -c-3'6 -c-4 -c-4T4 -c-6 -c-7 -c-8 -c-9 -c-B -c@2O14 -c@3 -c@A -c@b -c@f -c@fO23 -c@lO02 -c@m -c@q-5 -cD0D8 -cD1 -cD4 -cD5 -cD5@k -cD6 -cD7 -cD7*05 -cDA -cDB -cK*14 -cKi1[ -cKp1 -cL0 -cL0^p -cL0l -cL0sl( -cL5 -cL7 -cL7O05 -cR2 -cR3 -cR5z3 -cR6 -cR6C -cR7 -cT1 -cT1$1 -cT1T2 -cT1T2T3 -cT1T2T4T5 -cT1T2T4T5T6 -cT1d -cT1f -cT1i1& -cT1i1+ -cT1i1- -cT1i1.i2Ei3. -cT1i1.i2Fi3. -cT1i1.i2Oi3. -cT1i1_ -cT2 -cT2$1 -cT2T4 -cT2T4T6 -cT2T4T6T8 -cT2T4T6T8TA -cT2T4T6T8TATC -cT2d -cT2f -cT2i2& -cT2i2+ -cT2i2- -cT2i2. -cT2i2_ -cT3$1 -cT3d -cT3f -cT3i3& -cT3i3+ -cT3i3- -cT3i3. -cT3i3_ -cT4$1 -cT4d -cT4i4& -cT4i4+ -cT4i4- -cT4i4. -cT4i4_ -cT5$1 -cT5+4 -cT5i5& -cT5i5+ -cT5i5- -cT5i5. -cT5i5_ -cT6$1 -cT6+B -cT6i6+ -cT6i6- -cT6i6_ -cT7$1 -cT7i7- -cT7i7_ -cT8 -cT8$1 -cT8@s -cT8i8+ -cT8i8- -cT8i8_ -cT9 -cT9$1 -cT9i9+ -cT9i9- -cT9i9. -cT9i9_ -cTA -cTA$1 -cTAiA- -cTB -cTB$1 -cTBiB_ -cZ1$6 -cZ1O61 -cZ2i32 -cZ3 -cZ3O53 -cZ3O83 -c[ -c[K -c[Z1 -c[z3 -c^ -c^! -c^!$! -c^!^1 -c^!d -c^"$" -c^# -c^#$# -c^$ -c^$$$ -c^$^$ -c^& -c^( -c^($) -c^* -c^*$# -c^*$* -c^*^* -c^*d -c^+ -c^+$+ -c^+d -c^- -c^-$- -c^. -c^0 -c^0$0 -c^0^0 -c^0^0^0^2 -c^0^1 -c^0^1^0^2 -c^0^2 -c^0^3 -c^0^4 -c^0^5 -c^0^6 -c^0^6^9^1 -c^0^7 -c^0^7^9^1 -c^0^8 -c^0^8^9^1 -c^0^9 -c^0^9^9^1 -c^1 -c^1$1 -c^1$2 -c^1^! -c^1^0 -c^1^0^0^2 -c^1^1 -c^1^2 -c^1^3 -c^1^4 -c^1^5 -c^1^6 -c^1^6^9^1 -c^1^7 -c^1^7^9^1 -c^1^8 -c^1^8^9^1 -c^1^9 -c^1^9^9^1 -c^1^e^h^T -c^1^e^h^t -c^1d -c^2 -c^2$2 -c^2^0 -c^2^0^0^2 -c^2^1 -c^2^2 -c^2^3 -c^2^4 -c^2^5 -c^2^6 -c^2^6^9^1 -c^2^7 -c^2^7^9^1 -c^2^8 -c^2^8^9^1 -c^2^9 -c^2^9^9^1 -c^2d -c^3 -c^3$3 -c^3^0 -c^3^0^0^2 -c^3^1 -c^3^2 -c^3^2^1 -c^3^3 -c^3^4 -c^3^5 -c^3^6 -c^3^6^9^1 -c^3^7 -c^3^7^9^1 -c^3^8 -c^3^8^9^1 -c^3^9 -c^3^9^9^1 -c^3d -c^4 -c^4$4 -c^4^0 -c^4^0^0^2 -c^4^1 -c^4^2 -c^4^3 -c^4^3^2^1 -c^4^4 -c^4^5 -c^4^6 -c^4^6^9^1 -c^4^7 -c^4^7^9^1 -c^4^8 -c^4^8^9^1 -c^4^9 -c^4^9^9^1 -c^5 -c^5$5 -c^5^0 -c^5^0^0^2 -c^5^1 -c^5^2 -c^5^3 -c^5^4 -c^5^4^3^2^1 -c^5^5 -c^5^6 -c^5^6^9^1 -c^5^7 -c^5^7^9^1 -c^5^8 -c^5^8^9^1 -c^5^9 -c^5^9^9^1 -c^5d -c^6 -c^6$6 -c^6^0 -c^6^0^0^2 -c^6^1 -c^6^2 -c^6^3 -c^6^4 -c^6^5 -c^6^5^4^3^2^1 -c^6^6 -c^6^6^9^1 -c^6^7 -c^6^7^9^1 -c^6^8 -c^6^8^9^1 -c^6^9 -c^6^9^9^1 -c^6d -c^7 -c^7$7 -c^7^0 -c^7^0^0^2 -c^7^1 -c^7^2 -c^7^3 -c^7^4 -c^7^5 -c^7^6 -c^7^6^9^1 -c^7^7 -c^7^7^9^1 -c^7^8 -c^7^8^9^1 -c^7^9 -c^7^9^9^1 -c^8 -c^8$8 -c^8^0 -c^8^0^0^2 -c^8^1 -c^8^2 -c^8^3 -c^8^4 -c^8^5 -c^8^6 -c^8^6^9^1 -c^8^7 -c^8^7^9^1 -c^8^8 -c^8^8^9^1 -c^8^9 -c^8^9^9^1 -c^8d -c^9 -c^9$9 -c^9^0 -c^9^0^0^2 -c^9^1 -c^9^2 -c^9^3 -c^9^4 -c^9^5 -c^9^6 -c^9^6^9^1 -c^9^7 -c^9^7^9^1 -c^9^8 -c^9^8^9^1 -c^9^9 -c^9^9^9^1 -c^9d -c^;*4A -c^< -c^<$> -c^=$= -c^? -c^@ -c^@$@ -c^A -c^B -c^C -c^D -c^F -c^G -c^H -c^I -c^IT0 -c^J -c^K -c^L -c^M -c^Q -c^S -c^V -c^[ -c^[$] -c^_ -c^_$_ -c^`D4 -c^a -c^af -c^c^R -c^e^h^T -c^e^h^t -c^e^v^o^l^I -c^e^v^o^l^i -c^f -c^k^2 -c^l -c^l^l^a^4 -c^m^a^I -c^m^a^i -c^r} -c^t^s^1 -c^tz3 -c^u -c^y^M -c^y^m -c^y^m^4 -c^z -c^{$} -cd -ci0: -ci0` -ci0r -ci1! -ci1# -ci1$ -ci1% -ci1& -ci1' -ci1* -ci1+ -ci1- -ci1. -ci10 -ci10T2 -ci10i31 -ci10i31i52 -ci10i31i52i73 -ci11 -ci11T2 -ci11i31 -ci11i31i51 -ci11i31i51i71 -ci11i31i51i71i91 -ci11i31i51i71i91iB1 -ci11i32 -ci11i32i53 -ci11i32i53i74 -ci11i32i53i74i95 -ci11i32i53i74i95iB6 -ci11i32i53i74i95iB6iD7 -ci12 -ci12T2 -ci13 -ci13T2 -ci14 -ci14T2 -ci15 -ci15T2 -ci16 -ci16T2 -ci17 -ci17T2 -ci18 -ci18T2 -ci19 -ci19T2 -ci1F -ci1R -ci1W -ci1_ -ci1a -ci1c -ci1e -ci1h -ci1i -ci1o -ci1u -ci2! -ci2# -ci2$ -ci2& -ci2' -ci2* -ci2+ -ci2- -ci2. -ci2/ -ci20 -ci20T3 -ci21 -ci21T3 -ci22 -ci22T3 -ci23 -ci23T3 -ci24 -ci24T3 -ci25 -ci26 -ci26T3 -ci27 -ci27T3 -ci28 -ci28T3 -ci29 -ci2_ -ci2a -ci2e -ci2o -ci2u -ci3 -ci3! -ci3"^' -ci3# -ci3$ -ci3& -ci3' -ci3* -ci3+ -ci3- -ci3. -ci3/ -ci30 -ci30T4 -ci31 -ci31T4 -ci32 -ci32T4 -ci33 -ci33T4 -ci34 -ci34T4 -ci35 -ci35T4 -ci36 -ci36T4 -ci37 -ci37T4 -ci38 -ci38T4 -ci39 -ci3: -ci3@ -ci3C -ci3H -ci3L -ci3_ -ci3a -ci3e -ci3i -ci3o -ci3u -ci4 -ci4! -ci4# -ci4$ -ci4& -ci4' -ci4* -ci4+ -ci4- -ci4. -ci40 -ci40T5 -ci41 -ci41T5 -ci42 -ci42T5 -ci43 -ci43T5 -ci44 -ci44T5 -ci45 -ci45T5 -ci46 -ci46T5 -ci47 -ci47T5 -ci48 -ci48T5 -ci49 -ci49T5 -ci4@ -ci4_ -ci4a -ci4b -ci4e -ci4j -ci4m -ci4o -ci4u -ci5 -ci5! -ci5# -ci5$ -ci5& -ci5' -ci5* -ci5+ -ci5, -ci5- -ci5. -ci5/ -ci50 -ci50T6 -ci51 -ci51T6 -ci52 -ci52T6 -ci53 -ci53T6 -ci54 -ci54T6 -ci55 -ci55T6 -ci56 -ci56T6 -ci57 -ci57T6 -ci58 -ci58T6 -ci59 -ci59T6 -ci5K -ci5M -ci5_ -ci5a -ci5e -ci5g -ci5o -ci5p -ci5r -ci5s -ci5u -ci6! -ci6# -ci6$ -ci6& -ci6' -ci6* -ci6+ -ci6- -ci6. -ci60 -ci61 -ci61T7 -ci62 -ci62T7 -ci63 -ci63T7 -ci64 -ci64T7 -ci65 -ci65T7 -ci66 -ci66T7 -ci67 -ci67T7 -ci68 -ci69 -ci6@ -ci6C -ci6R -ci6W -ci6_ -ci6a -ci6b -ci6e -ci6h -ci6o -ci6u -ci7! -ci7# -ci7$ -ci7& -ci7' -ci7* -ci7+ -ci7- -ci7. -ci70 -ci71 -ci72 -ci73 -ci74 -ci75 -ci76 -ci77 -ci78 -ci79 -ci7@ -ci7_ -ci7a -ci7e -ci7o -ci7u -ci8 -ci8! -ci8# -ci8$ -ci8& -ci8* -ci8+ -ci8- -ci80 -ci81 -ci82 -ci83 -ci84 -ci85 -ci86 -ci87 -ci88 -ci89 -ci8_ -ci8a -ci8e -ci8i -ci8o -ci8r -ci8u -ciA2 -ck -ck*16 -clL4 -co06 -co0? -co0k -co0p -co0r -co0t -co0v -co0y -co1! -co1# -co1$ -co1* -co1+ -co1- -co1. -co10 -co11 -co12 -co13 -co14 -co15 -co16 -co17 -co18 -co19 -co1@ -co1A -co1T -co1V -co1_ -co1a -co1e -co1l -co1m -co1v -co1y -co2! -co2# -co2$ -co2& -co2* -co2+ -co2- -co20 -co21 -co22 -co23 -co24 -co25 -co26 -co27 -co28 -co29 -co2@ -co2L -co2_ -co2n -co2y -co3! -co3# -co3$ -co3% -co3& -co3* -co3+ -co3, -co3- -co30 -co31 -co32 -co33 -co34 -co35 -co36 -co37 -co38 -co39 -co3@ -co3R -co3S -co3_ -co3c -co3m -co4! -co4# -co4$ -co4& -co4* -co4+ -co4- -co4. -co40 -co41 -co42 -co43 -co44 -co45 -co46 -co47 -co48 -co49 -co4@ -co4N -co4O -co4S -co4V -co4W -co4_ -co4l -co4w -co5! -co5!O74 -co5# -co5$ -co5& -co5* -co5+ -co5- -co5. -co50 -co51 -co52 -co53 -co54 -co55 -co56 -co57 -co58 -co59 -co5@ -co5F -co5J -co5W -co5X -co5_ -co5a -co6! -co6# -co6$ -co6& -co6* -co6+ -co6+i1s -co6- -co6. -co60 -co61 -co62 -co63 -co64 -co65 -co66 -co67 -co68 -co69 -co6@ -co6M -co6T -co6W -co6_ -co6e -co6o -co6q -co7! -co7# -co7$ -co7& -co7* -co7+ -co7- -co7. -co70 -co71 -co72 -co73 -co74 -co75 -co76 -co77 -co78 -co79 -co7? -co7@ -co7M -co7S -co7V -co7_ -co7e -co7o -co7r -co8! -co8# -co8$ -co8& -co8* -co8+ -co8+R7 -co8- -co8/ -co80 -co81 -co82 -co83 -co84 -co85 -co86 -co87 -co88 -co89 -co8H -co8S -co8_ -co8o -co9! -co9# -co9$ -co9* -co9+ -co9- -co90 -co91 -co92 -co93 -co94 -co95 -co96 -co97 -co98 -co99 -co9V -co9_ -coA.O25 -coA4 -coA6 -coAm -cp3 -cp3'8 -cp4 -cp5 -cq -cr -cs$2 -cs0# -cs0I -cs0oZ5 -cs1, -cs10 -cs2* -cs2I -cs2m -cs4K -cs8! -cs87O43 -csGI -csa4 -csa4$! -csa4d -csa@ -csa@$! -csa@T4 -csa@T5 -csa@T6 -csa@d -csa@se3 -csa@se3si1 -csa@se3ss$ -csa@si! -csa@si1 -csa@si1ss$ -csa@sl1 -csa@so0 -csa@so0se3 -csa@so0si! -csa@so0si1 -csa@so0ss$ -csa@ss$ -csaw -csb1 -csb5$! -csb8 -csb8$! -csb8d -csd1 -cse3 -cse3$! -cse3T1 -cse3T2 -cse3T3 -cse3T4 -cse3T5 -cse3T6 -cse3T7 -cse3d -cse3si! -cse3si!ss$ -cse3si1ss$ -cse3sl1 -cse3ss$ -cseu -csex -csg9 -csg9$! -csgV -csi! -csi!$! -csi!T1 -csi!T2 -csi!T3 -csi!T4 -csi!T5 -csi!T6 -csi!sl1 -csi!ss$ -csi1 -csi1$! -csi1T1 -csi1T2 -csi1T3 -csi1T4 -csi1T5 -csi1T6 -csi1T7 -csi1d -csi1se3 -csi1ss$ -csiU -csiZ -csiu -csl1 -csl1$! -csl1T1 -csl1T2 -csl1T4 -csl1T5 -csl1T6 -csl1T7 -csl1d -cslt -cslz -csnj -cso&c -cso* -cso0 -cso0$! -cso0T1 -cso0T2 -cso0T3 -cso0T4 -cso0T5 -cso0T6 -cso0T7 -cso0d -cso0sa4 -cso0se3 -cso0se3si! -cso0se3si1 -cso0se3ss$ -cso0si! -cso0si!ss$ -cso0si1 -cso0si1ss$ -cso0sl1 -cso0ss$ -cspv -css$ -css$$! -css$T1 -css$T2 -css$T3 -css$T4 -css$T5 -css$T6 -css$T7 -css$d -css$sl1 -css-L7 -css3 -css3$! -css4 -css5 -css5$! -css5d -css5se3 -cssO -cst7 -cst7$! -cstC -csu4 -csu4$! -csu[ -csvz -csx,R5 -csy1 -csy2 -cuZ4 -cO02 -cO02L1 -cO03 -cO08 -cO12O28 -cO17$O -cO23 -cO24 -cO25 -cO26 -cO28 -cO32 -cO35 -cO35q -cO36 -cO38 -cO41$" -cO43 -cO43$7 -cO52 -cO53 -cO54'7 -cO57 -cO64 -cO65 -cO84 -cO85 -cO92 -cOA1O04 -cOA2 -cOB2 -cz1 -cz1$0 -cz2 -cz2$2 -cz2$t -cz2o9o -cz2ssR -cz3 -cz3K -cz3^K -cz3O81 -cz4 -cz5O18 -cz5O1B -c{ -c} -d$ -d$! -d$# -d$$ -d$& -d$* -d$+ -d$- -d$. -d$0 -d$1 -d$2 -d$3 -d$4 -d$5 -d$6 -d$7 -d$7snb -d$8 -d$9 -d$=} -d$?o1( -d$@ -d$N*13 -d$P -d$Z -d$] -d$_ -d$aO7A -d$c -d$d*58 -d$g -d$h -d$ki31 -d$m -d$n -d$p -d$q -d$t -d$xD0 -d'6L5 -d'8*20 -d'8i2, -d'9 -d'A -d'B -d*03 -d*04'8 -d*05 -d*06 -d*09 -d*14 -d*15O93 -d*16 -d*19*08 -d*20 -d*26 -d*28O13 -d*32 -d*32Z1 -d*3A -d*45 -d*47O58 -d*52 -d*52R4 -d*53 -d*56 -d*57 -d*64 -d*68 -d*68t -d*70 -d*71 -d*74 -d*7BO73 -d*81O63 -d*83O75 -d*87 -d*92D2 -d*98 -d*A9*53 -d+0 -d+1 -d+1*70 -d+2 -d+3 -d+6 -d+6t -d+7 -d+8 -d+B -d+BO67 -d-0O92 -d-2 -d-3^ -d-3O92 -d-4 -d-5 -d-6 -d-6K -d-7 -d-A -d@3 -d@a -d@k -d@zt -dCO39 -dD1c -dD2] -dD2o4s -dD3 -dD4^; -dD4o4w -dD5[ -dD6 -dD6t -dD7 -dK -dK{ -dL2 -dL2o8g -dL3l -dR0 -dR3i7Q -dR5 -dT0O85 -dT1 -dT2 -dT4D9 -dT5 -dT5^P -dZ1 -dZ1D3 -dZ1^! -dZ2-8 -dZ3 -d[ -d[+1 -d[^? -d[} -d]so" -d^$ -d^% -d^) -d^0 -d^1 -d^4 -d^5 -d^6 -d^7q -d^A-4 -d^C -d^CO14 -d^T -d^ak -d^b -d^c -d^f -d^s -dc -dcsh1 -dcO58 -dfO9A -di0# -di0m -di0q -di0z -di2m -di3 -di3,O07 -di3o -di3s -di4* -di4, -di44[ -di4b -di4y -di4z -di5 -di5, -di5hD7 -di5m -di5n -di5o -di5p -di5r -di6b -di6s -di6x -di7 -di7a -di7u -di8_ -dk -dkc -dko5- -dkO5A -dl -dlOB1 -do0! -do06O21 -do0:T1 -do0E -do0H -do0L -do0T -do0c -do0f -do0n -do0p -do0t -do0z -do1C -do1I -do2G -do2O -do2U -do2i -do2iu -do2o[ -do2x -do2| -do3( -do3_ -do3bo3b -do3h -do4@ -do4m -do4y -do5b -do5j -do5n -do5u -do5v -do5w -do6b -do6c -do6t[ -do6u -do6y -do79z4 -do7bc -do7l -do8i -do8k -do8o -do93 -do9i -do9vO94 -doBa -doBm -doBx -dr -drO0B -ds04 -ds0f -ds1h -ds2q -ds34O29 -ds5- -ds65C -ds9y -dsam -dsbh -dsby -dseg -dsg0 -dsgd -dsgr -dsh6 -dsir -dsjlO14 -dskz -dslY -dsmp -dspi -dsr3 -dsrw -dstp -dsvt -dsx/ -dt$Q -du -du*42 -dO02 -dO03 -dO04 -dO05 -dO06 -dO07 -dO09 -dO09$e -dO12 -dO12$q -dO13 -dO13t -dO15O63 -dO16 -dO17 -dO18$A -dO21 -dO23 -dO24 -dO25 -dO26 -dO26^R -dO27 -dO28 -dO28^Y -dO29 -dO29$z -dO29C -dO29o6| -dO32 -dO32Z1 -dO32o6y -dO34 -dO34$m -dO34p1 -dO34O03 -dO36 -dO37 -dO37k -dO37O92 -dO38 -dO38o0B -dO38O64 -dO41 -dO42 -dO42[ -dO43 -dO45 -dO45$d -dO46 -dO46z1 -dO48 -dO48^. -dO49$L -dO51O12 -dO52 -dO53 -dO54 -dO56 -dO62 -dO62K -dO63 -dO63c -dO69 -dO6As2@ -dO72 -dO73 -dO74 -dO75 -dO76 -dO79 -dO7Bs0k -dO81 -dO82 -dO83 -dO83O51 -dO84 -dO85 -dO85O34 -dO8A -dO94 -dO95 -dO96 -dO97 -dOA1 -dOA4 -dOA5 -dOA5O52 -dOA6 -dOA6*93 -dOA7 -dOB4 -dOB8 -dz1r -dz2 -dz3 -dz3Z1 -dz3s*p -dz3O75 -dz4 -dz4$! -dz4i11 -d{ -d}D2 +c $ +c $! +c $! $1 +c $! $@ +c $! $@ $# +c $! d +c $! d ] +c $! o4a +c $" +c $# +c $# d +c $$ +c $$ d +c $& d +c $& d ] +c $) +c $* +c $* $* ^* ^* +c $* d +c $* d ] +c $+ +c $+ d +c $+ d ] +c $- +c $- d +c $- d ] +c $. +c $0 $0 +c $0 $0 $0 +c $0 $0 $1 +c $0 $0 $7 +c $0 $2 +c $0 $3 +c $0 $4 +c $0 $5 +c $0 $6 +c $0 $7 +c $0 $8 +c $0 $9 +c $0 $9 $8 +c $0 $9 $8 $7 +c $0 $9 $8 $7 $6 +c $0 $9 $8 $7 $6 $5 +c $0 d +c $0 d ] +c $1 $! +c $1 $0 +c $1 $1 +c $1 $1 $1 +c $1 $2 $3 $4 +c $1 $2 $3 $4 $5 +c $1 $2 $3 $4 $5 $6 +c $1 $2 $3 $a $b $c +c $1 $2 $a $b +c $1 $3 +c $1 $4 +c $1 $5 +c $1 $6 +c $1 $7 +c $1 $8 +c $1 $9 +c $1 $9 $6 $0 +c $1 $9 $6 $1 +c $1 $9 $6 $2 +c $1 $9 $6 $3 +c $1 $9 $6 $4 +c $1 $9 $6 $5 +c $1 $9 $6 $6 +c $1 $9 $6 $7 +c $1 $9 $6 $8 +c $1 $9 $6 $9 +c $1 $9 $7 $0 +c $1 $9 $7 $1 +c $1 $9 $7 $2 +c $1 $9 $7 $3 +c $1 $9 $7 $4 +c $1 $9 $7 $5 +c $1 $9 $7 $6 +c $1 $9 $7 $7 +c $1 $9 $7 $8 +c $1 $9 $7 $9 +c $1 $9 $8 $0 +c $1 $9 $8 $1 +c $1 $9 $8 $2 +c $1 $9 $8 $3 +c $1 $9 $8 $4 +c $1 $9 $8 $5 +c $1 $9 $8 $6 +c $1 $9 $8 $7 +c $1 $9 $8 $8 +c $1 $9 $8 $9 +c $1 $9 $9 $0 +c $1 $9 $9 $1 +c $1 $9 $9 $2 +c $1 $9 $9 $3 +c $1 $9 $9 $4 +c $1 $9 $9 $5 +c $1 $9 $9 $6 +c $1 $9 $9 $7 +c $1 $9 $9 $8 +c $1 $9 $9 $9 +c $1 $s $t +c $1 d +c $1 d ] +c $2 +c $2 $0 +c $2 $0 $0 $0 +c $2 $0 $0 $1 +c $2 $0 $0 $2 +c $2 $0 $0 $3 +c $2 $0 $0 $4 +c $2 $0 $0 $5 +c $2 $0 $0 $6 +c $2 $0 $0 $7 +c $2 $0 $0 $8 +c $2 $0 $0 $9 +c $2 $0 $1 $0 +c $2 $0 $1 $1 +c $2 $0 $1 $2 +c $2 $0 $1 $3 +c $2 $0 $1 $4 +c $2 $0 $1 $5 +c $2 $0 $1 $6 +c $2 $0 $1 $7 +c $2 $0 $1 $8 +c $2 $0 $1 $9 +c $2 $0 $2 $0 +c $2 $0 $2 $1 +c $2 $0 $2 $2 +c $2 $0 $2 $3 +c $2 $0 $2 $4 +c $2 $0 $2 $5 +c $2 $0 $2 $6 +c $2 $0 $2 $7 +c $2 $0 $2 $8 +c $2 $0 $2 $9 +c $2 $1 +c $2 $2 +c $2 $2 $2 +c $2 $3 +c $2 $3 $4 +c $2 $4 +c $2 $5 +c $2 $6 +c $2 $7 +c $2 $8 +c $2 $9 +c $2 $k +c $2 $m $e +c $2 $u +c $2 d +c $2 d ] +c $2 z3 +c $3 $0 +c $3 $1 +c $3 $2 +c $3 $2 $1 +c $3 $3 +c $3 $3 $3 +c $3 $4 +c $3 $4 $5 +c $3 $5 +c $3 $6 +c $3 $7 +c $3 $8 +c $3 $9 +c $3 d +c $3 d ] +c $4 +c $4 $0 +c $4 $1 +c $4 $2 +c $4 $3 +c $4 $3 $2 $1 +c $4 $4 +c $4 $4 $4 +c $4 $5 +c $4 $5 $6 +c $4 $6 +c $4 $7 +c $4 $8 +c $4 $9 +c $4 $M $e +c $4 $U +c $4 $a $l $l +c $4 $e $v $e $r +c $4 $f $r $e $e +c $4 $l $i $f $e +c $4 $m $e +c $4 $u +c $4 $u $s +c $4 d +c $4 d ] +c $5 +c $5 $0 +c $5 $1 +c $5 $2 +c $5 $3 +c $5 $4 +c $5 $4 $3 $2 $1 +c $5 $5 +c $5 $5 $5 +c $5 $6 +c $5 $6 $7 +c $5 $7 +c $5 $8 +c $5 $9 +c $5 d +c $6 $0 +c $6 $1 +c $6 $2 +c $6 $3 +c $6 $4 +c $6 $5 +c $6 $5 $4 $3 $2 $1 +c $6 $6 +c $6 $6 $6 +c $6 $7 +c $6 $7 $8 +c $6 $8 +c $6 $9 +c $6 d +c $6 d ] +c $7 +c $7 $0 +c $7 $1 +c $7 $2 +c $7 $3 +c $7 $4 +c $7 $5 +c $7 $6 +c $7 $7 +c $7 $7 $7 +c $7 $8 +c $7 $8 $9 +c $7 $9 +c $7 T3 +c $7 d +c $7 d ] +c $8 $0 +c $8 $1 +c $8 $2 +c $8 $3 +c $8 $4 +c $8 $5 +c $8 $6 +c $8 $7 +c $8 $8 +c $8 $8 $8 +c $8 $9 +c $8 d +c $8 d ] +c $9 +c $9 $0 +c $9 $1 +c $9 $2 +c $9 $3 +c $9 $4 +c $9 $5 +c $9 $6 +c $9 $7 +c $9 $8 +c $9 $9 +c $9 $9 $9 +c $9 d +c $9 d ] +c $: $) +c $; +c $? +c $A +c $D +c $G +c $H +c $I +c $L +c $M +c $N +c $R +c $U +c $X +c $Z +c $[ +c $^ +c $_ +c $_ d +c $_ d ] +c $a $b +c $a $b $c +c $e +c $k +c $l +c $m $e +c $v +c $x +c $x $x $x +c ${ +c '3 z5 +c '5 +c '7 Z1 +c '9 T3 +c 'B +c *21 +c *24 T0 +c *25 O13 +c *40 t +c *46 +c *52 +0 +c *58 +c *65 o65 +c *68 +c *70 +c *83 +c *8A +c *A8 O86 +c +0 +c +2 +c +3 +c +4 +c +5 +c +7 +c +7 L3 +c +A +c -0 $= +c -1 +c -2 +c -3 +c -3 '6 +c -4 +c -4 T4 +c -6 +c -7 +c -8 +c -9 +c -B +c @2 O14 +c @3 +c @A +c @b +c @f +c @f O23 +c @l O02 +c @m +c @q -5 +c D0 D8 +c D1 +c D4 +c D5 +c D5 @k +c D6 +c D7 +c D7 *05 +c DA +c DB +c K *14 +c K i1[ +c K p1 +c L0 +c L0 ^p +c L0 l +c L0 sl( +c L5 +c L7 +c L7 O05 +c R2 +c R3 +c R5 z3 +c R6 +c R6 C +c R7 +c T1 +c T1 $1 +c T1 T2 +c T1 T2 T3 +c T1 T2 T4 T5 +c T1 T2 T4 T5 T6 +c T1 d +c T1 f +c T1 i1& +c T1 i1+ +c T1 i1- +c T1 i1. i2E i3. +c T1 i1. i2F i3. +c T1 i1. i2O i3. +c T1 i1_ +c T2 +c T2 $1 +c T2 T4 +c T2 T4 T6 +c T2 T4 T6 T8 +c T2 T4 T6 T8 TA +c T2 T4 T6 T8 TA TC +c T2 d +c T2 f +c T2 i2& +c T2 i2+ +c T2 i2- +c T2 i2. +c T2 i2_ +c T3 $1 +c T3 d +c T3 f +c T3 i3& +c T3 i3+ +c T3 i3- +c T3 i3. +c T3 i3_ +c T4 $1 +c T4 d +c T4 i4& +c T4 i4+ +c T4 i4- +c T4 i4. +c T4 i4_ +c T5 $1 +c T5 +4 +c T5 i5& +c T5 i5+ +c T5 i5- +c T5 i5. +c T5 i5_ +c T6 $1 +c T6 +B +c T6 i6+ +c T6 i6- +c T6 i6_ +c T7 $1 +c T7 i7- +c T7 i7_ +c T8 +c T8 $1 +c T8 @s +c T8 i8+ +c T8 i8- +c T8 i8_ +c T9 +c T9 $1 +c T9 i9+ +c T9 i9- +c T9 i9. +c T9 i9_ +c TA +c TA $1 +c TA iA- +c TB +c TB $1 +c TB iB_ +c Z1 $6 +c Z1 O61 +c Z2 i32 +c Z3 O53 +c Z3 O83 +c [ +c [ K +c [ Z1 +c [ z3 +c ^ +c ^! +c ^! $! +c ^! ^1 +c ^! d +c ^" $" +c ^# +c ^# $# +c ^$ +c ^$ $$ +c ^$ ^$ +c ^& +c ^( +c ^( $) +c ^* +c ^* $# +c ^* $* +c ^* ^* +c ^* d +c ^+ +c ^+ $+ +c ^+ d +c ^- +c ^- $- +c ^. +c ^0 +c ^0 $0 +c ^0 ^0 +c ^0 ^0 ^0 ^2 +c ^0 ^1 +c ^0 ^1 ^0 ^2 +c ^0 ^2 +c ^0 ^3 +c ^0 ^4 +c ^0 ^5 +c ^0 ^6 +c ^0 ^6 ^9 ^1 +c ^0 ^7 +c ^0 ^7 ^9 ^1 +c ^0 ^8 +c ^0 ^8 ^9 ^1 +c ^0 ^9 +c ^0 ^9 ^9 ^1 +c ^1 +c ^1 $1 +c ^1 $2 +c ^1 ^! +c ^1 ^0 +c ^1 ^0 ^0 ^2 +c ^1 ^1 +c ^1 ^2 +c ^1 ^3 +c ^1 ^4 +c ^1 ^5 +c ^1 ^6 +c ^1 ^6 ^9 ^1 +c ^1 ^7 +c ^1 ^7 ^9 ^1 +c ^1 ^8 +c ^1 ^8 ^9 ^1 +c ^1 ^9 +c ^1 ^9 ^9 ^1 +c ^1 ^e ^h ^T +c ^1 ^e ^h ^t +c ^1 d +c ^2 +c ^2 $2 +c ^2 ^0 +c ^2 ^0 ^0 ^2 +c ^2 ^1 +c ^2 ^2 +c ^2 ^3 +c ^2 ^4 +c ^2 ^5 +c ^2 ^6 +c ^2 ^6 ^9 ^1 +c ^2 ^7 +c ^2 ^7 ^9 ^1 +c ^2 ^8 +c ^2 ^8 ^9 ^1 +c ^2 ^9 +c ^2 ^9 ^9 ^1 +c ^2 d +c ^3 +c ^3 $3 +c ^3 ^0 +c ^3 ^0 ^0 ^2 +c ^3 ^1 +c ^3 ^2 +c ^3 ^2 ^1 +c ^3 ^3 +c ^3 ^4 +c ^3 ^5 +c ^3 ^6 +c ^3 ^6 ^9 ^1 +c ^3 ^7 +c ^3 ^7 ^9 ^1 +c ^3 ^8 +c ^3 ^8 ^9 ^1 +c ^3 ^9 +c ^3 ^9 ^9 ^1 +c ^3 d +c ^4 +c ^4 $4 +c ^4 ^0 +c ^4 ^0 ^0 ^2 +c ^4 ^1 +c ^4 ^2 +c ^4 ^3 +c ^4 ^3 ^2 ^1 +c ^4 ^4 +c ^4 ^5 +c ^4 ^6 +c ^4 ^6 ^9 ^1 +c ^4 ^7 +c ^4 ^7 ^9 ^1 +c ^4 ^8 +c ^4 ^8 ^9 ^1 +c ^4 ^9 +c ^4 ^9 ^9 ^1 +c ^5 +c ^5 $5 +c ^5 ^0 +c ^5 ^0 ^0 ^2 +c ^5 ^1 +c ^5 ^2 +c ^5 ^3 +c ^5 ^4 +c ^5 ^4 ^3 ^2 ^1 +c ^5 ^5 +c ^5 ^6 +c ^5 ^6 ^9 ^1 +c ^5 ^7 +c ^5 ^7 ^9 ^1 +c ^5 ^8 +c ^5 ^8 ^9 ^1 +c ^5 ^9 +c ^5 ^9 ^9 ^1 +c ^5 d +c ^6 +c ^6 $6 +c ^6 ^0 +c ^6 ^0 ^0 ^2 +c ^6 ^1 +c ^6 ^2 +c ^6 ^3 +c ^6 ^4 +c ^6 ^5 +c ^6 ^5 ^4 ^3 ^2 ^1 +c ^6 ^6 +c ^6 ^6 ^9 ^1 +c ^6 ^7 +c ^6 ^7 ^9 ^1 +c ^6 ^8 +c ^6 ^8 ^9 ^1 +c ^6 ^9 +c ^6 ^9 ^9 ^1 +c ^6 d +c ^7 +c ^7 $7 +c ^7 ^0 +c ^7 ^0 ^0 ^2 +c ^7 ^1 +c ^7 ^2 +c ^7 ^3 +c ^7 ^4 +c ^7 ^5 +c ^7 ^6 +c ^7 ^6 ^9 ^1 +c ^7 ^7 +c ^7 ^7 ^9 ^1 +c ^7 ^8 +c ^7 ^8 ^9 ^1 +c ^7 ^9 +c ^7 ^9 ^9 ^1 +c ^8 +c ^8 $8 +c ^8 ^0 +c ^8 ^0 ^0 ^2 +c ^8 ^1 +c ^8 ^2 +c ^8 ^3 +c ^8 ^4 +c ^8 ^5 +c ^8 ^6 +c ^8 ^6 ^9 ^1 +c ^8 ^7 +c ^8 ^7 ^9 ^1 +c ^8 ^8 +c ^8 ^8 ^9 ^1 +c ^8 ^9 +c ^8 ^9 ^9 ^1 +c ^8 d +c ^9 +c ^9 $9 +c ^9 ^0 +c ^9 ^0 ^0 ^2 +c ^9 ^1 +c ^9 ^2 +c ^9 ^3 +c ^9 ^4 +c ^9 ^5 +c ^9 ^6 +c ^9 ^6 ^9 ^1 +c ^9 ^7 +c ^9 ^7 ^9 ^1 +c ^9 ^8 +c ^9 ^8 ^9 ^1 +c ^9 ^9 +c ^9 ^9 ^9 ^1 +c ^9 d +c ^; *4A +c ^< +c ^< $> +c ^= $= +c ^? +c ^@ +c ^@ $@ +c ^A +c ^B +c ^C +c ^D +c ^F +c ^G +c ^H +c ^I +c ^I T0 +c ^J +c ^K +c ^L +c ^M +c ^Q +c ^S +c ^V +c ^[ +c ^[ $] +c ^_ +c ^_ $_ +c ^` D4 +c ^a +c ^a f +c ^c ^R +c ^e ^h ^T +c ^e ^h ^t +c ^e ^v ^o ^l ^I +c ^e ^v ^o ^l ^i +c ^f +c ^k ^2 +c ^l +c ^l ^l ^a ^4 +c ^m ^a ^I +c ^m ^a ^i +c ^r } +c ^t ^s ^1 +c ^t z3 +c ^u +c ^y ^M +c ^y ^m +c ^y ^m ^4 +c ^z +c ^{ $} +c d +c i0: +c i0` +c i0r +c i1! +c i1# +c i1$ +c i1% +c i1& +c i1' +c i1* +c i1+ +c i1- +c i1. +c i10 +c i10 T2 +c i10 i31 +c i10 i31 i52 +c i10 i31 i52 i73 +c i11 +c i11 T2 +c i11 i31 +c i11 i31 i51 +c i11 i31 i51 i71 +c i11 i31 i51 i71 i91 +c i11 i31 i51 i71 i91 iB1 +c i11 i32 +c i11 i32 i53 +c i11 i32 i53 i74 +c i11 i32 i53 i74 i95 +c i11 i32 i53 i74 i95 iB6 +c i11 i32 i53 i74 i95 iB6 iD7 +c i12 +c i12 T2 +c i13 +c i13 T2 +c i14 +c i14 T2 +c i15 +c i15 T2 +c i16 +c i16 T2 +c i17 +c i17 T2 +c i18 +c i18 T2 +c i19 +c i19 T2 +c i1F +c i1R +c i1W +c i1_ +c i1a +c i1c +c i1e +c i1h +c i1i +c i1o +c i1u +c i2! +c i2# +c i2$ +c i2& +c i2' +c i2* +c i2+ +c i2- +c i2. +c i2/ +c i20 +c i20 T3 +c i21 +c i21 T3 +c i22 +c i22 T3 +c i23 +c i23 T3 +c i24 +c i24 T3 +c i25 +c i26 +c i26 T3 +c i27 +c i27 T3 +c i28 +c i28 T3 +c i29 +c i2_ +c i2a +c i2e +c i2o +c i2u +c i3 +c i3! +c i3" ^' +c i3# +c i3$ +c i3& +c i3' +c i3* +c i3+ +c i3- +c i3. +c i3/ +c i30 +c i30 T4 +c i31 +c i31 T4 +c i32 +c i32 T4 +c i33 +c i33 T4 +c i34 +c i34 T4 +c i35 +c i35 T4 +c i36 +c i36 T4 +c i37 +c i37 T4 +c i38 +c i38 T4 +c i39 +c i3: +c i3@ +c i3C +c i3H +c i3L +c i3_ +c i3a +c i3e +c i3i +c i3o +c i3u +c i4 +c i4! +c i4# +c i4$ +c i4& +c i4' +c i4* +c i4+ +c i4- +c i4. +c i40 +c i40 T5 +c i41 +c i41 T5 +c i42 +c i42 T5 +c i43 +c i43 T5 +c i44 +c i44 T5 +c i45 +c i45 T5 +c i46 +c i46 T5 +c i47 +c i47 T5 +c i48 +c i48 T5 +c i49 +c i49 T5 +c i4@ +c i4_ +c i4a +c i4b +c i4e +c i4j +c i4m +c i4o +c i4u +c i5 +c i5! +c i5# +c i5$ +c i5& +c i5' +c i5* +c i5+ +c i5, +c i5- +c i5. +c i5/ +c i50 +c i50 T6 +c i51 +c i51 T6 +c i52 +c i52 T6 +c i53 +c i53 T6 +c i54 +c i54 T6 +c i55 +c i55 T6 +c i56 +c i56 T6 +c i57 +c i57 T6 +c i58 +c i58 T6 +c i59 +c i59 T6 +c i5K +c i5M +c i5_ +c i5a +c i5e +c i5g +c i5o +c i5p +c i5r +c i5s +c i5u +c i6! +c i6# +c i6$ +c i6& +c i6' +c i6* +c i6+ +c i6- +c i6. +c i60 +c i61 +c i61 T7 +c i62 +c i62 T7 +c i63 +c i63 T7 +c i64 +c i64 T7 +c i65 +c i65 T7 +c i66 +c i66 T7 +c i67 +c i67 T7 +c i68 +c i69 +c i6@ +c i6C +c i6R +c i6W +c i6_ +c i6a +c i6b +c i6e +c i6h +c i6o +c i6u +c i7! +c i7# +c i7$ +c i7& +c i7' +c i7* +c i7+ +c i7- +c i7. +c i70 +c i71 +c i72 +c i73 +c i74 +c i75 +c i76 +c i77 +c i78 +c i79 +c i7@ +c i7_ +c i7a +c i7e +c i7o +c i7u +c i8 +c i8! +c i8# +c i8$ +c i8& +c i8* +c i8+ +c i8- +c i80 +c i81 +c i82 +c i83 +c i84 +c i85 +c i86 +c i87 +c i88 +c i89 +c i8_ +c i8a +c i8e +c i8i +c i8o +c i8r +c i8u +c iA2 +c k +c k *16 +l L4 +c o06 +c o0? +c o0k +c o0p +c o0r +c o0t +c o0v +c o0y +c o1! +c o1# +c o1$ +c o1* +c o1+ +c o1- +c o1. +c o10 +c o11 +c o12 +c o13 +c o14 +c o15 +c o16 +c o17 +c o18 +c o19 +c o1@ +c o1A +c o1T +c o1V +c o1_ +c o1a +c o1e +c o1l +c o1m +c o1v +c o1y +c o2! +c o2# +c o2$ +c o2& +c o2* +c o2+ +c o2- +c o20 +c o21 +c o22 +c o23 +c o24 +c o25 +c o26 +c o27 +c o28 +c o29 +c o2@ +c o2L +c o2_ +c o2n +c o2y +c o3! +c o3# +c o3$ +c o3% +c o3& +c o3* +c o3+ +c o3, +c o3- +c o30 +c o31 +c o32 +c o33 +c o34 +c o35 +c o36 +c o37 +c o38 +c o39 +c o3@ +c o3R +c o3S +c o3_ +c o3c +c o3m +c o4! +c o4# +c o4$ +c o4& +c o4* +c o4+ +c o4- +c o4. +c o40 +c o41 +c o42 +c o43 +c o44 +c o45 +c o46 +c o47 +c o48 +c o49 +c o4@ +c o4N +c o4O +c o4S +c o4V +c o4W +c o4_ +c o4l +c o4w +c o5! +c o5! O74 +c o5# +c o5$ +c o5& +c o5* +c o5+ +c o5- +c o5. +c o50 +c o51 +c o52 +c o53 +c o54 +c o55 +c o56 +c o57 +c o58 +c o59 +c o5@ +c o5F +c o5J +c o5W +c o5X +c o5_ +c o5a +c o6! +c o6# +c o6$ +c o6& +c o6* +c o6+ +c o6+ i1s +c o6- +c o6. +c o60 +c o61 +c o62 +c o63 +c o64 +c o65 +c o66 +c o67 +c o68 +c o69 +c o6@ +c o6M +c o6T +c o6W +c o6_ +c o6e +c o6o +c o6q +c o7! +c o7# +c o7$ +c o7& +c o7* +c o7+ +c o7- +c o7. +c o70 +c o71 +c o72 +c o73 +c o74 +c o75 +c o76 +c o77 +c o78 +c o79 +c o7? +c o7@ +c o7M +c o7S +c o7V +c o7_ +c o7e +c o7o +c o7r +c o8! +c o8# +c o8$ +c o8& +c o8* +c o8+ +c o8+ R7 +c o8- +c o8/ +c o80 +c o81 +c o82 +c o83 +c o84 +c o85 +c o86 +c o87 +c o88 +c o89 +c o8H +c o8S +c o8_ +c o8o +c o9! +c o9# +c o9$ +c o9* +c o9+ +c o9- +c o90 +c o91 +c o92 +c o93 +c o94 +c o95 +c o96 +c o97 +c o98 +c o99 +c o9V +c o9_ +c oA. O25 +c oA4 +c oA6 +c oAm +c p3 +c p3 '8 +c p4 +c p5 +c q +c r +c s$2 +c s0# +c s0I +c s0o Z5 +c s1, +c s10 +c s2* +c s2I +c s2m +c s4K +c s8! +c s87 O43 +c sGI +c sa4 +c sa4 $! +c sa4 d +c sa@ +c sa@ $! +c sa@ T4 +c sa@ T5 +c sa@ T6 +c sa@ d +c sa@ se3 +c sa@ se3 si1 +c sa@ se3 ss$ +c sa@ si! +c sa@ si1 +c sa@ si1 ss$ +c sa@ sl1 +c sa@ so0 +c sa@ so0 se3 +c sa@ so0 si! +c sa@ so0 si1 +c sa@ so0 ss$ +c sa@ ss$ +c saw +c sb1 +c sb5 $! +c sb8 +c sb8 $! +c sb8 d +c sd1 +c se3 +c se3 $! +c se3 T1 +c se3 T2 +c se3 T3 +c se3 T4 +c se3 T5 +c se3 T6 +c se3 T7 +c se3 d +c se3 si! +c se3 si! ss$ +c se3 si1 ss$ +c se3 sl1 +c se3 ss$ +c seu +c sex +c sg9 +c sg9 $! +c sgV +c si! +c si! $! +c si! T1 +c si! T2 +c si! T3 +c si! T4 +c si! T5 +c si! T6 +c si! sl1 +c si! ss$ +c si1 +c si1 $! +c si1 T1 +c si1 T2 +c si1 T3 +c si1 T4 +c si1 T5 +c si1 T6 +c si1 T7 +c si1 d +c si1 se3 +c si1 ss$ +c siU +c siZ +c siu +c sl1 +c sl1 $! +c sl1 T1 +c sl1 T2 +c sl1 T4 +c sl1 T5 +c sl1 T6 +c sl1 T7 +c sl1 d +c slt +c slz +c snj +c so& +c so* +c so0 +c so0 $! +c so0 T1 +c so0 T2 +c so0 T3 +c so0 T4 +c so0 T5 +c so0 T6 +c so0 T7 +c so0 d +c so0 sa4 +c so0 se3 +c so0 se3 si! +c so0 se3 si1 +c so0 se3 ss$ +c so0 si! +c so0 si! ss$ +c so0 si1 +c so0 si1 ss$ +c so0 sl1 +c so0 ss$ +c spv +c ss$ +c ss$ $! +c ss$ T1 +c ss$ T2 +c ss$ T3 +c ss$ T4 +c ss$ T5 +c ss$ T6 +c ss$ T7 +c ss$ d +c ss$ sl1 +c ss- L7 +c ss3 +c ss3 $! +c ss4 +c ss5 +c ss5 $! +c ss5 d +c ss5 se3 +c ssO +c st7 +c st7 $! +c stC +c su4 +c su4 $! +c su[ +c svz +c sx, R5 +c sy1 +c sy2 +u Z4 +c O02 +c O02 L1 +c O03 +c O08 +c O12 O28 +c O17 $O +c O23 +c O24 +c O25 +c O26 +c O28 +c O32 +c O35 +c O35 q +c O36 +c O38 +c O41 $" +c O43 +c O43 $7 +c O52 +c O53 +c O54 '7 +c O57 +c O64 +c O65 +c O84 +c O85 +c O92 +c OA1 O04 +c OA2 +c OB2 +c z1 +c z1 $0 +c z2 +c z2 $2 +c z2 $t +c z2 o9o +c z2 ssR +c z3 +c z3 K +c z3 ^K +c z3 O81 +c z4 +c z5 O18 +c z5 O1B +c { +c } +d $ +d $! +d $# +d $$ +d $& +d $* +d $+ +d $- +d $. +d $0 +d $1 +d $2 +d $3 +d $4 +d $5 +d $6 +d $7 +d $7 snb +d $8 +d $9 +d $= } +d $? o1( +d $@ +d $N *13 +d $P +d $Z +d $] +d $_ +d $a O7A +d $c +d $d *58 +d $g +d $h +d $k i31 +d $m +d $n +d $p +d $q +d $t +d $x D0 +d '6 L5 +d '8 *20 +d '8 i2, +d '9 +d 'A +d 'B +d *03 +d *04 '8 +d *05 +d *06 +d *09 +d *14 +d *15 O93 +d *16 +d *19 *08 +d *20 +d *26 +d *28 O13 +d *32 +d *32 Z1 +d *3A +d *45 +d *47 O58 +d *52 +d *52 R4 +d *53 +d *56 +d *57 +d *64 +d *68 +d *68 t +d *70 +d *71 +d *74 +d *7B O73 +d *81 O63 +d *83 O75 +d *87 +d *92 D2 +d *98 +d *A9 *53 +d +0 +d +1 +d +1 *70 +d +2 +d +3 +d +6 +d +6 t +d +7 +d +8 +d +B +d +B O67 +d -0 O92 +d -2 +d -3 ^ +d -3 O92 +d -4 +d -5 +d -6 +d -6 K +d -7 +d -A +d @3 +d @a +d @k +d @z t +d C O39 +d D1 c +d D2 ] +d D2 o4s +d D3 +d D4 ^; +d D4 o4w +d D5 [ +d D6 +d D6 t +d D7 +d K +d K { +d L2 +d L2 o8g +d L3 l +d R0 +d R3 i7Q +d R5 +d T0 O85 +d T1 +d T2 +d T4 D9 +d T5 +d T5 ^P +d Z1 +d Z1 D3 +d Z1 ^! +d Z2 -8 +d Z3 +d [ +d [ +1 +d [ ^? +d [ } +d ] so" +d ^$ +d ^% +d ^) +d ^0 +d ^1 +d ^4 +d ^5 +d ^6 +d ^7 q +d ^A -4 +d ^C +d ^C O14 +d ^T +d ^a k +d ^b +d ^c +d ^f +d ^s +d c +d c sh1 +d c O58 +d f O9A +d i0# +d i0m +d i0q +d i0z +d i2m +d i3 +d i3, O07 +d i3o +d i3s +d i4* +d i4, +d i44 [ +d i4b +d i4y +d i4z +d i5 +d i5, +d i5h D7 +d i5m +d i5n +d i5o +d i5p +d i5r +d i6b +d i6s +d i6x +d i7 +d i7a +d i7u +d i8_ +d k +d k c +d k o5- +d k O5A +d l +d l OB1 +d o0! +d o06 O21 +d o0: T1 +d o0E +d o0H +d o0L +d o0T +d o0c +d o0f +d o0n +d o0p +d o0t +d o0z +d o1C +d o1I +d o2G +d o2O +d o2U +d o2i +d o2i u +d o2o [ +d o2x +d o2| +d o3( +d o3_ +d o3b +d o3h +d o4@ +d o4m +d o4y +d o5b +d o5j +d o5n +d o5u +d o5v +d o5w +d o6b +d o6c +d o6t [ +d o6u +d o6y +d o79 z4 +d o7b c +d o7l +d o8i +d o8k +d o8o +d o93 +d o9i +d o9v O94 +d oBa +d oBm +d oBx +d r +d r O0B +d s04 +d s0f +d s1h +d s2q +d s34 O29 +d s5- +d s65 C +d s9y +d sam +d sbh +d sby +d seg +d sg0 +d sgd +d sgr +d sh6 +d sir +d sjl O14 +d skz +d slY +d smp +d spi +d sr3 +d srw +d stp +d svt +d sx/ +d t $Q +d u +d u *42 +d O02 +d O03 +d O04 +d O05 +d O06 +d O07 +d O09 +d O09 $e +d O12 +d O12 $q +d O13 +d O13 t +d O15 O63 +d O16 +d O17 +d O18 $A +d O21 +d O23 +d O24 +d O25 +d O26 +d O26 ^R +d O27 +d O28 +d O28 ^Y +d O29 +d O29 $z +d O29 C +d O29 o6| +d O32 +d O32 Z1 +d O32 o6y +d O34 +d O34 $m +d O34 p1 +d O34 O03 +d O36 +d O37 +d O37 k +d O37 O92 +d O38 +d O38 o0B +d O38 O64 +d O41 +d O42 +d O42 [ +d O43 +d O45 +d O45 $d +d O46 +d O46 z1 +d O48 +d O48 ^. +d O49 $L +d O51 O12 +d O52 +d O53 +d O54 +d O56 +d O62 +d O62 K +d O63 +d O63 c +d O69 +d O6A s2@ +d O72 +d O73 +d O74 +d O75 +d O76 +d O79 +d O7B s0k +d O81 +d O82 +d O83 +d O83 O51 +d O84 +d O85 +d O85 O34 +d O8A +d O94 +d O95 +d O96 +d O97 +d OA1 +d OA4 +d OA5 +d OA5 O52 +d OA6 +d OA6 *93 +d OA7 +d OB4 +d OB8 +d z1 r +d z2 +d z3 +d z3 Z1 +d z3 s*p +d z3 O75 +d z4 +d z4 $! +d z4 i11 +d { +d } D2 f -f$1 -f$8 -f$9 -f$F -f$P -f$V -f$a -f$d -f$e -f$ei1Z -f$f -f$go8n -f$gO76 -f$h+0 -f$l -f$m -f$n -f$no3X -f$r*01 -f$t -f$v -f$z -f'7 -f'7z4 -f'8 -f'8i5m -f'9 -f'9@l -f'9O61 -f'A -f'B -f*06O13 -f*15 -f*16 -f*20 -f*21 -f*24 -f*25] -f*31 -f*31$o -f*32$Y -f*36 -f*37 -f*51z1 -f*60 -f*67 -f*67f -f*69O6B -f*71 -f*75O54 -f*78 -f*79 -f*86 -f*94 -f*98O27 -f*9B -f*A5'8 -f+0O16 -f+0O29 -f+2 -f+4 -f+6 -f+7 -f+9 -f-4 -f-5 -f-7O7B -f@a -fC -fCL3 -fD1O58 -fD2 -fD3 -fD4 -fDB -fK -fKO69 -fL2 -fL3K -fL6K -fR4 -fR6iAA -fR8O29 -fT0O0A -fT4 -fT4D0 -fT6O75 -fT9O08 -fZ1 -fZ2 -fZ4*A3 -fZ5 -f[ -f[O59 -f[O75 -f] -f]*51 -f]O19 -f]O72 -f^5 -f^6O3A -f^8 -f^9 -f^T -f^c -f^h -f^m -f^n -f^o*06 -f^s -f^tO17 -f^x+4 -fc -fcD0 -fd -fi00 -fi01 -fi0v -fi3/ -fi3; -fi40 -fi41 -fi44 -fi5E -fi5n -fi60*35 -fi65 -fi6o -fi90 -fl -fo0l -fo1Q -fo1^ -fo21 -fo2e*53 -fo3P -fo4I -fo5) -fo5hk -fo68 -fr+5 -frD8 -fri4q -fs!g'7 -fs4k -fsnc -fss0 -fswv -fsy< -ft -fu[ -fO02 -fO03 -fO04 -fO05 -fO06 -fO08c -fO0Ad -fO13 -fO13$6 -fO14 -fO15 -fO16 -fO17*0A -fO18 -fO18*50 -fO18{ -fO19 -fO19$S -fO1A -fO23 -fO24 -fO25f -fO26 -fO27 -fO28 -fO2A -fO2B -fO31*31 -fO34 -fO34T0 -fO36 -fO36*25 -fO37 -fO38 -fO38T1 -fO39 -fO3A -fO3Ak -fO3B-2 -fO3Bi0b -fO42 -fO42*40 -fO42z3 -fO43 -fO45 -fO47 -fO47Z2 -fO48 -fO48D8 -fO48sh/ -fO49 -fO4AL5 -fO4B -fO51 -fO52 -fO53 -fO56 -fO57 -fO58 -fO59 -fO59o57 -fO5A -fO5AT0 -fO5Asts -fO5B -fO61 -fO61o3s -fO63 -fO64 -fO64L7 -fO65 -fO65t -fO67 -fO68 -fO69 -fO6A -fO6B -fO73 -fO74 -fO75 -fO75i7l -fO76 -fO78 -fO7A -fO7A+6 -fO7B -fO82 -fO83 -fO85 -fO86 -fO8Ao8a -fO8B -fO91 -fO93 -fO96 -fOA5 -fOA8 -fOB4 -fz1 -fz1'A -fz2 -fz2R1 -fz2O2A -f{ -f{*65 -f{[ -f} -f}O53 -i0 ^m -i0 l -i0 z2 -i0!o3t+0 -i0!O81 -i0$o3s -i0$O46 -i0$z3Z2 -i0'^U -i0($g^B -i0)i5Fo9z -i0)z2 -i0*$0 -i0+$Vo6k -i0+-0OA3 -i0+-3 -i0+O72O24 -i0,*62 -i0-D6 -i0.z3 -i0.} -i0/z5 -i00'4 -i00o6m -i00z2i2^ -i01$9 -i01'B -i01TA -i01Z2 -i01i8o -i01r -i01szt -i01z4z2 -i02$t -i02^l -i02z4 -i03K -i04'6 -i04^! -i04o5^ -i05D3 -i05^! -i05lO65 -i05O31T2 -i06i5t -i07D5 -i08O71 -i09+2 -i09cR4 -i09O15 -i09z3 -i09} -i0:o2" -i0;i2xl -i0;i5A -i0<$uo6( -i0Z4 -i0?$! -i0@*19l -i0@i3q -i0AO13 -i0D^q*14 -i0Dr -i0Dz3 -i0E$J -i0G*19 -i0G] -i0Gt -i0Gz1$5 -i0I+2 -i0IO53 -i0J$M -i0J$d -i0Ji3f -i0Ll -i0LO18d -i0LO23 -i0M$b -i0Mo0?su` -i0MO71 -i0N*56i3N -i0N^=^i -i0OD3 -i0O^L -i0O^esk> -i0PD2 -i0P^E -i0Po1w -i0Q$"o4^ -i0Q$7 -i0QO26 -i0QO61^2 -i0R^W -i0SD4 -i0T^Y -i0TO52 -i0U$5l -i0Uo4h -i0V$B -i0Vo6# -i0Z$; -i0Z^* -i0Zz1 -i0\$w -i0\p4 -i0]'4 -i0]o73^[ -i0^z2 -i0_s87 -i0`^Lo2I -i0`o8f -i0`r -i0a$r -i0a^K -i0ai7'*48 -i0ao6c -i0at -i0b*17 -i0bD5 -i0bZ1 -i0bsrs -i0b} -i0c*23 -i0c-6 -i0c-7 -i0co5m -i0cshk -i0cz3O31 -i0d$x -i0d+2i4' -i0dR6 -i0dZ3 -i0dZ3O18 -i0d^Y*52 -i0do1h -i0dz4 -i0e*21 -i0e*93O1B -i0e^h -i0esn_ -i0ez3 -i0f'8 -i0f-1 -i0fo15 -i0fq -i0fs9v -i0fz3O56 -i0g$r -i0g*12 -i0g*16 -i0g*70 -i0gz1 -i0h*15 -i0h*67 -i0h@5 -i0hZ2 -i0h^d -i0h^e -i0hsli -i0hO48 -i0j*56l -i0jo0G*57 -i0jz2 -i0k$e -i0k$o -i0k+4 -i0kD4 -i0k^g -i0lR6$M -i0lsv8 -i0m*02 -i0m*62 -i0m*70 -i0mi1V -i0n$so4+ -i0n'A -i0n*49c -i0n^k -i0n^zt -i0ni5Yo7E -i0nOB6O08 -i0o+7OA1 -i0o^N -i0p*80 -i0p+8 -i0qo3g -i0r$T*07 -i0rD6 -i0rl^z -i0rz4 -i0s$a -i0s@a -i0sZ2T8 -i0s^X -i0ss2y^p -i0t*50 -i0t+2 -i0tO04o2h -i0tz2 -i0u^c -i0v'9 -i0v*07 -i0vo4w -i0vr -i0w*30 -i0wl -i0wO23Z5 -i0wO81 -i0x*0AO09 -i0x^C*12 -i0xs9u -i0xz3i1? -i0y$0 -i0y$c -i0y@w -i0yr -i0zsiVl -i0zO04-8 -i0zz1 -i0{K -i0{u -i0|*52 -i0}'8 +f $1 +f $8 +f $9 +f $F +f $P +f $V +f $a +f $d +f $e +f $e i1Z +f $f +f $g o8n +f $g O76 +f $h +0 +f $l +f $m +f $n +f $n o3X +f $r *01 +f $t +f $v +f $z +f '7 +f '7 z4 +f '8 +f '8 i5m +f '9 +f '9 @l +f '9 O61 +f 'A +f 'B +f *06 O13 +f *15 +f *16 +f *20 +f *21 +f *24 +f *25 ] +f *31 +f *31 $o +f *32 $Y +f *36 +f *37 +f *51 z1 +f *60 +f *67 +f *67 f +f *69 O6B +f *71 +f *75 O54 +f *78 +f *79 +f *86 +f *94 +f *98 O27 +f *9B +f *A5 '8 +f +0 O16 +f +0 O29 +f +2 +f +4 +f +6 +f +7 +f +9 +f -4 +f -5 +f -7 O7B +f @a +f C +f C L3 +f D1 O58 +f D2 +f D3 +f D4 +f DB +f K +f K O69 +f L2 +f L3 K +f L6 K +f R4 +f R6 iAA +f R8 O29 +f T0 O0A +f T4 +f T4 D0 +f T6 O75 +f T9 O08 +f Z1 +f Z2 +f Z4 *A3 +f Z5 +f [ +f [ O59 +f [ O75 +f ] +f ] *51 +f ] O19 +f ] O72 +f ^5 +f ^6 O3A +f ^8 +f ^9 +f ^T +f ^c +f ^h +f ^m +f ^n +f ^o *06 +f ^s +f ^t O17 +f ^x +4 +f c +f c D0 +f d +f i00 +f i01 +f i0v +f i3/ +f i3; +f i40 +f i41 +f i44 +f i5E +f i5n +f i60 *35 +f i65 +f i6o +f i90 +f l +f o0l +f o1Q +f o1^ +f o21 +f o2e *53 +f o3P +f o4I +f o5) +f o5h k +f o68 +f +5 +f D8 +f i4q +f s!g '7 +f s4k +f snc +f ss0 +f swv +f sy< +f t +f u [ +f O02 +f O03 +f O04 +f O05 +f O06 +f O08 c +f O0A d +f O13 +f O13 $6 +f O14 +f O15 +f O16 +f O17 *0A +f O18 +f O18 *50 +f O18 { +f O19 +f O19 $S +f O1A +f O23 +f O24 +f O25 f +f O26 +f O27 +f O28 +f O2A +f O2B +f O31 *31 +f O34 +f O34 T0 +f O36 +f O36 *25 +f O37 +f O38 +f O38 T1 +f O39 +f O3A +f O3A k +f O3B -2 +f O3B i0b +f O42 +f O42 *40 +f O42 z3 +f O43 +f O45 +f O47 +f O47 Z2 +f O48 +f O48 D8 +f O48 sh/ +f O49 +f O4A L5 +f O4B +f O51 +f O52 +f O53 +f O56 +f O57 +f O58 +f O59 +f O59 o57 +f O5A +f O5A T0 +f O5A sts +f O5B +f O61 +f O61 o3s +f O63 +f O64 +f O64 L7 +f O65 +f O65 t +f O67 +f O68 +f O69 +f O6A +f O6B +f O73 +f O74 +f O75 +f O75 i7l +f O76 +f O78 +f O7A +f O7A +6 +f O7B +f O82 +f O83 +f O85 +f O86 +f O8A o8a +f O8B +f O91 +f O93 +f O96 +f OA5 +f OA8 +f OB4 +f z1 +f z1 'A +f z2 +f z2 R1 +f z2 O2A +f { +f { *65 +f { [ +f } +f } O53 +i0 ^m +i0 l +i0 z2 +i0! o3t +0 +i0! O81 +i0$ o3s +i0$ O46 +i0$ z3 Z2 +i0' ^U +i0( $g ^B +i0) i5F o9z +i0) z2 +i0* $0 +i0+ $V o6k +i0+ -0 OA3 +i0+ -3 +i0+ O72 O24 +i0, *62 +i0- D6 +i0. z3 +i0. } +i0/ z5 +i00 '4 +i00 o6m +i00 z2 i2^ +i01 $9 +i01 'B +i01 TA +i01 Z2 +i01 i8o +i01 r +i01 szt +i01 z4 z2 +i02 $t +i02 ^l +i02 z4 +i03 K +i04 '6 +i04 ^! +i04 o5^ +i05 D3 +i05 ^! +i05 l O65 +i05 O31 T2 +i06 i5t +i07 D5 +i08 O71 +i09 +2 +i09 c R4 +i09 O15 +i09 z3 +i09 } +i0: o2" +i0; i2x l +i0; i5A +i0< $u o6( +i0< Z2 +i0= $1 +i0= R3 d +i0= ^/ +i0= } +i0> Z4 +i0? $! +i0@ *19 l +i0@ i3q +i0A O13 +i0D ^q *14 +i0D r +i0D z3 +i0E $J +i0G *19 +i0G ] +i0G t +i0G z1 $5 +i0I +2 +i0I O53 +i0J $M +i0J $d +i0J i3f +i0L l +i0L O18 d +i0L O23 +i0M $b +i0M o0? su` +i0M O71 +i0N *56 i3N +i0N ^= ^i +i0O D3 +i0O ^L +i0O ^e sk> +i0P D2 +i0P ^E +i0P o1w +i0Q $" o4^ +i0Q $7 +i0Q O26 +i0Q O61 ^2 +i0R ^W +i0S D4 +i0T ^Y +i0T O52 +i0U $5 l +i0U o4h +i0V $B +i0V o6# +i0Z $; +i0Z ^* +i0Z z1 +i0\ $w +i0\ p4 +i0] '4 +i0] o73 ^[ +i0^ z2 +i0_ s87 +i0` ^L o2I +i0` o8f +i0` r +i0a $r +i0a ^K +i0a i7' *48 +i0a o6c +i0a t +i0b *17 +i0b D5 +i0b Z1 +i0b srs +i0b } +i0c *23 +i0c -6 +i0c -7 +i0c o5m +i0c shk +i0c z3 O31 +i0d $x +i0d +2 i4' +i0d R6 +i0d Z3 +i0d Z3 O18 +i0d ^Y *52 +i0d o1h +i0d z4 +i0e *21 +i0e *93 O1B +i0e ^h +i0e sn_ +i0e z3 +i0f '8 +i0f -1 +i0f o15 +i0f q +i0f s9v +i0f z3 O56 +i0g $r +i0g *12 +i0g *16 +i0g *70 +i0g z1 +i0h *15 +i0h *67 +i0h @5 +i0h Z2 +i0h ^d +i0h ^e +i0h sli +i0h O48 +i0j *56 l +i0j o0G *57 +i0j z2 +i0k $e +i0k $o +i0k +4 +i0k D4 +i0k ^g +i0l R6 $M +i0l sv8 +i0m *02 +i0m *62 +i0m *70 +i0m i1V +i0n $s o4+ +i0n 'A +i0n *49 c +i0n ^k +i0n ^z t +i0n i5Y o7E +i0n OB6 O08 +i0o +7 OA1 +i0o ^N +i0p *80 +i0p +8 +i0q o3g +i0r $T *07 +i0r D6 +i0r l ^z +i0r z4 +i0s $a +i0s @a +i0s Z2 T8 +i0s ^X +i0s s2y ^p +i0t *50 +i0t +2 +i0t O04 o2h +i0t z2 +i0u ^c +i0v '9 +i0v *07 +i0v o4w +i0v r +i0w *30 +i0w l +i0w O23 Z5 +i0w O81 +i0x *0A O09 +i0x ^C *12 +i0x s9u +i0x z3 i1? +i0y $0 +i0y $c +i0y @w +i0y r +i0z siV l +i0z O04 -8 +i0z z1 +i0{ K +i0{ u +i0| *52 +i0} '8 i1 -i1 C -i1 l +i1 C +i1 l i1! -i1!*17 -i1!Z1*42 +i1! *17 +i1! Z1 *42 i1# -i1#$h +i1# $h i1$ i1% -i1%i2U$g +i1% i2U $g i1& -i1&*46 -i1&r -i1&sso^= +i1& *46 +i1& r +i1& sso ^= i1' i1( i1* -i1*L9'6 -i1*O1Az5 +i1* '6 +i1* O1A z5 i1+ i1, i1- -i1-] -i1-d -i1-i3- -i1-i3-i5- -i1-i3-i5-i7- -i1-i3-i5-i7-i9- -i1-u -i1-O13p2 +i1- ] +i1- d +i1- i3- +i1- i3- i5- +i1- i3- i5- i7- +i1- i3- i5- i7- i9- +i1- u +i1- O13 p2 i1. -i1.i3. -i1.i3.$. -i1.i3.i5. -i1.i3.i5.$. -i1.i3.i5.i7. -i1.i3.i5.i7.$. -i1.i3.i5.i7.i9. -i1.i3.i5.i7.i9.$. -i1.sdO +i1. i3. +i1. i3. $. +i1. i3. i5. +i1. i3. i5. $. +i1. i3. i5. i7. +i1. i3. i5. i7. $. +i1. i3. i5. i7. i9. +i1. i3. i5. i7. i9. $. +i1. sdO i1/ i10 -i10d -i10i31 -i10i31i52 -i10i39 -i10r -i10z1 +i10 d +i10 i31 +i10 i31 i52 +i10 i39 +i10 r +i10 z1 i11 -i11*14r -i11+5 -i11-1^l -i11-3 -i11T2 -i11^i -i11i22 -i11i22i33 -i11i31 -i11i31i51 -i11i31i51i71 -i11i31i51i71i91 -i11i31i51i71i91iB1 -i11i32 -i11i32i53 -i11i32i53i74 -i11i32i53i74i95 -i11i32i53i74i95iB6 -i11i32i53i74i95iB6iD7 -i11s8T +i11 *14 r +i11 +5 +i11 -1 ^l +i11 -3 +i11 T2 +i11 ^i +i11 i22 +i11 i22 i33 +i11 i31 +i11 i31 i51 +i11 i31 i51 i71 +i11 i31 i51 i71 i91 +i11 i31 i51 i71 i91 iB1 +i11 i32 +i11 i32 i53 +i11 i32 i53 i74 +i11 i32 i53 i74 i95 +i11 i32 i53 i74 i95 iB6 +i11 i32 i53 i74 i95 iB6 iD7 +i11 s8T i12 -i12i0f -i12o62 -i12z3 +i12 i0f +i12 o62 +i12 z3 i13 -i13*46 -i13T2 -i13^Z -i13i24^2^1 -i13o1S +i13 *46 +i13 T2 +i13 ^Z +i13 i24 ^2 ^1 +i13 o1S i14 -i14T2 -i14^a -i14i23 -i14t +i14 T2 +i14 ^a +i14 i23 +i14 t i15 -i15$d -i15R2 -i15T2 -i15r -i15z1 +i15 $d +i15 R2 +i15 T2 +i15 r +i15 z1 i16 -i16R0'9 -i16T2 -i16o21 -i16o2z -i16z2} +i16 R0 '9 +i16 T2 +i16 o21 +i16 o2z +i16 z2 } i17 -i17$+ -i17$2 -i17C +i17 $+ +i17 $2 +i17 C i18 -i18T2 -i18Z2O35 -i18r +i18 T2 +i18 Z2 O35 +i18 r i19 -i19+3 -i19T2 -i19Z1 -i19suv -i19} +i19 +3 +i19 T2 +i19 Z1 +i19 suv +i19 } i1: -i1:*27 -i1:Z3o8A -i1:sjV +i1: *27 +i1: Z3 o8A +i1: sjV i1; -i1;R5k +i1; R5 k i1< -i1<*72$c -i1^r -i1>i3wo91 +i1> ^r +i1> i3w o91 i1? -i1?Z3 -i1?o7l -i1?z2 +i1? Z3 +i1? o7l +i1? z2 i1@ -i1@o5C +i1@ o5C i1B -i1B*18 +i1B *18 i1C -i1C{D2 +i1C { D2 i1D -i1DR0 -i1D{ -i1E^J -i1Eo8E -i1Er -i1Ez1 +i1D R0 +i1D { +i1E ^J +i1E o8E +i1E r +i1E z1 i1F i1G i1H -i1Hl -i1Ho9L +i1H l +i1H o9L i1I i1J -i1J$e*04 -i1J*78 +i1J $e *04 +i1J *78 i1K -i1Ko1/Z4 +i1K o1/ Z4 i1L -i1L*91'6 -i1LC -i1L^a -i1Lu[ +i1L *91 '6 +i1L C +i1L ^a +i1L u [ i1M -i1M+8R3 +i1M +8 R3 i1N -i1N[ -i1N^w -i1Ni30$6 -i1Nr +i1N ^w +i1N i30 $6 +i1N r i1O -i1O@d -i1Ot -i1OO28 -i1Oz2 +i1O @d +i1O t +i1O O28 +i1O z2 i1P -i1PZ1 -i1PuR3 -i1P{ +i1P Z1 +i1P u R3 +i1P { i1Q -i1Q-5k -i1Rl -i1SO62 +i1Q -5 k +i1R l +i1S O62 i1T -i1T^4 -i1Ti0v*24 +i1T ^4 +i1T i0v *24 i1U i1V i1W -i1W*27-1 +i1W *27 -1 i1X -i1XC -i1X{ +i1X C +i1X { i1Y -i1YL4 +i1Y L4 i1Z -i1Zi5%o7l -i1Zt +i1Z i5% o7l +i1Z t i1[ -i1\^lR6 +i1\ ^l R6 i1^ -i1^^zi5m -i1^i5]$e +i1^ ^z i5m +i1^ i5] $e i1_ -i1_} +i1_ } i1` -i1`$` -i1`^\*6A +i1` $` +i1` ^\ *6A i1a -i1a'5u -i1a*16 -i1a*37 -i1a*40 -i1ai7o -i1ao0H +i1a '5 u +i1a *16 +i1a *37 +i1a *40 +i1a i7o +i1a o0H i1b -i1b$s -i1b-2 -i1b-5 -i1b@G -i1b[^A -i1bi85O63 +i1b $s +i1b -2 +i1b -5 +i1b @G +i1b [ ^A +i1b i85 O63 i1c -i1c-6 -i1cq -i1c{ +i1c -6 +i1c q +i1c { i1d -i1d$y -i1d*65 -i1dZ1 -i1do3lz3 +i1d $y +i1d *65 +i1d Z1 +i1d o3l z3 i1e -i1eo3 +i1e o3 i1f -i1f-5 -i1fd -i1f} +i1f -5 +i1f d +i1f } i1g -i1g-0 -i1gi5, -i1gO42 -i1gz2 +i1g -0 +i1g i5, +i1g O42 +i1g z2 i1h -i1h^d -i1hp1 +i1h ^d +i1h p1 i1i -i1i*13 -i1i-6 -i1iR2 -i1i^`R6 -i1isry -i1iz3 +i1i *13 +i1i -6 +i1i R2 +i1i ^` R6 +i1i sry +i1i z3 i1j -i1j*23 -i1j+8 -i1jZ4 -i1j^a +i1j *23 +i1j +8 +i1j Z4 +i1j ^a i1k -i1k@b -i1kT6 -i1kZ1 +i1k @b +i1k T6 +i1k Z1 i1l -i1lO26O31 -i1l{ +i1l O26 O31 +i1l { i1m -i1m'5 -i1m*45 -i1mO12 -i1mO57 -i1mz4^P +i1m '5 +i1m *45 +i1m O12 +i1m O57 +i1m z4 ^P i1n -i1n$7 -i1no2k +i1n $7 +i1n o2k i1o -i1o*61i5N -i1o-4 -i1ossN -i1oO52 -i1oz5+7 +i1o *61 i5N +i1o -4 +i1o ssN +i1o O52 +i1o z5 +7 i1p -i1p*46 -i1p+6 +i1p *46 +i1p +6 i1q -i1q] -i1q{ +i1q ] +i1q { i1r -i1r$ -i1r-5 -i1ro70@c +i1r $ +i1r -5 +i1r o70 @c i1s -i1s*13 -i1so2lT6 +i1s *13 +i1s o2l T6 i1t -i1t$b -i1t-0 -i1to4e -i1tz2R5 +i1t $b +i1t -0 +i1t o4e +i1t z2 R5 i1u -i1u$ -i1uT4 -i1uZ3 -i1ul -i1uo3i -i1uOA1 +i1u $ +i1u T4 +i1u Z3 +i1u l +i1u o3i +i1u OA1 i1v -i1v*60 -i1v-4 -i1v^c +i2= *65 +i2= D3 O31 +i2= T4 ^@ +i2= ^k +i2> c i2? -i2?^^i6s -i2?{ +i2? ^^ i6s +i2? { i2@ -i2@'8 -i2@i2ac +i2@ '8 +i2@ i2a c i2A -i2AKi20 -i2A[{ -i2A^z +i2A K i20 +i2A [ { +i2A ^z i2B -i2Bu +i2B u i2C -i2CD0 -i2CZ3o5r -i2C^B -i2C{ +i2C D0 +i2C Z3 o5r +i2C ^B +i2C { i2D -i2D$4t -i2D*25c -i2D-4 +i2D $4 t +i2D *25 c +i2D -4 i2E -i2E*73 -i2El -i2F*37i3| -i2G$8O12 -i2GR6-5 +i2E *73 +i2E l +i2F *37 i3| +i2G $8 O12 +i2G R6 -5 i2H -i2Hu +i2H u i2I -i2J*35o8* +i2J *35 o8* i2L -i2L'5 -i2LC -i2LR7 -i2LZ2 +i2L '5 +i2L C +i2L R7 +i2L Z2 i2M -i2M$= +i2M $= i2N -i2N$jl +i2N $j l i2O -i2OZ2 -i2Ol -i2Or +i2O Z2 +i2O l +i2O r i2P -i2P*2A +i2P *2A i2R -i2Rc -i2Ri4YO36 +i2R c +i2R i4Y O36 i2S -i2S+1O51 -i2SZ2 -i2S[ +i2S +1 O51 +i2S Z2 +i2S [ i2T -i2T[ -i2Tl +i2T [ +i2T l i2U i2V -i2Vo5bl +i2V o5b l i2W -i2Xi0t$9 +i2X i0t $9 i2Y i2Z -i2Z^wk -i2Zo7l -i2Zu -i2[i2S -i2[l +i2Z ^w k +i2Z o7l +i2Z u +i2[ i2S +i2[ l i2\ -i2\^6k +i2\ ^6 k i2^ -i2^*51*86 +i2^ *51 *86 i2_ -i2_l +i2_ l i2` i2a -i2a*32 -i2a-4 -i2a-9 -i2aL6 -i2al -i2az3 +i2a *32 +i2a -4 +i2a -9 +i2a L6 +i2a l +i2a z3 i2b -i2bDA -i2bi2T -i2bO61 +i2b DA +i2b i2T +i2b O61 i2c -i2c*30 -i2cR4 -i2cO06ssD -i2cz1 +i2c *30 +i2c R4 +i2c O06 ssD +i2c z1 i2d -i2d'6 -i2d-1 -i2dR3 -i2dT4^2 -i2dz1 +i2d '6 +i2d -1 +i2d R3 +i2d T4 ^2 +i2d z1 i2e -i2e'7 -i2e-6 -i2e@y -i2eC -i2eT4 -i2eo7o -i2ez2 +i2e '7 +i2e -6 +i2e @y +i2e C +i2e T4 +i2e o7o +i2e z2 i2f -i2f$# -i2f$4 -i2fD5 -i2fo2i+4 -i2fsua +i2f $# +i2f $4 +i2f D5 +i2f o2i +4 +i2f sua i2g -i2g'B -i2gL1 -i2gr -i2gse +i2g 'B +i2g L1 +i2g r +i2g se i2h -i2h$3 -i2h*42 -i2h^# -i2hl -i2hz5 -i2h} +i2h $3 +i2h *42 +i2h ^# +i2h l +i2h z5 +i2h } i2i -i2i*68 -i2iL1 -i2iZ5*13 -i2io5v^z -i2isJp -i2iz4 -i2i{i5n +i2i *68 +i2i L1 +i2i Z5 *13 +i2i o5v ^z +i2i sJp +i2i z4 +i2i { i5n i2j -i2j$* -i2j*17z2 -i2j*23t -i2jK -i2jz2+0 +i2j $* +i2j *17 z2 +i2j *23 t +i2j K +i2j z2 +0 i2k -i2k'A -i2k+4 -i2k[ -i2ki0t -i2ki5n -i2kz4 -i2k} +i2k 'A +i2k +4 +i2k [ +i2k i0t +i2k i5n +i2k z4 +i2k } i2l -i2l'5 -i2l^)*38 -i2lu -i2lO61 +i2l '5 +i2l ^) *38 +i2l u +i2l O61 i2m -i2m'9 -i2mZ3 -i2md -i2mo3([ -i2mo76 -i2mO46o52 +i2m '9 +i2m Z3 +i2m d +i2m o3( [ +i2m o76 +i2m O46 o52 i2n -i2n[ -i2nk -i2nscf +i2n [ +i2n k +i2n scf i2o -i2oZ1 -i2oZ2 -i2oO01 -i2oO37 -i2oO45 -i2oz1 -i2oz3 -i2oz3D9 +i2o Z1 +i2o Z2 +i2o O01 +i2o O37 +i2o O45 +i2o z1 +i2o z3 +i2o z3 D9 i2p -i2p*53 -i2pD5 -i2p[ -i2pq +i2p *53 +i2p D5 +i2p [ +i2p q i2q -i2qR7i00 +i2q R7 i00 i2r -i2r$WZ1 -i2r*81O5B -i2rZ1 -i2rr -i2rt -i2rO01 -i2rz1 +i2r $W Z1 +i2r *81 O5B +i2r Z1 +i2r r +i2r t +i2r O01 +i2r z1 i2s -i2sZ1 -i2s] -i2ssr0 -i2sO02 -i2sO32 -i2sO54 +i2s Z1 +i2s ] +i2s sr0 +i2s O02 +i2s O32 +i2s O54 i2t -i2t'9 -i2t*05 -i2tiAXO59 -i2tscp -i2tz3*93 +i2t '9 +i2t *05 +i2t iAX O59 +i2t scp +i2t z3 *93 i2u -i2u$u -i2ul -i2usjc +i2u $u +i2u l +i2u sjc i2v -i2v*13 -i2v^\ -i2v^z} -i2vd -i2vu -i2vO01 -i2v} +i2v *13 +i2v ^\ +i2v ^z } +i2v d +i2v u +i2v O01 +i2v } i2w -i2w*03 -i2w+0^, -i2w@o -i2wT0 +i2w *03 +i2w +0 ^, +i2w @o +i2w T0 i2x -i2x^{ -i2xz4 +i2x ^{ +i2x z4 i2y -i2y*62 -i2yi3x -i2yl +i2y *62 +i2y i3x +i2y l i2z -i2zC -i2zL1 -i2zZ1 -i2zc -i2zO14o3U +i2z C +i2z L1 +i2z Z1 +i2z c +i2z O14 o3U i2| -i2|o2)+5 -i2}+3 -i2}+5z2 +i2| o2) +5 +i2} +3 +i2} +5 z2 i3 -i3 D0 -i3 T2 +i3 D0 +i3 T2 i3! -i3"R4 -i3"^u -i3"skr +i3" R4 +i3" ^u +i3" skr i3# -i3#k +i3# k i3$ -i3$o74 +i3$ o74 i3% -i3%'A -i3%C -i3%r -i3%O51 +i3% 'A +i3% C +i3% r +i3% O51 i3& -i3&[ +i3& [ i3' -i3'Z2 -i3'i6+ -i3't +i3' Z2 +i3' i6+ +i3' t i3( i3) -i3)*43 +i3) *43 i3* i3+ -i3+*42 -i3+r +i3+ *42 +i3+ r i3, -i3,{ +i3, { i3- -i3-[ -i3-r} -i3-snq -i3-u +i3- [ +i3- r } +i3- snq +i3- u i3. -i3.z2 +i3. z2 i3/ -i3/'8 -i3/*10r -i3/+4 -i3/o5H +i3/ '8 +i3/ *10 r +i3/ +4 +i3/ o5H i30 -i30z1 -i30z1*58 -i30z3l +i30 z1 +i30 z1 *58 +i30 z3 l i31 -i31T4 -i31^a -i31d -i31i42 -i31i42i53 -i31o0s -i31O91 +i31 T4 +i31 ^a +i31 d +i31 i42 +i31 i42 i53 +i31 o0s +i31 O91 i32 -i32*81 -i32T4 -i32Z1 -i32^' -i32O43 +i32 *81 +i32 T4 +i32 Z1 +i32 ^' +i32 O43 i33 -i33T4 -i33^7 -i33^H'4 -i33i40 -i33i44^2^1 -i33p1 -i33O67 +i33 T4 +i33 ^7 +^H '4 +i33 i40 +i33 i44 ^2 ^1 +i33 p1 +i33 O67 i34 -i34@t -i34T4 -i34[ +i34 @t +i34 T4 +i34 [ i35 -i35q +i35 q i36 -i36+2 +i36 +2 i37 -i37$v -i37T4 -i37O03 -i37z2O03 +i37 $v +i37 T4 +i37 O03 +i37 z2 O03 i38 -i38-4 -i38L0 -i38T4 +i38 -4 +i38 L0 +i38 T4 i39 -i39T4 -i39i59 -i39u^) -i39}^b +i39 T4 +i39 i59 +i39 u ^) +i39 } ^b i3: i3; -i3;$l -i3;'7 -i3;'8 +i3; $l +i3; '7 +i3; '8 i3< i3= -i3=CO42 -i3=O02 +i3= C O42 +i3= O02 i3> -i3>*20 -i3>ci2Z +i3> *20 +i3> c i2Z i3? -i3?+4Z1 -i3?o6+ -i3?t +i3? +4 Z1 +i3? o6+ +i3? t i3@ -i3@'8 -i3@*50 -i3@-0 -i3@t +i3@ '8 +i3@ *50 +i3@ -0 +i3@ t i3A -i3A$N -i3A'4 -i3A^W -i3BT6 -i3Bc -i3Bl +i3A $N +i3A '4 +i3A ^W +i3B T6 +i3B c +i3B l i3C -i3Cl -i3CuD2 -i3CO02T1 +i3C l +i3C u D2 +i3C O02 T1 i3D -i3DR5^3 -i3Dc -i3Dl] +i3D R5 ^3 +i3D c +i3D l ] i3E -i3Ei3' -i3Eu +i3E i3' +i3E u i3F -i3FZ2'5 +i3F Z2 '5 i3G -i3G-4 -i3G^] -i3G^hl +i3G -4 +i3G ^] +i3G ^h l i3H -i3Hi22 -i3Hl +i3H i22 +i3H l i3I -i3J*56{ -i3J-4^$ -i3KT0 -i3Klst1 -i3L$a*68 -i3LiA.O27 -i3Ll -i3Lr +i3J *56 { +i3J -4 ^$ +i3K T0 +i3K l st1 +i3L $a *68 +i3L iA. O27 +i3L l +i3L r i3M -i3Mo6,-0 -i3Mz3[ +i3M o6, -0 +i3M z3 [ i3N -i3O{ +i3O { i3P i3Q i3R -i3RR6i6m -i3Ri2? -i3Rt +i3R R6 i6m +i3R i2? +i3R t i3S -i3Si4& -i3Srl -i3TO43 +i3S i4& +i3S r l +i3T O43 i3U -i3UK +i3U K i3V i3W -i3W+0slV -i3W[ -i3Wl +i3W +0 slV +i3W [ +i3W l i3X i3Y -i3Y*30 -i3YD0 -i3Yi4_L0 -i3Yl -i3YO34 +i3Y *30 +i3Y D0 +i3Y i4_ L0 +i3Y l +i3Y O34 i3Z -i3Z^| +i3Z ^| i3[ -i3[*12 -i3[[ -i3[O12s73 +i3[ *12 +i3[ [ +i3[ O12 s73 i3\ -i3\'5 +i3\ '5 i3] -i3]*24oA: +i3] *24 oA: i3^ -i3^@s*04 -i3^O41 +i3^ @s *04 +i3^ O41 i3_ -i3_*46 -i3_+1 -i3_+5 -i3_@1 +i3_ *46 +i3_ +1 +i3_ +5 +i3_ @1 i3` i3a -i3a*35 -i3a-0R3 -i3aO02 +i3a *35 +i3a -0 R3 +i3a O02 i3b -i3bZ2 -i3bk -i3bu +i3b Z2 +i3b k +i3b u i3c -i3c$FO47 -i3c'6 -i3cT0 -i3cZ1 -i3ci1i -i3ci7U +i3c $F O47 +i3c '6 +i3c T0 +i3c Z1 +i3c i1i +i3c i7U i3d -i3d*63 -i3dL1 -i3do1r -i3dO43 +i3d *63 +i3d L1 +i3d o1r +i3d O43 i3e -i3e$3 -i3e$Z -i3e*53o2f -i3e*60 -i3eD5 -i3ei2s -i3eO43 +i3e $3 +i3e $Z +i3e *53 o2f +i3e *60 +i3e D5 +i3e i2s +i3e O43 i3f -i3f*50 -i3f-4 -i3f^!skT +i3f *50 +i3f -4 +i3f ^! skT i3g -i3g$x -i3g+7 -i3g-1 -i3gL6$t -i3gT6 -i3go98 -i3gO43 -i3g{ +i3g $x +i3g +7 +i3g -1 +i3g L6 $t +i3g T6 +i3g o98 +i3g O43 +i3g { i3h -i3h*03 -i3hZ1 -i3hZ3 -i3h[ -i3h^k -i3ht -i3hO12 -i3h} +i3h *03 +i3h Z1 +i3h Z3 +i3h [ +i3h ^k +i3h t +i3h O12 +i3h } i3i -i3i$x -i3i*12$y -i3iZ1 -i3i[ -i3ii0Y -i3ip1 -i3ir -i3iu -i3iz1 +i3i $x +i3i *12 $y +i3i Z1 +i3i [ +i3i i0Y +i3i p1 +i3i r +i3i u +i3i z1 i3j -i3jZ1 -i3jk -i3jl -i3jr[ +i3j Z1 +i3j k +i3j l +i3j r [ i3k -i3kz2$g +i3k z2 $g i3l -i3lL7 -i3lZ2 -i3l[ -i3l]$3 -i3l^z -i3lc -i3lO03 -i3lz1 +i3l L7 +i3l Z2 +i3l [ +i3l ] $3 +i3l ^z +i3l c +i3l O03 +i3l z1 i3m -i3m'9 -i3m*14 -i3m+2 -i3mD2o50 -i3mZ1 -i3ml -i3mt -i3mz5 +i3m '9 +i3m *14 +i3m +2 +i3m D2 o50 +i3m Z1 +i3m l +i3m t +i3m z5 i3n -i3nZ1 -i3n^T*51 -i3nc -i3nl -i3no4dD5 +i3n Z1 +i3n ^T *51 +i3n c +i3n l +i3n o4d D5 i3o -i3o$4 -i3o*20 -i3ou +i3o $4 +i3o *20 +i3o u i3p -i3p*03 -i3p^S -i3p^a -i3pz1 -i3p} +i3p *03 +i3p ^S +i3p ^a +i3p z1 +i3p } i3q -i3q-5 -i3q^#o1b -i3qi4d -i3qk -i3q{ +i3q -5 +i3q ^# o1b +i3q i4d +i3q k +i3q { i3r -i3r*59 -i3ri01 -i3ro6h -i3rsct -i3ru -i3rO41 +i3r *59 +i3r i01 +i3r o6h +i3r sct +i3r u +i3r O41 i3s -i3s*87 -i3s-1 -i3sZ2 -i3sk -i3sO35sDb -i3sO43 +i3s *87 +i3s -1 +i3s Z2 +i3s k +i3s O35 sDb +i3s O43 i3t -i3t*60 -i3t@c -i3tC -i3t[ -i3t^r -i3to0z+5 -i3to7n -i3tu +i3t *60 +i3t @c +i3t C +i3t [ +i3t ^r +i3t o0z +5 +i3t o7n +i3t u i3u -i3up1 -i3uq -i3ussV -i3uO63 +i3u p1 +i3u q +i3u ssV +i3u O63 i3v -i3vZ1 -i3vo2N +i3v Z1 +i3v o2N i3w -i3w*54 -i3wT1 -i3w^A -i3wc -i3wp1 +i3w *54 +i3w T1 +i3w ^A +i3w c +i3w p1 i3x -i3x@m -i3xZ4*02 -i3xd -i3xO46 +i3x @m +i3x Z4 *02 +i3x d +i3x O46 i3y -i3y*42 -i3yK -i3yO13o2D -i3yO51Z2 +i3y *42 +i3y K +i3y O13 o2D +i3y O51 Z2 i3z -i3z*56 -i3z*62 -i3zK -i3z^Z -i3zi5& -i3zr +i3z *56 +i3z *62 +i3z K +i3z ^Z +i3z i5& +i3z r i3{ -i3{*02 +i3{ *02 i3| -i3}i4j -i3}o7C +i3} i4j +i3} o7C i4 -i4 '6 -i4 *23 -i4 *37 -i4 +6 -i4 +7 -i4 -0 -i4 -6 -i4 D6 -i4 K} -i4 Z1 -i4 Z2 -i4 [ -i4 i7 -i4 r -i4 O12 -i4 { +i4 '6 +i4 *23 +i4 *37 +i4 +6 +i4 +7 +i4 -0 +i4 -6 +i4 D6 +i4 K } +i4 Z1 +i4 Z2 +i4 [ +i4 i7 +i4 r +i4 O12 +i4 { i4! -i4!{ -i4"*8AO45 +i4! { +i4" *8A O45 i4# -i4#$i*67 -i4#l +i4# $i *67 +i4# l i4$ -i4$+8 +i4$ +8 i4% -i4%+6 -i4%u +i4% +6 +i4% u i4& -i4&+7 -i4&Z2 -i4&^j -i4&l -i4&o7b -i4&s1J$o -i4&O03 +i4& +7 +i4& Z2 +i4& ^j +i4& l +i4& o7b +i4& s1J $o +i4& O03 i4' i4( -i4(^% +i4( ^% i4* i4+ -i4+'7 -i4+] +i4+ '7 +i4+ ] i4, -i4,[ -i4,s,k +i4, [ +i4, s,k i4- -i4-*30-8 -i4-^K -i4-o0e*13 -i4-O02 -i4-{^{ +i4- *30 -8 +i4- ^K +i4- o0e *13 +i4- O02 +i4- { ^{ i4. -i4.i5, -i4.t +i4. i5, +i4. t i4/ -i4/'A -i4/*37 -i4/[ -i4/t -i4/O12 +i4/ 'A +i4/ *37 +i4/ [ +i4/ t +i4/ O12 i40 -i40D6 -i40T5 -i40^k -i40z1 +i40 D6 +i40 T5 +i40 ^k +i40 z1 i41 -i41$2 -i41*04 -i41-7 -i41T5 -i41^-o7f -i41i2$ -i41i52 -i41i52i63 -i41r +i41 $2 +i41 *04 +i41 -7 +i41 T5 +i41 ^- o7f +i41 i2$ +i41 i52 +i41 i52 i63 +i41 r i42 -i42-7 -i42C -i42T5 -i42[ -i42^z -i42sky +i42 -7 +i42 C +i42 T5 +i42 [ +i42 ^z +i42 sky i43 -i43T5 -i43i54^2^1 -i43O57 -i43O73 -i43z1 +i43 T5 +i43 i54 ^2 ^1 +i43 O57 +i43 O73 +i43 z1 i44 -i44$h -i44*16 -i44L6*54 -i44T5 -i44sj\ -i44O15q +i44 $h +i44 *16 +i44 L6 *54 +i44 T5 +i44 sj\ +i44 O15 q i45 -i45T5 -i45o1x^3 -i45o58 -i45z2T2 +i45 T5 +i45 o1x ^3 +i45 o58 +i45 z2 T2 i46 -i46T5 -i46Z2 -i46i42 -i46i9c -i46s57t +i46 T5 +i46 Z2 +i46 i42 +i46 i9c +i46 s57 t i47 -i47*47 -i47*61z2 -i47D7 -i47T5 -i47o1g -i47t +i47 *47 +i47 *61 z2 +i47 D7 +i47 T5 +i47 o1g +i47 t i48 -i48L2 -i48^Lo6x -i48l -i48O68 -i48}$6 +i48 L2 +i48 ^L o6x +i48 l +i48 O68 +i48 } $6 i49 -i49T5 -i49d +i49 T5 +i49 d i4: -i4:c -i4:l +i4: c +i4: l i4; i4< i4= -i4=$5 -i4=*86 -i4=Z1 -i4=O15o0s +i4= $5 +i4= *86 +i4= Z1 +i4= O15 o0s i4> i4? -i4?*32O01 -i4?^% -i4?O2A +i4? *32 O01 +i4? ^% +i4? O2A i4@ -i4@-8 -i4@@7 -i4@[ -i4@o3n -i4@sL" +i4@ -8 +i4@ @7 +i4@ [ +i4@ o3n +i4@ sL" i4A -i4A$vt -i4At +i4A $v t +i4A t i4B -i4BD0 -i4Bt +i4B D0 +i4B t i4C -i4C*87'6 -i4Cz1 +i4C '6 +i4C z1 i4D i4E -i4E$1D6 -i4El +i4E $1 D6 +i4E l i4F i4G i4H -i4HcD3 +i4H c D3 i4I -i4J$a -i4JO02 +i4J $a +i4J O02 i4K -i4K$4 -i4K*63 +i4K $4 +i4K *63 i4L i4M -i4M$0 -i4M+0 -i4M^> +i4M $0 +i4M +0 +i4M ^> i4N -i4N*35 -i4No1A'9 -i4Nu -i4OD7 +i4N *35 +i4N o1A '9 +i4N u +i4O D7 i4P -i4P$3 -i4P*35L0 -i4Pc -i4Pl@v +i4P $3 +i4P *35 L0 +i4P c +i4P l @v i4Q i4R i4S -i4SO53 +i4S O53 i4T -i4U*29 +i4U *29 i4V i4W i4X -i4X^R+8 +i4X ^R +8 i4Y -i4Yu -i4Y{ +i4Y u +i4Y { i4[ -i4[-7 -i4[u} -i4[O04 -i4[O35 +i4[ -7 +i4[ u } +i4[ O04 +i4[ O35 i4\ -i4]*14 -i4]Z2 +i4] *14 +i4] Z2 i4^ -i4^i91O27 +i4^ i91 O27 i4_ -i4_'8 -i4_+5 -i4_Z1 -i4_O53 -i4_O54 -i4_O84 +i4_ '8 +i4_ +5 +i4_ Z1 +i4_ O53 +i4_ O54 +i4_ O84 i4` -i4`'AO32 -i4`[ +i4` 'A O32 +i4` [ i4a -i4a*36 -i4aD2 -i4a[ -i4au -i4aO52 +i4a *36 +i4a D2 +i4a [ +i4a u +i4a O52 i4b -i4b*45$x -i4bO04d -i4bO51 -i4bz1 +i4b *45 $x +i4b O04 d +i4b O51 +i4b z1 i4c -i4cc -i4cd -i4ck -i4cl +i4c c +i4c d +i4c k +i4c l i4d -i4d*04 -i4d^%o95 -i4dk -i4dz1 +i4d *04 +i4d ^% o95 +i4d k +i4d z1 i4e -i4e$a -i4e$r -i4e+3o5m -i4eZ3 -i4e^Dc -i4ei2W -i4ei52 -i4et -i4eO13 +i4e $a +i4e $r +i4e +3 o5m +i4e Z3 +i4e ^D c +i4e i2W +i4e i52 +i4e t +i4e O13 i4f -i4f$az3 -i4f$h -i4f'5 -i4f[ -i4fp1 +i4f $a z3 +i4f $h +i4f '5 +i4f [ +i4f p1 i4g -i4g$# -i4gl] -i4gr -i4g} +i4g $# +i4g l ] +i4g r +i4g } i4h -i4h*31 -i4h*45 -i4h+7 -i4h-0 -i4hD0 -i4ho2r -i4hsfK -i4h} +i4h *31 +i4h *45 +i4h +7 +i4h -0 +i4h D0 +i4h o2r +i4h sfK +i4h } i4i -i4i*64 -i4i+5 -i4i-8 -i4i-A -i4i[Z2 -i4i^>z3 -i4id +i4i *64 +i4i +5 +i4i -8 +i4i -A +i4i [ Z2 +i4i ^> z3 +i4i d i4j -i4j$!*80 -i4j*21 -i4j*57^[ -i4jK -i4jtT4 +i4j $! *80 +i4j *21 +i4j *57 ^[ +i4j K +i4j t T4 i4k -i4k$9 -i4k'6 -i4k'A -i4k*38Z1 -i4kD2 -i4kD5*36 -i4kZ1 -i4k[ -i4k^ -i4kO31z3 +i4k $9 +i4k '6 +i4k 'A +i4k *38 Z1 +i4k D2 +i4k D5 *36 +i4k Z1 +i4k [ +i4k ^ +i4k O31 z3 i4l -i4l'8 +i4l '8 i4m -i4m*90O29 -i4m-1 -i4m-3 -i4mi4V +i4m *90 O29 +i4m -1 +i4m -3 +i4m i4V i4n -i4n*58r -i4n*65 -i4nT0 -i4nZ3 -i4n^k -i4ni3go6n -i4nO91 +i4n *58 r +i4n *65 +i4n T0 +i4n Z3 +i4n ^k +i4n i3g o6n +i4n O91 i4o -i4o+8 -i4o-3 -i4o[ -i4ou -i4o} +i4o +8 +i4o -3 +i4o [ +i4o u +i4o } i4p -i4p$s -i4p*57 -i4p-1 -i4p{ +i4p $s +i4p *57 +i4p -1 +i4p { i4q -i4q*47 -i4qo5u -i4qr +i4q *47 +i4q o5u +i4q r i4r -i4rD6 -i4rR1 -i4r[ -i4ri0> -i4ro5f -i4ru -i4rO91 +i4r D6 +i4r R1 +i4r [ +i4r i0> +i4r o5f +i4r u +i4r O91 i4s -i4s-0 -i4s@b -i4s@h -i4sR6Z2 -i4s^: +i4s -0 +i4s @b +i4s @h +i4s R6 Z2 +i4s ^: i4t -i4t$g -i4t*04 -i4t+2 -i4t+6 -i4tD0 -i4td -i4t{*63 +i4t $g +i4t *04 +i4t +2 +i4t +6 +i4t D0 +i4t d +i4t { *63 i4u -i4u+0o0r -i4u+2 -i4uZ2 +i4u o0r +i4u +2 +i4u Z2 i4v -i4viAo -i4vs59o44 -i4vsk3 +i4v iAo +i4v s59 o44 +i4v sk3 i4w -i4w'9 -i4w-9 -i4w] -i4w]$y -i4wc^r -i4wl +i4w '9 +i4w -9 +i4w ] +i4w ] $y +i4w c ^r +i4w l i4x -i4x^+ -i4x} +i4x ^+ +i4x } i4y -i4y+3 -i4y^& -i4yc -i4yi3g+1 -i4yi6k+7 -i4yr -i4yO52 -i4yO64 +i4y +3 +i4y ^& +i4y c +i4y i3g +1 +i4y i6k +7 +i4y r +i4y O52 +i4y O64 i4z -i4z*64 +i4z *64 i4{ i4| -i4|-8 -i4}^%O35 -i4}i6u +i4| -8 +i4} ^% O35 +i4} i6u i5 -i5 $6 -i5 'A -i5 +6 -i5 -6 -i5 ^d -i5 i69 -i5 s5>O04 -i5 t -i5 {K +i5 $6 +i5 'A +i5 +6 +i5 -6 +i5 ^d +i5 i69 +i5 s5> O04 +i5 t +i5 { K i5! -i5!O32 +i5! O32 i5" -i5"*53 -i5"Z2*16 -i5"i5] +i5" *53 +i5" Z2 *16 +i5" i5] i5# -i5#$` -i5#l -i5#O13 +i5# $` +i5# l +i5# O13 i5$ -i5$@0 -i5$k -i5$lz3 -i5$r +i5$ @0 +i5$ k +i5$ l z3 +i5$ r i5% -i5%o61 +i5% o61 i5& i5' i5( i5) i5* -i5*$* -i5**04 -i5**73*76 +i5* $* +i5* *04 +i5* *73 *76 i5+ -i5+*34 -i5+l +i5+ *34 +i5+ l i5, -i5,o0/ +i5, o0/ i5- -i5-$3 -i5-'A -i5-*13L6 -i5--6 -i5-D0 -i5-D2 -i5-i2: +i5- $3 +i5- 'A +i5- *13 L6 +i5- -6 +i5- D0 +i5- D2 +i5- i2: i5. -i5.O03 +i5. O03 i5/ -i5/T6 +i5/ T6 i50 -i50$9 -i50$s -i50i4c -i50l +i50 $9 +i50 $s +i50 i4c +i50 l i51 -i51$8 -i51T6 -i51i62 -i51i62i73 -i51k -i51o4b +i51 $8 +i51 T6 +i51 i62 +i51 i62 i73 +i51 k +i51 o4b i52 -i52$A -i52$d -i52*16} -i52*30i3* -i52-2 -i52R2 -i52T6 -i52[ -i52k -i52O76 +i52 $A +i52 $d +i52 *16 } +i52 *30 i3* +i52 -2 +i52 R2 +i52 T6 +i52 [ +i52 k +i52 O76 i53 -i53*68 -i53*81 -i53T6 -i53i3f -i53i64^2^1 +i53 *68 +i53 *81 +i53 T6 +i53 i3f +i53 i64 ^2 ^1 i54 -i54'A -i54*31 -i54-6 -i54-8 -i54D1 -i54D8@s -i54T6 -i54l +i54 'A +i54 *31 +i54 -6 +i54 -8 +i54 D1 +i54 D8 @s +i54 T6 +i54 l i55 -i55*47 -i55+9 -i55@4 -i55T6 -i55r -i55u +i55 *47 +i55 +9 +i55 @4 +i55 T6 +i55 r +i55 u i56 -i56+6 -i56^_ -i56i55 -i56l +i56 +6 +i56 ^_ +i56 i55 +i56 l i57 -i57*60^\ -i57D8 -i57T6 -i57Z2 -i57k -i57o2C$7 +i57 *60 ^\ +i57 D8 +i57 T6 +i57 Z2 +i57 k +i57 o2C $7 i58 -i58T6 -i58[ -i58o1* -i58u -i58O23 -i58O71 +i58 T6 +i58 [ +i58 o1* +i58 u +i58 O23 +i58 O71 i59 -i59'8 -i59*02 -i59*54 -i59T6 -i59Z2 -i59l -i59O02 -i59O07^" +i59 '8 +i59 *02 +i59 *54 +i59 T6 +i59 Z2 +i59 l +i59 O02 +i59 O07 ^" i5: i5; -i5;^go87 +i5; ^g o87 i5< -i5^k -i5>O81O24 +i5> ^k +i5> O81 O24 i5? -i5?i2% +i5? i2% i5@ -i5@*02^I +i5@ *02 ^I i5A -i5A*16 -i5AtD1 -i5AO04 -i5AO32 +i5A *16 +i5A t D1 +i5A O04 +i5A O32 i5D -i5Dl +i5D l i5E -i5Eo1r +i5E o1r i5F i5G i5H i5I -i5Iu +i5I u i5J -i5Jc +i5J c i5K -i5KZ2 -i5Kt -i5KO64 +i5K Z2 +i5K t +i5K O64 i5L -i5Ll +i5L l i5M -i5M*02i6r -i5MT4 -i5Mri2i +i5M *02 i6r +i5M T4 +i5M r i2i i5N -i5N*30 -i5Nl +i5N *30 +i5N l i5O -i5O'8 +i5O '8 i5P -i5Pt +i5P t i5Q i5R -i5Ru -i5S*67 -i5Sl +i5R u +i5S *67 +i5S l i5T -i5T*85 -i5TD1 +i5T *85 +i5T D1 i5U -i5UO14[ -i5VR7 -i5Vi22 +i5U O14 [ +i5V R7 +i5V i22 i5W i5X i5Y -i5Y@aO24 +i5Y @a O24 i5Z -i5Z[ +i5Z [ i5[ -i5\o4I +i5\ o4I i5] i5^ -i5^-2 -i5^[ -i5^l +i5^ -2 +i5^ [ +i5^ l i5_ -i5_*97 -i5_[ -i5_] -i5_^u -i5_u -i5_O64 -i5_OB3'9 +i5_ *97 +i5_ [ +i5_ ] +i5_ ^u +i5_ u +i5_ O64 +i5_ '9 i5` -i5`{ +i5` { i5a -i5a'6 -i5a*04 -i5a*56 -i5ai24O76 -i5ai27 -i5ai6n -i5az1*36 +i5a '6 +i5a *04 +i5a *56 +i5a i24 O76 +i5a i27 +i5a i6n +i5a z1 *36 i5b i5c -i5c'7 -i5c*24 -i5cd -i5cs62 -i5c{ +i5c '7 +i5c *24 +i5c d +i5c s62 +i5c { i5d -i5d*05 -i5d[ -i5d^\ +i5d *05 +i5d [ +i5d ^\ i5e -i5e+0 -i5e-4i4c -i5eZ1 -i5ei8i -i5el -i5er -i5eO23 +i5e +0 +i5e -4 i4c +i5e Z1 +i5e i8i +i5e l +i5e r +i5e O23 i5f -i5f*03 -i5f-4 -i5fD1 -i5fr -i5fO13 +i5f *03 +i5f -4 +i5f D1 +i5f r +i5f O13 i5g -i5g@1 -i5gD6 -i5gT1 -i5gi8kO65 -i5go4a -i5gO01 -i5gz1i2{ -i5g{ +i5g @1 +i5g D6 +i5g T1 +i5g i8k O65 +i5g o4a +i5g O01 +i5g z1 i2{ +i5g { i5h -i5h*76 -i5h-8 -i5hT0 -i5hZ2O6A -i5h[ -i5hz2 +i5h *76 +i5h -8 +i5h T0 +i5h Z2 O6A +i5h [ +i5h z2 i5i -i5i$q -i5i+7 -i5i@s -i5iT0 -i5ii18^8 -i5io2Mi1S -i5i{ +i5i $q +i5i +7 +i5i @s +i5i T0 +i5i i18 ^8 +i5i o2M i1S +i5i { i5j -i5ju -i5jO13 -i5jO45 +i5j u +i5j O13 +i5j O45 i5k -i5k$2 -i5k@2 -i5ko6e +i5k $2 +i5k @2 +i5k o6e i5l -i5l-6 -i5li6A +i5l -6 +i5l i6A i5m -i5m*53 -i5m-0 -i5mZ1 -i5mO62 -i5mz1 +i5m *53 +i5m -0 +i5m Z1 +i5m O62 +i5m z1 i5n -i5n*76 -i5n+3 -i5nZ1 -i5n] -i5n^) -i5nO37z2 +i5n *76 +i5n +3 +i5n Z1 +i5n ] +i5n ^) +i5n O37 z2 i5o -i5oL4 -i5oZ2 -i5oi5E*74 -i5oO23 +i5o L4 +i5o Z2 +i5o i5E *74 +i5o O23 i5p -i5p^x -i5pk -i5pO05 -i5pO12 +i5p ^x +i5p k +i5p O05 +i5p O12 i5q -i5q'4-3 -i5q{ +'4 -3 +i5q { i5r -i5rD2 -i5ri3= -i5ri5? -i5rs9SO51 -i5rO23l +i5r D2 +i5r i3= +i5r i5? +i5r s9S O51 +i5r O23 l i5s -i5s*10 -i5s-4 -i5s^T -i5sO03 +i5s *10 +i5s -4 +i5s ^T +i5s O03 i5t -i5t[Z1 -i5tc +i5t [ Z1 +i5t c i5u -i5u$0 -i5u*57 -i5u*68 +i5u $0 +i5u *57 +i5u *68 i5v -i5vi1^ +i5v i1^ i5w -i5w*57 -i5w[ -i5wO72 +i5w *57 +i5w [ +i5w O72 i5x -i5x+2 -i5x@1 -i5xD3 -i5xl -i5xO32 +i5x +2 +i5x @1 +i5x D3 +i5x l +i5x O32 i5y -i5yi0r -i5yr +i5y i0r +i5y r i5z -i5zl -i5zO14 -i5zz1 -i5{+7 +i5z l +i5z O14 +i5z z1 +i5{ +7 i6 -i6 +8 -i6 T0 -i6 c +i6 +8 +i6 T0 +i6 c i6! -i6!CK +i6! C K i6" -i6"$j-8 +i6" $j -8 i6# i6$ i6% -i6%c -i6%O71 +i6% c +i6% O71 i6& i6' i6( i6* -i6*OB1 -i6*} +i6* OB1 +i6* } i6+ -i6+*56o62 -i6+O18O31 +i6+ *56 o62 +i6+ O18 O31 i6, -i6,O02 +i6, O02 i6- -i6-*78 -i6-Z1 -i6-i1" -i6-o3- +i6- *78 +i6- Z1 +i6- i1" +i6- o3- i6. -i6.O12 +i6. O12 i6/ i60 -i60*34 -i60*36 -i60*62 -i60Z1 -i60i2" -i60O05 -i60O13 -i60z1 +i60 *34 +i60 *36 +i60 *62 +i60 Z1 +i60 i2" +i60 O05 +i60 O13 +i60 z1 i61 -i61L3 -i61R1 -i61R4 -i61i3o -i61l +i61 L3 +i61 R1 +i61 R4 +i61 i3o +i61 l i62 -i62*27i2] -i62Z2 -i62[ -i62s2% +i62 *27 i2] +i62 Z2 +i62 [ +i62 s2% i63 -i63T1-4 -i63Z1 -i63t +i63 T1 -4 +i63 Z1 +i63 t i64 -i64R5 -i64] -i64} +i64 R5 +i64 ] +i64 } i65 -i65$6 -i65'9 -i65*06 -i65*52 -i65-8 -i65R5 -i65Z3 -i65o87 +i65 $6 +i65 '9 +i65 *06 +i65 *52 +i65 -8 +i65 R5 +i65 Z3 +i65 o87 i66 -i66'7 -i66+2l -i66o2RsH3 -i66O75 +i66 '7 +i66 +2 l +i66 o2R sH3 +i66 O75 i67 -i67*13 -i67*53 -i67Z1 -i67[ -i67O42 -i67O45 +i67 *13 +i67 *53 +i67 Z1 +i67 [ +i67 O42 +i67 O45 i68 -i68*68 -i68D8 -i68D8*54 -i68Z2 +i68 *68 +i68 D8 +i68 D8 *54 +i68 Z2 i69 -i69$r -i69$x -i69+7 -i69R5 -i69O32 -i69{ +i69 $r +i69 $x +i69 +7 +i69 R5 +i69 O32 +i69 { i6: -i6:*57 +i6: *57 i6; i6< i6= -i6=c +i6= c i6> -i6>o8. +i6> o8. i6? -i6?T7 +i6? T7 i6@ -i6@O02 +i6@ O02 i6A -i6AT0 -i6Au -i6Bi8PO72 +i6A T0 +i6A u +i6B i8P O72 i6D -i6D-5 -i6D^W -i6Dci0U -i6Do9. +i6D -5 +i6D ^W +i6D c i0U +i6D o9. i6E -i6E*64$k -i6ET4i1$ -i6FO02 +i6E *64 $k +i6E T4 i1$ +i6F O02 i6G i6H i6I -i6IO29$w +i6I O29 $w i6J i6K -i6KO13 +i6K O13 i6L -i6LuD1 +i6L u D1 i6M i6N -i6N$zO26 -i6Ni2b -i6Nri7r +i6N $z O26 +i6N i2b +i6N r i7r i6O i6P i6Q i6R i6S -i6S$$t -i6SO62T1 +i6S $$ t +i6S O62 T1 i6T i6U -i6U$isU -i6U*71 -i6UO16O35 -i6Vl +i6U $i sU +i6U *71 +i6U O16 O35 +i6V l i6X -i6Xt -i6Yt -i6ZL7 -i6Zo7= -i6Zu +i6X t +i6Y t +i6Z L7 +i6Z o7= +i6Z u i6[ -i6[*52o4s -i6[-2'5 -i6[O24 +i6[ *52 o4s +-2 '5 +i6[ O24 i6\ i6^ -i6^o7X +i6^ o7X i6_ -i6_+7 -i6_-7 -i6_D2 +i6_ +7 +i6_ -7 +i6_ D2 i6` -i6`*01 +i6` *01 i6a -i6a*85 -i6a+5 -i6al -i6aO02 -i6aO05 -i6az1 -i6az2^i +i6a *85 +i6a +5 +i6a l +i6a O02 +i6a O05 +i6a z1 +i6a z2 ^i i6b -i6b$oi3m -i6bO71 +i6b $o i3m +i6b O71 i6c -i6c*35 -i6cc +i6c *35 +i6c c i6d -i6d*60 -i6d-5 -i6dlO81 -i6do2c -i6d{ +i6d *60 +i6d -5 +i6d l O81 +i6d o2c +i6d { i6e -i6e[ -i6e] -i6el -i6eO94 +i6e [ +i6e ] +i6e l +i6e O94 i6f -i6f*64 -i6f*76 -i6fl +i6f *64 +i6f *76 +i6f l i6g -i6gD4 -i6g^K -i6gu -i6g} +i6g D4 +i6g ^K +i6g u +i6g } i6h -i6h'A -i6h+4 -i6hZ1 -i6hr -i6hO82 -i6hz2 +i6h 'A +i6h +4 +i6h Z1 +i6h r +i6h O82 +i6h z2 i6i -i6i$6 -i6i-3[ -i6il -i6is5c -i6isvt +i6i $6 +i6i -3 [ +i6i l +i6i s5c +i6i svt i6j -i6jo81 +i6j o81 i6k -i6k+7 -i6kD3 -i6kD4 -i6kT0 -i6k^* -i6klz1 +i6k +7 +i6k D3 +i6k D4 +i6k T0 +i6k ^* +i6k l z1 i6l -i6l*83 -i6li0Z -i6lo5] +i6l *83 +i6l i0Z +i6l o5] i6m -i6mZ1 -i6mO06 -i6mO76 +i6m Z1 +i6m O06 +i6m O76 i6n -i6nc -i6nl -i6no7j +i6n c +i6n l +i6n o7j i6o -i6oo1p -i6oO32 -i6oO91 +i6o o1p +i6o O32 +i6o O91 i6p -i6p-7 -i6p] -i6po74 -i6ps1! +i6p -7 +i6p ] +i6p o74 +i6p s1! i6q -i6qri6I -i6qO39T3 +i6q r i6I +i6q O39 T3 i6r -i6r$r -i6r-5 -i6rZ1 -i6rk +i6r $r +i6r -5 +i6r Z1 +i6r k i6s -i6s'8c -i6s'A -i6si4? -i6sO21 +i6s '8 c +i6s 'A +i6s i4? +i6s O21 i6t -i6tO36^d +i6t O36 ^d i6u -i6u*64 -i6u+5 -i6uD4 -i6ut -i6u}} +i6u *64 +i6u +5 +i6u D4 +i6u t +i6u } } i6v i6w -i6w$y -i6w[ +i6w $y +i6w [ i6x i6y -i6y-2 -i6y-8 -i6yC +i6y -2 +i6y -8 +i6y C i6z -i6zD4 -i6zc -i6zco5> -i6zi0s -i6zo5s -i6zO73 +i6z D4 +i6z c +i6z c o5> +i6z i0s +i6z o5s +i6z O73 i6| -i6}$rO49 -i6}O53i2K +i6} $r O49 +i6} O53 i2K i7 -i7 [ +i7 [ i7! i7" i7# i7$ i7% -i7%D3 +i7% D3 i7& i7' -i7'@1O09 +i7' @1 O09 i7* i7+ -i7,O25 +i7, O25 i7- -i7-u -i7-O43 +i7- u +i7- O43 i7. -i7.[ +i7. [ i7/ -i7/srX +i7/ srX i70 -i70T8 -i70t +i70 T8 +i70 t i71 -i71+8 -i71[ -i71O25 +i71 +8 +i71 [ +i71 O25 i72 -i72+6 -i72O45z3 +i72 +6 +i72 O45 z3 i73 -i73*79 -i73[[ -i73i49 -i73u[ +i73 *79 +i73 [ [ +i73 i49 +i73 u [ i74 -i74o3[ +i74 o3[ i75 -i75$4 -i75Z1 -i75l+1 -i75O43 -i75O91 +i75 $4 +i75 Z1 +i75 l +1 +i75 O43 +i75 O91 i76 -i76+9 -i76D5 -i76R8 +i76 +9 +i76 D5 +i76 R8 i77 -i77$3 +i77 $3 i78 i79 -i79O93 +i79 O93 i7; i7< -i7O56 +i7> O56 i7@ i7A -i7AO02 -i7AO15 -i7AO23 +i7A O02 +i7A O15 +i7A O23 i7C i7D -i7F'8T3 +i7F '8 T3 i7G -i7HO17^M +i7H O17 ^M i7K -i7Lc +i7L c i7M -i7M*37 -i7Ml -i7NZ1+1 -i7Nc +i7M *37 +i7M l +i7N Z1 +1 +i7N c i7P -i7Pc -i7QO14 +i7P c +i7Q O14 i7R i7S -i7SZ1 -i7Uu -i7V-6 +i7S Z1 +i7U u +i7V -6 i7X -i7Xt +i7X t i7Z i7[ i7\ i7_ -i7_D2 +i7_ D2 i7a -i7aL6 -i7aZ2 -i7aO01 -i7aO21 -i7a{ +i7a L6 +i7a Z2 +i7a O01 +i7a O21 +i7a { i7b i7c -i7c+1o46 -i7cc +i7c +1 o46 +i7c c i7d -i7d'6@2 -i7dO91 +'6 @2 +i7d O91 i7e -i7e-8 -i7eR9 -i7es17 +i7e -8 +i7e R9 +i7e s17 i7f -i7f[ -i7fc +i7f [ +i7f c i7g -i7gc -i7gi90 +i7g c +i7g i90 i7h -i7h$2 -i7h-9 -i7hi7{ -i7hl -i7hO25 +i7h $2 +i7h -9 +i7h i7{ +i7h l +i7h O25 i7i -i7i+3 -i7idO28 -i7iO34 +i7i +3 +i7i d O28 +i7i O34 i7j -i7jR9 -i7jl -i7jsjeu +i7j R9 +i7j l +i7j sje u i7k -i7k+8 -i7ki7u +i7k +8 +i7k i7u i7l -i7l'8 -i7lD2 -i7l^7 +i7l '8 +i7l D2 +i7l ^7 i7m -i7m+8 -i7mL8 -i7mO25 +i7m +8 +i7m L8 +i7m O25 i7n -i7n[ +i7n [ i7o -i7o*35 -i7oo0d +i7o *35 +i7o o0d i7p -i7p*70 -i7p[ -i7pO52 +i7p *70 +i7p [ +i7p O52 i7q -i7qt +i7q t i7r i7s -i7sR8 -i7sT0 -i7s^j -i7sl -i7sz1 +i7s R8 +i7s T0 +i7s ^j +i7s l +i7s z1 i7t -i7t$3 +i7t $3 i7u -i7u-8 -i7uO84 +i7u -8 +i7u O84 i7v -i7vo9n +i7v o9n i7w -i7wl -i7wO01 -i7wO34 -i7wO49 +i7w l +i7w O01 +i7w O34 +i7w O49 i7x -i7x+4*67 +i7x +4 *67 i7y -i7yi3d -i7yi5_^{ +i7y i3d +i7y i5_ ^{ i7z -i7z} -i7|^m +i7z } +i7| ^m i8 -i8 -9 -i8 Z1 -i8 O16 +i8 -9 +i8 Z1 +i8 O16 i8! i8# -i8#u +i8# u i8$ i8% -i8%$@O38 +i8% $@ O38 i8& -i8&D4*87 -i8&Z4O78 +i8& D4 *87 +i8& Z4 O78 i8' -i8)-9 +i8) -9 i8* -i8*s61 +i8* s61 i8+ -i8+i7I +i8+ i7I i8, i8- -i8-T0 -i8-p1'9 +i8- T0 +i8- p1 '9 i8. i8/ i80 -i80$4 -i80[ -i80[z1 -i80k -i80o6. -i80r +i80 $4 +i80 [ +i80 [ z1 +i80 k +i80 o6. +i80 r i81 -i81C'A +i81 C 'A i82 i83 -i83-7 +i83 -7 i84 -i84+7 -i84+A -i84^1O83 +i84 +7 +i84 +A +i84 ^1 O83 i85 -i85O23 -i85O53 +i85 O23 +i85 O53 i86 -i86o9,[ +i86 o9, [ i87 -i87O61 +i87 O61 i88 i89 -i89-9 -i89[ +i89 -9 +i89 [ i8; -i8;*37 +i8; *37 i8< i8= -i8=O53 +i8= O53 i8> -i8>z1 +i8> z1 i8? i8@ -i8@O16 -i8Cl +i8@ O16 +i8C l i8D -i8Dc -i8DiA-*86 +i8D c +i8D iA- *86 i8E i8F -i8Il -i8JD6 -i8MZ4O67 -i8MO53 +i8I l +i8J D6 +i8M Z4 O67 +i8M O53 i8P -i8QO57$t -i8Rl +i8Q O57 $t +i8R l i8U -i8UD4 +i8U D4 i8V -i8WD1O27 +i8W D1 O27 i8X -i8Zc +i8Z c i8[ i8_ -i8_Z1 -i8_l +i8_ Z1 +i8_ l i8a -i8a*18 -i8aD6 -i8aso3O71 -i8aO53 +i8a *18 +i8a D6 +i8a so3 O71 +i8a O53 i8c -i8c+1 +i8c +1 i8d i8e -i8e*45R8 +i8e *45 R8 i8f -i8fO05O21 +i8f O05 O21 i8g -i8gO05 +i8g O05 i8h -i8hD5 +i8h D5 i8i -i8iD6 +i8i D6 i8j i8k -i8k$1 -i8kD6 +i8k $1 +i8k D6 i8l -i8lO07 +i8l O07 i8m -i8mD0 +i8m D0 i8n -i8nO08O43 +i8n O08 O43 i8o -i8ol +i8o l i8p -i8po0/s9W +i8p o0/ s9W i8r i8s -i8s'9 -i8s+7 -i8so1o +i8s '9 +i8s +7 +i8s o1o i8t -i8t$0 -i8tc +i8t $0 +i8t c i8u -i8ul -i8vc -i8v{ +i8u l +i8v c +i8v { i8w i8x -i8x'9 -i8x*14O04 -i8xD9*32 +i8x '9 +i8x *14 O04 +i8x D9 *32 i8y -i8yc +i8y c i8z -i8z'9 -i8zr -i8zO05 -i8zO52 +i8z '9 +i8z r +i8z O05 +i8z O52 i9 i9# -i9'Z2O65 +i9' Z2 O65 i9, i9- i90 -i90c +i90 c i91 -i91T7R8 -i91l +i91 T7 R8 +i91 l i92 i93 -i93TB -i93O34 +i93 TB +i93 O34 i94 -i94[C -i94O42 +i94 [ C +i94 O42 i95 -i95i4|O0A -i95O71 -i96i7sO37 +i95 i4| O0A +i95 O71 +i96 i7s O37 i97 -i97$5 +i97 $5 i98 -i98s18 -i98O61 +i98 s18 +i98 O61 i99 -i99Z1[ -i99O01 -i99O43 +i99 Z1 [ +i99 O01 +i99 O43 i9; -i9=i0-O1A +i9= i0- O1A i9A -i9B$dO92 -i9Bll -i9Ec -i9FR9'A -i9Rl -i9Sl -i9Tl +i9B $d O92 +i9B l +i9E c +i9F R9 'A +i9R l +i9S l +i9T l i9_ i9a -i9aO61 -i9aOA4 +i9a O61 +i9a OA4 i9c -i9c*04 -i9cl +i9c *04 +i9c l i9d -i9dT0 +i9d T0 i9e -i9eO54 +i9e O54 i9f i9g i9h -i9hD6 +i9h D6 i9i -i9i'A +i9i 'A i9j -i9jOA3 +i9j OA3 i9k i9l -i9lD7 +i9l D7 i9m i9n i9o i9p -i9po6a'B +i9p o6a 'B i9q i9r -i9r-A -i9riAu +i9r -A +i9r iAu i9s -i9s'B -i9sO02 +i9s 'B +i9s O02 i9t i9u -i9u*13i9+ -i9wO35 +i9u *13 i9+ +i9w O35 i9x -i9x-A +i9x -A i9y iA -iA!O56 -iA&O47c -iA,O67 +iA! O56 +iA& O47 c +iA, O67 iA- -iA--B +iA- -B iA. -iA.O67O91 -iA/OA3 -iA/z2O37 +iA. O67 O91 +iA/ OA3 +iA/ z2 O37 iA0 iA1 iA2 iA3 iA4 -iA4+B +iA4 +B iA5 iA7 -iA7o95 +iA7 o95 iA8 iA9 iA: -iAE$rO57 -iAG$8OA3 -iA\*B1 +iAE $r O57 +iAG $8 OA3 +iA\ *B1 iA_ -iA_o4AO46 -iAcO78 +iA_ o4A O46 +iAc O78 iAe -iAel -iAeO72 +iAe l +iAe O72 iAg iAh iAi iAj -iAkO82 -iAnO64 +iAk O82 +iAn O64 iAo iAr iAs -iAsO28 +iAs O28 iAt -iAt$v'B +iAt $v 'B iAu iAx -iAxZ3O18 +iAx Z3 O18 iAy iAz -iAzO82 -iA}O86T8 -iB1O37 -iB2@9 -iB4O38 +iAz O82 +iA} O86 T8 +iB1 O37 +iB2 @9 +iB4 O38 iB5 iB9 iB_ iBa -iBaO74 +iBa O74 iBd iBe iBi -iBiR2O25 -iBiO16 -iBiO65 -iBrO46 +iBi R2 O25 +iBi O16 +iBi O65 +iBr O46 iBs -iBuO05 -iBxO65 -iBysi`O17 +iBu O05 +iBx O65 +iBy si` O17 k -k$! -k$) -k$1 -k$1i5t -k$8 -k$: -k$C -k$G -k$P -k$_ -k$b -k$c -k$d -k$e -k$h -k$hi4X -k$i -k$k -k$o -k$oZ1 -k$p -k$q -k$t -k$u -k$v -k$|Z2 -k'6 -k'6l -k'7 -k'9 -k*04l -k*04z3 -k*07 -k*13 -k*16 -k*17 -k*20 -k*34-1 -k*46 -k*51 -k*54 -k*54$9 -k*54R3 -k*57z2 -k*63 -k*B0 -k*B7 -k+0 -k+1f -k+2 -k+3 -k+4 -k+5 -k+5i2e -k-0 -k-5*13 -k-7[ -kD0o5r -kD2 -kD4 -kK*15 -kK^M -kK^P -kL2 -kR0i4y -kR1^= -kR1O41 -kR2 -kR3 -kR4 -kT5 -kZ1 -kZ1^4 -kZ1t -kZ2 -kZ2+2 -kZ3 -kZ3+A -k[r -k[sy6 -k[z3 -k^"$V -k^1$u -k^2 -k^5 -k^8 -k^A -k^G -k^H -k^J -k^K -k^T -k^X -k^Z -k^h -k^j -k^k -k^m -k^n -k^rt -k^s -k^t -k^u -k^w -k^z -kc -kd -kf -kfT4 -ki0C -ki0b -ki0r -ki1- -ki12 -ki13[ -ki16 -ki17 -ki1UZ2 -ki1Y -ki1e -ki1h -ki1m -ki1o -ki1s -ki2v -ki2z -ki3@*74 -ki3Q*62 -ki3f -ki3h -ki4' -ki40 -ki4v -ki4z -ki5\ -ki5^ -ki5i -ko0! -ko0: -ko0E -ko0c -ko0el -ko0k -ko0p] -ko0u -ko0z -ko1- -ko10 -ko16 -ko1a -ko1f -ko21 -ko29 -ko2O -ko2d -ko2g -ko2l -ko3- -ko31 -ko3_ -ko3h -ko3lf -ko4 -ko4k -ko4o^E -ko5g -ko65 -ko6f -ko6g -ko7m -ko85 -ko91 -ko92 -koA7 -kp1*13 -kp2O62 -kq -kqi15 -kr -kr$| -krR1 -krZ2 -ks2c -ks3H -ks52 -ks5b -ks8k -ksaj -ksbd -ksd3 -ksej -ksfpO71 -ksgd -ksir-2 -ksjt -ksmO -ksnb -ksrJ -kssL -kssy -ksuz -ksy$ -kt-3 -kuo9y -kO07 -kO07^1 -kO08sd; -kO13 -kO18 -kO23 -kO51 -kO62 -kz1 -kz1T0 -kz1l -kz1O51 -kz2 -kz2^7 -kz3 -kz3C -kz4 -kz4*97 -kz5D9 -kz5i9s -kz5O06 -k{ -k{$v -k{*48 -k{C -k{O51 -k}q -k}r -k}s9" +k $! +k $) +k $1 +k $1 i5t +k $8 +k $: +k $C +k $G +k $P +k $_ +k $b +k $c +k $d +k $e +k $h +k $h i4X +k $i +k $k +k $o +k $o Z1 +k $p +k $q +k $t +k $u +k $v +k $| Z2 +k '6 +k '6 l +k '7 +k '9 +k *04 l +k *04 z3 +k *07 +k *13 +k *16 +k *17 +k *20 +k *34 -1 +k *46 +k *51 +k *54 +k *54 $9 +k *54 R3 +k *57 z2 +k *63 +k *B0 +k *B7 +k +0 +k +1 f +k +2 +k +3 +k +4 +k +5 +k +5 i2e +k -0 +k -5 *13 +k -7 [ +k D0 o5r +k D2 +k D4 +k K *15 +k K ^M +k K ^P +k L2 +k R0 i4y +k R1 ^= +k R1 O41 +k R2 +k R3 +k R4 +k T5 +k Z1 +k Z1 ^4 +k Z1 t +k Z2 +k Z2 +2 +k Z3 +k Z3 +A +k [ r +k [ sy6 +k [ z3 +k ^" $V +k ^1 $u +k ^2 +k ^5 +k ^8 +k ^A +k ^G +k ^H +k ^J +k ^K +k ^T +k ^X +k ^Z +k ^h +k ^j +k ^k +k ^m +k ^n +k ^r t +k ^s +k ^t +k ^u +k ^w +k ^z +k c +k d +k f +k f T4 +k i0C +k i0b +k i0r +k i1- +k i12 +k i13 [ +k i16 +k i17 +k i1U Z2 +k i1Y +k i1e +k i1h +k i1m +k i1o +k i1s +k i2v +k i2z +k i3@ *74 +k i3Q *62 +k i3f +k i3h +k i4' +k i40 +k i4v +k i4z +k i5\ +k i5^ +k i5i +k o0! +k o0: +k o0E +k o0c +k o0e l +k o0k +k o0p ] +k o0u +k o0z +k o1- +k o10 +k o16 +k o1a +k o1f +k o21 +k o29 +k o2O +k o2d +k o2g +k o2l +k o3- +k o31 +k o3_ +k o3h +k o3l f +k o4 +k o4k +k o4o ^E +k o5g +k o65 +k o6f +k o6g +k o7m +k o85 +k o91 +k o92 +k oA7 +k p1 *13 +k p2 O62 +k q +k q i15 +k r +k r $| +k r R1 +k r Z2 +k s2c +k s3H +k s52 +k s5b +k s8k +k saj +k sbd +k sd3 +k sej +k sfp O71 +k sgd +k sir -2 +k sjt +k smO +k snb +k srJ +k ssL +k ssy +k suz +k sy$ +k t -3 +k u o9y +k O07 +k O07 ^1 +k O08 sd; +k O13 +k O18 +k O23 +k O51 +k O62 +k z1 +k z1 T0 +k z1 l +k z1 O51 +k z2 +k z2 ^7 +k z3 +k z3 C +k z4 +k z4 *97 +k z5 D9 +k z5 i9s +k z5 O06 +k { +k { $v +k { *48 +k { C +k { O51 +k } q +k } r +k } s9" l -l $1$2$3 -l $2$0$0$7 -l $2$0$0$8 -l $2$0$0$9 +l $1 $2 $3 +l $2 $0 $0 $7 +l $2 $0 $0 $8 +l $2 $0 $0 $9 l i3 l i3& l i3+ @@ -20825,4909 +20799,4895 @@ l i6- l i7 l i7+ l i7- -l$ -l$! -l$% -l$- -l$1f -l$3 -l$4 -l$6 -l$7 -l$8 -l$DZ1 -l$So7m -l$SO0A -l$[ -l$^$s -l$g*32 -l$ii6R -l$j -l$kO92 -l$l -l$o -l$q -l$u -l'8 -l*03 -l*13i53 -l*20 -l*23L4 -l*23spe -l*30*64 -l*35 -l*37 -l*41 -l*5B -l*63K -l*68o6y -l*74 -l*75 -l*79 -l*86 -l*87 -l*92 -l*98 -l*B9 -l+0 -l+0i5t -l+1 -l+1[ -l+2 -l+2^L -l+3 -l+3$K -l+3'7 -l+3-6 -l+4 -l+4*30 -l+5 -l+6 -l+6$j -l+9 -l+AO45 -l+B -l-1 -l-2 -l-2^` -l-2s?9 -l-3@m -l-4 -l-5 -l-5*24 -l-7 -l-8 -l-A -l-B -l@9 -l@c -l@h -l@mD7 -l@n -l@v -l@x -lD1$_ -lD3L5 -lD4 -lD5i7x -lD6 -lD8 -lL1 -lL1T3 -lL2 -lL2i2m -lL5 -lL7 -lLB -lR0 -lR1 -lR3 -lR6 -lR6Z2 -lR8 -lT1 -lT2 -lT3 -lT4 -lT5 -lT5i1p -lT6 -lT7 -lT8 -lT9+B -lZ1 -lZ1$y -lZ1o4| -lZ1O5B -lZ2i6z -lZ2st3 -lZ2O83 -lZ5 -lZ5O57 -l[d -l[i5q -l]d -l]z3 -l^! -l^'z3 -l^4 -l^5o41 -l^D -l^Ei66 -l^M -l^QD5 -l^R -l^Ui0` -l^W -l^_O58 -l^aZ2 -l^b -l^c -l^e^N -l^h -l^hz2 -l^m -l^oz1 -l^v^8 -l^y -l^zO91 -l^}K -ld$o -ldstC -lfsns -lfO1B -lfO46 -li0$ -li05z5 -li09o6P -li0S -li0d -li13 -li15 -li1: -li1Q -li1_ -li1b -li1n -li2% -li2p -li3/ -li37z2 -li3a -li3k -li3r -li42 -li4; -li4_ -li4d'9 -li4h -li4n -li51 -li58 -li5t -li5u -li5zD7 -li6%+9 -li6' -li6/ -li60 -li67 -li6: -li6dO26 -li6j -li6p -li6t -li70 -li7S[ -li7e -li7k -li7v -li8 -li8a -li8t -li94 -liAb -lk -lo01O82 -lo0C -lo0E$a -lo0L -lo0c -lo0d -lo0e -lo0i -lo0v^q -lo0z -lo19 -lo1@ -lo1V -lo1a -lo1b -lo1e -lo1i -lo21 -lo2a -lo2j -lo2o -lo2t -lo3_ -lo3c -lo3e -lo3l -lo3pu -lo3w+1 -lo42 -lo4a -lo4b -lo4g -lo4v -lo4z -lo5, -lo5- -lo5; -lo5< -lo5K$) -lo5f -lo5i -lo5n -lo5u^4 -lo6 -lo6- -lo63 -lo66 -lo68 -lo69 -lo6` -lo6g -lo6i -lo6k -lo7- -lo74 -lo7K -lo7R -lo7` -lo7e -lo7f -lo85 -lo89 -lo8d -lo8e -lo9e -lo9i -loA9 -loAf -loAk -loB1 -loBF -lp2z2 -lp3 -lq -lqZ3 -lqsaT -lr -lr^+ -lrz4 -ls#j -ls$8 -ls0j$9 -ls12 -ls1a -ls4+ -ls5d -ls6- -ls6p -ls70 -ls8p -lsdk -lseSo3e -lsgc -lsgj -lshj -lslh -lsmK -lsmb[ -lso1 -lsp1 -lsr[ -lss& -lss[$] -lssd -lssf -lssi -lsuy -lsys -lsz2 -lui5C -luO03 -luOB2 -lO05 -lO06 -lO07 -lO12 -lO13 -lO14 -lO15 -lO21i31 -lO23 -lO23$N -lO23z2 -lO24 -lO24$8 -lO26 -lO27 -lO35-5 -lO35R1 -lO38 -lO3A^k -lO42 -lO43 -lO47 -lO48 -lO52 -lO53 -lO56 -lO56i5M -lO57 -lO58 -lO61o0H -lO61o8e -lO63 -lO69 -lO72 -lO75 -lO76 -lO78 -lO83D9 -lO8B -lO92 -lO95 -lOA3 -lz1 -lz2 -lz2$5 -lz2*14 -lz3o6F -lz4 -lz5 -lz5@7 -l{ -l{*02 -l{*15 -l} -l}-1 -l}Z2 -l}^K +l $ +l $! +l $% +l $- +l $1 f +l $3 +l $4 +l $6 +l $7 +l $8 +l $D Z1 +l $S o7m +l $S O0A +l $[ +l $^ $s +l $g *32 +l $i i6R +l $j +l $k O92 +l $l +l $o +l $q +l $u +l '8 +l *03 +l *13 i53 +l *20 +l *23 L4 +l *23 spe +l *30 *64 +l *35 +l *37 +l *41 +l *5B +l *63 K +l *68 o6y +l *74 +l *75 +l *79 +l *86 +l *87 +l *92 +l *98 +l *B9 +l +0 +l +0 i5t +l +1 +l +1 [ +l +2 +l +2 ^L +l +3 +l +3 $K +l +3 '7 +l +3 -6 +l +4 +l +4 *30 +l +5 +l +6 +l +6 $j +l +9 +l +A O45 +l +B +l -1 +l -2 +l -2 ^` +l -2 s?9 +l -3 @m +l -4 +l -5 +l -5 *24 +l -7 +l -8 +l -A +l -B +l @9 +l @c +l @h +l @m D7 +l @n +l @v +l @x +l D1 $_ +l D3 L5 +l D4 +l D5 i7x +l D6 +l D8 +l L1 +l L1 T3 +l L2 +l L2 i2m +l L5 +l L7 +l LB +l R0 +l R1 +l R3 +l R6 +l R6 Z2 +l R8 +l T1 +l T2 +l T3 +l T4 +l T5 +l T5 i1p +l T6 +l T7 +l T8 +l T9 +B +l Z1 +l Z1 $y +l Z1 o4| +l Z1 O5B +l Z2 i6z +l Z2 st3 +l Z2 O83 +l Z5 +l Z5 O57 +l [ d +l [ i5q +l ] d +l ] z3 +l ^! +l ^' z3 +l ^4 +l ^5 o41 +l ^D +l ^E i66 +l ^M +l ^Q D5 +l ^R +l ^U i0` +l ^W +l ^_ O58 +l ^a Z2 +l ^b +l ^c +l ^e ^N +l ^h +l ^h z2 +l ^m +l ^o z1 +l ^v ^8 +l ^y +l ^z O91 +l ^} K +l d $o +l d stC +l f sns +l f O1B +l f O46 +l i0$ +l i05 z5 +l i09 o6P +l i0S +l i0d +l i13 +l i15 +l i1: +l i1Q +l i1_ +l i1b +l i1n +l i2% +l i2p +l i3/ +l i37 z2 +l i3a +l i3k +l i3r +l i42 +l i4; +l i4_ +l i4d '9 +l i4h +l i4n +l i51 +l i58 +l i5t +l i5u +l i5z D7 +l i6% +9 +l i6' +l i6/ +l i60 +l i67 +l i6: +l i6d O26 +l i6j +l i6p +l i6t +l i70 +l i7S [ +l i7e +l i7k +l i7v +l i8 +l i8a +l i8t +l i94 +l iAb +l k +l o01 O82 +l o0C +l o0E $a +l o0L +l o0c +l o0d +l o0e +l o0i +l o0v ^q +l o0z +l o19 +l o1@ +l o1V +l o1a +l o1b +l o1e +l o1i +l o21 +l o2a +l o2j +l o2o +l o2t +l o3_ +l o3c +l o3e +l o3l +o3p u +l o3w +1 +l o42 +l o4a +l o4b +l o4g +l o4v +l o4z +l o5, +l o5- +l o5; +l o5< +l o5K $) +l o5f +l o5i +l o5n +l o5u ^4 +l o6 +l o6- +l o63 +l o66 +l o68 +l o69 +l o6` +l o6g +l o6i +l o6k +l o7- +l o74 +l o7K +l o7R +l o7` +l o7e +l o7f +l o85 +l o89 +l o8d +l o8e +l o9e +l o9i +l oA9 +l oAf +l oAk +l oB1 +l oBF +l p2 z2 +l p3 +l q +l q Z3 +l q saT +l r +l r ^+ +l r z4 +l s#j +l s$8 +l s0j $9 +l s12 +l s1a +l s4+ +l s5d +l s6- +l s6p +l s70 +l s8p +l sdk +l seS o3e +l sgc +l sgj +l shj +l slh +l smK +l smb [ +l so1 +l sp1 +l sr[ +l ss& +l ss[ $] +l ssd +l ssf +l ssi +l suy +l sys +l sz2 +u i5C +u O03 +u OB2 +l O05 +l O06 +l O07 +l O12 +l O13 +l O14 +l O15 +l O21 i31 +l O23 +l O23 $N +l O23 z2 +l O24 +l O24 $8 +l O26 +l O27 +l O35 -5 +l O35 R1 +l O38 +l O3A ^k +l O42 +l O43 +l O47 +l O48 +l O52 +l O53 +l O56 +l O56 i5M +l O57 +l O58 +l O61 o0H +l O61 o8e +l O63 +l O69 +l O72 +l O75 +l O76 +l O78 +l O83 D9 +l O8B +l O92 +l O95 +l OA3 +l z1 +l z2 +l z2 $5 +l z2 *14 +l z3 o6F +l z4 +l z5 +l z5 @7 +l { +l { *02 +l { *15 +l } +l } -1 +l } Z2 +l } ^K o0 -o0 Z5 +o0 Z5 o0! -o0!*A9@R -o0!o2^o25 -o0!O34 -o0!z1 +o0! *A9 @R +o0! o25 +o0! O34 +o0! z1 o0# o0$ -o0$*54 -o0$+2 -o0% -o0%$eq -o0& -o0&'6 -o0&-5 -o0'r -o0('7 -o0(-7 -o0({ -o0)+1z2 +o0$ *54 +o0$ +2 +o0% $e q +o0& '6 +o0& -5 +o0' r +o0( '7 +o0( -7 +o0( { +o0) +1 z2 o0* -o0*D2 -o0*z5 +o0* D2 +o0* z5 o0+ o0, -o0,cO02 -o0,p1 -o0- -o0-'9^L -o0-D1 -o0-R1 -o0-} +o0, c O02 +o0, p1 +o0- '9 ^L +o0- D1 +o0- R1 +o0- } o0. -o0.O31 -o0.z1 -o0/ -o0/C -o0/T1 -o0/z1 +o0. O31 +o0. z1 +o0/ C +o0/ T1 +o0/ z1 o00 -o00+3 -o00-5o1M -o00L1 -o00^1 -o00p1 -o00z1 +o00 +3 +o00 -5 o1M +o00 L1 +o00 ^1 +o00 p1 +o00 z1 o01 -o01i07 -o01l -o01p1 -o01p3 -o01s0h -o01uZ3 -o01z1 -o01z3 -o01z4+1 +o01 i07 +o01 l +o01 p1 +o01 p3 +o01 s0h +o01 u Z3 +o01 z1 +o01 z3 +o01 z4 +1 o02 -o02*20 -o02D5 -o02D6 -o02Z1 -o02saC -o02z1 +o02 *20 +o02 D5 +o02 D6 +o02 Z1 +o02 saC +o02 z1 o03 -o03+1 -o03-1 -o03^1 -o03^< -o03^Q -o03i3a -o03r -o03O2Az3 +o03 +1 +o03 -1 +o03 ^1 +o03 ^< +o03 ^Q +o03 i3a +o03 r +o03 O2A z3 o04 -o04'8 -o04L1 -o04O13 +o04 '8 +o04 L1 +o04 O13 o05 -o05'8 -o05l -o05t -o05z1 -o05z5 +o05 '8 +o05 l +o05 t +o05 z1 +o05 z5 o06 -o06+1 -o06@r -o06Z2 -o06Z4 -o06O85 +o06 +1 +o06 @r +o06 Z2 +o06 Z4 +o06 O85 o07 -o07*51 -o07-5Z2 -o07D2*56 -o07R2 -o07o2z -o07{u +o07 *51 +o07 -5 Z2 +o07 D2 *56 +o07 R2 +o07 o2z +o07 { u o08 -o08$xr -o08Z1 -o08]d -o08rD5 -o08O74 -o08z2 -o08z3O64 +o08 $x r +o08 Z1 +o08 ] d +o08 r D5 +o08 O74 +o08 z2 +o08 z3 O64 o09 -o09$x -o09*13 -o09*54 -o09-1 -o09L4 -o09Z4l -o09k +o09 $x +o09 *13 +o09 *54 +o09 -1 +o09 L4 +o09 Z4 l +o09 k o0: o0; o0< -o0 -o0>-1 -o0?$K -o0?^! -o0?^A -o0?}i3u +o0> -1 +o0? $K +o0? ^! +o0? ^A +o0? } i3u o0@ -o0@O24 +o0@ O24 o0A -o0AL1*17 -o0AZ2 -o0A^Q +o0A L1 *17 +o0A Z2 +o0A ^Q o0B -o0Bz3 +o0B z3 o0C -o0Cp1O01 -o0Ctz2 -o0Cz1 +o0C p1 O01 +o0C t z2 +o0C z1 o0D -o0D'6 -o0D'9 -o0Di6r -o0Du^I +o0D '6 +o0D '9 +o0D i6r +o0D u ^I o0E -o0EC +o0E C o0F -o0F$s -o0Fk -o0Fl -o0G -o0G@q -o0Gi0Q +o0F $s +o0F k +o0F l +o0G @q +o0G i0Q o0H -o0HD8*18 -o0Hi3m -o0Hl -o0HstA +o0H D8 *18 +o0H i3m +o0H l +o0H stA o0I -o0Ik -o0I{C +o0I k +o0I { C o0J -o0JT5 -o0Jt -o0Jz2D2 +o0J T5 +o0J t +o0J z2 D2 o0K -o0K*02 -o0KT5 -o0Ku -o0KO23^z -o0L -o0Lp1 +o0K *02 +o0K T5 +o0K u +o0K O23 ^z +o0L p1 o0M -o0M$n -o0M'9 -o0M*13 -o0M*43 -o0MD3 -o0ML1 -o0MZ5 -o0Md -o0Mo2N -o0Mz1 -o0N*25 -o0N*72 -o0ND8O14 -o0No4oZ2 -o0O -o0O$4z5 -o0OT2 -o0Oi3B -o0Ou -o0P -o0P$r -o0P*23 -o0PZ4 -o0Pd +o0M $n +o0M '9 +o0M *13 +o0M *43 +o0M D3 +o0M L1 +o0M Z5 +o0M d +o0M o2N +o0M z1 +o0N *25 +o0N *72 +o0N D8 O14 +o0N o4o Z2 +o0O $4 z5 +o0O T2 +o0O i3B +o0O u +o0P $r +o0P *23 +o0P Z4 +o0P d o0Q -o0Q$w +o0Q $w o0R -o0R$A -o0R$i -o0R*31 -o0R+4 -o0RO31 -o0Rz3D1 +o0R $A +o0R $i +o0R *31 +o0R +4 +o0R O31 +o0R z3 D1 o0S -o0S*45*34 -o0S^* -o0Sp1 +o0S *45 *34 +o0S ^* +o0S p1 o0T -o0T+4 -o0TL1 +o0T +4 +o0T L1 o0U -o0Uu -o0V -o0V+2 -o0VD3 -o0VO32 +o0U u +o0V +2 +o0V D3 +o0V O32 o0W -o0W$f-6 -o0W*31 -o0WC -o0WD2 -o0WT5Z2 -o0Wp1 -o0Wskt -o0WtO43 +o0W $f -6 +o0W *31 +o0W C +o0W D2 +o0W T5 Z2 +o0W p1 +o0W skt +o0W t O43 o0X -o0Xu -o0Xz2 +o0X u +o0X z2 o0Y -o0Y$b -o0Y$r -o0Y*56 -o0YZ4 -o0YO43 +o0Y $b +o0Y $r +o0Y *56 +o0Y Z4 +o0Y O43 o0Z -o0Z$Z -o0Z*31K -o0ZZ1 -o0Zc -o0Zz2 +o0Z $Z +o0Z *31 K +o0Z Z1 +o0Z c +o0Z z2 o0[ -o0[O23 +o0[ O23 o0\ o0] o0^ -o0^i0cZ1 -o0^p1 -o0^z1 +o0^ i0c Z1 +o0^ p1 +o0^ z1 o0_ o0` -o0a -o0aT2 -o0a[i2b -o0a^f -o0a^q -o0ai6; -o0aO46 -o0aO63 +o0a T2 +[ i2b +o0a ^f +o0a ^q +o0a i6; +o0a O46 +o0a O63 o0b -o0b*02 -o0b*23*43 -o0bC -o0b^t -o0bc -o0bk -o0bl -o0bo6BO04 -o0bp1 +o0b *02 +o0b *23 *43 +o0b C +o0b ^t +o0b c +o0b k +o0b l +o0b o6B O04 +o0b p1 o0c -o0c$0 -o0c*42 -o0c*62 -o0c*86 -o0ck -o0cscq +o0c $0 +o0c *42 +o0c *62 +o0c *86 +o0c k +o0c scq o0d -o0d$z -o0d+A -o0d-5 -o0d@s -o0dD5 -o0dR9 -o0d] -o0di4[ -o0dr -o0dO37q -o0dz3 -o0d} +o0d $z +o0d +A +o0d -5 +o0d @s +o0d D5 +o0d R9 +o0d ] +o0d i4[ +o0d r +o0d O37 q +o0d z3 +o0d } o0e -o0e'A -o0e-2 -o0eT6 -o0e^Kl -o0ei1s -o0ekZ1 -o0eo3l -o0esa"*61 -o0eO3A -o0eO72 +o0e 'A +o0e -2 +o0e T6 +o0e ^K l +o0e i1s +o0e k Z1 +o0e o3l +o0e sa" *61 +o0e O3A +o0e O72 o0f -o0f$1 -o0fC^a -o0fD1 -o0fK -o0fT3 -o0f^7 -o0fo39l -o0fO12 -o0fO32 -o0g -o0g*34 -o0g+6 -o0gZ2 -o0g] -o0gd -o0gf -o0gp2 -o0gq -o0gqr -o0gt -o0gz2 +o0f $1 +o0f C ^a +o0f D1 +o0f K +o0f T3 +o0f ^7 +o0f o39 l +o0f O12 +o0f O32 +o0g *34 +o0g +6 +o0g Z2 +o0g ] +o0g d +o0g f +o0g p2 +o0g q +o0g q r +o0g t +o0g z2 o0h -o0h*12 -o0hu -o0hO91 +o0h *12 +o0h u +o0h O91 o0i -o0i+1 -o0ip1 -o0it -o0iu -o0j^9 -o0j^D -o0j^v -o0jc -o0jk -o0jstg[ -o0jO31 -o0jz3 -o0jz4 +o0i +1 +o0i p1 +o0i t +o0i u +o0j ^9 +o0j ^D +o0j ^v +o0j c +o0j k +stg [ +o0j O31 +o0j z3 +o0j z4 o0k -o0k*27 -o0k*30 -o0k*46 -o0k^g -o0kc -o0ko1. -o0kp1 -o0ks7c -o0ksm+ -o0kO23 -o0kO41 -o0kO61 -o0kz1 +o0k *27 +o0k *30 +o0k *46 +o0k ^g +o0k c +o0k o1. +o0k p1 +o0k s7c +o0k sm+ +o0k O23 +o0k O41 +o0k O61 +o0k z1 o0l -o0l^2 -o0ld -o0ldL6 -o0lkz4 -o0lO35 -o0lO47 -o0lz4 +o0l ^2 +o0l d +o0l d L6 +o0l k z4 +o0l O35 +o0l O47 +o0l z4 o0m -o0mT4 -o0md -o0ml -o0mo5w -o0mz1 -o0m{ +o0m T4 +o0m d +o0m l +o0m o5w +o0m z1 +o0m { o0n -o0n*61 -o0n*62 -o0n^n -o0no4K -o0no62 -o0nO02$A -o0nz5 -o0n} +o0n *61 +o0n *62 +o0n ^n +o0n o4K +o0n o62 +o0n O02 $A +o0n z5 +o0n } o0o -o0o*13 -o0oZ2 -o0op1 -o0oqO26 -o0p -o0p'6 -o0p*40 -o0p+3 -o0p-1 -o0p@1 -o0pZ1 -o0pi42 -o0po3e -o0pt +o0o *13 +o0o Z2 +o0o p1 +o0o q O26 +o0p '6 +o0p *40 +o0p +3 +o0p -1 +o0p @1 +o0p Z1 +o0p i42 +o0p o3e +o0p t o0q -o0q$5 -o0ql +o0q $5 +o0q l o0r -o0r+4 -o0rR4 -o0rT5 -o0r^E -o0r^b -o0ri0p -o0ro2k -o0rswz -o0rO21 -o0rO24 +o0r +4 +o0r R4 +o0r T5 +o0r ^E +o0r ^b +o0r i0p +o0r o2k +o0r swz +o0r O21 +o0r O24 o0s -o0s+6 -o0sZ5 -o0sd -o0si39 -o0sk -o0sl -o0so3X -o0sO31 -o0sO46^i +o0s +6 +o0s Z5 +o0s d +o0s i39 +o0s k +o0s l +o0s o3X +o0s O31 +o0s O46 ^i o0t -o0t$9 -o0t$? -o0t$e -o0t'7 -o0t*54 -o0t*91 -o0t@0 -o0tD5 -o0tf -o0to3w -o0tq -o0tsPk -o0tu -o0tz1 -o0u -o0u^t -o0ui3- -o0uk +o0t $9 +o0t $? +o0t $e +o0t '7 +o0t *54 +o0t *91 +o0t @0 +o0t D5 +o0t f +o0t o3w +o0t q +o0t sPk +o0t u +o0t z1 +o0u ^t +o0u i3- +o0u k o0v -o0v'5 -o0v*23 -o0v^b -o0vi75O17 -o0vo1- -o0vr -o0vO41 +o0v '5 +o0v *23 +o0v ^b +o0v i75 O17 +o0v o1- +o0v r +o0v O41 o0w -o0w$3 -o0w$r -o0w'7Z1 -o0w*05 -o0w*14 -o0w*25 -o0w*45^Z -o0wD8 -o0wq -o0wO23 -o0wz1 -o0wz5D0 +o0w $3 +o0w $r +o0w '7 Z1 +o0w *05 +o0w *14 +o0w *25 +o0w *45 ^Z +o0w D8 +o0w q +o0w O23 +o0w z1 +o0w z5 D0 o0x -o0xL1 -o0xZ5 -o0x] +o0x L1 +o0x Z5 +o0x ] o0y -o0y$CD0 -o0yr +$C D0 +o0y r o0z -o0z$q -o0z-9 -o0z-9O53 -o0z@u -o0z^I -o0zt -o0zO13 -o0zO32 -o0z} -o0{$rZ4 -o0{O17 +o0z $q +o0z -9 +o0z -9 O53 +o0z @u +o0z ^I +o0z t +o0z O13 +o0z O32 +o0z } +o0{ $r Z4 +o0{ O17 o0| -o0|-2C +o0| -2 C o1 -o1 O02$o -o1 z4 +o1 O02 $o +o1 z4 o1! -o1!T0 +o1! T0 o1" -o1"*53 +o1" *53 o1# -o1#+6 -o1#z2 -o1#{ +o1# +6 +o1# z2 +o1# { o1$ -o1$s0J-1 -o1%u +o1$ s0J -1 +o1% u o1& -o1&*13 +o1& *13 o1' o1( -o1(d*37 -o1(rR1 +o1( d *37 +o1( r R1 o1) -o1)d -o1)s2) +o1) d +o1) s2) o1* o1+ -o1+'A -o1+D4 -o1+Z1 -o1+t +o1+ 'A +o1+ D4 +o1+ Z1 +o1+ t o1, -o1,$1+7 -o1,z2 +o1, $1 +7 +o1, z2 o1- -o1-'6 -o1-'8 -o1-o0B +o1- '6 +o1- '8 +o1- o0B o1. -o1.+0 -o1.^h -o1.p1 -o1.O27 +o1. +0 +o1. ^h +o1. p1 +o1. O27 o1/ -o1/T0@1 -o1/z2 -o1/}Z5 +o1/ T0 @1 +o1/ z2 +o1/ } Z5 o10 -o10D2 -o10Z5[ -o10ls3" -o10p1 -o10uz5 +o10 D2 +o10 Z5 [ +o10 l s3" +o10 p1 +o10 u z5 o11 -o11$/ -o11D1^O -o11R2 -o11i2 -o11k -o11o9bO81 -o11tz4 -o11z1 -o11z3 +o11 $/ +D1 ^O +o11 R2 +o11 i2 +o11 k +o11 o9b O81 +o11 t z4 +o11 z1 +o11 z3 o12 -o12$! -o12C -o12L0 -o12k^4 -o12l +o12 $! +o12 C +o12 L0 +o12 k ^4 +o12 l o13 -o13$_ -o13-2 -o13Z1 -o13[ -o13o2S -o13o8hO73 -o13p1 -o13t +o13 $_ +o13 -2 +o13 Z1 +o13 [ +o13 o2S +o13 o8h O73 +o13 p1 +o13 t o14 -o14$C -o14-9 -o14Z1 -o14Z4 -o14^3 -o14^6 -o14l -o14p1 +o14 $C +o14 -9 +o14 Z1 +o14 Z4 +o14 ^3 +o14 ^6 +o14 l +o14 p1 o15 -o15'9 -o15Z2*85 -o15[ -o15[+5 -o15o6u -o15O24 +o15 '9 +o15 Z2 *85 +o15 [ +o15 [ +5 +o15 o6u +o15 O24 o16 -o16*31 -o16L8@b -o16z1$3 -o16z2 -o16z3 +o16 *31 +o16 L8 @b +o16 z1 $3 +o16 z2 +o16 z3 o17 -o17R2 -o17T0 -o17[ -o17l +o17 R2 +o17 T0 +o17 [ +o17 l o18 -o18L9 -o18^M -o18^gi4* -o18p1 -o18sjh -o18u +o18 L9 +o18 ^M +o18 ^g i4* +o18 p1 +o18 sjh +o18 u o19 -o19*51 -o19D4 -o19Z4 -o19[ -o19^iO1B -o19f -o19k -o1:*37 +o19 *51 +o19 D4 +o19 Z4 +o19 [ +o19 ^i O1B +o19 f +o19 k +o1: *37 o1; -o1;*58 -o1;l -o1;O32 -o1<*36 +o1; *58 +o1; l +o1; O32 +o1< *36 o1= -o1=*71 -o1=[ -o1={ -o1>i5J*52 +o1= *71 +o1= [ +o1= { +o1> i5J *52 o1? -o1?O35 +o1? O35 o1@ -o1@-8 -o1@D0 -o1@^s -o1@O43 -o1Au +o1@ -8 +o1@ D0 +o1@ ^s +o1@ O43 +o1A u o1B -o1B*10 +o1B *10 o1C -o1Cu -o1Cz1 -o1Cz3D2 +o1C u +o1C z1 +o1C z3 D2 o1D -o1D*21 -o1DR4 -o1Dc -o1Dz1*56 +o1D *21 +o1D R4 +o1D c +o1D z1 *56 o1E -o1ED0Z1 +o1E D0 Z1 o1F -o1F$1 -o1F^1 -o1Fc +o1F $1 +o1F ^1 +o1F c o1G -o1GZ1O71 +o1G Z1 O71 o1H -o1H$6 -o1Hl -o1Hu +o1H $6 +o1H l +o1H u o1I -o1I+2 -o1IT2 -o1IT4 -o1I[ -o1I] -o1Ip1 -o1Iu +o1I +2 +o1I T2 +o1I T4 +o1I [ +o1I ] +o1I p1 +o1I u o1J -o1JcZ2 -o1Jt +o1J c Z2 +o1J t o1K -o1K[ -o1Kk -o1KO35 -o1KO47 +o1K [ +o1K k +o1K O35 +o1K O47 o1L -o1L[ +o1L [ o1M -o1M^x -o1M{ +o1M ^x +o1M { o1N o1O -o1Oc -o1Odl +o1O c +o1O d l o1P -o1PrT6 -o1Pz5 -o1P{+4 -o1Q$\ +o1P r T6 +o1P z5 +o1P { +4 +o1Q $\ o1R o1S -o1Sco0t +o1S c o0t o1T -o1T^v -o1Tr -o1TtC -o1Tz2-5 +o1T ^v +o1T r +o1T C +o1T z2 -5 o1U -o1U@U -o1U[ -o1Ul -o1Ulstq -o1UsUQu -o1UO53t +o1U @U +o1U [ +o1U l +o1U l stq +o1U sUQ u +o1U O53 t o1V -o1V^\+7 -o1Vk +o1V ^\ +7 +o1V k o1W -o1Wl^1 +o1W l ^1 o1X o1Y -o1Y$p -o1Y*13sma -o1YO31 +o1Y $p +o1Y *13 sma +o1Y O31 o1Z -o1Z*01 +o1Z *01 o1[ -o1[Z2o5j +o1[ Z2 o5j o1\ -o1\o7% +o1\ o7% o1] -o1]O12o34 +o1] O12 o34 o1^ -o1^$( -o1^{$2 +o1^ $( +o1^ { $2 o1_ -o1_$z -o1_sdy -o1_z2 +o1_ $z +o1_ sdy +o1_ z2 o1` o1a -o1a$$ -o1a$- -o1a-9 -o1aD2 -o1a^g -o1ai2s -o1ai4- -o1asbk -o1aO63 +o1a $$ +o1a $- +o1a -9 +o1a D2 +o1a ^g +o1a i2s +o1a i4- +o1a sbk +o1a O63 o1b -o1b^w -o1bo0r -o1bs30 +o1b ^w +o1b o0r +o1b s30 o1c -o1cD6 -o1cL5 -o1ci0et +o1c D6 +o1c L5 +o1c i0e t o1d -o1d$6 -o1d$b -o1dZ4 -o1do2e -o1do3? -o1dz4 +o1d $6 +o1d $b +o1d Z4 +o1d o2e +o1d o3? +o1d z4 o1e -o1e$7 -o1e*31 -o1e*51^n -o1e+0 -o1eD7 -o1eL5 -o1eZ1 -o1eZ5 -o1eo2d -o1esdh -o1est3 -o1ez5 +o1e $7 +o1e *31 +o1e *51 ^n +o1e +0 +o1e D7 +o1e L5 +o1e Z1 +o1e Z5 +o1e o2d +o1e sdh +o1e st3 +o1e z5 o1f -o1f$br -o1f$w -o1f*20 -o1f+0 -o1fk -o1fp2 -o1fz2 +o1f $b r +o1f $w +o1f *20 +o1f +0 +o1f k +o1f p2 +o1f z2 o1g -o1gD0^B -o1gT0 -o1gi0e -o1gp1 -o1gu -o1gO3A +o1g D0 ^B +o1g T0 +o1g i0e +o1g p1 +o1g u +o1g O3A o1h -o1h+0 -o1hR0 -o1h[ -o1ho7s +o1h +0 +o1h R0 +o1h [ +o1h o7s o1i -o1i'A -o1i^v -o1ii04 +o1i 'A +o1i ^v +o1i i04 o1j -o1j$1 -o1j*41 -o1j-2 -o1jZ1 +o1j $1 +o1j *41 +o1j -2 +o1j Z1 o1k -o1k$! -o1kL4 -o1kZ2o63 -o1k[p1 -o1k^i -o1k^s -o1kc -o1ki1u -o1kl -o1kz4 +o1k $! +o1k L4 +o1k Z2 o63 +o1k [ p1 +o1k ^i +o1k ^s +o1k c +o1k i1u +o1k l +o1k z4 o1l -o1l*13 -o1l*53 -o1l-2 -o1ld +o1l *13 +o1l *53 +o1l -2 +o1l d o1m -o1m*21 -o1m*24[ -o1m*65 -o1m-3 -o1mD0 -o1mL2 -o1md -o1mo0e -o1mu -o1mO28 +o1m *21 +o1m *24 [ +o1m *65 +o1m -3 +o1m D0 +o1m L2 +o1m d +o1m o0e +o1m u +o1m O28 o1n -o1n*10 -o1n*17 -o1nl -o1nu -o1n{t +o1n *10 +o1n *17 +o1n l +o1n u +o1n { t o1o -o1o*13 -o1o+7 -o1o@9 -o1oD4 -o1oL0 -o1oR0 -o1oZ1O53 -o1od -o1osWt -o1ossEu -o1oO25 +o1o *13 +o1o +7 +o1o @9 +o1o D4 +o1o L0 +o1o R0 +o1o Z1 O53 +o1o d +o1o sWt +o1o ssE u +o1o O25 o1p -o1p-2 -o1pZ2 -o1p^c -o1pz1 -o1pz3Z3 -o1p} +o1p -2 +o1p Z2 +o1p ^c +o1p z1 +o1p z3 Z3 +o1p } o1q -o1qt -o1qu +o1q t +o1q u o1r -o1r[ -o1ro7t -o1rt -o1rO45 +o1r [ +o1r o7t +o1r t +o1r O45 o1s -o1s$h -o1s+0 -o1sZ1 -o1sc -o1sd -o1si0g -o1si3n -o1su -o1sz1 +o1s $h +o1s +0 +o1s Z1 +o1s c +o1s d +o1s i0g +o1s i3n +o1s u +o1s z1 o1t -o1tp1 +o1t p1 o1u -o1u$- -o1u$yo1u -o1up1 -o1up2OAB -o1usBm -o1u}-0 +o1u $- +$y o1u +o1u p1 +o1u p2 OAB +o1u sBm +o1u } -0 o1v -o1v*51 -o1vC +o1v *51 +o1v C o1w -o1w$4 -o1w$C -o1w+3 -o1w-8 -o1w@9 -o1wD5 -o1wi17 -o1wq -o1wz1 +o1w $4 +o1w $C +o1w +3 +o1w -8 +o1w @9 +o1w D5 +o1w i17 +o1w q +o1w z1 o1x -o1xZ4 -o1x^l -o1xu +o1x Z4 +o1x ^l +o1x u o1y -o1y*27 -o1y*43z1 -o1yT5 -o1yo4f -o1yp1 -o1ysPD -o1ysc1 -o1yO12Z4 +o1y *27 +o1y *43 z1 +o1y T5 +o1y o4f +o1y p1 +o1y sPD +o1y sc1 +o1y O12 Z4 o1z -o1z'8 -o1zZ2 -o1z^j -o1zq -o1{z3 -o1|i1g +o1z '8 +o1z Z2 +o1z ^j +o1z q +o1{ z3 +o1| i1g o1} o2 -o2 *20i3D -o2 T0 -o2 ^4 -o2 ^t -o2 i1i -o2 u -o2 uo2a +o2 *20 i3D +o2 T0 +o2 ^4 +o2 ^t +o2 i1i +o2 u +u o2a o2! -o2!*12 -o2!i3V -o2!k +o2! *12 +o2! i3V +o2! k o2" -o2"^S +o2" ^S o2# o2$ -o2$Z1O42 -o2$Z2 +o2$ Z1 O42 +o2$ Z2 o2% -o2%*73 +o2% *73 o2& o2' -o2'^*T3 -o2'} +o2' ^* +o2' } o2) o2* -o2*T3O01 -o2*d -o2*t -o2*z1 +o2* T3 O01 +o2* d +o2* t +o2* z1 o2+ -o2+O32 +o2+ O32 o2, -o2,$1 +o2, $1 o2- -o2-*01 -o2-+4 -o2-R4 -o2-[o0J -o2-^k -o2-o1w +o2- *01 +o2- +4 +o2- R4 +o2- [ o0J +o2- ^k +o2- o1w o2. -o2.D1 +o2. D1 o2/ -o2/Z2 -o2/suz +o2/ Z2 +o2/ suz o20 -o20Z1 -o20^V -o20fO58 -o20i0K -o20z3 +o20 Z1 +o20 ^V +o20 f O58 +o20 i0K +o20 z3 o21 -o21'9 -o21D2snq -o21L6 -o21q -o21u -o21z3 +o21 '9 +D2 snq +o21 L6 +o21 q +o21 u +o21 z3 o22 -o22*32 -o22[ -o22] -o22t -o22z1 +o22 *32 +o22 [ +o22 ] +o22 t +o22 z1 o23 -o23R1 +o23 R1 o24 -o24u +o24 u o25 -o25R6 -o25p1 -o25r -o25z1 +o25 R6 +o25 p1 +o25 r +o25 z1 o26 -o26'9 -o26Z3 -o26d -o26O61 -o26z2 +o26 '9 +o26 Z3 +o26 d +o26 O61 +o26 z2 o27 -o27+8 -o27C +o27 +8 +o27 C o28 -o28*12 -o28l -o28p1i3H -o28O36 -o28z1 +o28 *12 +o28 l +o28 p1 i3H +o28 O36 +o28 z1 o29 -o29R4 -o29T4 -o29o65T2 -o29z2 -o2:*27{ +o29 R4 +o29 T4 +o29 o65 +o29 z2 +o2: *27 { o2; -o2;*31 -o2;o0SO16 +o2; *31 +o2; o0S O16 o2< -o2$G[ +o2= D3 o3_ +o2> $G [ o2? -o2?+3 +o2? +3 o2@ -o2@T0 -o2@oAR[ +o2@ T0 +o2@ oAR [ o2A -o2A[ -o2A^1 -o2Au -o2Bl*53 -o2Bsxrl +o2A [ +o2A ^1 +o2A u +o2B l *53 +o2B sxr l o2C -o2C-3 -o2Co6\ -o2Ct +o2C -3 +o2C o6\ +o2C t o2D -o2Dl -o2D} +o2D l +o2D } o2E o2F -o2F+1 +o2F +1 o2G -o2Gl -o2Go0P +o2G l +o2G o0P o2H -o2HT3 -o2HZ1u -o2H^H -o2H^q$7 -o2Hs0A +o2H T3 +o2H Z1 u +o2H ^H +o2H ^q $7 +o2H s0A o2I o2J -o2Ju +o2J u o2K -o2K*5Bk -o2K^Z -o2Kz2 -o2L@du -o2Lo75 +o2K *5B k +o2K ^Z +o2K z2 +o2L @d u +o2L o75 o2M -o2Mc +o2M c o2N -o2Nl +o2N l o2O o2P -o2Pl -o2PO61 +o2P l +o2P O61 o2Q -o2Q-2Z3 -o2Qu -o2Q} +o2Q -2 Z3 +o2Q u +o2Q } o2R -o2RT0 -o2RlO02 -o2ST1 -o2Si6GR4 -o2TZ2 -o2To33 +o2R T0 +o2R l O02 +o2S T1 +o2S i6G R4 +o2T Z2 +o2T o33 o2U -o2UO53u +o2U O53 u o2V -o2V$p*53 -o2V-3 -o2V[ -o2Vo3)$/ -o2Vt +o2V $p *53 +o2V -3 +o2V [ +o2V o3) $/ +o2V t o2W -o2Wc -o2Wu -o2Wz2 -o2XR0 +o2W c +o2W u +o2W z2 +o2X R0 o2Y -o2Y'7 -o2Yck -o2Yt -o2Z'7 -o2ZD3 -o2Z[ -o2Z^g +o2Y '7 +o2Y c k +o2Y t +o2Z '7 +o2Z D3 +o2Z [ +o2Z ^g o2[ -o2[L2 +o2[ L2 o2] o2^ o2_ -o2_*06 +o2_ *06 o2` o2a -o2a'6 -o2a*32 -o2aK -o2aswr -o2a{ +o2a '6 +o2a *32 +o2a K +o2a swr +o2a { o2b -o2b$u -o2b*26 -o2b*32 -o2b-0 -o2b[ -o2bO53 -o2b} +o2b $u +o2b *26 +o2b *32 +o2b -0 +o2b [ +o2b O53 +o2b } o2c -o2cD0 -o2cR4 -o2co7% -o2cO31 -o2cO41 -o2cz2 -o2cz2{ -o2c} +o2c D0 +o2c R4 +o2c o7% +o2c O31 +o2c O41 +o2c z2 +o2c z2 { +o2c } o2d -o2d*54 -o2d+8 -o2d-0 -o2d-8 -o2dC -o2dZ1 -o2d[ -o2dc -o2d{ +o2d *54 +o2d +8 +o2d -0 +o2d -8 +o2d C +o2d Z1 +o2d [ +o2d c +o2d { o2e -o2ek -o2eo1]o1& +o2e k +o2e o1& o2f -o2fi45 -o2fr -o2f} +o2f i45 +o2f r +o2f } o2g -o2g$# -o2gD3 -o2gD6 -o2g^a -o2gd -o2gi4k -o2go58 -o2gO34o1& -o2gO51 -o2g{ +o2g $# +o2g D3 +o2g D6 +o2g ^a +o2g d +o2g i4k +o2g o58 +o2g O34 o1& +o2g O51 +o2g { o2h -o2h$d*15 -o2h*26 -o2hT5 -o2hr -o2hszS +o2h $d *15 +o2h *26 +o2h T5 +o2h r +o2h szS o2i -o2i$j -o2i*40 -o2iL3 -o2iT0 -o2iZ2 -o2iZ4} -o2i] -o2isaA*31 +o2i $j +o2i *40 +o2i L3 +o2i T0 +o2i Z2 +o2i Z4 } +o2i ] +o2i saA *31 o2j -o2j*60 -o2j-5 -o2jZ1 -o2j^8 +o2j *60 +o2j -5 +o2j Z1 +o2j ^8 o2k -o2k$dZ4 -o2k$p*21 -o2k*01 -o2k[ -o2kc -o2ko2i[ -o2ksus -o2kO06Z1 +o2k $d Z4 +o2k $p *21 +o2k *01 +o2k [ +o2k c +o2i [ +o2k sus +o2k O06 Z1 o2l -o2l$k -o2l'6 -o2l*42 -o2l-8 -o2lT0 -o2lZ1 -o2ls4f -o2lsxZO02 -o2lO31 +o2l $k +o2l '6 +o2l *42 +o2l -8 +o2l T0 +o2l Z1 +o2l s4f +o2l sxZ O02 +o2l O31 o2m -o2m$2 -o2mD3 -o2m^d +o2m $2 +o2m D3 +o2m ^d o2n -o2n-4 -o2nC -o2nZ1 -o2n[ -o2ndO58 -o2nr -o2nO32 -o2nz3 -o2n} +o2n -4 +o2n C +o2n Z1 +o2n [ +o2n d O58 +o2n r +o2n O32 +o2n z3 +o2n } o2o -o2o+2R5 -o2o^@ -o2o^D -o2oc -o2oi2j -o2oo0p +o2o +2 R5 +o2o ^@ +o2o ^D +o2o c +o2o i2j +o2o o0p o2p -o2p*37 -o2p*51 -o2p+3 -o2pC -o2pD4D0 -o2pO35 +o2p *37 +o2p *51 +o2p +3 +o2p C +o2p D4 D0 +o2p O35 o2q -o2q$4 -o2q]i3i -o2qo5r -o2q{[ +o2q $4 +o2q ] i3i +o2q o5r +o2q { [ o2r -o2r$. -o2r+3O53 -o2rZ3 -o2r^v -o2rc -o2rf -o2rk -o2rq -o2rsc@ -o2rz3 -o2r}[ +o2r $. +o2r +3 O53 +o2r Z3 +o2r ^v +o2r c +o2r f +o2r k +o2r q +o2r sc@ +o2r z3 +o2r } [ o2s -o2s] -o2sc -o2sp1 -o2su -o2sO81 +o2s ] +o2s c +o2s p1 +o2s u +o2s O81 o2t -o2t$e -o2t+3 -o2t+4 -o2tZ2 -o2tZ3 -o2t^P*67 -o2tk -o2to7b +o2t $e +o2t +3 +o2t +4 +o2t Z2 +o2t Z3 +o2t ^P *67 +o2t k +o2t o7b o2u -o2u$# -o2uc -o2ud -o2ui3y -o2uro1d +o2u $# +o2u c +o2u d +o2u i3y +o2u r o1d o2v -o2v$Bi0m -o2vd -o2vz2 +o2v $B i0m +o2v d +o2v z2 o2w -o2w+4 -o2wZ1 -o2w^6 -o2w^8 -o2w^n -o2wi0_} -o2wi0j -o2wi1L -o2wk -o2wO48 +o2w +4 +o2w Z1 +o2w ^6 +o2w ^8 +o2w ^n +o2w i0_ } +o2w i0j +o2w i1L +o2w k +o2w O48 o2x -o2x*01 -o2x^xO54 -o2xr +o2x *01 +o2x ^x O54 +o2x r o2y -o2yT0 -o2yk -o2yo3k +o2y T0 +o2y k +o2y o3k o2z -o2z$ -o2z*21 -o2zC -o2zT4 -o2zO53 +o2z $ +o2z *21 +o2z C +o2z T4 +o2z O53 o2{ -o2{L0 +o2{ L0 o2| -o2|$gO2A -o2|^j -o2|o8HO15 -o2|s1z -o2}o0l +o2| $g O2A +o2| ^j +o2| o8H O15 +o2| s1z +o2} o0l o3 -o3 *53 -o3 c -o3 O21 -o3 } +o3 *53 +o3 c +o3 O21 +o3 } o3! -o3!$* -o3!-2 -o3!-4 -o3!Z1o53 -o3!i6C +o3! $* +o3! -2 +o3! -4 +o3! Z1 o53 +o3! i6C o3" -o3"s"K -o3"ss/ +o3" s"K +o3" ss/ o3# -o3#+5 -o3#o0T +o3# +5 +o3# o0T o3$ -o3$D2 -o3$Z2 -o3${ +o3$ D2 +o3$ Z2 +o3$ { o3% -o3%D1 +o3% D1 o3& -o3&-2l -o3&^1T2 +o3& -2 l +o3& ^1 T2 o3' o3( -o3(CO32 +o3( C O32 o3) o3* -o3*{ +o3* { o3+ -o3+D6 -o3+o0w*35 +o3+ D6 +o3+ o0w *35 o3, -o3,$#'5 -o3,R0 +o3, $# '5 +o3, R0 o3- -o3-*20 -o3-Z3 -o3-[ -o3-O5B -o3-z4O07 +o3- *20 +o3- Z3 +o3- [ +o3- O5B +o3- z4 O07 o3. -o3.*01 +o3. *01 o3/ -o3/O16u -o3/O45 +o3/ O16 u +o3/ O45 o30 -o30*63 -o30@a -o30R1 -o30r*30 -o30t +o30 *63 +o30 @a +o30 R1 +o30 r *30 +o30 t o31 -o31R7 -o31T3O61 +o31 R7 +o31 O61 o32 -o32*32u -o32[ -o32i3k -o32l^c -o32p1 -o32t -o32z3 +o32 *32 u +o32 [ +o32 i3k +o32 l ^c +o32 p1 +o32 t +o32 z3 o33 -o33-2 -o33d -o33o7@ -o33s9f +o33 -2 +o33 d +o33 o7@ +o33 s9f o34 -o34^M -o34l -o34s2n -o34t -o34{ +o34 ^M +o34 l +o34 s2n +o34 t +o34 { o35 -o35'5sw3 -o35Z2 +o35 '5 sw3 +o35 Z2 o36 -o36^j -o36sa0 +o36 ^j +o36 sa0 o37 -o37*20 -o37@2 -o37@y -o37R0 -o37i1n -o37o11 +o37 *20 +o37 @2 +o37 @y +o37 R0 +o37 i1n +o37 o11 o38 -o38$6R3 -o38$M -o38Z2u -o38qT5 -o38O72 -o38z5o2= +o38 $6 R3 +o38 $M +o38 Z2 u +o38 q T5 +o38 O72 +o38 z5 o2= o39 -o39*02 -o39*71 -o39Co3! -o39d +o39 *02 +o39 *71 +C o3! +o39 d o3: -o3:*15^8 -o3:^s +o3: *15 ^8 +o3: ^s o3; -o3;'6 -o3;*20 -o3;k -o3 -o4>z3*57 +o4> z3 *57 o4? -o4?@9 -o4?o7A +o4? @9 +o4? o7A o4@ -o4@$! +o4@ $! o4A -o4Ac -o4Ao1z +o4A c +o4A o1z o4B o4C -o4Ct +o4C t o4D -o4DDA -o4Dc -o4DO21 +o4D DA +o4D c +o4D O21 o4E -o4Et +o4E t o4F -o4Fz3 +o4F z3 o4G o4H o4I -o4Ic -o4Iu +o4I c +o4I u o4J o4K -o4K'6 -o4KL5 -o4K[ -o4Kl -o4Ku +o4K '6 +o4K L5 +o4K [ +o4K l +o4K u o4L o4M -o4M$7 -o4Mu{ +o4M $7 +o4M u { o4N -o4Nt +o4N t o4O -o4OZ5 -o4O^I +o4O Z5 +o4O ^I o4P -o4P^0'B -o4Pl +o4P ^0 'B +o4P l o4Q o4R -o4R} +o4R } o4S -o4Sl +o4S l o4T -o4T+1 -o4UZ2 -o4Uc +o4T +1 +o4U Z2 +o4U c o4V -o4Wi3Q +o4W i3Q o4X -o4Xt +o4X t o4Y -o4Y$E -o4YR2 -o4Yc +o4Y $E +o4Y R2 +o4Y c o4Z -o4Z*13i27 -o4Zo30^! +o4Z *13 i27 +o4Z o30 ^! o4[ -o4[i0s} -o4[o4mr -o4\o2[T2 -o4\o3= -o4\u +o4[ i0s } +o4m r +o4\ o2[ +o4\ o3= +o4\ u o4^ -o4^l +o4^ l o4_ -o4_o7s -o4_sp> +o4_ o7s +o4_ sp> o4` o4a -o4aZ2 -o4aZ2L6 -o4at -o4aO21 +o4a Z2 +o4a Z2 L6 +o4a t +o4a O21 o4b -o4b*42 -o4b@mz1 -o4bZ2 -o4b[^N -o4bz1 -o4bz2 -o4b} +o4b *42 +o4b @m z1 +o4b Z2 +o4b [ ^N +o4b z1 +o4b z2 +o4b } o4c -o4c*67 -o4c+3 -o4c^{^Q -o4cc -o4cl -o4co0@ -o4cp1 -o4cs0s+2 -o4cu -o4cO02 +o4c *67 +o4c +3 +o4c ^{ ^Q +o4c c +o4c l +o4c o0@ +o4c p1 +o4c s0s +2 +o4c u +o4c O02 o4d -o4d$k -o4d*07 -o4d*53 -o4dZ2 -o4do3j -o4dO71 +o4d $k +o4d *07 +o4d *53 +o4d Z2 +o4d o3j +o4d O71 o4e -o4eD5 -o4e^j -o4ed -o4esTw +o4e D5 +o4e ^j +o4e d +o4e sTw o4f -o4f$q^r -o4f$s -o4f*04 -o4fD6 -o4fo4J*20 -o4frZ1 +o4f $q ^r +o4f $s +o4f *04 +o4f D6 +o4J *20 +o4f r Z1 o4g -o4g$u -o4g-3 -o4g] -o4gu +o4g $u +o4g -3 +o4g ] +o4g u o4h -o4h*51 -o4h*71O37 -o4hK] -o4hi8uO31 +o4h *51 +o4h *71 O37 +o4h K ] +o4h i8u O31 o4i -o4iT1 -o4iZ1+4 -o4i^8z1 -o4io6! -o4iO31 +o4i T1 +o4i Z1 +4 +o4i ^8 z1 +o4i o6! +o4i O31 o4j -o4jR1 -o4ji2H$a -o4jo6Yc -o4jo80 -o4jp1 -o4jO31 +o4j R1 +o4j i2H $a +o4j o6Y c +o4j o80 +o4j p1 +o4j O31 o4k -o4k*35 -o4k+5 -o4k+6 -o4k[ -o4ki62 +o4k *35 +o4k +5 +o4k +6 +o4k [ +o4k i62 o4l -o4lD3 -o4lo1k -o4lo3r -o4lu -o4lO53 +o4l D3 +o4l o1k +o4l o3r +o4l u +o4l O53 o4m -o4m'6O32 -o4m*07 -o4m+0 -o4mqO56 -o4mO67 +o4m '6 O32 +o4m *07 +o4m +0 +o4m q O56 +o4m O67 o4n o4o -o4o*03ssl -o4o*24 -o4o+6 -o4oc -o4op1 -o4or +o4o *03 ssl +o4o *24 +o4o +6 +o4o c +o4o p1 +o4o r o4p -o4pD1 -o4pk -o4p} +o4p D1 +o4p k +o4p } o4q -o4qD5 -o4q[ +o4q D5 +o4q [ o4r -o4r*10 -o4r*35t -o4r^o -o4rp1 +o4r *10 +o4r *35 t +o4r ^o +o4r p1 o4s -o4s$AO25 -o4s*41 -o4s-0 -o4sR0 -o4st +o4s $A O25 +o4s *41 +o4s -0 +o4s R0 +o4s t o4t -o4t*45 -o4t*73 -o4tC -o4tD5 -o4tR3 -o4tZ1 -o4tZ2 -o4tZ3 -o4t^M -o4t^Zu -o4t^b -o4tO21 +o4t *45 +o4t *73 +o4t C +o4t D5 +o4t R3 +o4t Z1 +o4t Z2 +o4t Z3 +o4t ^M +o4t ^Z u +o4t ^b +o4t O21 o4u -o4u*21 -o4u^ki2G -o4ut -o4uO02 +o4u *21 +o4u ^k i2G +o4u t +o4u O02 o4v -o4v'6 -o4v*15 -o4vi0x -o4vO59 +o4v '6 +o4v *15 +o4v i0x +o4v O59 o4w -o4wZ1 -o4w^l -o4wi2m +o4w Z1 +o4w ^l +o4w i2m o4x -o4x*46 -o4x+2 -o4x-9 -o4xZ1 -o4xZ4 -o4xc -o4xp1 -o4xO21 +o4x *46 +o4x +2 +o4x -9 +o4x Z1 +o4x Z4 +o4x c +o4x p1 +o4x O21 o4y -o4y+0l -o4y^( -o4yo2k -o4yu -o4yz2 +o4y +0 l +o4y ^( +o4y o2k +o4y u +o4y z2 o4z -o4zL8t -o4zO56 -o4z{l +o4z L8 t +o4z O56 +o4z { l o4{ o4| o4} o5 -o5 '6 -o5 +6 -o5 -0 -o5 D3 -o5 Z1 -o5 sdhO13 -o5 O02 +o5 '6 +o5 +6 +o5 -0 +o5 D3 +o5 Z1 +o5 sdh O13 +o5 O02 o5! -o5!'6D1 -o5!*30 -o5!Z2 -o5!i4e -o5!o2l -o5!sgd -o5"$" +o5! '6 D1 +o5! *30 +o5! Z2 +o5! i4e +o5! o2l +o5! sgd +o5" $" o5# -o5#O62 +o5# O62 o5$ -o5$Z3 +o5$ Z3 o5% o5& -o5&^B*01 +o5& ^B *01 o5' -o5'+0 +o5' +0 o5( -o5(i5n +o5( i5n o5) o5* -o5*Z2 -o5*Z3 -o5*^o +o5* Z2 +o5* Z3 +o5* ^o o5+ -o5+*67 -o5+o1&k +o5+ *67 +o5+ o1& k o5, -o5,@8 -o5,L2 -o5,Z2 -o5,p1 -o5,O61 +o5, @8 +o5, L2 +o5, Z2 +o5, p1 +o5, O61 o5- -o5-'8 -o5-*40 -o5-O03 -o5-O83 +o5- '8 +o5- *40 +o5- O03 +o5- O83 o5. -o5.@w -o5.Z2 -o5.Z4 -o5.O41 +o5. @w +o5. Z2 +o5. Z4 +o5. O41 o5/ -o5/satz3 +o5/ sat z3 o50 -o50$y -o50*12 -o50-7 -o50Z1 -o50Z3 -o50^b -o50^f -o50d -o50l -o50o5!t +o50 $y +o50 *12 +o50 -7 +o50 Z1 +o50 Z3 +o50 ^b +o50 ^f +o50 d +o50 l +o5! t o51 -o51$k -o51l -o51O13 -o51z5 +o51 $k +o51 l +o51 O13 +o51 z5 o52 -o52$x -o52Z1 -o52Z3 -o52Z4 -o52l -o52o1E +o52 $x +o52 Z1 +o52 Z3 +o52 Z4 +o52 l +o52 o1E o53 -o53$e -o53D8 -o53^s -o53u -o53}^g +o53 $e +o53 D8 +o53 ^s +o53 u +o53 } ^g o54 -o54*02 -o54Z3 -o54p1 -o54u -o54O41 +o54 *02 +o54 Z3 +o54 p1 +o54 u +o54 O41 o55 -o55*78 -o55+6 -o55+7 -o55R0 -o55Z1 -o55Z5 -o55l -o55t -o55tZ1 +o55 *78 +o55 +6 +o55 +7 +o55 R0 +o55 Z1 +o55 Z5 +o55 l +o55 t +o55 t Z1 o56 -o56$6 -o56@w -o56L4 -o56o8s +o56 $6 +o56 @w +o56 L4 +o56 o8s o57 -o57$v -o57*13 -o57R4@4 -o57^l^d -o57u +o57 $v +o57 *13 +o57 R4 @4 +o57 ^l ^d +o57 u o58 -o58'7 -o58*65 -o58Z4 -o58[ -o58p1 -o58z2 +o58 '7 +o58 *65 +o58 Z4 +o58 [ +o58 p1 +o58 z2 o59 -o59Z2 -o59d +o59 Z2 +o59 d o5; -o5;*57*52 +o5; *57 *52 o5< -o5<*14s o5? -o5?'6 -o5?i6? -o5?kC +o5? '6 +o5? i6? +o5? k C o5@ -o5@*24 +o5@ *24 o5A -o5Al +o5A l o5B -o5Bl +o5B l o5C -o5CT6 -o5Cl +o5C T6 +o5C l o5D -o5D*8A -o5DO81 +o5D *8A +o5D O81 o5E -o5E@0D2 -o5ED7 -o5ET3 -o5EO02 +o5E @0 D2 +o5E D7 +o5E T3 +o5E O02 o5F -o5FZ1 +o5F Z1 o5G -o5GD6 +o5G D6 o5H -o5Hc^4 -o5Hdl -o5HO31 +o5H c ^4 +o5H d l +o5H O31 o5I -o5I$z -o5I-4 -o5IZ1 +o5I $z +o5I -4 +o5I Z1 o5J o5K -o5Ki3# -o5Kl -o5Ku -o5Luz1 +o5K i3# +o5K l +o5K u +o5L u z1 o5M -o5MD1 +o5M D1 o5N -o5N+2t -o5NO02 -o5NO52$: +o5N +2 t +o5N O02 +o5N O52 $: o5O -o5O+0 -o5Oc +o5O +0 +o5O c o5P -o5PZ2 -o5Pi2ii5} -o5Q*15 -o5Q*43 -o5QO24T1 +o5P Z2 +o5P i2i i5} +o5Q *15 +o5Q *43 +o5Q O24 T1 o5R -o5R@1 -o5RZ1 -o5S'6 +o5R @1 +o5R Z1 +o5S '6 o5T -o5Tc -o5To8gO35 -o5TO02+1 +o5T c +o5T o8g O35 +o5T O02 +1 o5U -o5Ui3E^, -o5Uo1B +o5U i3E ^, +o5U o1B o5V -o5V^n -o5Vo8{ +o5V ^n +o5V o8{ o5W -o5W[ -o5Wt +o5W [ +o5W t o5X o5Z -o5Zc -o5Z{o6" +o5Z c +o5Z { o6" o5[ -o5\o3IZ3 +o5\ o3I Z3 o5^ o5_ -o5_*15 -o5_*24 -o5_^Q -o5_o66 -o5_u +o5_ *15 +o5_ *24 +o5_ ^Q +o5_ o66 +o5_ u o5` o5a -o5a*68 -o5a+9 -o5aD6 -o5aZ1 -o5a[ -o5a^` -o5ad -o5aO32 +o5a *68 +o5a +9 +o5a D6 +o5a Z1 +o5a [ +o5a ^` +o5a d +o5a O32 o5b -o5bi62 +o5b i62 o5c -o5c-0 -o5cC -o5cO7BO07 -o5cz2 +o5c -0 +o5c C +o5c O7B O07 +o5c z2 o5d -o5d'9 -o5d*87 -o5dd -o5di16 -o5dssF{ -o5dz2 +o5d '9 +o5d *87 +o5d d +o5d i16 +o5d ssF { +o5d z2 o5e -o5e$2 -o5e*37 -o5e@z -o5eK -o5eZ1 -o5ei2U -o5eO61 -o5eO67 +o5e $2 +o5e *37 +o5e @z +o5e K +o5e Z1 +o5e i2U +o5e O61 +o5e O67 o5f -o5f$z -o5f-4 -o5fZ3 -o5fO74 +o5f $z +o5f -4 +o5f Z3 +o5f O74 o5g -o5g+7 -o5gZ1 -o5gO02 -o5gz1 +o5g +7 +o5g Z1 +o5g O02 +o5g z1 o5h -o5h*43 -o5hZ2 -o5hc -o5hi4% -o5hi5C -o5h{ +o5h *43 +o5h Z2 +o5h c +o5h i4% +o5h i5C +o5h { o5i -o5i$h -o5i'B -o5iD4 -o5iR3 -o5ii6r -o5io6n +o5i $h +o5i 'B +o5i D4 +o5i R3 +o5i i6r +o5i o6n o5j -o5j*50 -o5j+0 -o5jZ1+8 +o5j *50 +o5j +0 +o5j Z1 +8 o5k -o5k*42 -o5kD7 -o5kp1 -o5kO04 -o5kz4 +o5k *42 +o5k D7 +o5k p1 +o5k O04 +o5k z4 o5l -o5l+3 -o5l+4 -o5l+6 -o5lD1 -o5lZ1 -o5lc -o5li6s +o5l +3 +o5l +4 +o5l +6 +o5l D1 +o5l Z1 +o5l c +o5l i6s o5m -o5m-6 -o5mD4C -o5mT6 -o5m^Dl -o5mi5_ -o5mk +o5m -6 +o5m D4 C +o5m T6 +o5m ^D l +o5m i5_ +o5m k o5n -o5n-3 -o5n@oo5u -o5nT1z1 -o5nd -o5nl-5 -o5n{ +o5n -3 +o5n @o o5u +o5n T1 z1 +o5n d +o5n l -5 +o5n { o5o -o5o$0c -o5o*36z3 -o5o*52 -o5ot -o5oz2 +o5o $0 c +o5o *36 z3 +o5o *52 +o5o t +o5o z2 o5p -o5pC$g -o5pZ1} -o5pc -o5po1T7 +o6= c +o6> T7 o6? -o6?*45 +o6? *45 o6@ -o6@$1 -o6@'8 +o6@ $1 +o6@ '8 o6A -o6AT0 -o6A[ -o6Ac +o6A T0 +o6A [ +o6A c o6B -o6BD3 -o6BO32 +o6B D3 +o6B O32 o6C -o6C$sl -o6Ct +o6C $s l +o6C t o6D o6E -o6Eo4. +o6E o4. o6F -o6F+7 -o6FO05 -o6G$B -o6Gi4=l -o6Gsy2O23 -o6HZ1k +o6F +7 +o6F O05 +o6G $B +o6G i4= l +o6G sy2 O23 +o6H Z1 k o6I -o6I^: +o6I ^: o6J -o6J] -o6Jrl -o6KT6O32 +o6J ] +o6J r l +o6K T6 O32 o6L -o6L*75t -o6LC +o6L *75 t +o6L C o6M -o6M$2 -o6M-7 -o6Mc$h -o6Mu +o6M $2 +o6M -7 +o6M c $h +o6M u o6N -o6Nl +o6N l o6O -o6O-5 -o6OT3 +o6O -5 +o6O T3 o6P -o6P$U -o6PD8 +o6P $U +o6P D8 o6Q -o6Q$7 -o6Q-7 +o6Q $7 +o6Q -7 o6R -o6R+1 -o6RK -o6S+3 -o6SZ2 +o6R +1 +o6R K +o6S +3 +o6S Z2 o6T -o6TT7 -o6Tc -o6TdO29 -o6Ti6Y -o6Tu -o6U+7 -o6UO1A^Y +o6T T7 +o6T c +o6T d O29 +o6T i6Y +o6T u +o6U +7 +o6U O1A ^Y o6V -o6V$I -o6VO74 +o6V $I +o6V O74 o6W o6X -o6X$aO27 +o6X $a O27 o6Y -o6[O42 +o6[ O42 o6^ -o6^$6^U -o6^Z1 -o6^sao +o6^ $6 ^U +o6^ Z1 +o6^ sao o6_ -o6_$0 +o6_ $0 o6` o6a -o6a*36 -o6ao4y -o6aO42 +o6a *36 +o6a o4y +o6a O42 o6b -o6b$m -o6bZ3 -o6bp1 +o6b $m +o6b Z3 +o6b p1 o6c -o6c'A -o6c[ -o6c[+5 -o6cl -o6co7fo4y +o6c 'A +o6c [ +o6c [ +5 +o6c l +o6c o7f o4y o6d -o6d+4] -o6di5S -o6dz2 +o6d +4 ] +o6d i5S +o6d z2 o6e -o6e*02 -o6e*86 -o6e+5 -o6e-1 -o6eZ4 -o6e[ -o6e^%i7; -o6eo2n -o6eu +o6e *02 +o6e *86 +o6e +5 +o6e -1 +o6e Z4 +o6e [ +o6e ^% i7; +o6e o2n +o6e u o6f -o6f$+Z2 -o6f*42 -o6f-4 -o6f-4+3 -o6fo8c -o6fO13 -o6fO24 -o6fz1 -o6f{[ +o6f $+ Z2 +o6f *42 +o6f -4 +o6f -4 +3 +o6f o8c +o6f O13 +o6f O24 +o6f z1 +o6f { [ o6g -o6gl$b -o6go5ou +o6g l $b +o6g o5o u o6h -o6h'8 -o6h*34 +o6h '8 +o6h *34 o6i -o6i+8 -o6ic -o6id -o6iO12 -o6i{ +o6i +8 +o6i c +o6i d +o6i O12 +o6i { o6j -o6j$8 -o6j$XC -o6j'5$o -o6jD8 -o6jc+2 -o6jO02 +o6j $8 +o6j $X C +'5 $o +o6j D8 +o6j c +2 +o6j O02 o6k -o6k$s -o6k[ -o6kr -o6ksk^ -o6kO12 +o6k $s +o6k [ +o6k r +o6k sk^ +o6k O12 o6l -o6l*14 -o6l+3 -o6l-8 -o6li4zO53 -o6ll -o6lO84 -o6lz1 +o6l *14 +o6l +3 +o6l -8 +o6l i4z O53 +o6l l +o6l O84 +o6l z1 o6m -o6m$. -o6m*43 -o6mZ1'8 -o6mc -o6m} +o6m $. +o6m *43 +o6m Z1 '8 +o6m c +o6m } o6n -o6n$4 -o6n$y -o6n+3 -o6nD7 -o6no7- +o6n $4 +o6n $y +o6n +3 +o6n D7 +o6n o7- o6o -o6o$d -o6o*61 -o6oC -o6oZ1 -o6od -o6oO13o3v +o6o $d +o6o *61 +o6o C +o6o Z1 +o6o d +O13 o3v o6p -o6p$s -o6p*56 -o6p+9 -o6pc -o6pi3/ -o6po5l -o6pr +o6p $s +o6p *56 +o6p +9 +o6p c +o6p i3/ +o6p o5l +o6p r o6q -o6q{ +o6q { o6r -o6r'9 -o6r@k -o6r[ +o6r '9 +o6r @k +o6r [ o6s -o6s^A -o6sc -o6sd -o6si6#T6 -o6ssdy -o6sO01 -o6sO71 +o6s ^A +o6s c +o6s d +o6s i6# +o6s sdy +o6s O01 +o6s O71 o6t -o6t*45 -o6t-5 -o6tD4 -o6tl -o6tO02 -o6tO03 -o6t} +o6t *45 +o6t -5 +o6t D4 +o6t l +o6t O02 +o6t O03 +o6t } o6u -o6u+1 -o6u-5 +o6u +1 +o6u -5 o6v -o6v*46o6G -o6vo5n +o6v *46 o6G +o6v o5n o6w -o6w+7 -o6wT2Z3 -o6w] -o6wO71 +o6w +7 +o6w T2 Z3 +o6w ] +o6w O71 o6x -o6xZ1 -o6xt -o6xO51 +o6x Z1 +o6x t +o6x O51 o6y -o6y$k -o6y@s -o6yl -o6ys04 -o6ysnj -o6yO02 +o6y $k +o6y @s +o6y l +o6y s04 +o6y snj +o6y O02 o6z -o6zT1 -o6zZ3 -o6zl[ -o6{O56@i -o6|s|d +o6z T1 +o6z Z3 +o6z l [ +o6{ O56 @i +o6| s|d o7 -o7 LAO17 -o7 O02 +o7 LA O17 +o7 O02 o7! -o7!-5 -o7!Z1 +o7! -5 +o7! Z1 o7" -o7"T3 +o7" T3 o7# -o7#*76 -o7#Z2 -o7#u -o7#} +o7# *76 +o7# Z2 +o7# u +o7# } o7$ -o7$'8 -o7$Z2 -o7$o4QO24 -o7$s$b +o7$ '8 +o7$ Z2 +o7$ o4Q O24 +o7$ s$b o7% -o7%O51 +o7% O51 o7& o7' -o7'T9 +o7' T9 o7( o7) o7* o7+ -o7+$,O4A -o7+D9 -o7+OB2O64 +o7+ $, O4A +o7+ D9 +o7+ OB2 O64 o7, -o7,*64-5 -o7,c +o7, *64 -5 +o7, c o7- o7. -o7.-2 -o7.D0 -o7.z2 +o7. -2 +o7. D0 +o7. z2 o7/ -o7/[Z3 -o7/t -o7/{ +o7/ [ Z3 +o7/ t +o7/ { o70 -o70$9 -o70$k -o70Z1 -o70^a -o70^i +o70 $9 +o70 $k +o70 Z1 +o70 ^a +o70 ^i o71 -o71$7 -o71+6 -o71-6 -o71-9 -o71Z1u -o71Z2 -o71i0{ -o71i7vZ1 -o71o1t -o71r +o71 $7 +o71 +6 +o71 -6 +o71 -9 +o71 Z1 u +o71 Z2 +o71 i0{ +o71 i7v Z1 +o71 o1t +o71 r o72 -o72$e -o72*43 -o72D3i1c -o72Z2 -o72sln +o72 $e +o72 *43 +o72 D3 i1c +o72 Z2 +o72 sln o73 -o73$+ -o73*36 -o73[ -o73o89 +o73 $+ +o73 *36 +o73 [ +o73 o89 o74 -o74o85 -o74o8i -o74s3_ +o74 o85 +o74 o8i +o74 s3_ o75 -o75*68 -o75-9 -o75@1'B -o75t -o75O25 +o75 *68 +o75 -9 +o75 @1 'B +o75 t +o75 O25 o76 -o76D4 -o76K -o76Z1 -o76] -o76^1 -o76s6z -o76sgd +o76 D4 +o76 K +o76 Z1 +o76 ] +o76 ^1 +o76 s6z +o76 sgd o77 -o77*10 -o77*A7 -o77-1l -o77Z1 -o77^7 -o77l -o77z1 +o77 *10 +o77 *A7 +o77 -1 l +o77 Z1 +o77 ^7 +o77 l +o77 z1 o78 -o78$h +o78 $h o79 -o79*56 -o79Z1 -o79l -o79s.n -o79t -o79O51Z4 +o79 *56 +o79 Z1 +o79 l +o79 s.n +o79 t +o79 O51 Z4 o7; -o7;i6x +o7; i6x o7< -o7<*67 -o7c +o7> c o7? o7@ o7A -o7A@+ +o7A @+ o7B -o7Bo2r +o7B o2r o7C -o7CCo6j -o7CL3 +o7C C o6j +o7C L3 o7D -o7DO49i1v +o7D O49 i1v o7E o7F o7G -o7GT6 +o7G T6 o7H -o7HD2 +o7H D2 o7I -o7J-0 +o7J -0 o7K -o7K$bO53 -o7Kt -o7KO13 +$b O53 +o7K t +o7K O13 o7L -o7L^` -o7LO08i5f -o7L} +o7L ^` +o7L O08 i5f +o7L } o7M -o7MD8 -o7MO03 -o7M{ +o7M D8 +o7M O03 +o7M { o7O -o7OuO03 +o7O u O03 o7P o7Q -o7QZ1 -o7Qc -o7QO36$P +o7Q Z1 +o7Q c +o7Q O36 $P o7S o7T -o7Tr +o7T r o7U -o7Uc +o7U c o7W -o7W'9 +o7W '9 o7X o7Y -o7Yl -o7Yt +o7Y l +o7Y t o7Z -o7Z^L +o7Z ^L o7\ o7] -o7]i4. +o7] i4. o7^ -o7^o6D +o7^ o6D o7_ -o7_T0 -o7_O12 +o7_ T0 +o7_ O12 o7` o7a -o7a*74 -o7a+8 -o7ao3DO13 -o7asr3O42 +o7a *74 +o7a +8 +o7a o3D O13 +o7a sr3 O42 o7b -o7b$jO26 -o7b*46 -o7b+4 -o7bZ1 -o7bz2 +$j O26 +o7b *46 +o7b +4 +o7b Z1 +o7b z2 o7c -o7c*75 -o7cK -o7cZ1 -o7cZ4Z2 -o7co4a -o7cO34 +o7c *75 +o7c K +o7c Z1 +o7c Z4 Z2 +o7c o4a +o7c O34 o7d -o7d$1 -o7d$l -o7dL4 -o7dp1l +o7d $1 +o7d $l +o7d L4 +o7d p1 l o7e -o7e*75 -o7eO43 +o7e *75 +o7e O43 o7f -o7f*23D8 -o7fsn, -o7ft +o7f *23 D8 +o7f sn, +o7f t o7g -o7g$o -o7g*98 -o7g] -o7gu +o7g $o +o7g *98 +o7g ] +o7g u o7h -o7h*56 -o7ho8i +o7h *56 +o7h o8i o7i -o7i*25+3 -o7i+4 -o7ic$l -o7ii3XO15 -o7il +o7i *25 +3 +o7i +4 +o7i c $l +o7i i3X O15 +o7i l o7j -o7j{ +o7j { o7k -o7k*63 -o7kr -o7ksbr +o7k *63 +o7k r +o7k sbr o7l -o7l-3-7 -o7lD8 -o7l^+$o +o7l -3 -7 +o7l D8 +o7l ^+ $o o7m -o7m$1 -o7m+8 -o7m-8 -o7mO81 +o7m $1 +o7m +8 +o7m -8 +o7m O81 o7n -o7n$1 -o7nZ2-4 -o7nt +o7n $1 +o7n Z2 -4 +o7n t o7o -o7o$2D2 -o7o$to4f -o7o'A -o7o-3 -o7oi9=O86 -o7oo0dD8 -o7or -o7oO34 +o7o $2 D2 +o7o $t o4f +o7o 'A +o7o -3 +o7o i9= O86 +o7o o0d D8 +o7o r +o7o O34 o7p o7q -o7q*67 -o7q*80T6 +o7q *67 +o7q *80 T6 o7r -o7rt -o7rO16 -o7rO41 -o7rO82 -o7rz3 +o7r t +o7r O16 +o7r O41 +o7r O82 +o7r z3 o7s -o7s*57 -o7s+2 -o7sc -o7si6t -o7sshe -o7sO51 +o7s *57 +o7s +2 +o7s c +o7s i6t +o7s she +o7s O51 o7t -o7tL8 -o7tO32 +o7t L8 +o7t O32 o7u -o7u$p -o7u*67 -o7uo0M -o7uO04^p +o7u $p +o7u *67 +o7u o0M +o7u O04 ^p o7v -o7v[ -o7vi7t +o7v [ +o7v i7t o7w -o7w-5 -o7wZ3 -o7wt +o7w -5 +o7w Z3 +o7w t o7x -o7x*46 +o7x *46 o7y -o7y*12 -o7y^j -o7yO0Bs 7 +o7y *12 +o7y ^j +o7y O0B s 7 o7z -o7zD4*56 -o7zl -o7zo8o +o7z D4 *56 +o7z l +o7z o8o o7} -o7}$4 +o7} $4 o8 -o8 '9 -o8 D7 -o8 O02 -o8 O06 +o8 '9 +o8 D7 +o8 O02 +o8 O06 o8! -o8![ +o8! [ o8" o8# -o8#+9 -o8#D7 -o8#D9 +o8# +9 +o8# D7 +o8# D9 o8$ -o8$O74c +o8$ O74 c o8% -o8%O31 +o8% O31 o8& -o8&$& -o8&R8 -o8&z1O07 +o8& $& +o8& R8 +o8& z1 O07 o8( -o8(c -o8(O0B$r +o8( c +o8( O0B $r o8) -o8)T4 +o8) T4 o8* -o8*K +o8* K o8+ -o8+Z1 +o8+ Z1 o8- -o8-Z1 +o8- Z1 o8. -o8.$1 +o8. $1 o8/ o80 -o80+7 -o80T0 -o80[ -o80i0* -o80o7r +o80 +7 +o80 T0 +o80 [ +o80 i0* +o80 o7r o81 -o81'9 -o81*63 -o81i1e -o81scw -o81sub +o81 '9 +o81 *63 +o81 i1e +o81 scw +o81 sub o82 -o82$9 -o82*79 -o82O21 -o82} +o82 $9 +o82 *79 +o82 O21 +o82 } o83 -o83*65 -o83-4 -o83o3e -o83tO64 -o83z1 +o83 *65 +o83 -4 +o83 o3e +o83 t O64 +o83 z1 o84 -o84+6 -o84Z1 -o84o4c -o84t -o84O12 +o84 +6 +o84 Z1 +o84 o4c +o84 t +o84 O12 o85 -o85*75 -o85*87 -o85*97 -o85+3 -o85o7y -o85O62 +o85 *75 +o85 *87 +o85 *97 +o85 +3 +o85 o7y +o85 O62 o86 -o86T9 -o86Z2 +o86 T9 +o86 Z2 o87 -o87+0 -o87+6 -o87Z3 -o87O52 -o87OA2 +o87 +0 +o87 +6 +o87 Z3 +o87 O52 +o87 OA2 o88 -o88$3 -o88+9 -o88Z2 -o88o9! +o88 $3 +o88 +9 +o88 Z2 +o88 o9! o89 -o89+9 -o89Z1 -o89Z2 -o89sw:sa5 +o89 +9 +o89 Z1 +o89 Z2 +o89 sw: sa5 o8: o8; o8< -o8<*78 -o8 o9? -o9?O13 +o9? O13 o9@ -o9@uO06 -o9A[ -o9Ao0tO35 +o9@ u O06 +o9A [ +o9A o0t O35 o9C o9E -o9Fi9nl +o9F i9n l o9H -o9H^qO36 -o9Hl +o9H ^q O36 +o9H l o9I -o9JZ1 -o9Yc -o9Yl +o9J Z1 +o9Y c +o9Y l o9] o9_ -o9_O34 +o9_ O34 o9` o9a -o9ac -o9aO43 +o9a c +o9a O43 o9b o9c -o9cD7 +o9c D7 o9d -o9d$6 -o9dZ2 -o9dl -o9dO63 +o9d $6 +o9d Z2 +o9d l +o9d O63 o9e -o9eO63 -o9eO72 +o9e O63 +o9e O72 o9f o9g o9h o9i -o9i$l -o9iD0 -o9ii4i -o9io7QO53 +o9i $l +o9i D0 +o9i i4i +o9i o7Q O53 o9j -o9j+8 -o9jO14 +o9j +8 +o9j O14 o9k -o9kZ2 -o9ki0s -o9ko8d +o9k Z2 +o9k i0s +o9k o8d o9l -o9lO52 -o9lO53 +o9l O52 +o9l O53 o9m -o9mO09 +o9m O09 o9n -o9no7v +o9n o7v o9o -o9ot -o9oOA3 +o9o t +o9o OA3 o9p o9q o9r -o9r$i -o9rO71 +o9r $i +o9r O71 o9s -o9s$e -o9s+3 -o9sD3 +o9s $e +o9s +3 +o9s D3 o9t -o9tu -o9tO62 +o9t u +o9t O62 o9u -o9uO36O41 +o9u O36 O41 o9v o9w -o9wl -o9wO42 +o9w l +o9w O42 o9x -o9xD6 +o9x D6 o9y -o9y*98 -o9y-5 +o9y *98 +o9y -5 o9z -o9zT0 -o9|O15 +o9z T0 +o9| O15 oA! -oA!O12 +oA! O12 oA$ oA* oA+ -oA.[ +oA. [ oA/ oA0 oA1 -oA1+9 -oA1D5 -oA1D8 -oA1l +oA1 +9 +oA1 D5 +oA1 D8 +oA1 l oA2 -oA2$! -oA2*87 -oA2OB2 +oA2 $! +oA2 *87 +oA2 OB2 oA3 -oA3'B -oA3Z1 +oA3 'B +oA3 Z1 oA4 -oA4O28 +oA4 O28 oA5 oA6 oA7 -oA7u'B +oA7 u 'B oA8 -oA8O19 -oA8} +oA8 O19 +oA8 } oA9 -oA9D8 +oA9 D8 oA; oA@ -oA@Z3L1 -oAB*74O5B +oA@ Z3 L1 +oAB *74 O5B oAD -oAEO06 -oAOc +oAE O06 +oAO c oAP oAR -oARl -oAXO84O24 -oAZsZ. -oA[O16 +oAR l +oAX O84 O24 +oAZ sZ. +oA[ O16 oA^ -oA_O05 +oA_ O05 oAa -oAaO02 +oAa O02 oAc -oAcO07 +oAc O07 oAd oAe oAg -oAgO13 +oAg O13 oAh oAi oAj -oAl'B +oAl 'B oAm oAn oAo -oAo+2O15 -oAoO72 -oAp'B +oAo +2 O15 +oAo O72 +oAp 'B oAr -oArO14 +oAr O14 oAs -oAsD5 -oAsl -oAsO28 -oAsO42 +oAs D5 +oAs l +oAs O28 +oAs O42 oAt oAu oAv -oAwO14 -oAwO37 +oAw O14 +oAw O37 oAx oAy -oAyO51D5 +oAy O51 D5 oAz -oAzc -oB O0A -oB!c +oAz c +oB O0A +oB! c oB* oB+ -oB/R5'8 +R5 '8 oB0 -oB0O47 +oB0 O47 oB1 oB2 -oB2D9 -oB2i6h'9 +oB2 D9 +i6h '9 oB3 oB4 oB5 -oB5*AB -oB5DA +oB5 *AB +oB5 DA oB6 -oB6D5 +oB6 D5 oB7 -oB7l +oB7 l oB8 -oB8Z1 +oB8 Z1 oB9 -oB9Z1 -oB9O05 -oBCO65 -oBKoBC -oBNcO48 -oBO+1O84 -oBSl +oB9 Z1 +oB9 O05 +oBC O65 +oBK oBC +oBN c O48 +oBO +1 O84 +oBS l oBX -oB_O26 -oB_OB2s91 +oB_ O26 +oB_ OB2 s91 oBa oBc -oBcO56O14 +oBc O56 O14 oBd -oBdO46 +oBd O46 oBe oBf -oBfO26 -oBgO29 +oBf O26 +oBg O29 oBi oBk -oBk^Zo3H +oBk ^Z o3H oBn -oBn[O84 -oBnO06 +oBn [ O84 +oBn O06 oBo -oBoO36 +oBo O36 oBr oBs oBu oBv oBy -oByO26 -oByO38 +oBy O26 +oBy O38 oBz -p1$"l -p1$< -p1$= -p1$D -p1$I -p1$Jz5 -p1$Lo6z -p1$M -p1$a -p1$b -p1$e -p1$fO17 -p1$i -p1$j -p1$j*03 -p1$k -p1$l -p1$r -p1$s -p1$v -p1$vO73 -p1$yD2 -p1'4^! -p1'6 -p1'6Z2 -p1'6o47 -p1'7 -p1'7*32 -p1'7+1 -p1'7sk{ -p1'8 -p1'9[ -p1'Az1 -p1*12 -p1*15L3 -p1*18 -p1*2A*0B -p1*37 -p1*39O7A -p1*43 -p1*50O25 -p1*51 -p1*56i7# -p1*56u -p1*63 -p1*65i0E -p1*67 -p1*69 -p1*72 -p1*76O83 -p1*7A -p1*80 -p1*83 -p1*89O2B -p1*8B -p1*8BO92 -p1*91 -p1*95R7 -p1*96O47 -p1*96O98 -p1*B6O87 -p1+1^t -p1+4 -p1+5 -p1+6O13 -p1+9 -p1-1 -p1-3 -p1@2 -p1@9'9 -p1@ic -p1C[ -p1D1 -p1D3'9 -p1D3-6 -p1D4o06 -p1D6i4, -p1D9 -p1K[ -p1KO25 -p1L1 -p1L4 -p1R1 -p1R9 -p1T0 -p1T2OB1 -p1T6 -p1T7 -p1TB@2 -p1Z1*30 -p1Z1O05 -p1Z2Z4 -p1Z4z5 -p1[O65 -p1] -p1]k -p1^ -p1^! -p1^#z2 -p1^&^/ -p1^.c -p1^3O4A -p1^8 -p1^< -p1^IT1 -p1^P -p1^Q -p1^V -p1^] -p1^]O2A -p1^a -p1^c] -p1^d -p1^eO45 -p1^j -p1^l -p1^p -p1^| -p1cD8 -p1cO08 -p1i02 -p1i1tO41 -p1i23 -p1i2U -p1i2n -p1i4 -p1i4% -p1i4/ -p1i49 -p1i4O06 -qi0UO2A -qi0l -qi0y -qi2&'6 -qi24 -qi2[ -qo07 -qo0_ -qo0b -qo0s -qo1FO26 -qo1k -qo2O -qo2y -qo4y -qo58 -qo5YO2B -qo6e -qo7**27 -qo77 -qo7n[ -qo8S -qo9.O7A -qoBa -qq -qr -qr'6 -qr'8 -qsX* -qsbB -qsbd -qsf4 -qss! -qt -qtO52 -quO61 -qO03 -qO03^u -qO03o32 -qO04 -qO05 -qO08 -qO09 -qO09*46 -qO0B -qO12 -qO13 -qO16k -qO16O52 -qO17 -qO17-1 -qO18 -qO19 -qO1A -qO1B-2 -qO1Bz3 -qO23 -qO25 -qO26 -qO27 -qO28 -qO29 -qO29o6p -qO2A -qO34 -qO35 -qO35*70 -qO36 -qO37 -qO37$y -qO38 -qO39 -qO3A -qO3B -qO3Bz4 -qO41s21 -qO42C -qO45L3 -qO46 -qO47 -qO47O12 -qO48 -qO49^s -qO4A -qO4B -qO51+5 -qO54 -qO54C -qO56 -qO59 -qO5A -qO5B -qO63 -qO64*07 -qO65 -qO65O31 -qO68 -qO6B -qO74 -qO78 -qO83 -qO83] -qO83O2A -qO84 -qO85 -qO86 -qO8B -qO92O73 -qO94 -qO95 -qO96 -qOA1*0B -qOA1O81 -qOA3 -qOA5 -qOA9 -qz1 -qz1O32 -qz2 -qz3 -qz3OB1 -q{D3 -q{O18 -q{O19 -q} -q}'6 -q}*80 +q $1 +q $3 +q $4 +q $6 +q $9 O73 +q $A +q $c +q $d +q $e +q $h +q $k +q $m +q $u +q '7 +q '8 +q '9 +q '9 *68 +q '9 -4 +q 'B +q *04 +q *05 +q *12 +q *13 +q *14 O94 +q *16 +q *16 $B +q *17 +q *20 ^o +q *26 +q *27 O82 +q *2A O53 +q *30 $2 +q *31 DA +q *35 +q *40 z3 +q *46 +q *56 { +q *69 +q *74 O12 +q *74 O7B +q *75 +q '5 +q *92 O05 +q +1 +q +1 O26 +q +3 +q +3 [ +q +4 l +q +5 +q +5 { +q +6 +q +7 +q +B +q -1 +q -3 +q -4 +q -7 +q -9 +q -A +q @0 O86 +q @a O69 +q @i +q C +q C { +q D2 O65 +q D3 +q D4 +q D5 *06 +q D8 +q D8 O61 +q D9 O43 +q L6 +q L8 +q Z1 +q Z3 +q Z5 +q [ +q [ ] +q ] +q ] $6 +q ] r +q ^* +q ^* { +q ^0 +q ^6 +q ^S +q ^a +q ^e O26 +q ^j O49 +q ^p +q ^q +q ^u ^c +q c +q d '8 +q i01 +q i0> O06 +q i0U O2A +q i0l +q i0y +q i2& '6 +q i24 +q i2[ +q o07 +q o0_ +q o0b +q o0s +q o1F O26 +q o1k +q o2O +q o2y +q o4y +q o58 +q o5Y O2B +q o6e +q o7* *27 +q o77 +q o7n [ +q o8S +q o9. O7A +q oBa +q q +q r +q r '6 +q r '8 +q sX* +q sbB +q sbd +q sf4 +q ss! +q t +q t O52 +q u O61 +q O03 +q O03 ^u +q O03 o32 +q O04 +q O05 +q O08 +q O09 +q O09 *46 +q O0B +q O12 +q O13 +q O16 k +q O16 O52 +q O17 +q O17 -1 +q O18 +q O19 +q O1A +q O1B -2 +q O1B z3 +q O23 +q O25 +q O26 +q O27 +q O28 +q O29 +q O29 o6p +q O2A +q O34 +q O35 +q O35 *70 +q O36 +q O37 +q O37 $y +q O38 +q O39 +q O3A +q O3B +q O3B z4 +q O41 s21 +q O42 C +q O45 L3 +q O46 +q O47 +q O47 O12 +q O48 +q O49 ^s +q O4A +q O4B +q O51 +5 +q O54 +q O54 C +q O56 +q O59 +q O5A +q O5B +q O63 +q O64 *07 +q O65 +q O65 O31 +q O68 +q O6B +q O74 +q O78 +q O83 +q O83 ] +q O83 O2A +q O84 +q O85 +q O86 +q O8B +q O92 O73 +q O94 +q O95 +q O96 +q OA1 *0B +q OA1 O81 +q OA3 +q OA5 +q OA9 +q z1 +q z1 O32 +q z2 +q z3 +q z3 OB1 +q { D3 +q { O18 +q { O19 +q } +q } '6 +q } *80 r -r$! -r$$ -r$& -r$*i4V -r$+f -r$2 -r$; -r$= -r$? -r$L -r$] -r$b -r$c -r$g -r$i -r$m -r$o -r$osoU -r$p -r$qZ1 -r$r -r$w -r'2 -r'5 -r'6 -r'A -r*02 -r*02K -r*02z3 -r*05 -r*07*64 -r*09 -r*10 -r*12*60 -r*14 -r*14D5 -r*15 -r*23$j -r*30 -r*34 -r*34[ -r*35[ -r*36 -r*40z2 -r*45 -r*45] -r*45^p -r*52 -r*53 -r*56 -r*57 -r*61$R -r*65O32 -r*68 -r+0 -r+4R0 -r+5 -r+6 -r+8 -r-0c -r-1*61 -r-2 -r-2^k -r-A -r@g -r@h -rC -rC$J -rC'6 -rD2 -rD3 -rD4 -rD5R8 -rD9 -rKd -rKi5e -rKz2 -rL2 -rL2*15 -rL5 -rL5L5 -rL6^q -rL7 -rL9 -rR0 -rR2 -rR3 -rR4C -rR4} -rR6 -rR8so% -rT0 -rT1 -rT7 -rZ1L4 -rZ1k -rZ1o0O -rZ2 -rZ2*05 -rZ2D3 -rZ2^- -rZ2O73 -rZ3 -rZ3Z4 -rZ3i4W -rZ3t -rZ4 -rZ4-4 -rZ5 -rZ5O09 -r[*30 -r[*54 -r]K -r]o0v -r^! -r^$ -r^%o0c -r^%u -r^5 -r^7T0 -r^; -r^@ -r^A^/ -r^B -r^H -r^I -r^M -r^S -r^U -r^\ -r^a -r^k -r^l -r^m -r^q -r^w -r^z -rc -rcK -rco6Q -rd*74 -rf -rfO3A -ri0% -ri0=z3 -ri0O^R -ri1@ -ri1S -ri1T+4 -ri1f -ri1k -ri1r -ri23 -ri2P -ri2r[ -ri2sZ4 -ri2u -ri3.T4 -ri35 -ri39z2 -ri3S -ri3i -ri3q -ri3t -ri4fz1 -ri4h -ri4v -ri5: -ri5E -ri5_ -ri5f^? -ri5m$q -ri6K -ri7l -ri7u -rk^! -rkz2 -ro0" -ro0*O13 -ro06 -ro07 -ro0C -ro0b -ro0e -ro0g -ro1F -ro1ip1 -ro2& -ro2f -ro3- -ro3W -ro3Y -ro3fZ4 -ro3p -ro3s -ro41 -ro43 -ro4t -ro51 -ro52 -ro6U -ro6zz2 -ro7[ -roA\ -rp1$J -rp2 -rp3T7 -rqz1 -rs0+ -rs0- -rs0l -rs1 -rs9! -rsJ7 -rsa3 -rsb9 -rsbq -rsil -rspQZ1 -rsra -rstE -rstk -rstp -rswg -rt -rt*40 -rO04 -rO05 -rO06 -rO07 -rO09 -rO15 -rO32 -rO37 -rO41t -rO42 -rO51 -rO51$2 -rO51K -rO54 -rO62 -rO64 -rz1D6 -rz1i4f -rz3-1 -rz3R6 -rz3T1 -r{ -r{*04 -r{D3 -r} -r}f -s $O28i2a +r $! +r $$ +r $& +r $* i4V +r $+ f +r $2 +r $; +r $= +r $? +r $L +r $] +r $b +r $c +r $g +r $i +r $m +r $o +r $o soU +r $p +r $q Z1 +r $r +r $w +r '2 +r '5 +r '6 +r 'A +r *02 +r *02 K +r *02 z3 +r *05 +r *07 *64 +r *09 +r *10 +r *12 *60 +r *14 +r *14 D5 +r *15 +r *23 $j +r *30 +r *34 +r *34 [ +r *35 [ +r *36 +r *40 z2 +r *45 +r *45 ] +r *45 ^p +r *52 +r *53 +r *56 +r *57 +r *61 $R +r *65 O32 +r *68 +r +0 +r +4 R0 +r +5 +r +6 +r +8 +r -0 c +r -1 *61 +r -2 +r -2 ^k +r -A +r @g +r @h +r C +r C $J +r C '6 +r D2 +r D3 +r D4 +r D5 R8 +r D9 +r K d +r K i5e +r K z2 +r L2 +r L2 *15 +r L5 +r L5 L5 +r L6 ^q +r L7 +r L9 +r R0 +r R2 +r R3 +r R4 C +r R4 } +r R6 +r R8 so% +r T0 +r T1 +r T7 +r Z1 L4 +r Z1 k +r Z1 o0O +r Z2 +r Z2 *05 +r Z2 D3 +r Z2 ^- +r Z2 O73 +r Z3 +r Z3 Z4 +r Z3 i4W +r Z3 t +r Z4 +r Z4 -4 +r Z5 +r Z5 O09 +r [ *30 +r [ *54 +r ] K +r ] o0v +r ^! +r ^$ +r ^% o0c +r ^% u +r ^5 +r ^7 +r ^; +r ^@ +r ^A ^/ +r ^B +r ^H +r ^I +r ^M +r ^S +r ^U +r ^\ +r ^a +r ^k +r ^l +r ^m +r ^q +r ^w +r ^z +r c +r c K +r c o6Q +r d *74 +r f +r f O3A +r i0% +r i0= z3 +r i0O ^R +r i1@ +r i1S +r i1T +4 +r i1f +r i1k +r i1r +r i23 +r i2P +r i2r [ +r i2s Z4 +r i2u +r i3. T4 +r i35 +r i39 z2 +r i3S +r i3i +r i3q +r i3t +r i4f z1 +r i4h +r i4v +r i5: +r i5E +r i5_ +r i5f ^? +r i5m $q +r i6K +r i7l +r i7u +r k ^! +r k z2 +r o0" +r o0* O13 +r o06 +r o07 +r o0C +r o0b +r o0e +r o0g +r o1F +r o1i p1 +r o2& +r o2f +r o3- +r o3W +r o3Y +r o3f Z4 +r o3p +r o3s +r o41 +r o43 +r o4t +r o51 +r o52 +r o6U +r o6z z2 +r o7[ +r oA\ +r p1 $J +r p2 +r p3 T7 +r q z1 +r s0+ +r s0- +r s0l +r s1 +r s9! +r sJ7 +r sa3 +r sb9 +r sbq +r sil +r spQ Z1 +r sra +r stE +r stk +r stp +r swg +r t +r t *40 +r O04 +r O05 +r O06 +r O07 +r O09 +r O15 +r O32 +r O37 +r O41 t +r O42 +r O51 +r O51 $2 +r O51 K +r O54 +r O62 +r O64 +r z1 D6 +r z1 i4f +r z3 -1 +r z3 R6 +r z3 T1 +r { +r { *04 +r { D3 +r } +r } f +s $ O28 i2a s - s . s 5 -s 5$8 +s 5 $8 s _ s d s g @@ -25736,7 +25696,7 @@ s y s!+ s!- s!. -s!0Z5 +s!0 Z5 s!2 s!5 s!7 @@ -25744,24 +25704,24 @@ s!8 s!I s!J s!L -s!Lz1 +s!L z1 s!X s!^ -s!co60 +s!c o60 s!k s"! s#! -s#$z2O25 +s#$ z2 O25 s#' s#* s#- -s#-Z5 +s#- Z5 s#. s#/ s#1 s#X s#^ -s#_T1 +s#_ T1 s#b s#t s#u @@ -25781,7 +25741,7 @@ s$d s$z s%# s%* -s%0u +s%0 u s%1 s%9 s%P @@ -25793,7 +25753,7 @@ s'z s(& s(* s(E -s(}o6! +s(} o6! s*# s*$ s*% @@ -25824,13 +25784,13 @@ s+G s+L s+b s+d -s,1+0 +s,1 +0 s,9 -s,rO34 +s,r O34 s,s s,z s- -s- DA +s- DA s-! s-$ s-% @@ -25838,18 +25798,18 @@ s-& s-* s-/ s-0 -s-7'8 +s-7 '8 s-9 s-@ s-A s-J -s-Qq'7 +s-Q q '7 s-T s-^ s-_ -s-_$1 -s-ou -s-s[ +s-_ $1 +s-o u +s-s [ s-z s.$ s.* @@ -25861,8 +25821,8 @@ s.8 s.9 s.; s.C -s.a$i -s.cD6 +s.a $i +s.c D6 s.e s.f s.g @@ -25871,46 +25831,46 @@ s.m s.o s.p s.x -s.x'7 -s.zlO51 +s.x '7 +s.z l O51 s/ s/? s/B s/i s/y s0 -s0 q -s0 z2 +s0 q +s0 z2 s0! -s0"'7i0B -s0%O31 +s0" '7 i0B +s0% O31 s0& s0) -s0*+6 +s0* +6 s0+ -s0+c -s0,D0 -s0,D7 +s0+ c +s0, D0 +s0, D7 s0- -s0-+6 +s0- +6 s0. s0/ -s01o17 +s01 o17 s02 s03 -s03*87 -s03p1 +s03 *87 +s03 p1 s04 s05 -s05+8 +s05 +8 s06 -s06O29+1 +s06 O29 +1 s07 -s07*13 -s08$3 -s08+7 +s07 *13 +s08 $3 +s08 +7 s09 -s09O81 +s09 O81 s0< s0@ s0A @@ -25919,127 +25879,127 @@ s0C s0D s0E s0F -s0FO37 -s0Gu +s0F O37 +s0G u s0J s0K s0M -s0PC -s0R@i-3 +s0P C +s0R @i -3 s0S -s0SZ2l -s0T[T1 -s0UD3t +s0S Z2 l +s0T [ T1 +s0U D3 t s0X -s0X'7D3 +s0X '7 D3 s0Y s0Z s0\ s0^ -s0^Z1 +s0^ Z1 s0_ -s0_[ +s0_ [ s0` s0a -s0aT9 +s0a T9 s0b s0c s0d s0e s0f s0g -s0g[ -s0h-0 +s0g [ +s0h -0 s0i s0j -s0j*04 +s0j *04 s0k -s0k-4 +s0k -4 s0m -s0m[C -s0mp1 -s0mz2 +s0m [ C +s0m p1 +s0m z2 s0n s0o -s0oc +s0o c s0q -s0q-4 -s0qd +s0q -4 +s0q d s0r -s0rL1 +s0r L1 s0s s0v s0w s0x -s0xc +s0x c s0y -s0y$a +s0y $a s0z -s0zO06 +s0z O06 s0| s1 -s1 [ +s1 [ s1! -s1!Z2 -s1!Z2$0 +s1! Z2 +s1! Z2 $0 s1# -s1#'8 -s1#^d +s1# '8 +s1# ^d s1$ s1% s1& -s1*D4 +s1* D4 s1+ s1- s1. s1/ s10 s12 -s12@e -s12oA0 +s12 @e +s12 oA0 s13 -s13D3 -s13Z1 +s13 D3 +s13 Z1 s14 s15 -s15-2 -s15shk +s15 -2 +s15 shk s16 -s16l +s16 l s17 -s17@b +s17 @b s18 -s18*85 -s18L6 -s18Z1 -s18u -s18O08$? -s18O26 +s18 *85 +s18 L6 +s18 Z1 +s18 u +s18 O08 $? +s18 O26 s19 -s19Z1 +s19 Z1 s1; s1= -s1=i04 -s1>z2 +s1= i04 +s1> z2 s1? -s1?T7o0C +s1? T7 o0C s1@ s1A s1B -s1Bt +s1B t s1D s1E s1F s1I s1K -s1Kc +s1K c s1L -s1NuZ2 +s1N u Z2 s1P -s1Rq +s1R q s1S s1U -s1U'5@b +s1U '5 @b s1V s1W s1X @@ -26047,355 +26007,355 @@ s1^ s1_ s1` s1a -s1asgF +s1a sgF s1c -s1cR0 +s1c R0 s1d s1e -s1eoAd -s1f'B +s1e oAd +s1f 'B s1g -s1gD0 +s1g D0 s1h s1i s1k -s1kd +s1k d s1l s1m s1n s1o s1p -s1pu +s1p u s1q -s1ql +s1q l s1r -s1r^1{ -s1rz4 +s1r ^1 { +s1r z4 s1s s1t s1u -s1u*37 +s1u *37 s1v -s1v*21 +s1v *21 s1w -s1w-4 -s1w-9 -s1wr +s1w -4 +s1w -9 +s1w r s1x s1y -s1y{ +s1y { s1z s2 -s2 'B +s2 'B s2! -s2!Z4@c -s2!^a +s2! Z4 @c +s2! ^a s2# s2$ s2* -s2**5AO43 -s2*Z2 -s2*r +s2* *5A O43 +s2* Z2 +s2* r s2+ s2, s2- s2. s20 -s20$! +s20 $! s21 -s21*82'6 -s21p1O36 +s21 *82 '6 +s21 p1 O36 s23 -s23Z2 -s23d +s23 Z2 +s23 d s24 -s25Z1 -s25o2_ -s25o3m +s25 Z1 +s25 o2_ +s25 o3m s26 -s26l +s26 l s27 -s27C +s27 C s28 -s28T0 -s28Z1 +s28 T0 +s28 Z1 s29 -s29$e +s29 $e s2< s2? s2@ -s2@+0 +s2@ +0 s2A s2B -s2Bu -s2DdO1A +s2B u +s2D d O1A s2F -s2GcO51 +s2G c O51 s2H s2K s2L s2M -s2Ql +s2Q l s2T -s2U^Z +s2U ^Z s2W s2X s2Z s2^ s2_ s2a -s2ao1f +s2a o1f s2b s2c -s2c[ +s2c [ s2d s2e -s2eq +s2e q s2f s2g s2h s2i -s2i^4'6 -s2j^Y^5 -s2k$h -s2k'5 +s2i ^4 '6 +s2j ^Y ^5 +s2k $h +s2k '5 s2l -s2lc +s2l c s2p s2s s2t -s2uO32^1 +s2u O32 ^1 s2v -s2v[ +s2v [ s2w s2y -s2y$RO46 -s2yD7D6 +s2y $R O46 +s2y D7 D6 s2z -s2zO61 +s2z O61 s3 s3! s3# s3$ s3% -s3'^2Z1 +s3' ^2 Z1 s3+ -s3++3 +s3+ +3 s3, -s3.Z4 -s3.u +s3. Z4 +s3. u s30 -s30*65 +s30 *65 s31 -s31Z2 -s31o77 +s31 Z2 +s31 o77 s32 -s32^i +s32 ^i s34 -s34$8 -s34c +s34 $8 +s34 c s35 s36 -s36u +s36 u s37 -s37L1 +s37 L1 s38 -s38+8 -s38c -s38O52 +s38 +8 +s38 c +s38 O52 s39 -s3?Z1 +s3? Z1 s3@ s3A -s3At +s3A t s3E s3F -s3GcO92 -s3Hz1 -s3K-5 -s3L[ +s3G c O92 +s3H z1 +s3K -5 +s3L [ s3S -s3Tf +s3T f s3V -s3W+5D5 +s3W D5 s3X s3Y s3[ s3^ s3_ -s3`l +s3` l s3a s3b s3c -s3d} +s3d } s3e -s3e$7 -s3e+5 +s3e $7 +s3e +5 s3f -s3fO03o48 -s3gO32 +s3f O03 o48 +s3g O32 s3h -s3iD7 +s3i D7 s3j s3k s3l -s3l*65 +s3l *65 s3m s3o s3q -s3qp1 +s3q p1 s3r -s3s[ -s3s^c +s3s [ +s3s ^c s3t -s3tr +s3t r s3u -s3ui1g +s3u i1g s3x s3y s3z -s3zi3ti0K +s3z i3t i0K s3} -s3}R5 +s3} R5 s4 -s4 Z1 -s4 i0z*15 +s4 Z1 +s4 i0z *15 s4$ s4% s4& -s4&i1o'7 -s4*u -s4+Z3 -s4+c +s4& i1o '7 +s4* u +s4+ Z3 +s4+ c s4, s4- s4. -s4/Z2 +s4/ Z2 s40 s41 s42 -s42Z1 +s42 Z1 s43 -s43s./ +s43 s./ s45 -s45s69 +s45 s69 s46 s47 -s47q +s47 q s48 s49 -s49*07 -s49o0l -s4:o5sc +s49 *07 +s49 o0l +s4: o5s c s4A s4C s4F s4G -s4HO02^w +s4H O02 ^w s4I -s4MO27^V +s4M O27 ^V s4O s4R s4X s4\ -s4^i5mO07 +s4^ i5m O07 s4_ -s4_O71 +s4_ O71 s4a s4b s4e s4f -s4gZ1 +s4g Z1 s4i s4j -s4j-3 +s4j -3 s4k -s4kOA1 -s4n^M -s4no6g +s4k OA1 +s4n ^M +s4n o6g s4o -s4o@9 -s4oZ2 +s4o @9 +s4o Z2 s4p -s4qo4e +s4q o4e s4r -s4rD0 +s4r D0 s4s -s4s*30 +s4s *30 s4v -s4wu +s4w u s4x -s4x$p -s4x^E -s4yD5 -s4ys.M +s4x $p +s4x ^E +s4y D5 +s4y s.M s4z s5 -s5 Z5 +s5 Z5 s5! s5# -s5%'5+3 -s5%O41 +s5% '5 +3 +s5% O41 s5* -s5+Z1 +s5+ Z1 s5, -s5.O23 +s5. O23 s5/ s50 s51 s52 -s52'B -s52-6 -s52o71 +s52 'B +s52 -6 +s52 o71 s53 -s53T0 +s53 T0 s54 -s54-1 +s54 -1 s56 s57 s58 -s58+8 +s58 +8 s59 -s59q -s5=O42 +s59 q +s5= O42 s5G s5J s5S -s5Z*15 -s5\i0h*56 +s5Z *15 +s5\ i0h *56 s5_ -s5ai7k +s5a i7k s5b -s5bL0 +s5b L0 s5c s5d -s5do06 +s5d o06 s5e -s5el +s5e l s5f s5g -s5gT7 -s5hq +s5g T7 +s5h q s5i s5k s5m s5n -s5ni4t +s5n i4t s5o -s5o+5 -s5qZ3 -s5r$c -s5rZ1 +s5o +5 +s5q Z3 +s5r $c +s5r Z1 s5s s5t s5w -s5wo45 -s5x[ -s5yO34q +s5w o45 +s5x [ +s5y O34 q s6! -s6![ -s6$[ -s6%l +s6! [ +s6$ [ +s6% l s6* s6+ s6- @@ -26405,112 +26365,112 @@ s60 s61 s62 s63 -s63-7 +s63 -7 s64 -s64$2 -s64T5 +s64 $2 +s64 T5 s65 s67 s68 -s68scv +s68 scv s69 -s69s71 +s69 s71 s6: -s6=d +s6= d s6@ -s6BT1o0w -s6Bc +s6B T1 o0w +s6B c s6C s6J -s6K*25 +s6K *25 s6N -s6OD4 -s6SC -s6Wc +s6O D4 +s6S C +s6W c s6X -s6]*06 -s6_^|i4* +s6] *06 +s6_ ^| i4* s6a -s6aslA +s6a slA s6b -s6bR0 -s6cc +s6b R0 +s6c c s6d s6e -s6e^b +s6e ^b s6f s6g -s6jZ3r +s6j Z3 r s6k -s6lZ1z1 +s6l Z1 z1 s6m -s6mZ2 +s6m Z2 s6n s6o -s6o$7 +s6o $7 s6p -s6po3h +s6p o3h s6q s6r s6t -s6ud -s6v*37O05 +s6u d +s6v *37 O05 s6w s6y s7 -s7 O04 +s7 O04 s7! s7" s7$ -s7%u -s7&O14z3 -s7)Z4*06 +s7% u +s7& O14 z3 +s7) Z4 *06 s7+ s7- -s7--1 +s7- -1 s7. s7/ s70 -s70Z2 +s70 Z2 s71 -s71L1 +s71 L1 s72 -s72o0a +s72 o0a s73 s74 -s74+8 -s74Z2 -s74[ +s74 +8 +s74 Z2 +s74 [ s75 -s75$t +s75 $t s76 -s76-6 -s76L6c -s76c +s76 -6 +s76 L6 c +s76 c s78 -s78O32 +s78 O32 s79 -s79$m -s79i0W -s7;*26o3N +s79 $m +s79 i0W +s7; *26 o3N s7= s7C s7D -s7D$z +s7D $z s7I s7L s7M s7N s7P -s7Qq -s7V@cD0 -s7W*31 +s7Q q +s7V @c D0 +s7W *31 s7Y -s7^lD2 -s7^o3o +s7^ l D2 +s7^ o3o s7a s7b -s7bO27 +s7b O27 s7c s7d s7e @@ -26518,13 +26478,13 @@ s7f s7g s7i s7j -s7j$k +s7j $k s7l -s7nO36i0k -s7nO56 +s7n O36 i0k +s7n O56 s7q s7r -s7rO13 +s7r O13 s7s s7v s7x @@ -26532,160 +26492,160 @@ s7| s8! s8# s8$ -s8$tO46 +s8$ t O46 s8* s8, s8- s8. -s8.*07-0 +s8. *07 -0 s8/ s80 -s80$n -s80+5 -s80l -s81O32d +s80 $n +s80 +5 +s80 l +s81 O32 d s82 -s83o1f +s83 o1f s84 -s84-2R1 +s84 -2 R1 s85 s86 -s86^z -s87C +s86 ^z +s87 C s89 -s89D0 -s8:[ +s89 D0 +s8: [ s8A s8B -s8B[s6q -s8Bc -s8D-3 +s8B [ s6q +s8B c +s8D -3 s8F s8H s8J s8K -s8M*02 +s8M *02 s8O -s8Pc +s8P c s8Q s8R -s8U'5 -s8Wl +s8U '5 +s8W l s8X s8^ s8a -s8aR3Z3 -s8aT5 -s8bp1O39 +s8a R3 Z3 +s8a T5 +s8b p1 O39 s8c -s8c*01 -s8cZ1 -s8csyi +s8c *01 +s8c Z1 +s8c syi s8d s8e -s8ez3 +s8e z3 s8g s8h s8i -s8iZ1 +s8i Z1 s8j s8k s8l -s8lZ2 -s8l^y -s8ll +s8l Z2 +s8l ^y +s8l l s8m -s8mp2'7 +s8m p2 '7 s8n -s8ni4r -s8nl +s8n i4r +s8n l s8o -s8qZ1 +s8q Z1 s8t -s8t[ -s8to23 +s8t [ +s8t o23 s8u -s8uO16$W -s8uO61 -s8vO41 +s8u O16 $W +s8u O61 +s8v O41 s8x s8y s8z -s8z+7 +s8z +7 s9 -s9 D4 -s9 O01 +s9 D4 +s9 O01 s9! s9" -s9"t +s9" t s9# s9$ -s9%} +s9% } s9* -s9*z2T0 -s9,Cp2 +s9* z2 T0 +s9, C p2 s9- s9. -s9.D7 +s9. D7 s90 -s90$m -s90$y -s90[ -s90i0d +s90 $m +s90 $y +s90 [ +s90 i0d s91 -s92*57 -s92-5 +s92 *57 +s92 -5 s93 s94 -s94i45 -s94i75l +s94 i45 +s94 i75 l s95 -s95^8z3 +s95 ^8 z3 s97 -s97*67 -s97R3 -s97T4 -s97z1 +s97 *67 +s97 R3 +s97 T4 +s97 z1 s98 s9; s9@ s9B s9D -s9Es8S +s9E s8S s9G -s9Hi3M^, +s9H i3M ^, s9J -s9LO14^m -s9PO45 +s9L O14 ^m +s9P O45 s9T -s9Z*93*43 +s9Z *93 *43 s9\ s9^ s9_ -s9_Z2 -s9_r +s9_ Z2 +s9_ r s9a -s9az2 +s9a z2 s9b -s9b+5 -s9bo4vL0 -s9bO56 +s9b +5 +s9b o4v L0 +s9b O56 s9c s9d -s9d*13 +s9d *13 s9e s9f s9i s9k -s9lZ2 +s9l Z2 s9n s9o s9p s9q s9r s9u -s9u-7 -s9uO05 +s9u -7 +s9u O05 s9w s9x s9y @@ -26698,10 +26658,10 @@ s=; s?! s@" s@* -s@u +s_> u s_U -s_aO13 +s_a O13 s_i sa -sa!r +sa! r sa' -sa)$@O01 +sa) $@ O01 sa* sa+ sa- -sa-l +sa- l sa. -sa.O41 +sa. O41 sa/ sa0 -sa0D4 -sa0l +sa0 D4 +sa0 l sa1 sa2 -sa2k +sa2 k sa3 -sa3Z4 -sa3O15 +sa3 Z4 +sa3 O15 sa4 -sa4C -sa4d -sa4q -sa4u +sa4 C +sa4 d +sa4 q +sa4 u sa5 -sa5z2 +sa5 z2 sa6 sa7 -sa7D6 -sa7Z2 -sa7o0b +sa7 D6 +sa7 Z2 +sa7 o0b sa8 sa9 -sa9Z2 +sa9 Z2 sa; -sa;$a +sa; $a sa= -sa=$5 +sa= $5 sa? sa@ -sa@+1 -sa@T1 -sa@T3 -sa@c -sa@d -sa@se3 -sa@se3si! -sa@se3si1 -sa@si! -sa@si1 -sa@so0 -sa@so0se3 -sa@so0si! -sa@so0si1 -sa@so0u -sa@ss$ -sa@u +sa@ +1 +sa@ T1 +sa@ T3 +sa@ c +sa@ d +sa@ se3 +sa@ se3 si! +sa@ se3 si1 +sa@ si! +sa@ si1 +sa@ so0 +sa@ so0 se3 +sa@ so0 si! +sa@ so0 si1 +sa@ so0 u +sa@ ss$ +sa@ u saA -saA+2 -saAZ2 -saCz2u +saA +2 +saA Z2 +saC z2 u saD -saER2 -saE{ +saE R2 +saE { saF -saFc +saF c saH -saLo1Q +saL o1Q saO saP -saQc +saQ c saR -saSO23 +saS O23 saU saW saY -saZ-6 +saZ -6 sa[ sa^ -sa^z2O65 +sa^ z2 O65 sac sad -sad$5^q -sadO52 +sad $5 ^q +sad O52 sae -sae$1 -sae*74 -saeD6 -saei2m +sae $1 +sae *74 +sae D6 +sae i2m saf sag sah sai sak -sakD6 -samD4O51 +sak D6 +sam D4 O51 san -sani40 +san i40 sao -saoZ4 +sao Z4 sap -sap$y -sap} +sap $y +sap } saq -saqZ2 -saqz1 +saq Z2 +saq z1 sar -sar-6 -sari1n +sar -6 +sar i1n sas sat -satt +sat t sau -sauk -sauO43 +sau k +sau O43 sav -savR4 +sav R4 saw -sawZ1O46 +saw Z1 O46 sax -saxo3z -saxr +sax o3z +sax r say -say^Az2 -sayz4 +say ^A z2 +say z4 saz -saz@p -sazO35O23 +saz @p +saz O35 O23 sa| -sb c +sb c sb! sb# sb$ sb& -sb&z4 -sb)^L +sb& z4 +sb) ^L sb- sb/ sb0 -sb0*23^t -sb0+0+4 -sb0i0D +sb0 *23 ^t +sb0 +0 +4 +sb0 i0D sb1 -sb1z1 +sb1 z1 sb2 sb3 sb4 sb5 -sb5d -sb5o79 -sb5u +sb5 d +sb5 o79 +sb5 u sb6 sb7 -sb7R1 -sb7l +sb7 R1 +sb7 l sb8 -sb8d -sb8u +sb8 d +sb8 u sb9 -sb9R5 +sb9 R5 sb: -sbs8= +sf7 Z1 +sf9 Z1 z1 +sf> s8= sfB sfF -sfFT4 +sfF T4 sfJ -sfK*26 -sfKO05 -sfNl +sfK *26 +sfK O05 +sfN l sfO sfT -sfUR0 -sfW$! +sfU R0 +sfW $! sfX -sfZo0L +sfZ o0L sf[ sf_ sfa -sfa'A +sfa 'A sfb sfc -sfc^k +sfc ^k sfd -sfg*15z2 -sfg@g -sfgO54 +sfg *15 z2 +sfg @g +sfg O54 sfh sfj -sfjz5 +sfj z5 sfk -sfk]] -sfkOB8 +sfk ] ] +sfk OB8 sfm sfn -sfn[ +sfn [ sfo sfp sfq -sfqi0z^3 +sfq i0z ^3 sfr -sfrD4 +sfr D4 sfs -sfs$! -sfsZ2 +sfs $! +sfs Z2 sfB u sft -sfv*86 +sfv *86 sfw -sfy$o +sfy $o sfz -sf{c -sg t +sf{ c +sg t sg# -sg#$* +sg# $* sg$ sg- sg1 -sg2] +sg2 ] sg3 sg4 -sg4*26 +sg4 *26 sg5 sg6 -sg6^0 +sg6 ^0 sg8 sg9 -sg9$f -sg9d -sg9u +sg9 $f +sg9 d +sg9 u sgC sgD sgE sgF -sgH[ +sgH [ sgJ sgN -sgOu +sgO u sgR -sgSc +sgS c sgT -sgTu +sgT u sgU -sgU^r +sgU ^r sgY -sg_+4*64 +sg_ +4 *64 sga -sgaZ4 +sga Z4 sgb sgc -sgf^r -sghl -sghO24 +sgf ^r +sgh l +sgh O24 sgi sgj -sgjL5 -sgk'B -sgki6u +sgj L5 +sgk 'B +sgk i6u sgl -sgl$9 -sgll -sgml +sgl $9 +sgl l +sgm l sgn -sgn-2 -sgnT0^j +sgn -2 +sgn T0 ^j sgo -sgo'7u +sgo '7 u sgp sgq -sgqt +sgq t sgr sgs sgt sgv -sgvo0m +sgv o0m sgw -sgw$7 -sgwD3 -sgwp1 +sgw $7 +sgw D3 +sgw p1 sgx -sgxo5d*13 +sgx o5d *13 sgy sgz -sgzi0m -sh*k -sh,O14 -sh-o0g -sh0} +sgz i0m +sh* k +sh, O14 +sh- o0g +sh0 } sh2 -sh2Z2 -sh2lc -sh2O52 -sh4^2 -sh4iA0O25 +sh2 Z2 +sh2 c +sh2 O52 +sh4 ^2 +sh4 iA0 O25 sh6 sh7 -sh7K -sh8o2% +sh7 K +sh8 o2% sh9 -sh9z3 -shBO4A +sh9 z3 +shB O4A shF shL shM shO -shRZ1 +shR Z1 shS shT -shT+2L1 +shT +2 L1 shU -shVo6m -shW^@o09 -shXD4 -shYc +shV o6m +shW ^@ o09 +shX D4 +shY c shZ sh^ -sh_$g +sh_ $g sha -shao4l +sha o4l shb -shbK +shb K shc -shc$j +shc $j shd she -she^a +she ^a shf shg -shi-3 +shi -3 shj shk -shk*02^i -shkD7D3 +shk *02 ^i +shk D7 D3 shl shm -shm$m -shmt +shm $m +shm t shn -shn$ui3o -shpO01 +shn $u i3o +shp O01 shq shr -shrD6 -shrz5 +shr D6 +shr z5 shs -shs$5 +shs $5 sht shu -shvZ1 -shvO46 +shv Z1 +shv O46 shx -shxc +shx c shy -shyu +shy u shz -shz-2O31 -shz{ +shz -2 O31 +shz { si -si l +si l si! -si!T1 -si!T2 -si!T3 -si!T4 -si!T5 -si!T6 -si!T8 -si!d -si!sl1 -si!ss$ -si!ss$u -si!u +si! T1 +si! T2 +si! T3 +si! T4 +si! T5 +si! T6 +si! T8 +si! d +si! sl1 +si! ss$ +si! ss$ u +si! u si" si$ si* si+ si- -si-o1ul +si- o1u l si. si1 -si1D6 -si1T1 -si1T2 -si1T3 -si1T4 -si1T5 -si1T6 -si1T7 -si1T8 -si1d -si1se3 -si1se3u -si1ss$ -si1ss$u -si1u +si1 D6 +si1 T1 +si1 T2 +si1 T3 +si1 T4 +si1 T5 +si1 T6 +si1 T7 +si1 T8 +si1 d +si1 se3 +si1 se3 u +si1 ss$ +si1 ss$ u +si1 u si2 -si2Z1 -si2O45 +si2 Z1 +si2 O45 si3 -si3*31 +si3 *31 si4 -si4$3 +si4 $3 si5 si6 si7 si9 -si9z1 -si;*82 -si=z1 -si@O36 -siCKc -siCl -siEu +si9 z1 +si; *82 +si= z1 +si@ O36 +siC K c +siC l +siE u siG -siGz2 -siId +siG z2 +siI d siM -siNl +siN l sik -siNsNk +siN sNk siO -siP*61 -siRZ1 +siP *61 +siR Z1 siW si[ si] -si^} +si^ } sia -siaZ2 -sib*45 -sibZ1 -sic$7 +sia Z2 +sib *45 +sib Z1 +sic $7 sid sie -sieo06 -sieo6h -sifo5WO02 -sifO26 +sie o06 +sie o6h +sif o5W O02 +sif O26 sih sij -sik*41 +sik *41 sil sim sin sio -sioK -sioO23 +sio K +sio O23 sip -sipp2O4B -siqk +sip p2 O4B +siq k sir sit siu siv siw -siwO31 -six$3 +siw O31 +six $3 siy -siyO12 +siy O12 siz -sizO01 -sj D0 +siz O01 +sj D0 sj# sj$ sj% -sj%'4 -sj-{ +sj% '4 +sj- { sj. sj1 -sj2z2 +sj2 z2 sj6 -sj7{+1 +sj7 { +1 sj8 sj9 sj? @@ -27685,7 +27645,7 @@ sj@ sjB sjC sjF -sjFl +sjF l sjH sjK sjL @@ -27696,155 +27656,155 @@ sjW sjY sjb sjd -sjdZ1 +sjd Z1 sjf -sjfd -sjfO37 +sjf d +sjf O37 sjg -sjgd +sjg d sjh -sjh$r +sjh $r sjl -sjl*05O53 +sjl *05 O53 sjm sjn -sjnZ2 +sjn Z2 sjo -sjo+3 +sjo +3 sjp sjq -sjqu -sjqO28 +sjq u +sjq O28 sjr sjs -sjs+2o4s +sjs +2 o4s sjt -sjtT1T8 -sjt[ +sjt T1 T8 +sjt [ sjx sjy -sjzD4[ -sk&u +sjz D4 [ +sk& u sk- sk0 sk2 -sk4O02 -sk7Z4 +sk4 O02 +sk7 Z4 sk8 sk9 -sk9z3^; +sk9 z3 ^; sk@ skA skB skC -skD$! -skDdO76 +skD $! +skD d O76 skG skL -skL-6 +skL -6 skM -skOZ2D3 +skO Z2 D3 skP skR skT skW -skW-7 -skZk*05 +skW -7 +skZ k *05 sk[ sk] sk^ -sk^'A +sk^ 'A sk_ ska skb -skbK -skb[O23 +skb K +skb [ O23 skc -skc[ +skc [ skd ske skf -skfD9O15 +skf D9 O15 skg -skg'8 -skg^sO1A -skgo4 +skg '8 +skg ^s O1A +skg o4 skh -skho3e -skhsYc +skh o3e +skh sYc ski -skii4z -skio2i +ski i4z +ski o2i skl skm -skm-5 -skmZ1 -skn@z -skn^p -skno1o +skm -5 +skm Z1 +skn @z +skn ^p +skn o1o sko skp -skpz3 +skp z3 skq skr sks -sks^-$6 -sksz1 -sksz4 +sks ^- $6 +sks z1 +sks z4 skt sku -skwr +skw r skx sky -skyD1 -skyc -skyi0n -skyO31 +sky D1 +sky c +sky i0n +sky O31 skz -skz'6 +skz '6 sl sl! -sl"*94 -sl"t +sl" *94 +sl" t sl$ sl* sl- -sl-O31 -sl/Z2 +sl- O31 +sl/ Z2 sl1 -sl1T1 -sl1T2 -sl1T3 -sl1T4 -sl1T5 -sl1T6 -sl1T7 -sl1d -sl1u +sl1 T1 +sl1 T2 +sl1 T3 +sl1 T4 +sl1 T5 +sl1 T6 +sl1 T7 +sl1 d +sl1 u sl2 -sl2z2L3 +sl2 z2 L3 sl4 -sl4Z5 +sl4 Z5 sl5 sl6 sl7 -sl7D4 +sl7 D4 sl8 -sl8O26 +sl8 O26 sl9 sl; -sl;D1 +sl; D1 sl< -sl?o5b -sl@l +sl? o5b +sl@ l slB -slDz2O32 +slD z2 O32 slF -slGi2u +slG i2u slH slL slM -slMT2 +slM T2 slO slP slQ @@ -27852,160 +27812,160 @@ slR slS slT slU -slUO15+2 -slVi4R +slU O15 +2 +slV i4R slW -slXi1qk -slZl +slX i1q k +slZ l sl] -sl^*62*16 +sl^ *62 *16 sl_ -sl`O41O83 +sl` O41 O83 sla -slao1O +sla o1O slb -slbZ2 -slbu -slbz2O18 +slb Z2 +slb u +slb z2 O18 slc -slcD0 +slc D0 sld -sld[ +sld [ sle slf -slf*12[ -slfu +slf *12 [ +slf u slg -slh+5 -slho10 +slh +5 +slh o10 sli slj -slj$u -slj{ +slj $u +slj { slk -slkZ4 +slk Z4 slm -slm$a -slm$w +slm $a +slm $w sln -slnZ4sp! -slnO43 +sln Z4 sp! +sln O43 slo -slo+5 -sloi2l -slou +slo +5 +slo i2l +slo u slp slq -slr$0^& -slrr +slr $0 ^& +slr r sls -sls^a +sls ^a slt -slt*50 -sltT6 +slt *50 +slt T6 slu -slu$7 +slu $7 slv slw slx -slx^i +slx ^i sly -slyo8( -slyO41 -slyO43 -slz'6 +sly o8( +sly O41 +sly O43 +slz '6 sl{ sl| -sl|o10[ +sl| o10 [ sm$ -sm$dO64 -sm$p2O34 -sm&o7H +sm$ d O64 +sm$ p2 O34 +sm& o7H sm+ sm- sm. sm/ sm1 -sm1$g -sm1C -sm1L6 -sm1^a'4 -sm1^e +sm1 $g +sm1 C +sm1 L6 +sm1 ^a '4 +sm1 ^e sm2 -sm2O62 +sm2 O62 sm3 -sm3*24 +sm3 *24 sm4 -sm4D2 +sm4 D2 sm5 sm6 -sm7Z1 -sm7z4 +sm7 Z1 +sm7 z4 sm8 -sm8O21 +sm8 O21 sm; -sm@t +sm@ t smB -smC$# +smC $# smD smG -smH-0u -smHi0s -smKuZ2 +smH -0 u +smH i0s +smK u Z2 smL -smM*32{ -smO'5 +smM *32 { +smO '5 smP -smPu +smP u smQ -smRO31 -smSp2'4 +smR O31 +smS p2 '4 smW -smXo5"+6 +smX o5" +6 smZ -sm[Cc -sm]^MO16 +sm[ c +sm] ^M O16 sm` smb smc smd -smdZ1 -smdO51 +smd Z1 +smd O51 sme -smeD1 +sme D1 smf -smf^6 +smf ^6 smg -smg'5 -smg[ +smg '5 +smg [ smj -smj-3 +smj -3 smk sml -smlk -smlu +sml k +sml u smn -smnt +smn t smo -smo'8c +smo '8 c smp -smp] +smp ] smq smr sms -smsD5 +sms D5 smt -smti6iO02 -smtz1{ +smt i6i O02 +smt z1 { smu -smu+4 -smu-2 -smui4b -smuo1 +smu +4 +smu -2 +smu i4b +smu o1 smv -smvi5n +smv i5n smw -smw+5} +smw +5 } smy smz sn# @@ -28017,190 +27977,190 @@ sn- sn0 sn1 sn2 -sn2Z3 -sn3rL2 +sn2 Z3 +sn3 r L2 sn4 -sn4-5 -sn4R6 -sn5O16 +sn4 -5 +sn4 R6 +sn5 O16 sn6 -sn6c +sn6 c sn7 -sn7d -sn7u +sn7 d +sn7 u sn8 sn9 sn; -snAZ3o4y +snA Z3 o4y snB -snDD2 -snGD0O67 -snGc +snD D2 +snG D0 O67 +snG c snH -snK*02p1 -snLc +snK *02 p1 +snL c snN snR -snRo5C +snR o5C snT -snT^H +snT ^H snX -snXO08 -sn\Z1 -sn^i2Cl +snX O08 +sn\ Z1 +sn^ i2C l sn_ -sn_l +sn_ l sna snb -snb-0 -snbo0L +snb -0 +snb o0L snc -sncq -sncO1A+2 +snc q +snc O1A +2 snd -sndZ2 -sndO02 +snd Z2 +snd O02 sne snf sng -sngR0'6 -sngi3t +sng R0 '6 +sng i3t snh -snh$! -snh*64 -snh*84O54 -snhp1 -snii2+ +snh $! +snh *64 +snh *84 O54 +snh p1 +sni i2+ snj -snjo3v +snj o3v snk snl -snl'9 +snl '9 snm -snmp1O23 -snmO53 -sno@i +snm p1 O23 +snm O53 +sno @i snp snq -snqr +snq r snr sns -snsz2 +sns z2 snt -sntc +snt c snu -snusey +snu sey snv snw -snwL6 -snwo4< +snw L6 +snw o4< snx sny -snyp1 +sny p1 snz -snz'7 +snz '7 sn| -sn|fO3A +sn| f O3A so! so" so# so$ -so'O24 +so' O24 so* so, so. so0 -so0T1 -so0T2 -so0T3 -so0T4 -so0T5 -so0T6 -so0T7 -so0T8 -so0d -so0sa4 -so0se3 -so0se3si! -so0se3si1 -so0se3ss$ -so0se3u -so0si! -so0si!ss$ -so0si!u -so0si1 -so0si1ss$ -so0si1u -so0sl1 -so0sl1u -so0ss$ -so0ss$u -so0u +so0 T1 +so0 T2 +so0 T3 +so0 T4 +so0 T5 +so0 T6 +so0 T7 +so0 T8 +so0 d +so0 sa4 +so0 se3 +so0 se3 si! +so0 se3 si1 +so0 se3 ss$ +so0 se3 u +so0 si! +so0 si! ss$ +so0 si! u +so0 si1 +so0 si1 ss$ +so0 si1 u +so0 sl1 +so0 sl1 u +so0 ss$ +so0 ss$ u +so0 u so1 -so1$b+4 -so1z2 +so1 $b +4 +so1 z2 so3 -so3i4j -so3lk +so3 i4j +so3 l k so4 so5 so6 -so6Z5O09 +so6 Z5 O09 so8 so; so= so> so@ -so@O05 -soCc -soCcZ2 -soIc +so@ O05 +soC c +soC c Z2 +soI c soK soN -soNi6k +soN i6k soO -soQ$? -soQl +soQ $? +soQ l soS soT soY so] so^ soa -soa[ +soa [ sob -soc*13 +soc *13 sod -sodL2 -sod] +sod L2 +sod ] soe sof -sof-5$: +sof -5 $: sog soh soi -soi^t +soi ^t sol -somO26 +som O26 sop soq sor -sor{ +sor { sos sot sou -souR6 +sou R6 sov sow soy -soyD7@u -soyp1 -soyt -sozsjA -sp)[ +soy D7 @u +soy p1 +soy t +soz sjA +sp) [ sp+ sp. -sp/-0 +sp/ -0 sp1 sp2 sp5 @@ -28208,23 +28168,23 @@ sp6 sp9 sp= spD -spGlC -spNZ3*39 -spNO05 -spSc +spG C +spN Z3 *39 +spN O05 +spS c spT -spT*32l -spVc -spV{i3[ -spWc +spT *32 l +spV c +spV { i3[ +spW c spY -spYtl -spZl +spY l +spZ l sp[ spb -spb*50 +spb *50 spc -spck +spc k spd spf spg @@ -28233,407 +28193,407 @@ spj spk spl spm -spmK +spm K spr -sprd +spr d sps spt spu spv -spw$s -spxq +spw $s +spx q spy -spyp1 +spy p1 spz -sp}o24@a +sp} o24 @a sq -sq$z3O03 +sq$ z3 O03 sq9 sqb -sqcK -sqdo1l -sqgD3 -sqid +sqc K +sqd o1l +sqg D3 +sqi d sqk sql sqm sqw sqx -sr *65 -sr O32 +sr *65 +sr O32 sr! sr$ -sr%L2 -sr&u -sr&O1Ap2 +sr% L2 +sr& u +sr& O1A p2 sr' -sr)$/ +sr) $/ sr+ sr0 -sr0O17 +sr0 O17 sr1 -sr1$_O14 +sr1 $_ O14 sr2 -sr2R5 -sr2c -sr3$m +sr2 R5 +sr2 c +sr3 $m sr4 sr5 -sr5D1 +sr5 D1 sr6 sr7 sr8 -sr:} -sr>O54 +sr: } +sr> O54 sr? -srGl -srHO21 +srG l +srH O21 srI srJ -srLqR5 -srN[ +srL q R5 +srN [ srR srS -srTO03 -srWC -srWdl -srXo3k -srXO32 +srT O03 +srW C +srW d l +srX o3k +srX O32 srY -srYu +srY u srZ sr\ sra -sraD1 -sra{] +sra D1 +sra { ] srb -srbZ2 -src+5 -src-1 -srcO23 +srb Z2 +src +5 +src -1 +src O23 srd -sreD5 +sre D5 srf -srfc -srf}i3X +srf c +srf } i3X srg -srgr -srgsny -srgz2 +srg r +srg sny +srg z2 srh -srid -srjO32 -srjO64 +sri d +srj O32 +srj O64 srk -srkO23 +srk O23 srl -srlZ2 +srl Z2 srm srn -srn*20 -sro+4 -srp^f +srn *20 +sro +4 +srp ^f srq srs -srs$m -srssaj +srs $m +srs saj srt -srt} +srt } sru -sru} -srv^c +sru } +srv ^c srw -srw^[$m -srwt -srwz3 +srw ^[ $m +srw t +srw z3 srx -srxT3O32 +srx T3 O32 sry -sry^l +sry ^l srz -srz'4 +srz '4 sr} -sr}ur +sr} u r ss# ss$ -ss$T1 -ss$T2 -ss$T3 -ss$T4 -ss$T5 -ss$T6 -ss$T7 -ss$T8 -ss$d -ss$sl1 -ss$u +ss$ T1 +ss$ T2 +ss$ T3 +ss$ T4 +ss$ T5 +ss$ T6 +ss$ T7 +ss$ T8 +ss$ d +ss$ sl1 +ss$ u ss% ss' ss* -ss*z4Z4 -ss+O52 -ss+} +ss* z4 Z4 +ss+ O52 +ss+ } ss, ss- ss. ss0 -ss0Z2 +ss0 Z2 ss1 -ss1r +ss1 r ss2 -ss2T4 -ss2t +ss2 T4 +ss2 t ss3 -ss3Z2 -ss3d -ss3u +ss3 Z2 +ss3 d +ss3 u ss4 -ss4-6 +ss4 -6 ss5 -ss5D3 -ss5d -ss5se3 -ss5u +ss5 D3 +ss5 d +ss5 se3 +ss5 u ss6 -ss6T3 +ss6 T3 ss7 ss8 ss9 ss: -ss=u +ss= u ss> ssB -ssBu +ssB u ssC -ssEu -ssFT3 +ssE u +ssF T3 ssH -ssHsoBl +ssH soB l ssK -ssOo0| +ssO o0| ssS ssT -ssTO45 +ssT O45 ssW ssZ -ss\l +ss\ l ss^ ss_ ss` ssa -ssal +ssa l ssb -ssbk +ssb k ssc -ssdi3i -ssdO32 +ssd i3i +ssd O32 ssf -ssfZ2 -ssfO04 -ssg*75 +ssf Z2 +ssf O04 +ssg *75 ssh -sshk +ssh k ssi ssj -ssjK -ssji5r +ssj K +ssj i5r ssk -ssk-5 -sskp1 +ssk -5 +ssk p1 ssl ssm -ssm$a -ssm$m +ssm $a +ssm $m ssn -ssn*45 -ssn^1 -ssndl +ssn *45 +ssn ^1 +ssn d l sso -ssoo8#*65 -ssop1 +sso o8# *65 +sso p1 ssp -ssp+7 +ssp +7 ssr sst -sstt +sst t ssu -ssuZ3O54 -ssuz2 +ssu Z3 O54 +ssu z2 ssv -ssvo5x +ssv o5x ssw -sswi12*18 -ssxZ1 -ssxc +ssw i12 *18 +ssx Z1 +ssx c ssy -ssy] -ssyO32 +ssy ] +ssy O32 ssz -ssz+3 -sszo0s +ssz +3 +ssz o0s st -st +0 -st!^bO23 +st +0 +st! ^b O23 st# -st*R6 +st* R6 st+ st, st/ st1 -st1-0 -st1{t -st2o0j -st3z5'8 +st1 -0 +st1 { t +st2 o0j +st3 z5 '8 st4 -st4O13 -st5Z2 -st5q -st5u +st4 O13 +st5 Z2 +st5 q +st5 u st6 st7 -st7d -st7u +st7 d +st7 u st8 -st;i4$^n -st -t$A -t$D -t$E -t$F -t$Id -t$O -t$P -t$Pk -t$R -t$R[ -t$T -t$T*76 -t$V -t$^ -t$_$h -t$` -t$a -t$b -t$d+7 -t$i -t$r -t$s -t'4 -t'7Z1 -t'7sg7 -t'9 -t*04k -t*05 -t*12p1 -t*14 -t*15 -t*20 -t*21 -t*31 -t*34 -t*37 -t*46 -t*78 -t*9A -t+0 -t+2 -t+3 -t+3u -t+4Z1 -t+4^a -t+4u -t+5^D -t+6 -t+8 -t+8o0M -t+9 -t-0 -t-3 -t-6-1 -t-7 -t-7*65 -t-7O03 -t-8 -t-A -t@# -t@1 -t@3 -t@7 -t@8O32 -t@E -t@K -t@L+7 -t@Lo1! -t@O -t@Oc -t@P -t@V -t@l -t@y -tD1-3 -tD1[ -tD4sLA -tD5$` -tD8 -tD8O24 -tDAO72 -tL4 -tL5 -tL5u -tR0 -tR1 -tR1*05 -tR3 -tR4 -tR7 -tT1o1h -tT3 -tT4 -tT5 -tT6O58 -tT9 -tZ1o26 -tZ1O45 -tZ3 -tZ3+8 -tZ3[ -tZ4 -tZ5O12 -t[ -t]{ -t^! -t^1 -t^1$2 -t^2O43 -t^6O3A -t^7 -t^FD5 -t^L -t^R+5 -t^Ss14 -t^V -t^W -t^Z -t^\ -t^b -t^d -t^e -t^f -t^j -t^o -t^p -t^t} -t^vL1 -t^{^' -tc^Z -td -tdOA4 -tfO3B -tfO4A -tf} -ti0B -ti0Q -ti1-Z1 -ti11 -ti1M -ti1Q -ti1S -ti1au -ti1v^B -ti22 -ti2F -ti2G -ti2P -ti2c -ti2y -ti3 -ti3.o55 -ti3G -ti3K -ti3L -ti3e -ti3p -ti3z -ti4* -ti4A[ -ti4C$7 -ti4G -ti4O$5 -ti4a^Q -ti4y -ti5N -ti5e -ti5y -ti62 -ti6O -ti7B -ti7P -ti7S -ti7l -ti9N -tl+A -to06 -to07O74 -to0F -to0H -to0S -to0V -to0Y -to0f -to0m -to0n -to0o -to1B -to1Cc -to1I -to1Ou -to1U -to1Z -to1y -to2 -to28o4M -to2FO32 -to2K -to2S -to2T -to2` -to2a -to2z -to3" -to30'6 -to3Cd -to3G -to3L$e -to3Lz1 -to3Rr -to3f -to3f$1 -to3kO21 -to4# -to42 -to4E -to4T -to4` -to4oT6 -to4y -to5 -to54 -to5J -to5TO81 -to5dD0 -to5k -to5s -to5u -to6 -to61 -to66 -to6F -to6z -to7! -to71O25 -to77 -to7K -to7S -to7X -to7_*41 -to7d -to7x -to82 -to86 -to8I -to8J -to8L -to8O -to8T -to9P -toA1O34 -tp1*41 -tp1^u -tp1z2 -tp2 -tp2O82 -tq+5 -tqZ2 -trD2 -ts0D -ts0Y -ts0e -ts0w -ts1n -ts2) -ts3e -ts4U -ts4f -ts52 -ts6b -ts6zl -ts7Kt -ts9! -tsBZ -tsF9 -tsJk -tsLH -tsLN -tsMD -tsN8 -tsNs -tsS9 -tsTc -tsTku -tsUR -tsUe -tsV6$Z -tsVFc -tsVG -tsXB -tsZK -tsgX -tskC -tui7Z -tO02O17 -tO03 -tO04 -tO04f -tO05 -tO06 -tO12 -tO12i3J -tO14O27 -tO15z1 -tO16p1 -tO17+0 -tO23 -tO24 -tO26 -tO31z1 -tO32 -tO32Z3 -tO32[ -tO34 -tO36 -tO38 -tO41i5a -tO42 -tO45 -tO46 -tO48 -tO52 -tO54 -tO57 -tO61 -tO62 -tO62@2 -tO63^9 -tO72 -tO74 -tO82 -tO93 -tOA2 -tz1^% -tz1O07 -tz2 -tz2L2 -tz2O0B -tz2O63 -tz2z3 -tz3 -t{*54 -t} -t}k +t $! +t $! sR< +t $" +t $( +t $* +t $, +t $- s8] +t $4 i10 +t $6 +t $8 z3 +t $; +t $= +t $> +t $A +t $D +t $E +t $F +t $I d +t $O +t $P +t $P k +t $R +t $R [ +t $T +t $T *76 +t $V +t $^ +t $_ $h +t $` +t $a +t $b +t $d +7 +t $i +t $r +t $s +t '4 +t '7 Z1 +t '7 sg7 +t '9 +t *04 k +t *05 +t *12 p1 +t *14 +t *15 +t *20 +t *21 +t *31 +t *34 +t *37 +t *46 +t *78 +t *9A +t +0 +t +2 +t +3 +t +3 u +t +4 Z1 +t +4 ^a +t +4 u +t +5 ^D +t +6 +t +8 +t +8 o0M +t +9 +t -0 +t -3 +t -6 -1 +t -7 +t -7 *65 +t -7 O03 +t -8 +t -A +t @# +t @1 +t @3 +t @7 +t @8 O32 +t @E +t @K +t @L +7 +t @L o1! +t @O +t @O c +t @P +t @V +t @l +t @y +t D1 -3 +t D1 [ +t D4 sLA +t D5 $` +t D8 +t D8 O24 +t DA O72 +t L4 +t L5 +t L5 u +t R0 +t R1 +t R1 *05 +t R3 +t R4 +t R7 +t o1h +t T3 +t T4 +t T5 +t T6 O58 +t T9 +t Z1 o26 +t Z1 O45 +t Z3 +t Z3 +8 +t Z3 [ +t Z4 +t Z5 O12 +t [ +t ] { +t ^! +t ^1 +t ^1 $2 +t ^2 O43 +t ^6 O3A +t ^7 +t ^F D5 +t ^L +t ^R +5 +t ^S s14 +t ^V +t ^W +t ^Z +t ^\ +t ^b +t ^d +t ^e +t ^f +t ^j +t ^o +t ^p +t ^t } +t ^v L1 +t ^{ ^' +c ^Z +t d +t d OA4 +t f O3B +t f O4A +t f } +t i0B +t i0Q +t i1- Z1 +t i11 +t i1M +t i1Q +t i1S +i1a u +t i1v ^B +t i22 +t i2F +t i2G +t i2P +t i2c +t i2y +t i3 +t i3. o55 +t i3G +t i3K +t i3L +t i3e +t i3p +t i3z +t i4* +t i4A [ +t i4C $7 +t i4G +t i4O $5 +t i4a ^Q +t i4y +t i5N +t i5e +t i5y +t i62 +t i6O +t i7B +t i7P +t i7S +t i7l +t i9N +l +A +t o06 +t o07 O74 +t o0F +t o0H +t o0S +t o0V +t o0Y +t o0f +t o0m +t o0n +t o0o +t o1B +o1C c +t o1I +o1O u +t o1U +t o1Z +t o1y +t o2 +t o28 o4M +t o2F O32 +t o2K +t o2S +t o2T +t o2` +t o2a +t o2z +t o3" +t o30 '6 +t o3C d +t o3G +t o3L $e +t o3L z1 +t o3R r +t o3f +t o3f $1 +t o3k O21 +t o4# +t o42 +t o4E +t o4T +t o4` +t o4o T6 +t o4y +t o5 +t o54 +t o5J +t o5T O81 +t o5d D0 +t o5k +t o5s +t o5u +t o6 +t o61 +t o66 +t o6F +t o6z +t o7! +t o71 O25 +t o77 +t o7K +t o7S +t o7X +t o7_ *41 +t o7d +t o7x +t o82 +t o86 +t o8I +t o8J +t o8L +t o8O +t o8T +t o9P +t oA1 O34 +t p1 *41 +t p1 ^u +t p1 z2 +t p2 +t p2 O82 +t q +5 +t q Z2 +t r D2 +t s0D +t s0Y +t s0e +t s0w +t s1n +t s2) +t s3e +t s4U +t s4f +t s52 +t s6b +s6z l +t s7K t +t s9! +t sBZ +t sF9 +t sJk +t sLH +t sLN +t sMD +t sN8 +t sNs +t sS9 +t sTc +t sTk u +t sUR +t sUe +t sV6 $Z +t sVF c +t sVG +t sXB +t sZK +t sgX +t skC +u i7Z +t O02 O17 +t O03 +t O04 +t O04 f +t O05 +t O06 +t O12 +t O12 i3J +t O14 O27 +t O15 z1 +t O16 p1 +t O17 +0 +t O23 +t O24 +t O26 +t O31 z1 +t O32 +t O32 Z3 +t O32 [ +t O34 +t O36 +t O38 +t O41 i5a +t O42 +t O45 +t O46 +t O48 +t O52 +t O54 +t O57 +t O61 +t O62 +t O62 @2 +t O63 ^9 +t O72 +t O74 +t O82 +t O93 +t OA2 +t z1 ^% +t z1 O07 +t z2 +t z2 L2 +t z2 O0B +t z2 O63 +t z2 z3 +t z3 +t { *54 +t } +t } k u -u$!d] -u$# -u$$ -u$&d] -u$* -u$+ -u$+d] -u$- -u$-d] -u$. -u$0 -u$0$0 -u$0$0$0 -u$0$0$1 -u$0$0$7 -u$0$1 -u$0$2 -u$0$3 -u$0$4 -u$0$5 -u$0$6 -u$0$7 -u$0$8 -u$0$9 -u$0d] -u$1$0 -u$1$1 -u$1$1$1 -u$1$2 -u$1$2$3 -u$1$2$3$4 -u$1$2$3$4$5 -u$1$2$3$4$5$6 -u$1$2$3$a$b$c -u$1$2$a$b -u$1$3 -u$1$4 -u$1$5 -u$1$6 -u$1$7 -u$1$8 -u$1$9 -u$1$9$6$0 -u$1$9$6$1 -u$1$9$6$2 -u$1$9$6$3 -u$1$9$6$4 -u$1$9$6$5 -u$1$9$6$6 -u$1$9$6$7 -u$1$9$6$8 -u$1$9$6$9 -u$1$9$7$0 -u$1$9$7$1 -u$1$9$7$2 -u$1$9$7$3 -u$1$9$7$4 -u$1$9$7$5 -u$1$9$7$6 -u$1$9$7$7 -u$1$9$7$8 -u$1$9$7$9 -u$1$9$8$0 -u$1$9$8$1 -u$1$9$8$2 -u$1$9$8$3 -u$1$9$8$4 -u$1$9$8$5 -u$1$9$8$6 -u$1$9$8$7 -u$1$9$8$8 -u$1$9$8$9 -u$1$9$9$0 -u$1$9$9$1 -u$1$9$9$2 -u$1$9$9$3 -u$1$9$9$4 -u$1$9$9$5 -u$1$9$9$6 -u$1$9$9$7 -u$1$9$9$8 -u$1$9$9$9 -u$1d] -u$2 -u$2$0 -u$2$0$0$0 -u$2$0$0$1 -u$2$0$0$2 -u$2$0$0$3 -u$2$0$0$4 -u$2$0$0$5 -u$2$0$0$6 -u$2$0$0$7 -u$2$0$0$8 -u$2$0$0$9 -u$2$0$1$0 -u$2$0$1$1 -u$2$0$1$2 -u$2$0$1$3 -u$2$0$1$4 -u$2$0$1$5 -u$2$0$1$6 -u$2$0$1$7 -u$2$0$1$8 -u$2$0$1$9 -u$2$0$2$0 -u$2$0$2$1 -u$2$0$2$2 -u$2$0$2$3 -u$2$0$2$4 -u$2$0$2$5 -u$2$0$2$6 -u$2$0$2$7 -u$2$0$2$8 -u$2$0$2$9 -u$2$1 -u$2$2 -u$2$2$2 -u$2$3 -u$2$3$4 -u$2$4 -u$2$5 -u$2$6 -u$2$7 -u$2$8 -u$2$9 -u$2^f -u$2d] -u$3$0 -u$3$1 -u$3$2 -u$3$2$1 -u$3$3 -u$3$3$3 -u$3$4 -u$3$4$5 -u$3$5 -u$3$6 -u$3$7 -u$3$8 -u$3$9 -u$3d] -u$4 -u$4$0 -u$4$1 -u$4$2 -u$4$3 -u$4$3$2$1 -u$4$4 -u$4$4$4 -u$4$5 -u$4$5$6 -u$4$6 -u$4$7 -u$4$8 -u$4$9 -u$4d] -u$5 -u$5$0 -u$5$1 -u$5$2 -u$5$3 -u$5$4 -u$5$4$3$2$1 -u$5$5 -u$5$5$5 -u$5$6 -u$5$6$7 -u$5$7 -u$5$8 -u$5$9 -u$5d] -u$6 -u$6$0 -u$6$1 -u$6$2 -u$6$3 -u$6$4 -u$6$5 -u$6$5$4$3$2$1 -u$6$6 -u$6$6$6 -u$6$7 -u$6$7$8 -u$6$8 -u$6$9 -u$6^\ -u$6d] -u$7 -u$7$0 -u$7$1 -u$7$2 -u$7$3 -u$7$4 -u$7$5 -u$7$6 -u$7$7 -u$7$7$7 -u$7$8 -u$7$8$9 -u$7$9 -u$7d] -u$8$0 -u$8$1 -u$8$2 -u$8$3 -u$8$4 -u$8$5 -u$8$6 -u$8$7 -u$8$8 -u$8$8$8 -u$8$9 -u$8d] -u$9 -u$9$0 -u$9$1 -u$9$2 -u$9$3 -u$9$4 -u$9$5 -u$9$6 -u$9$7 -u$9$8 -u$9$9 -u$9$9$9 -u$9Z4 -u$9d] -u$: -u$? -u$@ -u$C -u$FO23 -u$Fz4 -u$H -u$I$O -u$S^1 -u$UO52 -u$X -u$_ -u$_d] -u$a -u$bD1 -u$i -u$j^F -u$m -u$o -u$y -u$zK -u'4 -u'6 -u'A -u'B -u*04] -u*05-5 -u*21 -u*30i5) -u*32 -u*32+2 -u*51o69 -u*52 -u*56 -u*67 -u*68 -u*75D5 -u+0 -u+1 -u+2 -u+4 -u+5 -u+6 -u+6^I -u+7 -u+7R7 -u+A -u-0 -u-2 -u-3^! -u-4 -u-4$g -u-5 -u-5'6 -u-6 -u-8 -u@0 -u@1sAM -u@7 -u@A -uD0+2 -uD0D7 -uD0o47 -uD3 -uD4o3t -uD4O43 -uD6 -uD8 -uL0 -uL1+4 -uL2 -uL2T4 -uL2r -uL2z1 -uL3 -uL4 -uL4i0Y -uR0 -uR5 -uT1 -uT1D3 -uT2 -uT5[ -uT6 -uT7 -uT8 -uZ1O75 -uZ4*27 -uZ4^z -uZ5 -uZ5$0 -uZ5O57 -u[L5 -u[T2 -u[T3 -u[^N -u]$V -u]-3 -u]^* -u^# -u^$ -u^( -u^. -u^0 -u^0^0^0^2 -u^0^1^0^2 -u^0^6^9^1 -u^0^7^9^1 -u^0^8^9^1 -u^0^9^9^1 -u^1 -u^1^0^0^2 -u^1^6^9^1 -u^1^7^9^1 -u^1^8^9^1 -u^1^9^9^1 -u^2^0^0^2 -u^2^6^9^1 -u^2^7^9^1 -u^2^8^9^1 -u^2^9^9^1 -u^3 -u^3^0^0^2 -u^3^2^1 -u^3^6^9^1 -u^3^7^9^1 -u^3^8^9^1 -u^3^9^9^1 -u^4^0^0^2 -u^4^3^2^1 -u^4^6^9^1 -u^4^7^9^1 -u^4^8^9^1 -u^4^9^9^1 -u^5 -u^5^0^0^2 -u^5^4^3^2^1 -u^5^6^9^1 -u^5^7^9^1 -u^5^8^9^1 -u^5^9^9^1 -u^6 -u^6^0^0^2 -u^6^5^4^3^2^1 -u^6^6^9^1 -u^6^7^9^1 -u^6^8^9^1 -u^6^9^9^1 -u^7 -u^7^0^0^2 -u^7^6^9^1 -u^7^7^9^1 -u^7^8^9^1 -u^7^9^9^1 -u^8 -u^8^0^0^2 -u^8^6^9^1 -u^8^7^9^1 -u^8^8^9^1 -u^8^9^9^1 -u^9 -u^9^0^0^2 -u^9^6^9^1 -u^9^7^9^1 -u^9^8^9^1 -u^9^9^9^1 -u^> -u^? -u^Bi1R -u^D -u^EO41 -u^K*15 -u^M -u^Q -u^U -u^V-1 -u^Y -u^_ -u^b -u^e -u^ii60 -u^uc -u^x-1 -u^| -uc@g -uco3Q -ud'B -udO12 -uf-5 -ui0$o5V -ui0NO16 -ui1! -ui1& -ui1' -ui1* -ui1+ -ui1. -ui1.i3.$. -ui1.i3.i5.$. -ui10 -ui10i31i52i73 -ui11 -ui11i31 -ui11i31i51 -ui11i31i51i71 -ui11i31i51i71i91 -ui11i31i51i71i91iB1 -ui11i32 -ui11i32i53 -ui11i32i53i74 -ui11i32i53i74i95 -ui11i32i53i74i95iB6 -ui12 -ui13 -ui15 -ui16 -ui17 -ui18 -ui19 -ui1_ -ui2! -ui2$ -ui2& -ui2' -ui2* -ui2+ -ui2- -ui20 -ui21 -ui22 -ui23 -ui24 -ui25 -ui26 -ui27 -ui28 -ui29 -ui2D -ui2I -ui2W -ui2_ -ui3! -ui3# -ui3$ -ui3& -ui3' -ui3* -ui3+ -ui3. -ui30 -ui31 -ui32 -ui33 -ui34 -ui35 -ui36 -ui37 -ui38 -ui39 -ui3O{ -ui3_ -ui4! -ui4# -ui4$ -ui4& -ui4' -ui4+ -ui4- -ui4. -ui40 -ui41 -ui42 -ui43 -ui44 -ui45 -ui46 -ui47 -ui48 -ui49 -ui4@ -ui4C -ui4D -ui4F -ui4J -ui4L -ui4TL7 -ui4_ -ui4u} -ui5 -ui5! -ui5# -ui5$ -ui5& -ui5' -ui5* -ui5+ -ui5- -ui5. -ui50 -ui51 -ui52 -ui53 -ui54 -ui56 -ui57 -ui59 -ui5E -ui5H -ui5L -ui5Q -ui5Y -ui5Z -ui6 -ui6! -ui6# -ui6$ -ui6& -ui6' -ui6* -ui6+ -ui6- -ui6. -ui60 -ui61 -ui62 -ui63 -ui64 -ui65 -ui66 -ui67 -ui68 -ui69 -ui6P -ui6_ -ui6r -ui7(O17 -ui7N -ui88l -ui8C -ui8N -uiB3 -ukO21 -uls0? -uls0i -uo0< -uo0A -uo0B -uo0VK -uo0W -uo14 -uo1F -uo1d -uo1k -uo25t -uo2G*23 -uo2U -uo2W[ -uo2i -uo3$ -uo33 -uo3V -uo4J -uo4Q -uo4Z -uo4Z'8 -uo4c -uo4pc -uo4z -uo4{ -uo5$ -uo5= -uo5L -uo5U -uo65 -uo6A -uo6H -uo6Ro0U -uo7% -uo78 -uo7I -uo7U -uo83 -uo90 -uoA8 -up1$R -up1-5 -up2O69 -up2O76 -uqO5A -us0_@B -us0b -us1c -us1d^d -us2n -us4T -us5R -us6& -us6c -us7t -us94 -us9D -us9_ -usCK -usCY -usEs -usG! -usLH -usMK -usP= -usPC -usRN -usS!Z2 -usTG -usTzr -usVX -usX> -usYM -ut$K -ut-3 -uO03O46 -uO04p3 -uO0A -uO13 -uO14p1 -uO14z4 -uO15 -uO18^L -uO1A -uO1B -uO21+1 -uO21K -uO24 -uO26z2 -uO28 -uO35 -uO35Z1 -uO41 -uO42 -uO42z4 -uO46 -uO47 -uO53 -uO54 -uO58 -uO59O02 -uO64 -uO67 -uO74 -uO75 -uO83 -uOA1 -uOA3 -uz1 -uz1$4 -uz1*31 -uz1*61 -uz1D4 -uz2 -uz2+3 -uz3 -uz3o6B -uz3q -uz4 -uz4+4 -uz5i5C -u{Z1 -u{r -u}d -u}o2E -u}o4V -O01$N*23 -O01$j -O01$m -O01$p -O01'9 -O01+2o42 -O01@1 -O01@H -O01@k -O01Co2G -O01Kd -O01T4o2N -O01^2$y -O01^M -O01c$n -O01csRu -O01i4s -O01i4u -O01i8i -O01l$9 -O01lo6# -O01o0 -O01o1: -O01o1a -O01o2& -O01o2HC -O01o2[ -O01o3e -O01o42} -O01o4S -O01o4i -O01o4x -O01o5L -O01qt -O01qO0B -O01sl. -O01sry -O01sta -O01swf -O01tf -O01O0A -O01O54 -O01O93 -O01z4^J -O01z5Z1 -O01{^h -O02$" -O02$% -O02$* -O02$+ -O02$1 -O02$1Z2 -O02$6 -O02$B -O02$P -O02$f -O02$g -O02$k -O02$n -O02$q -O02$s -O02'4 -O02'5 -O02'A -O02*20 -O02*23 -O02*31 -O02+1 -O02+2 -O02+2$7 -O02+3 -O02+3*02 -O02+6 -O02+8 -O02+A -O02-4 -O02-7 -O02@0 -O02C -O02D3 -O02D5 -O02D6 -O02K{ -O02L5 -O02R5 -O02T5 -O02Z1 -O02Z1R2 -O02Z2 -O02Z4 -O02Z4suM -O02^% -O02^2 -O02^M -O02^U -O02^X -O02^b -O02^g -O02^j -O02^u -O02^v -O02^x -O02^y -O02d -O02f -O02f+0 -O02i0, -O02i0f -O02i2^ -O02i2l -O02i4f -O02i5e -O02i6| -O02i9i -O02k -O02o1. -O02o1n -O02o1p -O02o1z -O02o2 -O02o2- -O02o2v -O02o3y -O02o4# -O02o4- -O02o4h$9 -O02p2 -O02qz3 -O02r -O02rk -O02s51z3 -O02sAO -O02sFH -O02str -O02syl -O02t*50 -O02u -O02O13 -O02O35 -O02O46 -O02O53 -O02O63 -O02O82 -O02O91 -O02z1 -O02z1f -O02z2 -O02z3 -O02z3l -O02z5 -O02z5z2 -O02{ -O03$! -O03$# -O03$2 -O03$5 -O03$6 -O03$R -O03$^ -O03$e -O03$h -O03$i -O03$j -O03$n -O03$r -O03'6 -O03'A -O03*12*50 -O03*30 -O03*31 -O03*34 -O03+0 -O03+0sy! -O03+2 -O03+6 -O03-0 -O03@n -O03CsK9 -O03D1 -O03D4 -O03L6 -O03R0 -O03R1 -O03R2 -O03R3 -O03T6 -O03Z1$i -O03Z2*74 -O03Z3 -O03Z3z2 -O03Z4 -O03Z5 -O03^1 -O03^@ -O03^F -O03^L -O03^g -O03^u -O03^w -O03d -O03f -O03f] -O03i0-^U -O03i0T -O03i1B -O03i2B -O03i2t -O03i4L -O03i5G -O03k -O03l -O03o1q -O03o1y -O03o3O -O03o66 -O03o69 -O03o7@ -O03p2 -O03p3 -O03p4 -O03p5'9 -O03q -O03qz3 -O03s2 -O03sld -O03ts8a -O03O19 -O03O34 -O03O34^d -O03O35 -O03O43 -O03O48 -O03z1 -O03z1sc? -O03z1} -O03z5 -O03{K -O04$$ -O04$3 -O04$F -O04$r -O04$s -O04$v -O04$y -O04$| -O04'3 -O04'5 -O04'8 -O04*02 -O04*78 -O04+1 -O04-1$M -O04-1+2 -O04@f -O04@l -O04@p -O04C -O04D8 -O04L0 -O04L7 -O04R5 -O04T3 -O04Z1 -O04Z2 -O04Z3 -O04Z4 -O04Z5 -O04^ -O04^P -O04^a -O04^l -O04^m -O04^o -O04^q -O04^y -O04csRi -O04d -O04di0n -O04i0d -O04i1a -O04i22 -O04i3d'4 -O04i3p -O04i44 -O04i6 -O04i6_ -O04l -O04o0'Z5 -O04o10+9 -O04o2 -O04o3% -O04o51 -O04p2 -O04p3 -O04p4i3B -O04sN[R1 -O04sf:'7 -O04u -O04O49 -O04O61 -O04O62 -O04O74 -O04z2 -O04{ -O05$ -O05$+ -O05$/ -O05$0 -O05$4 -O05$@@3 -O05$S -O05'9 -O05'A -O05*41 -O05-2 -O05-4 -O05D3 -O05R3Z2 -O05T4 -O05Z1 -O05Z1$u -O05Z2C -O05Z4 -O05Z4C -O05Z5 -O05^# -O05^+ -O05^-q -O05^? -O05^_ -O05^h -O05^j -O05^mO64 -O05^r -O05^t@o -O05^w -O05k -O05l^3 -O05o1 -O05o1P -O05o3t -O05o4a -O05p1 -O05p1[ -O05p2 -O05p3 -O05q -O05r -O05sum -O05tZ4 -O05O41 -O05O53 -O05z2 -O05z3 -O05z5 +u $! d ] +u $# +u $$ +u $& d ] +u $* +u $+ +u $+ d ] +u $- +u $- d ] +u $. +u $0 +u $0 $0 +u $0 $0 $0 +u $0 $0 $1 +u $0 $0 $7 +u $0 $1 +u $0 $2 +u $0 $3 +u $0 $4 +u $0 $5 +u $0 $6 +u $0 $7 +u $0 $8 +u $0 $9 +u $0 d ] +u $1 $0 +u $1 $1 +u $1 $1 $1 +u $1 $2 +u $1 $2 $3 +u $1 $2 $3 $4 +u $1 $2 $3 $4 $5 +u $1 $2 $3 $4 $5 $6 +u $1 $2 $3 $a $b $c +u $1 $2 $a $b +u $1 $3 +u $1 $4 +u $1 $5 +u $1 $6 +u $1 $7 +u $1 $8 +u $1 $9 +u $1 $9 $6 $0 +u $1 $9 $6 $1 +u $1 $9 $6 $2 +u $1 $9 $6 $3 +u $1 $9 $6 $4 +u $1 $9 $6 $5 +u $1 $9 $6 $6 +u $1 $9 $6 $7 +u $1 $9 $6 $8 +u $1 $9 $6 $9 +u $1 $9 $7 $0 +u $1 $9 $7 $1 +u $1 $9 $7 $2 +u $1 $9 $7 $3 +u $1 $9 $7 $4 +u $1 $9 $7 $5 +u $1 $9 $7 $6 +u $1 $9 $7 $7 +u $1 $9 $7 $8 +u $1 $9 $7 $9 +u $1 $9 $8 $0 +u $1 $9 $8 $1 +u $1 $9 $8 $2 +u $1 $9 $8 $3 +u $1 $9 $8 $4 +u $1 $9 $8 $5 +u $1 $9 $8 $6 +u $1 $9 $8 $7 +u $1 $9 $8 $8 +u $1 $9 $8 $9 +u $1 $9 $9 $0 +u $1 $9 $9 $1 +u $1 $9 $9 $2 +u $1 $9 $9 $3 +u $1 $9 $9 $4 +u $1 $9 $9 $5 +u $1 $9 $9 $6 +u $1 $9 $9 $7 +u $1 $9 $9 $8 +u $1 $9 $9 $9 +u $1 d ] +u $2 +u $2 $0 +u $2 $0 $0 $0 +u $2 $0 $0 $1 +u $2 $0 $0 $2 +u $2 $0 $0 $3 +u $2 $0 $0 $4 +u $2 $0 $0 $5 +u $2 $0 $0 $6 +u $2 $0 $0 $7 +u $2 $0 $0 $8 +u $2 $0 $0 $9 +u $2 $0 $1 $0 +u $2 $0 $1 $1 +u $2 $0 $1 $2 +u $2 $0 $1 $3 +u $2 $0 $1 $4 +u $2 $0 $1 $5 +u $2 $0 $1 $6 +u $2 $0 $1 $7 +u $2 $0 $1 $8 +u $2 $0 $1 $9 +u $2 $0 $2 $0 +u $2 $0 $2 $1 +u $2 $0 $2 $2 +u $2 $0 $2 $3 +u $2 $0 $2 $4 +u $2 $0 $2 $5 +u $2 $0 $2 $6 +u $2 $0 $2 $7 +u $2 $0 $2 $8 +u $2 $0 $2 $9 +u $2 $1 +u $2 $2 +u $2 $2 $2 +u $2 $3 +u $2 $3 $4 +u $2 $4 +u $2 $5 +u $2 $6 +u $2 $7 +u $2 $8 +u $2 $9 +u $2 ^f +u $2 d ] +u $3 $0 +u $3 $1 +u $3 $2 +u $3 $2 $1 +u $3 $3 +u $3 $3 $3 +u $3 $4 +u $3 $4 $5 +u $3 $5 +u $3 $6 +u $3 $7 +u $3 $8 +u $3 $9 +u $3 d ] +u $4 +u $4 $0 +u $4 $1 +u $4 $2 +u $4 $3 +u $4 $3 $2 $1 +u $4 $4 +u $4 $4 $4 +u $4 $5 +u $4 $5 $6 +u $4 $6 +u $4 $7 +u $4 $8 +u $4 $9 +u $4 d ] +u $5 +u $5 $0 +u $5 $1 +u $5 $2 +u $5 $3 +u $5 $4 +u $5 $4 $3 $2 $1 +u $5 $5 +u $5 $5 $5 +u $5 $6 +u $5 $6 $7 +u $5 $7 +u $5 $8 +u $5 $9 +u $5 d ] +u $6 +u $6 $0 +u $6 $1 +u $6 $2 +u $6 $3 +u $6 $4 +u $6 $5 +u $6 $5 $4 $3 $2 $1 +u $6 $6 +u $6 $6 $6 +u $6 $7 +u $6 $7 $8 +u $6 $8 +u $6 $9 +u $6 ^\ +u $6 d ] +u $7 +u $7 $0 +u $7 $1 +u $7 $2 +u $7 $3 +u $7 $4 +u $7 $5 +u $7 $6 +u $7 $7 +u $7 $7 $7 +u $7 $8 +u $7 $8 $9 +u $7 $9 +u $7 d ] +u $8 $0 +u $8 $1 +u $8 $2 +u $8 $3 +u $8 $4 +u $8 $5 +u $8 $6 +u $8 $7 +u $8 $8 +u $8 $8 $8 +u $8 $9 +u $8 d ] +u $9 +u $9 $0 +u $9 $1 +u $9 $2 +u $9 $3 +u $9 $4 +u $9 $5 +u $9 $6 +u $9 $7 +u $9 $8 +u $9 $9 +u $9 $9 $9 +u $9 Z4 +u $9 d ] +u $: +u $? +u $@ +u $C +u $F O23 +u $F z4 +u $H +u $I $O +u $S ^1 +u $U O52 +u $X +u $_ +u $_ d ] +u $a +u $b D1 +u $i +u $j ^F +u $m +u $o +u $y +u $z K +u '4 +u '6 +u 'A +u 'B +u *04 ] +u *05 -5 +u *21 +u *30 i5) +u *32 +u *32 +2 +u *51 o69 +u *52 +u *56 +u *67 +u *68 +u *75 D5 +u +0 +u +1 +u +2 +u +4 +u +5 +u +6 +u +6 ^I +u +7 +u +7 R7 +u +A +u -0 +u -2 +u -3 ^! +u -4 +u -4 $g +u -5 +u -5 '6 +u -6 +u -8 +u @0 +u @1 sAM +u @7 +u @A +u D0 +2 +u D0 D7 +u D0 o47 +u D3 +u D4 o3t +u D4 O43 +u D6 +u D8 +u L0 +u L1 +4 +u L2 +u L2 T4 +u L2 r +u L2 z1 +u L3 +u L4 +u L4 i0Y +u R0 +u R5 +u T1 +u T1 D3 +u T2 +u T5 [ +u T6 +u T7 +u T8 +u Z1 O75 +u Z4 *27 +u Z4 ^z +u Z5 +u Z5 $0 +u Z5 O57 +u [ L5 +u [ T2 +u [ T3 +u [ ^N +u ] $V +u ] -3 +u ] ^* +u ^# +u ^$ +u ^( +u ^. +u ^0 +u ^0 ^0 ^0 ^2 +u ^0 ^1 ^0 ^2 +u ^0 ^6 ^9 ^1 +u ^0 ^7 ^9 ^1 +u ^0 ^8 ^9 ^1 +u ^0 ^9 ^9 ^1 +u ^1 +u ^1 ^0 ^0 ^2 +u ^1 ^6 ^9 ^1 +u ^1 ^7 ^9 ^1 +u ^1 ^8 ^9 ^1 +u ^1 ^9 ^9 ^1 +u ^2 ^0 ^0 ^2 +u ^2 ^6 ^9 ^1 +u ^2 ^7 ^9 ^1 +u ^2 ^8 ^9 ^1 +u ^2 ^9 ^9 ^1 +u ^3 +u ^3 ^0 ^0 ^2 +u ^3 ^2 ^1 +u ^3 ^6 ^9 ^1 +u ^3 ^7 ^9 ^1 +u ^3 ^8 ^9 ^1 +u ^3 ^9 ^9 ^1 +u ^4 ^0 ^0 ^2 +u ^4 ^3 ^2 ^1 +u ^4 ^6 ^9 ^1 +u ^4 ^7 ^9 ^1 +u ^4 ^8 ^9 ^1 +u ^4 ^9 ^9 ^1 +u ^5 +u ^5 ^0 ^0 ^2 +u ^5 ^4 ^3 ^2 ^1 +u ^5 ^6 ^9 ^1 +u ^5 ^7 ^9 ^1 +u ^5 ^8 ^9 ^1 +u ^5 ^9 ^9 ^1 +u ^6 +u ^6 ^0 ^0 ^2 +u ^6 ^5 ^4 ^3 ^2 ^1 +u ^6 ^6 ^9 ^1 +u ^6 ^7 ^9 ^1 +u ^6 ^8 ^9 ^1 +u ^6 ^9 ^9 ^1 +u ^7 +u ^7 ^0 ^0 ^2 +u ^7 ^6 ^9 ^1 +u ^7 ^7 ^9 ^1 +u ^7 ^8 ^9 ^1 +u ^7 ^9 ^9 ^1 +u ^8 +u ^8 ^0 ^0 ^2 +u ^8 ^6 ^9 ^1 +u ^8 ^7 ^9 ^1 +u ^8 ^8 ^9 ^1 +u ^8 ^9 ^9 ^1 +u ^9 +u ^9 ^0 ^0 ^2 +u ^9 ^6 ^9 ^1 +u ^9 ^7 ^9 ^1 +u ^9 ^8 ^9 ^1 +u ^9 ^9 ^9 ^1 +u ^> +u ^? +u ^B i1R +u ^D +u ^E O41 +u ^K *15 +u ^M +u ^Q +u ^U +u ^V -1 +u ^Y +u ^_ +u ^b +u ^e +u ^i i60 +^u c +u ^x -1 +u ^| +c @g +c o3Q +u d 'B +u d O12 +u f -5 +u i0$ o5V +u i0N O16 +u i1! +u i1& +u i1' +u i1* +u i1+ +u i1. +u i1. i3. $. +u i1. i3. i5. $. +u i10 +u i10 i31 i52 i73 +u i11 +u i11 i31 +u i11 i31 i51 +u i11 i31 i51 i71 +u i11 i31 i51 i71 i91 +u i11 i31 i51 i71 i91 iB1 +u i11 i32 +u i11 i32 i53 +u i11 i32 i53 i74 +u i11 i32 i53 i74 i95 +u i11 i32 i53 i74 i95 iB6 +u i12 +u i13 +u i15 +u i16 +u i17 +u i18 +u i19 +u i1_ +u i2! +u i2$ +u i2& +u i2' +u i2* +u i2+ +u i2- +u i20 +u i21 +u i22 +u i23 +u i24 +u i25 +u i26 +u i27 +u i28 +u i29 +u i2D +u i2I +u i2W +u i2_ +u i3! +u i3# +u i3$ +u i3& +u i3' +u i3* +u i3+ +u i3. +u i30 +u i31 +u i32 +u i33 +u i34 +u i35 +u i36 +u i37 +u i38 +u i39 +u i3O { +u i3_ +u i4! +u i4# +u i4$ +u i4& +u i4' +u i4+ +u i4- +u i4. +u i40 +u i41 +u i42 +u i43 +u i44 +u i45 +u i46 +u i47 +u i48 +u i49 +u i4@ +u i4C +u i4D +u i4F +u i4J +u i4L +u i4T L7 +u i4_ +u i4u } +u i5 +u i5! +u i5# +u i5$ +u i5& +u i5' +u i5* +u i5+ +u i5- +u i5. +u i50 +u i51 +u i52 +u i53 +u i54 +u i56 +u i57 +u i59 +u i5E +u i5H +u i5L +u i5Q +u i5Y +u i5Z +u i6 +u i6! +u i6# +u i6$ +u i6& +u i6' +u i6* +u i6+ +u i6- +u i6. +u i60 +u i61 +u i62 +u i63 +u i64 +u i65 +u i66 +u i67 +u i68 +u i69 +u i6P +u i6_ +u i6r +u i7( O17 +u i7N +i88 l +u i8C +u i8N +u iB3 +u k O21 +l s0? +l s0i +u o0< +u o0A +u o0B +u o0V K +u o0W +u o14 +u o1F +u o1d +u o1k +u o25 t +u o2G *23 +u o2U +u o2W [ +u o2i +u o3$ +u o33 +u o3V +u o4J +u o4Q +u o4Z +u o4Z '8 +u o4c +o4p c +u o4z +u o4{ +u o5$ +u o5= +u o5L +u o5U +u o65 +u o6A +u o6H +u o6R o0U +u o7% +u o78 +u o7I +u o7U +u o83 +u o90 +u oA8 +u p1 $R +u p1 -5 +u p2 O69 +u p2 O76 +u q O5A +u s0_ @B +u s0b +u s1c +u s1d ^d +u s2n +u s4T +u s5R +u s6& +u s6c +u s7t +u s94 +u s9D +u s9_ +u sCK +u sCY +u sEs +u sG! +u sLH +u sMK +u sP= +u sPC +u sRN +u sS! Z2 +u sTG +u sTz r +u sVX +u sX> +u sYM +u t $K +u t -3 +u O03 O46 +u O04 p3 +u O0A +u O13 +u O14 p1 +u O14 z4 +u O15 +u O18 ^L +u O1A +u O1B +u O21 +1 +u O21 K +u O24 +u O26 z2 +u O28 +u O35 +u O35 Z1 +u O41 +u O42 +u O42 z4 +u O46 +u O47 +u O53 +u O54 +u O58 +u O59 O02 +u O64 +u O67 +u O74 +u O75 +u O83 +u OA1 +u OA3 +u z1 +u z1 $4 +u z1 *31 +u z1 *61 +u z1 D4 +u z2 +u z2 +3 +u z3 +u z3 o6B +u z3 q +u z4 +u z4 +4 +u z5 i5C +u { Z1 +u { r +u } d +u } o2E +u } o4V +O01 $N *23 +O01 $j +O01 $m +O01 $p +O01 '9 +O01 +2 o42 +O01 @1 +O01 @H +O01 @k +O01 C o2G +O01 K d +O01 T4 o2N +O01 ^2 $y +O01 ^M +O01 c $n +O01 c sRu +O01 i4s +O01 i4u +O01 i8i +O01 l $9 +O01 l o6# +O01 o0 +O01 o1: +O01 o1a +O01 o2& +O01 o2H C +O01 o2[ +O01 o3e +O01 o42 } +O01 o4S +O01 o4i +O01 o4x +O01 o5L +O01 q t +O01 q O0B +O01 sl. +O01 sry +O01 sta +O01 swf +O01 t f +O01 O0A +O01 O54 +O01 O93 +O01 z4 ^J +O01 z5 Z1 +O01 { ^h +O02 $" +O02 $% +O02 $* +O02 $+ +O02 $1 +O02 $1 Z2 +O02 $6 +O02 $B +O02 $P +O02 $f +O02 $g +O02 $k +O02 $n +O02 $q +O02 $s +O02 '4 +O02 '5 +O02 'A +O02 *20 +O02 *23 +O02 *31 +O02 +1 +O02 +2 +O02 +2 $7 +O02 +3 +O02 +3 *02 +O02 +6 +O02 +8 +O02 +A +O02 -4 +O02 -7 +O02 @0 +O02 C +O02 D3 +O02 D5 +O02 D6 +O02 K { +O02 L5 +O02 R5 +O02 T5 +O02 Z1 +O02 Z1 R2 +O02 Z2 +O02 Z4 +O02 Z4 suM +O02 ^% +O02 ^2 +O02 ^M +O02 ^U +O02 ^X +O02 ^b +O02 ^g +O02 ^j +O02 ^u +O02 ^v +O02 ^x +O02 ^y +O02 d +O02 f +O02 f +0 +O02 i0, +O02 i0f +O02 i2^ +O02 i2l +O02 i4f +O02 i5e +O02 i6| +O02 i9i +O02 k +O02 o1. +O02 o1n +O02 o1p +O02 o1z +O02 o2 +O02 o2- +O02 o2v +O02 o3y +O02 o4# +O02 o4- +O02 o4h $9 +O02 p2 +O02 q z3 +O02 r +O02 r k +O02 s51 z3 +O02 sAO +O02 sFH +O02 str +O02 syl +O02 t *50 +O02 u +O02 O13 +O02 O35 +O02 O46 +O02 O53 +O02 O63 +O02 O82 +O02 O91 +O02 z1 +O02 z1 f +O02 z2 +O02 z3 +O02 z3 l +O02 z5 +O02 z5 z2 +O02 { +O03 $! +O03 $# +O03 $2 +O03 $5 +O03 $6 +O03 $R +O03 $^ +O03 $e +O03 $h +O03 $i +O03 $j +O03 $n +O03 $r +O03 '6 +O03 'A +O03 *12 *50 +O03 *30 +O03 *31 +O03 *34 +O03 +0 +O03 +0 sy! +O03 +2 +O03 +6 +O03 -0 +O03 @n +O03 C sK9 +O03 D1 +O03 D4 +O03 L6 +O03 R0 +O03 R1 +O03 R2 +O03 R3 +O03 T6 +O03 Z1 $i +O03 Z2 *74 +O03 Z3 +O03 Z3 z2 +O03 Z4 +O03 Z5 +O03 ^1 +O03 ^@ +O03 ^F +O03 ^L +O03 ^g +O03 ^u +O03 ^w +O03 d +O03 f +O03 f ] +O03 i0- ^U +O03 i0T +O03 i1B +O03 i2B +O03 i2t +O03 i4L +O03 i5G +O03 k +O03 l +O03 o1q +O03 o1y +O03 o3O +O03 o66 +O03 o69 +O03 o7@ +O03 p2 +O03 p3 +O03 p4 +O03 p5 '9 +O03 q +O03 q z3 +O03 s2 +O03 sld +O03 t s8a +O03 O19 +O03 O34 +O03 O34 ^d +O03 O35 +O03 O43 +O03 O48 +O03 z1 +O03 z1 sc? +O03 z1 } +O03 z5 +O03 { K +O04 $$ +O04 $3 +O04 $F +O04 $r +O04 $s +O04 $v +O04 $y +O04 $| +O04 '3 +O04 '5 +O04 '8 +O04 *02 +O04 *78 +O04 +1 +O04 -1 $M +O04 -1 +2 +O04 @f +O04 @l +O04 @p +O04 C +O04 D8 +O04 L0 +O04 L7 +O04 R5 +O04 T3 +O04 Z1 +O04 Z2 +O04 Z3 +O04 Z4 +O04 Z5 +O04 ^ +O04 ^P +O04 ^a +O04 ^l +O04 ^m +O04 ^o +O04 ^q +O04 ^y +O04 c sRi +O04 d +O04 d i0n +O04 i0d +O04 i1a +O04 i22 +O04 i3d '4 +O04 i3p +O04 i44 +O04 i6 +O04 i6_ +O04 l +O04 o0' Z5 +O04 o10 +9 +O04 o2 +O04 o3% +O04 o51 +O04 p2 +O04 p3 +O04 p4 i3B +O04 sN[ R1 +O04 sf: '7 +O04 u +O04 O49 +O04 O61 +O04 O62 +O04 O74 +O04 z2 +O04 { +O05 $ +O05 $+ +O05 $/ +O05 $0 +O05 $4 +O05 $@ @3 +O05 $S +O05 '9 +O05 'A +O05 *41 +O05 -2 +O05 -4 +O05 D3 +O05 R3 Z2 +O05 T4 +O05 Z1 +O05 Z1 $u +O05 Z2 C +O05 Z4 +O05 Z4 C +O05 Z5 +O05 ^# +O05 ^+ +O05 ^- q +O05 ^? +O05 ^_ +O05 ^h +O05 ^j +O05 ^m O64 +O05 ^r +O05 ^t @o +O05 ^w +O05 k +O05 l ^3 +O05 o1 +O05 o1P +O05 o3t +O05 o4a +O05 p1 +O05 p1 [ +O05 p2 +O05 p3 +O05 q +O05 r +O05 sum +O05 t Z4 +O05 O41 +O05 O53 +O05 z2 +O05 z3 +O05 z5 O06 -O06$1 -O06$H -O06$Z -O06$]p1 -O06$y -O06'9 -O06'A -O06'B -O06*20 -O06-1 -O06-3 -O06-8 -O06@9 -O06R1 -O06R4 -O06Z1 -O06Z1-0 -O06Z4l -O06^2 -O06d -O06dp3 -O06dt -O06dz2 -O06f -O06i2. -O06i2h -O06i49 -O06i62 -O06i7i -O06o2- -O06o2S -O06o3N -O06o3R -O06o99 -O06p2 -O06p2[ -O06q -O06sk@ -O06szy -O06u -O06O13 -O06O32 -O06z1^e -O06z3 -O06z3$0 -O06{ +O06 $1 +O06 $H +O06 $Z +O06 $] p1 +O06 $y +O06 '9 +O06 'A +O06 'B +O06 *20 +O06 -1 +O06 -3 +O06 -8 +O06 @9 +O06 R1 +O06 R4 +O06 Z1 +O06 Z1 -0 +O06 Z4 l +O06 ^2 +O06 d +O06 d p3 +O06 d t +O06 d z2 +O06 f +O06 i2. +O06 i2h +O06 i49 +O06 i62 +O06 i7i +O06 o2- +O06 o2S +O06 o3N +O06 o3R +O06 o99 +O06 p2 +O06 p2 [ +O06 q +O06 sk@ +O06 szy +O06 u +O06 O13 +O06 O32 +O06 z1 ^e +O06 z3 +O06 z3 $0 +O06 { O07 -O07$- -O07$1 -O07$n -O07'7 -O07+2 -O07+5 -O07-0 -O07-1 -O07-6 -O07D1 -O07D5 -O07R4 -O07T0 -O07Z1 -O07Z2 -O07Z3 -O07Z4 -O07^k -O07^s -O07^t -O07d -O07dO42 -O07i1n -O07i2H -O07k -O07o0Z -O07o2 -O07o4z -O07shv -O07slk -O07t -O07to1 -O07u$I -O07u^F -O07O21 -O07O39 -O07O74 -O07z2 -O07z4 -O07z5 +O07 $- +O07 $1 +O07 $n +O07 '7 +O07 +2 +O07 +5 +O07 -0 +O07 -1 +O07 -6 +O07 D1 +O07 D5 +O07 R4 +O07 T0 +O07 Z1 +O07 Z2 +O07 Z3 +O07 Z4 +O07 ^k +O07 ^s +O07 ^t +O07 d +O07 d O42 +O07 i1n +O07 i2H +O07 k +O07 o0Z +O07 o2 +O07 o4z +O07 shv +O07 slk +O07 t +O07 t o1 +O07 u $I +O07 u ^F +O07 O21 +O07 O39 +O07 O74 +O07 z2 +O07 z4 +O07 z5 O08 -O08$6 -O08$bZ1 -O08$n -O08'8 -O08*63 -O08-5 -O08C -O08L0 -O08T2 -O08T4 -O08^Dq -O08^Q -O08^bt -O08c -O08i1a -O08i2c -O08o0, -O08p1 -O08p2 -O08p5o2V -O08s4b -O08t -O08O61 +O08 $6 +O08 $b Z1 +O08 $n +O08 '8 +O08 *63 +O08 -5 +O08 C +O08 L0 +O08 T2 +O08 T4 +O08 ^D q +O08 ^Q +O08 ^b t +O08 c +O08 i1a +O08 i2c +O08 o0, +O08 p1 +O08 p2 +O08 p5 o2V +O08 s4b +O08 t +O08 O61 O09 -O09L0 -O09Z1 -O09Z3 -O09Z3+5 -O09Z5 -O09^2 -O09^=d -O09^B -O09c -O09d -O09l -O09o1 -O09o2 -O09o48 -O09o6, -O09O21 -O09O34o0w -O09O54 -O09z5 +O09 L0 +O09 Z1 +O09 Z3 +O09 Z3 +5 +O09 Z5 +O09 ^2 +O09 ^= d +O09 ^B +O09 c +O09 d +O09 l +O09 o1 +O09 o2 +O09 o48 +O09 o6, +O09 O21 +O09 O34 o0w +O09 O54 +O09 z5 O0A -O0AR0 -O0AZ1 -O0Ad -O0Ai2x -O0AO35 -O0AOB9O38 +O0A R0 +O0A Z1 +O0A d +O0A i2x +O0A O35 +O0A OB9 O38 O0B -O0B$' -O0B$h -O0BT7 -O0BZ5 -O0Bc -O0Bc^. -O0Bi8- -O0Bo2C -O0BO46 -O0Bz5 +O0B $' +O0B $h +O0B T7 +O0B Z5 +O0B c +O0B c ^. +O0B i8- +O0B o2C +O0B O46 +O0B z5 O12 -O12$ -O12$* -O12$. -O12$6 -O12$m -O12$r -O12$s -O12$w -O12'5D0 -O12*21 -O12*30O31 -O12*34 -O12*41 -O12*52*41 -O12+1Z1 -O12+2 -O12-1 -O12-4 -O12@c -O12D7 -O12Kl -O12L1 -O12L3 -O12R0 -O12R3 -O12T3 -O12Z1 -O12Z3*41 -O12Z3T6 -O12Z4 -O12Z5 -O12Z5z5 -O12^1o7v -O12^3 -O12^4 -O12^E -O12^[ -O12^e -O12^o -O12^p -O12^y -O12c -O12d -O12i0I -O12i1j -O12i2k -O12i3g -O12i5 -O12i5T -O12o0p -O12o1@ -O12o2 -O12o2r -O12o3l -O12o4 -O12p2 -O12q -O12q+8 -O12r -O12s2z -O12s81 -O12s9n -O12sf4 -O12sgo -O12shI'5 -O12shs -O12sna -O12t} -O12u -O12u'8 -O12O23 -O12O32 -O12O91 -O12z1 -O12z2T3 -O12z4 -O12z5 +O12 $ +O12 $* +O12 $. +O12 $6 +O12 $m +O12 $r +O12 $s +O12 $w +O12 '5 D0 +O12 *21 +O12 *30 O31 +O12 *34 +O12 *41 +O12 *52 *41 +O12 +1 Z1 +O12 +2 +O12 -1 +O12 -4 +O12 @c +O12 D7 +O12 K l +O12 L1 +O12 L3 +O12 R0 +O12 R3 +O12 T3 +O12 Z1 +O12 Z3 *41 +O12 Z3 T6 +O12 Z4 +O12 Z5 +O12 Z5 z5 +O12 ^1 o7v +O12 ^3 +O12 ^4 +O12 ^E +O12 ^[ +O12 ^e +O12 ^o +O12 ^p +O12 ^y +O12 c +O12 d +O12 i0I +O12 i1j +O12 i2k +O12 i3g +O12 i5 +O12 i5T +O12 o0p +O12 o1@ +O12 o2 +O12 o2r +O12 o3l +O12 o4 +O12 p2 +O12 q +O12 q +8 +O12 r +O12 s2z +O12 s81 +O12 s9n +O12 sf4 +O12 sgo +O12 shI '5 +O12 shs +O12 sna +O12 t } +O12 u +O12 u '8 +O12 O23 +O12 O32 +O12 O91 +O12 z1 +O12 z2 T3 +O12 z4 +O12 z5 O13 -O13$. -O13$0d -O13$1 -O13$4 -O13$P -O13$X@m -O13$Yc -O13$gz1 -O13$h^9 -O13$oO13 -O13$y -O13*03 -O13*03d -O13*04 -O13*21p1 -O13*34 -O13+1r -O13-0K -O13-2 -O13@m -O13C -O13D6 -O13D7 -O13L0 -O13R2 -O13R5 -O13T1 -O13T5svz -O13Z1 -O13Z3 -O13Z5 -O13^9*21 -O13^C -O13^S -O13^c -O13^e -O13^s -O13^v -O13^x -O13c'7 -O13d -O13f -O13i0Gi0K -O13i0M -O13i0X -O13i0tL0 -O13i1j -O13i1r -O13i4X -O13o1? -O13o1u -O13o2y -O13o37 -O13o4Kl -O13o5e -O13o9+[ -O13p2 -O13s2f -O13s9Q -O13s9i -O13sgP -O13shF -O13sk5z1 -O13spw -O13O32 -O13z2 -O13z2s8g -O13z3R4 -O13z3z4 -O13z5 +O13 $. +O13 $0 d +O13 $1 +O13 $4 +O13 $P +O13 $X @m +O13 $Y c +O13 $g z1 +O13 $h ^9 +O13 $o O13 +O13 $y +O13 *03 +O13 *03 d +O13 *04 +O13 *21 p1 +O13 *34 +O13 +1 r +O13 -0 K +O13 -2 +O13 @m +O13 C +O13 D6 +O13 D7 +O13 L0 +O13 R2 +O13 R5 +O13 T1 +O13 T5 svz +O13 Z1 +O13 Z3 +O13 Z5 +O13 ^9 *21 +O13 ^C +O13 ^S +O13 ^c +O13 ^e +O13 ^s +O13 ^v +O13 ^x +O13 c '7 +O13 d +O13 f +O13 i0G i0K +O13 i0M +O13 i0X +O13 i0t L0 +O13 i1j +O13 i1r +O13 i4X +O13 o1? +O13 o1u +O13 o2y +O13 o37 +O13 o4K l +O13 o5e +O13 o9+ [ +O13 p2 +O13 s2f +O13 s9Q +O13 s9i +O13 sgP +O13 shF +O13 sk5 z1 +O13 spw +O13 O32 +O13 z2 +O13 z2 s8g +O13 z3 R4 +O13 z3 z4 +O13 z5 O14 -O14$* -O14$1 -O14$3 -O14$L -O14$M -O14$g -O14$i -O14$k -O14$p -O14'4 -O14'8 -O14*50 -O14+0 -O14-1 -O14@t -O14D2$_ -O14D3 -O14L0 -O14R0 -O14R3 -O14Z1 -O14Z3 -O14Z3t -O14Z4 -O14Z5 -O14^2 -O14^2C -O14^3 -O14^M$n -O14^P -O14^g -O14^gr -O14^qq -O14^s -O14^y -O14cz5 -O14d -O14do1m -O14f*10 -O14i0T -O14i1G -O14i1t -O14i2; -O14i4+ -O14o0G -O14p1c -O14p1O83 -O14s28C -O14s6no40 -O14sa? -O14sam -O14u -O14O05Z2 -O14O24 -O14O32 -O14O34 -O14z3 -O14z4 -O14z4Z2 -O14{ +O14 $* +O14 $1 +O14 $3 +O14 $L +O14 $M +O14 $g +O14 $i +O14 $k +O14 $p +O14 '4 +O14 '8 +O14 *50 +O14 +0 +O14 -1 +O14 @t +O14 D2 $_ +O14 D3 +O14 L0 +O14 R0 +O14 R3 +O14 Z1 +O14 Z3 +O14 Z3 t +O14 Z4 +O14 Z5 +O14 ^2 +O14 ^2 C +O14 ^3 +O14 ^M $n +O14 ^P +O14 ^g +O14 ^g r +O14 ^q q +O14 ^s +O14 ^y +O14 c z5 +O14 d +O14 d o1m +O14 f *10 +O14 i0T +O14 i1G +O14 i1t +O14 i2; +O14 i4+ +O14 o0G +O14 p1 c +O14 p1 O83 +O14 s28 C +O14 s6n o40 +O14 sa? +O14 sam +O14 u +O14 O05 Z2 +O14 O24 +O14 O32 +O14 O34 +O14 z3 +O14 z4 +O14 z4 Z2 +O14 { O15 -O15$- -O15$5 -O15$8u -O15$ML3 -O15$P -O15$X -O15$a -O15$k -O15$t -O15'6 -O15'8 -O15*15 -O15+0 -O15+1 -O15+2 -O15+3 -O15-4 -O15D5L2 -O15T1 -O15Z2@2 -O15Z3 -O15Z4 -O15Z5l -O15^G -O15c -O15d -O15d^i -O15f -O15i0A -O15i1r -O15i41 -O15i51 -O15lo5x -O15o0j -O15o1> -O15o3p -O15o57 -O15o5j -O15sza -O15szh -O15O41 -O15z3 -O15z3t -O15z4^V -O15z5 -O15{ +O15 $- +O15 $5 +O15 $8 u +O15 $M L3 +O15 $P +O15 $X +O15 $a +O15 $k +O15 $t +O15 '6 +O15 '8 +O15 *15 +O15 +0 +O15 +1 +O15 +2 +O15 +3 +O15 -4 +O15 D5 L2 +O15 T1 +O15 Z2 @2 +O15 Z3 +O15 Z4 +O15 Z5 l +O15 ^G +O15 c +O15 d +O15 d ^i +O15 f +O15 i0A +O15 i1r +O15 i41 +O15 i51 +O15 l o5x +O15 o0j +O15 o1> +O15 o3p +O15 o57 +O15 o5j +O15 sza +O15 szh +O15 O41 +O15 z3 +O15 z3 t +O15 z4 ^V +O15 z5 +O15 { O16 -O16$: -O16$F -O16$R$v -O16$V -O16$_ -O16'9 -O16+2q -O16+3 -O16+7 -O16-1 -O16D4 -O16L1 -O16Z3 -O16Z4 -O16Z5 -O16^5 -O16^D -O16^JZ1 -O16^Sz2 -O16^a -O16i2n -O16i4bo2n -O16l -O16o0H -O16o1 -O16o3 -O16p1 -O16p2 -O16q -O16r -O16sHx -O16sb9D4 -O16t$2 -O16O23O03 -O16z4q -O16z5 +O16 $: +O16 $F +O16 $R $v +O16 $V +O16 $_ +O16 '9 +O16 +2 q +O16 +3 +O16 +7 +O16 -1 +O16 D4 +O16 L1 +O16 Z3 +O16 Z4 +O16 Z5 +O16 ^5 +O16 ^D +O16 ^J Z1 +O16 ^S z2 +O16 ^a +O16 i2n +O16 i4b o2n +O16 l +O16 o0H +O16 o1 +O16 o3 +O16 p1 +O16 p2 +O16 q +O16 r +O16 sHx +O16 sb9 D4 +O16 t $2 +O16 O23 O03 +O16 z4 q +O16 z5 O17 -O17$1 -O17$N -O17$S -O17$o -O17$v -O17*20 -O17+1 -O17-1 -O17-4 -O17C -O17L4 -O17T2i0O -O17Z5 -O17^P -O17^c -O17^m -O17^r -O17d -O17l -O17q -O17qd -O17stP -O17u -O17O51 -O17z5 -O17{ +O17 $1 +O17 $N +O17 $S +O17 $o +O17 $v +O17 *20 +O17 +1 +O17 -1 +O17 -4 +O17 C +O17 L4 +O17 T2 i0O +O17 Z5 +O17 ^P +O17 ^c +O17 ^m +O17 ^r +O17 d +O17 l +O17 q +O17 q d +O17 stP +O17 u +O17 O51 +O17 z5 +O17 { O18 -O18$q -O18*42 -O18+0 -O18+3 -O18+7 -O18L0 -O18R0 -O18Z2 -O18Z3 -O18Z3q -O18[^G -O18d -O18i5w -O18lZ5 -O18o3cl -O18o3i+4 -O18o6{-6 -O18p1'3 -O18p2 -O18t -O18O51 -O18O53 -O18O64 -O18z1O71 -O18z4 -O18z4O43 -O19$@ -O19+3 -O19@l$z -O19D4 -O19Z5 -O19^dz1 -O19i0jo21 -O19p2 -O19q -O19qd -O19r -O19uD5 -O1A$s -O1AZ1 -O1A[$J -O1A^pz2 -O1Ai15 -O1Ai1rp2 +O18 $q +O18 *42 +O18 +0 +O18 +3 +O18 +7 +O18 L0 +O18 R0 +O18 Z2 +O18 Z3 +O18 Z3 q +O18 [ ^G +O18 d +O18 i5w +O18 l Z5 +O18 o3c l +O18 o3i +4 +O18 o6{ -6 +O18 p1 '3 +O18 p2 +O18 t +O18 O51 +O18 O53 +O18 O64 +O18 z1 O71 +O18 z4 +O18 z4 O43 +O19 $@ +O19 +3 +O19 @l $z +O19 D4 +O19 Z5 +O19 ^d z1 +O19 i0j o21 +O19 p2 +O19 q +O19 q d +O19 r +O19 u D5 +O1A $s +O1A Z1 +O1A [ $J +O1A ^p z2 +O1A i15 +O1A i1r p2 O1B -O1B+3 -O1B+5 -O1BR2 -O1B[d -O1B^1R1 -O1Bd$v -O1Bi1P -O1Bo1* -O21$6 -O21$X[ -O21$g -O21$k -O21$k+2 -O21'9 -O21*25 -O21*30 -O21*68 -O21+1 -O21+2 -O21-0 -O21@Y -O21@o -O21@s -O21@y -O21D7 -O21R1o1x -O21R5D4 -O21R7 -O21^3 -O21^7 -O21^L -O21^cz3 -O21^l -O21^q-3 -O21^r -O21^t -O21di3n -O21f -O21i0k -O21i1*O34 -O21i11 -O21i42 -O21i5^ -O21i6e -O21i81 -O21kR0 -O21o0C -O21o0y -O21o1^ -O21o1b -O21o1n -O21o2? -O21o2i -O21o34 -O21o3j -O21o7Il -O21p1O54 -O21p2 -O21q -O21s&X -O21s., -O21s5 -O21scZ -O21scs -O21sm0 -O21sobi1* -O21stkp1 -O21stl -O21syu -O21O24s6+ -O21O46 -O21O52 -O21z3i1* -O21z5 -O21{l +O1B +3 +O1B +5 +O1B R2 +O1B [ d +O1B ^1 R1 +O1B d $v +O1B i1P +O1B o1* +O21 $6 +O21 $X [ +O21 $g +O21 $k +O21 $k +2 +O21 '9 +O21 *25 +O21 *30 +O21 *68 +O21 +1 +O21 +2 +O21 -0 +O21 @Y +O21 @o +O21 @s +O21 @y +O21 D7 +O21 o1x +O21 R5 D4 +O21 R7 +O21 ^3 +O21 ^7 +O21 ^L +O21 ^c z3 +O21 ^l +O21 ^q -3 +O21 ^r +O21 ^t +O21 d i3n +O21 f +O21 i0k +O21 i1* O34 +O21 i11 +O21 i42 +O21 i5^ +O21 i6e +O21 i81 +O21 k R0 +O21 o0C +O21 o0y +O21 o1^ +O21 o1b +O21 o1n +O21 o2? +O21 o2i +O21 o34 +O21 o3j +O21 o7I l +O21 p1 O54 +O21 p2 +O21 q +O21 s&X +O21 s., +O21 s5 +O21 scZ +O21 scs +O21 sm0 +O21 sob i1* +O21 stk p1 +O21 stl +O21 syu +O21 O24 s6+ +O21 O46 +O21 O52 +O21 z3 i1* +O21 z5 +O21 { l O23 -O23$# -O23$*[ -O23$. -O23$? -O23$I -O23$f'6 -O23$g -O23$j -O23$l -O23$r -O23$t -O23'7 -O23*23{ -O23+0 -O23+9 -O23-2$d -O23-2o28 -O23-8 -O23@h -O23C -O23D3 -O23K -O23L4 -O23L5 -O23R3 -O23Z1 -O23Z1s1R -O23Z2 -O23Z3 -O23Z4 -O23Z5 -O23^( -O23^6 -O23^D -O23^V -O23^m -O23^s -O23f -O23i1K -O23i1b -O23i2i -O23i3x -O23i4i -O23i57 -O23l$! -O23o13 -O23o19 -O23o2n -O23o36 -O23o3@O12 -O23p1 -O23p1+0 -O23p1O03 -O23p2O82 -O23q*82 -O23r -O23sLo -O23sdgZ1 -O23siL -O23z1 -O23z1^b -O23z2 -O23z2Z1 -O23z3 -O23z5o2$ +O23 $# +O23 $* [ +O23 $. +O23 $? +O23 $I +O23 $f '6 +O23 $g +O23 $j +O23 $l +O23 $r +O23 $t +O23 '7 +O23 *23 { +O23 +0 +O23 +9 +O23 -2 $d +O23 o28 +O23 -8 +O23 @h +O23 C +O23 D3 +O23 K +O23 L4 +O23 L5 +O23 R3 +O23 Z1 +O23 Z1 s1R +O23 Z2 +O23 Z3 +O23 Z4 +O23 Z5 +O23 ^( +O23 ^6 +O23 ^D +O23 ^V +O23 ^m +O23 ^s +O23 f +O23 i1K +O23 i1b +O23 i2i +O23 i3x +O23 i4i +O23 i57 +O23 l $! +O23 o13 +O23 o19 +O23 o2n +O23 o36 +O23 o3@ O12 +O23 p1 +O23 p1 +0 +O23 p1 O03 +O23 p2 O82 +O23 q *82 +O23 r +O23 sLo +O23 sdg Z1 +O23 siL +O23 z1 +O23 z1 ^b +O23 z2 +O23 z2 Z1 +O23 z3 +O23 z5 o2$ O24 -O24$. -O24$6 -O24$7 -O24$_ -O24$g -O24$h -O24$i -O24$r -O24'6 -O24'8 -O24*20p1 -O24*36 -O24+2 -O24+5 -O24-3 -O24@1i4b -O24@hZ3 -O24K$p -O24L2 -O24L6 -O24Z2 -O24Z3 -O24Z3*15 -O24Z5 -O24[ -O24[O25 -O24^# -O24^W -O24^g -O24^m -O24^o -O24^oD3 -O24^r -O24^z -O24d -O24f -O24i2, -O24i32 -O24kd -O24o0SZ1 -O24o21 -O24o2r -O24o2y -O24o4 -O24sa. -O24sat -O24skX -O24sod -O24sr4 -O24t*13 -O24tR1 -O24uz5 -O24O05 -O24O15Z5 -O24z3 -O24z4 -O24z5 +O24 $. +O24 $6 +O24 $7 +O24 $_ +O24 $g +O24 $h +O24 $i +O24 $r +O24 '6 +O24 '8 +O24 *20 p1 +O24 *36 +O24 +2 +O24 +5 +O24 -3 +O24 @1 i4b +O24 @h Z3 +O24 K $p +O24 L2 +O24 L6 +O24 Z2 +O24 Z3 +O24 Z3 *15 +O24 Z5 +O24 [ +O24 [ O25 +O24 ^# +O24 ^W +O24 ^g +O24 ^m +O24 ^o +O24 ^o D3 +O24 ^r +O24 ^z +O24 d +O24 f +O24 i2, +O24 i32 +O24 k d +O24 o0S Z1 +O24 o21 +O24 o2r +O24 o2y +O24 o4 +O24 sa. +O24 sat +O24 skX +O24 sod +O24 sr4 +O24 t *13 +O24 t R1 +O24 u z5 +O24 O05 +O24 O15 Z5 +O24 z3 +O24 z4 +O24 z5 O25 -O25$ -O25$& -O25$0 -O25$d -O25$r -O25'6 -O25*13 -O25+2 -O25-1f -O25-5 -O25D4 -O25D9 -O25L1 -O25R6 -O25RA'7 -O25T6 -O25T6'5 -O25Z1 -O25Z2 -O25Z2c -O25Z3 -O25Z4 -O25Z5*70 -O25^, -O25^U -O25^c -O25^i -O25^n -O25i3g^f -O25i3z -O25l -O25l[ -O25o1q -O25o49i4i -O25o4B -O25p1 -O25rz5 -O25s5c -O25uo3y -O25O51+2 -O25z1 -O25z4L6 -O25z5 +O25 $ +O25 $& +O25 $0 +O25 $d +O25 $r +O25 '6 +O25 *13 +O25 +2 +O25 -1 f +O25 -5 +O25 D4 +O25 D9 +O25 L1 +O25 R6 +O25 '7 +O25 T6 +O25 '5 +O25 Z1 +O25 Z2 +O25 Z2 c +O25 Z3 +O25 Z4 +O25 Z5 *70 +O25 ^, +O25 ^U +O25 ^c +O25 ^i +O25 ^n +O25 i3g ^f +O25 i3z +O25 l +O25 l [ +O25 o1q +O25 o49 i4i +O25 o4B +O25 p1 +O25 r z5 +O25 s5c +O25 u o3y +O25 O51 +2 +O25 z1 +O25 z4 L6 +O25 z5 O26 -O26$@ -O26$F -O26$X -O26$a -O26$r -O26'6 -O26+1 -O26-5 -O26@az1 -O26R0 -O26Z1 -O26Z3 -O26^'o0Z -O26^a -O26^bskr -O26^c -O26^t -O26d -O26i1v -O26i3? -O26o4y -O26p1[ -O26p2O94 -O26qz4 -O26skf -O26sp6 -O26ssa -O26z2 -O26z5 -O26} +O26 $@ +O26 $F +O26 $X +O26 $a +O26 $r +O26 '6 +O26 +1 +O26 -5 +O26 @a z1 +O26 R0 +O26 Z1 +O26 Z3 +O26 ^' o0Z +O26 ^a +O26 ^b skr +O26 ^c +O26 ^t +O26 d +O26 i1v +O26 i3? +O26 o4y +O26 p1 [ +O26 p2 O94 +O26 q z4 +O26 skf +O26 sp6 +O26 ssa +O26 z2 +O26 z5 +O26 } O27 -O27$3 -O27$i -O27'8 -O27-1^f -O27@3 -O27L4 -O27Z2 -O27Z5 -O27^8 -O27^M -O27^h -O27d -O27i2az4 -O27i4p -O27o03 -O27o0m -O27o1MZ2 -O27o1j -O27o1y -O27o57@r -O27p1z1 -O27q -O27s1q -O27z1 -O28$_D2 -O28'9 -O28+4 -O28-0 -O28^6z4 -O28^e -O28^z -O28d -O28l -O28o0d -O28o27d -O28q -O28O0B -O29$J -O29$y -O29-1 -O29-2 -O29T4 -O29^n -O29^{-0 -O29d -O29i0s -O29i5t -O29lo5- -O29o1j -O29O41 -O2A$. -O2A'7 -O2A^T -O2Al -O2Ao1e -O2AO37 -O2Az1i17 -O2B$9 -O2B^i -O2Bi0fL4 -O2BO15O08 -O31$6 -O31$8 -O31$T -O31$_ -O31$m -O31$o -O31$y -O31'4 -O31'6 -O31'7@7 -O31*15ssr -O31*24 -O31*26 -O31*28 -O31*54] -O31*61 -O31*80 -O31+4L7 -O31+4d -O31-0 -O31-2 -O31@3 -O31R6l -O31T2 -O31Z2 -O31Z3+1 -O31Z4 -O31[o6T -O31]p1 -O31^B -O31^^l -O31^t -O31^u -O31f -O31i0! -O31i2WT5 -O31i3g -O31i4X -O31i4w -O31i67 -O31i73'5 -O31i89O76 -O31o0D -O31o0Y -O31o0t -O31o1C -O31o2U -O31o3a -O31o4z -O31o8r -O31oA5O36 -O31p1[ -O31p2O25 -O31r -O31s-h -O31sar[ -O31si' -O31sl9 -O31smf -O31syT -O31O21*45 -O31O42 -O31O43 -O31O46 -O31z1-0 -O31z1o6e -O31z3O61 -O31z4*62 -O31} +O27 $3 +O27 $i +O27 '8 +O27 -1 ^f +O27 @3 +O27 L4 +O27 Z2 +O27 Z5 +O27 ^8 +O27 ^M +O27 ^h +O27 d +O27 i2a z4 +O27 i4p +O27 o03 +O27 o0m +O27 o1M Z2 +O27 o1j +O27 o1y +O27 o57 @r +O27 p1 z1 +O27 q +O27 s1q +O27 z1 +O28 $_ D2 +O28 '9 +O28 +4 +O28 -0 +O28 ^6 z4 +O28 ^e +O28 ^z +O28 d +O28 l +O28 o0d +O28 o27 d +O28 q +O28 O0B +O29 $J +O29 $y +O29 -1 +O29 -2 +O29 T4 +O29 ^n +O29 ^{ -0 +O29 d +O29 i0s +O29 i5t +O29 l o5- +O29 o1j +O29 O41 +O2A $. +O2A '7 +O2A ^T +O2A l +O2A o1e +O2A O37 +O2A z1 i17 +O2B $9 +O2B ^i +O2B i0f L4 +O2B O15 O08 +O31 $6 +O31 $8 +O31 $T +O31 $_ +O31 $m +O31 $o +O31 $y +O31 '4 +O31 '6 +O31 '7 @7 +O31 *15 ssr +O31 *24 +O31 *26 +O31 *28 +O31 *54 ] +O31 *61 +O31 *80 +O31 +4 L7 +O31 +4 d +O31 -0 +O31 -2 +O31 @3 +O31 R6 l +O31 T2 +O31 Z2 +O31 Z3 +1 +O31 Z4 +O31 [ o6T +O31 ] p1 +O31 ^B +O31 ^^ l +O31 ^t +O31 ^u +O31 f +O31 i0! +O31 i2W T5 +O31 i3g +O31 i4X +O31 i4w +O31 i67 +O31 '5 +O31 i89 O76 +O31 o0D +O31 o0Y +O31 o0t +O31 o1C +O31 o2U +O31 o3a +O31 o4z +O31 o8r +O31 oA5 O36 +O31 p1 [ +O31 p2 O25 +O31 r +O31 s-h +O31 sar [ +O31 si' +O31 sl9 +O31 smf +O31 syT +O31 O21 *45 +O31 O42 +O31 O43 +O31 O46 +O31 z1 -0 +O31 z1 o6e +O31 z3 O61 +O31 z4 *62 +} D4 O32 -O32$ -O32$7 -O32$8 -O32$L -O32$Y} -O32$b -O32'8 -O32*43 -O32+1 -O32+2 -O32+5 -O32+7 -O32-3 -O32-5 -O32@. -O32@k -O32@t -O32@zC -O32D1 -O32L2d -O32L4 -O32R4 -O32R5 -O32T3 -O32Z2i3H -O32Z2O35 -O32Z3 -O32Z4 -O32Z5 -O32[ -O32^$ -O32^6 -O32^I -O32^S -O32^X -O32^e -O32^o -O32c$b -O32d -O32d'6 -O32d-2 -O32i1e -O32i3$ -O32i3: -O32k -O32kp1 -O32l -O32o0k -O32o2 -O32o20 -O32o2x -O32o3+q -O32o3@ -O32o4w -O32o55d -O32o5w -O32p1o5K -O32s7u$A -O32sG6 -O32sg* -O32sqc -O32srl -O32srs -O32u -O32O42 -O32O65sts -O32O72 -O32z1-3 -O32z2 -O32z3 -O32z4^c -O32z5 -O32} +O32 $ +O32 $7 +O32 $8 +O32 $L +O32 $Y } +O32 $b +O32 '8 +O32 *43 +O32 +1 +O32 +2 +O32 +5 +O32 +7 +O32 -3 +O32 -5 +O32 @. +O32 @k +O32 @t +O32 @z C +O32 D1 +O32 L2 d +O32 L4 +O32 R4 +O32 R5 +O32 T3 +O32 Z2 i3H +O32 Z2 O35 +O32 Z3 +O32 Z4 +O32 Z5 +O32 [ +O32 ^$ +O32 ^6 +O32 ^I +O32 ^S +O32 ^X +O32 ^e +O32 ^o +O32 c $b +O32 d +O32 d '6 +O32 d -2 +O32 i1e +O32 i3$ +O32 i3: +O32 k +O32 k p1 +O32 l +O32 o0k +O32 o2 +O32 o20 +O32 o2x +O32 o3+ q +O32 o3@ +O32 o4w +O32 o55 d +O32 o5w +O32 p1 o5K +O32 s7u $A +O32 sG6 +O32 sg* +O32 sqc +O32 srl +O32 srs +O32 u +O32 O42 +O32 O65 sts +O32 O72 +O32 z1 -3 +O32 z2 +O32 z3 +O32 z4 ^c +O32 z5 +O32 } O34 -O34$$ -O34$& -O34$3p2 -O34$Z -O34$n -O34'5 -O34*13 -O34+1 -O34+6D2 -O34+8l -O34-4 -O34-5 -O34-7 -O34@y -O34C -O34Cu -O34D6 -O34L0 -O34R4 -O34Z1 -O34Z2 -O34Z3{ -O34Z5 -O34[t -O34^4 -O34^J -O34^e -O34^p -O34^usb* -O34^x -O34c -O34d -O34fu -O34l -O34lo0k -O34o2e -O34o38q -O34o3yu -O34o65 -O34o6n -O34scf'5 -O34seB -O34sifp1 -O34somssm -O34ssp -O34svj -O34O52 -O34O63 -O34O94 -O34z1 -O34z2 -O34z3 -O34z4 +O34 $$ +O34 $& +O34 $3 p2 +O34 $Z +O34 $n +O34 '5 +O34 *13 +O34 +1 +O34 +6 D2 +O34 +8 l +O34 -4 +O34 -5 +O34 -7 +O34 @y +O34 C +O34 u +O34 D6 +O34 L0 +O34 R4 +O34 Z1 +O34 Z2 +O34 Z3 { +O34 Z5 +O34 [ t +O34 ^4 +O34 ^J +O34 ^e +O34 ^p +O34 ^u sb* +O34 ^x +O34 c +O34 d +O34 f u +O34 l +O34 l o0k +O34 o2e +O34 o38 q +O34 o3y u +O34 o65 +O34 o6n +O34 scf '5 +O34 seB +O34 sif p1 +O34 som ssm +O34 ssp +O34 svj +O34 O52 +O34 O63 +O34 O94 +O34 z1 +O34 z2 +O34 z3 +O34 z4 O35 -O35$! -O35$'[ -O35$* -O35$5 -O35$5R2 -O35$A -O35$C -O35$n -O35+0 -O35+0T2 -O35-1 -O35-6 -O35Z1 -O35Z2R0 -O35Z3 -O35Z4-5 -O35Z5 -O35Z5O58 -O35^B -O35^nT4 -O35d -O35i1 -O35i33 -O35k -O35l -O35o0cq -O35o0jz2 -O35qT6 -O35sr7 -O35tT7 -O35O92O63 -O35z1 -O35z2 -O35z3 -O35z4 +O35 $! +O35 $' [ +O35 $* +O35 $5 +O35 $5 R2 +O35 $A +O35 $C +O35 $n +O35 +0 +O35 +0 T2 +O35 -1 +O35 -6 +O35 Z1 +O35 Z2 R0 +O35 Z3 +O35 Z4 -5 +O35 Z5 +O35 Z5 O58 +O35 ^B +O35 ^n T4 +O35 d +O35 i1 +O35 i33 +O35 k +O35 l +O35 o0c q +O35 o0j z2 +O35 q T6 +O35 sr7 +O35 t T7 +O35 O92 O63 +O35 z1 +O35 z2 +O35 z3 +O35 z4 O36 -O36$ -O36$# -O36$. -O36$0 -O36$2 -O36$p -O36+3 -O36Cz2 -O36D1 -O36D3C -O36L3 -O36T3 -O36Z1$f -O36Z2 -O36Z2c -O36^2 -O36^U -O36^b -O36^z -O36d -O36i0@ -O36i5u -O36sbt -O36t^A -O36u -O36z1 -O36z3 +O36 $ +O36 $# +O36 $. +O36 $0 +O36 $2 +O36 $p +O36 +3 +O36 C z2 +O36 D1 +O36 D3 C +O36 L3 +O36 T3 +O36 Z1 $f +O36 Z2 +O36 Z2 c +O36 ^2 +O36 ^U +O36 ^b +O36 ^z +O36 d +O36 i0@ +O36 i5u +O36 sbt +O36 t ^A +O36 u +O36 z1 +O36 z3 O37 -O37$C -O37$n -O37L5 -O37T6 -O37^C -O37d -O37i0GZ2 -O37i2A -O37i4g -O37l -O37o0V -O37o0x -O37o20 -O37O41 -O37z2l -O37z3 -O37z4'A -O38$7 -O38$l -O38'8 -O38+0 -O38-0 -O38R0 -O38Z2 -O38^O -O38^s -O38i3o -O38o1r -O38o3f -O38sce -O38O51 +O37 $C +O37 $n +O37 L5 +O37 T6 +O37 ^C +O37 d +O37 i0G Z2 +O37 i2A +O37 i4g +O37 l +O37 o0V +O37 o0x +O37 o20 +O37 O41 +O37 z2 l +O37 z3 +O37 z4 'A +O38 $7 +O38 $l +O38 '8 +O38 +0 +O38 -0 +O38 R0 +O38 Z2 +O38 ^O +O38 ^s +O38 i3o +O38 o1r +O38 o3f +O38 sce +O38 O51 O39 -O39$b -O39D0^0 -O39^1 -O39d -O39l -O39o3r -O39q -O39z1 +O39 $b +O39 D0 ^0 +O39 ^1 +O39 d +O39 l +O39 o3r +O39 q +O39 z1 O3A -O3A^9 -O3Az2R2 +O3A ^9 +O3A z2 R2 O3B -O3Bo0e -O3Bo3 -O41$+ -O41$3 -O41$4 -O41$5q -O41$9 -O41$@ -O41$G -O41$XO91 -O41$w[ -O41'B -O41*23Z3 -O41*40 -O41*40O15 -O41*53 -O41*56C -O41*78 -O41+1*30 -O41-0 -O41@8 -O41@m -O41@t -O41D1 -O41D5 -O41L2@2 -O41R0^m -O41RA -O41T3 -O41Z3 -O41Z4 -O41[$h -O41^6 -O41^i -O41^v -O41d-2 -O41i2o -O41i4!u -O41o0h -O41o3S -O41o7i -O41p2 -O41r*36 -O41sh5 -O41sjL -O41sku -O41snl -O41O54Z2 -O41O61 -O41O82 -O41O86 +O3B o0e +O3B o3 +O41 $+ +O41 $3 +O41 $4 +O41 $5 q +O41 $9 +O41 $@ +O41 $G +O41 $X O91 +O41 $w [ +O41 'B +O41 *23 Z3 +O41 *40 +O41 *40 O15 +O41 *53 +O41 *56 C +O41 *78 +O41 +1 *30 +O41 -0 +O41 @8 +O41 @m +O41 @t +O41 D1 +O41 D5 +O41 L2 @2 +O41 R0 ^m +O41 RA +O41 T3 +O41 Z3 +O41 Z4 +O41 [ $h +O41 ^6 +O41 ^i +O41 ^v +O41 d -2 +O41 i2o +O41 i4! u +O41 o0h +O41 o3S +O41 o7i +O41 p2 +O41 r *36 +O41 sh5 +O41 sjL +O41 sku +O41 snl +O41 O54 Z2 +O41 O61 +O41 O82 +O41 O86 O42 -O42$! -O42$% -O42$& -O42$2Z2 -O42$J -O42$k -O42$o -O42'6 -O42'B -O42*34 -O42*37Z1 -O42*53 -O42+3 -O42+9 -O42-0 -O42-4 -O42-6 -O42-7 -O42-8 -O42@4 -O42D1 -O42D1*21 -O42K$a -O42KZ1 -O42L5 -O42L6 -O42R5 -O42R6O13 -O42R7 -O42T5 -O42Z3 -O42Z4 -O42^& -O42^2 -O42^4 -O42^D -O42^I -O42^d -O42^h -O42c -O42c^h -O42d -O42d+B -O42i1ao48 -O42i2h -O42i3Ut -O42i4= -O42i4e -O42i4zL3 -O42o0j -O42o21 -O42o3D -O42o5` -O42o5d -O42p2 -O42p2O79 -O42r -O42s91z3 -O42sKE -O42sa -O42sdp -O42sjbD8 -O42slL -O42srz -O42t*52 -O42z1 -O42z1i0A -O42z2 -O42z4+7 -O42{T6 -O42} +O42 $! +O42 $% +O42 $& +O42 $2 Z2 +O42 $J +O42 $k +O42 $o +O42 '6 +O42 'B +O42 *34 +O42 *37 Z1 +O42 *53 +O42 +3 +O42 +9 +O42 -0 +O42 -4 +O42 -6 +O42 -7 +O42 -8 +O42 @4 +O42 D1 +O42 D1 *21 +O42 K $a +O42 K Z1 +O42 L5 +O42 L6 +O42 R5 +O42 R6 O13 +O42 R7 +O42 T5 +O42 Z3 +O42 Z4 +O42 ^& +O42 ^2 +O42 ^4 +O42 ^D +O42 ^I +O42 ^d +O42 ^h +O42 c +O42 c ^h +O42 d +O42 d +B +O42 i1a o48 +O42 i2h +O42 i3U t +O42 i4= +O42 i4e +O42 i4z L3 +O42 o0j +O42 o21 +O42 o3D +O42 o5` +O42 o5d +O42 p2 +O42 p2 O79 +O42 r +O42 s91 z3 +O42 sKE +O42 sa +O42 sdp +O42 sjb D8 +O42 slL +O42 srz +O42 t *52 +O42 z1 +O42 z1 i0A +O42 z2 +O42 z4 +7 +O42 { T6 +O42 } O43 -O43$! -O43$4D8 -O43$5 -O43$a -O43$dc -O43$e -O43$k -O43$xO31 -O43'8 -O43*04 -O43*05 -O43*42 -O43*43 -O43+2 -O43+3 -O43+4 -O43+7 -O43-9O73 -O43@7z1 -O43C -O43D7 -O43L0 -O43L4 -O43R0 -O43Z2 -O43Z3 -O43[ -O43^0 -O43^8R3 -O43^C -O43^D -O43^d -O43^i -O43d -O43f -O43i0% -O43i05 -O43i0m -O43i0w -O43i2I^# -O43i2uK -O43i4I -O43i50 -O43i76 -O43o2n -O43o4B -O43p1+0 -O43s2i -O43s6n -O43sKi -O43sbh -O43t -O43tZ1 -O43u -O43up1 -O43O41$$ -O43O41@l -O43z1 -O43z1O51 -O43z2 -O43{$a +O43 $! +O43 $4 D8 +O43 $5 +O43 $a +O43 $d c +O43 $e +O43 $k +O43 $x O31 +O43 '8 +O43 *04 +O43 *05 +O43 *42 +O43 *43 +O43 +2 +O43 +3 +O43 +4 +O43 +7 +O43 -9 O73 +O43 @7 z1 +O43 C +O43 D7 +O43 L0 +O43 L4 +O43 R0 +O43 Z2 +O43 Z3 +O43 [ +O43 ^0 +O43 ^8 R3 +O43 ^C +O43 ^D +O43 ^d +O43 ^i +O43 d +O43 f +O43 i0% +O43 i05 +O43 i0m +O43 i0w +O43 i2I ^# +O43 i2u K +O43 i4I +O43 i50 +O43 i76 +O43 o2n +O43 o4B +O43 p1 +0 +O43 s2i +O43 s6n +O43 sKi +O43 sbh +O43 t +O43 t Z1 +O43 u +O43 u p1 +O43 O41 $$ +O43 O41 @l +O43 z1 +O43 z1 O51 +O43 z2 +O43 { $a O45 -O45$pl -O45-0Z3 -O45-3 -O45-5 -O45@oi5i -O45C -O45C^. -O45D1 -O45L4 -O45R0 -O45R1 -O45T2^l -O45Z1 -O45Z2 -O45Z5[ -O45[ -O45^7 -O45^L -O45^j -O45^m -O45c -O45i1x -O45i5$ -O45l -O45o2+ -O45o4z -O45o78 -O45oAX'9 -O45p1 -O45s2i -O45spb -O45O53 -O45z1 -O45z5 -O45{ +O45 $p l +O45 -0 Z3 +O45 -3 +O45 -5 +O45 @o i5i +O45 C +O45 C ^. +O45 D1 +O45 L4 +O45 R0 +O45 R1 +O45 T2 ^l +O45 Z1 +O45 Z2 +O45 Z5 [ +O45 [ +O45 ^7 +O45 ^L +O45 ^j +O45 ^m +O45 c +O45 i1x +O45 i5$ +O45 l +O45 o2+ +O45 o4z +O45 o78 +O45 '9 +O45 p1 +O45 s2i +O45 spb +O45 O53 +O45 z1 +O45 z5 +O45 { O46 -O46$1 -O46$nZ1 -O46'7 -O46'8l -O46+2 -O46-1 -O46-2 -O46L4 -O46T0 -O46T2 -O46Z2 -O46^U -O46d -O46i0L -O46i4Yc -O46o02 -O46o3s -O46o6f -O46O61 -O46z1 -O46z2 +O46 $1 +O46 $n Z1 +O46 '7 +O46 '8 l +O46 +2 +O46 -1 +O46 -2 +O46 L4 +O46 T0 +O46 T2 +O46 Z2 +O46 ^U +O46 d +O46 i0L +O46 i4Y c +O46 o02 +O46 o3s +O46 o6f +O46 O61 +O46 z1 +O46 z2 O47 -O47$; -O47-4 -O47D1 -O47R1 -O47[ -O47^FR0 -O47^sO52 -O47c -O47o0_ -O47o3* -O47q -O47sge +O47 $; +O47 -4 +O47 D1 +O47 R1 +O47 [ +O47 ^F R0 +O47 ^s O52 +O47 c +O47 o0_ +O47 o3* +O47 q +O47 sge O48 -O48$3 -O48$8 -O48$z -O48^! -O48^2O16 -O48p1 -O48sat -O48sek -O48snw +O48 $3 +O48 $8 +O48 $z +O48 ^! +O48 ^2 O16 +O48 p1 +O48 sat +O48 sek +O48 snw O49 -O49'6 -O49D3^2 -O49Z1 -O49Z2 -O49^1 -O49^9 -O49i4u -O49o7s -O4A$f -O4A$p -O4A-0o1j -O4Ao4m -O4A} -O4Bc -O4Bt -O51$! -O51$6 -O51$; -O51$@ -O51$S -O51$x -O51$y -O51$z -O51'9 -O51'9so -O51*04 -O51*68 -O51+1 -O51+2Z3 -O51-1 -O51-2 -O51-4^2 -O51-5d -O51-7 -O51D4O59 -O51Kse6 -O51L3 -O51L3L1 -O51R1r -O51R5O5B -O51R8 -O51T1 -O51T3 -O51Z1t -O51Z2 -O51^' -O51^1 -O51^2 -O51^S -O51^i^o -O51^n -O51i0w*67 -O51i2T -O51i2h -O51i2o -O51i3m -O51i3q -O51i44 -O51i4A -O51i6r -O51o1h -O51o3L -O51o3s -O51o4N -O51r -O51s9u -O51sh2o6. -O51sj4 -O51sjm -O51ssa -O51O03 -O51O25i3k -O51O62 -O51z1 -O51z2O71 -O51z4 -O51{ +O49 '6 +O49 D3 ^2 +O49 Z1 +O49 Z2 +O49 ^1 +O49 ^9 +O49 i4u +O49 o7s +O4A $f +O4A $p +O4A -0 o1j +O4A o4m +O4A } +O4B c +O4B t +O51 $! +O51 $6 +O51 $; +O51 $@ +O51 $S +O51 $x +O51 $y +O51 $z +O51 '9 +O51 '9 so +O51 *04 +O51 *68 +O51 +1 +O51 +2 Z3 +O51 -1 +O51 -2 +O51 -4 ^2 +O51 -5 d +O51 -7 +O51 D4 O59 +O51 K se6 +O51 L3 +O51 L3 L1 +O51 R1 r +O51 R5 O5B +O51 R8 +O51 T1 +O51 T3 +O51 Z1 t +O51 Z2 +O51 ^' +O51 ^1 +O51 ^2 +O51 ^S +O51 ^i ^o +O51 ^n +O51 i0w *67 +O51 i2T +O51 i2h +O51 i2o +O51 i3m +O51 i3q +O51 i44 +O51 i4A +O51 i6r +O51 o1h +O51 o3L +O51 o3s +O51 o4N +O51 r +O51 s9u +O51 sh2 o6. +O51 sj4 +O51 sjm +O51 ssa +O51 O03 +O51 O25 i3k +O51 O62 +O51 z1 +O51 z2 O71 +O51 z4 +O51 { O52 -O52$$ -O52$6 -O52$7+4 -O52$9 -O52$@T0 -O52$Cu -O52$G -O52$a -O52$n -O52$p -O52$v -O52'A -O52*02 -O52*05 -O52*31 -O52*32 -O52*41 -O52*67 -O52+2 -O52+3+3 -O52+5 -O52+6i7e -O52-6 -O52@y -O52D7 -O52L4 -O52R2 -O52R3o66 -O52R4 -O52T5Z4 -O52T5O13 -O52Z1 -O52Z1$q -O52Z3 -O52[Z3 -O52^$ -O52^0 -O52^9 -O52^J -O52^O -O52^_ -O52^k -O52d -O52i01 -O52i0Q -O52i2u -O52i4r -O52i59 -O52o0C -O52o1P -O52o1dz1 -O52o23 -O52o41 -O52o4g -O52o4j -O52r -O52s0% -O52sMj -O52u -O52O02 -O52z1 -O52z1slI -O52z3 -O52} +O52 $$ +O52 $6 +O52 $7 +4 +O52 $9 +O52 $@ T0 +O52 $C u +O52 $G +O52 $a +O52 $n +O52 $p +O52 $v +O52 'A +O52 *02 +O52 *05 +O52 *31 +O52 *32 +O52 *41 +O52 *67 +O52 +2 +O52 +3 +3 +O52 +5 +O52 +6 i7e +O52 -6 +O52 @y +O52 D7 +O52 L4 +O52 R2 +O52 R3 o66 +O52 R4 +O52 T5 Z4 +O52 T5 O13 +O52 Z1 +O52 Z1 $q +O52 Z3 +O52 [ Z3 +O52 ^$ +O52 ^0 +O52 ^9 +O52 ^J +O52 ^O +O52 ^_ +O52 ^k +O52 d +O52 i01 +O52 i0Q +O52 i2u +O52 i4r +O52 i59 +O52 o0C +O52 o1P +O52 o1d z1 +O52 o23 +O52 o41 +O52 o4g +O52 o4j +O52 r +O52 s0% +O52 sMj +O52 u +O52 O02 +O52 z1 +O52 z1 slI +O52 z3 +O52 } O53 -O53$' -O53$H -O53$R -O53$X -O53$do4R -O53'7o0. -O53*10 -O53*96 -O53*97 -O53+9 -O53-2p1 -O53-4 -O53-9 -O53@e -O53D7 -O53L1 -O53L2@5 -O53R6s2r -O53R7 -O53T0 -O53T1 -O53T4 -O53Z1 -O53Z1sde -O53Z2 -O53Z3 -O53Z5 -O53^2 -O53^P -O53^S -O53^no3n -O53i14 -O53i1a -O53i4l -O53o2e -O53o3 -O53o6a -O53s0. -O53s1B -O53sln -O53t -O53O62 -O53z2 -O53z3 +O53 $' +O53 $H +O53 $R +O53 $X +O53 $d o4R +O53 '7 o0. +O53 *10 +O53 *96 +O53 *97 +O53 +9 +O53 -2 p1 +O53 -4 +O53 -9 +O53 @e +O53 D7 +O53 L1 +O53 L2 @5 +O53 R6 s2r +O53 R7 +O53 T0 +O53 T1 +O53 T4 +O53 Z1 +O53 Z1 sde +O53 Z2 +O53 Z3 +O53 Z5 +O53 ^2 +O53 ^P +O53 ^S +O53 ^n o3n +O53 i14 +O53 i1a +O53 i4l +O53 o2e +O53 o3 +O53 o6a +O53 s0. +O53 s1B +O53 sln +O53 t +O53 O62 +O53 z2 +O53 z3 O54 -O54$, -O54$t -O54$y -O54+A -O54-1R0 -O54-4 -O54-4+2 -O54-5 -O54@5 -O54C -O54D3 -O54R1 -O54R5 -O54R6 -O54R7 -O54T5 -O54Z1z2 -O54Z3 -O54]O21 -O54cO28 -O54i0t -O54i5t -O54i6i -O54i8i -O54l -O54o1F -O54o2P -O54o3D -O54o4/ -O54o54 -O54o6B -O54o6e -O54set -O54shCO02 -O54smBO32 -O54O04 -O54O48 -O54z1 -O54z2 +O54 $, +O54 $t +O54 $y +O54 +A +O54 -1 R0 +O54 -4 +O54 -4 +2 +O54 -5 +O54 @5 +O54 C +O54 D3 +O54 R1 +O54 R5 +O54 R6 +O54 R7 +O54 T5 +O54 Z1 z2 +O54 Z3 +O54 ] O21 +O54 c O28 +O54 i0t +O54 i5t +O54 i6i +O54 i8i +O54 l +O54 o1F +O54 o2P +O54 o3D +O54 o4/ +O54 o54 +O54 o6B +O54 o6e +O54 set +O54 shC O02 +O54 smB O32 +O54 O04 +O54 O48 +O54 z1 +O54 z2 O56 -O56$/ -O56$1 -O56$@ -O56$k -O56$w -O56'8o4s -O56+5 -O56+6 -O56-2@6 -O56-3o2& -O56-6 -O56CO04 -O56L5 -O56R1D3 -O56Z1 -O56Z2 -O56Z3[ -O56^6 -O56^OO23 -O56^r$b -O56i3x -O56o3, -O56O01 -O56O02d -O56O14^i -O56z1 +O56 $/ +O56 $1 +O56 $@ +O56 $k +O56 $w +O56 '8 o4s +O56 +5 +O56 +6 +O56 -2 @6 +O56 -3 o2& +O56 -6 +O56 C O04 +O56 L5 +O56 R1 D3 +O56 Z1 +O56 Z2 +O56 Z3 [ +O56 ^6 +O56 ^O O23 +O56 ^r $b +O56 i3x +O56 o3, +O56 O01 +O56 O02 d +O56 O14 ^i +O56 z1 O57 -O57$. -O57$0 -O57@0 -O57@a -O57R5 -O57Z2 -O57csti -O57i0a -O57i3- -O57p1 +O57 $. +O57 $0 +O57 @0 +O57 @a +O57 R5 +O57 Z2 +O57 c sti +O57 i0a +O57 i3- +O57 p1 O58 -O58'6i5w -O58+2 -O58+5 -O58z1 -O59$z -O59*16 -O59c+0 -O59i5l -O59to3e -O59O71 +O58 '6 i5w +O58 +2 +O58 +5 +O58 z1 +O59 $z +O59 *16 +O59 c +0 +O59 i5l +O59 t o3e +O59 O71 O5A -O5Bo6m -O61$* -O61$+ -O61$1 -O61$5 -O61$= -O61$p -O61$z -O61*41 -O61*53 -O61*64 -O61*78 -O61-2 -O61@i -O61@m -O61C$r -O61L0 -O61R5 -O61T4 -O61^. -O61^/ -O61^? -O61^Q^i -O61^i -O61^q -O61^z -O61i2$O13 -O61i25 -O61i3f -O61i3l -O61i3p'7 -O61i78 -O61i8k -O61i8u -O61o09 -O61o6 -O61o68 -O61o6g -O61o7w -O61o86 -O61r -O61s8m -O61sjxD4 -O61O14 -O61O21 -O61O23 -O61O53@h -O61z3 -O61{z4 -O61}-1 -O61}-9 +O5B o6m +O61 $* +O61 $+ +O61 $1 +O61 $5 +O61 $= +O61 $p +O61 $z +O61 *41 +O61 *53 +O61 *64 +O61 *78 +O61 -2 +O61 @i +O61 @m +O61 C $r +O61 L0 +O61 R5 +O61 T4 +O61 ^. +O61 ^/ +O61 ^? +O61 ^Q ^i +O61 ^i +O61 ^q +O61 ^z +O61 i2$ O13 +O61 i25 +O61 i3f +O61 i3l +i3p '7 +O61 i78 +O61 i8k +O61 i8u +O61 o09 +O61 o6 +O61 o68 +O61 o6g +O61 o7w +O61 o86 +O61 r +O61 s8m +O61 sjx D4 +O61 O14 +O61 O21 +O61 O23 +O61 O53 @h +O61 z3 +O61 { z4 +O61 } -1 +O61 } -9 O62 -O62$n -O62$w -O62'8 -O62*65 -O62+0 -O62+2 -O62-6 -O62-8 -O62@eR1 -O62@u -O62D3 -O62D6s0l -O62D8i61 -O62T3 -O62T6 -O62Z2 -O62Z5*3A -O62[ -O62^3 -O62^H -O62^M -O62^_ -O62^a -O62^l -O62^ul -O62c -O62d -O62i0S -O62i0b^Z -O62i0s -O62i35 -O62i3d-1 -O62i5; -O62i6a -O62i6m -O62i6u -O62i7r -O62l -O62l^M -O62o2y -O62o3t -O62o4* -O62o4j -O62o63 -O62o8s -O62r -O62s1i -O62sbd -O62se< -O62O02 -O62O23 -O62z5O27 +O62 $n +O62 $w +O62 '8 +O62 *65 +O62 +0 +O62 +2 +O62 -6 +O62 -8 +O62 @e R1 +O62 @u +O62 D3 +O62 D6 s0l +O62 D8 i61 +O62 T3 +O62 T6 +O62 Z2 +O62 Z5 *3A +O62 [ +O62 ^3 +O62 ^H +O62 ^M +O62 ^_ +O62 ^a +O62 ^l +O62 ^u l +O62 c +O62 d +O62 i0S +O62 i0b ^Z +O62 i0s +O62 i35 +O62 i3d -1 +O62 i5; +O62 i6a +O62 i6m +O62 i6u +O62 i7r +O62 l +O62 l ^M +O62 o2y +O62 o3t +O62 o4* +O62 o4j +O62 o63 +O62 o8s +O62 r +O62 s1i +O62 sbd +O62 se< +O62 O02 +O62 O23 +O62 z5 O27 O63 -O63$K -O63$R -O63$ao00 -O63$c -O63$mT2 -O63'B -O63*34 -O63*62 -O63-1O25 -O63@h -O63@n -O63R1 -O63R6 -O63R7 -O63Z1 -O63Z3 -O63Z5 -O63[O43 -O63^2 -O63c -O63d -O63i0F -O63i3so46 -O63i4s -O63i73 -O63i82T8 -O63l$r -O63o0x -O63o3z -O63p1O04 -O63r -O63scH -O63sk$ -O63sxS -O63u -O63z3$B +O63 $K +O63 $R +O63 $a o00 +O63 $c +O63 $m T2 +O63 'B +O63 *34 +O63 *62 +O63 -1 O25 +O63 @h +O63 @n +O63 R1 +O63 R6 +O63 R7 +O63 Z1 +O63 Z3 +O63 Z5 +O63 [ O43 +O63 ^2 +O63 c +O63 d +O63 i0F +O63 i3s o46 +O63 i4s +O63 i73 +O63 i82 +O63 l $r +O63 o0x +O63 o3z +O63 p1 O04 +O63 r +O63 scH +O63 sk$ +O63 sxS +O63 u +O63 z3 $B O64 -O64$! -O64$$ -O64$0 -O64$9 -O64$g -O64$u -O64+1 -O64+9 -O64-6 -O64-8o5m -O64T0 -O64[o5c -O64^7 -O64^g -O64i5o -O64i6< -O64i6t -O64i6w -O64l -O64o5q -O64skL -O64t -O64O23 -O64O32 -O64O91O43 +O64 $! +O64 $$ +O64 $0 +O64 $9 +O64 $g +O64 $u +O64 +1 +O64 +9 +O64 -6 +O64 -8 o5m +O64 T0 +O64 [ o5c +O64 ^7 +O64 ^g +O64 i5o +O64 i6< +O64 i6t +O64 i6w +O64 l +O64 o5q +O64 skL +O64 t +O64 O23 +O64 O32 +O64 O91 O43 O65 -O65$+ -O65$/ -O65$c -O65$k -O65*76 -O65+6 -O65@n -O65R0 -O65[ -O65l -O65o0K -O65o0v -O65o1t -O65o6p -O65o91 -O65slb -O65O0B -O65O21 -O65O73 +O65 $+ +O65 $/ +O65 $c +O65 $k +O65 *76 +O65 +6 +O65 @n +O65 R0 +O65 [ +O65 l +O65 o0K +O65 o0v +O65 o1t +O65 o6p +O65 o91 +O65 slb +O65 O0B +O65 O21 +O65 O73 O67 -O67$. -O67+7 -O67-4 -O67D2@w -O67T0 -O67i3l -O67o6ml -O68Z1 +O67 $. +O67 +7 +O67 -4 +O67 D2 @w +O67 T0 +O67 i3l +O67 o6m l +O68 Z1 O69 -O69$x -O69-5 -O69z1 +O69 $x +O69 -5 +O69 z1 O6A -O6A$1 -O6B[ -O71$" -O71$2D3 -O71$9 -O71$E -O71$a -O71$k -O71'8$g -O71'B -O71*53 -O71*56 -O71*58D5 -O71+5 -O71-0c -O71@9 -O71@s -O71L7 -O71R6 -O71T7 -O71Z4 -O71[O41 -O71c} -O71k*64 -O71o5 -O71o6h -O71o6j -O71o81 -O71o8e -O71o8k -O71r -O71s2! -O71s2x -O71sh-O43 -O71O04$f -O71O21 -O71z2O31 +O6A $1 +O6B [ +O71 $" +O71 $2 D3 +O71 $9 +O71 $E +O71 $a +O71 $k +O71 '8 $g +O71 'B +O71 *53 +O71 *56 +O71 *58 D5 +O71 +5 +O71 -0 c +O71 @9 +O71 @s +O71 L7 +O71 R6 +O71 T7 +O71 Z4 +O71 [ O41 +O71 c } +O71 k *64 +O71 o5 +O71 o6h +O71 o6j +O71 o81 +O71 o8e +O71 o8k +O71 r +O71 s2! +O71 s2x +O71 sh- O43 +O71 O04 $f +O71 O21 +O71 z2 O31 O72 -O72$0 -O72$3 -O72$4O63 -O72$a -O72'B -O72*13 -O72+1 -O72+2T6 -O72+8 -O72-5 -O72D1 -O72R7 -O72T2 -O72T7o74 -O72Z2 -O72Z3 -O72Z5 -O72[ -O72[l -O72^2 -O72^O -O72^h -O72^l -O72^m -O72c -O72i0f -O72i62 -O72i83 -O72o0v -O72o6u -O72o7Z -O72sa1 -O72O31 -O72O42 -O72z1 +O72 $0 +O72 $3 +O72 $4 O63 +O72 $a +O72 'B +O72 *13 +O72 +1 +O72 +2 T6 +O72 +8 +O72 -5 +O72 D1 +O72 R7 +O72 T2 +O72 o74 +O72 Z2 +O72 Z3 +O72 Z5 +O72 [ +O72 [ l +O72 ^2 +O72 ^O +O72 ^h +O72 ^l +O72 ^m +O72 c +O72 i0f +O72 i62 +O72 i83 +O72 o0v +O72 o6u +O72 o7Z +O72 sa1 +O72 O31 +O72 O42 +O72 z1 O73 -O73$4 -O73$6T6 -O73$8 -O73$C -O73$z -O73'9u -O73D8 -O73L1 -O73R4 -O73R6 -O73R8 -O73T6 -O73^S -O73^a -O73^i -O73^k -O73i6e -O73l -O73o14 -O73o64 -O73o8! -O73o8? -O73o9o -O73s23 -O73t -O73O51 -O73O84 +O73 $4 +O73 $6 T6 +O73 $8 +O73 $C +O73 $z +O73 '9 u +O73 D8 +O73 L1 +O73 R4 +O73 R6 +O73 R8 +O73 T6 +O73 ^S +O73 ^a +O73 ^i +O73 ^k +O73 i6e +O73 l +O73 o14 +O73 o64 +O73 o8! +O73 o8? +O73 o9o +O73 s23 +O73 t +O73 O51 +O73 O84 O74 -O74$# -O74$i -O74$y -O74'9 -O74+1 -O74+9 -O74@3 -O74D2 -O74T1 -O74i5sD1 -O74l -O74l'8 -O74o0g -O74o0rT7 -O74o4o -O74O04 +O74 $# +O74 $i +O74 $y +O74 '9 +O74 +1 +O74 +9 +O74 @3 +O74 D2 +O74 T1 +O74 i5s D1 +O74 l +O74 l '8 +O74 o0g +O74 o0r T7 +O74 o4o +O74 O04 O75 -O75$1 -O75$u -O75+9 -O75D3sck -O75L0 -O75R7 -O75T0 -O75Z1 -O75i70 -O75o4z -O75o8h -O75O03 -O75O13 -O75O51 +O75 $1 +O75 $u +O75 +9 +O75 D3 sck +O75 L0 +O75 R7 +O75 T0 +O75 Z1 +O75 i70 +O75 o4z +O75 o8h +O75 O03 +O75 O13 +O75 O51 O76 -O76+3 -O76+7 -O76[ -O76i7# -O76o6 -O76O81 -O78$5 -O78i3t -O7A+0 -O7Bc-7 -O7BO1AO15 -O7BO43O2B -O81$1 -O81$9 -O81$m -O81$z -O81'9 -O81*34 -O81*91 -O81-1 -O81-6 -O81-8 -O81-9 -O81-A -O81@b+3 -O81D1 -O81R8 -O81T3 -O81T4 -O81T5 -O81T8 -O81[@f -O81i8ac -O81o0uO53 -O81o2e -O81o5+ -O81o8s -O81o93 -O81p1O6A -O81r -O81s21 -O81seo -O81sry -O81O12 -O81O25l -O81O42 -O81O61 -O81O94 +O76 +3 +O76 +7 +O76 [ +O76 i7# +O76 o6 +O76 O81 +O78 $5 +O78 i3t +O7A +0 +O7B c -7 +O7B O1A O15 +O7B O43 O2B +O81 $1 +O81 $9 +O81 $m +O81 $z +O81 *34 +O81 *91 +O81 -1 +O81 -6 +O81 -8 +O81 -9 +O81 -A +O81 @b +3 +O81 D1 +O81 R8 +O81 T3 +O81 T4 +O81 T5 +O81 T8 +O81 [ @f +O81 i8a c +O81 o0u O53 +O81 o2e +O81 o5+ +O81 o8s +O81 o93 +O81 p1 O6A +O81 r +O81 s21 +O81 seo +O81 sry +O81 O12 +O81 O25 l +O81 O42 +O81 O61 +O81 O94 O82 -O82$6 -O82$c -O82$t -O82'A -O82*86 -O82*94'9 -O82*96 -O82*98 -O82+1 -O82-0 -O82-1 -O82-9 -O82D3 -O82D5 -O82L1 -O82R4O32 -O82R7 -O82T7 -O82Z2 -O82^1 -O82c -O82i6a -O82l -O82s45 -O82O06 -O82O17i1T -O82O34 -O82O92 +O82 $6 +O82 $c +O82 $t +O82 'A +O82 *86 +O82 *94 '9 +O82 *96 +O82 *98 +O82 +1 +O82 -0 +O82 -1 +O82 -9 +O82 D3 +O82 D5 +O82 L1 +O82 R4 O32 +O82 R7 +O82 T7 +O82 Z2 +O82 ^1 +O82 c +O82 i6a +O82 l +O82 s45 +O82 O06 +O82 O17 i1T +O82 O34 +O82 O92 O83 -O83$! -O83$# -O83$3 -O83$7 -O83'A -O83*57 -O83L8 -O83Z1 -O83Z2 -O83Z3 -O83^+ -O83c -O83l -O83o6h -O83o7mO04 -O83sa1 -O83O02T5 -O83O04^z -O83O12 -O83O42 -O83O43 -O83O51 +O83 $! +O83 $# +O83 $3 +O83 $7 +O83 'A +O83 *57 +O83 L8 +O83 Z1 +O83 Z2 +O83 Z3 +O83 ^+ +O83 c +O83 l +O83 o6h +O83 o7m O04 +O83 sa1 +O83 O02 T5 +O83 O04 ^z +O83 O12 +O83 O42 +O83 O43 +O83 O51 O84 -O84$9 -O84*78 -O84+7 -O84-7 -O84-8 -O84L8 -O84Z1 -O84Z1O24 -O84^x -O84i8c -O84l -O84oB0 -O84O34 +O84 $9 +O84 *78 +O84 +7 +O84 -7 +O84 -8 +O84 L8 +O84 Z1 +O84 Z1 O24 +O84 ^x +O84 i8c +O84 l +O84 oB0 +O84 O34 O85 -O85*67 -O85D0 -O85L8 -O85l -O85O43 +O85 *67 +O85 D0 +O85 L8 +O85 l +O85 O43 O86 -O86$1 -O86$l -O86-7 -O86-8 -O86T0 -O86O23 -O86O52 +O86 $1 +O86 $l +O86 -7 +O86 -8 +O86 T0 +O86 O23 +O86 O52 O87 -O87'8o6u -O87+2 -O87O21 -O89+9'9 -O89l -O89O62+7 -O91$9 -O91$< -O91'B -O91+6 -O91+B -O91@dO02 -O91@t -O91R8 -O91R9 -O91i1QO04 -O91i85 -O91o0j -O91o69 -O91o6p -O91o8_ -O91s92 -O91O06 -O91O24 -O91O51'A +'8 o6u +O87 +2 +O87 O21 +O89 '9 +O89 l +O89 O62 +7 +O91 $9 +O91 $< +O91 'B +O91 +6 +O91 +B +O91 @d O02 +O91 @t +O91 R8 +O91 R9 +O91 i1Q O04 +O91 i85 +O91 o0j +O91 o69 +O91 o6p +O91 o8_ +O91 s92 +O91 O06 +O91 O24 +O91 O51 'A O92 -O92$6 -O92$y -O92*87O08 -O92*98 -O92+7'A -O92+A -O92-8 -O92-9 -O92@3[ -O92Z1 -O92cO71 -O92i20 -O92u -O92O21 -O92O25 -O92O35 +O92 $6 +O92 $y +O92 *87 O08 +O92 *98 +O92 +7 'A +O92 +A +O92 -8 +O92 -9 +O92 @3 [ +O92 Z1 +O92 c O71 +O92 i20 +O92 u +O92 O21 +O92 O25 +O92 O35 O93 -O93$2 -O93*18O07 -O93-7 -O93C -O93D6 -O93L9 -O93c -O93i9e -O93l -O93O07 -O93O41 -O93O62 +O93 $2 +O93 *18 O07 +O93 -7 +O93 C +O93 D6 +O93 L9 +O93 c +O93 i9e +O93 l +O93 O07 +O93 O41 +O93 O62 O94 -O94T9o9g -O94O13 -O94O26 -O94O27R1 +O94 o9g +O94 O13 +O94 O26 +O94 O27 R1 O95 -O95$5 -O95o66 -O95O42 +O95 $5 +O95 o66 +O95 O42 O96 -O96'B -O96-6 -O96i16O15 +O96 'B +O96 -6 +O96 i16 O15 O97 -O9Al -O9AO15 -O9AO56O18 -O9AO62 -OA1$yO4A -OA1'B -OA1+7 -OA1+A -OA1+A$6 -OA1-9 -OA1@gO23 -OA1D8 -OA1LA -OA1Z1'B -OA1i0ZO06 -OA1i2k -OA1o1a -OA1oA6 -OA1oB0 -OA1O15 -OA1O21 +O9A l +O9A O15 +O9A O56 O18 +O9A O62 +OA1 $y O4A +OA1 'B +OA1 +7 +OA1 +A +OA1 +A $6 +OA1 -9 +OA1 @g O23 +OA1 D8 +OA1 LA +OA1 Z1 'B +OA1 i0Z O06 +OA1 i2k +OA1 o1a +OA1 oA6 +OA1 oB0 +OA1 O15 +OA1 O21 OA2 -OA2*97 -OA2+A -OA2T8O26 -OA2[ -OA2u +OA2 *97 +OA2 +A +OA2 T8 O26 +OA2 [ +OA2 u OA3 -OA3-A -OA3D6 -OA3c +OA3 -A +OA3 D6 +OA3 c OA4 -OA4$! -OA4$S -OA4D9u -OA4cO03 -OA4O35 -OA5O15 +OA4 $! +OA4 $S +OA4 D9 u +OA4 c O03 +OA4 O35 +OA5 O15 OA6 -OA7O07 -OA9O57 -OABOB4O69 -OB1$1 -OB1$2 -OB1$3 -OB1-B -OB1D1'8 -OB1oB3 +OA7 O07 +OA9 O57 +OAB OB4 O69 +OB1 $1 +OB1 $2 +OB1 $3 +OB1 -B +D1 '8 +OB1 oB3 OB2 -OB2$0 -OB2$4 -OB2$7 -OB2+B -OB2iB9 -OB2l -OB2O16 -OB2O36 +OB2 $0 +OB2 $4 +OB2 $7 +OB2 +B +OB2 iB9 +OB2 l +OB2 O16 +OB2 O36 OB3 -OB3$6 -OB3+9 -OB3-B -OB3Z1 -OB3[ -OB3l -OB3O04 -OB3O17 +OB3 $6 +OB3 +9 +OB3 -B +OB3 Z1 +OB3 [ +OB3 l +OB3 O04 +OB3 O17 OB4 -OB4$r -OB4O19 +OB4 $r +OB4 O19 OB5 -OB6O04 -OB6O46 +OB6 O04 +OB6 O46 OB7 z1 -z1$' -z1$-^A -z1$2 -z1$3 -z1$3^l -z1$7+3 -z1$7@j -z1$; -z1$?k -z1$bu -z1$f -z1$h -z1$i -z1$jR4 -z1$k -z1$l -z1$lC -z1$n -z1$o -z1$x -z1$y-1 -z1'5+1 -z1'5z5 -z1'6$0 -z1'7^M -z1'8 -z1'9T4 -z1'A -z1*02 -z1*03 -z1*10-B -z1*13 -z1*16 -z1*23 -z1*24 -z1*28 -z1*31-5 -z1*3Bc -z1*45O14 -z1*50 -z1*51} -z1*60 -z1*80i1{ -z1*84 -z1*94O12 -z1+1 -z1+4 -z1+6R6 -z1-1 -z1-1sf0 -z1-3 -z1-3d -z1-5Z1 -z1-9O32 -z1@1 -z1@2 -z1@7 -z1@a@1 -z1@b -z1@e -z1@f -z1@g -z1@gT0 -z1@k -z1@m -z1@p -z1@s+7 -z1@t -z1@tz3 -z1@z -z1C -z1Co1f -z1CsHM -z1D4shQ -z1DB -z1L0$1 -z1L1 -z1L2^7 -z1L3 -z1R3 -z1R7k -z1RAO54 -z1T0 -z1T5 -z1Z1*38 -z1Z1^S -z1Z1i16 -z1Z2^4 -z1Z3 -z1Z3'5 -z1Z3^q -z1Z3q -z1Z4 -z1Z5 -z1]r -z1^# -z1^)c -z1^/ -z1^0 -z1^2 -z1^4 -z1^5 -z1^7 -z1^8 -z1^9 -z1^9TB -z1^: -z1^= -z1^A -z1^D -z1^G -z1^I -z1^J -z1^L -z1^N -z1^R -z1^X -z1^^ -z1^a -z1^d -z1^e -z1^f -z1^h -z1^i -z1^j -z1^n -z1^p -z1^s -z1^w -z1^x -z1^| -z1c -z1d -z1f -z1i0F -z1i0F$1 -z1i0k -z1i0l} -z1i0u -z1i0}$7 -z1i1 -z1i1.D5 -z1i14 -z1i15 -z1i17 -z1i1; -z1i1_ -z1i1a -z1i1e -z1i1f -z1i1i -z1i1j -z1i1n -z1i1p -z1i1s -z1i1t -z1i2( -z1i28 -z1i29 -z1i2F -z1i2K-5 -z1i2R -z1i2W -z1i2_T0 -z1i2l -z1i3K -z1i3_*17 -z1i3k -z1i41 -z1i4_ -z1i4h -z1i4ssg3 -z1i5/ -z1i5Z*47 -z1i5e -z1i5f -z1i5yi6R -z1i6q -z1i7G -z1i8a -z1i8lO23 -z1i8t -z1i9H -z1iA1 -z1k^H -z1lO57 -z1o05+8 -z1o0nT4 -z1o0yz3 -z1o2% -z1o24 -z1o2N -z1o2O -z1o2X+6 -z1o2_ -z1o2gl -z1o2y -z1o3- -z1o3No4) -z1o3_ -z1o3f -z1o3m -z1o3x -z1o3z -z1o4, -z1o49 -z1o4c -z1o4k -z1o52 -z1o56Z3 -z1o5E -z1o5Ji3? -z1o5Y -z1o5k -z1o6)O03 -z1o61 -z1o6l -z1o6w -z1o6| -z1o71 -z1o7L -z1o7n -z1o7p -z1o8n -z1o91 -z1oAs -z1p1'5 -z1p1-5 -z1p1z1 -z1r$i -z1r*60 -z1r^r -z1rt -z1s0DO07 -z1s3e -z1s5pc -z1s8zO72 -z1s;| -z1sd5^v -z1sd= -z1sf* -z1shi -z1sig -z1sm/*52 -z1sm8i5n -z1sn9o0p -z1sot -z1stj -z1t -z1tD5 -z1O02o1B -z1O03p1 -z1O06^r -z1O07z2 -z1O0Ai1[ -z1O16Z2 -z1O19'7 -z1O24 -z1O27 -z1O32 -z1O34 -z1O36 -z1O36+4 -z1O38 -z1O42 -z1O43T2 -z1O47 -z1O51 -z1O52Z1 -z1O54 -z1O62l -z1O63 -z1O63l -z1O71 -z1O72 -z1O75 -z1O81 -z1O83 -z1O93 -z1OA7O23 -z1z1*25 -z1z1*68 -z1z1o0l -z1z2^M -z1z2o7m -z1z2o8n -z1{ -z1} -z1}$m -z1}R5 -z1}Z1 -z1}k -z1}u -z1}z1 -z2$-O31 -z2$. -z2$4 -z2$5*58 -z2$6l -z2$@ -z2$A -z2$AO2A -z2$Co80 -z2$D -z2$H -z2$Qo5f -z2$WO36 -z2$^Z2 -z2$c -z2$c^a -z2$fc -z2$h -z2$io1L -z2$k -z2$l -z2$o -z2$o*49 -z2$oT0 -z2$r -z2$s -z2$u -z2$z -z2$| -z2'5 -z2'8d -z2'9 -z2'A -z2*03 -z2*04 -z2*07 -z2*13O02 -z2*14 -z2*15 -z2*23 -z2*24 -z2*25o7r -z2*31 -z2*31} -z2*36*79 -z2*36o19 -z2*39*40 -z2*50 -z2*61 -z2*65 -z2*71 -z2*72 -z2*73 -z2*91 -z2*96 -z2+0 -z2+0r -z2+1 -z2+2 -z2+4$@ -z2+6 -z2+7t -z2+9 -z2+B -z2-0 -z2-1 -z2-1{ -z2-2 -z2-2*69 -z2-3o0T -z2-8 -z2@2 -z2@3 -z2@a -z2@b -z2@bt -z2@j -z2@m -z2@q -z2C -z2C*54 -z2CZ1 -z2D4^+ -z2D5Z5 -z2D7O81 -z2D8 -z2K -z2L0*53 -z2L0i2< -z2L1 -z2L3 -z2L7 -z2R0 -z2R0'7 -z2R1 -z2R2 -z2R4-6 -z2R6 -z2R9 -z2T0*45 -z2T2O38 -z2T4 -z2T4L1 -z2Z1 -z2Z3O38 -z2Z5O14 -z2[i6N -z2] -z2]u -z2^ -z2^" -z2^"C -z2^#$j -z2^*$% -z2^,k -z2^2 -z2^2i3r -z2^4 -z2^7 -z2^< -z2^A*80 -z2^AD4 -z2^W -z2^X$! -z2^[ -z2^` -z2^a -z2^b -z2^c -z2^e -z2^i -z2^ii5y -z2^k*53 -z2^m -z2^p -z2^t -z2^vz2 -z2^{^N -z2c -z2cZ1 -z2c^[ -z2co7d -z2dO82 -z2i0! -z2i0Fi4b -z2i0J -z2i1 ^h -z2i1+] -z2i14 -z2i19] -z2i1C+5 -z2i1Vc -z2i1a -z2i1k -z2i1m*13 -z2i1n -z2i1o -z2i1u -z2i2g -z2i38c -z2i3f*16 -z2i3h -z2i3l*06 -z2i3o -z2i3p -z2i3ro4k -z2i58 -z2i5LO36 -z2i5g -z2i6gk -z2i6u -z2i73 -z2i7a -z2i7o -z2i7s -z2i7t -z2i99*36 -z2i9e -z2lr -z2lO52 -z2o0!i0f -z2o0"*06 -z2o03 -z2o06 -z2o0Z -z2o0g*15 -z2o0m -z2o1- -z2o1. -z2o1/ -z2o10 -z2o1H -z2o1k -z2o1l -z2o1u -z2o1y -z2o2- -z2o21 -z2o2P -z2o2a*07 -z2o2b -z2o2gO35 -z2o3>$2 -z2o3\i1k -z2o3mD5 -z2o3o -z2o4H -z2o4Z -z2o4qz1 -z2o59 -z2o5w -z2o6= -z2o6> -z2o6Qi7N -z2o6a -z2o6nk -z2o7.l -z2o74 -z2o7N -z2o7gz1 -z2o7l -z2o83 -z2o88 -z2o93 -z2oB9 -z2p1 -z2p2O74 -z2q -z2r-7 -z2rc -z2s.@c -z2s0Ol -z2s2b -z2s4f -z2s4x -z2s7m -z2s97 -z2s9k -z2sbq -z2scl -z2sd8 -z2si3O34 -z2siai2g -z2slMo99 -z2srtO04 -z2su% -z2sx -z2tK -z2u+9 -z2u^0 -z2u^K -z2uo1< -z2usG0 -z2O24 -z2O27 -z2O29Z1 -z2O2A -z2O32 -z2O35*03 -z2O35T0 -z2O42 -z2O45i0E -z2O47 -z2O53 -z2O61 -z2O65l -z2z1i2: -z2z1i37 -z2z3o5l -z2z4 -z2{Z5 -z2} -z2}*29 -z3$+ -z3$3 -z3$5O51 -z3$7 -z3$Ak -z3$c -z3$e -z3$ei4; -z3$el -z3$f -z3$h -z3$k -z3$n -z3$rD9 -z3$s -z3$y -z3'8 -z3'8Z4 -z3'9 -z3'9r -z3'A -z3'B*39 -z3*04 -z3*06 -z3*07 -z3*14 -z3*15 -z3*16*70 -z3*17 -z3*19 -z3*24 -z3*26 -z3*27 -z3*28 -z3*35 -z3*43 -z3*46 -z3*57O71 -z3*58 -z3*58o8* -z3*61 -z3*72T5 -z3*73 -z3*75 -z3*83 -z3*87 -z3*94R3 -z3*95+8 -z3*97 -z3+0 -z3+1 -z3+1O49 -z3+2 -z3+4z5 -z3+5 -z3+6 -z3+6u -z3+8 -z3-1 -z3-1-2 -z3-2 -z3-3 -z3-5-3 -z3-9 -z3@a -z3@h -z3@j -z3@k -z3@mss1 -z3C -z3D1*75 -z3D3O2B -z3D4*59 -z3D5r -z3D7 -z3K -z3K$g -z3K} -z3L4O38 -z3R0*37 -z3R1 -z3R4 -z3R4-0 -z3R6 -z3T1 -z3T2 -z3T4sru -z3Z1*80 -z3Z1-0 -z3Z3'8 -z3Z3+9 -z3Z4 -z3[o7i -z3[{ -z3] -z3^! -z3^# -z3^' -z3^. -z3^; -z3^B -z3^D-5 -z3^G -z3^Qi0S -z3^R$` -z3^V -z3^Y -z3^Y*30 -z3^c -z3^m -z3^q -z3^q-8 -z3^ssns -z3^w^= -z3^wl -z3^x -z3c -z3c*42 -z3cK -z3cs7V -z3dO54 -z3i01^# -z3i0U -z3i0d -z3i15 -z3i1XO01 -z3i26 -z3i28 -z3i3gO48 -z3i3r -z3i3z -z3i41 -z3i4C -z3i4l -z3i4yO36 -z3i5^ -z3i5zT4 -z3i5{ -z3i6++8 -z3i6r -z3k'7 -z3ksgc -z3l -z3o08 -z3o0f -z3o0mZ1 -z3o0n -z3o0qo4! -z3o12 -z3o1O*84 -z3o1c -z3o2- -z3o21 -z3o23 -z3o2LO64 -z3o2b -z3o39z2 -z3o3A -z3o3j[ -z3o3r+5 -z3o3z -z3o48L6 -z3o4J -z3o4Z -z3o4d -z3o4dD5 -z3o5Xc -z3o5b -z3o5d^' -z3o5g -z3o5l*38 -z3o6-D0 -z3o6}*2B -z3o7g -z3o8 -z3o88 -z3o8P -z3o8h -z3rsk* -z3s3lO35 -z3s8jo84 -z3sM4O24 -z3sMr -z3scl -z3scr -z3siI*26 -z3sis -z3sjW -z3srx -z3ssz*23 -z3sys -z3szd -z3tO54 -z3O01O72 -z3O02^E -z3O14Z4 -z3O25u -z3O27 -z3O29 -z3O29$B -z3O2A -z3O36i11 -z3O39 -z3O41 -z3O41O46 -z3O42 -z3O43 -z3O52 -z3O52z4 -z3O56 -z3O61{ -z3O63 -z3O63*42 -z3O72 -z3O75 -z3O84 -z3OA1*5A -z3z2*65 -z3z3*81 -z3z3C -z3z3^N -z3z4 -z3z5 -z3z5-A -z3z5O93 -z3{ -z3{-4 -z3{^' -z3} -z3}^( -z3}i4* +z1 $' +z1 $- ^A +z1 $2 +z1 $3 +z1 $3 ^l +z1 $7 +3 +z1 $7 @j +z1 $; +z1 $? +z1 $b u +z1 $f +z1 $h +z1 $i +z1 $j R4 +z1 $k +z1 $l +z1 $l C +z1 $n +z1 $o +z1 $x +z1 $y -1 +z1 '5 +1 +z1 '5 z5 +z1 '6 $0 +z1 '7 ^M +z1 '8 +z1 '9 T4 +z1 'A +z1 *02 +z1 *03 +z1 -B +z1 *13 +z1 *16 +z1 *23 +z1 *24 +z1 *28 +z1 *31 -5 +z1 *3B c +z1 *45 O14 +z1 *50 +z1 *51 } +z1 *60 +z1 *80 i1{ +z1 *84 +z1 *94 O12 +z1 +1 +z1 +4 +z1 +6 R6 +z1 -1 +z1 -1 sf0 +z1 -3 +z1 -3 d +z1 -5 Z1 +z1 -9 O32 +z1 @1 +z1 @2 +z1 @a @1 +z1 @b +z1 @e +z1 @g +z1 @g T0 +z1 @k +z1 @m +z1 @p +z1 @s +7 +z1 @t +z1 @t z3 +z1 C +z1 C o1f +z1 C sHM +z1 D4 shQ +z1 DB +z1 L0 $1 +z1 L1 +z1 L2 ^7 +z1 L3 +z1 R3 +z1 R7 +z1 RA O54 +z1 T0 +z1 T5 +z1 Z1 *38 +z1 Z1 ^S +z1 Z1 i16 +z1 Z2 ^4 +z1 Z3 +z1 Z3 '5 +z1 Z3 ^q +z1 Z3 q +z1 Z4 +z1 Z5 +z1 ] r +z1 ^# +z1 ^) c +z1 ^/ +z1 ^0 +z1 ^2 +z1 ^4 +z1 ^5 +z1 ^7 +z1 ^8 +z1 ^9 +z1 ^9 TB +z1 ^: +z1 ^= +z1 ^A +z1 ^D +z1 ^G +z1 ^I +z1 ^J +z1 ^L +z1 ^N +z1 ^R +z1 ^X +z1 ^^ +z1 ^a +z1 ^d +z1 ^e +z1 ^f +z1 ^h +z1 ^i +z1 ^j +z1 ^n +z1 ^p +z1 ^s +z1 ^w +z1 ^x +z1 ^| +z1 c +z1 d +z1 f +z1 i0F +z1 i0F $1 +z1 i0k +z1 i0l } +z1 i0u +z1 i0} $7 +z1 i1 +z1 i1. D5 +z1 i14 +z1 i15 +z1 i17 +z1 i1; +z1 i1_ +z1 i1a +z1 i1e +z1 i1f +z1 i1i +z1 i1j +z1 i1n +z1 i1p +z1 i1s +z1 i1t +z1 i2( +z1 i28 +z1 i29 +z1 i2F +z1 i2K -5 +z1 i2R +z1 i2W +z1 i2_ T0 +z1 i2l +z1 i3K +z1 i3_ *17 +z1 i3k +z1 i41 +z1 i4_ +z1 i4h +z1 i4s sg3 +z1 i5/ +z1 i5Z *47 +z1 i5e +z1 i5f +z1 i5y i6R +z1 i6q +z1 i7G +z1 i8a +z1 i8l O23 +z1 i8t +z1 i9H +z1 iA1 +z1 ^H +z1 l O57 +z1 o05 +8 +z1 o0n T4 +z1 o0y z3 +z1 o2% +z1 o24 +z1 o2N +z1 o2O +z1 o2X +6 +z1 o2_ +z1 o2g l +z1 o2y +z1 o3- +z1 o3N o4) +z1 o3_ +z1 o3f +z1 o3m +z1 o3x +z1 o3z +z1 o4, +z1 o49 +z1 o4c +z1 o4k +z1 o52 +z1 o56 Z3 +z1 o5E +z1 o5J i3? +z1 o5Y +z1 o5k +z1 o6) O03 +z1 o61 +z1 o6l +z1 o6w +z1 o6| +z1 o71 +z1 o7L +z1 o7n +z1 o7p +z1 o8n +z1 o91 +z1 oAs +z1 p1 '5 +z1 p1 -5 +z1 p1 z1 +z1 r $i +z1 r *60 +z1 r ^r +z1 r t +z1 s0D O07 +z1 s3e +z1 s5p c +z1 s8z O72 +z1 s;| +z1 sd5 ^v +z1 sd= +z1 sf* +z1 shi +z1 sig +z1 sm/ *52 +z1 sm8 i5n +z1 sn9 o0p +z1 sot +z1 stj +z1 t +z1 t D5 +z1 O02 o1B +z1 O03 p1 +z1 O06 ^r +z1 O07 z2 +z1 O0A i1[ +z1 O16 Z2 +z1 O19 '7 +z1 O24 +z1 O27 +z1 O32 +z1 O34 +z1 O36 +z1 O36 +4 +z1 O38 +z1 O42 +z1 O43 T2 +z1 O47 +z1 O51 +z1 O52 Z1 +z1 O54 +z1 O62 l +z1 O63 +z1 O63 l +z1 O71 +z1 O72 +z1 O75 +z1 O81 +z1 O83 +z1 O93 +z1 OA7 O23 +z1 z1 *25 +z1 z1 *68 +z1 z1 o0l +z1 z2 ^M +z1 z2 o7m +z1 z2 o8n +z1 { +z1 } +z1 } $m +z1 } R5 +z1 } Z1 +z1 } k +z1 } u +z1 } z1 +z2 $- O31 +z2 $. +z2 $4 +z2 $5 *58 +z2 $6 l +z2 $@ +z2 $A +z2 $A O2A +z2 $C o80 +z2 $D +z2 $H +z2 $Q o5f +z2 $W O36 +z2 $^ Z2 +z2 $c +z2 $c ^a +z2 $f c +z2 $h +z2 $i o1L +z2 $k +z2 $l +z2 $o +z2 $o *49 +z2 $o T0 +z2 $r +z2 $s +z2 $u +z2 $z +z2 $| +z2 '5 +z2 '8 d +z2 '9 +z2 'A +z2 *03 +z2 *04 +z2 *07 +z2 *13 O02 +z2 *14 +z2 *15 +z2 *23 +z2 *24 +z2 *25 o7r +z2 *31 +z2 *31 } +z2 *36 *79 +z2 *36 o19 +z2 *39 *40 +z2 *50 +z2 *61 +z2 *65 +z2 *71 +z2 *72 +z2 *73 +z2 *91 +z2 *96 +z2 +0 +z2 +0 r +z2 +1 +z2 +2 +z2 +4 $@ +z2 +6 +z2 +7 t +z2 +9 +z2 +B +z2 -0 +z2 -1 +z2 -1 { +z2 -2 +z2 -2 *69 +z2 -3 o0T +z2 -8 +z2 @2 +z2 @a +z2 @b +z2 @b t +z2 @j +z2 @m +z2 @q +z2 C +z2 C *54 +z2 C Z1 +z2 D4 ^+ +z2 D5 Z5 +z2 D7 O81 +z2 D8 +z2 K +z2 L0 *53 +z2 L0 i2< +z2 L1 +z2 L3 +z2 L7 +z2 R0 +z2 R0 '7 +z2 R1 +z2 R2 +z2 R4 -6 +z2 R6 +z2 R9 +z2 T0 *45 +z2 T2 O38 +z2 T4 +z2 T4 L1 +z2 Z1 +z2 Z3 O38 +z2 Z5 O14 +z2 [ i6N +z2 ] +z2 ] u +z2 ^ +z2 ^" +z2 ^" C +z2 ^# $j +z2 ^* $% +z2 ^, k +z2 ^2 +z2 ^2 i3r +z2 ^4 +z2 ^7 +z2 ^< +z2 ^A *80 +z2 ^A D4 +z2 ^W +z2 ^X $! +z2 ^[ +z2 ^` +z2 ^a +z2 ^b +z2 ^c +z2 ^e +z2 ^i +z2 ^i i5y +z2 ^k *53 +z2 ^m +z2 ^p +z2 ^t +z2 ^v z2 +z2 ^{ ^N +z2 c +z2 c Z1 +z2 c ^[ +z2 c o7d +z2 d O82 +z2 i0! +z2 i0F i4b +z2 i0J +z2 i1 ^h +z2 i1+ ] +z2 i14 +z2 i19 ] +z2 i1C +5 +z2 i1V c +z2 i1a +z2 i1k +z2 i1m *13 +z2 i1n +z2 i1o +z2 i1u +z2 i2g +z2 i38 c +z2 i3f *16 +z2 i3h +z2 i3l *06 +z2 i3o +z2 i3p +z2 i3r o4k +z2 i58 +z2 i5L O36 +z2 i5g +z2 i6g +z2 i6u +z2 i73 +z2 i7a +z2 i7o +z2 i7s +z2 i7t +z2 i99 *36 +z2 i9e +z2 l r +z2 l O52 +z2 o0! i0f +z2 o0" *06 +z2 o03 +z2 o06 +z2 o0Z +z2 o0g *15 +z2 o0m +z2 o1- +z2 o1. +z2 o1/ +z2 o10 +z2 o1H +z2 o1k +z2 o1l +z2 o1u +z2 o1y +z2 o2- +z2 o21 +z2 o2P +z2 o2a *07 +z2 o2b +z2 o2g O35 +z2 o3> $2 +z2 o3\ i1k +z2 o3m D5 +z2 o3o +z2 o4H +z2 o4Z +z2 o4q z1 +z2 o59 +z2 o5w +z2 o6= +z2 o6> +z2 o6Q i7N +z2 o6a +z2 o6n +z2 o7. l +z2 o74 +z2 o7N +z2 o7g z1 +z2 o7l +z2 o83 +z2 o88 +z2 o93 +z2 oB9 +z2 p1 +z2 p2 O74 +z2 q +z2 r -7 +z2 r c +z2 s.@ c +z2 s0O l +z2 s2b +z2 s4f +z2 s4x +z2 s7m +z2 s97 +z2 s9k +z2 sbq +z2 scl +z2 sd8 +z2 si3 O34 +z2 sia i2g +z2 slM o99 +z2 srt O04 +z2 su% +z2 sx +z2 t K +z2 u +9 +z2 u ^0 +z2 u ^K +z2 u o1< +z2 u sG0 +z2 O24 +z2 O27 +z2 O29 Z1 +z2 O2A +z2 O32 +z2 O35 *03 +z2 O35 T0 +z2 O42 +z2 O45 i0E +z2 O47 +z2 O53 +z2 O61 +z2 O65 l +z2 z1 i2: +z2 z1 i37 +z2 z3 o5l +z2 z4 +z2 { Z5 +z2 } +z2 } *29 +z3 $+ +z3 $3 +z3 $5 O51 +z3 $7 +z3 $A +z3 $c +z3 $e +z3 $e i4; +z3 $e l +z3 $f +z3 $h +z3 $k +z3 $n +z3 $r D9 +z3 $s +z3 $y +z3 '8 +z3 '8 Z4 +z3 '9 +z3 '9 r +z3 'A +z3 'B *39 +z3 *04 +z3 *06 +z3 *07 +z3 *14 +z3 *15 +z3 *16 *70 +z3 *17 +z3 *19 +z3 *24 +z3 *26 +z3 *27 +z3 *28 +z3 *35 +z3 *43 +z3 *46 +z3 *57 O71 +z3 *58 +z3 *58 o8* +z3 *61 +z3 *72 T5 +z3 *73 +z3 *75 +z3 *83 +z3 *87 +z3 *94 R3 +z3 *95 +8 +z3 *97 +z3 +0 +z3 +1 +z3 +1 O49 +z3 +2 +z3 +4 z5 +z3 +5 +z3 +6 +z3 +6 u +z3 +8 +z3 -1 +z3 -1 -2 +z3 -2 +z3 -3 +z3 -5 -3 +z3 -9 +z3 @a +z3 @h +z3 @j +z3 @k +z3 @m ss1 +z3 C +z3 D1 *75 +z3 D3 O2B +z3 D4 *59 +z3 D5 r +z3 D7 +z3 K +z3 K $g +z3 K } +z3 L4 O38 +z3 R0 *37 +z3 R1 +z3 R4 +z3 R4 -0 +z3 R6 +z3 T1 +z3 T2 +z3 T4 sru +z3 Z1 *80 +z3 Z1 -0 +z3 Z3 '8 +z3 Z3 +9 +z3 Z4 +z3 [ o7i +z3 [ { +z3 ] +z3 ^! +z3 ^# +z3 ^' +z3 ^. +z3 ^; +z3 ^B +z3 ^D -5 +z3 ^G +z3 ^Q i0S +z3 ^R $` +z3 ^V +z3 ^Y +z3 ^Y *30 +z3 ^c +z3 ^m +z3 ^q +z3 ^q -8 +z3 ^s sns +z3 ^w ^= +z3 ^w l +z3 ^x +z3 c +z3 c *42 +z3 c K +z3 c s7V +z3 d O54 +z3 i01 ^# +z3 i0U +z3 i0d +z3 i15 +z3 i1X O01 +z3 i26 +z3 i28 +z3 i3g O48 +z3 i3r +z3 i3z +z3 i41 +z3 i4C +z3 i4l +z3 i4y O36 +z3 i5^ +z3 i5z T4 +z3 i5{ +z3 i6+ +8 +z3 i6r +z3 '7 +z3 sgc +z3 l +z3 o08 +z3 o0f +z3 o0m Z1 +z3 o0n +z3 o0q o4! +z3 o12 +z3 o1O *84 +z3 o1c +z3 o2- +z3 o21 +z3 o23 +z3 o2L O64 +z3 o2b +z3 o39 z2 +z3 o3A +z3 o3j [ +z3 o3r +5 +z3 o3z +z3 o48 L6 +z3 o4J +z3 o4Z +z3 o4d +z3 o4d D5 +z3 o5X c +z3 o5b +z3 o5d ^' +z3 o5g +z3 o5l *38 +z3 o6- D0 +z3 o6} *2B +z3 o7g +z3 o8 +z3 o88 +z3 o8P +z3 o8h +z3 r sk* +z3 s3l O35 +z3 s8j o84 +z3 sM4 O24 +z3 sMr +z3 scl +z3 scr +z3 siI *26 +z3 sis +z3 sjW +z3 srx +z3 ssz +z3 sys +z3 szd +z3 t O54 +z3 O01 O72 +z3 O02 ^E +z3 O14 Z4 +z3 O25 u +z3 O27 +z3 O29 +z3 O29 $B +z3 O2A +z3 O36 i11 +z3 O39 +z3 O41 +z3 O41 O46 +z3 O42 +z3 O43 +z3 O52 +z3 O52 z4 +z3 O56 +z3 O61 { +z3 O63 +z3 O63 *42 +z3 O72 +z3 O75 +z3 O84 +z3 OA1 *5A +z3 z2 *65 +z3 z3 *81 +z3 z3 C +z3 z3 ^N +z3 z4 +z3 z5 +z3 z5 -A +z3 z5 O93 +z3 { +z3 { -4 +z3 { ^' +z3 } +z3 } ^( +z3 } i4* z4 -z4$! -z4$0 -z4$1 -z4$=C -z4$M -z4$b -z4$e*71 -z4$f -z4$m -z4$x} -z4'9o2^ -z4*07 -z4*0A -z4*17 -z4*25 -z4*28'5 -z4*28O62 -z4*35'A -z4*36 -z4*36+4 -z4*49 -z4*50O54 -z4*51 -z4*54 -z4*58 -z4*59O16 -z4*60 -z4*61$3 -z4*73*59 -z4*76 -z4*78*76 -z4*81 -z4*83O61 -z4*95*35 -z4*98 -z4+0 -z4+0+6 -z4+1 -z4+2 -z4+5 -z4+6T2 -z4+9^+ -z4+A -z4-0 -z4-0] -z4-1 -z4-2 -z4-3 -z4-4 -z4-5 -z4-8O12 -z4C -z4D8 -z4K*35 -z4L0 -z4L1 -z4L2O38 -z4L5 -z4R2 -z4R3 -z4R6+3 -z4R8*21 -z4T1 -z4T2sm5 -z4T4 -z4T5 -z4T7+4 -z4Z1 -z4Z1O81 -z4Z1} -z4Z2$A -z4Z3 -z4Z5 -z4[$b -z4[L2 -z4[o4l -z4] -z4]{ -z4^. -z4^4D2 -z4^9 -z4^: -z4^B-8 -z4^N -z4^`*5A -z4^c -z4^i -z4^j -z4^n -z4^|o0O -z4c -z4f'9 -z4i0b -z4i11 -z4i1h -z4i2Dsrw -z4i37 -z4i4# -z4i4- -z4i47 -z4i4b -z4i4f -z4i5_ -z4i5m -z4i5y[ -z4i6d -z4i7& -z4i8@O27 -z4i9r -z4iBd -z4li4+ -z4o2y -z4o3[ -z4o3d -z4o3h -z4o3l$1 -z4o3y -z4o3{ -z4o4> -z4o6= -z4o7u -z4o84c -z4o8U -z4o8z -z4oAr -z4p1O3A -z4p3 -z4r*18 -z4rO34 -z4s0ao3f -z4sbq -z4srPT5 -z4sso -z4suy -z4sw+ -z4swv -z4t -z4t$L -z4tO34 -z4O01@e -z4O06$u -z4O06o3v -z4O16i4e -z4O16o4% -z4O18+2 -z4O1AZ2 -z4O24i7O -z4O28u -z4O29 -z4O34} -z4O35 -z4O35f -z4O35o0N -z4O37 -z4O42o6x -z4O43 -z4O43C -z4O46 -z4O54R0 -z4O56 -z4O5A -z4O63z5 -z4O71+9 -z4O82 -z4O92c -z4z5 -z4z5O75 -z4{ -z4{+0 -z4{^y -z4} -z4}O28 -z5$9 -z5$; -z5$y -z5'6T4 -z5'8$o -z5*17 -z5*27+3 -z5*36 -z5*48 -z5*4Ai0# -z5*60 -z5*64 -z5*67 -z5*72[ -z5*74 -z5*A2O92 -z5+1 -z5+2 -z5+4 -z5+4shk -z5+5T5 -z5+6 -z5+7 -z5+7z3 -z5+8o8f -z5-0 -z5-1+2 -z5-2 -z5-9 -z5@3 -z5@a -z5D7-4 -z5K -z5L1 -z5R0 -z5R1 -z5R5 -z5T1 -z5T5 -z5T7-3 -z5Z1O27 -z5Z2O27 -z5Z4 -z5Z4^g -z5[o4o -z5] -z5^/ -z5^3O75 -z5^6 -z5^D -z5^m -z5^nz1 -z5^w -z5^z -z5^zO76 -z5d'9 -z5i01z4 -z5i3|i6X -z5i4c -z5i57 -z5i5l -z5i69O57 -z5i6U -z5i71O34 -z5i7R -z5i7u*9B -z5i9?O57 -z5i9Zl -z5ki6d -z5o0er -z5o10o3k -z5o1X -z5o1li28 -z5o3O-8 -z5o4{O39 -z5o6d*15 -z5o6t -z5o7e -z5o7pD8 -z5oA1i4l -z5oA3z1 -z5qO3A -z5rO34 -z5s36 -z5s36O36 -z5s5q -z5s5t -z5s9AO1B -z5shsO38 -z5sw& -z5t*76 -z5u -z5u+3 -z5O07@p -z5O0B+5 -z5O0B^r -z5O17k -z5O1AZ1 -z5O23i72 -z5O24O76 -z5O25 -z5O28 -z5O29 -z5O35 -z5O35Z2 -z5O38+1 -z5O38l -z5O39 -z5O3A -z5O43 -z5O45r -z5O48 -z5O49Z1 -z5O53K -z5O53^; -z5O56 -z5O5Az2 -z5O61 -z5O62i40 -z5O64 -z5O65D6 -z5O68 -z5O71*27 -z5O71o33 -z5O72 -z5O73 -z5O79 -z5O79$r -z5O81] -z5O84 -z5z3o7b -z5}O47 +z4 $! +z4 $0 +z4 $1 +z4 $= C +z4 $M +z4 $b +z4 $e *71 +z4 $f +z4 $m +z4 $x } +z4 '9 o2^ +z4 *07 +z4 *0A +z4 *17 +z4 *25 +z4 *28 '5 +z4 *28 O62 +z4 *35 'A +z4 *36 +z4 *36 +4 +z4 *49 +z4 *50 O54 +z4 *51 +z4 *54 +z4 *58 +z4 *59 O16 +z4 *60 +z4 *61 $3 +z4 *73 *59 +z4 *76 +z4 *78 *76 +z4 *81 +z4 *83 O61 +z4 *95 *35 +z4 *98 +z4 +0 +z4 +0 +6 +z4 +1 +z4 +2 +z4 +5 +z4 +6 T2 +z4 +9 ^+ +z4 +A +z4 -0 +z4 -0 ] +z4 -1 +z4 -2 +z4 -3 +z4 -4 +z4 -5 +z4 -8 O12 +z4 C +z4 D8 +z4 K *35 +z4 L0 +z4 L1 +z4 L2 O38 +z4 L5 +z4 R2 +z4 R3 +z4 R6 +3 +z4 R8 +z4 T1 +z4 T2 sm5 +z4 T4 +z4 T5 +z4 T7 +4 +z4 Z1 +z4 Z1 O81 +z4 Z1 } +z4 Z2 $A +z4 Z3 +z4 Z5 +z4 [ $b +z4 [ L2 +z4 [ o4l +z4 ] +z4 ] { +z4 ^. +z4 ^4 D2 +z4 ^9 +z4 ^: +z4 ^B -8 +z4 ^N +z4 ^` *5A +z4 ^c +z4 ^i +z4 ^j +z4 ^n +z4 ^| o0O +z4 c +z4 f '9 +z4 i0b +z4 i11 +z4 i1h +z4 i2D srw +z4 i37 +z4 i4# +z4 i4- +z4 i47 +z4 i4b +z4 i4f +z4 i5_ +z4 i5m +z4 i5y [ +z4 i6d +z4 i7& +z4 i8@ O27 +z4 i9r +z4 iBd +z4 l i4+ +z4 o2y +z4 o3[ +z4 o3d +z4 o3h +z4 o3l $1 +z4 o3y +z4 o3{ +z4 o4> +z4 o6= +z4 o7u +z4 o84 c +z4 o8U +z4 o8z +z4 oAr +z4 p1 O3A +z4 p3 +z4 r *18 +z4 r O34 +z4 s0a o3f +z4 sbq +z4 srP T5 +z4 sso +z4 suy +z4 sw+ +z4 swv +z4 t +z4 t $L +z4 t O34 +z4 O01 @e +z4 O06 $u +z4 O06 o3v +z4 O16 i4e +z4 O16 o4% +z4 O18 +2 +z4 O1A Z2 +z4 O24 i7O +z4 O28 u +z4 O29 +z4 O34 } +z4 O35 +z4 O35 f +z4 O35 o0N +z4 O37 +z4 O42 o6x +z4 O43 +z4 O43 C +z4 O46 +z4 O54 R0 +z4 O56 +z4 O5A +z4 O63 z5 +z4 O71 +9 +z4 O82 +z4 O92 c +z4 z5 +z4 z5 O75 +z4 { +z4 { +0 +z4 { ^y +z4 } +z4 } O28 +z5 $9 +z5 $; +z5 $y +z5 '6 T4 +z5 '8 $o +z5 *17 +z5 *27 +3 +z5 *36 +z5 *48 +z5 *4A i0# +z5 *60 +z5 *64 +z5 *67 +z5 *72 [ +z5 *74 +z5 *A2 O92 +z5 +1 +z5 +2 +z5 +4 +z5 +4 shk +z5 +5 T5 +z5 +6 +z5 +7 +z5 +7 z3 +z5 o8f +z5 -0 +z5 -1 +2 +z5 -2 +z5 -9 +z5 @3 +z5 @a +z5 D7 -4 +z5 K +z5 L1 +z5 R0 +z5 R1 +z5 R5 +z5 T1 +z5 T5 +z5 T7 -3 +z5 Z1 O27 +z5 Z2 O27 +z5 Z4 +z5 Z4 ^g +z5 [ o4o +z5 ] +z5 ^/ +z5 ^3 O75 +z5 ^6 +z5 ^D +z5 ^m +z5 ^n z1 +z5 ^w +z5 ^z +z5 ^z O76 +z5 d '9 +z5 i01 z4 +z5 i3| i6X +z5 i4c +z5 i57 +z5 i5l +z5 i69 O57 +z5 i6U +z5 i71 O34 +z5 i7R +z5 i7u *9B +z5 i9? O57 +z5 i9Z l +z5 i6d +z5 o0e r +z5 o10 o3k +z5 o1X +z5 o1l i28 +z5 o3O -8 +z5 o4{ O39 +z5 o6d +z5 o6t +z5 o7e +z5 o7p D8 +z5 oA1 i4l +z5 oA3 z1 +z5 q O3A +z5 r O34 +z5 s36 +z5 s36 O36 +z5 s5q +z5 s5t +z5 s9A O1B +z5 shs O38 +z5 sw& +z5 t *76 +z5 u +z5 u +3 +z5 O07 @p +z5 O0B +5 +z5 O0B ^r +z5 O17 k +z5 O1A Z1 +z5 O23 i72 +z5 O24 O76 +z5 O25 +z5 O28 +z5 O29 +z5 O35 +z5 O35 Z2 +z5 O38 +1 +z5 O38 l +z5 O39 +z5 O3A +z5 O43 +z5 O45 r +z5 O48 +z5 O49 Z1 +z5 O53 K +z5 O53 ^; +z5 O56 +z5 O5A z2 +z5 O61 +z5 O62 i40 +z5 O64 +z5 O65 D6 +z5 O68 +z5 O71 *27 +z5 O71 o33 +z5 O72 +z5 O73 +z5 O79 +z5 O79 $r +z5 O81 ] +z5 O84 +z5 z3 o7b +z5 } O47 { -{$) -{$+ -{$- -{$0 -{$1 -{$2 -{$4 -{$6 -{$7 -{$8$P -{$9 -{$C -{$Pl -{$_ -{$` -{$a -{$e^` -{$g -{$i -{$j -{$k -{$l -{$n -{$oz3 -{$s -{$w -{$x -{'9 -{*03 -{*05 -{*12 -{*13 -{*16 -{*17 -{*20u -{*24 -{*25 -{*27 -{*30z1 -{*31*51 -{*32 -{*34 -{*37 -{*41 -{*42o3> -{*51C -{*65 -{*A7 -{+1 -{+1Z2 -{+4 -{+7 -{+7*75 -{+9 -{-0 -{-0t -{-3 -{-4c -{-7 -{-8 -{C -{C[ -{Ci1R -{D1t -{D3 -{K*35 -{L1 -{L6l -{L8 -{R0 -{R0z1 -{R2 -{R3 -{R3[ -{R5 -{R7 -{R8 -{R9 -{T0 -{T2 -{T6i3X -{Z1 -{Z1'4 -{Z1*26 -{Z1o0: -{Z1s1^ -{Z1z2 -{Z2 -{Z2$0 -{Z2R5 -{Z2u -{Z3 -{Z3k -{Z4 -{Z4r -{Z5 -{[sfd -{]i2v -{^! -{^% -{^* -{^. -{^0 -{^1 -{^3 -{^7 -{^8 -{^9 -{^:D1 -{^;L0 -{^= -{^> -{^Au -{^B -{^C -{^E -{^L -{^M -{^R -{^T -{^X^Q -{^a -{^b -{^d -{^j -{^k -{^m -{^p -{^t -{^w -{^y$f -{c -{cO21 -{f -{i0$ -{i1' -{i14 -{i15 -{i16 -{i17 -{i18 -{i1a -{i1d -{i1} -{i2+Z2 -{i2V -{i2` -{i2c -{i3-o20 -{i3N -{i3Y -{i3g -{i3w^p -{i4$ -{i4J -{i5i -{i5j -{i5r -{i65 -{i6C -{i6L -{i6W -{i6xi4+ -{iA0 -{k -{kz4 -{o0D -{o0I -{o0T -{o0j -{o0m -{o0q -{o1i*13 -{o2/[ -{o2: -{o2I -{o3/ -{o46 -{o4_ -{o4b -{o4q -{o5c -{o5f+1 -{o5z -{o6**60 -{o61 -{o6t -{o7= -{o7k -{o8E -{o8O -{o8x -{oA2 -{p3 -{q -{q*65 -{qZ2 -{qu -{s0a -{s19 -{s3$ -{sbu -{scs -{sei$i -{sg{ -{sn9 -{snkZ2 -{sog -{ssv -{sue -{svu -{t -{u -{O02 -{O03 -{O05Z4 -{O12 -{O21l -{O21o5n -{O21z5 -{O23 -{O24 -{O25q -{O51o8o -{O61 -{O71 -{O92 -{z1 -{z1Z1 -{z1o5K -{z2 -{z2$A -{z2*03 -{z2*63 -{z2i2> -{z2o5e -{z3 -{z3{ -{z4*81 -{z5 -{{ -{{c -{{i32 -{{{ -{{{c -{{{{ -{{{{c -{{{{{ -{{{{{c +{ $) +{ $+ +{ $- +{ $0 +{ $1 +{ $2 +{ $4 +{ $6 +{ $7 +{ $8 $P +{ $9 +{ $C +{ $P l +{ $_ +{ $` +{ $a +{ $e ^` +{ $g +{ $i +{ $j +{ $k +{ $l +{ $n +{ $o z3 +{ $s +{ $w +{ $x +{ '9 +{ *03 +{ *05 +{ *12 +{ *13 +{ *16 +{ *17 +{ *20 u +{ *24 +{ *25 +{ *27 +{ *30 z1 +{ *31 *51 +{ *32 +{ *34 +{ *37 +{ *41 +{ *42 o3> +{ *51 C +{ *65 +{ *A7 +{ +1 +{ +1 Z2 +{ +4 +{ +7 +{ +7 *75 +{ +9 +{ -0 +{ -0 t +{ -3 +{ -4 c +{ -7 +{ -8 +{ C +{ C [ +{ C i1R +{ D1 t +{ D3 +{ K *35 +{ L1 +{ L6 l +{ L8 +{ R0 +{ R0 z1 +{ R2 +{ R3 +{ R3 [ +{ R5 +{ R7 +{ R8 +{ R9 +{ T0 +{ T2 +{ T6 i3X +{ Z1 +{ Z1 '4 +{ Z1 *26 +{ Z1 o0: +{ Z1 s1^ +{ Z1 z2 +{ Z2 +{ Z2 $0 +{ Z2 R5 +{ Z2 u +{ Z3 +{ Z3 k +{ Z4 +{ Z4 r +{ Z5 +{ [ sfd +{ ] i2v +{ ^! +{ ^% +{ ^* +{ ^. +{ ^0 +{ ^1 +{ ^3 +{ ^7 +{ ^8 +{ ^9 +{ ^: D1 +{ ^; L0 +{ ^= +{ ^> +{ ^A u +{ ^B +{ ^C +{ ^E +{ ^L +{ ^M +{ ^R +{ ^T +{ ^X ^Q +{ ^a +{ ^b +{ ^d +{ ^j +{ ^k +{ ^m +{ ^p +{ ^t +{ ^w +{ ^y $f +{ c +{ c O21 +{ f +{ i0$ +{ i1' +{ i14 +{ i15 +{ i16 +{ i17 +{ i18 +{ i1a +{ i1d +{ i1} +{ i2+ Z2 +{ i2V +{ i2` +{ i2c +{ i3- o20 +{ i3N +{ i3Y +{ i3g +{ i3w ^p +{ i4$ +{ i4J +{ i5i +{ i5j +{ i5r +{ i65 +{ i6C +{ i6L +{ i6W +{ i6x i4+ +{ iA0 +{ k +{ k z4 +{ o0D +{ o0I +{ o0T +{ o0j +{ o0m +{ o0q +{ o1i *13 +{ o2/ [ +{ o2: +{ o2I +{ o3/ +{ o46 +{ o4_ +{ o4b +{ o4q +{ o5c +{ o5f +1 +{ o5z +{ o6* *60 +{ o61 +{ o6t +{ o7= +{ o7k +{ o8E +{ o8O +{ o8x +{ oA2 +{ p3 +{ q +{ q *65 +{ q Z2 +{ q u +{ s0a +{ s19 +{ s3$ +{ sbu +{ scs +{ sei $i +{ sg{ +{ sn9 +{ snk Z2 +{ sog +{ ssv +{ sue +{ svu +{ t +{ u +{ O02 +{ O03 +{ O05 Z4 +{ O12 +{ O21 l +{ O21 o5n +{ O21 z5 +{ O23 +{ O24 +{ O25 q +{ O51 o8o +{ O61 +{ O71 +{ O92 +{ z1 +{ z1 Z1 +{ z1 o5K +{ z2 +{ z2 $A +{ z2 *03 +{ z2 *63 +{ z2 i2> +{ z2 o5e +{ z3 +{ z3 { +{ z4 *81 +{ z5 +{ { +{ { c +{ { i32 +{ { { +{ { { c +{ { { { +{ { { { c +{ { { { { +{ { { { { c } -}$ -}$% -}$' -}$* -}$- -}$3 -}$4o0x -}$5 -}$6 -}$6*53 -}$6^& -}$7 -}$? -}$Ai13 -}$G -}$O -}$P -}$Qo5$ -}$XO52 -}$d -}$j -}$j-4 -}$n -}$o -}$q -}$r -}$v -}$z -}${ -}'6 -}'7 -}'9 -}'A -}*01Z3 -}*03$7 -}*14 -}*15O12 -}*23d -}*24 -}*24*74 -}*25^z -}*30 -}*30D0 -}*35'5 -}*35*50 -}*40 -}*42Z1 -}*43 -}*48 -}*54 -}*61 -}*62 -}*63 -}*75D3 -}*91 -}*A0 -}*B7L6 -}+3Z2 -}+4 -}+4} -}+9 -}-0 -}-1*53 -}-2k -}-4 -}-7o4a -}-9} -}D1 -}D1Z4 -}D4 -}D4o3y -}D8 -}L0 -}R0 -}R2 -}R4 -}T2 -}T3 -}T4 -}Z1 -}Z2 -}Z2$n -}Z2L0 -}Z2o0I -}Z2o7[ -}Z3 -}Z4 -}Z4$W -}Z4O21 -}Z5 -}Z5'7 -}[*72 -}[T6 -}]$g -}^" -}^$ -}^& -}^* -}^1 -}^2 -}^4 -}^6 -}^7 -}^8 -}^: -}^; -}^C -}^G -}^M -}^P -}^Q -}^Y^q -}^] -}^_-0 -}^a -}^b -}^c -}^d -}^e -}^f -}^g -}^h -}^hz5 -}^i -}^j -}^k -}^k{ -}^l -}^p -}^p*05 -}^q -}^s -}^t^K -}^v -}^w -}c -}c-2 -}c^3 -}dl -}dO04 -}f -}i0A -}i0S -}i0z -}i1D -}i1^ -}i1f -}i1wi74 -}i1{ -}i2/R2 -}i2b -}i30D5 -}i3G -}i3NsgO -}i3n -}i4-O34 -}i50 -}i56 -}i6" -}i6p -}i7XO54 -}k -}ku -}lz4 -}o0 -}o02 -}o0b -}o0k -}o0v -}o0x -}o18Z2 -}o1a -}o1c -}o1h -}o1o -}o2 -}o2/ -}o23^v -}o24^H -}o24i49 -}o2_ -}o3*Z1 -}o3Rr -}o3f-0 -}o3l -}o3p^k -}o3y -}o4b -}o4d -}o4r -}o4u -}o53 -}o59 -}o5ci7% -}o5x -}o6- -}o6@*67 -}o6Gc -}o6g -}o6p -}o7_^E -}o7u -}o8X -}p1 -}p1o5p -}p1O43 -}q -}q'8 -}q-7 -}q^T -}r*50 -}rD0 -}s0- -}s1d -}s38 -}s5$ -}sAu -}sAy -}sRm -}san -}sc]{ -}scrK -}slc -}soi -}sro -}svr -}t^S -}u+3 -}uL7 -}uz2 -}O02 -}O02p1 -}O03 -}O04 -}O05 -}O08 -}O13 -}O14 -}O21 -}O32 -}O37 -}O43 -}O52 -}O72 -}O91 -}z1 -}z1i1Y -}z1o5o -}z1sv# -}z2 -}z3 -}z4 -}z4$7 -}z4z3 -}z4z5 -}z5 -}} -}}*80 -}}c -}}d -}}} -}}}c -}}}} -}}}}c -}}}}} -}}}}}c +} $ +} $% +} $' +} $* +} $- +} $3 +} $4 o0x +} $5 +} $6 +} $6 *53 +} $6 ^& +} $7 +} $? +} $A i13 +} $G +} $O +} $P +} $Q o5$ +} $X O52 +} $d +} $j +} $j -4 +} $n +} $o +} $q +} $r +} $v +} $z +} ${ +} '6 +} '7 +} '9 +} 'A +} *01 Z3 +} *03 $7 +} *14 +} *15 O12 +} *23 d +} *24 +} *24 *74 +} *25 ^z +} *30 +} *30 D0 +} *35 '5 +} *35 *50 +} *40 +} *42 Z1 +} *43 +} *48 +} *54 +} *61 +} *62 +} *63 +} *75 D3 +} *91 +} *A0 +} *B7 L6 +} +3 Z2 +} +4 +} +4 } +} +9 +} -0 +} -1 *53 +} -2 k +} -4 +} -7 o4a +} -9 } +} D1 Z4 +} D4 o3y +} D8 +} L0 +} R0 +} R2 +} R4 +} T2 +} T3 +} T4 +} Z1 +} Z2 +} Z2 $n +} Z2 L0 +} Z2 o0I +} Z2 o7[ +} Z3 +} Z4 +} Z4 $W +} Z4 O21 +} Z5 +} Z5 '7 +} [ *72 +} [ T6 +} ] $g +} ^" +} ^$ +} ^& +} ^* +} ^1 +} ^2 +} ^4 +} ^6 +} ^7 +} ^8 +} ^: +} ^; +} ^C +} ^G +} ^M +} ^P +} ^Q +} ^Y ^q +} ^] +} ^_ -0 +} ^a +} ^b +} ^c +} ^d +} ^e +} ^f +} ^g +} ^h +} ^h z5 +} ^i +} ^j +} ^k +} ^k { +} ^l +} ^p +} ^p *05 +} ^q +} ^s +} ^t ^K +} ^v +} ^w +} c +} c -2 +} c ^3 +} d l +} d O04 +} f +} i0A +} i0S +} i0z +} i1D +} i1^ +} i1f +} i1w i74 +} i1{ +} i2/ R2 +} i2b +} i30 D5 +} i3G +} i3N sgO +} i3n +} i4- O34 +} i50 +} i56 +} i6" +} i6p +} i7X O54 +} k +} k u +} l z4 +} o0 +} o02 +} o0b +} o0k +} o0v +} o0x +} o18 Z2 +} o1a +} o1c +} o1h +} o1o +} o2 +} o2/ +} o23 ^v +} o24 ^H +} o24 i49 +} o2_ +} o3* Z1 +} o3R r +} o3f -0 +} o3l +} o3p ^k +} o3y +} o4b +} o4d +} o4r +} o4u +} o53 +} o59 +} o5c i7% +} o5x +} o6- +} o6@ *67 +} o6G c +} o6g +} o6p +} o7_ ^E +} o7u +} o8X +} p1 +} p1 o5p +} p1 O43 +} q +} q '8 +} q -7 +} q ^T +} r *50 +} r D0 +} s0- +} s1d +} s38 +} s5$ +} sAu +} sAy +} sRm +} san +} sc] { +} scr K +} slc +} soi +} sro +} svr +} t ^S +} u +3 +} u L7 +} u z2 +} O02 +} O02 p1 +} O03 +} O04 +} O05 +} O08 +} O13 +} O14 +} O21 +} O32 +} O37 +} O43 +} O52 +} O72 +} O91 +} z1 +} z1 i1Y +} z1 o5o +} z1 sv# +} z2 +} z3 +} z4 +} z4 $7 +} z4 z3 +} z4 z5 +} z5 +} } +} } *80 +} } c +} } d +} } } +} } } c +} } } } +} } } } c +} } } } } +} } } } } c diff --git a/rules/generated.rule b/rules/generated.rule index 16ff02225..3dcf8a20a 100644 --- a/rules/generated.rule +++ b/rules/generated.rule @@ -13,11 +13,11 @@ t i3 i6 $2 -l$1 -^&O03 +l $1 +^& O03 O02 -$ O04 -$ O08 +$ O04 +$ O08 i2 $3 i7 @@ -25,91 +25,90 @@ $! -8 '9 'A -$ O06 +$ O06 Z1 '8 -p2'B +p2 'B T5 -c$1 +c $1 $7 [ -$!Z2 -cT4 +$! Z2 +c T4 o4 -L9'9 -f'A +f 'A ^1 -7 T4 -$ O13 +$ O13 +8 o5 $5 -$2Z1 -d'A +$2 Z1 +p1 'A $s '6 -0 o3 $0 o0d -$ Z2 +$ Z2 $8 i5_ o0b -i4 r -i0 +i4 r +^ o0p $4 $9 -dO02 +p1 O02 i5- -cT7 -cT5 +c T7 +c T5 +9 T7 -dO05 +p1 O05 $6 o0f +0 o0c -d[ +p1 [ o0s i4- -$5Z4 +$5 Z4 'B -i4 O12 +i4 O12 siy -o0ml -$1[ +o0m l +$1 [ C D5 T6 -}[ +} [ p1 -9 o0w o0z o1o -'6d -'4p1 -r$ +'6 d +'4 p1 +r $ o1u $. -$1t +$1 t o0g -'Al -O05$ +'A l +O05 $ T3 -Z3'B +Z3 'B i6_ -6 D9 -l$! -lZ1 +l $! +l Z1 i2s o8 -p1'9 +p1 '9 i5s '7 i6- @@ -119,119 +118,117 @@ o1b o0v o0r o81 -$ O23 +$ O23 -5 D7 -$el +$e l Z2 i4_ i3_ -^ T2 -T6T0 +T6 T0 -3 -^ } +^ } o6 T1 o0l $a -$8Z1 +$8 Z1 '5 -^e^2 +^e ^2 *56 o5i -'Bl +'B l +7 -dO06 +d O06 O03 -dO54 +d O54 +6 +5 o3i D3 -}O01 o64 u o6d O61 -lp1 -lD8 -$ O34 +l p1 +l D8 +$ O34 -1 o0k -^ci12 -o4 t +^c i12 +o4 t O31 -4 -$ O09 -Z2l +$ O09 +Z2 l o6u -O07$ +O07 $ r i8 O42 -[$ +[ $ O41 i2r -i02c -$&Z1 +^2 c +$& Z1 i4i o3t oB3 $r k -i3.-3 +i3- o6s o8s D1 -p1O43 +p1 O43 i1 o54 +B i51 $i -^e^3 +^e ^3 D2 -lO31 +l O31 o1a $e O82 i7s sck -$6Z1 +$6 Z1 o3b si1 -p2O64 -$1D3 -O02$1 +p2 O64 +$1 D3 +O02 $1 o8e o4b o3c o86 -$sZ1 +$s Z1 o92 -dO46 -+7+6 +p1 O46 ++7 +6 o91 -A -O02p1 -L0R0 +O02 p1 +L0 R0 o0P o1 o4i i4, -do6b -i4 '6 -[c -$1$3 +d o6b +i4 '6 +[ c +$1 $3 $n o0R o95 -$^$^ -^4^a +$^ $^ +^4 ^a suy o2m -$qZ2 +$q Z2 o1f R0 o8r @@ -239,19 +236,19 @@ o0h -B o5o o72 -$@Z1 -uD2 +$@ Z1 +u D2 i3d O51 -O32$ +O32 $ i52 $- $/ s1 o60 i6s -$7Z1 -o81'9 +$7 Z1 +o81 '9 o2a i4n $o @@ -266,20 +263,20 @@ T8 i4s o84 $, -$ s05 +$ s05 o8z s0 i4. -'4$ +'4 $ +3 o82 o5s -l$ -l$4 +l $ +l $4 o3a sio T0 -D5T0 +D5 T0 i5i o2r $* @@ -287,78 +284,77 @@ o4y i63 sb +2 -lD4 +l D4 $d +4 -p1'A -O01d +O01 d i7r o0D $k -$/Z2 -$7[ -l*98 -$ Z1 -$fl +$/ Z2 +$7 [ +l *98 +$ Z1 +$f l $x OB2 -+0p1 ++0 p1 o61 i62 ^m -^xz2 +^x z2 o0M o13 -o9Yl +o9Y l o9 o2g o4n i3t -$3$d -o8Yl +$3 $d +o8Y l i2i +A o6w o8a -o5Al +o5A l $@ -R0z5 +R0 z5 i6b -lD6 -$1O62 -^e^1 +l D6 +$1 O62 +^e ^1 i42 -^9z2 +^9 z2 o4o -[k +[ k o10 o7a -o0md +o0m d oB6 -2 -ti0 -$!Z1 +t i0 +$! Z1 } o2z o4k -z4p3 +z4 p3 i5n -$5t -[o4 -o8 O06 +$5 t +[ o4 +o8 O06 i4= soa o5_ -^5z2 +^5 z2 $z -'5d +'5 d i7l -$ s16 -O25$ -cD5 +$ s16 +O25 $ +c D5 o7l o97 -[^j +o0j o6t oBf O04 @@ -369,40 +365,40 @@ i2l o4j o4e o0S -O15$ +O15 $ oB5 -p1O63 +p1 O63 o4l i2c i5r -td -l+1 +p1 t +l +1 ^p st` o4- -T3T5 -o1f+0 -+0l +T3 T5 +o1f +0 ++0 l i4y -o0sd +o0s d o5e i5t o74 -l$6 +l $6 o63 -Z1z1 -}$ -$aZ1 +Z1 z1 +} $ +$a Z1 $$ o5t o0T -Z2O83 +Z2 O83 '3 -c$2 +c $2 i2t i5l o03 -^az1 +^a z1 se $y o7e @@ -414,23 +410,23 @@ o73 $` i7a i4a -'6$ +'6 $ o0m -i6b+6 -p1D6 -[$2 -p1O52 +i6c +p1 D6 +[ $2 +p1 O52 o6a o0e o2f -$1u -cT8 +$1 u +c T8 o14 -O21l -$fOB1 +O21 l +$f OB1 o2d -c[ -z1^9 +l [ +z1 ^9 ^v o2 i50 @@ -441,39 +437,39 @@ o0G sbd DA o3- -p2O16 -Z1$ -p1O16 -{R5 -lT4 +p2 O16 +Z1 $ +p1 O16 +{ R5 +l T4 se3 -$)t +$) t $t -o1fk +o1f k o50 i4h -[q +[ q o7! o3y O21 o2n i2f o7t -o7(s(1 +o7( s(1 i8t *46 o89 o9a -^3z1 -R6R6 +^3 z1 +R6 R6 oB2 o3s -c$ -dO34 -o9El -$,l +c $ +p1 O34 +o9E l +$, l sa1 -Z3-4 +Z3 -4 i6i i4c o2p @@ -483,92 +479,92 @@ o2t sa4 o9e i3e -Z1+9 +Z1 +9 i2n o83 -O23p1 +O23 p1 i4p -D2d +D2 p1 @2 o3o o2k oBa sdt o7u -$a+0 +$a +0 i3i i5% -^i*01 +^i k i41 o19 -$2O61 +$2 O61 o5p o8! ^3 -$$Z1 -fO86 -z5$ +$$ Z1 +f O86 +z5 $ o3e o57 z2 -o19k -O32d +o19 k +O32 p1 ^c -p1O73 +p1 O73 *20 -D1l +D1 l i3l -+0o1i ++0 o1i i2a i5. o0 -$0Z2 +$0 Z2 o7i -O41p1 -p1O64 +O41 p1 +p1 O64 o3g o6e o2c o4t -c$) +c $) $) -R6D5 -p1O04 -^sz1 +R6 D5 +p1 O04 +^s z1 i5y i6. i70 sa8 s18 -'9l +'9 l O52 o6_ s69 -p1O75 +p1 O75 o3d -c$4 +c $4 i6d o71 o9k -^b^b +^b ^b o3w --7$a +-7 $a i6r -O05p1 -$5Z1 -p2O05 +O05 p1 +$5 Z1 +p2 O05 i5f -dO84 +d O84 o8i -$k$e +$k $e O81 o6- -i4 *23 +i4 *23 O91 -T4$1 +T4 $1 o53 i5d -$2t +$2 t o3v o8g o0a @@ -576,189 +572,188 @@ o4_ ^e i3s ^l -Z2z2 +Z2 z2 T9 o1y i6n -$+Z1 +$+ Z1 ^4 -*76l -l$. +*76 l +l $. i4l o68 -cD4 -o3zl +c D4 +o3z l *87 i6h oB8 -d$q +d $q o2s -i9Rl +i9R l O32 i5j o6j -O03f -Z4O63 -l+6 -O53o3 -[^L +O03 f +Z4 O63 +l +6 +O53 o3 +o0L o5r i8n o94 o7o -$[L4 +$[ L4 o80 -[o6 -$ -7 -o3ol -T7T2 -$ t -cT9 +[ o6 +$ -7 +o3o l +T7 T2 +$ t +c T9 i4e o93 i4+ i7t O06 -D0} -$il -{R7 +D0 } +$i l +{ R7 i8r O62 o0t -^3l -^c^3 -$ k -Z4Z5 +^3 l +^c ^3 +$ k +Z4 Z5 oB9 -T7T4 +T7 T4 o1l O12 i8_ s0o -D1^0 +D1 ^0 o4p -i6iR6 +i64 *34 i7n -dO25 +p1 O25 s97 i4t -O62l -o01l -@0$ +O62 l +o01 l +@0 $ ^r oBd -l+5 +l +5 spb o2y -o6 c +o6 c s75 -R7o7 +o7 i7i O72 -*23p1 +*23 p1 s35 -$0Z1 +$0 Z1 o6n O83 s17 o08 -R5Z5 +R5 Z5 o4u i5m -$*Z1 +$* Z1 o5- O63 o3k O54 o8k --1D0 +[ -0 o9i -o7 O01 s68 o6i o3q -$#$1 +$# $1 siu -D3$2 -*50L5 -T0so --0O16 -i08-0 -z2+1 +D3 $2 +*50 L5 +T0 so +-0 O16 +i08 -0 +z2 +1 *53 -T2T5 -O53l -+9c -D0+6 +T2 T5 +O53 l ++9 c +D0 +6 o7c o96 o76 -DB$6 -d$1 -O31p1 -lssf -i7 [ +DB $6 +d $1 +O31 p1 +l ssf +i7 [ s6 D8 i4u -l$8 +l $8 s49 oAz -i6 T0 -R5l -dO24 -^vd +i6 T0 +R5 l +d O24 +^v d o9r -'6Z1 +'6 Z1 ^@ i4z i8k i3/ -dc -o0.z1 -'5Z1 +p1 c +o0. z1 +'5 Z1 i7y oB4 -o8 D0 +o8 D0 i65 i2_ i6t o8l i3r -o6 O13 -^7^5 -i0 z2 +o6 O13 +^7 ^5 +i0 z2 i4q -dO42 +d O42 o7_ -O02c +O02 c sc -$;T0 +$; T0 o69 -o0ip1 -p1$a -$3c +o0i p1 +p1 $a +$3 c o4m s31 i7_ syi -$1i6 +$1 i6 i69 i5e s7e i3y o5, -^fz1 -o5 O02 -[i1e -dO62 +^f z1 +o5 O02 +[ i1e +d O62 o3l o8f -Z2OB2 +Z2 OB2 i6y o5j -^5z1 +^5 z1 i8h o0W srl @@ -767,59 +762,59 @@ sea i3g *12 o05 -T4$5 -i5^l -$$Z2 -+0D2 -o7n$1 -dO45 -^@z1 +T4 $5 +i5^ l +$$ Z2 ++0 D2 +o7n $1 +d O45 +^@ z1 o8o o45 -DB$7 -i4h*45 +DB $7 +i4h *45 i80 -i01^5 -z1^2 +i01 ^5 +z1 ^2 o75 $# -lO71 -lz1 -$3i8< +l O71 +l z1 +$3 i8< o4f i9k i71 i3k ssz -i3YO34 +i3Y O34 *03 -$a+2 -OB1$6 +$a +2 +OB1 $6 i8e o4z -o5.Z2 +o5. Z2 o90 -lo6i +l o6i i4& L8 o6m i5= o7k -{R8 +{ R8 i5k O43 -$<$3 -*56l +$< $3 +*56 l o3j o3n -i0h^d -$au -}^d -T0D9 +i0h ^d +$a u +} ^d +T0 D9 ^z o9n --2i3 -*65Z1 +-2 i3 +*65 Z1 o20 ^a s57 @@ -828,13906 +823,13533 @@ sl1 sbm i6o o9q -kR1 +k R1 oB0 i3n { o1k -$a*01 -lo5f -$=l -'6l -$.c -lf -lq -}^1 +$a *01 +l o5f +$= l +'6 l +$. c +l f +l q +} ^1 o7j o5y -R4R5 -[i4, +R4 R5 +[ i4, oAl -$9Z1 +$9 Z1 sx i4b -+9'A -OB2+B ++9 'A +OB2 +B ^8 o2e -o3Gl +o3G l $m $c -$.Z2 +$. Z2 o1@ o70 i2h o51 -T0$n +T0 $n o0o i4@ ^t -$3O71 -O05r +$3 O71 +O05 r i4o i0h o3_ -i7hl -$![ -o8 D7 -$,[ +i7h l +$! [ +o8 D7 +$, [ o0q i5c i6m $A i7o i7h -[i0x +[ i0x i9n ^I $= -l'7 +l '7 OB3 -ko0c -o1e+0 +k o0c +o1e +0 ^d TA -$yO53 +$y O53 o09 $g o52 o2i i6, -^aO21 -^.r -i4Qo4_ +^a O21 +r $. o2l -$fc +$f c sou i2m -f'B +f 'B i6e -$ou +$o u se4 o6o -^Al -i3- +^A l o5m -kp1 +k p1 o0i -+6+6 ++6 +6 o4` o78 -o0Hl +o0H l o5n s4a i8s -T0'9 -}} -R5O05 -^jz1 +T0 '9 +} } +R5 O05 +^j z1 i47 i2k -i4.l -+7$a -$1T1 +i4. l ++7 $a +$1 T1 i53 Z3 -O07o2 -O03q -$bOB1 +O07 o2 +O03 q +$b OB1 i4r -p1O48 -R0r -o1Au -lDB -o89Z2 -L2R2 -R7Z1 +p1 O48 +R0 r +o1A u +l DB +o89 Z2 +L2 R2 +R7 Z1 $u o7g i49 i3o -}^a +} ^a o6k o3. -fO8B +f O8B i6k i3c -l+2 +l +2 ^k -*23[ +*23 [ OB1 o4s o01 -^y^s +^y ^s o8m -l$o -O31+3 +l $o +O31 +3 $p -cT1 -u'9 +c T1 +u '9 i6l o40 i5, z1 ^_ -lo6` +l o6` i4g -lT1 -^zl +l T1 +^z l o62 -$5O81 +$5 O81 o7r s. -*01+1 -cO61 -OB1$2 -[O31 +k +1 +c O61 +OB1 $2 +[ O31 o9f o5g -^ez1 -ko1f -O12d +^e z1 +k o1f +O12 p1 $_ o9s *A9 -'9i4 -l-2 +'9 i4 +l -2 o2u -^d^6 +^d ^6 $f -li3k -$9$1 -o11k -$s-7 -li4n -^3^d -c'8 --5-5 -O61u -$Ic +l i3k +$9 $1 +o11 k +$s -7 +l i4n +^3 ^d +c '8 +-5 -5 +O61 u +$I c D6 -'9^1 -$,$. -o0j -D5i2 +'9 ^1 +$, $. +D5 i2 o12 -i5_[ +i5_ [ stb -*32l +*32 l i2z -+0D3 ++0 D3 $P $? -O34d +O34 p1 o5k o8p i7d -^6^e +^6 ^e o1j o2h o7m o58 o7? i7u -^l^a +^l ^a srd -$m$p -o0ck +$m $p +o0c k o2o -+1o0a -+3p1 -^9^7 -CT1 -'At ++1 o0a ++3 p1 +^9 ^7 +C T1 +'A t s10 oBc -$ z4 -o4 $1 -Z4Z3 -^.l +$ z4 +o4 $1 +Z4 Z3 +^. l sa7 -+0$2 -+2+0 ++0 $2 ++2 +0 skm o65 -dO83 -+2p1 -^0z5 +d O83 ++2 p1 +^0 z5 ^C o42 i9 -o6.Z1 -$1i0F -{{ -T5o5z -O14d -$1Z5 -^a^1 -T0std -$ ^2 +o6. Z1 +$1 i0F +{ { +o5z +O14 d +$1 Z5 +^a ^1 +T0 std +$ ^2 o3x f -d'B -O12z1 -^?z2 +d 'B +O12 z1 +^? z2 $w -[R0 -'6q +[ R0 +'6 q ^9 -O19$ -{o61 -dO76 +O19 $ +{ o61 +p1 O76 i5w -$.[ -O03k +$. [ +O03 k o6l ^. s6b -$1d -p1O35 +$1 p1 +p1 O35 i5g -c-6 +c -6 i67 -^Di1j -p1T0 +^D i1j +p1 T0 o02 i2d -$9l -$`l +$9 l +$` l snr -o2iT0 -k-0 -$1$6 -O15d +o2i T0 +k -0 +$1 $6 +O15 d *13 s3 -o5uT0 -o6tl -'7$! -^Az1 -^sl +o5u T0 +o6t l +'7 $! +^A z1 +^s l o2b ^n -T6T7 -*13$q -+0'2 -D6Z1 -D1^b -do5b +T6 T7 +*13 $q ++0 '2 +D6 Z1 +D1 ^b +d o5b i1- i5N -+9$a ++9 $a o34 -^1T5 -dO12 +^1 T5 +d O12 o8u o2x o5` -o5 -0 +o5 -0 sbf o7d -$rl -OB1$1 +$r l +OB1 $1 s76 @0 -R6Z4 -+6$@ +R6 Z4 ++6 $@ ^G q -^dz1 +^d z1 sbl -oB7l --0*02 +oB7 l +-0 *02 i32 -i4,s,k +i4, s,k ^2 -+3c ++3 c i7e *71 -^td +^t p1 oA8 TB slg s13 -$_l +$_ l o1s -$#Z1 -$/[ -$Ac -$1Z2 +$# Z1 +$/ [ +$A c +$1 Z2 ^f -li3r -o0bc -O42d +l i3r +o0b c +O42 p1 stp i1j o6@ o6b -DB$0 -^;$; +DB $0 +^; $; i4f -^nl -R4R4 +^n l +R4 R4 o4c -$8$7 +$8 $7 sae -O02Z2 +O02 Z2 o5c -z1$1 +z1 $1 i5& -cT3 -Z2[ -[D4 +c T3 +Z2 [ +[ D4 iA o3f $b -d$ -*32T0 -*40p1 +d $ +*32 T0 +*40 p1 i7c -lo74 -+1[ +l o74 ++1 [ '4 i3j i1e -^c^2 +^c ^2 o7p -i5-c +i5- c i5x o1m -fO96 -T0'6 +f O96 +T0 '6 sx7 -p3$ -T0i1r +p3 $ +T0 i1r s37 -i0b^8 -o2-*01 +i0b ^8 +o2- *01 s3e -D1^2 -$9OB1 +D1 ^2 +$9 OB1 s20 -Z1c +Z1 c ^j o8w -z2Z1 +z2 Z1 o3z o6y -R5D4 +R5 D4 i5v o8% -i2Tl +i2T l o30 -lr -$tZ1 -$Tl +l r +$t Z1 +$T l ^- o6g -T0T3 +T0 T3 i3, o0y o8b o5u -+1o0b -T0L4 ++1 o0b +T0 L4 o6p -p2OB7 +p2 OB7 i8- -o71-6 -dOA7 -Z5Z5 -$BZ1 -O03p2 -$.^. -qO08 +o71 -6 +p1 OA7 +Z5 Z5 +$B Z1 +O03 p2 +$. ^. +q O08 o2q -i1N[ -t^1 +o0N +t ^1 i1u -}O05 -$ O53 +} O05 +$ O53 i7w o3u i6@ -T3T8 +T3 T8 $F -i14[ +o04 i76 -^-^4 +^- ^4 sa0 @1 i3f o0[ -Z2$ -[-1 -o2Dl -c'7 -^dz2 -T5$3 --9u -{d +Z2 $ +[ -1 +o2D l +c '7 +^d z2 +T5 $3 +-9 u +p1 { *05 -lO92 -$xZ3 -cD6 +l O92 +$x Z3 +c D6 o0F -D8$2 -o0rO21 +D8 $2 +o0r O21 i60 i8: s21 o06 -R4+4 +R4 +4 i5o -o5*Z2 +o5* Z2 spd -D3c +D3 c i6j -$1-3 -l*03 +$1 -3 +l *03 snl -p1O51 -o1Hl +p1 O51 +o1H l oAe -T4'8 -*20p1 -^Ei1l -p1O26 +T4 '8 +*20 p1 +^E i1l +p1 O26 sa* -+8l ++8 l i9p -i3Cl -^8} -$s*17 -z2o1y -o7 -i8Cl -oAsl +i3C l +^8 } +$s *17 +z2 o1y +i8C l +oAs l o0Z -^7z4 -}z2 +^7 z4 +} z2 srf -$ap1 -Z4Z4 +$a p1 +Z4 Z4 o3@ -^/z1 -R0R0 -Z2$3 -L7L7 +^/ z1 +R0 R0 +Z2 $3 +L7 L7 ^\ -$4$5 -+6$ +$4 $5 ++6 $ i3m -$6Z2 -p1O87 +$6 Z2 +p1 O87 o6! -$?$! -i7 l -p1o5p -O73l -*67$1 +$? $! +i7 l +p1 o5p +O73 l +*67 $1 $S -L6R6 -p1O97 +L6 R6 +p1 O97 o6f i2. -[$4 -D2+0 -^mz2 -[^a -Z1u -Z1O42 +[ $4 +^m z2 +Z1 u +Z1 O42 o3/ o7. -u'A -i3hO12 +u 'A +i3h O12 i2x -z1i1f +z1 i1f o0C -*45O32 +*45 O32 s0c -t$E +t $E o8h -k^X -R8T0 -^6l -D3R0 -c$8 -i40-4 -$SZ1 -*76+7 +k ^X +R8 T0 +^6 l +D3 R0 +c $8 +i4/ +$S Z1 +*76 +7 O57 i14 *98 -o0k*30 +o0k *30 smw -$9Z4 -R0z3 -p1i4 -fO61 -$/$1 -p2O03 -$s$1 -sa9Z2 +$9 Z4 +R0 z3 +p1 i4 +f O61 +$/ $1 +p2 O03 +$s $1 +sa9 Z2 ^, -^-^6 +^- ^6 L7 i4j O92 i5a -r'2 +r '2 o98 sr -i5a*56 -o8 '9 -$q-0 +i5a *56 +o8 '9 +$q -0 oAo -^c-1 -+0^1 -'9Z1 +^c -1 ++0 ^1 +'9 Z1 i9l i3p -T4T2 +T4 T2 $j -+1+3 -O32l -t*21 -z5'7 -O04o2 ++1 +3 +O32 l +t *21 +z5 '7 +O04 o2 sl -fOA7 +f OA7 o79 -o2Ct +o2C t o6# s82 -$1+8 -o50Z3 -$6*57 -$md -o9zT0 -lT5 -$8Z2 -O01$m +$1 +8 +o50 Z3 +$6 *57 +$m d +o9z T0 +l T5 +$8 Z2 +O01 $m o5w -D6i3 +D6 i3 i9s R4 -$d*57 -dO71 -O02D3 -o7!Z1 -z1^f +$d *57 +d O71 +O02 D3 +o7! Z1 +z1 ^f spz -O05Z1 -z4-5 -^m^m -O31[ -i0m -$zZ3 -}^2 -i4_+5 +O05 Z1 +z4 -5 +^m ^m +O31 [ +$z Z3 +} ^2 +i4_ +5 i72 iBa -i01r -'AZ1 -i2oO01 -p1o6t -z1o1r -p1O15 +i01 r +'A Z1 +i2o O01 +p1 o6t +i1r +p1 O15 s3b oB7 -+5-6 -Z2k -Z2} -*10i2b -i7l'8 -li7e -lO52 -}z1 -^oO12 ++5 -6 +Z2 k +Z2 } +*10 i2b +i7l '8 +l i7e +l O52 +} z1 +^o O12 sfz OA3 -i9cl -$bZ1 +i9c l +$b Z1 i30 -z1r -z1^a -$Al +z1 r +z1 ^a +$A l o7z -p1O86 -['A -^Fl -O02{ -iA/OA3 +p1 O86 +[ 'A +^F l +O02 { +iA/ OA3 snu -^8^c +^8 ^c sdf -z1i1j +z1 i1j o1- o7b -[+0 o3m -*78+6 +*78 +6 s63 -$ z2 +$ z2 O23 -ci5 -$5l -$lu +c i5 +$5 l +$l u i4x -ci3 -^4i1e -+4p1 -$Nu -kL1 -o01z3 +c i3 +^4 i1e ++4 p1 +$N u +k L1 +o01 z3 o15 -$ *47 +$ *47 o9o -^h^o -c$* -dO27 +^h ^o +c $* +d O27 i9d -O81-8 +O81 -8 i5b o7& -i3-[ +i3- [ i3. -D1p1 -f$1 +D1 p1 +f $1 R9 -o0op1 +o0o p1 o7h -$*Z3 -l*87 +$* Z3 +l *87 i1y -O23+0 +O23 +0 Z4 $v -o61$. +o61 $. i7g ^6 -DB$d +DB $d sb5 -T5$e -$-{ -[$% -$ O03 -+3$m -rp1 +T5 $e +$- { +[ $% +$ O03 ++3 $m +r p1 oAi -D1R0 -^w*21 -p1O05 -o1e$7 +D1 R0 +k ^w +o1e $7 i86 i8z --7Z1 -Z2$8 +-7 Z1 +Z2 $8 o4. i9i -O71o5 -$$Z3 -OB2$4 -Z1$6 +O71 o5 +$$ Z3 +OB2 $4 +Z1 $6 i6% -'8c o5h -O61R5 +O61 R5 i5! -lo2j -li8 -lo7f -$.T6 -*31*20 +l o2j +l i8 +l o7f +$. T6 +*31 *20 i6K -Z1OB1 -l'8 +Z1 OB1 +l '8 s59 -o91c -lO42 +o91 c +l O42 i1c -i5-'A -O04i0d -$qZ3 -O42p1 -$5$3 -T9T4 -k-1 -$1l +i5- 'A +O04 i0d +$q Z3 +$5 $3 +T9 T4 +k -1 o4v s1. -^c^e -T7T3 -+4$5 +^c ^e +T7 T3 ++4 $5 shf -i28[ -lo21 +i28 [ +l o21 sdj -fO73 +f O73 i5+ -li4h --6l -o4lD3 -$iu -^9i1- -c$n +l i4h +-6 l +o4l D3 +$i u +^9 i1- +c $n i9y -o8LT7 -i8x'9 -p1O14 +o8L T7 +i8x '9 +p1 O14 oBe -$2^4 +$2 ^4 ^S -O17$ -*20o3i +O17 $ +*20 o3i o2M -$z*37 +$z *37 sc4 -O0A$ -'4z4 +O0A $ +'4 z4 o9d -*75D1 -'2z4 +*75 D1 +'2 z4 O34 -fO45 -$i*89 -$8$4 +f O45 +$i *89 +$8 $4 o5b -lo4. -*35q -o13-2 -{^T -$IZ1 +l o4. +*35 q +o13 -2 +{ ^T +$I Z1 s61 o3Z -$b$d +$b $d O64 -T4o0R -*30u -L9Z1 -^6i1b +T4 o0R +*30 u +L9 Z1 +^6 i1b O53 i9g -{$a -^$ss$ -c-2 +{ $a +^$ ss$ +c -2 o0@ o5< -Z1+5 -r$2 -do6c +Z1 +5 +r $2 +d o6c O13 -z1^5 -p1^ -l*86 -iAel +z1 ^5 +p1 ^ +l *86 +iAe l o7D -c^1 -T0+8 -^1z5 -sbs+0 -ls70 -O81O61 +c ^1 +T0 +8 +^1 z5 +sbs +0 +l s70 +O81 O61 i1w -^1*10 +^1 *10 *48 -i0b} --4O03 +i0b } +-4 O03 o9j -z1^8 -^Xz1 -*56+5 +z1 ^8 +^X z1 +*56 +5 o8^ -i55o5i i81 -^8z1 --9+8 +^8 z1 +-9 +8 slf sCk -D2c -'6c +D2 c +'6 c o5. -sae$1 -*50 -O61$ -+0'5 -$ L1 -^ei0l +sae $1 +O61 $ ++0 '5 +$ L1 +^e i0l o6v i3[ -$%c -i3-u +$% c +i3- u sgc o0K -^xp1 +^x p1 i3u -o8Vl -k$1 -*30O23 -$xp1 -$3o62 -o3 c -$4O02 +o8V l +k $1 +*30 O23 +$x p1 +$3 o62 +o3 c +$4 O02 o4r -^5i0e -$z@s -Z2+5 -^(o7) -Z1*58 -$1OB3 +^5 i0e +$z @s +Z2 +5 +^( o7) +Z1 *58 +$1 OB3 sA1 -c$6 +c $6 sbt i5: -+8-7 -i3lO03 ++8 -7 +i3l O03 snt -fO69 +f O69 o0B i7m -o09k -*21*13 --4c -i97D8 +o09 k +*21 *13 +-4 c +o87 s64 O08 -^R^D -o6sc -O32p1 +^R ^D +o6s c ^b o9c -$.o0w -D0o3p -p5z5 -o6Nl +$. o0w +D0 o3p +p5 z5 +o6N l ^w -O17d -T2k -o1mD0 -i5 'A +O17 d +T2 k +o1m D0 +i5 'A z4 -*20o6 -*98+9 +*20 o6 +*98 +9 sad -D2D3 +D2 D3 s2- -*20+2 +*20 +2 o07 i1s -*A3O06 -$1@k -O21c -+6O51 -+1R0 +*A3 O06 +$1 @k +O21 c ++6 O51 ++1 R0 i7. s0x -*78 -^u^y +^u ^y o0< -p5Z4 -l^h -$e$w -ko16 -$1o8d -$4+0 -*57$a +p5 Z4 +l ^h +$e $w +k o16 +$1 o8d +$4 +0 +*57 $a O71 -lD5 -dO85 -z2o06 +l D5 +d O85 +z2 o06 sx6 -i0.} -[i5i +i0. } +[ i5i stl -o62+5 -T6O02 --6$4 -z2R0 -i3Hl -t+2 -$nO71 -$=$) +o62 +5 +T6 O02 +-6 $4 +z2 R0 +i3H l +t +2 +$n O71 +$= $) sjm -$Bl +$B l o41 -L0{ +L0 { Z5 i3h sa3 -Co1e +C o1e i78 i75 -$0DB -$*Z2 +$0 DB +$* Z2 o6, -$*D0 +$* D0 o0{ i3a -i0a -$qZ1 -'A$a -i4-O02 -p1+B -$tZ2 -di5, -*52O04 -@5$ -*30c +$q Z1 +'A $a +i4- O02 +p1 +B +$t Z2 +d i5, +*52 O04 +@5 $ +*30 c i6x -DB$e +DB $e slb i4! -$i+6 -*43 -p1OB6 -O02k +$i +6 +p1 OB6 +O02 k o7s i8i -O51t +O51 t i2b -$0Z3 -[-0 +$0 Z3 o6r -sA){ +sA) { ^# -o6yO02 -O71o8k -*53p1 -'AT5 -O02p2 -*42R0 +o6y O02 +O71 o8k +*53 p1 +'A T5 +O02 p2 +*42 R0 i2o R1 o1h -^0z1 -^dT1 +^0 z1 +^d T1 i3% -Z1i5- +Z1 i5- o46 i1l -'7l -$aOB1 -p1-4 +$a OB1 +p1 -4 i6' -R7R7 -R1d -$9R8 -+4'9 +R7 R7 +R1 d +$9 R8 ++4 '9 i54 -$xZ1 -^5t -D0p2 -+5$y -o6 o8o -i5.O03 +$x Z1 +^5 t +D0 p2 ++5 $y +o6 o8o +i5. O03 o6* oB1 --5d -i3rO41 --1-0 -$$i0% -p1Z1 -$)D1 -T0o6s +-5 d +i3r O41 +-1 -0 +$$ i0% +p1 Z1 +$) D1 +T0 o6s ^+ -i5PO34 +i5P O34 i6# -$ O82 -o4Sl -^vD3 +$ O82 +o4S l +^v D3 o5a -o87 -k{ -d+6 -co7S -'7$8 -T0$h +k { +d +6 +c o7S +'7 $8 +T0 $h o7x -*79$1 -+Bl -*13D1 +*79 $1 ++B l +*13 D1 sln -T5o5k --4p1 -sT t -o8cO51 +-4 p1 +sT t +o8c O51 i5* -uD6 -+6$7 -[*23 +u D6 ++6 $7 +[ *23 o5% -O01o0 -^ei09 -o6-Z1 +O01 o0 +^e i09 +o6- Z1 *40 -ls12 -stll -$ z3 -'6[ +l s12 +stl l +$ z3 +'6 [ i1t -fO67 -o3jo36 -seyo4 -$2O82 -o2dc +f O67 +o36 +sey o4 +$2 O82 +o2d c o18 i9x -l^c -t-7 -^e^7 -*30p1 -^ ^ +l ^c +t -7 +^e ^7 +*30 p1 +^ ^ shl -$?^! -o7$Z2 -i8ZR8 -fc +$? ^! +o7$ Z2 +f c scg -o0kp1 -$1Z4 -p1O7A +o0k p1 +$1 Z4 +p1 O7A iBe -z2+0 -+7-8 -'5$i -T5L5 -^?$ +z2 +0 ++7 -8 +'5 $i +T5 L5 +^? $ ^K smt -R9o9a -$%Z2 -$g$o -D4$1 -Z2$. +$% Z2 +$g $o +D4 $1 +Z2 $. s5f i5u i6p -}^G -i0f^b -[-2 -o91Z1 +} ^G +i0f ^b +[ -2 +o91 Z1 i5\ -i2Ec -k+0 -o96Z1 -O92-9 -O21i0k +i2E c +k +0 +o96 Z1 +O92 -9 +O21 ^k o0A -^lz1 -+8o6a -oB0+B -+8+6 -o06+1 -^p*40 -z1i1a +^l z1 ++8 o6a ++8 +6 +o06 +1 +^p *40 +z1 i1a sX- -$1o04 -o7i-7 +$1 o04 i7P -$ O52 -t$, +$ O52 +t $, i1\ -$ ^> -$d$k -{-7 +$ ^> +$d $k +{ -7 i4m -D4R3 -$pZ2 -D0'B +D4 R3 +$p Z2 +D0 'B szt i1o -t^G -Z2+6 -O81$z -z1^7 --1d -DB$c +t ^G +Z2 +6 +O81 $z +z1 ^7 +-1 d +DB $c s+ -$8Z3 -i42-7 -o5z -^9c -D5$7 -co5F -$6-8 -+6*56 -^ho4 +$8 Z3 +i42 -7 +^9 c +D5 $7 +c o5F +$6 -8 ++6 *56 +^h o4 i7- -O02^y +O02 ^y o5d -+7c -D7$i ++7 c +D7 $i iAr -+3o3p +o3p smk i1f i7z oA4 -{i1a -O02u -$ D1 -p5Z5 -o55l -O51p1 --6-8 -[{ -L5R5 -+8-9 +{ i1a +O02 u +$ D1 +p5 Z5 +o55 l +O51 p1 +-6 -8 +[ { +L5 R5 i6+ o2@ -$(u -lo4a -+3*12 -o5sl +$( u +l o4a ++3 *12 +o5s l i6= $% -$o$s -^7^0 -$1O72 -$4+8 +$o $s +^7 ^0 +$1 O72 +$4 +8 s48 -DAl -$gl -$1*02 -L3O02 -O02i0f -[o2v +DA l +$g l +$1 *02 +L3 O02 +O02 i0f +[ o2v i8j -$@z2 +$@ z2 s52 --3o0G +-3 o0G o3` -O12o0p +O12 o0p o1w $] o1p -o4Et +o4E t o6. -O03^1 -^d^5 -$\Z1 -Z2-8 -dO09 -$5o65 +O03 ^1 +^d ^5 +$\ Z1 +Z2 -8 +p1 O09 +$5 o65 i2w i2u o8d i8u -$ZZ2 -$ZZ1 -$^l -'9o7n +$Z Z2 +$Z Z1 +$^ l +'9 o7n oAw *AB -ko2l -T0i3y -*32'9 -[o10 -*75t -T0i6_ -o7Yl -cO51 +k o2l +T0 i3y +*32 '9 +[ o10 +*75 t +T0 i6_ +o7Y l +c O51 sbn se5 -l-5 -*10*42 -$u$r -^0O12 -*35r -^gT1 +l -5 +*24 k +$u $r +^0 O12 +*35 r +^g T1 o3G -D2^1 +D2 ^1 o5l -$su -^7c -O03$r +$s u +^7 c +O03 $r o1! -^6z1 +^6 z1 o4h --2*10 -^z$z +-2 k +^z $z i7@ -R0z4 -ko6 +R0 z4 +k o6 O09 -$7$6 -l+9 -D1i1. --2D1 -^_O12 -o0-} +$7 $6 +l +9 +D1 i1. +-2 D1 +^_ O12 +o0- } s30 -O31o3a -+0D4 -[o0l +O31 o3a ++0 D4 +[ o0l O93 -$_Z2 -ko1a -i4wl -O02d -}p1 +$_ Z2 +k o1a +i4w l +} p1 O94 -i4:l -o0p'6 +i4: l +o0p '6 i6J -*79O81 -$jc +*79 O81 +$j c i4# -i0=$1 +i0= $1 si -^e^w -$pZ1 -+0-1 --1$7 -+1^l -p1o7o -co4l +^e ^w +$p Z1 ++0 -1 +-1 $7 ++1 ^l +p1 o7o +c o4l slw -i6,O02 -$3i7< -t$` -^\R1 -+6[ +i6, O02 +$3 i7< +t $` +^\ R1 ++6 [ OB4 -i2nk +i2n k i97 -T4[ -D8$7 +T4 [ +D8 $7 o3+ -O03^u -'8z1 -O54l +O03 ^u +'8 z1 +O54 l o24 -o0bk +o0b k o0X -^ad -fO47 +^a d +f O47 ^5 o4= -'7Z2 +'7 Z2 O84 --8O04 -O03d -$.Z1 -O03sld +-8 O04 +O03 d +$. Z1 +O03 sld iAx s0/ -L4L4 -cO03 +L4 L4 +c O03 swp -[o2z -sj\o6 +[ o2z +sj\ o6 o3= --6Z2 -ki0b -lZ4 -Z5{ -*79*95 +-6 Z2 +k i0b +l Z4 +Z5 { +*79 *95 i3M -$:Z2 -l*75 -sunD4 +$: Z2 +l *75 +sun D4 s4 -T0o6r -[$8 -^3Z1 +T0 o6r +[ $8 +^3 Z1 o7@ -'8t +'8 t o9z O74 -'9c -^eO21 +'9 c +^e O21 o7) R5 -z1sx -^K-2 -us0b -o2Z^g +z1 sx +^K -2 +u s0b +o2Z ^g i3A -p1-6 +p1 -6 sak -{^b -d*09 -sedl +{ ^b +d *09 +sed l o0Q -sR9z5 -t$= -o2lT0 +sR9 z5 +t $= +o2l T0 o4K -o0Sp1 +o0S p1 *42 -$3D3 -{R9 -$.D1 -*40t +$3 D3 +{ R9 +$. D1 +*40 t s73 -i2a*32 +i2a *32 sch --5o61 -D7o5v -O02*20 -[+2 -^4T1 -Z2o8t -^6i05 +-5 o61 +D7 o5v +O02 *20 +[ +2 +^4 T1 +Z2 o8t +^6 i05 ssc -p1s6w -$t$b -d -$eO53 -O41o3l -t^\ -z1Z1 -$ O16 -t$T -z1i1e +p1 s6w +$t $b +$e O53 +O41 o3l +t ^\ +$ O16 +t $T +z1 i1e sb0 -D3^@ -^tl -'Ai7s -z2-1 -O52D7 -[o33 +D3 ^@ +^t l +'A i7s +z2 -1 +O52 D7 +[ o33 oA9 -o2Mc -$2*14 -rc -p1O9A -*15o5 +o2M c +$2 *14 +r c +p1 O9A +*15 o5 ssp -i4ec -p1t -*42p1 -+3i4k -do6u -Z2O82 -O12$* -^cO13 -*71'9 +i4e c +*42 p1 ++3 i4k +d o6u +Z2 O82 +O12 $* +^c O13 +*71 '9 o7y -ko2d -o3g-4 +k o2d +o3g -4 o6c -}^b -qO05 -}i56 -$h$ -O81'9 -*02O21 -$rL8 +} ^b +q O05 +} i56 +$h $ +O81 '9 +*02 O21 +$r L8 skx -$n$a -k^r +$n $a +k ^r o3& -'B$l -tz2 -$8@y -p1$e -+0z4 -$TZ1 -*03$r -$5DA -Z1o0t -$.Z4 -r$z -^6^c -$7O62 +'B $l +t z2 +$8 @y +p1 $e ++0 z4 +$T Z1 +*03 $r +$5 DA +Z1 o0t +$. Z4 +r $z +^6 ^c +$7 O62 i2= sa. -$ O18 -$7o61 +$ O18 +$7 o61 syz -$/@o -O61O21 -Z3l +$/ @o +O61 O21 +Z3 l i3b i8y -dO94 -i3eD5 -^Jl +d O94 +i3e D5 +^J l sml -D8O61 -$uO52 -+7$% -$X*56 -{$w +D8 O61 +$u O52 ++7 $% +$X *56 +{ $w o16 o1v o6` --5'6 -i3ml -dsg0 +-5 '6 +i3m l +d sg0 i7= -}^k -^ O62 -Z1o5_ -^BO32 -o3ic -o3 O21 +} ^k +^ O62 +Z1 o5_ +^B O32 +o3i c +o3 O21 i4d sgj -sa3z5 -k$d +sa3 z5 +k $d sfa -slZl -R6t -i2[l -$5i6 -^7^4 -usCK -+4Z3 -+6O32 -t$; +slZ l +R6 t +i2[ l +$5 i6 +^7 ^4 +u sCK ++4 Z3 ++6 O32 +t $; iAq -o1h+0 --9l -O32^e -kO13 +o1h +0 +-9 l +O32 ^e +k O13 i31 -p1+2 +p1 +2 o8n -$1p1 o4d -'8^a -$%Z1 -dO37 -$x$p -Z5$6 -z5sG6 -O46T0 -$2T0 +'8 ^a +$% Z1 +p1 O37 +$x $p +Z5 $6 +z5 sG6 +O46 T0 +$2 T0 i5A ^& -o2d-0 -o1sc -*76'8 -z1o3- -^/c +o2d -0 +o1s c +*76 '8 +z1 o3- +^/ c i92 o8& -Z3O74 -*21d +Z3 O74 +*12 p1 i5h -t'B +t 'B *15 shk -D5-4 +D5 -4 s0e -Z2c -d*53 +Z2 c +d *53 o7J -T0i3s +T0 i3s sdg -$:$1 -$$C -i8Il -L1{ +$: $1 +$$ C +i8I l +L1 { sie o0x *85 -L1+1 -o7"T3 +L1 +1 +o7" T3 s98 -l-A -z1i17 -L7'8 -r*68 -C$2 +l -A +z1 i17 +L7 '8 +r *68 +C $2 $h -$ $7 -$wi6q -o3mO41 -i0fo15 -+2c -$Xt -i2ul +$ $7 +$w i6q +o3m O41 +i0f o15 ++2 c +$X t +i2u l stz @b srb -i7jl -*50O15 -cD8 +i7j l +*50 O15 +c D8 @h o3r -D2*02 -+8Z1 +D2 *02 ++8 Z1 i4; -o3 R0 +o3 R0 o6& -O83l +O83 l snc i1z -^k*13 -$3$i -p1O02 -*03oBc +^k *13 +$3 $i +*03 oBc @a -*21R0 +*21 R0 i5P o6I -p1O19 +p1 O19 i5$ -+1$n ++1 $n i6a -Z3O53 -+0$` --2R0 -^C^ --6$7 -R1R1 --8$! -*78-6 +Z3 O53 ++0 $` +-2 R0 +^C ^ +-6 $7 +R1 R1 +-8 $! +*78 -6 so8 -q$1 -*45D0 +q $1 +*45 D0 s0+ -to3f -*60D6 -^l^s +t o3f +*60 D6 +^l ^s oA5 -*60*01 -Z1$e -ci4 -o0b*02 +*60 *01 +Z1 $e +c i4 +o0b *02 o5@ -L3L1 -p1O28 -p1o0b -o6od +L3 L1 +p1 O28 +p1 o0b +o6o d o1c -$3T2 -di7, -li5t +$3 T2 +d i7, +l i5t o28 -i6_D2 -[o4j -$yD8 -$4-7 -T1k -*65$! -$uo7u -O81o8s --3O41 +i6_ D2 +[ o4j +$y D8 +$4 -7 +T1 k +*65 $! +$u o7u +O81 o8s +-3 O41 i8. -$2[ -$8DB -lL1 -T0r --6-5 +$8 DB +l L1 +T0 r +-6 -5 i3= i8d s2e -$Wl -z3{ +$W l +z3 { i4S -$iD2 -+2D3 -i3i[ -o2*d -*53*46 -'7i5_ -$1O51 +$i D2 ++2 D3 +i3i [ +o2* d +*53 *46 +'7 i5_ +$1 O51 sh -^6^a -Z1T4 -o0t$9 +^6 ^a +Z1 T4 +o0t $9 s47 s07 -o08z2 -OB1$3 +o08 z2 +OB1 $3 i34 -i6rZ1 -O32*35 --1o01 -*57o7s -+5'6 -lO03 +i6r Z1 +O32 *35 +-1 o01 +*57 o7s ++5 '6 +l O03 ^A -^ji0h -u$! -ls' -$xD2 +^j i0h +u $! +l s' +$x D2 sy1 -^ZL0 -s0 z2 -}O03 -Z1Z5 -$?Z2 -p5z3 -p1i5s +^Z L0 +s0 z2 +} O03 +Z1 Z5 +$? Z2 +p5 z3 +p1 i5s swd s51 -i3 D0 -^ z1 -O72l +i3 D0 +O72 l o4g -o71+6 -T3i3f +o71 +6 +T3 i3f $C -p1D1 -$zZ1 +p1 D1 +$z Z1 $X -$4o4o -Z2-9 -ki2z -z1^4 -$!T3 -^rz2 -$ep1 +$4 o4o +Z2 -9 +k i2z +z1 ^4 +$! T3 +^r z2 +$e p1 ^g -$.$9 -p2O0A -^1i16 -$!^0 +$. $9 +p2 O0A +^1 i16 +$! ^0 s14 -T5o7 +T5 o7 o31 -p1+9 +p1 +9 ^y -L0Z5 -^qz1 -l-1 -O02+1 -O62T6 +L0 Z5 +^q z1 +l -1 +O02 +1 +O62 T6 s38 oAj -+3+5 -s25Z1 -$4{ -O03O43 -uO02 -'9i8r ++3 +5 +s25 Z1 +$4 { +O03 O43 +'9 i8r @3 -[o0d -$2*68 -do0z -T7^2 -o0bp1 -*04O32 -O71o81 -i3nl -^7^f -o1Kk -$eZ1 +[ o0d +$2 *68 +d o0z +T7 ^2 +o0b p1 +*04 O32 +O71 o81 +i3n l +^7 ^f +o1K k +$e Z1 i1b -}D1 -l+3 -O06d -*BA -i8Rl -O03D1 -O07i5 +l +3 +O06 d +i8R l +O03 D1 +O07 i5 i12 -fO59 -qs2 -ti0B --4D5 -$-Z3 -co3m -z2L1 -D1^d -+1p1 -o16*31 -^/r +f O59 +q s2 +t i0B +$- Z3 +c o3m +z2 L1 +D1 ^d ++1 p1 +o16 *31 +^/ r O73 -['8 +[ '8 o1z -d+1 -to0F +d +1 +t o0F o7, -OB2-B -i5+l -$&Z2 +OB2 -B +i5+ l +$& Z2 s0) o8A *76 o7P -'8*76 --2k o7F -i5Nl -o5.Z4 -T0o7 -uT1 -i8iD6 -^tO13 -i4qr -$0O82 -i2sO32 -$wZ1 -c$+ -$ii3 -^3^c +i5N l +o5. Z4 +T0 o7 +u T1 +i8i D6 +^t O13 +i4q r +$0 O82 +i2s O32 +$w Z1 +c $+ +$i i3 +^3 ^c i2\ -R3p1 -O05z5 -o7m$1 -{Z1 -$lZ4 -i3p} -Z3o0j -'7$. +R3 p1 +O05 z5 +o7m $1 +{ Z1 +$l Z4 +i3p } +Z3 o0j +'7 $. o0V -Z2O31 -i10d -*13o4B --8[ -o6mc -c^A -OB2$b +Z2 O31 +i10 d +*13 o4B +-8 [ +o6m c +c ^A +OB2 $b s26 $+ -$YL8 +$Y L8 s3f o7] -*51[ -D3$. -rT0 +*51 [ +D3 $. +r T0 i9h -^1^c -^nd -o7>c +^1 ^c +^n d +o7> c i68 -$($) -c^2 -o4Dc -$!D9 -{^a -o7sO51 -p1i4g -$1+7 -*53*20 +$( $) +c ^2 +o4D c +$! D9 +{ ^a +o7s O51 +p1 i4g +$1 +7 +*53 *20 sv, -di4, -^t$. -lO95 -dO53 -$jZ1 -z1-1 -i3p*03 -R0^1 -i5;*34 +d i4, +^t $. +l O95 +p1 O53 +$j Z1 +z1 -1 +i3p *03 +R0 ^1 +i5; *34 i9a s24 -i1do1z o4, -R5Z1 +R5 Z1 o1r -i00^d -o6wO71 +i00 ^d +o6w O71 sa6 -D3+2 -*12l -p1OA3 +*12 l +p1 OA3 i8a -co7r +c o7r s39 -D8c -co1y -rt +c o1y +r t srz -o03+1 +o03 +1 o0$ -T8[ -lsp1 -$er -D4*30 -$IZ2 +T8 [ +l sp1 +$e r +D4 *30 +$I Z2 o0E -$IT2 -o3dp1 -^2z1 -}k --6+0 +$I T2 +o3d p1 +^2 z1 +} k +-6 +0 i5p -lsr[ +l sr[ s2f -p3O73 -i3^O41 -z2-0 -*45o0g +p3 O73 +i3^ O41 +z2 -0 +*45 o0g i84 -D1^7 -cL0 +D1 ^7 +c L0 sbg -$*^$ -*57O16 +$* ^$ +*57 O16 ^! -^c*12 -L3+3 -$.-5 -o4tO21 -sdil -+0T2 -R5R5 -O46$1 -o0'{ -Z2-4 +^c *12 +L3 +3 +$. -5 +o4t O21 +sdi l ++0 T2 +R5 R5 +O46 $1 +o0' { +Z2 -4 o5x -qO12 -*97$q -z1$d +q O12 +*97 $q +z1 $d i4* sec -^o} -$`O02 +^o } +$` O02 s2a -}^c -O04p1 +} ^c +O04 p1 o9g -i0f-1 -o0m{ -sud$3 -^9^6 +i0f -1 +o0m { +sud $3 +^9 ^6 stc -O24d -p1o5k -l+4 +O24 d +p1 o5k +l +4 i4k ^` o67 -+0z1 -$qL9 -'7c -Z3t -o1r[ -*58'8 ++0 z1 +$q L9 +Z3 t +o1r [ +*58 '8 O07 -R0'1 +R0 '1 o4% -^Az2 +^A z2 sjh -^h^a -[o3z -doBa -Z2O03 -^]$[ -di5 +^h ^a +[ o3z +d oBa +Z2 O03 +^] $[ +d i5 $> oAk -}O02 -O04L0 -T2+1 -o0aT2 -O32$7 +} O02 +O04 L0 +T2 +1 +o0a T2 +O32 $7 slF -[*05 -o3g*30 -o76Z1 -o3n[ -^5^c -$Qc +[ *05 +o3g *30 +o76 Z1 +o3n [ +^5 ^c +$Q c stm -'5q -^8^3 -dT6 +'5 q +^8 ^3 +d T6 ^B -dO32 -p1O74 -^Mz1 +d O32 +p1 O74 +^M z1 o0H -o07$ -$!O21 +o07 $ +$! O21 sbe i6: -l^m -D1+3 -Z3$- -$<^< -*06l -o91D4 -*67 -^k'7 -z5O25 -o9eO63 -L5O32 -$-$x -^vO14 -$yZ2 -o67+8 -*67o75 -$$^# -o6k[ --5t +l ^m +D1 +3 +Z3 $- +$< ^< +*06 l +o91 D4 +^k '7 +z5 O25 +o9e O63 +L5 O32 +$- $x +^v O14 +$y Z2 +o67 +8 +*67 o75 +$$ ^# +o6k [ +-5 t oA1 -[+1 -^l^k -O62c -$%i61 -[i1z -'7$9 +[ +1 +^l ^k +O62 c +$% i61 +[ i1z +'7 $9 i8f -'BO71 -i54*31 +'B O71 +i54 *31 sj -*54-4 -u-5 -O02^X -p1O34 -$ $3 -o1yp1 +*54 -4 +u -5 +O02 ^X +$ $3 +o1y p1 o2. -D6d -O81R8 +D6 d +O81 R8 i82 -+8-6 -O21+1 -O03$! -D6$9 -O01r -fO43 -O31-0 -$6$7 ++8 -6 +O21 +1 +O03 $! +D6 $9 +O01 r +f O43 +O31 -0 +$6 $7 o6B -'5z1 -+0^p -o12$! -o1K[ +'5 z1 ++0 ^p +o12 $! +o1K [ s2c -}Z2 +} Z2 o56 -+0+3 -D3p1 -i0do1h -$mZ1 -i7k+8 ++0 +3 +D3 p1 +i0d o1h +$m Z1 +i7k +8 srS -^ik -di5p --6-7 -Ck -O26d -o0kO23 -^c^1 -d'9 -i3mR3 -$9o76 -c'9 +d i5p +-6 -7 +C k +O26 p1 +o0k O23 +^c ^1 +i3m R3 +$9 o76 si* -$2$x -^8z2 +$2 $x +^8 z2 sdm -^ z3 -p1o5g --7+9 --AZ1 +^ z3 +p1 o5g +-7 +9 +-A Z1 s86 -$z{ -$-$. +$z { +$- $. $G -o4cO02 -'2z3 -'8$a +o4c O02 +'2 z3 +'8 $a i6E -R0} -fO65 -O34q -^GZ2 -O03^g -lO23 -D4o0m -*86+7 -ci8 -l$u +R0 } +f O65 +O34 q +^G Z2 +O03 ^g +l O23 +D4 o0m +*86 +7 +c i8 +l $u O0B -$AZ1 -p1O72 +$A Z1 +p1 O72 soe -O0Ai0 -ki0r --0c -D6$0 -O61$+ -fi01 -$ +0 -$qd -o1;l +O0A i0 +-0 c +D6 $0 +O61 $+ +f i01 +$ +0 +$q d +o1; l sbk -fO91 +f O91 o4A -*74*65 -^n$1 -Z1o0K -^K^J +*74 *65 +^n $1 +Z1 o0K +^K ^J s4& -p1+5 -z2i1n -o44d -[o3_ -o0L -O41i2o -kO12 -$!-5 -Z2d -$-Z4 -$i$n -p1O36 -o6cl -u+7 -T0^e -sz t --3D2 -$id -^S$S -O71+5 -*56$1 -O21+6 -$:d -o2d-8 -lssd -o3 } -CT7 +p1 +5 +z2 i1n +o44 d +[ o3_ +O41 i2o +k O12 +$! -5 +Z2 d +$- Z4 +$i $n +p1 O36 +o6c l +u +7 +T0 ^e +sz t +-3 D2 +$i d +^S $S +O71 +5 +*56 $1 +O21 +6 +$: p1 +o2d -8 +l ssd +o3 } +C T7 i2g sl4 o7= -uo6A +u o6A o27 -O23o2n -$b$a +O23 o2n +$b $a iBs -*74$k --4o0P -^tO12 -[-3 -i4 +7 -'5^z -$5O52 +*74 $k +-4 o0P +^t O12 +[ -3 +i4 +7 +'5 ^z +$5 O52 i2y -T6T5 -Z1$2 -dOB9 -[o1o -T4'A +T6 T5 +Z1 $2 +d OB9 +[ o1o +T4 'A se, ^H i9o -dOA5 +d OA5 O45 -*45p1 -z2R1 -p1i6r -$4T5 -^.^t -'6Z2 +*45 p1 +z2 R1 +p1 i6r +$4 T5 +^. ^t +'6 Z2 o6; -*10R1 -rf -o6.*07 -l$q -i6%c -c$x -O04T3 --4Z1 -*21o1e +r f +o6. *07 +l $q +i6% c +c $x +O04 T3 +-4 Z1 +*21 o1e i3z --3+2 -^sO14 -i1b$s +-3 +2 +^s O14 +i1b $s i6I -se8d -*13*42 -R2o2v -z3+1 -$#o0w -$0+5 +se8 d +*13 *42 +o2v +z3 +1 +$# o0w +$0 +5 sas -p1O47 -l*35 -[$@ -p3O4A -^v} -*02*97 -dsh6 -*76*68 -$7O52 -$2O53 -o8ru -LBO92 -sb7l -$3k -Z1L5 -O25p1 -p1O98 -dO67 +p1 O47 +l *35 +[ $@ +p3 O4A +^v } +*02 *97 +d sh6 +*67 *86 +$7 O52 +$2 O53 +o8r u +LB O92 +sb7 l +$3 k +Z1 L5 +O25 p1 +p1 O98 +d O67 spt i0i -*67*86 snk o9m -z1*50 -}$% -o2-^k -$!O71 -^;$ +z1 *50 +} $% +o2- ^k +$! O71 +^; $ i6` -fO7A +f O7A s65 -$;@p -l^D -lo6. -$2$! +$; @p +l ^D +l o6. +$2 $! i6w -Z1iB8 +Z1 iB8 sw -$1o7l +$1 o7l i7k -$ sro +$ sro oA- -$!O61 -^q*14 -T2T9 -Z1i5e -}R0 -cZ1 -^.^1 -D0+1 +$! O61 +^q *14 +T2 T9 +Z1 i5e +} R0 +^. ^1 sr! i9t --6+5 --3d +-3 d s2# -o0KT5 -^0^c -o54*02 +o0K T5 +^0 ^c +o54 *02 i5z -o2Pl +o2P l o7$ -D0^u -o0Fl -*30O41 -cL5 -lO26 -z1^d -^Rl -T7t -i27[ -p2O04 -}i1f -i47c -do0f +D0 ^u +o0F l +*30 O41 +c L5 +l O26 +z1 ^d +^R l +T7 t +i27 [ +p2 O04 +} i1f +i47 c +d o0f sce s5b -*20-0 -o4sl -i4El -i6zc -^WT1 -O32o0k -[$r -o4yo2k +*20 -0 +i4E l +i6z c +^W T1 +O32 o0k +[ $r +o4y o2k sed -o5Ac +o5A c s1e su1 -o4iO31 -p1O68 -o60Z5 -$PL9 +o4i O31 +p1 O68 +o60 Z5 +$P L9 o7^ -[o3 -p1c -[f -$>$ -[$i -$j$o -}O04 +[ o3 +[ f +$> $ +[ $i +$j $o +} O04 i6u -'7d -T0*9A +'7 d +T0 *9A ss7 o4D -*46+4 -t$B -p1*78 +*46 +4 +t $B +p1 *78 s1m -*46$v +*46 $v i73 L1 s50 $B sb3 o26 -o2mD3 -*05[ -i5d*05 -+AO82 -^ci1j -t*20 -L0c -$8@m -c$k --7l -cO53 +o2m D3 +*05 [ +i5d *05 ++A O82 +^c i1j +t *20 +L0 c +$8 @m +c $k +-7 l +c O53 o6W -p1o0h -^ $ -[d -$zZ2 +p1 o0h +^ $ +[ d +$z Z2 o4; -*02i0s -up1 -+5p1 -O01+6 -T7*64 -o1Ul -o64$o -^md -p2O58 --7-9 -}^e --4O31 -fO53 -o73o89 -c$^ +*02 i0s +u p1 ++5 p1 +T7 *64 +o1U l +o64 $o +^m d +p2 O58 +-7 -9 +} ^e +-4 O31 +f O53 +o73 o89 +c $^ i6g -i09} -$9*01 -k'9 -^2$$ -*65*67 -^.z2 -^gp1 -[z2 --1^8 -^4^4 -i05p1 +i09 } +$9 *01 +k '9 +^2 $$ +*65 *67 +^. z2 +^g p1 +[ z2 +-1 ^8 +^4 ^4 +i05 p1 i7b s1+ -@ed -+7Z1 -O46z2 -o2b-0 -O02i5e -$oo6w -^i^M -L5O04 +@e d ++7 Z1 +O46 z2 +o2b -0 +O02 i5e +$o o6w +^i ^M +L5 O04 @8 -^Eo4e -R6+5 -q$d +^E o4e +R6 +5 +q $d o6z -co7M +c o7M o37 stD i6z -i5ju -o0kz1 -p1oBr -$p^9 -^1^b -o1j$1 -o6?*45 -$,*64 -$M+7 -^S^J -^7O21 -T8D5 -O45l -i5i{ -o04 -^Sz2 -^4z2 +i5j u +o0k z1 +p1 oBr +$p ^9 +^1 ^b +o1j $1 +o6? *45 +$, *64 +$M +7 +^S ^J +^7 O21 +T8 D5 +O45 l +i5i { +^S z2 +^4 z2 seb sb2 -R0O13 -^V$v -o23R1 +R0 O13 +^V $v +o23 R1 s6e -o1%u -o6@$1 -+6-5 -'6*54 -^g$7 -o8m*67 -to86 -*50O53 -^mo2i -$VZ1 -o2r^v --6^@ -o5s+4 -$bO72 -O12o4 -$e^d -*37$k -$-D5 -o5$Z3 -O73OA2 -^.^a -[p3 +o1% u +o6@ $1 ++6 -5 +'6 *54 +^g $7 +o8m *67 +t o86 +*50 O53 +^m o2i +$V Z1 +o2r ^v +-6 ^@ +o5s +4 +$b O72 +O12 o4 +$e ^d +*37 $k +$- D5 +o5$ Z3 +O73 OA2 +^. ^a +[ p3 sko s_4 --3o4e --4t -+7i5j -^=z1 -saeD6 -+6o5w +-3 o4e +-4 t ++7 i5j +^= z1 +sae D6 ++6 o5w *63 o8` -$B$J -$+@9 -i2-^z -o8Kc -i0h^r -^t*23 +$B $J +$+ @9 +i2- ^z +o8K c +^h ^r +^t *23 o6^ -D2$. -o52$x -O93L9 --1{ +D2 $. +o52 $x +O93 L9 +-1 { O87 sPs -$*$1 -o5Kl -^ z4 -^aO12 -$1^c -O43l -o8go9r -o6/$6 -o1ki1u -$"i7! -$4O62 -$iO62 -$!^D -t$" -qO86 -[z5 -DB$4 +$* $1 +o5K l +^ z4 +^a O12 +$1 ^c +O43 l +o8g o9r +o6/ $6 +o1k i1u +$" i7! +$4 O62 +$i O62 +$! ^D +t $" +q O86 +[ z5 +DB $4 i2- -o0gd -ki3f +o0g d +k i3f i7* i7, -*74O41 -@9p1 -T3i3- -i1kT6 -$3o6= -$1+6 -dO81 -o81sub -o2d[ -rZ3 -T7o5z -*71[ +*74 O41 +@9 p1 +T3 i3- +i1k T6 +$3 o6= +$1 +6 +d O81 +o81 sub +o2d [ +z3 r +T7 o5z +*71 [ ^< -^ki1i -Z1*34 -'7o6z +^k i1i +Z1 *34 +'7 o6z svg -+9o8j -$V$6 -*85i7e ++9 o8j +$V $6 +*85 i7e oAs -Z1O03 -o6TT7 -o0iu -$q$w +Z1 O03 +o6T T7 +o0i u +$q $w i2$ -sh-o0g -o1j*41 -D5*45 -Z4O61 +sh- o0g +o1j *41 +D5 *45 +Z4 O61 oA7 -li6t -*27D2 -O21f -^MO43 -*53T4 -*97syi -i5KO64 -i4@-8 -ci31 -^5^b -i5#-9 +l i6t +*27 D2 +O21 f +^M O43 +*53 T4 +*97 syi +i5K O64 +i4@ -8 +c i31 +^5 ^b +i5# -9 o4T svn *97 -DAo91 -dOB4 +DA o91 +p1 OB4 sx+ -DBO71 +DB O71 i1! -O12$s +O12 $s oAx -sunsjk -+5+7 -*13p1 -OB2l -Z1T0 -$7+1 -$9+4 -ri4, -+0o44 -Z2$5 -}z4 -$2O51 -o0uk -*87o0p +sun sjk ++5 +7 +*13 p1 +OB2 l +Z1 T0 +$7 +1 +$9 +4 +r i4, ++0 o44 +Z2 $5 +} z4 +$2 O51 +o0u k +*87 o0p o4G -*31q -$-$+ -R7l -L9O62 -$uO62 -sJgl -O14^g -o6d-6 -r$; -'9r -tO72 -$`Z1 -o8Ec -Z3$5 -o61T5 -L1-0 -*A9+3 -$JL5 +*31 q +$- $+ +R7 l +L9 O62 +$u O62 +sJg l +O14 ^g +r $; +'9 r +t O72 +$` Z1 +o8E c +Z3 $5 +o61 T5 +L1 -0 +*A9 +3 +$J L5 s1I s,g -+6R5 -$ R5 -o0W*31 -$6T2 -o4Uc -O02^j -^c^4 -{o6t -+6$A -[*64 ++6 R5 +$ R5 +o0W *31 +$6 T2 +o4U c +O02 ^j +^c ^4 +{ o6t ++6 $A +[ *64 so& -i3mt -$pT2 -o0Ku -+2$ -i4 *37 -o6M$2 -kc -o4Iu -uo1d -^[l +i3m t +$p T2 +o0K u ++2 $ +i4 *37 +o6M $2 +k c +o4I u +u o1d +^[ l sfj -+6O42 -^zL0 -[$- -kO31 -o9/T0 -^sD4 -^,f ++6 O42 +^z L0 +[ $- +k O31 +o9/ T0 +^s D4 +^, f s!6 -$?$2 --2o0T -li5- -@6o57 -^0*20 -i0.c -kq -k*51 -+5o4 -o3 ^4 -*23^ -$:$! +$? $2 +-2 o0T +l i5- +@6 o57 +^0 *20 +k q +k *51 ++5 o4 +o3 ^4 +*23 ^ +$: $! s3o --Bl -i3ou -$"Z1 +-B l +i3o u +$" Z1 srm -{R2 -z1R1 -D6L5 -i6aO02 -O16$_ -$f-3 +{ R2 +z1 R1 +D6 L5 +i6a O02 +O16 $_ +$f -3 o3O -+9i91 -$ui5- -dO21 -i3Qo3h ++9 i91 +$u i5- +d O21 o6E -$.$K -$roAg -*97@a +$. $K +$r oAg +*97 @a swc -lsgj -T0T9 -$pD2 -^u^n --0l -c^M +l sgj +T0 T9 +$p D2 +^u ^n +-0 l +c ^M o1, -$g*54 -*45R4 -i4:*02 -$=T5 +$g *54 +*45 R4 +i4: *02 +$= T5 oA0 --1o0t -^3z2 -*40O42 -o15[ -i3e$Z -$3$ -o4;^c -^y^o +-1 o0t +^3 z2 +*40 O42 +o15 [ +i3e $Z +$3 $ +o4; ^c +^y ^o o7f -p1O76 -*36O32 -dsam -@bi5 -i5^[ -sprd -^Zi4X -z2R2 -O14i0T -o7&$y -sBLp1 -O0Ad -$ *52 +*36 O32 +d sam +@b i5 +i5^ [ +spr d +^Z i4X +z2 R2 +O14 i0T +o7& $y +sBL p1 +O0A d +$ *52 i90 -z4O46 +z4 O46 i2j sb7 s7f -O02'A -$#*57 -$di4 -*21f -s4/Z2 -+0$s -p1*A8 -T0^S -^u^S -R0q -[u -di0m -Z1*21 +O02 'A +$# *57 +$d i4 +*21 f +s4/ Z2 ++0 $s +p1 *A8 +T0 ^S +^u ^S +R0 q +[ u +d i0m +Z1 *21 i7S o3D -p4Z1 -D8i5b -Z2*65 -$U$J -R0p1 +p4 Z1 +D8 i5b +Z2 *65 +$U $J +R0 p1 iA0 -$z$2 -$mk -lo1a -sfg*91 -o2-+4 +$z $2 +$m k +l o1a +sfg *91 +o2- +4 iB5 -$"iA! +$" iA! s62 --6O51 +-6 O51 s28 -o7 $l +o7 $l @6 s5 s09 -^sL0 -*16O43 -dO07 -^x'8 -$.O63 -o4"o0! -lo6k -o3np1 -i3-c -di4y -o7cZ1 -i3h} +^s L0 +*16 O43 +d O07 +^x '8 +$. O63 +o4" o0! +l o6k +o3n p1 +i3- c +d i4y +o7c Z1 +i3h } i4% -i0s$a -$eZ4 -C^7 +i0s $a +$e Z4 +C ^7 slm -$fO82 -O05p2 -sgml -o7mO81 --0^2 -*74+5 +$f O82 +O05 p2 +sgm l +o7m O81 +-0 ^2 +*74 +5 L4 o9@ -t$F +t $F s9 i1_ -o6tD4 --8*BA -o1kL4 -D3i3_ -O51Z2 -s3Tf +o6t D4 +-8 *BA +o1k L4 +D3 i3_ +O51 Z2 +s3T f sw6 -o7#R4 -L2O02 -$qZ5 -*62*73 --3O02 -{$i -di5o -R0o1 +o7# R4 +L2 O02 +$q Z5 +*62 *73 +-3 O02 +{ $i +d i5o +R0 o1 scs -^6D2 -to61 +^6 D2 +t o61 OA2 -o54O41 -{^d -Z2*53 -'Bt -*65O42 -O51*57 -$"u -}o0x -s2eq -*46Z1 -o0kO41 +o54 O41 +{ ^d +Z2 *53 +*65 O42 +O51 *57 +$" u +} o0x +s2e q +*46 Z1 +o0k O41 $" -D6^b +D6 ^b spj -^eO12 -i67*53 -p2O2A -D1^p -$o*82 -i4!c -*40'9 -$vD5 -s3e$7 -$xO92 -[o1t -^yi3_ -i15r -+6$0 -+9Z1 -i4.r -@5+2 -T3$1 -T6Z2 -rs1 +^e O12 +i67 *53 +p2 O2A +D1 ^p +$o *82 +i4! c +*40 '9 +$v D5 +s3e $7 +$x O92 +[ o1t +^y i3_ +i15 r ++6 $0 ++9 Z1 +i4. r +@5 +2 +T3 $1 +T6 Z2 +r s1 i74 -i5q{ -*06$1 +i5q { +*06 $1 sms -$q$a -O09$ -Z1i7o -f@a -z1o4, --2u -'6$i -$1-6 -*78s71 -i6mO06 -p1O09 -$N*65 -'8-2 --1$5 +$q $a +O09 $ +Z1 i7o +f @a +z1 o4, +-2 u +'6 $i +$1 -6 +*78 s71 +i6m O06 +$N *65 +'8 -2 +-1 $5 s@, -z1o91 -L1O23 -$X$2 -OB3Z2 -$pL6 -*24k -o5/i0A +z1 o91 +L1 O23 +$X $2 +OB3 Z2 +$p L6 +o5/ i0A iAs --6i5, -O81seo -Z5OB6 +-6 i5, +O81 seo +Z5 OB6 shd -i00o6m -p3O0A -$mZ2 -$7Z3 -L5O62 -+6*57 +i00 o6m +p3 O0A +$m Z2 +$7 Z3 +L5 O62 ++6 *57 i1d -o1q^& -^k$a +o1q ^& +^k $a sor -O2Bo2 -to0V -r'A +O2B o2 +t o0V +r 'A o4' -o0=^b +o0= ^b O39 -sAcp1 +sAc p1 O15 -T0i3: -O72^l +T0 i3: +O72 ^l sNS -O61O14 -$hZ2 -^wz2 -$1*74 --2r -Z1i4K -o6p*56 -O02z1 -o8i*57 -o5 @e -}'A -T4i4! -o5,O61 -Z3D7 +O61 O14 +$h Z2 +^w z2 +$1 *74 +-2 r +Z1 i4K +o6p *56 +O02 z1 +o8i *57 +o5 @e +} 'A +T4 i4! +o5, O61 +Z3 D7 i46 -O61*9A -^N$H +O61 *9A +^N $H s23 -}o0 -^so2y -i1-u -k+1 --0$u -^j*41 +} o0 +^s o2y +i1- u +-0 $u +^j *41 i1p i5L scf *25 i4? -qq -$4+2 -fO64 -O06R1 -Z1-3 -i2w@o -$lZ1 -d*03 -$_$+ -O13o1u +q q +$4 +2 +f O64 +O06 R1 +Z1 -3 +i2w @o +$l Z1 +p1 *03 +$_ $+ +O13 o1u s!+ --0$1 -$hp1 -+4*53 -o89Z1 -*72$q -o5ei2U -l^4 +-0 $1 +$h p1 ++4 *53 +o89 Z1 +*72 $q +o5e i2U +l ^4 sx) i37 -uo0W -o7<*67 +u o0W +o7< *67 i4P -Z1ssB -*41d +Z1 ssB +*41 d oA -o9iD0 +o9i D0 i5E -^Ct -o6xO51 -O71O21 +^C t +o6x O51 +O71 O21 o2? o9x -i56l -+6*75 +i56 l i6q sp+ -$1O53 -z5R5 +$1 O53 +z5 R5 o5N -'7^ -+0*32 -^a^p -O13i1j -O04Z3 -*61O12 -$_$i -@8k -p1i5z -i3uq --6$8 --1*13 -$sk -o5.O41 -^8+1 -s9 O01 +'7 ^ ++0 *32 +^a ^p +O13 i1j +O04 Z3 +*61 O12 +$_ $i +@8 k +p1 i5z +i3u q +-6 $8 +-1 *13 +$s k +o5. O41 +^8 +1 +s9 O01 @5 -$xl -^lo3 -o51$k -o0sO31 +$x l +^l o3 +o51 $k +o0s O31 o4@ oBy -Z4+7 +Z4 +7 o2: -$3srl -[O32 -D3$g -o06@r -^1z3 -*32i4s -'4z5 -z2sD -$1*34 -$7s4_ --5$? -D6o2d -$yp1 -R2^b -$6[ -i6a+5 -+5$g -$w$e -+6+1 -o8![ -'5$3 -fi5n -o40p1 +$3 srl +[ O32 +D3 $g +o06 @r +^1 z3 +*32 i4s +'4 z5 +z2 sD +$1 *34 +$7 s4_ +-5 $? +D6 o2d +$y p1 +R2 ^b +$6 [ +i6a +5 ++5 $g +$w $e ++6 +1 +o8! [ +'5 $3 +f i5n +o40 p1 sn2 -$ sg; -*10o1. -i3mZ1 -ci1F -OB1oB3 -$ ^b -*40q +$ sg; +*10 o1. +i3m Z1 +c i1F +OB1 oB3 +$ ^b +*40 q oBr -dOB8 -*68D6 -$9*14 -Z1ss& +d OB8 +*68 D6 +$9 *14 +Z1 ss& i9e -OA1D8 -$@u -^AD4 -z1o2O -o2H^H -$.i12 -Z2$, +OA1 D8 +$@ u +^A D4 +z1 o2O +o2H ^H +$. i12 +Z2 $, shO -$y$s --4z1 -o65Z2 -*65^z -$4p1 -i46i42 -T5O62 -O01*42 +$y $s +-4 z1 +o65 Z2 +*65 ^z +$4 p1 +i46 i42 +T5 O62 +*53 [ iA! -$d-8 -$Po6. -z1^i -$LO73 -r'6 -d^1 --4-1 -$-Z2 -O82T7 -*46l -Z2$v -i3jl -^@^p -$5O41 -Z3o4a -O23q -O21+2 -L5i6g -O21^k -^6^4 -o4tZ2 +$d -8 +$P o6. +z1 ^i +$L O73 +r '6 +d ^1 +-4 -1 +$- Z2 +O82 T7 +*46 l +Z2 $v +i3j l +^@ ^p +$5 O41 +Z3 o4a +O23 q +O21 +2 +L5 i6g +^6 ^4 +o4t Z2 i3! -u$m -*05+3 +u $m +*05 +3 ^W o6x -+7i6y --7i7t -L4'5 -O01i4u -L0L0 -i4aD2 -D2-2 ++7 i6y +-7 i7t +L4 '5 +O01 i4u +L0 L0 +i4a D2 sd* -+6d -^Pz1 -Z1^4 -^kO15 -+5*78 -dO75 -D7*78 -$8*78 -^a} -'6o5l ++6 d +^P z1 +Z1 ^4 +^k O15 ++5 *78 +D7 *78 +$8 *78 +^a } +'6 o5l o6< -Z1*86 -T1T6 +Z1 *86 +T1 T6 skr i1= -$s$m +$s $m o8M -i8tc -i5O{ -+5*35 -Z5se6 -L0z2 -D7u -i41r -l$i -T4+2 -T9T8 -to8T -^mO12 -D4o4 --0d -Z5O43 -*03o5_ -c$? -$u^? -i3y*42 -s, q -O32O42 -p3O65 -loB1 -^6L1 -$1O58 -}^w -*32^s -o2rq -o1oL0 -z2o1. -$0c -*50*41 +i8t c +i5O { ++5 *35 +Z5 se6 +L0 z2 +D7 u +i41 r +T4 +2 +T9 T8 +t o8T +^m O12 +D4 o4 +-0 d +Z5 O43 +*03 o5_ +c $? +$u ^? +i3y *42 +s, q +O32 O42 +p3 O65 +l oB1 +^6 L1 +$1 O58 +} ^w +*32 ^s +o2r q +o1o L0 +z2 o1. +$0 c +*50 *41 $T sx! -li8a +l i8a si. --8DA -$iO54 +-8 DA +$i O54 s74 sft o6/ -^0-5 -i0d^7 -L0^h -{$6 -O42-4 +^0 -5 +i0d ^7 +L0 ^h +{ $6 +O42 -4 oA3 -$8{ -O13+0 -s37L1 -i31o0s -*62O03 -L1R1 -i7iT5 -$e$m -oB9+8 -R7Z3 -^Vi1c -+6Z1 -fO27 -^1'8 -D3sao -Z1i8x -i01$9 -[z1 -i65'9 -i74i8z -sm8O21 -li3/ -D5d +$8 { +O13 +0 +s37 L1 +i31 o0s +*62 O03 +L1 R1 +i7i T5 +$e $m +oB9 +8 +R7 Z3 +^V i1c ++6 Z1 +f O27 +^1 '8 +D3 sao +Z1 i8x +i01 $9 +[ z1 +i65 '9 +i74 i8z +sm8 O21 +l i3/ +D5 d sdq -'4[ -z5O62 +'4 [ +z5 O62 scv -o6l+3 -o1eo2d +o6l +3 +o1e o2d s1/ o7% -^/z2 -fi6o -z5o7 -fO49 -R7*67 -to9H -D6'9 +^/ z2 +f i6o +z5 o7 +f O49 +R7 *67 +t o9H +D6 '9 o5K -rs0- -i4qo5u -i3:c -O03Z5 -*01R0 -$8d -o51c -o0f^7 -Z5$a -O02+3 -^>o71 -^ei13 +r s0- +i4q o5u +i3: c +O03 Z5 +*01 R0 +$8 d +o51 c +o0f ^7 +Z5 $a +O02 +3 +^> o71 +^e i13 s90 -o0dD5 -lZ2 -O37p1 -o2su -$s^k -i62[ -o3wl -L0p1 -o4aZ2 -*03O43 -T3$D --5+2 -p1+7 +o0d D5 +O37 p1 +o2s u +$s ^k +i62 [ +o3w l +L0 p1 +o4a Z2 +*03 O43 +T3 $D +-5 +2 +p1 +7 s6a -o70c -$6$2 -OB3Z1 -$-@T -*01$f -$Ml -lo5< +o70 c +$6 $2 +OB3 Z1 +$- @T +*01 $f +$M l +l o5< *16 -*37$" -i1Eo8E -O72c -dOA6 -^c+1 -*12o1b --7$5 -^l-8 -O62O13 +*37 $" +i1E o8E +O72 c +p1 OA6 +^c +1 +*12 o1b +-7 $5 +^l -8 +O62 O13 syj -Z5$c +Z5 $c sMk i9u -*25z2 -T0$9 -O34ssp -^2$* -fO76 -*65l -Z1+1 -D3i4, -R7'8 -lo5n -+6k -$t$h -o9sD3 -*98O71 -Co6: -r^z -p2O06 -$k^m -$xf -*21O41 -L6Z1 +*25 z2 +T0 $9 +O34 ssp +^2 $* +f O76 +Z1 +1 +D3 i4, +R7 '8 +l o5n ++6 k +$t $h +o9s D3 +*98 O71 +C o6: +r ^z +p2 O06 +$k ^m +$x f +*21 O41 +L6 Z1 oA, -D1sn_ -c^H -*57$0 -i2a-4 -o8#+9 +D1 sn_ +c ^H +*57 $0 +i2a -4 +o8# +9 i57 -$p$l -$?+6 -o75t +$p $l +$? +6 +o75 t sn, -*46-7 -*87$1 -$8*75 -*31D2 -$d$b -i0esn_ +*46 -7 +*87 $1 +$8 *75 +*31 D2 +$d $b +i0e sn_ s9x -+0*86 -i42@2 -^#O61 -o56$6 -i0P^E ++0 *86 +^# O61 +o56 $6 +i0P ^E s9G -R2l -$:c -c$" +R2 l +$: c +c $" o8$ -$ +$< ^> i2H -O12$6 -$i$d -*03sbe -Z2O23 -s2 '3 -$s$4 -$Gc -*B1O03 -^pc -'5$r -O52*67 -*54o3 -O31-2 -{^L +O12 $6 +$i $d +*03 sbe +Z2 O23 +s2 '3 +$s $4 +$G c +*B1 O03 +^p c +'5 $r +O52 *67 +*54 o3 +O31 -2 +{ ^L sx* -T2^) -*41s9< -^/^7 +T2 ^) +*41 s9< +^/ ^7 i5F -^bD4 +^b D4 sla -+7l ++7 l o8) -$hi8% -di6b -qO4A +$h i8% +d i6b +q O4A sac -O02L5 -o1k^s -'5p3 -$ O73 -o5 '6 -'8*70 -T0$} -^s+7 +O02 L5 +o1k ^s +'5 p3 +$ O73 +o5 '6 +'8 *70 +T0 $} +^s +7 sbp --BZ1 -*35t -qr -$Ru -R4R2 +-B Z1 +*35 t +q r +$R u +R4 R2 s0q -O96-6 -D0i2m -Z2$7 +O96 -6 +D0 i2m +Z2 $7 $l -D2+3 -c^< -[s7+ -$sD7 +D2 +3 +c ^< +[ s7+ +$s D7 o7w -T0T5 +T0 T5 sv6 -*74O54 -i8zr --7o80 -*02^b -^#$@ -*87+8 -tD1 -i17C -fOA5 -^_T1 -$#O62 -*61*21 --5*68 -z3o12 -uo7% -si\*12 +*74 O54 +i8z r +-7 o80 +*02 ^b +^# $@ +*87 +8 +t D1 +i17 C +f OA5 +^_ T1 +$# O62 +*61 *21 +-5 *68 +z3 o12 +u o7% +si\ *12 o1N -^1$" +^1 $" sdP -$*sln -$%t +$* sln +$% t i3v -+7-6 ++7 -6 *72 -+At -T6*65 -t$> ++A t +T6 *65 +t $> O75 -o14Z4 +o14 Z4 o4( -$@@i -o5m-6 -{c -l^{ -*42T0 -o2v -p2^T -$@L4 -o2cD0 -+4[ -O12$ -i4ho2r -*65[ -li58 -$2*78 -ki7g --2d -o85O62 -o93+8 -*01i11 -s20$! -T5o0S -{i8* -$nO82 -$D*57 -$7OB3 +$@ @i +o5m -6 +{ c +l ^{ +*42 T0 +p2 ^T +$@ L4 +o2c D0 ++4 [ +O12 $ +i4h o2r +*65 [ +l i58 +$2 *78 +k i7g +-2 d +o85 O62 +o93 +8 +*01 i11 +s20 $! +T5 o0S +{ i8* +$n O82 +$D *57 +$7 OB3 sx^ -o7bZ1 -p4[ -*74k -i4,-5 -$d$w -*78Z1 +o7b Z1 +p4 [ +*74 k +i4, -5 +$d $w +*78 Z1 sl! -fo68 -l$j -$b$u -o2nO32 -$lO62 -o01p1 -'Ai9 -*57o7, -[o0W -*06T6 -+1^b -O63$. -*76i5 -o7#*76 -Z2s7@ -O02^x +f o68 +l $j +$b $u +o2n O32 +$l O62 +o01 p1 +'A i9 +*57 o7, +[ o0W +*06 T6 ++1 ^b +O63 $. +*76 i5 +o7# *76 +Z2 s7@ +O02 ^x s _ i7v -u*68 -T2T6 -O04i6 -O04u +u *68 +T2 T6 +O04 i6 +O04 u o1g -@0Z1 -+A*9A -Z5s3+ -'3p1 -$%se1 +@0 Z1 ++A *9A +Z5 s3+ +'3 p1 +$% se1 i6& -o89+9 -^kz1 -$b+6 -i4gr -$m$x -$ao7f -^hc -slMT2 -'8Z5 -*74*85 --4+3 --3-4 -z2*96 -*40O41 -$_-0 --6O05 +o89 +9 +^k z1 +$b +6 +i4g r +$m $x +$a o7f +^h c +slM T2 +'8 Z5 +*74 *85 +-4 +3 +-3 -4 +z2 *96 +*40 O41 +$_ -0 +-6 O05 i3; -Z2-6 -sb1z1 -^8r +Z2 -6 +sb1 z1 +^8 r o4w -D5$i -O03*34 -^6O12 -$3Z2 -o6P*75 -$7Z4 -s1.*57 -*72O03 -^s} -o0gq -*13i4y -^?z3 -tT9 -tZ4 -}o71 -$$+7 -Cr -$2i6R -*10z2 -^i} -o34t -o5e$2 -*83O59 -^f*21 -*50R5 -^0r +D5 $i +O03 *34 +^6 O12 +$3 Z2 +o6P *75 +$7 Z4 +s1. *57 +*72 O03 +^s } +o0g q +*13 i4y +^? z3 +t T9 +t Z4 +} o71 +$$ +7 +C r +$2 i6R +k z2 +^i } +o34 t +o5e $2 +*83 O59 +^f *21 +*50 R5 +^0 r i1, sm+ iAo -$!^y -$K$! -dO63 --0i1r -sgll -*A4O05 -O07d -*05c +$! ^y +$K $! +-0 i1r +sgl l +*A4 O05 +O07 d +*05 c o8[ -O24^m -O52O31 -Z1+6 -'6$2 -r^a -$2$k -Z2*64 -$ { -D0Z1 -k^m --7*87 -dO38 -$&u -$qLA -*67-7 -$8-5 -D0 +O24 ^m +O52 O31 +Z1 +6 +'6 $2 +r ^a +$2 $k +Z2 *64 +$ { +D0 Z1 +k ^m +-7 *87 +d O38 +$& u +$q LA +*67 -7 +$8 -5 siO -*21-3 -i3/'8 -D1L0 -*4BO63 -o9'^s -O35l -*58l -z3-3 -$8$+ --5$* -ui6 -i6hr +*21 -3 +i3/ '8 +D1 L0 +*4B O63 +o9' ^s +O35 l +*58 l +z3 -3 +$8 $+ +-5 $* +u i6 +i6h r o6D -^Hi5` -$#$7 -do0L +^H i5` +$# $7 +d o0L su0 o3% -q'B -'Aq -^J^J +q 'B +'A q +^J ^J s95 -$a*38 +$a *38 sf2 --0o6p -i6,t -O42^d -p2O09 -z5O35 -[o0n -^j$s -+0$i -p5i0; -o3uD2 -^/$/ -R1C -*31$r -[z4 -i4_O54 -}i0z -ko3- -^h^m -T0^F +-0 o6p +i6, t +O42 ^d +p2 O09 +z5 O35 +[ o0n +^j $s ++0 $i +p5 i0; +o3u D2 +^/ $/ +R1 C +*31 $r +[ z4 +i4_ O54 +} i0z +k o3- +^h ^m +T0 ^F sF1 -@ki19 -fO48 -ci7u +@k i19 +f O48 +c i7u $H R6 -+8z1 ++8 z1 sa- -Z1i7n +Z1 i7n o8, ^q -o6 Z1 -si_p1 -to6 -p2O85 -i60c --6d -Z1i7% +o6 Z1 +si_ p1 +t o6 +p2 O85 +i60 c +-6 d +Z1 i7% i8@ O46 -^+z1 -O02C -+1$j -Z3o30 -uo4Z -i7o*35 -^o@o -o0eT6 -+1i4X -$/$) -ti1S +^+ z1 +O02 C ++1 $j +Z3 o30 +u o4Z +i7o *35 +@o +o0e T6 ++1 i4X +$/ $) +t i1S o0. -^)z1 -@1l -lo2o --0+2 -*45*35 -s5qZ3 -^w^t --0+3 -'AD7 -*BAD9 +^) z1 +@1 l +l o2o +-0 +2 +*45 *35 +s5q Z3 +^w ^t +-0 +3 +'A D7 +*BA D9 sc5 -i06z5 -^c$z -*56*85 -O02o3y -s42Z1 -T0o4r -$6+7 -$3t -cO02 +i06 z5 +^c $z +*56 *85 +O02 o3y +s42 Z1 +T0 o4r +$6 +7 +$3 t +c O02 s32 o6) -Z1*35 -o5a[ -p1o0s +Z1 *35 +o5a [ +p1 o0s i7+ -tr -*89+8 +*89 +8 stj o7Y -i9dT0 -*30O01 -+7r -i9 O52 -f$m +i9d T0 +*30 [ ++7 r +i9 O52 +f $m sO= -^!z2 +^! z2 se0 -o8bZ1 -O32u +o8b Z1 +O32 u i91 -R4D0 -p4O3A +R4 D0 +p4 O3A i9_ -T1'8 -+5s36 -O02*23 -o6 D1 -Z1$0 -do0H -li6/ -'8o7a +T1 '8 ++5 s36 +O02 *23 +o6 D1 +Z1 $0 +d o0H +l i6/ +'8 o7a o8T -$rZ1 -@z$8 -+BO02 +$r Z1 +@z $8 ++B O02 sgb -DAD5 -'9q -T0T7 -o0ri0p +DA D5 +'9 q +T0 T7 +o0r i0p s5_ i9f -^_z2 -{Z5 -+5O01 -+1Z4 -o05t +^_ z2 +{ Z5 +[ +4 ++1 Z4 +o05 t o4L -O43$! -i3xd -so.*40 -DAoAa -R0Z1 -^go78 -o2Nl -o3p -*42z1 -Z1T1 -R6O06 -*84O23 -O41} +O43 $! +i3x d +so. *40 +DA oAa +R0 Z1 +^g o78 +o2N l +*42 z1 +Z1 T1 +R6 O06 +*84 O23 +O41 } o4H -O91+9 -z2*14 +O91 +9 +z2 *14 s72 -*12o2y +*12 o2y @4 -o2[L2 -$!D3 -+3$1 -o0n^n -D1k -sbm^S -R1$5 +o2[ L2 +$! D3 ++3 $1 +o0n ^n +D1 k +sbm ^S +R1 $5 o5q -^;c -T1T3 -d-5 -o2p+3 -'8u -co4N -o0wq -c$! -p2z3 -O32i3: -i6 c -$;Z2 -^Cu +^; c +T1 T3 +d -5 +o2p +3 +'8 u +c o4N +o0w q +c $! +p2 z3 +O32 i3: +i6 c +$; Z2 +^C u o9y -'A*84 +'A *84 ssb -R5Z4 -i3_*46 +R5 Z4 +i3_ *46 sq o9v -R7$x -s0rL1 -o1bo0r -O04^l -*25R5 -$9$4 -p1*80 --2$) -$Uo7# -T3'9 +R7 $x +s0r L1 +o1b o0r +O04 ^l +*25 R5 +$9 $4 +p1 *80 +-2 $) +$U o7# +T3 '9 oBz -*01^R -$3Z4 -+0O42 -li2p -c$0 +*01 ^R +$3 Z4 ++0 O42 +l i2p s42 -+5*87 -p1*63 +p1 *63 i2^ -$kO13 -$to6w -o1aD2 +$k O13 +$t o6w +o1a D2 o6M -o7u*67 -o6c'A +o7u *67 +o6c 'A o0! *06 -D3$b +D3 $b sdo -co06 -Z3OB5 -$M$W -$zo3 +c o06 +Z3 OB5 +$M $W +$z o3 o7( -i0H -^ri1t -*56*76 -o5-*40 +^r i1t +o5- *40 swk sh7 -O61$1 -L1*15 -^AD3 -O02-7 -p1'6 -Z1o9_ +O61 $1 +L1 *15 +^A D3 +O02 -7 +p1 '6 +Z1 o9_ o9b -T2^` -[o3j -sxy*40 -Z2$! -o5H$i -o3Ec -D7+A +T2 ^` +[ o3j +sxy *40 +Z2 $! +o5H $i +o3E c +D7 +A o3? -i3%C -T6o1C -O09l -$2$% -q$3 -R1-3 -$"Z2 -^bsrz -$3O61 -z1$i -$d*21 -^.z1 -i9r-A -$3d -D3^p -+6$; -i0o^N -di7u -o55+6 -ki1h -^Dz2 -D0o3n -o94l -^ O24 +i3% C +T6 o1C +O09 l +$2 $% +q $3 +R1 -3 +$" Z2 +^b srz +$3 O61 +z1 $i +$d *21 +^. z1 +i9r -A +$3 d +D3 ^p ++6 $; +i0o ^N +d i7u +o55 +6 +k i1h +^D z2 +D0 o3n +o94 l +^ O24 s9. --3$1 -ri3t -^qL0 -Z1i58 -$P$s -$j*07 -^&$2 -i0?$! -z2o1H -^ID4 +-3 $1 +r i3t +^q L0 +Z1 i58 +$P $s +$j *07 +^& $2 +i0? $! +z2 o1H +^I D4 i1v -O07k -o0Oi3B -Z2^$ -$(Z3 -Z4O42 -*40O34 -*53o15 -$o+8 -O02+8 -o11z3 -l*83 -$iO92 -^f^a -dO36 -p2*B1 +O07 k +o0O i3B +Z2 ^$ +$( Z3 +Z4 O42 +*40 O34 +*53 o15 +$o +8 +O02 +8 +o11 z3 +l *83 +$i O92 +^f ^a +p2 *B1 i1. o3A -p1O17 -o3!-2 -$*D7 -$ O41 -O21*68 -$ai02 -lo6 +p1 O17 +o3! -2 +$* D7 +$ O41 +O21 *68 +$a i02 +l o6 oAd -^b^2 -$u-6 -^1-1 -uD8 -z2i1a -^=$0 +^b ^2 +$u -6 +^1 -1 +u D8 +z2 i1a +^= $0 o5I iB_ sir -i48l -Z1+8 -o7!-5 -s1Rq -o5to3u -^2i42 -*48z1 -}^j -^5l +i48 l +Z1 +8 +o7! -5 +s1R q +o5t o3u +^2 i42 +*48 z1 +} ^j +^5 l i45 -o7)l -c$D -D3^8 +o7) l +c $D +D3 ^8 slt -^9i1b +^9 i1b spk -'8o7; -*30+3 -*67-5 -stw} -co3c -p2O6B -^zz2 -*08$* --0*21 -O91D6 -@r*62 +'8 o7; +*30 +3 +*67 -5 +stw } +c o3c +p2 O6B +^z z2 +*08 $* +-0 *21 +O91 D6 +@r *62 $Q -O41Z4 -p5Z2 -$z+5 -i3l^z -$zD4 +O41 Z4 +p5 Z2 +$z +5 +i3l ^z +$z D4 i8m -o7o'A -^c*16 -+0Z1 -c$v -p1seh -T2d +o7o 'A +^c *16 ++0 Z1 +c $v +p1 seh +T2 d i2< -$9Z2 -i66'7 -lO75 -^>o2 -O52$$ -Z3sr& -+1o25 --0O12 -$9i7. --8-6 -^qz2 -Z2o70 -$D$r -p1O25 -o5+*67 -+6u -$c-B +$9 Z2 +i66 '7 +l O75 +^> o2 +O52 $$ +Z3 sr& ++1 o25 +-0 O12 +$9 i7. +^q z2 +Z2 o70 +$D $r +o5+ *67 ++6 u +$c -B o8q -L5*21 --8z3 -i51k -Z1RA -s9lZ2 -i1uZ3 -oA3Z1 -+1l -z1o0M -p1o0l -+4+0 -RBO0B -r-A -sn6c -$1o6c -*20O32 +L5 *21 +-8 z3 +i51 k +Z1 RA +s9l Z2 +i1u Z3 +oA3 Z1 ++1 l +^M +p1 o0l ++4 +0 +RB O0B +r -A +sn6 c +$1 o6c +*20 O32 o1n ^; o8x -o0Di6r -O32c -O84c -^SO12 +o0D i6r +O32 c +O84 c +^S O12 sw, ^^ -o7zl -O32^6 -o4x+2 -Z1$! -$0O72 --3+4 -o1sz1 -lZ5 -}o4d -$fk +o7z l +O32 ^6 +o4x +2 +Z1 $! +$0 O72 +-3 +4 +o1s z1 +l Z5 +} o4d +$f k skl -p1z3 +p1 z3 o2[ -'9Z2 -*42^k -o3ul -O91R9 +'9 Z2 +*42 ^k +o3u l +O91 R9 o3K -o6mp1 -'2p2 +o6m p1 +'2 p2 srh i21 o0; -lO78 -k^w -k^n -ci5/ -tD8 -$sO83 -$Z*76 +l O78 +k ^n +c i5/ +t D8 +$s O83 +$Z *76 o5A -O51o3s -O12^o -^ai15 --9} +O51 o3s +O12 ^o +^a i15 +-9 } s9^ -+5*65 -*51{ -o77Z1 -@0s3_ --2T4 -*30*02 ++5 *65 +*51 { +o77 Z1 +@0 s3_ +-2 T4 +*30 *02 o9t -^pz1 -O13i0M -*02o3e -qO82 -^1o63 -*76o6. -'7Z1 -s1wr -p2z5 -@sl +^p z1 +O13 i0M +*02 o3e +q O82 +^1 o63 +*76 o6. +'7 Z1 +s1w r +p2 z5 +@s l s5, -$5O51 -$no2- -$aOB4 -$z*23 -{$- -O26} -i3nZ1 -^S^N -*05O35 -o8 O02 -O02q -O14+0 -Z2si9 -+0*20 -T9[ -o5 Z1 -+7o6x -Z1ss -o87Z3 -i98s18 -$aZ2 -O85l -s2*r -Z1$- -r^/ -i1Ro1J -^1$0 -Z2+8 -o0,@2 -'7o3 -T6o53 -p1o5z -p1'8 +$5 O51 +$n o2- +$a OB4 +$z *23 +{ $- +O26 } +i3n Z1 +^S ^N +*05 O35 +o8 O02 +O02 q +O14 +0 +Z2 si9 ++0 *20 +T9 [ +o5 Z1 ++7 o6x +Z1 ss +o87 Z3 +i98 s18 +$a Z2 +O85 l +s2* r +Z1 $- +r ^/ +i1J +^1 $0 +Z2 +8 +o0, @2 +'7 o3 +T6 o53 +p1 o5z +p1 '8 oAu -Z2T0 -i32*81 -i5Vi22 -o7L} -$Z*80 +Z2 T0 +i32 *81 +i5V i22 +o7L } +$Z *80 i1T -O81-9 -^q^n -*14Z2 -^s$b -^#i1k +O81 -9 +^q ^n +*14 Z2 +^s $b +^# i1k i3& -z1i00 -i4f[ -[$k -Z1+B -O05s6 -z3o8h -c^@ -Z1i81 -oB2se6 -^O^M +z1 i00 +i4f [ +[ $k +Z1 +B +O05 s6 +z3 o8h +c ^@ +Z1 i81 +oB2 se6 +^O ^M i8/ -+3^d -+4i44 -sckO21 -o79t -dO31 -[R1 -*25o0B -$z$x --0+7 -o3f*72 -o3Ic -i10i39 -$.*45 -O05'A -i4/[ -Z4O53 ++3 ^d ++4 i44 +sck O21 +o79 t +d O31 +[ R1 +*25 o0B +$z $x +-0 +7 +o3f *72 +i10 i39 +$. *45 +O05 'A +i4/ [ +Z4 O53 saf -[i1d -$g$n -di7 -^h^r -+5$- -^-^j --4$* -lO24 -^>o1j -$4k -'AO61 +[ i1d +$g $n +d i7 ++5 $- +^- ^j +-4 $* +l O24 +^> o1j +$4 k +'A O61 s._ -o88+9 -L7O52 +o88 +9 +L7 O52 ss_ so, s.+ -^iO23 -u$" -O21*30 -[*12 -R3T7 -+5*53 -cslt -ss\l +O21 *30 +R3 T7 +c slt +ss\ l o0J iA2 -Z1o5- -z1+1 -i7u-8 -s1Kc -z1$ -$Cr +Z1 o5- +z1 +1 +i7u -8 +s1K c +z1 $ +$C r i93 -$)R0 -lO12 -^f*18 --5O05 -T5} -*68-6 +$) R0 +l O12 +^f *18 +-5 O05 +T5 } +*68 -6 spl -^SO14 -D5$, -+6-7 +^S O14 +D5 $, ++6 -7 '2 -T6Z1 -+0^/ -$ti4C -*34l -uO21 -*27 -*65+3 +T6 Z1 ++0 ^/ +$t i4C +u O21 +*65 +3 siR -}o0, -C$1 -O02$k -i63Z1 -o4r*10 -*64O72 --6o5t +} o0, +C $1 +O02 $k +i63 Z1 +o4r *10 +*64 O72 +-6 o5t svb -o7g*98 -i0at -*05l -L7o6. -o4tZ3 -R4D1 +o7g *98 +i0a t +*05 l +L7 o6. +o4t Z3 +R4 D1 o6Q -$h$k -o3hp1 -{o7k -co56 -*83*47 -*67o7r -z2p1 -O24z5 -o7$s$b -$s$u -lo0c -+0O92 -p1o5f -sskp1 --2*05 +$h $k +o3h p1 +{ o7k +c o56 +*83 *47 +*67 o7r +z2 p1 +O24 z5 +o7$ s$b +$s $u +l o0c ++0 O92 +p1 o5f +ssk p1 +-2 *05 $L -$cT0 -i3c'6 -[O21 +$c T0 +i3c '6 o6T -'9i8e -+1*06 -$k+0 -$?Z1 -$7@i --0D7 -O06Z1 +'9 i8e ++1 *06 +$k +0 +$? Z1 +$7 @i +-0 D7 +O06 Z1 $R -k'6 -R1o0e -o8Ml -z3o2- -ti7l +k '6 +R1 o0e +o8M l +z3 o2- +t i7l sjl -$7D2 --2L3 -$+$5 -o0MD3 -D7$5 -O01^o +$7 D2 +-2 L3 +$+ $5 +o0M D3 +D7 $5 +O01 ^o s4@ s3c -i5xO32 +i5x O32 $| -$ ^8 -z3'A -$1*21 -*20o2. -^qp1 -Z1i8v -*63D3 -$5+5 -T4sau -}s0- -O24o2r -Z5O49 -T3o71 -D8o7t -i09^e +$ ^8 +z3 'A +$1 *21 +*20 o2. +^q p1 +Z1 i8v +*63 D3 +$5 +5 +T4 sau +} s0- +O24 o2r +Z5 O49 +T3 o71 +D8 o7t +i09 ^e i58 -p3O34 -O35$ -z1sf* -*54l -$2Z2 -Z1srz +p3 O34 +O35 $ +z1 sf* +*54 l +$2 Z2 +Z1 srz sBk o5J -$ @1 -st@*41 -i0a^K -o64l -o12L0 -^,$, -^kO13 -$.+0 -^g'6 -i17$+ -o0P*23 -$d$4 -li1: -$/c -D6$g -^mO31 -i6Ec -*74+4 -o1l*13 -^7'9 -$+*56 -+4$a -i6-*78 +$ @1 +st@ *41 +i0a ^K +o64 l +o12 L0 +^, $, +^k O13 +$. +0 +^g '6 +i17 $+ +o0P *23 +$d $4 +l i1: +$/ c +D6 $g +^m O31 +i6E c +*74 +4 +o1l *13 +^7 '9 +$+ *56 ++4 $a +i6- *78 s80 -r^I -o1B*10 +r ^I +o1B *10 i48 -o8rO71 -^G^M -*79-9 +o8r O71 +^G ^M +*79 -9 scp -^<$ +^< $ ss% -^p^m -*50O32 -$v-5 -o4 O54 -o2lO31 -^Rz1 -l-4 -O02^% -i6w$y --1C -i4l'8 +^p ^m +*50 O32 +$v -5 +o4 O54 +o2l O31 +^R z1 +l -4 +O02 ^% +i6w $y +-1 C +i4l '8 ^$ -+7i7f -{i6W ++7 i7f +{ i6W o8U -o5_*24 --7o6- -i0k$o -p1OB2 -'A+3 +o5_ *24 +-7 o6- +i0k $o +p1 OB2 +'A +3 o8L -^yL0 -T0sM -^di8d -'9o4h -Z4O84 -s2*Z2 -$0*85 -O92sA1 -+6O02 -O71$v -$1@s -sdxz2 -p4z5 -o0Lp1 -$e$n --4O12 -O32i1e -lo2t -c$[ +^y L0 +T0 sM +^d i8d +'9 o4h +Z4 O84 +s2* Z2 +$0 *85 +O92 sA1 ++6 O02 +O71 $v +$1 @s +sdx z2 +p4 z5 +o0L p1 +$e $n +-4 O12 +O32 i1e +l o2t +c $[ s03 -o3g-5 -O28q -^iz1 -O12^3 -o4_o7s +o3g -5 +O28 q +^i z1 +O12 ^3 +o4_ o7s ^/ s91 -o0R+4 -^gO31 -i4hD0 -o79c -c$N -$(Z1 -$&C +o0R +4 +^g O31 +i4h D0 +o79 c +c $N +$( Z1 +$& C slj -^lc -z1O54 -i4&O03 -i0h^e +^l c +z1 O54 +i4& O03 +i0h ^e i6/ -s1#'8 -T2Z1 -D3-6 -*18o5g -o1s+0 -^i^m -O81-6 +s1# '8 +T2 Z1 +D3 -6 +*18 o5g +o1s +0 +^i ^m +O81 -6 oB+ -D3-1 -p2O93 -sdLu +D3 -1 +p2 O93 +sdL u oBu -i8MO53 -o3/f -+6Z2 -sA O53 -O12$. -$0Z4 -+7o6_ -^zL1 -i4eZ3 -o6a@9 -$e$l -O45[ -p2O82 +i8M O53 +o3/ f ++6 Z2 +sA O53 +O12 $. +$0 Z4 ++7 o6_ +i4e Z3 +o6a @9 +$e $l +O45 [ +p2 O82 s7c -cTA -$mt -D6o60 -D1^s -o0Md -L3} -^h$m -do5n -$+$# -D4D7 -o3w*32 +c TA +$m t +D6 o60 +D1 ^s +o0M d +L3 } +^h $m +d o5n +$+ $# +D4 D7 +o3w *32 s, -^6t -uR0 -^1'9 -$P$E -{'9 -O32+2 +^6 t +u R0 +^1 '9 +$P $E +{ '9 +O32 +2 i56 -Z3-8 -^Wz1 -z3@k -^;^s -p1sbp -i2hl -*05-1 -^PO31 -^zi4_ -'8$Q -$,c -$ O0B -i40^k -'7Z3 -z2u -^Iu +Z3 -8 +^W z1 +z3 @k +^; ^s +p1 sbp +i2h l +*05 -1 +^P O31 +^z i4_ +'8 $Q +$, c +$ O0B +i40 ^k +'7 Z3 +z2 u +^I u s*< -c$3 -s0aRA -$ki8o -i64 +s0a RA +$k i8o o1S --7o14 -ko4 -i0,r -$-f -^{R0 -z2l -o5_@p -}$o -o13k +-7 o14 +k o4 +r $, +$- f +^= +z2 l +o5_ @p +} $o +o13 k $( R7 -$,O02 -*10c -Z3O96 -Z1{ -p1*98 -r[ -O42slL +$, O02 +Z3 O96 +Z1 { +p1 *98 +r [ +O42 slL s3q -'9-2 -o1Oc -i42sky -L7o07 +'9 -2 +o1O c +i42 sky +L7 o07 ssa -i77$3 +i77 $3 sek -^6z2 +^6 z2 o35 -s8M*02 -$7C -$a$p -o2 ^= -O41-0 -D2R1 -[$A -*23o3y +s8M *02 +$7 C +$a $p +o2 ^= +O41 -0 +D2 R1 +[ $A +*23 o3y sbr -*87c +*87 c o3! -*89-7 +*98 -7 i3x -s4x^E -cR6 +s4x ^E +c R6 o2; i9b -$!C +$! C i1m -i1c{ -$S$V -O02o2 -s9 k +i1c { +$S $V +O02 o2 +s9 k s0| -o8k$e +o8k $e se* --6o7r -+0+0 -*76i7u -R4O04 -$!Z4 -i2:t -*05O02 -do0T -dO41 -L0o1. -D4p1 -o5iD4 -^t'7 -D3+0 -L0+1 -$u$8 --1$; -Z1T5 -z2+6 -*98-7 -'7$s --1-1 -*76+8 -T1T7 -oA3'B -^3^b --6Z1 -'8^t -o68D8 -Z1D5 -^CT4 -*16o27 -t[ -o0N +-6 o7r ++0 +0 +*76 i7u +R4 O04 +$! Z4 +i2: t +*05 O02 +d o0T +d O41 +L0 o1. +D4 p1 +o5i D4 +^t '7 +L0 +1 +$u $8 +-1 $; +Z1 T5 +z2 +6 +'7 $s +-1 -1 +*76 +8 +T1 T7 +oA3 'B +^3 ^b +-6 Z1 +'8 ^t +o68 D8 +Z1 D5 +^C T4 +*16 o27 +t [ i2@ -z3-2 -[Z5 -cs1, -*1A'A -{Z2 +z3 -2 +[ Z5 +c s1, +*1A 'A +{ Z2 o7U -^7} -+4Z1 -@aoB9 -D9-7 +^7 } ++4 Z1 +@a oB9 +D9 -7 shy --8c -R1o07 --0{ --6i7d +-8 c +R1 o07 +-0 { +-6 i7d ${ -^1*50 +^1 *50 so# -$s^1 -D6LB -ci2/ -$_@0 -$r-8 -k^j -+1{ -Z4$4 -[D1 +$s ^1 +D6 LB +c i2/ +$_ @0 +$r -8 +k ^j ++1 { +Z4 $4 +[ D1 ssf -i4n^k -OB2LB -OB2iBb -^ti5t -i8z'9 -O21^3 -O31$y -^di1s -O31r -*43$a -o1@-8 +i4n ^k +OB2 LB +OB2 iBb +^t i5t +i8z '9 +O21 ^3 +O31 $y +^d i1s +O31 r +*43 $a +o1@ -8 s71 -O62^3 -i37c -$ *03 -O32*30 -i1a*40 -o8a+5 +O62 ^3 +i37 c +$ *03 +O32 *30 +i1a *40 +o8a +5 sBF -o0^z1 -O21^L -^c} -*89} +o0^ z1 +O21 ^L +^c } +*89 } iAt --0i0c -p1o0w --4'6 +p1 o0w +-4 '6 i6A -*23*05 +*23 *05 ^T --7i4x -+4i4z -O12s2z -O17*20 -O51*75 -o62l -^Yo5d -cD7 -O51$6 -O17l -{scs +-7 i4x ++4 i4z +O12 s2z +O17 *20 +o62 l +^Y o5d +c D7 +O51 $6 +O17 l +{ scs sB3 -'4Z5 -z1i14 -^Lz1 -^-z4 -$9Z5 +'4 Z5 +z1 i14 +^L z1 +^- z4 +$9 Z5 sb- -*61^ -*36c -O41$G +*61 ^ +*36 c +O41 $G skh -$#$g +$# $g s@. -^Sz1 -^@*13 -dD6 -Z1@a -sr *65 -'9o6m -$9t -Z1-5 -csd1 -*35*54 +^S z1 +^@ *13 +Z1 @a +sr *65 +'9 o6m +$9 t +Z1 -5 +c sd1 +*35 *54 o2P -^a^n -O32k -D5o1a -i35q -O13$1 -[i31 -*46O05 -*47D4 -su[D3 -o6Oc -^7o2n -d-A -}^4 -$iq -z5z4 -$hl -i21^L +^a ^n +O32 k +D5 o1a +i35 q +O13 $1 +[ i31 +*46 O05 +*47 D4 +su[ D3 +o6O c +^7 o2n +d -A +} ^4 +$i q +z5 z4 +$h l +i21 ^L scw -+1i2g -se1D5 -^YT2 -$3Z3 -Z3i1o -lo63 -$2*52 -i1P{ -^,c -^s'A -$d$ -$eo9l -us94 -p1O13 ++1 i2g +se1 D5 +^Y T2 +$3 Z3 +Z3 i1o +l o63 +$2 *52 +i1P { +^, c +^s 'A +$d $ +$e o9l +u s94 +p1 O13 i7D -O82'A -$-C -$ s9a -D6i66 -$#r +O82 'A +$- C +$ s9a +D6 i66 +$# r ss, -O61o6 -^O+6 -Z1o6 -sa!r -i6mZ1 --0^9 -$M$L -do5w -'4sc -z5O63 -*42R6 +O61 o6 +^O +6 +Z1 o6 +sa! r +i6m Z1 +-0 ^9 +$M $L +d o5w +'4 sc +z5 O63 +*42 R6 i15 -$ ^: --8l -R8R8 -+0z3 -$x{ +$ ^: +-8 l +R8 R8 ++0 z3 +$x { o32 -i2y*62 -[i5 -OB2$7 -*A6O26 -^j+1 --2R1 -O06l -o0fD1 -p1O96 -p1o5d -si l -c'5 -R0l -$,$0 -p3O7B -$!O53 +i2y *62 +[ i5 +OB2 $7 +*A6 O26 +^j +1 +-2 R1 +O06 l +o0f D1 +p1 O96 +p1 o5d +si l +c '5 +R0 l +$, $0 +p3 O7B +$! O53 sPN -o5eO61 -ci0M -i3_+5 -O14L0 -t-0 +o5e O61 +i3_ +5 +O14 L0 +t -0 i4F oBo --5$S -*67i65 -di6x -$nZ3 -rO51 -'7o6! -p1$i -'6z4 -Z3o14 -o77*A7 -lo7e -D7Z2 --3i33 -o4io6! -i3aO02 -O03$6 -p1*67 -$*T5 -{+7 -i01'B -lo68 -*51+1 -i4aO52 -L0O51 -Z1oB0 -R7o6 -*14o1X -$x*31 -$wc -^_$6 -{o46 -o1zq -O0Bl -$$-7 -Z2o9m -to1y --6O84 -i3ei2s +-5 $S +*67 i65 +d i6x +$n Z3 +r O51 +'7 o6! +p1 $i +'6 z4 +Z3 o14 +o77 *A7 +l o7e +D7 Z2 +-3 i33 +o4i o6! +i3a O02 +O03 $6 +p1 *67 +$* T5 +{ +7 +i01 'B +l o68 +*51 +1 +i4a O52 +L0 O51 +Z1 oB0 +R7 o6 +*14 o1X +$x *31 +$w c +^_ $6 +{ o46 +o1z q +O0B l +$$ -7 +Z2 o9m +t o1y +-6 O84 +i3e i2s i83 -$s$ -o0Ik -O51i44 -^-D3 -*15$p -siB$V -$/t -*52o5B -so@O05 -O41^i -i0v*07 -D5o2_ -*71O01 -o85*75 -lO58 -o3_D4 +$s $ +o0I k +O51 i44 +^- D3 +*15 $p +siB $V +$/ t +*52 o5B +so@ O05 +O41 ^i +i0v *07 +D5 o2_ +o85 *75 +l O58 +o3_ D4 ssn -^b-3 -O43*05 -ci6R -'5*13 -o04L1 -^4sb1 -i5u*68 -$c$b -p1O8B -p1o5c -ci6$ -*20*03 -^:s( -*26^f -+5T4 -*9A@5 -ti11 -R5i5, -i0_l -^zO24 -+6$L -u+4 -*B8*A9 -i1uOA1 -dsrw -'9i8K -$7Z5 -lOA3 -*21^j -${L4 -$Fo1g -$dOA6 -p3DA -i7.*79 -do8o -O05$0 -s7W*74 -L0O31 -}o1a -$DZ1 -*53smb -ti62 -o8|Z2 -o9r$i -T2O02 +^b -3 +O43 *05 +c i6R +'5 *13 +o04 L1 +^4 sb1 +i5u *68 +$c $b +p1 O8B +p1 o5c +c i6$ +*20 *03 +^: s( +*26 ^f ++5 T4 +*9A @5 +t i11 +R5 i5, +i0_ l +^z O24 ++6 $L +u +4 +*B8 *A9 +i1u OA1 +d srw +'9 i8K +$7 Z5 +l OA3 +*21 ^j +${ L4 +$F o1g +$d OA6 +p3 DA +i7. *79 +d o8o +O05 $0 +s7W *74 +L0 O31 +} o1a +$D Z1 +*53 smb +t i62 +o8| Z2 +o9r $i +T2 O02 st# -shD^F -i60Z1 -z1o2N -$0i5k -i5_o9o -@a-3 -^d$ -kD2 -sc$+2 -'6$0 --8o3b -D2o0l -O01O93 -z5*21 -z1^R -O83Z1 -o34l -slho10 -o3az5 -o6jD8 -*10oA9 -*20c -s16l -L2i3l -i0k+4 +shD ^F +i60 Z1 +z1 o2N +$0 i5k +i5_ o9o +@a -3 +^d $ +k D2 +sc$ +2 +'6 $0 +-8 o3b +D2 o0l +O01 O93 +z5 *21 +z1 ^R +O83 Z1 +o34 l +slh o10 +o3a z5 +o6j D8 +*10 oA9 +*20 c +s16 l +L2 i3l +^k +4 sb, -*12o1j -Z2o4- -Z3o9r +*12 o1j +Z2 o4- +Z3 o9r i1/ -$iO12 -z1^p --8*8A -qoA2 -[o2q -o6-Z2 -+0s@y -$mi7g -kL2 -'B$e +$i O12 +z1 ^p +-8 *8A +q oA2 +[ o2q +o6- Z2 ++0 s@y +$m i7g +k L2 +'B $e shr -$ $2 -$hL8 -$f$j -^psx- -'5o0d -^1-9 -O04*78 -sIEc -^m-7 -*82O06 -o0g+6 -^2D4 -i59*02 -o7&-3 -*62i0z -Z4O46 -i5*$* -p2D1 -$ -0 -*34o3r -R4Z3 -$oO15 -T0o2S -$5sk1 -{+9 --5$3 --2o3x --1$8 -*56-6 -*7AO64 -^t*34 -}*91 -'A$] -*57*93 -^[O15 -r^k -Z5@a -li4; -^6*07 --9*98 +$ $2 +$h L8 +$f $j +^p sx- +'5 o0d +^1 -9 +O04 *78 +sIE c +^m -7 +*82 O06 +o0g +6 +^2 D4 +i59 *02 +o7& -3 +*62 i0z +Z4 O46 +i5* $* +p2 D1 +$ -0 +*34 o3r +R4 Z3 +$o O15 +T0 o2S +$5 sk1 +{ +9 +-5 $3 +-2 o3x +-1 $8 +*56 -6 +*7A O64 +^t *34 +} *91 +'A $] +*57 *93 +^[ O15 +r ^k +Z5 @a +l i4; +^6 *07 +-9 *98 i16 -o4xp1 -$y^i -$$+6 -D4sg -*06s7A -li2% -$aO73 -*10o8# -i2f$# -[$9 -O64z3 -'9i45 -$5D8 --9$% -^bo8* -^tO24 -i4Pc -o7,c -o7`L7 -sS/c -$0o0G -*09'6 -o91*18 -sPa^k -$^@j -sdf+8 +o4x p1 +$y ^i +$$ +6 +D4 sg +*06 s7A +l i2% +$a O73 +k o8# +i2f $# +[ $9 +O64 z3 +'9 i45 +$5 D8 +-9 $% +^b o8* +^t O24 +i4P c +o7, c +o7` L7 +sS/ c +$0 o0G +*09 '6 +o91 *18 +sPa ^k +$^ @j +sdf +8 s+7 -i0e*21 +i0e *21 s58 sjB -sfa'A -T7$0 -s7Qq -o59Z2 -T7$7 -o4t*45 -+4o0m -i21i6q -i6h'A --3@8 -i8t-1 -'4$o -O28^z -Z1o54 -+5O04 -+9D3 -o7il --4^j -sbs^j -ci4- -o6:@9 -L7i6d -to77 -'6D2 -^h} -+8*9A -*63+1 -ko65 -o72$e -qi0y -O14i1G -D2^f -z4O5A -o6sd -O65$/ -^P^4 -d*57 -O82+1 -sCs^! -'9i1t --2O52 -ds2q -+6o77 -O57$ -*B3*B9 -i6p*28 +sfa 'A +T7 $0 +s7Q q +o59 Z2 +T7 $7 +o4t *45 ++4 o0m +i21 i6q +i6h 'A +-3 @8 +i8t -1 +'4 $o +O28 ^z +Z1 o54 ++5 O04 ++9 D3 +o7i l +-4 ^j +sbs ^j +c i4- +o6: @9 +L7 i6d +t o77 +'6 D2 +^h } ++8 *9A +*63 +1 +k o65 +o72 $e +q i0y +O14 i1G +D2 ^f +z4 O5A +o6s d +O65 $/ +^P ^4 +p1 *57 +O82 +1 +sCs ^! +'9 i1t +-2 O52 +d s2q ++6 o77 +O57 $ +*B3 *B9 +i6p *28 iBi -^,z1 -O14Z4 -'7+6 -D5*87 -^*$- -{*34 -i8Zc -Z2-3 -i85O53 -D7o7. -*60$3 -T3$" -i8uu -i4.t -sf6^c -iBrRA -$mO43 -k^8 -i1xz1 -+7o54 +^, z1 +O14 Z4 +'7 +6 +D5 *87 +^* $- +{ *34 +i8Z c +Z2 -3 +i85 O53 +D7 o7. +*60 $3 +T3 $" +i8u u +i4. t +sf6 ^c +iBr RA +$m O43 +k ^8 +i1x z1 ++7 o54 spc -s- DA --8-2 +s- DA +-8 -2 s8z -slyO41 +sly O41 sC o9B -*04+4 -[i45 -*64o66 -i4ei52 -z1c -+4+1 -i7eR9 -O64$9 -$%$! -$0Z5 -D4o83 -$ p1 -ci61 -{i4J -lo0z -D2o6y -s2k$h -p1O23 -i05^! -O62p1 -D1*31 -^N$L -O01o4i +*04 +4 +[ i45 +*64 o66 +i4e i52 +z1 c ++4 +1 +i7e R9 +O64 $9 +$% $! +$0 Z5 +D4 o83 +$ p1 +c i61 +{ i4J +l o0z +D2 o6y +s2k $h +p1 O23 +i05 ^! +O62 p1 +D1 *31 +^N $L +O01 o4i svt -$9Z3 -o4Fz3 -o1mo0e -+5O61 -O41f +$9 Z3 +o4F z3 +o1m o0e ++5 O61 +O41 f ssw sr$ -se ^Z -D4-B -Z4$9 -i0^z2 -*87sti -o2"u -+8$@ -O81$m +se ^Z +D4 -B +Z4 $9 +i0^ z2 +*87 sti +o2" u ++8 $@ +O81 $m sjx -+6@d -R1+0 -O42i4e ++6 @d +R1 +0 +O42 i4e s1! -o8Z*67 -o3d^z -O91Z1 -r*30 -z1'B -co90 -o7sshe -+8o7b -shRZ1 -^rD5 -Z2i7u +o8Z *67 +o3d ^z +O91 Z1 +r *30 +z1 'B +c o90 +o7s she ++8 o7b +shR Z1 +^r D5 +Z2 i7u si2 -snyp1 -*71O03 -$3L0 -^dL1 -O56O01 -sph*91 -sDIO52 -z2+8 -i48L2 -co7+ -^g^h -^1s8x -$nk -'A$7 -*79'A -i3^^x -lp3 -ri7u -r^5 -o2j*60 -f$8 -*30-4 -*51O35 -O62^l --7o6b --8*76 -^,r -O05o1 +sny p1 +*71 O03 +$3 L0 +^d L1 +O56 O01 +sph *91 +sDI O52 +z2 +8 +i48 L2 +c o7+ +^g ^h +^1 s8x +$n k +'A $7 +*79 'A +i3^ ^x +l p3 +r i7u +r ^5 +o2j *60 +f $8 +*30 -4 +*51 O35 +O62 ^l +-7 o6b +-8 *76 +O05 o1 i8* -$b$. -s12oA0 -*97siu +$b $. +s12 oA0 +*97 siu i9r -$MZ2 -oAcO07 -^LO19 -i5fO13 -$1i9 -}i0A -o15O24 -O82*86 -soIc -z3@j -o2n-4 -o0eo3l -*25+2 -o5 +6 -O36D1 -o3iO02 -O31Z3 -T0$D -^AoAa -D0i2j -O89l -i3gO43 -$f^f -D8^\ -$0O15 +$M Z2 +oAc O07 +^L O19 +i5f O13 +$1 i9 +} i0A +o15 O24 +O82 *86 +soI c +z3 @j +o2n -4 +o0e o3l +*25 +2 +o5 +6 +O36 D1 +o3i O02 +O31 Z3 +T0 $D +^A oAa +D0 i2j +O89 l +i3g O43 +$f ^f +D8 ^\ +$0 O15 s8g -+8$m ++8 $m o1q -T8O02 -*20o5X -^"R6 -z4$e -o8zD7 -+1O28 -l*40 -'8i1. +T8 O02 +*20 o5X +^" R6 +z4 $e +o8z D7 ++1 O28 +l *40 +'8 i1. sgl -O41'B -sbku -L1i27 -'5o3k -i6d-5 -^gO23 +O41 'B +sbk u +L1 i27 +'5 o3k +i6d -5 +^g O23 o8- -$c$t -cO23 -+3^2 -Z2o73 +$c $t +c O23 ++3 ^2 +Z2 o73 sDL -i5ri3= +i5r i3= i4w -T0$6 -srYu -O81sz -o7k*63 -o9eO72 -dseg -z2$k -i55r -*53O13 -i4i*64 +T0 $6 +srY u +O81 sz +o7k *63 +o9e O72 +d seg +z2 $k +i55 r +*53 O13 +i4i *64 s0g -k$p -o5fZ3 -o4jO31 -oAp'B -*62o2s -Z4o93 -o5rz4 -*36'6 -$vD3 -*74sds -^1Z3 -Z3^3 -$a*16 -to7S -$_$? -*13s73 -T2i0I -Z3o5E -$M$* -o1s*84 -z1o6w -*69O92 -i6fl -sdj*29 -$b*34 -o5bi62 -i0u^c -s- D5 -o6SZ2 -*60-8 +k $p +o5f Z3 +o4j O31 +oAp 'B +*62 o2s +Z4 o93 +o5r z4 +*36 '6 +$v D3 +*74 sds +^1 Z3 +Z3 ^3 +$a *16 +t o7S +$_ $? +*13 s73 +T2 i0I +Z3 o5E +$M $* +o1s *84 +z1 o6w +*69 O92 +i6f l +sdj *29 +$b *34 +o5b i62 +i0u ^c +s- D5 +o6S Z2 +*60 -8 o47 -$qz2 -OB2s24 -z1i5/ -o6pT1 -o7_T0 -@iZ5 -p2Z1 -$7*98 -$mO32 -s#,} -li3a -z2z4 +$q z2 +OB2 s24 +z1 i5/ +o6p T1 +o7_ T0 +@i Z5 +p2 Z1 +$7 *98 +$m O32 +s#, } +l i3a +z2 z4 iAb -*80'6 -*98*85 --8o9l -O34^p -z3sT7 -l@9 -O81$f -*A9O52 -$k^D -p1*57 +*80 '6 +*98 *85 +-8 o9l +O34 ^p +z3 sT7 +l @9 +O81 $f +*A9 O52 +$k ^D i3R -*78o4! -O52*78 -D3$X -to4T -s18*85 -*12$! -O6B[ -i4 [ -sa7o0b -p5z1 -$ *84 -*20o0l -o05z1 -z4*58 -OB2iB9 -$)o64 -o0M*13 -D2-6 -o51l -O7A[ -$n$b +*78 o4! +D3 $X +t o4T +s18 *85 +*12 $! +O6B [ +i4 [ +sa7 o0b +p5 z1 +$ *84 +*20 o0l +o05 z1 +z4 *58 +OB2 iB9 +$) o64 +o0M *13 +D2 -6 +o51 l +O7A [ +$n $b sZs -*97o93 -^XO31 -sbpi7t -^Ql -$r$F -t-8 -O36$ -OBA^4 -o6p+9 -*98@9 -o5aD6 -O71*56 -^_O13 -Cs4b -p1O53 -*56r -Z2o0_ -i7fc +*97 o93 +^X O31 +sbp i7t +^Q l +$r $F +t -8 +O36 $ +OBA ^4 +o6p +9 +*98 @9 +o5a D6 +O71 *56 +^_ O13 +C s4b +*56 r +Z2 o0_ +i7f c sDF -o56o8s -L5T4 -i1h^d -O15$t -iAeO72 -D7$0 -$b^a -*04i4t -p1o7h -{^k +o56 o8s +L5 T4 +i1h ^d +O15 $t +iAe O72 +D7 $0 +$b ^a +*04 i4t +p1 o7h +{ ^k sph -o8_*87 +o8_ *87 sa9 -O64$0 -T3} -$4t -$3*74 -O42l -O93O41 -+0Z2 -O64l -$L*16 -^c*46 -i2g'B -O42'B -s05+8 -L7t -*35O12 -TBTA -O09L0 -*41O34 -*81o3@ -$o@1 -O42i4= -kO23 -*86o8s -c^( -k-3 -'4^8 -{o4_ +O64 $0 +T3 } +$4 t +$3 *74 +O93 O41 ++0 Z2 +O64 l +$L *16 +^c *46 +i2g 'B +O42 'B +s05 +8 +L7 t +*35 O12 +TB TA +O09 L0 +*41 O34 +*81 o3@ +$o @1 +O42 i4= +k O23 +*86 o8s +c ^( +'4 ^8 +{ o4_ s0B -o3i*53 -*35^# -'B+0 -{-0 +o3i *53 +*35 ^# +'B +0 +{ -0 syo -{R3 -i4]l -Z1o59 -^Fi0B +{ R3 +i4] l +Z1 o59 +^F i0B snh -ds5- -OB3O04 -*32^A --4$! -o6n$y -^Po5d -s* '3 -O16r -Z3^J -^W*14 -Z2i7d +d s5- +OB3 O04 +*32 ^A +-4 $! +o6n $y +^P o5d +s* '3 +O16 r +Z3 ^J +^W *14 +Z2 i7d o2) -Z1^B +Z1 ^B ^: -k$; -@y{ -i6Si7h -o6n+3 -p3O01 -o3lD0 -^hO71 -*86i6; -smZ$e -O62+5 -p1*72 -}O14 -^.$? -$KZ1 -O34*13 -T5i0p -O05*41 -O71'B -DA$1 -co1V -*98+0 -L8s5s -L8O17 -@0l -ti2F -O93-7 -O23i2i +k $; +@y { +i6S i7h +o6n +3 +p3 D0 +o3l D0 +^h O71 +*86 i6; +smZ $e +O62 +5 +p1 *72 +} O14 +^. $? +$K Z1 +O34 *13 +T5 i0p +O05 *41 +O71 'B +DA $1 +c o1V +*98 +0 +L8 s5s +L8 O17 +@0 l +t i2F +O93 -7 +O23 i2i i8U -*23O03 -$oz4 -o0tq -o4D*78 -z3sis -*32*45 -O13R2 +*23 O03 +$o z4 +o0t q +o4D *78 +z3 sis +*32 *45 +O13 R2 smo -L7O07 -^7-3 -d$g -$6s19 -{i6L -i4&o7b -^si1j -@4{ -*68o6r -s8c*01 -O53o2e -o2Wc -$xO64 -Z1$c +L7 O07 +^7 -3 +d $g +$6 s19 +{ i6L +i4& o7b +^s i1j +@4 { +*68 o6r +s8c *01 +O53 o2e +o2W c +$x O64 +Z1 $c o2A -O15*15 -O81$1 +O15 *15 +O81 $1 i4N -i1&r -z2o1s --1l -O04'3 -*56o5j -ksgd -Co1a -o7UR3 -D3R3 +i1& r +z2 o1s +-1 l +O04 '3 +*56 o5j +k sgd +C o1a +o7U R3 +D3 R3 s2M -o90*96 -O85O43 +o90 *96 +O85 O43 sd5 -f*87 -*A1[ -*31o32 -o5eZ1 -'5f -l} +f *87 +*A1 [ +*31 o32 +o5e Z1 +'5 f +l } i2I -'8+0 -i1hp1 +'8 +0 +i1h p1 o4> -tR1 -@oi1s -o0M*43 --2i3l -$fo1e -o6u-5 +t R1 +@o i1s +o0M *43 +-2 i3l +$f o1e +o6u -5 s0\ -i9u[ -}soi +i9u [ +} soi o5G -lOBA -Z2o1n -fO18 -'7Z5 -o4Od -o36 -[$^ -@6*53 -o0Wskt +l OBA +Z2 o1n +f O18 +'7 Z5 +o4O d +[ $^ +@6 *53 +o0W skt svz -rz2 +r z2 s79 -$KD3 -o0zO13 --7o8! -$)^. -*34O51 -$2o62 --1*91 -}$? +$K D3 +o0z O13 +-7 o8! +$) ^. +*34 O51 +$2 o62 +-1 *91 +} $? s-/ -$3$% +$3 $% sAT -Z2$e -z2s4x -fO03 -'7O51 -OB2$0 -s3qp1 -*02*7A -z1o3_ -o9oOA3 -p1i7o -O24^g -TAs09 +Z2 $e +z2 s4x +f O03 +'7 O51 +OB2 $0 +s3q p1 +*02 *7A +z1 o3_ +o9o OA3 +p1 i7o +O24 ^g +TA s09 s0^ -L8O35 -^['8 -*35+1 -sdc-0 -ts0e -$%$j -*35R4 -$3@o -o0Q$w -o4 $5 -'3p2 -'2o0- -z1^L -*03i3e +L8 O35 +^[ '8 +*35 +1 +sdc -0 +t s0e +$% $j +*35 R4 +$3 @o +o0Q $w +o4 $5 +'3 p2 +'2 o0- +z1 ^L +*03 i3e o4) -*45z1 -p1i49 -$vL5 -sGtO41 -$ -o3Yc -ki12 +i0R ^W +u sX> +o3Y c +k i12 s.z -$1OB2 -$Kc -p1i4m -p1s1+ -s8qZ1 -*21i50 -Z1sua -Z2s85 --B$3 --1$3 -+2o0z -LB@5 +$1 OB2 +p1 i4m +p1 s1+ +s8q Z1 +*21 i50 +Z1 sua +Z2 s85 +-B $3 +-1 $3 ++2 o0z +LB @5 o7T -o66$/ +o66 $/ *73 -o7#u -i68Z2 -T9*41 -$=T8 -uo95 -O51i6r +o7# u +i68 Z2 +T9 *41 +$= T8 +u o95 +O51 i6r i6" -'8i6P -*46o54 -$HD3 -i4%u -$sOA1 -$8-7 -*05i1y -uO74 -$C-1 +'8 i6P +*46 o54 +$H D3 +i4% u +$s OA1 +$8 -7 +*05 i1y +u O74 +$C -1 o1_ -+B*9A -^r*67 -s,E$B -i4p*57 -i6(l -O61i2@ -$siAi -O25i3z -'6$l -$xO93 -$c^t -'Bo8f -o3xO42 -+5*60 -R3k -$o$x -i50$9 -*01o6! -o9uc -OB3LB -uo78 -i2h$3 -$t*13 -$/Z1 -o4 i4o -D2O45 -O96l -*32D7 -o1fp2 --3+1 -Z1i93 -*20^1 -^w$w -i0MO71 -O03^@ -*50O23 -O36z3 -^L$8 --5o62 -D3l -'B$I -*63ssN -O72+1 -z1+3 --1*12 -*14i2- -o2 sy? ++B *9A +^r *67 +s,E $B +i4p *57 +i6( l +O61 i2@ +$s iAi +O25 i3z +'6 $l +$x O93 +$c ^t +'B o8f +o3x O42 ++5 *60 +R3 k +$o $x +i50 $9 +o6! k +o9u c +OB3 LB +u o78 +i2h $3 +$t *13 +$/ Z1 +o4 i4o +D2 O45 +O96 l +*32 D7 +o1f p2 +-3 +1 +Z1 i93 +*20 ^1 +^w $w +i0M O71 +O03 ^@ +*50 O23 +O36 z3 +^L $8 +-5 o62 +D3 l +'B $I +*63 ssN +O72 +1 +z1 +3 +-1 *12 +*14 i2- +o2 sy? o4S -^6$, -sx8*70 -+2*30 -@wd -i7r*8A -o2cO41 -^CO32 -+9@s -O35+0 +^6 $, +sx8 *70 ++2 *30 +@w d +i7r *8A +o2c O41 +^C O32 ++9 @s +O35 +0 oAv -^#^@ +^# ^@ sp= --8o4b -$8O42 -D9+7 -L0^f +-8 o4b +$8 O42 +D9 +7 +L0 ^f sij -o9dO63 -O35$n -^gu -O03-0 -^7$+ -iA--B --6$z -*24R3 -p1O5A -*21i61 +o9d O63 +O35 $n +^g u +O03 -0 +^7 $+ +iA- -B +-6 $z +*24 R3 +p1 O5A +*21 i61 o4/ -csL, -$gi0r -{i65 -t+4 -O29d -^!T4 +c sL, +$g i0r +{ i65 +t +4 +O29 d sx_ -+0O12 -^,^- -o51O13 -O31i67 -O42$% -siaOA1 -i65R5 ++0 O12 +^, ^- +o51 O13 +O31 i67 +O42 $% +sia OA1 +i65 R5 s%$ -cstC -+1o2b -o2ek -L2Z2 -O56Z1 +c stC ++1 o2b +o2e k +L2 Z2 +O56 Z1 i5I -D5i4B -^+^a +D5 i4B +^+ ^a se- -+5*54 -O21$g -+7i4/ -^Ki71 -*36*17 -$xD5 -Z3+5 -o4.Z3 -O63^2 -li0S -O62O02 -z1i1s -ksej ++5 *54 +O21 $g ++7 i4/ +^K i71 +*36 *17 +$x D5 +Z3 +5 +o4. Z3 +O63 ^2 +l i0S +O62 O02 +k sej s-K -$S{ -o1L[ +$S { +o1L [ sx, -o2Ju -*32i6_ -o2b*32 -ri6, -R0O24 -*30sdD -*62o6. -^mO24 -$uZ1 -s1^Z1 -o4 *B0 -$e+B -'9$' -$!$, -O04'8 +o2J u +*32 i6_ +o2b *32 +r i6, +R0 O24 +*30 sdD +*62 o6. +^m O24 +$u Z1 +s1^ Z1 +o4 *B0 +$e +B +'9 $' +$! $, +O04 '8 o3H -$RO23 -OA2*97 -o32i3k -o9 Z1 -spck -cDA -f*9B -{T0 -+B@7 -Z2sQv -^Bs52 -Z2o8_ -o6/$5 -z1$, -o2tZ3 -i99*86 -'8d -ssuz2 -*52$3 +$R O23 +OA2 *97 +o32 i3k +o9 Z1 +spc k +c DA +f *9B +{ T0 ++B @7 +Z2 sQv +^B s52 +Z2 o8_ +o6/ $5 +z1 $, +o2t Z3 +i99 *86 +'8 d +ssu z2 +*52 $3 o2E -O02z5 -D2-4 -*15*23 -^*R1 -s6Wc -D9L7 +O02 z5 +*15 *23 +^* R1 +s6W c +D9 L7 sai -^nstk -'3d +^n stk R8 -^i^g --1z3 -Z5O05 -@1o8! -D1Z4 -Z4O02 -$st -o1ai2s -oAuLA -$_$t --1s9s -fO74 -s0^Z1 -Z1$7 -*46^P -O51i3q -o4oc -$?L8 -+2*02 -+A*8A -o70$9 -$E+4 -*04l -'7^@ -i5wO72 -$5[ -*27o2n -$f$1 -*90O26 -oAsO42 --6L6 -o6^Z1 -to8% --8o66 -}$P -*76o6a +^i ^g +-1 z3 +Z5 O05 +@1 o8! +D1 Z4 +Z4 O02 +$s t +o1a i2s +oAu LA +$_ $t +-1 s9s +f O74 +s0^ Z1 +Z1 $7 +*46 ^P +O51 i3q +o4o c +$? L8 ++2 *02 ++A *8A +o70 $9 +$E +4 +'7 ^@ +i5w O72 +$5 [ +*27 o2n +$f $1 +*90 O26 +oAs O42 +-6 L6 +o6^ Z1 +t o8% +-8 o66 +} $P +*76 o6a s1l --9-4 +-9 -4 i7j -*84o84 -c} -swbZ1 -@Do7} -$gO52 -^e+3 -$?O45 -^_k -$O*86 -*02+9 -rO15 +*84 o84 +c } +swb Z1 +@D o7} +$g O52 +^e +3 +$? O45 +$O *86 +*02 +9 +r O15 svp -i4r*49 -iALoBP -O04^q +i4r *49 +iAL oBP +O04 ^q i3H -i3!*93 -o77*10 +i3! *93 +o77 k sd` sjH -o0gp2 -$A$Y -o81scw -Z4o6a -u*56 -^2o42 -ssbk -^r+A -o3/O45 -i58O23 -'5z4 -O32o2x -oAOc -O43*43 -p1sl7 -i97$5 -^dO13 -c^8 -*78O53 -*03o0h -o2m^d -^M$D -lo4b -$8*A5 -o81*63 -o3oi3k -$1-7 +o0g p2 +$A $Y +o81 scw +Z4 o6a +u *56 +^2 o42 +ssb k +^r +A +o3/ O45 +i58 O23 +'5 z4 +O32 o2x +oAO c +O43 *43 +p1 sl7 +i97 $5 +^d O13 +c ^8 +*78 O53 +*03 o0h +o2m ^d +^M $D +l o4b +$8 *A5 +o81 *63 +o3o i3k +$1 -7 sa^ -*32$k -O41[ -'B*52 -di4* -i2isJp -OA3l --1o7m -fO3A -O59$H -O53sln +*32 $k +'B *52 +d i4* +i2i sJp +-1 o7m +f O3A +O59 $H +O53 sln o9u -^pZ2 -z1Z4 -o58'7 +^p Z2 +z1 Z4 +o58 '7 svy -'7$t -O0AR0 +'7 $t +O0A R0 o4< -o6t-5 -$,O93 -o47d -z2@a -}s7. -o6oC -o1wz1 -O34z4 +o6t -5 +$, O93 +o47 d +z2 @a +} s7. +o6o C +o1w z1 +O34 z4 i6\ -Z1i2c -*30f -Co3d -*24o31 +Z1 i2c +*30 f +C o3d +*24 o31 o23 i2O -^%z2 -*31*74 -^io4_ -i7p*70 -i4%+6 -+0o4o --8R7 -$eo0d -c*21 -O72-5 -*47T4 -*30O32 -*B9O65 -^#^+ -li7k -Z1*31 -[i4l -O24$r -sn.{ -$k$4 -o7.-2 +^% z2 +*31 *74 +^i o4_ +i7p *70 +i4% +6 ++0 o4o +-8 R7 +$e o0d +c *21 +O72 -5 +*47 T4 +*30 O32 +*B9 O65 +^# ^+ +l i7k +Z1 *31 +[ i4l +O24 $r +sn. { +$k $4 +o7. -2 slT -$2-9 -*30o82 -OB3[ -D1$1 -*28O05 +$2 -9 +*30 o82 +OB3 [ +D1 $1 +*28 O05 s.b -Z1$b -iBaO74 -O51^2 -i7X'B -$+Z2 -co50 +Z1 $b +iBa O74 +O51 ^2 +i7X 'B +$+ Z2 +c o50 sbJ -*BAO02 -o1oO25 -ks2c -D1'7 -o4c*67 -D3R2 -O64-6 -i9i'A -O81o5+ -ssFT3 -o0s+6 -^?$, -o8vD7 -*64*57 -[sLe +*BA O02 +o1o O25 +k s2c +D1 '7 +o4c *67 +D3 R2 +O64 -6 +i9i 'A +O81 o5+ +ssF T3 +o0s +6 +^? $, +o8v D7 +*64 *57 +[ sLe sm` -O64O32 -R6[ -o65O81 -$LO12 -i5 +6 -o24$# -lo0C +O64 O32 +R6 [ +o65 O81 +$L O12 +i5 +6 +o24 $# +l o0C i2: -Z4$_ -[i5: -T0L3 -ti8u -o2k*01 -t$V -tsUR -Z1R1 -^zi8" -o5wsct -^dO31 -$5O21 -i4@@7 -o3e'B -^1z4 -i1-d -o3t+6 -L5-5 -@3o8, -^cD3 -O17q -to2T -*97*21 -$ld -$B$e -*54o3l -*72o7r -^7^3 +Z4 $_ +[ i5: +T0 L3 +t i8u +o2k *01 +t $V +t sUR +Z1 R1 +^z i8" +o5w sct +^d O31 +$5 O21 +i4@ @7 +o3e 'B +^1 z4 +i1- d +o3t +6 +L5 -5 +@3 o8, +^c D3 +O17 q +t o2T +*97 *21 +$l d +$B $e +*54 o3l +*72 o7r +^7 ^3 sn8 -+5D1 -[-A -s9d*13 -Z1i4] ++5 D1 +[ -A +s9d *13 +Z1 i4] stL -i7wl --1L8 -^<-1 -o6BO32 -c+A -^[i1v -^"^\ -O32L4 -o0*z5 -kssy -ss=u -o19[ -i47D7 -s23d -o4K[ -i4li8h -$1OA5 -i5el -i7cc -DBO64 --7i4; +i7w l +-1 L8 +o6B O32 +c +A +^[ i1v +^" ^\ +O32 L4 +o0* z5 +k ssy +ss= u +o19 [ +i47 D7 +s23 d +o4K [ +i4l i8h +$1 OA5 +i5e l +i7c c +DB O64 +-7 i4; s; -^7-2 -l*5B -o0ai93 -f$f -$l^b -O27$i -D2i7i +^7 -2 +l *5B +o0a i93 +f $f +$l ^b +O27 $i +D2 i7i s., -O04i6_ -o0i+1 --6T2 -i5i+7 +O04 i6_ +o0i +1 +-6 T2 +i5i +7 o6q --6*70 -o5-'8 -Z1i2v -i3zi5& -o0_'2 -o7QZ1 -T4sIs -^@O71 -rk -'B*35 -skgo4 -loAf -o67l -'8$N -s13Z1 -O62$n -'A$ +-6 *70 +o5- '8 +Z1 i2v +i3z i5& +o0_ '2 +o7Q Z1 +T4 sIs +^@ O71 +r k +'B *35 +skg o4 +l oAf +o67 l +'8 $N +s13 Z1 +O62 $n +'A $ o3R -$!$3 -O81$9 -t} -T6'9 +$! $3 +O81 $9 +t } +T6 '9 s1k -O48p1 -cO24 +O48 p1 +c O24 oAr -*39o58 -i5s*10 -o8jD7 -*86O14 -$&o67 --Ao93 -T4o0H --8oB3 -o80+7 -o5Wt -O12sx. -li6: -O42$ -z1i8t -'9$M -$lZ2 +*39 o58 +i5s *10 +o8j D7 +*86 O14 +$& o67 +-A o93 +T4 o0H +-8 oB3 +o80 +7 +o5W t +O12 sx. +l i6: +O42 $ +z1 i8t +'9 $M +$l Z2 i8x -Cs04 -*30[ -^e'8 -soa[ -o1-o0B -{O03 -$6L1 -uo5L -$;$; --2o7* -*17+7 -o79Z1 -o0Zz2 -*36^- -*57$% -^ip1 -o1sd -+2oAs -$tsbL -$$O61 -D5*12 -*15+3 -$&c -sm7z4 -^t*65 +C s04 +^e '8 +soa [ +o1- o0B +{ O03 +$6 L1 +u o5L +$; $; +-2 o7* +*17 +7 +o79 Z1 +o0Z z2 +*36 ^- +*57 $% +^i p1 +o1s d ++2 oAs +$t sbL +$$ O61 +D5 *12 +*15 +3 +$& c +sm7 z4 +^t *65 *41 --0^= -[i5- -*41D1 -O51o3L -csb1 -@r$g -*A6O42 -*A6i2m -p3'9 -o5 D3 -L1$d -i0_s87 -o0/z1 -i69{ -i34+8 +-0 ^= +[ i5- +*41 D1 +O51 o3L +c sb1 +@r $g +*A6 O42 +*A6 i2m +p3 '9 +o5 D3 +L1 $d +i0_ s87 +o0/ z1 +i69 { se2 -$&i0@ -Z2sg. -o8#D9 -Z5i5f -*85*63 -R9^G -o6c[ -^@T6 -i5#l -$Tz1 -o1Iu -C+6 -$`o0h -^mi3- -i2vO01 -+0*31 +$& i0@ +Z2 sg. +o8# D9 +Z5 i5f +*85 *63 +R9 ^G +o6c [ +^@ T6 +i5# l +$T z1 +o1I u +C +6 +$` o0h +^m i3- +i2v O01 ++0 *31 o4F -i18r -c*75 -R6i74 -sBtf +i18 r +R6 i74 +sBt f o5+ -i2D-4 -O02'4 -$2o9 -^t^u -T5O13 -p2O79 -sztd -^kO46 -'9-4 -+5-4 -^6'8 -T9i9_ -$a$3 -*65@5 -sjfO37 -$@*68 -$e[ -^8^i -o0z} -^-O92 -$%O81 -Z1o7e -O42^I -*16$R +i2D -4 +O02 '4 +$2 o9 +^t ^u +T5 O13 +p2 O79 +szt d +^k O46 +'9 -4 ++5 -4 +^6 '8 +T9 i9_ +$a $3 +*65 @5 +sjf O37 +$@ *68 +$e [ +^8 ^i +o0z } +^- O92 +$% O81 +Z1 o7e +O42 ^I +*16 $R s5w -p3$9 -ui4C -$vL6 -^kz4 -O2Al -}$O -O98Z1 -cO52 -ti9, -$7k -i6Xt -Z2*45 +p3 $9 +u i4C +$v L6 +^k z4 +O2A l +} $O +O98 Z1 +c O52 +t i9, +$7 k +i6X t +Z2 *45 slM sdF sjV -o2z$ -^"$" +o2z $ +^" $" s60 -}@D -$5T6 --AO01 -z5'8 -$6*9B -^a'B -^Y*32 +} @D +$5 T6 +-A O01 +z5 '8 +$6 *9B +^a 'B +^Y *32 ^D -D6s2; -^H^C -$I$! +D6 s2; +^H ^C +$I $! *08 -O86O52 -i12i0f -p1snd -L1O35 --8Z2 -@n} -^P*42 -i4@o3n +O86 O52 +i12 i0f +p1 snd +L1 O35 +-8 Z2 +@n } +^P *42 +i4@ o3n s2z -to5 -$-@j -*12*68 -+6$& -z5O18 -O71c -*18l -uO31 -T4T5 -*56se2 -'9$2 -i4+*47 -O12q -$oT0 +t o5 +$- @j +*12 *68 ++6 $& +z5 O18 +O71 c +*18 l +u O31 +T4 T5 +*56 se2 +'9 $2 +i4+ *47 +O12 q +$o T0 sv? -[i1y -*79-8 -d$p -sv3c -+0'B -D6o3@ -*0A-0 -'8$@ -i5MT4 -ci69 -o39*71 -sn2Z3 -*73O21 -$4DA +[ i1y +*79 -8 +d $p +sv3 c +D6 o3@ +*0A -0 +'8 $@ +i5M T4 +c i69 +o39 *71 +sn2 Z3 +*73 O21 +$4 DA i5| -skm-5 -o1nl -O35-1 -to0Y -q$e -o2u$# -i3t^r -^ho5. +skm -5 +o1n l +O35 -1 +t o0Y +q $e +o2u $# +i3t ^r +^h o5. o7E -o2o^@ -o0t*91 -'8R2 --0z1 -p3O06 -o58p1 -cs0I -{$0 -O12L1 -r+8 -o9!O61 -sp z2 -i80sdz -*12^k -o9d$6 -ds0f -L6O06 --7-3 -*8At -$r^p -$#O42 -$UT4 --1R0 +o2o ^@ +o0t *91 +'8 R2 +-0 z1 +p3 O06 +o58 p1 +c s0I +{ $0 +O12 L1 +r +8 +o9! O61 +sp z2 +i80 sdz +*12 ^k +o9d $6 +d s0f +L6 O06 +-7 -3 +*8A t +$r ^p +$# O42 +$U T4 +-1 R0 o6N sz7 -^M -O42[ i3I --8$% -o3@D4 -*54+0 -kss[ -o4K@h -p1sMw +-8 $% +o3@ D4 +*54 +0 +k ss[ +o4K @h +p1 sMw i8= -{^C +{ ^C i6M -O06$1 -*49O53 -*63slp +O06 $1 +*49 O53 +*63 slp o5= -O24$7 -o6w+7 -p3i4, -^mO15 -o70$k -^!O71 +O24 $7 +o6w +7 +p3 i4, +^m O15 +o70 $k +^! O71 i3q -^t-2 -o0=r -O15o0j -o10p1 -D2o0D -$q*02 -i4Yu -T2*03 +^t -2 +o0= r +O15 o0j +o10 p1 +D2 o0D +$q *02 +i4Y u +T2 *03 i3* -[o3c -i3Si4& -*34sm_ -uo7I -^b*24 -$7o0Z -i9Tl -i70t -o6Fo8s -saQc +[ o3c +i3S i4& +*34 sm_ +u o7I +$7 o0Z +i9T l +i70 t +o6F o8s +saQ c o2{ -$7O54 +$7 O54 st8 -$1*41 -p1z1 -*27*76 -O78l -*53OB2 -o3WO5A -$8*68 +$1 *41 +p1 z1 +*27 *76 +*53 OB2 +o3W O5A +$8 *68 O1B -D4^p -D1o2c -c-3 -z4o6= -sqdo1l -Z2i88 +D4 ^p +D1 o2c +c -3 +z4 o6= +sqd o1l +Z2 i88 s3^ -[szp +[ szp slv sgq -*14c -'5o2k -lo3_ -O53*96 -p1i4` -o2_*06 +*14 c +'5 o2k +l o3_ +O53 *96 +p1 i4` +o2_ *06 o2` -O91oBz -i31O91 -$_O75 -si2Z1 -[o2d -s2ao1f -o0ML1 -{o0q -$6T3 -*56'7 -{i1d -fO36 -$3i6@ -sg o3l -i4 D6 +O91 oBz +i31 O91 +$_ O75 +si2 Z1 +[ o2d +s2a o1f +o0M L1 +{ o0q +$6 T3 +*56 '7 +{ i1d +f O36 +$3 i6@ +sg o3l +i4 D6 smg -o62*56 -O61*64 -i3p^a -p3O28 -O07$1 -o3pc -o8cC -qO29 -^dD4 -+8D4 -o82O21 -O03p3 -^e$7 -lss& --2o3j +o62 *56 +O61 *64 +i3p ^a +p3 O28 +O07 $1 +o3p c +o8c C +q O29 +^d D4 ++8 D4 +o82 O21 +O03 p3 +^e $7 +l ss& +-2 o3j o7A -*63T2 -^8$9 -z1^x -o4@$! -@,^v -$msh= -*43O53 -O04z2 -o1p^c --0*31 -$4O23 -o4lo1k -li51 -sfy$o -rp2 -*61^R -RBZ1 -*36o3g -z1$3 -o2pO35 -*56s40 -Z2+4 -O72Z5 -R5Z2 -i5xl -T4+4 +^8 $9 +z1 ^x +o4@ $! +@, ^v +$m sh= +*43 O53 +O04 z2 +o1p ^c +-0 *31 +$4 O23 +o4l o1k +l i51 +sfy $o +r p2 +*61 ^R +RB Z1 +*36 o3g +z1 $3 +o2p O35 +*56 s40 +Z2 +4 +O72 Z5 +R5 Z2 +i5x l +T4 +4 o9E --0^& -*16i5a -suo+5 -o52l -O53Z2 -iBTk -+6$p -o7eO43 -O26^t -O37l -OB1Z2 --5O02 -'Ac -o1si0g -o5}s}$ -s4+Z3 -sAjd -O73O84 -dsCf -$(c -+1@a -O82$: -*35o7A -o5l+3 -o0ro2k -Z2RA -s8,o33 -O56l -i2/i5/ -*05o00 -$x*71 -o62T5 -i56i55 -o7?*75 -fO85 -O53t -$@o58 -i7iO34 -'B+1 -o3i*B3 -*32+5 -o1k$! -*64O61 -'B$6 -rz3 -seAd -^n^t +-0 ^& +*16 i5a +suo +5 +o52 l +O53 Z2 +iBT k ++6 $p +o7e O43 +O26 ^t +O37 l +OB1 Z2 +-5 O02 +'A c +o1s i0g +o5} s}$ +s4+ Z3 +sAj d +O73 O84 +d sCf +$( c ++1 @a +O82 $: +*35 o7A +o5l +3 +o0r o2k +Z2 RA +s8, o33 +O56 l +i2/ i5/ +*05 o00 +$x *71 +o62 T5 +i56 i55 +o7? *75 +f O85 +O53 t +$@ o58 +i7i O34 +'B +1 +o3i *B3 +*32 +5 +o1k $! +*64 O61 +'B $6 +r z3 +seA d +^n ^t s7+ -o09*13 --5T0 -i40c -$@Z2 -fO37 -$Du -sngi3t -R7O41 -*98o7 -i4@r -ti3p -o6lz4 +o09 *13 +-5 T0 +i40 c +$@ Z2 +f O37 +$D u +sng i3t +R7 O41 +*98 o7 +i4@ r +t i3p +o6l z4 i2` -O83sa1 -$^@m -i3/+4 -{^R -^%D2 -o05$ -i3to7n +O83 sa1 +$^ @m +i3/ +4 +{ ^R +^% D2 +o05 $ +i3t o7n si& -^po1k -*07*18 -o0r^b -*56$3 -z2@A -O16^D -s2_^g -^K^T -Z2o3 -o5d'9 -'2o0< -i47o1g -*40O24 +^p o1k +*07 *18 +o0r ^b +*56 $3 +z2 @A +O16 ^D +s2_ ^g +^K ^T +Z2 o3 +o5d '9 +'2 o0< +i47 o1g +*40 O24 sI? -O45R0 -*65-5 -Z3} -O28O0B -o4m+0 -@r'5 -Z4$e +O45 R0 +*65 -5 +Z3 } +O28 O0B +o4m +0 +@r '5 +Z4 $e sps -Z2s1t -uo83 -qD1 -i4hsfK --9L9 +Z2 s1t +u o83 +q D1 +i4h sfK +-9 L9 s70 -o2yk -T4-6 -ks3H -t^d -'3R2 -D3o1h -o2gD3 -i8ol -o6iO12 -s83o1f -{o7= -'4s0 -Z1$9 -s6$[ +o2y k +T4 -6 +k s3H +t ^d +'3 R2 +D3 o1h +o2g D3 +i8o l +o6i O12 +s83 o1f +{ o7= +'4 s0 +Z1 $9 +s6$ [ i3@ -$KsbC -c*14 --7oAD -${L5 -*52^p -o5tZ1 -Z2i78 -O07R4 -$mOA4 -+2o1b -^8i4d -r^s -$Bo3z -O52d -o5uO61 -T7R7 -@2oB9 -O24R0 -$m+4 -@np1 -O19r -i8a*18 -^o*58 -o3k^z -R5st3 -T0se4 -fDB +$K sbC +-7 oAD +${ L5 +*52 ^p +o5t Z1 +Z2 i78 +O07 R4 +$m OA4 ++2 o1b +^8 i4d +r ^s +$B o3z +O52 d +o5u O61 +T7 R7 +@2 oB9 +$m +4 +@n p1 +O19 r +i8a *18 +^o *58 +o3k ^z +R5 st3 +T0 se4 +f DB she -^bO35 -*75o87 -T8T4 -svYT2 -$>@n -i3%r -^kO32 -O61+5 -ls/, -@a*03 -TAZ1 -'Bo6? -o11$/ -shVo6m -ss0Z2 -Z4'8 -R9[ -T6$9 +^b O35 +*75 o87 +T8 T4 +svY T2 +$> @n +i3% r +^k O32 +l s/, +@a *03 +TA Z1 +'B o6? +o11 $/ +shV o6m +ss0 Z2 +Z4 '8 +R9 [ +T6 $9 saU -d+A -i9jOA3 -O01@k -Z4OA5 -O85o1g -O05sL +d +A +i9j OA3 +O01 @k +Z4 OA5 +O85 o1g +O05 sL sct -o9s+3 -o4ed -O02i2l -$3$2 -^oL0 -Cs8M --0i2n -o41O02 -O82-1 -*03o3w -o5*^o -+4D3 -^zO23 -O36+3 -CZ2 +o9s +3 +o4e d +O02 i2l +$3 $2 +^o L0 +C s8M +-0 i2n +o41 O02 +O82 -1 +*03 o3w +o5* ^o ++4 D3 +^z O23 +O36 +3 +C Z2 i79 -*68o0k -smsD5 -$GD5 -{*37 --7^3 -o6yl -us1c +*68 o0k +sms D5 +$G D5 +{ *37 +-7 ^3 +o6y l +u s1c i43 -^sO52 -z3O01 -^#O75 -O52$G --3*45 -${L8 -^:c -T8$1 -*03$ -*40*73 -L7D9 -$B$G -['6 +^s O52 +^# O75 +O52 $G +-3 *45 +${ L8 +^: c +T8 $1 +*03 $ +*40 *73 +$B $G +[ '6 slS -o1m*65 -OA1i2k -i9#+0 -O21o0y -o5kz4 +o1m *65 +OA1 i2k +i9# +0 +O21 o0y +o5k z4 sdb -^v*31 -i3s-1 -z4-3 -$)O0A -O51T3 -Z1i1l -$&^$ -suz$s -ki2n -O41p2 -R4i45 -'9O61 -lo1i -o6S@c -+0$$ -lshj -o4cc --B-9 -o1-'8 -ci7. -$d@p -c$R -$AT2 -^Sz3 +^v *31 +i3s -1 +z4 -3 +$) O0A +O51 T3 +Z1 i1l +$& ^$ +suz $s +O41 p2 +R4 i45 +'9 O61 +o6S @c ++0 $$ +l shj +o4c c +-B -9 +o1- '8 +c i7. +$d @p +c $R +$A T2 +^S z3 O25 -O52^O -R1'4 -^6-1 -r$! -O03$5 -i3;'8 -'B$m +O52 ^O +R1 '4 +^6 -1 +r $! +O03 $5 +i3; '8 +'B $m i17 -cz2 -O24Z5 -o1-*74 --0i7s -*78'9 -*91o1a +c z2 +O24 Z5 +o1- *74 +-0 i7s +*78 '9 +*91 o1a si! -i8@+A -R3*72 -slnO43 -o0LL1 -o2vd -{O12 -$nOB4 +i8@ +A +R3 *72 +sln O43 +o2v d +{ O12 +$n OB4 sk@ -i41*04 -*9Ao9J --5+4 -$it -o6@'8 -^KT2 -Z3o0 -O04$v -*40$s -D5D7 -^Ti0P -o6b$m -ls6- -^eO31 -'4o0> -^DiA! +i41 *04 +*9A o9J +-5 +4 +$i t +o6@ '8 +^K T2 +Z3 o0 +O04 $v +*40 $s +D5 D7 +^T i0P +o6b $m +l s6- +^e O31 +'4 o0> +^D iA! sb1 -dsP -+7-1 -R0o1r -o1do3? -Z3i7x -*0Bl -ssop1 -lo2a -oBlD8 -$@o5# -O31o0Y -Z5*27 -^b-2 -O31o8r -*64O53 -@Rz1 -+6i7u +d sP ++7 -1 +R0 o1r +o1d o3? +Z3 i7x +*0B l +sso p1 +l o2a +oBl D8 +$@ o5# +O31 o0Y +Z5 *27 +^b -2 +O31 o8r +*64 O53 +@R z1 ++6 i7u ^x -T4st5 -p1O49 +T4 st5 +p1 O49 iB0 -$,$5 -i5-D2 -p1oB2 -$D^S -O03^L -*06*67 -D0s30 -c$f -i20{ -o6*Z1 -O91[ -O34Z1 -$6*05 -D6*23 -Z5i4i -d*64 -[s07 -$k[ -D1sds -i9x-A -i0k^g -Z3k +$, $5 +i5- D2 +p1 oB2 +$D ^S +O03 ^L +*06 *67 +D0 s30 +i20 { +o6* Z1 +O91 [ +O34 Z1 +$6 *05 +D6 *23 +Z5 i4i +d *64 +[ s07 +D1 sds +i9x -A +i0k ^g +Z3 k *B7 -i38*49 -$!*74 -D4Z1 -oB2D9 -i4:c -D2$` -o2fi45 -lL0 -^Wz2 -o6_sfx --5o8* --0T7 -R4Z4 -*32D6 -*94'8 -^CscK --1@2 -$nZ2 -*13o2- -^u*31 +$! *74 +D4 Z1 +oB2 D9 +i4: c +D2 $` +o2f i45 +l L0 +^W z2 +o6_ sfx +-5 o8* +T7 -0 +R4 Z4 +*94 '8 +^C scK +-1 @2 +$n Z2 +*13 o2- +^u *31 shs -$XL8 -$$i21 -O53R1 -do2U -o4at -+Ai81 -^P*92 +$X L8 +$$ i21 +O53 R1 +d o2U +o4a t ++A i81 +^P *92 swx ss* -+0@z -^Z$" -$kR7 -*8AoB3 -O62o3t -$!*25 -lo1b ++0 @z +^Z $" +$k R7 +*8A oB3 +O62 o3t +$! *25 +l o1b i8$ -*12R3 -i3Dc -T7-0 -i3bk -o0r^E -r$r -'6^a -O72*13 -o7s*A5 -$p$0 -$sO64 -o63d -$_$0 -i4o+8 -O52$9 -*01*83 -o1wq -o14-9 -@h[ -*48O43 -$,*74 -p1R9 -Z4o2h -D2s3- -^7*27 -*02o3a +*12 R3 +i3D c +i3b k +o0r ^E +r $r +'6 ^a +O72 *13 +o7s *A5 +$p $0 +$s O64 +o63 d +$_ $0 +i4o +8 +O52 $9 +k *38 +o1w q +o14 -9 +@h [ +*48 O43 +$, *74 +p1 R9 +Z4 o2h +D2 s3- +^7 *27 +*02 o3a s0. -O56$/ +O56 $/ ^R -Z5*20 -i8v*68 -o34^M -i2T[ -^Nz1 -o0ko1. -s* *A0 -s38c -ci8r +Z5 *20 +i8v *68 +o34 ^M +i2T [ +^N z1 +o0k o1. +s* *A0 +s38 c +c i8r sHl -$mo2r -O12sna -$MZ1 -R0i1e -*63o4h -R7o0K -to3" -sthD0 -^y} -C@6 -$AD6 -O24+2 -*80O47 -O63scH -O83o6h -^(D1 -l*39 +$m o2r +O12 sna +$M Z1 +R0 i1e +*63 o4h +R7 o0K +t o3" +sth D0 +^y } +C @6 +$A D6 +O24 +2 +O63 scH +O83 o6h +^( D1 +l *39 seu s56 -*06R7 -cspv -$6Z3 -o7si6t -+9O71 +*06 R7 +c spv +$6 Z3 +o7s i6t ++9 O71 o3, -^p*B5 -tO93 -o2Mo85 -f{ -$#*97 -L1[ --Bsae -o0WD2 -s5 Z5 -@1c -D5O04 -D3i4k +^p *B5 +t O93 +o2M o85 +f { +$# *97 +L1 [ +-B sae +o0W D2 +s5 Z5 +@1 c +D5 O04 +D3 i4k sku -D1Z1 -*06R0 -co77 -O07-1 +D1 Z1 +*06 R0 +c o77 +O07 -1 sy! -t$* -skC*98 -^$*02 +t $* +skC *98 +^$ *02 ss3 -$"i7" -D9O32 -f*24 -L2^b -i4di2N -+BDB -i1r$ -L9[ -Z2o8s -$x-6 -sac*18 -D5i2! -ss]sy -Z4o1i -^g$t -$eo5% +$" i7" +D9 O32 +f *24 +L2 ^b +i4d i2N ++B DB +i1r $ +L9 [ +Z2 o8s +$x -6 +sac *18 +D5 i2! +ss] sy +Z4 o1i +^g $t +$e o5% o2C oBm -s9az2 -o2 T0 -*7A'A -T3O43 -i16o21 -O21o2? -O2A$_ -csaw -i1Hc -$1i7? -^4} -O12c -sckz1 -k^s -O12^E -$]i6: -sa=$5 -f*31 -T0i85 +s9a z2 +o2 T0 +*7A 'A +T3 O43 +i16 o21 +O21 o2? +O2A $_ +c saw +i1H c +$1 i7? +^4 } +O12 c +sck z1 +k ^s +O12 ^E +$] i6: +sa= $5 +f *31 +T0 i85 i3\ -Z1*68 -*40i8j -z3i5} -i5:+5 -Z3o5i -$bZ3 -*31'A +*40 i8j +z3 i5} +i5; +Z3 o5i +$b Z3 +*31 'A sw7 -$0-B -+3$4 -O06{ --3o4. -*06'6 -dsbh -i1y*25 -*89D5 -i3ii0Y +$0 -B ++3 $4 +O06 { +-3 o4. +*06 '6 +d sbh +i1y *25 +i3i i0Y iAh -*91oA7 -$jr -^M-1 -^x^= -z5*8A -$sZ2 -o0bl -to8J -@2$ -*76$o -z1'A -o48*78 -u^M --3T6 -C$5 -z3r -$0O12 -i0m*02 -D5u -^= -OA1o1a -O32Z5 -o0vO41 -T1r --2R6 -O02$g -R8Z4 -o7s+2 -$3+2 -k^J -o3l^, -D2-5 -+9o8i -uOA3 -O42o3D +*91 oA7 +$j r +^M -1 +^x ^= +z5 *8A +$s Z2 +o0b l +t o8J +@2 $ +*76 $o +z1 'A +o48 *78 +u ^M +-3 T6 +C $5 +$0 O12 +i0m *02 +D5 u +OA1 o1a +O32 Z5 +o0v O41 +T1 r +-2 R6 +O02 $g +R8 Z4 +o7s +2 +$3 +2 +k ^J +o3l ^, +D2 -5 ++9 o8i +u OA3 +O42 o3D st) -o2l-8 -sCL-6 +o2l -8 +sCL -6 s@c -o84+6 -o2gi4k -iAmO02 -$yi20 -$d*19 +o84 +6 +o2g i4k +iAm O02 +$y i20 +$d *19 s9, -^ci3t -L5$n -o2 sh\ +^c i3t +L5 $n +o2 sh\ spM -*34o3h +*34 o3h oA/ -i1`*91 -cso* +i1` *91 +c so* s8^ -*96sdr +*96 sdr i3S -Z2C -$dD6 -i5cd -O62$w -i7.o99 -dO16 -*50O16 -*73o0d -$s-8 -@6i9! -@5-B -sDw$e -R3t -@0+9 -T0s.% -$OZ1 -i76+9 +$d D6 +i5c d +O62 $w +i7. o99 +*50 O16 +*73 o0d +$s -8 +@6 i9! +@5 -B +sDw $e +R3 t +@0 +9 +T0 s.% +$O Z1 +i76 +9 o6X -$9z1 -o6#O51 -*8Ao0W -$ *35 -D7O12 --3sTB -O01o4x --6^k -O04O49 -s0+c -D7$1 -$D$E -*83O81 +$9 z1 +o6# O51 +*8A o0W +$ *35 +D7 O12 +-3 sTB +O01 o4x +-6 ^k +O04 O49 +s0+ c +D7 $1 +$D $E +*83 O81 O35 -O41*78 -[o7i -Z1*57 -D0i4o --3-B -lD9 -o0d$z -'7q -^Gz1 -*12$ --0O13 -o5io6n -*A6l -$p*73 -^Ho6O --1$q +O41 *78 +[ o7i +Z1 *57 +D0 i4o +-3 -B +o0d $z +'7 q +^G z1 +*12 $ +-0 O13 +o5i o6n +*A6 l +$p *73 +^H o6O +-1 $q sWC -Z4-2 +Z4 -2 sxk -^2^0 -o7tO32 -i4_O53 -+4O54 -$t*86 -^x*20 -*58D7 -p1svg -i8zO52 -i5p^; -qOB3 -O24o21 -*01^0 -$?Z4 -$P$# -O07$n -*97O07 -$4sr1 -^zi8z -$=O02 -*67i6; +^2 ^0 +o7t O32 +i4_ O53 ++4 O54 +$t *86 +^x *20 +*58 D7 +p1 svg +i8z O52 +i5p ^; +q OB3 +O24 o21 +*01 ^0 +$? Z4 +$P $# +O07 $n +*97 O07 +$4 sr1 +^z i8z +$= O02 +*67 i6; stE -o5vT0 -i6-Z1 -o60*98 +o5v T0 +i6- Z1 +o60 *98 si: sBO -^`^k -i55u -o91*74 +^` ^k +i55 u +o91 *74 $W -ci3H -o5aZ1 -@2+9 +c i3H +o5a Z1 +@2 +9 i4v -o0ei1s -$vZ3 -i57D8 -oB_O26 --3+6 -^1Z4 -D0o4e -Z1i3| -$aDA -u^$ -p1suk -o8Sc -c*86 -+7i8, --2o0d -*87Z1 -}+9 -^ r --1o08 -^u*71 -s3gO32 -$?-7 -i3nc -t+6 -*98o1d --9-8 +o0e i1s +$v Z3 +i57 D8 +oB_ O26 +-3 +6 +^1 Z4 +D0 o4e +Z1 i3| +$a DA +u ^$ +p1 suk +o8S c +c *86 ++7 i8, +-2 o0d +} +9 +-1 o08 +^u *71 +s3g O32 +$? -7 +i3n c +t +6 +*98 o1d +-9 -8 s1a -dskz -OA3$f -o2e*89 -'6$p -$9*04 -*43*47 -o8<*78 -O82R7 -'8i2d -sor{ -OB7Z2 -o0sl +d skz +OA3 $f +o2e *89 +'6 $p +$9 *04 +o8< *78 +O82 R7 +'8 i2d +sor { +OB7 Z2 +o0s l ^P -*A1i2+ -*57o7a -O51$; -*65$n -O14i4+ --6-9 -OA1oA6 -i7Lc -[*72 -'BO51 +*A1 i2+ +*57 o7a +O51 $; +*65 $n +O14 i4+ +-6 -9 +OA1 oA6 +i7L c +[ *72 +'B O51 s0b -*89Z1 -}'9 -z1o2_ +*89 Z1 +} '9 +z1 o2_ i7/ -^a^h -'7} -koA7 -s6o$7 -$!$) -R8$1 -*97-8 -ui54 -i2no1+ -*01soi +^a ^h +'7 } +k oA7 +s6o $7 +$! $) +R8 $1 +u i54 +i2n o1+ +*01 soi sSF -*32i1u +*32 i1u ^Y -o1Jt -O39$ -o4v'6 -p4z2 -saqZ2 -o6i[ -C^X +o1J t +O39 $ +o4v '6 +p4 z2 +saq Z2 +o6i [ +C ^X o5? -i4u+2 -+1'2 -$1DA -*83+3 -'9i8, -o0M'9 -o4x-9 -O26z5 -DA*BA -^Ez2 -o1;O32 -$ri7t -o0p*59 -*32o3h -sIiT7 -'2o0, -i95oA@ -*6BO84 -$(R8 -i5pO12 -*3AO24 +i4u +2 ++1 '2 +$1 DA +*83 +3 +'9 i8, +o0M '9 +o4x -9 +O26 z5 +DA *BA +^E z2 +o1; O32 +$r i7t +o0p *59 +*32 o3h +sIi T7 +'2 o0, +i95 oA@ +*6B O84 +$( R8 +i5p O12 +*3A O24 o8v -}^P -DA$+ -$n@0 -'5+4 -o9xsmt -O83$# -+6*60 -+1$t -D7o8z -O63i4s -DBo9y -D6o5_ +} ^P +DA $+ +$n @0 +'5 +4 +o9x smt +O83 $# ++6 *60 ++1 $t +D7 o8z +O63 i4s +DB o9y +D6 o5_ i6V -f^9 -o5Zc -i0:O32 -i0h*67 -oByO38 -'8i4_ -[st -o5q*40 -$TO03 -i3KT0 -s4oZ2 -c*68 -*52+1 -$+O94 -^FT7 -[$v -'7$e -^gD4 -i6 +8 -^w^M -o7.[ -sW7z5 -O93c -'6^G -o4pk -*69o67 -C$X -'5^b -*31@3 -i71O25 -o44+1 -o0p+3 -p4O03 +f ^9 +o5Z c +i0: O32 +i0h *67 +oBy O38 +'8 i4_ +[ st +o5q *40 +$T O03 +i3K T0 +s4o Z2 +*52 +1 +$+ O94 +^F T7 +[ $v +'7 $e +^g D4 +i6 +8 +^w ^M +sW7 z5 +O93 c +'6 ^G +o4p k +*69 o67 +C $X +'5 ^b +*31 @3 +i71 O25 +o44 +1 +o0p +3 +p4 O03 s34 -^gO52 -p2DB -o0EC -$-*17 -Co6& -i04 +^g O52 +p2 DB +o0E C +$- *17 +C o6& sAo -^.^: -Z2s1z -^$$1 -i3z*56 -T6D1 -$3D2 +^. ^: +Z2 s1z +^$ $1 +i3z *56 +T6 D1 +$3 D2 oAD -u@A -o1.'9 +u @A +o1. '9 sBr -o6eu -D0i1h -$4q -i1#$h -i65-8 +o6e u +D0 i1h +$4 q +i1# $h +i65 -8 iAy -T7*06 -^/z4 -*02Z2 -o72Z2 -o2TO74 -$uO34 -Z2$4 -*67*85 -t$X -*07R7 -lOB9 -Z1iA^ -'6i4g -o5_u -L8*08 +^/ z4 +*02 Z2 +o72 Z2 +o2T O74 +$u O34 +Z2 $4 +*67 *85 +t $X +*07 R7 +l OB9 +Z1 iA^ +'6 i4g +o5_ u +L8 *08 iBu -}L0 -^zO42 -+2z1 +} L0 +^z O42 i2p su_ -O91O06 -O04Z2 +O91 O06 +O04 Z2 i39 -^jO21 -rsJ! +^j O21 +r sJ! o9$ -D4o4/ -*53^& -O62Z2 -i8mD0 -kR9 -cst` -p1i5y -o8d} -^ d +D4 o4/ +*53 ^& +O62 Z2 +i8m D0 +c st` +p1 i5y +o8d } +^ d saz -p1*03 -k$e -i4id -Z4$r -o4Kl +k $e +i4i d +Z4 $r +o4K l *4A -O63R6 -O71*53 -k*07 -O92*98 -Z1o8j +O63 R6 +O71 *53 +k *07 +O92 *98 +Z1 o8j O38 -$G$A -$pO92 -'7$n -o52c -o3sc -$3$k -O52L4 -c^G -*B0'8 +$G $A +$p O92 +'7 $n +o52 c +o3s c +$3 $k +O52 L4 +c ^G +*B0 '8 s - -$cO73 -r$] -D7skt -T8o5l -t^q +$c O73 +r $] +D7 skt +T8 o5l +t ^q sIR -O51z1 -*01^v +O51 z1 +*01 ^v i1Z -Z2o8n -s6_T0 -D3sVF -}O37 -^ho23 -+7$g -'5o4d -*A9oAy -i2 ^k -L0Z1 -o28z1 +Z2 o8n +s6_ T0 +D3 sVF +} O37 +^h o23 ++7 $g +'5 o4d +*A9 oAy +i2 ^k +L0 Z1 +o28 z1 i2D -*34} -O53$H -@ML4 -$xOA7 -*43*48 -i52-2 -s8Wl -O87O21 -*09*91 -+8O08 -*18O75 -o28*12 --0z4 -o1md -O64i6< +*34 } +O53 $H +@M L4 +$x OA7 +*43 *48 +i52 -2 +s8W l +O87 O21 +*09 *91 ++8 O08 +*18 O75 +o28 *12 +-0 z4 +o1m d +O64 i6< sra -*83D5 -$6i8t +*83 D5 +$6 i8t s1_ -Z1i6/ -$1^z -R3s1j -R5s1n -i9Ec -cs2* -*03*41 -^s-3 +Z1 i6/ +$1 ^z +R3 s1j +R5 s1n +i9E c +c s2* +*03 *41 +^s -3 o5V -doBt --6-2 -o0D$ -*17O42 -$%+8 +d oBt +o0D $ +*17 O42 +$% +8 i5D -sj-{ -T8D2 -D0$t -sB } -i5/T6 -O01$p -T6$ -z2i1o -O51*68 -p1LB -O63Z3 -ci4b +sj- { +T8 D2 +$t [ +sB } +i5/ T6 +O01 $p +T6 $ +z2 i1o +O51 *68 +p1 LB +O63 Z3 +c i4b s2 -}OA3 -p2O73 -^m^W +} OA3 +p2 O73 +^m ^W str sze -p3O04 +p3 O04 sb6 -C*9A -Z3{ +C *9A +Z3 { i6( -i3Ll -+AD4 -o87+0 -i41$2 -$t+9 -@io4e -^mO32 -T0d -+4*23 -i0w*30 +i3L l +o87 +0 +i41 $2 +$t +9 +@i o4e +^m O32 +T0 d ++4 *23 +i0w *30 sl2 -Z4sj! -Z4i4, -D5i72 -*74O31 +Z4 sj! +Z4 i4, +D5 i72 +*74 O31 s5* -D3o0S -^3O14 -L7*13 -}$r -$1*28 -tR9 -i3wp1 -o45Z3 -o1xu -$8^b -'Ao7l -$x@c -$/O75 -$1^I -z3o0f -}@b -D8$b -o3j*62 -*70s+' -$[L5 -i54-8 -O05$/ +D3 o0S +^3 O14 +L7 *13 +} $r +$1 *28 +t R9 +i3w p1 +o45 Z3 +o1x u +$8 ^b +'A o7l +$x @c +$/ O75 +$1 ^I +z3 o0f +} @b +D8 $b +o3j *62 +*70 s+' +$[ L5 +i54 -8 +O05 $/ so; -O62i6a -LBiB3 -i0OD3 -*05Z1 -p1*91 -^c*30 -O75Z2 -[i1P -i5; -Z2o2y -O41O61 -OB7Z5 -L5d -o5yu -}-0 -Z4Z2 -o2l*42 -o97[ -o4s-0 -o4f*04 -o1.p1 -O21i81 -$t$ -O54T5 -c+4 -O62*01 -i3i$x +O62 i6a +LB iB3 +i0O D3 +*05 Z1 +p1 *91 +^c *30 +O75 Z2 +[ i1P +Z2 o2y +O41 O61 +OB7 Z5 +L5 d +o5y u +} -0 +o2l *42 +o97 [ +o4s -0 +o4f *04 +o1. p1 +O21 i81 +$t $ +O54 T5 +c +4 +i3i $x syV -sa.O41 -ci0- -^1z2 +sa. O41 +c ^- +^1 z2 o29 -'7^< -$s-1 -^Oz2 -do3h -$m+6 -[i2a +'7 ^< +$s -1 +^O z2 +d o3h +$m +6 +[ i2a se_ -ds1h -R8o7x -sfjz5 --1*90 -$t*57 -s4 +3 +d s1h +R8 o7x +sfj z5 +-1 *90 +$t *57 +s4 +3 i1K -z1o2% --1i82 -L6D5 -*41o82 -z5*60 -R3L4 -to7! -*76O41 --B*B0 -tO71 -$3$* -*58D4 -i2a-9 -i3hZ3 -doBm -o0A^Q -s +[ -i3w*54 -O52$n -Z1i5! -$to6k --3$4 -*A9s05 -Z3*54 -o71r -Z1*59 -*B4'7 -z4-7 +z1 o2% +-1 i82 +L6 D5 +*41 o82 +z5 *60 +R3 L4 +t o7! +-B *B0 +t O71 +$3 $* +*58 D4 +i2a -9 +i3h Z3 +d oBm +o0A ^Q +s + [ +i3w *54 +O52 $n +Z1 i5! +$t o6k +-3 $4 +*A9 s05 +Z3 *54 +o71 r +Z1 *59 +*B4 '7 +z4 -7 ssk -Co1i -$Ko5B -^l^r -D6i6= -i2eC -o8a+9 -R3+6 -$mO72 -i3jk -tD3 -O57$0 -o5ri2 -o1z^j -^8t -*04*73 +C o1i +$K o5B +^l ^r +D6 i6= +i2e C +o8a +9 +R3 +6 +$m O72 +i3j k +t D3 +O57 $0 +o5r i2 +o1z ^j +^8 t sul -$*@5 --1*43 -C^0 -o8-Z1 -o77k -T0s. -+4o3g -o8z} +$* @5 +-1 *43 +C ^0 +o8- Z1 +T0 s. ++4 o3g +o8z } i3? -^aO61 -ci1i -O52Z1 -*9A$3 -^H^R -CT9 --3o97 -Z5OB7 +^a O61 +c i1i +O52 Z1 +*9A $3 +^H ^R +C T9 +-3 o97 +Z5 OB7 sef -z3o8 -*94O06 -s19Z1 -*53$L -{$9 -p1*17 -i40D6 --2f -'5$2 -O45{ -p1o1a -i2t'9 -O93i9e -swfO94 -s09O81 -[o0F -D2^N -o03-1 -^k*78 -o6&$2 -o5k*42 +z3 o8 +*94 O06 +s19 Z1 +*53 $L +{ $9 +p1 *17 +i40 D6 +-2 f +'5 $2 +O45 { +p1 o1a +i2t '9 +O93 i9e +swf O94 +s09 O81 +[ o0F +D2 ^N +o03 -1 +^k *78 +o6& $2 +o5k *42 sGj -CssN -O13p2 -i4z*64 -oB5*AB -i5oO23 -O51i2T -i5r@4 -sd7d -*84$# -^1l -oB[O12 -i27i0H -p3D0 -$%^g -i80[ -o5W[ -sa@c -sauO43 -DBsbl +C ssN +O13 p2 +i4z *64 +oB5 *AB +i5o O23 +O51 i2T +i5r @4 +sd7 d +*84 $# +oB[ O12 +i27 i0H +$% ^g +o5W [ +sa@ c +sau O43 +DB sbl o5F -'AT9 -ti03 -^$o1p -D4+3 -*46{ -z3'8 -D4T1 -i59O02 --7*76 -^3^7 -+2i2d -'7$J -O81s21 -{^9 -ti3L -f$9 -O38^s -@o -i5g{ -d*68 -*5AO06 -T0*43 --2$4 +'A T9 +t i03 +^$ o1p +D4 +3 +*46 { +z3 '8 +D4 T1 +i59 O02 +-7 *76 +^3 ^7 ++2 i2d +'7 $J +O81 s21 +{ ^9 +t i3L +f $9 +O38 ^s +i5g { +d *68 +*5A O06 +T0 *43 +-2 $4 sHa -*76o6g -O62@U -i4g$# -*06T4 -'3$L -^o-3 -o7ft -$kC +*76 o6g +O62 @U +i4g $# +*06 T4 +'3 $L +^o -3 +o7f t +$k C sof -stBscl -D6*05 -ki7d -O54^[ -Z1o3n -*08'5 -i0PO83 --6sS -@8^3 -O42'6 -R2r -+B$f -D7o1h -*54i6t -qi01 -do0t -*60o3R -'9^k -O12l -o3dsmF -$.Z3 -r*57 -Z1i6f -O05z2 -O71s2x -o6ci6P +stB scl +D6 *05 +k i7d +O54 ^[ +Z1 o3n +*08 '5 +i0P O83 +-6 sS +@8 ^3 +O42 '6 +R2 r ++B $f +D7 o1h +*54 i6t +q i01 +d o0t +*60 o3R +'9 ^k +o3d smF +$. Z3 +r *57 +Z1 i6f +O05 z2 +O71 s2x +o6c i6P s06 -^a*20 -$XO62 -z1} -L3R3 -t$. -d$n -$@L6 -'9o2l -^L-1 -o6#Z1 -^B$. +^a *20 +$X O62 +z1 } +L3 R3 +t $. +d $n +$@ L6 +'9 o2l +^L -1 +o6# Z1 +^B $. o5; -+7^o -L7@v -$4*85 -T3i6m -}+5 -*04*17 -Z1*75 -O14sa? -O02O35 -+0@t -O05^_ -o85o7y -$r+6 -^Bu -'9O06 -sl4Z5 -k*54 -o2D} -iA7o95 -^i^s -^1o3w ++7 ^o +L7 @v +$4 *85 +T3 i6m +} +5 +*04 *17 +O14 sa? +O02 O35 ++0 @t +O05 ^_ +o85 o7y +$r +6 +^B u +'9 O06 +sl4 Z5 +k *54 +o2D } +iA7 o95 +^i ^s +^1 o3w s41 -O62-8 -'A$e -@d*96 -u'B -kr -*97c -l*B9 -lssi -s39DB -*81d --1*21 -Co2( -^g@a +O62 -8 +'A $e +@d *96 +u 'B +k r +*97 c +l *B9 +l ssi +s39 DB +*81 d +C o2( +^g @a o7L -*41O21 +*41 O21 s7^ -'8i02 +'8 i02 i3# -$h*37 +$h *37 s9w *7A -^M+1 -$aoB8 -*42^w -^a^V --7o5g -'7sat -i4i+5 +^M +1 +$a oB8 +*42 ^w +^a ^V +-7 o5g +'7 sat +i4i +5 o1E -Z2oB5 -s5=O42 -o73*36 -Z2sxn -$-Z1 -sdt^v -p1o7i -*76O52 -o5r'8 -}o0b +Z2 oB5 +s5= O42 +o73 *36 +Z2 sxn +$- Z1 +sdt ^v +p1 o7i +*76 O52 +o5r '8 +} o0b sn+ -i5y^C +i5y ^C i5W s3F -+9sif -o6WO83 -$nl -p2O8A -T0+0 -Z2R1 -lO63 -*37*87 -i0yz1 -o4lu -*06i2, -z3o1c -sid*91 -O94*31 -@p$* -i2oZ2 -+2^8 ++9 sif +o6W O83 +$n l +p2 O8A +T0 +0 +Z2 R1 +l O63 +*37 *87 +o4l u +*06 i2, +z3 o1c +sid *91 +O94 *31 +@p $* +i2o Z2 ++2 ^8 su -ssyO32 -dO74 -ko0k -*46D4 -*B7o3a -D9r -o0?^! -z5$; -O02i2^ -oAn-1 -Z2O13 -s31o77 -$6$m -$.^= -smO'5 -D5*65 -$p*86 -*84 -$g$N -$G*75 -^@O15 -*03sjx -i80k -^li9n -O72^2 +ssy O32 +k o0k +*46 D4 +*B7 o3a +D9 r +o0? ^! +z5 $; +O02 i2^ +oAn -1 +Z2 O13 +s31 o77 +$6 $m +$. ^= +smO '5 +D5 *65 +$p *86 +$g $N +$G *75 +^@ O15 +*03 sjx +i80 k +^l i9n +O72 ^2 skB -p1O08 +p1 O08 oBk -D2o6B -i2El -o6%O83 -i32$% -+3o4i -i2sO02 -[o2t +D2 o6B +i2E l +o6% O83 +i32 $% ++3 o4i +i2s O02 +[ o2t skp -$>Z3 -$9OA2 -o5.*45 -O61$p -$uD9 -O41sku -^mo3n -^f^0 +$> Z3 +$9 OA2 +o5. *45 +O61 $p +$u D9 +O41 sku +^m o3n +^f ^0 o6R -p2i60 -Z1i21 -D4o13 -'9o4j -o6 O72 -*02$i -^&$; -*ABoAz -o5CT6 -O01L3 +p2 i60 +Z1 i21 +D4 o13 +'9 o4j +o6 O72 +*02 $i +^& $; +*AB oAz +o5C T6 +O01 L3 s3u -O67+7 -sm3*24 -*3A'8 -[*09 -s1w-9 -^7*09 -O85*67 -^t+1 -OB3$6 -O64$! -T4$3 -rstk --5o6= -'5o0m -o3_Z1 -^7q -$b$l -^2o1Z -$%$f -li15 -{T3 -^Tz1 -slt*50 -+8iB9 -'7*30 -O92i20 -*61-4 -$1@y -i5-D0 --3-0 -O17u -^7z5 --Ai82 -O02z2 -*57$n -i0n'A -s5.O23 -i3a[ +O67 +7 +sm3 *24 +*3A '8 +s1w -9 +^7 *09 +O85 *67 +^t +1 +OB3 $6 +O64 $! +T4 $3 +r stk +-5 o6= +'5 o0m +o3_ Z1 +^7 q +$b $l +^2 o1Z +$% $f +l i15 +{ T3 +^T z1 +slt *50 ++8 iB9 +'7 *30 +O92 i20 +*61 -4 +$1 @y +i5- D0 +-3 -0 +O17 u +^7 z5 +-A i82 +O02 z2 +*57 $n +i0n 'A +s5. O23 ssW -T8i4 -Z3o6@ -sgwp1 -O72sa1 -*45*01 -{O92 --Bs21 -^1o1f -$*^k -i7sR8 -D6$7 -o7MD8 -$ko78 +T8 i4 +Z3 o6@ +sgw p1 +O72 sa1 +{ O92 +-B s21 +^1 o1f +$* ^k +i7s R8 +D6 $7 +o7M D8 +$k o78 @v -o69^n -D6O31 -^Wi5j -o7@*97 -O15z3 --6*85 -^A+1 +o69 ^n +D6 O31 +^W i5j +o7@ *97 +O15 z3 +-6 *85 +^A +1 svd -O43+2 -o09*54 -skL-6 -ti5y -^FD3 -[*02 -O91o8_ +O43 +2 +o09 *54 +skL -6 +t i5y +^F D3 +O91 o8_ i4\ -[$a -+Bs7a -$s+4 -i3f-4 -$gO73 -z2i3p -^m-4 -sC6t -+4*86 -^g^w +[ $a ++B s7a +$s +4 +i3f -4 +$g O73 +z2 i3p +^m -4 +sC6 t ++4 *86 +^g ^w i7K -i9Sl +i9S l @e -p1o6d -*20s9! -o4Ct -*90L0 --4O82 -O27d -o9y-5 -sysZ3 -}*63 +p1 o6d +*20 s9! +o4C t +*90 L0 +-4 O82 +O27 d +o9y -5 +sys Z3 +} *63 oBs sx[ -^Md -i6zo5s +^M d +i6z o5s sle -Z2o1- -f+6 -sa2k -z4L5 -o4Lu -R1$7 -O81*78 -*32p1 -o3ct -T5*31 --5*97 -z1@b -uR5 -i4/O12 +Z2 o1- +f +6 +sa2 k +z4 L5 +R1 $7 +O81 *78 +o3c t +T5 *31 +z1 @b +u R5 +i4/ O12 o3S -o7ho8i -o7j{ -$w[ -^@*62 -Z5O52 -O71*86 -*54$ -$7*87 -i5ei8i -^{O06 +o7h o8i +o7j { +$w [ +^@ *62 +Z5 O52 +O71 *86 +*54 $ +$7 *87 +i5e i8i +^{ O06 L9 -D3d sHn -$h$z -sakD6 --1^0 -o0Y$r -O03R1 -qO83 +$h $z +sak D6 +-1 ^0 +o0Y $r +O03 R1 +q O83 snm -@-$a -*25*54 -O59*16 -i93-1 -[i1Z -i7uO84 -+8+7 -[sez -$x^! -$j*A4 -*5AO73 -*A1O07 -'7u -^p@m -oB8Z1 -D4-7 -o48Z4 -o71o1t -'4c -D6$m -+5o79 -sS^l -+5o9y -*03i1r -sCM*68 -kd -Z1sb+ -O13$. -*79i9n -i0g@C -*14z5 +@- $a +*25 *54 +O59 *16 +i93 -1 +[ i1Z +i7u O84 +[ sez +$x ^! +$j *A4 +*5A O73 +*A1 O07 +'7 u +^p @m +oB8 Z1 +D4 -7 +o48 Z4 +o71 o1t +'4 c +D6 $m ++5 o79 +sS^ l ++5 o9y +*03 i1r +sCM *68 +Z1 sb+ +O13 $. +*79 i9n +i0g @C +*14 z5 s9! -@j[ -z1f -o2;*31 -$aswc -*07O58 -Z4s93 -o1@*21 -$ O26 -$Kt -'9T4 +@j [ +z1 f +o2; *31 +$a swc +*07 O58 +Z4 s93 +o1@ *21 +$ O26 +$K t +'9 T4 s @ -s97*67 +s97 *67 i3Q -i5w*57 -shvO46 -*41^v -o9ko8d -$vp1 -O84l -sv0$! -*A2O76 -$W$8 -o0['2 -O06*20 -o8c[ -@nsC8 -$0o87 -*89o7p -Z2o0K -^Io4m -*73O31 -o2t$e -o6n$4 -OB1-B -snz'7 -o7?-8 -'7+5 -$J*80 -O32o3@ -T2r -L7O82 -{$` -$,o0H -D3o9c +i5w *57 +shv O46 +*41 ^v +o9k o8d +$v p1 +O84 l +sv0 $! +*A2 O76 +$W $8 +o0[ '2 +O06 *20 +o8c [ +@n sC8 +$0 o87 +*89 o7p +Z2 o0K +^I o4m +*73 O31 +o2t $e +o6n $4 +OB1 -B +snz '7 +o7? -8 +'7 +5 +$J *80 +O32 o3@ +T2 r +L7 O82 +{ $` +$, o0H +D3 o9c sfs --7$v -l*74 -C*61 -uOA1 -^pu -dsgr --0D1 -$no9e -o4q[ -i7_D2 -^7Z3 -O51'9 -O42$o -$ O19 -^%z5 -$3r -@g$ -o0a^f -R6ss8 -i1t-0 -D0O56 -+0o4i -O89i1g -T5[ -qi24 -o2rc -$zOA2 -[$s -i2LC -z2@2 -$5O91 --0O56 -$7Z2 -oBoD6 -kZ3 -i1i*13 -o0ZZ1 +-7 $v +l *74 +C *61 +u OA1 +^p u +d sgr +-0 D1 +$n o9e +o4q [ +i7_ D2 +^7 Z3 +O51 '9 +O42 $o +$ O19 +^% z5 +$3 r +@g $ +o0a ^f +R6 ss8 +i1t -0 +D0 O56 ++0 o4i +O89 i1g +T5 [ +q i24 +o2r c +$z OA2 +[ $s +i2L C +z2 @2 +$5 O91 +-0 O56 +$7 Z2 +oBo D6 +k Z3 +i1i *13 +o0Z Z1 sl$ --5Z4 -dsh@ -^!i78 -o0gZ2 -L0} -z2o10 -o6#Z2 -i4cd -^7$h -lL7 -^1o4C -sCyc -o4Xp1 -^a^8 -@dD8 -i8WC -$ @f -skyc -$gi9u -o1eZ5 --8D7 -sej+7 -*54D7 -R7T4 -o0Mo2N -$aO31 --9O25 -TAT0 -*20O41 -O94O81 -i71+8 -to06 -^|l -T1[ -^.^, -dl -o6aO42 -O61$| -L5Z3 -Z2DB -i2k[ -+0i2j -o4p} -i31p1 -kz3 -i5eO23 -'2$ +-5 Z4 +d sh@ +^! i78 +o0g Z2 +L0 } +z2 o10 +o6# Z2 +i4c d +^7 $h +l L7 +^1 o4C +sCy c +o4X p1 +^a ^8 +@d D8 +i8W C +$ @f +sky c +$g i9u +o1e Z5 +-8 D7 +sej +7 +*54 D7 +R7 T4 +o0M o2N +$a O31 +-9 O25 +TA T0 +*20 O41 +O94 O81 +i71 +8 +t o06 +^| l +T1 [ +^. ^, +o6a O42 +O61 $| +L5 Z3 +Z2 DB +i2k [ ++0 i2j +o4p } +i31 p1 +k z3 +i5e O23 +'2 $ s7} -L7o6h +L7 o6h sa/ -p2o0l -o5TO72 -O06O32 -i6Yt +p2 o0l +o5T O72 +O06 O32 +i6Y t s@+ -*37$A -o0f$1 -$U*37 -'6^j -$;O02 +*37 $A +o0f $1 +$U *37 +'6 ^j +$; O02 s2L -R0^9 -$qL7 -T4o8o -L1o2n -@9*A9 -i90c +R0 ^9 +$q L7 +T4 o8o +L1 o2n +@9 *A9 +i90 c i2! -s1!Z2 -+1i1u -*A8O35 -tO91 -p4O94 +s1! Z2 ++1 i1u +*A8 O35 +t O91 +p4 O94 s#+ i2/ -O27*A9 -o1tp1 -LB@2 -D0i1V -*13sc2 -D5*46 -DBO05 -R9Z5 -*63$j -u$o --8o6b -+6s57 -i6Psf6 +O27 *A9 +o1t p1 +LB @2 +D0 i1V +*13 sc2 +DB O05 +R9 Z5 +*63 $j +u $o +-8 o6b ++6 s57 +i6P sf6 s8 -^T^Q --1^i -i8c*57 -o8e'9 -O61o68 -s58+8 -*35*24 -^!*40 -T3Z2 -*18O62 -+4O62 +^T ^Q +-1 ^i +i8c *57 +o8e '9 +O61 o68 +s58 +8 +*35 *24 +^! *40 +T3 Z2 +*18 O62 ++4 O62 sa+ -o5u[ -$;*01 -sdc^B -$2z4 --3sCg -i7_c -$3^d +o5u [ +$; *01 +sdc ^B +$2 z4 +-3 sCg +i7_ c +$3 ^d o6= -*28c -*52 -*65'9 +*28 c +*65 '9 i9P -o13Z1 -*B9o2o -$.O05 -s28T0 -p2D3 -D2'A -o1ai4- -L3-5 -*B2O89 -i3m+2 -o2rZ3 -o7kr -$m^+ -z1^ -s4n^M -o71$7 -^3o2x -+7OA2 -^Iz2 -sdbO31 -i1,i2. -*49$2 -z1iA1 -p2O95 -k$q -co32 -'3s.` -[o0q -i47*47 -sdXr -$#+7 -+1'A -p1o5y +o13 Z1 +*B9 o2o +$. O05 +s28 T0 +p2 D3 +D2 'A +o1a i4- +L3 -5 +*B2 O89 +i3m +2 +o2r Z3 +o7k r +$m ^+ +z1 ^ +s4n ^M +o71 $7 +^3 o2x ++7 OA2 +^I z2 +sdb O31 +i1, i2. +*49 $2 +z1 iA1 +p2 O95 +k $q +c o32 +'3 s.` +[ o0q +i47 *47 +sdX r +$# +7 ++1 'A +p1 o5y s54 -o3h[ -o5-1 -^w*53 -+1Z2 -O04$3 +o0> -1 ++1 Z2 +O04 $3 i5# o0_ -O14{ +O14 { sb^ -'BT7 -i0sp1 +'B T7 +^s p1 o9; -$5*57 -*03*36 -$!+4 -*43*12 -$j[ -ci6C -$,D8 -D0oB2 -$9r +$5 *57 +*03 *36 +$! +4 +*43 *12 +$j [ +c i6C +$, D8 +D0 oB2 +$9 r s27 sim -$f*96 -T4T3 -'6^w -*58$. -^hZ1 +$f *96 +T4 T3 +'6 ^w +*58 $. +^h Z1 s1q -ko29 -O24o4 --5*46 -$D$I -i3q{ -i5eZ1 -R0^s -i1:} -sgjL5 -*12p1 -o3t^s +k o29 +O24 o4 +-5 *46 +$D $I +i3q { +i5e Z1 +R0 ^s +i1: } +sgj L5 +o3t ^s sxa -o3Cl -i53*81 -o64i3r -O03O94 -i5f*03 -D1i5+ +o3C l +i53 *81 +o64 i3r +O03 O94 +i5f *03 +D1 i5+ o5{ -^1c -o2r$. +o2r $. i4T -o55Z5 -i6nc -$6^6 -$8O63 -oA1+9 -R1$0 -O83c -Co4b +o55 Z5 +i6n c +$6 ^6 +$8 O63 +oA1 +9 +R1 $0 +O83 c +C o4b o2R -i2d-1 -^k+4 -[$b -O42^D --9$! -*63o1l -o0rO24 -O05c +i2d -1 +[ $b +O42 ^D +-9 $! +*63 o1l +o0r O24 +O05 c s2t -s9 D4 -*54O12 -f@6 +s9 D4 +*54 O12 +f @6 sfd -i76D5 -i4cl -o97^! -s5bL0 -i5-$3 +i76 D5 +i4c l +o97 ^! +s5b L0 +i5- $3 i2G -i7]} -[i1# -i1q{ -@m*AB -i83-7 -Z4*A8 -^s-1 -*BAc --1*27 -O73o8! -RA$0 -$6*B9 -@uo53 -z1$T -i1d*65 -@l'9 -p1OA7 -$f*91 -O31$8 +i7] } +[ i1# +i1q { +@m *AB +i83 -7 +Z4 *A8 +^s -1 +*BA c +-1 *27 +O73 o8! +RA $0 +@u o53 +i1d *65 +@l '9 +$f *91 +O31 $8 si+ -+3o0d -ser*26 -z2*65 -o2 ^? --8^1 -sui*23 -oAak -O91s92 ++3 o0d +ser *26 +z2 *65 +o2 ^? +sui *23 +oAa k +O91 s92 se. -*36*28 -r@e -O02o1. -D2Z4 +*36 *28 +O02 o1. +D2 Z4 o5& -$eL8 -$OO53 -$+@3 -*3Bl -ksd3 -*A0T2 -o0$*54 -+1+2 -$A$a -O62se< -O23o36 -to1B -T0+1 -i9/D8 -i60*62 +$e L8 +$O O53 +$+ @3 +*3B l +k sd3 +*A0 T2 +o0$ *54 ++1 +2 +$A $a +O62 se< +O23 o36 +t o1B +T0 +1 +i9/ D8 +i60 *62 o4X -+8*70 -T5o4} -u*63 -i4fp1 ++8 *70 +T5 o4} +u *63 +i4f p1 se9 -i0/i1) +i0/ i1) o5X -o8%O31 -D1$$ -O47c -Z1^n +o8% O31 +D1 $$ +O47 c +Z1 ^n o1* sFl -k*38 -csiu -D5i1j +c siu +D5 i1j s.l -i6no7j -T5'B -+4q -$ @# -dsxZ -^wi1r -$.*76 -T0st5 -o1M{ -T7i0R +i6n o7j +T5 'B ++4 q +$ @# +d sxZ +^w i1r +$. *76 +T0 st5 +o1M { +T7 i0R s5e -$0s9a +$0 s9a s7a -*63o3q -T5$v -^!o3/ -^ ^x -co42 -o69*71 -$F+7 -$@O12 -O56O74 -scZu -D3$? -^ri4y -i7h$2 -T4r -*67s1/ -^sp1 -@c*24 +*63 o3q +T5 $v +^! o3/ +^ ^x +c o42 +o69 *71 +$F +7 +$@ O12 +O56 O74 +scZ u +D3 $? +^r i4y +i7h $2 +T4 r +*67 s1/ +@c *24 sw9 -iA_O46 -i2_l -o2g$# -Z5$8 -DBi01 -i9k*A6 -i0Md -o3nD2 -O54$. -O43+4 -OB3RB -qO19 -i2rO01 -ui4O -$8q -i4w'9 -O81o8- -*0AO7A -*02o1a -O32Z3 -*70Z1 -$<$1 --7i68 -oAl'B -$Ft -o0fRA -O72o6u -oA2$! -$_d -o7Uc -tO62 -$P^^ +iA_ O46 +i2_ l +o2g $# +Z5 $8 +DB i01 +i9k *A6 +o3n D2 +O54 $. +O43 +4 +OB3 RB +q O19 +i2r O01 +$8 q +i4w '9 +O81 o8- +*0A O7A +*02 o1a +O32 Z3 +*70 Z1 +$< $1 +-7 i68 +oAl 'B +$F t +o0f RA +O72 o6u +oA2 $! +$_ d +o7U c +t O62 +$P ^^ shM -$3-8 -$9{ -+6c -i21^2 -s54-1 -o4wf -O12i5 +$3 -8 +$9 { ++6 c +i21 ^2 +s54 -1 +o4w f +O12 i5 s!2 -p2D6 -{sue -D2D2 +p2 D6 +{ sue +D2 D2 sa2 -*95*5A -sls^a -i6d*60 +*95 *5A +sls ^a +i6d *60 i4A -'6i3m -i8zO05 -+8o7_ +'6 i3m +i8z O05 ++8 o7_ o2G -*7BO64 -i56+6 -o5t+2 -+3o6e -i0zz1 -T5*45 -o28l -Z1i7N -+7R5 -o4 L5 -*67$0 -sreD5 +*7B O64 +i56 +6 +o5t +2 ++3 o6e +i0z z1 +T5 *45 +o28 l +Z1 i7N ++7 R5 +o4 L5 +*67 $0 +sre D5 ^u -i4 *81 -*59o90 -O43f -slm$w -RAOB3 -}O21 -@u*82 -+AO62 -s 5$8 -O21-0 -*57@9 -sjf*7A -$aO02 -^%z1 -$o^C -ks8k -i3gT6 -o0Z$Z -z2i14 -^aD9 -^,-1 -z1@2 -Z4+0 +i4 *81 +*59 o90 +O43 f +slm $w +RA OB3 +} O21 +@u *82 ++A O62 +s 5 $8 +O21 -0 +*57 @9 +sjf *7A +$a O02 +^% z1 +$o ^C +k s8k +i3g T6 +o0Z $Z +z2 i14 +^a D9 +^, -1 +z1 @2 +Z4 +0 *39 -o5j*50 -+0^g -^oi1' -s76c -+8Z2 -+0*58 -oA_O05 +o5j *50 ++0 ^g +^o i1' +s76 c ++8 Z2 ++0 *58 +oA_ O05 sLF s6, -$"p1 -O13L0 -D8$f -Z2O26 -^L$i -+9$. -^.-1 -$6+8 -*01z2 -^lO36 -i6aO05 -T6i0N -$-O12 -+6$! -ko6f -o7W'9 -D6^t -p1sGb -$sO43 -i4k[ -O01o6, -$YL7 -s38O52 -iAnO64 -i4M+0 -*53o8o +$" p1 +O13 L0 +D8 $f +Z2 O26 +^L $i ++9 $. +^. -1 +$6 +8 +^l O36 +i6a O05 +T6 i0N +$- O12 ++6 $! +k o6f +o7W '9 +D6 ^t +p1 sGb +$s O43 +i4k [ +O01 o6, +$Y L7 +s38 O52 +iAn O64 +i4M +0 +*53 o8o iAe -^c$m -*50u -Z2-A -li1Q -{$x -co0r -i6y-8 -o91Z2 +^c $m +*50 u +Z2 -A +l i1Q +{ $x +c o0r +i6y -8 +o91 Z2 s8j -l$7 -O73t -[o41 -*83i54 -to66 -o7or -o88o9! -*94O73 -o6o*61 -'9i6* -O42sa -i5.T2 -Z1$% -co2$ -$tO02 -O15O41 +l $7 +O73 t +[ o41 +*83 i54 +t o66 +o7o r +o88 o9! +*94 O73 +o6o *61 +'9 i6* +O42 sa +i5. T2 +Z1 $% +c o2$ +$t O02 +O15 O41 o9% --5O03 -o3sC +-5 O03 +o3s C sfJ -$2+4 -}^6 -saoZ4 -i5_*97 -O56*28 -^jc -^lD2 -*36T9 -^.^f -Z3sdz --5*74 +$2 +4 +} ^6 +sao Z4 +i5_ *97 +O56 *28 +^j c +^l D2 +*36 T9 +^. ^f +Z3 sdz +-5 *74 skf -O74$# -o5w*75 -o0mz1 -Z1O52 -*97D1 +O74 $# +o5w *75 +o0m z1 +Z1 O52 +*97 D1 o7W -T9*29 +T9 *29 s8* -$4sdr +$4 sdr siG -+1O24 --2o4y -k^h -t-3 -$dO02 -R4D6 ++1 O24 +-2 o4y +k ^h +t -3 +$d O02 +R4 D6 i3N -p1D9 -i52$A -i1b+9 -o2*z1 -p1O57 -o5GD6 --0+6 -t*37 +p1 D9 +i52 $A +i1b +9 +o2* z1 +p1 O57 +o5G D6 +-0 +6 +t *37 srZ -co3- -s29$e +c o3- +s29 $e sqw -sf+z1 -o70^i -uo3s -Z1i9s -o0({ -l$% -o73$+ -^1O73 -i8hR7 -*68^? -T5o7h -dsS -i9.+B -+1$f -*54O23 -o18^M -@2o94 -O13^e +sf+ z1 +o70 ^i +u o3s +Z1 i9s +o0( { +l $% +o73 $+ +^1 O73 +i8h R7 +*68 ^? +T5 o7h +d sS +i9. +B ++1 $f +*54 O23 +o18 ^M +@2 o94 +O13 ^e o3h i8! --8q -$m-0 -o5,Z2 -O05q -}i7g +-8 q +$m -0 +o5, Z2 +O05 q +} i7g s7! -i67Z1 -Z1O83 -lO76 -o8gk +i67 Z1 +Z1 O83 +l O76 +o8g k s3j -$liAx -}o0v -^Eu -O02$" -oB O0A -O32o2 -i33i40 -*86D3 --9*01 -sfc^k -$7$j -o58Z4 -p2z2 -o0YZ4 -d^s -i8aO53 -*76*34 -O04o51 +$l iAx +} o0v +^E u +O02 $" +oB O0A +O32 o2 +i33 i40 +*86 D3 +-9 *01 +sfc ^k +$7 $j +o58 Z4 +p2 z2 +o0Y Z4 +d ^s +i8a O53 +*76 *34 +O04 o51 ssl -O64$@ -O03Z4 +O64 $@ +O03 Z4 i6[ -@5^9 -o0vl -O63@f +@5 ^9 +o0v l +O63 @f s* -l*79 -$+Z3 -*59D2 -$b$, +l *79 +$+ Z3 +*59 D2 +$b $, s0! -DA$b -+9i8 -fO5A -^7*35 -D6sng -^m*08 -o3+D6 -i0}^{ -i7aZ2 -+8*76 -*40D4 -D9D4 -O71o6j -ts52 -D7$8 -p1o7d -T8o04 -'B+5 -DA-A --7} -$b^h -O08i1a -L1R0 -$\l -o13$_ -Co4F -l*7B -^0z2 -i49p2 -o55*78 -o3Ql -$ $m -R0$8 +DA $b ++9 i8 +f O5A +^7 *35 +D6 sng +^m *08 +o3+ D6 +i0} ^{ +i7a Z2 +*40 D4 +D9 D4 +O71 o6j +t s52 +D7 $8 +p1 o7d +T8 o04 +'B +5 +DA -A +-7 } +$b ^h +O08 i1a +L1 R0 +$\ l +o13 $_ +C o4F +l *7B +^0 z2 +i49 p2 +o55 *78 +o3Q l +$ $m +R0 $8 oA+ -+7*98 -@v[ -$ED8 -$fZ2 -kZ1 -'5o1g -RBO02 -$o+4 -o8.$1 -$/s1. -i4s@b -o50^b -$]i3[ -i1to4e -p3Z2 -o82*79 -^[L0 -Z3su- -$Uc -i6l*83 -O02O13 -$7sgc ++7 *98 +@v [ +$E D8 +$f Z2 +k Z1 +'5 o1g +RB O02 +$o +4 +o8. $1 +$/ s1. +i4s @b +o50 ^b +$] i3[ +i1t o4e +p3 Z2 +o82 *79 +^[ L0 +Z3 su- +$U c +i6l *83 +O02 O13 +$7 sgc sog -o4m*07 -o59d -ciA2 -cs2I -ti7P -tO26 -$3O92 -z5O61 -c*58 -$I^R -O21o9x -$ki5f -$ sMP +o4m *07 +o59 d +c iA2 +c s2I +t i7P +t O26 +$3 O92 +z5 O61 +c *58 +$I ^R +O21 o9x +$k i5f +$ sMP o3F -$+O53 +$+ O53 slc -i1C{ -O32D1 --0-5 -o4-*54 -$A+7 -z1o2y -*86o5 -o5f-4 -^RD3 -[o04 -D3-8 -D6o7: -p1$v -$1+B -sjrT4 -+4D5 -D1*13 -^.z4 -^At -*94o0t -lo42 -co8o -$9O72 -T5T7 -^8z4 -^d*0A +O32 D1 +-0 -5 +o4- *54 +$A +7 +z1 o2y +*86 o5 +o5f -4 +^R D3 +[ o04 +D3 -8 +D6 o7: +p1 $v +$1 +B +sjr T4 ++4 D5 +^. z4 +^A t +*94 o0t +l o42 +c o8o +$9 O72 +T5 T7 +^8 z4 +^d *0A i18 -$++7 -Z1o4! +$+ +7 +Z1 o4! o5) -O81D1 -o4Yc -o4qD5 -R4*30 +O81 D1 +o4Y c +o4q D5 +R4 *30 i6N -*17-8 +*17 -8 smd -o0g*34 -O24*36 -i5c*24 -$2O32 +o0g *34 +O24 *36 +i5c *24 +$2 O32 s!^ -D6+7 -'Bi5n -*73$_ +D6 +7 +'B i5n +*73 $_ s1L -Z1i3: -i3go98 -*58O91 -[$3 -+4'5 -D7i1q -$2D4 -Z4o8 -*56o2l -*89^q -ci9G +Z1 i3: +i3g o98 +*58 O91 +[ $3 +D7 i1q +$2 D4 +Z4 o8 +*56 o2l +*89 ^q +c i9G @i -T0s8 -i8_Z1 -lo8d -O23$l -+3T5 -o5u$3 -$8O41 -'4^d -$di0t -^mT5 -*63o5t -*56Z2 -i4/ -*84u -O32@= -+8$g -^v'6 --8+4 -+1D7 +T0 s8 +i8_ Z1 +l o8d +O23 $l ++3 T5 +o5u $3 +$8 O41 +'4 ^d +$d i0t +^m T5 +*63 o5t +*56 Z2 +*84 u +O32 @= ++8 $g +^v '6 +-8 +4 ++1 D7 sgr -+8^a -O03o66 -o5hi5C -R9+4 -s8t[ -^eO46 -O16o3 -s9_r -d*45 -o4^l -+5l --1^3 -o80i0* -*82T5 ++8 ^a +O03 o66 +o5h i5C +R9 +4 +s8t [ +^e O46 +O16 o3 +s9_ r +d *45 +o4^ l ++5 l +-1 ^3 +o80 i0* +*82 T5 smr -*74*94 -OA1DB -O84*78 -i5k*28 -o3Fi3B -DAD4 -D3o55 -o4*Z3 -R0p5 -L0^w -szef -i8-T0 -i0 *05 -[i6= -sr&u -o9Esa@ -*20s29 -co4V -i65Z3 -z1$k -src-1 -Cs49 -'2k -^nO31 -*48i5K -O31O43 -csgV -o7y^j +*74 *94 +OA1 DB +O84 *78 +i5k *28 +o3F i3B +DA D4 +D3 o55 +o4* Z3 +R0 p5 +L0 ^w +sze f +i8- T0 +i0 *05 +[ i6= +sr& u +o9E sa@ +*20 s29 +c o4V +i65 Z3 +z1 $k +src -1 +C s49 +'2 k +^n O31 +*48 i5K +O31 O43 +c sgV +o7y ^j *5A -o0hu +o0h u o7- sh^ i3| -ro0" -i3Wl -$fT0 -*09O03 -Z3$1 -Z3O54 -o6a*36 -T6O12 --7s., -$r*A9 -suoo4! -*20o4 --5+8 -i42c -'B*97 -^a$v -+2sui -i7,O25 -*31O24 -$1s7_ -'8o0E +r o0" +i3W l +$f T0 +*09 O03 +Z3 $1 +Z3 O54 +o6a *36 +T6 O12 +-7 s., +$r *A9 +suo o4! +*20 o4 +-5 +8 +i42 c +'B *97 +^a $v ++2 sui +i7, O25 +*31 O24 +$1 s7_ +'8 o0E sa; -$$i0* -$_O25 -o4.D6 -O01i8i -i7D^1 -*30*43 -o02Z1 -o6t} -o4loB2 -$Jo1o +$$ i0* +$_ O25 +o4. D6 +O01 i8i +i7D ^1 +*30 *43 +o02 Z1 +o6t } +o4l oB2 +$J o1o shb -o8rZ2 -$]o4[ +o8r Z2 +$] o4[ sgi -^c^a -sa7Z2 -O52^$ -s52o71 -$5@w -p2O56 -{Z3 -^@$ -^fi10 -O93O07 -*08O45 -z1$h -i4tD0 -D3T3 +^c ^a +sa7 Z2 +O52 ^$ +s52 o71 +$5 @w +p2 O56 +{ Z3 +^@ $ +^f i10 +O93 O07 +*08 O45 +z1 $h +i4t D0 +D3 T3 o8: -p2O02 -*26o3G -D5l -D7$ -^9O31 +p2 O02 +*26 o3G +D7 $ +^9 O31 O27 -o7 @6 --2'A -@1o64 -o3lo0H -s30*65 -$+^N +o7 @6 +-2 'A +@1 o64 +o3l o0H +s30 *65 +$+ ^N so^ -to75 -O41^K -O82*48 -o94Z1 --6o5z -i4o-3 -*74L5 -O14R3 +O41 ^K +O82 *48 +o94 Z1 +-6 o5z +i4o -3 +*74 L5 +O14 R3 sly -D5$w -p2i4 -O17{ -s0 q -O68Z1 -D5o7D -o0w*05 -*73$m -@5$7 -o5n{ +D5 $w +p2 i4 +O17 { +s0 q +O68 Z1 +D5 o7D +o0w *05 +*73 $m +@5 $7 +o5n { sBZ -o6 $k +o6 $k i5T -O89$i -^Bo7X -O0B$' -O72^m +O89 $i +^B o7X +O0B $' +O72 ^m sa? -T5-3 -o5/@g +T5 -3 +o5/ @g s3@ s1& -^9$G -'A$? -p4Z4 -O12s81 +^9 $G +'A $? +p4 Z4 +O12 s81 sf6 -sb c -+9D7 -ti5N -T9Z1 -sbyl -$$D2 -*45o6` -qo0s -s7OD8 -co1A -L5*34 -*78O62 -$*i2e -$r$! -$k{ -i3h[ -i5x+2 +sb c ++9 D7 +t i5N +T9 Z1 +sby l +$$ D2 +*45 o6` +q o0s +s7O D8 +c o1A +L5 *34 +*78 O62 +$* i2e +$r $! +$k { +i3h [ +i5x +2 sAF -*01O61 -'Ao43 -i1r -ti9N +*01 O61 +'A o43 +t i9N oA6 -$p*64 -O01*38 -R6^! -o0bC -[L0 -^2i5d -i7Ml -^n^n -*57i3s -o4pD1 -L0O16 -i84+7 --4*03 -CsO= -i3@k -Ci21 -*75$m -}^$ -fi41 -'6o3t -OB3s7f -i0oz1 -si z5 -$+sla -z2o4Z -+9D0 -ci6b -O81O12 -z4c +$p *64 +O01 *38 +R6 ^! +o0b C +^2 i5d +i7M l +*57 i3s +o4p D1 +L0 O16 +i84 +7 +C sO= +i3@ k +C i21 +*75 $m +} ^$ +f i41 +'6 o3t +OB3 s7f +i0o z1 +si z5 +$+ sla +z2 o4Z ++9 D0 +c i6b +O81 O12 +z4 c i4< snq -i37O03 -i4!{ -*46i5g -srXo3k -ui6\ -D2z2 -i69+7 -qO26 -o99*19 -o0yr -D6sGM -O23L5 -O73R8 -OB1o1s -O05$+ -o5a+9 -i3l[ -$$i01 -$@O02 -O14-1 -*76scv -o5mk -@eO12 -d+0 -$u$w -L7*17 -*27^2 -Z2o9! -D9o8d -rR0 -O71T7 -@1^a -*15$u -i2w*03 -o1rt -i4Nu -i6=c -p1*7A -Z3RA -$;u -z2c -O52'A -Z1sa? +i37 O03 +i4! { +*46 i5g +srX o3k +u i6\ +D2 z2 +i69 +7 +q O26 +o99 *19 +o0y r +D6 sGM +O23 L5 +O73 R8 +OB1 o1s +O05 $+ +o5a +9 +i3l [ +$$ i01 +$@ O02 +O14 -1 +*76 scv +o5m k +@e O12 +$u $w +L7 *17 +*27 ^2 +Z2 o9! +D9 o8d +r R0 +O71 T7 +@1 ^a +*15 $u +i2w *03 +o1r t +i4N u +i6= c +p1 *7A +Z3 RA +$; u +z2 c +O52 'A +Z1 sa? i9. -+8T2 -^b*30 -^Di0O ++8 T2 +^b *30 +^D i0O szL -'7C -$.*54 -$LT9 -'B$4 -i7gc -i2*-1 +'7 C +$L T9 +'B $4 +i7g c +i2* -1 sr+ -Z1s6) -$ $t +Z1 s6) +$ $t o7C -*74Z2 -'9snP -o2f} -^ni1d -co9$ -$][ -tOA2 -$2l -srHO21 --3^$ -^.i1/ +*74 Z2 +'9 snP +o2f } +^n i1d +c o9$ +$] [ +t OA2 +$2 l +srH O21 +-3 ^$ +^. i1/ i5` -[i11 -O09T5 -T4o5i -+6+4 +[ i11 +O09 T5 +T4 o5i ++6 +4 s7v -OB3O17 -o83*65 -D7^n -fO83 -D2$o -O94O26 -o2zT4 -O62^a +OB3 O17 +o83 *65 +D7 ^n +f O83 +D2 $o +O94 O26 +o2z T4 +O62 ^a s5. -slz'6 -O06'B -$1*89 -sws$9 --3*75 -li8t -+9i8d -svjO52 -rsb9 --6$x -^Co1a -*15o1u -$boB2 -$5R0 +slz '6 +O06 'B +$1 *89 +sws $9 +l i8t ++9 i8d +svj O52 +r sb9 +-6 $x +^C o1a +*15 o1u +$b oB2 +$5 R0 sGm -lsuy -*39+5 -*76'B -o65$M -$+Z5 -c$y --4L4 -'2o0> -+1smd -$s-5 -'5i2l -o79l +l suy +*39 +5 +*76 'B +o65 $M +$+ Z5 +c $y +-4 L4 +'2 o0> ++1 smd +$s -5 +'5 i2l +o79 l smb -Z1+2 -ro41 -O23siL -c^ -O23Z2 +Z1 +2 +r o41 +O23 siL +c ^ +O23 Z2 o7: -*32*25 -*53[ -{^0 -o69s74 -$k*A8 -*40O27 -$;-7 -$3^N -i02^l +*32 *25 +{ ^0 +o69 s74 +$k *A8 +*40 O27 +$; -7 +$3 ^N +i02 ^l s2? -Z1o07 +Z1 o07 scj -*57*06 -i52R2 -*87i88 -fO75 -^n*03 -$p*61 -sw-r -*9A@0 -$s*68 -{$s -tO42 -^fO61 -z3@d -+4+3 -[o0S -*54-8 -sgw$7 -*43suo -p1o2r -z1*32 -i5zO14 -D6i01 -Z2i5r -o61O76 -O23^m --2-1 -sH@Z2 -o7m+8 -*46o7E -O03z5 -*06*15 -R7O43 -O56L5 -p1s19 -co6T -*65Z3 -swV$! -}i14 -rL7 -*25i5a -^1*36 -o8ul -*A9RB -i50$s -}sAu -z1Z3 --0i3j -i2gse -i1ai7o -o0n*61 -^H*63 -i61R1 -{iA0 --3z3 -Z3o0d -Z1o3t -R4O51 -sc7Z1 -s;Hu -*87$7 +*57 *06 +i52 R2 +*87 i88 +f O75 +^n *03 +$p *61 +sw- r +*9A @0 +$s *68 +{ $s +t O42 +^f O61 +z3 @d ++4 +3 +[ o0S +*54 -8 +sgw $7 +*43 suo +p1 o2r +z1 *32 +i5z O14 +D6 i01 +Z2 i5r +o61 O76 +O23 ^m +-2 -1 +sH@ Z2 +o7m +8 +*46 o7E +O03 z5 +*06 *15 +R7 O43 +O56 L5 +p1 s19 +c o6T +*65 Z3 +swV $! +r L7 +*25 i5a +^1 *36 +o8u l +*A9 RB +i50 $s +} sAu +z1 Z3 +-0 i3j +i2g se +i1a i7o +o0n *61 +^H *63 +i61 R1 +{ iA0 +-3 z3 +Z3 o0d +Z1 o3t +R4 O51 +sc7 Z1 +s;H u +*87 $7 o2w -$rL5 -O43d -z1sf_ -i8=O53 -*24i6^ -@1+8 -}o2# -O72T2 -DBsab -+3o8a +$r L5 +O43 d +z1 sf_ +i8= O53 +*24 i6^ +@1 +8 +} o2# +O72 T2 +DB sab ++3 o8a sAZ -O09o2 -Z2i5x +O09 o2 +Z2 i5x OB8 -oByO26 -$fO91 -$8*23 -*76-9 -L3{ -$dR0 -o1D*21 +oBy O26 +$f O91 +$8 *23 +L3 { +$d R0 +o1D *21 suw -*19$2 -z4-2 +*19 $2 +z4 -2 O48 -'B@z -^p'A -*72'6 -{^E -$4*86 -*14i0m +'B @z +^p 'A +*72 '6 +{ ^E +$4 *86 +*14 i0m O16 -$!^% -i3uc -+8} -o3rO42 -z4z4 -o0v'5 -D6o2w -Z1o5c -Z2i7Y -$6O73 +$! ^% +i3u c ++8 } +o3r O42 +o0v '5 +D6 o2w +Z1 o5c +Z2 i7Y +$6 O73 o7H -^Mi6i -O54i6i -$5@6 -$7z2 +^M i6i +O54 i6i +$5 @6 +$7 z2 o8# --0O25 -Z1$n +Z1 $n sp< -{^8 -Z3-A -r*14 -o4xc -z4l -$t$g -^Bz1 -+5D4 -i5oL4 -OB3l -o8Kr -^yO41 -rO05 -s!(D5 -$.$$ -o2B-9 -O16^a -$yO04 -{*65 +{ ^8 +Z3 -A +o4x c +z4 l +$t $g ++5 D4 +i5o L4 +OB3 l +o8K r +^y O41 +r O05 +s!( D5 +$. $$ +o2B -9 +O16 ^a +$y O04 +{ *65 o3P -z1+2 -i0Dz3 -$*^+ -Z2o5F -$i-9 +i0D z3 +$* ^+ +Z2 o5F +$i -9 sO8 -^pz3 -L6O4B -O07-0 -$pl -O25l +^p z3 +L6 O4B +O07 -0 +$p l +O25 l o0U s2_ -+5+4 -Z4i0r ++5 +4 +Z4 i0r sxp -*67k -*76z1 -*36^m -$2Z4 -Z2$z -T7i3? -'9$c -si^l -^`r -*A8[ -'8i5e -^M+4 +*67 k +*76 z1 +*36 ^m +$2 Z4 +Z2 $z +T7 i3? +'9 $c +si^ l +*A8 [ +'8 i5e +^M +4 sCK -*78i6k -^6$2 -o6!i58 -lL5 -o4x*46 -D1*68 -i1uo3i -*14*34 -z2scl -O8Ap1 -$:T6 -s-@-8 -*56o6q -[*76 -o1up1 +*78 i6k +^6 $2 +o6! i58 +l L5 +o4x *46 +i1u o3i +*14 *34 +z2 scl +O8A p1 +$: T6 +s-@ -8 +*56 o6q +o1u p1 s46 -C'5 -i8t$0 -T8O31 -z1^G -i4cc +C '5 +i8t $0 +T8 O31 +z1 ^G +i4c c O58 -O61s8m -T2i0y -o8=s_g -p2OB9 -li5e --9Z1 -Z3p3 -^3^< -*78$6 -z5O24 -R0R2 -p1^a -^4$s +O61 s8m +T2 i0y +o8= s_g +p2 OB9 +-9 Z1 +Z3 p3 +^3 ^< +*78 $6 +z5 O24 +R0 R2 +p1 ^a +^4 $s se7 -O41Z3 --8@6 +O41 Z3 +-8 @6 i9m -Z2O28 --0-7 -T2$! -s[iT0 -O62i6m -OB2C -i7es17 -Z1^h -o67$A -*75o1h -o9bi9/ -u@E -$+-A -s53T0 -L7$4 -Z2O21 -T5*67 -+4o0t -O05D3 -*0At --1'7 -$8O92 -'9i2l --2Z1 +Z2 O28 +-0 -7 +T2 $! +s[i T0 +O62 i6m +OB2 C +i7e s17 +o67 $A +*75 o1h +o9b i9/ +u @E +$+ -A +s53 T0 +L7 $4 +Z2 O21 +T5 *67 ++4 o0t +O05 D3 +*0A t +-1 '7 +$8 O92 +'9 i2l +-2 Z1 sl_ -+8R2 ++8 R2 i1" -$_$s -O71$E --7Z3 -+5O62 -Z3o0m -o8l-7 -Z1*97 -^vR1 +$_ $s +O71 $E +-7 Z3 +Z3 o0m +o8l -7 +Z1 *97 +^v R1 O4B -T4O8B -*A1O16 -ro6U -o6!k --2o0g -sZ+O01 -+9p1 -sL3'9 -co64 -o3Yl -i4rO91 -i3!c -*01o6. -O23i1b +T4 O8B +*A1 O16 +r o6U +-2 o0g +sZ+ O01 ++9 p1 +sL3 '9 +c o64 +o3Y l +i4r O91 +i3! c +*01 o6. +O23 i1b i35 -R0@o -D2p1 -'5z5 -'9u -o91*A9 --4o7e -^sk -fZ5 -$a$6 -*A9o9J -$G$E +R0 @o +'5 z5 +o91 *A9 +-4 o7e +f Z5 +$a $6 +$G $E i1V -o27+8 -^l'9 -z2@i -O13^S -z2@q -'8$h -[i1w -ri1k -'9$1 -$F*23 -p1*69 -$AZ3 -sn7d -^az2 -li1\ -Z3O63 -*14 -R4*64 -o1%z1 -'Bsoa -*09O34 -p1-3 --5sb- -i4,c -sdc-3 -sf7Z1 -O72z1 -$r$n +o27 +8 +^l '9 +z2 @i +O13 ^S +z2 @q +'8 $h +[ i1w +r i1k +'9 $1 +$F *23 +p1 *69 +$A Z3 +sn7 d +^a z2 +l i1\ +Z3 O63 +R4 *64 +'B soa +*09 O34 +p1 -3 +-5 sb- +i4, c +sdc -3 +sf7 Z1 +O72 z1 +$r $n i3$ -o93D8 --5o1_ -{$2 +o93 D8 +-5 o1_ +{ $2 s.7 -sndO02 -$E[ -R3O73 -z2o1l -O34O52 -^di31 -o1ii04 -D8@7 -T3si1 -o4$Z1 -'9R8 -z1t -o6 @a -$ro6 -*07+0 -Z2o2d -+4$N -o87O52 -$m*28 -sy5i31 +snd O02 +$E [ +R3 O73 +z2 o1l +O34 O52 +^d i31 +o1i i04 +D8 @7 +T3 si1 +o4$ Z1 +'9 R8 +z1 t +o6 @a +$r o6 +*07 +0 +Z2 o2d ++4 $N +o87 O52 +$m *28 +sy5 i31 sO% -$g$s -C-7 --8O61 -i4=*86 -Ci9v -qt -i74^3 +$g $s +C -7 +-8 O61 +i4= *86 +C i9v +q t +i74 ^3 i0" -O83$M +O83 $M sm- -*A8s0x +*A8 s0x o2# -@Sz1 -^4C -o4dO71 -[-6 -^r'B -$TL6 -o4,*06 -ui6r -^iO12 -'9*83 -z2*74 -*53q --4-2 -o2Vt +@S z1 +^4 C +o4d O71 +[ -6 +^r 'B +$T L6 +o4, *06 +u i6r +^i O12 +'9 *83 +-4 -2 +o2V t o9! sA9 -O54$y -Z4O13 +O54 $y +Z4 O13 ^O -+7oAo -$#o69 -$4Z3 -+3^b -fOA8 -+7u -+0*37 ++7 oAo +$# o69 +$4 Z3 ++3 ^b +f OA8 ++7 u sfm -z1o1* +z1 o1* i5H -*41-0 -T0i3m -O02^b --2*26 -$9@O -O19p2 -O04'5 -p4O1B -T4O02 -d+B -se,$5 -$od -i7mT4 -*21i4t -i62Z2 -T4sc$ -O93l -Z1o5C +*41 -0 +T0 i3m +O02 ^b +-2 *26 +$9 @O +O19 p2 +O04 '5 +p4 O1B +T4 O02 +se, $5 +$o d +i7m T4 +*21 i4t +i62 Z2 +T4 sc$ +O93 l +Z1 o5C s7x -*41$z -*B6*89 +*41 $z +*B6 *89 sOK -[T1 -O14O32 -o0kc -o6.^m --6i62 -O09O54 -Z4D1 -i5oc -O18R0 +[ T1 +O14 O32 +o0k c +o6. ^m +-6 i62 +O09 O54 +Z4 D1 +i5o c +O18 R0 $' -O13$y -i0vd -p2O45 -^kR3 -p2Z3 -*75o6e -se [ +O13 $y +p2 O45 +^k R3 +p2 Z3 +*75 o6e +se [ i1G -*86o30 --8*53 -o7zo8o -i4K$4 -$x$t -z5@a -O08*63 -R7+9 -smlk -o8dD9 -o0D'9 -o7$'8 +*86 o30 +-8 *53 +o7z o8o +i4K $4 +$x $t +z5 @a +O08 *63 +R7 +9 +sml k +o0D '9 +o7$ '8 o49 -s1cR0 +s1c R0 o9` s8d -o8kO23 -^1O56 -^ *20 -o1eZ1 -R0$} -*67s- -*15f -^m*40 -usLH -Z4i0= --5*16 -+0R6 +o8k O23 +^1 O56 +^ *20 +o1e Z1 +R0 $} +*67 s- +*15 f +u sLH +Z4 i0= +-5 *16 ++0 R6 $N -+7O41 -o54p2 -*85+5 -$Gr -z2o1- -*49O24 -i5nZ1 ++7 O41 +o54 p2 +*85 +5 +$G r +z2 o1- +*49 O24 +i5n Z1 scF oBE -o0p-1 -uO83 -*87o7z +o0p -1 +u O83 +*87 o7z s,G --B@r -*43$3 -$!*04 -$5o7o -*01scx -T7@E --5l -+8*78 -$9o84 -O52o4g -*45s2_ +-B @r +*43 $3 +$! *04 +$5 o7o +*01 scx +T7 @E +-5 l ++8 *78 +$9 o84 +O52 o4g +*45 s2_ sau -'3sd: +'3 sd: si[ -$9$O -*23*86 -^s+2 -*35o2m +$9 $O +*23 *86 +^s +2 +*35 o2m sZb -T7o22 -^8p1 -@%+6 -o0fO32 -[$: -+7sfb -[o4t -$s[ +T7 o22 +^8 p1 +@% +6 +o0f O32 +[ $: ++7 sfb +[ o4t s9@ -cs2m +c s2m stw -T9L9 -o4jo80 -D3o0N -i2k+4 -li67 +T9 L9 +o4j o80 +D3 o0N +i2k +4 +l i67 iA7 -$/D3 -spyp1 +$/ D3 +spy p1 $< s1$ -$0*67 -Z4O15 -@5R3 -D3i7D -i3o*20 -$#O61 -^p'5 +Z4 O15 +@5 R3 +D3 i7D +i3o *20 +$# O61 +^p '5 sDm -O12i2k -+5L0 -o9A[ -^Ui10 -Z3^# -s5V'A -z2*51 +O12 i2k ++5 L0 +o9A [ +^U i10 +Z3 ^# +s5V 'A +z2 *51 $U -tO03 -i7 kernel_threads_min) { diff --git a/src/backend.c b/src/backend.c index d5f071464..1adaf22c3 100644 --- a/src/backend.c +++ b/src/backend.c @@ -528,7 +528,7 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont return true; } -static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources) +bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources) { HCFILE fp; @@ -617,6 +617,11 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_ return true; } +u32 backend_device_idx_real_from_virtual (const u32 device_idx, const u32 backend_devices_virtual) +{ + return device_idx / backend_devices_virtual; +} + void generate_source_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file) { if (opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) @@ -1050,8 +1055,8 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, // - hooks can have a large influence depending on the OS. // spawning threads and memory allocations take a lot of time on windows (compared to linux). // - the kernel execution can take shortcuts based on intermediate values - // while these intermediate valus depend on input values. - // - if we meassure runtimes of different kernels to find out about their weightning + // while these intermediate values depend on input values. + // - if we measure runtimes of different kernels to find out about their weightning // we need to call them with real input values otherwise we miss the shortcuts inside the kernel. // - the problem is that these real input values could crack the hash which makes the chaos perfect. // @@ -1584,7 +1589,7 @@ static void rebuild_pws_compressed_append (hc_device_param_t *device_param, cons const u32 dst_pw_len4_cnt = dst_pw_len4 / 4; pw_idx_dst->cnt = dst_pw_len4_cnt; - pw_idx_dst->len = src_len; // this is intenionally! src_len can not be dst_len, we dont want the kernel to think 0x80 is part of the password + pw_idx_dst->len = src_len; // this is intentionally! src_len can not be dst_len, we dont want the kernel to think 0x80 is part of the password u8 *dst = (u8 *) (tmp_pws_comp + pw_idx_dst->off); @@ -3507,7 +3512,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (iconv_ctx == (iconv_t) -1) return -1; } - // find higest password length, this is for optimization stuff + // find highest password length, this is for optimization stuff u32 highest_pw_len = 0; @@ -4249,11 +4254,12 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) backend_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; @@ -4390,6 +4396,14 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) backend_ctx->rc_hiprtc_init = rc_hiprtc_init; hiprtc_close (hashcat_ctx); + + #if defined (_WIN) + event_log_warning (hashcat_ctx, "Support for HIPRTC was dropped by AMD Adrenalin Edition 22.7.1 and later."); + event_log_warning (hashcat_ctx, "This is not a hashcat problem."); + event_log_warning (hashcat_ctx, NULL); + event_log_warning (hashcat_ctx, "Please install the AMD HIP SDK"); + event_log_warning (hashcat_ctx, NULL); + #endif } /** @@ -4522,27 +4536,6 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) mtl_close (hashcat_ctx); } - else - { - if (user_options->force == false) - { - // disable metal < 300 - - if (backend_ctx->metal_runtimeVersion < 300) - { - event_log_warning (hashcat_ctx, "Unsupported Apple Metal runtime version '%s' detected! Falling back to OpenCL...", backend_ctx->metal_runtimeVersionStr); - event_log_warning (hashcat_ctx, NULL); - - rc_metal_init = -1; - - backend_ctx->rc_metal_init = rc_metal_init; - - backend_ctx->mtl = NULL; - - mtl_close (hashcat_ctx); - } - } - } } else { @@ -4592,7 +4585,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_warning (hashcat_ctx, " \"AMDGPU\" (21.50 or later) and \"ROCm\" (5.0 or later)"); #elif defined (_WIN) event_log_warning (hashcat_ctx, "* AMD GPUs on Windows require this driver:"); - event_log_warning (hashcat_ctx, " \"AMD Adrenalin Edition\" (Adrenalin 22.5.1 exactly)"); + event_log_warning (hashcat_ctx, " \"AMD Adrenalin Edition\" (23.7.2 or later) and \"AMD HIP SDK\" (23.Q3 or later)"); #endif event_log_warning (hashcat_ctx, "* Intel CPUs require this runtime:"); @@ -4840,6 +4833,13 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) } } + opencl_platform_devices_cnt *= user_options->backend_devices_virtual; + + for (int i = opencl_platform_devices_cnt - 1; i >= 0; i--) + { + opencl_platform_devices[i] = opencl_platform_devices[backend_device_idx_real_from_virtual (i, user_options->backend_devices_virtual)]; + } + opencl_platforms_devices[opencl_platforms_idx] = opencl_platform_devices; opencl_platforms_devices_cnt[opencl_platforms_idx] = opencl_platform_devices_cnt; } @@ -4929,7 +4929,7 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_warning (hashcat_ctx, " \"AMDGPU\" (21.50 or later) and \"ROCm\" (5.0 or later)"); #elif defined (_WIN) event_log_warning (hashcat_ctx, "* AMD GPUs on Windows require this driver:"); - event_log_warning (hashcat_ctx, " \"AMD Adrenalin Edition\" (Adrenalin 22.5.1 exactly)"); + event_log_warning (hashcat_ctx, " \"AMD Adrenalin Edition\" (23.7.2 or later) and \"AMD HIP SDK\" (23.Q3 or later)"); #endif event_log_warning (hashcat_ctx, "* Intel CPUs require this runtime:"); @@ -5010,6 +5010,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cuda_close (hashcat_ctx); } + cuda_devices_cnt *= user_options->backend_devices_virtual; + backend_ctx->cuda_devices_cnt = cuda_devices_cnt; // device specific @@ -5018,6 +5020,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { const u32 device_id = backend_devices_idx; + const u32 cuda_devices_idx_real = backend_device_idx_real_from_virtual (cuda_devices_idx, user_options->backend_devices_virtual); + hc_device_param_t *device_param = &devices_param[backend_devices_idx]; device_param->device_id = device_id; @@ -5026,7 +5030,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) CUdevice cuda_device; - if (hc_cuDeviceGet (hashcat_ctx, &cuda_device, cuda_devices_idx) == -1) + if (hc_cuDeviceGet (hashcat_ctx, &cuda_device, cuda_devices_idx_real) == -1) { device_param->skipped = true; @@ -5417,6 +5421,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) hip_close (hashcat_ctx); } + hip_devices_cnt *= user_options->backend_devices_virtual; + backend_ctx->hip_devices_cnt = hip_devices_cnt; // device specific @@ -5425,6 +5431,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { const u32 device_id = backend_devices_idx; + const u32 hip_devices_idx_real = backend_device_idx_real_from_virtual (hip_devices_idx, user_options->backend_devices_virtual); + hc_device_param_t *device_param = &devices_param[backend_devices_idx]; device_param->device_id = device_id; @@ -5433,7 +5441,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) hipDevice_t hip_device; - if (hc_hipDeviceGet (hashcat_ctx, &hip_device, hip_devices_idx) == -1) + if (hc_hipDeviceGet (hashcat_ctx, &hip_device, hip_devices_idx_real) == -1) { device_param->skipped = true; @@ -5845,6 +5853,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) mtl_close (hashcat_ctx); } + metal_devices_cnt *= user_options->backend_devices_virtual; + backend_ctx->metal_devices_cnt = metal_devices_cnt; // device specific @@ -5853,6 +5863,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { const u32 device_id = backend_devices_idx; + const u32 metal_devices_idx_real = backend_device_idx_real_from_virtual (metal_devices_idx, user_options->backend_devices_virtual); + hc_device_param_t *device_param = &devices_param[backend_devices_idx]; device_param->device_id = device_id; @@ -5861,7 +5873,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) mtl_device_id metal_device = NULL; - if (hc_mtlDeviceGet (hashcat_ctx, &metal_device, metal_devices_idx) == -1) + if (hc_mtlDeviceGet (hashcat_ctx, &metal_device, metal_devices_idx_real) == -1) { device_param->skipped = true; @@ -6223,35 +6235,6 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_param->device_processors == 1) device_param->skipped = true; - // Since we can't match OpenCL with Metal devices (missing PCI ID etc.) and at the same time we have better OpenCL support than Metal support, - // we disable all Metal devices by default. The user can reactivate them with -d. - - if (device_param->skipped == false) - { - if (backend_ctx->backend_devices_filter == -1ULL) - { - if (user_options->backend_info == 0) - { - event_log_warning (hashcat_ctx, "The device #%d has been disabled as it most likely also exists as an OpenCL device, but it is not possible to automatically map it.", device_id + 1); - event_log_warning (hashcat_ctx, "You can use -d %d to use Metal API instead of OpenCL API. In some rare cases this is more stable.", device_id + 1); - event_log_warning (hashcat_ctx, NULL); - } - - device_param->skipped = true; - } - else - { - if (backend_ctx->backend_devices_filter & (1ULL << device_id)) - { - // ok - } - else - { - device_param->skipped = true; - } - } - } - /** * activate device */ @@ -6362,11 +6345,9 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // try CL_DEVICE_BOARD_NAME_AMD first, if it fails fall back to CL_DEVICE_NAME // since AMD ROCm does not identify itself at this stage we simply check for return code from clGetDeviceInfo() - #define CHECK_BOARD_NAME_AMD 1 - cl_int rc_board_name_amd = CL_INVALID_VALUE; - if (CHECK_BOARD_NAME_AMD) + if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) { //backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; @@ -7575,6 +7556,57 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) backend_ctx->backend_devices_cnt = cuda_devices_cnt + hip_devices_cnt + metal_devices_cnt + opencl_devices_cnt; backend_ctx->backend_devices_active = cuda_devices_active + hip_devices_active + metal_devices_active + opencl_devices_active; + #if defined (__APPLE__) + // disable Metal devices if at least one OpenCL device is enabled + if (backend_ctx->opencl_devices_active > 0) + { + if (backend_ctx->mtl) + { + for (int backend_devices_cnt = 0; backend_devices_cnt < backend_ctx->backend_devices_cnt; backend_devices_cnt++) + { + hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_cnt]; + + if (device_param->is_metal == false) continue; + + // Since we can't match OpenCL with Metal devices (missing PCI ID etc.) and at the same time we have better OpenCL support than Metal support, + // we disable all Metal devices by default. The user can reactivate them with -d. + + if (device_param->skipped == false) + { + if (backend_ctx->backend_devices_filter == -1ULL) + { + if ((user_options->quiet == false) && (user_options->backend_info == 0)) + { + event_log_warning (hashcat_ctx, "The device #%d has been disabled as it most likely also exists as an OpenCL device, but it is not possible to automatically map it.", device_param->device_id + 1); + event_log_warning (hashcat_ctx, "You can use -d %d to use Metal API instead of OpenCL API. In some rare cases this is more stable.", device_param->device_id + 1); + event_log_warning (hashcat_ctx, NULL); + } + + device_param->skipped = true; + } + else + { + if (backend_ctx->backend_devices_filter & (1ULL << device_param->device_id)) + { + // ok + } + else + { + device_param->skipped = true; + } + } + + if (device_param->skipped == true) + { + backend_ctx->metal_devices_active--; + backend_ctx->backend_devices_active--; + } + } + } + } + } + #endif + // find duplicate devices //if ((cuda_devices_cnt > 0) && (hip_devices_cnt > 0) && (opencl_devices_cnt > 0)) @@ -7854,6 +7886,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) backend_ctx->opencl_devices_active--; backend_ctx->backend_devices_active--; + continue; } @@ -7869,6 +7902,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) backend_ctx->opencl_devices_active--; backend_ctx->backend_devices_active--; + continue; } @@ -7964,94 +7998,97 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) */ } - // available device memory + // available device memory // This test causes an GPU memory usage spike. // In case there are multiple hashcat instances starting at the same time this will cause GPU out of memory errors which otherwise would not exist. // We will simply not run it if that device was skipped by the user. - #define MAX_ALLOC_CHECKS_CNT 8192 - #define MAX_ALLOC_CHECKS_SIZE (64 * 1024 * 1024) - - device_param->device_available_mem = device_param->device_global_mem - MAX_ALLOC_CHECKS_SIZE; - - if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) + if (device_param->device_global_mem) { - // OK, so the problem here is the following: - // There's just CL_DEVICE_GLOBAL_MEM_SIZE to ask OpenCL about the total memory on the device, - // but there's no way to ask for available memory on the device. - // In combination, most OpenCL runtimes implementation of clCreateBuffer() - // are doing so called lazy memory allocation on the device. - // Now, if the user has X11 (or a game or anything that takes a lot of GPU memory) - // running on the host we end up with an error type of this: - // clEnqueueNDRangeKernel(): CL_MEM_OBJECT_ALLOCATION_FAILURE - // The clEnqueueNDRangeKernel() is because of the lazy allocation - // The best way to workaround this problem is if we would be able to ask for available memory, - // The idea here is to try to evaluate available memory by allocating it till it errors + #define MAX_ALLOC_CHECKS_CNT 8192 + #define MAX_ALLOC_CHECKS_SIZE (64 * 1024 * 1024) - cl_mem *tmp_device = (cl_mem *) hccalloc (MAX_ALLOC_CHECKS_CNT, sizeof (cl_mem)); + device_param->device_available_mem = device_param->device_global_mem - MAX_ALLOC_CHECKS_SIZE; - u64 c; - - for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++) + if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) { - if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break; + // OK, so the problem here is the following: + // There's just CL_DEVICE_GLOBAL_MEM_SIZE to ask OpenCL about the total memory on the device, + // but there's no way to ask for available memory on the device. + // In combination, most OpenCL runtimes implementation of clCreateBuffer() + // are doing so called lazy memory allocation on the device. + // Now, if the user has X11 (or a game or anything that takes a lot of GPU memory) + // running on the host we end up with an error type of this: + // clEnqueueNDRangeKernel(): CL_MEM_OBJECT_ALLOCATION_FAILURE + // The clEnqueueNDRangeKernel() is because of the lazy allocation + // The best way to workaround this problem is if we would be able to ask for available memory, + // The idea here is to try to evaluate available memory by allocating it till it errors - // work around, for some reason apple opencl can't have buffers larger 2^31 - // typically runs into trap 6 - // maybe 32/64 bit problem affecting size_t? - // this seems to affect global memory as well no just single allocations + cl_mem *tmp_device = (cl_mem *) hccalloc (MAX_ALLOC_CHECKS_CNT, sizeof (cl_mem)); - if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->is_metal == false)) + u64 c; + + for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++) { - const size_t undocumented_single_allocation_apple = 0x7fffffff; + if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break; - if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= undocumented_single_allocation_apple) break; - } + // work around, for some reason apple opencl can't have buffers larger 2^31 + // typically runs into trap 6 + // maybe 32/64 bit problem affecting size_t? + // this seems to affect global memory as well no just single allocations - cl_int CL_err; + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->is_metal == false)) + { + const size_t undocumented_single_allocation_apple = 0x7fffffff; - OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; + if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= undocumented_single_allocation_apple) break; + } - tmp_device[c] = ocl->clCreateBuffer (context, CL_MEM_READ_WRITE, MAX_ALLOC_CHECKS_SIZE, NULL, &CL_err); + cl_int CL_err; - if (CL_err != CL_SUCCESS) - { - c--; + OCL_PTR *ocl = (OCL_PTR *) backend_ctx->ocl; - break; - } + tmp_device[c] = ocl->clCreateBuffer (context, CL_MEM_READ_WRITE, MAX_ALLOC_CHECKS_SIZE, NULL, &CL_err); - // transfer only a few byte should be enough to force the runtime to actually allocate the memory + if (CL_err != CL_SUCCESS) + { + c--; - u8 tmp_host[8]; + break; + } - if (ocl->clEnqueueReadBuffer (command_queue, tmp_device[c], CL_TRUE, 0, sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; - if (ocl->clEnqueueWriteBuffer (command_queue, tmp_device[c], CL_TRUE, 0, sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; + // transfer only a few byte should be enough to force the runtime to actually allocate the memory - if (ocl->clEnqueueReadBuffer (command_queue, tmp_device[c], CL_TRUE, MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; - if (ocl->clEnqueueWriteBuffer (command_queue, tmp_device[c], CL_TRUE, MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; - } + u8 tmp_host[8]; - device_param->device_available_mem = MAX_ALLOC_CHECKS_SIZE; + if (ocl->clEnqueueReadBuffer (command_queue, tmp_device[c], CL_TRUE, 0, sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; + if (ocl->clEnqueueWriteBuffer (command_queue, tmp_device[c], CL_TRUE, 0, sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; - if (c > 0) - { - device_param->device_available_mem *= c; - } + if (ocl->clEnqueueReadBuffer (command_queue, tmp_device[c], CL_TRUE, MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; + if (ocl->clEnqueueWriteBuffer (command_queue, tmp_device[c], CL_TRUE, MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host), tmp_host, 0, NULL, NULL) != CL_SUCCESS) break; + } - // clean up + device_param->device_available_mem = MAX_ALLOC_CHECKS_SIZE; - for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++) - { - if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break; + if (c > 0) + { + device_param->device_available_mem *= c; + } - if (tmp_device[c] != NULL) + // clean up + + for (c = 0; c < MAX_ALLOC_CHECKS_CNT; c++) { - if (hc_clReleaseMemObject (hashcat_ctx, tmp_device[c]) == -1) return -1; + if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break; + + if (tmp_device[c] != NULL) + { + if (hc_clReleaseMemObject (hashcat_ctx, tmp_device[c]) == -1) return -1; + } } - } - hcfree (tmp_device); + hcfree (tmp_device); + } } hc_clReleaseCommandQueue (hashcat_ctx, command_queue); @@ -9753,8 +9790,10 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->size_results = size_results; - u64 size_rules = (u64) straight_ctx->kernel_rules_cnt * sizeof (kernel_rule_t); - u64 size_rules_c = (u64) KERNEL_RULES * sizeof (kernel_rule_t); + u32 aligned_rules_cnt = MAX (MAX (straight_ctx->kernel_rules_cnt, device_param->kernel_loops_min), KERNEL_RULES); + + u64 size_rules = (u64) aligned_rules_cnt * sizeof (kernel_rule_t); + u64 size_rules_c = (u64) KERNEL_RULES * sizeof (kernel_rule_t); device_param->size_rules = size_rules; device_param->size_rules_c = size_rules_c; @@ -9850,6 +9889,13 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } } + if ((int) kern_type == -1) + { + event_log_error (hashcat_ctx, "Invalid hash-mode selected: -1"); + + return -1; + } + // built options const size_t build_options_sz = 4096; diff --git a/src/bitmap.c b/src/bitmap.c index 8fb30ddb4..367b16a7c 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -79,14 +79,15 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) bitmap_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; bitmap_ctx->enabled = true; diff --git a/src/brain.c b/src/brain.c index bd97d9695..bc55c131a 100644 --- a/src/brain.c +++ b/src/brain.c @@ -2311,7 +2311,7 @@ void *brain_server_handle_client (void *p) hc_thread_mutex_unlock (brain_server_dbs->mux_dbs); - // higest position of that attack + // highest position of that attack u64 highest = brain_server_highest_attack (brain_server_db_attack); diff --git a/src/combinator.c b/src/combinator.c index c56d21440..654ada03f 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -19,12 +19,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->backend_info > 0) return 0; if ((user_options->attack_mode != ATTACK_MODE_COMBI) && (user_options->attack_mode != ATTACK_MODE_HYBRID1) diff --git a/src/cpt.c b/src/cpt.c index 235dafe27..8dc393c3a 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -15,14 +15,15 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; cpt_ctx->enabled = true; diff --git a/src/debugfile.c b/src/debugfile.c index 21cd4e17f..cf943f3aa 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -114,6 +114,11 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) debugfile_ctx->enabled = false; + if (user_options->debug_mode == 0) return 0; + + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; @@ -122,11 +127,8 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->debug_mode == 0) return 0; - if (user_options->backend_info > 0) return 0; debugfile_ctx->enabled = true; diff --git a/src/dictstat.c b/src/dictstat.c index 6ae52b9de..02bb86b5f 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -56,21 +56,22 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) dictstat_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; if (user_options->attack_mode == ATTACK_MODE_BF) return 0; - dictstat_ctx->enabled = true; - dictstat_ctx->base = (dictstat_t *) hccalloc (MAX_DICTSTAT, sizeof (dictstat_t)); - dictstat_ctx->cnt = 0; + dictstat_ctx->enabled = true; + dictstat_ctx->base = (dictstat_t *) hccalloc (MAX_DICTSTAT, sizeof (dictstat_t)); + dictstat_ctx->cnt = 0; hc_asprintf (&dictstat_ctx->filename, "%s/%s", folder_config->profile_dir, DICTSTAT_FILENAME); diff --git a/src/ext_hiprtc.c b/src/ext_hiprtc.c index ea1b67c27..ad7d14be9 100644 --- a/src/ext_hiprtc.c +++ b/src/ext_hiprtc.c @@ -41,14 +41,14 @@ int hiprtc_init (void *hashcat_ctx) #if defined (_WIN) hiprtc->lib = hc_dlopen ("hiprtc.dll"); - if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("contrib/bin/win64/hiprtc0503.dll"); + if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("C:/Program Files/AMD/ROCm/5.5/bin/hiprtc0505.dll"); if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("amdhip64.dll"); #elif defined (__APPLE__) hiprtc->lib = hc_dlopen ("fixme.dylib"); #elif defined (__CYGWIN__) hiprtc->lib = hc_dlopen ("hiprtc.dll"); - if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("contrib/bin/win64/hiprtc0503.dll"); + if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("C:/Program Files/AMD/ROCm/5.5/bin/hiprtc0505.dll"); if (hiprtc->lib == NULL) hiprtc->lib = hc_dlopen ("amdhip64.dll"); #else hiprtc->lib = hc_dlopen ("libhiprtc.so"); diff --git a/src/ext_iokit.c b/src/ext_iokit.c index adeb9291d..1c45ea367 100644 --- a/src/ext_iokit.c +++ b/src/ext_iokit.c @@ -37,7 +37,7 @@ void hm_IOKIT_ultostr (char *str, UInt32 val) { str[0] = '\0'; - sprintf (str, "%c%c%c%c", (unsigned int) (val >> 24), (unsigned int) (val >> 16), (unsigned int) (val >> 8), (unsigned int) (val)); + snprintf (str, 5, "%c%c%c%c", (unsigned int) (val >> 24), (unsigned int) (val >> 16), (unsigned int) (val >> 8), (unsigned int) (val)); } kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn) @@ -48,7 +48,7 @@ kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn) CFMutableDictionaryRef matchingDictionary = IOServiceMatching ("AppleSMC"); - result = IOServiceGetMatchingServices (kIOMasterPortDefault, matchingDictionary, &iterator); + result = IOServiceGetMatchingServices (hc_IOMasterPortDefault, matchingDictionary, &iterator); if (result != kIOReturnSuccess) { @@ -231,7 +231,7 @@ int hm_IOKIT_get_utilization_current (void *hashcat_ctx, int *utilization) CFMutableDictionaryRef matching = IOServiceMatching ("IOAccelerator"); - if (IOServiceGetMatchingServices (kIOMasterPortDefault, matching, &iterator) != kIOReturnSuccess) + if (IOServiceGetMatchingServices (hc_IOMasterPortDefault, matching, &iterator) != kIOReturnSuccess) { event_log_error (hashcat_ctx, "IOServiceGetMatchingServices(): failure"); @@ -301,6 +301,9 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf) if (totalFans <= 0) return -1; + // limit totalFans to 10 + if (totalFans > 10) totalFans = 10; + char tmp_buf[16]; for (int i = 0; i < totalFans; i++) @@ -310,12 +313,12 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf) float maximum_speed = 0.0f; memset (&key, 0, sizeof (UInt32Char_t)); - sprintf (key, "F%dAc", i); + snprintf (key, 5, "F%dAc", i); hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &actual_speed); if (actual_speed < 0.f) continue; memset (&key, 0, sizeof (UInt32Char_t)); - sprintf (key, "F%dMx", i); + snprintf (key, 5, "F%dMx", i); hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed); if (maximum_speed < 0.f) continue; diff --git a/src/ext_metal.m b/src/ext_metal.m index b8428369c..6a51d48bd 100644 --- a/src/ext_metal.m +++ b/src/ext_metal.m @@ -47,7 +47,7 @@ static bool iokit_getGPUCore (void *hashcat_ctx, int *gpu_core) CFMutableDictionaryRef matching = IOServiceMatching ("IOAccelerator"); - io_service_t service = IOServiceGetMatchingService (kIOMasterPortDefault, matching); + io_service_t service = IOServiceGetMatchingService (hc_IOMasterPortDefault, matching); if (!service) { @@ -681,7 +681,8 @@ int hc_mtlCreateCommandQueue (void *hashcat_ctx, mtl_device_id metal_device, mtl int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_library metal_library, const char *func_name, mtl_function *metal_function, mtl_pipeline *metal_pipeline) { - backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; + backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; + user_options_t *user_options = ((hashcat_ctx_t *) hashcat_ctx)->user_options; MTL_PTR *mtl = (MTL_PTR *) backend_ctx->mtl; @@ -708,7 +709,7 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra return -1; } - NSError *error = nil; + __block NSError *error = nil; NSString *f_name = [NSString stringWithCString: func_name encoding: NSUTF8StringEncoding]; @@ -721,6 +722,9 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra return -1; } + // workaround for MTLCompilerService 'Infinite Loop' bug + + /* mtl_pipeline mtl_pipe = [metal_device newComputePipelineStateWithFunction: mtl_func error: &error]; if (error != nil) @@ -729,6 +733,46 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra return -1; } + */ + + error = nil; + + __block mtl_pipeline mtl_pipe; + + dispatch_group_t group = dispatch_group_create (); + dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + // if no user-defined runtime, set to METAL_COMPILER_RUNTIME + long timeout = (user_options->metal_compiler_runtime > 0) ? user_options->metal_compiler_runtime : METAL_COMPILER_RUNTIME; + + dispatch_time_t when = dispatch_time (DISPATCH_TIME_NOW,NSEC_PER_SEC * timeout); + + __block int rc_async_err = 0; + + dispatch_group_async (group, queue, ^(void) + { + mtl_pipe = [metal_device newComputePipelineStateWithFunction: mtl_func error: &error]; + + if (error != nil) + { + event_log_error (hashcat_ctx, "%s(): failed to create '%s' pipeline, %s", __func__, func_name, [[error localizedDescription] UTF8String]); + + rc_async_err = -1; + } + }); + + long rc_queue = dispatch_group_wait (group, when); + + dispatch_release (group); + + if (rc_async_err != 0) return -1; + + if (rc_queue != 0) + { + event_log_error (hashcat_ctx, "%s(): failed to create '%s' pipeline, timeout reached (status %ld)", __func__, func_name, rc_queue); + + return -1; + } if (mtl_pipe == nil) { diff --git a/src/hashes.c b/src/hashes.c index 9ed4cc680..97d765948 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -2545,7 +2545,7 @@ int hashes_init_zerohash (hashcat_ctx_t *hashcat_ctx) hash_t *hashes_buf = hashes->hashes_buf; u32 hashes_cnt = hashes->hashes_cnt; - // no solution for these special hash types (for instane because they use hashfile in output etc) + // no solution for these special hash types (for instance because they use hashfile in output etc) hash_t hash_buf; diff --git a/src/hwmon.c b/src/hwmon.c index b1cf2d56e..5ef2e4a9c 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -1226,16 +1226,17 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return 0; #endif // WITH_HWMON + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; if (user_options->stdout_flag == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; if (user_options->hwmon_disable == true) return 0; - if (user_options->backend_info > 0) return 0; hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); diff --git a/src/induct.c b/src/induct.c index ff5ca0fbb..3d9755034 100644 --- a/src/induct.c +++ b/src/induct.c @@ -39,6 +39,9 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) induct_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; @@ -47,10 +50,8 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) && (user_options->attack_mode != ATTACK_MODE_ASSOCIATION)) return 0; diff --git a/src/interface.c b/src/interface.c index 1cba43229..a4a13fd03 100644 --- a/src/interface.c +++ b/src/interface.c @@ -137,7 +137,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) return -1; } - // check for missing pointer assignements + // check for missing pointer assignments #define CHECK_DEFINED(func) \ if ((func) == NULL) \ @@ -818,7 +818,7 @@ u32 default_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED co u32 default_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - // salt_min : this limit is only interessting for generic hash types that support a salt + // salt_min : this limit is only interesting for generic hash types that support a salt u32 salt_min = SALT_MIN; @@ -837,7 +837,7 @@ u32 default_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED { const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - // salt_max : this limit is only interessting for generic hash types that support a salt + // salt_max : this limit is only interesting for generic hash types that support a salt u32 salt_max = SALT_MAX; diff --git a/src/loopback.c b/src/loopback.c index 3f09cd87a..c20c88ea5 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -60,6 +60,9 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; @@ -68,10 +71,8 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; loopback_ctx->enabled = true; loopback_ctx->fp.pfp = NULL; diff --git a/src/main.c b/src/main.c index 8c35fa8b4..e0df90e74 100644 --- a/src/main.c +++ b/src/main.c @@ -988,7 +988,7 @@ static void main_hashconfig_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE { if (hashconfig->opti_type & OPTI_TYPE_RAW_HASH) { - event_log_info (hashcat_ctx, "Minimim salt length supported by kernel: %u", hashconfig->salt_min); + event_log_info (hashcat_ctx, "Minimum salt length supported by kernel: %u", hashconfig->salt_min); event_log_info (hashcat_ctx, "Maximum salt length supported by kernel: %u", hashconfig->salt_max); } } @@ -1312,7 +1312,7 @@ int main (int argc, char **argv) if (hashcat_session_init (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME) == 0) { - if (user_options->usage == true) + if (user_options->usage > 0) { usage_big_print (hashcat_ctx); diff --git a/src/memory.c b/src/memory.c index 86fe44f6d..54995cc86 100644 --- a/src/memory.c +++ b/src/memory.c @@ -66,3 +66,26 @@ void hcfree (void *ptr) free (ptr); } + +void *hcmalloc_aligned (const size_t sz, const int align) +{ + // store the original allocated address so we can later use it to free the memory + // this is convenient to use because we don't need to store two memory addresses + + const int align1 = align - 1; + + void *ptr1 = hcmalloc (sz + sizeof (void *) + align1); + + void *ptr2 = (void **) ((uintptr_t) (ptr1 + sizeof (void *) + align1) & ~align1); + + ((void **) ptr2)[-1] = ptr1; + + return ptr2; +} + +void hcfree_aligned (void *ptr) +{ + if (ptr == NULL) return; + + free (((void **) ptr)[-1]); +} diff --git a/src/modules/module_00000.c b/src/modules/module_00000.c index 8c4190264..127d95c16 100644 --- a/src/modules/module_00000.c +++ b/src/modules/module_00000.c @@ -55,11 +55,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00010.c b/src/modules/module_00010.c index 4fadfe1d5..57197205e 100644 --- a/src/modules/module_00010.c +++ b/src/modules/module_00010.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00011.c b/src/modules/module_00011.c index 6d30965e1..e762f70d7 100644 --- a/src/modules/module_00011.c +++ b/src/modules/module_00011.c @@ -55,17 +55,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { diff --git a/src/modules/module_00012.c b/src/modules/module_00012.c index d9fa59a78..f0236e151 100644 --- a/src/modules/module_00012.c +++ b/src/modules/module_00012.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = 0; diff --git a/src/modules/module_00020.c b/src/modules/module_00020.c index 134e22708..505f648e4 100644 --- a/src/modules/module_00020.c +++ b/src/modules/module_00020.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00021.c b/src/modules/module_00021.c index 7223cad97..7ad9d9acf 100644 --- a/src/modules/module_00021.c +++ b/src/modules/module_00021.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[1] = 2; diff --git a/src/modules/module_00022.c b/src/modules/module_00022.c index 83ea25c18..986ddc37e 100644 --- a/src/modules/module_00022.c +++ b/src/modules/module_00022.c @@ -56,12 +56,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 30; - token.len_max[0] = 30; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 30; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00023.c b/src/modules/module_00023.c index 81c35d48e..1cbce89a2 100644 --- a/src/modules/module_00023.c +++ b/src/modules/module_00023.c @@ -56,12 +56,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00024.c b/src/modules/module_00024.c index 3f0652298..fedd77c37 100644 --- a/src/modules/module_00024.c +++ b/src/modules/module_00024.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[1] = 2; diff --git a/src/modules/module_00030.c b/src/modules/module_00030.c index e1306c98e..50c5ca511 100644 --- a/src/modules/module_00030.c +++ b/src/modules/module_00030.c @@ -56,12 +56,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00040.c b/src/modules/module_00040.c index 1bdf420bc..2d0186982 100644 --- a/src/modules/module_00040.c +++ b/src/modules/module_00040.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00050.c b/src/modules/module_00050.c index 7b7ad4c68..7e4eeaa4d 100644 --- a/src/modules/module_00050.c +++ b/src/modules/module_00050.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00060.c b/src/modules/module_00060.c index a91a7e38f..7a3e0757d 100644 --- a/src/modules/module_00060.c +++ b/src/modules/module_00060.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00070.c b/src/modules/module_00070.c index 04cb1a020..d503dd5fe 100644 --- a/src/modules/module_00070.c +++ b/src/modules/module_00070.c @@ -56,11 +56,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00100.c b/src/modules/module_00100.c index ea725c5b2..3d6bb223d 100644 --- a/src/modules/module_00100.c +++ b/src/modules/module_00100.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00101.c b/src/modules/module_00101.c index fd7a1181c..7482896e2 100644 --- a/src/modules/module_00101.c +++ b/src/modules/module_00101.c @@ -54,6 +54,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; @@ -63,9 +65,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 28; - token.len_max[1] = 28; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 28; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00110.c b/src/modules/module_00110.c index f9b384301..30ce167af 100644 --- a/src/modules/module_00110.c +++ b/src/modules/module_00110.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00111.c b/src/modules/module_00111.c index 10e8c9c23..499c9a67c 100644 --- a/src/modules/module_00111.c +++ b/src/modules/module_00111.c @@ -57,6 +57,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 2; diff --git a/src/modules/module_00112.c b/src/modules/module_00112.c index 370adaf82..152f2314a 100644 --- a/src/modules/module_00112.c +++ b/src/modules/module_00112.c @@ -62,17 +62,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 20; - token.len_max[1] = 20; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 20; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00120.c b/src/modules/module_00120.c index 6a1f0f089..2ecb1aa79 100644 --- a/src/modules/module_00120.c +++ b/src/modules/module_00120.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00121.c b/src/modules/module_00121.c index 497fa2167..e988a45a6 100644 --- a/src/modules/module_00121.c +++ b/src/modules/module_00121.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00122.c b/src/modules/module_00122.c index 5ab58b391..c806a2055 100644 --- a/src/modules/module_00122.c +++ b/src/modules/module_00122.c @@ -55,6 +55,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.len[0] = 8; diff --git a/src/modules/module_00124.c b/src/modules/module_00124.c index 1c08c6f87..ccdfe4e63 100644 --- a/src/modules/module_00124.c +++ b/src/modules/module_00124.c @@ -56,6 +56,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_00125.c b/src/modules/module_00125.c index 396194aed..b865e087a 100644 --- a/src/modules/module_00125.c +++ b/src/modules/module_00125.c @@ -55,6 +55,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.len[0] = 10; diff --git a/src/modules/module_00130.c b/src/modules/module_00130.c index 713ff747f..d071fdc94 100644 --- a/src/modules/module_00130.c +++ b/src/modules/module_00130.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00131.c b/src/modules/module_00131.c index 3b3bbcffe..26eae96f9 100644 --- a/src/modules/module_00131.c +++ b/src/modules/module_00131.c @@ -59,6 +59,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; diff --git a/src/modules/module_00132.c b/src/modules/module_00132.c index 33257e486..ab05701cb 100644 --- a/src/modules/module_00132.c +++ b/src/modules/module_00132.c @@ -58,6 +58,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_00133.c b/src/modules/module_00133.c index f10d1966b..ecef6b61f 100644 --- a/src/modules/module_00133.c +++ b/src/modules/module_00133.c @@ -55,11 +55,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 28; - token.len_max[0] = 28; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 28; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00140.c b/src/modules/module_00140.c index 42227e7b7..bfded211a 100644 --- a/src/modules/module_00140.c +++ b/src/modules/module_00140.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00141.c b/src/modules/module_00141.c index 2bed1ea03..6a356562f 100644 --- a/src/modules/module_00141.c +++ b/src/modules/module_00141.c @@ -58,32 +58,32 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_EPISERVER; - token.len_min[0] = 11; - token.len_max[0] = 11; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '*'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = '*'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '*'; token.len_min[2] = ((SALT_MIN * 8) / 6) + 0; token.len_max[2] = ((SALT_MAX * 8) / 6) + 3; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.len_min[3] = 27; - token.len_max[3] = 27; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 27; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00150.c b/src/modules/module_00150.c index d770c6898..9df2e605c 100644 --- a/src/modules/module_00150.c +++ b/src/modules/module_00150.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00160.c b/src/modules/module_00160.c index 35249b7e4..ab82bed03 100644 --- a/src/modules/module_00160.c +++ b/src/modules/module_00160.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_00170.c b/src/modules/module_00170.c index 4856f3379..ae08beca6 100644 --- a/src/modules/module_00170.c +++ b/src/modules/module_00170.c @@ -55,11 +55,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00200.c b/src/modules/module_00200.c index eb4905525..e2bd7c8f4 100644 --- a/src/modules/module_00200.c +++ b/src/modules/module_00200.c @@ -47,11 +47,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00300.c b/src/modules/module_00300.c index 1a318dc20..db4731a85 100644 --- a/src/modules/module_00300.c +++ b/src/modules/module_00300.c @@ -53,11 +53,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_00400.c b/src/modules/module_00400.c index 9fff7051d..3105bc546 100644 --- a/src/modules/module_00400.c +++ b/src/modules/module_00400.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 2; diff --git a/src/modules/module_00500.c b/src/modules/module_00500.c index e86de7a19..e2e6bba93 100644 --- a/src/modules/module_00500.c +++ b/src/modules/module_00500.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -181,9 +183,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 0; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_OPTIONAL_ROUNDS; diff --git a/src/modules/module_00501.c b/src/modules/module_00501.c index b22c8f80d..76980adaa 100644 --- a/src/modules/module_00501.c +++ b/src/modules/module_00501.c @@ -251,11 +251,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 104; - token.len_max[0] = 104; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 104; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -272,6 +273,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token2; + memset (&token2, 0, sizeof (hc_token_t)); + token2.token_cnt = 3; token2.signatures_cnt = 1; @@ -281,11 +284,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token2.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token2.len_min[1] = 8; - token2.len_max[1] = 8; token2.sep[1] = '$'; - token2.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token2.len[1] = 8; + token2.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token2.sep[2] = '$'; token2.len[2] = 22; token2.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; diff --git a/src/modules/module_00600.c b/src/modules/module_00600.c index ec36cb376..9165bb744 100644 --- a/src/modules/module_00600.c +++ b/src/modules/module_00600.c @@ -51,6 +51,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_00610.c b/src/modules/module_00610.c index 8242494d1..05f5074dc 100644 --- a/src/modules/module_00610.c +++ b/src/modules/module_00610.c @@ -52,6 +52,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; // signature @@ -64,9 +66,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // hash token.sep[1] = hashconfig->separator; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // salt diff --git a/src/modules/module_00620.c b/src/modules/module_00620.c index fab49c066..fc56fadb6 100644 --- a/src/modules/module_00620.c +++ b/src/modules/module_00620.c @@ -52,6 +52,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; // signature @@ -64,9 +66,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // hash token.sep[1] = hashconfig->separator; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // salt diff --git a/src/modules/module_00900.c b/src/modules/module_00900.c index 4200b54aa..8e007962a 100644 --- a/src/modules/module_00900.c +++ b/src/modules/module_00900.c @@ -55,11 +55,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01000.c b/src/modules/module_01000.c index 8a1a35536..7662af81b 100644 --- a/src/modules/module_01000.c +++ b/src/modules/module_01000.c @@ -58,11 +58,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01100.c b/src/modules/module_01100.c index 1e1c9b9f8..d514c311e 100644 --- a/src/modules/module_01100.c +++ b/src/modules/module_01100.c @@ -56,12 +56,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01300.c b/src/modules/module_01300.c index d4f3b5f21..149fd39ad 100644 --- a/src/modules/module_01300.c +++ b/src/modules/module_01300.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 56; - token.len_max[0] = 56; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 56; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01400.c b/src/modules/module_01400.c index dfa7c0136..ab002efbe 100644 --- a/src/modules/module_01400.c +++ b/src/modules/module_01400.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01410.c b/src/modules/module_01410.c index a54104a02..f2f763bfe 100644 --- a/src/modules/module_01410.c +++ b/src/modules/module_01410.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01411.c b/src/modules/module_01411.c index 6584decc0..63d8bde69 100644 --- a/src/modules/module_01411.c +++ b/src/modules/module_01411.c @@ -56,6 +56,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_01420.c b/src/modules/module_01420.c index a0e9c6764..795bd254f 100644 --- a/src/modules/module_01420.c +++ b/src/modules/module_01420.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01421.c b/src/modules/module_01421.c index 6bfe2dd75..22cda42c1 100644 --- a/src/modules/module_01421.c +++ b/src/modules/module_01421.c @@ -54,14 +54,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.len[0] = 6; token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[1] = 64; - token.len_max[1] = 64; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01430.c b/src/modules/module_01430.c index c3931e087..650a7ec92 100644 --- a/src/modules/module_01430.c +++ b/src/modules/module_01430.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01440.c b/src/modules/module_01440.c index 9aca7a0de..4dd8fb3c6 100644 --- a/src/modules/module_01440.c +++ b/src/modules/module_01440.c @@ -55,12 +55,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01441.c b/src/modules/module_01441.c index 63c7d2c96..89ff454d6 100644 --- a/src/modules/module_01441.c +++ b/src/modules/module_01441.c @@ -58,32 +58,32 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_EPISERVER; - token.len_min[0] = 11; - token.len_max[0] = 11; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '*'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = '*'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '*'; token.len_min[2] = ((SALT_MIN * 8) / 6) + 0; token.len_max[2] = ((SALT_MAX * 8) / 6) + 3; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.len_min[3] = 43; - token.len_max[3] = 43; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 43; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01450.c b/src/modules/module_01450.c index bbf13ff02..b909b0b70 100644 --- a/src/modules/module_01450.c +++ b/src/modules/module_01450.c @@ -49,12 +49,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01460.c b/src/modules/module_01460.c index f04ff77c2..08937aeb2 100644 --- a/src/modules/module_01460.c +++ b/src/modules/module_01460.c @@ -81,12 +81,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01470.c b/src/modules/module_01470.c index 735351a67..07d3b5bee 100644 --- a/src/modules/module_01470.c +++ b/src/modules/module_01470.c @@ -55,11 +55,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01500.c b/src/modules/module_01500.c index b939b0a10..1956999dd 100644 --- a/src/modules/module_01500.c +++ b/src/modules/module_01500.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.len[0] = 2; diff --git a/src/modules/module_01600.c b/src/modules/module_01600.c index 5c62252b1..fd2698d9d 100644 --- a/src/modules/module_01600.c +++ b/src/modules/module_01600.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -181,9 +183,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 0; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_OPTIONAL_ROUNDS; diff --git a/src/modules/module_01700.c b/src/modules/module_01700.c index f6c8b839f..66398ad54 100644 --- a/src/modules/module_01700.c +++ b/src/modules/module_01700.c @@ -86,11 +86,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01710.c b/src/modules/module_01710.c index a302a1957..870bc22ef 100644 --- a/src/modules/module_01710.c +++ b/src/modules/module_01710.c @@ -86,12 +86,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01711.c b/src/modules/module_01711.c index 8c92539d4..7d5f1b112 100644 --- a/src/modules/module_01711.c +++ b/src/modules/module_01711.c @@ -88,6 +88,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_01720.c b/src/modules/module_01720.c index 7c1c0aaaa..01b2571ee 100644 --- a/src/modules/module_01720.c +++ b/src/modules/module_01720.c @@ -86,12 +86,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01722.c b/src/modules/module_01722.c index 69c2aac70..9da97c101 100644 --- a/src/modules/module_01722.c +++ b/src/modules/module_01722.c @@ -87,6 +87,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.len[0] = 8; diff --git a/src/modules/module_01730.c b/src/modules/module_01730.c index bb1280a97..0f9d1632b 100644 --- a/src/modules/module_01730.c +++ b/src/modules/module_01730.c @@ -87,12 +87,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01731.c b/src/modules/module_01731.c index 26dc8b9fd..a150b407d 100644 --- a/src/modules/module_01731.c +++ b/src/modules/module_01731.c @@ -90,6 +90,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_01740.c b/src/modules/module_01740.c index 19289d9ad..c45cb2cdf 100644 --- a/src/modules/module_01740.c +++ b/src/modules/module_01740.c @@ -87,12 +87,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01750.c b/src/modules/module_01750.c index 93f162be1..e2eaa5382 100644 --- a/src/modules/module_01750.c +++ b/src/modules/module_01750.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01760.c b/src/modules/module_01760.c index 1311f89be..b2bff2f12 100644 --- a/src/modules/module_01760.c +++ b/src/modules/module_01760.c @@ -51,12 +51,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_01770.c b/src/modules/module_01770.c index a0e0cac4f..799f0d71f 100644 --- a/src/modules/module_01770.c +++ b/src/modules/module_01770.c @@ -70,11 +70,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_01800.c b/src/modules/module_01800.c index a983cda0a..eeea0a484 100644 --- a/src/modules/module_01800.c +++ b/src/modules/module_01800.c @@ -494,6 +494,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -503,9 +505,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 0; token.len_max[1] = 16; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_OPTIONAL_ROUNDS; diff --git a/src/modules/module_02100.c b/src/modules/module_02100.c index 154b9d789..a304c003f 100644 --- a/src/modules/module_02100.c +++ b/src/modules/module_02100.c @@ -78,6 +78,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -87,21 +89,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '#'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = '#'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '#'; token.len_min[2] = SALT_MIN; token.len_max[2] = SALT_MAX; - token.sep[2] = '#'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_SEPARATOR_FARTHEST; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_02400.c b/src/modules/module_02400.c index 09e8f3396..1856a6f1d 100644 --- a/src/modules/module_02400.c +++ b/src/modules/module_02400.c @@ -45,18 +45,33 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + u32 pw_max = PW_MAX; + + if (optimized_kernel == true) + { + pw_max = 31; + } + + return pw_max; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.sep[0] = ':'; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -216,7 +231,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_potfile_disable = MODULE_DEFAULT; module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; module_ctx->module_pwdump_column = MODULE_DEFAULT; - module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; module_ctx->module_pw_min = MODULE_DEFAULT; module_ctx->module_salt_max = MODULE_DEFAULT; module_ctx->module_salt_min = MODULE_DEFAULT; diff --git a/src/modules/module_02410.c b/src/modules/module_02410.c index 47e4f46d4..e7aa402b8 100644 --- a/src/modules/module_02410.c +++ b/src/modules/module_02410.c @@ -44,18 +44,54 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + u32 pw_max = PW_MAX; + + if (optimized_kernel == true) + { + if (user_options->attack_mode == ATTACK_MODE_BF) + { + pw_max = 47; // with salt_len 1, but 44 if salt_len is 4 + } + else + { + pw_max = 31; + } + } + + return pw_max; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 1; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 4; + + return salt_max; +} + int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) { u32 *digest = (u32 *) digest_buf; hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; token.len_min[1] = 1; @@ -232,10 +268,10 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_potfile_disable = MODULE_DEFAULT; module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; module_ctx->module_pwdump_column = MODULE_DEFAULT; - module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; module_ctx->module_pw_min = MODULE_DEFAULT; - module_ctx->module_salt_max = MODULE_DEFAULT; - module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; module_ctx->module_salt_type = module_salt_type; module_ctx->module_separator = MODULE_DEFAULT; module_ctx->module_st_hash = module_st_hash; diff --git a/src/modules/module_02600.c b/src/modules/module_02600.c index 02bbeeb03..a784dcb79 100644 --- a/src/modules/module_02600.c +++ b/src/modules/module_02600.c @@ -52,11 +52,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_02611.c b/src/modules/module_02611.c index cb3902db9..096fb3cd8 100644 --- a/src/modules/module_02611.c +++ b/src/modules/module_02611.c @@ -52,12 +52,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_02612.c b/src/modules/module_02612.c index 8ca360b7d..56edc1de8 100644 --- a/src/modules/module_02612.c +++ b/src/modules/module_02612.c @@ -55,6 +55,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -70,9 +72,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_02630.c b/src/modules/module_02630.c new file mode 100644 index 000000000..f1098413d --- /dev/null +++ b/src/modules/module_02630.c @@ -0,0 +1,226 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5(md5($pass.$salt))"; +static const u64 KERN_TYPE = 2630; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_ST_ADD80 + | OPTS_TYPE_ST_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "0127eecea3120e34c8934ba3b72a390a:0"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + memset (salt->salt_buf, 0, sizeof (salt->salt_buf)); + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_02711.c b/src/modules/module_02711.c index 242d95c76..e9943538f 100644 --- a/src/modules/module_02711.c +++ b/src/modules/module_02711.c @@ -52,12 +52,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_02811.c b/src/modules/module_02811.c index eb587a4c6..7f9c5fb3a 100644 --- a/src/modules/module_02811.c +++ b/src/modules/module_02811.c @@ -80,12 +80,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_03000.c b/src/modules/module_03000.c index 741ef1f91..2fe4cf17b 100644 --- a/src/modules/module_03000.c +++ b/src/modules/module_03000.c @@ -162,12 +162,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.sep[0] = hashconfig->separator; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_03100.c b/src/modules/module_03100.c index b42bb584a..af0f98840 100644 --- a/src/modules/module_03100.c +++ b/src/modules/module_03100.c @@ -75,12 +75,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = 0; diff --git a/src/modules/module_03200.c b/src/modules/module_03200.c index 98ff740e1..8f0ad91aa 100644 --- a/src/modules/module_03200.c +++ b/src/modules/module_03200.c @@ -178,6 +178,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 4; @@ -190,10 +192,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len[2] = 22; diff --git a/src/modules/module_03500.c b/src/modules/module_03500.c index b4f2fec4e..cdca0d157 100644 --- a/src/modules/module_03500.c +++ b/src/modules/module_03500.c @@ -52,11 +52,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_03610.c b/src/modules/module_03610.c new file mode 100644 index 000000000..e93be95ed --- /dev/null +++ b/src/modules/module_03610.c @@ -0,0 +1,223 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5(md5(md5($pass)).$salt)"; +static const u64 KERN_TYPE = 3610; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14 + | OPTS_TYPE_ST_ADD80; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "a0ab79f9e2b5a4434d2da61673b56362:1234"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_03710.c b/src/modules/module_03710.c index a92e7c405..787473468 100644 --- a/src/modules/module_03710.c +++ b/src/modules/module_03710.c @@ -51,12 +51,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_03711.c b/src/modules/module_03711.c index 85d5e4bdf..ad7fd3a9a 100644 --- a/src/modules/module_03711.c +++ b/src/modules/module_03711.c @@ -53,6 +53,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -67,9 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_max[1] = SALT_MAX; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_03730.c b/src/modules/module_03730.c index 336fa32d4..eb37c234f 100644 --- a/src/modules/module_03730.c +++ b/src/modules/module_03730.c @@ -71,12 +71,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; diff --git a/src/modules/module_03800.c b/src/modules/module_03800.c index 860ea5e85..a863b7ec0 100644 --- a/src/modules/module_03800.c +++ b/src/modules/module_03800.c @@ -52,12 +52,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_03910.c b/src/modules/module_03910.c index 8f643fc1a..4aebe37c3 100644 --- a/src/modules/module_03910.c +++ b/src/modules/module_03910.c @@ -82,12 +82,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04010.c b/src/modules/module_04010.c index 49198d6ee..0e7e2063e 100644 --- a/src/modules/module_04010.c +++ b/src/modules/module_04010.c @@ -51,12 +51,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04110.c b/src/modules/module_04110.c index 1d81ed647..396238751 100644 --- a/src/modules/module_04110.c +++ b/src/modules/module_04110.c @@ -49,12 +49,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04300.c b/src/modules/module_04300.c index f8bd08a39..85d999530 100644 --- a/src/modules/module_04300.c +++ b/src/modules/module_04300.c @@ -52,11 +52,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04400.c b/src/modules/module_04400.c index 0ec255375..6c86306d1 100644 --- a/src/modules/module_04400.c +++ b/src/modules/module_04400.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04410.c b/src/modules/module_04410.c index 8c824bb15..4a763340a 100644 --- a/src/modules/module_04410.c +++ b/src/modules/module_04410.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04420.c b/src/modules/module_04420.c new file mode 100644 index 000000000..9a2727935 --- /dev/null +++ b/src/modules/module_04420.c @@ -0,0 +1,221 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5(sha1($pass.$salt))"; +static const u64 KERN_TYPE = 4420; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_ST_ADD80 + | OPTS_TYPE_ST_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "34ebbba3e5c98f6253c160eae53da092:6224378456121050285"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_04430.c b/src/modules/module_04430.c new file mode 100644 index 000000000..52eae5dea --- /dev/null +++ b/src/modules/module_04430.c @@ -0,0 +1,221 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5(sha1($salt.$pass))"; +static const u64 KERN_TYPE = 4430; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "df0e9ede5b6c7d1f1b47199f86029002:59132809201799180722359939692710461886"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_04500.c b/src/modules/module_04500.c index 22596eeb6..ad98eb05d 100644 --- a/src/modules/module_04500.c +++ b/src/modules/module_04500.c @@ -52,11 +52,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04510.c b/src/modules/module_04510.c index fad21b425..51d0a686a 100644 --- a/src/modules/module_04510.c +++ b/src/modules/module_04510.c @@ -64,12 +64,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04520.c b/src/modules/module_04520.c index 723e78990..3c0ff2eb5 100644 --- a/src/modules/module_04520.c +++ b/src/modules/module_04520.c @@ -52,12 +52,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04521.c b/src/modules/module_04521.c index 5fb91e8e6..3e0f8abe8 100644 --- a/src/modules/module_04521.c +++ b/src/modules/module_04521.c @@ -52,17 +52,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04522.c b/src/modules/module_04522.c index 06c1681cf..5423f86cc 100644 --- a/src/modules/module_04522.c +++ b/src/modules/module_04522.c @@ -52,17 +52,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 12; - token.len_max[1] = 12; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 12; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04700.c b/src/modules/module_04700.c index 58d7c969f..90b1f0f18 100644 --- a/src/modules/module_04700.c +++ b/src/modules/module_04700.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04710.c b/src/modules/module_04710.c index 91794b21c..48d0e0a9b 100644 --- a/src/modules/module_04710.c +++ b/src/modules/module_04710.c @@ -64,12 +64,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_04711.c b/src/modules/module_04711.c index 956d517a3..5020a5d18 100644 --- a/src/modules/module_04711.c +++ b/src/modules/module_04711.c @@ -67,22 +67,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 8; - token.len_max[1] = 8; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { - token.len_min[1] *= 2; - token.len_max[1] *= 2; + token.len[1] *= 2; token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; } diff --git a/src/modules/module_04800.c b/src/modules/module_04800.c index f856c8ce6..d65124938 100644 --- a/src/modules/module_04800.c +++ b/src/modules/module_04800.c @@ -53,23 +53,22 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = ':'; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = ':'; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[2] = 2; - token.len_max[2] = 2; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_04900.c b/src/modules/module_04900.c index ad661e4c1..02c7a2ca7 100644 --- a/src/modules/module_04900.c +++ b/src/modules/module_04900.c @@ -49,12 +49,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_05000.c b/src/modules/module_05000.c index 72ce7de91..85c5c9e87 100644 --- a/src/modules/module_05000.c +++ b/src/modules/module_05000.c @@ -49,12 +49,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_05100.c b/src/modules/module_05100.c index 3753fbb50..d16ae19d6 100644 --- a/src/modules/module_05100.c +++ b/src/modules/module_05100.c @@ -50,11 +50,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_05300.c b/src/modules/module_05300.c index 16895447c..ea10850b2 100644 --- a/src/modules/module_05300.c +++ b/src/modules/module_05300.c @@ -74,6 +74,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.sep[0] = ':'; @@ -125,9 +127,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[8] = ':'; - token.len_min[8] = 32; - token.len_max[8] = 32; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 32; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_05400.c b/src/modules/module_05400.c index 276422103..f6470f0c0 100644 --- a/src/modules/module_05400.c +++ b/src/modules/module_05400.c @@ -74,6 +74,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.sep[0] = ':'; @@ -125,9 +127,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[8] = ':'; - token.len_min[8] = 40; - token.len_max[8] = 40; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 40; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_05500.c b/src/modules/module_05500.c index e02b828a3..ec6771bd9 100644 --- a/src/modules/module_05500.c +++ b/src/modules/module_05500.c @@ -114,45 +114,44 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; // username + token.sep[0] = ':'; token.len_min[0] = 0; token.len_max[0] = 60; - token.sep[0] = ':'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; // unused - token.len_min[1] = 0; - token.len_max[1] = 0; token.sep[1] = ':'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 0; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; // domain + token.sep[2] = ':'; token.len_min[2] = 0; token.len_max[2] = 45; - token.sep[2] = ':'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; // lm response + token.sep[3] = ':'; token.len_min[3] = 0; token.len_max[3] = 48; - token.sep[3] = ':'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // ntlm response - token.len_min[4] = 48; - token.len_max[4] = 48; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 48; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // challenge - token.len_min[5] = 16; - token.len_max[5] = 16; token.sep[5] = ':'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_05600.c b/src/modules/module_05600.c index 9ce22c4b3..78955456d 100644 --- a/src/modules/module_05600.c +++ b/src/modules/module_05600.c @@ -73,19 +73,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; // username + token.sep[0] = ':'; token.len_min[0] = 0; token.len_max[0] = 60; - token.sep[0] = ':'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; // unused - token.len_min[1] = 0; - token.len_max[1] = 0; token.sep[1] = ':'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 0; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; // domain token.len_min[2] = 0; @@ -94,23 +95,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; // lm response - token.len_min[3] = 16; - token.len_max[3] = 16; token.sep[3] = ':'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // ntlm response - token.len_min[4] = 32; - token.len_max[4] = 32; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // challenge + token.sep[5] = ':'; token.len_min[5] = 2; token.len_max[5] = 1024; - token.sep[5] = ':'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -197,7 +196,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); /** - * reuse challange data as salt_buf, its the buffer that is most likely unique + * reuse challenge data as salt_buf, its the buffer that is most likely unique */ salt->salt_buf[0] = 0; diff --git a/src/modules/module_05700.c b/src/modules/module_05700.c index 396f7ce3f..dab3dc8c5 100644 --- a/src/modules/module_05700.c +++ b/src/modules/module_05700.c @@ -54,6 +54,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 43; diff --git a/src/modules/module_05800.c b/src/modules/module_05800.c index 23c97f03b..b646d0f89 100644 --- a/src/modules/module_05800.c +++ b/src/modules/module_05800.c @@ -77,12 +77,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = 1; diff --git a/src/modules/module_06000.c b/src/modules/module_06000.c index 204617b2f..6c7b5ffec 100644 --- a/src/modules/module_06000.c +++ b/src/modules/module_06000.c @@ -48,11 +48,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_06050.c b/src/modules/module_06050.c index 7d1fec6c0..7cb55504c 100644 --- a/src/modules/module_06050.c +++ b/src/modules/module_06050.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_06060.c b/src/modules/module_06060.c index 0d0e59e8a..5407e642e 100644 --- a/src/modules/module_06060.c +++ b/src/modules/module_06060.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_06100.c b/src/modules/module_06100.c index a5243cd96..c583db693 100644 --- a/src/modules/module_06100.c +++ b/src/modules/module_06100.c @@ -48,11 +48,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_06300.c b/src/modules/module_06300.c index 02fc4d051..0f6ed5bc0 100644 --- a/src/modules/module_06300.c +++ b/src/modules/module_06300.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -181,9 +183,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 0; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_OPTIONAL_ROUNDS; diff --git a/src/modules/module_06400.c b/src/modules/module_06400.c index 39d6c8628..79e825509 100644 --- a/src/modules/module_06400.c +++ b/src/modules/module_06400.c @@ -261,6 +261,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -270,14 +272,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token.sep[2] = '$'; token.len_min[2] = 16; token.len_max[2] = 48; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.len[3] = 43; diff --git a/src/modules/module_06500.c b/src/modules/module_06500.c index 05cc564d5..bfaa5e243 100644 --- a/src/modules/module_06500.c +++ b/src/modules/module_06500.c @@ -445,6 +445,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -454,14 +456,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token.sep[2] = '$'; token.len_min[2] = 16; token.len_max[2] = 48; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.len[3] = 86; diff --git a/src/modules/module_06600.c b/src/modules/module_06600.c index 58972c082..f7bea8cdd 100644 --- a/src/modules/module_06600.c +++ b/src/modules/module_06600.c @@ -90,23 +90,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; + token.sep[0] = ':'; token.len_min[0] = 1; token.len_max[0] = 6; - token.sep[0] = ':'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[1] = 16; - token.len_max[1] = 16; token.sep[1] = ':'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[2] = 2080; - token.len_max[2] = 2080; token.sep[2] = ':'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2080; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_06700.c b/src/modules/module_06700.c index bbc36fe8d..3305f1502 100644 --- a/src/modules/module_06700.c +++ b/src/modules/module_06700.c @@ -196,6 +196,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -205,14 +207,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token.sep[2] = '$'; token.len_min[2] = 16; token.len_max[2] = 48; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.len[3] = 27; diff --git a/src/modules/module_06800.c b/src/modules/module_06800.c index 8f189fc45..35eebf6b4 100644 --- a/src/modules/module_06800.c +++ b/src/modules/module_06800.c @@ -118,28 +118,29 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; + token.sep[0] = ':'; token.len_min[0] = 32; token.len_max[0] = 64; - token.sep[0] = ':'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[1] = ':'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = ':'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[2] = ':'; token.len_min[2] = 0; token.len_max[2] = 32; - token.sep[2] = ':'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = ':'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_06900.c b/src/modules/module_06900.c index 3e659d629..eff993986 100644 --- a/src/modules/module_06900.c +++ b/src/modules/module_06900.c @@ -64,11 +64,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07000.c b/src/modules/module_07000.c index f97d8a4d8..99fb188cc 100644 --- a/src/modules/module_07000.c +++ b/src/modules/module_07000.c @@ -65,6 +65,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_07100.c b/src/modules/module_07100.c index 1d7b764ef..22adc6a98 100644 --- a/src/modules/module_07100.c +++ b/src/modules/module_07100.c @@ -119,6 +119,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -128,16 +130,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 64; - token.len_max[2] = 64; token.sep[2] = '$'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[3] = 128; @@ -206,6 +207,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; diff --git a/src/modules/module_07200.c b/src/modules/module_07200.c index 785c2538e..7f2852234 100644 --- a/src/modules/module_07200.c +++ b/src/modules/module_07200.c @@ -104,6 +104,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -113,21 +115,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '.'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = '.'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '.'; token.len_min[2] = SALT_MIN; token.len_max[2] = SALT_MAX; - token.sep[2] = '.'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[3] = 128; - token.len_max[3] = 128; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 128; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07300.c b/src/modules/module_07300.c index 905be677d..77a07db2d 100644 --- a/src/modules/module_07300.c +++ b/src/modules/module_07300.c @@ -66,17 +66,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; + token.sep[0] = hashconfig->separator; token.len_min[0] = 64; token.len_max[0] = 512; - token.sep[0] = hashconfig->separator; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07350.c b/src/modules/module_07350.c index 7c9dcb67c..fd79d31d1 100644 --- a/src/modules/module_07350.c +++ b/src/modules/module_07350.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = RAKP_HEX_SALT_MIN; diff --git a/src/modules/module_07400.c b/src/modules/module_07400.c index c1b57fdef..b4f82ed16 100644 --- a/src/modules/module_07400.c +++ b/src/modules/module_07400.c @@ -287,6 +287,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -296,9 +298,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 0; token.len_max[1] = 20; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_OPTIONAL_ROUNDS; diff --git a/src/modules/module_07401.c b/src/modules/module_07401.c index eb5143e97..9584781a4 100644 --- a/src/modules/module_07401.c +++ b/src/modules/module_07401.c @@ -288,6 +288,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -297,27 +299,24 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token.sep[2] = '*'; token.len_min[2] = 3; token.len_max[2] = 4; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 40; - token.len_max[3] = 40; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 40; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 86; - token.len_max[4] = 86; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 86; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07500.c b/src/modules/module_07500.c index 96a358ba0..30bdb71dc 100644 --- a/src/modules/module_07500.c +++ b/src/modules/module_07500.c @@ -104,6 +104,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -113,19 +115,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 0; token.len_max[1] = 64; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[2] = '$'; token.len_min[2] = 0; token.len_max[2] = 64; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[3] = '$'; token.len_min[3] = 0; token.len_max[3] = 128; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; token.len[4] = 72; @@ -223,12 +225,12 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (u32 i = 0; i < 36; i++, ptr_data += 2) { - sprintf (ptr_data, "%02x", ptr_timestamp[i]); + snprintf (ptr_data, 3, "%02x", ptr_timestamp[i]); } for (u32 i = 0; i < 16; i++, ptr_data += 2) { - sprintf (ptr_data, "%02x", ptr_checksum[i]); + snprintf (ptr_data, 3, "%02x", ptr_checksum[i]); } *ptr_data = 0; diff --git a/src/modules/module_07700.c b/src/modules/module_07700.c index 490c7ec4b..af5dd78d6 100644 --- a/src/modules/module_07700.c +++ b/src/modules/module_07700.c @@ -59,16 +59,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; + token.sep[0] = '$'; token.len_min[0] = 1; token.len_max[0] = 40; - token.sep[0] = '$'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07701.c b/src/modules/module_07701.c index cd7a0c211..8ca22e4c3 100644 --- a/src/modules/module_07701.c +++ b/src/modules/module_07701.c @@ -51,16 +51,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; + token.sep[0] = '$'; token.len_min[0] = 1; token.len_max[0] = 40; - token.sep[0] = '$'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07800.c b/src/modules/module_07800.c index 03c607845..080a26252 100644 --- a/src/modules/module_07800.c +++ b/src/modules/module_07800.c @@ -60,16 +60,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; + token.sep[0] = '$'; token.len_min[0] = 1; token.len_max[0] = 40; - token.sep[0] = '$'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07801.c b/src/modules/module_07801.c index 21ce106d9..0e390d259 100644 --- a/src/modules/module_07801.c +++ b/src/modules/module_07801.c @@ -60,16 +60,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; + token.sep[0] = '$'; token.len_min[0] = 1; token.len_max[0] = 40; - token.sep[0] = '$'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_07900.c b/src/modules/module_07900.c index a1cfb0e91..bebfb6aab 100644 --- a/src/modules/module_07900.c +++ b/src/modules/module_07900.c @@ -334,6 +334,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; diff --git a/src/modules/module_08000.c b/src/modules/module_08000.c index 238f4d613..0c774b5a6 100644 --- a/src/modules/module_08000.c +++ b/src/modules/module_08000.c @@ -82,6 +82,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_08100.c b/src/modules/module_08100.c index 8bbf03c06..14459192a 100644 --- a/src/modules/module_08100.c +++ b/src/modules/module_08100.c @@ -54,6 +54,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_08200.c b/src/modules/module_08200.c index 2d148936d..b8a7b75d9 100644 --- a/src/modules/module_08200.c +++ b/src/modules/module_08200.c @@ -62,6 +62,11 @@ typedef struct pbkdf2_sha512_tmp bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { + if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) + { + return true; + } + // AMD Radeon Pro W5700X, Metal.Version.: 261.13, compiler hangs if (device_param->is_metal == true) { @@ -122,18 +127,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = ':'; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = ':'; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = ':'; @@ -237,7 +242,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (int i = 0, j = 0; i < 512; i += 1, j += 8) { - sprintf (data_buf + j, "%08x", cloudkey->data_buf[i]); + snprintf (data_buf + j, 9, "%08x", cloudkey->data_buf[i]); } data_buf[cloudkey->data_len * 2] = 0; diff --git a/src/modules/module_08300.c b/src/modules/module_08300.c index 233812261..88975f396 100644 --- a/src/modules/module_08300.c +++ b/src/modules/module_08300.c @@ -49,12 +49,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = ':'; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = ':'; token.len_min[1] = 0; diff --git a/src/modules/module_08400.c b/src/modules/module_08400.c index 60cb06c68..199177f2c 100644 --- a/src/modules/module_08400.c +++ b/src/modules/module_08400.c @@ -51,17 +51,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_08500.c b/src/modules/module_08500.c index c3cd866ca..30984cb2e 100644 --- a/src/modules/module_08500.c +++ b/src/modules/module_08500.c @@ -103,25 +103,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_RACF; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '*'; token.len_min[1] = 0; token.len_max[1] = 8; - token.sep[1] = '*'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[2] = '$'; token.len_min[2] = 2; token.len_max[2] = 16; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_08600.c b/src/modules/module_08600.c index 4feea6537..498e3f378 100644 --- a/src/modules/module_08600.c +++ b/src/modules/module_08600.c @@ -57,11 +57,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_08700.c b/src/modules/module_08700.c index 6cf0ab3ac..6b3b2970e 100644 --- a/src/modules/module_08700.c +++ b/src/modules/module_08700.c @@ -81,6 +81,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.len[0] = 1; diff --git a/src/modules/module_08800.c b/src/modules/module_08800.c index a47feaa36..6b78e7f16 100644 --- a/src/modules/module_08800.c +++ b/src/modules/module_08800.c @@ -93,6 +93,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -102,32 +104,27 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '$'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[3] = 2; - token.len_max[3] = 2; token.sep[3] = '$'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[4] = 32; - token.len_max[4] = 32; token.sep[4] = '$'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[5] = 3072; - token.len_max[5] = 3072; token.sep[5] = '$'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 3072; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -186,7 +183,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (u32 i = 0, j = 0; i < 384; i += 1, j += 8) { - sprintf (tmp + j, "%08x", androidfde->data[i]); + snprintf (tmp + j, 9, "%08x", androidfde->data[i]); } tmp[3072] = 0; diff --git a/src/modules/module_08900.c b/src/modules/module_08900.c index c5b1014d8..d7b7a9a62 100644 --- a/src/modules/module_08900.c +++ b/src/modules/module_08900.c @@ -271,41 +271,42 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SCRYPT; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = ':'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = ':'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = ':'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[2] = ':'; token.len_min[2] = 1; token.len_max[2] = 6; - token.sep[2] = ':'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[3] = ':'; token.len_min[3] = 1; token.len_max[3] = 6; - token.sep[3] = ':'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; + token.sep[4] = ':'; token.len_min[4] = 0; token.len_max[4] = 45; - token.sep[4] = ':'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; + token.sep[5] = ':'; token.len_min[5] = 44; token.len_max[5] = 88; - token.sep[5] = ':'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; diff --git a/src/modules/module_09100.c b/src/modules/module_09100.c index 45cbd94ad..b0378756a 100644 --- a/src/modules/module_09100.c +++ b/src/modules/module_09100.c @@ -72,6 +72,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.len[0] = 1; diff --git a/src/modules/module_09200.c b/src/modules/module_09200.c index 60526214d..bfc3aac69 100644 --- a/src/modules/module_09200.c +++ b/src/modules/module_09200.c @@ -95,6 +95,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -104,10 +106,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 14; - token.len_max[1] = 14; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 14; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; token.len[2] = 43; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH diff --git a/src/modules/module_09300.c b/src/modules/module_09300.c index 1c1137021..e60d47b36 100644 --- a/src/modules/module_09300.c +++ b/src/modules/module_09300.c @@ -271,6 +271,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -280,10 +282,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 14; - token.len_max[1] = 14; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 14; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; token.len[2] = 43; token.attr[2] = TOKEN_ATTR_FIXED_LENGTH diff --git a/src/modules/module_09400.c b/src/modules/module_09400.c index 4f9c7a5e3..a5961f4fb 100644 --- a/src/modules/module_09400.c +++ b/src/modules/module_09400.c @@ -92,57 +92,51 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_OFFICE2007; - token.len_min[0] = 8; - token.len_max[0] = 8; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 4; - token.len_max[1] = 4; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 4; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 2; - token.len_max[2] = 2; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 2; - token.len_max[4] = 2; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 32; - token.len_max[5] = 32; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 32; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 32; - token.len_max[6] = 32; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[7] = 40; - token.len_max[7] = 40; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 40; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09500.c b/src/modules/module_09500.c index e6b6f9c5b..a9b179889 100644 --- a/src/modules/module_09500.c +++ b/src/modules/module_09500.c @@ -95,57 +95,51 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_OFFICE2010; - token.len_min[0] = 8; - token.len_max[0] = 8; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 4; - token.len_max[1] = 4; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 4; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 6; - token.len_max[2] = 6; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 6; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 2; - token.len_max[4] = 2; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 32; - token.len_max[5] = 32; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 32; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 32; - token.len_max[6] = 32; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[7] = 64; - token.len_max[7] = 64; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09600.c b/src/modules/module_09600.c index 8458d0490..10b55cd3e 100644 --- a/src/modules/module_09600.c +++ b/src/modules/module_09600.c @@ -129,57 +129,51 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_OFFICE2013; - token.len_min[0] = 8; - token.len_max[0] = 8; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 4; - token.len_max[1] = 4; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 4; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 6; - token.len_max[2] = 6; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 6; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 2; - token.len_max[4] = 2; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 32; - token.len_max[5] = 32; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 32; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 32; - token.len_max[6] = 32; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[7] = 64; - token.len_max[7] = 64; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09700.c b/src/modules/module_09700.c index 4e1850b91..a50e380b7 100644 --- a/src/modules/module_09700.c +++ b/src/modules/module_09700.c @@ -115,6 +115,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 2; @@ -125,27 +127,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 32; - token.len_max[4] = 32; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09710.c b/src/modules/module_09710.c index 588c9d4ad..10ca46814 100644 --- a/src/modules/module_09710.c +++ b/src/modules/module_09710.c @@ -135,6 +135,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 2; @@ -145,27 +147,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 32; - token.len_max[4] = 32; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09720.c b/src/modules/module_09720.c index 68583435d..ee1b6c6e8 100644 --- a/src/modules/module_09720.c +++ b/src/modules/module_09720.c @@ -117,6 +117,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 2; @@ -127,33 +129,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 32; - token.len_max[4] = 32; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[5] = 10; - token.len_max[5] = 10; token.sep[5] = ':'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 10; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09800.c b/src/modules/module_09800.c index e4e1f31e1..899b852e7 100644 --- a/src/modules/module_09800.c +++ b/src/modules/module_09800.c @@ -117,6 +117,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 2; @@ -127,27 +129,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 40; - token.len_max[4] = 40; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -158,10 +156,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { token.token_cnt = 6; - token.len_min[5] = 64; - token.len_max[5] = 64; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09810.c b/src/modules/module_09810.c index 7e210f91a..b689304ea 100644 --- a/src/modules/module_09810.c +++ b/src/modules/module_09810.c @@ -136,6 +136,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 2; @@ -146,27 +148,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 40; - token.len_max[4] = 40; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -177,10 +175,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { token.token_cnt = 6; - token.len_min[5] = 64; - token.len_max[5] = 64; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09820.c b/src/modules/module_09820.c index eaccd0bee..7508f8fff 100644 --- a/src/modules/module_09820.c +++ b/src/modules/module_09820.c @@ -119,6 +119,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -128,32 +130,27 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[4] = 40; - token.len_max[4] = 40; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[5] = 10; - token.len_max[5] = 10; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 10; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -166,15 +163,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[4] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; token.sep[5] = ':'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 10; - token.len_max[6] = 10; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 10; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_09900.c b/src/modules/module_09900.c index d2bb6eef8..3d845f55a 100644 --- a/src/modules/module_09900.c +++ b/src/modules/module_09900.c @@ -60,11 +60,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_10000.c b/src/modules/module_10000.c index a111fea93..ce6518d3d 100644 --- a/src/modules/module_10000.c +++ b/src/modules/module_10000.c @@ -92,15 +92,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_DJANGOPBKDF2; token.sep[0] = '$'; - token.len_min[0] = 13; - token.len_max[0] = 13; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 13; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; @@ -115,9 +116,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[3] = '$'; - token.len_min[3] = 44; - token.len_max[3] = 44; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 44; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_10100.c b/src/modules/module_10100.c index 333fb5104..096b8eba2 100644 --- a/src/modules/module_10100.c +++ b/src/modules/module_10100.c @@ -50,24 +50,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = ':'; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = ':'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = ':'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len[3] = 32; diff --git a/src/modules/module_10200.c b/src/modules/module_10200.c index 3ef6b4fcb..b236e573a 100644 --- a/src/modules/module_10200.c +++ b/src/modules/module_10200.c @@ -68,6 +68,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_10300.c b/src/modules/module_10300.c index cf3998d78..0768b6029 100644 --- a/src/modules/module_10300.c +++ b/src/modules/module_10300.c @@ -69,6 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_10400.c b/src/modules/module_10400.c index 05bd67c95..65a76701e 100644 --- a/src/modules/module_10400.c +++ b/src/modules/module_10400.c @@ -44,22 +44,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -122,6 +124,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 12; token.signatures_cnt = 1; @@ -131,69 +135,59 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 2; - token.len_max[3] = 2; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[6] = 2; - token.len_max[6] = 2; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 64; - token.len_max[9] = 64; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[10] = '*'; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[11] = 64; - token.len_max[11] = 64; token.sep[11] = '*'; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -214,6 +208,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -291,7 +289,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const pdf_t *pdf = (const pdf_t *) esalt_buf; - const int line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + const int line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 40, diff --git a/src/modules/module_10410.c b/src/modules/module_10410.c index cdf598787..1e0914738 100644 --- a/src/modules/module_10410.c +++ b/src/modules/module_10410.c @@ -46,22 +46,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -143,6 +145,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 12; token.signatures_cnt = 1; @@ -152,70 +156,60 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 2; - token.len_max[3] = 2; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[6] = 2; - token.len_max[6] = 2; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 64; - token.len_max[9] = 64; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[10] = '*'; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.sep[11] = '*'; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.sep[11] = '*'; + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -235,6 +229,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -312,7 +310,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const pdf_t *pdf = (const pdf_t *) esalt_buf; - const int line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + const int line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 40, diff --git a/src/modules/module_10420.c b/src/modules/module_10420.c index 908021b3b..23e8cb663 100644 --- a/src/modules/module_10420.c +++ b/src/modules/module_10420.c @@ -45,22 +45,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -123,6 +125,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 13; token.signatures_cnt = 1; @@ -132,76 +136,65 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 2; - token.len_max[3] = 2; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[6] = 2; - token.len_max[6] = 2; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 64; - token.len_max[9] = 64; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[10] = '*'; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.sep[11] = ':'; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.sep[11] = ':'; + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; - token.len_min[12] = 10; - token.len_max[12] = 10; - token.sep[12] = '*'; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.sep[12] = '*'; + token.len[12] = 10; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -222,6 +215,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -322,7 +319,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *rc4key = (const u8 *) pdf->rc4key; - const int line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x"; + + const int line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 40, diff --git a/src/modules/module_10500.c b/src/modules/module_10500.c index c253847cd..b9d932bc0 100644 --- a/src/modules/module_10500.c +++ b/src/modules/module_10500.c @@ -45,22 +45,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -153,6 +155,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 12; token.signatures_cnt = 1; @@ -162,70 +166,61 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[6] = 2; - token.len_max[6] = 2; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[7] = '*'; token.len_min[7] = 32; token.len_max[7] = 64; - token.sep[7] = '*'; token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 64; - token.len_max[9] = 64; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[10] = '*'; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.sep[11] = '*'; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.sep[11] = '*'; + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -245,6 +240,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -379,7 +378,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (pdf->id_len == 32) { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, @@ -416,7 +419,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, diff --git a/src/modules/module_10600.c b/src/modules/module_10600.c index 4218bc019..dc5422137 100644 --- a/src/modules/module_10600.c +++ b/src/modules/module_10600.c @@ -51,22 +51,22 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; } pdf_t; @@ -99,6 +99,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 16; token.signatures_cnt = 1; @@ -108,92 +110,88 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 4; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[7] = '*'; token.len_min[7] = 0; token.len_max[7] = 1024; - token.sep[7] = '*'; token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[8] = '*'; token.len_min[8] = 1; token.len_max[8] = 4; - token.sep[8] = '*'; token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[9] = '*'; token.len_min[9] = 0; token.len_max[9] = 1024; - token.sep[9] = '*'; token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[10] = '*'; token.len_min[10] = 1; token.len_max[10] = 4; - token.sep[10] = '*'; token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[11] = '*'; token.len_min[11] = 0; token.len_max[11] = 1024; - token.sep[11] = '*'; token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[12] = '*'; token.len_min[12] = 1; token.len_max[12] = 4; - token.sep[12] = '*'; token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[13] = '*'; token.len_min[13] = 0; token.len_max[13] = 1024; - token.sep[13] = '*'; token.attr[13] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[14] = '*'; token.len_min[14] = 1; token.len_max[14] = 4; - token.sep[14] = '*'; token.attr[14] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[15] = '*'; token.len_min[15] = 0; token.len_max[15] = 1024; - token.sep[15] = '*'; token.attr[15] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_10700.c b/src/modules/module_10700.c index 3f1e78b89..9b6fa97a3 100644 --- a/src/modules/module_10700.c +++ b/src/modules/module_10700.c @@ -47,22 +47,22 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; } pdf_t; @@ -71,7 +71,7 @@ typedef struct pdf17l8_tmp union { u32 dgst32[16]; - u64 dgst64[8]; + u64 dgst64[8]; } d; u32 dgst_len; @@ -84,10 +84,13 @@ static const int ROUNDS_PDF17L8 = 64; bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - // AppleM1, OpenCL, MTLCompilerService, createKernel: newComputePipelineState failed (or never-end with pure kernel) + // AppleM1, OpenCL, MTLCompilerService, createKernel never-end with pure kernel if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) { - return true; + if ((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) + { + return true; + } } return false; @@ -132,6 +135,11 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { char *jit_build_options = NULL; + if (device_param->is_metal == true) + { + hc_asprintf (&jit_build_options, "-D FORCE_DISABLE_SHM"); + } + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false)) { // this is a workaround to avoid a Segmentation fault and self-test fails on AMD GPU PRO @@ -170,6 +178,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 16; token.signatures_cnt = 1; @@ -179,92 +189,88 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 4; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[7] = '*'; token.len_min[7] = 0; token.len_max[7] = 1024; - token.sep[7] = '*'; token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[8] = '*'; token.len_min[8] = 1; token.len_max[8] = 4; - token.sep[8] = '*'; token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[9] = '*'; token.len_min[9] = 0; token.len_max[9] = 1024; - token.sep[9] = '*'; token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[10] = '*'; token.len_min[10] = 1; token.len_max[10] = 4; - token.sep[10] = '*'; token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[11] = '*'; token.len_min[11] = 0; token.len_max[11] = 1024; - token.sep[11] = '*'; token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[12] = '*'; token.len_min[12] = 1; token.len_max[12] = 4; - token.sep[12] = '*'; token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[13] = '*'; token.len_min[13] = 0; token.len_max[13] = 1024; - token.sep[13] = '*'; token.attr[13] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[14] = '*'; token.len_min[14] = 1; token.len_max[14] = 4; - token.sep[14] = '*'; token.attr[14] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[15] = '*'; token.len_min[15] = 0; token.len_max[15] = 1024; - token.sep[15] = '*'; token.attr[15] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_10800.c b/src/modules/module_10800.c index 7bce90227..d121df35b 100644 --- a/src/modules/module_10800.c +++ b/src/modules/module_10800.c @@ -100,11 +100,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 96; - token.len_max[0] = 96; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 96; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_10810.c b/src/modules/module_10810.c index eca1e2c89..a21fcdb56 100644 --- a/src/modules/module_10810.c +++ b/src/modules/module_10810.c @@ -86,12 +86,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 96; - token.len_max[0] = 96; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 96; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_10820.c b/src/modules/module_10820.c index f3c5de9e6..97dd5b775 100644 --- a/src/modules/module_10820.c +++ b/src/modules/module_10820.c @@ -86,12 +86,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 96; - token.len_max[0] = 96; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 96; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_10830.c b/src/modules/module_10830.c index a37e13146..6e3831d78 100644 --- a/src/modules/module_10830.c +++ b/src/modules/module_10830.c @@ -87,12 +87,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 96; - token.len_max[0] = 96; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 96; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_10840.c b/src/modules/module_10840.c index 9dc69e059..77e070dc0 100644 --- a/src/modules/module_10840.c +++ b/src/modules/module_10840.c @@ -87,12 +87,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 96; - token.len_max[0] = 96; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 96; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_10870.c b/src/modules/module_10870.c index 735ae8d87..3e2e4bfdd 100644 --- a/src/modules/module_10870.c +++ b/src/modules/module_10870.c @@ -87,11 +87,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 96; - token.len_max[0] = 96; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 96; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_10900.c b/src/modules/module_10900.c index 81393a8e6..75385f023 100644 --- a/src/modules/module_10900.c +++ b/src/modules/module_10900.c @@ -125,15 +125,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_PBKDF2_SHA256; token.sep[0] = ':'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ':'; diff --git a/src/modules/module_10901.c b/src/modules/module_10901.c index ed7f7448a..ed95f467d 100644 --- a/src/modules/module_10901.c +++ b/src/modules/module_10901.c @@ -94,6 +94,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; @@ -105,9 +107,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; //length of base64 encoded hash - token.len_min[1] = 432; - token.len_max[1] = 432; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 432; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_11000.c b/src/modules/module_11000.c index 7615ac640..60ab88df0 100644 --- a/src/modules/module_11000.c +++ b/src/modules/module_11000.c @@ -65,17 +65,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 56; - token.len_max[1] = 56; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 56; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_11100.c b/src/modules/module_11100.c index fbf53a92f..c95bd6893 100644 --- a/src/modules/module_11100.c +++ b/src/modules/module_11100.c @@ -52,6 +52,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -67,15 +69,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[2] = '*'; - token.len_min[2] = 8; - token.len_max[2] = 8; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 8; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_11200.c b/src/modules/module_11200.c index 5296043f7..938b179b1 100644 --- a/src/modules/module_11200.c +++ b/src/modules/module_11200.c @@ -52,6 +52,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -62,15 +64,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 40; - token.len_max[2] = 40; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_11300.c b/src/modules/module_11300.c index 00035b60c..7b81b3d26 100644 --- a/src/modules/module_11300.c +++ b/src/modules/module_11300.c @@ -134,6 +134,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 10; token.signatures_cnt = 1; @@ -156,9 +158,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; - token.len_min[3] = 2; - token.len_max[3] = 2; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '$'; diff --git a/src/modules/module_11400.c b/src/modules/module_11400.c index fc167c209..f6f656629 100644 --- a/src/modules/module_11400.c +++ b/src/modules/module_11400.c @@ -87,15 +87,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 15; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SIP_AUTH; token.sep[0] = '*'; - token.len_min[0] = 5; - token.len_max[0] = 5; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; @@ -159,14 +160,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[13] = '*'; - token.len_min[13] = 3; - token.len_max[13] = 3; - token.attr[13] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[13] = 3; + token.attr[13] = TOKEN_ATTR_FIXED_LENGTH; token.sep[14] = '*'; - token.len_min[14] = 32; - token.len_max[14] = 32; - token.attr[14] = TOKEN_ATTR_VERIFY_LENGTH + token.len[14] = 32; + token.attr[14] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_11500.c b/src/modules/module_11500.c index 9cdad89a1..fa691a2e2 100644 --- a/src/modules/module_11500.c +++ b/src/modules/module_11500.c @@ -48,18 +48,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 8; - token.len_max[0] = 8; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; - token.len_min[1] = 8; - token.len_max[1] = 8; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_11600.c b/src/modules/module_11600.c index d105aed32..9f1d37992 100644 --- a/src/modules/module_11600.c +++ b/src/modules/module_11600.c @@ -438,6 +438,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 11; token.signatures_cnt = 1; @@ -448,9 +450,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; @@ -460,9 +461,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 1; - token.len_max[3] = 1; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 1; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '$'; @@ -477,9 +477,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '$'; diff --git a/src/modules/module_11700.c b/src/modules/module_11700.c index 9e5308405..55b1bd13b 100644 --- a/src/modules/module_11700.c +++ b/src/modules/module_11700.c @@ -71,6 +71,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 64; diff --git a/src/modules/module_11750.c b/src/modules/module_11750.c index e575c0f9a..bf49d3f9e 100644 --- a/src/modules/module_11750.c +++ b/src/modules/module_11750.c @@ -71,12 +71,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_11760.c b/src/modules/module_11760.c index 96153191c..b9d0c19a2 100644 --- a/src/modules/module_11760.c +++ b/src/modules/module_11760.c @@ -71,12 +71,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_11800.c b/src/modules/module_11800.c index 2daaf0c83..36fa205ce 100644 --- a/src/modules/module_11800.c +++ b/src/modules/module_11800.c @@ -71,6 +71,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 128; diff --git a/src/modules/module_11850.c b/src/modules/module_11850.c index 73d4c8fd4..4e952013a 100644 --- a/src/modules/module_11850.c +++ b/src/modules/module_11850.c @@ -71,12 +71,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_11860.c b/src/modules/module_11860.c index bd9879085..3147c7a8c 100644 --- a/src/modules/module_11860.c +++ b/src/modules/module_11860.c @@ -71,12 +71,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_11900.c b/src/modules/module_11900.c index ee74a44e2..6e85beb0d 100644 --- a/src/modules/module_11900.c +++ b/src/modules/module_11900.c @@ -94,15 +94,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_PBKDF2_MD5; token.sep[0] = ':'; - token.len_min[0] = 3; - token.len_max[0] = 3; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 3; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ':'; diff --git a/src/modules/module_12000.c b/src/modules/module_12000.c index f36f8f0d0..733f161b6 100644 --- a/src/modules/module_12000.c +++ b/src/modules/module_12000.c @@ -94,15 +94,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_PBKDF2_SHA1; token.sep[0] = ':'; - token.len_min[0] = 4; - token.len_max[0] = 4; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 4; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ':'; diff --git a/src/modules/module_12001.c b/src/modules/module_12001.c index 264509ae2..e2be237fe 100644 --- a/src/modules/module_12001.c +++ b/src/modules/module_12001.c @@ -94,6 +94,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; @@ -103,9 +105,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 64; - token.len_max[1] = 64; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_12100.c b/src/modules/module_12100.c index 71a00d7a3..556476236 100644 --- a/src/modules/module_12100.c +++ b/src/modules/module_12100.c @@ -95,15 +95,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_PBKDF2_SHA512; token.sep[0] = ':'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ':'; diff --git a/src/modules/module_12200.c b/src/modules/module_12200.c index ab4a4d8c5..c731fc89f 100644 --- a/src/modules/module_12200.c +++ b/src/modules/module_12200.c @@ -106,6 +106,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -116,27 +118,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_12300.c b/src/modules/module_12300.c index 75bc6fd5d..1352e956d 100644 --- a/src/modules/module_12300.c +++ b/src/modules/module_12300.c @@ -89,6 +89,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.len[0] = 128; diff --git a/src/modules/module_12400.c b/src/modules/module_12400.c index c57efa59b..e84420685 100644 --- a/src/modules/module_12400.c +++ b/src/modules/module_12400.c @@ -93,6 +93,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; diff --git a/src/modules/module_12500.c b/src/modules/module_12500.c index c8f014b7b..ada4ac4d8 100644 --- a/src/modules/module_12500.c +++ b/src/modules/module_12500.c @@ -116,33 +116,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_RAR3; token.sep[0] = '*'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 16; - token.len_max[2] = 16; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 16; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_12600.c b/src/modules/module_12600.c index 3fb0c60db..27606ceeb 100644 --- a/src/modules/module_12600.c +++ b/src/modules/module_12600.c @@ -66,17 +66,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 64; - token.len_max[1] = 64; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_12700.c b/src/modules/module_12700.c index 7100a6b87..f7af4f4d1 100644 --- a/src/modules/module_12700.c +++ b/src/modules/module_12700.c @@ -79,6 +79,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -88,15 +90,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '$'; token.len_min[2] = 144; token.len_max[2] = 65536; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_12800.c b/src/modules/module_12800.c index f962cfb7b..066ed8a1d 100644 --- a/src/modules/module_12800.c +++ b/src/modules/module_12800.c @@ -108,32 +108,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_MS_DRSR; - token.len_min[0] = 11; - token.len_max[0] = 11; token.sep[0] = ','; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 20; - token.len_max[1] = 20; token.sep[1] = ','; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 20; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + token.sep[2] = ','; token.len_min[2] = 1; token.len_max[2] = 6; - token.sep[2] = ','; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 64; - token.len_max[3] = 64; token.sep[3] = ','; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_12900.c b/src/modules/module_12900.c index a3be18b9c..2a09a0652 100644 --- a/src/modules/module_12900.c +++ b/src/modules/module_12900.c @@ -108,6 +108,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.len[0] = 64; diff --git a/src/modules/module_13000.c b/src/modules/module_13000.c index 55c74af28..2bb211b7d 100644 --- a/src/modules/module_13000.c +++ b/src/modules/module_13000.c @@ -123,6 +123,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -133,39 +135,33 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 2; - token.len_max[1] = 2; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; - token.len_min[3] = 2; - token.len_max[3] = 2; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '$'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; - token.len_min[5] = 1; - token.len_max[5] = 1; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 16; - token.len_max[6] = 16; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 16; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_13100.c b/src/modules/module_13100.c index 1be89316a..d3949ae75 100644 --- a/src/modules/module_13100.c +++ b/src/modules/module_13100.c @@ -105,6 +105,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5TGS; @@ -146,9 +148,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // etype token.sep[1] = '$'; - token.len_min[1] = 2; - token.len_max[1] = 2; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // user$realm$spn @@ -159,9 +160,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // checksum token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // edata2 @@ -179,17 +179,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // etype token.sep[1] = '$'; - token.len_min[1] = 2; - token.len_max[1] = 2; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // checksum token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // edata2 @@ -215,9 +213,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // checksum token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // edata2 @@ -316,7 +313,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u8 *ptr_edata2 = (u8 *) krb5tgs->edata2; - sprintf (data + j, "%02x", ptr_edata2[i]); + snprintf (data + j, 3, "%02x", ptr_edata2[i]); } int line_len; diff --git a/src/modules/module_13200.c b/src/modules/module_13200.c index 54ddbba29..22d201208 100644 --- a/src/modules/module_13200.c +++ b/src/modules/module_13200.c @@ -74,21 +74,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_AXCRYPT; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -98,15 +98,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 48; - token.len_max[4] = 48; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 48; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_13300.c b/src/modules/module_13300.c index 5da86224e..daef383d7 100644 --- a/src/modules/module_13300.c +++ b/src/modules/module_13300.c @@ -55,6 +55,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_13400.c b/src/modules/module_13400.c index d559115e1..2ce9fc5ca 100644 --- a/src/modules/module_13400.c +++ b/src/modules/module_13400.c @@ -112,19 +112,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KEEPASS; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -148,33 +148,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 11; token.sep[4] = '*'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '*'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[8] = '*'; - token.len_min[8] = 1; - token.len_max[8] = 1; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[9] = '*'; @@ -194,21 +189,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 14; token.sep[11] = '*'; - token.len_min[11] = 1; - token.len_max[11] = 1; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + token.len[11] = 1; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[12] = '*'; - token.len_min[12] = 2; - token.len_max[12] = 2; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH + token.len[12] = 2; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[13] = '*'; - token.len_min[13] = 64; - token.len_max[13] = 64; - token.attr[13] = TOKEN_ATTR_VERIFY_LENGTH + token.len[13] = 64; + token.attr[13] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; } } @@ -217,33 +209,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 9; token.sep[4] = '*'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '*'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[8] = '*'; - token.len_min[8] = 64; - token.len_max[8] = 64; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 64; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; if (is_keyfile_present == true) @@ -251,21 +238,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 12; token.sep[9] = '*'; - token.len_min[9] = 1; - token.len_max[9] = 1; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 1; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[10] = '*'; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[11] = '*'; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; } } @@ -561,20 +545,17 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < final_random_seed_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_final_random_seed[i]); + for (u32 i = 0; i < final_random_seed_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_final_random_seed[i]); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < transf_random_seed_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_transf_random_seed[i]); + for (u32 i = 0; i < transf_random_seed_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_transf_random_seed[i]); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < enc_iv_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_enc_iv[i]); + for (u32 i = 0; i < enc_iv_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_enc_iv[i]); *ptr_data = '*'; ptr_data++; @@ -584,8 +565,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 contents_len = keepass->contents_len; u32 *ptr_contents = (u32 *) keepass->contents; - for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_contents_hash[i]); + for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_contents_hash[i]); *ptr_data = '*'; ptr_data++; @@ -599,31 +579,28 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE char ptr_contents_len[10] = { 0 }; - sprintf ((char*) ptr_contents_len, "%u", contents_len); + snprintf ((char*) ptr_contents_len, sizeof (ptr_contents_len), "%u", contents_len); - sprintf (ptr_data, "%u", contents_len); + snprintf (ptr_data, sizeof (ptr_contents_len), "%u", contents_len); ptr_data += strlen (ptr_contents_len); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < contents_len / 4; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_contents[i]); + for (u32 i = 0; i < contents_len / 4; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_contents[i]); } else if (version == 2) { expected_bytes_len = 8; ptr_expected_bytes = (u32 *) keepass->expected_bytes; - for (u32 i = 0; i < expected_bytes_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_expected_bytes[i]); + for (u32 i = 0; i < expected_bytes_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_expected_bytes[i]); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_contents_hash[i]); + for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_contents_hash[i]); } if (keyfile_len) @@ -638,15 +615,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE *ptr_data = '*'; ptr_data++; - sprintf (ptr_data, "%u", keyfile_len * 2); + snprintf (ptr_data, 3, "%u", keyfile_len * 2); ptr_data += 2; *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < 8; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_keyfile[i]); + for (u32 i = 0; i < 8; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_keyfile[i]); } return strlen (line_buf); diff --git a/src/modules/module_13500.c b/src/modules/module_13500.c index 42829d9f8..5f59900df 100644 --- a/src/modules/module_13500.c +++ b/src/modules/module_13500.c @@ -73,12 +73,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = 32; @@ -183,7 +184,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const u8 *ptr = (const u8 *) pstoken->salt_buf; - sprintf (pstoken_tmp + j, "%02x", ptr[i]); + snprintf (pstoken_tmp + j, 3, "%02x", ptr[i]); } const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%c%s", diff --git a/src/modules/module_13600.c b/src/modules/module_13600.c index 60988c4d6..c6dd15498 100644 --- a/src/modules/module_13600.c +++ b/src/modules/module_13600.c @@ -119,70 +119,66 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 10; token.signatures_cnt = 2; token.signatures_buf[0] = SIGNATURE_ZIP2_START; token.signatures_buf[1] = SIGNATURE_ZIP2_STOP; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 1; - token.len_max[3] = 1; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 1; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 16; token.len_max[4] = 32; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[5] = '*'; token.len_min[5] = 1; token.len_max[5] = 6; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 6; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[7] = '*'; token.len_min[7] = 0; token.len_max[7] = 0x200000 * 4 * 2; - token.sep[7] = '*'; token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 20; - token.len_max[8] = 20; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 20; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[9] = 7; - token.len_max[9] = 7; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 7; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -362,7 +358,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const u8 *ptr = (const u8 *) zip2->salt_buf; - sprintf (salt_tmp + j, "%02x", ptr[i]); + snprintf (salt_tmp + j, 3, "%02x", ptr[i]); } const u32 data_len = zip2->data_len; @@ -373,7 +369,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const u8 *ptr = (const u8 *) zip2->data_buf; - sprintf (data_tmp + j, "%02x", ptr[i]); + snprintf (data_tmp + j, 3, "%02x", ptr[i]); } const u32 auth_len = zip2->auth_len; @@ -384,7 +380,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const u8 *ptr = (const u8 *) zip2->auth_buf; - sprintf (auth_tmp + j, "%02x", ptr[i]); + snprintf (auth_tmp + j, 3, "%02x", ptr[i]); } const int line_len = snprintf (line_buf, line_size, "%s*%u*%u*%u*%s*%x*%x*%s*%s*%s", diff --git a/src/modules/module_13800.c b/src/modules/module_13800.c index 8bae1d163..199aeebda 100644 --- a/src/modules/module_13800.c +++ b/src/modules/module_13800.c @@ -86,18 +86,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; - token.len_min[0] = 64; - token.len_max[0] = 64; token.sep[0] = hashconfig->separator; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 256; - token.len_max[1] = 256; token.sep[1] = hashconfig->separator; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 256; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -163,7 +163,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (int i = 0, j = 0; i < 32; i += 1, j += 8) { - sprintf (buf + j, "%08x", esalt->salt_buf[i]); + snprintf (buf + j, 9, "%08x", esalt->salt_buf[i]); } const int line_len = snprintf (line_buf, line_size, "%08x%08x%08x%08x%08x%08x%08x%08x%c%s", diff --git a/src/modules/module_13900.c b/src/modules/module_13900.c index b5eadb8c7..ed573ec79 100644 --- a/src/modules/module_13900.c +++ b/src/modules/module_13900.c @@ -51,17 +51,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 9; - token.len_max[1] = 9; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 9; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_14000.c b/src/modules/module_14000.c index 28b07df76..80d1fd79f 100644 --- a/src/modules/module_14000.c +++ b/src/modules/module_14000.c @@ -163,17 +163,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_14100.c b/src/modules/module_14100.c index 2c93b2d53..bece404ad 100644 --- a/src/modules/module_14100.c +++ b/src/modules/module_14100.c @@ -114,17 +114,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_14400.c b/src/modules/module_14400.c index a45d818e7..7c10075a6 100644 --- a/src/modules/module_14400.c +++ b/src/modules/module_14400.c @@ -63,17 +63,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 20; - token.len_max[1] = 20; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 20; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_14500.c b/src/modules/module_14500.c index 23ff627be..8033ed481 100644 --- a/src/modules/module_14500.c +++ b/src/modules/module_14500.c @@ -144,6 +144,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -160,27 +162,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16 * 2; - token.len_max[3] = 16 * 2; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16 * 2; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 16 * 2; - token.len_max[4] = 16 * 2; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16 * 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; - token.len_min[5] = 16 * 2; - token.len_max[5] = 16 * 2; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16 * 2; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_14700.c b/src/modules/module_14700.c index 5bdfe431c..601e07063 100644 --- a/src/modules/module_14700.c +++ b/src/modules/module_14700.c @@ -94,50 +94,49 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ITUNES_BACKUP; - token.len_min[0] = 15; - token.len_max[0] = 15; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 15; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '*'; token.len_min[1] = 1; token.len_max[1] = 2; - token.sep[1] = '*'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 80; - token.len_max[2] = 80; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 80; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[3] = '*'; token.len_min[3] = 1; token.len_max[3] = 6; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 40; - token.len_max[4] = 40; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[5] = '*'; token.len_min[5] = 0; token.len_max[5] = 10; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[6] = '*'; token.len_min[6] = 0; token.len_max[6] = 40; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_14800.c b/src/modules/module_14800.c index 9e88690e4..2825b93ce 100644 --- a/src/modules/module_14800.c +++ b/src/modules/module_14800.c @@ -110,50 +110,49 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ITUNES_BACKUP; - token.len_min[0] = 15; - token.len_max[0] = 15; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 15; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = '*'; token.len_min[1] = 1; token.len_max[1] = 2; - token.sep[1] = '*'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 80; - token.len_max[2] = 80; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 80; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[3] = '*'; token.len_min[3] = 1; token.len_max[3] = 6; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 40; - token.len_max[4] = 40; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[5] = '*'; token.len_min[5] = 0; token.len_max[5] = 10; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[6] = '*'; token.len_min[6] = 0; token.len_max[6] = 40; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_14900.c b/src/modules/module_14900.c index 33614cc1d..2bedb5553 100644 --- a/src/modules/module_14900.c +++ b/src/modules/module_14900.c @@ -67,18 +67,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; - token.len_min[0] = 8; - token.len_max[0] = 8; token.sep[0] = hashconfig->separator; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 8; - token.len_max[1] = 8; token.sep[1] = hashconfig->separator; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_15000.c b/src/modules/module_15000.c index 8a4fe3b6c..b41d51d35 100644 --- a/src/modules/module_15000.c +++ b/src/modules/module_15000.c @@ -97,17 +97,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 64; - token.len_max[1] = 64; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_15100.c b/src/modules/module_15100.c index 670aa3754..e1c27067c 100644 --- a/src/modules/module_15100.c +++ b/src/modules/module_15100.c @@ -200,6 +200,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -216,14 +218,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 8; - token.len_max[2] = 8; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[2] = 8; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH; token.sep[3] = '$'; - token.len_min[3] = 28; - token.len_max[3] = 28; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 28; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_15200.c b/src/modules/module_15200.c index 0f1ef64ef..91c25f0c3 100644 --- a/src/modules/module_15200.c +++ b/src/modules/module_15200.c @@ -77,6 +77,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; diff --git a/src/modules/module_15300.c b/src/modules/module_15300.c index 661ad20c9..0469b19d2 100644 --- a/src/modules/module_15300.c +++ b/src/modules/module_15300.c @@ -52,7 +52,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; @@ -105,6 +105,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 10; token.signatures_cnt = 1; @@ -116,55 +118,52 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // version - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // context - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // sid + token.sep[3] = '*'; token.len_min[3] = 10; token.len_max[3] = 60; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; // cipher + token.sep[4] = '*'; token.len_min[4] = 4; token.len_max[4] = 6; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; // hash + token.sep[5] = '*'; token.len_min[5] = 4; token.len_max[5] = 6; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH; // iterations + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 6; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iv - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // content len + token.sep[8] = '*'; token.len_min[8] = 1; token.len_max[8] = 6; - token.sep[8] = '*'; token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; diff --git a/src/modules/module_15310.c b/src/modules/module_15310.c index 85ebc3860..c58dba69b 100644 --- a/src/modules/module_15310.c +++ b/src/modules/module_15310.c @@ -55,7 +55,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; @@ -121,6 +121,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 10; token.signatures_cnt = 1; @@ -132,55 +134,52 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // version - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // context - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // sid + token.sep[3] = '*'; token.len_min[3] = 10; token.len_max[3] = 60; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; // cipher + token.sep[4] = '*'; token.len_min[4] = 4; token.len_max[4] = 6; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; // hash + token.sep[5] = '*'; token.len_min[5] = 4; token.len_max[5] = 6; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH; // iterations + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 6; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iv - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // content len + token.sep[8] = '*'; token.len_min[8] = 1; token.len_max[8] = 6; - token.sep[8] = '*'; token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; diff --git a/src/modules/module_15400.c b/src/modules/module_15400.c index ffca28876..a42b7ba67 100644 --- a/src/modules/module_15400.c +++ b/src/modules/module_15400.c @@ -90,21 +90,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_CHACHA20; token.sep[0] = '*'; - token.len_min[0] = 10; - token.len_max[0] = 10; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; @@ -113,21 +113,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[3] = '*'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 16; - token.len_max[5] = 16; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_15500.c b/src/modules/module_15500.c index a352777a8..dd10ed9cf 100644 --- a/src/modules/module_15500.c +++ b/src/modules/module_15500.c @@ -89,27 +89,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_JKS_SHA1; token.sep[0] = '*'; - token.len_min[0] = 10; - token.len_max[0] = 10; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 40; - token.len_max[2] = 40; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; @@ -119,15 +118,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 2; - token.len_max[4] = 2; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 28; - token.len_max[5] = 28; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 28; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; @@ -231,7 +228,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (u32 i = 0, j = 0; i < jks_sha1->enc_key_len; i += 1, j += 2) { - sprintf (enc_key + j, "%02X", ptr[i]); + snprintf (enc_key + j, 3, "%02X", ptr[i]); } u8 *der = (u8 *) jks_sha1->der; diff --git a/src/modules/module_15600.c b/src/modules/module_15600.c index 76766b004..a9605061f 100644 --- a/src/modules/module_15600.c +++ b/src/modules/module_15600.c @@ -126,15 +126,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ETHEREUM_PBKDF2; token.sep[0] = '*'; - token.len_min[0] = 11; - token.len_max[0] = 11; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; @@ -150,15 +151,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_15700.c b/src/modules/module_15700.c index 5743dea70..baf0c72c1 100644 --- a/src/modules/module_15700.c +++ b/src/modules/module_15700.c @@ -287,15 +287,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ETHEREUM_SCRYPT; token.sep[0] = '*'; - token.len_min[0] = 11; - token.len_max[0] = 11; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; @@ -317,21 +318,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '*'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; - token.len_min[6] = 64; - token.len_max[6] = 64; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 64; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_15900.c b/src/modules/module_15900.c index 0f4af0d5c..0614b1157 100644 --- a/src/modules/module_15900.c +++ b/src/modules/module_15900.c @@ -53,7 +53,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; @@ -117,6 +117,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 10; token.signatures_cnt = 1; @@ -128,41 +130,39 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // version - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // context - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // sid + token.sep[3] = '*'; token.len_min[3] = 10; token.len_max[3] = 60; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; // cipher + token.sep[4] = '*'; token.len_min[4] = 4; token.len_max[4] = 6; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; // hash + token.sep[5] = '*'; token.len_min[5] = 4; token.len_max[5] = 6; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH; // iterations + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 6; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; @@ -174,9 +174,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; // content len + token.sep[8] = '*'; token.len_min[8] = 1; token.len_max[8] = 6; - token.sep[8] = '*'; token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; diff --git a/src/modules/module_15910.c b/src/modules/module_15910.c index 5b85bb2b6..5e8be508f 100644 --- a/src/modules/module_15910.c +++ b/src/modules/module_15910.c @@ -56,7 +56,7 @@ typedef struct dpapimk u32 SID_offset; /* here only for possible - forward compatibiliy + forward compatibility */ // u8 cipher_algo[16]; // u8 hash_algo[16]; @@ -127,6 +127,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 10; token.signatures_cnt = 1; @@ -138,55 +140,52 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // version - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // context - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // sid + token.sep[3] = '*'; token.len_min[3] = 10; token.len_max[3] = 60; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; // cipher + token.sep[4] = '*'; token.len_min[4] = 4; token.len_max[4] = 6; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; // hash + token.sep[5] = '*'; token.len_min[5] = 4; token.len_max[5] = 6; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH; // iterations + token.sep[6] = '*'; token.len_min[6] = 1; token.len_max[6] = 6; - token.sep[6] = '*'; token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iv - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // content len + token.sep[8] = '*'; token.len_min[8] = 1; token.len_max[8] = 6; - token.sep[8] = '*'; token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; diff --git a/src/modules/module_16000.c b/src/modules/module_16000.c index f5b533c67..0d9536f73 100644 --- a/src/modules/module_16000.c +++ b/src/modules/module_16000.c @@ -55,6 +55,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 10; diff --git a/src/modules/module_16100.c b/src/modules/module_16100.c index 15418a7b7..9e470f079 100644 --- a/src/modules/module_16100.c +++ b/src/modules/module_16100.c @@ -72,6 +72,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -82,9 +84,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 8; - token.len_max[1] = 8; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; @@ -94,9 +95,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; - token.len_min[3] = 4; - token.len_max[3] = 4; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 4; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -166,7 +166,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE for (u32 i = 0, j = 0; i < tacacs_plus->ct_data_len; i += 1, j += 2) { - sprintf (ct_data + j, "%02x", ct_data_ptr[i]); + snprintf (ct_data + j, 3, "%02x", ct_data_ptr[i]); } const u8 *session_ptr = (const u8 *) tacacs_plus->session_buf; diff --git a/src/modules/module_16200.c b/src/modules/module_16200.c index e846b875b..36e14358e 100644 --- a/src/modules/module_16200.c +++ b/src/modules/module_16200.c @@ -116,15 +116,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_APPLE_SECURE_NOTES; token.sep[0] = '*'; - token.len_min[0] = 5; - token.len_max[0] = 5; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; @@ -140,15 +141,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 48; - token.len_max[4] = 48; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 48; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_16300.c b/src/modules/module_16300.c index 9ac1c7cf0..1efe11c73 100644 --- a/src/modules/module_16300.c +++ b/src/modules/module_16300.c @@ -128,15 +128,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ETHEREUM_PRESALE; token.sep[0] = '*'; - token.len_min[0] = 11; - token.len_max[0] = 11; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 11; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; @@ -146,15 +147,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 40; - token.len_max[2] = 40; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_16400.c b/src/modules/module_16400.c index e2c1c9abf..009d82ad2 100644 --- a/src/modules/module_16400.c +++ b/src/modules/module_16400.c @@ -64,6 +64,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_16500.c b/src/modules/module_16500.c index 6bd19f712..d4add2cf9 100644 --- a/src/modules/module_16500.c +++ b/src/modules/module_16500.c @@ -123,6 +123,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = '.'; diff --git a/src/modules/module_16600.c b/src/modules/module_16600.c index cde2db041..0571028f7 100644 --- a/src/modules/module_16600.c +++ b/src/modules/module_16600.c @@ -70,6 +70,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -80,21 +82,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_16700.c b/src/modules/module_16700.c index e683a5356..50314c20d 100644 --- a/src/modules/module_16700.c +++ b/src/modules/module_16700.c @@ -85,6 +85,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -107,9 +109,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; @@ -119,9 +120,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[5] = '$'; - token.len_min[5] = 48; - token.len_max[5] = 48; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 48; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_16800.c b/src/modules/module_16800.c index bff43cdfd..f01ac61ee 100644 --- a/src/modules/module_16800.c +++ b/src/modules/module_16800.c @@ -333,24 +333,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = sep; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = sep; - token.len_min[1] = 12; - token.len_max[1] = 12; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 12; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = sep; - token.len_min[2] = 12; - token.len_max[2] = 12; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 12; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = sep; diff --git a/src/modules/module_16801.c b/src/modules/module_16801.c index 82fe33bb1..43886ed82 100644 --- a/src/modules/module_16801.c +++ b/src/modules/module_16801.c @@ -355,26 +355,25 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + // real 16801 pmkid hash-lines token.token_cnt = 3; token.sep[0] = sep; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = sep; - token.len_min[1] = 12; - token.len_max[1] = 12; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 12; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = sep; - token.len_min[2] = 12; - token.len_max[2] = 12; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 12; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -386,21 +385,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 4; token.sep[0] = sep; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = sep; - token.len_min[1] = 12; - token.len_max[1] = 12; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 12; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = sep; - token.len_min[2] = 12; - token.len_max[2] = 12; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 12; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = sep; diff --git a/src/modules/module_16900.c b/src/modules/module_16900.c index 9ab655617..213b5940e 100644 --- a/src/modules/module_16900.c +++ b/src/modules/module_16900.c @@ -127,6 +127,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -137,21 +139,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; @@ -161,9 +160,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_17010.c b/src/modules/module_17010.c index ede464576..865a6f8eb 100644 --- a/src/modules/module_17010.c +++ b/src/modules/module_17010.c @@ -137,6 +137,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 13; // signature $gpg$ @@ -144,93 +146,84 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.signatures_buf[0] = SIGNATURE_GPG; // signature $gpg$ - token.len_min[0] = 5; - token.len_max[0] = 5; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // "1" -- unknown option - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of the encrypted data in bytes + token.sep[2] = '*'; token.len_min[2] = 3; token.len_max[2] = 4; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of the key: 1024, 2048, 4096, etc. + token.sep[3] = '*'; token.len_min[3] = 3; token.len_max[3] = 4; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // encrypted key -- twice the amount of byte because its interpreted as characters + token.sep[4] = '*'; token.len_min[4] = 256; token.len_max[4] = 3072; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // "3" - String2Key parameter - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // "254" - String2Key parameters - token.len_min[6] = 3; - token.len_max[6] = 3; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 3; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // "2" - String2Key parameters - token.len_min[7] = 1; - token.len_max[7] = 1; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 1; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // cipher mode: 7 or 9 - token.len_min[8] = 1; - token.len_max[8] = 1; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of initial vector in bytes: 16 - token.len_min[9] = 2; - token.len_max[9] = 2; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 2; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // initial vector - twice the amount of bytes because its interpreted as characters - token.len_min[10] = 32; - token.len_max[10] = 32; token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 32; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // iteration count + token.sep[11] = '*'; token.len_min[11] = 1; token.len_max[11] = 8; - token.sep[11] = '*'; token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt - 8 bytes / 16 characters - token.len_min[12] = 16; - token.len_max[12] = 16; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH + token.len[12] = 16; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_17020.c b/src/modules/module_17020.c index 4ce8e21ea..c4c9c7bef 100644 --- a/src/modules/module_17020.c +++ b/src/modules/module_17020.c @@ -141,6 +141,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 13; // signature $gpg$ @@ -148,93 +150,84 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.signatures_buf[0] = SIGNATURE_GPG; // signature $gpg$ - token.len_min[0] = 5; - token.len_max[0] = 5; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // "1" -- unknown option - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of the encrypted data in bytes + token.sep[2] = '*'; token.len_min[2] = 3; token.len_max[2] = 4; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of the key: 1024, 2048, 4096, etc. + token.sep[3] = '*'; token.len_min[3] = 3; token.len_max[3] = 4; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // encrypted key -- twice the amount of byte because its interpreted as characters + token.sep[4] = '*'; token.len_min[4] = 256; token.len_max[4] = 3072; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // "3" - String2Key parameter - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // "254" - String2Key parameters - token.len_min[6] = 3; - token.len_max[6] = 3; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 3; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // "10" - String2Key parameters - token.len_min[7] = 2; - token.len_max[7] = 2; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 2; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // cipher mode: 7 or 9 - token.len_min[8] = 1; - token.len_max[8] = 1; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of initial vector in bytes: 16 - token.len_min[9] = 2; - token.len_max[9] = 2; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 2; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // initial vector - twice the amount of bytes because its interpreted as characters - token.len_min[10] = 32; - token.len_max[10] = 32; token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 32; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // iteration count + token.sep[11] = '*'; token.len_min[11] = 1; token.len_max[11] = 8; - token.sep[11] = '*'; token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt - 8 bytes / 16 characters - token.len_min[12] = 16; - token.len_max[12] = 16; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH + token.len[12] = 16; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_17030.c b/src/modules/module_17030.c index 5b06d694e..05867755c 100644 --- a/src/modules/module_17030.c +++ b/src/modules/module_17030.c @@ -137,6 +137,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 13; // signature $gpg$ @@ -144,93 +146,84 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.signatures_buf[0] = SIGNATURE_GPG; // signature $gpg$ - token.len_min[0] = 5; - token.len_max[0] = 5; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // "1" -- unknown option - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of the encrypted data in bytes + token.sep[2] = '*'; token.len_min[2] = 3; token.len_max[2] = 4; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of the key: 1024, 2048, 4096, etc. + token.sep[3] = '*'; token.len_min[3] = 3; token.len_max[3] = 4; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // encrypted key -- twice the amount of byte because its interpreted as characters + token.sep[4] = '*'; token.len_min[4] = 256; token.len_max[4] = 3072; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // "3" - String2Key parameter - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // "254" - String2Key parameters - token.len_min[6] = 3; - token.len_max[6] = 3; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 3; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // "10" - String2Key parameters - token.len_min[7] = 1; - token.len_max[7] = 1; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 1; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // cipher mode: 7 or 9 - token.len_min[8] = 1; - token.len_max[8] = 1; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // size of initial vector in bytes: 16 - token.len_min[9] = 2; - token.len_max[9] = 2; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 2; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // initial vector - twice the amount of bytes because its interpreted as characters - token.len_min[10] = 32; - token.len_max[10] = 32; token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 32; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // iteration count + token.sep[11] = '*'; token.len_min[11] = 1; token.len_max[11] = 8; - token.sep[11] = '*'; token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt - 8 bytes / 16 characters - token.len_min[12] = 16; - token.len_max[12] = 16; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH + token.len[12] = 16; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_17040.c b/src/modules/module_17040.c new file mode 100644 index 000000000..36c94c897 --- /dev/null +++ b/src/modules/module_17040.c @@ -0,0 +1,435 @@ +/** + * Author......: Netherlands Forensic Institute + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_PRIVATE_KEY; +static const char *HASH_NAME = "GPG (CAST5 (SHA-1($pass)))"; +static const u64 KERN_TYPE = 17040; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_LOOP_PREPARE + | OPTS_TYPE_AUX1 + | OPTS_TYPE_DEEP_COMP_KERNEL; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "Hashcat1!"; +static const char *ST_HASH = "$gpg$*1*1308*4096*ddf02802e2d06319bcf5962745b73677ecfa229649fed991e3360bdf2fffe71f521b8f877bccfcdce9a4fb4aeb63bd21fed6e37f96f193a6f7d3c476f4a7e01e7421d0eba5bfcd59544e37887572cd40e8d03e901574ec0f3afdff35ad3f25cb818ddadee84ddfef636207febd8d12d8a98983c86afa46608d178dba5ec51e98a182bd9687b6431fba87b5a16b5e0cf872db7dc12c55bfe7faaa443044d5a84ddf034198e5bc6b4b707b5f4a4c5999ff3885975113fca02693620f36f8f20570bdaf581726053b6c982cb988a3091dc206624f9d36372b151b22c7dc2cb71b9aaed95dc5630c4c4b045f80c403836cc9c84951fc04b8d6e413e1d4f6b3815508f43cf80c25c7db3882b5b6572f1395a00dcda7fe65ce2155f9ea2cfe13588e0fb10316e7dd978e1d89cffc06a5e722ec765315926d2ee9060d8f449ead31cbacea88a5251be3b518d23984530da9f930114e614b7ed30f748c7512bddca8604bb5310ed76b9982eb88acaf49a29325e9db6987c6dea3878e2cb7daf3800177579ddcaafeacdba8edd147fae61bae36ab83a98db69a6c92017b3db8cff68985db989a03ee1bd045e6a577151486cdaeaf26517027b2f140b8493e2f401ea222511c2ce61c7057d64e8c3568e3f547f4b2875db59bc8c4f3346e0faf54e30745f583494b59e570bacb2b9eb71eb834e57f68aadda9af4bdb03276f71770c611aad0278033bb8c108471c4f4a2aa9070774367b9334661daf8a5e3eaf3d8dcca723d64ae7264c8709987a6cee9f42287b6e20d1d753262ff74886f3995412e59d09c61e4c637b6e97e6a3b08f9fa6adf9a1ec44a0372e893febd6712decc00bbd9cdacaf6bb9302fe8bd2ca27fdf5156c33582d56781ab0e5bd14da4b1edd73edd8f2a034a56d1a6f836724b605657f4714d59d522805e0ab02c6c5daed0973f93120ae01623ce0a96fbdf4402ce20ebb4f97fabbc90da5bb12aac3cd5f15c1add2d3863be59e843dca564ce9aa25b43ca1044b1e7e65d03d1f55f77d2a39cd85536ff38058837a23743c4e252f7de5654a562506b55d2b8fa29c7f4ecd307a8ae686cbb73fea6a8f72775d9e417ec346415024263a9f339dda286b682ccc8f93f7d4f59921620dd276188441fd44fc63925d18caa30a75c79c37a2ea45d14f6e423d2146281f9c6699a0658e50d69cfbc174090a0420bbb6f4e6b5b1f2b81b26f035aaf5c2e558c812496cb494587c78bf75350fb1a36e8c88076b4684094e0cba5dcdc4f672dbd2b432306b75077ae07b8fd88ba5b829eaed3fd2959a09b162329b75ac8fc20d4eea6e5971f54b31a23952dd4c111765822182cd60ee0de3cce3752c648918e3ec4c52643223132dcc885140faf8108230ebf4ef4149cbfa3070c91ec013404c15c1cecaa1efd544ab8313d378ef0e77c615b76b8ec07769960873ce9c7bdb1d75e7faef4c8a0b015c95a4e2bcd9ff7f5dfddd9a243fc0688db09e534ef1f3ebebd0c73b75bd57b8e02667da5744b1400dc695d4ae1e255d3487d1dead115de7d48962a15c7aecb97444173c40c028a46a7cfdd8cc7421f71d757cb809341c5148aedeab16f9289bc55b7475d646ae4993ab36fe5609a05121d140d4390289c94e4d87fd902fe03c8bfa13e7cfc9c21355ab6461d214137e4d90dff4a8f599020f12d7560fa4b5aaee1727f21c873fde76415b65357ecb923a547ddcdb20dde0880a287ed26d5ea4ce45514b907e368527c62e39ffdf2efeb817cd59694d23bafd48862e723f45e3c258cff3c804c5d2f17e24be8fe81a00f11f519beb9cde7be95226ac2a7f11e0f4f09dc040c11e1bf63172aa0f8a*1*254*2*3*8*0000000000000000*0*a11df265e4e54bee"; + + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct gpg +{ + u32 cipher_algo; + u32 iv[4]; // TODO make this dynamic based on the input hash.. iv_size can be 8 bytes or 16 bytes + u32 modulus_size; + u32 encrypted_data[384]; + u32 encrypted_data_size; + +} gpg_t; + +typedef struct gpg_tmp +{ + u32 salted_pw_block[80]; + + u32 salted_pw_block_len; + + u32 h[10]; + + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + u32 len; + +} gpg_tmp_t; + +static const char *SIGNATURE_GPG = "$gpg$"; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (gpg_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (gpg_tmp_t); + + return tmp_size; +} + +bool module_hlfmt_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool hlfmt_disable = true; + + return hlfmt_disable; +} + +u32 module_kernel_loops_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_min = 1024; + + return kernel_loops_min; +} + +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 65536; + + return kernel_loops_max; +} + +u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) +{ + const u32 digests_offset = hashes->salts_buf[salt_pos].digests_offset; + + gpg_t *gpgs = (gpg_t *) hashes->esalts_buf; + + gpg_t *gpg = &gpgs[digests_offset + digest_pos]; + + if (gpg->cipher_algo == 3) // CAST5 + { + return KERN_RUN_AUX1; + } + return 0; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + gpg_t *gpg = (gpg_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 13; + + // signature $gpg$ + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_GPG; + + // signature $gpg$ + token.sep[0] = '*'; + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + // "1" -- unknown option + token.sep[1] = '*'; + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // size of the encrypted data in bytes + token.sep[2] = '*'; + token.len_min[2] = 3; + token.len_max[2] = 4; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // size of the key: 1024, 2048, 4096, etc. + token.sep[3] = '*'; + token.len_min[3] = 3; + token.len_max[3] = 4; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // encrypted key -- twice the amount of byte because its interpreted as characters + token.sep[4] = '*'; + token.len_min[4] = 256; + token.len_max[4] = 3072; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + // "3" - String2Key parameter "S2K Type" https://www.rfc-editor.org/rfc/rfc4880#section-3.7 + // https://security.stackexchange.com/questions/142914/does-s2k-hold-any-use-in-symmetric-encryption-with-gnupg "OpenPGP uses the string-to-key function for both encrypting the private key with a passphrase and symmetric encryption. The function is used to derive a session key (cipher block) for symmetric encryption." + // https://github.com/gpg/gnupg/blob/ab35d756d86438db124fa68aa633fe528ff8be50/g10/packet.h#L98 + // https://www.rfc-editor.org/rfc/rfc4880#section-3.7 so we only have a salted s2k not an iterated-and-salted + // ID S2K Type + // -- -------- + // 0 Simple S2K + // 1 Salted S2K + // 2 Reserved value + // 3 Iterated and Salted S2K + token.sep[5] = '*'; + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // "254" - String2Key parameter "usage" / "Secret-Key Packet Format" https://github.com/openwall/john/blob/bleeding-jumbo/src/gpg2john.c#L2424 + // 255 or 254 + // indicates that a string-to-key specifier is being given. Any + // other value is a symmetric-key encryption algorithm identifier. + + // If the string-to-key usage octet was + // 254, then a 20-octet SHA-1 hash of the plaintext of the + // algorithm-specific portion. + token.sep[6] = '*'; + token.len[6] = 3; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // "2" - String2Key parameter "HASH_ALGS" https://github.com/openwall/john/blob/bleeding-jumbo/src/gpg2john.c#L646 + // sha1 in this case + token.sep[7] = '*'; + token.len[7] = 1; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // "3" cipher mode: String2Key parameter "SYM_ALGS" https://github.com/openwall/john/blob/bleeding-jumbo/src/gpg2john.c#L558 + // cast in this case + token.sep[8] = '*'; + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // size of initial vector in bytes: 8 or 16 + token.sep[9] = '*'; + token.len_min[9] = 1; + token.len_max[9] = 2; + token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // initial vector - twice the amount of bytes because its interpreted as characters + token.sep[10] = '*'; + token.len_min[10] = 16; + token.len_max[10] = 32; + token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + // iteration count + token.sep[11] = '*'; + token.len_min[11] = 1; + token.len_max[11] = 8; + token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // salt - 8 bytes / 16 characters + token.len[12] = 16; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // Modulus size + + const int modulus_size = hc_strtoul ((const char *) token.buf[3], NULL, 10); + + if ((modulus_size < 256) || (modulus_size > 16384)) return (PARSER_SALT_LENGTH); + + gpg->modulus_size = modulus_size; + + // Encrypted data + + const int enc_data_size = hc_strtoul ((const char *) token.buf[2], NULL, 10); + + const int encrypted_data_size = hex_decode ((const u8 *) token.buf[4], token.len[4], (u8 *) gpg->encrypted_data); + + if (enc_data_size != encrypted_data_size) return (PARSER_CT_LENGTH); + + gpg->encrypted_data_size = encrypted_data_size; + + // Check String2Key parameters + + if ((hc_strtoul ((const char *) token.buf[5], NULL, 10) != 1) && (hc_strtoul ((const char *) token.buf[5], NULL, 10) != 3)) { + return (PARSER_HASH_VALUE); // for us this "String2Key parameter 1" is 1 instead of 3, no idea what that means.. + } + + // 100 to 110 Private/Experimental S2K + if (hc_strtoul ((const char *) token.buf[6], NULL, 10) != 254) return (PARSER_HASH_VALUE); + if (hc_strtoul ((const char *) token.buf[7], NULL, 10) != 2) return (PARSER_HASH_VALUE); + + // Cipher algo + const int cipher_algo = hc_strtoul ((const char *) token.buf[8], NULL, 10); + + if (cipher_algo != 3) return (PARSER_CIPHER); + + gpg->cipher_algo = cipher_algo; + + // IV (size) + + // if (hc_strtoul ((const char *) token.buf[9], NULL, 10) != sizeof (gpg->iv)) { + // // printf("hc_strtoul ((const char *) token.buf[9]=%d\n", (const char *) token.buf[9], NULL, 10); + // // printf("sizeof (gpg->iv)=%d\n", sizeof (gpg->iv)); + // return (PARSER_IV_LENGTH); + // } + // const int iv_size = hex_decode ((const u8 *) token.buf[10], token.len[10], (u8 *) gpg->iv); + + // if (iv_size != sizeof (gpg->iv)){ + // return (PARSER_IV_LENGTH); + // } + + + // Salt Iter + + const u32 salt_iter = hc_strtoul ((const char *) token.buf[11], NULL, 10); + + if (salt_iter != 0) return (PARSER_HASH_VALUE); // only accept 0 for now + if(salt_iter ==0){ salt->salt_iter = 8; } // just once should work? TODO not sure why I cannot change this to zero / remove the salt_iter completely.. + // else { + // if (salt_iter < 8 || salt_iter > 65011712){ return (PARSER_SALT_ITERATION); } + // else { + // salt->salt_iter = salt_iter; + // } + // } + + + // Salt Value + + salt->salt_repeats = gpg->cipher_algo == 7 ? 0 : 1; // "minus one" // TODO check this? + + salt->salt_len = hex_decode ((const u8 *) token.buf[12], token.len[12], (u8 *) salt->salt_buf); + + if (salt->salt_len != 8) return (PARSER_SALT_LENGTH); + + // hash fake + digest[0] = gpg->iv[0]; + digest[1] = gpg->iv[1]; + digest[2] = gpg->iv[2]; + digest[3] = gpg->iv[3]; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const gpg_t *gpg = (const gpg_t *) esalt_buf; + + u8 encrypted_data[(384 * 8) + 1]; + memset(encrypted_data,0,384*8+1); // always initialize to zero + + hex_encode ((const u8 *) gpg->encrypted_data, gpg->encrypted_data_size, (u8 *) encrypted_data); + + const int line_len = snprintf (line_buf, line_size, "%s*%d*%d*%d*%s*%d*%d*%d*%d*%d*%08x%08x*%d*%08x%08x", + SIGNATURE_GPG, + 1, /* unknown field */ + gpg->encrypted_data_size, + gpg->modulus_size, + encrypted_data, + 1, /* version (major?) */ + 254, /* version (minor?) */ + 2, /* key cipher (sha-1) */ + gpg->cipher_algo, + 8, /*iv_size*/ + byte_swap_32 (gpg->iv[0]), + byte_swap_32 (gpg->iv[1]), + 0, /* salt_iter is always zero */ + byte_swap_32 (salt->salt_buf[0]), + byte_swap_32 (salt->salt_buf[1])); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = module_hlfmt_disable; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_17300.c b/src/modules/module_17300.c index 69b2d9a71..139bf7181 100644 --- a/src/modules/module_17300.c +++ b/src/modules/module_17300.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 56; diff --git a/src/modules/module_17400.c b/src/modules/module_17400.c index 8960f81b0..74a7b2275 100644 --- a/src/modules/module_17400.c +++ b/src/modules/module_17400.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 64; diff --git a/src/modules/module_17500.c b/src/modules/module_17500.c index 21f36b68c..2bd2448e4 100644 --- a/src/modules/module_17500.c +++ b/src/modules/module_17500.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 96; diff --git a/src/modules/module_17600.c b/src/modules/module_17600.c index be05ad43d..b6760541b 100644 --- a/src/modules/module_17600.c +++ b/src/modules/module_17600.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 128; diff --git a/src/modules/module_17700.c b/src/modules/module_17700.c index f0ac2fe15..803bed8c5 100644 --- a/src/modules/module_17700.c +++ b/src/modules/module_17700.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 56; diff --git a/src/modules/module_17800.c b/src/modules/module_17800.c index aa0c1d710..ae6abb885 100644 --- a/src/modules/module_17800.c +++ b/src/modules/module_17800.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 64; diff --git a/src/modules/module_17900.c b/src/modules/module_17900.c index 95bc5f611..3db6a9496 100644 --- a/src/modules/module_17900.c +++ b/src/modules/module_17900.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 96; diff --git a/src/modules/module_18000.c b/src/modules/module_18000.c index 1d99d0a4e..5f3209c5b 100644 --- a/src/modules/module_18000.c +++ b/src/modules/module_18000.c @@ -50,6 +50,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 128; diff --git a/src/modules/module_18100.c b/src/modules/module_18100.c index d2d3eaee3..d7b1f62a9 100644 --- a/src/modules/module_18100.c +++ b/src/modules/module_18100.c @@ -57,12 +57,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_18200.c b/src/modules/module_18200.c index b7c4aab11..87120b443 100644 --- a/src/modules/module_18200.c +++ b/src/modules/module_18200.c @@ -104,6 +104,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5ASREP; @@ -131,7 +133,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE krb5asrep->format = 1; - parse_off += 2; + parse_off += 3; } else { @@ -145,8 +147,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (account_info_stop == NULL) return (PARSER_SEPARATOR_UNMATCHED); - account_info_stop++; // we want the : char included - const int account_info_len = account_info_stop - account_info_start; token.token_cnt = 4; @@ -171,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // checksum token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // edata2 @@ -195,9 +194,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // checksum token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // edata2 @@ -285,14 +283,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u8 *ptr_edata2 = (u8 *) krb5asrep->edata2; - sprintf (data + j, "%02x", ptr_edata2[i]); + snprintf (data + j, 3, "%02x", ptr_edata2[i]); } int line_len = 0; if (krb5asrep->format == 1) { - line_len = snprintf (line_buf, line_size, "%s23%s%08x%08x%08x%08x$%s", + line_len = snprintf (line_buf, line_size, "%s23$%s:%08x%08x%08x%08x$%s", SIGNATURE_KRB5ASREP, (char *) krb5asrep->account_info, byte_swap_32 (krb5asrep->checksum[0]), @@ -303,7 +301,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - line_len = snprintf (line_buf, line_size, "%s%s%08x%08x%08x%08x$%s", + line_len = snprintf (line_buf, line_size, "%s%s:%08x%08x%08x%08x$%s", SIGNATURE_KRB5ASREP, (char *) krb5asrep->account_info, byte_swap_32 (krb5asrep->checksum[0]), diff --git a/src/modules/module_18300.c b/src/modules/module_18300.c index 0bd20be83..6a3750718 100644 --- a/src/modules/module_18300.c +++ b/src/modules/module_18300.c @@ -116,6 +116,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -138,9 +140,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; @@ -150,9 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[5] = '$'; - token.len_min[5] = 80; - token.len_max[5] = 80; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 80; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_18400.c b/src/modules/module_18400.c index 43fa0cea4..549e6ab71 100644 --- a/src/modules/module_18400.c +++ b/src/modules/module_18400.c @@ -58,6 +58,7 @@ typedef struct odf12 u32 iv[4]; u32 checksum[8]; u32 encrypted_data[256]; + int encrypted_len; } odf12_t; @@ -95,89 +96,82 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 12; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ODF; - token.len_min[0] = 5; - token.len_max[0] = 5; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[3] = '*'; token.len_min[3] = 4; token.len_max[3] = 6; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 2; - token.len_max[4] = 2; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 64; - token.len_max[5] = 64; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 2; - token.len_max[6] = 2; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[7] = 32; - token.len_max[7] = 32; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 32; - token.len_max[9] = 32; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 32; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 1; - token.len_max[10] = 1; token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 1; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len[11] = 2048; - token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + token.len_min[11] = 16; + token.len_max[11] = 2048; + token.sep[11] = '*'; + token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - const u8 *checksum = token.buf[5]; - const u8 *iv = token.buf[7]; - const u8 *salt_buf = token.buf[9]; - const u8 *encrypted_data = token.buf[11]; + const u8 *checksum = token.buf[5]; + const u8 *iv = token.buf[7]; + const u8 *salt_buf = token.buf[9]; const u32 cipher_type = strtol ((const char *) token.buf[1], NULL, 10); const u32 checksum_type = strtol ((const char *) token.buf[2], NULL, 10); @@ -207,15 +201,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE odf12->checksum[6] = hex_to_u32 (&checksum[48]); odf12->checksum[7] = hex_to_u32 (&checksum[56]); + // iv + odf12->iv[0] = hex_to_u32 (&iv[0]); odf12->iv[1] = hex_to_u32 (&iv[8]); odf12->iv[2] = hex_to_u32 (&iv[16]); odf12->iv[3] = hex_to_u32 (&iv[24]); - for (int i = 0, j = 0; i < 256; i += 1, j += 8) - { - odf12->encrypted_data[i] = hex_to_u32 (&encrypted_data[j]); - } + // ct + + const int ct_len = token.len[11]; + const u8 *ct_pos = token.buf[11]; + + odf12->encrypted_len = hex_decode (ct_pos, ct_len, (u8 *) odf12->encrypted_data); // salt @@ -248,7 +246,17 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const odf12_t *odf12 = (const odf12_t *) esalt_buf; - int out_len = snprintf (line_buf, line_size, "%s*1*1*%u*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*", + // ct + + u8 ct_buf[(256 * 4 * 2) + 1]; + + memset (ct_buf, 0, sizeof (ct_buf)); + + const int ct_len = hex_encode ((const u8 *) odf12->encrypted_data, odf12->encrypted_len, ct_buf); + + ct_buf[ct_len] = 0; + + const int out_len = snprintf (line_buf, line_size, "%s*1*1*%u*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*%s", SIGNATURE_ODF, odf12->iterations, byte_swap_32 (odf12->checksum[0]), @@ -266,14 +274,8 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE byte_swap_32 (salt->salt_buf[0]), byte_swap_32 (salt->salt_buf[1]), byte_swap_32 (salt->salt_buf[2]), - byte_swap_32 (salt->salt_buf[3])); - - u8 *out_buf = (u8 *) line_buf; - - for (int i = 0; i < 256; i++) - { - u32_to_hex (odf12->encrypted_data[i], out_buf + out_len); out_len += 8; - } + byte_swap_32 (salt->salt_buf[3]), + (char *) ct_buf); return out_len; } diff --git a/src/modules/module_18500.c b/src/modules/module_18500.c index 920a624de..f4e0e3cdc 100644 --- a/src/modules/module_18500.c +++ b/src/modules/module_18500.c @@ -68,11 +68,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_18600.c b/src/modules/module_18600.c index b0cd68a52..ec7e5cbef 100644 --- a/src/modules/module_18600.c +++ b/src/modules/module_18600.c @@ -60,6 +60,7 @@ typedef struct odf11 u32 iv[2]; u32 checksum[5]; u32 encrypted_data[256]; + int encrypted_len; } odf11_t; @@ -190,89 +191,82 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 12; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ODF; - token.len_min[0] = 5; - token.len_max[0] = 5; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[3] = '*'; token.len_min[3] = 4; token.len_max[3] = 6; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 2; - token.len_max[4] = 2; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 40; - token.len_max[5] = 40; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 40; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 1; - token.len_max[6] = 1; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 1; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[7] = 16; - token.len_max[7] = 16; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 16; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 32; - token.len_max[9] = 32; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 32; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 1; - token.len_max[10] = 1; token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 1; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len[11] = 2048; - token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + token.sep[11] = '*'; + token.len_min[11] = 16; + token.len_max[11] = 2048; + token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - const u8 *checksum = token.buf[5]; - const u8 *iv = token.buf[7]; - const u8 *salt_buf = token.buf[9]; - const u8 *encrypted_data = token.buf[11]; + const u8 *checksum = token.buf[5]; + const u8 *iv = token.buf[7]; + const u8 *salt_buf = token.buf[9]; const u32 cipher_type = strtol ((const char *) token.buf[1], NULL, 10); const u32 checksum_type = strtol ((const char *) token.buf[2], NULL, 10); @@ -299,15 +293,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE odf11->checksum[3] = hex_to_u32 (&checksum[24]); odf11->checksum[4] = hex_to_u32 (&checksum[32]); + // iv + odf11->iv[0] = byte_swap_32 (hex_to_u32 (&iv[0])); odf11->iv[1] = byte_swap_32 (hex_to_u32 (&iv[8])); - for (int i = 0, j = 0; i < 256; i += 1, j += 8) - { - odf11->encrypted_data[i] = hex_to_u32 (&encrypted_data[j]); + // ct - odf11->encrypted_data[i] = byte_swap_32 (odf11->encrypted_data[i]); - } + const int ct_len = token.len[11]; + const u8 *ct_pos = token.buf[11]; + + odf11->encrypted_len = hex_decode (ct_pos, ct_len, (u8 *) odf11->encrypted_data); + + for (int i = 0, j = 0; i < odf11->encrypted_len; i += 4, j += 1) odf11->encrypted_data[j] = byte_swap_32 (odf11->encrypted_data[j]); // salt @@ -342,7 +340,19 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const odf11_t *odf11 = (const odf11_t *) esalt_buf; - int out_len = snprintf (line_buf, line_size, "%s*0*0*%u*16*%08x%08x%08x%08x%08x*8*%08x%08x*16*%08x%08x%08x%08x*0*", + // ct + + u32 ct_buf[256]; + + for (int i = 0; i < 256; i++) ct_buf[i] = byte_swap_32 (odf11->encrypted_data[i]); + + u8 ct_buf8[(256 * 4 * 2) + 1]; + + const int ct_len = hex_encode ((const u8 *) ct_buf, odf11->encrypted_len, ct_buf8); + + ct_buf8[ct_len] = 0; + + const int out_len = snprintf (line_buf, line_size, "%s*0*0*%u*16*%08x%08x%08x%08x%08x*8*%08x%08x*16*%08x%08x%08x%08x*0*%s", SIGNATURE_ODF, odf11->iterations, byte_swap_32 (odf11->checksum[0]), @@ -355,14 +365,8 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE salt->salt_buf[0], salt->salt_buf[1], salt->salt_buf[2], - salt->salt_buf[3]); - - u8 *out_buf = (u8 *) line_buf; - - for (int i = 0; i < 256; i++) - { - u32_to_hex (byte_swap_32 (odf11->encrypted_data[i]), out_buf + out_len); out_len += 8; - } + salt->salt_buf[3], + (char *) ct_buf8); return out_len; } diff --git a/src/modules/module_18700.c b/src/modules/module_18700.c index f1d6823af..57c7bdc1e 100644 --- a/src/modules/module_18700.c +++ b/src/modules/module_18700.c @@ -48,11 +48,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 8; - token.len_max[0] = 8; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_18800.c b/src/modules/module_18800.c index 342f2ecfc..45e30f6b6 100644 --- a/src/modules/module_18800.c +++ b/src/modules/module_18800.c @@ -125,11 +125,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 80; - token.len_max[0] = 80; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 80; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_18900.c b/src/modules/module_18900.c index b23b81467..2141796f2 100644 --- a/src/modules/module_18900.c +++ b/src/modules/module_18900.c @@ -96,6 +96,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; @@ -107,52 +109,46 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // version - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // cipher - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter + token.sep[3] = '*'; token.len_min[3] = 1; token.len_max[3] = 6; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // user_salt - token.len_min[4] = 128; - token.len_max[4] = 128; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 128; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // ck_salt - token.len_min[5] = 128; - token.len_max[5] = 128; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 128; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // user_iv - token.len_min[6] = 32; - token.len_max[6] = 32; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // masterkey_blob - token.len_min[7] = 192; - token.len_max[7] = 192; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 192; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_19000.c b/src/modules/module_19000.c index d0d23c2b4..b9875463e 100644 --- a/src/modules/module_19000.c +++ b/src/modules/module_19000.c @@ -72,12 +72,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = '@'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '@'; token.len_min[1] = 1; @@ -114,7 +115,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE iter = hc_strtoul ((const char *) token.buf[1] + 2, NULL, 10); } - // iter++; the additinal round is added in the init kernel + // iter++; the additional round is added in the init kernel salt->salt_iter = iter; diff --git a/src/modules/module_19100.c b/src/modules/module_19100.c index 44538ca08..74222b883 100644 --- a/src/modules/module_19100.c +++ b/src/modules/module_19100.c @@ -64,12 +64,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = '@'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '@'; token.len_min[1] = 1; @@ -106,7 +107,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE iter = hc_strtoul ((const char *) token.buf[1] + 2, NULL, 10); } - // iter++; the additinal round is added in the init kernel + // iter++; the additional round is added in the init kernel salt->salt_iter = iter; diff --git a/src/modules/module_19200.c b/src/modules/module_19200.c index 657e132ea..4fa1c8daa 100644 --- a/src/modules/module_19200.c +++ b/src/modules/module_19200.c @@ -67,12 +67,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = '@'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '@'; token.len_min[1] = 1; @@ -109,7 +110,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE iter = hc_strtoul ((const char *) token.buf[1] + 2, NULL, 10); } - // iter++; the additinal round is added in the init kernel + // iter++; the additional round is added in the init kernel salt->salt_iter = iter; diff --git a/src/modules/module_19300.c b/src/modules/module_19300.c index c78e03727..2e9bb17d9 100644 --- a/src/modules/module_19300.c +++ b/src/modules/module_19300.c @@ -90,12 +90,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; diff --git a/src/modules/module_19500.c b/src/modules/module_19500.c index 130a3bea6..3e6748efa 100644 --- a/src/modules/module_19500.c +++ b/src/modules/module_19500.c @@ -82,12 +82,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; diff --git a/src/modules/module_19600.c b/src/modules/module_19600.c index 19a327f75..af5e04a82 100644 --- a/src/modules/module_19600.c +++ b/src/modules/module_19600.c @@ -89,6 +89,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5TGS; @@ -125,16 +127,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[3] = '$'; // hmac-sha1 stripped to 12bytes - token.len_min[3] = 24; - token.len_max[3] = 24; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; token.len_min[4] = 64; token.len_max[4] = 40960; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + | TOKEN_ATTR_VERIFY_HEX; } // assume $krb5tgs$17$user$realm$*spn*$checksum$edata2 else @@ -164,16 +165,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; token.sep[4] = '$'; - token.len_min[4] = 24; - token.len_max[4] = 24; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[4] = 24; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; token.len_min[5] = 64; token.len_max[5] = 40960; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + | TOKEN_ATTR_VERIFY_HEX; is_spn_provided = 1; } @@ -267,7 +267,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u8 *ptr_edata2 = (u8 *) krb5tgs->edata2; - sprintf (data + j, "%02x", ptr_edata2[i]); + snprintf (data + j, 3, "%02x", ptr_edata2[i]); } const int line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x$%s", diff --git a/src/modules/module_19700.c b/src/modules/module_19700.c index 4ccaefea1..d7eba1d4a 100644 --- a/src/modules/module_19700.c +++ b/src/modules/module_19700.c @@ -89,6 +89,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5TGS; @@ -125,10 +127,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.sep[3] = '$'; // hmac-sha1 stripped to 12bytes - token.len_min[3] = 24; - token.len_max[3] = 24; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; token.len_min[4] = 64; @@ -164,16 +165,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; token.sep[4] = '$'; - token.len_min[4] = 24; - token.len_max[4] = 24; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[4] = 24; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; token.len_min[5] = 64; token.len_max[5] = 40960; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + | TOKEN_ATTR_VERIFY_HEX; is_spn_provided = 1; } @@ -267,7 +267,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u8 *ptr_edata2 = (u8 *) krb5tgs->edata2; - sprintf (data + j, "%02x", ptr_edata2[i]); + snprintf (data + j, 3, "%02x", ptr_edata2[i]); } const int line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x$%s", diff --git a/src/modules/module_19800.c b/src/modules/module_19800.c index 9c5957fe5..28560777f 100644 --- a/src/modules/module_19800.c +++ b/src/modules/module_19800.c @@ -89,6 +89,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5PA; @@ -213,7 +215,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u8 *ptr_enc_timestamp = (u8 *) krb5pa->enc_timestamp; - sprintf (data + j, "%02x", ptr_enc_timestamp[i]); + snprintf (data + j, 3, "%02x", ptr_enc_timestamp[i]); } const int line_len = snprintf (line_buf, line_size, "%s%s$%s$%s%08x%08x%08x", diff --git a/src/modules/module_19900.c b/src/modules/module_19900.c index 7a0fb6e04..329b4902e 100644 --- a/src/modules/module_19900.c +++ b/src/modules/module_19900.c @@ -89,6 +89,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5PA; @@ -213,7 +215,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { u8 *ptr_enc_timestamp = (u8 *) krb5pa->enc_timestamp; - sprintf (data + j, "%02x", ptr_enc_timestamp[i]); + snprintf (data + j, 3, "%02x", ptr_enc_timestamp[i]); } const int line_len = snprintf (line_buf, line_size, "%s%s$%s$%s%08x%08x%08x", diff --git a/src/modules/module_20011.c b/src/modules/module_20011.c index 8e3892521..c01b548bb 100644 --- a/src/modules/module_20011.c +++ b/src/modules/module_20011.c @@ -104,6 +104,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -113,10 +115,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[2] = 4096; diff --git a/src/modules/module_20012.c b/src/modules/module_20012.c index 76f6f8b6a..627765d09 100644 --- a/src/modules/module_20012.c +++ b/src/modules/module_20012.c @@ -104,6 +104,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -113,10 +115,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[2] = 4096; diff --git a/src/modules/module_20013.c b/src/modules/module_20013.c index d0e6a8958..b8cfbf9b7 100644 --- a/src/modules/module_20013.c +++ b/src/modules/module_20013.c @@ -104,6 +104,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -113,10 +115,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[2] = 4096; diff --git a/src/modules/module_20200.c b/src/modules/module_20200.c index d775cc986..351810ae1 100644 --- a/src/modules/module_20200.c +++ b/src/modules/module_20200.c @@ -93,6 +93,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -100,14 +102,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // the hash starts with a $ token.sep[0] = '$'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '$'; - token.len_min[1] = 13; - token.len_max[1] = 13; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 13; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // iterations in decimal representation @@ -117,18 +117,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - // salt in alternate base64 repretentation + // salt in alternate base64 representation token.sep[3] = '$'; token.len_min[3] = SALT_MIN; token.len_max[3] = SALT_MAX; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; - // payload in alternate base64 representanion + // payload in alternate base64 representation token.sep[4] = '$'; - token.len_min[4] = HASH_LEN_B64; - token.len_max[4] = HASH_LEN_B64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = HASH_LEN_B64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20300.c b/src/modules/module_20300.c index 792243334..1a65498e2 100644 --- a/src/modules/module_20300.c +++ b/src/modules/module_20300.c @@ -92,6 +92,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -99,14 +101,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // the hash starts with a $ token.sep[0] = '$'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '$'; - token.len_min[1] = 13; - token.len_max[1] = 13; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 13; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // iterations in decimal representation @@ -116,18 +116,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - // salt in alternate base64 repretentation + // salt in alternate base64 representation token.sep[3] = '$'; token.len_min[3] = SALT_MIN; token.len_max[3] = SALT_MAX; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; - // payload in alternate base64 representanion + // payload in alternate base64 representation token.sep[4] = '$'; - token.len_min[4] = HASH_LEN_B64; - token.len_max[4] = HASH_LEN_B64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = HASH_LEN_B64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20400.c b/src/modules/module_20400.c index be36d1fb9..d099fb360 100644 --- a/src/modules/module_20400.c +++ b/src/modules/module_20400.c @@ -92,6 +92,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -99,14 +101,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // the hash starts with a $ token.sep[0] = '$'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '$'; - token.len_min[1] = 6; - token.len_max[1] = 6; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 6; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // iterations in decimal representation @@ -116,18 +116,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - // salt in alternate base64 repretentation + // salt in alternate base64 representation token.sep[3] = '$'; token.len_min[3] = SALT_MIN; token.len_max[3] = SALT_MAX; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; - // payload in alternate base64 representanion + // payload in alternate base64 representation token.sep[4] = '$'; - token.len_min[4] = HASH_LEN_B64; - token.len_max[4] = HASH_LEN_B64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = HASH_LEN_B64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64B; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20500.c b/src/modules/module_20500.c index 7b05986a1..3a001c93e 100644 --- a/src/modules/module_20500.c +++ b/src/modules/module_20500.c @@ -105,11 +105,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 24; - token.len_max[0] = 24; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 24; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20510.c b/src/modules/module_20510.c index 04fef62f8..e89e8dfc2 100644 --- a/src/modules/module_20510.c +++ b/src/modules/module_20510.c @@ -146,11 +146,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 24; - token.len_max[0] = 24; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 24; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20600.c b/src/modules/module_20600.c index d957e6f76..dc35c6081 100644 --- a/src/modules/module_20600.c +++ b/src/modules/module_20600.c @@ -99,6 +99,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -107,9 +109,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // sig token.sep[0] = ':'; - token.len_min[0] = 10; - token.len_max[0] = 10; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // iter diff --git a/src/modules/module_20710.c b/src/modules/module_20710.c index 9a7cfbed0..49705221e 100644 --- a/src/modules/module_20710.c +++ b/src/modules/module_20710.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_20711.c b/src/modules/module_20711.c index 44e8c9976..1103ddf7b 100644 --- a/src/modules/module_20711.c +++ b/src/modules/module_20711.c @@ -70,6 +70,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -80,14 +82,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; token.sep[2] = '$'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20712.c b/src/modules/module_20712.c new file mode 100644 index 000000000..e2b5a492d --- /dev/null +++ b/src/modules/module_20712.c @@ -0,0 +1,266 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "RSA Security Analytics / NetWitness (sha256)"; +static const u64 KERN_TYPE = 20712; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15 + | OPTS_TYPE_ST_BASE64; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "6F48F44C46F5ADC534597687B086278F0AAF7D262ADDB3978562A7D55BBDF467:MDAwMzY1NzYwODI4MQ=="; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= SHA256M_A; + digest[1] -= SHA256M_B; + digest[2] -= SHA256M_C; + digest[3] -= SHA256M_D; + digest[4] -= SHA256M_E; + digest[5] -= SHA256M_F; + digest[6] -= SHA256M_G; + digest[7] -= SHA256M_H; + } + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + u32 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += SHA256M_A; + tmp[1] += SHA256M_B; + tmp[2] += SHA256M_C; + tmp[3] += SHA256M_D; + tmp[4] += SHA256M_E; + tmp[5] += SHA256M_F; + tmp[6] += SHA256M_G; + tmp[7] += SHA256M_H; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); + tmp[5] = byte_swap_32 (tmp[5]); + tmp[6] = byte_swap_32 (tmp[6]); + tmp[7] = byte_swap_32 (tmp[7]); + + u8 tmp_uc[64]; + + memset (tmp_uc, 0, sizeof (tmp_uc)); + + int tmp_off = 0; + + u32_to_hex (tmp[0], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[1], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[2], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[3], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[4], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[5], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[6], tmp_uc + tmp_off); tmp_off += 8; + u32_to_hex (tmp[7], tmp_uc + tmp_off); tmp_off += 8; + + uppercase (tmp_uc, 64); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + memcpy (out_buf, tmp_uc, 64); + + out_len += 64; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_20720.c b/src/modules/module_20720.c index 1eab75d78..3dc89ef5e 100644 --- a/src/modules/module_20720.c +++ b/src/modules/module_20720.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_20800.c b/src/modules/module_20800.c index 5aa0103d9..54a1b02d5 100644 --- a/src/modules/module_20800.c +++ b/src/modules/module_20800.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_20900.c b/src/modules/module_20900.c index 41022fb54..8a0dd5c60 100644 --- a/src/modules/module_20900.c +++ b/src/modules/module_20900.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21000.c b/src/modules/module_21000.c index 32355f409..f8fadf552 100644 --- a/src/modules/module_21000.c +++ b/src/modules/module_21000.c @@ -67,11 +67,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 128; - token.len_max[0] = 128; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21100.c b/src/modules/module_21100.c index 6198d0916..b722be594 100644 --- a/src/modules/module_21100.c +++ b/src/modules/module_21100.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_21200.c b/src/modules/module_21200.c index af03a0feb..f51d214a6 100644 --- a/src/modules/module_21200.c +++ b/src/modules/module_21200.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_21300.c b/src/modules/module_21300.c index 7dfc04005..1825bef35 100644 --- a/src/modules/module_21300.c +++ b/src/modules/module_21300.c @@ -53,12 +53,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_21310.c b/src/modules/module_21310.c new file mode 100644 index 000000000..106424fb0 --- /dev/null +++ b/src/modules/module_21310.c @@ -0,0 +1,296 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_md5.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5($salt1.sha1($salt2.$pass))"; +static const u64 KERN_TYPE = 21310; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "dc91b5a658ef4b7d859e90742f340e24:708237:d270e9eea5802e346bcaa9b229f37766"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (md5_double_salt_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + md5_double_salt_t *md5_double_salt = (md5_double_salt_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[1] = hashconfig->separator; + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = hashconfig->separator; + token.len_min[2] = SALT_MIN; + token.len_max[2] = SALT_MAX; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + + token.len_min[2] *= 2; + token.len_max[2] *= 2; + + token.attr[2] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + memset (md5_double_salt->salt1_buf, 0, sizeof (md5_double_salt->salt1_buf)); + + const bool parse_rc1 = generic_salt_decode (hashconfig, token.buf[1], token.len[1], (u8 *) md5_double_salt->salt1_buf, (int *) &md5_double_salt->salt1_len); + + if (parse_rc1 == false) return (PARSER_SALT_LENGTH); + + memset (md5_double_salt->salt2_buf, 0, sizeof (md5_double_salt->salt2_buf)); + + const bool parse_rc2 = generic_salt_decode (hashconfig, token.buf[2], token.len[2], (u8 *) md5_double_salt->salt2_buf, (int *) &md5_double_salt->salt2_len); + + if (parse_rc2 == false) return (PARSER_SALT_LENGTH); + + for (int i = 0; i < 64; i++) + { + md5_double_salt->salt2_buf[i] = byte_swap_32 (md5_double_salt->salt2_buf[i]); + } + + // make salt sorter happy + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, md5_double_salt->salt1_buf, md5_double_salt->salt1_len); + md5_update (&md5_ctx, md5_double_salt->salt2_buf, md5_double_salt->salt2_len); + md5_final (&md5_ctx); + + salt->salt_buf[0] = md5_ctx.h[0]; + salt->salt_buf[1] = md5_ctx.h[1]; + salt->salt_buf[2] = md5_ctx.h[2]; + salt->salt_buf[3] = md5_ctx.h[3]; + + salt->salt_len = 16; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + md5_double_salt_t *md5_double_salt = (md5_double_salt_t *) esalt_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_double_salt->salt1_buf, (const int) md5_double_salt->salt1_len, out_buf + out_len); + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + u32 salt2_buf[64]; + + for (int i = 0; i < 64; i++) + { + salt2_buf[i] = byte_swap_32 (md5_double_salt->salt2_buf[i]); + } + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt2_buf, (const int) md5_double_salt->salt2_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_21400.c b/src/modules/module_21400.c index dc57927f6..2959a503f 100644 --- a/src/modules/module_21400.c +++ b/src/modules/module_21400.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21420.c b/src/modules/module_21420.c index 6df334958..e55c031ab 100644 --- a/src/modules/module_21420.c +++ b/src/modules/module_21420.c @@ -54,12 +54,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_21500.c b/src/modules/module_21500.c index 314eda447..837c942bb 100644 --- a/src/modules/module_21500.c +++ b/src/modules/module_21500.c @@ -95,6 +95,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -110,9 +112,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[2] = '$'; - token.len_min[2] = 88; - token.len_max[2] = 88; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 88; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21501.c b/src/modules/module_21501.c index abccc527c..a36517053 100644 --- a/src/modules/module_21501.c +++ b/src/modules/module_21501.c @@ -109,6 +109,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -119,15 +121,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 24; - token.len_max[1] = 24; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 24; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[2] = '$'; - token.len_min[2] = 88; - token.len_max[2] = 88; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 88; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21600.c b/src/modules/module_21600.c index 7120445ea..1342e697c 100644 --- a/src/modules/module_21600.c +++ b/src/modules/module_21600.c @@ -90,6 +90,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 2; @@ -97,9 +99,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.signatures_buf[1] = SIGNATURE_WEB2PY_STOP; token.sep[0] = '('; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ','; @@ -109,9 +110,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 10; - token.len_max[2] = 10; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 10; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[3] = '$'; @@ -119,9 +119,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.len_max[3] = SALT_MAX; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[4] = 40; - token.len_max[4] = 40; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21700.c b/src/modules/module_21700.c index 96c12c811..68d4f60eb 100644 --- a/src/modules/module_21700.c +++ b/src/modules/module_21700.c @@ -68,6 +68,11 @@ static const char *SIGNATURE_ELECTRUM = "$electrum$4*"; bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { + if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) + { + return true; + } + // AMD Radeon Pro W5700X, Metal.Version.: 261.13, compiler hangs if (device_param->is_metal == true) { @@ -125,6 +130,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -135,9 +142,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 66; - token.len_max[1] = 66; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 66; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; @@ -147,9 +153,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_21800.c b/src/modules/module_21800.c index 13fd8523c..752f3451c 100644 --- a/src/modules/module_21800.c +++ b/src/modules/module_21800.c @@ -116,6 +116,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -126,21 +128,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 66; - token.len_max[1] = 66; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 66; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 2048; - token.len_max[2] = 2048; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2048; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_22000.c b/src/modules/module_22000.c index 79238c32f..5c20d6c7d 100644 --- a/src/modules/module_22000.c +++ b/src/modules/module_22000.c @@ -717,24 +717,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = sep; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = sep; - token.len_min[1] = 12; - token.len_max[1] = 12; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 12; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = sep; - token.len_min[2] = 12; - token.len_max[2] = 12; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 12; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = sep; @@ -759,39 +758,36 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; token.signatures_buf[0] = "WPA"; token.sep[0] = '*'; - token.len_min[0] = 3; - token.len_max[0] = 3; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 3; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 2; - token.len_max[1] = 2; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 12; - token.len_max[3] = 12; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 12; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 12; - token.len_max[4] = 12; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 12; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; diff --git a/src/modules/module_22001.c b/src/modules/module_22001.c index 6bd49698d..8bd35cd2b 100644 --- a/src/modules/module_22001.c +++ b/src/modules/module_22001.c @@ -719,24 +719,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.sep[0] = sep; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = sep; - token.len_min[1] = 12; - token.len_max[1] = 12; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 12; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = sep; - token.len_min[2] = 12; - token.len_max[2] = 12; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 12; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = sep; @@ -760,39 +759,36 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; token.signatures_buf[0] = "WPA"; token.sep[0] = '*'; - token.len_min[0] = 3; - token.len_max[0] = 3; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 3; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 2; - token.len_max[1] = 2; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 12; - token.len_max[3] = 12; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 12; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 12; - token.len_max[4] = 12; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 12; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; diff --git a/src/modules/module_22100.c b/src/modules/module_22100.c index 67b67ddbe..833eb4a63 100644 --- a/src/modules/module_22100.c +++ b/src/modules/module_22100.c @@ -159,6 +159,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; @@ -169,51 +171,43 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 2; - token.len_max[2] = 2; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 7; - token.len_max[4] = 7; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 7; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[5] = '$'; - token.len_min[5] = 2; - token.len_max[5] = 2; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 2; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 24; - token.len_max[6] = 24; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 24; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '$'; - token.len_min[7] = 2; - token.len_max[7] = 2; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 2; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[8] = '$'; - token.len_min[8] = 120; - token.len_max[8] = 120; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 120; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_22200.c b/src/modules/module_22200.c index 8f1937ab7..6e9141ba8 100644 --- a/src/modules/module_22200.c +++ b/src/modules/module_22200.c @@ -91,6 +91,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; diff --git a/src/modules/module_22300.c b/src/modules/module_22300.c index eced4ebd8..64f33ad4f 100644 --- a/src/modules/module_22300.c +++ b/src/modules/module_22300.c @@ -51,12 +51,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_22301.c b/src/modules/module_22301.c index a22d7e6c7..f75c196dc 100644 --- a/src/modules/module_22301.c +++ b/src/modules/module_22301.c @@ -53,6 +53,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -62,21 +64,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 64; - token.len_max[2] = 64; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_22400.c b/src/modules/module_22400.c index 29efc0a3a..cd373a75d 100644 --- a/src/modules/module_22400.c +++ b/src/modules/module_22400.c @@ -134,6 +134,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -144,33 +146,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_22500.c b/src/modules/module_22500.c index 3dd33067e..534539b4e 100644 --- a/src/modules/module_22500.c +++ b/src/modules/module_22500.c @@ -63,6 +63,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -73,21 +75,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 16; - token.len_max[2] = 16; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 16; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_22600.c b/src/modules/module_22600.c index 1178c3e91..236ba6453 100644 --- a/src/modules/module_22600.c +++ b/src/modules/module_22600.c @@ -94,6 +94,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; diff --git a/src/modules/module_22700.c b/src/modules/module_22700.c index 4409ddb29..009b4a280 100644 --- a/src/modules/module_22700.c +++ b/src/modules/module_22700.c @@ -271,6 +271,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -280,22 +282,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 32; - token.len_max[2] = 32; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[3] = 32; - token.len_max[3] = 32; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[4] = 32; diff --git a/src/modules/module_22911.c b/src/modules/module_22911.c index 0f76a3793..8beeca76b 100644 --- a/src/modules/module_22911.c +++ b/src/modules/module_22911.c @@ -68,6 +68,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -78,21 +80,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; diff --git a/src/modules/module_22921.c b/src/modules/module_22921.c index 54f13a4ee..182c1c6f3 100644 --- a/src/modules/module_22921.c +++ b/src/modules/module_22921.c @@ -69,6 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -79,21 +81,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; diff --git a/src/modules/module_22931.c b/src/modules/module_22931.c index d9309918a..5296c58fc 100644 --- a/src/modules/module_22931.c +++ b/src/modules/module_22931.c @@ -68,6 +68,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -78,21 +80,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 2; - token.len_max[2] = 2; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; diff --git a/src/modules/module_22941.c b/src/modules/module_22941.c index ff219aa56..e2b2e8116 100644 --- a/src/modules/module_22941.c +++ b/src/modules/module_22941.c @@ -68,6 +68,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -78,21 +80,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 2; - token.len_max[2] = 2; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; diff --git a/src/modules/module_22951.c b/src/modules/module_22951.c index 84b474740..ad0d95659 100644 --- a/src/modules/module_22951.c +++ b/src/modules/module_22951.c @@ -68,6 +68,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -78,21 +80,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 2; - token.len_max[2] = 2; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; diff --git a/src/modules/module_23001.c b/src/modules/module_23001.c index 18a5e482b..02e4bd62b 100644 --- a/src/modules/module_23001.c +++ b/src/modules/module_23001.c @@ -72,69 +72,62 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 11; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SECUREZIP; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 1; - token.len_max[4] = 1; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 1; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[5] = '*'; token.len_min[5] = 0; token.len_max[5] = 32; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 288; - token.len_max[6] = 288; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 288; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[7] = 1; - token.len_max[7] = 1; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 1; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[8] = 1; - token.len_max[8] = 1; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 1; - token.len_max[9] = 1; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 1; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len_min[10] = 0; diff --git a/src/modules/module_23002.c b/src/modules/module_23002.c index 1adf4be72..223096535 100644 --- a/src/modules/module_23002.c +++ b/src/modules/module_23002.c @@ -72,74 +72,67 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 11; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SECUREZIP; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 1; - token.len_max[4] = 1; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 1; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[5] = '*'; token.len_min[5] = 0; token.len_max[5] = 32; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 288; - token.len_max[6] = 288; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 288; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[7] = 1; - token.len_max[7] = 1; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 1; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[8] = 1; - token.len_max[8] = 1; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 1; - token.len_max[9] = 1; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 1; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[10] = '*'; token.len_min[10] = 0; token.len_max[10] = 64; - token.sep[10] = '*'; token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_23003.c b/src/modules/module_23003.c index 95542b881..3e1dd0428 100644 --- a/src/modules/module_23003.c +++ b/src/modules/module_23003.c @@ -73,74 +73,67 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 11; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SECUREZIP; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 1; - token.len_max[4] = 1; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 1; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[5] = '*'; token.len_min[5] = 0; token.len_max[5] = 32; - token.sep[5] = '*'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 288; - token.len_max[6] = 288; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 288; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[7] = 1; - token.len_max[7] = 1; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 1; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[8] = 1; - token.len_max[8] = 1; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 1; - token.len_max[9] = 1; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 1; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[10] = '*'; token.len_min[10] = 0; token.len_max[10] = 64; - token.sep[10] = '*'; token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_23100.c b/src/modules/module_23100.c index 4d626f31b..f3057c803 100644 --- a/src/modules/module_23100.c +++ b/src/modules/module_23100.c @@ -95,27 +95,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KEYCHAIN; token.sep[0] = '*'; - token.len_min[0] = 10; - token.len_max[0] = 10; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; - token.len_min[2] = 16; - token.len_max[2] = 16; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 16; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[3] = 96; diff --git a/src/modules/module_23200.c b/src/modules/module_23200.c index d7639d994..bcea54bce 100644 --- a/src/modules/module_23200.c +++ b/src/modules/module_23200.c @@ -77,26 +77,25 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_XMPP; token.sep[0] = '$'; - token.len_min[0] = 0; - token.len_max[0] = 0; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 0; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; token.sep[1] = '$'; - token.len_min[1] = 10; - token.len_max[1] = 10; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 10; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; @@ -118,9 +117,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '$'; - token.len_min[6] = 40; - token.len_max[6] = 40; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 40; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_23300.c b/src/modules/module_23300.c index ccf052c88..21d03e82c 100644 --- a/src/modules/module_23300.c +++ b/src/modules/module_23300.c @@ -95,6 +95,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; @@ -104,40 +106,36 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '$'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 1; - token.len_max[3] = 1; token.sep[3] = '$'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 1; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '$'; token.len_min[4] = 4; token.len_max[4] = 6; - token.sep[4] = '$'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[5] = '$'; token.len_min[5] = 16; token.len_max[5] = 32; - token.sep[5] = '$'; token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[6] = 32; - token.len_max[6] = 32; token.sep[6] = '$'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[7] = 128; diff --git a/src/modules/module_23400.c b/src/modules/module_23400.c index 6112bb03d..7a0e5fb95 100644 --- a/src/modules/module_23400.c +++ b/src/modules/module_23400.c @@ -110,6 +110,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -120,9 +122,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -143,9 +144,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[5] = '*'; - token.len_min[5] = 44; - token.len_max[5] = 44; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 44; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_23500.c b/src/modules/module_23500.c index e3c9f53bb..4e4220296 100644 --- a/src/modules/module_23500.c +++ b/src/modules/module_23500.c @@ -111,21 +111,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_AXCRYPT2; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -135,15 +135,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 128; - token.len_max[3] = 128; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 128; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 288; - token.len_max[4] = 288; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 288; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; diff --git a/src/modules/module_23600.c b/src/modules/module_23600.c index 6d67ece13..b94c2530a 100644 --- a/src/modules/module_23600.c +++ b/src/modules/module_23600.c @@ -111,21 +111,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_AXCRYPT2; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -135,15 +135,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 128; - token.len_max[3] = 128; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 128; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 288; - token.len_max[4] = 288; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 288; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; diff --git a/src/modules/module_23700.c b/src/modules/module_23700.c index 59f3364d0..e8296c575 100644 --- a/src/modules/module_23700.c +++ b/src/modules/module_23700.c @@ -135,33 +135,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_RAR3; token.sep[0] = '*'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 16; - token.len_max[2] = 16; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 16; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 8; - token.len_max[3] = 8; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 8; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; @@ -177,9 +175,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '*'; - token.len_min[6] = 1; - token.len_max[6] = 1; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 1; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[7] = '*'; diff --git a/src/modules/module_23800.c b/src/modules/module_23800.c index 9305db990..5f164b084 100644 --- a/src/modules/module_23800.c +++ b/src/modules/module_23800.c @@ -420,33 +420,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_RAR3; token.sep[0] = '*'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; - token.len_min[2] = 16; - token.len_max[2] = 16; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 16; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 8; - token.len_max[3] = 8; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 8; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; @@ -462,9 +460,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '*'; - token.len_min[6] = 1; - token.len_max[6] = 1; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 1; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[7] = '*'; diff --git a/src/modules/module_23900.c b/src/modules/module_23900.c index 15eda1a91..ffc1f2b39 100644 --- a/src/modules/module_23900.c +++ b/src/modules/module_23900.c @@ -89,6 +89,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -98,22 +100,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 2; - token.len_max[2] = 2; token.sep[2] = '$'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 2; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[3] = 16; - token.len_max[3] = 16; token.sep[3] = '$'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[4] = 192; diff --git a/src/modules/module_24100.c b/src/modules/module_24100.c index 53bf5e9f0..699fbf7b5 100644 --- a/src/modules/module_24100.c +++ b/src/modules/module_24100.c @@ -96,21 +96,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_MONGODB_SHA1; token.sep[0] = '*'; - token.len_min[0] = 15; - token.len_max[0] = 15; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 15; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -126,9 +126,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '*'; - token.len_min[4] = 24; - token.len_max[4] = 24; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 24; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.len[5] = 28; diff --git a/src/modules/module_24200.c b/src/modules/module_24200.c index 86a6334b4..9457eb4a7 100644 --- a/src/modules/module_24200.c +++ b/src/modules/module_24200.c @@ -127,21 +127,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_MONGODB_SHA256; token.sep[0] = '*'; - token.len_min[0] = 15; - token.len_max[0] = 15; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 15; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -157,9 +157,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '*'; - token.len_min[4] = 40; - token.len_max[4] = 40; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 40; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.len[5] = 44; diff --git a/src/modules/module_24300.c b/src/modules/module_24300.c index c1e66d458..cad17a5b4 100644 --- a/src/modules/module_24300.c +++ b/src/modules/module_24300.c @@ -50,12 +50,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_24410.c b/src/modules/module_24410.c index 4b8ab978f..6e59fd160 100644 --- a/src/modules/module_24410.c +++ b/src/modules/module_24410.c @@ -122,6 +122,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; @@ -132,15 +134,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; diff --git a/src/modules/module_24420.c b/src/modules/module_24420.c index c0aea4c28..90f00ffa0 100644 --- a/src/modules/module_24420.c +++ b/src/modules/module_24420.c @@ -122,6 +122,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; @@ -132,15 +134,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; diff --git a/src/modules/module_24500.c b/src/modules/module_24500.c index a4d60ed31..f95cdbef5 100644 --- a/src/modules/module_24500.c +++ b/src/modules/module_24500.c @@ -96,6 +96,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -106,9 +108,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -118,15 +119,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = DATA_LEN_TELEGRAM * 2; - token.len_max[4] = DATA_LEN_TELEGRAM * 2; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = DATA_LEN_TELEGRAM * 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_24600.c b/src/modules/module_24600.c index 66d3e6e20..0194cb05e 100644 --- a/src/modules/module_24600.c +++ b/src/modules/module_24600.c @@ -151,21 +151,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SQLCIPHER; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -175,21 +175,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 32; - token.len_max[5] = 32; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 32; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_24700.c b/src/modules/module_24700.c index 30edc76cd..24b41cf61 100644 --- a/src/modules/module_24700.c +++ b/src/modules/module_24700.c @@ -51,6 +51,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 10; diff --git a/src/modules/module_24800.c b/src/modules/module_24800.c index e25e7841e..fff6a347b 100644 --- a/src/modules/module_24800.c +++ b/src/modules/module_24800.c @@ -49,11 +49,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 28; - token.len_max[0] = 28; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 28; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_24900.c b/src/modules/module_24900.c index ec4c2113c..d3e419861 100644 --- a/src/modules/module_24900.c +++ b/src/modules/module_24900.c @@ -93,11 +93,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 8; - token.len_max[0] = 8; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_25000.c b/src/modules/module_25000.c index 144aef509..71461a8f0 100644 --- a/src/modules/module_25000.c +++ b/src/modules/module_25000.c @@ -81,6 +81,16 @@ typedef struct snmpv3 } snmpv3_t; +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (snmpv3_t); @@ -120,6 +130,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -335,6 +347,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_25100.c b/src/modules/module_25100.c index be0d0d852..d157c8143 100644 --- a/src/modules/module_25100.c +++ b/src/modules/module_25100.c @@ -77,6 +77,16 @@ typedef struct snmpv3 } snmpv3_t; +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (snmpv3_t); @@ -116,6 +126,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -316,6 +328,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_25200.c b/src/modules/module_25200.c index 1ed4630a4..0865bc2c1 100644 --- a/src/modules/module_25200.c +++ b/src/modules/module_25200.c @@ -77,6 +77,16 @@ typedef struct snmpv3 } snmpv3_t; +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) + { + return true; + } + + return false; +} + u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 esalt_size = (const u64) sizeof (snmpv3_t); @@ -116,6 +126,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -125,28 +137,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // packet number + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt + token.sep[2] = '$'; token.len_min[2] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.len_max[2] = SNMPV3_SALT_MAX * 2; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // engineid + token.sep[3] = '$'; token.len_min[3] = 26; token.len_max[3] = SNMPV3_ENGINEID_MAX; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // digest - token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.sep[4] = '$'; + token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -327,6 +339,6 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_st_hash = module_st_hash; module_ctx->module_st_pass = module_st_pass; module_ctx->module_tmp_size = module_tmp_size; - module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; module_ctx->module_warmup_disable = MODULE_DEFAULT; } diff --git a/src/modules/module_25300.c b/src/modules/module_25300.c index 801f548f6..d2d56bbd4 100644 --- a/src/modules/module_25300.c +++ b/src/modules/module_25300.c @@ -120,6 +120,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -130,21 +132,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 6; - token.len_max[1] = 6; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 6; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 24; - token.len_max[2] = 24; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 24; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[3] = '$'; - token.len_min[3] = 88; - token.len_max[3] = 88; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 88; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_25400.c b/src/modules/module_25400.c index baad6e6fd..7b2402267 100644 --- a/src/modules/module_25400.c +++ b/src/modules/module_25400.c @@ -69,6 +69,8 @@ typedef struct pdf u32 rc4key[2]; u32 rc4data[2]; + int P_minus; + } pdf_t; typedef struct pdf14_tmp @@ -163,6 +165,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 12; token.signatures_cnt = 1; @@ -172,70 +176,61 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 1; - token.len_max[2] = 1; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[3] = 3; - token.len_max[3] = 3; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[4] = '*'; token.len_min[4] = 1; token.len_max[4] = 11; - token.sep[4] = '*'; token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - token.len_min[5] = 1; - token.len_max[5] = 1; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[6] = 2; - token.len_max[6] = 2; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[7] = '*'; token.len_min[7] = 32; token.len_max[7] = 64; - token.sep[7] = '*'; token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 64; - token.len_max[9] = 64; token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.sep[10] = '*'; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.sep[11] = '*'; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.sep[11] = '*'; + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); // was a const, now no longer, as we need it again for the new hashformat @@ -251,83 +246,74 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE input_len = tmp_len; } - token.token_cnt = 13; + token.token_cnt = 13; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_PDF; - token.len[0] = 5; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_SIGNATURE; - - token.len_min[1] = 1; - token.len_max[1] = 1; - token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.len_min[2] = 1; - token.len_max[2] = 1; - token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.len_min[3] = 3; - token.len_max[3] = 3; - token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.len_min[4] = 1; - token.len_max[4] = 6; - token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; - - token.len_min[5] = 1; - token.len_max[5] = 1; - token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.len_min[6] = 2; - token.len_max[6] = 2; - token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.len_min[7] = 32; - token.len_max[7] = 64; - token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '*'; + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[2] = '*'; + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[3] = '*'; + token.len[3] = 3; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[4] = '*'; + token.len_min[4] = 1; + token.len_max[4] = 6; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[5] = '*'; + token.len[5] = 1; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[6] = '*'; + token.len[6] = 2; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[7] = '*'; + token.len_min[7] = 32; + token.len_max[7] = 64; + token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; - token.len_min[8] = 2; - token.len_max[8] = 2; - token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[8] = '*'; + token.len[8] = 2; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[9] = 64; - token.len_max[9] = 64; - token.sep[9] = '*'; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.sep[9] = '*'; + token.len[9] = 64; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; - token.len_min[10] = 2; - token.len_max[10] = 2; token.sep[10] = '*'; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[11] = 64; - token.len_max[11] = 64; token.sep[11] = '*'; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; + token.sep[12] = '*'; token.len_min[12] = 0; token.len_max[12] = 32; // "truncate the password string to exactly 32 bytes." see "Algorithm 3.2 computing an encryption key" - token.sep[12] = '*'; token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH; rc_tokenizer = input_tokenizer ((const u8 *) input_buf, input_len, &token); @@ -354,6 +340,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -568,9 +558,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE int line_len = 0; pdf_t *pdf = (pdf_t *) esalt_buf; + if (pdf->id_len == 32) { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, @@ -608,7 +603,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, diff --git a/src/modules/module_25500.c b/src/modules/module_25500.c index 47355ff26..7d68a8648 100644 --- a/src/modules/module_25500.c +++ b/src/modules/module_25500.c @@ -122,6 +122,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -132,21 +134,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 24; - token.len_max[1] = 24; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 24; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[2] = '$'; - token.len_min[2] = 16; - token.len_max[2] = 16; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 16; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[3] = '$'; - token.len_min[3] = 96; - token.len_max[3] = 96; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 96; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_25600.c b/src/modules/module_25600.c index dde892210..e39224b54 100644 --- a/src/modules/module_25600.c +++ b/src/modules/module_25600.c @@ -171,6 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 4; @@ -183,10 +185,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len[2] = 22; diff --git a/src/modules/module_25700.c b/src/modules/module_25700.c index 62960a2ff..c6a805dcc 100644 --- a/src/modules/module_25700.c +++ b/src/modules/module_25700.c @@ -62,18 +62,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; - token.len_min[0] = 8; - token.len_max[0] = 8; token.sep[0] = hashconfig->separator; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 8; - token.len_max[1] = 8; token.sep[1] = hashconfig->separator; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_25800.c b/src/modules/module_25800.c index 6f6023657..9c3189f21 100644 --- a/src/modules/module_25800.c +++ b/src/modules/module_25800.c @@ -171,6 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 4; @@ -183,10 +185,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len[2] = 22; diff --git a/src/modules/module_25900.c b/src/modules/module_25900.c index ca6f8bc91..b8ce7a24a 100644 --- a/src/modules/module_25900.c +++ b/src/modules/module_25900.c @@ -132,6 +132,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -139,31 +141,27 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // Signature token.sep[0] = '*'; - token.len_min[0] = 42; - token.len_max[0] = 42; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 42; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; // Secure Session Identifier (from SESSION_RESPONSE) token.sep[1] = '*'; - token.len_min[1] = 4; - token.len_max[1] = 4; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 4; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // XOR of Client Public Value X (from SESSION_REQUEST) // and Server Public Value Y (from SESSION_RESPONSE) token.sep[2] = '*'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // Message Authentication Code (from SESSION_RESPONSE) token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26000.c b/src/modules/module_26000.c index 6a1deccb4..2d7ea5f7b 100644 --- a/src/modules/module_26000.c +++ b/src/modules/module_26000.c @@ -77,6 +77,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 2; @@ -84,33 +86,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.signatures_buf[1] = SIGNATURE_MOZILLA_3DES; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 4; - token.len_max[1] = 4; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 4; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[2] = '*'; - token.len_min[2] = 40; - token.len_max[2] = 40; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 40; - token.len_max[3] = 40; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 40; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26100.c b/src/modules/module_26100.c index f7e2dac5a..91a170b44 100644 --- a/src/modules/module_26100.c +++ b/src/modules/module_26100.c @@ -94,6 +94,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 2; @@ -101,27 +103,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.signatures_buf[1] = SIGNATURE_MOZILLA_AES; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 3; - token.len_max[1] = 3; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 3; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[2] = '*'; - token.len_min[2] = 40; - token.len_max[2] = 40; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '*'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '*'; @@ -131,15 +129,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[5] = '*'; - token.len_min[5] = 32; - token.len_max[5] = 32; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 32; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26200.c b/src/modules/module_26200.c index d47e63729..c3696d5fc 100644 --- a/src/modules/module_26200.c +++ b/src/modules/module_26200.c @@ -81,11 +81,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26300.c b/src/modules/module_26300.c index 2a18f7f4e..0a219af8a 100644 --- a/src/modules/module_26300.c +++ b/src/modules/module_26300.c @@ -54,6 +54,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_26401.c b/src/modules/module_26401.c index d0b4dade8..108fb1697 100644 --- a/src/modules/module_26401.c +++ b/src/modules/module_26401.c @@ -56,17 +56,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26402.c b/src/modules/module_26402.c index b660feca4..f720ea3e7 100644 --- a/src/modules/module_26402.c +++ b/src/modules/module_26402.c @@ -56,17 +56,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26403.c b/src/modules/module_26403.c index 4337a46da..7248f4a74 100644 --- a/src/modules/module_26403.c +++ b/src/modules/module_26403.c @@ -56,17 +56,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26500.c b/src/modules/module_26500.c index 849f94b34..7e766f036 100644 --- a/src/modules/module_26500.c +++ b/src/modules/module_26500.c @@ -94,6 +94,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -104,15 +106,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 40; - token.len_max[2] = 40; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; @@ -122,9 +122,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '$'; - token.len_min[4] = 80; - token.len_max[4] = 80; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 80; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_26600.c b/src/modules/module_26600.c index 929c37a76..a60917cc9 100644 --- a/src/modules/module_26600.c +++ b/src/modules/module_26600.c @@ -132,6 +132,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -142,15 +144,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 44; - token.len_max[1] = 44; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 44; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[2] = '$'; - token.len_min[2] = 24; - token.len_max[2] = 24; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 24; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[3] = '$'; @@ -291,7 +291,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if ((ct_len % 4) > 0) j++; - u32 tmp_buf[784] = { 0 }; + u32 tmp_buf[788] = { 0 }; for (u32 i = 0; i < j; i++) tmp_buf[i] = byte_swap_32 (metamask->ct_buf[i]); diff --git a/src/modules/module_26610.c b/src/modules/module_26610.c index 96ec0a12c..532246128 100644 --- a/src/modules/module_26610.c +++ b/src/modules/module_26610.c @@ -18,7 +18,6 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; -// 22610 generates a decryption key based on a password-guess and uses that to AES-GCM decrypt the data decrypts static const char *HASH_NAME = "MetaMask Wallet (short hash, plaintext check)"; static const u64 KERN_TYPE = 26610; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE @@ -28,7 +27,6 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE | OPTS_TYPE_DEEP_COMP_KERNEL; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat1"; -// hash generated using with python3 tools/metamask2hashcat.py --vault tools/2hashcat_tests/metamask2hashcat.json --shortdata static const char *ST_HASH = "$metamask-short$jfGI3TXguhb8GPnKSXFrMzRk2NCEc131Gt5G3kZr5+s=$h+BoIf2CQ5BEjaIOShFE7g==$R95fzGt4UQ0uwrcrVYnIi4UcSlWn9wlmer+//526ZDwYAp50K82F1u1oacYcdjjhuEvbZnWk/uBG00UkgLLlOw=="; u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } @@ -48,11 +46,11 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pbkdf2_sha256_tmp { - u32 ipad[8]; - u32 opad[8]; + u32 ipad[8]; + u32 opad[8]; - u32 dgst[32]; - u32 out[32]; + u32 dgst[32]; + u32 out[32]; } pbkdf2_sha256_tmp_t; @@ -61,7 +59,7 @@ typedef struct pbkdf2_sha256_aes_gcm u32 salt_buf[64]; u32 iv_buf[4]; u32 iv_len; - u32 ct_buf[784]; // TODO this can be smaller and would speedup the attack, only 64 bytes of ciphertext are allowed + u32 ct_buf[16]; u32 ct_len; } pbkdf2_sha256_aes_gcm_t; @@ -135,10 +133,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE pbkdf2_sha256_aes_gcm_t *metamask = (pbkdf2_sha256_aes_gcm_t *) esalt_buf; - #define CT_MAX_LEN_BASE64 (((3136+16) * 8) / 6) + 3 // TODO this can be smaller and would speedup the attack, only 64 bytes of ciphertext are allowed - hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -149,20 +147,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 44; - token.len_max[1] = 44; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 44; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[2] = '$'; - token.len_min[2] = 24; - token.len_max[2] = 24; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 24; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 100; // TODO this can be smaller and would speedup the attack, only 64 bytes of ciphertext are allowed + token.len_min[3] = 88; + token.len_max[3] = 88; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; @@ -170,10 +166,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - u8 tmp_buf[CT_MAX_LEN_BASE64] = { 0 }; - - size_t tmp_len = 0; - // iter salt->salt_iter = 10000 - 1; @@ -183,9 +175,11 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; + u8 tmp_buf[88+1]; + memset (tmp_buf, 0, sizeof (tmp_buf)); - tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); + size_t tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); if (tmp_len != 32) return (PARSER_SALT_LENGTH); @@ -231,20 +225,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp_len = base64_decode (base64_to_int, ct_pos, ct_len, tmp_buf); + if (tmp_len != 64) return (PARSER_CT_LENGTH); + memcpy ((u8 *) metamask->ct_buf, tmp_buf, tmp_len); u32 j = tmp_len / 4; - if ((tmp_len % 4) > 0) j++; - - for (u32 i = 0; i < j; i++) metamask->ct_buf[i] = byte_swap_32 (metamask->ct_buf[i]); + for (u32 i = 0; i < j; i++) + { + metamask->ct_buf[i] = byte_swap_32 (metamask->ct_buf[i]); + } metamask->ct_len = tmp_len; - digest[0] = (metamask->ct_buf[0]); - digest[1] = (metamask->ct_buf[1]); - digest[2] = (metamask->ct_buf[2]); - digest[3] = (metamask->ct_buf[3]); + digest[0] = metamask->ct_buf[0]; + digest[1] = metamask->ct_buf[1]; + digest[2] = metamask->ct_buf[2]; + digest[3] = metamask->ct_buf[3]; return (PARSER_OK); } @@ -255,40 +252,42 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt - #define SALT_LEN_BASE64 ((32 * 8) / 6) + 3 - #define IV_LEN_BASE64 ((16 * 8) / 6) + 3 - #define CT_MAX_LEN_BASE64 (((3136+16) * 8) / 6) + 3 // TODO this can be much smaller now, probably 32 ? + u8 salt_buf[44+1]; - u8 salt_buf[SALT_LEN_BASE64] = { 0 }; + memset (salt_buf, 0, sizeof (salt_buf)); base64_encode (int_to_base64, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); // iv - u32 tmp_iv_buf[4] = { 0 }; + u32 tmp_iv_buf[4]; tmp_iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); tmp_iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); tmp_iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); tmp_iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); - u8 iv_buf[IV_LEN_BASE64+1] = { 0 }; + u8 iv_buf[24+1]; + + memset (iv_buf, 0, sizeof (iv_buf)); base64_encode (int_to_base64, (const u8 *) tmp_iv_buf, (const int) metamask->iv_len, iv_buf); // ct - u32 ct_len = metamask->ct_len; + u32 tmp_buf[16]; - u32 j = ct_len / 4; + memset (tmp_buf, 0, sizeof (tmp_buf)); - if ((ct_len % 4) > 0) j++; + u32 ct_len = metamask->ct_len; - u32 tmp_buf[784] = { 0 }; // TODO this can be smaller and would speedup the attack, only 64 bytes of ciphertext are allowed + u32 j = ct_len / 4; for (u32 i = 0; i < j; i++) tmp_buf[i] = byte_swap_32 (metamask->ct_buf[i]); - u8 ct_buf[CT_MAX_LEN_BASE64] = { 0 }; + u8 ct_buf[88+1]; + + memset (ct_buf, 0, sizeof (ct_buf)); base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len, ct_buf); diff --git a/src/modules/module_26700.c b/src/modules/module_26700.c index 45a0652eb..050eb196a 100644 --- a/src/modules/module_26700.c +++ b/src/modules/module_26700.c @@ -123,6 +123,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -132,28 +134,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // packet number + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt + token.sep[2] = '$'; token.len_min[2] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.len_max[2] = SNMPV3_SALT_MAX * 2; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // engineid + token.sep[3] = '$'; token.len_min[3] = 26; token.len_max[3] = SNMPV3_ENGINEID_MAX; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // digest - token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.sep[4] = '$'; + token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_26800.c b/src/modules/module_26800.c index 0dc5e25fe..fc43bf17a 100644 --- a/src/modules/module_26800.c +++ b/src/modules/module_26800.c @@ -123,6 +123,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -132,28 +134,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // packet number + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt + token.sep[2] = '$'; token.len_min[2] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.len_max[2] = SNMPV3_SALT_MAX * 2; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // engineid + token.sep[3] = '$'; token.len_min[3] = 26; token.len_max[3] = SNMPV3_ENGINEID_MAX; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // digest - token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.sep[4] = '$'; + token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_26900.c b/src/modules/module_26900.c index 2d724b509..633e9e512 100644 --- a/src/modules/module_26900.c +++ b/src/modules/module_26900.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -172,28 +174,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // packet number + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt + token.sep[2] = '$'; token.len_min[2] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.len_max[2] = SNMPV3_SALT_MAX * 2; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // engineid + token.sep[3] = '$'; token.len_min[3] = 26; token.len_max[3] = SNMPV3_ENGINEID_MAX; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // digest - token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.sep[4] = '$'; + token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; @@ -282,7 +284,19 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE out_len++; - out_len += hex_encode ((u8 *) snmpv3->engineID_buf, snmpv3->engineID_len, out_buf + out_len); + // remove zero padding from snmpv3->engineID_buf + + u8 *engineID_buf_tmp = (u8 *) snmpv3->engineID_buf; + + u32 engineID_len = snmpv3->engineID_len; + + while (engineID_buf_tmp[engineID_len] == 0x00) engineID_len--; + + engineID_len++; + + // append to output + + out_len += hex_encode ((u8 *) snmpv3->engineID_buf, engineID_len, out_buf + out_len); out_buf[out_len] = '$'; diff --git a/src/modules/module_27000.c b/src/modules/module_27000.c index 0cfb69bcb..c9cca63b4 100644 --- a/src/modules/module_27000.c +++ b/src/modules/module_27000.c @@ -129,45 +129,44 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; // username + token.sep[0] = ':'; token.len_min[0] = 0; token.len_max[0] = 60; - token.sep[0] = ':'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; // unused - token.len_min[1] = 0; - token.len_max[1] = 0; + token.len[1] = 0; token.sep[1] = ':'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; // domain + token.sep[2] = ':'; token.len_min[2] = 0; token.len_max[2] = 45; - token.sep[2] = ':'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; // lm response + token.sep[3] = ':'; token.len_min[3] = 0; token.len_max[3] = 48; - token.sep[3] = ':'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // ntlm response - token.len_min[4] = 48; - token.len_max[4] = 48; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 48; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // challenge - token.len_min[5] = 16; - token.len_max[5] = 16; token.sep[5] = ':'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_27100.c b/src/modules/module_27100.c index d096f903d..06dac32dd 100644 --- a/src/modules/module_27100.c +++ b/src/modules/module_27100.c @@ -89,38 +89,37 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; // username + token.sep[0] = ':'; token.len_min[0] = 0; token.len_max[0] = 60; - token.sep[0] = ':'; token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; // unused - token.len_min[1] = 0; - token.len_max[1] = 0; token.sep[1] = ':'; + token.len[1] = 0; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; // domain + token.sep[2] = ':'; token.len_min[2] = 0; token.len_max[2] = 45; - token.sep[2] = ':'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; // lm response - token.len_min[3] = 16; - token.len_max[3] = 16; token.sep[3] = ':'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // ntlm response - token.len_min[4] = 32; - token.len_max[4] = 32; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // challenge @@ -213,7 +212,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); /** - * reuse challange data as salt_buf, its the buffer that is most likely unique + * reuse challenge data as salt_buf, its the buffer that is most likely unique */ salt->salt_buf[0] = 0; diff --git a/src/modules/module_27200.c b/src/modules/module_27200.c index 6f165a58b..ffa2c6c8b 100644 --- a/src/modules/module_27200.c +++ b/src/modules/module_27200.c @@ -80,17 +80,17 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 40; - token.len_max[1] = 40; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_27300.c b/src/modules/module_27300.c index 376082ff1..1512bbbb4 100644 --- a/src/modules/module_27300.c +++ b/src/modules/module_27300.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_SNMPV3; @@ -172,28 +174,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // packet number + token.sep[1] = '$'; token.len_min[1] = 1; token.len_max[1] = 8; - token.sep[1] = '$'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // salt + token.sep[2] = '$'; token.len_min[2] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.len_max[2] = SNMPV3_SALT_MAX * 2; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // engineid + token.sep[3] = '$'; token.len_min[3] = 26; token.len_max[3] = SNMPV3_ENGINEID_MAX; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; // digest - token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.sep[4] = '$'; + token.len[4] = SNMPV3_MSG_AUTH_PARAMS_LEN * 2; token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_27400.c b/src/modules/module_27400.c index 31183701c..3bd35cff5 100644 --- a/src/modules/module_27400.c +++ b/src/modules/module_27400.c @@ -95,12 +95,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_VMWARE_VMX; - token.sep[0] = '$'; token.len[0] = 7; token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; @@ -112,15 +113,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_27500.c b/src/modules/module_27500.c index 0c5c1e6fa..12d576bff 100644 --- a/src/modules/module_27500.c +++ b/src/modules/module_27500.c @@ -114,12 +114,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_VBOX; - token.sep[0] = '$'; token.len[0] = 8; token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; @@ -131,9 +132,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; @@ -143,9 +143,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '$'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; @@ -155,15 +154,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 64; - token.len_max[6] = 64; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 64; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '$'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_27600.c b/src/modules/module_27600.c index 971556193..d458cbd8a 100644 --- a/src/modules/module_27600.c +++ b/src/modules/module_27600.c @@ -114,12 +114,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_VBOX; - token.sep[0] = '$'; token.len[0] = 8; token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; @@ -131,9 +132,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; @@ -143,9 +143,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[4] = '$'; - token.len_min[4] = 128; - token.len_max[4] = 128; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 128; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; @@ -155,15 +154,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 64; - token.len_max[6] = 64; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 64; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '$'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_27700.c b/src/modules/module_27700.c index da1516233..10ecefe70 100644 --- a/src/modules/module_27700.c +++ b/src/modules/module_27700.c @@ -271,6 +271,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -280,34 +282,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '*'; token.len_min[2] = 1; token.len_max[2] = 10; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[3] = '*'; token.len_min[3] = 1; token.len_max[3] = 2; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 1; - token.len_max[4] = 1; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 1; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 16; - token.len_max[5] = 16; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[6] = 64; diff --git a/src/modules/module_27800.c b/src/modules/module_27800.c index 8f69f60ed..4aefff85a 100644 --- a/src/modules/module_27800.c +++ b/src/modules/module_27800.c @@ -62,18 +62,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; - token.len_min[0] = 8; - token.len_max[0] = 8; token.sep[0] = hashconfig->separator; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; - token.len_min[1] = 8; - token.len_max[1] = 8; token.sep[1] = hashconfig->separator; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_27900.c b/src/modules/module_27900.c index 2e76feace..ea06e0f2c 100644 --- a/src/modules/module_27900.c +++ b/src/modules/module_27900.c @@ -48,18 +48,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 8; - token.len_max[0] = 8; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 8; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; - token.len_min[1] = 8; - token.len_max[1] = 8; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 8; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_28000.c b/src/modules/module_28000.c index c73cb7f6f..653e6dddf 100644 --- a/src/modules/module_28000.c +++ b/src/modules/module_28000.c @@ -64,18 +64,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; - token.len_min[1] = 16; - token.len_max[1] = 16; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_28100.c b/src/modules/module_28100.c index b75dafce0..88e8b7e74 100644 --- a/src/modules/module_28100.c +++ b/src/modules/module_28100.c @@ -108,69 +108,62 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_WINHELLO; - token.len_min[0] = 10; - token.len_max[0] = 10; token.sep[0] = '*'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 10; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 6; // fixed SHA512 - token.len_max[1] = 6; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 6; // fixed SHA512 + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; // pbkdf2 iter - token.len_min[2] = 5; // fixed 10000 - token.len_max[2] = 5; token.sep[2] = '*'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 5; // fixed 10000 + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // pbdfk2 salt - token.len_min[3] = 8; - token.len_max[3] = 8; token.sep[3] = '*'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 8; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // sign (hash) - token.len_min[4] = 128; - token.len_max[4] = 128; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 128; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // mk - token.len_min[5] = 128; - token.len_max[5] = 128; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 128; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // hmac - token.len_min[6] = 64; - token.len_max[6] = 64; token.sep[6] = '*'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 64; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // verify blob - token.len_min[7] = 1384; - token.len_max[7] = 1384; token.sep[7] = '*'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 1384; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // magicv - token.len_min[8] = 34; // fixed 785435725a573571565662727670754100 - token.len_max[8] = 34; token.sep[8] = '*'; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 34; // fixed 785435725a573571565662727670754100 + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); @@ -284,7 +277,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE winhello->mk_buf_pc[6] = 0; winhello->mk_buf_pc[7] = 0; - // yes we can precompute the first block of both sha512 here, because length is 128 + hmac lenght + magic length, but + // yes we can precompute the first block of both sha512 here, because length is 128 + hmac length + magic length, but // speed improvement is negligible, but readability would drop a lot return (PARSER_OK); diff --git a/src/modules/module_28200.c b/src/modules/module_28200.c index af538472a..4eaf61bc6 100644 --- a/src/modules/module_28200.c +++ b/src/modules/module_28200.c @@ -285,57 +285,54 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_EXODUS; - token.len_min[0] = 6; - token.len_max[0] = 6; token.sep[0] = ':'; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; + token.sep[1] = ':'; token.len_min[1] = 1; token.len_max[1] = 6; - token.sep[1] = ':'; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = ':'; token.len_min[2] = 1; token.len_max[2] = 6; - token.sep[2] = ':'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[3] = ':'; token.len_min[3] = 1; token.len_max[3] = 6; - token.sep[3] = ':'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 44; - token.len_max[4] = 44; token.sep[4] = ':'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 44; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.len_min[5] = 16; - token.len_max[5] = 16; token.sep[5] = ':'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.len_min[6] = 44; - token.len_max[6] = 44; token.sep[6] = ':'; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 44; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.len_min[7] = 24; - token.len_max[7] = 24; token.sep[7] = ':'; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 24; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_28300.c b/src/modules/module_28300.c index b5c74be75..b820dd9cb 100644 --- a/src/modules/module_28300.c +++ b/src/modules/module_28300.c @@ -51,6 +51,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -60,22 +62,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[2] = 28; - token.len_max[2] = 28; token.sep[2] = '$'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 28; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; - token.len_min[3] = 152; - token.len_max[3] = 152; token.sep[3] = '$'; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 152; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_28400.c b/src/modules/module_28400.c index b003b336c..dbeba6126 100644 --- a/src/modules/module_28400.c +++ b/src/modules/module_28400.c @@ -171,6 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 4; @@ -183,10 +185,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len[2] = 22; diff --git a/src/modules/module_28501.c b/src/modules/module_28501.c index be173044f..8692e05e6 100644 --- a/src/modules/module_28501.c +++ b/src/modules/module_28501.c @@ -69,6 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len_min[0] = 26; diff --git a/src/modules/module_28502.c b/src/modules/module_28502.c index 2c9fdeae3..daafa9be3 100644 --- a/src/modules/module_28502.c +++ b/src/modules/module_28502.c @@ -69,6 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len_min[0] = 26; diff --git a/src/modules/module_28503.c b/src/modules/module_28503.c index d52cd51ec..696bbf2d8 100644 --- a/src/modules/module_28503.c +++ b/src/modules/module_28503.c @@ -91,6 +91,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_28504.c b/src/modules/module_28504.c index dae2ae67d..93e35784c 100644 --- a/src/modules/module_28504.c +++ b/src/modules/module_28504.c @@ -91,6 +91,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_28505.c b/src/modules/module_28505.c index 49db31745..133bf1e43 100644 --- a/src/modules/module_28505.c +++ b/src/modules/module_28505.c @@ -69,6 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 34; diff --git a/src/modules/module_28506.c b/src/modules/module_28506.c index 35b378088..296122758 100644 --- a/src/modules/module_28506.c +++ b/src/modules/module_28506.c @@ -69,6 +69,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 34; diff --git a/src/modules/module_28600.c b/src/modules/module_28600.c index 48058649c..e152e8dc8 100644 --- a/src/modules/module_28600.c +++ b/src/modules/module_28600.c @@ -133,15 +133,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_POSTGRES_SHA256; token.sep[0] = '$'; - token.len_min[0] = 13; - token.len_max[0] = 13; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 13; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ':'; @@ -157,9 +158,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_BASE64A; token.sep[3] = ':'; - token.len_min[3] = 44; - token.len_max[3] = 44; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 44; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.len[4] = 44; diff --git a/src/modules/module_28700.c b/src/modules/module_28700.c index 4c956f230..e86ccb448 100644 --- a/src/modules/module_28700.c +++ b/src/modules/module_28700.c @@ -97,6 +97,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_AWS_SIG_V4; @@ -106,35 +108,32 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; // longdate - token.len_min[1] = 16; - token.len_max[1] = 16; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; // region + token.sep[2] = '$'; token.len_min[2] = 1; token.len_max[2] = 16; - token.sep[2] = '$'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; // service + token.sep[3] = '$'; token.len_min[3] = 1; token.len_max[3] = 16; - token.sep[3] = '$'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH; // canonical - token.len_min[4] = 32 * 2; - token.len_max[4] = 32 * 2; token.sep[4] = '$'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32 * 2; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // digest - token.len_min[5] = 32 * 2; - token.len_max[5] = 32 * 2; token.sep[5] = '$'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 32 * 2; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_28800.c b/src/modules/module_28800.c index 98a8baeab..d34c860e5 100644 --- a/src/modules/module_28800.c +++ b/src/modules/module_28800.c @@ -99,6 +99,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5DB; @@ -134,10 +136,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[3] = '$'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; } // assume $krb5db$17$user$realm$*spn*$hash else @@ -167,10 +168,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; token.sep[4] = '$'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; is_spn_provided = 1; } diff --git a/src/modules/module_28900.c b/src/modules/module_28900.c index 10c2ae4ab..929e09a04 100644 --- a/src/modules/module_28900.c +++ b/src/modules/module_28900.c @@ -99,6 +99,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KRB5DB; @@ -134,9 +136,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[3] = '$'; - token.len_min[3] = 64; - token.len_max[3] = 64; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; } @@ -168,9 +169,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[3] = TOKEN_ATTR_FIXED_LENGTH; token.sep[4] = '$'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; is_spn_provided = 1; diff --git a/src/modules/module_29000.c b/src/modules/module_29000.c index b1a1f4698..4204020d8 100644 --- a/src/modules/module_29000.c +++ b/src/modules/module_29000.c @@ -17,7 +17,7 @@ static const u32 DGST_POS1 = 4; static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; -static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; static const char *HASH_NAME = "sha1($salt.sha1(utf16le($username).':'.utf16le($pass)))"; static const u64 KERN_TYPE = 29000; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE @@ -74,12 +74,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = hashconfig->separator; - token.len_min[0] = 40; - token.len_max[0] = 40; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 40; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[1] = hashconfig->separator; diff --git a/src/modules/module_29100.c b/src/modules/module_29100.c index 5d2227f41..b0db0f42f 100644 --- a/src/modules/module_29100.c +++ b/src/modules/module_29100.c @@ -58,6 +58,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.sep[0] = '.'; diff --git a/src/modules/module_29200.c b/src/modules/module_29200.c index 245e25d44..9a9d95c03 100644 --- a/src/modules/module_29200.c +++ b/src/modules/module_29200.c @@ -79,6 +79,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_RADMIN3; @@ -95,9 +97,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // SHA1 salt token.sep[2] = '*'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // verifier diff --git a/src/modules/module_29311.c b/src/modules/module_29311.c index 78bc26ca6..b6603ad73 100644 --- a/src/modules/module_29311.c +++ b/src/modules/module_29311.c @@ -125,6 +125,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -135,15 +137,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29312.c b/src/modules/module_29312.c index 1ee66f9a7..6d8bfe643 100644 --- a/src/modules/module_29312.c +++ b/src/modules/module_29312.c @@ -125,6 +125,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -135,15 +137,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29313.c b/src/modules/module_29313.c index a0f8032f8..064ef2c46 100644 --- a/src/modules/module_29313.c +++ b/src/modules/module_29313.c @@ -125,6 +125,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -135,15 +137,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29321.c b/src/modules/module_29321.c index cad92dfd1..c443ce2a3 100644 --- a/src/modules/module_29321.c +++ b/src/modules/module_29321.c @@ -126,6 +126,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -136,15 +138,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29322.c b/src/modules/module_29322.c index 5adaccc95..0dad95126 100644 --- a/src/modules/module_29322.c +++ b/src/modules/module_29322.c @@ -126,6 +126,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -136,15 +138,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29323.c b/src/modules/module_29323.c index a20b7167b..1186809af 100644 --- a/src/modules/module_29323.c +++ b/src/modules/module_29323.c @@ -126,6 +126,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -136,15 +138,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29331.c b/src/modules/module_29331.c index b5b198a57..00f89b10c 100644 --- a/src/modules/module_29331.c +++ b/src/modules/module_29331.c @@ -111,6 +111,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -121,15 +123,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29332.c b/src/modules/module_29332.c index 03154bcf0..aea7fb0a5 100644 --- a/src/modules/module_29332.c +++ b/src/modules/module_29332.c @@ -111,6 +111,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -121,15 +123,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29333.c b/src/modules/module_29333.c index adab22650..cd3c4ac05 100644 --- a/src/modules/module_29333.c +++ b/src/modules/module_29333.c @@ -111,6 +111,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -121,15 +123,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29341.c b/src/modules/module_29341.c index 873c646c2..01e0947aa 100644 --- a/src/modules/module_29341.c +++ b/src/modules/module_29341.c @@ -138,6 +138,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -148,15 +150,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29342.c b/src/modules/module_29342.c index 465e3a52a..cf6f6abf2 100644 --- a/src/modules/module_29342.c +++ b/src/modules/module_29342.c @@ -138,6 +138,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -148,15 +150,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29343.c b/src/modules/module_29343.c index 2eb1dbbf0..6ed61b839 100644 --- a/src/modules/module_29343.c +++ b/src/modules/module_29343.c @@ -138,6 +138,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -148,15 +150,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = TC_SALT_HEX_LEN; - token.len_max[1] = TC_SALT_HEX_LEN; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = TC_SALT_HEX_LEN; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = TC_DATA_HEX_LEN; - token.len_max[2] = TC_DATA_HEX_LEN; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = TC_DATA_HEX_LEN; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29411.c b/src/modules/module_29411.c index 7c5063bf5..e0695a5a0 100644 --- a/src/modules/module_29411.c +++ b/src/modules/module_29411.c @@ -153,6 +153,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -163,15 +165,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29412.c b/src/modules/module_29412.c index ca95614b2..cf5e403b8 100644 --- a/src/modules/module_29412.c +++ b/src/modules/module_29412.c @@ -153,6 +153,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -163,15 +165,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29413.c b/src/modules/module_29413.c index d96acbe4a..f8ea19758 100644 --- a/src/modules/module_29413.c +++ b/src/modules/module_29413.c @@ -153,6 +153,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -163,15 +165,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29421.c b/src/modules/module_29421.c index 25c39d811..69d86b307 100644 --- a/src/modules/module_29421.c +++ b/src/modules/module_29421.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -173,15 +175,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29422.c b/src/modules/module_29422.c index 202fbb1b6..8099b8998 100644 --- a/src/modules/module_29422.c +++ b/src/modules/module_29422.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -173,15 +175,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29423.c b/src/modules/module_29423.c index a4f586d09..afaa1b147 100644 --- a/src/modules/module_29423.c +++ b/src/modules/module_29423.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -173,15 +175,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29431.c b/src/modules/module_29431.c index 05efeee6e..a48035fc5 100644 --- a/src/modules/module_29431.c +++ b/src/modules/module_29431.c @@ -140,6 +140,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -150,15 +152,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29432.c b/src/modules/module_29432.c index 44cdac43d..a3ace917a 100644 --- a/src/modules/module_29432.c +++ b/src/modules/module_29432.c @@ -140,6 +140,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -150,15 +152,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29433.c b/src/modules/module_29433.c index 2970869b8..9ea966525 100644 --- a/src/modules/module_29433.c +++ b/src/modules/module_29433.c @@ -154,6 +154,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -164,15 +166,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29441.c b/src/modules/module_29441.c index e3e9e95c9..65a34b8c3 100644 --- a/src/modules/module_29441.c +++ b/src/modules/module_29441.c @@ -155,6 +155,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -165,15 +167,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29442.c b/src/modules/module_29442.c index aece9619e..2e688d499 100644 --- a/src/modules/module_29442.c +++ b/src/modules/module_29442.c @@ -155,6 +155,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -165,15 +167,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29443.c b/src/modules/module_29443.c index dcda52155..124bac2e6 100644 --- a/src/modules/module_29443.c +++ b/src/modules/module_29443.c @@ -155,6 +155,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -165,15 +167,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29451.c b/src/modules/module_29451.c index 0cee1aac1..e2cfc368c 100644 --- a/src/modules/module_29451.c +++ b/src/modules/module_29451.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -182,15 +184,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29452.c b/src/modules/module_29452.c index 61c3d7aba..39c826da1 100644 --- a/src/modules/module_29452.c +++ b/src/modules/module_29452.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -182,15 +184,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29453.c b/src/modules/module_29453.c index 5d102ac56..e5bbe5d9e 100644 --- a/src/modules/module_29453.c +++ b/src/modules/module_29453.c @@ -172,6 +172,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -182,15 +184,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29461.c b/src/modules/module_29461.c index 9bc7f7dd7..0489a8e6b 100644 --- a/src/modules/module_29461.c +++ b/src/modules/module_29461.c @@ -174,6 +174,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -184,15 +186,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29462.c b/src/modules/module_29462.c index 28f2194f8..329eee24b 100644 --- a/src/modules/module_29462.c +++ b/src/modules/module_29462.c @@ -174,6 +174,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -184,15 +186,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29463.c b/src/modules/module_29463.c index 2726ab426..2b61a3e43 100644 --- a/src/modules/module_29463.c +++ b/src/modules/module_29463.c @@ -174,6 +174,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -184,15 +186,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29471.c b/src/modules/module_29471.c index 9590b080c..2fa8e247d 100644 --- a/src/modules/module_29471.c +++ b/src/modules/module_29471.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -173,15 +175,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29472.c b/src/modules/module_29472.c index 241788a69..7fc95a2d9 100644 --- a/src/modules/module_29472.c +++ b/src/modules/module_29472.c @@ -163,6 +163,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -173,15 +175,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29473.c b/src/modules/module_29473.c index 67c180f78..1b8a7d6e4 100644 --- a/src/modules/module_29473.c +++ b/src/modules/module_29473.c @@ -169,6 +169,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -179,15 +181,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29481.c b/src/modules/module_29481.c index 71a3e078c..3cf55a275 100644 --- a/src/modules/module_29481.c +++ b/src/modules/module_29481.c @@ -165,6 +165,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -175,15 +177,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29482.c b/src/modules/module_29482.c index 137350cbe..aece087db 100644 --- a/src/modules/module_29482.c +++ b/src/modules/module_29482.c @@ -165,6 +165,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -175,15 +177,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29483.c b/src/modules/module_29483.c index b3de3bc24..d958e5424 100644 --- a/src/modules/module_29483.c +++ b/src/modules/module_29483.c @@ -165,6 +165,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -175,15 +177,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 896; - token.len_max[2] = 896; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 896; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29511.c b/src/modules/module_29511.c index e2b098ba7..673f1833c 100644 --- a/src/modules/module_29511.c +++ b/src/modules/module_29511.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29512.c b/src/modules/module_29512.c index 8db821145..0079abd74 100644 --- a/src/modules/module_29512.c +++ b/src/modules/module_29512.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29513.c b/src/modules/module_29513.c index 61e6c6a46..20fb7620b 100644 --- a/src/modules/module_29513.c +++ b/src/modules/module_29513.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29521.c b/src/modules/module_29521.c index 5a1bb3320..43ba8a537 100644 --- a/src/modules/module_29521.c +++ b/src/modules/module_29521.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29522.c b/src/modules/module_29522.c index e424d3c66..cc940ef1b 100644 --- a/src/modules/module_29522.c +++ b/src/modules/module_29522.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29523.c b/src/modules/module_29523.c index 0a6a7705b..7d7c17ae9 100644 --- a/src/modules/module_29523.c +++ b/src/modules/module_29523.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29531.c b/src/modules/module_29531.c index 2fd82133e..bc175f9b0 100644 --- a/src/modules/module_29531.c +++ b/src/modules/module_29531.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29532.c b/src/modules/module_29532.c index 3ebdb3fcb..fc864498b 100644 --- a/src/modules/module_29532.c +++ b/src/modules/module_29532.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29533.c b/src/modules/module_29533.c index ef52bafba..a21a581ea 100644 --- a/src/modules/module_29533.c +++ b/src/modules/module_29533.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29541.c b/src/modules/module_29541.c index 9bab26aed..4f9d02309 100644 --- a/src/modules/module_29541.c +++ b/src/modules/module_29541.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29542.c b/src/modules/module_29542.c index 08bf7e871..397e70c92 100644 --- a/src/modules/module_29542.c +++ b/src/modules/module_29542.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29543.c b/src/modules/module_29543.c index 9c77dacc5..4dd2e82f8 100644 --- a/src/modules/module_29543.c +++ b/src/modules/module_29543.c @@ -151,6 +151,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -169,9 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // key size token.sep[2] = '$'; - token.len_min[2] = 3; - token.len_max[2] = 3; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 3; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; // iter @@ -183,9 +184,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // salt token.sep[4] = '$'; - token.len_min[4] = LUKS_SALT_HEX_LEN; - token.len_max[4] = LUKS_SALT_HEX_LEN; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = LUKS_SALT_HEX_LEN; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; // af @@ -197,9 +197,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct token.sep[6] = '$'; - token.len_min[6] = LUKS_CT_HEX_LEN; - token.len_max[6] = LUKS_CT_HEX_LEN; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = LUKS_CT_HEX_LEN; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29600.c b/src/modules/module_29600.c index 9d7eb86f9..e05e75eab 100644 --- a/src/modules/module_29600.c +++ b/src/modules/module_29600.c @@ -22,8 +22,7 @@ static const char *HASH_NAME = "Terra Station Wallet (AES256-CBC(PBKDF2($pa static const u64 KERN_TYPE = 29600; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE - | OPTS_TYPE_ST_HEX - | OPTS_TYPE_PT_GENERATE_BE; + | OPTS_TYPE_ST_HEX; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "67445496c838e96c1424a8dae4b146f0fc247c8c34ef33feffeb1e4412018512wZGtBMeN84XZE2LoOKwTGvA4Ee4m7PR1lDGIdWUV6OSUZKRiKFx9tlrnZLt8r8OfOzbwUS2a2Uo+nrrP6F85fh4eHstwPJw0KwzHWB8br58="; @@ -109,6 +108,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; // salt diff --git a/src/modules/module_29700.c b/src/modules/module_29700.c index 50c36de3e..bfa0c1801 100644 --- a/src/modules/module_29700.c +++ b/src/modules/module_29700.c @@ -122,19 +122,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_KEEPASS; token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 9; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '*'; @@ -158,33 +158,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 11; token.sep[4] = '*'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 32; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '*'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[8] = '*'; - token.len_min[8] = 1; - token.len_max[8] = 1; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 1; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[9] = '*'; @@ -204,21 +199,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 14; token.sep[11] = '*'; - token.len_min[11] = 1; - token.len_max[11] = 1; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + token.len[11] = 1; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[12] = '*'; - token.len_min[12] = 2; - token.len_max[12] = 2; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH + token.len[12] = 2; + token.attr[12] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[13] = '*'; - token.len_min[13] = 64; - token.len_max[13] = 64; - token.attr[13] = TOKEN_ATTR_VERIFY_LENGTH + token.len[13] = 64; + token.attr[13] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; } } @@ -227,33 +219,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 9; token.sep[4] = '*'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 64; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 64; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 32; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '*'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH + token.len[7] = 64; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[8] = '*'; - token.len_min[8] = 64; - token.len_max[8] = 64; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 64; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; if (is_keyfile_present == true) @@ -261,21 +248,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.token_cnt = 12; token.sep[9] = '*'; - token.len_min[9] = 1; - token.len_max[9] = 1; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH + token.len[9] = 1; + token.attr[9] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[10] = '*'; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH + token.len[10] = 2; + token.attr[10] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[11] = '*'; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH + token.len[11] = 64; + token.attr[11] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; } } @@ -571,20 +555,17 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < final_random_seed_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_final_random_seed[i]); + for (u32 i = 0; i < final_random_seed_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_final_random_seed[i]); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < transf_random_seed_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_transf_random_seed[i]); + for (u32 i = 0; i < transf_random_seed_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_transf_random_seed[i]); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < enc_iv_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_enc_iv[i]); + for (u32 i = 0; i < enc_iv_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_enc_iv[i]); *ptr_data = '*'; ptr_data++; @@ -594,8 +575,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 contents_len = keepass->contents_len; u32 *ptr_contents = (u32 *) keepass->contents; - for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_contents_hash[i]); + for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_contents_hash[i]); *ptr_data = '*'; ptr_data++; @@ -609,31 +589,28 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE char ptr_contents_len[10] = { 0 }; - sprintf ((char*) ptr_contents_len, "%u", contents_len); + snprintf ((char*) ptr_contents_len, sizeof (ptr_contents_len), "%u", contents_len); - sprintf (ptr_data, "%u", contents_len); + snprintf (ptr_data, sizeof (ptr_contents_len), "%u", contents_len); ptr_data += strlen (ptr_contents_len); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < contents_len / 4; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_contents[i]); + for (u32 i = 0; i < contents_len / 4; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_contents[i]); } else if (version == 2) { expected_bytes_len = 8; ptr_expected_bytes = (u32 *) keepass->expected_bytes; - for (u32 i = 0; i < expected_bytes_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_expected_bytes[i]); + for (u32 i = 0; i < expected_bytes_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_expected_bytes[i]); *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_contents_hash[i]); + for (u32 i = 0; i < contents_hash_len; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_contents_hash[i]); } if (keyfile_len) @@ -648,15 +625,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE *ptr_data = '*'; ptr_data++; - sprintf (ptr_data, "%u", keyfile_len * 2); + snprintf (ptr_data, 3, "%u", keyfile_len * 2); ptr_data += 2; *ptr_data = '*'; ptr_data++; - for (u32 i = 0; i < 8; i++, ptr_data += 8) - sprintf (ptr_data, "%08x", ptr_keyfile[i]); + for (u32 i = 0; i < 8; i++, ptr_data += 8) snprintf (ptr_data, 9, "%08x", ptr_keyfile[i]); } return strlen (line_buf); diff --git a/src/modules/module_29800.c b/src/modules/module_29800.c index 653587030..364076c45 100644 --- a/src/modules/module_29800.c +++ b/src/modules/module_29800.c @@ -278,6 +278,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 7; token.signatures_cnt = 1; @@ -287,34 +289,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 1; - token.len_max[1] = 1; token.sep[1] = '*'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[2] = '*'; token.len_min[2] = 1; token.len_max[2] = 10; - token.sep[2] = '*'; token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; + token.sep[3] = '*'; token.len_min[3] = 1; token.len_max[3] = 2; - token.sep[3] = '*'; token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[4] = 1; - token.len_max[4] = 1; token.sep[4] = '*'; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 1; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; - token.len_min[5] = 16; - token.len_max[5] = 16; token.sep[5] = '*'; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 16; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len[6] = 64; diff --git a/src/modules/module_29910.c b/src/modules/module_29910.c index 0960c3cb2..23ed260c7 100644 --- a/src/modules/module_29910.c +++ b/src/modules/module_29910.c @@ -92,6 +92,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 8; token.signatures_cnt = 1; @@ -102,39 +104,33 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; - token.len_min[5] = 2; - token.len_max[5] = 2; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 2; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 64; - token.len_max[6] = 64; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 64; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '$'; diff --git a/src/modules/module_29920.c b/src/modules/module_29920.c index e73dc1268..bb433b090 100644 --- a/src/modules/module_29920.c +++ b/src/modules/module_29920.c @@ -92,6 +92,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 9; token.signatures_cnt = 1; @@ -102,39 +104,33 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; - token.len_min[5] = 2; - token.len_max[5] = 2; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 2; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[6] = '$'; - token.len_min[6] = 64; - token.len_max[6] = 64; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + token.len[6] = 64; + token.attr[6] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[7] = '$'; @@ -144,9 +140,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[8] = '$'; - token.len_min[8] = 256; - token.len_max[8] = 256; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH + token.len[8] = 256; + token.attr[8] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29930.c b/src/modules/module_29930.c index f436d64f4..bf467b029 100644 --- a/src/modules/module_29930.c +++ b/src/modules/module_29930.c @@ -87,6 +87,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; token.signatures_cnt = 1; @@ -97,27 +99,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_29940.c b/src/modules/module_29940.c index 02d6ec047..5cdca974e 100644 --- a/src/modules/module_29940.c +++ b/src/modules/module_29940.c @@ -87,6 +87,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 6; token.signatures_cnt = 1; @@ -97,33 +99,28 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 1; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 1; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 16; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + token.len[4] = 16; + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[5] = '$'; - token.len_min[5] = 256; - token.len_max[5] = 256; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + token.len[5] = 256; + token.attr[5] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_30000.c b/src/modules/module_30000.c index 0c9cd8c6d..2a3fd4704 100644 --- a/src/modules/module_30000.c +++ b/src/modules/module_30000.c @@ -53,15 +53,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_WERKZEUG_MD5; token.sep[0] = '$'; - token.len_min[0] = 3; - token.len_max[0] = 3; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 3; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; @@ -70,9 +71,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) diff --git a/src/modules/module_30120.c b/src/modules/module_30120.c index 15d602fa9..f17570333 100644 --- a/src/modules/module_30120.c +++ b/src/modules/module_30120.c @@ -84,15 +84,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_WERKZEUG_SHA256; token.sep[0] = '$'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; @@ -101,9 +102,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; token.sep[2] = '$'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) diff --git a/src/modules/module_30420.c b/src/modules/module_30420.c index 64237bdab..8074d3412 100644 --- a/src/modules/module_30420.c +++ b/src/modules/module_30420.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 56; - token.len_max[0] = 56; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 56; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_30500.c b/src/modules/module_30500.c index f9d0a6342..e68921944 100644 --- a/src/modules/module_30500.c +++ b/src/modules/module_30500.c @@ -80,12 +80,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.sep[0] = hashconfig->separator; - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.len_min[1] = SALT_MIN; diff --git a/src/modules/module_30600.c b/src/modules/module_30600.c index 5172ffecf..713fa6f64 100644 --- a/src/modules/module_30600.c +++ b/src/modules/module_30600.c @@ -171,6 +171,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 4; @@ -183,10 +185,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; - token.len_min[1] = 2; - token.len_max[1] = 2; token.sep[1] = '$'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 2; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_DIGIT; token.len[2] = 22; diff --git a/src/modules/module_30700.c b/src/modules/module_30700.c index 953ed21da..b078dc447 100644 --- a/src/modules/module_30700.c +++ b/src/modules/module_30700.c @@ -56,27 +56,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_ANOPE; token.sep[0] = ':'; - token.len_min[0] = 6; - token.len_max[0] = 6; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 6; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = ':'; - token.len_min[1] = 64; - token.len_max[1] = 64; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = ':'; - token.len_min[2] = 64; - token.len_max[2] = 64; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_30901.c b/src/modules/module_30901.c index 0422f4f20..3d60c3d90 100644 --- a/src/modules/module_30901.c +++ b/src/modules/module_30901.c @@ -74,6 +74,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len_min[0] = 26; diff --git a/src/modules/module_30902.c b/src/modules/module_30902.c index 3a765943b..984496707 100644 --- a/src/modules/module_30902.c +++ b/src/modules/module_30902.c @@ -75,6 +75,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len_min[0] = 26; diff --git a/src/modules/module_30903.c b/src/modules/module_30903.c index 1d179a527..3bcdad5af 100644 --- a/src/modules/module_30903.c +++ b/src/modules/module_30903.c @@ -97,6 +97,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_30904.c b/src/modules/module_30904.c index 27add2ea6..a3c9f2abe 100644 --- a/src/modules/module_30904.c +++ b/src/modules/module_30904.c @@ -97,6 +97,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_30905.c b/src/modules/module_30905.c index 5f8297f20..e3e9b7d55 100644 --- a/src/modules/module_30905.c +++ b/src/modules/module_30905.c @@ -75,6 +75,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 34; diff --git a/src/modules/module_30906.c b/src/modules/module_30906.c index fce7b67e7..1be061fad 100644 --- a/src/modules/module_30906.c +++ b/src/modules/module_30906.c @@ -75,6 +75,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len[0] = 34; diff --git a/src/modules/module_31000.c b/src/modules/module_31000.c index b6b9a330c..b7a3c2208 100644 --- a/src/modules/module_31000.c +++ b/src/modules/module_31000.c @@ -51,6 +51,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t * hashconfig, MAYBE_UNUS hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; diff --git a/src/modules/module_31100.c b/src/modules/module_31100.c index 008f84d4c..8db92fb91 100644 --- a/src/modules/module_31100.c +++ b/src/modules/module_31100.c @@ -54,11 +54,12 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; - token.len_min[0] = 64; - token.len_max[0] = 64; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 64; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_31200.c b/src/modules/module_31200.c index 32c1a181a..50bc5405e 100644 --- a/src/modules/module_31200.c +++ b/src/modules/module_31200.c @@ -81,21 +81,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; token.signatures_buf[0] = SIGNATURE_VEEAM_VBK; token.sep[0] = '*'; - token.len_min[0] = 5; - token.len_max[0] = 5; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + token.len[0] = 5; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '*'; - token.len_min[1] = 128; - token.len_max[1] = 128; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 128; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '*'; @@ -105,9 +105,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_DIGIT; token.sep[3] = '*'; - token.len_min[3] = 32; - token.len_max[3] = 32; - token.attr[3] = TOKEN_ATTR_VERIFY_HEX + token.len[3] = 32; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_31300.c b/src/modules/module_31300.c index 731c34e43..ae4130837 100644 --- a/src/modules/module_31300.c +++ b/src/modules/module_31300.c @@ -52,6 +52,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 3; token.signatures_cnt = 1; @@ -62,15 +64,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 32; - token.len_max[1] = 32; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[2] = '$'; - token.len_min[2] = 96; - token.len_max[2] = 96; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 96; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); diff --git a/src/modules/module_31400.c b/src/modules/module_31400.c index fb1b6e03a..dc9a94582 100644 --- a/src/modules/module_31400.c +++ b/src/modules/module_31400.c @@ -28,9 +28,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_NOT_ITERATED | OPTI_TYPE_NOT_SALTED | OPTI_TYPE_RAW_HASH; -static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE - | OPTS_TYPE_PT_ADD80 - | OPTS_TYPE_PT_ADDBITS15; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE; // OPTS_TYPE_PT_ADD80 and OPTS_TYPE_PT_ADDBITS15 added within kernel static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "S:\"Config Passphrase\"=02:ded7137400e0a1004a12f1708453968ccc270908ba02ab0345c83690d1de3d9937587be66ad2a7fe8cc6cb16ecff02e61ac05e09d4f49f284efd24f6b16d6ae3"; @@ -57,7 +55,7 @@ typedef struct scrtv2 } scrtv2_t; -static const char *CONFIGPASSPHRASEV2_SIGNATURE = "S:\"Config Passphrase\"=02:"; //The whole line is part of the format to prevent confusion with other similiar tokens also prefixed with 02: in the config files +static const char *CONFIGPASSPHRASEV2_SIGNATURE = "S:\"Config Passphrase\"=02:"; //The whole line is part of the format to prevent confusion with other similar tokens also prefixed with 02: in the config files u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { @@ -74,6 +72,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 2; token.signatures_cnt = 1; @@ -84,7 +84,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.len_min[1] = 96; - token.len_max[1] = 160; + token.len_max[1] = 224; token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_HEX; diff --git a/src/modules/module_31700.c b/src/modules/module_31700.c new file mode 100644 index 000000000..a99bdc663 --- /dev/null +++ b/src/modules/module_31700.c @@ -0,0 +1,275 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_md5.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "md5(md5(md5($pass).$salt1).$salt2)"; +static const u64 KERN_TYPE = 31700; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "c7a971e405313d0ecc22e37e8b2424a1:2316355934:478467"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct md5_double_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + +} md5_double_salt_t; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (md5_double_salt_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + md5_double_salt_t *md5_double_salt = (md5_double_salt_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[1] = hashconfig->separator; + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = hashconfig->separator; + token.len_min[2] = SALT_MIN; + token.len_max[2] = SALT_MAX; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + + token.len_min[2] *= 2; + token.len_max[2] *= 2; + + token.attr[2] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + const bool parse_rc1 = generic_salt_decode (hashconfig, token.buf[1], token.len[1], (u8 *) md5_double_salt->salt1_buf, (int *) &md5_double_salt->salt1_len); + + if (parse_rc1 == false) return (PARSER_SALT_LENGTH); + + const bool parse_rc2 = generic_salt_decode (hashconfig, token.buf[2], token.len[2], (u8 *) md5_double_salt->salt2_buf, (int *) &md5_double_salt->salt2_len); + + if (parse_rc2 == false) return (PARSER_SALT_LENGTH); + + // make salt sorter happy + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, md5_double_salt->salt1_buf, md5_double_salt->salt1_len); + md5_update (&md5_ctx, md5_double_salt->salt2_buf, md5_double_salt->salt2_len); + md5_final (&md5_ctx); + + salt->salt_buf[0] = md5_ctx.h[0]; + salt->salt_buf[1] = md5_ctx.h[1]; + salt->salt_buf[2] = md5_ctx.h[2]; + salt->salt_buf[3] = md5_ctx.h[3]; + + salt->salt_len = 16; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const md5_double_salt_t *md5_double_salt = (const md5_double_salt_t *) esalt_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_double_salt->salt1_buf, (const int) md5_double_salt->salt1_len, out_buf + out_len); + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_double_salt->salt2_buf, (const int) md5_double_salt->salt2_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_31800.c b/src/modules/module_31800.c new file mode 100644 index 000000000..e1dfa3b04 --- /dev/null +++ b/src/modules/module_31800.c @@ -0,0 +1,452 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER; +static const char *HASH_NAME = "1Password, mobilekeychain (1Password 8)"; +static const u64 KERN_TYPE = 31800; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_DEEP_COMP_KERNEL; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$mobilekeychain$31800@hashcat.net$0226802599846590531367298686059042845608249051353268870564348733$fa53b7d424cdd36667dc12e585810729efc8ea9b2f8e5dd7a3ee72f7576a6788$100000$e1fea241e7b7c84535a0d53388bccbb9$dfd5f9ad6da1a72a47a3c04e03b02142b2fc301b3afff610669058527828a0e0388f5a2b0e6909813a5f9653c54f797adf0869107f4b875d4beb736cfbcec428ca19fc28346642fa32ec00f2ca4ad8dcf119af33cb247273e7b7427fd20eae8fb992779979a5e25aa465b3954794f62f4ea85355032efcd4e43ae3db6b14720d1dda963a384c37b521a92cef3494f77580edab210987ebcf2f0f7ed0220c0a4777be693e075b5f1e1302$995f3703b8ea4519f8cdc1cbded4d595"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct onepassword8 +{ + u32 hkdf_salt_buf[8]; + u32 hkdf_key_buf[8]; + u32 tag_buf[4]; + + u32 iv_buf[4]; + int iv_len; + + u32 email_buf[64]; + int email_len; + + u32 ct_buf[1024]; + int ct_len; + +} onepassword8_t; + +static const char *SIGNATURE_1PASSWORD8 = "$mobilekeychain$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos) +{ + return KERN_RUN_3; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (onepassword8_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + onepassword8_t *onepassword8 = (onepassword8_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 8; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_1PASSWORD8; + + token.len[0] = 16; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len_min[1] = 0; + token.len_max[1] = 255; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = '$'; + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '$'; + token.len[3] = 64; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[4] = '$'; + token.len_min[4] = 1; + token.len_max[4] = 10; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + token.sep[5] = '$'; + token.len_min[5] = 24; + token.len_max[5] = 32; + token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[6] = '$'; + token.len_min[6] = 16; + token.len_max[6] = 4096; + token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[7] = '$'; + token.len[7] = 32; + token.attr[7] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // email + + const int email_len = token.len[1]; + const u8 *email_pos = token.buf[1]; + + onepassword8->email_len = email_len; + + memcpy ((void *) onepassword8->email_buf, email_pos, email_len); + + u8 *ptr = (u8 *) onepassword8->email_buf; + + ptr[email_len] = 0; + + // hkdf_salt + + //const int hkdf_salt_len = token.len[2]; + const u8 *hkdf_salt_pos = token.buf[2]; + + onepassword8->hkdf_salt_buf[0] = hex_to_u32 (hkdf_salt_pos + 0); + onepassword8->hkdf_salt_buf[1] = hex_to_u32 (hkdf_salt_pos + 8); + onepassword8->hkdf_salt_buf[2] = hex_to_u32 (hkdf_salt_pos + 16); + onepassword8->hkdf_salt_buf[3] = hex_to_u32 (hkdf_salt_pos + 24); + onepassword8->hkdf_salt_buf[4] = hex_to_u32 (hkdf_salt_pos + 32); + onepassword8->hkdf_salt_buf[5] = hex_to_u32 (hkdf_salt_pos + 40); + onepassword8->hkdf_salt_buf[6] = hex_to_u32 (hkdf_salt_pos + 48); + onepassword8->hkdf_salt_buf[7] = hex_to_u32 (hkdf_salt_pos + 56); + + onepassword8->hkdf_salt_buf[0] = byte_swap_32 (onepassword8->hkdf_salt_buf[0]); + onepassword8->hkdf_salt_buf[1] = byte_swap_32 (onepassword8->hkdf_salt_buf[1]); + onepassword8->hkdf_salt_buf[2] = byte_swap_32 (onepassword8->hkdf_salt_buf[2]); + onepassword8->hkdf_salt_buf[3] = byte_swap_32 (onepassword8->hkdf_salt_buf[3]); + onepassword8->hkdf_salt_buf[4] = byte_swap_32 (onepassword8->hkdf_salt_buf[4]); + onepassword8->hkdf_salt_buf[5] = byte_swap_32 (onepassword8->hkdf_salt_buf[5]); + onepassword8->hkdf_salt_buf[6] = byte_swap_32 (onepassword8->hkdf_salt_buf[6]); + onepassword8->hkdf_salt_buf[7] = byte_swap_32 (onepassword8->hkdf_salt_buf[7]); + + // hkdf_key + + //const int hkdf_key_len = token.len[3]; + const u8 *hkdf_key_pos = token.buf[3]; + + onepassword8->hkdf_key_buf[0] = hex_to_u32 (hkdf_key_pos + 0); + onepassword8->hkdf_key_buf[1] = hex_to_u32 (hkdf_key_pos + 8); + onepassword8->hkdf_key_buf[2] = hex_to_u32 (hkdf_key_pos + 16); + onepassword8->hkdf_key_buf[3] = hex_to_u32 (hkdf_key_pos + 24); + onepassword8->hkdf_key_buf[4] = hex_to_u32 (hkdf_key_pos + 32); + onepassword8->hkdf_key_buf[5] = hex_to_u32 (hkdf_key_pos + 40); + onepassword8->hkdf_key_buf[6] = hex_to_u32 (hkdf_key_pos + 48); + onepassword8->hkdf_key_buf[7] = hex_to_u32 (hkdf_key_pos + 56); + + onepassword8->hkdf_key_buf[0] = byte_swap_32 (onepassword8->hkdf_key_buf[0]); + onepassword8->hkdf_key_buf[1] = byte_swap_32 (onepassword8->hkdf_key_buf[1]); + onepassword8->hkdf_key_buf[2] = byte_swap_32 (onepassword8->hkdf_key_buf[2]); + onepassword8->hkdf_key_buf[3] = byte_swap_32 (onepassword8->hkdf_key_buf[3]); + onepassword8->hkdf_key_buf[4] = byte_swap_32 (onepassword8->hkdf_key_buf[4]); + onepassword8->hkdf_key_buf[5] = byte_swap_32 (onepassword8->hkdf_key_buf[5]); + onepassword8->hkdf_key_buf[6] = byte_swap_32 (onepassword8->hkdf_key_buf[6]); + onepassword8->hkdf_key_buf[7] = byte_swap_32 (onepassword8->hkdf_key_buf[7]); + + // iter + + const u8 *iter_pos = token.buf[4]; + + salt->salt_iter = hc_strtoul ((const char *) iter_pos, NULL, 10) - 1; + + // iv + + const int iv_len = token.len[5]; + const u8 *iv_pos = token.buf[5]; + + onepassword8->iv_len = hex_decode (iv_pos, iv_len, (u8 *) onepassword8->iv_buf); + + for (int i = 0; i < 4; i++) onepassword8->iv_buf[i] = byte_swap_32 (onepassword8->iv_buf[i]); + + // ct + + const int ct_len = token.len[6]; + const u8 *ct_pos = token.buf[6]; + + onepassword8->ct_len = hex_decode (ct_pos, ct_len, (u8 *) onepassword8->ct_buf); + + for (int i = 0; i < 1024; i++) onepassword8->ct_buf[i] = byte_swap_32 (onepassword8->ct_buf[i]); + + // tag + + //const int tag_len = token.len[7]; + const u8 *tag_pos = token.buf[7]; + + onepassword8->tag_buf[0] = hex_to_u32 (tag_pos + 0); + onepassword8->tag_buf[1] = hex_to_u32 (tag_pos + 8); + onepassword8->tag_buf[2] = hex_to_u32 (tag_pos + 16); + onepassword8->tag_buf[3] = hex_to_u32 (tag_pos + 24); + + onepassword8->tag_buf[0] = byte_swap_32 (onepassword8->tag_buf[0]); + onepassword8->tag_buf[1] = byte_swap_32 (onepassword8->tag_buf[1]); + onepassword8->tag_buf[2] = byte_swap_32 (onepassword8->tag_buf[2]); + onepassword8->tag_buf[3] = byte_swap_32 (onepassword8->tag_buf[3]); + + // salt + + salt->salt_buf[0] = onepassword8->hkdf_salt_buf[0]; + salt->salt_buf[1] = onepassword8->hkdf_salt_buf[1]; + salt->salt_buf[2] = onepassword8->hkdf_salt_buf[2]; + salt->salt_buf[3] = onepassword8->hkdf_salt_buf[3]; + salt->salt_buf[4] = onepassword8->hkdf_salt_buf[4]; + salt->salt_buf[5] = onepassword8->hkdf_salt_buf[5]; + salt->salt_buf[6] = onepassword8->hkdf_salt_buf[6]; + salt->salt_buf[7] = onepassword8->hkdf_salt_buf[7]; + + salt->salt_len = 32; + + // digest + + digest[0] = onepassword8->ct_buf[0]; + digest[1] = onepassword8->ct_buf[1]; + digest[2] = onepassword8->ct_buf[2]; + digest[3] = onepassword8->ct_buf[3]; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + // const u32 *digest = (const u32 *) digest_buf; + + onepassword8_t *onepassword8 = (onepassword8_t *) esalt_buf; + + // iv + + u32 iv_buf[4]; + + for (int i = 0; i < 4; i++) iv_buf[i] = byte_swap_32 (onepassword8->iv_buf[i]); + + u8 iv_buf8[(4 * 2 * 4) + 1]; + + const int iv_len = hex_encode ((const u8 *) iv_buf, onepassword8->iv_len, iv_buf8); + + iv_buf8[iv_len] = 0; + + // ct + + u32 ct_buf[1024]; + + for (int i = 0; i < 1024; i++) ct_buf[i] = byte_swap_32 (onepassword8->ct_buf[i]); + + u8 ct_buf8[(1024 * 2 * 4) + 1]; + + const int ct_len = hex_encode ((const u8 *) ct_buf, onepassword8->ct_len, ct_buf8); + + ct_buf8[ct_len] = 0; + + // final + + int out_len = snprintf ((char *) line_buf, line_size, "%s%s$%08x%08x%08x%08x%08x%08x%08x%08x$%08x%08x%08x%08x%08x%08x%08x%08x$%u$%s$%s$%08x%08x%08x%08x", + SIGNATURE_1PASSWORD8, + (char *) onepassword8->email_buf, + onepassword8->hkdf_salt_buf[0], + onepassword8->hkdf_salt_buf[1], + onepassword8->hkdf_salt_buf[2], + onepassword8->hkdf_salt_buf[3], + onepassword8->hkdf_salt_buf[4], + onepassword8->hkdf_salt_buf[5], + onepassword8->hkdf_salt_buf[6], + onepassword8->hkdf_salt_buf[7], + onepassword8->hkdf_key_buf[0], + onepassword8->hkdf_key_buf[1], + onepassword8->hkdf_key_buf[2], + onepassword8->hkdf_key_buf[3], + onepassword8->hkdf_key_buf[4], + onepassword8->hkdf_key_buf[5], + onepassword8->hkdf_key_buf[6], + onepassword8->hkdf_key_buf[7], + salt->salt_iter + 1, + (char *) iv_buf8, + (char *) ct_buf8, + onepassword8->tag_buf[0], + onepassword8->tag_buf[1], + onepassword8->tag_buf[2], + onepassword8->tag_buf[3]); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = module_deep_comp_kernel; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_31900.c b/src/modules/module_31900.c new file mode 100644 index 000000000..291c3d213 --- /dev/null +++ b/src/modules/module_31900.c @@ -0,0 +1,355 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "memory.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; +static const char *HASH_NAME = "MetaMask Mobile Wallet"; +static const u64 KERN_TYPE = 31900; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat1"; +static const char *ST_HASH = "$metamaskMobile$MjU1NTA5MTU2ODY5MjY4OQ==$3cccb51c401e54abc82987fd9310a8d3$WQhIECN0blOaV31RC3lKfQ=="; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct pbkdf2_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[32]; + u64 out[32]; + +} pbkdf2_sha512_tmp_t; + +typedef struct pbkdf2_sha512_aes_cbc +{ + u32 salt_buf[64]; + u32 iv_buf[4]; + u32 iv_len; + u32 ct_buf[4]; + u32 ct_len; + +} pbkdf2_sha512_aes_cbc_t; + +static const char *SIGNATURE_METAMASK_WALLET = "$metamaskMobile$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha512_aes_cbc_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha512_tmp_t); + + return tmp_size; +} + +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 pw_min = 8; + + return pw_min; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha512_aes_cbc_t *metamask = (pbkdf2_sha512_aes_cbc_t *) esalt_buf; + + #define CT_MAX_LEN_BASE64 ((3136 * 8) / 6) + 3 + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 4; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_METAMASK_WALLET; + + token.len[0] = strlen (SIGNATURE_METAMASK_WALLET); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 24; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[2] = '$'; + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[3] = '$'; + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + size_t tmp_len = 0; + + // iter + + salt->salt_iter = 5000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + memcpy ((u8 *) metamask->salt_buf, salt_pos, salt_len); + + salt->salt_len = salt_len; + + memcpy ((u8 *) salt->salt_buf, metamask->salt_buf, salt->salt_len); + + // iv + + const u8 *iv_pos = token.buf[2]; + const int iv_len = token.len[2] / 2; + + metamask->iv_buf[0] = hex_to_u32 (iv_pos + 0); + metamask->iv_buf[1] = hex_to_u32 (iv_pos + 8); + metamask->iv_buf[2] = hex_to_u32 (iv_pos + 16); + metamask->iv_buf[3] = hex_to_u32 (iv_pos + 24); + + metamask->iv_buf[0] = byte_swap_32 (metamask->iv_buf[0]); + metamask->iv_buf[1] = byte_swap_32 (metamask->iv_buf[1]); + metamask->iv_buf[2] = byte_swap_32 (metamask->iv_buf[2]); + metamask->iv_buf[3] = byte_swap_32 (metamask->iv_buf[3]); + + metamask->iv_len = iv_len; + + // ciphertext + + const u8 *ct_pos = token.buf[3]; + const int ct_len = token.len[3]; + + u8 tmp_buf[24+1]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, ct_pos, ct_len, tmp_buf); + + if (tmp_len != 16) return (PARSER_CT_LENGTH); + + memcpy ((u8 *) metamask->ct_buf, tmp_buf, tmp_len); + + metamask->ct_buf[0] = byte_swap_32 (metamask->ct_buf[0]); + metamask->ct_buf[1] = byte_swap_32 (metamask->ct_buf[1]); + metamask->ct_buf[2] = byte_swap_32 (metamask->ct_buf[2]); + metamask->ct_buf[3] = byte_swap_32 (metamask->ct_buf[3]); + + metamask->ct_len = tmp_len / 4; + + // digest + + digest[0] = metamask->ct_buf[0]; + digest[1] = metamask->ct_buf[1]; + digest[2] = metamask->ct_buf[2]; + digest[3] = metamask->ct_buf[3]; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + pbkdf2_sha512_aes_cbc_t *metamask = (pbkdf2_sha512_aes_cbc_t *) esalt_buf; + + // salt + + u8 *salt_buf = (u8 *) salt->salt_buf; + + // iv + + u8 iv_buf[32+1]; + + memset (iv_buf, 0, sizeof (iv_buf)); + + u32_to_hex (byte_swap_32 (metamask->iv_buf[0]), iv_buf + 0); + u32_to_hex (byte_swap_32 (metamask->iv_buf[1]), iv_buf + 8); + u32_to_hex (byte_swap_32 (metamask->iv_buf[2]), iv_buf + 16); + u32_to_hex (byte_swap_32 (metamask->iv_buf[3]), iv_buf + 24); + + // ct + + u32 tmp_buf[4]; + + tmp_buf[0] = byte_swap_32 (digest[0]); + tmp_buf[1] = byte_swap_32 (digest[1]); + tmp_buf[2] = byte_swap_32 (digest[2]); + tmp_buf[3] = byte_swap_32 (digest[3]); + + u8 ct_buf[24+1]; + + memset (ct_buf, 0, sizeof (ct_buf)); + + base64_encode (int_to_base64, (const u8 *) tmp_buf, (const int) metamask->ct_len * 4, ct_buf); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s$%s", + SIGNATURE_METAMASK_WALLET, + salt_buf, + iv_buf, + ct_buf); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32000.c b/src/modules/module_32000.c new file mode 100644 index 000000000..f1e17711a --- /dev/null +++ b/src/modules/module_32000.c @@ -0,0 +1,211 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_5; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (MD5)"; +static const u64 KERN_TYPE = 32000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_VIRTUAL; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$0$100000$NONE$2c8586ef492e3c3dd3795395507dc14f"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_md5_tmp +{ + u32 dgst[4]; + +} netiq_sspr_md5_tmp_t; + +static const char *SIGNATURE_NETIQ_SSPR_MD5 = "$sspr$0$100000$NONE$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_md5_tmp_t); + + return tmp_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_SSPR_MD5; + + token.len[0] = strlen (SIGNATURE_NETIQ_SSPR_MD5); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // digest + + const u8 *hash_pos = token.buf[1]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // digest + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s", SIGNATURE_NETIQ_SSPR_MD5); + + out_buf += out_len; + + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + + out_len += 32; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32010.c b/src/modules/module_32010.c new file mode 100644 index 000000000..d82e5ca6a --- /dev/null +++ b/src/modules/module_32010.c @@ -0,0 +1,220 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 4; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_5; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (SHA1)"; +static const u64 KERN_TYPE = 32010; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_VIRTUAL; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$1$100000$NONE$b3485214dfa55b038a606a183a560dab7db4ecf1"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_sha1_tmp +{ + u32 dgst[5]; + +} netiq_sspr_sha1_tmp_t; + +static const char *SIGNATURE_NETIQ_SSPR_SHA1 = "$sspr$1$100000$NONE$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_sha1_tmp_t); + + return tmp_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_SSPR_SHA1; + + token.len[0] = strlen (SIGNATURE_NETIQ_SSPR_SHA1); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 40; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // digest + + const u8 *hash_pos = token.buf[1]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // digest + + u32 tmp[5]; + + tmp[0] = byte_swap_32 (digest[0]); + tmp[1] = byte_swap_32 (digest[1]); + tmp[2] = byte_swap_32 (digest[2]); + tmp[3] = byte_swap_32 (digest[3]); + tmp[4] = byte_swap_32 (digest[4]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s", SIGNATURE_NETIQ_SSPR_SHA1); + + out_buf += out_len; + + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + u32_to_hex (tmp[4], out_buf + 32); + + out_len += 40; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32020.c b/src/modules/module_32020.c new file mode 100644 index 000000000..6b35439b2 --- /dev/null +++ b/src/modules/module_32020.c @@ -0,0 +1,255 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 4; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_5; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (SHA-1 with Salt)"; +static const u64 KERN_TYPE = 32020; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_ST_BASE64 + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$2$100000$CxCpGqosk9PkCBcoRFp6DLjjRhVEJKK8$a33283d71c2ecaf4f3017b0a89feca2fc879221c"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_sha1_tmp +{ + u32 dgst[5]; + +} netiq_sspr_sha1_tmp_t; + +static const char *SIGNATURE_NETIQ_SSPR_SHA1_SALTED = "$sspr$2$100000$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_sha1_tmp_t); + + return tmp_size; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 32; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 32; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_SSPR_SHA1_SALTED; + + token.len[0] = strlen (SIGNATURE_NETIQ_SSPR_SHA1_SALTED); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[2] = '$'; + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + salt->salt_len = salt_len; + + memcpy ((u8 *) salt->salt_buf, salt_pos, salt->salt_len); + + // digest + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // salt + + u8 *salt_buf = (u8 *) salt->salt_buf; + + // digest + + u32 tmp[5]; + + tmp[0] = byte_swap_32 (digest[0]); + tmp[1] = byte_swap_32 (digest[1]); + tmp[2] = byte_swap_32 (digest[2]); + tmp[3] = byte_swap_32 (digest[3]); + tmp[4] = byte_swap_32 (digest[4]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$", + SIGNATURE_NETIQ_SSPR_SHA1_SALTED, + salt_buf); + + out_buf += out_len; + + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + u32_to_hex (tmp[4], out_buf + 32); + + out_len += 40; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32030.c b/src/modules/module_32030.c new file mode 100644 index 000000000..d2a28f172 --- /dev/null +++ b/src/modules/module_32030.c @@ -0,0 +1,267 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (SHA-256 with Salt)"; +static const u64 KERN_TYPE = 32030; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_ST_BASE64 + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$3$100000$ODk2NDA5Mjc2NDIwMjMwMjQyMTQ1NzMz$7195873d47c7e3627510862e37fe7cab9bc83b91feecb9864841bf80cff92419"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_sha256_tmp +{ + u32 dgst[8]; + +} netiq_sspr_sha256_tmp_t; + +static const char *SIGNATURE_NETIQ_SSPR_SHA256_SALTED = "$sspr$3$100000$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_sha256_tmp_t); + + return tmp_size; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 32; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 32; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_SSPR_SHA256_SALTED; + + token.len[0] = strlen (SIGNATURE_NETIQ_SSPR_SHA256_SALTED); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[2] = '$'; + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + salt->salt_len = salt_len; + + memcpy ((u8 *) salt->salt_buf, salt_pos, salt->salt_len); + + // digest + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // salt + + u8 *salt_buf = (u8 *) salt->salt_buf; + + // digest + + u32 tmp[8]; + + tmp[0] = byte_swap_32 (digest[0]); + tmp[1] = byte_swap_32 (digest[1]); + tmp[2] = byte_swap_32 (digest[2]); + tmp[3] = byte_swap_32 (digest[3]); + tmp[4] = byte_swap_32 (digest[4]); + tmp[5] = byte_swap_32 (digest[5]); + tmp[6] = byte_swap_32 (digest[6]); + tmp[7] = byte_swap_32 (digest[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$", + SIGNATURE_NETIQ_SSPR_SHA256_SALTED, + salt_buf); + + out_buf += out_len; + + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + u32_to_hex (tmp[4], out_buf + 32); + u32_to_hex (tmp[5], out_buf + 40); + u32_to_hex (tmp[6], out_buf + 48); + u32_to_hex (tmp[7], out_buf + 56); + + out_len += 64; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32031.c b/src/modules/module_32031.c new file mode 100644 index 000000000..2ce2cf719 --- /dev/null +++ b/src/modules/module_32031.c @@ -0,0 +1,272 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "Adobe AEM (SSPR, SHA-256 with Salt)"; +static const u64 KERN_TYPE = 32030; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$3$1000$f9bbf1381f481427$a1b45fd7eb190cc7f0bf831698cb777207eebbb4b7ea2abd6fff84be539aae62"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_sha256_tmp +{ + u32 dgst[8]; + +} netiq_sspr_sha256_tmp_t; + +static const char *SIGNATURE_ADOBE_AES_SHA256_SALTED = "$sspr$3$1000$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_sha256_tmp_t); + + return tmp_size; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 16; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 16; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_ADOBE_AES_SHA256_SALTED; + + token.len[0] = strlen (SIGNATURE_ADOBE_AES_SHA256_SALTED); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + token.sep[2] = '$'; + token.len[2] = 64; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 1000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + // digest + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + digest[5] = hex_to_u32 (hash_pos + 40); + digest[6] = hex_to_u32 (hash_pos + 48); + digest[7] = hex_to_u32 (hash_pos + 56); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // salt + + u8 salt_buf[16 + 1]; + + memset (salt_buf, 0, sizeof (salt_buf)); + + generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); + + // digest + + u32 tmp[8]; + + tmp[0] = byte_swap_32 (digest[0]); + tmp[1] = byte_swap_32 (digest[1]); + tmp[2] = byte_swap_32 (digest[2]); + tmp[3] = byte_swap_32 (digest[3]); + tmp[4] = byte_swap_32 (digest[4]); + tmp[5] = byte_swap_32 (digest[5]); + tmp[6] = byte_swap_32 (digest[6]); + tmp[7] = byte_swap_32 (digest[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$", SIGNATURE_ADOBE_AES_SHA256_SALTED, salt_buf); + + out_buf += out_len; + + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + u32_to_hex (tmp[4], out_buf + 32); + u32_to_hex (tmp[5], out_buf + 40); + u32_to_hex (tmp[6], out_buf + 48); + u32_to_hex (tmp[7], out_buf + 56); + + out_len += 64; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32040.c b/src/modules/module_32040.c new file mode 100644 index 000000000..2a8f248af --- /dev/null +++ b/src/modules/module_32040.c @@ -0,0 +1,268 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 14; +static const u32 DGST_POS1 = 15; +static const u32 DGST_POS2 = 6; +static const u32 DGST_POS3 = 7; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (SHA-512 with Salt)"; +static const u64 KERN_TYPE = 32040; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_ST_BASE64 + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$4$100000$NzYwNjMyNDc2MTQ2OTE4NTUzODAyODE3$0ce2e8b8efa4280e6e003d77cb45d45300dff3960c5c073f68303565fe62fe4ff3ada8cee7d3b87d0457335ab0df73c5c64ee1f71ccf6b8bd43a316ecb42ecd4"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_sha512_tmp +{ + u64 dgst[8]; + +} netiq_sspr_sha512_tmp_t; + +static const char *SIGNATURE_NETIQ_SSPR_SHA512_SALTED = "$sspr$4$100000$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_sha512_tmp_t); + + return tmp_size; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 32; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 32; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_SSPR_SHA512_SALTED; + + token.len[0] = strlen (SIGNATURE_NETIQ_SSPR_SHA512_SALTED); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 32; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + token.sep[2] = '$'; + token.len[2] = 128; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + salt->salt_len = salt_len; + + memcpy ((u8 *) salt->salt_buf, salt_pos, salt->salt_len); + + // digest + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u64 (hash_pos + 0); + digest[1] = hex_to_u64 (hash_pos + 16); + digest[2] = hex_to_u64 (hash_pos + 32); + digest[3] = hex_to_u64 (hash_pos + 48); + digest[4] = hex_to_u64 (hash_pos + 64); + digest[5] = hex_to_u64 (hash_pos + 80); + digest[6] = hex_to_u64 (hash_pos + 96); + digest[7] = hex_to_u64 (hash_pos + 112); + + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u64 *digest = (const u64 *) digest_buf; + + // salt + + u8 *salt_buf = (u8 *) salt->salt_buf; + + // digest + + u64 tmp[8]; + + tmp[0] = byte_swap_64 (digest[0]); + tmp[1] = byte_swap_64 (digest[1]); + tmp[2] = byte_swap_64 (digest[2]); + tmp[3] = byte_swap_64 (digest[3]); + tmp[4] = byte_swap_64 (digest[4]); + tmp[5] = byte_swap_64 (digest[5]); + tmp[6] = byte_swap_64 (digest[6]); + tmp[7] = byte_swap_64 (digest[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$", + SIGNATURE_NETIQ_SSPR_SHA512_SALTED, + salt_buf); + + out_buf += out_len; + + u64_to_hex (tmp[0], out_buf + 0); + u64_to_hex (tmp[1], out_buf + 16); + u64_to_hex (tmp[2], out_buf + 32); + u64_to_hex (tmp[3], out_buf + 48); + u64_to_hex (tmp[4], out_buf + 64); + u64_to_hex (tmp[5], out_buf + 80); + u64_to_hex (tmp[6], out_buf + 96); + u64_to_hex (tmp[7], out_buf + 112); + + out_len += 128; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32041.c b/src/modules/module_32041.c new file mode 100644 index 000000000..445562e30 --- /dev/null +++ b/src/modules/module_32041.c @@ -0,0 +1,275 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 14; +static const u32 DGST_POS1 = 15; +static const u32 DGST_POS2 = 6; +static const u32 DGST_POS3 = 7; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "Adobe AEM (SSPR, SHA-512 with Salt)"; +static const u64 KERN_TYPE = 32040; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$sspr$4$1000$9ad596c50a5c9acd$d4cdc3c7d227e3cc57a9c9014b1eff1684808ef40191482cd8ae6e9d7b66211a5f04e4b34f494b0513a5f67b9614c5ff16e95e624a60f41b16b90533f305146e"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct netiq_sspr_sha512_tmp +{ + u64 dgst[8]; + +} netiq_sspr_sha512_tmp_t; + +static const char *SIGNATURE_ADOBE_AEM_SHA512_SALTED = "$sspr$4$1000$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (netiq_sspr_sha512_tmp_t); + + return tmp_size; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 16; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 16; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_ADOBE_AEM_SHA512_SALTED; + + token.len[0] = strlen (SIGNATURE_ADOBE_AEM_SHA512_SALTED); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 16; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + token.sep[2] = '$'; + token.len[2] = 128; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 1000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + // digest + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u64 (hash_pos + 0); + digest[1] = hex_to_u64 (hash_pos + 16); + digest[2] = hex_to_u64 (hash_pos + 32); + digest[3] = hex_to_u64 (hash_pos + 48); + digest[4] = hex_to_u64 (hash_pos + 64); + digest[5] = hex_to_u64 (hash_pos + 80); + digest[6] = hex_to_u64 (hash_pos + 96); + digest[7] = hex_to_u64 (hash_pos + 112); + + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u64 *digest = (const u64 *) digest_buf; + + // salt + + u8 salt_buf[16 + 1]; + + memset (salt_buf, 0, sizeof (salt_buf)); + + generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, salt_buf); + + // digest + + u64 tmp[8]; + + tmp[0] = byte_swap_64 (digest[0]); + tmp[1] = byte_swap_64 (digest[1]); + tmp[2] = byte_swap_64 (digest[2]); + tmp[3] = byte_swap_64 (digest[3]); + tmp[4] = byte_swap_64 (digest[4]); + tmp[5] = byte_swap_64 (digest[5]); + tmp[6] = byte_swap_64 (digest[6]); + tmp[7] = byte_swap_64 (digest[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$", + SIGNATURE_ADOBE_AEM_SHA512_SALTED, + salt_buf); + + out_buf += out_len; + + u64_to_hex (tmp[0], out_buf + 0); + u64_to_hex (tmp[1], out_buf + 16); + u64_to_hex (tmp[2], out_buf + 32); + u64_to_hex (tmp[3], out_buf + 48); + u64_to_hex (tmp[4], out_buf + 64); + u64_to_hex (tmp[5], out_buf + 80); + u64_to_hex (tmp[6], out_buf + 96); + u64_to_hex (tmp[7], out_buf + 112); + + out_len += 128; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32050.c b/src/modules/module_32050.c new file mode 100644 index 000000000..47e0b2c6d --- /dev/null +++ b/src/modules/module_32050.c @@ -0,0 +1,297 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_5; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (PBKDF2WithHmacSHA1)"; +static const u64 KERN_TYPE = 12000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$pbkdf2-hmac-sha1$100000$7134180503252384106490944216249411431665011151428170747164626720$990e0c5f62b1384d48cbe3660329b9741c4a8473"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct pbkdf2_sha1_tmp +{ + u32 ipad[5]; + u32 opad[5]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha1_tmp_t; + +typedef struct pbkdf2_sha1 +{ + u32 salt_buf[64]; + +} pbkdf2_sha1_t; + +static const char *SIGNATURE_NETIQ_PBKDF2_HMAC_SHA1 = "$pbkdf2-hmac-sha1$100000$"; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha1_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha1_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 64; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 64; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha1_t *pbkdf2_sha1 = (pbkdf2_sha1_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_PBKDF2_HMAC_SHA1; + + token.len[0] = strlen (SIGNATURE_NETIQ_PBKDF2_HMAC_SHA1); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + token.sep[2] = '$'; + token.len[2] = 40; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + u8 *salt_ptr = (u8 *) pbkdf2_sha1->salt_buf; + + salt->salt_len = hex_decode (salt_pos, salt_len, salt_ptr); + + salt->salt_buf[0] = pbkdf2_sha1->salt_buf[0]; + salt->salt_buf[1] = pbkdf2_sha1->salt_buf[1]; + salt->salt_buf[2] = pbkdf2_sha1->salt_buf[2]; + salt->salt_buf[3] = pbkdf2_sha1->salt_buf[3]; + salt->salt_buf[4] = salt->salt_iter; + + // hash + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + digest[4] = hex_to_u32 (hash_pos + 32); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + pbkdf2_sha1_t *pbkdf2_sha1 = (pbkdf2_sha1_t *) esalt_buf; + + // salt + + u8 salt_buf[64 + 1]; + + memset (salt_buf, 0, sizeof (salt_buf)); + + hex_encode ((u8 *) pbkdf2_sha1->salt_buf, salt->salt_len, salt_buf); + + // digest + + u32 tmp[5]; + + tmp[0] = byte_swap_32 (digest[0]); + tmp[1] = byte_swap_32 (digest[1]); + tmp[2] = byte_swap_32 (digest[2]); + tmp[3] = byte_swap_32 (digest[3]); + tmp[4] = byte_swap_32 (digest[4]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$", + SIGNATURE_NETIQ_PBKDF2_HMAC_SHA1, + salt_buf); + + out_buf += out_len; + + u32_to_hex (tmp[0], out_buf + 0); + u32_to_hex (tmp[1], out_buf + 8); + u32_to_hex (tmp[2], out_buf + 16); + u32_to_hex (tmp[3], out_buf + 24); + u32_to_hex (tmp[4], out_buf + 32); + + out_len += 40; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32060.c b/src/modules/module_32060.c new file mode 100644 index 000000000..8933dc487 --- /dev/null +++ b/src/modules/module_32060.c @@ -0,0 +1,362 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_64; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (PBKDF2WithHmacSHA256)"; +static const u64 KERN_TYPE = 10900; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_ST_BASE64 + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_ST_BASE64; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$pbkdf2-sha256$100000$MDUzMTE4NjQyNDc5NTQxMjAwMjg1OTYxNjAxNDgzNzc$bwYpAyQ2g5PqdnMj8mJ46mkwQbyztw8gEQqnhDHj48c"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct pbkdf2_sha256_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} pbkdf2_sha256_tmp_t; + +typedef struct pbkdf2_sha256 +{ + u32 salt_buf[64]; + +} pbkdf2_sha256_t; + +static const char *SIGNATURE_NETIQ_PBKDF2_HMAC_SHA256 = "$pbkdf2-sha256$100000$"; + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // NVIDIA GPU + if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha256_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha256_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 43; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 43; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha256_t *pbkdf2_sha256 = (pbkdf2_sha256_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_PBKDF2_HMAC_SHA256; + + token.len[0] = strlen (SIGNATURE_NETIQ_PBKDF2_HMAC_SHA256); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '$'; + token.len[1] = 43; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64B; + + token.sep[2] = '$'; + token.len[2] = 43; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64B; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + u8 tmp_buf[32 + 1]; + int tmp_len; + + // iter + + salt->salt_iter = 100000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (ab64_to_int, salt_pos, salt_len, tmp_buf); + + if (tmp_len != 32) return (PARSER_SALT_LENGTH); + + memcpy (pbkdf2_sha256->salt_buf, tmp_buf, tmp_len); + + salt->salt_len = tmp_len; + + salt->salt_buf[0] = pbkdf2_sha256->salt_buf[0]; + salt->salt_buf[1] = pbkdf2_sha256->salt_buf[1]; + salt->salt_buf[2] = pbkdf2_sha256->salt_buf[2]; + salt->salt_buf[3] = pbkdf2_sha256->salt_buf[3]; + salt->salt_buf[4] = salt->salt_iter; + + // hash + + const u8 *hash_pos = token.buf[2]; + const int hash_len = token.len[2]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (ab64_to_int, hash_pos, hash_len, tmp_buf); + + if (tmp_len != 32) return (PARSER_HASH_LENGTH); + + memcpy (digest, tmp_buf, tmp_len); + + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + u32 *digest = (u32 *) digest_buf; + + pbkdf2_sha256_t *pbkdf2_sha256 = (pbkdf2_sha256_t *) esalt_buf; + + // salt + + u8 salt_buf[44 + 1]; + + memset (salt_buf, 0, sizeof (salt_buf)); + + const size_t salt_len_enc = base64_encode (int_to_ab64, (const u8 *) pbkdf2_sha256->salt_buf, salt->salt_len, salt_buf); + + // remove padding + + for (size_t i = 0; i < salt_len_enc; i++) + { + if (salt_buf[i] == '=') + { + salt_buf[i] = '\0'; + } + } + + // digest + + u32 tmp[9]; + + tmp[0] = byte_swap_32 (digest[0]); + tmp[1] = byte_swap_32 (digest[1]); + tmp[2] = byte_swap_32 (digest[2]); + tmp[3] = byte_swap_32 (digest[3]); + tmp[4] = byte_swap_32 (digest[4]); + tmp[5] = byte_swap_32 (digest[5]); + tmp[6] = byte_swap_32 (digest[6]); + tmp[7] = byte_swap_32 (digest[7]); + tmp[8] = 0; + + u8 hash_buf[44 + 1]; + + memset (hash_buf, 0, sizeof (hash_buf)); + + const size_t hash_len_enc = base64_encode (int_to_ab64, (const u8 *) tmp, 32, hash_buf); + + // remove padding + + for (size_t i = 0; i < hash_len_enc; i++) + { + if (hash_buf[i] == '=') + { + hash_buf[i] = '\0'; + } + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s$%s", + SIGNATURE_NETIQ_PBKDF2_HMAC_SHA256, + salt_buf, + hash_buf); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32070.c b/src/modules/module_32070.c new file mode 100644 index 000000000..391f993c4 --- /dev/null +++ b/src/modules/module_32070.c @@ -0,0 +1,310 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_8_16; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "NetIQ SSPR (PBKDF2WithHmacSHA512)"; +static const u64 KERN_TYPE = 7100; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$pbkdf2-hmac-sha512$100000.0211258841559010919749469547425215185689838310218571790549787198.1659e40e64daf84d635a5f1ed2f5708f6735233bed471994bdc0307b3c5f77597f79bdcdd088d1e79357b383809ddfd84379006b49e14f4ff45c449071478777"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct pbkdf2_sha512_tmp +{ + u64 ipad[8]; + u64 opad[8]; + + u64 dgst[16]; + u64 out[16]; + +} pbkdf2_sha512_tmp_t; + +typedef struct pbkdf2_sha512 +{ + u32 salt_buf[64]; + +} pbkdf2_sha512_t; + +static const char *SIGNATURE_NETIQ_PBKDF2_HMAC_SHA512 = "$pbkdf2-hmac-sha512$100000."; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (pbkdf2_sha512_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (pbkdf2_sha512_tmp_t); + + return tmp_size; +} + +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + // this overrides the reductions of PW_MAX in case optimized kernel is selected + // IOW, even in optimized kernel mode it support length 256 + + const u32 pw_max = PW_MAX; + + return pw_max; +} + +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_min = 64; + + return salt_min; +} + +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_max = 64; + + return salt_max; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + pbkdf2_sha512_t *pbkdf2_sha512 = (pbkdf2_sha512_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_NETIQ_PBKDF2_HMAC_SHA512; + + token.len[0] = strlen (SIGNATURE_NETIQ_PBKDF2_HMAC_SHA512); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.sep[1] = '.'; + token.len[1] = 64; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + token.sep[2] = '.'; + token.len[2] = 128; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // iter + + salt->salt_iter = 100000 - 1; + + // salt + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + u8 *salt_ptr = (u8 *) pbkdf2_sha512->salt_buf; + + salt->salt_len = hex_decode (salt_pos, salt_len, salt_ptr); + + salt->salt_buf[0] = pbkdf2_sha512->salt_buf[0]; + salt->salt_buf[1] = pbkdf2_sha512->salt_buf[1]; + salt->salt_buf[2] = pbkdf2_sha512->salt_buf[2]; + salt->salt_buf[3] = pbkdf2_sha512->salt_buf[3]; + salt->salt_buf[4] = salt->salt_iter; + + // hash + + const u8 *hash_pos = token.buf[2]; + + digest[0] = hex_to_u64 (hash_pos + 0); + digest[1] = hex_to_u64 (hash_pos + 16); + digest[2] = hex_to_u64 (hash_pos + 32); + digest[3] = hex_to_u64 (hash_pos + 48); + digest[4] = hex_to_u64 (hash_pos + 64); + digest[5] = hex_to_u64 (hash_pos + 80); + digest[6] = hex_to_u64 (hash_pos + 96); + digest[7] = hex_to_u64 (hash_pos + 112); + + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + u64 *digest = (u64 *) digest_buf; + + pbkdf2_sha512_t *pbkdf2_sha512 = (pbkdf2_sha512_t *) esalt_buf; + + // salt + + u8 salt_buf[64 + 1]; + + memset (salt_buf, 0, sizeof (salt_buf)); + + hex_encode ((u8 *) pbkdf2_sha512->salt_buf, salt->salt_len, salt_buf); + + // digest + + u64 tmp[8]; + + tmp[0] = byte_swap_64 (digest[0]); + tmp[1] = byte_swap_64 (digest[1]); + tmp[2] = byte_swap_64 (digest[2]); + tmp[3] = byte_swap_64 (digest[3]); + tmp[4] = byte_swap_64 (digest[4]); + tmp[5] = byte_swap_64 (digest[5]); + tmp[6] = byte_swap_64 (digest[6]); + tmp[7] = byte_swap_64 (digest[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s%s.", + SIGNATURE_NETIQ_PBKDF2_HMAC_SHA512, + salt_buf); + + out_buf += out_len; + + u64_to_hex (tmp[0], out_buf + 0); + u64_to_hex (tmp[1], out_buf + 16); + u64_to_hex (tmp[2], out_buf + 32); + u64_to_hex (tmp[3], out_buf + 48); + u64_to_hex (tmp[4], out_buf + 64); + u64_to_hex (tmp[5], out_buf + 80); + u64_to_hex (tmp[6], out_buf + 96); + u64_to_hex (tmp[7], out_buf + 112); + + out_len += 128; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32100.c b/src/modules/module_32100.c new file mode 100644 index 000000000..1460bed62 --- /dev/null +++ b/src/modules/module_32100.c @@ -0,0 +1,420 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; +static const char *HASH_NAME = "Kerberos 5, etype 17, AS-REP"; +static const u64 KERN_TYPE = 32100; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$krb5asrep$17$user$EXAMPLE.COM$a419c4030e555734b06c2629$c09a1421f96eb126c757a4b87830381f142477d9a85b2beb3093dbfd44f38ddb6016a479537fb7b36e046315869fe79187217971ff6a12c1e0a2df3f68045e03814b21f756d8981f781803d65e8572823c88979581d93cf7d768f2efced16f3719b8d1004d9e73d798de255383476bced47d1982f16be77d0feb55a1f44f58bd013fa4caee58ac614caf0f1cf9101ec9623c5b8c2a1491b73f134f074790088fdb360b5ebce0d32a8145ed00a81ddf77188e150b92d8e8ddd0285d27f1514253e5546e6bba864b362bb1e6483b26d08fa4cc268bfbefe0f690039bcc524b774599df3680c1c3431d891bfa99514a877f964e"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +// Struct to store the hash structure - same fields as TGS-REP type 17 +typedef struct krb5asrep_17 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + u32 format; + +} krb5asrep_17_t; + +typedef struct krb5asrep_17_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[16]; + u32 out[16]; + +} krb5asrep_17_tmp_t; + +static const char *SIGNATURE_KRB5ASREP = "$krb5asrep$17$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (krb5asrep_17_tmp_t); + + return tmp_size; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (krb5asrep_17_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + krb5asrep_17_t *krb5asrep = (krb5asrep_17_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_KRB5ASREP; + + token.len[0] = strlen (SIGNATURE_KRB5ASREP); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + /** + * Hashcat + * format 1: $krb5asrep$18$user$realm$checksum$edata2 + * + * JtR + * format 2: $krb5asrep$18$salt$edata2$checksum + */ + + if (line_len < (int) strlen (SIGNATURE_KRB5ASREP)) return (PARSER_SALT_LENGTH); + + memset (krb5asrep, 0, sizeof (krb5asrep_17_t)); + + /** + * JtR format has the checksum at the end, so can identify it based on the + * separator ('$') being at a fixed length from the end of the line. Checksum + * is 24 characters in length, so then there should be a '$' at line_len - 25 + */ + + if (line_buf[line_len - 25] == '$') + { + // JtR format + krb5asrep->format = 2; + } + else + { + // Hashcat format + krb5asrep->format = 1; + } + + token.token_cnt = 4; + + if (krb5asrep->format == 1) + { + token.token_cnt++; + + // user + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + // realm + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 512; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + // checksum + token.sep[3] = '$'; + // hmac-sha1 stripped to 12bytes + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + // edata2 + token.sep[4] = '$'; + token.len_min[4] = 64; + token.len_max[4] = 40960; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + else + { + // salt + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + // edata2 + token.sep[2] = '$'; + token.len_min[2] = 64; + token.len_max[2] = 40960; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + // checksum + token.sep[3] = '$'; + // hmac-sha1 stripped to 12bytes + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *user_pos; + const u8 *domain_pos; + const u8 *salt_pos; + const u8 *checksum_pos; + const u8 *data_pos; + + int user_len; + int domain_len; + int data_len; + int account_info_len; + + if (krb5asrep->format == 1) + { + user_pos = token.buf[1]; + user_len = token.len[1]; + + memcpy (krb5asrep->user, user_pos, user_len); + + domain_pos = token.buf[2]; + domain_len = token.len[2]; + + memcpy (krb5asrep->domain, domain_pos, domain_len); + + checksum_pos = token.buf[3]; + + data_pos = token.buf[4]; + data_len = token.len[4]; + + account_info_len = token.len[2] + token.len[1]; + } + else + { + salt_pos = token.buf[1]; + account_info_len = token.len[1]; + + memcpy (krb5asrep->account_info, salt_pos, account_info_len); + + /** + * JtR format only has the final salt/account_info value (combination of + * user and domain), rather than separate "user" and "domain" values. Since + * user and domain won't be used for the JtR format, their values won't + * matter, so set them both to the same value as account_info. + */ + + user_pos = token.buf[1]; + user_len = token.len[1]; + + memcpy (krb5asrep->user, user_pos, user_len); + + domain_pos = token.buf[1]; + domain_len = token.len[1]; + + memcpy (krb5asrep->domain, domain_pos, domain_len); + + data_pos = token.buf[2]; + data_len = token.len[2]; + + checksum_pos = token.buf[3]; + } + + u8 *account_info_ptr = (u8 *) krb5asrep->account_info; + + // Domain must be uppercase + u8 domain[128]; + + if (krb5asrep->format == 1) + { + memcpy (domain, domain_pos, domain_len); + uppercase (domain, domain_len); + + memcpy (account_info_ptr, domain, domain_len); + memcpy (account_info_ptr + domain_len, user_pos, user_len); + } + + krb5asrep->account_info_len = account_info_len; + + // hmac-sha1 is reduced to 12 bytes + krb5asrep->checksum[0] = byte_swap_32 (hex_to_u32 (checksum_pos + 0)); + krb5asrep->checksum[1] = byte_swap_32 (hex_to_u32 (checksum_pos + 8)); + krb5asrep->checksum[2] = byte_swap_32 (hex_to_u32 (checksum_pos + 16)); + + u8 *edata_ptr = (u8 *) krb5asrep->edata2; + + for (int i = 0; i < data_len; i += 2) + { + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; + + *edata_ptr++ = hex_convert (p1) << 0 + | hex_convert (p0) << 4; + } + + krb5asrep->edata2_len = data_len / 2; + + salt->salt_buf[0] = krb5asrep->checksum[0]; + salt->salt_buf[1] = krb5asrep->checksum[1]; + salt->salt_buf[2] = krb5asrep->checksum[2]; + + salt->salt_len = 12; + + salt->salt_iter = 4096 - 1; + + digest[0] = krb5asrep->checksum[0]; + digest[1] = krb5asrep->checksum[1]; + digest[2] = krb5asrep->checksum[2]; + digest[3] = 0; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const krb5asrep_17_t *krb5asrep = (const krb5asrep_17_t *) esalt_buf; + + char data[5120 * 4 * 2] = { 0 }; + + for (u32 i = 0, j = 0; i < krb5asrep->edata2_len; i += 1, j += 2) + { + u8 *ptr_edata2 = (u8 *) krb5asrep->edata2; + + snprintf (data + j, 3, "%02x", ptr_edata2[i]); + } + + int line_len = 0; + + if (krb5asrep->format == 1) + { + line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x$%s", + SIGNATURE_KRB5ASREP, + (char *) krb5asrep->user, + (char *) krb5asrep->domain, + krb5asrep->checksum[0], + krb5asrep->checksum[1], + krb5asrep->checksum[2], + data); + } + else + { + line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x", + SIGNATURE_KRB5ASREP, + (char *) krb5asrep->account_info, + data, + krb5asrep->checksum[0], + krb5asrep->checksum[1], + krb5asrep->checksum[2]); + } + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32200.c b/src/modules/module_32200.c new file mode 100644 index 000000000..f87f9fe2a --- /dev/null +++ b/src/modules/module_32200.c @@ -0,0 +1,419 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; +static const char *HASH_NAME = "Kerberos 5, etype 18, AS-REP"; +static const u64 KERN_TYPE = 32200; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$krb5asrep$18$user$EXAMPLE.COM$aa4c494f520b27873a4de8f7$ebc9976a77f62e8ccca02d43d68bafcc66a81fcbb44a336b00ce401982f32975a5f9bcdc752643252185866685b0a30aaf50e449e392a5994e6979f23aba25f7704c90b2efa03b703c3c2f9e3617cc588ed226d0417e7742d45407878fd946d046b4a9732b9a203cb857811714b009c195b7c96b9bccb7e48832b11a4e92ecf24c49e54de8d0d5d5351445b5126db90bb7eebc7861db1e61de1175824b0a45023a6fa06c2a9d3035fdcf863bea922648e3dc28b48e39b1dec0869e7fe4de399cb52dfcf2596599da54a4bb0169c72d9496de2e137a4594e0e8a69082fc558ac9ace65d32eae5e260a65ca3f2f5871aaeee7a3b090b50f39321d120c144421e0abe7d"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +// Struct to store the hash structure - same fields as TGS-REP type 18 +typedef struct krb5asrep_18 +{ + u32 user[128]; + u32 domain[128]; + u32 account_info[512]; + u32 account_info_len; + + u32 checksum[3]; + u32 edata2[5120]; + u32 edata2_len; + u32 format; + +} krb5asrep_18_t; + +typedef struct krb5asrep_18_tmp +{ + u32 ipad[5]; + u32 opad[5]; + u32 dgst[16]; + u32 out[16]; + +} krb5asrep_18_tmp_t; + +static const char *SIGNATURE_KRB5ASREP = "$krb5asrep$18$"; + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (krb5asrep_18_tmp_t); + + return tmp_size; +} + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (krb5asrep_18_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + krb5asrep_18_t *krb5asrep = (krb5asrep_18_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_KRB5ASREP; + + token.len[0] = strlen (SIGNATURE_KRB5ASREP); + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + /** + * Hashcat + * format 1: $krb5asrep$18$user$realm$checksum$edata2 + * + * JtR + * format 2: $krb5asrep$18$salt$edata2$checksum + */ + + if (line_len < (int) strlen (SIGNATURE_KRB5ASREP)) return (PARSER_SALT_LENGTH); + + memset (krb5asrep, 0, sizeof (krb5asrep_18_t)); + + /** + * JtR format has the checksum at the end, so can identify it based on the + * separator ('$') being at a fixed length from the end of the line. Checksum + * is 24 characters in length, so then there should be a '$' at line_len - 25 + */ + + if (line_buf[line_len - 25] == '$') + { + // JtR format + krb5asrep->format = 2; + } + else + { + // Hashcat format + krb5asrep->format = 1; + } + + token.token_cnt = 4; + + if (krb5asrep->format == 1) + { + token.token_cnt++; + + // user + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + // realm + token.sep[2] = '$'; + token.len_min[2] = 1; + token.len_max[2] = 512; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + // checksum + token.sep[3] = '$'; + // hmac-sha1 stripped to 12bytes + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + // edata2 + token.sep[4] = '$'; + token.len_min[4] = 64; + token.len_max[4] = 40960; + token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + else + { + // salt + token.sep[1] = '$'; + token.len_min[1] = 1; + token.len_max[1] = 512; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + // edata2 + token.sep[2] = '$'; + token.len_min[2] = 64; + token.len_max[2] = 40960; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + // checksum + token.sep[3] = '$'; + // hmac-sha1 stripped to 12bytes + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *user_pos; + const u8 *domain_pos; + const u8 *salt_pos; + const u8 *checksum_pos; + const u8 *data_pos; + + int user_len; + int domain_len; + int data_len; + int account_info_len; + + if (krb5asrep->format == 1) + { + user_pos = token.buf[1]; + user_len = token.len[1]; + + memcpy (krb5asrep->user, user_pos, user_len); + + domain_pos = token.buf[2]; + domain_len = token.len[2]; + + memcpy (krb5asrep->domain, domain_pos, domain_len); + + checksum_pos = token.buf[3]; + + data_pos = token.buf[4]; + data_len = token.len[4]; + + account_info_len = token.len[2] + token.len[1]; + } + else + { + salt_pos = token.buf[1]; + account_info_len = token.len[1]; + + memcpy (krb5asrep->account_info, salt_pos, account_info_len); + + /** + * JtR format only has the final salt/account_info value (combination of + * user and domain), rather than separate "user" and "domain" values. Since + * user and domain won't be used for the JtR format, their values won't + * matter, so set them both to the same value as account_info. + */ + + user_pos = token.buf[1]; + user_len = token.len[1]; + + memcpy (krb5asrep->user, user_pos, user_len); + + domain_pos = token.buf[1]; + domain_len = token.len[1]; + + memcpy (krb5asrep->domain, domain_pos, domain_len); + + data_pos = token.buf[2]; + data_len = token.len[2]; + + checksum_pos = token.buf[3]; + } + + u8 *account_info_ptr = (u8 *) krb5asrep->account_info; + + // Domain must be uppercase + u8 domain[128]; + + if (krb5asrep->format == 1) + { + memcpy (domain, domain_pos, domain_len); + uppercase (domain, domain_len); + + memcpy (account_info_ptr, domain, domain_len); + memcpy (account_info_ptr + domain_len, user_pos, user_len); + } + + krb5asrep->account_info_len = account_info_len; + + // hmac-sha1 is reduced to 12 bytes + krb5asrep->checksum[0] = byte_swap_32 (hex_to_u32 (checksum_pos + 0)); + krb5asrep->checksum[1] = byte_swap_32 (hex_to_u32 (checksum_pos + 8)); + krb5asrep->checksum[2] = byte_swap_32 (hex_to_u32 (checksum_pos + 16)); + + u8 *edata_ptr = (u8 *) krb5asrep->edata2; + + for (int i = 0; i < data_len; i += 2) + { + const u8 p0 = data_pos[i + 0]; + const u8 p1 = data_pos[i + 1]; + + *edata_ptr++ = hex_convert (p1) << 0 + | hex_convert (p0) << 4; + } + + krb5asrep->edata2_len = data_len / 2; + + salt->salt_buf[0] = krb5asrep->checksum[0]; + salt->salt_buf[1] = krb5asrep->checksum[1]; + salt->salt_buf[2] = krb5asrep->checksum[2]; + + salt->salt_len = 12; + + salt->salt_iter = 4096 - 1; + + digest[0] = krb5asrep->checksum[0]; + digest[1] = krb5asrep->checksum[1]; + digest[2] = krb5asrep->checksum[2]; + digest[3] = 0; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const krb5asrep_18_t *krb5asrep = (const krb5asrep_18_t *) esalt_buf; + + char data[5120 * 4 * 2] = { 0 }; + + for (u32 i = 0, j = 0; i < krb5asrep->edata2_len; i += 1, j += 2) + { + u8 *ptr_edata2 = (u8 *) krb5asrep->edata2; + + snprintf (data + j, 3, "%02x", ptr_edata2[i]); + } + + int line_len = 0; + + if (krb5asrep->format == 1) + { + line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x$%s", + SIGNATURE_KRB5ASREP, + (char *) krb5asrep->user, + (char *) krb5asrep->domain, + krb5asrep->checksum[0], + krb5asrep->checksum[1], + krb5asrep->checksum[2], + data); + } + else + { + line_len = snprintf (line_buf, line_size, "%s%s$%s$%08x%08x%08x", + SIGNATURE_KRB5ASREP, + (char *) krb5asrep->account_info, + data, + krb5asrep->checksum[0], + krb5asrep->checksum[1], + krb5asrep->checksum[2]); + } + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32300.c b/src/modules/module_32300.c new file mode 100644 index 000000000..c97bbd007 --- /dev/null +++ b/src/modules/module_32300.c @@ -0,0 +1,301 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" +#include "emu_inc_hash_md5.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; +static const char *HASH_NAME = "Empire CMS (Admin password)"; +static const u64 KERN_TYPE = 32300; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "5962d4ada95d6493379cd9c05ce7a376:726620866134417802643053384570:6056291339665060317728572165496183"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +typedef struct md5_triple_salt +{ + u32 salt1_buf[64]; + int salt1_len; + + u32 salt2_buf[64]; + int salt2_len; + + u32 salt3_buf[64]; + int salt3_len; + +} md5_triple_salt_t; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (md5_triple_salt_t); + + return esalt_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + md5_triple_salt_t *md5_triple_salt = (md5_triple_salt_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 3; + + token.sep[0] = hashconfig->separator; + token.len[0] = 32; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.sep[1] = hashconfig->separator; + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + token.sep[2] = hashconfig->separator; + token.len_min[2] = SALT_MIN; + token.len_max[2] = SALT_MAX; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + + token.len_min[2] *= 2; + token.len_max[2] *= 2; + + token.attr[2] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } + + memset (md5_triple_salt, 0, sizeof (md5_triple_salt_t)); + + const bool parse_rc1 = generic_salt_decode (hashconfig, token.buf[1], token.len[1], (u8 *) md5_triple_salt->salt1_buf, (int *) &md5_triple_salt->salt1_len); + + if (parse_rc1 == false) return (PARSER_SALT_LENGTH); + + const bool parse_rc2 = generic_salt_decode (hashconfig, token.buf[2], token.len[2], (u8 *) md5_triple_salt->salt2_buf, (int *) &md5_triple_salt->salt2_len); + + if (parse_rc2 == false) return (PARSER_SALT_LENGTH); + + const u8 *empire_salt1 = (const u8 *) "E!m^p-i(r#e.C:M?S"; + const u32 empire_salt1_len = strlen ((char *) empire_salt1); + + const u8 *empire_salt2 = (const u8 *) "d)i.g^o-d"; + const u32 empire_salt2_len = strlen ((char *) empire_salt2); + + memcpy ((u8 *) md5_triple_salt->salt2_buf + md5_triple_salt->salt2_len, empire_salt1, empire_salt1_len); + + md5_triple_salt->salt2_len += empire_salt1_len; + + memcpy ((u8 *) md5_triple_salt->salt3_buf, empire_salt2, empire_salt2_len); + memcpy ((u8 *) md5_triple_salt->salt3_buf + empire_salt2_len, (u8 *) md5_triple_salt->salt1_buf, md5_triple_salt->salt1_len); + + md5_triple_salt->salt3_len = empire_salt2_len + md5_triple_salt->salt1_len; + + // make salt sorter happy + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, md5_triple_salt->salt1_buf, md5_triple_salt->salt1_len); + md5_update (&md5_ctx, md5_triple_salt->salt2_buf, md5_triple_salt->salt2_len); + md5_update (&md5_ctx, md5_triple_salt->salt3_buf, md5_triple_salt->salt3_len); + md5_final (&md5_ctx); + + salt->salt_buf[0] = md5_ctx.h[0]; + salt->salt_buf[1] = md5_ctx.h[1]; + salt->salt_buf[2] = md5_ctx.h[2]; + salt->salt_buf[3] = md5_ctx.h[3]; + + salt->salt_len = 16; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + const md5_triple_salt_t *md5_triple_salt = (const md5_triple_salt_t *) esalt_buf; + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u32_to_hex (tmp[0], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[1], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[2], out_buf + out_len); out_len += 8; + u32_to_hex (tmp[3], out_buf + out_len); out_len += 8; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_triple_salt->salt1_buf, (const int) md5_triple_salt->salt1_len, out_buf + out_len); + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) md5_triple_salt->salt2_buf, (const int) md5_triple_salt->salt2_len, out_buf + out_len); + + out_len -= 17; // remove empire_salt1 + + out_buf[out_len] = '\0'; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32410.c b/src/modules/module_32410.c new file mode 100644 index 000000000..9554e980b --- /dev/null +++ b/src/modules/module_32410.c @@ -0,0 +1,271 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 14; +static const u32 DGST_POS1 = 15; +static const u32 DGST_POS2 = 6; +static const u32 DGST_POS3 = 7; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "sha512(sha512($pass).$salt)"; +static const u64 KERN_TYPE = 32410; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_APPENDED_SALT + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_ST_ADD80 + | OPTS_TYPE_ST_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "25d509824028a999f4ee851b5de404bb316b78ae8e974874376484018f58520e082747a7ce9f769bcaccb5f63878356c780f602e23393f12b650a6931e4b9338:21881837027919828109608"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // Metal + if (device_param->is_metal == true) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u64 (hash_pos + 0); + digest[1] = hex_to_u64 (hash_pos + 16); + digest[2] = hex_to_u64 (hash_pos + 32); + digest[3] = hex_to_u64 (hash_pos + 48); + digest[4] = hex_to_u64 (hash_pos + 64); + digest[5] = hex_to_u64 (hash_pos + 80); + digest[6] = hex_to_u64 (hash_pos + 96); + digest[7] = hex_to_u64 (hash_pos + 112); + + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u64 *digest = (const u64 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u64 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + tmp[0] = byte_swap_64 (tmp[0]); + tmp[1] = byte_swap_64 (tmp[1]); + tmp[2] = byte_swap_64 (tmp[2]); + tmp[3] = byte_swap_64 (tmp[3]); + tmp[4] = byte_swap_64 (tmp[4]); + tmp[5] = byte_swap_64 (tmp[5]); + tmp[6] = byte_swap_64 (tmp[6]); + tmp[7] = byte_swap_64 (tmp[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u64_to_hex (tmp[0], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[1], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[2], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[3], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[4], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[5], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[6], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[7], out_buf + out_len); out_len += 16; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32420.c b/src/modules/module_32420.c new file mode 100644 index 000000000..d4187ff55 --- /dev/null +++ b/src/modules/module_32420.c @@ -0,0 +1,271 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 14; +static const u32 DGST_POS1 = 15; +static const u32 DGST_POS2 = 6; +static const u32 DGST_POS3 = 7; +static const u32 DGST_SIZE = DGST_SIZE_8_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "sha512(sha512_bin($pass).$salt)"; +static const u64 KERN_TYPE = 32420; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_APPENDED_SALT + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_ST_ADD80 + | OPTS_TYPE_ST_ADDBITS15; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "c1bade2bd4ebc8db841ac6ab3e0a5035a29619e5b1a6135782b77da5d7cfaccee096f3ddb9ee23b9866378cfc2fb19f2c013fed1b7e1fffd18340a4f39238412:789"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // Metal + if (device_param->is_metal == true) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; + } + + // HIP + if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD_USE_HIP) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u64 *digest = (u64 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u64 (hash_pos + 0); + digest[1] = hex_to_u64 (hash_pos + 16); + digest[2] = hex_to_u64 (hash_pos + 32); + digest[3] = hex_to_u64 (hash_pos + 48); + digest[4] = hex_to_u64 (hash_pos + 64); + digest[5] = hex_to_u64 (hash_pos + 80); + digest[6] = hex_to_u64 (hash_pos + 96); + digest[7] = hex_to_u64 (hash_pos + 112); + + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u64 *digest = (const u64 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u64 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + tmp[0] = byte_swap_64 (tmp[0]); + tmp[1] = byte_swap_64 (tmp[1]); + tmp[2] = byte_swap_64 (tmp[2]); + tmp[3] = byte_swap_64 (tmp[3]); + tmp[4] = byte_swap_64 (tmp[4]); + tmp[5] = byte_swap_64 (tmp[5]); + tmp[6] = byte_swap_64 (tmp[6]); + tmp[7] = byte_swap_64 (tmp[7]); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = 0; + + u64_to_hex (tmp[0], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[1], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[2], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[3], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[4], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[5], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[6], out_buf + out_len); out_len += 16; + u64_to_hex (tmp[7], out_buf + out_len); out_len += 16; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_32500.c b/src/modules/module_32500.c new file mode 100644 index 000000000..f99791b28 --- /dev/null +++ b/src/modules/module_32500.c @@ -0,0 +1,277 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_CRYPTOCURRENCY_WALLET; +static const char *HASH_NAME = "Dogechain.info Wallet"; +static const u64 KERN_TYPE = 32500; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$dogechain$0*5000*EEmAkgiMlVrToRhu2suq91R5Frf+VQCvNzv9lj6OwRWIf/3IM31wqhJM7gGQpinXH9kqHkuQ2DMZxspgA7QFAddsUWvZxGdNAkaeKy90EAsTLIuDQnH3plfBQfmL6j5NPaH7Nr7kF1PdvM0pbUw6XHySBYkD/rPHNM6n58NRK4xfO4VVMykeX3+m2LaVyv5s269r/op38svRPT0YFGpRcanY6/U1BeSrvG2IXii1BKXXAcVEN4GFmyEQRWKI0uZE+3M0atf7UEPD4K9tmEKosqdsF4MFLiBtfI4eq0+926ijoezDmUPvHIiyQZ9CH2jZ*6jOgqW/GxL9He1afQiINIg=="; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +static const char *SIGNATURE_DOGECHAIN = "$dogechain$0"; + +typedef struct payload +{ + u32 pl_buf[64]; + u32 pl_len; + +} payload_t; + +typedef struct doge_tmp +{ + u32 ipad[8]; + u32 opad[8]; + + u32 dgst[32]; + u32 out[32]; + +} doge_tmp_t; + +u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 esalt_size = (const u64) sizeof (payload_t); + + return esalt_size; +} + +u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u64 tmp_size = (const u64) sizeof (doge_tmp_t); + + return tmp_size; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + payload_t *payload = (payload_t *) esalt_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 4; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_DOGECHAIN; + + // sig + token.sep[0] = '*'; + token.len_min[0] = 12; + token.len_max[0] = 12; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH //VERIFY NOT FIXED + | TOKEN_ATTR_VERIFY_SIGNATURE; + + // iter + token.sep[1] = '*'; + token.len_min[1] = 1; + token.len_max[1] = 10; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_DIGIT; + + // payload + token.sep[2] = '*'; + token.len_min[2] = 320; + token.len_max[2] = 320; + token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; //verify is b64 + + // salt + token.sep[3] = '*'; + token.len_min[3] = 24; + token.len_max[3] = 24; + token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; //verify is b64 + + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + // Our parsing + + // esalt for payload + + const u8 *data_pos = token.buf[2]; + const int data_len = token.len[2]; + + u8 tmp_buf[256] = { 0 }; + + int tmp_len = base64_decode (base64_to_int, (const u8 *) data_pos, data_len, tmp_buf); + + memcpy (payload->pl_buf, tmp_buf, tmp_len); + + payload->pl_len = tmp_len; + + // salt + + const u8 *salt_pos = token.buf[3]; + const int salt_len = token.len[3]; + + memset (tmp_buf, 0, sizeof (tmp_buf)); + + tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); + + memcpy (salt->salt_buf, tmp_buf, tmp_len); + + salt->salt_len = tmp_len; + + // iter + + const u8 *iter_pos = token.buf[1]; + + salt->salt_iter = hc_strtoul ((const char *) iter_pos, NULL, 10) - 1; + + // digest + + digest[0] = 0; + digest[1] = 0; + digest[2] = 0; + digest[3] = 0; + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + //const u32 *digest = (const u32 *) digest_buf; + + const payload_t *payload = (const payload_t *) esalt_buf; + + // payload + + u8 payload_base64[512]; + + base64_encode (int_to_base64, (const u8 *) payload->pl_buf, payload->pl_len, payload_base64); + + // salt + + u8 salt_base64[32]; + + base64_encode (int_to_base64, (const u8 *) salt->salt_buf, salt->salt_len, salt_base64); + + u8 *out_buf = (u8 *) line_buf; + + int out_len = snprintf ((char *) out_buf, line_size, "%s*%u*%s*%s", + SIGNATURE_DOGECHAIN, + salt->salt_iter + 1, + payload_base64, + salt_base64); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = module_esalt_size; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; + +} diff --git a/src/modules/module_32600.c b/src/modules/module_32600.c new file mode 100644 index 000000000..c8be26f3a --- /dev/null +++ b/src/modules/module_32600.c @@ -0,0 +1,274 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_16; +static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; +static const char *HASH_NAME = "CubeCart (whirlpool($salt.$pass.$salt))"; +static const u64 KERN_TYPE = 32600; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE + | OPTS_TYPE_PT_GENERATE_BE + | OPTS_TYPE_PT_ADD80; +static const u32 SALT_TYPE = SALT_TYPE_GENERIC; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "a2c0342a2617026fbaeed01130c826cc3f58242799894b3ecc1abfa811ede03fd712efd14a886af6fa74045502f22c9feb1c45a291cf2d7bbe9bb94c388b6403:deadbeef"; + +u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; } +u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; } +u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; } +u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; } +u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; } +u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; } +u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; } +const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; } +u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; } +u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; } +u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; } +u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; } +const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; } +const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; } + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + + token.token_cnt = 2; + + token.sep[0] = hashconfig->separator; + token.len[0] = 128; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + token.len_min[1] = SALT_MIN; + token.len_max[1] = SALT_MAX; + token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH; + + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + token.len_min[1] *= 2; + token.len_max[1] *= 2; + + token.attr[1] |= TOKEN_ATTR_VERIFY_HEX; + } + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[ 0] = hex_to_u32 (hash_pos + 0); + digest[ 1] = hex_to_u32 (hash_pos + 8); + digest[ 2] = hex_to_u32 (hash_pos + 16); + digest[ 3] = hex_to_u32 (hash_pos + 24); + digest[ 4] = hex_to_u32 (hash_pos + 32); + digest[ 5] = hex_to_u32 (hash_pos + 40); + digest[ 6] = hex_to_u32 (hash_pos + 48); + digest[ 7] = hex_to_u32 (hash_pos + 56); + digest[ 8] = hex_to_u32 (hash_pos + 64); + digest[ 9] = hex_to_u32 (hash_pos + 72); + digest[10] = hex_to_u32 (hash_pos + 80); + digest[11] = hex_to_u32 (hash_pos + 88); + digest[12] = hex_to_u32 (hash_pos + 96); + digest[13] = hex_to_u32 (hash_pos + 104); + digest[14] = hex_to_u32 (hash_pos + 112); + digest[15] = hex_to_u32 (hash_pos + 120); + + digest[ 0] = byte_swap_32 (digest[ 0]); + digest[ 1] = byte_swap_32 (digest[ 1]); + digest[ 2] = byte_swap_32 (digest[ 2]); + digest[ 3] = byte_swap_32 (digest[ 3]); + digest[ 4] = byte_swap_32 (digest[ 4]); + digest[ 5] = byte_swap_32 (digest[ 5]); + digest[ 6] = byte_swap_32 (digest[ 6]); + digest[ 7] = byte_swap_32 (digest[ 7]); + digest[ 8] = byte_swap_32 (digest[ 8]); + digest[ 9] = byte_swap_32 (digest[ 9]); + digest[10] = byte_swap_32 (digest[10]); + digest[11] = byte_swap_32 (digest[11]); + digest[12] = byte_swap_32 (digest[12]); + digest[13] = byte_swap_32 (digest[13]); + digest[14] = byte_swap_32 (digest[14]); + digest[15] = byte_swap_32 (digest[15]); + + const u8 *salt_pos = token.buf[1]; + const int salt_len = token.len[1]; + + const bool parse_rc = generic_salt_decode (hashconfig, salt_pos, salt_len, (u8 *) salt->salt_buf, (int *) &salt->salt_len); + + if (parse_rc == false) return (PARSER_SALT_LENGTH); + + return (PARSER_OK); +} + +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[16]; + + tmp[ 0] = digest[ 0]; + tmp[ 1] = digest[ 1]; + tmp[ 2] = digest[ 2]; + tmp[ 3] = digest[ 3]; + tmp[ 4] = digest[ 4]; + tmp[ 5] = digest[ 5]; + tmp[ 6] = digest[ 6]; + tmp[ 7] = digest[ 7]; + tmp[ 8] = digest[ 8]; + tmp[ 9] = digest[ 9]; + tmp[10] = digest[10]; + tmp[11] = digest[11]; + tmp[12] = digest[12]; + tmp[13] = digest[13]; + tmp[14] = digest[14]; + tmp[15] = digest[15]; + + tmp[ 0] = byte_swap_32 (tmp[ 0]); + tmp[ 1] = byte_swap_32 (tmp[ 1]); + tmp[ 2] = byte_swap_32 (tmp[ 2]); + tmp[ 3] = byte_swap_32 (tmp[ 3]); + tmp[ 4] = byte_swap_32 (tmp[ 4]); + tmp[ 5] = byte_swap_32 (tmp[ 5]); + tmp[ 6] = byte_swap_32 (tmp[ 6]); + tmp[ 7] = byte_swap_32 (tmp[ 7]); + tmp[ 8] = byte_swap_32 (tmp[ 8]); + tmp[ 9] = byte_swap_32 (tmp[ 9]); + tmp[10] = byte_swap_32 (tmp[10]); + tmp[11] = byte_swap_32 (tmp[11]); + tmp[12] = byte_swap_32 (tmp[12]); + tmp[13] = byte_swap_32 (tmp[13]); + tmp[14] = byte_swap_32 (tmp[14]); + tmp[15] = byte_swap_32 (tmp[15]); + + u8 *out_buf = (u8 *) line_buf; + + u32_to_hex (tmp[ 0], out_buf + 0); + u32_to_hex (tmp[ 1], out_buf + 8); + u32_to_hex (tmp[ 2], out_buf + 16); + u32_to_hex (tmp[ 3], out_buf + 24); + u32_to_hex (tmp[ 4], out_buf + 32); + u32_to_hex (tmp[ 5], out_buf + 40); + u32_to_hex (tmp[ 6], out_buf + 48); + u32_to_hex (tmp[ 7], out_buf + 56); + u32_to_hex (tmp[ 8], out_buf + 64); + u32_to_hex (tmp[ 9], out_buf + 72); + u32_to_hex (tmp[10], out_buf + 80); + u32_to_hex (tmp[11], out_buf + 88); + u32_to_hex (tmp[12], out_buf + 96); + u32_to_hex (tmp[13], out_buf + 104); + u32_to_hex (tmp[14], out_buf + 112); + u32_to_hex (tmp[15], out_buf + 120); + + int out_len = 128; + + out_buf[out_len] = hashconfig->separator; + + out_len += 1; + + out_len += generic_salt_encode (hashconfig, (const u8 *) salt->salt_buf, (const int) salt->salt_len, out_buf + out_len); + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_99999.c b/src/modules/module_99999.c index f09d550d7..6189d4aea 100644 --- a/src/modules/module_99999.c +++ b/src/modules/module_99999.c @@ -65,6 +65,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 1; token.len_min[0] = 1; diff --git a/src/mpsp.c b/src/mpsp.c index 05c7c3eb3..ba5511616 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -1401,12 +1401,13 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->backend_info > 0) return 0; if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION) return 0; if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) return 0; diff --git a/src/potfile.c b/src/potfile.c index 3945d3c55..2b2006d90 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -110,17 +110,18 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) potfile_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; if (user_options->potfile_disable == true) return 0; - if (user_options->backend_info > 0) return 0; if (hashconfig->potfile_disable == true) return 0; @@ -396,7 +397,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) hash_t *hashes_buf = hashes->hashes_buf; u32 hashes_cnt = hashes->hashes_cnt; - // no solution for these special hash types (for instane because they use hashfile in output etc) + // no solution for these special hash types (for instance because they use hashfile in output etc) hash_t hash_buf; diff --git a/src/restore.c b/src/restore.c index 8f0547313..0b6906fff 100644 --- a/src/restore.c +++ b/src/restore.c @@ -302,6 +302,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; @@ -310,11 +313,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; if (user_options->restore_disable == true) return 0; - if (user_options->backend_info > 0) return 0; if (argc == 0) return 0; if (argv == NULL) return 0; diff --git a/src/selftest.c b/src/selftest.c index 977c38682..9c80374af 100644 --- a/src/selftest.c +++ b/src/selftest.c @@ -624,7 +624,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param salt_t *salt_buf = &hashes->st_salts_buf[salt_pos]; - const u32 salt_repeats = hashes->salts_buf[salt_pos].salt_repeats; + const u32 salt_repeats = salt_buf->salt_repeats; for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++) { diff --git a/src/shared.c b/src/shared.c index 7110c91ac..e301523da 100644 --- a/src/shared.c +++ b/src/shared.c @@ -80,7 +80,9 @@ static const char *const OPTI_STR_BRUTE_FORCE = "Brute-Force"; static const char *const OPTI_STR_RAW_HASH = "Raw-Hash"; static const char *const OPTI_STR_REGISTER_LIMIT = "Register-Limit"; static const char *const OPTI_STR_SLOW_HASH_SIMD_INIT = "Slow-Hash-SIMD-INIT"; +static const char *const OPTI_STR_SLOW_HASH_SIMD_INIT2 = "Slow-Hash-SIMD-INIT-2"; static const char *const OPTI_STR_SLOW_HASH_SIMD_LOOP = "Slow-Hash-SIMD-LOOP"; +static const char *const OPTI_STR_SLOW_HASH_SIMD_LOOP2 = "Slow-Hash-SIMD-LOOP-2"; static const char *const OPTI_STR_SLOW_HASH_SIMD_COMP = "Slow-Hash-SIMD-COMP"; static const char *const OPTI_STR_USES_BITS_8 = "Uses-8-Bit"; static const char *const OPTI_STR_USES_BITS_16 = "Uses-16-Bit"; @@ -620,11 +622,11 @@ u32 get_random_num (const u32 min, const u32 max) #if defined (_WIN) - return (((u32) rand () % (max - min)) + min); + return (((u32) rand () % (max - min + 1)) + min); #else - return (((u32) random () % (max - min)) + min); + return (((u32) random () % (max - min + 1)) + min); #endif } @@ -1014,27 +1016,29 @@ const char *stroptitype (const u32 opti_type) { switch (opti_type) { - case OPTI_TYPE_OPTIMIZED_KERNEL: return OPTI_STR_OPTIMIZED_KERNEL; - case OPTI_TYPE_ZERO_BYTE: return OPTI_STR_ZERO_BYTE; - case OPTI_TYPE_PRECOMPUTE_INIT: return OPTI_STR_PRECOMPUTE_INIT; - case OPTI_TYPE_MEET_IN_MIDDLE: return OPTI_STR_MEET_IN_MIDDLE; - case OPTI_TYPE_EARLY_SKIP: return OPTI_STR_EARLY_SKIP; - case OPTI_TYPE_NOT_SALTED: return OPTI_STR_NOT_SALTED; - case OPTI_TYPE_NOT_ITERATED: return OPTI_STR_NOT_ITERATED; - case OPTI_TYPE_PREPENDED_SALT: return OPTI_STR_PREPENDED_SALT; - case OPTI_TYPE_APPENDED_SALT: return OPTI_STR_APPENDED_SALT; - case OPTI_TYPE_SINGLE_HASH: return OPTI_STR_SINGLE_HASH; - case OPTI_TYPE_SINGLE_SALT: return OPTI_STR_SINGLE_SALT; - case OPTI_TYPE_BRUTE_FORCE: return OPTI_STR_BRUTE_FORCE; - case OPTI_TYPE_RAW_HASH: return OPTI_STR_RAW_HASH; - case OPTI_TYPE_REGISTER_LIMIT: return OPTI_STR_REGISTER_LIMIT; - case OPTI_TYPE_SLOW_HASH_SIMD_INIT: return OPTI_STR_SLOW_HASH_SIMD_INIT; - case OPTI_TYPE_SLOW_HASH_SIMD_LOOP: return OPTI_STR_SLOW_HASH_SIMD_LOOP; - case OPTI_TYPE_SLOW_HASH_SIMD_COMP: return OPTI_STR_SLOW_HASH_SIMD_COMP; - case OPTI_TYPE_USES_BITS_8: return OPTI_STR_USES_BITS_8; - case OPTI_TYPE_USES_BITS_16: return OPTI_STR_USES_BITS_16; - case OPTI_TYPE_USES_BITS_32: return OPTI_STR_USES_BITS_32; - case OPTI_TYPE_USES_BITS_64: return OPTI_STR_USES_BITS_64; + case OPTI_TYPE_OPTIMIZED_KERNEL: return OPTI_STR_OPTIMIZED_KERNEL; + case OPTI_TYPE_ZERO_BYTE: return OPTI_STR_ZERO_BYTE; + case OPTI_TYPE_PRECOMPUTE_INIT: return OPTI_STR_PRECOMPUTE_INIT; + case OPTI_TYPE_MEET_IN_MIDDLE: return OPTI_STR_MEET_IN_MIDDLE; + case OPTI_TYPE_EARLY_SKIP: return OPTI_STR_EARLY_SKIP; + case OPTI_TYPE_NOT_SALTED: return OPTI_STR_NOT_SALTED; + case OPTI_TYPE_NOT_ITERATED: return OPTI_STR_NOT_ITERATED; + case OPTI_TYPE_PREPENDED_SALT: return OPTI_STR_PREPENDED_SALT; + case OPTI_TYPE_APPENDED_SALT: return OPTI_STR_APPENDED_SALT; + case OPTI_TYPE_SINGLE_HASH: return OPTI_STR_SINGLE_HASH; + case OPTI_TYPE_SINGLE_SALT: return OPTI_STR_SINGLE_SALT; + case OPTI_TYPE_BRUTE_FORCE: return OPTI_STR_BRUTE_FORCE; + case OPTI_TYPE_RAW_HASH: return OPTI_STR_RAW_HASH; + case OPTI_TYPE_REGISTER_LIMIT: return OPTI_STR_REGISTER_LIMIT; + case OPTI_TYPE_SLOW_HASH_SIMD_INIT: return OPTI_STR_SLOW_HASH_SIMD_INIT; + case OPTI_TYPE_SLOW_HASH_SIMD_INIT2: return OPTI_STR_SLOW_HASH_SIMD_INIT2; + case OPTI_TYPE_SLOW_HASH_SIMD_LOOP: return OPTI_STR_SLOW_HASH_SIMD_LOOP; + case OPTI_TYPE_SLOW_HASH_SIMD_LOOP2: return OPTI_STR_SLOW_HASH_SIMD_LOOP2; + case OPTI_TYPE_SLOW_HASH_SIMD_COMP: return OPTI_STR_SLOW_HASH_SIMD_COMP; + case OPTI_TYPE_USES_BITS_8: return OPTI_STR_USES_BITS_8; + case OPTI_TYPE_USES_BITS_16: return OPTI_STR_USES_BITS_16; + case OPTI_TYPE_USES_BITS_32: return OPTI_STR_USES_BITS_32; + case OPTI_TYPE_USES_BITS_64: return OPTI_STR_USES_BITS_64; } return NULL; @@ -1149,10 +1153,6 @@ int input_tokenizer (const u8 *input_buf, const int input_len, hc_token_t *token int len = token->len[token_idx]; if (len_left < len) return (PARSER_TOKEN_LENGTH); - - token->buf[token_idx + 1] = token->buf[token_idx] + len; - - len_left -= len; } else { @@ -1171,7 +1171,10 @@ int input_tokenizer (const u8 *input_buf, const int input_len, hc_token_t *token len_left -= len + 1; // +1 = separator } } + } + if (token->sep[token_idx] != 0x00) + { const u8 *next_pos = NULL; if (token->attr[token_idx] & TOKEN_ATTR_SEPARATOR_FARTHEST) @@ -1187,12 +1190,32 @@ int input_tokenizer (const u8 *input_buf, const int input_len, hc_token_t *token const int len = next_pos - token->buf[token_idx]; + if (token->attr[token_idx] & TOKEN_ATTR_FIXED_LENGTH) + { + if (len != token->len[token_idx]) return (PARSER_TOKEN_LENGTH); + } + token->len[token_idx] = len; token->buf[token_idx + 1] = next_pos + 1; // +1 = separator len_left -= len + 1; // +1 = separator } + else + { + const int len = token->len[token_idx]; + + token->buf[token_idx + 1] = token->buf[token_idx] + len; + + len_left -= len; + + if (token->sep[token_idx] != 0) + { + token->buf[token_idx + 1]++; // +1 = separator + + len_left--; // -1 = separator + } + } } if (token->attr[token_idx] & TOKEN_ATTR_FIXED_LENGTH) diff --git a/src/straight.c b/src/straight.c index 2cf5ff714..36d3a8eb8 100644 --- a/src/straight.c +++ b/src/straight.c @@ -262,12 +262,13 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) straight_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->hash_info == true) return 0; - if (user_options->backend_info > 0) return 0; if (user_options->attack_mode == ATTACK_MODE_BF) return 0; diff --git a/src/terminal.c b/src/terminal.c index 2de912e0a..0898ad47b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -35,7 +35,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) if (user_options->left == true) return; if (user_options->identify == true) return; - if (user_options->usage == true) + if (user_options->usage > 0) { event_log_info (hashcat_ctx, "%s (%s) starting in help mode", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); @@ -490,7 +490,7 @@ int tty_fix () } #endif -#if defined (__APPLE__) || defined (__FreeBSD__) +#if defined (__APPLE__) static struct termios savemodes; static int havemodes = 0; @@ -634,6 +634,37 @@ void compress_terminal_line_length (char *out_buf, const size_t keep_from_beginn *ptr1 = 0; } +void json_encode (char *text, char *escaped) +{ + /* + * Based on https://www.freeformatter.com/json-escape.html, below these 7 different chars + * are getting escaped before being printed. + */ + + size_t len = strlen (text); + unsigned long i, j; + + for (i = 0, j = 0; i < len; i++, j++) + { + char c = text[i]; + + switch (c) + { + case '\b': c = 'b'; escaped[j] = '\\'; j++; break; + case '\t': c = 't'; escaped[j] = '\\'; j++; break; + case '\n': c = 'n'; escaped[j] = '\\'; j++; break; + case '\f': c = 'f'; escaped[j] = '\\'; j++; break; + case '\r': c = 'r'; escaped[j] = '\\'; j++; break; + case '\\': c = '\\'; escaped[j] = '\\'; j++; break; + case '"': c = '"'; escaped[j] = '\\'; j++; break; + } + + escaped[j] = c; + } + + escaped[j] = 0; +} + void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_options_extra) { if (hashconfig_init (hashcat_ctx) == 0) @@ -692,14 +723,20 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us { printf ("\"example_hash_format\": \"%s\", ", "hex-encoded (binary file only)"); } - printf ("\"example_hash\": \"%s\", ", hashconfig->st_hash); } else { printf ("\"example_hash_format\": \"%s\", ", "plain"); - printf ("\"example_hash\": \"%s\", ", hashconfig->st_hash); } + char *example_hash_json_encoded = (char *) hcmalloc (strlen (hashconfig->st_hash) * 2); + + json_encode ((char *)hashconfig->st_hash, example_hash_json_encoded); + + printf ("\"example_hash\": \"%s\", ", example_hash_json_encoded); + + hcfree (example_hash_json_encoded); + if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options_extra->separator, false)) { char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); @@ -1760,37 +1797,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_status); } -void json_encode (char *text, char *escaped) -{ - /* - * Based on https://www.freeformatter.com/json-escape.html, below these 7 different chars - * are getting escaped before being printed. - */ - - size_t len = strlen (text); - unsigned long i, j; - - for (i = 0, j = 0; i < len; i++, j++) - { - char c = text[i]; - - switch (c) - { - case '\b': c = 'b'; escaped[j] = '\\'; j++; break; - case '\t': c = 't'; escaped[j] = '\\'; j++; break; - case '\n': c = 'n'; escaped[j] = '\\'; j++; break; - case '\f': c = 'f'; escaped[j] = '\\'; j++; break; - case '\r': c = 'r'; escaped[j] = '\\'; j++; break; - case '\\': c = '\\'; escaped[j] = '\\'; j++; break; - case '"': c = '"'; escaped[j] = '\\'; j++; break; - } - - escaped[j] = c; - } - - escaped[j] = 0; -} - void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -1893,14 +1899,18 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"rejected\": %" PRIu64 ",", hashcat_status->progress_rejected); printf (" \"devices\": ["); - for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + for (int device_id = 0, first_dev = 1; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; if (device_info->skipped_warning_dev == true) continue; - if (device_id != 0) + if (first_dev) + { + first_dev = 0; + } + else { printf (","); } diff --git a/src/tuningdb.c b/src/tuningdb.c index 4a92db0a4..2f983b31e 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -54,14 +54,15 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info == true) return 0; if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; tuning_db->enabled = true; diff --git a/src/usage.c b/src/usage.c index 7a6649c4e..03d676741 100644 --- a/src/usage.c +++ b/src/usage.c @@ -29,7 +29,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -m, --hash-type | Num | Hash-type, references below (otherwise autodetect) | -m 1000", " -a, --attack-mode | Num | Attack-mode, see references below | -a 3", " -V, --version | | Print version |", - " -h, --help | | Print help |", + " -h, --help | | Print help. Use -hh to show all supported hash-modes | -h or -hh", " --quiet | | Suppress output |", " --hex-charset | | Assume charset is given in hex |", " --hex-salt | | Assume salt is given in hex |", @@ -49,6 +49,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --markov-classic | | Enables classic markov-chains, no per-position |", " --markov-inverse | | Enables inverse markov-chains, no per-position |", " -t, --markov-threshold | Num | Threshold X when to stop accepting new markov-chains | -t 50", + " --metal-compiler-runtime | Num | Abort Metal kernel build after X seconds of runtime | --metal-compiler-runtime=180", " --runtime | Num | Abort session after X seconds of runtime | --runtime=10", " --session | Str | Define specific session name | --session=mysession", " --restore | | Restore session from --session |", @@ -97,8 +98,9 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --backend-ignore-hip | | Do not try to open HIP interface on startup |", " --backend-ignore-metal | | Do not try to open Metal interface on startup |", " --backend-ignore-opencl | | Do not try to open OpenCL interface on startup |", - " -I, --backend-info | | Show system/evironment/backend API info | -I or -II", + " -I, --backend-info | | Show system/environment/backend API info | -I or -II", " -d, --backend-devices | Str | Backend devices to use, separated with commas | -d 1", + " -Y, --backend-devices-virtual | Num | Spawn X virtual instances for each real device | -Y 8", " -D, --opencl-device-types | Str | OpenCL device-types to use, separated with commas | -D 1", " -O, --optimized-kernel-enable | | Enable optimized kernels (limits password length) |", " -M, --multiply-accel-disable | | Disable multiply kernel-accel with processor count |", @@ -106,7 +108,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -n, --kernel-accel | Num | Manual workload tuning, set outerloop step size to X | -n 64", " -u, --kernel-loops | Num | Manual workload tuning, set innerloop step size to X | -u 256", " -T, --kernel-threads | Num | Manual workload tuning, set thread count to X | -T 64", - " --backend-vector-width | Num | Manually override backend vector-width to X | --backend-vector=4", + " --backend-vector-width | Num | Manually override backend vector-width to X | --backend-vector-width=4", " --spin-damp | Num | Use CPU for device synchronization, in percent | --spin-damp=10", " --hwmon-disable | | Disable temperature and fanspeed reads and triggers |", " --hwmon-temp-abort | Num | Abort if temperature reaches X degrees Celsius | --hwmon-temp-abort=100", @@ -143,13 +145,28 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --brain-session-whitelist | Hex | Allow given sessions only, separated with commas | --brain-session-whitelist=0x2ae611db", #endif "", - "- [ Hash modes ] -", + NULL +}; + +static const char *const USAGE_BIG_HEADER_HASHMODES[] = +{ + "- [ Hash Modes ] -", "", " # | Name | Category", " ======+============================================================+======================================", NULL }; +static const char *const USAGE_BIG_NO_HASHMODES[] = +{ + "- [ Hash Modes ] -", + "", + " please use -hh to show all supported Hash Modes" + "", + "", + NULL +}; + static const char *const USAGE_BIG_POST_HASHMODES[] = { #ifdef WITH_BRAIN @@ -304,37 +321,42 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; user_options_t *user_options = hashcat_ctx->user_options; - char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY); - - usage_sort_t *usage_sort_buf = (usage_sort_t *) hccalloc (MODULE_HASH_MODES_MAXIMUM, sizeof (usage_sort_t)); - int usage_sort_cnt = 0; - for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++) + usage_sort_t *usage_sort_buf = NULL; + + if (user_options->usage > 1) { - user_options->hash_mode = i; + char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY); - module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY); + usage_sort_buf = (usage_sort_t *) hccalloc (MODULE_HASH_MODES_MAXIMUM, sizeof (usage_sort_t)); - if (hc_path_exist (modulefile) == false) continue; + for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++) + { + user_options->hash_mode = i; - const int rc = hashconfig_init (hashcat_ctx); + module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY); - if (rc == 0) - { - usage_sort_buf[usage_sort_cnt].hash_mode = hashconfig->hash_mode; - usage_sort_buf[usage_sort_cnt].hash_name = hcstrdup (hashconfig->hash_name); - usage_sort_buf[usage_sort_cnt].hash_category = hashconfig->hash_category; + if (hc_path_exist (modulefile) == false) continue; - usage_sort_cnt++; - } + const int rc = hashconfig_init (hashcat_ctx); - hashconfig_destroy (hashcat_ctx); - } + if (rc == 0) + { + usage_sort_buf[usage_sort_cnt].hash_mode = hashconfig->hash_mode; + usage_sort_buf[usage_sort_cnt].hash_name = hcstrdup (hashconfig->hash_name); + usage_sort_buf[usage_sort_cnt].hash_category = hashconfig->hash_category; + + usage_sort_cnt++; + } - hcfree (modulefile); + hashconfig_destroy (hashcat_ctx); + } + + hcfree (modulefile); - qsort (usage_sort_buf, usage_sort_cnt, sizeof (usage_sort_t), sort_by_usage); + qsort (usage_sort_buf, usage_sort_cnt, sizeof (usage_sort_t), sort_by_usage); + } for (int i = 0; USAGE_BIG_PRE_HASHMODES[i] != NULL; i++) { @@ -345,21 +367,40 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) //hc_fwrite (EOL, strlen (EOL), 1, stdout); - for (int i = 0; i < usage_sort_cnt; i++) + if (user_options->usage > 1) { - printf ("%7u | %-58s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + for (int i = 0; USAGE_BIG_HEADER_HASHMODES[i] != NULL; i++) + { + printf ("%s", USAGE_BIG_HEADER_HASHMODES[i]); + + fwrite (EOL, strlen (EOL), 1, stdout); + } + + for (int i = 0; i < usage_sort_cnt; i++) + { + printf ("%7u | %-58s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + + fwrite (EOL, strlen (EOL), 1, stdout); + } fwrite (EOL, strlen (EOL), 1, stdout); - } - fwrite (EOL, strlen (EOL), 1, stdout); + for (int i = 0; i < usage_sort_cnt; i++) + { + hcfree (usage_sort_buf[i].hash_name); + } - for (int i = 0; i < usage_sort_cnt; i++) - { - hcfree (usage_sort_buf[i].hash_name); + hcfree (usage_sort_buf); } + else + { + for (int i = 0; USAGE_BIG_NO_HASHMODES[i] != NULL; i++) + { + printf ("%s", USAGE_BIG_NO_HASHMODES[i]); - hcfree (usage_sort_buf); + fwrite (EOL, strlen (EOL), 1, stdout); + } + } for (int i = 0; USAGE_BIG_POST_HASHMODES[i] != NULL; i++) { diff --git a/src/user_options.c b/src/user_options.c index 4dd2dce39..a510c1d69 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -21,9 +21,9 @@ #endif #ifdef WITH_BRAIN -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSz"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:z"; #else -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMS"; +static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:"; #endif static char *const SEPARATOR = ":"; @@ -33,6 +33,7 @@ static const struct option long_options[] = {"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE}, {"attack-mode", required_argument, NULL, IDX_ATTACK_MODE}, {"backend-devices", required_argument, NULL, IDX_BACKEND_DEVICES}, + {"backend-devices-virtual", required_argument, NULL, IDX_BACKEND_DEVICES_VIRTUAL}, {"backend-ignore-cuda", no_argument, NULL, IDX_BACKEND_IGNORE_CUDA}, {"backend-ignore-hip", no_argument, NULL, IDX_BACKEND_IGNORE_HIP}, #if defined (__APPLE__) @@ -93,6 +94,7 @@ static const struct option long_options[] = {"markov-hcstat2", required_argument, NULL, IDX_MARKOV_HCSTAT2}, {"markov-inverse", no_argument, NULL, IDX_MARKOV_INVERSE}, {"markov-threshold", required_argument, NULL, IDX_MARKOV_THRESHOLD}, + {"metal-compiler-runtime", required_argument, NULL, IDX_METAL_COMPILER_RUNTIME}, {"nonce-error-corrections", required_argument, NULL, IDX_NONCE_ERROR_CORRECTIONS}, {"opencl-device-types", required_argument, NULL, IDX_OPENCL_DEVICE_TYPES}, {"optimized-kernel-enable", no_argument, NULL, IDX_OPTIMIZED_KERNEL_ENABLE}, @@ -171,6 +173,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->attack_mode = ATTACK_MODE; user_options->autodetect = AUTODETECT; user_options->backend_devices = NULL; + user_options->backend_devices_virtual = BACKEND_DEVICES_VIRTUAL; user_options->backend_ignore_cuda = BACKEND_IGNORE_CUDA; user_options->backend_ignore_hip = BACKEND_IGNORE_HIP; #if defined (__APPLE__) @@ -234,6 +237,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->markov_hcstat2 = NULL; user_options->markov_inverse = MARKOV_INVERSE; user_options->markov_threshold = MARKOV_THRESHOLD; + user_options->metal_compiler_runtime = METAL_COMPILER_RUNTIME; user_options->nonce_error_corrections = NONCE_ERROR_CORRECTIONS; user_options->opencl_device_types = NULL; user_options->optimized_kernel_enable = OPTIMIZED_KERNEL_ENABLE; @@ -328,6 +332,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_STATUS_TIMER: case IDX_HASH_MODE: case IDX_RUNTIME: + case IDX_METAL_COMPILER_RUNTIME: case IDX_ATTACK_MODE: case IDX_RP_GEN: case IDX_RP_GEN_FUNC_MIN: @@ -353,6 +358,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_INCREMENT_MIN: case IDX_INCREMENT_MAX: case IDX_HOOK_THREADS: + case IDX_BACKEND_DEVICES_VIRTUAL: #ifdef WITH_BRAIN case IDX_BRAIN_PORT: #endif @@ -384,7 +390,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) { switch (c) { - case IDX_HELP: user_options->usage = true; break; + case IDX_HELP: user_options->usage++; break; case IDX_VERSION: user_options->version = true; break; case IDX_RESTORE: user_options->restore = true; break; case IDX_QUIET: user_options->quiet = true; break; @@ -433,6 +439,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) user_options->hash_mode_chgd = true; break; case IDX_RUNTIME: user_options->runtime = hc_strtoul (optarg, NULL, 10); user_options->runtime_chgd = true; break; + case IDX_METAL_COMPILER_RUNTIME: user_options->metal_compiler_runtime = hc_strtoul (optarg, NULL, 10); + user_options->metal_compiler_runtime_chgd = true; break; case IDX_ATTACK_MODE: user_options->attack_mode = hc_strtoul (optarg, NULL, 10); user_options->attack_mode_chgd = true; break; case IDX_RP_FILE: user_options->rp_files[user_options->rp_files_cnt++] = optarg; break; @@ -467,6 +475,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_BACKEND_IGNORE_OPENCL: user_options->backend_ignore_opencl = true; break; case IDX_BACKEND_INFO: user_options->backend_info++; break; case IDX_BACKEND_DEVICES: user_options->backend_devices = optarg; break; + case IDX_BACKEND_DEVICES_VIRTUAL: user_options->backend_devices_virtual = hc_strtoul (optarg, NULL, 10); break; case IDX_BACKEND_VECTOR_WIDTH: user_options->backend_vector_width = hc_strtoul (optarg, NULL, 10); user_options->backend_vector_width_chgd = true; break; case IDX_OPENCL_DEVICE_TYPES: user_options->opencl_device_types = optarg; break; @@ -559,24 +568,38 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->usage > 2) + { + event_log_error (hashcat_ctx, "Invalid --help/-h value, must have a value greater or equal to 0 and lower than 3."); + + return -1; + } + #ifdef WITH_BRAIN if ((user_options->brain_client == true) && (user_options->brain_server == true)) { - event_log_error (hashcat_ctx, "Can not have --brain-client and --brain-server at the same time"); + event_log_error (hashcat_ctx, "Can not have --brain-client and --brain-server at the same time."); return -1; } if ((user_options->brain_client_features < 1) || (user_options->brain_client_features > 3)) { - event_log_error (hashcat_ctx, "Invalid --brain-client-feature argument"); + event_log_error (hashcat_ctx, "Invalid --brain-client-feature argument."); + + return -1; + } + + if (user_options->brain_port > 65535) + { + event_log_error (hashcat_ctx, "Invalid brain port specified (greater than 65535)."); return -1; } if ((user_options->brain_client == true) && (user_options->brain_password_chgd == false)) { - event_log_error (hashcat_ctx, "Brain clients need to set --brain-password"); + event_log_error (hashcat_ctx, "Brain clients must specify --brain-password."); return -1; } @@ -605,17 +628,20 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->separator_chgd == true) { bool error = false; + if ((strlen (user_options->separator) != 1) && (strlen (user_options->separator) != 4)) { error = true; } + if (strlen (user_options->separator) == 4) { if ((user_options->separator[0] == '0') && (user_options->separator[1] == 'x')) { - if (is_valid_hex_string ((u8 * ) (&(user_options->separator[2])), 2)) + if (is_valid_hex_string ((u8 *) (&(user_options->separator[2])), 2)) { - u8 sep = hex_to_u8 ((u8 * ) (&(user_options->separator[2]))); + u8 sep = hex_to_u8 ((u8 *) (&(user_options->separator[2]))); + user_options->separator[0] = sep; user_options->separator[1] = 0; } @@ -624,7 +650,8 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) error = true; } } - else{ + else + { error = true; } } @@ -717,6 +744,15 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + // --metal-compiler-runtime is really used only on Apple + + if (user_options->metal_compiler_runtime_chgd == true && user_options->metal_compiler_runtime == 0) + { + event_log_error (hashcat_ctx, "Invalid --metal-compiler-runtime value specified (must be > 0)."); + + return -1; + } + if (user_options->limit_chgd == true && user_options->loopback == true) { event_log_error (hashcat_ctx, "Combining --limit with --loopback is not allowed."); @@ -731,6 +767,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->backend_devices_virtual == 0) + { + event_log_error (hashcat_ctx, "Invalid --backend-devices-virtual value specified."); + + return -1; + } + if (user_options->outfile_format == 0) { event_log_error (hashcat_ctx, "Invalid --outfile-format value specified."); @@ -1000,6 +1043,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) } } + if ((user_options->show == true) && (user_options->username == true)) + { + event_log_error (hashcat_ctx, "Mixing --show with --username can cause exponential delay in output."); + + return 0; + } + if (user_options->show == true || user_options->left == true) { if (user_options->remove == true) @@ -1471,7 +1521,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { show_error = false; } - else if (user_options->usage == true) + else if (user_options->usage > 0) { show_error = false; } @@ -1691,7 +1741,7 @@ void user_options_session_auto (hashcat_ctx_t *hashcat_ctx) user_options->session = "hash_info"; } - if (user_options->usage == true) + if (user_options->usage > 0) { user_options->session = "usage"; } @@ -1774,7 +1824,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) || user_options->speed_only == true || user_options->progress_only == true || user_options->identify == true - || user_options->usage == true + || user_options->usage > 0 || user_options->backend_info > 0) { user_options->hwmon_disable = true; @@ -1831,7 +1881,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->quiet = true; } - if (user_options->usage == true) + if (user_options->usage > 0) { user_options->quiet = true; } @@ -2044,6 +2094,11 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "* --backend-devices=%s", user_options->backend_devices); } + if (user_options->backend_devices_virtual) + { + event_log_info (hashcat_ctx, "* --backend-devices-virtual=%u", user_options->backend_devices_virtual); + } + if (user_options->opencl_device_types) { event_log_info (hashcat_ctx, "* --opencl-device-types=%s", user_options->opencl_device_types); @@ -2103,6 +2158,11 @@ void user_options_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "# option: --backend-devices=%s", user_options->backend_devices); } + if (user_options->backend_devices_virtual) + { + event_log_info (hashcat_ctx, "# option: --backend-devices-virtual=%u", user_options->backend_devices_virtual); + } + if (user_options->opencl_device_types) { event_log_info (hashcat_ctx, "# option: --opencl-device-types=%s", user_options->opencl_device_types); @@ -3133,6 +3193,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint64 (user_options->limit); logfile_top_uint64 (user_options->skip); logfile_top_uint (user_options->attack_mode); + logfile_top_uint (user_options->backend_devices_virtual); logfile_top_uint (user_options->benchmark); logfile_top_uint (user_options->benchmark_all); logfile_top_uint (user_options->bitmap_max); @@ -3164,6 +3225,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->markov_disable); logfile_top_uint (user_options->markov_inverse); logfile_top_uint (user_options->markov_threshold); + logfile_top_uint (user_options->metal_compiler_runtime); logfile_top_uint (user_options->multiply_accel_disable); logfile_top_uint (user_options->backend_info); logfile_top_uint (user_options->backend_vector_width); diff --git a/src/wordlist.c b/src/wordlist.c index bc413396c..62941295f 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -695,20 +695,21 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) return 0; + if (user_options->benchmark == true) return 0; if (user_options->hash_info == true) return 0; if (user_options->left == true) return 0; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->backend_info > 0) return 0; wl_data->enabled = true; - wl_data->buf = (char *) hcmalloc (user_options->segment_size); - wl_data->avail = user_options->segment_size; - wl_data->incr = user_options->segment_size; - wl_data->cnt = 0; - wl_data->pos = 0; + wl_data->buf = (char *) hcmalloc (user_options->segment_size); + wl_data->avail = user_options->segment_size; + wl_data->incr = user_options->segment_size; + wl_data->cnt = 0; + wl_data->pos = 0; /** * choose dictionary parser diff --git a/tools/2hashcat_tests/metamask2hashcat-test.py b/tools/2hashcat_tests/metamask2hashcat-test.py index 3ee031f05..7c4ea1ba7 100644 --- a/tools/2hashcat_tests/metamask2hashcat-test.py +++ b/tools/2hashcat_tests/metamask2hashcat-test.py @@ -3,7 +3,7 @@ from base64 import b64decode from hashlib import pbkdf2_hmac -from Crypto.Cipher import AES +from Crypto.Cipher import AES #TODO perhaps load the vault from tools/2hashcat_tests/metamask2hashcat.json similar as in tools/metamask2hashcat.py vault = {"data":"R95fzGt4UQ0uwrcrVYnIi4UcSlWn9wlmer+//526ZDwYAp50K82F1u1oacYcdjjhuEvbZnWk/uBG00UkgLLlO3WbINljqmu2QWdDEwjTgo/qWR6MU9d/82rxNiONHQE8UrZ8SV+htVr6XIB0ze3aCV0E+fwI93EeP79ZeDxuOEhuHoiYT0bHWMv5nA48AdluG4DbOo7SrDAWBVCBsEdXsOfYsS3/TIh0a/iFCMX4uhxY2824JwcWp4H36SFWyBYMZCJ3/U4DYFbbjWZtGRthoJlIik5BJq4FLu3Y1jEgza0AWlAvu4MKTEqrYSpUIghfxf1a1f+kPvxsHNq0as0kRwCXu09DObbdsiggbmeoBkxMZiFq0d9ar/3Gon0r3hfc3c124Wlivzbzu1JcZ3wURhLSsUS7b5cfG86aXHJkxmQDA5urBz6lw3bsIvlEUB2ErkQy/zD+cPwCG1Rs/WKt7KNh45lppCUkHccbf+xlpdc8OfUwj01Xp7BdH8LMR7Vx1C4hZCvSdtURVl0VaAMxHDX0MjRkwmqS","iv":"h+BoIf2CQ5BEjaIOShFE7g==","salt":"jfGI3TXguhb8GPnKSXFrMzRk2NCEc131Gt5G3kZr5+s="} @@ -38,4 +38,4 @@ print("Partially encrypted message (32 bytes):", plaintext.decode()) cipher = AES.new(key, AES.MODE_GCM, nonce=iv) plaintext = cipher.decrypt(ciphertext[:450]) -print("Partially encrypted message (450 bytes):", plaintext.decode()) \ No newline at end of file +print("Partially encrypted message (450 bytes):", plaintext.decode()) diff --git a/tools/2hashcat_tests/metamask2hashcat.android.json b/tools/2hashcat_tests/metamask2hashcat.android.json new file mode 100644 index 000000000..443668f83 --- /dev/null +++ b/tools/2hashcat_tests/metamask2hashcat.android.json @@ -0,0 +1 @@ +{"collectibles":"{\"favorites\":{}}","engine":"{\"backgroundState\":{\"AccountTrackerController\":{\"accounts\":{\"0x66F9C09118B1C726BC24811a611baf60af42070A\":{\"balance\":\"0x0\"}},\"_U\":0,\"_V\":0,\"_W\":null,\"_X\":null},\"AddressBookController\":{\"addressBook\":{}},\"AssetsContractController\":{},\"CollectiblesController\":{\"allCollectibleContracts\":{},\"allCollectibles\":{},\"ignoredCollectibles\":[],\"collectibleContracts\":[],\"collectibles\":[]},\"CurrencyRateController\":{\"conversionDate\":1650127160.54,\"conversionRate\":3025.29,\"nativeCurrency\":\"ETH\",\"currentCurrency\":\"usd\",\"pendingCurrentCurrency\":null,\"pendingNativeCurrency\":null,\"usdConversionRate\":3025.29},\"KeyringController\":{\"keyrings\":[],\"vault\":\"{\\\"cipher\\\":\\\"pzGHRQw3aj//zSjUNAA83WC1EttUHvm4eNNd7YpdoA+bLsU1FXecXYckE3KGWcBIHIdQjdPp2OEgUms0D4XmoWFoAKVnuEUiokWMHy0jpI9z6QTpkSET7xaUY1ZAEWxas1HDBjUBFMhTsuOPiXD1k69tQkxTEe8bHcFFhFsEKfh743b0YypfFbTcOC5HdiuzwEkrtO+nhwBeHBzjzVyGgjQVlqFQiWzbg7JdVPvozbnB5KaongYSEn19o4EbxWiIx7RQWsQ88LR79fWS/nzT0udjxjj9Auu58lGAyvpYTHZzt6n1yapQVXRoHAV44h1AH30f8LY+c2yDKRcPtgc8qqTZXDWzwm4UeFf1BiwUXA6qjN9dFDa0F9Gvl8ugL9HbboGQHQcgQtIKbQnjQSmYucR7kUrZVn/i5jShNglt5lMb4WO28wBaMebBl0tIPPw8xa16tZ3C1Z7RmJrdr3HXDTrwSm5ybqkcngeIOLQwqIOT0WGkSAg6BAce/0oeAp1kgaZWj5BNqnGAsTzaHK1VggFbbQjoX/CQG65vEZBGQXsmdJSfd3m+sTAO113QCpiovvOQFAwcn5eQXQgIv57k2UCrE+SuQcahfd0cZ9GerjI=\\\",\\\"iv\\\":\\\"8fc2c478acc10f6428355312fce293de\\\",\\\"salt\\\":\\\"QW4ie0WH8XP7ust40yy7pg==\\\",\\\"lib\\\":\\\"original\\\"}\"},\"PersonalMessageManager\":{\"unapprovedMessages\":{},\"unapprovedMessagesCount\":0},\"NetworkController\":{\"network\":\"loading\",\"isCustomNetwork\":false,\"provider\":{\"type\":\"mainnet\",\"chainId\":\"1\"},\"properties\":{}},\"PreferencesController\":{\"featureFlags\":{},\"frequentRpcList\":[],\"identities\":{\"0x66F9C09118B1C726BC24811a611baf60af42070A\":{\"address\":\"0x66F9C09118B1C726BC24811a611baf60af42070A\",\"name\":\"Account 1\",\"importTime\":1650114145762}},\"ipfsGateway\":\"https://cloudflare-ipfs.com/ipfs/\",\"lostIdentities\":{},\"selectedAddress\":\"0x66F9C09118B1C726BC24811a611baf60af42070A\",\"useStaticTokenList\":true,\"useCollectibleDetection\":false,\"openSeaEnabled\":false,\"_U\":0,\"_V\":0,\"_W\":null,\"_X\":null},\"TokenBalancesController\":{\"contractBalances\":{}},\"TokenRatesController\":{\"contractExchangeRates\":{}},\"TokensController\":{\"allTokens\":{},\"allIgnoredTokens\":{},\"ignoredTokens\":[],\"suggestedAssets\":[],\"tokens\":[]},\"TransactionController\":{\"methodData\":{},\"transactions\":[],\"internalTransactions\":[],\"swapsTransactions\":{}},\"TypedMessageManager\":{\"unapprovedMessages\":{},\"unapprovedMessagesCount\":0},\"GasFeeController\":{\"gasFeeEstimates\":{},\"estimatedGasFeeTimeBounds\":{},\"gasEstimateType\":\"none\"},\"TokenDetectionController\":{},\"CollectibleDetectionController\":{},\"TokenListController\":{\"tokensChainsCache\":{}},\"SwapsController\":{\"quotes\":{},\"quoteValues\":{},\"fetchParams\":{\"slippage\":0,\"sourceToken\":\"\",\"sourceAmount\":0,\"destinationToken\":\"\",\"walletAddress\":\"\"},\"fetchParamsMetaData\":{\"sourceTokenInfo\":{\"decimals\":0,\"address\":\"\",\"symbol\":\"\"},\"destinationTokenInfo\":{\"decimals\":0,\"address\":\"\",\"symbol\":\"\"}},\"topAggSavings\":null,\"approvalTransaction\":null,\"quotesLastFetched\":0,\"error\":{\"key\":null,\"description\":null},\"topAggId\":null,\"isInPolling\":false,\"pollingCyclesLeft\":3,\"quoteRefreshSeconds\":null,\"usedGasEstimate\":null,\"usedCustomGas\":null},\"PhishingController\":{}}}","privacy":"{\"privacyMode\":true,\"thirdPartyApiMode\":true,\"approvedHosts\":{}}","bookmarks":"[]","recents":"[]","browser":"{\"activeTab\":null,\"history\":[],\"whitelist\":[],\"tabs\":[]}","modals":"{\"networkModalVisible\":false,\"accountsModalVisible\":false,\"collectibleContractModalVisible\":false,\"receiveModalVisible\":false,\"dappTransactionModalVisible\":false,\"approveModalVisible\":false}","settings":"{\"searchEngine\":\"DuckDuckGo\",\"primaryCurrency\":\"ETH\",\"useBlockieIcon\":true,\"hideZeroBalanceTokens\":false,\"lockTime\":30000}","alert":"{\"isVisible\":false,\"autodismiss\":null,\"content\":null,\"data\":null}","transaction":"{\"selectedAsset\":{},\"transaction\":{}}","user":"{\"loadingMsg\":\"Deleting current wallet\",\"loadingSet\":false,\"backUpSeedphraseVisible\":false,\"protectWalletModalVisible\":false,\"gasEducationCarouselSeen\":false,\"nftDetectionDismissed\":false,\"appTheme\":\"os\",\"passwordSet\":true,\"seedphraseBackedUp\":true,\"userLoggedIn\":true}","wizard":"{\"step\":0}","notification":"{\"notifications\":[]}","swaps":"{\"1\":{\"isLive\":true},\"isLive\":true,\"hasOnboarded\":false}","fiatOrders":"{\"selectedCountry\":\"US\",\"orders\":[]}","infuraAvailability":"{\"isBlocked\":false}","navigation":"{\"currentRoute\":\"WalletView\"}","networkOnboarded":"{\"networkOnboardedState\":[],\"networkState\":{\"showNetworkOnboarding\":false,\"nativeToken\":\"\",\"networkType\":\"\",\"networkUrl\":\"\"},\"switchedNetwork\":{\"networkUrl\":\"\",\"networkStatus\":false}}","_persist":"{\"version\":10,\"rehydrated\":true}"} diff --git a/tools/2hashcat_tests/metamask2hashcat.ios.json b/tools/2hashcat_tests/metamask2hashcat.ios.json new file mode 100644 index 000000000..9b90c972d --- /dev/null +++ b/tools/2hashcat_tests/metamask2hashcat.ios.json @@ -0,0 +1 @@ +{"collectibles":"{\"favorites\":{}}","engine":"{\"backgroundState\":{\"AccountTrackerController\":{\"accounts\":{\"0x66F9C09118B1C726BC24811a611baf60af42070A\":{\"balance\":\"0x0\"}},\"_U\":0,\"_V\":0,\"_W\":null,\"_X\":null},\"AddressBookController\":{\"addressBook\":{}},\"AssetsContractController\":{},\"CollectiblesController\":{\"allCollectibleContracts\":{},\"allCollectibles\":{},\"ignoredCollectibles\":[],\"collectibleContracts\":[],\"collectibles\":[]},\"CurrencyRateController\":{\"conversionDate\":1649988414.582,\"conversionRate\":3019.01,\"nativeCurrency\":\"ETH\",\"currentCurrency\":\"usd\",\"pendingCurrentCurrency\":null,\"pendingNativeCurrency\":null,\"usdConversionRate\":3019.01},\"KeyringController\":{\"vault\":\"{\\\"cipher\\\":\\\"oyvzsghbruyPSrkcEv0B+qfkODclFQNIPWuvWHSgIMr26dcVDcsj+sBjzMrJ0mWP0jZQ1xhKt1bAp3v8+rLPauI8OsJ/1uoImqAcBRBu1ORUHmwk2kYIiYLC+qgqvf6OHZGmhF3OAT4Fpt4TSZIP5kVI12DHLNO0yLZDkBliXhQSmuhmY8CCpE13IaTrBWipe/E5lblr5zQWvgfz6lBzrxzE87eY4bAGJ5bh4P/5Nxc=\\\",\\\"iv\\\":\\\"9ec290a383a4c4cf5fcae9137455dc72\\\",\\\"salt\\\":\\\"ywv4d3UyjBtjVQ0gip0Swg==\\\",\\\"lib\\\":\\\"original\\\"}\"},\"PersonalMessageManager\":{\"unapprovedMessages\":{},\"unapprovedMessagesCount\":0},\"NetworkController\":{\"network\":\"1\",\"isCustomNetwork\":false,\"provider\":{\"type\":\"mainnet\",\"chainId\":\"1\"},\"properties\":{\"isEIP1559Compatible\":true}},\"PreferencesController\":{\"featureFlags\":{},\"frequentRpcList\":[],\"identities\":{\"0x66F9C09118B1C726BC24811a611baf60af42070A\":{\"address\":\"0x66F9C09118B1C726BC24811a611baf60af42070A\",\"name\":\"Account 1\",\"importTime\":1649815458524}},\"ipfsGateway\":\"https://cloudflare-ipfs.com/ipfs/\",\"lostIdentities\":{},\"selectedAddress\":\"0x66F9C09118B1C726BC24811a611baf60af42070A\",\"useStaticTokenList\":true,\"useCollectibleDetection\":false,\"openSeaEnabled\":false,\"_U\":0,\"_V\":0,\"_W\":null,\"_X\":null},\"TokenBalancesController\":{\"contractBalances\":{}},\"TokenRatesController\":{\"contractExchangeRates\":{}},\"TokensController\":{\"allTokens\":{},\"allIgnoredTokens\":{},\"ignoredTokens\":[],\"suggestedAssets\":[],\"tokens\":[]},\"TransactionController\":{\"methodData\":{},\"transactions\":[{\"blockNumber\":\"10717310\",\"id\":\"5edf6880-e552-11ea-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1598195253000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x9aa65464b4cfbe3dc2bdb3df412aee2b3de86687\",\"gas\":\"0x5208\",\"gasPrice\":\"0x156ba09800\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x3593\",\"to\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"value\":\"0x5b471c5b794400\"},\"transactionHash\":\"0x1331372b3750105d06a4d6e89a17cbd148b71a7c521f96ba3099c46457e5caef\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"10717318\",\"id\":\"a6fe8b00-e552-11ea-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1598195374000,\"transaction\":{\"data\":\"0xa9059cbb000000000000000000000000da511c376ad5dbcc5e7ffccc5fb9396f91271f1d0000000000000000000000000000000000000000000000056bc75e2d63100000\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0x1036b\",\"gasPrice\":\"0x1ac688c51f\",\"gasUsed\":\"0x9d97\",\"nonce\":\"0x0\",\"to\":\"0xbe9375c6a420d2eeb258962efb95551a5b722803\",\"value\":\"0x0\"},\"transactionHash\":\"0xa75468b70d963d11dcfbe96213c1511e37c3e3aeb6fd676bc6ac51868626d302\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":true},{\"blockNumber\":\"10717322\",\"id\":\"c39ac300-e552-11ea-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1598195422000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0x5208\",\"gasPrice\":\"0x165a0bc000\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x1\",\"to\":\"0x36f403aa625e7122c1455c23624abf7378b5c80b\",\"value\":\"0x43a204cc0afbb7\"},\"transactionHash\":\"0xf0b86dfd64fbd28f446ac185c3cae4a7228aecad5fa77ac0551d5d9d7a768b6f\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14305381\",\"id\":\"e8d97e80-99de-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1646194321000,\"transaction\":{\"data\":\"0x\",\"from\":\"0xeb2629a2734e272bcc07bda959863f316f4bd4cf\",\"gas\":\"0x5208\",\"gasPrice\":\"0xa23f6685e\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x49b32a\",\"to\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"value\":\"0x8d500fae96000\"},\"transactionHash\":\"0x106f49a9205a3c1d636b5d47766c948b54cd18180d4fe956520c5395c4393daa\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14305384\",\"id\":\"f858c780-99de-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1646194347000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0x5208\",\"gasPrice\":\"0x1382de8600\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x2\",\"to\":\"0x108b48bae093cea505fdd725c7bef561abda3f1b\",\"value\":\"0x294799d093000\"},\"transactionHash\":\"0xa26fa2604f27eecd2fb89e843ad034950b3aa2e5615b32138ea52930dbbc484b\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14305392\",\"id\":\"68674d80-99df-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1646194535000,\"transaction\":{\"data\":\"0x\",\"from\":\"0xb5d85cbf7cb3ee0d56b3bb207d5fc4b82f43f511\",\"gas\":\"0x5208\",\"gasPrice\":\"0xc6d980a03\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x5d6a22\",\"to\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"value\":\"0x81f1ad9f4e000\"},\"transactionHash\":\"0xc98bfc1edbd1b36734466915ceccacb22b8024ed76a6911225df209bc737698e\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14305393\",\"id\":\"77e69680-99df-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1646194561000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0x5208\",\"gasPrice\":\"0x156d6a5b80\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x3\",\"to\":\"0x63889c748ec8d558b90f8bf93d9540851f01e74c\",\"value\":\"0x141635d530400\"},\"transactionHash\":\"0xcb35054a37268a871ca74e827fa6c7333de3a62102718acafc37cf7d99987312\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14305487\",\"id\":\"c21d4701-99e2-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1646195974000,\"transaction\":{\"data\":\"0xa9059cbb0000000000000000000000006d0c7d96c2cb4105a25301df2a1d102cc71cf8ae00000000000000000000000000000000000000000002bacd5bc40aa9c6800000\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0xcab7\",\"gasPrice\":\"0xdd2f15172\",\"gasUsed\":\"0xb7f7\",\"nonce\":\"0x4\",\"to\":\"0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce\",\"value\":\"0x0\"},\"transactionHash\":\"0x33c2a4c9f47072600ad15c6e48e8d2685046b96b6e1152871ef63de279cb1eb5\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":true},{\"blockNumber\":\"14305487\",\"id\":\"c21d4700-99e2-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1646195974000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x6d0c7d96c2cb4105a25301df2a1d102cc71cf8ae\",\"gas\":\"0x5208\",\"gasPrice\":\"0xdd2f15172\",\"gasUsed\":\"0x5208\",\"nonce\":\"0xb\",\"to\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"value\":\"0xaf25434c52c7e\"},\"transactionHash\":\"0x3b7d33cd9878b2aa9dd9c4b025bffc49211c0a4b10a65c24e07a4e5c5bef103f\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14370492\",\"id\":\"62d5e880-a1d3-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1647068981000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0x5208\",\"gasPrice\":\"0x296352580\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x5\",\"to\":\"0x012e97041ed39dba037307055a8180327fee15b6\",\"value\":\"0x2f01750aed80\"},\"transactionHash\":\"0xd68054922a1053f4bcc340d548677eaa28efd0ceccf548e3c1b5f123f02eb8e5\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14410592\",\"id\":\"9aa1cc00-a6bc-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1647608952000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x4976a4a02f38326660d17bf34b431dc6e2eb2327\",\"gas\":\"0x32918\",\"gasPrice\":\"0xa0168e5cf\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x10532c\",\"to\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"value\":\"0x17bc0cc54afb000\"},\"transactionHash\":\"0x4c6171d65d38c54c53c5a649f4fadb21670af9d383c2fdeceaa5487c1554624a\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false},{\"blockNumber\":\"14410593\",\"id\":\"a1c8da00-a6bc-11ec-b269-29db90905b87\",\"networkID\":\"1\",\"chainId\":\"1\",\"time\":1647608964000,\"transaction\":{\"data\":\"0x\",\"from\":\"0x66f9c09118b1c726bc24811a611baf60af42070a\",\"gas\":\"0x5208\",\"gasPrice\":\"0x3bff249faa4\",\"gasUsed\":\"0x5208\",\"nonce\":\"0x6\",\"to\":\"0xe067e61d1adaff1c56ec89a31697102622be2a93\",\"value\":\"0x482731101752e0\"},\"transactionHash\":\"0xafd3a07905262628e5311ba4222e86adbff5dacde459aff74da7a78618b0104f\",\"verifiedOnBlockchain\":true,\"status\":\"confirmed\",\"toSmartContract\":false}],\"internalTransactions\":[],\"swapsTransactions\":{}},\"TypedMessageManager\":{\"unapprovedMessages\":{},\"unapprovedMessagesCount\":0},\"GasFeeController\":{\"gasFeeEstimates\":{},\"estimatedGasFeeTimeBounds\":{},\"gasEstimateType\":\"none\"},\"TokenDetectionController\":{},\"CollectibleDetectionController\":{},\"TokenListController\":{\"tokensChainsCache\":{}},\"SwapsController\":{\"quotes\":{},\"quoteValues\":{},\"fetchParams\":{\"slippage\":0,\"sourceToken\":\"\",\"sourceAmount\":0,\"destinationToken\":\"\",\"walletAddress\":\"\"},\"fetchParamsMetaData\":{\"sourceTokenInfo\":{\"decimals\":0,\"address\":\"\",\"symbol\":\"\"},\"destinationTokenInfo\":{\"decimals\":0,\"address\":\"\",\"symbol\":\"\"}},\"topAggSavings\":null,\"approvalTransaction\":null,\"quotesLastFetched\":0,\"error\":{\"key\":null,\"description\":null},\"topAggId\":null,\"isInPolling\":false,\"pollingCyclesLeft\":3,\"quoteRefreshSeconds\":null,\"usedGasEstimate\":null,\"usedCustomGas\":null},\"PhishingController\":{}}}","privacy":"{\"approvedHosts\":{},\"privacyMode\":true,\"thirdPartyApiMode\":true}","bookmarks":"[]","recents":"[]","browser":"{\"history\":[],\"whitelist\":[],\"tabs\":[],\"activeTab\":null}","modals":"{\"networkModalVisible\":false,\"accountsModalVisible\":false,\"collectibleContractModalVisible\":false,\"receiveModalVisible\":false,\"dappTransactionModalVisible\":false,\"approveModalVisible\":false}","settings":"{\"searchEngine\":\"DuckDuckGo\",\"primaryCurrency\":\"ETH\",\"lockTime\":30000,\"useBlockieIcon\":true,\"hideZeroBalanceTokens\":false}","alert":"{\"isVisible\":false,\"autodismiss\":null,\"content\":null,\"data\":null}","transaction":"{\"selectedAsset\":{},\"transaction\":{}}","user":"{\"loadingMsg\":\"\",\"loadingSet\":false,\"passwordSet\":true,\"seedphraseBackedUp\":true,\"backUpSeedphraseVisible\":false,\"protectWalletModalVisible\":false,\"gasEducationCarouselSeen\":false,\"nftDetectionDismissed\":false,\"userLoggedIn\":true,\"appTheme\":\"os\"}","wizard":"{\"step\":3}","notification":"{\"notifications\":[]}","swaps":"{\"1\":{\"isLive\":true},\"isLive\":true,\"hasOnboarded\":false}","fiatOrders":"{\"orders\":[],\"selectedCountry\":\"US\"}","infuraAvailability":"{\"isBlocked\":false}","navigation":"{\"currentRoute\":\"WalletView\"}","networkOnboarded":"{\"networkOnboardedState\":[],\"networkState\":{\"showNetworkOnboarding\":false,\"nativeToken\":\"\",\"networkType\":\"\",\"networkUrl\":\"\"},\"switchedNetwork\":{\"networkUrl\":\"\",\"networkStatus\":false}}","_persist":"{\"version\":10,\"rehydrated\":true}"} diff --git a/tools/aescrypt2hashcat.pl b/tools/aescrypt2hashcat.pl index 8cb2c6efa..b20cf9fb6 100755 --- a/tools/aescrypt2hashcat.pl +++ b/tools/aescrypt2hashcat.pl @@ -72,7 +72,7 @@ if ($version ne "\x02") } -read_bytes ($file_handle, 1); # reservered/skip (normally should be just \x00) +read_bytes ($file_handle, 1); # reserved/skip (normally should be just \x00) # Loop over the extensions until we got extension size 0 diff --git a/tools/benchmark_deep.pl b/tools/benchmark_deep.pl index af0ca873e..79bb19580 100755 --- a/tools/benchmark_deep.pl +++ b/tools/benchmark_deep.pl @@ -379,7 +379,7 @@ chdir ($hashcat_path); for my $hash_type (@hash_types) { - # banchmark always in optimized mode with single hash and mask! + # benchmark always in optimized mode with single hash and mask! my $mask = $default_mask; @@ -521,7 +521,7 @@ sub get_module { if (($hash_type == 22000) || ($hash_type == 22001)) { - ## problem while in -m 2500 backward compatiblity mode + ## problem while in -m 2500 backward compatibility mode } else { diff --git a/tools/bisq2hashcat.py b/tools/bisq2hashcat.py old mode 100644 new mode 100755 diff --git a/tools/gpg_tests/example17040.sh b/tools/gpg_tests/example17040.sh new file mode 100755 index 000000000..b72153daf --- /dev/null +++ b/tools/gpg_tests/example17040.sh @@ -0,0 +1,16 @@ +#!/bin/bash +FILE="./hashcat.exe" +if [[ -f "$FILE" ]]; then + echo "we found hashcat.exe binary so use that" #wsl +else + FILE="./hashcat" + if [[ -f "$FILE" ]]; then + echo "we found ./hashcat binary so use that" #linux + else + echo "could not find hashcat binary, compile it first using make" + exit + fi +fi + +$FILE -a0 -m17040 tools/gpg_tests/refdata/m17040/ref1-cast5.hash tools/gpg_tests/refdata/m17040/ref1-cast5.txt --potfile-disable +$FILE -a0 -m17040 tools/gpg_tests/refdata/m17040/ref2-cast5.hash tools/gpg_tests/refdata/m17040/ref2-cast5.txt --potfile-disable diff --git a/tools/gpg_tests/refdata/m17040/ref1-cast5.hash b/tools/gpg_tests/refdata/m17040/ref1-cast5.hash new file mode 100644 index 000000000..bf1ba0dde --- /dev/null +++ b/tools/gpg_tests/refdata/m17040/ref1-cast5.hash @@ -0,0 +1 @@ +$gpg$*1*1308*4096*ddf02802e2d06319bcf5962745b73677ecfa229649fed991e3360bdf2fffe71f521b8f877bccfcdce9a4fb4aeb63bd21fed6e37f96f193a6f7d3c476f4a7e01e7421d0eba5bfcd59544e37887572cd40e8d03e901574ec0f3afdff35ad3f25cb818ddadee84ddfef636207febd8d12d8a98983c86afa46608d178dba5ec51e98a182bd9687b6431fba87b5a16b5e0cf872db7dc12c55bfe7faaa443044d5a84ddf034198e5bc6b4b707b5f4a4c5999ff3885975113fca02693620f36f8f20570bdaf581726053b6c982cb988a3091dc206624f9d36372b151b22c7dc2cb71b9aaed95dc5630c4c4b045f80c403836cc9c84951fc04b8d6e413e1d4f6b3815508f43cf80c25c7db3882b5b6572f1395a00dcda7fe65ce2155f9ea2cfe13588e0fb10316e7dd978e1d89cffc06a5e722ec765315926d2ee9060d8f449ead31cbacea88a5251be3b518d23984530da9f930114e614b7ed30f748c7512bddca8604bb5310ed76b9982eb88acaf49a29325e9db6987c6dea3878e2cb7daf3800177579ddcaafeacdba8edd147fae61bae36ab83a98db69a6c92017b3db8cff68985db989a03ee1bd045e6a577151486cdaeaf26517027b2f140b8493e2f401ea222511c2ce61c7057d64e8c3568e3f547f4b2875db59bc8c4f3346e0faf54e30745f583494b59e570bacb2b9eb71eb834e57f68aadda9af4bdb03276f71770c611aad0278033bb8c108471c4f4a2aa9070774367b9334661daf8a5e3eaf3d8dcca723d64ae7264c8709987a6cee9f42287b6e20d1d753262ff74886f3995412e59d09c61e4c637b6e97e6a3b08f9fa6adf9a1ec44a0372e893febd6712decc00bbd9cdacaf6bb9302fe8bd2ca27fdf5156c33582d56781ab0e5bd14da4b1edd73edd8f2a034a56d1a6f836724b605657f4714d59d522805e0ab02c6c5daed0973f93120ae01623ce0a96fbdf4402ce20ebb4f97fabbc90da5bb12aac3cd5f15c1add2d3863be59e843dca564ce9aa25b43ca1044b1e7e65d03d1f55f77d2a39cd85536ff38058837a23743c4e252f7de5654a562506b55d2b8fa29c7f4ecd307a8ae686cbb73fea6a8f72775d9e417ec346415024263a9f339dda286b682ccc8f93f7d4f59921620dd276188441fd44fc63925d18caa30a75c79c37a2ea45d14f6e423d2146281f9c6699a0658e50d69cfbc174090a0420bbb6f4e6b5b1f2b81b26f035aaf5c2e558c812496cb494587c78bf75350fb1a36e8c88076b4684094e0cba5dcdc4f672dbd2b432306b75077ae07b8fd88ba5b829eaed3fd2959a09b162329b75ac8fc20d4eea6e5971f54b31a23952dd4c111765822182cd60ee0de3cce3752c648918e3ec4c52643223132dcc885140faf8108230ebf4ef4149cbfa3070c91ec013404c15c1cecaa1efd544ab8313d378ef0e77c615b76b8ec07769960873ce9c7bdb1d75e7faef4c8a0b015c95a4e2bcd9ff7f5dfddd9a243fc0688db09e534ef1f3ebebd0c73b75bd57b8e02667da5744b1400dc695d4ae1e255d3487d1dead115de7d48962a15c7aecb97444173c40c028a46a7cfdd8cc7421f71d757cb809341c5148aedeab16f9289bc55b7475d646ae4993ab36fe5609a05121d140d4390289c94e4d87fd902fe03c8bfa13e7cfc9c21355ab6461d214137e4d90dff4a8f599020f12d7560fa4b5aaee1727f21c873fde76415b65357ecb923a547ddcdb20dde0880a287ed26d5ea4ce45514b907e368527c62e39ffdf2efeb817cd59694d23bafd48862e723f45e3c258cff3c804c5d2f17e24be8fe81a00f11f519beb9cde7be95226ac2a7f11e0f4f09dc040c11e1bf63172aa0f8a*1*254*2*3*8*0000000000000000*0*a11df265e4e54bee diff --git a/tools/gpg_tests/refdata/m17040/ref1-cast5.txt b/tools/gpg_tests/refdata/m17040/ref1-cast5.txt new file mode 100644 index 000000000..f30ae1eed --- /dev/null +++ b/tools/gpg_tests/refdata/m17040/ref1-cast5.txt @@ -0,0 +1 @@ +Hashcat1! diff --git a/tools/gpg_tests/refdata/m17040/ref2-cast5.hash b/tools/gpg_tests/refdata/m17040/ref2-cast5.hash new file mode 100644 index 000000000..c84a3f2f7 --- /dev/null +++ b/tools/gpg_tests/refdata/m17040/ref2-cast5.hash @@ -0,0 +1 @@ +$gpg$*1*1308*4096*b9bb392ab1b52997984826fd57c60ff16469f7e3a2bedf44e735e1426d5ad3aa43ce6adcd1f6d28e4357f31660fdd232c884653183cbe824bfe7364b2931f9b2028f93d00867c92dd77108dd4e65085944d08f2111f51308e26926d7d555580db59dc1874dc0611db82216e5788e0cb7cbd07f59fba91d36b3f1123d7be110301a59865bb318df5f8028858ca81e70bb85dd580130665f17a53cab073ffced08677f0dc7f6f8c49eb0ff2e828e0da97219fc09d1db45734834a57c6e19fac198938447153911df1dde314681c0caf368b91f2f9442eeda043765a70967e9da618d2cca7fd5d53a0d24a27652702a7924f4773a84d1d04bbc4d5d839235efa15933ac8c7652b28b9c84ac5f096a7ff32d7ccf791b514f1066daab43736807295f6814fde8f4956b3eeb302b6831bce1864af67a90a319bf2693de58e4834e11179246192750a09909ab9254314324069a498154245d72a9d0ca9c48f84b2ff4ac8ed7b4abb6ce5c4277722faaf7c74e9f00a5e7b518c637624df7c2261629850b0a7a673f325d9c3dd0243c1d966ab69ef1780c620f0d0da3315111b4ef07efa68b63779d4f4dbf625508ff176a4d7ce1e65384b6b781808dae43e9ae2b7a2bbcb80b854e0f154503f3600b7a1c4114bb0fcbc78c9f85d44e766cf729debebf6e8e221b1ba16f96a2f3540ec2723c522080599202160c14b17d587cdfffa29b691966a48cce551de7a97830c79de76fa46515159a8b78436b85b22985066827cc4b04e867e9a33c50cd8adafe8706b7cd06670ff8fc4e2bf853cd4cd78f050a722e45958eec6885fb0b9dc900357bfa47519f9bf28828c0899166656722e63eb877b00de244aea1badfcd92584153a6b6acb4d5a45a8c745718b4d439bf51792f7e3945042d8e199fcff6cdb4a8247565013e2b544611cf897cb14517eda73459f2879e2727cbedb7c3853e2c0f8fe5864fe19069019666bb9292689bd90edcb2839b8fe7e923036049657175f3ec37466024cd5c084c2454da962a908ae48ca2fcd0b2a03b246f53e1f1acf1229cd4ee62e4bcb64f9f545b4feb21c28f4f3244b974975ee61e2bb5216c1cb9bf9416cf19cc28ef61d32908c178e19927d8edefdf241b0773085eab933d2f57644426f7e1b46b6beafab98fe9099fb5e7fbe7aac3a521e7491cc0321ee9bc2b5b4a6aa1fd6ede05a6a35b33c9fff2668ce90a1b4d66d82f6da127be1097f9f686670d143cbd71766550d7fff099f39ced941237d8f71bb9289e96bf9b100b8ee361db30956550da1834e3cf1f1c70dc0c79bc35758596664448c43a8993beab7b08f69c9350601aa2d6b9ae576b4882af869135e49cc97cdc0cbb82ec62e77a3297e61efb661813d258d8e723a97058d41715187aa6c97bbe6046230a5414a3923f2380c6d10ccaab328ef93309c951b4c7e474b9662ae766b491c2705c5fa115e651e307a0b7d2b0411b949e1153b1d8e32580594a78e746cb00011677736d4a6830f450ebaec16653ea0cc20dcb29fdcd6b79f5b9cf50794dd40908dc2a509a64f6f32779d9b52fca2693d9d2bb787217df0135429fad20f102d4f44271f4c4e9a786a7304c894498fcac18afe3ef299de712263167427353fcb70a1c6fd9a649b71fb67a90b9395cba095d2bdad7f0b59710fd580dcfc3256ce98da04145bd4e887c3a859f48b7eda9954c445844bf26017b919c0423ed2f2cecbbe7e7eba02cc0ef51a5e74e846d6fe5e23ac42ef58b77354cc0ae8f101262fe9b97d17b17a1cca4e766ebce7c0e15f89f2dd3eca4a87951df9bd24db7807706e141a72c4a447fa81b9a18987b29b7856352aedc*1*254*2*3*8*0000000000000000*0*562609e55571bac3 diff --git a/tools/gpg_tests/refdata/m17040/ref2-cast5.txt b/tools/gpg_tests/refdata/m17040/ref2-cast5.txt new file mode 100644 index 000000000..98f9b1685 --- /dev/null +++ b/tools/gpg_tests/refdata/m17040/ref2-cast5.txt @@ -0,0 +1 @@ +Test123! diff --git a/tools/metamask2hashcat.py b/tools/metamask2hashcat.py index cc631b444..fe2f0e006 100755 --- a/tools/metamask2hashcat.py +++ b/tools/metamask2hashcat.py @@ -2,12 +2,14 @@ # -*- coding: utf-8 -*- # Author: Gabriele 'matrix' Gristina -# Version: 1.0 +# Version: 2.0 # Date: Thu 12 Aug 2021 06:44:14 PM CEST # License: MIT # Extract metamask vault from browser and save to file, then you can use this tool # reference: https://metamask.zendesk.com/hc/en-us/articles/360018766351-How-to-use-the-Vault-Decryptor-with-the-MetaMask-Vault-Data +# From version 2.0 works also for Metamask Mobile +# reference: https://github.com/3rdIteration/btcrecover/pull/346 import json import argparse @@ -19,21 +21,58 @@ def metamask_parser(file, shortdata): j = json.load(f) - if 'salt' not in j or 'iv' not in j or 'data' not in j: - print("! Invalid vault format ...") - parser.print_help() - exit(1) + isMobile = False + + if 'engine' not in j: + if 'salt' not in j or 'iv' not in j or 'data' not in j: + print("! Invalid vault format ...") + parser.print_help() + exit(1) + else: + f.close() + wallet_data = open(file, "rb").read().decode("utf-8","ignore").replace("\\","") + + # taken from https://github.com/3rdIteration/btcrecover/blob/master/btcrecover/btcrpass.py#L3096-L3103 + walletStartText = "vault" + wallet_data_start = wallet_data.lower().find(walletStartText) + wallet_data_trimmed = wallet_data[wallet_data_start:] + wallet_data_start = wallet_data_trimmed.find("cipher") + wallet_data_trimmed = wallet_data_trimmed[wallet_data_start - 2:] + wallet_data_end = wallet_data_trimmed.find("}") + wallet_data = wallet_data_trimmed[:wallet_data_end + 1] + wallet_json = json.loads(wallet_data) + + j = json.loads(wallet_data) + + if 'lib' in j and 'original' in j['lib']: + isMobile = True + else: + print("! Invalid vault format ...") + parser.print_help() + exit(1) - if((len(j['data']) > 3000) or shortdata): - data_bin = base64.b64decode(j['data']) - # TODO limit data to 16 bytes, we only check the first block of data, so we don't need more data. - # The use of smaller buffers should speedup the attack. - # Still the pbkdf 10k iter will be taking the most time by far probably. - j['data'] = base64.b64encode(data_bin[0:64]).decode("ascii") + if isMobile is False: + + if((len(j['data']) > 3000) or shortdata): + data_bin = base64.b64decode(j['data']) + # TODO limit data to 16 bytes, we only check the first block of data, so we don't need more data. + # The use of smaller buffers should speedup the attack. + # Still the pbkdf 10k iter will be taking the most time by far probably. + j['data'] = base64.b64encode(data_bin[0:64]).decode("ascii") + + print('$metamask-short$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + else: + print('$metamask$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) - print('$metamask-short$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) else: - print('$metamask$' + j['salt'] + '$' + j['iv'] + '$' + j['data']) + + # extract only first 16 bytes of ciphertext + + cipher_bin = base64.b64decode(j['cipher']) + j['cipher'] = base64.b64encode(cipher_bin[:16]).decode("ascii") + + print('$metamaskMobile$' + j['salt'] + '$' + j['iv'] + '$' + j['cipher']) + except ValueError as e: parser.print_help() exit(1) @@ -52,4 +91,3 @@ if __name__ == "__main__": else: parser.print_help() exit(1) - diff --git a/tools/test.sh b/tools/test.sh index e2440b564..c1cdf382d 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -218,7 +218,7 @@ function init() echo "They will be fetched from ${luks_tests_url}" echo "Note: this needs to be done only once and could take a little bit to download/extract." echo "These luks test files are not shipped directly with hashcat because the file sizes are" - echo "particularily large and therefore a bandwidth burner for users who do not run these tests." + echo "particularly large and therefore a bandwidth burner for users who do not run these tests." echo "" # download: @@ -256,8 +256,8 @@ function init() grep " ${hash_type} '" "${OUTD}/all.sh" > "${cmd_file}" 2>/dev/null # create separate list of password and hashes - sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords.txt" - sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{print $10}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes.txt" + sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords.txt" + sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{t="";for(i=10;i<=NF;i++){if(t){t=t" "$i}else{t=$i}};print t}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes.txt" if [ "${hash_type}" -eq 10300 ]; then #cat ${OUTD}/${hash_type}.sh | cut -d' ' -f11- | cut -d"'" -f2 > ${OUTD}/${hash_type}_hashes.txt @@ -368,8 +368,8 @@ function init() perl tools/test.pl single "${hash_type}" ${i} > "${cmd_file}" - sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords_multi_${i}.txt" - sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{print $10}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes_multi_${i}.txt" + sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords_multi_${i}.txt" + sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{t="";for(i=10;i<=NF;i++){if(t){t=t" "$i}else{t=$i}};print t}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes_multi_${i}.txt" if [ "${hash_type}" -eq 10300 ]; then #cat ${OUTD}/${hash_type}_multi_${i}.txt | cut -d' ' -f11- | cut -d"'" -f2 > ${OUTD}/${hash_type}_hashes_multi_${i}.txt @@ -591,7 +591,7 @@ function attack_0() # out-of-memory, workaround - echo "${output}" | head -1 > tmp_file_out + echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out echo "${search}" > tmp_file_search out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) @@ -874,7 +874,7 @@ function attack_1() # out-of-memory, workaround - echo "${output}" | head -1 > tmp_file_out + echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out echo "${search}" > tmp_file_search out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) @@ -1180,7 +1180,7 @@ function attack_3() # out-of-memory, workaround - echo "${output}" | head -1 > tmp_file_out + echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out echo "${search}" > tmp_file_search out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) @@ -1840,9 +1840,10 @@ function attack_6() newRet=$? if [ "${newRet}" -eq 2 ]; then + # out-of-memory, workaround - echo "${output}" | head -1 > tmp_file_out + echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out echo "${search}" > tmp_file_search out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) @@ -2273,7 +2274,7 @@ function attack_7() # out-of-memory, workaround - echo "${output}" | head -1 > tmp_file_out + echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out echo "${search}" > tmp_file_search out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) @@ -2287,7 +2288,6 @@ function attack_7() fi if [ "${newRet}" -ne 0 ]; then - if [ "${newRet}" -eq 2 ]; then ret=20 else diff --git a/tools/test_modules/README.md b/tools/test_modules/README.md index 2593e8ccf..c743bec32 100644 --- a/tools/test_modules/README.md +++ b/tools/test_modules/README.md @@ -13,12 +13,12 @@ During `verify` tests the `module_verify_hash` function must parse the hash:pass **Important**: You have to call `pack_if_HEX_notation` as soon as you have parsed the password, or your tests will fail on passwords in the `$HEX[...]` format. -If the algorithm has ambiguous hashes (e.g. partial case-insensetivity), the test module can provide an optional function `module_preprocess_hashlist`. It recieves a reference to the hashlist array and can unify the hashes in a way that guarantees the match with the output of `module_verify_hash`. +If the algorithm has ambiguous hashes (e.g. partial case-insensitivity), the test module can provide an optional function `module_preprocess_hashlist`. It receives a reference to the hashlist array and can unify the hashes in a way that guarantees the match with the output of `module_verify_hash`. #### Examples #### * For the most basic test modules, see [m00000.pm](m00000.pm) and [m00100.pm](m00100.pm) * For the basic salted hash tests, see [m00110.pm](m00110.pm) and [m00120.pm](m00120.pm) -* For some sligthly more complex modules with PBKDF2 and encryption, see [m18400.pm](m18400.pm) and [m18600.pm](m18600.pm) +* For some slightly more complex modules with PBKDF2 and encryption, see [m18400.pm](m18400.pm) and [m18600.pm](m18600.pm) * For a test module with hashlist preprocessing and a custom salt generation algorithm, see [m05600.pm](m05600.pm) diff --git a/tools/test_modules/m00070.pm b/tools/test_modules/m00070.pm index 9cb545327..7edcbe1ee 100644 --- a/tools/test_modules/m00070.pm +++ b/tools/test_modules/m00070.pm @@ -11,7 +11,7 @@ use warnings; use Digest::MD5 qw (md5_hex); use Encode; -sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m00170.pm b/tools/test_modules/m00170.pm index da8fb866f..45b6eaa10 100644 --- a/tools/test_modules/m00170.pm +++ b/tools/test_modules/m00170.pm @@ -11,7 +11,7 @@ use warnings; use Digest::SHA1 qw (sha1_hex); use Encode; -sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m01470.pm b/tools/test_modules/m01470.pm index 4d7c6182c..1e1469309 100644 --- a/tools/test_modules/m01470.pm +++ b/tools/test_modules/m01470.pm @@ -11,7 +11,7 @@ use warnings; use Digest::SHA qw (sha256_hex); use Encode; -sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m01770.pm b/tools/test_modules/m01770.pm index b50644b97..6b9c63de7 100644 --- a/tools/test_modules/m01770.pm +++ b/tools/test_modules/m01770.pm @@ -11,7 +11,7 @@ use warnings; use Digest::SHA qw (sha512_hex); use Encode; -sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m02400.pm b/tools/test_modules/m02400.pm index 46cba1aee..c1d2c0e2c 100644 --- a/tools/test_modules/m02400.pm +++ b/tools/test_modules/m02400.pm @@ -11,7 +11,7 @@ use warnings; use Digest::MD5 qw (md5); use POSIX qw (ceil); -sub module_constraints { [[-1, -1], [-1, -1], [1, 55], [-1, -1], [-1, -1]] } +sub module_constraints { [[-1, -1], [-1, -1], [1, 31], [-1, -1], [-1, -1]] } sub pseudo_base64 { diff --git a/tools/test_modules/m02410.pm b/tools/test_modules/m02410.pm index a8808013c..4bc57c821 100644 --- a/tools/test_modules/m02410.pm +++ b/tools/test_modules/m02410.pm @@ -11,7 +11,7 @@ use warnings; use Digest::MD5 qw (md5); use POSIX qw (ceil); -sub module_constraints { [[-1, -1], [-1, -1], [0, 55], [1, 4], [-1, -1]] } +sub module_constraints { [[-1, -1], [-1, -1], [0, 47], [1, 4], [0, 48]] } sub pseudo_base64 { diff --git a/tools/test_modules/m02630.pm b/tools/test_modules/m02630.pm new file mode 100644 index 000000000..d54c5598f --- /dev/null +++ b/tools/test_modules/m02630.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex (md5_hex ($word . $salt)); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m03610.pm b/tools/test_modules/m03610.pm new file mode 100644 index 000000000..9e777d507 --- /dev/null +++ b/tools/test_modules/m03610.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); + +sub module_constraints { [[0, 256], [0, 223], [0, 55], [1, 23], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex (md5_hex (md5_hex ($word)) . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; \ No newline at end of file diff --git a/tools/test_modules/m04420.pm b/tools/test_modules/m04420.pm new file mode 100644 index 000000000..97e509c09 --- /dev/null +++ b/tools/test_modules/m04420.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex (sha1_hex ($word . $salt)); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04430.pm b/tools/test_modules/m04430.pm new file mode 100644 index 000000000..e41afa0ae --- /dev/null +++ b/tools/test_modules/m04430.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex (sha1_hex ($salt . $word)); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m08300.pm b/tools/test_modules/m08300.pm index 35caab10d..879949fde 100644 --- a/tools/test_modules/m08300.pm +++ b/tools/test_modules/m08300.pm @@ -11,7 +11,7 @@ use warnings; use Net::DNS::RR::NSEC3; use Net::DNS::SEC; -# we need to restict the pure password length for the test module to 63 bytes, +# we need to restrict the pure password length for the test module to 63 bytes, # because we can't have any string (including the pass) of over 63 bytes without "." # sub module_constraints { [[1, 256], [-1, -1], [1, 55], [-1, -1], [-1, -1]] } diff --git a/tools/test_modules/m10870.pm b/tools/test_modules/m10870.pm index 9aaf01efe..53c074c5b 100644 --- a/tools/test_modules/m10870.pm +++ b/tools/test_modules/m10870.pm @@ -11,7 +11,7 @@ use warnings; use Digest::SHA qw (sha384_hex); use Encode; -sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m11700.pm b/tools/test_modules/m11700.pm index 8a0c250f6..0b3b19e3e 100644 --- a/tools/test_modules/m11700.pm +++ b/tools/test_modules/m11700.pm @@ -8,7 +8,7 @@ use strict; use warnings; -sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [-1, -1]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m11900.pm b/tools/test_modules/m11900.pm index f75c70486..4464c434e 100644 --- a/tools/test_modules/m11900.pm +++ b/tools/test_modules/m11900.pm @@ -29,7 +29,7 @@ sub module_generate_hash my $word_buf_base64 = encode_base64 ($word, ""); my $salt_buf_base64 = encode_base64 ($salt, ""); - # sanitize lenghs + # sanitize lengths $out_len = int ($out_len); diff --git a/tools/test_modules/m20712.pm b/tools/test_modules/m20712.pm new file mode 100644 index 000000000..7cea4821f --- /dev/null +++ b/tools/test_modules/m20712.pm @@ -0,0 +1,52 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256_hex); +use MIME::Base64 qw (decode_base64 encode_base64); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 51], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + #$word = "hashcat"; + #$salt = decode_base64 ("c2FsdHNhbHQ="); + + my $salt_b64 = encode_base64 ($salt, ""); + + my $digest = uc (sha256_hex ( uc (sha256_hex ($word)) . $salt)); + + my $hash = sprintf ("%s:%s", $digest, $salt_b64); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($digest, $salt, $word) = split (':', $line); + + return unless defined $digest; + return unless defined $salt; + return unless defined $word; + + my $salt_b64 = decode_base64 ($salt); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt_b64); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m21310.pm b/tools/test_modules/m21310.pm new file mode 100644 index 000000000..9a20f8ae3 --- /dev/null +++ b/tools/test_modules/m21310.pm @@ -0,0 +1,47 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt1 = shift; + my $salt2 = shift // random_hex_string(32); + + my $digest = md5_hex ($salt1 . sha1_hex ($salt2 . $word)); + + my $hash = sprintf ("%s:%s:%s", $digest, $salt1, $salt2); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt1, $salt2, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt1; + return unless defined $salt2; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt1, $salt2); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m21400.pm b/tools/test_modules/m21400.pm index 7446133b3..daaa02108 100644 --- a/tools/test_modules/m21400.pm +++ b/tools/test_modules/m21400.pm @@ -1,3 +1,5 @@ +#!/usr/bin/env perl + ## ## Author......: See docs/credits.txt ## License.....: MIT diff --git a/tools/test_modules/m22911.pm b/tools/test_modules/m22911.pm index fd4b0b18c..d8c53693f 100644 --- a/tools/test_modules/m22911.pm +++ b/tools/test_modules/m22911.pm @@ -59,7 +59,7 @@ sub module_generate_hash my $dec_bin = $aes->decrypt ($data_bin); - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m22921.pm b/tools/test_modules/m22921.pm index 63e9d4aad..4839da1f6 100644 --- a/tools/test_modules/m22921.pm +++ b/tools/test_modules/m22921.pm @@ -56,7 +56,7 @@ sub module_generate_hash my $dec_bin = $aes->decrypt ($data_bin); - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m22931.pm b/tools/test_modules/m22931.pm index 9e508b29e..138f56e66 100644 --- a/tools/test_modules/m22931.pm +++ b/tools/test_modules/m22931.pm @@ -56,7 +56,7 @@ sub module_generate_hash my $dec_bin = $aes->decrypt ($data_bin); - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m22941.pm b/tools/test_modules/m22941.pm index f4f6e0f91..d4fb2b554 100644 --- a/tools/test_modules/m22941.pm +++ b/tools/test_modules/m22941.pm @@ -58,7 +58,7 @@ sub module_generate_hash my $dec_bin = $aes->decrypt ($data_bin); - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m22951.pm b/tools/test_modules/m22951.pm index ad90582b0..c9c794be8 100644 --- a/tools/test_modules/m22951.pm +++ b/tools/test_modules/m22951.pm @@ -58,7 +58,7 @@ sub module_generate_hash my $dec_bin = $aes->decrypt ($data_bin); - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m24410.pm b/tools/test_modules/m24410.pm index 313810a28..f5beb8c59 100644 --- a/tools/test_modules/m24410.pm +++ b/tools/test_modules/m24410.pm @@ -80,7 +80,7 @@ sub module_generate_hash $dec_bin = $aes->decrypt ($data_bin); } - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m24420.pm b/tools/test_modules/m24420.pm index adf084642..6467421f3 100644 --- a/tools/test_modules/m24420.pm +++ b/tools/test_modules/m24420.pm @@ -80,7 +80,7 @@ sub module_generate_hash $dec_bin = $aes->decrypt ($data_bin); } - ## This is a ridiculous check of successfull decryption + ## This is a ridiculous check of successful decryption ## There are no useable asn1 parsers for perl available ## We have to rely on a combination of padding check and pattern matching ## The (minimum) 16 bit should be good enough for a unit test diff --git a/tools/test_modules/m24800.pm b/tools/test_modules/m24800.pm index 00de6fced..e00bf9b83 100644 --- a/tools/test_modules/m24800.pm +++ b/tools/test_modules/m24800.pm @@ -13,7 +13,7 @@ use Digest::HMAC qw (hmac); use Encode qw (encode); use MIME::Base64 qw (encode_base64); -sub module_constraints { [[0, 256], [0, 256], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 256], [-1, -1], [0, 27], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m25400.pm b/tools/test_modules/m25400.pm index 7dce337bb..d6f0bb4bf 100644 --- a/tools/test_modules/m25400.pm +++ b/tools/test_modules/m25400.pm @@ -99,7 +99,7 @@ sub pdf_compute_encryption_key_owner my $o_key; if ($R == 2) { - $o_key = substr ($o_digest, 0, 8); # rc4 key is always 5 for revision 2, but for 3 or greather is dependent on the value of the encryption dictionaries length entry + $o_key = substr ($o_digest, 0, 8); # rc4 key is always 5 for revision 2, but for 3 or greater is dependent on the value of the encryption dictionaries length entry } else { diff --git a/tools/test_modules/m25700.pm b/tools/test_modules/m25700.pm index aaea6c1c8..3197a722b 100644 --- a/tools/test_modules/m25700.pm +++ b/tools/test_modules/m25700.pm @@ -115,7 +115,7 @@ sub module_generate_hash my $salt_bin = pack ("H*", $salt); - my $seed = unpack ("N", $salt_bin); # or maybe "L" ? not enought example data to clarify + my $seed = unpack ("N", $salt_bin); # or maybe "L" ? not enough example data to clarify my $digest = MurmurHash ($word, $seed); diff --git a/tools/test_modules/m26610.pm b/tools/test_modules/m26610.pm index bde52a1f7..71f2d05b0 100644 --- a/tools/test_modules/m26610.pm +++ b/tools/test_modules/m26610.pm @@ -21,9 +21,6 @@ sub module_generate_hash my $iv = shift // random_hex_string (32); my $ct = shift; - my $ct_min_len = 30; - my $ct_max_len = 64; - my $kdf = Crypt::PBKDF2->new ( hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256), @@ -31,34 +28,18 @@ sub module_generate_hash output_len => 32 ); + my $ct_len = 64; + my $salt_bin = pack ("H*", $salt); my $key = $kdf->PBKDF2 ($salt_bin, $word); my $iv_bin = pack ("H*", $iv); - my $pt; - - if (defined $ct) - { - my $ct_bin = pack ("H*", $ct); - - my $data_bin = $ct_bin; - my $aes = Crypt::AuthEnc::GCM->new ("AES", $key, $iv_bin); + my $pt = "[{\"type\":\"HD Key Tree\",\"data\":{\"mnemonic\":[112,97,121,109,101,110,116,32,117,112,115,101,116,32,109,101,116,97,108,32,99,104,97,112,116,101,114,32,114,117,110,32,97,100,109,105,116,32,109,101,97,115,117,114,101,32,114,101,109,105,110,100,32,115,117,112,112,108,121,32,104,111,112,101,32,101,110,101,109,121,32,104,101,100,103,101,104,111,103],\"numberOfAccounts\":1,\"hdPath\":\"m/44'/60'/0'/0\"}}]"; - $pt = $aes->decrypt_add ($data_bin); - - } - else - { - # generate plaintext - - # TODO now the data is all ASCII 'a', would be better to have it mimic the same structure as the reference data: - # [{"type":"HD Key Tree","data":{"mnemonic":[112,97,121,109,101,110,116,32,117,112,115,101,116,32,109,101,116,97,108,32,99,104,97,112,116,101,114,32,114,117,110,32,97,100,109,105,116,32,109,101,97,115,117,114,101,32,114,101,109,105,110,100,32,115,117,112,112,108,121,32,104,111,112,101,32,101,110,101,109,121,32,104,101,100,103,101,104,111,103],"numberOfAccounts":1,"hdPath":"m/44'/60'/0'/0"}}] - # generated from tools/2hashcat_tests/metamask2hashcat-test.py - $pt = "a" x ($ct_min_len + int (rand ($ct_max_len - $ct_min_len)) + 1); - } + $pt = substr ($pt, 0, $ct_len); my $aes = Crypt::AuthEnc::GCM->new ("AES", $key, $iv_bin); @@ -80,7 +61,7 @@ sub module_verify_hash my $hash = substr ($line, 0, $idx); my $word = substr ($line, $idx + 1); - return unless substr ($hash, 0, 10) eq '$metamask-short$'; + return unless substr ($hash, 0, 16) eq '$metamask-short$'; my (undef, $signature, $salt, $iv, $ct) = split '\$', $hash; @@ -95,12 +76,7 @@ sub module_verify_hash return unless length $salt_bin == 32; return unless length $iv_bin == 16; - - my $ct_len = length ($ct_bin); - my $ct_min_len = 30; - my $ct_max_len = 3136; - - return unless ($ct_len >= $ct_min_len && $ct_len <= $ct_max_len); + return unless length $ct_bin == 64; my $word_packed = pack_if_HEX_notation ($word); diff --git a/tools/test_modules/m28100.pm b/tools/test_modules/m28100.pm index 2f5398535..2df4aa5e1 100644 --- a/tools/test_modules/m28100.pm +++ b/tools/test_modules/m28100.pm @@ -58,7 +58,7 @@ sub module_generate_hash ## convert_userpin_to_secretpin() ## this looks strange. what if the user password is outside 0x20 - 0x7f? - ## from some testing, it seems MS prevents the user to use any non-ascii charcters + ## from some testing, it seems MS prevents the user to use any non-ascii characters my $stage1_hexpin = uc (encode ("UTF-16LE", unpack ("H*", $word))); diff --git a/tools/test_modules/m28200.pm b/tools/test_modules/m28200.pm index 85bde1ec1..c8ae72830 100644 --- a/tools/test_modules/m28200.pm +++ b/tools/test_modules/m28200.pm @@ -12,7 +12,7 @@ use Crypt::AuthEnc::GCM; use Crypt::ScryptKDF qw (scrypt_raw); use MIME::Base64 qw (decode_base64 encode_base64); -sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } +sub module_constraints { [[4, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { diff --git a/tools/test_modules/m28501.pm b/tools/test_modules/m28501.pm index 1892346a2..afd386fc9 100644 --- a/tools/test_modules/m28501.pm +++ b/tools/test_modules/m28501.pm @@ -26,7 +26,7 @@ sub module_constraints { [[52, 52], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { - my $word = shift; # expecting valid WIF formated private key + my $word = shift; # expecting valid WIF formatted private key my @is_valid_base58 = eval { diff --git a/tools/test_modules/m28502.pm b/tools/test_modules/m28502.pm index 430b968f7..fa0605023 100644 --- a/tools/test_modules/m28502.pm +++ b/tools/test_modules/m28502.pm @@ -26,7 +26,7 @@ sub module_constraints { [[51, 51], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { - my $word = shift; # expecting valid WIF formated private key + my $word = shift; # expecting valid WIF formatted private key my @is_valid_base58 = eval { diff --git a/tools/test_modules/m28503.pm b/tools/test_modules/m28503.pm index aa87d4255..b5438a5ac 100644 --- a/tools/test_modules/m28503.pm +++ b/tools/test_modules/m28503.pm @@ -26,7 +26,7 @@ sub module_constraints { [[52, 52], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { - my $word = shift; # expecting valid WIF formated private key + my $word = shift; # expecting valid WIF formatted private key my @is_valid_base58 = eval { diff --git a/tools/test_modules/m28504.pm b/tools/test_modules/m28504.pm index 05ebe9795..e48ccccdf 100644 --- a/tools/test_modules/m28504.pm +++ b/tools/test_modules/m28504.pm @@ -26,7 +26,7 @@ sub module_constraints { [[51, 51], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { - my $word = shift; # expecting valid WIF formated private key + my $word = shift; # expecting valid WIF formatted private key my @is_valid_base58 = eval { diff --git a/tools/test_modules/m28505.pm b/tools/test_modules/m28505.pm index 945dc0468..99600ef66 100644 --- a/tools/test_modules/m28505.pm +++ b/tools/test_modules/m28505.pm @@ -26,7 +26,7 @@ sub module_constraints { [[52, 52], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { - my $word = shift; # expecting valid WIF formated private key + my $word = shift; # expecting valid WIF formatted private key my @is_valid_base58 = eval { diff --git a/tools/test_modules/m28506.pm b/tools/test_modules/m28506.pm index a1e15e44d..962c3d219 100644 --- a/tools/test_modules/m28506.pm +++ b/tools/test_modules/m28506.pm @@ -26,7 +26,7 @@ sub module_constraints { [[51, 51], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { - my $word = shift; # expecting valid WIF formated private key + my $word = shift; # expecting valid WIF formatted private key my @is_valid_base58 = eval { diff --git a/tools/test_modules/m29800.pm b/tools/test_modules/m29800.pm index 8854632dd..85c0e8c37 100644 --- a/tools/test_modules/m29800.pm +++ b/tools/test_modules/m29800.pm @@ -12,7 +12,7 @@ use Crypt::ScryptKDF qw (scrypt_raw); use Encode; use Crypt::CBC; -sub module_constraints { [[0, 256], [8, 8], [-1, -1], [-1, -1], [-1, -1]] } +sub module_constraints { [[8, 256], [8, 8], [-1, -1], [-1, -1], [-1, -1]] } my $SCRYPT_N = 32768; my $SCRYPT_R = 8; diff --git a/tools/test_modules/m31400.pm b/tools/test_modules/m31400.pm index 60a855b6c..6eae0ef03 100644 --- a/tools/test_modules/m31400.pm +++ b/tools/test_modules/m31400.pm @@ -11,39 +11,36 @@ use warnings; use Digest::SHA qw (sha256_hex); use Crypt::CBC; -sub module_constraints { [[0, 256], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } +sub module_constraints { [[0, 55], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } sub calculate_padding { - my $length = shift; - my $blocksize = shift // 32; - my $minpadding = shift // 16; + my $length = shift; + my $blocksize = shift // 32; + my $minpadding = shift // 16; - my $padded_len=$length+$minpadding; - my $finalpadded=( ( $padded_len - 1 ) | ( $blocksize - 1 ) ) + 1; - - return $finalpadded - $length; + my $padded_len = $length+$minpadding; + my $finalpadded = (($padded_len - 1) | ($blocksize - 1)) + 1; + return $finalpadded - $length; } sub module_generate_hash { my $word = shift; - my $total_len = (length($word)*2) + 8 + 64; - my $padding = shift // random_hex_string (calculate_padding($total_len)); - - if (length $padding == 0){ - $padding=random_hex_string (calculate_padding($total_len)); - } + my $total_len = (length ($word) * 2) + 8 + 64; + my $padding = shift // random_hex_string (calculate_padding ($total_len)); + if (length $padding == 0) { + $padding = random_hex_string (calculate_padding ($total_len)); + } my $digest = sha256_hex ($word); - my $len = sprintf("%02d",length($word)); - my $paddedlen = sprintf("%02x000000", $len); - my $hexofword=unpack "H*",$word; + my $len = sprintf ("%02d", length ($word)); + my $paddedlen = sprintf ("%02x000000", $len); + my $hexofword = unpack "H*", $word; my $plaintext = $paddedlen . $hexofword . $digest . $padding; - my $aes = Crypt::CBC->new ({ key => pack ("H*", $digest), cipher => "Crypt::Rijndael", @@ -54,18 +51,18 @@ sub module_generate_hash padding => "none", }); - my $ciphertext=$aes->encrypt(pack("H*",$plaintext)); - my $hash = sprintf("S:\"Config Passphrase\"=02:%s",unpack ("H*",$ciphertext)); + my $ciphertext = $aes->encrypt (pack ("H*", $plaintext)); + my $hash = sprintf ("S:\"Config Passphrase\"=02:%s", unpack ("H*", $ciphertext)); return $hash } sub get_aes { - my $word_packed=shift; - my $key = sha256_hex ($word_packed); + my $word_packed = shift; + my $key = sha256_hex ($word_packed); - my $aes = Crypt::CBC->new ({ + my $aes = Crypt::CBC->new ({ key => pack ("H*", $key), cipher => "Crypt::Rijndael", iv => => "\x00" x 16, @@ -74,6 +71,7 @@ sub get_aes keysize => 32, padding => "none", }); + return $aes } @@ -87,11 +85,10 @@ sub module_verify_hash return unless defined $word; my $word_packed = pack_if_HEX_notation ($word); - my $decrypted = get_aes($word_packed)->decrypt(pack"H*", $hash); - my $plaintext_hex=unpack "H*",$decrypted; - my $passlen=hex(substr($plaintext_hex,0,2)); - my $padding = substr($plaintext_hex,8+2*$passlen+64); - + my $decrypted = get_aes ($word_packed)->decrypt (pack"H*", $hash); + my $plaintext_hex = unpack "H*", $decrypted; + my $passlen = hex (substr ($plaintext_hex, 0, 2)); + my $padding = substr ($plaintext_hex, 8 + 2 * $passlen + 64); my $new_hash = module_generate_hash ($word_packed,$padding); diff --git a/tools/test_modules/m31500.pm b/tools/test_modules/m31500.pm new file mode 100644 index 000000000..aad5eb32a --- /dev/null +++ b/tools/test_modules/m31500.pm @@ -0,0 +1,61 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD4 qw (md4_hex); +use Text::Iconv; +use Encode; + +sub module_constraints { [[32, 32], [0, 256], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_get_random_password +{ + my $word = shift; + + my $converter = Text::Iconv->new('utf8', 'UTF-16LE'); + + $word = md4_hex ($converter->convert ($word)); + + return $word; +} + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $word_bin = pack ("H*", $word); + + my $salt_bin = encode ("UTF-16LE", lc ($salt)); + + my $digest = md4_hex ($word_bin . $salt_bin); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m31600.pm b/tools/test_modules/m31600.pm new file mode 100644 index 000000000..ed425996e --- /dev/null +++ b/tools/test_modules/m31600.pm @@ -0,0 +1,88 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD4 qw (md4 md4_hex); +use Crypt::PBKDF2; +use Text::Iconv; +use Encode; + +sub module_constraints { [[32, 32], [0, 256], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_get_random_password +{ + my $word = shift; + + my $converter = Text::Iconv->new('utf8', 'UTF-16LE'); + + $word = md4_hex ($converter->convert ($word)); + + return $word; +} + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iterations = shift // 10240; + + my $salt_bin = encode ("UTF-16LE", lc ($salt)); + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => $iterations, + output_len => 16, + salt_len => length ($salt_bin), + ); + + my $word_bin = pack ("H*", $word); + + my $digest = unpack ("H*", $pbkdf2->PBKDF2 ($salt_bin, md4 ($word_bin . $salt_bin))); + + my $hash = sprintf ("\$DCC2\$%i#%s#%s", $iterations, $salt, $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $signature = substr ($hash, 0, 6); + + return unless ($signature eq '$DCC2$'); + + $hash = substr ($hash, 6); + + my @data = split ('#', $hash); + + return unless scalar @data == 3; + + my $iterations = shift @data; + my $salt = shift @data; + my $digest = shift @data; + + return unless defined $iterations; + return unless defined $salt; + return unless defined $digest; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt, $iterations); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m31700.pm b/tools/test_modules/m31700.pm new file mode 100644 index 000000000..f0f058656 --- /dev/null +++ b/tools/test_modules/m31700.pm @@ -0,0 +1,46 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); + +sub module_constraints { [[0, 256], [0, 256], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt1 = shift; + my $salt2 = shift || random_numeric_string (random_number (1, 255)); + + my $digest = md5_hex (md5_hex (md5_hex ($word) . $salt1) . $salt2); + + my $hash = sprintf ("%s:%s:%s", $digest, $salt1, $salt2); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt1, $salt2, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt1; + return unless defined $salt2; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt1, $salt2); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m31800.pm b/tools/test_modules/m31800.pm new file mode 100644 index 000000000..5a1fbf227 --- /dev/null +++ b/tools/test_modules/m31800.pm @@ -0,0 +1,134 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use Crypt::AuthEnc::GCM; +use MIME::Base64 qw (decode_base64 encode_base64); +use Crypt::KeyDerivation ':all'; + +sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $hkdf_salt = shift; + my $hkdf_key = shift // random_hex_string (64); + my $iterations = shift // 100000; + my $iv = shift // (random_number (0,1) ? random_hex_string (32) : random_hex_string (24)); + my $ct = shift; + my $tag = shift; + my $email = shift // "31800\@hashcat.net"; + + my $hkdf_salt_bin = pack ("H*", $hkdf_salt); + + my $kdf = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256), + iterations => $iterations, + output_len => 32 + ); + + my $password_key = $kdf->PBKDF2 ($hkdf_salt_bin, $word); + + my $hkdf_key_bin = pack ("H*", $hkdf_key); + + my $muk = xor_len ($password_key, $hkdf_key_bin, 32); + + my $pt; + + my $iv_bin = pack ("H*", $iv); + + if (defined $ct) + { + my $ct_bin = pack ("H*", $ct); + + my $tag_bin = pack ("H*", $tag); + + my $aes = Crypt::AuthEnc::GCM->new ("AES", $muk, $iv_bin); + + $pt = $aes->decrypt_add ($ct_bin); + + my $result_tag = $aes->decrypt_done ($tag_bin); + + if ($result_tag == 1) + { + ## correct password + } + else + { + $pt = "{'key_ops': ['decrypt', 'encrypt'], 'kty': 'oct', 'alg': 'A256GCM', 'k': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=', 'ext': True, 'kid': 'xxxxxxxxxxxxxxxxxxxxxxxxxx'}"; + } + } + else + { + $pt = "{'key_ops': ['decrypt', 'encrypt'], 'kty': 'oct', 'alg': 'A256GCM', 'k': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=', 'ext': True, 'kid': 'xxxxxxxxxxxxxxxxxxxxxxxxxx'}"; + } + + my $aes = Crypt::AuthEnc::GCM->new ("AES", $muk, $iv_bin); + + my $ct_bin = $aes->encrypt_add ($pt); + + my $tag_bin = $aes->encrypt_done (); + + ## so far so good + + my $hash = sprintf ('$mobilekeychain$%s$%s$%s$%u$%s$%s$%s', $email, unpack ("H*", $hkdf_salt_bin), unpack ("H*", $hkdf_key_bin), $iterations, unpack ("H*", $iv_bin), unpack ("H*", $ct_bin), unpack ("H*", $tag_bin)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 16) eq '$mobilekeychain$'; + + my (undef, $signature, $email, $hkdf_salt, $hkdf_key, $iterations, $iv, $ct, $tag) = split '\$', $hash; + + return unless defined $signature; + return unless defined $email; + return unless defined $hkdf_salt; + return unless defined $hkdf_key; + return unless defined $iterations; + return unless defined $iv; + return unless defined $ct; + return unless defined $tag; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $hkdf_salt, $hkdf_key, $iterations, $iv, $ct, $tag, $email); + + return ($new_hash, $word); +} + +sub xor_len +{ + my $in1 = shift; + my $in2 = shift; + my $len = shift; + + my $out; + + for (my $i = 0; $i < $len; $i++) + { + $out .= chr (ord (substr ($in1, $i, 1)) ^ ord (substr ($in2, $i, 1))); + } + + return $out; +} + +1; diff --git a/tools/test_modules/m31900.pm b/tools/test_modules/m31900.pm new file mode 100644 index 000000000..c3dbf5c91 --- /dev/null +++ b/tools/test_modules/m31900.pm @@ -0,0 +1,91 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use Crypt::CBC; +use MIME::Base64 qw (decode_base64 encode_base64); + +sub module_constraints { [[8, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iv = shift // random_hex_string (32); + my $ct = shift; + + my $kdf = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 512), + iterations => 5000, + output_len => 32 + ); + + my $salt_b64 = encode_base64 ($salt, ""); + + my $key = $kdf->PBKDF2 ($salt_b64, $word); + + my $iv_bin = pack ("H*", $iv); + + my $cipher = Crypt::CBC->new ({ + key => $key, + cipher => "Crypt::Rijndael", + iv => $iv_bin, + literal_key => 1, + header => "none", + keysize => 32, + padding => "none" + }); + + my $pt = "[{\"type\":\"HD Key Tree\",\"data\":{\"mnemonic\":\"ocean hidden kidney famous rich season gloom husband spring convince attitude boy\",\"numberOfAccounts\":1,\"hdPath\":\"m/44'/60'/0'/0\"}}]"; + + my $ct1 = substr ($cipher->encrypt ($pt), 0, 16); + + my $hash = sprintf ('$metamaskMobile$%s$%s$%s', $salt_b64, $iv, encode_base64 ($ct1, "")); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 16) eq '$metamaskMobile$'; + + my (undef, $signature, $salt, $iv, $ct) = split '\$', $hash; + + return unless defined $signature; + return unless defined $salt; + return unless defined $iv; + return unless defined $ct; + + my $salt_b64 = decode_base64 ($salt); + my $iv_bin = pack ("H*", $iv); + my $ct_bin = decode_base64 ($ct); + + return unless length $salt_b64 == 16; + return unless length $iv_bin == 16; + return unless length $ct_bin == 16; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt_b64, $iv, unpack ("H*", $ct_bin)); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32000.pm b/tools/test_modules/m32000.pm new file mode 100644 index 000000000..44f016466 --- /dev/null +++ b/tools/test_modules/m32000.pm @@ -0,0 +1,71 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5; + +sub module_constraints { [[0, 256], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $md5 = Digest::MD5->new; + + $md5->add ($word); + + for (my $i = 1; $i < 100000; $i++) + { + my $tmp = $md5->digest; + + $md5->reset; + + $md5->add ($tmp); + } + + my $digest = $md5->digest; + + my $hash = sprintf ('$sspr$0$100000$NONE$%s', unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 20) eq '$sspr$0$100000$NONE$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 0; + return unless $iter == 100000; + return unless $salt eq "NONE"; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32010.pm b/tools/test_modules/m32010.pm new file mode 100644 index 000000000..5c472658c --- /dev/null +++ b/tools/test_modules/m32010.pm @@ -0,0 +1,71 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA1; + +sub module_constraints { [[0, 256], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $sha1 = Digest::SHA1->new; + + $sha1->add ($word); + + for (my $i = 1; $i < 100000; $i++) + { + my $tmp = $sha1->digest; + + $sha1->reset; + + $sha1->add ($tmp); + } + + my $digest = $sha1->digest; + + my $hash = sprintf ('$sspr$1$100000$NONE$%s', unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 20) eq '$sspr$1$100000$NONE$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 1; + return unless $iter == 100000; + return unless $salt eq "NONE"; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32020.pm b/tools/test_modules/m32020.pm new file mode 100644 index 000000000..eac5a5ec1 --- /dev/null +++ b/tools/test_modules/m32020.pm @@ -0,0 +1,78 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA1; +use MIME::Base64 qw (decode_base64 encode_base64); + +sub module_constraints { [[0, 256], [24, 24], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $salt_b64 = encode_base64 ($salt, ""); + + my $sha1 = Digest::SHA1->new; + + $sha1->add ($salt_b64 . $word); + + for (my $i = 1; $i < 100000; $i++) + { + my $tmp = $sha1->digest; + + $sha1->reset; + + $sha1->add ($tmp); + } + + my $digest = $sha1->digest; + + my $hash = sprintf ('$sspr$2$100000$%s$%s', $salt_b64, unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 15) eq '$sspr$2$100000$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 2; + return unless $iter == 100000; + return unless length $salt == 32; + + my $salt_b64 = decode_base64 ($salt); + + return unless length $salt_b64 == 24; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt_b64); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32030.pm b/tools/test_modules/m32030.pm new file mode 100644 index 000000000..e077f4eca --- /dev/null +++ b/tools/test_modules/m32030.pm @@ -0,0 +1,78 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA; +use MIME::Base64 qw (decode_base64 encode_base64); + +sub module_constraints { [[0, 256], [24, 24], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $salt_b64 = encode_base64 ($salt, ""); + + my $sha256 = Digest::SHA->new(256); + + $sha256->add ($salt_b64 . $word); + + for (my $i = 1; $i < 100000; $i++) + { + my $tmp = $sha256->digest; + + $sha256->reset; + + $sha256->add ($tmp); + } + + my $digest = $sha256->digest; + + my $hash = sprintf ('$sspr$3$100000$%s$%s', $salt_b64, unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 15) eq '$sspr$3$100000$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 3; + return unless $iter == 100000; + return unless length $salt == 32; + + my $salt_b64 = decode_base64 ($salt); + + return unless length $salt_b64 == 24; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt_b64); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32031.pm b/tools/test_modules/m32031.pm new file mode 100644 index 000000000..e7f39fc8e --- /dev/null +++ b/tools/test_modules/m32031.pm @@ -0,0 +1,71 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA; + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $sha256 = Digest::SHA->new(256); + + $sha256->add ($salt . $word); + + for (my $i = 1; $i < 1000; $i++) + { + my $tmp = $sha256->digest; + + $sha256->reset; + + $sha256->add ($tmp); + } + + my $digest = $sha256->digest; + + my $hash = sprintf ('$sspr$3$1000$%s$%s', $salt, unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 13) eq '$sspr$3$1000$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 3; + return unless $iter == 1000; + return unless length $salt == 16; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32040.pm b/tools/test_modules/m32040.pm new file mode 100644 index 000000000..5446fa01d --- /dev/null +++ b/tools/test_modules/m32040.pm @@ -0,0 +1,78 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA; +use MIME::Base64 qw (decode_base64 encode_base64); + +sub module_constraints { [[0, 256], [24, 24], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $salt_b64 = encode_base64 ($salt, ""); + + my $sha512 = Digest::SHA->new(512); + + $sha512->add ($salt_b64 . $word); + + for (my $i = 1; $i < 100000; $i++) + { + my $tmp = $sha512->digest; + + $sha512->reset; + + $sha512->add ($tmp); + } + + my $digest = $sha512->digest; + + my $hash = sprintf ('$sspr$4$100000$%s$%s', $salt_b64, unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 15) eq '$sspr$4$100000$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 4; + return unless $iter == 100000; + return unless length $salt == 32; + + my $salt_b64 = decode_base64 ($salt); + + return unless length $salt_b64 == 24; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt_b64); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32041.pm b/tools/test_modules/m32041.pm new file mode 100644 index 000000000..380ccabf2 --- /dev/null +++ b/tools/test_modules/m32041.pm @@ -0,0 +1,71 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA; + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $sha512 = Digest::SHA->new(512); + + $sha512->add ($salt . $word); + + for (my $i = 1; $i < 1000; $i++) + { + my $tmp = $sha512->digest; + + $sha512->reset; + + $sha512->add ($tmp); + } + + my $digest = $sha512->digest; + + my $hash = sprintf ('$sspr$4$1000$%s$%s', $salt, unpack ("H*", $digest)); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 13) eq '$sspr$4$1000$'; + + my (undef, $signature, $version, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $version; + return unless defined $iter; + return unless defined $salt; + + return unless $version == 4; + return unless $iter == 1000; + return unless length $salt == 16; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32050.pm b/tools/test_modules/m32050.pm new file mode 100644 index 000000000..e24e5298b --- /dev/null +++ b/tools/test_modules/m32050.pm @@ -0,0 +1,65 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; + +sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + $salt = pack ("H*", $salt); + + my $kdf = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => 100000, + output_len => 20 + ); + + my $key = $kdf->PBKDF2_hex ($salt, $word); + + my $hash = sprintf ('$pbkdf2-hmac-sha1$100000$%s$%s', unpack ("H*", $salt), $key); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 25) eq '$pbkdf2-hmac-sha1$100000$'; + + my (undef, $signature, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $iter; + return unless defined $salt; + + return unless $iter == 100000; + return unless length $salt == 64; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32060.pm b/tools/test_modules/m32060.pm new file mode 100644 index 000000000..09f55a781 --- /dev/null +++ b/tools/test_modules/m32060.pm @@ -0,0 +1,80 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use MIME::Base64 qw (encode_base64 decode_base64); + +sub module_constraints { [[0, 256], [32, 32], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $pbkdf2 = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256), + iterations => 100000, + ); + + my $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt, $word), ""); + + my $salt_buf = encode_base64 ($salt, ""); + + # replace + with . + $hash_buf =~ s/\+/\./g; + $salt_buf =~ s/\+/\./g; + + # remove padding = + $hash_buf =~ s/\=+$//; + $salt_buf =~ s/\=+$//; + + my $hash = sprintf ('$pbkdf2-sha256$100000$%s$%s', $salt_buf, $hash_buf); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 22) eq '$pbkdf2-sha256$100000$'; + + my (undef, $signature, $iter, $salt) = split '\$', $hash; + + return unless defined $signature; + return unless defined $iter; + return unless defined $salt; + + return unless $iter == 100000; + return unless length $salt == 43; + + $salt =~ s/\./\+/g; + $salt .= '=='; + + my $salt_b64 = decode_base64 ($salt); + + return unless length $salt_b64 == 32; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt_b64); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32070.pm b/tools/test_modules/m32070.pm new file mode 100644 index 000000000..83083f295 --- /dev/null +++ b/tools/test_modules/m32070.pm @@ -0,0 +1,68 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; + +sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + $salt = pack ("H*", $salt); + + my $kdf = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 512), + iterations => 100000, + ); + + my $key = $kdf->PBKDF2_hex ($salt, $word); + + my $hash = sprintf ('$pbkdf2-hmac-sha512$100000.%s.%s', unpack ("H*", $salt), $key); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $idx = index ($line, ':'); + + return unless $idx >= 0; + + my $hash = substr ($line, 0, $idx); + my $word = substr ($line, $idx + 1); + + return unless substr ($hash, 0, 27) eq '$pbkdf2-hmac-sha512$100000.'; + + my (undef, $signature, $tmp) = split '\$', $hash; + + return unless defined $signature; + return unless defined $tmp; + + my ($iter, $salt) = split '\.', $tmp; + + return unless defined $iter; + return unless defined $salt; + + return unless $iter == 100000; + return unless length $salt == 64; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32100.pm b/tools/test_modules/m32100.pm new file mode 100644 index 000000000..499eddd12 --- /dev/null +++ b/tools/test_modules/m32100.pm @@ -0,0 +1,217 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (hmac_sha1); +use Crypt::Mode::CBC; +use Crypt::PBKDF2; + +sub byte2hex +{ + my $input = shift; + return unpack ("H*", $input); +} + +sub hex2byte +{ + my $input = shift; + return pack ("H*", $input); +} + +sub pad +{ + my $n = shift; + my $size = shift; + + return (~$n + 1) & ($size - 1); +} + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $user = shift // "user"; + my $realm = shift // "example.com"; + my $checksum = shift; + my $edata2 = shift; + + my $mysalt = uc $realm; + $mysalt = $mysalt . $user; + + # first we generate the 'seed' + my $iter = 4096; + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => $iter, + output_len => 16 + ); + + my $b_seed = $pbkdf2->PBKDF2 ($mysalt, $word); + + # we can precompute this + my $b_kerberos_nfolded = hex2byte ('6b65726265726f737b9b5b2b93132b93'); + + my $b_iv = hex2byte ('0' x 32); + + # 'key_bytes' will be the AES key used to generate 'ki' (for final hmac-sha1) + # and 'ke' (AES key to decrypt/encrypt the ticket) + my $cbc = Crypt::Mode::CBC->new ('AES', 0); + my $b_key_bytes = $cbc->encrypt ($b_kerberos_nfolded, $b_seed, $b_iv); + + # precomputed stuff + my $b_nfolded1 = hex2byte ('6b60b0582a6ba80d5aad56ab55406ad5'); + my $b_nfolded2 = hex2byte ('be349a4d24be500eaf57abd5ea80757a'); + + my $b_ki = $cbc->encrypt ($b_nfolded1, $b_key_bytes, $b_iv); + my $b_ke = $cbc->encrypt ($b_nfolded2, $b_key_bytes, $b_iv); + + my $cleartext_ticket = '7981df3081dca01b3019a003020111a1120410e2aa1c894df7'. + '23b7277eef29700bf760a11c301a3018a003020100a111180f32303233303333313132303'. + '434355aa20602041d9d970ba311180f32303337303931343032343830355aa40703050040'. + 'c10000a511180f32303233303333313132303434355aa611180f323032333033333131323'. + '03434355aa711180f32303233303333313232303434355aa811180f323032333034303731'. + '32303434355aa90d1b0b4558414d504c452e434f4daa20301ea003020102a11730151b066'. + 'b72627467741b0b6578616d706c652e636f6d'; + + if (defined $edata2) + { + my $len_last_block = length ($edata2) % 32; + + my $tmp = $len_last_block + 32; + + my $b_truncated_enc_ticket = hex2byte (substr $edata2, 0, -$tmp); + + my $b_last_block = hex2byte (substr $edata2, -$len_last_block); + + my $b_n_1_block = hex2byte (substr (substr ($edata2, -$tmp), 0, 32)); + + my $b_truncated_ticket_decrypted = $cbc->decrypt ($b_truncated_enc_ticket, $b_ke, $b_iv); + + my $truncated_ticket_decrypted = byte2hex ($b_truncated_ticket_decrypted); + + my $check_correct = ((substr ($truncated_ticket_decrypted, 16, 4) eq "7981" || substr ($truncated_ticket_decrypted, 16, 4) eq "7a81") && (substr ($truncated_ticket_decrypted, 22, 2) eq "30")) || + ((substr ($truncated_ticket_decrypted, 16, 2) eq "79" || substr ($truncated_ticket_decrypted, 16, 2) eq "7a") && (substr ($truncated_ticket_decrypted, 20, 2) eq "30")) || + ((substr ($truncated_ticket_decrypted, 16, 4) eq "7982" || substr ($truncated_ticket_decrypted, 16, 4) eq "7a82") && (substr ($truncated_ticket_decrypted, 24, 2) eq "30")); + + if ($check_correct == 1) + { + my $b_n_2 = substr $b_truncated_enc_ticket, -16; + + my $b_n_1_decrypted = $cbc->decrypt ($b_n_1_block, $b_ke, $b_iv); + + my $b_last_plain = substr $b_n_1_decrypted, 0, $len_last_block / 2; + + $b_last_plain = $b_last_plain ^ $b_last_block; + + my $omitted = substr $b_n_1_decrypted, -(16 - $len_last_block / 2); + + my $b_n_1 = $b_last_block . $omitted; + + $b_n_1 = $cbc->decrypt ($b_n_1, $b_ke, $b_iv); + + $b_n_1 = $b_n_1 ^ $b_n_2; + + my $b_cleartext_ticket = $b_truncated_ticket_decrypted . $b_n_1 . $b_last_plain; + + $cleartext_ticket = byte2hex ($b_cleartext_ticket); + } + else # validation failed + { + # fake/wrong ticket (otherwise if we just decrypt/encrypt we end + #up with false positives all the time) + $cleartext_ticket = "0" x (length ($cleartext_ticket) + 32); + } + } + + if (defined $checksum) + { + $checksum = pack ("H*", $checksum); + } + else + { + if (!defined $edata2) + { + my $nonce = unpack ("H*", random_bytes (16)); + + $cleartext_ticket = $nonce . $cleartext_ticket; + } + # we have what is required to compute checksum + $checksum = hmac_sha1 (hex2byte ($cleartext_ticket), $b_ki); + + $checksum = substr $checksum, 0, 12; + } + + my $len_cleartext_last_block = length ($cleartext_ticket) % 32; + my $cleartext_last_block = substr $cleartext_ticket, -$len_cleartext_last_block; + + my $padding = pad (length ($cleartext_ticket), 32); + + my $b_cleartext_last_block_padded = hex2byte ($cleartext_last_block . '0' x $padding); + + # we will encrypt until n-1 block (included) + my $truncated_cleartext_ticket = substr $cleartext_ticket, 0, -$len_cleartext_last_block; + + my $b_truncated_enc_ticket = $cbc->encrypt (hex2byte ($truncated_cleartext_ticket), $b_ke, $b_iv); + + my $b_enc_ticket_n_1_block= substr $b_truncated_enc_ticket, -16; + + my $b_enc_last_block = substr $b_enc_ticket_n_1_block, 0, $len_cleartext_last_block / 2; + + # we now craft the new n-1 block + my $tmp = $b_enc_ticket_n_1_block ^ $b_cleartext_last_block_padded; + + $b_enc_ticket_n_1_block = $cbc->encrypt ($tmp, $b_ke, $b_iv); + + $tmp = substr $b_truncated_enc_ticket, 0, -16; + + $edata2 = $tmp . $b_enc_ticket_n_1_block . $b_enc_last_block; + + my $tmp_hash = sprintf ('$krb5asrep$17$%s$%s$%s$%s', $user, $realm, unpack ("H*", $checksum), unpack ("H*", $edata2)); + + return $tmp_hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my @data = split ('\$', $hash); + + return unless scalar @data == 7; + + shift @data; + + my $signature = shift @data; + my $algorithm = shift @data; + my $user = shift @data; + my $realm = shift @data; + my $checksum = shift @data; + my $edata2 = shift @data; + + return unless ($signature eq "krb5asrep"); + return unless ($algorithm eq "17"); + return unless (length ($checksum) == 24); + return unless (length ($edata2) >= 64); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, undef, $user, $realm, $checksum, $edata2); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32200.pm b/tools/test_modules/m32200.pm new file mode 100644 index 000000000..6a3710621 --- /dev/null +++ b/tools/test_modules/m32200.pm @@ -0,0 +1,224 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (hmac_sha1); +use Crypt::Mode::CBC; +use Crypt::PBKDF2; + +sub byte2hex +{ + my $input = shift; + return unpack ("H*", $input); +} + +sub hex2byte +{ + my $input = shift; + return pack ("H*", $input); +} + +sub pad +{ + my $n = shift; + my $size = shift; + + return (~$n + 1) & ($size - 1); +} + +sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $user = shift // "user"; + my $realm = shift // "example.com"; + my $checksum = shift; + my $edata2 = shift; + + my $mysalt = uc $realm; + $mysalt = $mysalt . $user; + + # first we generate the 'seed' + my $iter = 4096; + my $pbkdf2 = Crypt::PBKDF2->new + ( + hash_class => 'HMACSHA1', + iterations => $iter, + output_len => 32 + ); + + my $b_seed = $pbkdf2->PBKDF2 ($mysalt, $word); + + # we can precompute this + my $b_kerberos_nfolded = hex2byte ('6b65726265726f737b9b5b2b93132b93'); + + my $b_iv = hex2byte ('0' x 32); + + # 'key_bytes' will be the AES key used to generate 'ki' (for final hmac-sha1) + # and 'ke' (AES key to decrypt/encrypt the ticket) + my $cbc = Crypt::Mode::CBC->new ('AES', 0); + my $b_key_bytes = $cbc->encrypt ($b_kerberos_nfolded, $b_seed, $b_iv); + + $b_key_bytes = $b_key_bytes . $cbc->encrypt ($b_key_bytes, $b_seed, $b_iv); + + # precomputed stuff + my $b_nfolded1 = hex2byte ('6b60b0582a6ba80d5aad56ab55406ad5'); + my $b_nfolded2 = hex2byte ('be349a4d24be500eaf57abd5ea80757a'); + + my $b_ki = $cbc->encrypt ($b_nfolded1, $b_key_bytes, $b_iv); + + $b_ki = $b_ki . $cbc->encrypt ($b_ki, $b_key_bytes, $b_iv); + + my $b_ke = $cbc->encrypt ($b_nfolded2, $b_key_bytes, $b_iv); + + $b_ke = $b_ke . $cbc->encrypt ($b_ke, $b_key_bytes, $b_iv); + + my $cleartext_ticket = '7981ef3081eca02b3029a003020112a12204200e97d1626616'. + '6e06252cbec52003e0f6b4f0280deec6dc58cdbf39845d6f0e77a11c301a3018a00302010'. + '0a111180f32303233303331363135353732315aa20602045b66ac3ea311180f3230333730'. + '3931343032343830355aa40703050050c10000a511180f323032333033313631353537323'. + '15aa611180f32303233303331363135353732315aa711180f323032333033313730313537'. + '32315aa811180f32303233303331373135353732315aa90d1b0b4558414d504c452e434f4'. + 'daa20301ea003020101a11730151b066b72627467741b0b4558414d504c452e434f4d'; + + if (defined $edata2) + { + my $len_last_block = length ($edata2) % 32; + + my $tmp = $len_last_block + 32; + + my $b_truncated_enc_ticket = hex2byte (substr $edata2, 0, -$tmp); + + my $b_last_block = hex2byte (substr $edata2, -$len_last_block); + + my $b_n_1_block = hex2byte (substr (substr ($edata2, -$tmp), 0, 32)); + + my $b_truncated_ticket_decrypted = $cbc->decrypt ($b_truncated_enc_ticket, $b_ke, $b_iv); + + my $truncated_ticket_decrypted = byte2hex ($b_truncated_ticket_decrypted); + + my $check_correct = ((substr ($truncated_ticket_decrypted, 16, 4) eq "7981" || substr ($truncated_ticket_decrypted, 16, 4) eq "7a81") && (substr ($truncated_ticket_decrypted, 22, 2) eq "30")) || + ((substr ($truncated_ticket_decrypted, 16, 2) eq "79" || substr ($truncated_ticket_decrypted, 16, 2) eq "7a") && (substr ($truncated_ticket_decrypted, 20, 2) eq "30")) || + ((substr ($truncated_ticket_decrypted, 16, 4) eq "7982" || substr ($truncated_ticket_decrypted, 16, 4) eq "7a82") && (substr ($truncated_ticket_decrypted, 24, 2) eq "30")); + + if ($check_correct == 1) + { + my $b_n_2 = substr $b_truncated_enc_ticket, -16; + + my $b_n_1_decrypted = $cbc->decrypt ($b_n_1_block, $b_ke, $b_iv); + + my $b_last_plain = substr $b_n_1_decrypted, 0, $len_last_block / 2; + + $b_last_plain = $b_last_plain ^ $b_last_block; + + my $omitted = substr $b_n_1_decrypted, -(16 - $len_last_block / 2); + + my $b_n_1 = $b_last_block . $omitted; + + $b_n_1 = $cbc->decrypt ($b_n_1, $b_ke, $b_iv); + + $b_n_1 = $b_n_1 ^ $b_n_2; + + my $b_cleartext_ticket = $b_truncated_ticket_decrypted . $b_n_1 . $b_last_plain; + + $cleartext_ticket = byte2hex ($b_cleartext_ticket); + } + else # validation failed + { + # fake/wrong ticket (otherwise if we just decrypt/encrypt we end + #up with false positives all the time) + $cleartext_ticket = "0" x (length ($cleartext_ticket) + 32); + } + } + + if (defined $checksum) + { + $checksum = pack ("H*", $checksum); + } + else + { + if (!defined $edata2) + { + my $nonce = unpack ("H*", random_bytes (16)); + + $cleartext_ticket = $nonce . $cleartext_ticket; + } + # we have what is required to compute checksum + $checksum = hmac_sha1 (hex2byte ($cleartext_ticket), $b_ki); + + $checksum = substr $checksum, 0, 12; + } + + my $len_cleartext_last_block = length ($cleartext_ticket) % 32; + my $cleartext_last_block = substr $cleartext_ticket, -$len_cleartext_last_block; + + my $padding = pad (length ($cleartext_ticket), 32); + + my $b_cleartext_last_block_padded = hex2byte ($cleartext_last_block . '0' x $padding); + + # we will encrypt until n-1 block (included) + my $truncated_cleartext_ticket = substr $cleartext_ticket, 0, -$len_cleartext_last_block; + + my $b_truncated_enc_ticket = $cbc->encrypt (hex2byte ($truncated_cleartext_ticket), $b_ke, $b_iv); + + my $b_enc_ticket_n_1_block= substr $b_truncated_enc_ticket, -16; + + my $b_enc_last_block = substr $b_enc_ticket_n_1_block, 0, $len_cleartext_last_block / 2; + + # we now craft the new n-1 block + my $tmp = $b_enc_ticket_n_1_block ^ $b_cleartext_last_block_padded; + + $b_enc_ticket_n_1_block = $cbc->encrypt ($tmp, $b_ke, $b_iv); + + $tmp = substr $b_truncated_enc_ticket, 0, -16; + + $edata2 = $tmp . $b_enc_ticket_n_1_block . $b_enc_last_block; + + my $tmp_hash = sprintf ('$krb5asrep$18$%s$%s$%s$%s', $user, $realm, unpack ("H*", $checksum), unpack ("H*", $edata2)); + + return $tmp_hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my @data = split ('\$', $hash); + + return unless scalar @data == 7; + + shift @data; + + my $signature = shift @data; + my $algorithm = shift @data; + my $user = shift @data; + my $realm = shift @data; + my $checksum = shift @data; + my $edata2 = shift @data; + + return unless ($signature eq "krb5asrep"); + return unless ($algorithm eq "18"); + return unless (length ($checksum) == 24); + return unless (length ($edata2) >= 64); + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, undef, $user, $realm, $checksum, $edata2); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32300.pm b/tools/test_modules/m32300.pm new file mode 100644 index 000000000..d9bf0bb8d --- /dev/null +++ b/tools/test_modules/m32300.pm @@ -0,0 +1,59 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); + +sub module_constraints { [[0, 256], [0, 246], [0, 31], [0, 41], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt1 = shift; + + my $IS_OPTIMIZED = 1; + + if (exists $ENV{"IS_OPTIMIZED"} && defined $ENV{"IS_OPTIMIZED"}) + { + $IS_OPTIMIZED = $ENV{"IS_OPTIMIZED"}; + } + + my $salt2_max_len = $IS_OPTIMIZED == 1 ? 33 : 238; + + my $salt2 = shift || random_numeric_string (random_number (0, $salt2_max_len)); + + my $empireCMS_salt1 = 'E!m^p-i(r#e.C:M?S'; + my $empireCMS_salt2 = 'd)i.g^o-d'; + + my $digest = md5_hex ($salt2 . $empireCMS_salt1 . md5_hex (md5_hex ($word) . $salt1) . $empireCMS_salt2 . $salt1); + + my $hash = sprintf ("%s:%s:%s", $digest, $salt1, $salt2); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt1, $salt2, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt1; + return unless defined $salt2; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt1, $salt2); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32410.pm b/tools/test_modules/m32410.pm new file mode 100644 index 000000000..658251704 --- /dev/null +++ b/tools/test_modules/m32410.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha512_hex (sha512_hex ($word) . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32420.pm b/tools/test_modules/m32420.pm new file mode 100644 index 000000000..61211f04e --- /dev/null +++ b/tools/test_modules/m32420.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_hex sha512); + +sub module_constraints { [[0, 256], [0, 256], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha512_hex (sha512 ($word) . $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m32600.pm b/tools/test_modules/m32600.pm new file mode 100644 index 000000000..b1a13d59f --- /dev/null +++ b/tools/test_modules/m32600.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::Digest::Whirlpool qw (whirlpool_hex); + +sub module_constraints { [[0, 256], [0, 256], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = whirlpool_hex ($salt, $word, $salt); + + my $hash = sprintf ("%s:%s", $digest, $salt); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $salt, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $salt; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; diff --git a/tunings/Alias.hctune b/tunings/Alias.hctune index 67d2d0bb2..d46e20d6e 100644 --- a/tunings/Alias.hctune +++ b/tunings/Alias.hctune @@ -165,12 +165,26 @@ Tesla_P4 ALIAS_nv_sm50_or_higher Tesla_P40 ALIAS_nv_sm50_or_higher Tesla_P100 ALIAS_nv_sm50_or_higher Tesla_V100 ALIAS_nv_sm50_or_higher +Tesla_T4 ALIAS_nv_sm50_or_higher + +L4 ALIAS_nv_sm50_or_higher + +A100-SXM4-40GB ALIAS_nv_sm50_or_higher +A100-SXM4-80GB ALIAS_nv_sm50_or_higher +A100-PCIE-40GB ALIAS_nv_sm50_or_higher +A100-PCIE-80GB ALIAS_nv_sm50_or_higher Quadro_M2000 ALIAS_nv_sm50_or_higher Quadro_M4000 ALIAS_nv_sm50_or_higher Quadro_M5000 ALIAS_nv_sm50_or_higher Quadro_M6000 ALIAS_nv_sm50_or_higher +Quadro_RTX_4000 ALIAS_nv_sm50_or_higher +Quadro_RTX_5000 ALIAS_nv_sm50_or_higher +Quadro_RTX_6000 ALIAS_nv_sm50_or_higher + +RTX_A6000 ALIAS_nv_sm50_or_higher + TITAN_X ALIAS_nv_sm50_or_higher TITAN_Xp ALIAS_nv_sm50_or_higher TITAN_V ALIAS_nv_sm50_or_higher @@ -236,10 +250,13 @@ GeForce_RTX_3080_Ti ALIAS_nv_sm50_or_higher GeForce_RTX_3090 ALIAS_nv_sm50_or_higher GeForce_RTX_3090_Ti ALIAS_nv_sm50_or_higher +GeForce_RTX_4070 ALIAS_nv_sm50_or_higher GeForce_RTX_4070_Ti ALIAS_nv_sm50_or_higher GeForce_RTX_4080 ALIAS_nv_sm50_or_higher GeForce_RTX_4090 ALIAS_nv_sm50_or_higher + + ## ## Unmapped GPU ## diff --git a/tunings/Module_08900.hctune b/tunings/Module_08900.hctune index e9ed6e64d..8aabacba9 100644 --- a/tunings/Module_08900.hctune +++ b/tunings/Module_08900.hctune @@ -29,6 +29,7 @@ GeForce_RTX_3060_Ti * 8900 1 51 GeForce_RTX_3070 * 8900 1 46 A GeForce_RTX_3090 * 8900 1 82 A GeForce_RTX_3090_Ti * 8900 1 84 A +GeForce_RTX_4090 * 8900 1 180 A NVS_510 * 8900 1 12 A ALIAS_AMD_RX480 * 8900 1 15 A ALIAS_AMD_Vega64 * 8900 1 30 A diff --git a/tunings/Module_15700.hctune b/tunings/Module_15700.hctune index fca474826..dd67e5f42 100644 --- a/tunings/Module_15700.hctune +++ b/tunings/Module_15700.hctune @@ -4,7 +4,7 @@ # # 1. For example, to find the value for 15700, first create a valid hash for 15700 as follows: # -# $ ./hashcat --example-hashes -m 15700 | grep Example.Hash | grep -v Format | cut -b 25- > tmp.hash.15700 +# $ ./hashcat --example-hashes --mach -m 15700 | grep -Eo '\$ethereum\$s[*a-f0-9]{1,}' > tmp.hash.15700 # # 2. Now let it iterate through all -n values to a certain point. In this case, I'm using 200, but in general it's a value that is at least twice that of the multiprocessor. If you don't mind you can just leave it as it is, it just runs a little longer. # @@ -29,6 +29,7 @@ GeForce_RTX_3060_Ti * 15700 1 11 GeForce_RTX_3070 * 15700 1 22 A GeForce_RTX_3090 * 15700 1 82 A GeForce_RTX_3090_Ti * 15700 1 84 A +GeForce_RTX_4090 * 15700 1 180 A ALIAS_AMD_RX480 * 15700 1 58 A ALIAS_AMD_Vega64 * 15700 1 53 A ALIAS_AMD_MI100 * 15700 1 120 A diff --git a/tunings/Module_22700.hctune b/tunings/Module_22700.hctune index 1b9b35414..2409eefff 100644 --- a/tunings/Module_22700.hctune +++ b/tunings/Module_22700.hctune @@ -29,6 +29,7 @@ GeForce_RTX_3060_Ti * 22700 1 51 GeForce_RTX_3070 * 22700 1 46 A GeForce_RTX_3090 * 22700 1 82 A GeForce_RTX_3090_Ti * 22700 1 84 A +GeForce_RTX_4090 * 22700 1 180 A NVS_510 * 22700 1 12 A ALIAS_AMD_RX480 * 22700 1 15 A ALIAS_AMD_Vega64 * 22700 1 30 A diff --git a/tunings/Module_27700.hctune b/tunings/Module_27700.hctune index d94f61094..4121ae1a4 100644 --- a/tunings/Module_27700.hctune +++ b/tunings/Module_27700.hctune @@ -29,6 +29,7 @@ GeForce_RTX_3060_Ti * 27700 1 51 GeForce_RTX_3070 * 27700 1 46 A GeForce_RTX_3090 * 27700 1 82 A GeForce_RTX_3090_Ti * 27700 1 84 A +GeForce_RTX_4090 * 27700 1 180 A NVS_510 * 27700 1 12 A ALIAS_AMD_RX480 * 27700 1 15 A ALIAS_AMD_Vega64 * 27700 1 30 A diff --git a/tunings/Module_28200.hctune b/tunings/Module_28200.hctune index 98b4c27e6..a01f9a24d 100644 --- a/tunings/Module_28200.hctune +++ b/tunings/Module_28200.hctune @@ -29,6 +29,7 @@ GeForce_RTX_3060_Ti * 28200 1 51 GeForce_RTX_3070 * 28200 1 46 A GeForce_RTX_3090 * 28200 1 82 A GeForce_RTX_3090_Ti * 28200 1 84 A +GeForce_RTX_4090 * 28200 1 180 A NVS_510 * 28200 1 12 A ALIAS_AMD_RX480 * 28200 1 15 A ALIAS_AMD_Vega64 * 28200 1 30 A diff --git a/tunings/README.md b/tunings/README.md index e917b0b20..d56b9064a 100644 --- a/tunings/README.md +++ b/tunings/README.md @@ -20,6 +20,7 @@ Each file in this folder with the filename suffix .hctune will be automatically - Invalid lines are ignored - The Device-Name is the OpenCL Device-Name. It's shown on hashcat startup. - If the device contains spaces, replace all spaces with _ character. + - Device Names prefixed with 'NVIDIA' will be matched with or without 'NVIDIA' present in the alias. e.g. 'NVIDIA_Tesla_T4' vs 'Tesla_T4' - The Device-Name can be assigned an alias. This is useful if many devices share the same chip - If you assign an alias, make sure to not use the devices name directly - There's also a hard-wired Device-Name which matches all device types called: