What Is XML Crypto? Comparing the Main Standards and Options

XML crypto is not a coin, a token, or a blockchain project. The term covers the W3C and OASIS standards that encrypt and digitally sign XML documents — chiefly XML Encryption and XML Signature (usually called XMLDSig) — along with derivatives such as XAdES for legally binding European signatures. Because XML still carries SAML single sign-on assertions, SOAP web service messages, e-invoices and government filings, these standards run quietly inside infrastructure most people touch every day.

The standards solve different problems, and the choices inside them — symmetric versus asymmetric keys, key transport versus key agreement, enveloped versus detached signatures — change both the security properties and the interoperability of a deployment. Comparing the main options side by side makes it easier to see which one a given integration actually needs.

What is XML crypto and which standards deliver it

Two specifications form the core. XML Encryption Syntax and Processing became a W3C recommendation in 2002 and was revised as version 1.1 in 2013; it defines how to replace any part of a document with an EncryptedData element. XML Signature Syntax and Processing, issued jointly by the W3C and IETF in the same period with its own 1.1 revision in 2013, defines how to attach verifiable digests to specific parts of a document. Both operate at the element level, which is their defining feature: a document can carry one encrypted subtree while the rest stays readable, or sign one section while leaving another free to change under controlled rules.

On top of the core sit profiles and extensions. WS-Security wraps encryption and signature elements into SOAP headers, SAML relies on XMLDSig to protect login assertions, and ETSI’s XAdES adds the signed attributes European law expects from a qualified electronic signature. Part of the confusion around the topic is naming, because searches for what is xml crypto frequently surface unrelated token pages and forum threads; checking whether a term names a protocol, a standard, or a traded asset is worth doing before any money moves.

XML Encryption and XML Signature do different jobs

Encryption handles confidentiality. The usual pattern encrypts the payload with a symmetric cipher such as AES, then places the AES key itself inside an EncryptedKey element, delivered either by key transport — encrypting it to the recipient’s RSA public key, with RSA-OAEP as the modern mode after RSA 1.5 was deprecated — or by key agreement schemes such as ephemeral Diffie-Hellman and ECDH, which version 1.1 added. The scope is flexible: an entire document, a single element, or just the content inside an element, leaving the element’s tags visible.

Signatures handle authenticity and integrity, and they hide nothing. An XMLDSig signature computes digests of the parts it references, signs them with RSA, ECDSA or HMAC, and stores the result alongside the document. Encryption without signing leaves a real gap: anyone can encrypt a message to your public key, so confidentiality alone proves nothing about the sender. Deployments that need both either combine the two standards or lean on transport security such as TLS and use signatures for the end-to-end guarantees that TLS cannot carry across intermediaries.

Canonicalization is where XML signatures get difficult

XML allows the same logical document to be written many ways: attributes in any order, different namespace declarations, entity references instead of literal characters, whitespace inside tags. A signature over raw bytes would break with every harmless rewrite, so XMLDSig canonicalizes a document into one fixed form before hashing. The W3C’s C14N and exclusive canonicalization algorithms do this, and they are consistently the most failure-prone part of implementations.

The three signature forms add another decision. An enveloped signature lives inside the document it protects; an enveloping signature wraps the signed data inside the signature object itself; a detached signature references a resource stored elsewhere, which suits large files. Each form changes how references and transformations must be validated.

The security history here is well documented. XML signature wrapping attacks, demonstrated against SAML implementations, exploit reference validation flaws: an attacker moves the legitimately signed element and inserts a forged one, so the signature still verifies against the original while the application processes the attacker’s element. The defenses are mechanical rather than exotic — validate the document against its schema, reject duplicate identifiers, and confirm that the element whose signature was verified is the exact element the application then consumes. Older settings should also be retired: SHA-1 digests and RSA 1.5 key transport are deprecated in favor of SHA-256 and, in XMLDSig 1.1, RSA-PSS and ECDSA.

How XML crypto compares with JSON-based alternatives

Modern APIs mostly speak JSON, and the JOSE family — JWS for signatures, JWE for encryption — is the direct counterpart. The comparison turns on granularity versus simplicity. XML crypto can encrypt one subtree and sign another within a single document, and it carries mature legal recognition through XAdES. JOSE signs or encrypts a whole payload, offers a compact token format that flows easily through HTTP headers, and avoids canonicalization entirely, which removes a whole class of verification bugs; partial protection in JSON requires nested structures rather than a built-in mechanism. The table below condenses the tradeoffs.

Option Primary job Typical setting Main operational difficulty
XML Encryption Hides a whole document or chosen subtrees SOAP messages, stored XML files Key transport and cipher choices
XMLDSig Proves origin and integrity of signed parts SAML assertions, WS-Security headers Canonicalization and reference validation
XAdES Adds legal-grade signature attributes EU e-invoicing, government filings Certificate and timestamp management
JOSE (JWS/JWE) Signs or encrypts whole JSON payloads OAuth and OpenID Connect tokens No native partial encryption

XAdES deserves a separate note because it extends XMLDSig rather than replacing it. ETSI’s specification adds signed properties such as signing time, signer role and commitment, and it expects trusted timestamps so a signature stays verifiable after the signing certificate expires. That machinery is what European eIDAS qualified signatures and many national e-invoicing formats are built on. ETSI has since defined a JSON sibling called JAdES, but XML-based XAdES remains the format with the deepest tooling and deployment across European e-government.

Choosing between the options in practice

The choice is usually made for you by the endpoint you must talk to. A SAML service provider or SOAP service requires XMLDSig, and the sensible move is a maintained implementation — Apache Santuario for Java, the System.Security.Cryptography.Xml classes in .NET, the xmlsec1 command-line tool, SignXML in Python, or the xml-crypto package in Node — rather than hand-built canonicalization, which is where wrapping vulnerabilities come from. New API work without legacy constraints gets comparable security from JOSE with far less code. Where European law requires an advanced or qualified signature, XAdES is the option to evaluate, with JAdES considered where counterparties accept it.

Whatever the choice, two settings matter more than the rest. Pin modern algorithms in policy so SHA-1 and RSA 1.5 cannot be negotiated back in by a misconfigured peer, and structure the code to verify first, then use only the exact node it verified — the single rule that closes most documented XML signature attacks.