1
$\begingroup$

Trying to get my head around digital signatures and hit a slight block. The book I am using gives the following information

  • Device A hashes a message to create a message digest
  • Device A encrypts the digest with device A's private key to create a signature
  • Device A adds the signature to the message Device A encrypts the whole message (including the signature) using device B's public key
  • Device A sends the message to device B

  • Device B decrypts the message with device B's private key
  • Device B splits the signature off of the message
  • Device B decrypts the signature using device A's public key to get the message digest
  • Device B hashes the message to get a message digest
  • If the message digest device B created is the same as the one decrpyted, the message has not been tampered with

All fine, but how does device B know what hashing algorithm was used to create the message digest?

$\endgroup$
  • 5
    $\begingroup$ It is always assumed that the details of the system are public. $\endgroup$ – fkraiem Feb 9 '16 at 10:20
  • $\begingroup$ So if the hashing algorithm is public to all patties, and can therefore be decrypted by anyone. What's the point? $\endgroup$ – Robert Flook Feb 9 '16 at 10:54
  • 4
    $\begingroup$ I suggest you start by studying some introductory material about cryptography; I hear the Coursera course is very good. $\endgroup$ – fkraiem Feb 9 '16 at 10:57
  • 1
    $\begingroup$ Does the book actualy contain "encrypts the digest with device A's private key to create a signature" ? If yes, complain to the authors for the poor wording choice, and another serious mistake: one never encipher with a private key in any public-key context; plus, there is a well-known chosen-message attack against the scheme as described. $\endgroup$ – fgrieu Feb 9 '16 at 13:55
  • 1
    $\begingroup$ See these two questions. ​ ​ $\endgroup$ – user991 Feb 9 '16 at 15:34
1
$\begingroup$

First of all signing does not equal encrypting. It only works on some crypto systems and even then it is not the whole picture.

Hash algorithms are used for various reasons. One of them is to reduce the size of the signature since the digest is generally a lot smaller than the message itself.

But the main cryptographic reason behind hash functions is to make it so that a possible attacker cannot force the message he wants to forge a signature for, to have a certain property.

It is a bit technical but for example in the ElGamal cryptosystem if you sign the message itself then it is possible for an attacker to produce a valid signature without knowing the secret key. If however you sign the hash of the message then this is not possible.

$\endgroup$
1
$\begingroup$

In a typical PKI system there are certain system parameters that needs to be known to both parties.

This can either pre-known or exchanged during a handshaking(eg.TLS). Once these details are known then the protocol can be followed as described

$\endgroup$
0
$\begingroup$

Just as someone uses a public key, they would also display their hash function. The hash function will make the message smaller, and it also adds security so that keys cannot be forged. Adding a hash function to public key crypto is just an added layer of security.

$\endgroup$
0
$\begingroup$

In any practical crypto system when you create digital signature, it will be encoded to a specific format called PKCS#7 signed data. PKCS#7 is a standard defined by RSA laboratory to store signature and it's associated parameter such as digest algorithm, signing certificate, signing time, signed data, digest value, signature algorithm, signature value etc in a single structure. For more information please refer RFC 2315 which deals with PKCS#7. So any signature verification tools parse this PKCS#7 structure and extract digest algorithm before it does signature verification.

$\endgroup$
  • $\begingroup$ Although the idea that the signature is part of a protocol is a good one, the statement "In any practical crypto system when you create digital signature, it will be encoded to a specific format called PKCS#7 signed data." is simply incorrect. There are plenty other schemes available. Furthermore, you seem to be some 4 to 5 versions behind (academic research into modern crypto is about 42 years old, you're pointing to a standard created in1998!). $\endgroup$ – Maarten Bodewes Mar 18 '16 at 1:12

protected by e-sushi Nov 13 '16 at 14:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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