Security and Cryptography (S2, 2013)

Homework 1 - Encryption with OpenSSL

This homework requires you to use OpenSSL to decrypt some ciphertext.

OpenSSL

OpenSSL is a popular open source library (and accompanying command line application) that implements many cryptographic operations and algorithms. It runs on Unix-like operating systems, including Linux and Mac OSX. You have several options to use it:

  1. If you have OSX or Linux on your own computer, OpenSSL should already be installed.
  2. Install Ubuntu Linux in a virtual machine (e.g. VirtualBox).
  3. OpenSSL will work on Windows if you use Cygwin or Mingw.
  4. Use a ICT Lab computer: Network lab on ground floor or MAC lab on 3rd floor.
  5. Similar to 2, I have created a virtual machine that can be used for this homework, as well as other networking and security tasks. If you want to try, see my instructions for creating a virtual network. This approach is not needed for this homework and takes some time, but you may be able to use the software in later tasks and other courses.
  6. Login to the ICT server and run OpenSSL on the server.

The version of OpenSSL that you use can be seen by running "openssl version". I am using: OpenSSL 1.0.1 14 Mar 2012.

Getting Started

I have a simple introduction to using OpenSSL. Read and try some operations. The basic way to decrypt is:

openssl enc -d -cipher-mode -in ciphertext.bin -out plaintext.txt -K keyinhex -iv ivinhex

To see the list of ciphers and modes try man encrypt. Note that options like -nopad are NOT needed.

Once you have OpenSSL installed and know the basics, your first task is to download your files at:

https://ict.siit.tu.ac.th/~uxxxxxxxxxx/private/

where xxxxxxxxxx is your student ID. You will be prompted for a username/password - it is the same as your Moodle login. The 4 files are: xxxxxxxxxx-ciphertext1.bin, xxxxxxxxxx-ciphertext2.bin, xxxxxxxxxx-ciphertext2.bin, xxxxxxxxxx-key.txt.

Now decrypt xxxxxxxxxx-ciphertext1.bin using OpenSSL and the key information in xxxxxxxxxx-key.txt. It was encrypted using DES with ECB mode of operation. Now view the plaintext.

Feedback

Students can see their grades and comments by viewing their submission below. In general, most people used OpenSSL correctly. However many students used the wrong length key and/or IV in the final encryption. With AES256 the key should be 256 bits or 64 hexadecimal digits. And with any variant of AES, the block size is 128 bits and so the IV should be 128 bits or 32 hexadecimal digits. If you used a different length value then OpenSSL extended the value for you and the encryption/decryption still worked. However I subtracted some several marks for this mistake.

Below are the OpenSSL speed results. Looks like many people used the lab computers (i3-530). You can see the different speeds across different processor classes, e.g. Atom < i3 < i5 < i7, and also between ciphers, e.g. des-ede3 < des < cast/blowfish < aes < camellia (although be careful when comparing key sizes). For reference, the first results are on several computers I tried, both standard software encryption and optional hardware encryption (using the -evp parameter in openssl speed).

Steve1
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
aes-128 cbc 16 114
aes-128 cbc 256 125
aes-128 cbc 8192 127
HW aes-128 cbc 16 689
HW aes-128 cbc 256 745
HW aes-128 cbc 8192 749
==============================
Steve2
Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
aes-128 cbc 16 138
aes-128 cbc 256 152
aes-128 cbc 8192 154
HW aes-128 cbc 16 689
HW aes-128 cbc 256 717
HW aes-128 cbc 8192 747
==============================
Steve3
Intel(R) Core(TM) i7-2630QM CPU @ 2.00 GHz
aes-128 cbc 16 87
aes-128 cbc 256 95
aes-128 cbc 8192 96
HW aes-128 cbc 16 254
HW aes-128 cbc 256 292
HW aes-128 cbc 8192 299
==============================
08cdf4f5686670455a9866bd23d291bb
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
des cbc 16 68
des cbc 256 70
des cbc 8192 70
blowfish cbc 16 104
blowfish cbc 256 111
blowfish cbc 8192 112
aes-128 cbc 16 89
aes-128 cbc 256 98
aes-128 cbc 8192 102
==============================
78bb641ce6f31109212c31d8e087ecc5
Intel® Core™ i3 CPU 530 @ 2.93GHz
cipher1 cbc 16 68
cipher1 cbc 256 69
cipher1 cbc 8192 69
cipher2 cbc 16 73
cipher2 cbc 256 82
cipher2 cbc 8192 83
cipher3 cbc 16 65
cipher3 cbc 256 72
cipher3 cbc 8192 72
==============================
9a6dcfa2ef44df5c26ba2abd3364d3be
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
des cbc 16 68
des cbc 256 70
des cbc 8192 70
des ede3 16 25
des ede3 256 25
des ede3 8192 25
camellia 256 cbc 16 69
camellia 256 cbc 256 97
camellia 256 cbc 8192 99
==============================
e4404dde6818d14b3fd002f0dd89c621
intel i3 2.30GHz
des cbc 16 42
des cbc 256 44
des cbc 8192 44
aes-128 cbc 16 68
aes-128 cbc 256 76
aes-128 cbc 8192 76
camellia-192 cbc 16 54
camellia-192 cbc 256 82
camellia-192 cbc 8192 85
==============================
07d1e95ac80e8417389a0c3ac8cf309f
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 69
cipher1 cbc 256 70
cipher1 cbc 8192 70
cipher2 cbc 16 74
cipher2 cbc 256 84
cipher2 cbc 8192 85
cipher3 cbc 16 74
cipher3 cbc 256 84
cipher3 cbc 8192 85
==============================
e28fff9f120b11f3fc05f66d2b20ac05
intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cbc 16 - 127
cbc 256 - 81
cbc 8192 - 25
aes-128 16 - 165
aes-128 256 - 118
aes-128 8192 - 37
camellia-128 16 - 157
camellia-128 256 - 147
camellia-128 8192 - 46
==============================
26bbd9c1e92d5f4ef61b01e3bdfde8e0
Intel i5-2430M @ 2.40GHz
des cbc 16 50
des cbc 256 52
des cbc 8192 42
des ede3 16 16
des ede3 256 17
des ede3 8192 17
blowfish cbc 16 66
blowfish cbc 256 76
blowfish cbc 8192 78
==============================
9a74527093c153913a8a21fa526bee61
Intel Core i5 @ 2.3 GHz
des cbc 16 52
des cbc 256 54
des cbc 8192 54
cast cbc 16 652
cast cbc 256 68
cast cbc 8192 69
aes-256 cbc 16 97
aes-256 cbc 256 104
aes-256 cbc 8192 104
==============================
c0e23cb547175865007ee56aae6826fa
2.9 GHz intel core i7
des cbc 16 72
des cbc 256 74
des cbc 8192 74
des ede3 16 27
des ede3 256 27
des ede3 8192 27
aes-256 cbc 16 139
aes-256 cbc 256 139
aes-256 cbc 8192 141
==============================
127fca51912c8ab7a2f08b708d7bf35c
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 68
cipher1 cbc 256 70
cipher1 cbc 8192 70
cipher2 cbc 16 88
cipher2 cbc 256 100
cipher2 cbc 8192 102
cipher3 cbc 16 83
cipher3 cbc 256 126
cipher3 cbc 8192 130
==============================
6cdbfdc192027b7f003ba65a2448ea1b
Intel Core i3 CPU 530 @ 2.93GHz 4
Doing des cbc for 3s on 16 size blocks: 12786081 des cbc's in 3.00s
Doing des cbc for 3s on 64 size blocks: 3252540 des cbc's in 3.00s
Doing des cbc for 3s on 256 size blocks: 817262 des cbc's in 2.99s
Doing des cbc for 3s on 1024 size blocks: 204506 des cbc's in 3.00s
Doing des cbc for 3s on 8192 size blocks: 25534 des cbc's in 3.00s
Doing aes-256 cbc for 3s on 16 size blocks: 12312663 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 64 size blocks: 3313254 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 256 size blocks: 848495 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 1024 size blocks: 211682 aes-256 cbc's in 3.00s
Doing aes-256 cbc for 3s on 8192 size blocks: 26588 aes-256 cbc's in 3.00s
Doing blowfish cbc for 3s on 16 size blocks: 19611228 blowfish cbc's in 3.00s
Doing blowfish cbc for 3s on 64 size blocks: 5176909 blowfish cbc's in 3.00s
Doing blowfish cbc for 3s on 256 size blocks: 1305533 blowfish cbc's in 3.00s
Doing blowfish cbc for 3s on 1024 size blocks: 329465 blowfish cbc's in 2.99s
Doing blowfish cbc for 3s on 8192 size blocks: 40964 blowfish cbc's in 3.00s
==============================
1a1bf0e7b3b4b171e7260f13689008dc
Intel(R) Core(TM)2 Duo @ 2.20GHz
des cbc 16 47
des cbc 256 51
des cbc 8192 51
cast5 cbc 16 72
cast5 cbc 256 81
cast5 cbc 8192 81
camellia128 cbc 16 61
camellia128 cbc 256 99
camellia128 cbc 8192 103
==============================
8361671c041747f2c51e69f7c48876d9
2.7GHz Intel COre i5
des cbc 16 72
des cbc 256 72
des cbc 8192 73
des-ede3 cbc 16 26
des-ede3 cbc 256 27
des-ede3 cbc 8192 27
aes-192 cbc 16 154
aes-192 cbc 256 152
aes-192 cbc 8192 161
==============================
a25227169bf0efcf24f9d6f7aea1b0f4
intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cbc 16 - 128
cbc 256 - 81
cbc 8192 - 25
aes-192 16 - 139
aes-128 256 - 98
aes-128 8192 - 31
cast5 16 - 110
cast5 256 - 74
cast5 8192 - 23
==============================
1ab30877a63748038e97fbd130e1538c
Intel® Atom™ CPU 230 @ 1.60GHz × 2
des cbc 16 24
des cbc 256 27
des cbc 8192 27
aes-256 cbc 16 10
aes-256 cbc 256 10
aes-256 cbc 8192 9
camellia-128 cbc 16 18
camellia-128 cbc 256 27
camellia-128 cbc 8192 28
==============================
8d679d0db32d4bed8642939bd74179c7
Intel® Core™ i5-3210M CPU @ 2.50GHz × 4
des cbc 16 68
des cbc 256 69
des cbc 8192 70
aes-128 cbc 16 102
aes-128 cbc 256 114
aes-128 cbc 8192 117
camellia-192 cbc 16 84
camellia-192 cbc 256 108
camellia-192 cbc 8192 112
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
des cbc 67644.89k 68702.07k 68820.91k 68488.25k 69508.71k
aes-128 cbc 101554.21k 112532.99k 114372.84k 117020.33k 116657.92k
camellia-192 cbc 84033.09k 103234.76k 108357.41k 109397.90k 111782.57k
==============================
a0dbc07f1b19619369d74a3d2022d98d
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 68
cipher1 cbc 256 69
cipher1 cbc 8192 70
cipher2 cbc 16 58
cipher2 cbc 256 63
cipher2 cbc 8192 63
cipher3 cbc 16 65
cipher3 cbc 256 72
cipher3 cbc 8192 72
==============================
8b22f0b55d9c11c7a2b9ec3e51c32c4e
Intel i3 @ 2.3GHz
des cbc 16 42
des cbc 256 44
des cbc 8192 44
cast5 cbc 16 68
cast5 cbc 256 72
cast5 cbc 8192 72
aes-192 cbc 16 58
aes-192 cbc 256 63
aes-192 cbc 8192 64
==============================
3b0e1ac4e1a1bdae8e846f2184d7d717
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
des cbc 16 68
des cbc 256 70
des cbc 8192 70
cast cbc 16 59
cast cbc 256 63
cast cbc 8192 64
camellia-192 cbc 16 70
camellia-192 cbc 256 98
camellia-192 cbc 8192 100
==============================
a5267f113d676e8fa14c364aa8bbdf6f
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
des cbc 16 69
des cbc 256 69
des cbc 8192 70
blowfish cbc 16 105
blowfish cbc 256 111
blowfish cbc 8192 112
aes-256 cbc 16 65
aes-256 cbc 256 67
aes-256 cbc 8192 73
==============================
42d4ba590b42018dc2e7fbb68e2d0462
intel i3 2.3GHz
des cbc 16 42
des cbc 256 44
des cbc 8192 44
camellia-128 cbc 16 62
camellia-128 cbc 256 108
camellia-128 cbc 8192 113
aes-256 cbc 16 50
aes-256 cbc 256 53
aes-256 cbc 8192 54
==============================
a00200219a607ee6a97bfc3fe92a246f
Intel Core i3-2350M @ 2.30GHz
des cbc 16 42
des cbc 256 44
des cbc 8192 44
bf cbc 16 71
bf cbc 256 76
bf cbc 8192 76
cast5 cbc 16 67
cast5 cbc 256 71
cast5 cbc 8192 72
==============================
01c0475e71bc5e921deea214e9e56771
intel i7 2.60GHz
des cbc 16 71
des cbc 256 73
des cbc 8192 74
bf cbc 16 113
bf cbc 256 121
bf cbc 8192 123
cast5 cbc 16 93
cast5 cbc 256 97
cast5 cbc 8192 98
==============================
67acb9f7f90bec6b8a8c065d57de6888
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
des cbc 16 68
des cbc 256 69
des cbc 8129 69
camellia-128 cbc 16 82
camellia-128 cbc 256 125
camellia-128 cbc 8129 129
aes-256 cbc 16 61
aes-256 cbc 256 71
aes-256 cbc 8129 72
==============================
69354c78e3ba7034e10b241401c63ba5
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 69
cipher1 cbc 256 70
cipher1 cbc 8192 70
cipher2 cbc 16 70
cipher2 cbc 256 97
cipher2 cbc 8192 99
cipher3 cbc 16 69
cipher3 cbc 256 97
cipher3 cbc 8192 100
==============================
394d97ce6cfccafd37bdffb182dc0302
intel i3 2.3GHz
des cbc 16 42
des cbc 256 44
des cbc 8192 44
camellia-256 cbc 16 54
camellia-256 cbc 256 82
camellia-256 cbc 8192 85
des-ede3 cbc 16 16
des-ede3 cbc 256 17
des-ede3 cbc 8192 17
==============================
ed5c2138c18c25b71960a8de0557cf29
Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
des cbc 16 66
des cbc 256 67
des cbc 8192 68
aes cbc 16 163
aes cbc 256 168
aes cbc 8192 169
camellia cbc 16 90
camellia cbc 256 136
camellia cbc 8192 141
==============================
b6a6f8fe4b9b68b9bada837d89f78dfa
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
des cbc 16 68
des cbc 256 70
des cbc 8192 70
aes-128 cbc 16 89
aes-128 cbc 256 101
aes-128 cbc 8192 102
aes-256 cbc 16 66
aes-256 cbc 256 72
aes-256 cbc 8192 73
==============================
01c1f0f96692e9b2b7cb3bd94bd6c38b
QEMU Virtual CPU version 1.0 (ICT Server? Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz)
des cbc 16 69
des cbc 256 72
des cbc 8192 72
cast cbc 16 109
cast cbc 256 115
cast cbc 8192 116
camellia-128 cbc 16 102
camellia-128 cbc 256 176
camellia-128 cbc 8192 184
==============================
b3345dce24974e8db7892cacb7b503ad
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 68
cipher1 cbc 256 70
cipher1 cbc 8192 70
cipher2 cbc 16 25
cipher2 cbc 256 25
cipher2 cbc 8192 25
cipher3 cbc 16 69
cipher3 cbc 256 98
cipher3 cbc 8192 100
==============================
f67a36b7e1b74e55c46e0610c764bbcd
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 67
cipher1 cbc 256 69
cipher1 cbc 8192 69
cipher2 cbc 16 24
cipher2 cbc 256 24
cipher2 cbc 8192 25
cipher3 cbc 16 69
cipher3 cbc 256 97
cipher3 cbc 8192 100
==============================
e2a561d6d7ee39a98b2d8e9f13ec2984
Intel® Core™ i3 CPU 530 @ 2.93GHz × 4
cipher1 cbc 16 68
cipher1 cbc 256 70
cipher1 cbc 8192 70
cipher2 cbc 16 105
cipher2 cbc 256 111
cipher2 cbc 8192 112
cipher3 cbc 16 76
cipher3 cbc 256 84
cipher3 cbc 8192 85

Return to: Course Home | Course List | Steven Gordon's Home | SIIT