Security

Digital signature

A digital signature is a cryptographic mechanism that uses a private key and its associated public key to prove who signed a document and that its content has not changed since.

In this post

A digital signature is a mathematical seal added to a document, a message or a program to prove who created it and that nobody has modified it since it was signed. It works with two-key cryptography. A private key, known only to the signer, and a public key, which anyone can use to check the signature. It is one of the foundations of trust on the internet, because it lets you know who each thing belongs to without the parties needing to know each other.

The closest image is the wax seal on old letters. Whoever stamped it used a unique ring that only they owned, and whoever received the letter could recognise the seal and check that it was still intact. If someone opened the letter, the seal broke. Something similar happens with a digital signature, but with mathematical certainty. The ring is the private key, and the seal is the signature that anyone can check with the public key.

A digital signature works like a wax seal that nobody can forge. It proves who a document belongs to and warns you if anyone has touched it after it was signed.

What is a digital signature?

A properly made digital signature guarantees three things to whoever receives it. Authenticity, because only the holder of the private key could have generated it. Integrity, because any change, even a single comma, makes the signature invalid. And non-repudiation, because the signer cannot later deny having signed. What it does not guarantee is that the content is true or good. It only says who signed it and that it has not changed since.

How a digital signature guarantees who signed and that nothing changed

For the signature to be useful, a certificate is needed. It is a document that links a public key to an identity, such as a person, a company or a domain. It is issued by a trusted authority, which first checks who the applicant is. The browser, the operating system and programs come with a list of authorities they trust. If the certificate comes from one of them, it is accepted. If not, a warning is displayed.

How a digital signature works inside

Inside, a digital signature is a mathematical calculation. First the fingerprint of the document is obtained, a fixed-length digest that changes completely if a single comma is modified. Then the signer encrypts that fingerprint with their private key. The result, attached to the document, is the signature. Anyone can check it with the signer’s public key, which is taken from their certificate. The check answers two questions. If the recalculated fingerprint matches the decrypted one, the document has not changed. And since only the holder of the private key could have produced that signature, you know who signed. The most widely used algorithms are RSA and elliptic curve algorithms, such as ECDSA and Ed25519, combined with hash functions such as SHA-256. If someone alters the document afterwards, the signature is invalidated immediately, which is why it is a much stronger guarantee than a scanned signature.

Signature algorithms, RSA, ECDSA and EdDSA

A digital signature is calculated with different public key algorithms depending on the use. RSA, published in 1977, is still the most widespread in certificates and PDF documents, with keys of 2048 bits or more. ECDSA uses elliptic curves and achieves the same security with much shorter keys, which is why it dominates in modern web certificates and in cryptocurrencies. EdDSA, in its Ed25519 variant, is faster and less prone to implementation errors, and it is used by SSH and many software package signing systems. Faced with the threat of quantum computers, NIST published the first post-quantum signature standards, ML-DSA and SLH-DSA, in 2024.

Differences from electronic and scanned signatures

The terms digital signature, electronic signature and scanned signature are often confused. An electronic signature is a broad legal concept that covers any electronic method of accepting a document, from ticking a box to using a certificate. A digital signature is a technical type of electronic signature based on cryptography, with guarantees of integrity and authorship. A scanned signature, an image of a handwritten signature pasted into a document, offers no technical guarantee and is easy to copy.

Difference between simple, advanced and qualified electronic signatures

In Europe, the eIDAS regulation talks about electronic signatures and distinguishes three levels. The simple signature, the advanced signature, uniquely linked to the signer and to the signed data, and the qualified signature, which relies on a certificate issued by an accredited provider and has the same legal value as a handwritten signature throughout the Union.

Signature formats and timestamping

A signature can be embedded in the document itself or kept in a separate file. PDFs use the PAdES format, XML data uses XAdES and any file can use CAdES, all defined by European standards. A timestamp can be added to the signature, issued by a trusted third party, which proves the exact moment it was signed. That way the signature remains verifiable even if the certificate expires years later, which is known as a long-term signature.

Where the digital signature is used

Code signing for programs and updates

Every time you install a program or an update, your device checks its signature. That is how it knows it comes from the vendor and that nobody has altered it along the way. If the signature is not valid, the system warns you or blocks the installation. It is one of the most important defences against harmful programs disguised as updates, which is why the most advanced attackers try to steal or forge trusted signatures.

The update systems of platforms such as WordPress, Drupal or Magento also use signatures or integrity checks to make sure that what is downloaded is what the developer published. But the protection only works if downloads come from official sources. An extension obtained from a dubious website does not go through that verification, and it is a good example of why a signature only protects when it is checked and when its origin is trustworthy.

Website certificates and email signing

The padlock shown by the browser is based on digital certificates. The website’s certificate proves that you are talking to the domain you think you are and allows the connection to be encrypted. In email, signatures make it possible to check that a message really comes from whoever it claims, and that it was not altered. Email authentication standards use signatures so that recipients can detect spoofing, a fundamental defence against phishing that impersonates a well-known company. For a website owner, keeping the certificate valid is essential. An expired certificate shows visitors a warning and damages trust, search rankings and sales. Most hosting providers renew it automatically, but it is worth checking. And it is a good idea to turn on expiry alerts, because a silly oversight can leave your website inaccessible to many users for hours or days.

Paperwork, invoices and contracts

Public administrations and many companies use digital signatures for official paperwork, invoices and contracts. They allow remote signing with full validity, saving travel and paper.

The certificate is stored in a protected device or in the browser, and it is activated with a password. Whoever uses it must protect it as they would protect their identity document, because whoever holds it can act on their behalf before the administration. Applying these measures properly is part of the job of an IT security expert with experience on real websites.

If the key is lost or stolen, the certificate is revoked. Revocation is published in lists and lookup services, known as CRL and OCSP, which programs check before accepting a signature. The sooner it is reported, the shorter the window in which someone could take advantage of it.

Certificates and signing tools in Spain

In Spain, most citizens sign with a certificate from the Royal Mint, known as FNMT, which is installed in the browser or on a card, or with the electronic national ID card, which carries its own chip with a certificate. The government’s AutoFirma application signs documents with those certificates on the computer, and the Cl@ve system allows signing in the cloud without storing the certificate on the device. A cloud signature keeps the key in a secure device belonging to the provider, which only uses it when the holder identifies themselves.

Electronically signed documents in your daily life

Most people use digital signatures without knowing it. Every time you open a website with a padlock, install an app from an official store or receive an update for your system, a signature is checked in the background. That is why it is important not to ignore browser warnings about invalid certificates. When an alert pops up, there is usually a reason, and carrying on without thinking can mean sending your data to an impostor.

If you use a digital signature for official paperwork, treat the certificate with the same care as your identity document. Do not keep it on shared computers. Protect it with a strong password. Make copies in a safe place. And have the procedure for revoking it at hand in case you lose it. Many frauds happen when someone installs their certificate on an infected computer, and the attacker uses it to sign transactions in their name.

In the world of development and websites, signing what you distribute adds trust. A developer who signs their programs or files lets users verify their origin. And a website that offers downloads can publish their fingerprints so they can be checked. These are professional practices that raise the security of the supply chain, something increasingly valued by customers and required by industry regulations.

A qualified signature enjoys a presumption of validity, which means that whoever disputes it must prove that it is not genuine. Simple and advanced signatures can also serve as evidence in court, but more evidence about how the document was signed has to be provided. The choice depends on the importance of the document. For a quote, a simple signature may be enough, and for a deed or a procedure with the administration, a qualified one is required.

Advantages over paper

Signing digitally saves travel, courier costs and paper, and a contract can be closed in minutes between people in different countries. It also leaves a technical record of who signed and when, which is harder to dispute than a signature on paper, and any later change to the document is detected immediately.

Limits of the digital signature

A digital signature does not guarantee that what was signed is fair or that the signer understood the content. Nor does it protect anyone whose private key is stolen, which must be guarded as seriously as the key to a safe. And it depends on the algorithms remaining secure, which is why signatures resistant to quantum computers are already being prepared, such as the ML-DSA standard that NIST published in 2024.

How to tell whether a signature can be trusted

To find out whether a signature can be trusted, pay attention to the program’s warnings. If your browser, your system or your email client warns that a certificate is invalid, has expired or does not match the name, take notice. In email, messages from serious companies usually pass the authenticity check, and spoofed ones do not. A warning is not definitive proof of a scam, but it is a reason to stop, check through another channel and not go any further until you are sure.

Also check who actually signs the document or the program. In program installation windows, the system shows the name of the verified publisher. If it says unknown, or the name does not match the vendor you expect, do not continue. Attackers also obtain legitimate certificates for fictitious companies, so a valid signature does not mean that the program is good, only that someone takes responsibility for it. Be equally wary of unofficial sources.

And if you run a website or an organisation, keep an eye on your own certificates. Expiry dates, modern algorithms, well-protected keys and a revocation procedure. The Flame case showed that the trust a signature provides can be broken by a technical or management detail that seemed minor. Discipline in small things sustains trust in big ones, and it is what allows millions of people to trust what they see every day.

A fake certificate used to sign a spy program

In May 2012 Flame was discovered, an unusually complex spying program that had been lurking for years on computers in the Middle East. One of its most surprising features was the way it spread. It posed as a legitimate Windows update, and the system accepted it because it carried a signature that appeared to come from Microsoft. Its authors had managed to produce a fake certificate that the system considered genuine.

Later analyses showed how the certificate had been forged. Because of a configuration error, Microsoft had issued certificates for a remote access licensing service that, without anyone foreseeing it, could be used to sign programs. Those certificates used an old, weak algorithm called MD5, which experts had been warning about for years. The attackers applied a new cryptographic technique, a hash collision, to create a fake certificate that looked legitimate and worked on every version of Windows.

The attackers then tampered with the communication between infected computers and the update server, so that they received the spying program instead of the real update. On 3 June 2012 Microsoft released an emergency fix that invalidated the affected certificates, and it changed the way it signs its updates. The researchers who reconstructed the technique concluded that it required world-class cryptographic expertise.

The case of that fake certificate left several lessons. Old algorithms eventually break and have to be retired in time. A small configuration error at a trusted authority can have enormous consequences. And a digital signature is only as strong as the weakest link in the chain that supports it. Since then, the industry has accelerated the abandonment of the MD5 algorithm and tightened oversight of how the certificates behind updates are issued and used.

History of the digital signature

The idea was born in 1976, when Whitfield Diffie and Martin Hellman published the paper that introduced public key cryptography and proposed using it to sign messages. A year later, Ron Rivest, Adi Shamir and Leonard Adleman created the RSA algorithm, the first that made signing possible in practice.

During the 1980s the digital signature was used mainly in technical environments, and in 1989 Lotus Notes was one of the first commercial programs to include it. Legal recognition arrived with the turn of the century. The European Union approved a directive on electronic signatures in 1999 and Spain transposed it with Law 59/2003. In 2014 the eIDAS regulation unified the rules across the Union, and its 2024 reform added the European digital identity wallet.

Frequently asked questions

Frequently asked questions about Digital signature

What is a digital signature?

It is a mathematical seal added to a document, message or program to prove who created it and that it has not been modified since it was signed. It is generated with a private key known only to the signer, and anyone can check it with the corresponding public key.

Is a digital signature the same as an electronic signature?

Not exactly. An electronic signature is a broad legal concept that includes any method of accepting a document, such as ticking a box or drawing your name. A digital signature is a specific cryptographic technique that gives technical guarantees of authorship and integrity. The most secure signatures combine both.

What does a digital signature guarantee?

Three things. Authenticity, because only whoever holds the private key could have signed. Integrity, because any later change invalidates the signature. And non-repudiation, because the signer cannot later deny having signed. It does not guarantee that the content is true, only who signed it and that it has not changed.

What is a digital certificate in a digital signature?

It is a document that links a public key to an identity, such as a person, a company or a website. It is issued by a trusted authority that verifies who the applicant is. It works like a digital identity card and lets you know who each signature belongs to.

How does a digital signature work?

The signer calculates a unique digest of the document and encrypts it with their private key. Whoever receives it decrypts that digest with the signer's public key and compares it with the one they calculate themselves. If they match, the document has not changed and the signature belongs to whoever claims it. Changing a single comma is enough to make the check fail.

Where is the digital signature used?

In tax returns, contracts, software updates, mobile apps, secure email, the padlocks of websites and dealings with public administration. Every time you install a legitimate update, your device checks a digital signature to make sure of its origin.

What happens to a digital signature if the private key is stolen?

It is very serious, because whoever has it can sign as if they were the holder. That is why keys are kept in protected devices, with a password. If it is lost or stolen, the certificate is revoked immediately so that it stops being accepted. The sooner it is reported, the smaller the damage.

How is a digital signature related to a website?

A website's padlock uses certificates signed by trusted authorities. Updates of content management systems and their official extensions are also distributed with integrity checks. In addition, payment gateways and many external services sign their messages so that your website can verify they are genuine.

I implement digital signatures in your online shop

I can help you integrate digital signature mechanisms into your website or online shop, especially for electronic invoicing and verifying payment messages.

About the author

Javier Afán

WordPress developer specialised in security, WooCommerce, and hacked website recovery.

I work on WordPress from a technical angle focused on security, architecture, and the decisions that really affect a project's continuity.