# Digital signature

Digital signature

A digital signature is a mathematical scheme for verifying the authenticity of digital messages or documents. A valid digital signature, where the prerequisites are satisfied, gives a recipient very strong reason to believe that the message was created by a known sender (authentication), and that the message was not altered in transit (integrity).

Digital signatures are a standard element of most cryptographic protocol suites, and are commonly used for software distribution, financial transactions, contract management software, and in other cases where it is important to detect forgery or tampering.

## Functioning

Let’s suppose that Alice wants to send a message to Bob which he can check the authenticity.

The message that want to send Alice is a binary file M (text, image, executable…) that can be assimilated to a text file.

### Setting up the signature’s architecture

Alice chooses :

- asymmetric cryptography made of ciphering function C and deciphering function D
- hash function : H.

For the chosen ciphering, Alice has generated a private key K_{pr} and a public key K_{pb} :

- she pass the public key K
_{pb}and the hash function H to Bob by a

non-secured channel - she keeps the private key K
_{pr}secret.

D,H and Kpb don’t need to remain secret. However C has to remain secret.

### Preparation of the signed message

Alice prepares the signed message :

- she produces an hash of the message with the chosen hash function

H(M) - she ciphers the hash thanks to a cipher function C using her private

key K_{pr}. The result is obtained by the signature of the message : S_{M}

= C(K_{pr},H(M)) - she prepares the signed message putting the message unencrypted and

the signature SM in any container : M_{signed}= (S_{M},M).

Alice send M_{signed} to Bob through a non-secured channel.

### Reception of the signed message

Bob receives the signed message. To check its authenticity :

- He produces a hash of the unencrypted message by using the Alice’s

hash function : H(M) - He deciphers the signature using D with K
_{pb}: D_{sm}=D(K_{pb},S_{M}) - He compares D
_{SM}with H(M)

In the case that the signature is authentic, D_{SM} and H(M) are equals, given the properties of the asymmetric cryptography: D_{SM} = D(K_{pb},S_{M}) = D(K_{pb},C(K_{pr},H(M)))=H(M)

Then the message is authenticated.