Good cryptography is based on being reliant on the secrecy of the key and not the algorithm for security. This is an important point. A good algorithm is one which can be publicly scrutinized and proven to be secure. If a vendor says “trust us, we’ve had experts look at this”, chances are they weren’t experts!

Cryptography can be used to provide:

**Confidentiality –** ensure data is read only by authorized parties,

**Data integrity –** ensure data wasn’t altered between sender and recipient,

**Authentication –** ensure data originated from a particular party.

A cryptographic system (or a cipher system) is a method of hiding data so that only certain people can view it. Cryptography is the practice of creating and using cryptographic systems. Cryptanalysis is the science of analyzing and reverse engineering cryptographic systems. The original data is called plaintext. The protected data is called ciphertext. Encryption is a procedure to convert plaintext into ciphertext. Decryption is a procedure to convert ciphertext into plaintext. A cryptographic system typically consists of algorithms, keys, and key management facilities.

There are two basic types of cryptographic systems: symmetric (“private key”) and asymmetric (“public key”).

**1. Symmetric Cryptography**

Symmetric cryptography uses a single private key to both encrypt and decrypt data. Any party that has the key can use it to encrypt and decrypt data. They are also referred to as block ciphers.

Symmetric cryptography algorithms are typically fast and are suitable for processing large streams of data.

The disadvantage of symmetric cryptography is that it presumes two parties have agreed on a key and been able to exchange that key in a secure manner prior to communication. This is a significant challenge. Symmetric algorithms are usually mixed with public key algorithms to obtain a blend of security and speed.

**2. Asymmetric, or Public Key, Cryptography**

Public-key cryptography is also called asymmetric. It uses a secret key that must be kept from unauthorized users and a public key that can be made public to anyone. Both the public key and the private key are mathematically linked; data encrypted with the public key can be decrypted only by the private key, and data signed with the private key can only be verified with the public key.

The public key can be published to anyone. Both keys are unique to the communication session.

Public-key cryptographic algorithms use a fixed buffer size. Private-key cryptographic algorithms use a variable length buffer. Public-key algorithms cannot be used to chain data together into streams like private-key algorithms can. With private-key algorithms only a small block size can be processed, typically 8 or 16 bytes.

**3. Digital Signatures**

Public-key and private-key algorithms can also be used to form digital signatures. Digital signatures authenticate the identity of a sender (if you trust the sender’s public key) and protect the integrity of data. You may also hear the term MAC (Message Authentication Code).

**4. Hash Values**

Hash algorithms are one-way mathematical algorithms that take an arbitrary length input and produce a fixed length output string. A hash value is a unique and extremely compact numerical representation of a piece of data. MD5 produces 128 bits for instance. It is computationally improbable to find two distinct inputs that hash to the same value (or “collide”). Hash functions have some very useful applications. They allow a party to prove they know something without revealing what it is, and hence are seeing widespread use in password schemes. They can also be used in digital signatures and integrity protection.

There are several other types of cryptographic algorithms like elliptic curve and stream ciphers. For a complete and thorough tutorial on implementing cryptographic systems we suggest “Applied Cryptography” by Bruce Schneier.

**5. Implementing Cryptography**

**Cryptographic Toolkits and Libraries**

There are many cryptographic toolkits to choose from. The final choice may be dictated by your development platform or the algorithm you wish to use. We list a few for your consideration.

**JCE and JSSE –** Now an integral part of JDK 1.4, the “Java Cryptography Extensions” and the “Java Secure Socket Extensions” are a natural choice if you are developing in Java. According to Javasoft: “The Java Cryptography Extension (JCE) provides a framework and implementations for encryption, key generation, key agreement and message authentication code algorithms. Support for encryption includes symmetric, asymmetric, block, and stream ciphers. The software also supports secure streams and sealed objects.”

**Cryptix –** An open source clean-room implementation of the Java Cryptography extensions. Javasoft cannot provide its international customers with an implementation of the JCE because of US export restrictions. Cryptix JCE is being developed to address this problem. Cryptix JCE is a complete clean-room implementation of the official JCE 1.2 API as published by Sun. Cryptix also produce a PGP library for those developers needing to integrate Java applications with PGP systems.

**OpenSSL –** The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a full-strength general purpose cryptography library. OpenSSL is based on the excellent SSLeay library developed by Eric A. Young and Tim J. Hudson. The OpenSSL toolkit is licensed under an Apache-style license, which basically means that you are free to get and use it for commercial and non-commercial purposes subject to some simple license conditions.