# Sign hashes

Hash signature allows the signing of document hashes instead of the actual documents. These hashes are signed by fidentity and can subsequently be embedded into a PDF outside of the fidentity flow.

#### Procedure

To sign hashes instead of documents, the initial call is made based on the QES variations. The `documentUris` array is set to empty and replaced by the `hashesToSign` array. Other than this difference, the calls for signing PDFs and hashes are identical.

**Example request**

```
  "documentUris": [],
  "hashesToSign": [{
      "id": "hash-id-{{$guid}}",
      "type": "signature",
      "title": "hash signature",
      "hash": "91951BA09F5213ADE633434681DFACC5F1C2F49920040AAEB451799037E40A3C",
      "hashAlgorithm": "sha256",
      "documentLink": ""
  }]
```

**Example respond**

At the end of the successful Process, you can get the process Object and in the field "signedHashes", there are 3 properties that are important:

* signature -> Signature of CMS object
* cmsObject -> CMS Object to integrate to pdf (pkcs7)
* certificate -> Public certificate of signing party (DER encoded)

````
"signedHashes": [
        {
            "id": "test-hash-1",
            "title": "QesSignature-cypress-test",
            "type": "contract",
            "hash": "538a54e1480b6...",
            "cmsObject": "MIIz+AYJK...",
            "preparedDigest": "17bd1...",
            "signature": "d181cffd28e...",
            "certificate": "MIIH2zCCBY...
        }
    ],```
````

#### PDF handling with Hash Signing

Our TSP Partner Swisscom has created a [step-by-step guide for developers ](https://trustservices.swisscom.com/en/support/help-center/how-to-embed-a-signed-hash-into-a-pdf-document)wishing to integrate hashes into PDF files by themselves. There are also references to some tools that provide this feature as well as github examples.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fidentity.ch/use-cases/qes/sign-hashes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
