João Rocha
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # SDIS Project SDIS Project for group T4G24. ## Clean-up Clears the `src/build` folder and all the storage. example: `./cleanup.sh` ## Compiling To compile the project: example: `./compile.sh` ## Running #### Server To start the server: `./server.sh <port> <address>` example: `./server.sh 5002 localhost` #### Peer `./peer.sh <peer_id> <peer_ap> <port> <central_server_address> <peer_pass>` example: `./peer.sh 1 1 5002 localhost 12345` #### Client `./test.sh <peer_id> <sub_protocol> [<file_path>]` example: `./test.sh 1 BACKUP test.txt` example: `./test.sh 1 STATE` ### Testing 1) Open the folder scripts 2) Clean up the class files and storage: `./cleanup.sh` 3) Compile the project: `./compile.sh` 4) Start the server: `./server.sh 5002 localhost` 5) Open another terminal to start the peer: `./peer.sh 1 1 5002 localhost 12345` 6) Open another terminal to start another peer: `./peer.sh 2 1 5002 localhost 123`` 7) Open yet another terminal to start the client using all subprotocols, starting with backup, following with state, then with restore and finally with delete to check them all: `./test.sh 1 BACKUP test.txt` -> `./test.sh 1 STATE` -> `./test.sh 1 RESTORE test.txt` -> `./test.sh 1 DELETE test.txt` Group members: 1. Bruno Vale Fernandes - (up200707284@fe.up.pt) 2. Diogo Gomes - (up201806572@fe.up.pt) 3. Inês Marques - (up201605542@fe.up.pt) 4. João Rocha - (up201708566@fe.up.pt) ---------------- # Report - Proj 2 -T4G24 ## Overview We decided to go with a centralized server approach. The implemention uses JSSE, more specifically the SSLEngine with *AsynchronousSocketChannel* to secure the communication between the Clients and the Server as well as allowing for non-blocking operations. Most of the code used to handle the protocols to handle the files (chunks) was taken from the first project. It also features a simple authentication system to avoid clients accessing unauthorized files. The files storage and the authentication systems both are serializable, allowing the server to "save" it's back-ups in the case of a crash. ## Protocols As said above, the protocol is heavily based on the first project. To Backup a file the Client must sends the chunks from a file to the Server and it will store on a folder (similar to the `putchunk` protocol in the first project). To restore/retrieve a chunk a Client must ask for it to the Server (sending a message with the `getchunk` protocol). If the authentication goes correctly it should respond with a `chunk` message informing it was successful. The code for each protocol can be found under the `Protocols/` folder. We used TCP with JSSE (SSLEngine, TLS context) for communication between the server and the clients. To avoid users accessing files from other users the server uses a basic authentication (userID + password). It stores the password using the same `sha256` hashing algorithm from the project 1. This authentication system is also *Serializable*. The file chunks are *Serialized*, Allowing for the server to recover from crashes without losing data. ## Concurrency design We used multithreading to maximize the likelihood of competition between processes and, as a result, to shorten the time required for peers to get the desired files. This strategy entails running multiple processes in parallel to reduce overall execution time. ## JSSE The *JSSE* services are utilized in this project when sending messages between the Client and the Server. In order to provide a greater level of security in data transmissions the TCP connections are established througth the employment of the *SSLEngine*. Almost all configurations regarding *SSLEngine* can be found inside the `SSLEngine/` folder. All the setup, wrapping/unwrapping, handshaking and read/write functions can be found there. The handshake phase begins after the SSLEngine has been formed and the connection has been properly established. There's also a *boolean/flag* called `debugmode` that, when `true`, allow to visualize the steps it takes to handshake, wrap, unwrap, send, etc. It needs to be manually changed in the code. This is an example of the server's output when running with `debugmode` as true during a `BACKUP` protocol call: ``` lang-text Received -- PUTCHUNK 1 0ffcb4fb332f4831dab823dbd94936b27f00ac673f4103fbecd7ea1d6a521b51 12345 4 OK WRITTEN 111 bytes Sent -- STORED 1 0ffcb4fb332f4831dab823dbd94936b27f00ac673f4103fbecd7ea1d6a521b51 12345 4 System started handshake NEED_UNWRAP res: BUFFER_UNDERFLOW res: OK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_WRAP OK Handshaking / re-handshaking in process NEED_UNWRAP res: BUFFER_UNDERFLOW res: OK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK Handshaking / re-handshaking in process NEED_TASK res: OK Handshaking / re-handshaking in process` ``` The passwords for the *keys* and the *truststore* are already present in the *scripts* used to test the project. They were generated beforehand using the guide in the Lab5. We did it that way because entering a wrong password would only cause the Server or Client to crash, showing the error that the password to the *keystore/truststore* is wrong. The only password required is needed to access the files "inside" the server. It should be specified when initiating a Peer. They are near "hard-coded" in the `Authentication/Authentication.java` file. We are using these 3 cypher-suites for the *SSLEngine* configuration: `TLS_ECDHE_RSA_WITH_NULL_SHA`,`TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256`,`TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384`. From our limited search these were 3 of the recommended cipher-suites from all the available. ## Fault-tolerance Both the storage and the user authentication systems are serializable. This allows the server to recover from any crash without losing data. The servers also are stateless: they act only given the data received in the messages. We simply need to `load()` before and `save()` after each operation. ## Notes In the last pratical class we told the professor we were trying to use *Chord* with *SSLSockets*. However assembling the *Chord* protocol proved too difficult and we changed to a centralized approach. ## Bibliography https://stackoverflow.com/questions/18787419/ssl-socket-connection (SSLSockets / certicates example) https://docs.oracle.com/en/java/javase/11/docs/api/java.base/javax/net/ssl/SSLEngine.html#:~:text=public%20abstract%20class%20SSLEngine%20extends,Integrity%20Protection. (SSLEngine documentation) https://docs.oracle.com/en/java/javase/16/security/java-secure-socket-extension-jsse-reference-guide.html#GUID-3D26386B-BC7A-41BB-AC70-80E6CD147D6F (generation keystores and truststore) https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLEngineResult.HandshakeStatus.html (SSLEngine status) https://docs.oracle.com/javase/10/security/sample-code-illustrating-use-sslengine.htm#JSSEC-GUID-EDE915F0-427B-48C7-918F-23C44384B862 (SSLEngine config and usage example by Oracle) https://ciphersuite.info/cs/TLS_RSA_WITH_AES_256_CBC_SHA/ (documentation about Cipher_suits) https://www.thesslstore.com/blog/cipher-suites-algorithms-security-settings/ (blog post explaining most TLS cyphers available) Group members: 1. Bruno Vale Fernandes - (up200707284@fe.up.pt) 2. Diogo Gomes - (up201806572@fe.up.pt) 3. Inês Marques - (up201605542@fe.up.pt) 4. João Rocha - (up201708566@fe.up.pt)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully