Sunteți pe pagina 1din 15

Concepts

Of
Cryptography

By: Md. Asif Siddique

Copyright © 1990-1998 Ample Associates, Inc. and its Affiliated Companies. All Rights Reserved.

Concepts Of Cryptography Page 1


Preface

Cryptography is the stuff of spy novels and action comics. Kids once saved up
bubble-gum wrappers and sent away for Captain Midnight’s Secret Decoder
Ring. Almost everyone has seen a television show or movie involving a
nondescript suit-clad gentleman with a briefcase handcuffed to his wrist. The
word “espionage” conjures images of James Bond, car chases, and flying bullets.
And here you are, sitting in your office, faced with the rather mundane task of
sending a sales report to a coworker in such a way that no one else can read it.
You just want to be sure that your colleague was the actual and only recipient of
the email and you want him or her to know that you were unmistakably the
sender. It’s not national security at stake, but if your company’s competitor got a
hold of it, it could cost you. How can you accomplish this?
You can use cryptography. You may find it lacks some of the drama of code
phrases whispered in dark alleys, but the result is the same: information revealed
only to those for whom it was intended.

Concepts Of Cryptography Page 2


Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . II

Chapter 1. The Basics of Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . 4


Encryption and decryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
What is cryptography? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Strong cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
How does cryptography work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Conventional cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Chapter 2. Symmetric Vs. Asymmetric Cryptography . . . . . . . . . . . . . . 7


Symmetric Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Asymmetric Cryptography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
RSA Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Diffie-Hellman Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Sample Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Concepts Of Cryptography Page 3


The Basics of Cryptography
When Julius Caesar sent messages to his generals, he didn’t trust his messengers.
So he replaced every A in his messages with a D, every B with an E, and so on
through the alphabet. Only someone who knew the “shift by 3” rule could
decipher his messages.
And so we begin.

Encryption and decryption


Data that can be read and understood without any special measures is called
plaintext or cleartext. The method of disguising plaintext in such a way as to hide
its substance is called encryption. Encrypting plaintext results in unreadable
gibberish called ciphertext. You use encryption to ensure that information is
hidden from anyone for whom it is not intended, even those who can see the
encrypted data. The process of reverting ciphertext to its original plaintext is
called decryption.

What is cryptography?
Cryptography is the science of using mathematics to encrypt and decrypt data.
Cryptography enables you to store sensitive information or transmit it across
insecure networks (like the Internet) so that it cannot be read by anyone except
the intended recipient.

While cryptography is the science of securing data, cryptanalysis is the science of


analyzing and breaking secure communication. Classical cryptanalysis involves an
interesting combination of analytical reasoning, application of mathematical
tools, pattern finding, patience, determination, and luck.
Cryptanalysts are also called attackers.
Cryptology embraces both cryptography and cryptanalysis.

Concepts Of Cryptography Page 4


Strong cryptography
“There are two kinds of cryptography in this world: cryptography that will stop our
kid sister from reading your files, and cryptography that will stop major
governments from reading your files. This book is about the latter.”
--Bruce Schneier, Applied Cryptography: Protocols, Algorithms, and Source Code
in C.

PGP is also about the latter sort of cryptography.

Cryptography can be strong or weak, as explained above. Cryptographic strength


is measured in the time and resources it would require to recover the plaintext.
The result of strong cryptography is ciphertext that is very difficult to decipher
without possession of the appropriate decoding tool. How difficult?
Given all of today’s computing power and available time—even a billion
computers doing a billion checks a second—it is not possible to decipher the
result of strong cryptography before the end of the universe.
One would think, then, that strong cryptography would hold up rather well
against even an extremely determined cryptanalyst. Who’s really to say? No one
has proven that the strongest encryption obtainable today will hold up under
tomorrow’s computing power. However, the strong cryptography employed by
PGP is the best available today. Vigilance and conservatism will protect you
better, however, than claims of impenetrability.

How does cryptography work?


A cryptographic algorithm, or cipher, is a mathematical function used in the
encryption and decryption process. A cryptographic algorithm works in
combination with a key—a word, number, or phrase—to encrypt the plaintext.
The same plaintext encrypts to different ciphertext with different keys. The
security of encrypted data is entirely dependent on two things: the strength of
the cryptographic algorithm and the secrecy of the key. A cryptographic
algorithm, plus all possible keys and all the protocols that make it work comprise
a cryptosystem. PGP is a cryptosystem.

Concepts Of Cryptography Page 5


Conventional cryptography
In conventional cryptography, also called secret-key or symmetric-key encryption,
one key is used both for encryption and decryption. The Data
Encryption Standard (DES) is an example of a conventional cryptosystem that is
widely employed by the Federal Government.

Concepts Of Cryptography Page 6


Symmetric Vs. Asymmetric Cryptography

Symmetric Cryptography
Initially people used cryptography with one key meaning the key used for
encryption is same as the key for decryption. It can be analogized with the door
key in real world because people use the same key for locking and unlocking the
door. The key in cryptography is mathematical function designed to convert a
plain text data to be cipher text data for encryption. With the same algorithm, the
ciphered data can be converted to be original text data.

To protect the access in using such algorithm for decrypting a ciphered data, it is
used a passphrase key controlling the operation of a cipher, so that the
authorized users having known the passphrase key can only perform decryption.
It means that although the type of cryptographic algorithm has been detected but
the passphrase key is still missing, so the ciphered data cannot be decrypted. This
key made along with the process of encryption has various key sizes depending on
the types of applied cryptography.
One of well known pioneer symmetric cryptographic algorithms is DES which is
based on 56-bit block size. It is considered weak at this time because it can be
broken by certain attacks such as brute force and cryptanalysis; therefore in 2002
it was superseded by AES using three block ciphers of 128-bit with key sizes of
128, 192 and 256-bit as a cryptography algorithm standard in the US. The other
symmetric algorithms which are frequently used are Twofish with 128-bit block
and up to 256-bit key size, Blowfish with 64-bit block and various key size
between 32 and 448 bits, Serpent with the block size of 128 bits providing 128,
192 or 256-bit key size, CAST5 with 64-bit block size supporting 40 to 128-bit key
size and Triple DES which is combination of three 56-bit DES. The algorithms
above can also be applied with a combination of two or three algorithms in order
to increase the security of cryptography such as AES-Twofish, Serpent-AES and
AES-Twofish-Serpent. These combinations have been implemented by certain
applications such as TrueCrypt. Nowadays the forms of using symmetric
cryptography is varied and more interesting with a nice Graphical User Interface
(GUI) such as Remora USB Disk Guard in figure 1 and PixelCryptor using a picture
as a bridge for encryption and decryption, so that it attracts people to use it for
their current needs on information security.

Concepts Of Cryptography Page 7


Figure 1

Remora USB Disk Guard protected by two types of passwords for logon and
encryption/ decryption is designed for mobile encryption on USB storage device.

These applications are easy to use and offer challenges such as PixelCryptor which
cannot be used to decrypt an encrypted package if the linked picture as the image
key is missing or modified. To decrypt the encrypted package on PixelCryptor, it is
required the image key as well as passphrase key as shown in figure 2. Besides
those above, there are still symmetric cryptography applications using ordinary
GUI such as Kruptos using 128/256-bit key size of Blowfish, and Blowfish
Advanced CS offering various types of algorithm.

Figure 2
PixelCryptor uses an image file as a link to encrypted package as well as
passphrase.

The other feature is encrypted volume which is used to store any files or folders
to be encrypted by putting it within the volume. Actually the volume is a file
Concepts Of Cryptography Page 8
which can be mounted as a virtual drive. The files and folders moved to the
volume become encrypted automatically, so that it gives an ease for the users to
modify the encrypted objects instantly as they want to. Once it is unmounted, all
files or folders within the volume will be encrypted and the virtual drive will
disappear, on the other hand if it is mounted, all files and folders within the
volume will be decrypted. This feature is delivered by TrueCrypt and LockDisk.

Asymmetric Cryptography
Since symmetric is considered as inflexible and insecure in sharing the encryption
key among the users, so the asymmetric cryptography is developed. Asymmetric
provides two different types of key, namely public key and private key. Public key
is designed to be shared to the other people for encrypting a plain text data to be
ciphered text data, whereas private key which must be kept securely by the
owner is used to decrypt ciphered text data to be plain text data.
This technique is considered secure because a user can distribute his public key to
anybody he wants without worrying to be intercepted by third party. Although
the encrypted data can be tapped by another people, they cannot decrypt it
without having the private key. Even the private key can be revoked if the owner
considers the key is stolen.
One of common usage of asymmetric cryptography is email. Since people need to
secure their email communication from interception by third party, the use of
asymmetric cryptography becomes frequent because it is more flexible and
secure in distributing public key to be shared to another people than symmetric
cryptography.
The asymmetric cryptography algorithm which is often used in encrypted email is
PGP (Pretty Good Privacy) providing privacy, authentication and integrity checking
over generating public and private key and digital signature. For email encryption,
the plug in Enigmail providing OpenPGP can be used along with mail clients such
as Mozilla Thunderbird and SeaMonkey as security extension.

Concepts Of Cryptography Page 9


Figure 3
OpenPGP Enigmail within Mozilla Thunderbird generates key pairs for public key
and private key with RSA algorithm and 4096-bit key size.
OpenPGP Enigmail offers key pairs generation as shown in figure 3 with 4096-bit
RSA algorithm which is used widely in e-commerce protocols because it is
accepted as one of means providing strong security. It also provides key expiry
from only 1 day to no expiry at all and revocation to terminate the private key in
the case of it is stolen or missing. Besides RSA, there are other algorithms such as
DSA (Digital Signature Algorithm) and El Gamal. DSA is used for digital signature,
while EL Gamal is asymmetric cryptography having three components namely key
generator, encryption and decryption algorithms.

Concepts Of Cryptography Page 10


Figure 4
The encrypted message created by OpenPGP Enigmail within Mozilla Thunderbird
uses RSA Algorithm with 4096-bit key size.

Through short experiment, it shows that encryption and decryption using


OpenPGP Enigmail within Mozilla Thunderbird is quite easy to carry out and
reliable for strong security. In this experiment, a sender sends his public key to a
recipient. After obtaining a public key, recipient sends an encrypted message
using sender’s public key. The encrypted email will be then decrypted by the
sender using his private key. If it is intercepted when it is in transit over network,
the interceptor will gain an encrypted message as shown in figure 4. He needs
sender’s private key to perform decryption of the message as well as passphrase
key. Both are required to perform such decryption.

Concepts Of Cryptography Page 11


RSA algorithm:

RSA Algorithm is based on the finding of the mathematician Leonhard Euler, that for any
number n = p * q where both p and q are prime, then:

m(p-1)(q-1) mod n = 1 (m and n must be relatively prime also)

In other word m(p-1)(q-1)+1 mod n = 1 * m

i.e. After a sequence of mathematical operation, we ended up with where we started, at m!!!

If we break that trip into two part. Find two number e and d, such than

e * d = [k(p-1)*(q-1)]+1 (where k is an integer)

so, me mod n = c

and, cd mod n = m

RSA Algorithm:
Step 1: Find two prime numbers (usually very big prime numbers), p and q

Step 2: Compute n = pq

Step 3: Compute Φ(n) = (p-1)(q-1)

Step 4: Generate e and d using Φ(n)

Step 5: using (e, n) to encrypt and (d, n) to decrypt

Concepts Of Cryptography Page 12


Diffie-Hellman Algorithm:
Unlike RSA, the Diffie-Hellman algorithm does not encrypt and decrypt text. Rather,
the strength of Diffie-Hellman is that it allows two users to share a secret key securely
over a public network. Once the key has been shared, both parties can use it to encrypt
and decrypt messages using symmetric cryptography

Diffie-Hellman Key Exchange

The 1st published public-key algorithm was invented by Whitfield Diffie and Martin
Hellman in 1976 and is generally referred to as Diffie-Hellman key exchange. The
purpose of the algorithm is to enable two users to exchange a key securely that can
then be used for subsequent encryption of messages. The algorithm itself is limited to
exchange of the keys.

The Diffie-Hellman algorithm depends for its effectiveness on the difficulty of


computing discrete logarithms. Briefly, we can define the discrete logarithm as
follows. First, we define a primitive root of a prime number p as one whose powers
generate all the integers from 1 to p-1. That is, if a is a primitive root of the pumber p,
then the numbers

a mod p, a2 mod p, .., ap-1 mod p are distinct and consist of the integers from 1 through
p-1 in some permutation. For any integer b and a primitive root a of prime number p,
we can find a unique exponent i such that

The exponent i is referred to as the discrete logarithm, or index of b for the base a,
mod p. This value is denoted as inda,p(b).

Because XA and XB are private, the opponent is forced to take a discrete logarithm to
determine the key. For example, attacking the secret key of user B, the opponent must
compute

The opponent then can calculate the key K in the same manner as user B calculates it.
For large primes, such an attack is considered infeasible.

Let’s consider example. Key exchange is based on the use of the prime number
q=353 and a primitive root of 353, in this case =3. A and B select secret keys XA=97
and XB=233, respectively.

Concepts Of Cryptography Page 13


Each computes its public key:

A computes YA=397 mod 353 = 40,

B computes YB=3233 mod 353 = 248.

After they exchange public keys, each can compute the common secret key:

A computes K=,

B computes K=.

We assume an attacker would have available the following information:

q=353, =3, YA= 40, YB= 248.

In this simple example, it would be possible by brute force attack to determine the
secret key 160. In particular, the attacker E can determine the common key by
discovering a solution to the equation or the equation . The brute-force attack is to
calculate powers of 3 modulo 353, stopping when result equals either 40 or 248. The
desired answer is reached with the exponent value of 97, which provides

With larger numbers, problem becomes impractical.

Concepts Of Cryptography Page 14


Sample Examples:

RSA file text: hello

Decrypted text file:



ü£u£Ê JÁG%ìt K^{^T‡y 5á â*ɶ‹S&ÆÅ…Ç¢n÷
U íaÃ#¢ š uJ aR @À—Hè !ÉÍ`™ ¶ƒ–^è$%çg àñsàλ"g ÚÂRZJdû( x’' 9 à »)) ³=#?WÎ

d²âñ¨òrîè¼¢DÒľþBrï”D Ì¢Ð-)Ъl Ø¢

Diffie-Hellman file text: hello

Decrypted text file is


(nœV^†Ã)= ÑÞ$~ë3(sô—6!ÿg˜ï᡹¢°FœÇŽ¥ƒ U†®9ªÂôÔÍpM7 ”¶0±& úŽocÐ
úà·ëÆ

Conclusion
Both cryptography algorithms of symmetric and asymmetric are frequently used
nowadays, even by criminals; therefore forensic investigators should know about
it and how to deal with it properly. Although it is almos impossible to break a high
level of key/block size of an encrypted message, there is still possibility to obtain
the encrypted message. For instance when the suspected computer found is still
running. It is not necessary to turn off directly because probably there is still an
encrypted message or volume which has been decrypted. Even the only access an
encrypted drive is when it is running. It means that it is being decrypted.

Concepts Of Cryptography Page 15

S-ar putea să vă placă și