<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN" "http://xml.resource.org/authoring/rfc2629.dtd" [
  <!ENTITY rfc2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
  <!ENTITY rfc2617 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2617.xml">
  <!ENTITY rfc3230 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3230.xml">
  <!ENTITY rfc3447 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3447.xml">
  <!ENTITY rfc4648 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4648.xml">
  <!ENTITY rfc5246 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
  <!ENTITY rfc6376 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6376.xml">
  <!ENTITY rfc6749 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6749.xml">
  <!ENTITY rfc7230 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7230.xml">
  <!ENTITY rfc7235 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7235.xml">
  <!ENTITY jwa SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-jose-json-web-algorithms-20.xml">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xsl" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc toc="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc symrefs="yes" ?>
<rfc category="std" ipr="trust200902" submissionType="independent" 
     docName="draft-cavage-http-signatures-06">
<front>
 <title>Signing HTTP Messages</title>

 <author initials="M.C." surname="Cavage" fullname="Mark Cavage">
  <organization>Oracle</organization>
  <address>
   <postal>
    <street>500 Oracle Parkway</street>
    <city>Redwood Shores</city> <region>CA</region>
    <code>94065</code>
    <country>US</country>
   </postal>
   <phone>+1 415 400 0626</phone>
   <email>mcavage@gmail.com</email>
   <uri>http://www.oracle.com/</uri>
  </address>
 </author>

 <author initials="M.S." surname="Sporny" fullname="Manu Sporny">
  <organization>Digital Bazaar</organization>
  <address>
   <postal>
    <street>203 Roanoke Street W.</street>
    <city>Blacksburg</city> <region>VA</region>
    <code>24060</code>
    <country>US</country>
   </postal>
   <phone>+1 540 961 4469</phone>
   <email>msporny@digitalbazaar.com</email>
   <uri>http://manu.sporny.org/</uri>
  </address>
 </author>

 <date month="January" year="2017" />
 <area>Security</area>
 <workgroup></workgroup>
 <keyword>HTTP</keyword>
 <keyword>digital signature</keyword>
 <keyword>PKI</keyword>
 <abstract>
  <t>
When communicating over the Internet using the HTTP protocol, it can be
desirable for a server or client to authenticate the sender of a
particular message. It can also be desirable to ensure that the message 
was not tampered with during transit. This document describes a way for 
servers and clients to simultaneously add authentication and 
message integrity to HTTP messages by using a digital signature.
  </t>
 </abstract>
 <note title="Feedback">
  <t>
This specification is a part of the 
<eref target="https://web-payments.org/">Web Payments</eref> work. Feedback 
related to this specification should be sent to
<eref target="mailto:public-webpayments@w3.org">public-webpayments@w3.org</eref>.
  </t>
 </note>
</front>

<middle>

 <section anchor="intro" title="Introduction">
  <t>
This protocol extension is intended to provide a simple and standard way for 
clients to sign HTTP messages.
  </t>
  
  <t>
<xref target="RFC2617">HTTP Authentication</xref> defines Basic and Digest 
authentication mechanisms, <xref target="RFC5246">TLS 1.2</xref>
defines cryptographically strong transport layer security, and 
<xref target="RFC6749">OAuth 2.0</xref> provides a 
fully-specified alternative for authorization of web service requests. Each of
these approaches are employed on the Internet today with varying degrees of 
protection. However, none of these schemes are designed to cryptographically 
sign the HTTP messages themselves, which is required in order to ensure
end-to-end message integrity. An added benefit of signing the HTTP message
for the purposes of end-to-end message integrity is that the client can be
authenticated using the same mechanism without the need for multiple
round-trips.
  </t>

  <t>
Several web service providers have invented their own schemes for signing
HTTP messages, but to date, none have been standardized. While there
are no techniques in this proposal that are novel beyond the previous art, it
is useful to standardize a simple and cryptographically strong mechanism for 
digitally signing HTTP messages.
  </t> 

  <section anchor="intro-requests" title="Using Signatures in HTTP Requests">
   <t>
It is common practice to protect sensitive website API functionality via 
authentication mechanisms. Often, the entity accessing these APIs is a
piece of automated software outside of an interactive human session. While
there are mechanisms like OAuth and API secrets that are used to grant
API access, each have their weaknesses such as unnecessary complexity 
for particular use cases or the use of shared secrets which may not be 
acceptable to an implementer.
   </t>
   <t>
Digital signatures are widely used to provide authentication without 
the need for shared secrets. They also do not require a round-trip in
order to authenticate the client. A server need only have a mapping between
the key being used to sign the content and the authorized entity to
verify that a message was signed by that entity.
   </t>
   <t>
This specification provides two mechanisms that can be used by a server
to authenticate a client. The first is the 'Signature' HTTP Authentication
Scheme, which may be used for interactive sessions. The second is the 
Signature HTTP Header, which is typically used by automated software
agents.
   </t>
  </section>

  <section anchor="intro-responses" title="Using Signatures in HTTP Responses">
   <t>
For high security transactions, having an additional signature on the HTTP 
header allows a client to ensure that even if the transport channel has been 
compromised, that the content of the messages have not been compromised.
This specification provides a HTTP Signature Header mechanism that can be 
used by a client to authenticate the sender of a message and ensure that
particular headers have not been modified in transit.
   </t>
  </section>
 
 </section>
 
 <section anchor="components" title="The Components of a Signature">
  <t>
There are a number of components in a signature that are common between the
'Signature' HTTP Authentication Scheme and the 'Signature' HTTP Header. This
section details the components of a digital signature.
  </t>

   <section anchor="params" title="Signature Parameters">

    <t>
The following section details the signature parameters.
    </t>

    <section anchor="keyId" title="keyId">
     <t>
REQUIRED.  The `keyId` field is an opaque string that the server can use to look
up the component they need to validate the signature.  It could be an SSH key
fingerprint, a URL to machine-readable key data, an LDAP DN, etc.  Management 
of keys and assignment of `keyId` is out of scope for this document.
     </t>
    </section>
    
    <section anchor="algorithm" title="algorithm">

     <t>
REQUIRED. The `algorithm` parameter is used to specify the digital signature
algorithm to use when generating the signature. Valid values for this
parameter can be found in the Signature Algorithms registry located at 
<eref target="http://www.iana.org/assignments/signature-algorithms">
http://www.iana.org/assignments/signature-algorithms</eref> and MUST NOT be
marked "deprecated".
     </t>
    </section>
    
    <section anchor="headers" title="headers">

     <t>
OPTIONAL.  The `headers` parameter is used to specify the list of HTTP headers
included when generating the signature for the message.  If specified, it 
should be a lowercased, quoted list of HTTP header fields, separated by a 
single space character. If not specified, implementations MUST operate as if 
the field were specified with a single value, the `Date` header, in the list 
of HTTP headers. Note that the list order is important, and MUST be specified in 
the order the HTTP header field-value pairs are concatenated together 
during signing.
     </t>

    </section>
    
    <section anchor="signature" title="signature">
     <t>
REQUIRED.  The `signature` parameter is a base 64 encoded digital signature,
as described in <xref target="RFC4648">RFC 4648</xref>, 
<eref target="http://tools.ietf.org/html/rfc4648#section-4">Section 4</eref>.
The client uses the `algorithm` and `headers` signature parameters to form a 
canonicalized `signing string`.  This `signing string` is then signed with the 
key associated with `keyId` and the algorithm corresponding to `algorithm`.
The `signature` parameter is then set to the base 64 encoding of the signature.
     </t>
    </section>
   </section>

   <section anchor="ambiguity" title="Ambiguous Parameters">
    <t>
If any of the parameters listed above are erroneously duplicated in the 
associated header field, then the last parameter defined MUST be used. Any
parameter that is not recognized as a parameter, or is not well-formed, 
MUST be ignored.
    </t>
   </section>
   
   <section anchor="canonicalization" title="Signature String Construction">
   
   <t>
In order to generate the string that is signed with a key, the client MUST use
the values of each HTTP header field in the `headers` Signature parameter, 
in the order they appear in the `headers` Signature parameter. It is out of 
scope for this document to dictate what header fields 
an application will want to enforce, but implementers SHOULD at minimum 
include the request target and Date header fields.
   </t>
   <t>
To include the HTTP request target in the signature calculation, use the 
special `(request-target)` header field name.
    <list style="numbers">
     <t>
If the header field name is `(request-target)` then generate the header field 
value by concatenating the lowercased :method, an ASCII space, and 
the :path pseudo-headers (as specified in
<eref target="https://tools.ietf.org/html/rfc7540#section-8.1.2.3">HTTP/2, Section 8.1.2.3</eref>).
     </t>
     <t>
Create the header field string by concatenating the lowercased header field 
name followed with an ASCII colon `:`, an ASCII space ` `, and the header 
field value. Leading and trailing optional whitespace (OWS) in the header field 
value MUST be omitted (as specified in 
<xref target="RFC7230">RFC7230</xref>, 
<eref target="http://tools.ietf.org/html/rfc7230#section-3.2.4">Section 3.2.4</eref>). 
If there are multiple instances of the same header field, all header field 
values associated with the header field MUST be concatenated, separated by a
ASCII comma and an ASCII space `, `, and used in the order in which 
they will appear in the transmitted HTTP message. Any other modification to 
the header field value MUST NOT be made. 
     </t>
     <t>
If value is not the last value then append an ASCII newline `\n`.
     </t>
    </list>
   </t>
   
   <t>
To illustrate the rules specified above, assume a `headers` parameter list
with the value of `(request-target) host date cache-control x-example` with
the following HTTP request headers:

    <figure>
     <artwork>
GET /foo HTTP/1.1
Host: example.org
Date: Tue, 07 Jun 2014 20:51:35 GMT
X-Example: Example header
    with some whitespace.
Cache-Control: max-age=60
Cache-Control: must-revalidate
     </artwork>
    </figure>
   </t>
   
   <t>
For the HTTP request headers above, the corresponding signature string is:

    <figure>
     <artwork>
(request-target): get /foo
host: example.org
date: Tue, 07 Jun 2014 20:51:35 GMT
cache-control: max-age=60, must-revalidate
x-example: Example header with some whitespace.
     </artwork>
    </figure>
   </t>
   
  </section>
  
  <section anchor="create" title="Creating a Signature">

   <t>
In order to create a signature, a client MUST:
    <list style="numbers">
     <t>
Use the contents of the HTTP message, the `headers` value, and the 
Signature String Construction algorithm to create the signature string.
     </t>
     <t>
The `algorithm` and key associated with `keyId` must then be used to
generate a digital signature on the signature string.
     </t>
     <t>
The `signature` is then generated by base 64 encoding the output of the
digital signature algorithm.
     </t>
    </list>
   </t>

   <t>
For example, assume that the `algorithm` value was "rsa-sha256". This would
signal to the application that the data associated with `keyId` is an
RSA Private Key (as defined in <xref target="RFC3447">RFC 3447</xref>), the
signature string hashing function is SHA-256, and the signing
algorithm is the one defined in <xref target="RFC3447">RFC 3447</xref>, 
Section <eref target="http://tools.ietf.org/html/rfc3447#section-8.2.1">
Section 8.2.1</eref>. The result of the signature creation algorithm 
specified in <xref target="RFC3447">RFC 3447</xref> should result in a
binary string, which is then base 64 encoded and placed into the
`signature` value.
   </t>
  
  </section>  
  
  <section anchor="verify" title="Verifying a Signature">

   <t>
In order to verify a signature, a server MUST:
    <list style="numbers">
     <t>
Use the received HTTP message, the `headers` value, and the Signature String 
Construction algorithm to recreate the signature string.
     </t>
     <t>
The `algorithm`, `keyId`, and base 64 decoded `signature` listed in the 
signature parameters are then used to verify the authenticity of the 
digital signature.
     </t>
    </list>
   </t>

   <t>
For example, assume that the `algorithm` value was "rsa-sha256". This would
signal to the application that the data associated with `keyId` is an
RSA Public Key (as defined in <xref target="RFC3447">RFC 3447</xref>), the
signature string hashing function is SHA-256, and the `signature` 
verification algorithm to use to verify the signature is the one defined in
<xref target="RFC3447">RFC 3447</xref>, Section <eref 
target="http://tools.ietf.org/html/rfc3447#section-8.2.2">
Section 8.2.2</eref>. The result of the signature verification algorithm 
specified in <xref target="RFC3447">RFC 3447</xref> should result in a
successful verification unless the headers protected by the signature were
tampered with in transit.
   </t>
  
  </section>  
 </section>
  
 <section anchor="auth-scheme" title="The 'Signature' HTTP Authentication Scheme">

  <t>
The "signature" authentication scheme is based on the model that the client must
authenticate itself with a digital signature produced by either a private
asymmetric key (e.g., RSA) or a shared symmetric key (e.g., HMAC).  The scheme
is parameterized enough such that it is not bound to any particular key type or
signing algorithm.  However, it does explicitly assume that clients can send an
HTTP `Date` header.
  </t>
  
  <section anchor="auth-header" title="Authorization Header">

   <t>
The client is expected to send an Authorization header 
(as defined in 
<xref target="RFC7235">RFC 7235</xref>, <eref 
target="http://tools.ietf.org/html/draft-ietf-rfc7235-auth-25#section-4.1">
Section 4.1</eref>) where the "auth-scheme" is "Signature" and the 
"auth-param" parameters meet the requirements listed in 
Section 2: The Components of a Signature.
   </t>

   <t>
The rest if this section uses the following HTTP request as an example.

    <figure>
     <artwork>
POST /foo HTTP/1.1
Host: example.org
Date: Tue, 07 Jun 2014 20:51:35 GMT
Content-Type: application/json
Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
Content-Length: 18

{"hello": "world"}
     </artwork>
    </figure>
   </t>
   
   <t>
Note that the use of the `Digest` header field is per 
<xref target="RFC3230">RFC 3230</xref>, <eref 
target="http://tools.ietf.org/html/rfc3230#section-4.3.2">Section 4.3.2</eref>
and is included merely as a demonstration of how an implementer could include 
information about the body of the message in the signature.
The following sections also assume that the "rsa-key-1" keyId refers to a 
private key known to the client and a public key known to the server. 
The "hmac-key-1" keyId refers to key known to the client and server.
   </t>

   <section anchor="auth-isa" title="Initiating Signature Authorization">

    <t>
A server may notify a client when a protected resource could be accessed by
authenticating itself to the server. To initiate this process, the server
will request that the client authenticate itself via a 401 response code. The
server may optionally specify which HTTP headers it expects to be signed
by specifying the `headers` parameter in the WWW-Authenticate header.
For example:
    <figure>
     <artwork>
HTTP/1.1 401 Unauthorized
Date: Thu, 08 Jun 2014 18:32:30 GMT
Content-Length: 1234
Content-Type: text/html
WWW-Authenticate: Signature realm="Example",headers="(request-target) date"

...
</artwork>
    </figure>
    </t>
   </section>
   
   <section anchor="auth-rsa-example" title="RSA Example">
   
   <t>
The authorization header and signature would be generated as:
    <figure>
     <artwork>
Authorization: Signature keyId="rsa-key-1",algorithm="rsa-sha256",
headers="(request-target) host date digest content-length",
signature="Base64(RSA-SHA256(signing string))"</artwork>
    </figure>
   </t>
   
   <t>
The client would compose the signing string as:
    <figure>
     <artwork>
(request-target): post /foo\n
host: example.org\n
date: Tue, 07 Jun 2014 20:51:35 GMT\n
digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n
content-length: 18</artwork>
    </figure>
Note that the '\n' symbols above are included to demonstrate where the new 
line character should be inserted. There is no new line on the final line of
the signing string.
   </t>

   <t>
For an RSA-based signature, the authorization header and signature would then
be generated as:
    <figure>
     <artwork>
Authorization: Signature keyId="rsa-key-1",algorithm="rsa-sha256",
headers="(request-target) host date digest content-length",
signature="Base64(RSA-SHA256(signing string))"</artwork>
    </figure>
   </t>
  </section>
  
  <section anchor="auth-hmac-example" title="HMAC Example">

   <t>
For an HMAC-based signature without a list of headers specified, the 
authorization header and signature would be generated as:
    <figure>
     <artwork>
Authorization: Signature keyId="hmac-key-1",algorithm="hmac-sha256",
headers="(request-target) host date digest content-length",
signature="Base64(HMAC-SHA256(signing string))"
     </artwork>
    </figure>
   </t>

   <t>
The only difference between the RSA Example and the HMAC Example is the
signature algorithm that is used. The client would compose the signing string 
in the same way as the RSA Example above:
    <figure>
     <artwork>
(request-target): post /foo\n
host: example.org\n
date: Tue, 07 Jun 2014 20:51:35 GMT\n
digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n
content-length: 18
     </artwork>
    </figure>
   </t>

    </section>
   </section>
  </section>

 <section anchor="sig" title="The 'Signature' HTTP Header">

  <t>
The "signature" HTTP Header is based on the model that the sender must
authenticate itself with a digital signature produced by either a private
asymmetric key (e.g., RSA) or a shared symmetric key (e.g., HMAC).  The scheme
is parameterized enough such that it is not bound to any particular key type or
signing algorithm.  However, it does explicitly assume that senders can send an
HTTP `Date` header.
  </t>
  
  <section anchor="sig-header" title="Signature Header">

   <t>
The sender is expected to transmit a header 
(as defined in 
<xref target="RFC7230">RFC 7230</xref>, <eref 
target="http://tools.ietf.org/html/rfc7230#section-3.2">
Section 3.2</eref>) where the "field-name" is "Signature", and the "field-value"
contains one or more "auth-param"s (as defined in 
<xref target="RFC7235">RFC 7235</xref>, <eref 
target="http://tools.ietf.org/html/rfc7235#section-4.1">
Section 4.1</eref>) where the "auth-param" parameters meet the requirements 
listed in Section 2: The Components of a Signature.
   </t>

   <t>
The rest if this section uses the following HTTP request as an example.

    <figure>
     <artwork>
POST /foo HTTP/1.1
Host: example.org
Date: Tue, 07 Jun 2014 20:51:35 GMT
Content-Type: application/json
Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
Content-Length: 18

{"hello": "world"}</artwork>
    </figure>
   </t>
   
   <t>
The following sections assume that the "rsa-key-1" keyId refers to a 
private key known to the client and a public key known to the server. 
The "hmac-key-1" keyId refers to key known to the client and server.
   </t>
   
   <section anchor="sig-rsa-example" title="RSA Example">
   
   <t>
The signature header and signature would be generated as:
    <figure>
     <artwork>
Signature: keyId="rsa-key-1",algorithm="rsa-sha256",
headers="(request-target) host date digest content-length",
signature="Base64(RSA-SHA256(signing string))"</artwork>
    </figure>
   </t>
   
   <t>
The client would compose the signing string as:
    <figure>
     <artwork>
(request-target): post /foo\n
host: example.org\n
date: Tue, 07 Jun 2014 20:51:35 GMT\n
digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n
content-length: 18</artwork>
    </figure>
Note that the '\n' symbols above are included to demonstrate where the new 
line character should be inserted. There is no new line on the final line of
the signing string.
   </t>

   <t>
For an RSA-based signature, the authorization header and signature would then
be generated as:
    <figure>
     <artwork>
Signature: keyId="rsa-key-1",algorithm="rsa-sha256",
headers="(request-target) host date digest content-length",
signature="Base64(RSA-SHA256(signing string))"</artwork>
    </figure>
   </t>
  </section>
  
  <section anchor="sig-hmac-example" title="HMAC Example">

   <t>
For an HMAC-based signature without a list of headers specified, the 
authorization header and signature would be generated as:
    <figure>
     <artwork>
Signature: keyId="hmac-key-1",algorithm="hmac-sha256",
headers="(request-target) host date digest content-length",
signature="Base64(HMAC-SHA256(signing string))"</artwork>
    </figure>
   </t>

   <t>
The only difference between the RSA Example and the HMAC Example is the
signature algorithm that is used. The client would compose the signing string 
in the same way as the RSA Example above:
    <figure>
     <artwork>
(request-target): post /foo\n
host: example.org\n
date: Tue, 07 Jun 2014 20:51:35 GMT\n
digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=\n
content-length: 18
     </artwork>
    </figure>
   </t>

    </section>
   </section>
  </section>

</middle>
<back>
 <references title="Normative References">
  &rfc2119;
  &rfc4648;
  &rfc6376;
  &rfc7230;
  &rfc7235;
  &jwa;
 </references>
 <references title="Informative References">
  &rfc2617;
  &rfc3230;
  &rfc3447;
  &rfc5246;
  &rfc6749;
 </references>

 <section anchor="appendix-a" title="Security Considerations">
  <t>
There are a number of security considerations to take into account when implementing
or utilizing this specification. A thorough security analysis of this protocol,
including its strengths and weaknesses, can be found in 
<eref target="https://web-payments.org/specs/source/http-signatures-audit/">
Security Considerations for HTTP Signatures</eref>.
  </t>
 </section>

 <section anchor="appendix-b" title="Extensions">
  <t>
This specification was designed to be simple, modular, and extensible. There
are a number of other specifications that build on this one. For
example, the 
<eref target="https://web-payments.org/specs/source/http-signature-nonces/">HTTP Signature Nonces</eref>
specification details how to
use HTTP Signatures over a non-secured channel like HTTP and the 
<eref target="https://web-payments.org/specs/source/http-signature-trailers/">HTTP Signature Trailers</eref>
specification explains how to apply HTTP
Signatures to streaming content. Developers that desire more functionality
than this specification provides are urged to ensure that an extension
specification doesn't already exist before implementing a proprietary 
extension.
  </t>

  <t>
If extensions to this specification are made by adding new Signature
Parameters, those extension parameters MUST be registered in the
Signature Authentication Scheme Registry. The registry will be created and 
maintained at (the suggested URI) 
<eref target="http://www.iana.org/assignments/http-auth-scheme-signature">
http://www.iana.org/assignments/http-auth-scheme-signature</eref>. An 
example entry in this registry is included below:

   <figure>
    <artwork>
Signature Parameter: nonce
Reference to specification: [HTTP_AUTH_SIGNATURE_NONCE], Section XYZ.
Notes (optional): The HTTP Signature Nonces specification details 
how to use HTTP Signatures over a unsecured channel like HTTP.
    </artwork>
   </figure>
  </t>
 </section>

 <section anchor="appendix-c" title="Test Values">
  <t>
The following test data uses the following RSA 2048-bit keys, 
which we will refer to as `keyId=Test` in the following samples:

   <figure>
    <artwork>
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFENGw33yGihy92pDjZQhl0C3
6rPJj+CvfSC8+q28hxA161QFNUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6
Z4UMR7EOcpfdUE9Hf3m/hs+FUR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJw
oYi+1hqp1fIekaxsyQIDAQAB
-----END PUBLIC KEY-----
    </artwork>
   </figure>

   <figure>
    <artwork>
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDCFENGw33yGihy92pDjZQhl0C36rPJj+CvfSC8+q28hxA161QF
NUd13wuCTUcq0Qd2qsBe/2hFyc2DCJJg0h1L78+6Z4UMR7EOcpfdUE9Hf3m/hs+F
UR45uBJeDK1HSFHD8bHKD6kv8FPGfJTotc+2xjJwoYi+1hqp1fIekaxsyQIDAQAB
AoGBAJR8ZkCUvx5kzv+utdl7T5MnordT1TvoXXJGXK7ZZ+UuvMNUCdN2QPc4sBiA
QWvLw1cSKt5DsKZ8UETpYPy8pPYnnDEz2dDYiaew9+xEpubyeW2oH4Zx71wqBtOK
kqwrXa/pzdpiucRRjk6vE6YY7EBBs/g7uanVpGibOVAEsqH1AkEA7DkjVH28WDUg
f1nqvfn2Kj6CT7nIcE3jGJsZZ7zlZmBmHFDONMLUrXR/Zm3pR5m0tCmBqa5RK95u
412jt1dPIwJBANJT3v8pnkth48bQo/fKel6uEYyboRtA5/uHuHkZ6FQF7OUkGogc
mSJluOdc5t6hI1VsLn0QZEjQZMEOWr+wKSMCQQCC4kXJEsHAve77oP6HtG/IiEn7
kpyUXRNvFsDE0czpJJBvL/aRFUJxuRK91jhjC68sA7NsKMGg5OXb5I5Jj36xAkEA
gIT7aFOYBFwGgQAQkWNKLvySgKbAZRTeLBacpHMuQdl1DfdntvAyqpAZ0lY0RKmW
G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI
7U1yQXnTAEFYM560yJlzUpOb1V4cScGd365tiSMvxLOvTA==
-----END RSA PRIVATE KEY-----
    </artwork>
   </figure>
  </t>

  <t>
All examples use this request:
   <figure>
    <artwork>
POST /foo?param=value&amp;pet=dog HTTP/1.1
Host: example.com
Date: Thu, 05 Jan 2014 21:31:40 GMT
Content-Type: application/json
Digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
Content-Length: 18

{"hello": "world"}
    </artwork>
   </figure>
  </t>

  <section anchor="default-test" title="Default Test">
   <t>
If a list of headers is not included, the date is the only header that is
signed by default. The string to sign would be:
    <figure>
     <artwork>
date: Thu, 05 Jan 2014 21:31:40 GMT</artwork>
   </figure>
   </t>
   
   <t>
The Authorization header would be:
    <figure>
     <artwork>
Authorization: Signature keyId="Test",algorithm="rsa-sha256",
signature="ATp0r26dbMIxOopqw0OfABDT7CKMIoENumuruOtarj8n/97Q3htH
FYpH8yOSQk3Z5zh8UxUym6FYTb5+A0Nz3NRsXJibnYi7brE/4tx5But9kkFGzG+
xpUmimN4c3TMN7OFH//+r8hBf7BT9/GmHDUVZT2JzWGLZES2xDOUuMtA="</artwork>
   </figure>
   </t>

   <t>
The Signature header would be:
    <figure>
     <artwork>
Signature: keyId="Test",algorithm="rsa-sha256",
signature="ATp0r26dbMIxOopqw0OfABDT7CKMIoENumuruOtarj8n/97Q3htH
FYpH8yOSQk3Z5zh8UxUym6FYTb5+A0Nz3NRsXJibnYi7brE/4tx5But9kkFGzG+
xpUmimN4c3TMN7OFH//+r8hBf7BT9/GmHDUVZT2JzWGLZES2xDOUuMtA="</artwork>
   </figure>
   </t>
  </section>

  <section anchor="basic-test" title="Basic Test">
   <t>
The minimum recommended data to sign is the (request-target), host, and date. In
this case, the string to sign would be:
    <figure>
     <artwork>
(request-target): post /foo?param=value&amp;pet=dog
host: example.com
date: Thu, 05 Jan 2014 21:31:40 GMT
    </artwork>
   </figure>
   </t>
   
   <t>
The Authorization header would be:
    <figure>
     <artwork>
Authorization: Signature keyId="Test",algorithm="rsa-sha256",
headers="(request-target) host date", signature="KcLSABBj/m3v2Dhxi
CKJmzYJvnx74tDO1SaURD8Dr8XpugN5wpy8iBVJtpkHUIp4qBYpzx2QvD16t8X
0BUMiKc53Age+baQFWwb2iYYJzvuUL+krrl/Q7H6fPBADBsHqEZ7IE8rR0Ys3l
b7J5A6VB9J/4yVTRiBcxTypW/mpr5w="
    </artwork>
   </figure>
   </t>
  </section>
  
  <section anchor="all-headers-test" title="All Headers Test">
   <t>
A strong signature including all of the headers and a digest of the body of
the HTTP request would result in the following signing string:
    <figure>
     <artwork>
(request-target): post /foo?param=value&amp;pet=dog
host: example.com
date: Thu, 05 Jan 2014 21:31:40 GMT
content-type: application/json
digest: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
content-length: 18</artwork>
    </figure>
   </t>
   
   <t>
The Authorization header would be:
    <figure>
     <artwork>
Authorization: Signature keyId="Test",algorithm="rsa-sha256",
headers="(request-target) host date content-type digest content-length",
signature="jgSqYK0yKclIHfF9zdApVEbDp5eqj8C4i4X76pE+XHoxugXv7q
nVrGR+30bmBgtpR39I4utq17s9ghz/2QFVxlnToYAvbSVZJ9ulLd1HQBugO0j
Oyn9sXOtcN7uNHBjqNCqUsnt0sw/cJA6B6nJZpyNqNyAXKdxZZItOuhIs78w="</artwork>
    </figure>
   </t>
   
   <t>
The Signature header would be:
    <figure>
     <artwork>
Signature: keyId="Test",algorithm="rsa-sha256",
headers="(request-target) host date content-type digest content-length",
signature="jgSqYK0yKclIHfF9zdApVEbDp5eqj8C4i4X76pE+XHoxugXv7q
nVrGR+30bmBgtpR39I4utq17s9ghz/2QFVxlnToYAvbSVZJ9ulLd1HQBugO0j
Oyn9sXOtcN7uNHBjqNCqUsnt0sw/cJA6B6nJZpyNqNyAXKdxZZItOuhIs78w="</artwork>
    </figure>
   </t>
 </section>
 </section>
 <section anchor="acknowledgements" title="Acknowledgements">
  <t>
The editor would like to thank the following individuals for feedback on and
implementations of the specification (in alphabetical order): Stephen Farrell, 
Phillip Hallam-Baker, Dave Lehn, Dave Longley, James H. Manger, 
Mark Nottingham, Yoav Nir, Julian Reschke, and Michael Richardson.
  </t>
 </section>
 <section anchor="appendix-d" title="IANA Considerations">
  <section anchor="iana-scheme" title="Signature Authentication Scheme">
   <t>
The following entry should be added to the Authentication Scheme Registry
located at <eref target="http://www.iana.org/assignments/http-authschemes">
http://www.iana.org/assignments/http-authschemes</eref>
   </t>
   <t>
Authentication Scheme Name: Signature<vspace/>
Reference: [RFC_THIS_DOCUMENT], Section 2.<vspace/>
Notes (optional): The Signature scheme is designed for clients to 
authenticate themselves with a server. 
   </t>
  </section>
  <section anchor="sa-registry" title="Signature Algorithm Registry">
   <t>
The following initial entries should be added to the Signature Algorithm 
Registry to be created and maintained at (the suggested URI) 
<eref target="http://www.iana.org/assignments/signature-algorithms">
http://www.iana.org/assignments/signature-algorithms</eref>:
   </t>
   <t>
Editor's note: The references in this section are problematic as many of the 
specifications that they refer to are too implementation specific, rather 
than just pointing to the proper signature and hashing specifications. A
better approach might be just specifying the signature and hashing function
specifications, leaving implementers to connect the dots (which are not that
hard to connect).
   </t>
   <t>
Algorithm Name: rsa-sha1<vspace/>
Reference: <xref target="RFC6376">RFC 6376</xref>, Section 3.3.1<vspace/>
Status: deprecated
   </t>
   <t>
Algorithm Name: rsa-sha256<vspace/>
Reference: <xref target="RFC6376">RFC 6376</xref>, Section 3.3.2<vspace/>
Status: active
   </t>
   <t>
Algorithm Name: hmac-sha256<vspace/>
Reference: HS256 in <xref target="I-D.ietf-jose-json-web-algorithms">
JOSE JSON Web Algorithms</xref>, Section 3.2<vspace/>
Status: active
   </t>
   <t>
Algorithm Name: ecdsa-sha256<vspace/>
Reference: ES256 in <xref target="I-D.ietf-jose-json-web-algorithms">
JOSE JSON Web Algorithms</xref>, Section 3.4<vspace/>
Status: active
   </t>
  </section>

 </section>
</back>
</rfc>
