Alan Kaminsky Department of Computer Science Rochester Institute of Technology 4571 + 2429 = 7000
Home Page
Introduction to Cryptography CSCI 462-01 Spring Semester 2018
Course Page

CSCI 462-01—Introduction to Cryptography
Programming Project 1

Prof. Alan Kaminsky—Spring Semester 2018
Rochester Institute of Technology—Department of Computer Science

Overview
The ARK6 Stream Cipher
Software Requirements
Software Design Criteria
Submission Requirements
Grading CriteriaTest Cases
Late Projects
Plagiarism
Resubmission


Overview

Write a Java class that implements a stream cipher to learn about stream cipher encryption and decryption.

Help with your project: I am willing to help you with the design of your project. I am willing to help you debug your project if the code isn't working. However, for help with design or debugging issues you must come see me in person. Either visit me during office hours or make an appointment. I will not help you with design or debugging issues via email. If it's the evening of the project deadline and I have gone home, you are on your own. Plan and work ahead so there will be plenty of time for me to help you if necessary.


The ARK6 Stream Cipher

Warning:
The ARK6 stream cipher's security has not been determined.
Do not use the ARK6 stream cipher for any real world application.

ARK6 takes a fixed-size 16-byte (128-bit) key and a fixed-size 8-byte (64-bit) nonce. Internally, ARK6 has a 256-element byte array S, a 256-element byte array T, and a 24-element byte array K.

ARK6's key scheduling algorithm (KSA) and pseudorandom generation algorithm (PRGA) use the following StateUpdate algorithm:

    For i = 0 to 255:
        T[i] = S[(i + 255) mod 256] xor (S[i] or S[(i + 1) mod 256])
    Swap S and T
where xor is bitwise Boolean exclusive-or and or is bitwise Boolean or.

ARK6's KSA is as follows. K is initialized from the key and the nonce.

    K[0..15] = key[0..15]
    K[16..23] = nonce[0..7]
    for i = 0 to 255:
        S[i] = i
    j = 0
    for i = 0 to 255:
        j = (j + S[i] + K[i mod 24]) mod 256
        Swap S[i] and S[j]
    Repeat 256 times:
        StateUpdate

ARK6's PRGA is as follows. Each execution of the loop outputs one keystream byte.

    Repeat:
        StateUpdate
        Output S[0]

To encrypt a plaintext, the keystream bytes are exclusive-ored with the plaintext bytes. To decrypt a ciphertext, the keystream bytes are exclusive-ored with the ciphertext bytes.

You will write a Java class named ARK6 that implements the StreamCipher interface from the Practical: Stream Cipher Implementation lecture notes (password required). You may NOT alter the StreamCipher interface in any way.

I will test your ARK6 class using the StreamCipherEncrypt, StreamCipherDecrypt, EncryptFile, and DecryptFile programs from the lecture notes. You may NOT alter those programs in any way.

Test Vectors

After ARK6 has been initialized with the key 000102030405060708090a0b0c0d0e0f and the nonce 1011121314151617, these are the contents of the S array (hexadecimal):

88 f3 ae 4a ed 17 f3 88 36 1f af 13 3c e1 da f4 
d7 35 f5 6d 97 40 7e f5 d8 a4 23 04 44 ad e1 dd 
57 d2 e5 c4 ca 00 61 16 e7 bf 91 96 df c6 eb b2 
e1 de e6 40 6b d0 5f bb 57 57 c4 b4 a0 12 c4 3c 
a8 d4 b7 5d 51 f3 96 58 7d 3c 84 9f e3 5f d1 d4 
12 31 af af 87 92 40 ae 8b d8 12 aa 54 37 71 0d 
5f f2 09 8c 9f d5 ad 35 85 15 dc 47 f4 ba 8d 2a 
20 1a 80 6b e2 fe 9e ae 8e cb c7 43 30 85 c0 f0 
3c 34 f7 ac c0 01 8d fe 8a 42 f5 fd d4 a2 3d 78 
0f 00 9a f9 f6 05 2f ce 0a 52 c3 df 67 bb e6 cd 
d6 fc 4f 19 08 a2 a0 9e 14 59 11 2b 88 1a a4 b3 
49 1c 0c 63 ea db e0 5a 03 07 8c 6b d7 78 d5 10 
7a da 89 69 4d 4b a7 30 2f e8 42 68 80 05 ad 82 
4a 93 ab f0 b5 66 7e 5c 57 f5 31 db 1d 12 76 25 
c0 5b d4 16 09 7c 74 08 41 bc 3f 7f 7d 67 0a 0c 
c2 93 79 e3 64 bf 1f 2c ab 07 8f 58 d6 04 64 3f

Here are some example commands and the correct outputs (on a Linux system):

$ java StreamCipherEncrypt ARK6 000102030405060708090a0b0c0d0e0f 1011121314151617 48454c4c4f20574f524c440a
48454c4c4f20574f524c440a
8c695736d68d6cd311ae0ebc

$ java StreamCipherDecrypt ARK6 000102030405060708090a0b0c0d0e0f 1011121314151617 8c695736d68d6cd311ae0ebc
8c695736d68d6cd311ae0ebc
48454c4c4f20574f524c440a

$ cat genesis.txt
In the beginning God created the heavens and the earth.
And the earth was without form and void,
and darkness was upon the face of the deep;
and the Spirit of God was moving over the face of the waters.

$ java EncryptFile ARK6 000102030405060708090a0b0c0d0e0f 1011121314151617 genesis.txt

$ od -t x1 genesis.txt 
0000000 8d 42 3b 0e f1 c8 1b fe 26 85 23 d8 37 c5 51 5b
0000020 ab 26 61 cd 87 73 f0 af 10 7a d6 64 9d b2 d0 be
0000040 18 e8 53 52 f7 c8 81 82 47 9c 9e fd c3 c4 2d 70
0000060 b8 bf 99 80 52 d3 97 78 78 18 73 65 0a e4 57 a5
0000100 6b 84 01 da 18 85 94 ea 4e fb dc 25 d1 e9 99 b7
0000120 c7 9a 06 d7 4a 50 36 e5 24 93 9b 6a eb 14 b0 a1
0000140 9e c6 a7 47 de af 6c 42 0d 4c 31 2b 0d f8 70 cf
0000160 94 40 6a 41 9b d4 4f 12 01 60 a3 7d 11 01 ff c8
0000200 45 55 c9 f2 de d4 8f cf dd 07 e8 16 6e 5c 2f 23
0000220 9f 41 b8 c5 b5 96 ae c2 49 0b f2 22 ff a5 e2 2e
0000240 a5 4c 75 20 bf a6 42 95 f1 28 4a 91 39 9a e7 f3
0000260 79 57 49 08 fc 22 0a a1 d6 cb c9 00 7e 9f 95 b0
0000300 de b6 8f a1 c0 d9 2b 20 f3 4e 60
0000313

$ java DecryptFile ARK6 000102030405060708090a0b0c0d0e0f 1011121314151617 genesis.txt

$ od -t x1 genesis.txt 
0000000 49 6e 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67
0000020 20 47 6f 64 20 63 72 65 61 74 65 64 20 74 68 65
0000040 20 68 65 61 76 65 6e 73 20 61 6e 64 20 74 68 65
0000060 20 65 61 72 74 68 2e 0a 41 6e 64 20 74 68 65 20
0000100 65 61 72 74 68 20 77 61 73 20 77 69 74 68 6f 75
0000120 74 20 66 6f 72 6d 20 61 6e 64 20 76 6f 69 64 2c
0000140 0a 61 6e 64 20 64 61 72 6b 6e 65 73 73 20 77 61
0000160 73 20 75 70 6f 6e 20 74 68 65 20 66 61 63 65 20
0000200 6f 66 20 74 68 65 20 64 65 65 70 3b 0a 61 6e 64
0000220 20 74 68 65 20 53 70 69 72 69 74 20 6f 66 20 47
0000240 6f 64 20 77 61 73 20 6d 6f 76 69 6e 67 20 6f 76
0000260 65 72 20 74 68 65 20 66 61 63 65 20 6f 66 20 74
0000300 68 65 20 77 61 74 65 72 73 2e 0a
0000313


Software Requirements

  1. The project must consist of one and only one Java class named ARK6.

  2. Class ARK6 must implement the StreamCipher interface from the Practical: Stream Cipher Implementation lecture notes (password required).

  3. Class ARK6 must implement the ARK6 stream cipher algorithm specified above.

    Note: If your project does not conform exactly to Requirements 1 through 3, you will lose credit on your project. See the Grading Criteria below.


Software Design Criteria

  1. The project must use the coding conventions for cryptographic algorithms discussed in class as appropriate.

  2. The project must be designed using object oriented design principles as appropriate.

  3. The project must make use of reusable software components as appropriate.

  4. Each class or interface must include a Javadoc comment describing the overall class or interface.

  5. Each constructor and method within each class or interface must include a Javadoc comment describing the overall constructor or method, the arguments if any, the return value if any, and the exceptions thrown if any.

    Note: See my Java source files which we studied in class for the style of Javadoc comments I'm looking for.

    Note: If your program's design does not conform to Software Design Criteria 1 through 5, you will lose credit on your project. See the Grading Criteria below.


Submission Requirements

Your project submission will consist of one and only one Java source file named ARK6.java. Send your source file to me by email at ark­@­cs.rit.edu. Include your full name and your computer account name in the email message, and include the source file as an attachment.

When I get your email message, I will store your ARK6.java source file in a directory. I will set my Java class path to include the directory with your source file, the directory with my StreamCipher interface and test programs, and the Parallel Java 2 Library. I will compile the Java source file using the Oracle JDK 1.8 compiler. I will then send you a reply message acknowledging I received your project and stating whether I was able to compile the source file. If you have not received a reply within one day, please contact me. Your project is not successfully submitted until I have sent you an acknowledgment stating I was able to compile the source file.

The submission deadline is Monday, February 19, 2018 at 11:59pm. The date/time at which your email message arrives in my inbox (not the time when I actually read the message) will determine whether your project meets the deadline.

You may submit your project multiple times up until the deadline. I will keep and grade only the most recent successful submission. There is no penalty for multiple submissions.

If you submit your project before the deadline, but I do not accept it (e.g. I can't compile all the source files), and you cannot or do not submit your project again before the deadline, the project will be late (see below). I STRONGLY advise you to submit the project several days BEFORE the deadline, so there will be time to deal with any problems that might arise in the submission process.


Grading Criteria

I will grade your project by:

I will grade the test cases based solely on whether your program produces the correct output as specified in the above Software Requirements. Any deviation from the requirements will result in a grade of 0 for the test case. This includes errors in the formatting (such as extra spaces), incorrect uppercase/lowercase, output lines not terminated with a newline, extra newline(s) in the output, and extraneous output not called for in the requirements. The requirements state exactly what the output is supposed to be, and there is no excuse for outputting anything different. If any requirement is unclear, please ask for clarification.

If there is a defect in your program and that same defect causes multiple test cases to fail, I will deduct points for every failing test case. The number of points deducted does not depend on the size of the defect; I will deduct the same number of points whether the defect is 1 line, 10 lines, 100 lines, or whatever.

When I grade your project, I will run your program on an Ubuntu 16.04 Linux system. The Java class path will include the directory with your compiled class files, the directory with my StreamCipher interface and test programs, and the Parallel Java 2 Library. I will run your program from the bash shell command line using Oracle's JDK 1.8; I will redirect your program's console output to a file; and I will look at the file's contents to determine if the output is correct. I STRONGLY recommend that you test your program in the same manner; that is, no Windows, no MacOS, no Eclipse, no IntelliJ, etc. If your program appears to produce the correct output on your machine, but your program does not produce the correct output on my machine, you will nonetheless lose points. If there's any doubt, you may visit me in my office and run your program on my machine.

After grading your project I will put your grade and any comments I have in your encrypted grade file. For further information, see the Course Grading and Policies and the Encrypted Grades.

Test Cases

The grading test case commands, input files, and correct outputs were as follows. If you want to run test cases 17–20 on your computer, download and unzip this ZIP file: p1.zip. It contains the files test17.txt through test20.txt.

1.  java StreamCipherEncrypt ARK6 00 00 00
    StreamCipherEncrypt: Key must be 16 bytes
    Usage: java StreamCipherEncrypt <cipherClass> <key> <nonce> <plaintext>
    <cipherClass> = StreamCipher class name
    <key> = Key (hexadecimal)
    <nonce> = Nonce (hexadecimal)
    <plaintext> = Plaintext (hexadecimal)
2.  java StreamCipherDecrypt ARK6 ffff ffff ffff
    StreamCipherDecrypt: Key must be 16 bytes
    Usage: java StreamCipherDecrypt <cipherClass> <key> <nonce> <ciphertext>
    <cipherClass> = StreamCipher class name
    <key> = Key (hexadecimal)
    <nonce> = Nonce (hexadecimal)
    <ciphertext> = Ciphertext (hexadecimal)
3.  java StreamCipherEncrypt ARK6 c6e36862e630a66ce21c137264bf4829 9a4b816faf9892c0 2331fb9a
    2331fb9a
    ca6ab8c2
4.  java StreamCipherEncrypt ARK6 b400656512d4fc6401d81d5fd9824821 14cc80083a52cbb5 55e64c9b50a3b7f1
    55e64c9b50a3b7f1
    7c1c16ac442b598f
5.  java StreamCipherEncrypt ARK6 44d7d9888708ffe4d17a463bc7c73b88 24b96042e9c061e5 28fbfd688cea665d8e8efa9b
    28fbfd688cea665d8e8efa9b
    7ad05ff99d05035123b1eea0
6.  java StreamCipherEncrypt ARK6 bfcf01e498e011774a38b40e64ddb7b3 ce978b5585614bbb ce9eff4a3a733aa6f11e915567115820
    ce9eff4a3a733aa6f11e915567115820
    b8672d26ae1da62da375e7409d47ceae
7.  java StreamCipherEncrypt ARK6 cb0bdaff1b89d08b81c5216804f4a39f a9d8a9fcbf1864af b3678992f2160f798c0e87fdf53b8ab23f985742
    b3678992f2160f798c0e87fdf53b8ab23f985742
    6aa6a808b6cc369b1fc0c80a3a0f7b7a5db611ed
8.  java StreamCipherEncrypt ARK6 b81a2d4e27890edd1898cc4a76ec225a c3ad2c1aa6205159 d7d82d81646d6c3c05fea0227850e0145648299d78f374af
    d7d82d81646d6c3c05fea0227850e0145648299d78f374af
    47e3ea9863428177627fa74862d6143a4fc3f92e6b392929
9.  java StreamCipherEncrypt ARK6 191fa4141eba57e8f717756bad394013 eeece6e0acc736fc 4c8dd48cece3e8c02307a71d91a7956e57e2383dff90d8a4c30a17d0
    4c8dd48cece3e8c02307a71d91a7956e57e2383dff90d8a4c30a17d0
    951870abdb110475502ce7e2638dcdc41ae42e28ac79f6655cfad708
10. java StreamCipherDecrypt ARK6 96394ca7ed3b290b3bb8c386a2b85653 2aa6c450722176a1 e16aceac
    e16aceac
    2ad09096
11. java StreamCipherDecrypt ARK6 004d87b692e90e1d6e2b325879a232d9 3b0f04f9b7697e89 7d664ce2602dd1f3
    7d664ce2602dd1f3
    692f466dcdb6ce01
12. java StreamCipherDecrypt ARK6 a66f3cd4de1185fcf826d7aee2fc5d4d bd20aede20140853 105f14f7f9acd88123436b7f
    105f14f7f9acd88123436b7f
    3ef610160449c247c4ab03fb
13. java StreamCipherDecrypt ARK6 e69d8dcc7c78368bd66966f0c22c1955 2b8efd8db0e7c7d6 cbd1551738e308263d2d26bd0e9491ea
    cbd1551738e308263d2d26bd0e9491ea
    29a90d24c281697bc8c6fe4049c60589
14. java StreamCipherDecrypt ARK6 06829d7431e32a7989fa9da1118f7783 b0f1f6192b233432 21ea4df43ad5a056c4833025fb75efc8b48fa55
    021ea4df43ad5a056c4833025fb75efc8b48fa55
    54b673abc3ff89c7878fa45af36e345a644ac257
15. java StreamCipherDecrypt ARK6 446549af64b7faec50d07411053c323c c4e514a8b90f685d c1910f185c09cfc84f0acd2c3d3583195c2bff1b605868
    c1910f185c09cfc84f0acd2c3d3583195c2bff1b605868
    3c9d7bda8af3d0a2aeec46bd6280b171fc0e60083ca0c2
16. java StreamCipherDecrypt ARK6 2b9e6879e16b6045985bee4870584140 dea94a887da931b0 9c806ffb3a57949cba9cca203b63f143d6d3c6d9d15d91b9dd593
    09c806ffb3a57949cba9cca203b63f143d6d3c6d9d15d91b9dd593
    a36776d131207ee489ab79b13379977303476519bfbab524e18ef5
17. java EncryptFile ARK6 28106446d9d2c896b3a1b9d765996e62 c6a4d42908b29dd2 test17.txt; od -t x1 test17.txt
    0000000 38 f7 90 fe f2 90 f9 e6 e7 15 9f 6f 18 3b 47 31
    0000020 72 05 7e 08 54 ff 94 d0 33 bf 72 6b 62 60 7f 90
    0000040 08 20 39 f1 0e 39 e2 25 54 a1 63 f6 10 a1 32 af
    0000060 8f 82 3e ab f0 1f 77 c4 75 c1 86 70 4c dd 80 d6
    0000100 8f 5b 80 15 34 68 60 34 cb 03 05 ad 9e d6 6d 70
    0000120 cb fe fe 33 64 cd 31 1b a5 29 04 d5 1e 92 2e df
    0000140 81 83 2f c1 a3 5f 2a 6f e1 f0 0c d2 e7 cc dc 1f
    0000160 c7 02 18 16 19 c7 c7 75 95 fa 0d a2 cf f1 cb 2b
    0000200 cd 7e 7d 09 ca b6 53 cb b3
    0000211
18. java EncryptFile ARK6 5c900d182d800f22c8dff9e422de19c0 45ee002ac9a6dff9 test18.txt; od -t x1 test18.txt
    0000000 61 c1 99 45 3e 6e 60 21 72 4b 1a 47 90 18 07 87
    0000020 61 11 5f 56 76 3f ff 2c 58 aa 73 07 53 f4 d5 f1
    0000040 15 ea 22 b6 45 09 1f 9d c7 11 d5 9b e6 92 55 20
    0000060 e1 c1 f6 2f 7a d2 b3 39 fa 33 0b ca 83 4f 1c 45
    0000100 35 95 09 5a 5b 16 5e 58 19 48 b1 67 69 0a 55 9f
    0000120 b5 73 1c 33 2b 19 fd 20 73 1c d6 9a 1f 02 15 17
    0000140 66 97 ec d8 c6 71 85 da 52 73 83 46 89 59
    0000156
19. java DecryptFile ARK6 b243c8e2ebcfa4500ae9012f290493ea 47d3dc83ea453242 test19.txt; od -t x1 test19.txt
    0000000 45 61 72 6c 79 20 74 6f 20 62 65 64 20 61 6e 64
    0000020 20 65 61 72 6c 79 20 74 6f 20 72 69 73 65 20 6d
    0000040 61 6b 65 73 20 61 20 6d 61 6e 20 68 65 61 6c 74
    0000060 68 79 2c 20 77 65 61 6c 74 68 79 2c 20 61 6e 64
    0000100 20 77 69 73 65 2e 0a 2d 2d 20 42 65 6e 6a 61 6d
    0000120 69 6e 20 46 72 61 6e 6b 6c 69 6e 0a
    0000134
20. java DecryptFile ARK6 344a90a618512f0a2cb4aaebaf59fa2d b45275bc38969adb test20.txt; od -t x1 test20.txt
    0000000 48 6f 77 20 6d 61 6e 79 20 6f 62 73 65 72 76 65
    0000020 20 43 68 72 69 73 74 27 73 20 62 69 72 74 68 64
    0000040 61 79 21 20 48 6f 77 20 66 65 77 2c 20 68 69 73
    0000060 20 70 72 65 63 65 70 74 73 21 20 4f 21 20 27 74
    0000100 69 73 20 65 61 73 69 65 72 20 74 6f 0a 6b 65 65
    0000120 70 20 48 6f 6c 69 64 61 79 73 20 74 68 61 6e 20
    0000140 43 6f 6d 6d 61 6e 64 6d 65 6e 74 73 2e 0a 2d 2d
    0000160 20 42 65 6e 6a 61 6d 69 6e 20 46 72 61 6e 6b 6c
    0000200 69 6e 0a
    0000203


Late Projects

If I have not received a successful submission of your project by the deadline, your project will be late and will receive a grade of zero. You may request an extension for the project. There is no penalty for an extension. See the Course Policies for my policy on extensions.


Plagiarism

Programming Project 1 must be entirely your own individual work. I will not tolerate plagiarism. If in my judgment the project is not entirely your own work, you will automatically receive, as a minimum, a grade of zero for the assignment. See the Course Policies for my policy on plagiarism.


Resubmission

If you so choose, you may submit a revised version of your project after you have received the grade for the original version. However, if the original project was not successfully submitted by the (possibly extended) deadline or was not entirely your own work (i.e., plagiarized), you are not allowed to submit a revised version. Submit the revised version via email in the same way as the original version. I will accept a resubmission up until 11:59pm Tuesday 27-Feb-2018. You may resubmit your project multiple times up until the deadline; I will keep and grade only the most recent successful resubmission; there is no penalty for multiple resubmissions. I will grade the revised version using the same criteria as the original version, then I will subtract 3 points (10% of the maximum possible points) as a resubmission penalty. The revised grade will replace the original grade, even if the revised grade is less than the original grade.

Introduction to Cryptography CSCI 462-01 Spring Semester 2018
Course Page
Alan Kaminsky Department of Computer Science Rochester Institute of Technology 4571 + 2429 = 7000
Home Page
Copyright © 2018 Alan Kaminsky. All rights reserved. Last updated 23-Feb-2018. Please send comments to ark­@­cs.rit.edu.