You are on page 1of 9

FEATURE: SECURITy

A Digital Signature
Architecture for
Web Apps
Harigopal K.B. Ponnapalli and Ashutosh Saxena, Infosys, India

This digital signature architecture provides browser-agnostic,


clientside signature components and generic server-side signature
validation components to help integrate signatures into Web
applications. The authors also discuss ways to extend HTML syntax to
support signatures.

I
n today’s competitive business world, in architecture that provides browser-agnostic, which enterprises
must extend their busi- client-side signature components and generic ness environments over the Web for
con- server-side signature validation components to sumers, employees, and partners, digital help integrate
signatures into Web applications.
security will play a pivotal role in building trust
and credibility. Secure sockets layer (SSL) over Digital signature technology can help address
HTTP (HTTPS) is the standard method used to nonrepudiation in addition to satisfying the
secure Web content. However, SSL addresses authentication and integrity requirements of
only a subset of security requirements. It can digital content. Here, we discuss a digital
establish a reliable private connection and signature
authenticate peer identities but doesn’t offer Signature Issues in Web Apps
nonrepudiation, which is an equally critical Using digital signatures and SSL in combination
security requirement for today’s business complements each technology’s innate capabilities. A
applications. Also, because SSL is a transport- digital signature, which requires a public key infrastructure
layer protocol, it only protects data while in (PKI), is a well-accepted, legally valid, electronic
transit between the client (browser) and Web equivalent of a handwritten signature in most parts of the
server. It doesn’t cover requirements vis-à-vis globe (see the “Digital Signatures” sidebar for more
end-to-end message-level protection. information). The process (outlined in the sidebar) is fairly

42 IT Pro
Digital Signatures
D
igital signatures can replace handwritten signatures
in workflow-based Web transactions, resulting in a trusted certification authority. The digital signature
completely automated, faster, and efficient and Web content are securely logged in persistent
workflows. Web applications across several industry storage. In the case of a nonrepudiation dispute at a
segments can benefit from digital signatures. later date, the digital signatures can be retrieved from
the secure storage and verified to prove which users
Use Cases participated in the transaction.
In the insurance sector, time-consuming, paperintensive
March/April
review, approval, and2013 Published by the IEEEServer-Side
archival processing of insurance Computer Society Digital Signatures
1520-9202/13/$31.00 © 2013 IEEE

documentation can be replaced with faster, low-cost, and An alternative to the client-side signature architecture is
digitally signed electronic documents. In the government to employ a server-side signature generation
sector, faster citizen service is possible with paperless e- mechanism,2 where the private signing keys of all users
governance, replacing handwritten signatures with digital are stored in a secure server-side store. When the
signatures. Furthermore, a more secure e-commerce signature is required, the user is authenticated by a
system can be built if consumers digitally sign the server through a mechanism other than a digital
purchase requests made on commerce portals. signature, such as a password, and the server-side
In e-banking systems, the use of digital signatures cryptomodule retrieves the user’s private key and
facilitate online loan applications, account openings, creates the signature on the server content on behalf of
approvals, and other financial transactions, mitigating the user.
paper dependence and helping banks stay productive, Although server-side signature generation has its
competitive, and compliant with regulatory merits, including ease of use and lower maintenance
requirements. and deployment costs, it increases the complexity of
In healthcare, digitally signed electronic documents the server-side infrastructure in terms of protection
enable paperless automated operations and business and performance needs. High protection is required to
processes in hospitals and medical centers. They also secure access to the server-side key store, which often
help such facilities comply with regulations, such as the becomes a target for attacks. Also, the legal validity
Health Insurance Portability and Accountability Act. must be analyzed in different geographies, because the
digital signature creation is delegated to the server by
Client-Side Digital Signatures the user. A detailed discussion of the server-side
In Web applications with an architecture based on a signature mechanism is beyond the scope of this
client-side digital signature, the process starts with the article.
user filling in a Web form and initiating the signature
process. The client signature component prompts the
user to select a private signing key from a secure private References
key storage. Then, the application creates a digital 1. Information Technology—Open Systems Interconnection
signature for the Web content and submits it to the Web — The Directory: Authentication Framework, International
server. A server component verifies the signature for its Telecommunication Union recommendation X.509, Aug.
authenticity and integrity, and validates the certificate 1 2005; www.itu.int/rec/T-REC-X.509.
to ensure it was issued by 2. “Digital Signatures and the Hidden Costs of PKI,” ARX,
Aug. 2010; www.arx.com/resources/white-papers/
digital-signatures-and-the-hidden-costs-of-pki.htm.

simple, but it becomes complicated when implemented in a Similarly, there are multiple private key storage
Web application for two main reasons. techniques (for hardware and software) and
First of all, the HTML specification doesn’t include formats—such as the Windows key store,7 Java
signature support.1 Using third-party signature tools2,3 to key stores (JKS),8 PKCS#11,9 and PKCS#1210—
sign Web content limits Web applications to certain and varied certificate-status verification
browsers and operating systems. mechanisms, such as the Certificate Revocation
Second, multiple signature-representation standards exist List (CRL)11 and Online Certificate Status
for different business contexts— such as the Public-Key Protocol (OCSP).12 It’s important to have
Cryptography Standard #7 (PKCS#7), 4 Cryptographic standardized interfaces to seamlessly consume
Message Syntax (CMS),5 and XML Digital Signature these underlying PKI services in Web
(XML DSig).6 However, there’s no single standardized applications.
interface that lets Web applications use these varied We propose addressing these issues by
signature format standards in a pluggable, flexible manner. amending the HTML specification to support the
creation of digital signatures for Web content.

computer.org/ITPro 43
FEATURE: SECURITy
and OCSP), and certificate-pathbuilding
algorithms, such as PKI X.509 (PKIX;
http://datatracker.ietf.
org/wg/pkix/charter).

A Java-Based Digital
Signature Architecture
In the absence of standards for browsers
to handle signatures in Web content,
Java is a good choice for developing a
browser-agnostic signature architecture,
because Java applet is the client
technology most commonly supported
by popular browsers. Furthermore, it
has

• feature-rich support for handling


signatures;
• built-in standardized API support for
dealing with multiple private key
stores in either the software or
hardware;
Figure 1. Digital signature architecture overview.

There’s one initiative to use XML digital signature syntax


to sign HTML content,13 but it’s still primitive and specific
to the XML signature standard. So, for now, our
architecture offers an interim solution.

Key Requirements
In defining our digital signature architecture, we
considered several key requirements. First, the
signature creation and verification functionality
had to be browser-agnostic so it works in all
popular browsers (Microsoft IE, Firefox,
Chrome, and so on). Second, we needed a
centralized, parameter-driven architecture that
could address varying business needs depending
on the underlying PKI services available. Third,
we needed the flexibility to digitally sign the
Signature Signature
Web form content in its entirety or selectively. Certificate
generator validator
We also needed extensible validator
(PKCS7, XML (PKCS7, XML for private
support
(CRL/OCSP )
key DSig)
store formats—such as the Windows key
DSig)
store, PKCS#11, PKCS#12, and JKS—both on
software and hardware (smartcards, USB tokens,
and so on). Finally, we needed configurable
support for multiple signature format standards
(such as PKCS#7 and XML DSig), certificate-
status verification mechanisms (such as CRLs

Configuration Certificate and Secure private Signature


repository CRL repository key storage storage and
(database, (database, (PKCS12, archival
files) directory, PKCS11, (database,
files) Windows) files)

44 IT Pro March/April 2013


Offline
Certificate and
signature
CRL update
verification
utilities
utilities

• built-in support for a standardized XML digital


signature API and commercial and open source
PKCS#7/CMS libraries (see www.bouncycastle. org);
and
• ready support for certification path validations using
OCSP and CRL.14

Although we discuss a Java-based architecture, it’s easy to


develop the server-side solution in other popular Web
technologies, such as .NET, which also provide rich
support for cryptographic functionality. Figure 1 depicts
the important building blocks of the architecture.
Using a factory design pattern is a good choice for a
flexible and dynamic invocation of signature functionality
from multiple options, such as signature syntax standards,
key store formats, and certificate validation. The factory
pattern allows dynamic instantiation of objects with
different behavior but with the same interface methods.
It’s important to carefully define the interface with
appropriate method signatures at a sufficiently abstracted
level. Specialized behaviors can be derived by
implementing these abstract interfaces. Similarly, the
parameters needed for these standards might vary widely,
so it’s appropriate to abstract the parameters into a separate
abstract class. Each standard that requires a specific

SignatureStandardFactory
SignatureStandard public SignatureStandard getInstance(String standardName)
public boolean verify()
public boolean verify (byte[]
dataSigned)
public X509 Certificate[]
getCertificates()
public X509CRL[]
GetCRLs()
XMLDSigParameters StandardParameters
public void setCertsAndCRLs(X509Certificate[]
,
public void sign(byte[] X509CRL[])
, dataToBeSigned, PrivateKey privKey)

PKCS7Parameters
PKCS7Standard XMLDSigStandard public void getOutputEncoding()
public PKCS7Standard(PKCS7Parameters) public XMLDSigStandard(XMLDSigParameters) public boolean isCertificateChainIncluded()
public boolean isAttachedSignature()
public void setOutputEncoding(String encodingFormat)
public void setCertificateChainIncluded(boolean includeChain)
public void setAttachedSignature(boolean attachedSignature)
public void setVerifyChain(boolean verifyCertChain)
Configurator public boolean getVerifyChain()
public void setCertVerficationMechanism(String mechanism)
public String getCertVerificationMechanism()

Aggregation
KeyStore Realization
Generalization
Interface
Windows KeyStore PKCS12KeyStore PKCS11KeyStore JavaKeyStore
Dependency

Figure 2. Digital signature architecture class diagram.


parameter set can provide its implementation of this
abstract class. The idea for the architecture is to reuse
existing standardized Java APIs wherever available and
define new ones wherever needed. Figure 2 provides a
definition of some important classes.
There’s a compelling need to define a centralized,
configuration-driven architecture that drives the behavior
of both client and server modules to meet varying business

computer.org/ITPro 45
FEATURE: SECURITy
needs. In the following, we discuss the corresponding Signature Generator
modules along with their functionality (excluding GUI This component creates the signature. Sun Java
components, in an effort to stay focused on key aspects has a signature factory that helps in instantiating
related to signatures). signature objects supporting specific algorithms,
such as RSA and XML digital signatures.
Configuration Repository However, Java doesn’t have a standardized
Digital signature requirements vary according to the interface for CMS/PKCS#7. To provide
business needs, available PKI services, local regulations pluggable and extensible support for these
and standards, organization security policies, and so on. multiple standards, a factory design pattern is
The configuration repository is a centralized store for all followed by our architecture (Figure 2).
configuration parameters and is the key component for a SignatureStandardFactory is a factory that helps
centralized, parameter-driven architecture. The repository in creating an instance of a SignatureStandard
can be a database, file system, or directory. object based on the signature standard that’s
The Configurator class depicted in Figure 2 reads all configured. SignatureStandard is a generic
configuration-related information and supplies it to the interface that captures the functionality of any
signature creation and verification components. In one digital signature standard (such as signature
possible implementation, the Configurator can be as simple creation or verification). Different standards, such
as a Java properties class that reads key value properties as PKCS7Standard (for PKCS#7) and
from a configuration repository. Table 1 provides a brief XMLDSigStandard (for XML DSig), implement
description of some important configuration parameters standard-specific functionality for the interface
considered, but it’s not an exhaustive list. methods. The behavior of SignatureStandard
objects can be customized by supplying
StandardParameters object (such as
PKCS7Parameters or XMLDSigParameters)
corresponding to the particular signature
standard. This gives applications the flexibility to
use different signature standards without code
changes.
Java Applet code on the client can use this signature
generator component to generate a

46 IT Pro March/April 2013


Table 1. Important configurable parameters.
Parameter Description

Key stores – Instruct client to select certificates from a configured key store
– Options include Windows, JKS, JCEKS, PKCS#12, or PKCS#11
Signature format – Standard format for signature representation
– Affects both client and server modules

– Options include PKCS#7 and XML DSig (this can be further populated when support for any other standard
formats is built)
Certificate chain – Instructs whether to include the entire certificate chain, the entire chain excluding the root, or only the user
certificate
– Helps save memory and network bandwidth in cases where the rest of the certificates are retrievable –
Affects both client and server modules
Content present – Affects both client and server behavior
– Instructs whether to include the data signed as part of signature content (for example, in PKCS#7,
content can be excluded in a scenario where content can be retrieved directly from the Web form
by the verification module)
– Saves memory and network bandwidth.
Signature algorithm – Affects both client and server behavior
– Indicates which signature algorithm (such as RSAwithSHA or DSAwithSHA) to use
Certificate validation – Affects server-side validation behavior
– Indicates the details of the certificate-status validation mechanism, like choosing CRL or OCSP and
their corresponding URLs (it’s also possible to have this check on the client side if such service is feasible)
Trusted CAs – Affects both client and server behavior
– Indicates the list of trusted and accepted certification authorities
Output encoding – Affects both client and server behavior
– Indicates the output encoding format for signature (for example, in case of PKCS#7, it can be either
Distinguished Encoding Rules15 or Base6416 encoding)
Signature holder – Affects both client and server behavior
– T he signature generated can be assigned by the client to this HTML form field, which is accessed to verify the
signature on the server
signature in the Web content. Other client-side The server-side module renders the Java applet tag with
technologies required to digitally sign Web content within configuration information read from the Configurator. The
browsers include JavaScript and Java applets. Java applet uses this information to generate a signature on
JavaScript is supported by all popular browsers and the content to be signed. The created signature can be
helps dynamically prepare the content to be signed. supplied to the server either directly by applet or by
Developers can write generic JavaScript functionality to assigning it to a predefined field (the signature holder
retrieve data to be signed from the form fields. This library specified in the configurable parameters in Table 1) within
interacts with the Java applet to invoke signature the HTML form. Client-side modules are written in Java
functionality and supply the content to be signed to the and JavaScript and can be used in a browser-agnostic
applet. manner in all Web applications, irrespective of the server-
Java applets are Java applications that run in side language.
the browser in a secure sandbox environment. An
applet-based solution offers Signature Validator
This component is part of SignatureStandardFactory and
• a browser- and platform-agnostic solution that helps verify the signature according to the configuration
runs in all popular Web browsers; read from the Configurator. The signature validator invokes
• easy maintenance, because the solution only certificate-status verification modules as per the
needs to be updated on the server side; configuration.
• rich built-in support for PKI in Java; and
• access to local system resources (such as Certificate Validator
This component helps validate the certificate chain in
private key files), which isn’t otherwise
possible through JavaScript. terms of correctness and trust. There are varied certificate-
status verification mechanisms, including CRLs and

computer.org/ITPro 47
FEATURE: SECURITy
OCSP. Similarly, there are multiple certificate-chain- validation. Certificates and CRLs can be stored in
building algorithms, such as PKIX. Depending on the multiple storage places, including file systems
available PKI services and configuration, the certificate and directories. This component abstracts the
validator component uses an appropriate certificatechain- underlying storage details and provides a
building algorithm and certificate-status verification consistent interface to access and manage
mechanisms to validate the target certificate. certificates and CRLs.
Typically, there are multiple trusted certification
authorities in a given business context, so it’s critical to Secure Private Key Storage
maintain a central repository of all related certificates and The security of the entire system depends on the
CRLs. These certificates are stored either in a database, security of underlying private keys. The private
local file system, or directory. The certificate validator keys can be stored as files either in local software
component retrieves certificates from the underlying file system or on hardware, such as smartcards
repository and validates their status. for higher security. There are multiple key
storage formats, such as PKCS#11 (hardware
Signature Storage and Archival crypto interface), PKCS#12, and JKS. This
This component addresses nonrepudiation. The signature component abstracts the details of underlying
and transaction data must be stored and archived securely private key storage and format. It provides a
for smooth retrieval in case of disputes. Signatures will be consistent interface to access and manage private
stored with transaction data or in isolated central storage keys securely for signing.
with cross references to transaction data.
Typically, digital signatures are stored for a longer Security Assurance
duration as a proof of nonrepudiation, so a secure archival When implementing this digital signature
mechanism separate from the active signature storage framework, developers should follow
space offers optimal performance. This component is also application- security best practices prescribed for
responsible for periodically archiving certificates and JavaScript, Java applets, and general Web
CRLs critical for supporting nonrepudiation. applications (see www.owasp.org and
https://buildsecurityin. us-
Offline Signature Verification Utilities cert.gov/bsi/home.html). Insecure software
These are the tools used in case of an audit or implementation practices can increase the attack
nonrepudiation trial. They retrieve the signature from surface and expose the applications to potentially
active or archival storage, validate signatures, and prove dangerous vulnerabilities, such as cross-site
the signature status by referring to the signed date and scripting or malware introduction, and undermine
time. To address a scenario in which the certificate status the system’s usefulness. A detailed discussion on
is invalid at the time of the audit but valid when the application security threats in Web applications is
signature was created, it’s important to include a time out of scope for this article.
stamp as part of the signed content. Digital Signature Extensions to HTML
Certificate and CRL Update Utilities If the HTML specification is amended to define
The list of trusted certification authorities can ways in which browsers support digitally signed
also change depending on business needs. This Web content, it will become easy to build Web
requires the administrator to update the certificate applications with digital signature support in a
and CRL repository accordingly. Certificates will browser- and system-agnostic manner.
have a limited shelf life and will need to be Considering HTML’s wide applications and the
updated occasionally; however, CRLs will be complexities of such a huge specification,
issued at regular intervals. The administrator amending it won’t be trivial. However, we have
must download the latest CRLs and certificates some ideas.
from the trusted sites and update the repository. First of all, the revised specification should
Automated scripts and tools that download CRLs define a new attribute “sign” to be supported by
using preconfiguration criteria and update local all significant HTML elements (for example,
certificate store are productive. form fields such as form, text, text area, lists,
and hidden fields) that indicate whether the field
Certificate & CRL Repository This should be part of the signed content. Introducing
component is mainly responsible for organized this optional attribute would let developers
storage of certificates and CRLs, which are select which content to sign. For example,
required for successful certificate status

48 IT Pro March/April 2013


<input type="text" name="OrderNumber" trigger digital signature creation by browsers. By
value="" sign> standardizing this feature for HTML, browser vendors can
<textarea name="Comments" rows="10" provide their proprietary implementations supporting
cols="10"> digital signatures and developers can develop applications
as per single standardized HTML syntax in a browser-
Here, the data in the “OrderNumber” text field agnostic manner.
would be digitally signed but not the data In the absence of established standards to digitally sign
entered in the “Comments” text area. Web content, we’ve discussed a browser-agnostic
Second, the specification should extend architecture for building digital signature support into Web
“sign” attribute support for forms with file applications in a productive, flexible, and extensible
uploads, so that the file content can be digitally manner.
signed.
Third, the specification should define a set of Acknowledgment
new attributes for the “Form” field that define We thank Sudarshana Dhar for her editing support. Views presented
how the signatures should be handled for form here are authors’ personal opinions and in no way represent the
content. For example, opinion of Infosys.

<form name="OrderForm" action- References


"actionURL" method="post" 1. HTML 4.01 Specification, World Wide Web Consortium (W3C)
signattrbs="format=pkcs7, specification, Dec. 1999; www.w3.org/ TR/html401.
encoding=base64,showTBSData=true, 2. Capicom Reference, Microsoft, 2012; http://msdn.
promptForCertificate=true,trustedCAs= microsoft.com/en-us/library/aa375732(VS.85). aspx.
'issuer dns of trusted certificates', 3. S. Mazumdar, “XML Digital Signature Tool,” Mozilla Add-Ons,
signatureAlgo=RSAwithSHA1, 2012; https://addons.mozilla.org/en-Us/ thunderbird/addon/xml-
includeCertChain=true"> digital-signature-tool.
4. B. Kaliski, PKCS#7: Cryptographic Message Syntax, Version
In this example, signattrbs defines the browser’s 1.5, RFC 2315, March 1998; ftp://ftp.rsasecurity.
signature component behavior: com/pub/pkcs/ascii/pkcs-7.asc.
5. R. Housley, Cryptographic Message Syntax (CMS), RFC 3852,
• format specifies the signature standard (PKCS#7); July 2004; https://tools.ietf.org/html/rfc3852.
• encoding reveals the digital signature’s encoding format 6. M. Bartle et al., XML Signature Syntax and Processing (Second
(for example, Distinguished Encoding Rules 15 or Edition), World Wide Web Consortium (W3C) recommendation,
Base6416 encoding); June 2008; www.w3.org/TR/ xmldsig-core.
• showTBSData, if true, displays the content being signed 7. “Cryptography Objects,” Microsoft, 26 Oct. 2012;
so the user is aware of what’s being signed; http://msdn.microsoft.com/en-us/library/windows/
• promptForCertificate, if true, tells the browser to prompt desktop/aa380254(v=vs.85).aspx#certificate_store_ objects.
the user to select the certificate to be used for signing 8. “Java Cryptography Architecture—API Specification &
among those available for that browser; Reference,” Oracle, 25 July 2004; http://
• trustedCAs provides Issuer Distinguished Name docs.oracle.com/javase/1.5.0/docs/guide/security/
attributes of the trusted certificate authority (CA) CryptoSpec.html.
9. PKCS#11: Cryptographic Token Interface Standard, RSA, 2004;
certificates—the user can select certificates only from
ftp://ftp.rsa.com/pub/pkcs/pkcs-11/v2-20/ pkcs-11v2-20.pdf.
this list of CAs; and
10. PKCS#12: Personal Information Exchange Syntax Standard,
• includeCertChain tells the browser to include or exclude
RSA, 1999; ftp://ftp.rsasecurity.com/pub/pkcs/ pkcs-12/pkcs-
the certificate chain.
12v1.doc.
11. “Internet X.509 Public Key Infrastructure Certificate and
The specification can also standardize support for
Certificate Revocation List (CRL) Profile,” tech. memo, The
browsers’ software and hardware-based key store types.
Internet Society, 2002; www.ietf.org/rfc/ rfc3280.txt.
12. “The Online Certificate Status Protocol (OCSP),” The

D
Internet Society, 1999; www.ietf.org/rfc/rfc2560.txt.
igital signatures can help build more secure and 13. “HTML Signing Profile,” World Wide Web Consortium
efficient Web applications across business (W3C), Feb. 2008; www.w3.org/2007/11/h6n.
segments. Wider adop- 14. “Java PKI API Programmer’s Guide,” Oracle, 1993;
tion of digital signatures would be possible if the HTML http://download.oracle.com/javase/6/docs/technotes/
standard specification were extended to provide integral guides/security/certpath/CertPathProgGuide.html.
support to digital signatures while defining tags that can

computer.org/ITPro 49
FEATURE: SECURITy
15. Data Networks and Open System Communications, Int’l India. He is coauthor of Distributed Systems
Telecommunication Union recommendation, 2002; Security: Issues, Processes and Solutions (Wiley,
www.itu.int/ITU-T/studygroups/com17/ 2009). Contact him at
languages/X.690-0207.pdf. harigopal_ponnapalli@infosys.com.
16. “The Base16, Base32, and Base64 Data Encodings,”
tech. memo, The Internet Society, 2006; http://tools. Ashutosh Saxena is a principal research scientist at
ietf.org/html/rfc4648. Infosys, India. His research interests include
authentication technologies and key management.
Harigopal Ponnapalli is a principal research Saxena received his PhD in computer science from
analyst at Infosys, India. His research interests Devi Ahilya University, Indore, India. He is the
include strong authentication, PKI, security author of PKI—Concepts Design and Deployment
assurance, and software piracy. Ponnapalli received (Tata McGraw-Hill, 2004). He’s a senior member of
his M.Tech in automation and computer vision from IEEE. Contact him at
the Indian Institute of Technology, Kharagpur, ashutosh_saxena01@infosys.com.

Internet Society, 1999; www.ietf.org/rfc/rfc2560.txt.

50 IT Pro March/April 2013

You might also like