This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
labs:codebreaker [2020/03/16 18:00] nelson |
labs:codebreaker [2020/06/08 09:29] (current) nelson |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | <color red> | ||
- | ===== UNDER CONSTRUCTION ===== \\ | ||
- | This assignment is being modified in light of the change to on-line courses. This notice will be removed when this page is finalized for this semester. \\ \\ | ||
- | |||
- | NOTE: changes have been made to the lab below. Items you no longer are required to do are shown with a <del>strikethrough</del>. | ||
- | </color> | ||
- | |||
====== Codebreaker ====== | ====== Codebreaker ====== | ||
Line 16: | Line 9: | ||
The progression of the exercises is: | The progression of the exercises is: | ||
- | * <del>Exercise 1: Set up your project, and draw a message of your choosing on the screen.</del> | + | * Exercise 1: Set up your project, and draw a message of your choosing on the screen. |
- | * Exercise 2 and 3: You will be given an encrypted message, and the decryption key. You will decrypt the message, and display the decrypted message <del>on the screen</del> via simulation. | + | * Exercise 2 and 3: You will be given an encrypted message, and the decryption key. You will decrypt the message, and display the decrypted message on the screen. |
- | * Exercise 4: You will be given an encrypted message, but not the decryption key. You will search through all keys to find the key that properly decrypts a given message, and then display the decoded message <del>on the screen</del> via simulation. | + | * Exercise 4: You will be given an encrypted message, but not the decryption key. You will search through all keys to find the key that properly decrypts a given message, and then display the decoded message on the screen. |
===== Learning Outcomes ===== | ===== Learning Outcomes ===== | ||
* Implement a state machine using behavioral SystemVerilog | * Implement a state machine using behavioral SystemVerilog | ||
Line 104: | Line 97: | ||
Look over the top-level module, and make sure you understand how it works. The module contains: | Look over the top-level module, and make sure you understand how it works. The module contains: | ||
- | * A ''clk_generator'' instance, that generates a 25MHz clock needed by the VGA display. | + | * A ''clk_generator'' instance, that generates a 25MHz clock needed by the VGA display. |
* A ''BitmapToVga'' instance, that controls the VGA outputs, and has inputs that allow you to modify the pixel colors of the bitmap that is displayed over VGA. | * A ''BitmapToVga'' instance, that controls the VGA outputs, and has inputs that allow you to modify the pixel colors of the bitmap that is displayed over VGA. | ||
* A ''CharDrawer'' instance, that is connected to the ''BitmapToVga'', that is used to draw messages to the bitmap, and thus the VGA display. | * A ''CharDrawer'' instance, that is connected to the ''BitmapToVga'', that is used to draw messages to the bitmap, and thus the VGA display. | ||
Line 117: | Line 110: | ||
- Create an appropriate constraints file for all of the top-level ports. | - Create an appropriate constraints file for all of the top-level ports. | ||
- Add all other necessary modules to your project. You will need to expand the modules in the Design Sources list to make sure you have included all necessary modules. For this lab, you only need to create the ''Codebreaker'' module (ports listed below). All other modules have been given to you, or were created in previous labs. | - Add all other necessary modules to your project. You will need to expand the modules in the Design Sources list to make sure you have included all necessary modules. For this lab, you only need to create the ''Codebreaker'' module (ports listed below). All other modules have been given to you, or were created in previous labs. | ||
- | - <del>In this first exercise, your Codebreaker module will be very simple:</del> | + | - In this first exercise, your Codebreaker module will be very simple: |
- | - <del>Drive the ''key_display'' and ''stopwatch_run'' outputs to 0.</del> | + | - Drive the ''key_display'' and ''stopwatch_run'' outputs to 0. |
- | - <del>Drive the ''plaintext_to_draw'' output to a message of your choice to draw on the screen (the ''CharDrawer'' can only draw upper case letters, digits and spaces. </del> | + | - Drive the ''plaintext_to_draw'' output to a message of your choice to draw on the screen (the ''CharDrawer'' can only draw upper case letters, digits and spaces. |
- | - <del>Connect the ''draw_plaintext'' output to the ''start'' input.</del> | + | - Connect the ''draw_plaintext'' output to the ''start'' input. |
Line 135: | Line 128: | ||
- | <del>**Pass-off:** Generate the bitstream and program the board. You can use the **+** button on the monitors in the lab to switch them to the VGA input. Verify that your message is displayed after you press ''btnc''. You don't need to show it to the TAs.</del> | + | **Pass-off:** Generate the bitstream and program the board. You can use the **+** button on the monitors in the lab to switch them to the VGA input. Verify that your message is displayed after you press ''btnc''. You don't need to show it to the TAs. |
---- | ---- | ||
Line 164: | Line 157: | ||
* It is good to choose meaningful state names (not S1, S2, etc.) This will help you reason about and debug your state machine. | * It is good to choose meaningful state names (not S1, S2, etc.) This will help you reason about and debug your state machine. | ||
- | **Pass-off**: <del>Show</del> Use Zoom to share your state machine with the TA and get feedback. | + | **Pass-off**: Show the TA your state machine. |
+ | |||
---- | ---- | ||
Line 171: | Line 166: | ||
- | Implement your state machine in your ''Codebreaker'' module. Test your design with the following 128-bit cyphertext and 24-bit key. You should get a readable message <del>on the display</del> in your simulation. | + | Implement your state machine in your ''Codebreaker'' module. Test your design with the following 128-bit cyphertext and 24-bit key. You should get a readable message on the display. |
<code SystemVerilog> | <code SystemVerilog> | ||
Line 180: | Line 175: | ||
Use simulation to debug your design when necessary. | Use simulation to debug your design when necessary. | ||
- | <del>For this exercise you can continue to connect 0 to the ''key_display'' and ''stopwatch_run'' outputs. Since your state machine is now assigning a value to ''draw_plaintext'', make sure you don't still have it connected to the ''start'' input.</del> | + | For this exercise you can continue to connect 0 to the ''key_display'' and ''stopwatch_run'' outputs. Since your state machine is now assigning a value to ''draw_plaintext'', make sure you don't still have it connected to the ''start'' input. |
- | **Pass-off:** <del>Show the TA the decoded message being displayed on the monitor.</del> <color red> Include a screenshot of the simulation showing the decoded message in the lab report.</color> | + | **Pass-off:** Show the TA the decoded message being displayed on the monitor. |
---- | ---- | ||
Line 225: | Line 220: | ||
- | <del>Test</del> Simulate your brute-force design on the cyphertext below. | + | Test your brute-force design on the cyphertext and key from the last exercise. Use simulation when necessary to help debug your design. |
- | <code SystemVerilog> | ||
- | assign cyphertext = 128'ha86c62de027d0defdad12ef771c50cd2; | ||
- | </code> | ||
- | <color red> Include a screenshot of your simulation waveforms demonstrating that your simulation works and finds the correct key (be sure both the key and resulting decoded text are visible in the simulation).</color> | + | **Final Pass-Off:** Chose one of the cyphertexts below, decode the message, and display it on the VGA display. |
- | **Final Pass-Off:** Choose one of the cyphertexts below, decode the message, and <del>display it on the VGA display</del> demonstrate that it works via simulation. NOTE: the cyphertexts were encoded using a key fairly close to 0 to minimize simulation time. Thus, if your search has not found the key prior to it reaching the value of 20, then you have a problem in your design and you can kill the simulation and start debugging your design. | + | <code Verilog> |
+ | assign cyphertext = 128'ha13a3ab3071897088f3233a58d6238bb; | ||
+ | assign cyphertext = 128'hb8935bbf5f819bcfec46da11d5393d4f; | ||
+ | assign cyphertext = 128'h396d6e70500754ff726bd5fb963998ce; | ||
+ | assign cyphertext = 128'h189f2800aac06ce4a74292bffe33fd2c; | ||
+ | assign cyphertext = 128'h19b39b044dc39c4e98f9dfb44a0b7c11; | ||
+ | </code> | ||
- | <color red>Be sure the original cyphertext, decoded text, and the resulting key are visible in your simulation waveforms. If it is necessary to take multiple screenshots to make them visible, please do so and then concatenate them into a single PDF file to attach to the lab writeup page.</color> | + | /* "BRUTE FORCE RC4" key = 24'hAAAAAA; |
+ | "EZ KEY IS 000300" key = 24'h000300; | ||
+ | "THAT TOOK FORVER" key = 24'hFFFFFF; | ||
+ | " I PICKED NUM 4 " key = 24'h123456; | ||
+ | "YOU CRACK ME UP " key = 24'h6DB6DB; | ||
+ | */ | ||
+ | /* | ||
<code Verilog> | <code Verilog> | ||
assign cyphertext = 128'hca91b1577f34443894de1001885d6aa5; | assign cyphertext = 128'hca91b1577f34443894de1001885d6aa5; | ||
Line 244: | Line 248: | ||
assign cyphertext = 128'hbd6a2012369d963f18802a8a70ca7ec7; | assign cyphertext = 128'hbd6a2012369d963f18802a8a70ca7ec7; | ||
</code> | </code> | ||
+ | */ | ||
/* Small keys for simulation: | /* Small keys for simulation: | ||
"BRUTE FORCE RC4" key = 24'h000009; | "BRUTE FORCE RC4" key = 24'h000009; | ||
Line 252: | Line 256: | ||
"YOU CRACK ME UP " key = 24'h000007; | "YOU CRACK ME UP " key = 24'h000007; | ||
*/ | */ | ||
- | |||
<color red>Submit your ''Codebreaker'' SystemVerilog module using the code submission on Learning Suite.</color> (Make sure your SystemVerilog conforms to the lab SystemVerilog coding standards). | <color red>Submit your ''Codebreaker'' SystemVerilog module using the code submission on Learning Suite.</color> (Make sure your SystemVerilog conforms to the lab SystemVerilog coding standards). | ||
Line 261: | Line 264: | ||
===== Personal Exploration ===== | ===== Personal Exploration ===== | ||
- | * <del>Try creating your own encrypted message. You can use [[https://cryptii.com/pipes/rc4-encryption]]. Set the mode to encode, be sure your input string is 16 characters and your key is 3 bytes. Keep in mind, the byte order of the key is reversed; for example, if you choose a key of "AABBCC" on the website, the resulting key will be 24'hCCBBAA in the SystemVerilog implementation. The plaintext/cyphertext doesn't need to be re-ordered.</del> | + | * Try creating your own encrypted message. You can use [[https://cryptii.com/pipes/rc4-encryption]]. Set the mode to encode, be sure your input string is 16 characters and your key is 3 bytes. Keep in mind, the byte order of the key is reversed; for example, if you choose a key of "AABBCC" on the website, the resulting key will be 24'hCCBBAA in the SystemVerilog implementation. The plaintext/cyphertext doesn't need to be re-ordered. |
- | * <del>Look through the ''CharDrawer'' SystemVerilog module and explore how it works. </del> | + | * Look through the ''CharDrawer'' SystemVerilog module and explore how it works. |
- | * <del>Look through the RC4 decryption module, and see how it implements the algorithm described on the RC4 Wikipedia page.</del> | + | * Look through the RC4 decryption module, and see how it implements the algorithm described on the RC4 Wikipedia page. |
- | * <del>Move the message to be drawn in a different location on the screen, and change the color.</del> | + | * Move the message to be drawn in a different location on the screen, and change the color. |
- | * <del>**Challenge:** Speed up the brute-force algorithm by using 2 or 4 simultaneous RC4 decryption instances, and have each of them try a different part of the key space. Stop as soon as any of the modules find the correct key.</del> | + | * **Challenge:** Speed up the brute-force algorithm by using 2 or 4 simultaneous RC4 decryption instances, and have each of them try a different part of the key space. Stop as soon as any of the modules find the correct key. |