Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transport Layer Security (TLS) added. #74

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
1221536
Added docker folder.
tulioalberton Aug 13, 2018
04582e7
Added docker folder.
tulioalberton Aug 13, 2018
053454e
Added Replica to Replica port into hosts.config.
tulioalberton Aug 14, 2018
16f8b58
Minimal changes.
tulioalberton Aug 17, 2018
67af6b6
Added ECDSA sign mode.
tulioalberton Aug 23, 2018
2593ff0
ECDSA added.
tulioalberton Aug 23, 2018
53110e3
Added into system.config option to enable SSL/TLS or no.
tulioalberton Aug 24, 2018
6fcd52f
SSL/TLS Specific Ciphers enabled, hard coded.
tulioalberton Aug 30, 2018
ebb1740
Before Merge with João's code.
tulioalberton Oct 11, 2018
0ac7013
Merged with providers done!
tulioalberton Oct 11, 2018
6894c32
Full merged with João's code!
tulioalberton Oct 15, 2018
5e0139f
Docker improved.
tulioalberton Oct 16, 2018
0e3012c
Minimal changes:
tulioalberton Oct 17, 2018
4ddc0d2
Minimal changes
tulioalberton Oct 17, 2018
c051c6c
Minimal changes.
tulioalberton Oct 17, 2018
7105162
Switched useMac and useSignature variables to boolean.
tulioalberton Oct 18, 2018
17a887f
Config changed..
tulioalberton Oct 18, 2018
07753e7
Before remove MAC, KeyExchange, etc... for SSL/TLS classes.
tulioalberton Oct 19, 2018
5d6e47f
Added bin dir.
tulioalberton Oct 20, 2018
5343f7a
Before removing Diffie-Hellman from SSL/TLS classes.
tulioalberton Oct 21, 2018
c6f4b45
SSL/TLS receive thread problem solved.
tulioalberton Oct 22, 2018
cc9c88f
Added AcceptorSSLTLS and MessagehandlerSSlTLS classes.
tulioalberton Oct 22, 2018
e8252da
Before add KeySectet to SSL/TLS connections (SERVER).
tulioalberton Oct 22, 2018
be53205
SSL/TLS seems working with AcceptorSSLTLS class.
tulioalberton Oct 22, 2018
55a1cbd
Defined only RSA into the setEnabledCiphers.
tulioalberton Oct 23, 2018
37a3c37
Added supported ciphers from config file.
tulioalberton Oct 23, 2018
61ebe1f
Added RSA 1024 and 2048 into config/keysSSL_TLS.
tulioalberton Oct 23, 2018
d09cf12
Renamed keys dir to keysRSA dir.
tulioalberton Oct 23, 2018
47fb9ca
Removed MAC Vector from AcceptorSSLTLS, MessageHandlerSSLTLS and LCMa…
tulioalberton Oct 23, 2018
f00ba14
Returned the MAC vector, it is necessary for leader changes.
tulioalberton Oct 23, 2018
6c3c255
Added EC KeyPar 384, and test OK with: TLS_ECDHE_ECDSA_WITH_NULL_SHA
tulioalberton Oct 23, 2018
5907ebb
Re-Generate the sectetKey if it is null.
tulioalberton Oct 23, 2018
2fbe2f2
hosts.config and system.config changes.
tulioalberton Oct 24, 2018
2556205
Updated Netty library to 4.1.30.Final.
tulioalberton Oct 24, 2018
f613dd4
Updated Netty to netty-all-4.1.30.Final.jar.
tulioalberton Oct 24, 2018
70f3e00
Several modifications at: NettyClientServerCommunicationSystemClientS…
tulioalberton Oct 25, 2018
e0088a0
Fallback to original NettyClientServerCommunicationSystemClientSide.
tulioalberton Oct 25, 2018
13ea227
Removed redundant code of NettyClientServerCommunicationSystemClientS…
tulioalberton Oct 26, 2018
0ecfce2
Changing Acceptor to sign messages before send.
tulioalberton Oct 26, 2018
e830656
Signature before send accept message included.
tulioalberton Oct 29, 2018
1376c09
Switched to SunEC.
tulioalberton Oct 29, 2018
4f99ed5
Changed jar lib order.
tulioalberton Oct 29, 2018
89d772a
Removed lib jce-jdk13-160.jar
tulioalberton Oct 29, 2018
c929d01
Added 256, 384 521 keys size to ECDSA with BouncyCastle provider.
tulioalberton Oct 30, 2018
c00e550
Removed not necessary default keys file.
tulioalberton Oct 30, 2018
33f7d0a
Added secp256r1 (23), secp384r1 (24), secp521r1 (25) as default to Su…
tulioalberton Oct 30, 2018
a7ddef7
Before create branch and start Tree Overlay Dissemination.
tulioalberton Oct 30, 2018
84adfc8
Added new file.
tulioalberton Oct 30, 2018
0a89397
Improved logger for AcceptorSSLTLS class.
tulioalberton Nov 1, 2018
6513d45
BlockingQueue added to process Signatures on AcceptorSSL_TLS
tulioalberton Nov 2, 2018
4d2fa57
Blocking Queue into Acceptor SSL TLS.
tulioalberton Nov 2, 2018
1ca87e9
Advancing Signature of ACCEPT message into PrososePhase.
tulioalberton Nov 3, 2018
fa43b04
Advancing Sign Acceptor message into ComputeWrite (if hasProof...)
tulioalberton Nov 3, 2018
9b98a18
In memory PrivateKey. InsertProof with specific thread.
tulioalberton Nov 3, 2018
4e28eac
Replica PrivateKey and PublicKey into Memory.
tulioalberton Nov 4, 2018
475c38a
BossThread increased to 8 and PublicKey for each Controller in View.
tulioalberton Nov 4, 2018
ac83f36
Shuffling targets before send message.
tulioalberton Nov 5, 2018
5076ccb
Converting to from int[] to Integer[] to use Collections.Shuffle and …
tulioalberton Nov 5, 2018
47aa13f
Before Save Batch to disk.
tulioalberton Nov 5, 2018
3c86789
Persisting values for each proposed consensus.
tulioalberton Nov 5, 2018
4e50dc1
Included option to enable/disable persistence at system.config and st…
tulioalberton Nov 6, 2018
8ff0da1
Storing Batch and proofs into a file, batch file is done at consensus…
tulioalberton Nov 6, 2018
1950c4f
RandomAccessFile to save batch and proof.
tulioalberton Nov 7, 2018
8225baf
Added SynchronizerSSLTLS to deal with crash/recovery.
tulioalberton Nov 8, 2018
4328271
Waiting to save batch at disk to dispatch Accept message.
tulioalberton Nov 8, 2018
99dcf3c
Switching client <-> server communication.
tulioalberton Nov 8, 2018
3d070a4
Modified NettyClientServerCommunicationSystemServerSide, Modified the…
tulioalberton Nov 8, 2018
8258a16
Modified thread which deal with ClientSession.
tulioalberton Nov 8, 2018
09cb7bc
Removed else if (sm.getSequence() >= 0 && sm.getSequence() <= 5) from…
tulioalberton Nov 13, 2018
a28660b
NettyClientServerCommunicationSystemClientSide and NettyClientServerC…
tulioalberton Nov 20, 2018
d331ee1
ReplyManager added to work with the number of available processors.
tulioalberton Nov 21, 2018
3d541c6
Fixed vulnerability that would cause the system to block if a client …
tulioalberton Nov 23, 2018
2fd0697
Added batch average size at ThroughputLatencyServer.
tulioalberton Mar 13, 2019
2ae2bdb
Added macVector option to Acceptor when not using TLS. Removed unuse…
tulioalberton Mar 14, 2019
ab5c829
Minimal changes.
tulioalberton Mar 20, 2019
bc61482
Initial commit, removed all files and copy BFT-SMaRt from João Branch.
tulioalberton Mar 21, 2019
e8a0318
Branch files from BFT-SMaRt with TLS included
tulioalberton Mar 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .attach_pid13921
Empty file.
14 changes: 14 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/bcprov-jdk15on-160.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/core-0.1.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/logback-classic-1.2.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/logback-core-1.2.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.7.25.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-8-oracle"/>
<classpathentry kind="lib" path="lib/bcpkix-jdk15on-160.jar"/>
<classpathentry kind="lib" path="lib/netty-all-4.1.34.Final.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BFT_SMaRt_TLS</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Byzantine Fault-Tolerant (BFT) State Machine Replication (SMaRt) v1.2

This is a Byzantine fault-tolerant state machine replication project named BFT-SMaRt, a Java open source library maintained by the LaSIGE research unit at the University of Lisbon.

This package contains the source code (src/), jar file (bin/BFT-SMaRt.jar), dependencies (lib/), documentation (doc/), running scripts (runscripts/), and configuration files (config/) for version 1.2 of the project.
BFT-SMaRt requires the Java Runtime Environment version 1.8 or later.

## Quick start

To run any demonstration you first need to configure BFT-SMaRt to define the protocol behavior and the location of each replica.

The servers must be specified in the configuration file (see `config/hosts.config`):

```
#server id, address and port (the ids from 0 to n-1 are the service replicas)
0 127.0.0.1 11000 11001
1 127.0.0.1 11010 11011
2 127.0.0.1 11020 11021
3 127.0.0.1 11030 11031
```

**Important tip #1:** Always provide IP addresses instead of hostnames. If a machine running a replica is not correctly configured, BFT-SMaRt may fail to bind to the appropriate IP address and use the loopback address instead (127.0.0.1). This phenomenom may prevent clients and/or replicas from successfully establishing a connection among them.

**Important tip #2:** Clients requests should not be issued before all replicas have been properly initialized. Replicas are ready to process client requests when each one outputs `-- Ready to process operations` in the console.

The system configurations also have to be specified (see`config/system.config`). Most of the parameters are self explanatory.

**Important tip #3:** When using the library in real systems, always make sure to set `system.communication.defaultkeys` to `false` and `system.communication.useSignatures` to `1`. Also make sure that only the `config/keys` directory only has the private key for the repective replica/client.

You can run the counter demonstration by executing the following commands, from within the main directory across four different consoles (4 replicas, to tolerate 1 fault):

```
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 0
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 1
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 2
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 3
```

**Important tip #4:** If you are getting timeout messages, it is possible that the application you are running takes too long to process the requests or the network delay is too high and PROPOSE messages from the leader does not arrive in time, so replicas may start the leader change protocol. To prevent that, try to increase the `system.totalordermulticast.timeout` parameter in 'config/system.config'.

**Important tip #5:** Never forget to delete the `config/currentView` file after you modify `config/hosts.config` or `config/system.config`. If `config/currentView` exists, BFT-SMaRt always fetches the group configuration from this file first. Otherwise, BFT-SMaRt fetches information from the other files and creates `config/currentView` from scratch. Note that `config/currentView` only stores information related to the group of replicas. You do not need to delete this file if, for instance, you want to enable the debugger or change the value of the request timeout.

Once all replicas are ready, the client can be launched as follows:

```
./runscripts/smartrun.sh bftsmart.demo.counter.CounterClient 1001 <increment> [<number of operations>]
```

If `<increment>` equals 0 the request will be read-only. Default `<number of operations>` equals 1000.

**Important tip #6:** always make sure that each client uses a unique ID. Otherwise, clients may not be able to complete their operations.

## State transfer protocol(s)

BFT-SMaRt offers two state transfer protocols. The first is a basic protocol that can be used by extending the classes `bftsmart.tom.server.defaultservices.DefaultRecoverable` and `bftsmart.tom.server.defaultservices.DefaultSingleRecoverable`. Thee classes logs requests into memory and periodically takes snapshots of the application state.

The second, more advanced protocol can be used by extending the class
`bftsmart.tom.server.defaultservices.durability.DurabilityCoordinator`. This protocol stores its logs to disk. To mitigate the latency of writing to disk, such tasks is done in batches and in parallel with the requests' execution. Additionally, the snapshots are taken at different points of the execution in different replicas.

**Important tip #7:** We recommend developers to use `bftsmart.tom.server.defaultservices.DefaultRecoverable`, since it is the most stable of the three classes.

**Important tip #8:** regardless of the chosen protocol, developers must avoid using Java API objects like `HashSet` or `HashMap`, and use `TreeSet` or `TreeMap` instead. This is because serialization of Hash* objects is not deterministic, i.e, it generates different byte arrays for equal objects. This will lead to problems after more than `f` replicas used the state transfer protocol to recover from failures.

## Group reconfiguration

The library also implements a reconfiguration protocol that can be used to add/remove replicas from the initial group. You can add/remove replicas on-the-fly by executing the following commands:

```
./runscripts/smartrun.sh bftsmart.reconfiguration.util.DefaultVMServices <smart id> <ip address> <port> (to add a replica to the group)
./runscripts/smartrun.sh bftsmart.reconfiguration.util.DefaultVMServices <smart id> (to remove a replica from the group)
```

**Important tip #9:** everytime you use the reconfiguration protocol, you must make sure that all replicas and the host where you invoke the above commands have the latest `config/currentView` file. The current implementation of BFT-SMaRt does not provide any mechanism to distribute this file, so you will need to distribute it on your own (e.g., using the `scp` command). You also need to make sure that any client that starts executing can read from the latest `config/currentView` file.

## BFT-SMaRt under crash faults

You can run BFT-SMaRt in crash-faults only mode by setting the `system.bft` parameter in the configuration file to `false`. This mode requires less replicas to execute, but will not withstand full Byzantine behavior from compromised replicas.

## Generating public/private key pairs

If you need to generate public/private keys for more replicas or clients, you can use the following command:

```
./runscripts/smartrun.sh bftsmart.tom.util.RSAKeyPairGenerator <id> <key size>
```

Keys are stored in the `config/keys` folder. The command above creates key pairs both for clients and replicas. Alternatively, you can set the `system.communication.defaultkeys` to `true` in the `config/system.config` file to forces all processes to use the same public/private keys pair and secret key. This is useful when deploying experiments and benchmarks, because it enables the programmer to avoid generating keys for all principals involved in the system. However, this must not be used in a real deployments.

## Compiling

Make sure that you have Ant installed and simply type `ant` in the main directory. The jar file is stored in the `bin/` directory.

## Additional information and publications

If you are interested in learning more about BFT-SMaRt, you can read:

- The paper about its state machine protocol published in [EDCC'12](http://www.di.fc.ul.pt/~bessani/publications/edcc12-modsmart.pdf):
- The paper about its advanced state transfer protocol published in [Usenix'13](http://www.di.fc.ul.pt/~bessani/publications/usenix13-dsmr.pdf):
- The tool description published in [DSN'14](http://www.di.fc.ul.pt/~bessani/publications/dsn14-bftsmart.pdf):

***Feel free to contact us if you have any questions!***
99 changes: 0 additions & 99 deletions README.txt

This file was deleted.

Binary file removed bin/BFT-SMaRt.jar
Binary file not shown.
21 changes: 21 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
First changes (commit), for porting to TLS.

+ Altered system.config, added TLS configurations.
+ Added directory with specific keys.
+ Updated Netty from 4.1.30 to 4.1.34.

Second changes
+ Changed communication system.
+ Changed ServerConnection
+ Changed Configuration and TOMConfiguration.
+ Added BouncyCastle provider at TOMUtil.init().
+ Tested changes, seems working.
TODO: Test failure scenarios.


Third changes
+ Remove hmac and mac from code and system.config
+ Decreased creation time among threads (ThroughputLatencyClient)

TODO:

20 changes: 11 additions & 9 deletions config/hosts.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@
# The ports defined here are the ports used by clients to communicate
# with the replicas. Additional connections are opened by replicas to
# communicate with each other. This additional connection is opened in the
# next port defined here. For an example, consider the line "0 127.0.0.1 11000".
# next port defined here. For an example, consider the line "0 127.0.0.1 11000 11001".
# That means that clients will open a communication channel to replica 0 in
# IP 127.0.0.1 and port 11000. On startup, replicas with id different than 0
# will open a communication channel to replica 0 in port 11001.
# The same holds for replicas 1, 2, 3 ... N.

#server id, address and port (the ids from 0 to n-1 are the service replicas)
0 127.0.0.1 11000
1 127.0.0.1 11010
2 127.0.0.1 11020
3 127.0.0.1 11030
4 127.0.0.1 11040
5 127.0.0.1 11050
6 127.0.0.1 11060
7 127.0.0.1 11070
0 127.0.0.1 11000 11001
1 127.0.0.1 11010 11011
2 127.0.0.1 11020 11021
3 127.0.0.1 11030 11031

#0 192.168.2.29 11000 11001
#1 192.168.2.30 11000 11001
#2 192.168.2.31 11000 11001
#3 192.168.2.32 11000 11001

7001 127.0.0.1 11100
Loading