You are on page 1of 76

Provably Secure Three-Party Authenticated Quantum Key Distribution Protocols

Abstract: The quantum key distribution protocols (QKDPs) to safeguard security in large networks, ushering in new directions in classical cryptography and quantum cryptography. Two three-party QKDPs, one with implicit user authentication and the other with explicit mutual authentication, are proposed to demonstrate the merits of the new combination, which include the following: 1) Security against such attacks as manin-the-middle, eavesdropping and replay, 2) efficiency is improved as the proposed protocols contain the fewest number of communication rounds among existing QKDPs, and 3) two parties can share and use a long-term secret (repeatedly).

Acknowledgement At the outset, we wish to express our sincere gratitude to our beloved Parents who are solely responsible for the successful completion of our B.E degree course. We would like to express our sincere gratitude to our Grateful Chairman -------------------------------------- for providing large facilities for progress. We take great pleasure in expressing our sincere thanks to our Principal ----------------------------------------------------------- for his valuable ideas regarding our project. We extend our thanks to Chief Executive Officer ------------------------------------------------------- for his moral support throughout this project. We express our sincere thanks to Head of the Department ---------------------------------------- Who spend her valuable time us in guiding throughout the project work. We would like to express profusely our deep sense of gratitude to our guide for his kind advice, encouragement and for having granted

permission to work this project.

We would like to express profusely our deep sense of gratitude to our guide for his kind advice, encouragement and for having granted

permission to work this project.

Bonafide Certificate

This is Certified that this project report titledis the bonafide work of Mr./ Ms..who carried out the research under my Supervision. Certified further, that to the best of my knowledge the work reported here in does not form part of any other project report or dissertation on the basis of which a degree or award was conferred on an earlier occasion on this or any other candidate.

Signature of the Guide

Signature of the H.O.D

Name of the Guide

(Certificate to be countersigned by the HOD.)

Where external guide is also there, the following format may be followed.

Signature of Internal Guide/ Name:

Signature of External Guide/Name:

Table of Contents

Abstract Acknowledgement 1. Introduction 2. Literature Survey 3. System Analysis Existing System Proposed System 4. System Requirement Hardware Specification Software Specification 5. System Design Data flow diagram System Diagram System architecture Module Description 6. Conclusion: 7. Screen Shots 8. Sample Coding

Introduction: 1.1 KEY distribution protocols: KEY distribution protocols are used to facilitate sharing secret session keys between users on communication networks. By using these shared session keys, secure communication is possible on insecure public networks. In quantum cryptography, quantum key distribution protocols employ quantum mechanisms to distribute session keys and public discussions to check for eavesdroppers and verify the correctness of a session key. A classical cryptography provides convenient techniques that enable efficient key verification and user authentication. Compared with classical Three-party key distribution protocols, the proposed quantum key distribution protocols easily resist replay and passive attacks. Compared with other quantum key distribution protocols, the proposed schemes efficiently achieve key verification and user authentication and preserve a long term secret key between the TC and each user. However, public discussions require additional communication rounds between a sender and receiver and cost precious qubits. By contrast, classical cryptography provides convenient techniques that enable efficient key verification and user authentication.

1.2 Problem Definition: In classical cryptography, three-party key distribution protocols utilize challenge response mechanisms or timestamps to prevent replay attacks. However, challenge response mechanisms require at least two communication rounds between the TC and participants, and the timestamp approach needs the assumption of clock synchronization which is not practical in distributed systems (due to the unpredictable nature of network delays and potential hostile attacks) . Furthermore, classical cryptography cannot detect the existence of passive attacks such as eavesdropping.

1.3 Project Description: The combination of 3AQKDP (implicit) and 3AQKDPMA (explicit) quantum cryptography is used to provide authenticated secure communication between sender and receiver. In quantum cryptography, quantum key distribution protocols (QKDPs) employ quantum mechanisms to distribute session keys and public discussions to check for eavesdroppers and verify the correctness of a session key. However, public discussions require additional communication rounds between a sender and receiver. The advantage of quantum cryptography easily resists replay and passive attacks. A 3AQKDP with implicit user authentication, which ensures that confidentiality, is only possible for legitimate users and mutual authentication is achieved only after secure communication using the session key start. In implicit quantum key distribution protocol (3AQKDP) have two phases such as setup phase and distribution phase to provide three party authentications with secure session key distribution. In this system there is no mutual understanding between sender and receiver. Both sender and receiver should communicate over trusted center. In explicit quantum key distribution protocol (3AQKDPMA) have two phases such as setup phase and distribution phase to provide three party authentications with secure session key distribution. Trusted center. Disadvantage of separate process 3AQKDP and 3AQKDPMA were providing the authentication only for message, to identify the security threads in the message. Not identify the security threads in the session key. Advantage of combining implicit and explicit quantum cryptography is to used to verify the session key from trusted center and sender which improve key verification and secure the communication. Also identify the security threads in session key verification. I have mutual understanding between sender and receiver. Both sender and receiver should communicate directly with authentication of

Another advantage of this project is to avoid the network noise in message transmission by identifying the size of bytes transmitted over the network from sender to receiver and remove the extra byte content received from network.

3.1 EXISTING SYSTEM


In classical cryptography, three-party key distribution protocols utilize challenge response mechanisms or timestamps to prevent replay attacks. However, challenge response mechanisms require at least two communication rounds between the TC and participants, and the timestamp approach needs the assumption of clock synchronization which is not practical in distributed systems (due to the unpredictable nature of network delays and potential hostile attacks) . Furthermore, classical cryptography cannot detect the existence of passive attacks such as eavesdropping.

3.2 PROPOSED SYSTEM


In quantum cryptography, quantum key distribution protocols (QKDPs) employ quantum mechanisms to distribute session keys and public discussions to check for eavesdroppers and verify the correctness of a session key. However, public discussions require additional communication rounds between a sender and receiver and cost precious qubits. By contrast, classical cryptography provides convenient techniques that enable efficient key verification and user authentication.

4. SYSTEM CONFIGURATION
4.1 HADWARE SPECIFICATION
The required hardware interfaces are LAN and a standard PC. Processor Type Speed Ram Hard disk : Pentium -IV : 2.4 GHZ : 128 MB RAM : 20 GB HD

4.2 SOFTWARE SPECIFICATION


A tool is used for capturing packets from network. Operating System Programming Package Data Base Tools SDK : Win2000 : JAVA : SQL : Eclipse. : JDK1.5.0

5.1 DATA FLOW DIAGRAM


Sender

TCRequest

Random number generation

Session Key Trusted center generation

Create qubits

Users preshare secret keys with the TC

Transaction allowed Original data

Transaction declined

Q ua nt ma Ke um tch y in g

Receiver

Level 1:

Sec Key

Random String Gen

Qubit Generation
Hashing

Sessio n Key Genera tion

Session key

Level 2

Truste d center Secret Key

Level1 Key Generation

Secret Key Session Key

Sender

Receiv er Encrypted Msg by Sess Key

5.2 Modules description


1. Sender Module a. Secret key Authentication The sender give the secret key to the trusted center, then the TC will verify the secret and authenticate to the corresponding sender and get the session key from TC or else TC not allow the user transmission b. Encryption The message is encrypted by the received session key and appends the qubit with that encrypted message, then transmit the whole information to the corresponding receiver. 2. Trusted Center a. Secret Key Verification Verify the secret key received from the user and authenticate the corresponding user for secure transmission. b. Session Key Generation It is shared secret key which is used to for encryption and decryption. The size of session key is 8 bits. This session key is generated from pseudo random prime number and exponential value of random number c. Qubit Generation To get secret key and random string, then convert into hex-code and then convert it into binary, find the least bit of the two binary values and get the quantum bit of 0 and 1. d. Quantum Key Generation To generate the quantum key using the qubit and session key which depends on the qubit combinations, such us i. If the value is 0 and 0, then 1/2(p[0] + p[1]). ii. If the value is 1 and 0, then 1/2(p[0] - p[1]). iii. If the value is 0 and 1, then p[0]. iv. If the value is 1 and 1, then p[1].

e. Hashing Its a technique to encrypt the session key by using the master key and store all the values to TC storage f. Key Distribution It distributes the original session key and qubit to the sender for encrypting the message. Also it distribute the key and qubit to the corresponding receiver to decrypt the received messages 3. Receiver Module a. Secret key Authentication It receive the encrypted message with hashed session key and qubit, then verify the qubit with TC and generate the master key and reverse the hash the session key and also reverse hash the session key from sender then compare the session key which improve the key authentication b. Decryption Then finally decrypt the message using session key and show it to the user

SQL Server SQL is a multithreaded, multi-user SQL database management system which has, according to SQL AB, more than 10 million installations. SQL is owned and sponsored by a single for-profit firm, the Swedish company SQL AB, which holds the copyright to most of the code base. This is similar to the JBoss model and how the Free Software Foundation handles copyright in its projects, and dissimilar to how the Apache project does it, where the software is developed by a public community, and the copyright to the code base is owned by its individual authors. There are APIs available that allow applications written in numerous programming languages to access SQL databases, including: C, C++, C#, D, Borland Delphi (via dbExpress), Eiffel, Smalltalk, Java (with a native Java driver implementation), Lisp, Perl, PHP, Python, Ruby, REALbasic (Mac), FreeBasic, and Tcl; each of these uses a specific API. An ODBC interface called MyODBC allows additional programming languages that support the ODBC interface to communicate with a SQL database, such as ASP or Coldfusion. SQL is mostly implemented in ANSI C. Uses SQL is popular for web applications and acts as the database component of the LAMP, MAMP, and WAMP platforms (Linux/Mac/Windows-Apache-SQLPHP/Perl/Python), and for open-source bug tracking tools like Bugzilla. Its popularity as a web application is closely tied to the popularity of PHP, which is often combined with SQL and nicknamed the Dynamic Duo. It is easy to find many references that combine the two in websites and books (PHP and SQL for Dummies, PHP and SQL Bible, Beginning PHP and SQL, etc.). PHP and SQL are also essential components for running the popular WordPress blogging platform. Wikipedia runs on MediaWiki software, which also uses PHP and a SQL database. Administration To administer SQL databases one can use the included command-line tool (commands: SQL and SQLadmin). Also downloadable from the SQL site are GUI

administration tools: SQL Administrator and SQL Query Browser. Both of the GUI tools are now included in one package called SQL GUI Tools. A widespread and popular alternative, written in PHP, is the free software web application phpMyAdmin which is a server side tool. For client side SQL administration and development, the leading tools are Navicat SQL GUI by PremiumSoft and SQL admin family by SQL Maestro Group, which provide the same functionality as phpMyAdmin but more advanced in the Import/Export, Query Building, OLAP, BLOB Editing, Backup and Data Sync. features. Navicat is also available for PostgreSQL Navicat PostgreSQL Manager. Platforms SQL works on many different platformsincluding AIX, BSDi, FreeBSD, HPUX, GNU/Linux, Mac OS X, NetBSD, Novell NetWare, OpenBSD, OS/2 Warp, QNX, SGI IRIX, Solaris, SunOS, SCO OpenServer, SCO UnixWare, Tru64, Windows 95, Windows 98, Windows ME, Windows NT, Windows 2000, Windows XP and Windows Vista. A port of SQL to OpenVMS is also available

Input We have to give the username and password for existing user to provide the file sharing and uploading permission for online user who can be chosen by the logged in user. Output Once the file sharing permission is given, the appropriate file can be downloaded and that can be viewed successfully.

SYSTEM TESTING:
Testing is performed to identify errors. It is used for quality assurance. Testing is an integral part of the entire development and maintenance process. The goal of the testing during phase is to verify that the specification has been accurately and completely incorporated into the design, as well as to ensure the correctness of the design itself. For example the design must not have any logic faults in the design is detected before coding commences, otherwise the cost of fixing the faults will be considerably higher as reflected. Detection of design faults can be achieved by means of inspection as well as walkthrough. Testing is one of the important steps in the software development phase. Testing checks for the errors, as a whole of the project testing involves the following test cases: Static analysis is used to investigate the structural properties of the Source code. Dynamic testing is used to investigate the behavior of the source code by executing the program on the test data.

1. UNIT TESTING:
Unit testing is conducted to verify the functional performance of each modular component of the software. Unit testing focuses on the smallest unit of the software design (i.e.), the module. The white-box testing techniques were heavily employed for unit testing.

FUNCTIONAL TESTS:
Functional test cases involved exercising the code with nominal input values for which the expected results are known, as well as boundary values and special values, such as logically related inputs, files of identical elements, and empty files. Three types of tests in Functional test: Performance Test Stress Test Structure Test

PERFORMANCE TEST:
It determines the amount of execution time spent in various parts of the unit, program throughput, and response time and device utilization by the program unit.

STRESS TEST:
Stress Test is those test designed to intentionally break the unit. A Great deal can be learned about the strength and limitations of a program by examining the manner in which a programmer in which a program unit breaks.

STRUCTURED TEST:
Structure Tests are concerned with exercising the internal logic of a program and traversing particular execution paths. The way in which White-Box test strategy was employed to ensure that the test cases could Guarantee that all independent paths within a module have been have been exercised at least once. Exercise all logical decisions on their true or false sides. Execute all loops at their boundaries and within their operational bounds. Exercise internal data structures to assure their validity. Checking attributes for their correctness. Handling end of file condition, I/O errors, buffer problems and textual errors in output information

2. INTEGRATION TESTING:
Integration testing is a systematic technique for construction the program structure while at the same time conducting tests to uncover errors associated with interfacing. i.e., integration testing is the complete testing of the set of modules which makes up the product. The objective is to take untested modules and build a program structure tester should identify critical modules.

Critical modules should be tested as early as possible. One approach is to wait until all the units have passed testing, and then combine them and then tested. This approach is evolved from unstructured testing of small programs. Another strategy is to construct the product in increments of tested units. A small set of modules are integrated together and tested, to which another module is added and tested in combination. And so on. The advantages of this approach are that, interface dispenses can be easily found and corrected. The major error that was faced during the project is linking error. When all the modules are combined the link is not set properly with all support files. Then we checked out for interconnection and the links. Errors are localized to the new module and its intercommunications. The product development can be staged, and modules integrated in as they complete unit testing. Testing is completed when the last module is integrated and tested.

TESTING TECHNIQUES / TESTING STRATRGIES: TESTING:


Testing is a process of executing a program with the intent of finding an error. A good test case is one that has a high probability of finding an as-yet undiscovered error. A successful test is one that uncovers an as-yet- undiscovered error. System testing is the stage of implementation, which is aimed at ensuring that the system works accurately and efficiently as expected before live operation commences. It verifies that the whole set of programs hang together. System testing requires a test consists of several key activities and steps for run program, string, system and is important in adopting a successful new system. This is the last chance to detect and correct errors before the system is installed for user acceptance testing. The software testing process commences once the program is created and the documentation and related data structures are designed. Software testing is essential for correcting errors. Otherwise the program or the project is not said to be complete. Software testing is the critical element of software quality assurance and represents the ultimate the review of specification design and coding.

Testing is the process of executing the program with the intent of finding the error. A good test case design is one that as a probability of finding an yet undiscovered error. A successful test is one that uncovers an yet undiscovered error. Any engineering product can be tested in one of the two ways:

White box testing:


This testing is also called as Glass box testing. In this testing, by knowing the specific functions that a product has been design to perform test can be conducted that demonstrate each function is fully operational at the same time searching for errors in each function. It is a test case design method that uses the control structure of the procedural design to derive test cases. Basis path testing is a white box testing.

Basis path testing:


Flow graph notation Cyclomatic complexity Deriving test cases Graph matrices Control

Black Box Testing:


In this testing by knowing the internal operation of a product, test can be conducted to ensure that all gears mesh, that is the internal operation performs according to specification and all internal components have been adequately exercised. It fundamentally focuses on the functional requirements of the software. The steps involved in black box test case design are: Graph based testing methods Equivalence partitioning Boundary value analysis Comparison testing

SOFTWARE TESTING STRATEGIES:


A software testing strategy provides a road map for the software developer. Testing is a set activity that can be planned in advance and conducted systematically. For this reason a template for software testing a set of steps into which we can place specific test case design methods should be strategy should have the following characteristics: Testing begins at the module level and works outward toward the integration of the entire computer based system. Different testing techniques are appropriate at different points in time. The developer of the software and an independent test group conducts testing. Testing and Debugging are different activities but debugging must be accommodated in any testing strategy.

INTEGRATION TESTING:
Integration testing is a systematic technique for constructing the program structure while at the same time conducting tests to uncover errors associated with. Individual modules, which are highly prone to interface errors, should not be assumed to work instantly when we put them together. The problem of course, is putting them together- interfacing. There may be the chances of data lost across on anothers sub functions, when combined may not produce the desired major function; individually acceptable impression may be magnified to unacceptable levels; global data structures can present problems.

VALIDATION TESTING:
Software validation is achieved through a series of tests that demonstrates conformity with requirements. A test plan outlines the classes of test to be conducted and a test procedure defines specific test cases that will be used to demonstrate conformity with requirements. Thus the proposed system under consideration has been tested by validation and found to be working satisfactorily.

PROGRAM TESTING:
The logical and syntax errors have been pointed out by program testing. A syntax error is an error in a program statement that in violates one or more rules of the language in which it is written. An improperly defined field dimension or omitted keywords are common syntax error. These errors are shown through error messages generated by the computer. A logic error on the other hand deals with the incorrect data fields, out-offrange items and invalid combinations. Since the compiler s will not deduct logical error, the programmer must examine the output. Condition testing exercises the logical conditions contained in a module. The possible types of elements in a condition include a Boolean operator, Boolean variable, a pair of Boolean parentheses A relational operator or on arithmetic expression. Condition testing method focuses on testing each condition in the program the purpose of condition test is to deduct not only errors in the condition of a program but also other a errors in the program.

SECURITY TESTING:
Security testing attempts to verify the protection mechanisms built in to a system well, in fact, protect it from improper penetration. The system security must be tested for invulnerability from frontal attack must also be tested for invulnerability from rear attack. During security, the tester places the role of individual who desires to penetrate system.

SYSTEM SECURITY MEASURES:


System security refers to the technical innovations and procedures applied to the hardware and operating systems to protect against deliberate or accidental damage from a defined threat. In contrast, data security is the protection of data from disclosure, modification and destruction. Data privacy and security are issues that go beyond the scope of system development. They are actually a societal concern. Our organization depends heavily on the use of data bases requires special controls to maintain viable information. These controls are classified in to three general categories.

Physical securities are production from fire flood and other physical damage. Database integrity through data validation techniques. Control measures through passwords encryption and monitoring users on a regular basis. Password is the most common authentication mechanism based on sharing of secret. In a password based system each user has a password, which may initially be assigned by the system or an administrator. In Online Recruitment System, only administrator is allowed to change the users passwords . The system stores all users passwords and users them to authenticate the user . When logging in , the system request the user supplies a presumably secret, user specific password. This way the passwords provide protection to some extent The proper backup of data in the form of hardcopies as well as on paper stationary is a measure of disaster recovery planning.

Database/Data security:
The design of database involved to maintain various security levels to maintain the data in table. Data Integrity Primary Key Unique Key Not null Foreign Key A PRIMARY KEY constraint is a unique identifier for a row within a database table. Every table should have a primary key constraint to uniquely identify each row and only one primary key constraint can be created for each table. The primary key constraints are used to enforce entity integrity. A UNIQUE constraint enforces the uniqueness of the values in a set of columns, so no duplicate values are entered. The

unique key constraints are used to enforce entity integrity as the primary key constraints.

A FOREIGN KEY constraint prevents any actions that would destroy link between tables with the corresponding data values. A foreign key in one table points to a primary key in another table. Foreign keys prevent actions that would leave rows with foreign key values when there are no primary keys with that value. The foreign key constraints are used to enforce referential integrity. A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints.

User Manual
JAVA: It is a Platform Independent. Java is an object-oriented programming language developed initially by James Gosling and colleagues at Sun Microsystems. The language, initially called Oak (named after the oak trees outside Gosling's office), was intended to replace C++, although the feature set better resembles that of Objective C. The following diagram shows the Java 2 Platform Standard Edition Architecture

Fig 3.2.1.1 Java 2 Platform Standard Edition The following are some of the features which have made Java one of the most popular among the various available programming languages. Simple Java was developed by taking the best points from other programming languages, primarily C and C++. Java therefore utilizes algorithms and methodologies that are already proven. Error prone tasks such as pointers and memory management have either been eliminated or are handled by the Java environment automatically rather than by the programmer. Since Java is primarily a derivative of C++ which most programmers are conversant with, it implies that Java has a familiar feel rendering it easy to use.

Object Oriented Even though Java has the look and feel of C++, it is a wholly independent

language which has been designed to be object-oriented from the ground up. In objectoriented programming (OOP), data is treated as objects to which methods are applied. Java's basic execution unit is the class. Advantages of OOP include: reusability of code, extensibility and dynamic applications Distributed Commonly used Internet protocols such as HTTP and FTP as well as calls for network access are built into Java. Internet programmers can call on the functions through the supplied libraries and be able to access files on the Internet as easily as writing to a local file system. Interpreted When Java code is compiled, the compiler outputs the Java Bytecode which is an executable for the Java Virtual Machine. The Java Virtual Machine does not exist physically but is the specification for a hypothetical processor that can run Java code. The bytecode is then run through a Java interpreter on any given platform that has the interpreter ported to it. The interpreter converts the code to the target hardware and executes it. Robust Java compels the programmer to be thorough. It carries out type checking at both compile and runtime making sure that every data structure has been clearly defined and typed. Java manages memory automatically by using an automatic garbage collector. The garbage collector runs as a low priority thread in the background keeping track of all objects and references to those objects in a Java program. When an object has no more references, the garbage collector tags it for removal and removes the object either when there is an immediate need for more memory or when the demand on processor cycles by the program is low.

Secure The Java language has built-in capabilities to ensure that violations of security do

not occur. Consider a Java program running on a workstation on a local area network which in turn is connected to the Internet. Being a dynamic and distributed computing environment, the Java program can, at runtime, dynamically bring in the classes it needs to run either from the workstation's hard drive, other computers on the local area network or a computer thousands of miles away somewhere on the Internet. This ability of classes or applets to come from unknown locations and execute automatically on a local computer sounds like every system administrator's nightmare considering that there could be lurking out there on one of the millions of computers on the Internet, some viruses, Trojan horses or worms which can invade the local computer system and wreak havoc on it. Java goes to great lengths to address these security issues by putting in place a very rigorous multilevel system of security: First and foremost, at compile time, pointers and memory allocation are removed thereby eliminating the tools that a system breaker could use to gain access to system resources. Memory allocation is deferred until runtime. Even though the Java compiler produces only correct Java code, there is still the possibility of the code being tampered with between compilation and runtime. Java guards against this by using the bytecode verifier to check the bytecode for language compliance when the code first enters the interpreter, before it ever even gets the chance to run. The bytecode verifier ensures that the code does not do any of the following:

Forge pointers Violate access restrictions Incorrectly access classes Overflow or underflow operand stack Use incorrect parameters of bytecode instructions

Use illegal data conversions

At runtime, the Java interpreter further ensures that classes loaded do not access the file system except in the manner permitted by the client or the user. Sun Microsystems will soon be adding yet another dimension to the security of Java. They are currently working on a public-key encryption system to allow Java applications to be stored and transmitted over the Internet in a secure encrypted form. Architecturally Neutral The Java compiler compiles source code to a stage which is intermediate between source and native machine code. This intermediate stage is known as the bytecode, which is neutral. The bytecode conforms to the specification of a hypothetical machine called the Java Virtual Machine and can be efficiently converted into native code for a particular processor. Portable By porting an interpreter for the Java Virtual Machine to any computer hardware/operating system, one is assured that all code compiled for it will run on that system. This forms the basis for Java's portability. Another feature which Java employs in order to guarantee portability is by creating a single standard for data sizes irrespective of processor or operating system platforms. High Performance The Java language supports many high-performance features such as multithreading, just-in-time compiling, and native code usage. Java has employed multithreading to help overcome the performance problems suffered by interpreted code as compared to native code. Since an executing program hardly ever uses CPU cycles 100 % of the time, Java uses the idle time to perform the necessary garbage cleanup and general system maintenance that renders traditional interpreters slow in executing applications. [NB: Multithreading is the ability of an

application to execute more than one task (thread) at the same time e.g. a word processor can be carrying out spell check in one document and printing a second document at the same time.] Since the bytecode produced by the Java compiler from the corresponding source code is very close to machine code, it can be interpreted very efficiently on any platform. In cases where even greater performance is necessary than the interpreter can provide, just-in-time compilation can be employed whereby the code is compiled at run-time to native code before execution. An alternative to just-in-time compilation is to link in native C code. This yields even greater performance but is more burdensome on the programmer and reduces the portability of the code. Dynamic By connecting to the Internet, a user immediately has access to thousands of programs and other computers. During the execution of a program, Java can dynamically load classes that it requires either from the local hard drive, from another computer on the local area network or from a computer somewhere on the Internet.

3.2.2 Eclipse 3.2 Eclipse is a toll that is used to edit the java programs that are created and has a very user friendly environment and makes the process to be very simple. Some of the advantages of using this application and its features are explained below. In the Eclipse environment, every file is stored inside a project. This means that every document, folder, code file (.java) and compiled code (.class) has to be contained by a project. Hence the Eclipse project framework is explained. It is necessary to create a new project to develop a new Java program, but also to edit existing code (i.e., a .java file stored inside a diskette). To create a new project select

from the main menu line "File > New > Project ... You may also select "New > Project ..." by right clicking any point of the package explorer window. To create or edit Java programs, a Java project should be created. Java project can also store program related information, such as code documentation and other related files. Simple projects should only be created to store documents and other files with no Java code. Plug-in Development projects are used to add new modules and facilities to the Eclipse environment. Eclipse Modeling Framework projects are used to create analysis and design models. Source folders are the folders that store the Java source code files (the .java files). By placing your Java files inside a source folder, they will be automatically compiled. Another striking feature of this version is that every imported element is duplicated. This means that the programmer may delete the copy of these files that Eclipse manages, and still have the original file. Nevertheless, when importing an existing Eclipse project, the project contents will not be duplicated. Hence, special care needs to be taken when deleting files from Eclipse workspace, especially while deleting those Eclipse imported projects, as no other copies may exist. The files created using Eclipse may also be exported as normal files (File system), Java Jar files and even Zip files. This is achieved through a process similar to the importing process already detailed, selecting the "Export" option. It is also possible copying, cutting and pasting files and folders from Eclipse to your file system (i.e., Windows explorer) and vice versa (i.e., selecting a file, pressing CTRL+C, then choosing a destination folder and pressing CTRL+V).

Conclusion This study proposed two three-party QKDPs to demonstrate the advantages of combining classical cryptography with quantum cryptography. Compared with classical

three-party key distribution protocols, the proposed QKDPs easily resist replay and passive attacks. Compared with other QKDPs, the proposed schemes efficiently achieve key verification and user authentication and preserve a long-term secret key between the TC and each user. Additionally, the proposed QKDPs have fewer communication rounds than other protocols. Although the requirement of the quantum channel can be costly in practice, it may not be costly in the future. Moreover, the proposed QKDPs have been shown secure under the random oracle model. By combining the advantages of classical cryptography with quantum cryptography, this work presents a new direction in designing QKDPs.

References
[1] G. Li, Efficient Network Authentication Protocols: Lower Bounds and Optimal Implementations, Distributed Computing, vol. 9, no. 3, pp. 131-145, 1995. [2] A. Kehne, J. Schonwalder, and H. Langendorfer, A Nonce-Based Protocol for Multiple Authentications, ACM Operating Systems Rev., vol. 26, no. 4, pp. 84-89, 1992. [3] M. Bellare and P. Rogaway, Provably Secure Session Key Distribution: The Three Party Case, Proc. 27th ACM Symp. Theory of Computing, pp. 57-66, 1995.

[4] J. Nam, S. Cho, S. Kim, and D. Won, Simple and Efficient Group Key Agreement Based on Factoring, Proc. Intl Conf. Computational Science and Its Applications (ICCSA 04), pp. 645-654, 2004. [5] H.A. Wen, T.F. Lee, and T. Hwang, A Provably Secure Three-Party Password-Based Authenticated Key Exchange Protocol Using Weil Pairing, IEE Proc. Comm., vol. 152, no. 2, pp. 138-143, 2005. [6] J.T. Kohl, The Evolution of the Kerberos Authentication Service, EurOpen Conf. Proc., pp. 295-313, 1991. [7] B. Neuman and T. Tso, Kerberos: An Authentication Service for Computer Networks, IEEE Comm., vol. 32, no. 9, pp. 33-38, 1994.

Screen Shots

Sample coding import java.io.*; import java.net.*; import java.sql.ResultSet; import java.sql.Statement; import java.util.*; public class TC {//extends TimerTask{ ServerSocket ss; Socket s; String randomStr; String secKey; StrToHex sth; char kta; char rta; int qk; String source; String dest; private String uname; private String pword; private String port; private ResultSet rs; private String responseFlag; private int s_id; private int d_id;

private boolean flag; private String key_response; private String d_port;

public TC() { System.out.println("Trusted Center..."); new TrustedCenter(); sth = new StrToHex(); Timer t1 = new Timer(); t1.schedule(new TCReceiver(), 1000); SendSessionKey(); } /*public void run(){ SendSessionKey(); } */ public void SendSessionKey() { //System.out.println("kkkkkk..."); flag = false; try { ss = new ServerSocket(1111); while(true){ s = ss.accept(); DataInputStream dis = new DataInputStream(s.getInputStream()); String request = dis.readUTF(); if (request.equalsIgnoreCase("SignUp")) { System.out.println("sign up..."); uname = dis.readUTF(); pword = dis.readUTF(); port = dis.readUTF(); String check = checkMember(uname, port); if (check.equalsIgnoreCase("norecord")) { responseFlag = "success"; new secureRandom(); String secretkey = secureRandom.seckey; String query = "insert into userdetails " + "values('"

+ uname + "', '" + pword + "', '" + port + "', " + "'" + secretkey + "')"; addMember(query); TrustedCenter.jTextArea1.append("\nUser "+uname+" Added...\n"); TrustedCenter.jTextArea1.append("\n-------------------------------\n"); } else { responseFlag = "failure"; TrustedCenter.jTextArea1.append("\nRegistration Failed \n"); } DataOutputStream signup_dos = new DataOutputStream(s.getOutputStream()); signup_dos.writeUTF(responseFlag); } else if (request.equalsIgnoreCase("SignIn")) { System.out.println("sign in..."); uname = dis.readUTF(); pword = dis.readUTF(); String response = getSignIn(uname, pword); DataOutputStream signin_dos = new DataOutputStream(s.getOutputStream()); signin_dos.writeUTF(response); TrustedCenter.jTextArea1.append("\n"+uname +" is Logged In...\n"); TrustedCenter.jTextArea1.append("-------------------------------"); } else if (request.equalsIgnoreCase("key")) { System.out.println("key..."); source = dis.readUTF(); dest = dis.readUTF(); secKey = dis.readUTF(); TrustedCenter.jTextArea1.append("\n Sender: "+source+" Receiver: "+dest+"\n"); // s_id = new Integer(source); DataOutputStream key_dos = new DataOutputStream(s.getOutputStream()); ConnectionDB cdb = new ConnectionDB(); Statement st = cdb.connectJDBC();

rs = st .executeQuery("select * from userdetails where username='" + source + "' and secretkey = '" + secKey + "'"); if (rs.next()) { flag = true; d_id = rs.getInt(1); System.out.println("Destination Port: " + d_port); /* * randomStr = randomString.randstr; * System.out.println("Random String: "+randomStr); * System.out.println("Session Key: "+secKey); */ } if (flag = true) { ResultSet rs1 = st .executeQuery("select * from userdetails where username = '" + dest + "'"); if (rs1.next()) { d_port = rs1.getString(4); } kta = sth.seckeyToHex(secKey); new randomString(); rta = sth.ranstrToHex(randomString.randstr); SessionKey sk = new SessionKey(); String sesskey = sk.getSessionKey(); UpdateKey uk = new UpdateKey(); qk = uk.getQubit(rta, kta, sesskey); System.out.println("RTA: " + rta + " KTA: " + kta + " SessKey: " + sesskey + " Qk: " + qk); SKHash skh = new SKHash();

String sessHash = skh.generateHash(sesskey, qk); System.out.println("rrrrrrrr" + dest + "-----------" + sessHash); String q_sess = sessHash + "," + UpdateKey.qqb+","+UpdateKey.oCount+","+UpdateKey.zCount; System.out.println("ddddd..."+q_sess); updateSessKey(source, dest, q_sess); key_response = "key," + d_port + "," + sesskey + "," + UpdateKey.qqb + "," + sessHash; TrustedCenter.jTextArea1.append("\n Session Key: "+sesskey+" QK: "+qk+"\n"); TrustedCenter.jTextArea1.append("\n Hashed Session Key: \n"); TrustedCenter.jTextArea1.append("\n"+sessHash+"\n"); TrustedCenter.jTextArea1.append("\n---------------------------------------"); System.out.println("wwwwwwww " + key_response); // key_dos.writeUTF(""+sesskey); } else { key_response = "nokey#123"; } key_dos.writeUTF(key_response); } } } catch (Exception e) { e.printStackTrace(); } } public String checkMember(String uname, String port) { String flag = ""; try { ConnectionDB cdb = new ConnectionDB(); Statement st = cdb.connectJDBC(); String query = "select * from userdetails where " + "username ='" + uname + "' or port='" + port + "'";

rs = st.executeQuery(query); if (rs.next()) { flag = "record"; } else { flag = "norecord"; } rs.close(); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return flag; } public void addMember(String query) { try { System.out.println("Add Query: " + query); ConnectionDB cdb = new ConnectionDB(); Statement st = cdb.connectJDBC(); st.executeUpdate(query); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } public String getSignIn(String username, String password) { String response = ""; try { String query = "select * from userdetails where " + "username='" + username + "' and" + " password = '" + password + "'"; ConnectionDB cdb = new ConnectionDB(); Statement st = cdb.connectJDBC(); rs = st.executeQuery(query); if (rs.next()) { int userid = rs.getInt(1); String port = rs.getString(4); String secretkey = rs.getString(5); response = "record#" + userid + "#" + port + "#" + secretkey; } else { response = "norecord#0"; }

} catch (Exception e) { // TODO: handle exception e.printStackTrace(); } return response; } public void updateSessKey(String s_id, String d_id, String seskey) { try { ConnectionDB cdb = new ConnectionDB(); Statement st = cdb.connectJDBC(); String query = "insert into transmission values('" + s_id + "','" + d_id + "','" + seskey + "')"; System.out.println(dest + "--------" + seskey); st.executeUpdate(query); } catch (Exception e) { System.out.println("wwwwwwwwwwwwwww"); e.printStackTrace(); } } public static void main(String[] args) { new TC(); } }

/****************************************************************/ /* key */ /* */ /****************************************************************/ import java.math.BigInteger; import java.util.*; class calculation1 { long great, a; double aa, bb, cc, rm; long rd; long eval;

long calE(long pi, long p, long q) { great = 0; aa = Math.log(pi) / Math.log(10); bb = Math.floor(aa); cc = Math.pow(10, bb); rm = Math.random() * cc; // System.out.println("rm :"+rm); rd = Math.round(rm); // System.out.println("rd :"+rd); while (great != 1) { rd = rd + 1; great = GCD(rd, pi); pi = (p - 1) * (q - 1); } return rd; } long GCD(long e, long pi) { // System.out.println("e :"+e); if (e > pi) { while (e % pi != 0) { a = e % pi; e = pi; pi = a; } great = pi; } else { while (pi % e != 0) { a = pi % e; // System.out.println("a :"+a); pi = e; // System.out.println("pi :"+pi); e = a; // System.out.println("e12 :"+e); } great = e; } return great; } } public class SessionKey { String pstr = ""; String qstr = "";

String s, output; long p, q, pi, e, val, ds, r, qd;; static long d, n; int i, cnt, inc = 0; long rst[] = new long[100]; long div[] = new long[100]; long qud[] = new long[100]; long rem[] = new long[100]; String fe = ""; String fd = ""; String fn = ""; String PubKey = ""; String PriKey = ""; String concat = ""; // End of variables declaration SessionKey() { } public String getSessionKey() { calculation1 cal = new calculation1(); Random rnd1 = new Random(10); Random rnd2 = new Random(10); BigInteger prime1 = BigInteger.probablePrime(10, rnd1); BigInteger prime2 = BigInteger.probablePrime(15, rnd2); p = prime1.longValue(); q = prime2.longValue(); // System.out.println(p); // System.out.println(q); // q=p;

n = p * q; pi = (p - 1) * (q - 1); e = cal.calE(pi, p, q); // System.out.println("e :"+e); qd = pi / e; r = pi % e; cnt = 0; rst[cnt] = pi; div[cnt] = e; qud[cnt] = qd; rem[cnt] = r; // System.out.println("val ds qd r"); do { cnt++; val = div[cnt - 1]; // val=e ds = rem[cnt - 1];// ds = r qd = val / ds; // qd=e/r r = val % ds; // r=e%r // System.out.println(val+"\t"+ds+"\t"+qd+"\t"+r); if (r != 0) { rst[cnt] = val; // e div[cnt] = ds; // r qud[cnt] = qd; // e/r rem[cnt] = r; // e%r } } while (r != 0); long p1, q1, s1, t1, p2, q2, s2, t; p1 = rst[cnt - 1]; q1 = -qud[cnt - 1]; s1 = div[cnt - 1]; t = 1; for (i = (cnt - 2); i >= 0; i--) { p2 = rst[i]; q2 = -qud[i]; s2 = div[i]; if (s1 == rem[i]) { if (p1 == s2) { p1 = p2; t1 = t; t = q1; q1 = t1 + (q1 * q2); s1 = s2; }

} } if (q1 < 0) d = pi + q1; else d = q1; // fe = String.valueOf(e); fd = String.valueOf(d); // fn = String.valueOf(n); // output ="\n\nPublic Key :"+"\n Exponent Value (e) = "+fe+"\n N Value // (n) ="+fn+"\n\nPrivate Key :"+"\n Decryption Key (d) ="+fd+"\n N // Value (n) ="+fn; // System.out.println(output); if (fd.length() <= 8) { if (fd.length() == 7) { fd = fd + "1"; } else if (fd.length() == 6) { fd = fd + "13"; } else if (fd.length() == 5) { fd = fd + "847"; } } else { getSessionKey(); } return fd; } // ============================= Testing ================================// // = =// // = The following main method is just for testing this class you built.=// // = After testing,you may simply delete it. =// // =============================================================== =======// public static void main(String[] args) { SessionKey sk = new SessionKey(); System.out.println("Session Key: " + sk.getSessionKey()); } }

/****************************************************************/ /* Sender */ /* */ /****************************************************************/ import java.awt.*; import java.awt.event.*; import java.io.File; import java.io.FileInputStream; import java.util.Timer; import javax.swing.*; /** * Summary description for Sender * */ public class Sender extends JFrame { // Variables declaration private JLabel jLabel1; private JLabel jLabel2; private JLabel jLabel3; private JTextField jTextField1; private JTextField jTextField2; private JTextArea jTextArea1; private JScrollPane jScrollPane1; private JButton jButton1; private JButton jButton2; private JButton jButton3;

private JPanel contentPane; private File f; private String path; private String SecKey; private String cypherFile; private String sessionkey; private int senderid; private ImageIcon image1; public static String d_host; // End of variables declaration public Sender() { super(); initializeComponent(); senderid = Login.userid; System.out.println("User Id: " + senderid); System.out.println("Port: " + Login.port); System.out.println("Session Key: " + Login.secretkey); Destination d = new Destination(Login.port); Timer t = new Timer(); t.schedule(d, 1000); // // TODO: Add any constructor code after initializeComponent call // this.setVisible(true); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Windows Form Designer. Otherwise, retrieving design * might not work properly. Tip: If you must revise this method, please * backup this GUI file for JFrameBuilder to retrieve your design properly * in future, before revising this method. */

private void initializeComponent() { image1 = new ImageIcon("sender.jpg"); jLabel1 = new JLabel(); jLabel2 = new JLabel(); jLabel3 = new JLabel(image1); jTextField1 = new JTextField(); jTextField2 = new JTextField(); jTextArea1 = new JTextArea(); jScrollPane1 = new JScrollPane(); jButton1 = new JButton(); jButton2 = new JButton(); jButton3 = new JButton(); contentPane = (JPanel) this.getContentPane(); // // jLabel1 // jLabel1.setText("Destination"); // // jLabel2 // jLabel2.setText("Choose File"); // // jLabel3 // //jLabel3.setText("jLabel3"); // // jTextField1 // jTextField1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField1_actionPerformed(e); } }); // // jTextField2 // jTextField2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField2_actionPerformed(e); } }); // // jTextArea1

// // // jScrollPane1 // jScrollPane1.setViewportView(jTextArea1); // // jButton1 // jButton1.setText("BROWSE"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); // // jButton2 // jButton2.setText("SEND"); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); // // jButton3 // jButton3.setText("RESET"); jButton3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton3_actionPerformed(e); } }); // // contentPane // contentPane.setLayout(null); addComponent(contentPane, jLabel1, 377, 247, 82, 40); addComponent(contentPane, jLabel2, 373, 311, 90, 40); addComponent(contentPane, jLabel3, 23, 11, 578, 212); addComponent(contentPane, jTextField1, 482, 250, 115, 40); addComponent(contentPane, jTextField2, 483, 311, 113, 40); addComponent(contentPane, jScrollPane1, 12, 244, 347, 246); addComponent(contentPane, jButton1, 425, 374, 100, 40);

addComponent(contentPane, jButton2, 375, 440, 100, 40); addComponent(contentPane, jButton3, 492, 439, 100, 40); // // Sender // this.setTitle("User - "+Login.myname); this.setLocation(new Point(0, 0)); this.setSize(new Dimension(633, 525)); } /** Add Component Without a Layout Manager (Absolute Positioning) */ private void addComponent(Container container, Component c, int x, int y, int width, int height) { c.setBounds(x, y, width, height); container.add(c); } // // TODO: Add any appropriate code in the following Event Handling Methods // private void jTextField1_actionPerformed(ActionEvent e) { System.out .println("\njTextField1_actionPerformed(ActionEvent e) called."); // TODO: Add any handling code here } private void jTextField2_actionPerformed(ActionEvent e) { System.out .println("\njTextField2_actionPerformed(ActionEvent e) called."); // TODO: Add any handling code here } private void jButton1_actionPerformed(ActionEvent e) { System.out.println("\njButton1_actionPerformed(ActionEvent e) called."); // TODO: Add any handling code here JFileChooser jf = new JFileChooser(); int m = jf.showOpenDialog(null); if (m == JFileChooser.APPROVE_OPTION) {

// f1=new File(); f = jf.getSelectedFile(); // f1=jf.getSelectedFile(); path = f.getPath(); // path=f.getAbsolutePath(); try { FileInputStream fis = new FileInputStream(path); byte b[] = new byte[fis.available()]; jTextField2.setText(path); fis.read(b); String str = new String(b); jTextArea1.setText(str); fis.close(); } catch (Exception e1) { System.out.println(e1); } } } private void jButton2_actionPerformed(ActionEvent e) { System.out.println("\njButton2_actionPerformed(ActionEvent e) called."); // TODO: Add any handling code here SecKey = JOptionPane.showInputDialog(this, "Enter The Secret Key", ""); String dest = jTextField1.getText(); String msg = jTextArea1.getText(); source sou = new source(); cypherFile = sou.getMsg(msg); String ses = sou.getSessionKey(Login.myname, dest, SecKey); String[] ses_arr = ses.split(","); if (ses_arr[0].equalsIgnoreCase("key")) { int d_port = new Integer(ses_arr[1]); String sesKey = ses_arr[2]; int qb = new Integer(ses_arr[3]); String h_sess = ses_arr[4]; sou.getCypher(cypherFile, sesKey); sou.sendMsg(cypherFile, Login.myname, dest, h_sess,sesKey, d_port); } else {

System.out.println("Invalid Secret Key"); } } private void jButton3_actionPerformed(ActionEvent e) { System.out.println("\njButton3_actionPerformed(ActionEvent e) called."); // TODO: Add any handling code here } // // TODO: Add any method code to meet your needs in the following area // // ============================= Testing ================================// // = =// // = The following main method is just for testing this class you built.=// // = After testing,you may simply delete it. =// // =============================================================== =======// public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); /*try { UIManager .setLookAndFeel("com.sun.java.swing.plaf.wind ows.WindowsLookAndFeel"); } catch (Exception ex) { System.out.println("Failed loading L&F: "); System.out.println(ex); }*/ new Sender(); } // = End of Testing = }

import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.ServerSocket; import java.net.Socket; import java.sql.ResultSet; import java.sql.Statement; import java.util.TimerTask; public class TCReceiver extends TimerTask { private String soc_name; private String rec_name; private String rec_seckey; private String rec_data; private ResultSet rec_rs; private String rkey; private DataInputStream dis; private DataOutputStream dos; private ServerSocket ss; private Socket s; private String res_data; private String req_flag; public TCReceiver() { // TODO Auto-generated constructor stub } public void run() { try { System.out.println("TC Receiver..."); ss = new ServerSocket(6565);

s = ss.accept(); dis = new DataInputStream(s.getInputStream()); dos = new DataOutputStream(s.getOutputStream()); req_flag = dis.readUTF(); soc_name = dis.readUTF(); rec_name = dis.readUTF(); rec_seckey = dis.readUTF(); TrustedCenter.jTextArea1.append("\n Receiver Request: "+rec_name+"\n"); TrustedCenter.jTextArea1.append("\n-------------------------------\n"); System.out.println(soc_name+"..."+rec_name+"..."+rec_seckey); ConnectionDB cdb = new ConnectionDB(); Statement st = cdb.connectJDBC(); String query = "select * from userdetails where username='" + rec_name + "'"; System.out.println("Query.."+query); rec_rs = st.executeQuery(query); if (rec_rs.next()) { rkey = rec_rs.getString(5); System.out.println("rkey..."+rkey); } rec_rs.close(); if (rec_seckey.equalsIgnoreCase(rkey)) { System.out.println("ok..."); String query1 = "select * from transmission " + "where source_id='" + soc_name + "' and " + "dest_id='" + rec_name + "'"; System.out.println("query1..."+query1); rec_rs = st.executeQuery(query1); if (rec_rs.next()) { rec_data = rec_rs.getString(4); res_data = "value@"+rec_data; } String query2 = "delete from transmission " + "where source_id='" + soc_name + "' and " + "dest_id='" + rec_name + "'";

st.executeUpdate(query2); TrustedCenter.jTextArea1.append("\n Request Success\n"); TrustedCenter.jTextArea1.append("\n "+res_data+" \n"); TrustedCenter.jTextArea1.append("\n---------------------------\n"); } else { res_data = "novalue@novalue"; TrustedCenter.jTextArea1.append("\n Request Failed \n"); } dos.writeUTF(res_data); } catch (Exception e) { e.printStackTrace(); } } }

import java.io.*; import java.net.*; public class source { String cypherFile; public source() { System.out.println("Source..."); /* * while(true){ String dest = getDestAddress(); String seckey = * getSecKey(); cypherFile = getMsg(); String seskey = * getSessionKey(dest, seckey); getCypher(cypherFile, seskey); * sendMsg(cypherFile, seskey); } */ } public String getSessionKey(String senderid, String dest, String seckey) { String str = null; try { String hname = InetAddress.getLocalHost().getHostName(); Socket socTC = new Socket("localhost", 1111); DataOutputStream dos = new DataOutputStream(socTC.getOutputStream());

dos.writeUTF("key"); String s_id = senderid; dos.writeUTF(s_id); dos.writeUTF(dest); dos.writeUTF(seckey); DataInputStream dis = new DataInputStream(socTC.getInputStream()); str = dis.readUTF(); System.out.println("Session Key: " + str); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; } public void sendMsg(String cypherFile,String sourceName, String destName, String h_seskey,String seskey, int d_port) { try { Socket socDest = new Socket("localhost", d_port); getCypher(cypherFile, seskey); InetAddress in = InetAddress.getLocalHost(); String str = in.getHostName() + ".txt"; String cypherFileName = str; /* * FileInputStream fis = new FileInputStream(cypherFile); * DataOutputStream dos = new * DataOutputStream(socDest.getOutputStream()); String cypherMsg=""; * int c; while((c=fis.read())!=-1){ cypherMsg = cypherMsg+ (char)c; } * //byte b[] = new byte[fis.available()]; //String cypherMsg = new * String(b); InetAddress in = InetAddress.getLocalHost(); String * str = in.getHostName()+".txt"; System.out.println("Cypher * Message: "+cypherMsg); fis.close(); String cypherFileName = str; * //seskey = seskey.trim(); //cypherMsg = cypherMsg.trim(); * dos.writeBytes(cypherFileName); dos.writeBytes(seskey); * dos.writeBytes(cypherMsg); dos.flush(); */ // DataInputStream dis = new // DataInputStream(socDest.getInputStream()); FileInputStream fis = new FileInputStream(cypherFile);

byte[] buffer = new byte[fis.available()]; fis.read(buffer); ObjectOutputStream oos = new ObjectOutputStream(socDest .getOutputStream()); oos.writeObject(sourceName); oos.writeObject(destName); oos.writeObject(cypherFileName); oos.writeObject(h_seskey); oos.writeObject(buffer); } catch (Exception e) { e.printStackTrace(); } } public void getCypher(String cypherFile, String seskey) { Encryption en = new Encryption(cypherFile, seskey); } public String getMsg(String m) { String str = null; try { // System.out.println("Enter The Message: "); // DataInputStream dis = new DataInputStream(System.in); String msg = m; // dis.readLine(); File f = new File("Message.txt"); if (f.isFile()) { f.delete(); } FileOutputStream fos = new FileOutputStream("Message.txt"); fos.write(msg.getBytes()); // InetAddress in = InetAddress.getLocalHost(); // str = in.getHostName(); str = "Encrypt.txt"; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; } public String getDestAddress() { String str = null; System.out.println("Enter the Dest Address: "); try {

DataInputStream dis = new DataInputStream(System.in); str = dis.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; } public String getSecKey() { String str = null; System.out.println("Enter the Secret Key: "); try { DataInputStream dis = new DataInputStream(System.in); str = dis.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return str; } public static void main(String args[]) { // new source(); } }

You might also like