(SSL Pining) How can a Public Key CA on a Device check the server's certificate

前端 未结 1 1358
悲哀的现实
悲哀的现实 2021-01-27 23:59

How CA on my device check that a digital signature is genuine or fake?. If a hacker gets my digital signature, can they combine my digital signature and their own public key and

1条回答
  •  清酒与你
    2021-01-28 00:38

    Since the first answer, I have updated this further to add further details and clarity.

    Background on Certificate Authority (CA) & Certificates

    1. Certificate Authorities or CAs issue certificates for individuals or business entities. CAs form a hierarchical structure where at the top, there is Root CA
    2. Certificates cannot be tampered by the attackers because the certificates are digitally signed by the certificate issuing CA
    3. Root CA has self-signed certificates
    4. Root CA signs next-level intermediate CA certificates
    5. Root CA certificate and various other globally recognized CA certificates are stored in trusted key store of browsers, operating systems or applications
    6. Intermediate CA may issue other intermediate CA certificates creating a chain
    7. Certificate chain contains the end certificate to the trusted Root CA including all intermediate CAs in the middle
    8. For successful verification of a certificate, the verifying agent must either get the chain certificate from the certificate owner, or, have the end certificate in its trusted key store

    Digital Signature provides:

    Digital certificates are used to digitally sign documents. The certificate is sent along with the signed document, so that the recipient can verify the authenticity and integrity of the signed document.

    Digitally signing a message means computing a hash (one-way) of the message using a pre-defined algorithm and then encrypting the hash with the private key of the certificate owner. since, no-one is supposed to know the private key of the certificate other than the owner himself/herself, no-one else can produce the same signature that can be decrypted with the public key of the certificate.

    Digital signature thus provides 3 things:

    1. Authentication - By verifying the digital certificate (using the certificate chain as mentioned above), the recipient knows that the message has been indeed sent by a trusted party

    2. Non-Repudiation - The message sender cannot deny later that the message was not sent by it, because nobody else has the private key of the message sender and therefore nobody else can sign the message with the same private key

    3. Integrity - Since the hash of the received message computed by the recipient is the same as the hash (after decryption using sender's public key) sent by the sender (after decryption using sender's public key), it proves that the client has received the exact same message as sent by the sender, otherwise if the message has been tampered by a deliberate attack or an unintentional network error, the hashes would have been different.

    Digital Signature Creation Digital signature is created by

    • Computing a hash of the message (that the signature owner wants to send to the other party) using a hashing function
    • Encrypting the hash using the private key

    Signature Verification

    Any recipient of a digitally signed document would want to verify the signature to ensure the authenticity and integrity of the document. Verification can be done in the following way:

    1. Compute the hash of the message using the same hashing function

    2. Decrypt the signature using the public key (available in the certificate) of the sender

    3. The computed hash and the decrypted hash should be the same

    Therefore as long as the certificate private key is not compromised, it is a robust mechanism.

    Some Technical Details

    Two important standards with respect to certificates are: X.509 and PKCS12. The details can be found in the linked Wikipedia pages.

    Using the Java keytool utility anyone can create a self-signed signature. However, such certificates or signature will not be trusted anywhere unless the recipient add the certificate in their device trust store.

    0 讨论(0)
提交回复
热议问题