@@ -273,45 +273,72 @@ The sender of an HTTP message signs outgoing HTTP messages as follows:
273273 * Compute a SHA256 hash over the concatenation of the allocated signing key and the content of
274274 the signed HTTP message and the parameters of the request. This hash is used as the signature.
275275
276- * Convey the base64 encoded signature in the HTTP header ` DSKE-Signature ` .
277-
278- * Convey the meta-data of the signing key in the HTTP header ` DSKE-Signing-Key ` .
276+ * Convey both the meta-data of the signing key and also the base64 encoded signature in the
277+ HTTP header ` DSKE-Signature ` .
278+ Below, we explain how all of this information is encoded in an HTTP header string .
279279 This allows the receiver to allocate the same signing key from the Pre-Shared Random Data
280280 to verify the signature.
281- The encoding of the signing key meta data into an HTTP header is described below.
282281
283282The received of an HTTP message verifies the signature on incoming HTTP messages as follows:
284283
285- * Extract the meta-data of the signing key from received HTTP header ` DSKE-Signing-Key ` .
284+ * Extract the meta-data of the signing key as well as the signature from received HTTP
285+ header ` DSKE-Signature ` .
286286
287- * Use this meta data to take the signing key value from the pool of Pre-Shared Random Data.
287+ * Use the meta data to take the signing key value from the pool of Pre-Shared Random Data.
288288
289289 * Compute a SHA256 hash over the concatenation of the allocated signing key and the content of
290290 the signed HTTP message and the parameters of the request.
291291 This hash is the locally computed signature.
292292
293- * Compare the locally computed signature with the signature received in the HTTP header
294- ` DSKE-Signature ` . If they match, the signature is correct.
293+ * Compare the locally computed signature with the received signature.
294+ If they match, the signature is correct.
295295
296296 * If the signatures do not match, the locally allocated signing key is given back to the pool.
297297 This is to prevent Denial-of-Service attacks from an attacker guessing singing keys.
298298
299- The meta-data of the signing key is encoded into the ` DSKE-Signing-Key ` header as follows:
299+ The meta-data of the signing key is encoded into the ` DSKE-Signature ` header as follows:
300+
301+ * The meta-data of the singing key, followed by a semi-colon (;), followed by the signature
302+ encoded using base64 encoding.
300303
301- * One or more encoded fragment meta-data strings, separated by commas.
304+ * The meta-data of the signing key is encoded as one or more encoded fragment meta-data strings,
305+ separated by commas.
302306
303307 * Each fragment meta-data string is encoded as the block UUID, the start byte within the block,
304308 and the size of the fragment, separated by colons.
305309
306310 * Note that the key data (fragment data) is not encoded into the meta-data.
307311
308- Example of an encoded signing key meta-data (consisting of two fragments, one fragment
309- of 20 bytes, and another fragment of a different block of 12 bytes):
312+ Example of an encoded signature:
313+
314+ ```
315+ 9ad7f620-5a0c-4979-8a2d-66142e06fd79:0:20,cda527e9-5ca7-40d6-a842-0b606597611c:0:12;V12fwNZiooqE1x0beAdQ4fo2YXnOCTPbUgqG38eUQc4=
316+ ```
317+
318+ The part after the semi-colon is the base64-encoded signature:
319+
320+ ```
321+ V12fwNZiooqE1x0beAdQ4fo2YXnOCTPbUgqG38eUQc4=
322+ ```
323+
324+ The part before the semi-colon is the sequence of two fragments:
310325
311326```
3123279ad7f620-5a0c-4979-8a2d-66142e06fd79:0:20,cda527e9-5ca7-40d6-a842-0b606597611c:0:12
313328```
314329
330+ The first fragment is bytes 0 through 19 of block 9ad7f620-5a0c-4979-8a2d-66142e06fd79:
331+
332+ ```
333+ 9ad7f620-5a0c-4979-8a2d-66142e06fd79:0:20
334+ ```
335+
336+ And the second fragment is bytes 0 through 11 of block cda527e9-5ca7-40d6-a842-0b606597611c:
337+
338+ ```
339+ cda527e9-5ca7-40d6-a842-0b606597611c:0:12
340+ ```
341+
315342The signatures have to be computed over the body of the HTTP message, exactly as it is encoded
316343in the HTTP message.
317344This was non-trivial to implement in the code.
@@ -344,6 +371,13 @@ We register the `dske_authentication` function as a middleware for HTTP.
344371This gives us access to the body in a request before decoding and the body in a response
345372before encoding.
346373
374+ However, when we are in the middleware code, it is too late to allocate
375+ a signing key from the PSRD pool. For this reason, the signing key is allocated in the main
376+ application logic code and passed to the middleware using a temporary HTTP header
377+ ` DSKE-Signing-Key ` .
378+ The middleware extracts the signing key from the temporary header, uses it to compute the
379+ signature, adds the ` DSKE-Signature ` header, and removes the temporary ` DSKE-Signing-Key ` header.
380+
347381## Share encryption
348382
349383TODO
0 commit comments