intel / isa-l_crypto

Other
275 stars 80 forks source link

behavior of rolling_hash2_run is ill defined #56

Open lasarohedvig opened 4 years ago

lasarohedvig commented 4 years ago

Hi, all. Could you help me clarify a few details regarding the use of rolling_hash2_run function?

gbtucker commented 4 years ago

Are you referring to the example at rolling_hash/chunking_with_mb_hash.c? This example does assume that there is a minimum chunk size. You don't have to call rolling_hash2_reset() but the example assumes that the chunk minimum is larger than the window size so that any computation in finding matches up the the minimum would be waisted. For this reason it skips to the min size offset and calls _reset() as this should be less work if min > window width.

The value FINGERPRINT_RET_OTHER is reserved for error conditions but so far there are no internal conditions that will set this.

I think you have the definition correct. On hit, offset is set to the position that causes the match, or ptr + 1 so the next offset to check, and it can be re-run without incrementing. On max_len, it will return the max offset - 1.

lasarohedvig commented 4 years ago

Thanks for clarifying that reset() is just a shortcut to skip bytes, that a return of MAX does set the offset and that OTHER is unused for now. I believe this should be put into the documentation.

gbtucker commented 4 years ago

Thanks @lasarohedvig for posting. I'll look into clarifying the documentation.