GithubHelp home page GithubHelp logo

gaphil / vpn Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 8.99 MB

Secure TCP port forwarding application; using AES session key, performing secure handshake with X.509 certificates.

Java 95.48% Shell 4.52%
encryption symmetric-key-cryptography public-key-cryptography certificates

vpn's Introduction

vpn

Secure TCP port forwarding application; using AES session key, performing secure handshake with X.509 certificates.

Getting started

  • clone with SSH: $ git clone [email protected]:GaPhil/vpn.git
    (or clone with HTTPS: $ git clone https://github.com/GaPhil/vpn.git)
  • $ cd vpn

Create certificates

In order for the handshake to work, three certificates are needed; one for the CA as well as one for the server and client (ca.pem, server.pem and client.pem):

  • create three certificates: $ sh create_certs.sh <email>
  • verify certificates:
    • compile: $ javac src/crypto_utils/verifyCertificate
    • run: $ java src/crypto_utils/verifyCertificate ca.pem server.pem
    • run: $ java src/crypto_utils/verifyCertificate ca.pem client.pem

Start the server:

  • compile: $ javac $(find ./src/* | grep .java) && cd src
  • run:
$ java ForwardServer --handshakeport=2206 --usercert=../server.pem \
       --cacert=../ca.pem --key=../server-private.der

Start the client:

  • compile: $ javac $(find ./src/* | grep .java) && cd src
  • run:
$ java ForwardClient --handshakehost=localhost --handshakeport=2206 \
       --targethost=localhost --targetport=6789 \
       --usercert=../client.pem --cacert=../ca.pem --key=../client-private.der

Handshake Protocol

  • Client and server authenticate each other
    • X.509 certificate exchange
  • Client requests forwarding to a target server
  • Server creates symmetric session key for session encryption
    • Session key is securely exchanged using public-key cryptography
  • Server creates server port; a new TCP endpoint to which the client connects
    • Communication over this connection is encrypted using symmetric encryption
  CLIENT                                                                  SERVER
    |                                                                       |
 1  |                      ClientHello, Certificate                         |
    |------>----------->----------->----------->----------->----------->----|
    |                                                                       |
 2  |                      ServerHello, Certificate                         |
    |------<-----------<-----------<-----------<-----------<-----------<----|
    |                                                                       |
 3  |                    Forward, TargetHost, TargetPort                    |
    |------>----------->----------->----------->----------->----------->----|
    |                                                                       |
 4  |        Session, SessionKey, SessionIV, ServerHost, ServerPort         |
    |------<-----------<-----------<-----------<-----------<-----------<----|
    |                                                                       |
  CLIENT                                                                  SERVER

Demo

VPN

Key Specifications

Asymmetric Keys

  • Server key pair: 2048-bit RSA key, created with openssl
  • Client key pair: 2048-bit RSA key, created with openssl
  • CA key pair: 2048-bit RSA key, created with openssl

Symmetric Keys

  • Session key: AES 128-bit key, used in CTR mode, created with SunJCE Provider

vpn's People

Contributors

gaphil avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.