NK Cryptography Dr. Nidhal K. El Abbadi* Ali D. Katheeth* alidg@kuiraq.com nidhalka@it.kuiraq.com Abdul Hussien .A. Mohammed Ali* Iman H. Raheem** a1_hussein@yahoo.com Abstract One of the effective technologies that used to deal with security issues is the cryptography that can be used to insure confidentiality, integrity, and availability for data when they are stored, transmitted or processed. This paper present new cryptography way depending on changing ASCII code for each letter in plaintext to another code depending on new value assign to plain text letter in plaintext, and these codes will grouping according to specific key before process each group by special equation use to this purpose. This method reduce plaintext size after encrypted, and give very high probabilities of producing different encrypted letter/symbol from one plaintext letter. Key Words : Cryptography, Cipher, Reduce size, Nk cryptography *Kufa University- Computer Center **Al Mustansyriaa University- Education College 1 1. Introduction The idea of a cipher system is to disguise confidential information in such a way that its meaning is unintelligible to an unauthorized person. The two most common uses are, probably, to store data securely in a computer file or to transmit it across an insecure channel such as the Internet. In either scenario the fact that the document is encrypted does not prevent unauthorized people gaining access to it, but rather, ensures that they cannot understand what they see. The information to be concealed is often called the plaintext and the operation of disguising it is known as encryption. The encrypted plaintext is called the ciphertext or cryptogram and the set of rules used to encrypt information plaintext is the encryption algorithm. Normally the operation of this algorithm depends on an encryption key, which is input to the algorithm together with the message. In order that the recipient can obtain the message from the cryptogram there has to be a decryption algorithm which, when used with the appropriate decryption key, reproduces the plaintext from the ciphertext. Any person who intercepts a message during transmission is called, not surprisingly, an interceptor. Other authors use different terms, including 'eavesdropper','enemy', 'adversary', or even 'bad guy'. However, it must be recognized that, on occasions, the interceptors may be the 'good guys'; more about them later. Even if they know the decryption algorithm, interceptors do not, in general, know the decryption key. It is this lack of knowledge that, it is hoped, prevents them from knowing the plaintext. Cryptography is the science of designing of cipher systems, whereas cryptanalysis is the name given to the process of deducing information about plaintext from the ciphertext without being given the appropriate key. Cryptology is the collective term for both cryptography and cryptanalysis. It is very important to realize that cryptanalysis may not be the only means by which an attacker can gain access to the plaintext. In practice most cryptanalytic attacks involve trying to determine the decryption key. If successful, the attacker then has the same knowledge as the intended recipient and is able to decrypt all other communications until the keys are changed. However there may be instances where an attacker's sole objective is to read a particular message. Nevertheless when authors refer to an algorithm as being broken, they usually mean that an attacker has found a practical way of determining the decryption key. Of course, the attacker is only able to break an algorithm if they have sufficient information to enable them to recognize the correct key or, more frequently, to identify incorrect keys. It is important to realize that this extra information is likely to be crucial to the attacker. One important fact that should already be clear from our introduction is that knowledge of the encryption key is not necessary for obtaining the message from the cryptogram. 2 A cipher system is called conventional or symmetric if it easy to deduce the decryption key from the encryption key. In practice, for symmetric systems, these two keys are often identical. For this reason, such systems are frequently called secret key or one-key systems. However, if it is practically impossible to deduce the decryption key from the encryption key, then the system is called asymmetric or public key. One reason for distinguishing between these two types of system should be clear. In order to prevent an interceptor with knowledge of the algorithm from obtaining the plaintext from intercepted ciphertext it is essential that the decryption key should be secret. Whereas for a symmetric system this necessitates that the encryption key should also be secret, if the system is asymmetric then knowledge of this key is of no practical use to the attacker. Indeed it can be, and usually is, made public. One consequence of this is that there is no need for the sender and receiver of a cryptogram to share any common secrets. In fact there may be no need for them to trust each other. 2. Uses of cryptography Cryptography is commonly used to ensure the detection of unauthorized alterations to documents. Indeed, at least for the commercial sector, the provision of confidentiality is no longer its major application. In addition to its traditional use for privacy, cryptography is now used to provide: data integrity: assurance that information has not been altered by unauthorized or unknown means; entity authentication: corroborating the identity of an entity; data origin authentication: corroborating the source of the information; non-repudiation: preventing the denial (this is usually by the originator) of the content of the information and/or the identity of the originator. Following a number of disjointed situations where the use of cryptography facilitates the provision of a secure service. Many of them represent scenarios that the man in the street encounters almost every day, but probably does not appreciate either the security risks or the role played by encryption. Some ATM (Automated Telling Machine ) networks now use smart cards, which enable the use of public key cryptography. A user's card then contains their private key and a certificate, signed by the card issuer, to confirm their public key value. In a typical Pay TV system each programmed is encrypted with its own unique key prior to transmission. Those who pay for a particular programmed are then essentially paying for knowledge of the key. PGP (Pretty Good Privacy) uses a two-level key hierarchy in which symmetric session keys are used to protect data, and asymmetric keys are used for both signature and the protection of the symmetric session keys. PGP has many uses including securing email and the secure storage of files. 3 3. Secure web browsing is an essential feature of e-commerce. The Secure Sockets Layer (SSL) and the Transport Layer Security (TLS) are two important protocols that are used to verify the authenticity of websites. They facilitate the use of encryption for sensitive data and help to ensure the integrity of information exchanged between web browsers and websites. Since intercepting radio signals is likely to be easier than intercepting landline calls, one of the initial security requirements for GSM was that their mobile phones should be no less secure than the conventional fixed telephones. This requirement was satisfied by providing encryption for transmissions from the handset to the nearest base station. Another serious security issue was the problem of the operator being able to identify the phone so that they knew whom to charge. Strength Everyone wants a practical cipher which is proven “absolutely secure," but such a cipher does not exist, and probably never will. Even the famed” unbreakable" one-time pad ( OTP) is mainly a theoretical concept: The OTP which is proven “Unconditionally secure" is not the realized OTP which is in practice, but instead the theoretical OTP which has an ideal theoretical-class random keying source. We cannot build such a source, but even if we could, we could not prove it, and absolute proof is required for mathematical- level guarantees. None of this prevents a cipher from being effectively unbreakable; of course, it just means that we cannot expect to attain theoretical ideals in the real world. There is NO theory of cipher strength such that, if we only follow the rules, we are guaranteed a strong cipher. Nobody who will talk can even measure the strength of an arbitrary cipher. This means that cipher construction is fundamentally art instead of science, despite the fact that strength is argued excruciating technical detail. Unfortunately, these arguments will be quite unintelligible to the average customer or cipher user. 4. Modern algorithms One- part and two- part codes Most codes involve the use of a code- book, which may contain thousands of code groups. A code used by the military would typically represent letters, numbers or phrases by code groups consisting of four or five letters or digits. 4.1 Bit-strings As we stressed earlier, most modern ciphers do not involve letter substitutions. Instead they tend to use an encoding scheme to convert the message into a sequence of binary digits (bits), that is, zeros and ones. The most commonly used encoding scheme is probably ASCII (American Standard Code for Information Interchange). This bit 4 sequence representing the plaintext is then encrypted to give the ciphertext as a bit sequence. The encryption algorithm may act on a bit-string in a number of ways. One 'natural' division is between stream ciphers, where the sequence is encrypted bit-by-bit, and block ciphers, where the sequence is divided into blocks of a predetermined size. ASCII requires eight bits to represent one character, and so for a block cipher that has 64-bit blocks, the encryption algorithm acts on eight characters at once. It is very important to realize that the same bit-string can be written in many different ways and, in particular, that the way that it is written may depend upon the size of the blocks into which it is divided. 4.2 Stream ciphers Various authors use the term stream cipher slightly differently. Many talk about wordbased, or character-based, stream ciphers. Here the message is enciphered word by word (or character by character), where the rule for the encryption of each word (character) is determined by its position in the message. The Vigenère Cipher, and the one-time pad both fit this definition. Perhaps the best-known historical example is the celebrated Enigma cipher. However, the most common modern use of the term stream cipher, and the one that we adopt, is a cipher where the plaintext is enciphered bit by bit. Clearly all that can happen to any particular bit is that its value is changed to the alternative value or left unchanged. Since a bit can have one of only two values, changing a bit means replacing it by the other value. Furthermore, if a bit is changed twice, then it returns to its original value. If an attacker knows that a stream cipher has been used, then their task is to try to identify the positions of those bits which have been changed, and to change them back to their original values. If there is any easily detectable pattern that identifies the changed bits then the attacker's task may be simple. Thus the positions of the changed bits must be unpredictable to the attacker but, as always, the genuine receiver needs to be able to identify them easily. For a stream cipher we can think of the encipherment process as a sequence of the following two operations: change and leave unchanged. This sequence is determined by the encryption key and is often called the keystream sequence. For simplicity and brevity, we can agree to write 0 to mean 'leave unchanged' and 1 to mean 'change'. We are now in the position where the plaintext, ciphertext and keystream are all binary sequences. 4.3 Block ciphers (ECB mode) For a block cipher, the bit-string is divided into blocks of a given size and the encryption algorithm acts on that block to produce a cryptogram block that, for most symmetric ciphers, has the same size. Block ciphers have many applications. They can be used to provide confidentiality, data integrity, or user authentication, and can even be used to provide the key stream generator for stream ciphers. As with stream ciphers, it is very difficult to give a precise 5 assessment of their security. Clearly, as we have already seen, the key size provides an upper bound of an algorithm's cryptographic strength. However, as we saw with the Simple Substitution Ciphers, having a large number of keys is no guarantee of strength. A symmetric algorithm is said to be well designed if an exhaustive key search is the simplest form of attack. Of course, an algorithm can be well designed but, if the number of keys is too small, also be easy to break. Designing strong encryption algorithms is a specialized skill. Nevertheless there are a few obvious properties that a strong block cipher should possess and which are easy to explain. If an attacker has obtained a known plaintext and ciphertext pair for an unknown key, then that should not enable them to deduce easily the ciphertext corresponding to any other plaintext block. For example, an algorithm in which changing the plaintext block in a known way produces a predictable change in the ciphertext, would not have this property. This is just one reason for requiring a block cipher to satisfy the diffusion property which is that a small change in the plaintext, maybe for example in one or two positions, should produce an unpredictable change in the ciphertext. 4.4 Hash functions So far we have concentrated on encryption algorithms that can be used to provide confidentiality. These algorithms have the fundamental basic property that they are reversible in the sense that, with knowledge of the appropriate key, it must be possible to reconstruct the plaintext message from the cryptogram. However, there are many instances where cryptography is used, but where there is no need to be able to deduce the original 'message' from its encrypted form. In fact there may be a definite requirement that it should not be possible. One example might be the protection of passwords on a computer system. Users are instructed to keep their passwords secret, and thus it is reasonable to assume that the system also tries to ensure this confidentiality. There are also many instances in cryptography where large messages need to be condensed into short bit-strings (considerably shorter than the length of the original message). When this occurs, then it is inevitable that more than one message can give rise to the same shorter bit-string and this automatically implies that the process is irreversible. These functions are known as hash functions and, depending on the application, they may or may not involve the use of a cryptographic key. The basic idea of a hash function is that the resultant hash value is a condensed representative image of the message. The hashed value has a number of names including digital fingerprint, message digest, or, not surprisingly, a hash. Hashing has a number of applications, including the provision of data integrity and as part of the digital signature process. In general hash functions accept inputs of arbitrary length but produce outputs of a fixed length. If two inputs result in the same output then we say that a collision has occurred. As we have already noted, the existence of collisions is inevitable. Thus, if we want to identify a message uniquely by its digital fingerprint, the hash function must be carefully chosen to ensure that, even though collisions exist, it is virtually impossible to find them. 6 4.5 Public key systems We have so far considered only symmetric algorithms where the sender and receiver share a secret key. This, of course, implies trust between the two parties. Prior to the late 1970s, these were the only algorithms available. The basic idea of a public key cryptosystem is that each entity has a public key and a corresponding private key. These keys are chosen so that it is practically impossible to deduce the private key from the public key. Anyone wishing to use this system to send a secret message to someone else needs to obtain that person's public key and use it to encrypt the data. It is, of course, necessary that they have confidence that they are using the correct public key because, otherwise, it is the owner of the private key corresponding to the public key used, as opposed to the intended recipient, who can understand the message. Thus, although there is no need to distribute them secretly, all public keys need protection in the sense that their authenticity must be assured. It is also worth observing that when a public key system is used to provide confidentiality then, since the public encryption key is widely known and can be used by everyone, the ciphertext does not provide any authentication of the sender. For a public key system both the algorithm and the encryption key are public. Thus an attacker is faced with the task of trying to deduce the message from the cryptogram, which was obtained by a method of which he has complete knowledge. Clearly the encryption process needs to be chosen very carefully to ensure that the attacker's task is difficult. However, it must not be forgotten that the genuine receiver needs to be able to decrypt easily. Thus the process must be chosen so that knowledge of the decryption key facilitates the determination of the message from the cryptogram. 4.6 Random Numbers and Random Number Sequences Random numbers are unordered numbers that are independent of preceding and succeeding numbers. Thus, a random number sequence is an unordered series of random numbers. The use of random number sequences in cryptology provides a mechanism to create an unbreakable enciphered message. 5. Proposal Algorithm Paper presents a method to convert plaintext into ciphertext according to the following steps: 5.1 Counting redundancy for each letter in plaintext. Plaintext in figure (1) used as example. 5.2 Sorting letters according to their frequency from most frequent letter to least frequent one. Table (1) show the frequency of plaintext letters in figure (1). 5.3 Numbering each letter in table(1) starting from zero. This number represents the new letter codes shown in table (2). 7 one of the building blocks of security is encryption which provides a means of scrambling data for secure transmission to other parties. in cryptographic terms the data or message to be encrypted is referred to as plaintext and the resulting encrypted block of text as ciphertext. a number of processes exist for converting plaintext into ciphertext through the use of keys which are essentially random numbers of a specified length used to lock and unlock date. this conversion is achieved by applying the keys to the plaintext by following a set of mathematical instructions referred to as the encryption algorithm. Figure ( 1 ): Plaintext used as example to encrypt. 5.4 Rewriting the plaintext by replacing each letter with the corresponding number from table (2) to get a new file with a sequence of integer numbers as shown in figure (2). 5.5 Dividing a new file (from step 4) to equal groups (number of integer code in each group is a key length), the key length change each time encrypt a text (in this example we choose key length with 3 code.) as shown in figure (3) Key (as a word) hidden in plaintext in special position (in this example first word in plain text is "three" (key length)). Also letters of table(2) hidden in plaintext in the same sequence Starting from zero. 5.6 By using equation (2) convert each group to a unique integer number, where equation (2) is a specific equation for converting three integer numbers to one unique number , while equation (1) ( its one to one and onto) is a general form equation and can be used to any number of integer numbers. Note, for each group of codes there is specific reverse equation taking the unique number as input and produce the origin numbers with the same value and same orders. Through this example we used group of three numbers (mean 3 byte), and the resulting unique number from three numbers by using equation (2) need no more than (2byte). 8 (x1, x2, x3,……,xm ) m m i 1 i 1 w1 = [(( xi m 1 )( xi m 2 ) …. m 1 1)*...*1)] + [(( xi m 2 ) ( i 1 m 1 m i 1 i 1 m xi ) / (m*(m- i 1 xi m 3 )….. xi ) / ((m-1)*(m-2)*...*1) ] + …….+[((x2 + x1 +1)( (x2 + x1 ) / 2*1)]+ x1 ……........................................ (1) (x1, x2, x3) w1 = [ (x1+x2+x3+2) (x1+x2+x3+1) (x1+x2+x3)] / 3! ……........................................ (2) + [(x1+x2+1) (x1+x2)] / 2!+ x1 5.7 Resulting numbers from step (5.6) store in file as an (ASCII code ), and when display by word processor it display the corresponding characters according to its (ASCII code), as in figure (4). Table ( 1 ): Frequency of plaintext letters show in figure(1) Letter ( symbols ) Frequency space 94 e 61 t 52 o 39 i 38 S 37 r 36 n 34 a 33 C 24 h 22 l 18 9 P 17 d 15 f 14 Y 12 g 11 M 11 u 11 p 9 x 7 k 6 v 4 . 4 w 3 Table ( 2 ): New code for letters \ symbols of plaintext in figure (1). Letter (symbols) New code o 3 a 8 p 12 b 19 q 26 c 9 r 6 d 13 s 5 e 1 t 2 f 14 u 18 g 16 v 22 h 10 w 24 i 4 x 20 g 25 y 15 k 21 z 27 l 11 . 23 m 17 , 28 n 7 "space" 0 10 3 7 1 0 3 14 0 2 10 1 0 19 18 4 11 13 4 7 16 0 19 11 3 9 21 5 0 3 14 0 5 1 9 18 6 4 2 15 0 4 5 0 1 7 9 6 15 12 2 4 3 7 24 10 4 9 10 0 12 6 3 22 4 13 1 5 0 8 0 17 1 8 7 5 0 3 14 0 5 9 6 8 17 19 11 4 7 16 0 13 8 2 8 0 14 3 6 0 5 1 9 18 6 1 0 2 6 8 7 5 17 4 5 5 4 3 7 0 2 3 0 3 2 10 1 6 0 12 8 6 2 4 1 5 23 0 4 7 0 9 6 15 12 2 3 16 6 8 12 10 4 9 0 2 1 6 17 5 2 10 1 0 13 8 2 8 0 3 6 0 17 1 5 5 8 16 1 0 2 3 0 19 1 0 1 7 9 6 15 12 2 1 13 0 4 5 0 6 1 14 1 6 6 1 13 0 2 3 0 8 5 0 12 11 8 4 7 2 1 20 2 8 7 13 0 2 10 1 0 6 1 5 13 11 2 4 7 16 0 1 7 9 6 15 12 2 1 13 0 19 11 3 9 21 0 3 14 0 2 1 20 2 0 8 5 0 9 4 12 10 1 6 2 1 20 2 23 0 8 0 7 18 17 19 1 6 0 3 14 0 12 6 3 9 1 5 5 1 5 0 1 20 4 5 2 0 14 3 6 0 9 3 7 22 1 6 2 4 7 16 0 12 11 8 4 7 2 1 20 2 0 4 7 2 3 0 9 4 12 10 1 6 2 1 20 2 0 2 10 6 3 18 16 10 0 2 10 1 0 18 5 1 0 3 14 0 21 1 15 5 24 10 4 9 10 0 8 6 1 0 1 5 5 1 7 2 4 8 11 11 15 0 6 8 7 13 3 17 0 7 18 17 19 1 6 5 0 3 14 0 8 0 5 12 1 9 4 14 4 1 13 0 11 1 7 16 2 10 0 18 5 1 13 0 2 3 0 11 3 9 21 0 8 7 13 0 18 7 11 3 9 21 0 13 8 2 8 23 0 2 10 4 5 0 9 3 7 22 1 6 5 4 3 7 0 4 5 0 8 9 10 4 1 22 1 13 0 19 15 0 8 12 12 11 15 4 7 16 0 2 10 1 0 21 1 15 5 0 2 3 0 2 10 1 0 12 11 8 4 7 2 1 20 2 0 19 15 0 14 3 11 11 3 24 4 7 16 0 8 0 5 1 2 0 3 14 0 17 8 2 10 1 17 8 2 4 9 8 11 0 4 7 5 2 6 18 9 2 4 3 7 5 6 1 14 1 6 6 1 13 0 2 3 0 8 5 0 2 10 1 0 1 7 9 6 15 12 2 4 3 7 0 8 11 16 3 3 4 2 10 17 23 Figure (2): New file with codes instead of letters (ASCII codes ) 11 Figure (3) : New file divided every three digit to group. Figure (4) :The resulting cipher text 12 6 Conclusion: This method has many force points 6.1 Plain text can represent about 32 or may be little more if we use the number in text ... and the number of characters yield in cipher text is (256) character , this give a wide range for representation number of letter, for each letter in plain text depending on neighbor letters. 6.2 Minimize the encrypted text file size with about (30%) (Every three symbol transformed into 2 symbols). 6.3 This algorithm can use to any language. 6.4 Complexity of decrypt the encryption file comes from : a) Variant of key length. b) Value of each letter depended on frequency of that letter in plain text file c) Reverse equations vary with varying key length . d) Encrypted file size is less than the origin file , and thus not give idea about number of letters . e) Any set of plain text letters give many different set of characters in cipher text . Probability of yielding different set of characters from one set of plain text character (consist of three characters as a key length for 30 different letters in plain text) equal 30*30*30=27000 different group (each group consist of two symbols). 13 References 1. Fred Piper and Sean Murphy ,“Cryptography: A Very Short Introduction” Oxford University Press © 2002 2. Rolf Oppliger.p.cm ,“Contemporary cryptography” Library of Congress Cataloging-in-Publication Data (Artech House computer security series), 2005 3. R.F. Churchhouse “ Codes and ciphers Julius Caesar, the Enigma and the internet”, Published by the press syndicate of the university of Cambridge 2004 4. Terry Ritter,P.E. “Cryptography - New Encryption Technologies for Communications designers”, (eBook) 1999 5. Wenbo Mao Hewlett, " Modern Cryptography: Theory and Practice”, Publisher:Prentice Hall PTR Pub Date: July 25, 2003 14 الخالصه التشفير هو واحد من التقنيات الفعاله التي تتعامل مع القضايا االمنيه والذي يستخدم للتأكد من تكامل ,وثوقية وتوفر البيانات اثناء الخزن ,النقل والمعالجة. هذا البحث يقدم طريقة تشفير جديدة تعتمد على تغيير شفرة ASCIIلكل حرف او رمز في النص الصريح الى شفره جديدة اعتمادا ً على قيم جديدة تستند لهذه المتغيرات ,هذه الشفرات تقسم الى مجاميع وفقا ً لمفتاح خاص قبل ان تتم معالجة كل مجموعة بواسطة معادلة رياضية خاصة تستخدم لهذا الغرض. ً من مزايا هذه الطريقة انها تقلل حجم النص المشفر نسبة الى حجم النص القديم فضال عن انها تعطي احتماليه كبيره النتاج حرف مشفر يختلف في كل مره نشفر نفس الحرف الصحيح حسب موقعه في النص الصريح. 15