zSORATH
    • 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
    # Network Security Assignment 1 ## Exploiting Textbook RSA Signatures (Task 2) #### Pernille Pallesen 201909457 The task: *You are given the source code of a simple website that a professor has created to automate annoying tasks such as grading. It also distributes quotes to particularly good students. To prevent students from coming up with their own grade, the website authenticates them with RSA signatures. Since the professor is quite lazy and does not want to be bothered by students, he/she provides another API to sign any paperwork except grades.* *Your task is to obtain a signed message stating you got a 12, so that you can receive a quote. To this end, you can use the given API and the malleability properties of plain, textbook RSA.* The solution is written in python and can be found in the `topgradestudent.py` file. I used Python version 3.10.7. ### What is Textbook RSA? RSA (Rivest-Shamir-Adleman) is an asymmetric encryption algorithm, which uses prime factorization as a one-way function. This means that it is easy to encrypt, but difficult to decrypt, since prime factorization is using the fact that every positive integer can be written as composite primes, and this is very difficult to compute for large numbers. This is useful, as you can quickly encrypt a message while making it difficult for others to decrypt it without the private key. When a message is sent it will be encrypted with the receiver's public key, and then the receiver will decrypt it with their private key. ### RSA Signatures RSA is also used for signing, which means that when a message is sent, it will be signed with the senders private key, and the receiver can then verify it by using the sender's public key. ### Why is Textbook RSA bad? Textbook RSA has some flaws, and these can be quite undesirable. For example the fact that it's deterministic, or that you can alter encrypted messages' plaintext. Having a deterministic function can have it's benefits and it's drawbacks. These drawbacks can make it prone to attacks as well as making it semantically insecure, as part of the plaintext can be extracted from the ciphertext. Another aspect of Textbook RSA was introduced by David Chaum as a means to sign a message without having the signer read the message they are signing. Chaum called it Blind Signatures. One of it's first uses was both electronic voting systems and digital cash schemes. This method is what allowed me to have a message signed by the server without exposing the plaintext, which I achieved by blinding the message before sending it to be signed. ### Implementation To solve the task, I want to get a signature for a message stating that I got a 12, so that I can recieve a quote. From the given API in the assignment, I can see that I can use the path `'/sign_random_document_for_students/'` to send a message, and then recieve the signature for the message. However, this does not work if the message includes the words 'grade', '12', 'twelve' or 'tolv', and since I need to get a message signed that includes '12', I can not just send it this way. Therefore, as mentioned earlier, I need to use blind signing. These are the steps I used for blind signing: * Pick the message you want to send. * Blind the message by multiplying it by a random factor r^e mod n. Here, e is the public key and n is the modulus. The random factor r needs to be co-prime with n and 0<r<n. * Send the blinded message and recieve a blinded signature for the message. * Unblind the signature by multiplying it with the inverse of r mod n. * Now you have the signature for the original message, and you can now create a cookie with the message and the signature. * Send the cookie to the `'/quote/'` path and recieve a quote, meaning you now got a signed message stating that you got a 12. These steps are also clarified as comments in the script `topgradestudent.py`. ### How to use the Implementation In the script I implemented the option to pick the local server (http://localhost:5000/) or the remote server (https://cbc-rsa.netsec22.dk:8001/). This option can be changed by setting LOCAL to True (to use local) or False (to use remote) in the script. ``` LOCAL = True OR LOCAL = False ``` If the local server is used, it needs to be running first. For this i will refer to the README in the github for this assignment: https://github.com/dfaranha/netsec-e22-assignments/tree/main/crypto/rsa-signatures under *"Running the Service Locally"*. Required modules: * requests * math * random * json * base64 * beautifulsoup4 I used Python version 3.10.7, but any version 3.10.X should work. Then, you can simply run the script: ``` $ python topgradestudent.py ``` ### Known Bugs For some random facor r's, the script will fail. This happens when r is used to make the blind message, and the blind message is made into a hex that has an uneven amount of characters. To generate a new r, simply run the script again.

    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