| A Practical Look at Digital Signatures in Java |
|
|
|
| Programming - Java | |
| Written by Joe Cropper | |
| Wednesday, 26 March 2008 | |
|
Whether it's verifying the integrity of a message's source, a software license file, or a download, employing digital signatures is imperative.
So just what is a digital signature anyway?
A digital signature is the digital era's equivalent of yesterday's hand-written signature. That is, each time we sign that receipt after using our debit or credit card, we are effectively telling our financial institution that we agreed to pay a given price for a given item. In the event that an alleged fraudulent charge is made, authorities can perform signature comparisons to help determine the validity of the claim. Digital signatures work in a similar fashion for electronic messages. That is, they use a form of asymmetric algorithms whereby the message's sender applies a digital signing algorithm to the message using a private key (asymmetric algorithms use public- and private-key technology in which each user has a private key that is known only to the user and a public key that is publicly known). The output is referred to as the digital signature. When the message is received by its target recipient, the sender's authenticity is determined by using a signature verification algorithm coupled with the sender's public key. Through the employment of this scheme, digital signatures offer two very important benefits to their users:
It's because of these benefits that digital signatures are so widely used today, especially given the nature of activities for which society uses its computers (e.g., online shopping, online banking, etc.). Without the use of digital signatures, it would be trivial for an attacker to forge a message or alter the contents of a message, actions that are just not acceptable by today's standards. Why Are Digital Signatures Important?It shouldn't be difficult to see why employing digital signatures is imperative in today's world. For example, imagine that we send instructions to a financial institution to transfer a large sum of money into another account. We'd definitely hope there's some sort of digital signature accompanying that transfer request! Or imagine sending emails within our organization; in the absence of digitally signing our emails (which most email clients now support), it would be (relatively) easy for an attacker to forge emails on our behalf. ImplicationsWhile digital signatures play an integral role in today's digital security, there are some disguised drawbacks. For example, what happens if a party's private key is inadvertently compromised? In essence, that would allow an attacker to forge the party's signature. This also leads to problems in the area of repudiation. In this context, "repudiation" refers to the act of disclaiming responsibility for a message. That is, a signer states that he or she did not sign the message, but the recipient claims that the message was verified. If signers make such claims, they're repudiating their signature key. In a nutshell, it's of utmost importance that private keys are kept private. In the event of any suspected compromise of that key, the owner of the key should immediately inform potential recipients of the compromise and then generate a new pair of keys. Digital Signatures in JavaBecause Java is widely used for many enterprise-level applications, it should come as no surprise that it supports a wide spectrum of cryptographic capabilities, one of which just happens to be out-of-the-box JDK support for digital signatures. Java supports the notion of a SignedObject, which is an authentic runtime object whose integrity cannot be compromised without being detected. This special object contains a serializable object (i.e., the to-be-signed object) and its signature. The signed object is a deep copy, a "clone" of sorts of the original to-be-signed object. It must be a deep copy for integrity's sake; manipulation of the original object has no effect on the copy.
Related Java Classes There are a wide variety of objects with which we might work when performing digital signature-type operations in Java. The following paragraphs will make a brief attempt to summarize some of the commonly used objects (note that all objects mentioned exist within the java.security package) and explain how they might be used.
As you can see, there are many pieces involved when working with digital signatures in Java, ranging from key generation to digital signature verification. Each piece plays an instrumental role in the end-to-end process, so it's important to study each component.
Another item worth touching on is the notion of cryptographic providers. As we study many of the classes encompassed by the java.security package, we will encounter many instances in which their methods accept a provider parameter. This parameter refers to whose implementation of the various algorithms is used. For example, both Company A and Company B might provide implementations of the DSA algorithm; this allows us to choose whose implementation to select.
Example: Digitally Signing a License File A common instance in which a digital signature is used is in the area of software-license file generation and verification. Often, software vendors will use a (vendor-generated) license file of sorts to determine, at runtime, the features available to the customer. At the very least, the license verifier engine should be able to detect when the license file has been changed from its original state (e.g., a mischievous customer tries to alter the license file so that features they didn't pay for are available). The following steps outline the procedure to create a license file (it's assumed that the software features are stored in an instance of java.util.Properties, although any serializable object would suffice):
Note: Although it's less flexible, the PublicKey could also be hard-coded (e.g., as a hexadecimal sequence) into the application. And since it's (by definition) in the public domain, we're not concerned with anyone decompiling the application and looking for private information.
Now that we've seen how to generate and transmit a signed license file, let's take a look at how we can verify its integrity before using it.
Take Note As with any programming project, there are always traps to look for while coding. One such trap in Java is the signing engine's provider. As mentioned previously, most of the APIs that have been referenced will also accept a provider (e.g., SUN, IBM, etc.) argument, specifying which vendor's implementation of the signing engine to use. For example, a malicious implementation of the SignedObject::verify(...) method could always return true, tricking a program into thinking the signature was verified. As such, this is definitely something worth keeping your eyes open for (i.e., always use a trusted provider). Get DigitizedDigital signatures serve a wide array of purposes in today's world of computing. Whether it's verifying the integrity of a message's source, a software license file, or a download, employing digital signatures is imperative. They provide effective solutions to the previously mentioned common problems. A wide variety of programming language libraries provide digital-signature support, and as we've seen from the Java pseudo-examples, their use is relatively simple when compared with their added benefits. |
|
|
Last Updated ( Thursday, 20 March 2008 ) |
|



