3

i have two similar questions about using certificates.

  1. I was reading about a Certificate Authority in a system and i've found that the CA uses PKI adhering to the X509 standard for public key infrastructure to sign a message. I will quote what the CA said:

Digital certificates are used to establish authenticity of user credentials and to digitally sign messages. Signing messages with a certificate ensures that the message has not been altered.

Source : https://github.com/hyperledger/fabric/blob/master/docs/protocol-spec.md#42-user-privacy-through-membership-services

I know X509 is a certificat format containing public key so is it possible to sign with a contract?

  1. While I was searching on the Internet for an answer to the first question, I've found that it is possible to ENCRYPT a message using a X509 certificate:

https://msdn.microsoft.com/en-us/library/ms824684.aspx

I am confused as to encrypt we need a private key. Is the key inside the certificate?

  • To encrypt a message for somebody you need the public key of the recipient which is contained in the recipients certificate. To sign a message in your name you need your private key and the recipient can use the public key in your certificate to validate the signature. – Steffen Ullrich Jan 10 '17 at 18:04
  • but the CA gives only a certificat without a Private key – Sig Touri Jan 10 '17 at 23:15
  • The private key is private to you and thus even the CA should not see it. You generate the key pair yourself and keep the private part secret. The CA just signs your certificate request which includes the public key and information about you but not the private key. – Steffen Ullrich Jan 11 '17 at 7:24
  • yes, I agree but how do you explain what i've found in these project they claim to encrypt and sign using a certificat did you visit the links? – Sig Touri Jan 11 '17 at 10:33
  • From my understanding of the linked information they don't claim that they sign and encrypt using the same certificate. Signing is done with the senders certificate where the sender needs the private key while encrypting is done with the recipients certificate and only the public key is needed. – Steffen Ullrich Jan 11 '17 at 11:08
2

I feel your confusion. From your provided link, I copied the first paragraph:

The Web Services Enhancements for Microsoft .NET (WSE) allows a sender, which can either be an XML Web service or its client, to encrypt portions of the SOAP message by using the public key for the recipient's X.509 certificate. A receiver, which can be either a Web service or its client, then decrypts the message by using the private key for its X.509 certificate. If the recipient is the only one with the private key, it is highly likely that only the recipient can decrypt the message. Therefore, to encrypt the message, the sender must have access to the public key for the recipient's X.509 certificate and the recipient must have access to the private key for the recipient's X.509 certificate.

In order to understand these things, you need to notice and laser your attention as to which X.509 certificate the sentence is referring to. Is it from the sender or from the receiver? Here are the two sides:

  • The sender side has his X.509 certificate
  • The receiver side has its own X.509 certificate too.

For example, let us analyze this one:

allows a sender, which can either be an XML Web service or its client, to encrypt portions of the SOAP message by using the public key for the recipient's X.509 certificate

Here is the analysis:

  • The sender is doing the encryption part
  • The sender uses the public key of the receiver to do the encryption
  • The sender extracts this public key from the X.509 certificate of the receiver

I tried to analyze the root cause of your confusion. I think, the root cause is the use of for instead of of in the sentences. Can you please confirm if, indeed, this is the root cause?

Most folks want to prove the rocket scientists that they are. But I am more interested in the root causes of confusion as it widens my point of view and allows me to see things in different perspectives.

| improve this answer | |
1

You are missing some basic conceptual knowledge about how digital certificates, signatures, and PKI works. I work with these concepts daily as someone working in the IT Security profession, so let me explain.

Digital signatures are used to protect the Integrity principle of information (I in CIA triad) along with the related principle of non - repudiation. Integrity of information means:

Data is not maliciously modified / destroyed / corrupted while either at rest or in transit

The related principle of non - repudiation ensures that if integrity principle has been violated, the accountable party cannot deny having tampered with the data.

PKI is a asymmetric method of signing / encrypting data, which means that 2 keys are needed to complete the operation:

  1. Private key only known to one party in the transaction
  2. Public key of each party in the transaction that is freely available

Signing a Message

When signing a message, the message digest of the message body is first generated by running the message through a hashing algorithm such as SHA2. The private key of the sender is then used to encrypt the transmitted message digest. The public key of the sender is often appended to the message body. Upon receiving the message, the receiver decrypts the message digest using the freely available public key of the sender. By comparing the decrypted message digest with a separately computed hash of the original message, integrity and non - repudiation can be assured if the two resulting hashes are equal.

Non - repudiation is assured via the role of the Certificate Authority (CA). The role of this party is to attest to the identity of each party in the transaction (sender and receiver) by binding the pubic key of each party to a document known as a certificate that contains information such as the origination domain, and method used to generate the keys.

Encrypting a Message

The purpose of encrypting a message is to ensure the C and I in CIA - Confidentiality and Integrity. Encryption (ex: via TLS) ensures that data in transit only cannot be intercepted by a malicious 3rd party. Data is encrypted with the public key of the receiver so that only the matching private key of the receiver can decrypt the message.

To answer your question, The private key is known only to the receiver and is NOT in the certificate

| improve this answer | |
  • 1
    thank you for your explanation but this didn't answer the qestion, I agree on what you said these are the bases but please look at the links and explain to me why they say they encrypt and sign using a delivered certificat? – Sig Touri Jan 11 '17 at 10:38
  • 1
    This is NOT the answer – Kennet Celeste Dec 9 '19 at 17:01
  • This answer is demoralizing. Root causes of confusion must be digged. – eigenfield Jul 15 at 14:23
1

Indeed, a certificate contains a public key plus information about who this public key belongs to. It is impossible to sign with a certificate. But there is a moderately common imprecision which consists of using “certificate” to mean “private key for which a certificate exists”. This is what's going on here. The private key is mathematically related to the public key contained in the certificate, but it's impossible to calculate the private key from the certificate (this impossibility is the whole point of public-key cryptography).

I do not recommend abusing the word “certificate” in this way, because it is a source of confusion around concepts that are often hard to understand. It's better to use more words and be more precise than to use fewer words and leave the reader confused, or worse leave the reader with an incorrect understanding. But when you read “for dummies” explanations of public key infrastructure, you need to keep in mind that there's a risk that the explanation doesn't really make sense due to its misuse of terminology.

On the other hand, it is possible to encrypt a message with a certificate. More precisely, it's possible to encrypt a message with the public key contained in a certificate, but using “certificate” where a public key is expected is not a big deal since the certificate is the public key plus extra data. You do not need a private key to encrypt data: public-key encryption uses the public key to encrypt and the private key to decrypt. Encrypting with a private key would be pointless since anyone could decrypt by using the public key (which is generally assumed to be, as the name implies, public).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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