verify_result is a command-line verification tool for reduced-round SHA-256 and SHA-512 compression results.
The program reads a configuration file, applies the selected verification mode, computes the hash states for two candidate message blocks, and reports whether the two outputs collide.
- SHA-256 verification
- SHA-512 verification
- Free-start collision verification
- Semi-free-start collision verification
- Standard initial-value collision verification
- One-block and two-block message chaining controlled by
Message_count
Open a terminal in the verify_result directory and compile the program with:
g++ -std=c++17 main.cpp -o check_valueRun the executable with a configuration file:
./check_value <config_file>If no configuration file is provided, the program prints:
Usage: ./check_value <config_file>
The configuration file uses the format:
key: value;
Each field must appear on its own line.
Example:
Message_count: 2;
Version: SHA256;
Round: 31;
Type: Collision;
MSG0: 0x8ce3f805,0x5c401aed,0x579e5f7f,0xbc3116cb,0xca189b3c,0xeb75f04c,0x958f0a0e,0x7760b082,0xdcd5027d,0x32260ad6,0x7b12b659,0xeee66518,0xad7f88dd,0xf8ad20bb,0x7ae40ffd,0x21609249;
MSG1: 0x9abdeb1b,0x1f195f41,0x5a7210c1,0x55614f13,0xa2269dd1,0xbe888a61,0x359257d4,0xadf3737b,0x9f0484a6,0xeb830a58,0x66add94a,0x9669232d,0x45271fa5,0xb8f69585,0x428bbce3,0x0703b904;
MSG2: 0x9abdeb1b,0x1f195f41,0x5a7210c1,0x55614f13,0xa2269dd1,0xbe887a67,0x35b2dfc5,0xfde32975,0xc70595a6,0xeb838a5c,0x66add94a,0x9669232d,0x45271fa5,0xb8f69585,0x428bbce3,0x0703b904;
Specifies how many message stages are used in the verification process.
Currently supported values:
12
Selects the hash function.
Allowed values:
SHA256SHA512
Specifies the number of compression rounds to execute.
Selects the verification mode.
Accepted forms:
FSFREE_STARTFREE-STARTSFSSEMI_FREE_STARTSEMI-FREE-STARTCollision
Required for semi-free-start verification.
Required for free-start verification.
Required when Message_count is 2.
Always required.
When Type is FREE_START, the program:
- reads
IV1 - reads
IV2 - compresses
MSG1fromIV1 - compresses
MSG2fromIV2
When Type is SEMI_FREE_START, the program:
- reads
IV - uses the same initial value for both message paths
- compresses
MSG1andMSG2from that shared initial value
When Type is Collision, the program uses the built-in standard initial values:
- SHA-256 standard IV for
SHA256 - SHA-512 standard IV for
SHA512
No external IV, IV1, or IV2 fields are required in this mode.
The program directly computes:
initial state -> MSG1
initial state -> MSG2
The program first compresses MSG0, then uses the output of MSG0 as the input state for both MSG1 and MSG2.
Flow:
initial state -> MSG0 -> intermediate state -> MSG1
initial state -> MSG0 -> intermediate state -> MSG2
In this mode, the output of MSG0 is printed so you can inspect the intermediate chaining state.
The program prints:
- hash version
- message count
- round count
- verification type
- initial value or values
MSG0and its intermediate state whenMessage_countis2MSG1MSG2- final hash state of
MSG1 - final hash state of
MSG2 - collision result
The final collision result is shown as:
Collision: YESCollision: NO
- Each message block must contain exactly 16 words.
- Each SHA state must contain exactly 8 words.
- All values must be written in hexadecimal form.
- The program currently supports only
Message_count = 1andMessage_count = 2.
Typical errors include:
- missing fields in the configuration file
- unsupported
Version - unsupported
Type - unsupported
Message_count - incorrect number of message words
- incorrect number of IV words
- Edit
msg.txt. - Set
Message_count,Version,Round, andType. - Fill in
IV,IV1,IV2,MSG0,MSG1, andMSG2as required by the selected mode. - Compile the program.
- Run the executable with the configuration file.
- Check the printed outputs and the final collision result.