The Big Picture: Who Made This Program, and Has It Been Changed?
You download setup.exe. Two questions matter: Who made it? and Is it exactly what they published, or did someone change it on the way? Looking at the file name tells you nothing.
Code signing answers both. The publisher puts a digital signature on the program. Windows checks the signature, and can say "this is from a known publisher and has not been changed", or "unknown publisher", or "tampered".
It is the same idea as a wax seal on a letter. The seal shows who sent it, and a broken seal shows it was opened.
Cryptography words, explained:
| Word | Plain meaning |
|---|---|
| Hash | A fingerprint of data. Any change gives a different fingerprint |
| Public/private key pair | Two linked keys. The private key is kept secret by its owner. The public key is shared with everyone |
| Signature | A hash of the data, locked with the private key. Anyone can unlock it with the public key to check it |
| Certificate | A digital ID card. It says "this public key belongs to this publisher", and is itself signed by someone trusted |
| Certificate Authority (CA) | A trusted organisation that checks identities and issues certificates |
9.1 Digital Signatures on Executables/Drivers
What it is: Microsoft's format for signing programs is called Authenticode. It is used on .exe, .dll, .sys (drivers), installers (.msi), scripts (.ps1) and more.
How a file gets signed:
Publisher Result
┌────────────────────────────────┐
│ 1. Hash the program │
│ 2. Lock the hash with the │ ┌──────────────────────────┐
│ PRIVATE key = signature │──►│ program + signature + │
│ 3. Attach signature and the │ │ certificate (public key) │
│ certificate to the file │ └──────────────────────────┘
└────────────────────────────────┘
How Windows checks it:
Windows receives the signed file
│
1. Hash the file again ──► hash A
2. Unlock the signature with the
certificate's PUBLIC key ──► hash B
│
3. Compare: A equals B ?
├── yes ► file is unchanged since signing
└── no ► file was altered: signature INVALID
A matching hash proves integrity (unchanged). A trusted certificate proves origin (who signed). Both are needed. Also, a signature does not mean the program is safe. It means this publisher stands behind it. Malware authors do sometimes get certificates (or steal them).
Timestamps. A signature can include a timestamp from a trusted server. If the certificate expires later, the signature is still considered valid, because it was made while the certificate was valid.
Where signing is required or used:
| Place | What Windows does |
|---|---|
| Kernel-mode drivers (64-bit Windows) | Must be signed, or Windows will not load them. For current Windows, drivers generally have to go through Microsoft's portal and be signed by Microsoft. (Details depend on version and Secure Boot state.) |
| Boot files | Secure Boot checks them (Section 3) |
| Windows files and updates | Windows' own files are signed or "cataloged" and checked |
| User Account Control (UAC) prompt | The elevation prompt shows a verified publisher in blue for signed apps, or "Unknown publisher" for unsigned ones |
| SmartScreen | Uses a signature as part of a program's reputation (below) |
| App Control and AppLocker | Can allow programs by publisher (Section 10) |
| PowerShell | Execution policy can require signed scripts |
SmartScreen reputation. When you download and run a file, SmartScreen checks it against Microsoft's reputation data. A file with a valid signature from a publisher who is widely used passes quietly. A brand-new, unsigned, rarely-downloaded file may show "Windows protected your PC". You can still click More info → Run anyway, but you should stop and think first. Signed files earn reputation with the publisher over time, instead of per file.
See a signature yourself:
| Method | Steps |
|---|---|
| File Properties | Right-click a file → Properties → Digital Signatures tab (shown only if the file is signed) → select the signature → Details |
| PowerShell | Get-AuthenticodeSignature C:\Windows\System32\notepad.exe (the path may differ on your Windows version; some programs are Store apps) |
The PowerShell output has a Status column. Typical values:
| Status | Meaning |
|---|---|
| Valid | Signature is correct and the certificate chain is trusted |
| NotSigned | No signature at all |
| HashMismatch | The file was changed after signing |
| NotTrusted / UnknownError | The signer or chain is not trusted |
Note on Windows' own files. Many Windows files are not signed inside the file. They are covered by catalog files (
.cat), which list the correct hashes of many files and are signed once.Get-AuthenticodeSignaturemay showNotSignedfor such a file unless it checks the catalog. Use the Properties tab or thesigchecktool from Sysinternals when in doubt.
9.2 Certificate Chain Validation
A certificate is only useful if you trust the one who issued it. But who vouches for them? The answer is a chain.
┌───────────────────────────────────────────────┐
│ ROOT CA │
│ (self-signed; already in Windows' trusted │
│ store, so Windows trusts it directly) │
└───────────────────────┬───────────────────────┘
│ signs
┌───────────────────────▼───────────────────────┐
│ INTERMEDIATE CA │
│ (issues certificates day to day) │
└───────────────────────┬───────────────────────┘
│ signs
┌───────────────────────▼───────────────────────┐
│ LEAF (end-entity) certificate │
│ "Example Software Ltd" signing certificate │
└───────────────────────────────────────────────┘
What Windows checks, step by step:
| Step | Question |
|---|---|
| 1 | Is the signature on the file correct (hash match)? |
| 2 | Does each certificate in the chain have a valid signature from the one above it? |
| 3 | Does the chain end at a trusted root? Windows keeps a store of these (Trusted Root Certification Authorities) |
| 4 | Is each certificate within its validity dates (or was the file timestamped in time)? |
| 5 | Is the certificate meant for code signing (its "usage" field says so)? |
| 6 | Has any certificate been revoked (cancelled because the key was stolen or misused)? Windows may check a CRL (revocation list) or OCSP (an online "is this still good?" check) |
If any step fails, the signature is not trusted.
Trusted publishers. Windows also has a Trusted Publishers store. A certificate placed there is trusted for things like policies that say "run only from trusted publishers". Do not add anything to it unless you are sure.
See the stores: Press Win + R, run certmgr.msc for your user certificates, or certlm.msc for the whole computer.
Why this is a big deal, and why it can fail:
| Risk | What happens |
|---|---|
| Stolen signing key | An attacker can sign malware that looks legitimate. The CA revokes the certificate once discovered |
| Weak or fraudulent CA | A bad certificate could be issued. Browsers and Windows remove untrustworthy CAs from their stores |
| Expired certificate | Old signatures without a timestamp stop validating |
| Vulnerable but signed driver | A legitimately signed driver with a bug can be abused. That is why Windows can block known vulnerable drivers by name (Section 1.2) |
Security tip: Do not install a root certificate that a random website or program tells you to install. A root you trust can vouch for anything, including fake sites and fake software.
Summary
| Term | Plain meaning |
|---|---|
| Code signing | A publisher's digital seal on a program |
| Authenticode | Microsoft's signing format for exe, dll, sys, msi, ps1 |
| Hash | Fingerprint: proves the file is unchanged |
| Signature | The hash locked with the publisher's private key |
| Certificate | Digital ID linking a public key to a publisher |
| CA / root | Trusted issuer / the top of the trust chain |
| Chain validation | Every link checked up to a trusted root, dates and revocation too |
| Timestamp | Proof the file was signed while the certificate was valid |
| Driver signing | 64-bit Windows refuses unsigned kernel drivers |
| SmartScreen | Uses signatures and reputation to warn about unknown downloads |
Get-AuthenticodeSignature | PowerShell command to read a file's signature status |
| Valid signature | Means "unchanged and from this publisher", not "safe" |