# How is the message digest related to Signatures and Encryption?

I was studying about 'Data Security' and I found out this one thing confusing.

What is a message digest? I got it is the hash of the message.

Is the message here referring to the plaintext or cipher text? I believe when using Digital Signatures, the message itself is also encrypted with a public key.

First of all, yes, the message digest is the hash of the message.

Secondly, do not mix things up. You are talking about public key encryption and signature. Let's redefine them to make sure we have everything right.

Alice and Bob got pairs of key ($A_{pub}$, $A_{priv}$), ($B_{pub}$, $B_{priv}$). Alice knows $B_{pub}$ and Bob knows $A_{pub}$.

• Alice wants to send a message $m$ to Bob $\implies$ She encrypts it with $B_{pub}$.
• Alice wants to prove to Bob that it was she who sent the message $\implies$ She signs it with her private key $A_{priv}$.

How does the message digest appear in all that ? Continue reading.

Problem: signing and encryption using RSA (standard procedure) is slow. How to speed up the process ?

1. Alice encrypts the message with a symmetric cipher (AES) using a random generated key $K_{sym}$. Then, encrypt $K_{sym}$ with the $B_{pub}$.

2. Alice does not sign the message, she signs the message digest. Smaller therefore faster.

All this together ? Here are the steps :

1. Alice hashes the message $m$ $\implies$ she gets the message digest.
$H(m) \to MD$.

2. Alice signs $MD$ with her private key.
$E_{A_{priv}}(MD) \to Sig$.

3. Alice generates a random key for the symmetric encryption.
$rdm() \to K_{sym}$

4. Alice encrypts the message and the signature with a symmetric cypher.
$E_{K_{sym}}(m\|Sig) \to c$

5. Alice encrypts the symmetric key with Bob's public key.
$E_{B_{pub}}(K_{Sym}) \to K_{cipher}$

6. Alice sends $(c,K_{cipher})$ to Bob.

Remark: It is a good practice to have 2 pairs of keys : one for encryption, one for signatures.

• Great! It was very useful! I was wondering if it was right to say if symmetric algorithms use the same algorithm and key for both encryption and decryption? Mar 21, 2016 at 14:08
• symmetric encryption algorithm means that the key is the same for the encryption and the decryption : caesar, AES, DES ... public key encryption (or asymmetric encryption) means that the key to encrypt is different to the key to decrypt. The source code for encryption and decryption is unrelated to the kind (symmetric / asymmetric) : RSA is asymmetric but the same code is used to encrypt and decrypt. DES, AES are symmetric, but you need to specify the mode you want to use.
– Biv
Mar 21, 2016 at 14:39
• What is the purpose of also encrypting the signature? Apr 20, 2018 at 9:32
• @Biv In your example, at the receiving end, how can Bob determine what Alice's private key is in order to rehash the message and compare the message digest that he gets to the one she obtained? I don't think Bob is supposed to know Alice's private key, but then how else is he able to compare the message digests? Thanks for your input.
– Dxml
Oct 2, 2021 at 1:23
• @Dxml 1. Bob decrypts Kcipher to retrieve Ksym, 2. Bob decrypt c with Ksym to retrieve m and Sig, 3. Bob hash m and get MD, 4. Bob knows Alice public key and apply it on Sig to retrieve MD'. He can then compare MD and MD'. No need for Alice private key.
– Biv
Oct 2, 2021 at 23:44