# Obtain the Hash of a Signature for Requesting a Time-stamp

# Alias

`DocumentSignerToBeTimeStampedCalculation`

# Description

Obtains the hash of a signature according to a signature definition and modifies it with the information from the hash (the `to_be_timestamped` property). Before performing this update, this operation modifies the signature definition with the digital signature (PKCS #1) of the document to which the definition is applied.

The hash of the signature is obtained using the algorithm specified by the `parameters.default_digest_algorithm` attribute of the signature definition, if not present, the SHA-256 algorithm.

The hash obtained by this operation must be used to request a time-stamp on the signature.

Important

This operation cannot be invoked if the signature definition involved contains the signature whose timestamp is wanted to be obtained.

# Request

`PUT /trustedx-resources/esignsp/v2/documents/{doc_and_sigdefs_id}/signers/{signature_definition_id}/to_be_timestamped`

## Parameters

Name | Type | Usage | Description
`doc_and_sigdefs_id` | path | Required | Identifier of the document and signature definitions resource that contains the definition of the signature from which the hash is requested.
`signature_definition_id` | path | Required | Identifier of the signature definition of the signature from which the hash is being requested.

## Authorization

The request must contain a bearer access token generated by an authorization server of the platform. This token must have a scope that includes the `urn:safelayer:eidas:sign:process:document` value and must be used as explained in RFC 6750. Basically, the access token must be included in an Authorization header as follows:

`Authorization: Bearer <token>`

The client application must obtain the required access token via a client credentials grant OAuth 2.0 interaction with the platform.

## Content-Type Header

`Content-Type: application/json`

## Body

The body of the request must include the following JSON object:

`{`
`"signature" : {string}`
`}`

Property | Usage | Description
`signature` | Required | Base64 encoding of the digital signature (PKCS #1) corresponding to the signature from which the hash is being requested.

# Response

## Status-Line

Value | Description
`HTTP/1.1 200 OK` | The calculation of the signature hash was performed correctly and its data is in the body of the response.
`HTTP/1.1 409 Conflict` | An attempt was made to obtain the hash of a signature that had already been obtained or that had already been updated with the digital signature.
Others | See HTTP Response Status for all the possible cases.

## Content-Type Header

`Content-Type: application/json`

## Body

If the hash is successfully calculated, the body contains the following JSON object:

`{`
`"type" : "message_imprint",`
`"digest_algorithm" : {string},`
`"digest_value" : {string}`
`}`

Property | Description
`type` | Always has the value `"message_imprint"`.
`digest_algorithm` | Hash algorithm. The value of this property can be `"sha1", "sha256", "sha384" or "sha512".`
`digest_value` | Hash of the signature performed according to the signature definition.