Skip to content

Commit

Permalink
Define hashing of fingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavweiss committed Nov 15, 2017
1 parent d32c533 commit c90f9b4
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions draft-ietf-httpbis-cache-digest.md
Expand Up @@ -204,20 +204,21 @@ Given the following inputs:
4. Let `key` be the return value of {{key}} with `URL` and `ETag` as inputs.
5. Let `h1` be the return value of {{hash}} with `key` and `N` as inputs.
6. Let `fingerprint` be the return value of {{fingerprint}} with `key`, `N` and `f` as inputs.
7. Let `h2` be the return value of {{hash}} with `fingerprint` and `N` as inputs, XORed with `h1`.
8. Let `h` be either `h1` or `h2`, picked in random.
9. Let `position_start` be 40 + `h` * `f`.
10. Let `position_end` be `position_start` + `f` \* `b`.
11. While `position_start` < `position_end`:
7. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
8. Let `h2` be the return value of {{hash}} with `fingerprint-string` and `N` as inputs, XORed with `h1`.
9. Let `h` be either `h1` or `h2`, picked in random.
10. Let `position_start` be 40 + `h` * `f`.
11. Let `position_end` be `position_start` + `f` \* `b`.
12. While `position_start` < `position_end`:
1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
2. If `bits` is all zeros, set `bits` to `fingerprint` and terminate these steps.
3. Add `f` to `position_start`.
12. Substract `f` from `position_start`.
13. Let `fingerprint` be the `f` bits starting at `position_start`.
14. Let `h1` be `h`
15. Substract 1 from `maxcount`.
16. If `maxcount` is zero, return an error.
17. Go to step 7.
13. Substract `f` from `position_start`.
14. Let `fingerprint` be the `f` bits starting at `position_start`.
15. Let `h1` be `h`
16. Substract 1 from `maxcount`.
17. If `maxcount` is zero, return an error.
18. Go to step 7.


### Removing a URL to the Digest-Value {#removing}
Expand All @@ -234,22 +235,22 @@ Given the following inputs:
4. Let `key` be the return value of {{key}} with `URL` and `ETag` as inputs.
5. Let `h1` be the return value of {{hash}} with `key` and `N` as inputs.
6. Let `fingerprint` be the return value of {{fingerprint}} with `key`, `N` and `f` as inputs.
7. Let `h2` be the return value of {{hash}} with `fingerprint` and `N` as inputs, XORed with `h1`.
8. Let `h` be `h1`.
9. Let `position_start` be 40 + `h` \* `f`.
10. Let `position_end` be `position_start` + `f` \* `b`.
11. While `position_start` < `position_end`:
7. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
8. Let `h2` be the return value of {{hash}} with `fingerprint-string` and `N` as inputs, XORed with `h1`.
9. Let `h` be `h1`.
10. Let `position_start` be 40 + `h` \* `f`.
11. Let `position_end` be `position_start` + `f` \* `b`.
12. While `position_start` < `position_end`:
1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
2. If `bits` is `fingerprint`, set `bits` to all zeros and terminate these steps.
3. Add `f` to `position_start`.
12. If `h` is not `h2`, set `h` to `h2` and return to step 9.
13. If `h` is not `h2`, set `h` to `h2` and return to step 9.

### Computing a fingerprint value {#fingerprint}

Given the following inputs:

* `key`, an array of characters
* `N`, an integer
* `f`, an integer indicating the number of output bits

1. Let `hash-value` be the SHA-256 message digest {{RFC6234}} of `key`, expressed as an integer.
Expand Down Expand Up @@ -328,15 +329,16 @@ Given the following inputs:
4. Let `key` be the return value of {{key}} with `URL` and `ETag` as inputs.
5. Let `h1` be the return value of {{hash}} with `key` and `N` as inputs.
6. Let `fingerprint` be the return value of {{fingerprint}} with `key`, `N` and `f` as inputs.
7. Let `h2` be the return value of {{hash}} with `fingerprint` and `N` as inputs, XORed with `h1`.
8. Let `h` be `h1`.
9. Let `position_start` be 40 + `h` \* `f`.
10. Let `position_end` be `position_start` + `f` \* `b`.
11. While `position_start` < `position_end`:
7. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
8. Let `h2` be the return value of {{hash}} with `fingerprint` and `N` as inputs, XORed with `h1`.
9. Let `h` be `h1`.
10. Let `position_start` be 40 + `h` \* `f`.
11. Let `position_end` be `position_start` + `f` \* `b`.
12. While `position_start` < `position_end`:
1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
2. If `bits` is `fingerprint`, return true
3. Add `f` to `position_start`.
12. Return false.
13. Return false.

# The SENDING_CACHE_DIGEST SETTINGS Parameter

Expand Down

0 comments on commit c90f9b4

Please sign in to comment.