Skip to content

Commit 7dfac53

Browse files
committed
define "signature base", explain signature computation, add variables
1 parent 6438b11 commit 7dfac53

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

section/algorithms.html

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -420,54 +420,58 @@ <h4>Generate HTTP Signature</h4>
420420
</li>
421421
</ol>
422422
</li>
423-
<li>
424-
Let <var>components</var> be an array of strings identifying which content (headers, etc.) to include in the signature.
425-
<ol>
426-
<li>Let |components| initial value be `<<"@method", "@target-uri">>`.</li>
427-
<li>If <var>request</var>'s headers includes the `Authorization` header, append `authorization` to <var>components</var>.
428-
<li>If <var>request</var>'s body is not `null`, append `content-length`, `content-digest` and `content-type` to <var>components</var>.
429-
</ol>
430-
</li>
431423
<li>
432424
Let <var>algorithm</var> be `ed25519`.
433425
</li>
434426
<li>
435427
Let <var>privateKey</var> be the Ed25519 [=private key=].
436428
</li>
429+
<li>Let |keyId:string| be JWK's [=Key ID=] corresponding to |privateKey|.</li>
430+
<li>Let |createdTimestamp:integer| represent the creation time of the signature as a UNIX timestamp value of type integer. <span class="note">Sub-second precision is not supported.</span></li>
437431
<li>
438-
Construct the canonical data for each element in <var>components</var>.
439-
</li>
440-
<li>
441-
Concatenate the canonical data into a single string (or buffer).
442-
</li>
443-
<li>
444-
Use `Ed25519` to sign the canonical data with <var>privateKey</var>.
445-
</li>
446-
<li>
447-
Let <var>signatureValue</var> be the resulting signature, as a byte sequence.
432+
<p>Construct the <a data-cite="RFC9421#section-1.1-7.19">|signature base|</a> as described in <a data-cite="RFC9421#name-creating-the-signature-base"></a>:</p>
433+
<ol>
434+
<li>Let |components| be an ordered <a data-cite="RFC8941#name-inner-lists">inner list of string values with parameters</a> to describe the <a data-cite="RFC9421#section-1.1-7.17">covered components</a> for the signature.</li>
435+
<li>Let |components| initial value be `<<"@method", "@target-uri">>`.</li>
436+
<li>If |request|'s headers includes the `Authorization` header, append `"authorization"` to |components|.</li>
437+
<li>If |request|'s body is not `null`, append `"content-length"`, `"content-digest"` and `"content-type"` to |components|.</li>
438+
<li>
439+
Define following as parameters to |components|: the |algorithm| as `alg`, |keyId| as `keyid` and |createdTimestamp| as `created`.
440+
</li>
441+
<li>Serialize |components| as described in <a data-cite="RFC9421#name-creating-the-signature-base"></a> to obtain the |signature base|.</li>
442+
</ol>
443+
444+
<aside class="example" title="Signature base">
445+
<pre>
446+
"@method": POST
447+
"@target-uri": https://example.com/
448+
"authorization": GNAP 123454321
449+
"content-length": 18
450+
"content-digest": sha-512=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:
451+
"content-type": application/json
452+
"@signature-params": ("@method" "@target-uri" "authorization" "content-length" "content-digest" "content-type");alg="ed25519";keyid="eddsa_key_1";created=1704722601
453+
</pre>
454+
</aside>
455+
</li>
456+
<li>
457+
Compute the signature |signatureValue|:
458+
<ol>
459+
<li>Let |signatureDigest| be the result of computing a digest of |signature base| using the `sha-512` algorithm.</li>
460+
<li>Use the `Ed25519` |privateKey| to sign the |signatureDigest|.</li>
461+
<li>
462+
Let <var>signatureValue</var> be the resulting signature, as a byte sequence.
463+
</li>
464+
</ol>
448465
</li>
466+
449467
<li>
450-
Construct the `Signature-Input` header value, including the |components|, the |algorithm|, `keyid` and `created` and [=header list/append=] it to <var>request's</var> headers with name `sig1`.
451-
<div class="note">
452-
<p>`keyid` represents the JWK's [=Key ID=]</a>.</p>
453-
<p>`created` represents the creation time of the signature as a UNIX timestamp value of type Integer. Sub-second precision is not supported.</p>
454-
</div>
468+
Construct the `Signature-Input` header value, including the |components|, the |algorithm|, |keyId| and |createdTimestamp| and [=header list/append=] it to <var>request's</var> headers with name `sig1`.
455469
</li>
456470
<li>
457471
[=Set a structured header=] with headerName `Signature`, key `sig1`, and |signatureValue| as value.
458472
</li>
459473
</ol>
460-
<aside class="example" title="Signature base">
461-
<pre>
462-
"@method": POST
463-
"@target-uri": https://example.com/
464-
"authorization": GNAP 123454321
465-
"content-length": 18
466-
"content-digest": sha-512=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:
467-
"content-type": application/json
468-
"@signature-params": ("@method" "@target-uri" "authorization" "content-length" "content-digest" "content-type");alg="ed25519";keyid="eddsa_key_1";created=1704722601
469-
</pre>
470-
</aside>
474+
471475
<aside class="example" title="Signed message">
472476
<pre>
473477
POST HTTP/1.1

0 commit comments

Comments
 (0)