Skip to content

PanagiotisDrakatos/Universal-Encryption-Channel

Repository files navigation

Universal-Encryption-Channel

Universal Encryption Channel aims at providing an easy-to-use Cross Platform API which allow an encrypted communication over sockets across server-client program. It provides the opportunity to client from Windows-Universal-Application to interact with a server written in pure java and send and receive encrypted messages with the `DHE-RSA` key exchange

Why Use this repo?

There are plenty reasons to use this library. The most important factor is the supply socket compatibility between the 2 different platforms through a secure channel with encryption. Very soon more platforms will be added like a client code written in python script and an android client application, however the last one is very widespread and there are many open source projects with Security-encryptions for android these days so it will not be so innovative.

Lets see and analyzing what are the useful things to use this repository and you might not think.

  1. You can use a server which follows the RFC1459 protocol and allows many common IRC clients to connect simultaneously and securely and interact with each other.

  2. You may already have a server written in java which control with sockets android clients and you may want with some way to add more clients that supported in windows applications just like Universal Windows Applications

  3. Security - if your client apps can connect to Server through sockets so anyone else can steal if you're not careful about sensitive data. Data can also be sniffed if you're not encrypting, and modified if you're not at least signing data. That is one of the common things that many apps does not provide to clients.

Diffie-Hellman Key Exchange

This photo is made in Microsoft Visio 2013 and it describes the key exchanges over the Server-Client program(for better explanation with code check DHkeyExchange). It describes exactly with details how both applications they encrypt and decrypt the message and share the public Random number until they will get the Diffie-hellman Key exchange and also how they try to ensure the model designed to guide policies for information security within an organization,the well known as CIA(Confidentiality,Integrity,Availability)

Confidentiality

is roughly equivalent to privacy. Measures undertaken to ensure confidentiality are designed to prevent sensitive information from reaching the wrong people, while making sure that the right people can in fact get it: Access must be restricted to those authorized to view the data in question. It is common, as well, for data to be categorized according to the amount and type of damage that could be done should it fall into unintended hands.

Integrity

Integrity involves maintaining the consistency, accuracy, and trustworthiness of data over its entire life cycle. Data must not be changed in transit, and steps must be taken to ensure that data cannot be altered by unauthorized people (for example, in a breach of confidentiality). These measures include file permissions and user access controls. Version control maybe used to prevent erroneous changes or accidental deletion by authorized users becoming a problem

Availability

Availability is best ensured by rigorously maintaining all hardware, performing hardware repairs immediately when needed and maintaining a correctly functioning operating system environment that is free of software conflicts. It’s also important to keep current with all necessary system upgrades.

alt tag

How do I use this library?

Java requirements with Gradle

For now you get to build this yourself. Eventually, when it has enough testing, I might consider publishing it to some maven repository.

  1. Install local maven (seriously, if you don't do this, nothing else will work)
  2. Clone this repo
  3. Install the JDK and Netbeans Netbeans & JDK
  4. Make sure Netbeans has Gradle Plugin else you can download from here

If you are going to use this library with Java then go to the 'java' sub-directory and run 'gradlew install'.

I would also recommend running 'gradlew test'. This will make sure you are properly set up and will copy your test files which I recommend reading.

Now everything should be build and installed into your local maven.

Now go to your build.gradle file (or equivalent) and make sure you add:

apply plugin: 'maven' 

Then go to your repositories and add:

mavenLocal()

Then go to dependencies and add in:

dependencies {
    // TODO: Add dependencies here ...
    // You can read more about how to add dependency here:
    //   http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
    testCompile group: 'junit', name: 'junit', version: '4.10'
    
    compile 'commons-codec:commons-codec:1.10'//commons-codec is an implementation of the Base64 encoder and Base64 decoder
    compile 'org.bouncycastle:bcprov-jdk16:1.46'//The Bouncy Castle APIs used for cryptography algorithms  for Java and C# 
    //just like  PKCS #7
    compile 'org.json:json:20151123'//store information in an organized, easy-to-access manner
    compile 'com.google.code.gson:gson:2.2.2'// serialize and deserialize Java json objects
}

Properties File

Navigate to properties file Properties and you will see all Properties which the application uses also you can put whatever you want for the message which you will receive it from the server.

package Properties;

public class Properties {

    //socket properties
    public static final int ConnectionPort = 5555;
    public static final int MaxConnections = 100;
    public static final int timeout = 10 * 1000;

    public static final String END_PROTOCOL = "EndSession";
    //Put your message which you want taken from Server
   public static final String PlainText_UTF8 = "Hello Client Send me again Enrypted Message";
   }

Install the unlimited strength policy files

The correct solution to run the Java server is that you must take consider to install unlimited strength policy files. While this is probably the right solution for your development, it quickly becomes a major hassle (if not a roadblock) to have non-technical users install the files on every computer. There is no way to distribute the files with your program. You must be installed in the JRE directory (which may even be read-only due to permissions) to run this application also you will have the opportunity to set your owns key size because for testing purposes the application does not provide big keys size.

Universal Windows app requirements

Client: Windows 10

Server: Windows Server 2016 Technical Preview

Phone: Windows 10

Network capabilities

SecureUWPChannel sample requires that network capabilities be set in the Package.appxmanifest file to allow the app to access the network at runtime. These capabilities can be set in the app manifest using Microsoft Visual Studio. For more information on network capabilities, see How to set network capabilities

Build the sample

  1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
  2. Start Microsoft Visual Studio 2015 and select File > Open > Project/Solution.
  3. Starting in the folder where you unzipped the sample, go to the SecureUWPChannel subfolder,and after this yoy are ready to double-click the Visual Studio 2015 Solution (.sln) file.
  4. Press Ctrl+Shift+B, or select Build > Build Solution.

Run the sample

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

Deploying the sample

  • Select Build > Deploy Solution.

Deploying and running the sample on a Windows 10 Desktop

  • To debug the sample and then run it, press F5 or use Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.

Configuration File

Navigate to SampleConfiguration and change Host to localhost if you are going to run the project locally or put the remote local ip which the server machine with the java code has obtain from the router (For example 192.168.1.2).Also you can put whatever you want for the message which you will send it to the server

//socket properties
        public static  String ConnectionPort = "5555";
        public static  int MaxConnections = 100;
        public static  int timeout = 4000;
        public static String Host = "localhost";
        
        //Put your Message to send to server
        public static String Messages = "Hello Server :D";

Deploying and running the sample on a Windows 10 Phone

This is not available on Windows Phone. basically this api is not tested in windows phone yet very soon i will publish and new version which it will support windows 10 phones stay tuned in the repository and don't forget to contribute with a simple click Fork

Windows 10 IoT Core

This api Platform have not been validated on Windows IoT Core very soon i will publish and new version which it will support Raspberry Pi 2 stay tuned in the repository

For more information about Windows 10 IoT Core, see online documentation here

Please download, build, deploy, and contribute!! For more information and descriptions about this sample you should feel free to create an issue and ask question and I will reply you as soon as possible and don't forget to Fork the repository and upload whatever you want that it will be helpful for this project.

About

Cross-platform socket API for Windows Universall Apps and Java

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages