# Generate Cryptokey By Unification Of Base 64 Computer Science Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

The use of the data exchange in e- way with the tremendous growth in e-commerce and m-commerce has created a high demand for information security. It becomes very important in data storage. However, widespread popularity of wireless data communication devices, combined with the availability of higher bandwidths, has led to an increased user demand for multi media content rich information and images. To make the cipher more robust against any attack, the secret key generated must have high randomness. It is very important in constructing cryptographic keys and its algorithm.

The Chaotic maps are best alternatives for generation of random secret keys, because the desirable properties of ergodicity and high sensitivity to initial conditions and other control parameters. Most chaotic maps are as equivalent as traditional pseudo random secret keys for multimedia content rich data encryption. In this paper, we have presented two different approach's, new permutation-substitution based random sequence generation from an image pixel and blended chaotic Blum Blum Shub shub.

A new approach is proposed to generate a random-bit sequence with a high degree of randomness. The proposed algorithm is better alternatives to satisfy the need for information security services. In this regard, we have developed an algorithm for the generation of random sequence of length 256 by shuffling and blending of image pixel based on Base 64 encoding and integrated chaotic Blum Blum Shub. The performance analysis of the proposed new approach is tested for randomness by carrying out various testing rules and statistical test. Results of the various types of analysis are encouraging and suggest that the proposedÂ methodÂ is veryÂ wellÂ ableÂ to efficientlyÂ the trade offs between theÂ speed and protectionÂ andÂ hence suitable for the real-time transmissionÂ ofÂ image and video communication applications.

## Key Words: Image cryptosystem, Random number generation, Base 64 encoding , blum blum shub ,chaotic maps

êµ ì •: ì´ˆë²ŒíŽ¸ì§‘

íŒŒ ì¼: ê¹€ìˆ˜ì˜(12-21)

I. Introduction

THE field of cryptography [1-3] is becomingÂ terriblyÂ significant in the present internet era in which information security is of utmost concern. Secure communication is anÂ important aspect of transmission and storage of images and encryption is one of the ways to ensure security.

Recent trends in wired and wireless communication has been to include multimedia content such as video, image, audio, music, text, etc. In particular image and multi media contents are preferred because of the very information-implicativeÂ attributes. They require a large communication channel capacity due to their data-intensive nature. Internet and mobile users exasperate potential security threats such as eaves dropping, illegal access and malicious attack. Therefore, it is essential that data be protected to ensure privacy. Web security and an image encryption have become very important and high profile issues. Most traditional crypto systems are well designed to protect textual data. An original information [1-3] and confidential plaintext converted into cipher text that is apparently random nonsense. The most traditional crypto system uses authentication, key distribution and encryption.

All this requires a sequential flow of operations and key [2][3]exchange or authentication performed by traditional encryption methods and also to reduce the redundant hardware in the system. TheÂ HashÂ function is used in modern crypto systems. It is best suited for communication devices, integrity verification and authentication of data and control packets. A stream cipher [4-7] based on Hash function is a best option to eliminate the redundant hardware of the crypto system. The important challenge in a hand held device like sensor networks, palmtop,Wi-fi ,WiMax enabled devices are its hardware complexity and power consumption. Generally, any crypto system can be made as stream ciphers or block ciphers. Both have specific applications. The block ciphers are made by simple substitution and transposition technique on a block of data bits, whereas in stream cipher time varying information on individual data bits. The security of the block cipher [4-7] method depends upon theÂ complication of the algorithm andÂ complicated structure for the encryption system. However, the circuit complexity is not a big issue, block ciphers can be designed to have better security per key bit than of stream ciphers. For ciphers of low hardware complexity, stream ciphers are preferred. In stream ciphers, the encryption operation synchronous and it is a simple xor operation. In addition to this, it allows real time operation of the data, which is essential in multimedia rich data communication.

In this paper, a novel image based random number generation scheme [8-10] is proposed. Based on certain transformation, all the pixels and frequencies in each sub block of the image are transformed to the random bit sequence. To implement this algorithm, first an image is shuffled before dividing themÂ to equal size of sub blocks. Second from the sub blocks one byte pixel values are selected as a seed. From the seed two random bits are selected and base 64 encoding transformation is performed to obtain a 32 bit sub key. The statistical test suiteÂ applied toÂ subÂ key.Â If it produces a valid randomness then 32 bit sequence is concatenated to produce a 256 bit sequence. Because of the proposed scheme based on simple transformation, it is easily implemented and highly efficient to encrypt and decrypt data and multi media messages. In order to increase randomness in the arbitrary bit sequence generated Base64 encoding technique is used to produce transformation like pseudo random gauss white noise.

The remaining of this paper is as follows. In Section 2 the algorithm of the unificationÂ ofÂ Base 64 and pixel shuffling method - IÂ discussed. In section 3 a new form of blendedÂ chaoticÂ BBSÂ discussed. The testing rules and various statistical analyses are discussed in section 4. Experimental results and conclusions are given in section 5 and section 6 respectively.

II. The Proposed Method -I

## 1Algorithm

The random bit sequence is generated as follows,

Step1: Read an image of size W x H.

Step2: Split the image to row (H) and column (W).

Step3: Shuffle the rows and column.

Step4: Divide the image to sub blocks.

Step5: Select a random byte from the sub blocks.

Step6: From the random byte, select a two bit randomly at a time and perform the following steps repeatedly until.

Step7: Take this 32 bit, Split them to two parts 3 byte and1 byte.

Step8: First take 3 byte,

Apply base64 encoding such that Then Iterate the above steps until

Then take 1 byte,

Then apply and iterate the above step until .

Step 9: Now perform

Step10: Finally concatenate the bit sequence of step 8 and step9.

Step11: After steps 10Â apply, statisticalÂ test suite, if it passes the test go to S10, otherwise reject.

Step13: Now concatenate 32 bits randomÂ sequenceÂ toÂ bits stream up to 256 bits.

M1

M2

M3

M4

M5

M6

M7

M8

32 bit x 8 =256 bit

FIG.2.The Concatenated Random sequence of the Proposed Method-I

## FIG.1.The Proposed Method-I

## III. METHOD - II

## 1.Blum-Blum-Shub chaotic pseudo random bit generator

The Blum-Blum-Shub pseudo random bit generator [1][11](also known as the x2 mod n generator or the BBS generator) is a CSPRBG under the assumption that integer factorization is intractable (x3.2). It forms the basis for the Blum-Goldwasser probabilistic public-key encryption scheme.

## 2.Algorithm for Blum-Blum-Shub pseudo random bit generator

Step1: Generate two large secret random (and distinct) primes p and q. For each congruent 3 modulo 4, and compute n = p q.

Step 2: Select a random integer s (the seed) in the interval [1; nâˆ’1] such that gcd (s; n) = 1, and compute

X0 S2 mod n.

Step 3: For i from 1 to l do the following:

3.1 Xi x2 iâˆ’1 mod n. (1)

3.2 Zi the least significant bit of Xi.

(2)

Step 4. The output sequence is Z1; Z2; : : : ; Zl.

The efficiency of the Blum-Blum-Shub

PRBG is generating each pseudo random bit Zi requires one modular squaring. The efficiency of the generator canbe improved by extracting the j least significant bits of Xi in step 3.2, where j = c log log n and c is a constant. Provided that n is sufficiently large, this modified generator is also cryptographically secure. For a modulus n of a fixed bit length (eg. 1024 bits), an explicit range of values of c for which the resulting generator is cryptographically secure under the intractability assumption of the integer factorization problem has not been determined.

## 3. Chaotic Map - Quadratic Map

The equation for the Quadratic map [12-14] is

(3)

For an analytic map point where f '(xc ) = 0 are called critical points. Quadratic map hasÂ theÂ crucial pointÂ Â atÂ Â Â Â xc = 0.So a fixed point is stable (attracting), super stable, repelling, indifferent (neutral) according to its multiplier satisfies |m| < 1, |m| = 0, |m| > 1 or |m| = 1.

The second fixed point is always repelling. For |x| > x2 iterations go to infinity. For |x| < x2 they go to the attracting fixed point x1. This interval is the basin of attraction of the point.

## 4.Algorithm for 1Blum-Blum-Shub chaotic pseudo random bit generator

Step 1: Generate two random blum blumÂ Â shubÂ prime number and calculate values of n.

Step 2: GenerateÂ a series fromÂ quadrature mapping by using equation (3).

Step 3: Apply quadrature mapping power ^2(mod(n)) and get subsequent values and get their parity as quadpar(i).

Step 4: Generate another series using the mod algorithm specified in blum blum shub algorithm (3.1&3.2).

Step 5: Get the parity of each element of x as xpar(i).

Step 6 : Do xor of "xpar" and "quadpar"

Step 7: Then that output of xor' with 1 and that is the final output.

Step 8: To determine the randomness test (run test) on this output for 100 times and if the p value was found to be <.01, it was considered to be aÂ non randomÂ number (fail test) else randomÂ number (pass test).

Step 9: The proposed technique 2Â passed the test98Â outÂ of 100 soÂ Â the confidence levelÂ 98%.

## X

## n

## Parity ( )

## 1

## Computed parity (sqrt(x^2))

## 0^2 mod n

## Q map (n,x^2 mod n)

## xor

## xor

## Combined BBS chaotic output

FIG.3.The Proposed Method-II

## IV. TESTING RULES

Various statistical tests [15-17] can be carried outÂ onÂ theÂ generatedÂ bitÂ sequence toÂ compareÂ and evaluate the sequence to beÂ truly random bit sequences. Randomness is a probabilistic property , it is characterized and described in terms of probability. The likely outcome of statistical tests, when applied to a truly random sequence, is known a priori and can be described in probabilistic terms. There are various statistical tests, each assessing the presence or absence of a "pattern" which, if detected, would indicate that the sequence is nonrandom.

After a key is generated, its randomness it tested by some of the important statistical tests. Now consider the key as a binary sequence and test for random-bit sequence or not.

A statistical test is formulated to test a specific null hypothesis (H0). For the purpose of this document, the null hypothesis under test is that the sequence being tested for random. Associated with this null hypothesis is the alternative hypothesis (Ha) which, for this document, is that the sequence is not random. For applied test a decision or conclusion is derived that accepts or rejects the null hypothesis, i.e., whether the generator is (or is not) producing random values, based on the sequence that was produced. For each test, a relevant randomness statistic must be chosen and used to determine the acceptance or rejection of the null hypothesis. Under an assumption of randomness, such a statistic has a distribution of possible values.

## TESTING RULE 1:

H0: The binary bit-sequence generated is not a random sequence.

HA: The binary bit-sequence generated is a random sequence.

## TESTING RULE 2:

Next important thing is to test the security level of the generated keys. We have to test the relationship between the security level of the generated key and its randomness level.

H0: No, relationship between randomness level and security level.

HA: Yes .There is a relationship between randomness level and security level.

## Methods for testing rules

To test all rules stated above, we have to calculate the randomness level of each key. This will be performed by testing the statistical tests [1][15].

## Randomness level

Let the binary sequence S = S0, S1, S2. . . Sn_1 of a length of a. The basic statistical tests are:

## 1 Frequency (Mono bit) Test

The objective of the test is the proportion of zeroes and ones for the entire sequence. The focus of this test is to determine whether the number of 0's and 1's are approximately the same. The test assesses the closeness of the fraction of ones to Â½, that is, the number of ones and zeroes in a sequence should be about the same. This test is accomplished as follows:

X1= (a0 - a1)2/a (4)

Where: a0; the number of 0's a1; the number of 1's; a: the sequence length (a = a0+ a1)

In fact, X1 is approximately follows a chi-square Ï‡2 reference distribution with 1 degree of freedom if a â‰¥10.

Compute the test statistic Sobs =â”‚Sn â”‚/âˆšn (5)

Sobs: The absolute value of the sum of the Xi (where, in the sequence divided by the square root of the length of the sequence.

Compute P-value = erfc (Sobs /âˆš2) (6)

Where erfc is the complementary error function.

If the computed P-value is < 0.01, then conclude that the sequence is non-random. Otherwise, conclude that the sequence is random.

## 4.1.2 Run test

This test runs up and down or the runs above and below the mean by comparing the actual values to expected values. The statistics for comparisonÂ the 'chi-square' testÂ is carried out.Â It is to find whether the number of zeros or ones of various lengths 'i' in the sequence S is as expected for a random sequenceÂ which is:

U i = (a-i+3)/2 i+2

(8)

where ;

Ci; the number of blocks of length i in S

Di; the number of gaps of length i in S

where and n is the largest integer i.

In fact,X2 approximately follows a chi-square Ï‡2 distribution with 2n - 2 degrees of freedom.

## 4.1.3 Autocorrelation test

Test the correlation between numbers and compare the sample correlation to the expected correlation of zero. The main focus of this test is to determine correlations between the sequence S and the shifted versions of it.

(9)

Where; k; any fixed integer, ,

; XOR operator.

(10)

In fact, X3 approximately follows an N (0, 1) distribution if n-k â‰¥ 10.

## 4.1.4 Serial test (Gap test)

Count the number of digits that appear between repetitions of a particular digit and then use the Kolmogorov-Smirnov test to compare with the expected number of gaps. The focus of this test is the frequency of all possible overlapping m-bit patterns across the entire sequence.

The focus of this test is to determine whether the number of occurrences of the 2m m-bit overlapping patterns is approximately the same as would be expected for a random sequence. This test is used to determine whether the number of occurrences of 00, 01, 10, and 11 are approximately the same by using:

(11)

where :

a00; the number of occurrences of 00

a01; the number of occurrences of 01

a10; the number of occurrences of 10

a11; the number of occurrences of 11

In fact, X4 approximately follows a chi-square Ï‡2 distribution with 2 degrees of freedom if a >= 21.

## 4.1.5 Poker test

It treats numbers grouped together as a poker hand. Then the hands obtained are compared to what is expected by using the 'chi-square' test. It determines whether the occurrences of each part of the length m are approximately the same.

(12)

where;

l; the length of each part (bits)

P; the number of non-overlapping parts of length l

Oi; the number of occurrences of the ith part

In practice, X5 is approximately follows a chi-square Ï‡2 distribution with 2l -1 degrees of freedom

## V. RESULTS

We have tested our proposed technique to see how arbitraryÂ [18-20] theirÂ output sequence. In figure 4 we see the average testÂ resultsÂ for 1000 test runs on each method withÂ Â a bit length of 256 bits.

By using a significance level of Î± =Â Â 0.05, then the threshold values for X1,X2, X3,X4, and X5 becomes 3.9, 9.349,1.89, 5.09 andÂ Â 14.507Â respectively. For each generated random bit-sequence value the X1, X2 , X3, X4, and X5 are calculated . Each computed value is individually compared with the threshold value, the results for methodÂ -1Â wereÂ 98.9,97.5,99.9,99.9 and 99.8 for method -Â 2 wereÂ 99.9,98.9 and 99.9,98.8 and 99.8.

The histogram of theÂ testÂ values of eachÂ statistical test follows the expected distribution.

Fig.4 Randomness test results of proposed methods

TheÂ Â Fig.8 & 9, shows that the correlation value of the horizontal, vertical and diagonal cipher image andÂ correlation between plain image and cipher image for the proposed method.

Fig.5 Original image and its histogram

Fig.6 Method 1 - Cipher image and its histogram

Fig.7. Method 2 - Cipher image and its histogram

Fig8.Correlation (Vertical, Horizontal and Diagonal) values of proposed method 1&2 cipher image

Fig.9.Over all Correlation of the cipher image for method 1 and method 2

Table 1 showsÂ theÂ calculatedÂ entropyÂ valuesÂ for both methods. For entropy of the cipher image [21], the value is approximately close to the theoretical value of 8. Hence, the message leakage in the encryption system is almost negligible and the proposed encryption technique is secure upon the entropy attack.

Table 1. The entropy values of the cipher image.

S.No

Image

Size

Entropy

Method -1

Method -2

1

Lena

512 x 512

7.9969

7.9993

## 6. CONCLUSION

For computer network security random numberÂ prime isÂ anÂ important task. It is very essential in constructing keys for cryptographic algorithm. In this paper, a new approach is proposed to generate a random-bit sequence from blended chaoticÂ blum blum shubÂ genearatorÂ and from the unified Base 64 based encoding based imageÂ pixel shufflingÂ andÂ mixing.Â

To validate the trueÂ randomness and degree of randomnessÂ ofÂ theÂ proposedÂ crypto system are investigated. The experimental result shows that bothÂ the proposed method can generate sequencesÂ trulyÂ randomÂ bits that can passÂ all requiredÂ statisticalÂ tests, it generates bitsÂ with aÂ high degree of randomness. The generated bit sequence is used for image encryption its histogram, correlation and entropyÂ found to be satisfied. In future, the proposed method is tested in real time and implemented in a FPGA.