Rabu, 22 Mei 2013

Generating Random Algorithm Number

In this section we consider the problem of generating a sequence of random numbers  on a computer. Specifically, we desire an infinite sequence of statistically independent random numbers uniformly distributed between zero and one. In practice, because the sequence is generated algorithmically using finite-precision arithmetic, it is neither infinite nor truly random. Instead, we say that an algorithm is ``good enough'' if the sequence it generates satisfies almost any statistical test of randomness. Such a sequence is said to be pseudorandom .
The most common algorithms for generating pseudorandom numbers are based on the linear congruential   random number generator invented by Lehmer. Given a positive integer m called the modulus  and an initial seed  value tex2html_wrap_inline69291 ( tex2html_wrap_inline69293), Lehmer's algorithm computes a sequence of integers between 0 and m-1. The elements of the sequence are given by
  equation33942
where a and c are carefully chosen integers such that tex2html_wrap_inline69301 and tex2html_wrap_inline69303.
For example, the parameters a=13, c=1, m=16 and tex2html_wrap_inline69311 produce the sequence
displaymath69279
The first m elements of this sequence are distinct and appear to have been drawn at random from the set tex2html_wrap_inline69315. However since tex2html_wrap_inline69317 the sequence is cyclic with period  m.
Notice that the elements of the sequence alternate between odd and even integers. This follows directly from Equation gif and the fact that m=16 is a multiple of 2. Similar patterns arise when we consider the elements as binary numbers:
displaymath69280
The least significant two bits are cyclic with period four and the least significant three bits are cycle with period eight! (These patterns arise because m=16 is also a multiple of 4 and 8). The existence of such patterns make the sequence less random. This suggests that the best choice for the modulus m is a prime number.
Not all parameter values result in a period of m. For example, changing the multiplier a to 11 produces the sequence
displaymath69281
the period of which is only m/2. In general because each subsequent element of the sequence is determined solely from its predecessor and because there are m possible values, the longest possible period is m. Such a generator is called a full period generator.
In practice the increment  c is often set to zero. In this case, Equation gif becomes
  equation33954
This is called a multiplicative linear congruential   random number generator. (For tex2html_wrap_inline69341 it is called a mixed linear congruential   generator).
In order to prevent the sequence generated by Equation gif from collapsing to zero, the modulus m must be prime and tex2html_wrap_inline69291 cannot be zero. For example, the parameters a=6, m=13 and tex2html_wrap_inline69351 produce the sequence
displaymath69282
Notice that the first 12 elements of the sequence are distinct. Since a multiplicative congruential generator can never produce a zero, the maximum possible period is m-1. Therefore, this is a full period generator.
As the final step of the process, the elements of the sequence are normalized  by division by the modulus:
displaymath69283
In so doing, we obtain a sequence of random numbers that fall between zero and one. Specifically, a mixed congruential generator ( tex2html_wrap_inline69341) produces numbers in the interval [0,1), whereas a multiplicative congruential generator (c=0) produces numbers in the interval (0,1).

Selasa, 07 Mei 2013

Encryption with DES

As mentioned earlier there are two main types of cryptography in use today - symmetric or secret key cryptography and asymmetric or public key cryptography. Symmetric key cryptography is the oldest type whereas asymmetric cryptography is only being used publicly since the late 1970’s1. Asymmetric cryptography was a major milestone in the search for a perfect encryption scheme. Secret key cryptography goes back to at least Egyptian times and is of concern here. It involves the use of only one key which is used for both encryption and decryption (hence the use of the term symmetric). Figure 2.1 depicts this idea. It is necessary for security purposes that the secret key never be revealed 

Figu 2.1



To accomplish encryption, most secret key algorithms use two main techniques known as substitution and permutation. Substitution is simply a mapping of one value to another whereas permutation is a reordering of the bit positions for each of the inputs. These techniques are used a number of times in iterations called rounds. Generally, the more rounds there are, the more secure the algorithm. A non-linearity is also introduced into the encryption so that decryption will be computationally infeasible2 without the secret key. This is achieved with the use of S-boxes which are basically non-linear substitution tables where either the output is smaller than the input or vice versa.

The DES algorithm


The main parts of the algorithm are as follows:
  • Fractioning of the text into 64-bit (8 octet) blocks;
  • Initial permutation of blocks;
  • Breakdown of the blocks into two parts: left and right, named L and R;
  • Permutation and substitution steps repeated 16 times (called rounds);
  • Re-joining of the left and right parts then inverse initial permutation.
DES algorithm

Permutation

In mathematical and computer science field of cryptography, a group of three numbers (x,y,z) is said to be a claw of two permutations f0 and f1 if f0(x) = f1(y) = z 
A pair of permutations f0 and f1 are said to be claw-free if there is no efficient algorithm for computing a claw.

The terminology claw free was introduced by Goldwasser, Micali, and Rivest in their 1984 paper, "A Paradoxical Solution to the Signature Problem", where they showed that the existence of claw-free pairs of trapdoor permutations implies the existence of digital signature schemes secure against adaptive chosen-message attack. This construction was later superseded by the construction of digital signatures from any one-way trapdoor permutation. The existence of trapdoor permutations does not by itself imply claw-free permutations exist; however, it has been shown that claw-free permutations do exist if factoring is hard.


The general notion of claw-free permutation (not necessarily trapdoor) was further studied by Ivan Damgard in his PhD thesis The Application of Claw Free Functions in Cryptography (Aarhus University, 1988), where he showed how to construct Collision Resistant Hash Functions from claw-free permutations. The notion of clawfreeness is closely related to that of collision resistance in hash functions. The distinction is that claw-free permutations are pairs of functions in which it is hard to create a collision between them, while a collision-resistant hash function is a single function in which it's hard to find a collision, i.e. a function H is collision resistant if it's hard to find a pair of distinct values x,y such that



H(x) = H(y).



In the hash function literature, this is commonly termed a hash collision. A hash function where collisions are difficult to find is said to have collision resistance.

Initial permutation


Firstly, each bit of a block is subject to initial permutation, which can be represented by the following initial permutation (IP) table:

IP
58 50 42 34 26 18 10 2
60 52 44 36 28 20 12 4
62 54 46 38 30 22 14 6
64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1
59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5
63 55 47 39 31 23 15 7

This permutation table shows, when reading the table from left to right then from top to bottom, that the 58th bit of the 64-bit block is in first position, the 50th in second position and so forth.