2

In general(PKI), encryption happens with public key and decryption happens with private key. But, how Certificate Authority sign a digital certificate with private key? How this can be validated using public key in browser? What is the logic behind CA certificate validation?

What is the role of SHA (hash algorithm) role here? How SHA and CA private key work together?

2
  • 1
    i think you have a misunderstanding here. you can encrypt with one key and decrypt with the other, that means that if the CA makes a signature using his private key then you can validate it using his public key. the use of a hashing function here would be to make the signature and it would be used like a message authentication code (MAC)
    – Nullman
    Commented Jun 4, 2020 at 5:43
  • 2
    "In general(PKI), encryption happens with public key and decryption happens with private key." - PKI itself is not about encryption but about providing electronic identities and being able to verify these identities using a few local trust anchors. Commented Jun 4, 2020 at 5:45

1 Answer 1

1

Signing is one of two basic operations you can perform in public key cryptography:

  • encryption: encrypt with recipient's public key, decrypt with matching private key
  • signature: sign with sender's private key, verify with matching public key

The goal of digital signatures using private keys is to ensure that the message is as intended by the signer and not modified. Anyone can verify the integrity of the message (in this case: a certificate).

The hash algorithm is applied to the message (the certificate contents), the output padded to the length appropriate to the key size, then signed. This ensures two things:

  • we have an amount of data to sign that can be handled by the algorithm (eg: RSA, ECDSA)
  • that data is a representation of the contents themselves

It is important for the certificate signature algorithm to be a safe one (with no known practical weaknesses). This is why md5 and sha-1 are no longer recommended.

You can find more details about message signature using RSA in this crypto.se answer.

4
  • Hi Marc, thanks for your answer. Can you clarify, what is the logic behind signature verification with public key? signature: sign with sender's private key, verify with matching public key Commented Jun 4, 2020 at 6:43
  • 1
    Obligatory reminder that encrypting and signing are NOT the same thing! RSA uses the same math for both (aside from some vitally important stuff like padding) but many other algorithms don't. Indeed, some - like DSA - can only be used for one (signing, in DSA's case) and not for the other (encryption)!
    – CBHacking
    Commented Jun 4, 2020 at 6:45
  • 1
    @srikanthvarma: I'm not sure what you're asking for. A receiver can use the signature and public key to compute a value. This value should be equal to the hash of the message (which the receiver can compute). The important part is that the receiver cannot create a signature for a different message (that would defeat the purpose) but can verify that a message matches an existing signature. I recommend you start with the first link I sent for an overview of public key cryptography.
    – Marc
    Commented Jun 4, 2020 at 7:08
  • This makes sense. Thanks a lot Marc Commented Jun 4, 2020 at 8:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .