@@ -215,16 +215,22 @@ the ETag is available; otherwise, null);
215
215
4. Let `key` be the return value of {{key}} with `URL` and `ETag` as inputs.
216
216
5. Let `h1` be the return value of {{hash}} with `key` and `N` as inputs.
217
217
6. Let `fingerprint` be the return value of {{fingerprint}} with `key` and `f` as inputs.
218
- 7. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
219
- 8. Let `h2` be the return value of {{hash}} with `fingerprint-string` and `N` as inputs, XORed with
220
- ` h1` .
221
- 9. Let `h` be either `h1` or `h2`, picked in random.
222
- 10. Let `position_start` be 40 + `h` * `f` \* `b`.
223
- 11. Let `position_end` be `position_start` + `f` \* `b`.
224
- 12. While `position_start` < `position_end` :
225
- 1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
226
- 2. If `bits` is all zeros, set `bits` to `fingerprint` and terminate these steps.
227
- 3. Add `f` to `position_start`.
218
+ 7. Let `h2` be the return value of {{hash2}} with `h1`, `fingerprint` and `N` as inputs.
219
+ 8. Let `h` be either `h1` or `h2`, picked in random.
220
+ 9. While `maxcount` is larger than zero :
221
+ 1. Let `position_start` be 40 + `h` * `f` \* `b`.
222
+ 2. Let `position_end` be `position_start` + `f` \* `b`.
223
+ 3. While `position_start` < `position_end` :
224
+ 1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
225
+ 2. If `bits` is all zeros, set `bits` to `fingerprint` and terminate these steps.
226
+ 3. Add `f` to `position_start`.
227
+ 4. Let `e` be a random number from 0 to `b`.
228
+ 5. Substract `f` * (`b` - `e`) from `position_start`.
229
+ 6. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
230
+ 7. Let `dest_fingerprint` be the value of bits, read as big endian.
231
+ 8. Set `bits` to `fingerprint`.
232
+ 9. Let `h` be {{hash2}} with `h`, `dest_fingerprint` and `N` as inputs.
233
+ 10. Substract 1 from `maxcount`.
228
234
13. Substract `f` from `position_start`.
229
235
14. Let `fingerprint` be the `f` bits starting at `position_start`.
230
236
15. Let `h1` be `h`
@@ -249,17 +255,15 @@ the ETag is available; otherwise, null);
249
255
4. Let `key` be the return value of {{key}} with `URL` and `ETag` as inputs.
250
256
5. Let `h1` be the return value of {{hash}} with `key` and `N` as inputs.
251
257
6. Let `fingerprint` be the return value of {{fingerprint}} with `key` and `f` as inputs.
252
- 7. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
253
- 8. Let `h2` be the return value of {{hash}} with `fingerprint-string` and `N` as inputs, XORed with
254
- ` h1` .
255
- 9. Let `h` be `h1`.
256
- 10. Let `position_start` be 40 + `h` \* `f` \* `b`.
257
- 11. Let `position_end` be `position_start` + `f` \* `b`.
258
- 12. While `position_start` < `position_end` :
259
- 1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
260
- 2. If `bits` is `fingerprint`, set `bits` to all zeros and terminate these steps.
261
- 3. Add `f` to `position_start`.
262
- 13. If `h` is not `h2`, set `h` to `h2` and return to step 10.
258
+ 7. Let `h2` be the return value of {{hash2}} with `h1`, `fingerprint` and `N` as inputs.
259
+ 8. Let `hashes` be an array containing `h1` and `h2`.
260
+ 9. For each `h` in `hashes` :
261
+ 1. Let `position_start` be 40 + `h` \* `f` \* `b`.
262
+ 2. Let `position_end` be `position_start` + `f` \* `b`.
263
+ 3. While `position_start` < `position_end` :
264
+ 1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
265
+ 2. If `bits` is `fingerprint`, set `bits` to all zeros and terminate these steps.
266
+ 3. Add `f` to `position_start`.
263
267
264
268
# ## Computing a fingerprint value {#fingerprint}
265
269
@@ -298,6 +302,8 @@ Given the following inputs:
298
302
and double quotes, as per {{RFC7232}}, Section 2.3.
299
303
3. Return `key`
300
304
305
+ TODO : Add an example of the ETag and the key calcuations.
306
+
301
307
# ## Computing a Hash Value {#hash}
302
308
303
309
Given the following inputs :
@@ -311,6 +317,16 @@ Given the following inputs:
311
317
expressed as an integer.
312
318
2. Return `hash-value` modulo N.
313
319
320
+ # ## Computing an Alternative Hash Value {#hash2}
321
+ Given the following inputs :
322
+
323
+ * `hash1`, an integer indicating the previous hash.
324
+ * `fingerprint`, an integer indicating the fingerprint value.
325
+ * `N`, an integer indicating the number of entries in the digest.
326
+
327
+ 1. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
328
+ 2. Let `hash2` be the return value of {{hash}} with `fingerprint-string` and `N` as inputs, XORed with `hash1`.
329
+ 3. Return `hash2`.
314
330
315
331
# # Server Behavior
316
332
@@ -351,17 +367,16 @@ the ETag is available; otherwise, null).
351
367
4. Let `key` be the return value of {{key}} with `URL` and `ETag` as inputs.
352
368
5. Let `h1` be the return value of {{hash}} with `key` and `N` as inputs.
353
369
6. Let `fingerprint` be the return value of {{fingerprint}} with `key` and `f` as inputs.
354
- 7. Let `fingerprint-string` be the value of `fingerprint` in base 10, expressed as a string.
355
- 8. Let `h2` be the return value of {{hash}} with `fingerprint` and `N` as inputs, XORed with `h1`.
356
- 9. Let `h` be `h1`.
357
- 10. Let `position_start` be 40 + `h` \* `f` \* `b`.
358
- 11. Let `position_end` be `position_start` + `f` \* `b`.
359
- 12. While `position_start` < `position_end` :
360
- 1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
361
- 2. If `bits` is `fingerprint`, return true
362
- 3. Add `f` to `position_start`.
363
- 13. If `h` is not `h2`, set `h` to `h2` and return to step 10.
364
- 13. Return false.
370
+ 7. Let `h2` be the return value of {{hash2}} with `h1`, `fingerprint` and `N` as inputs.
371
+ 8. Let `hashes` be an array containing `h1` and `h2`.
372
+ 9. For each `h` in `hashes` :
373
+ 1. Let `position_start` be 40 + `h` \* `f` \* `b`.
374
+ 2. Let `position_end` be `position_start` + `f` \* `b`.
375
+ 3. While `position_start` < `position_end` :
376
+ 1. Let `bits` be `f` bits from `digest_value` starting at `position_start`.
377
+ 2. If `bits` is `fingerprint`, return true
378
+ 3. Add `f` to `position_start`.
379
+ 10. Return false.
365
380
366
381
# The SENDING_CACHE_DIGEST SETTINGS Parameter
367
382
0 commit comments