| SSL/TLS Certificate :👈 | 👉:Kusto Query Keywords |
SHA-256 with RSA |
SHA-256 with RSA – Complete Explanation
SHA256 with RSA is a cryptographic digital-signature algorithm combination used to verify the authenticity and integrity of data.
It is commonly used in:
- SSL/TLS certificates.
- HTTPS communication.
- Digital signatures.
- Software signing.
- Authentication systems.
- Secure document exchange.
When you see SHA256withRSA in an SSL/TLS certificate, it means that SHA-256 is used to calculate a hash, and RSA is used to generate a digital signature from that hash.
1. First, Understand SHA-256 and RSA Separately
A. What is SHA-256?
SHA stands for Secure Hash Algorithm.
SHA-256 is a cryptographic hash function that converts input data of any length into a fixed-length output of 256 bits (32 bytes).
Example:
Input:
Hello World
SHA-256 Output:
a591a6d40bf420404a011733cfb7b190
d62c65bf0bcda32b57b277d9ad9f146e
Important characteristics:
- Fixed output: Regardless of input size, the output is always 256 bits.
- One-way function: It is computationally infeasible to recover the original input from its hash.
- Deterministic: The same input always produces the same hash.
- Avalanche effect: A tiny change in the input produces a very different hash.
- Collision resistance: It is computationally infeasible to find two different inputs with the same SHA-256 hash.
Example:
Input 1: Hello
Hash 1:
185f8db32271fe25f561a6fc938b2e26
4306ec304eda518007d1764826381969
Input 2: hello
Hash 2:
2cf24dba5fb0a30e26e83b2ac5b9e29e
1b161e5c1fa7425e73043362938b9824
Notice that changing just one character changes the resulting hash significantly.
Important: SHA-256 alone does not encrypt data and does not prove who created the data. It only produces a hash.
B. What is RSA?
RSA is an asymmetric cryptographic algorithm.
It uses two mathematically related keys:
- Public Key: Can be shared with others.
- Private Key: Must be kept secret by its owner.
RSA supports operations such as digital signing and signature verification.
The private key is used to create a digital signature, and the corresponding public key is used to verify it.
Important: RSA is not the same as SHA-256. RSA performs the asymmetric cryptographic operation, while SHA-256 calculates the hash.
2. What Exactly Is SHA256 with RSA?
It combines both technologies to create a digital signature.
The process has three main steps:
- SHA-256 calculates a hash of the original data.
- RSA uses the sender's private key to generate a digital signature.
- The receiver uses the sender's public key to verify the signature.
The combination is commonly called SHA256withRSA.
Technically, RSA signing uses a defined signature scheme, such as RSASSA-PKCS1-v1_5 or RSASSA-PSS. It is not simply encrypting the hash with the private key.
3. How Is SHA256 with RSA Created?
Let's consider a website called:
www.example.com
The website owner needs a TLS certificate.
Step 1: Generate an RSA Key Pair
The website owner generates two mathematically related keys.
Example:
Public Key:
-----BEGIN PUBLIC KEY-----
Public key data...
-----END PUBLIC KEY-----
Private Key:
-----BEGIN PRIVATE KEY-----
Private key data...
-----END PRIVATE KEY-----
These are illustrative formats, not actual usable keys.
Step 2: Create a Certificate Signing Request (CSR)
The website owner creates a CSR containing:
- Website domain name.
- Organization details, where applicable.
- Public key.
- Requested certificate information.
The CSR is submitted to a Certificate Authority (CA).
Important: The private key is not sent to the CA.
Step 3: Certificate Authority Creates the Certificate
The CA verifies the domain owner's control of the domain.
After successful validation, the CA creates an X.509 certificate containing information such as:
Certificate
|
+-- Subject: www.example.com
|
+-- Issuer: Certificate Authority
|
+-- Validity Period
|
+-- Public Key
|
+-- Extensions
|
+-- Signature Algorithm: SHA256 with RSA
|
+-- Digital Signature
The CA calculates the SHA-256 hash of the certificate information that must be signed and signs it using the CA's private signing key.
The resulting signature is included in the issued certificate.
Important distinction: The certificate contains the website's public key, but the certificate's digital signature is created using the CA's private key. These are usually two different key pairs.
4. How Is the Digital Signature Created?
Suppose the CA needs to sign the certificate information.
Certificate Information:
Subject: www.example.com
Issuer: Example CA
Validity: 2026 - 2027
Public Key: Website Public Key
Step 1: Calculate the SHA-256 Hash
The CA passes the certificate information to SHA-256.
Certificate Information
|
v
SHA-256
|
v
256-bit Hash
The output is always 256 bits, or 32 bytes.
Step 2: Generate the RSA Signature
The CA uses its private key and an RSA signature scheme to sign the hash.
256-bit Hash
|
v
RSA Signing Algorithm
|
+---- CA Private Key
|
v
Digital Signature
The result is the digital signature.
Step 3: Attach the Signature
The CA attaches the signature to the certificate.
X.509 Certificate
|
+-- Certificate Information
|
+-- Signature Algorithm
| SHA256 with RSA
|
+-- Digital Signature
The certificate is now signed by the CA.
5. How Is It Passed from Server to Browser?
Now suppose a user visits:
https://www.example.com
The browser needs to verify the website's certificate.
Step 1: Browser Connects to the Website
Browser
|
| HTTPS Connection
|
v
Web Server
Step 2: Server Sends Its Certificate
During the TLS handshake, the server sends its certificate to the browser.
The certificate contains:
- Website identity information.
- Website public key.
- Issuer information.
- Validity period.
- CA's digital signature.
The private key is never sent.
Step 3: Browser Receives the Certificate Chain
The browser uses the supplied certificate and intermediate certificates to build a chain towards a trusted root certificate.
Browser
|
| Receives certificates
|
v
Website Certificate
|
v
Intermediate CA Certificate
|
v
Trusted Root CA
The browser uses the appropriate issuer public key to verify each certificate signature.
6. How Does the Browser Verify SHA256 with RSA?
This is the most important part.
The browser needs to verify whether the CA's digital signature is valid.
Step 1: Read the Certificate Information
The browser obtains the certificate's signed information.
Step 2: Calculate the SHA-256 Hash Again
The browser independently calculates the SHA-256 hash of the same certificate information.
Certificate Information
|
v
SHA-256
|
v
Browser Hash
Step 3: Verify the Digital Signature
The browser uses the issuing CA's public key to verify the signature.
Digital Signature
|
v
RSA Verification
|
+---- Issuing CA Public Key
|
v
Signature Verification Result
The verification algorithm checks that the signature is valid for the certificate information and the CA's public key.
Step 4: Determine Whether the Certificate Is Trusted
The browser also checks:
- Is the certificate issued by a trusted CA?
- Does the certificate chain lead to a trusted root?
- Does the website hostname match the certificate's SAN?
- Is the certificate within its validity period?
- Is the certificate revoked, where revocation checking is performed?
- Are the algorithms and key sizes acceptable?
If the necessary checks succeed, the browser can trust the certificate for that connection.
Remember: The browser does not need the CA's private key. It only needs the CA's public key to verify the signature.
7. How Does the Website Prove It Owns the Private Key?
Receiving a certificate alone does not prove that the server actually possesses the corresponding private key.
During the TLS handshake, the server also proves possession of its private key by signing handshake-related data when certificate-based signature authentication is used.
For example:
Browser
|
| ClientHello
|
v
Server
|
| ServerHello
|
| Sends Certificate
|
| Sends CertificateVerify
| (Digital Signature)
|
v
Browser
|
| Verifies signature
| using server public key
|
v
Handshake Continues
This proves possession of the private key corresponding to the public key in the server certificate.
Important: The CA's signature on the certificate and the server's signature during the TLS handshake are two different signatures.
Also, TLS 1.3 commonly uses RSA-PSS for RSA handshake signatures. The certificate itself may have been signed using SHA256 with RSA PKCS#1 v1.5. These are separate operations.
8. How Is SHA256 with RSA Secure?
It provides important security properties.
A. Data Integrity
If someone modifies the signed data, the hash changes.
For example:
Original Data:
Amount = 1000
Modified Data:
Amount = 9000
The SHA-256 hashes will be different.
The original digital signature will not verify against the modified data.
B. Authentication
The signature can be verified using the corresponding public key.
Only someone possessing the corresponding private key should be able to create a valid signature, assuming the RSA scheme and key are secure.
C. Non-Repudiation Support
A digital signature can provide evidence that a particular private key signed the data.
However, it does not automatically prove which human used the key. Key protection, identity verification, and audit records also matter.
D. Collision Resistance
SHA-256 is designed to make it computationally infeasible to find two different inputs with the same hash.
This helps prevent an attacker from substituting different data while retaining the same hash.
E. Private-Key Protection
The private key is never included in the public certificate or sent to the browser.
This protects the signing capability as long as the private key remains secure.
9. What Happens If Someone Changes the Certificate?
Suppose an attacker modifies:
Original:
Domain = www.example.com
To:
Modified:
Domain = www.attacker.com
The attacker cannot create a valid CA signature for the modified certificate without the CA's signing private key.
When the browser verifies the signature, verification fails.
This is why a trusted certificate chain is important.
10. SHA-256 vs RSA vs SHA256 with RSA
| Feature | SHA-256 | RSA | SHA256 with RSA |
|---|---|---|---|
| Type | Hash function | Asymmetric cryptographic algorithm | Digital-signature combination |
| Main purpose | Calculate hash | Public/private key operations | Sign and verify data |
| Uses keys? | No | Yes | Yes |
| Output | 256-bit hash | Depends on operation and key | Digital signature |
| Encryption? | No | Supports encryption schemes, among other operations | Not an encryption algorithm |
| Authentication | No, not by itself | Depends on how it is used | Yes, with a trusted public key |
| Integrity | Hash can detect changes when compared securely | Can support integrity through signatures | Yes |
11. C# Example: SHA256 with RSA
The following example demonstrates how to create an RSA key pair, sign data, and verify the signature.
using System;
using System.Security.Cryptography;
using System.Text;
class Program
{
static void Main()
{
// Generate RSA key pair
using RSA rsa = RSA.Create(2048);
// Original message
string message = "Hello Secure World";
byte[] data = Encoding.UTF8.GetBytes(message);
// Generate digital signature
byte[] signature = rsa.SignData(
data,
HashAlgorithmName.SHA256,
RSASignaturePadding.Pss
);
// Convert signature to Base64
string signatureBase64 =
Convert.ToBase64String(signature);
Console.WriteLine("Original Message:");
Console.WriteLine(message);
Console.WriteLine("Digital Signature:");
Console.WriteLine(signatureBase64);
// Verify signature using public key
bool isValid = rsa.VerifyData(
data,
signature,
HashAlgorithmName.SHA256,
RSASignaturePadding.Pss
);
Console.WriteLine("Signature Valid: " + isValid);
}
}
Explanation
RSA.Create(2048)generates an RSA key pair.SignData()calculates the SHA-256 hash and creates an RSA digital signature.Convert.ToBase64String()converts the signature bytes into a transport-friendly text representation.VerifyData()verifies the signature using the public key contained in the RSA object.
In a real application, the sender would securely retain the private key and provide the corresponding public key or certificate to the receiver.
12. How Is the Signature Passed Between Applications?
A digital signature is usually transmitted along with the original data.
Sender
|
| Original Data
|
| SHA-256 + RSA Signing
|
v
Digital Signature
|
v
Send Data + Signature + Public Key/Certificate
|
v
Receiver
|
| Verify using Public Key
|
v
Valid / Invalid
A simplified JSON representation might look like:
{
"message": "Hello Secure World",
"signature": "BASE64_ENCODED_SIGNATURE",
"certificate": "CERTIFICATE_REFERENCE_OR_DATA"
}
In production, the receiver must obtain and validate the public key or certificate through a trusted mechanism. Merely receiving a public key alongside a message does not establish trust.
13. Best Practices
- Use SHA-256 or stronger approved hash algorithms.
- Prefer RSA keys of at least 2048 bits according to current security policy.
- Prefer RSA-PSS for new RSA digital-signature implementations where supported.
- Protect private keys using secure key storage.
- Never transmit private keys.
- Validate the certificate chain and hostname.
- Monitor certificate expiration and renewal.
- Avoid obsolete algorithms such as SHA-1.
- Use secure TLS configurations.
- Use Azure Key Vault or another suitable hardware-backed key-management service where appropriate.
14. Quick Revision
| Question | Answer |
|---|---|
| What is SHA-256? | A cryptographic hash function. |
| What is RSA? | An asymmetric cryptographic algorithm. |
| What is SHA256 with RSA? | A digital-signature algorithm combination. |
| Who creates the RSA key pair? | The certificate owner or a secure key-management service. |
| Who signs the website certificate? | The Certificate Authority. |
| Which key signs the certificate? | The CA's private signing key. |
| Which key verifies the certificate signature? | The CA's public key. |
| Is the private key sent to the browser? | No. |
| What is the hash size of SHA-256? | 256 bits (32 bytes). |
| What happens if signed data changes? | Signature verification fails. |
| Does SHA-256 encrypt data? | No. |
| Does RSA alone provide TLS encryption? | No. TLS uses negotiated cryptographic mechanisms for secure communication. |
Conclusion
SHA-256 creates a fixed-size fingerprint of data. RSA uses a private key to sign that fingerprint, and the corresponding public key allows another party to verify the signature.
This combination helps establish authenticity and integrity in digital certificates and secure communication.
Official References
| SSL/TLS Certificate :👈 | 👉:Kusto Query Keywords |