8
$\begingroup$

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.

$\endgroup$

1 Answer 1

19
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ 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? $\endgroup$
    – codez
    Mar 21, 2016 at 14:08
  • $\begingroup$ 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. $\endgroup$
    – Biv
    Mar 21, 2016 at 14:39
  • $\begingroup$ What is the purpose of also encrypting the signature? $\endgroup$
    – Cocowalla
    Apr 20, 2018 at 9:32
  • $\begingroup$ @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. $\endgroup$
    – Dxml
    Oct 2, 2021 at 1:23
  • 1
    $\begingroup$ @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. $\endgroup$
    – Biv
    Oct 2, 2021 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.