Homework 01
Homework 01
IT-Security
Homework 1
Breaking and Protecting a KeePass Database
General notes:
• Please submit your solutions as a ZIP archive containing the answers as a PDF document
as well as the corresponding source code and any other files relevant to your answers.
The PDF can be any combination of text, photographed notes, program code, etc.
Clarity is desirable, there are no beauty points.
• Explain your answers briefly but in a comprehensive way (if necessary with references
to the source code, you do not have to write a novel).
• Upload your solutions to the corresponding homework exercise on Ilias for submission.
• Please work in groups of 1–3 students and provide the names and matriculation numbers
of all group members.
b) Use the cracked password to open the database (e.g. with KeePass, KeePassX, KeeP-
assXC, . . . ). What is the combination of login and password stored in the password
database?
Exercise 2 (Discussion of the Database Format)
a) What is the purpose of the key transformation (calculation of transformedCredentials)?
What influence does the number of rounds transform_rounds have?
b) Does the use of ECB mode weaken the security of the transformation?
1
c) Measure the number of passwords that you can test with your program from Exercise 1
in one second. Estimate the approximate time for cracking the database if the key space
is expanded to also include
a) lowercase letters
b) lowercase letters and uppercase letters
with the number of rounds set to both 10000 (as in the example database) and 1000000
(newer versions).
d) What is the purpose of the stream start bytes field in the header? Is there another way
to achieve the same functionality (without repeating the first 32 plaintext bytes)?
e) In older KeePass versions, the header is not integrity protected. Show that without
the new integrity check it would be possible to create a second valid file based on an
existing database file, which has the same content (but a modified header) and can still
be successfully decrypted. Include the modified database file in your solution.
(Note: Use a hex editor of your choice. The modified file can no longer be opened with
KeePass, as the header is checked nowadays, but your program from task 1 should still
work in the same way.)
f) AES is much faster than SHA-2 on modern CPUs, so repeating the AES in the key
transformation seems to make less sense than a good hash-based key derivation, for
example based on PBKDF2 (see RFC 8018):
2. List of header fields. Each header field has the following structure:
There are the following header fields (other fields can be ignored):
2
ID Description
0 end of header (the encrypted database starts after this header field.)
4 master seed
5 transform seed
6 transform rounds
7 encryption initialisation vector (IV)
9 stream start bytes (the first 32 bytes of the decrypted database)
Note that header fields can appear in any order until an end of header field appears.
3. The data stream encrypted with AES-256 in CBC mode. (The derivation of the key is
explained below).
• The first 32 bytes of the decrypted data stream are randomly selected bytes and
are copied into the header field stream start bytes when the file is created.
• If the content of this header field matches the decrypted data, the password is
correct.
• This is followed by the actual database (a compressed XML document), but this
is not relevant for this homework.
Note that on Intel CPUs we have little-endian byte order: the 32-bit hexadecimal
value 0x9aa2d903 is encoded in memory (and thus also in the file) by the byte sequence
03 D9 A2 9A.
credentials = SHA-256(SHA-256(password))
transformed_credentials = SHA-256 AES-256transform_rounds
transform_seed (credentials)
AES-256tK (m)
means that we apply the block cipher AES-256 with the key K in ECB mode t-fold to m, i.e.
for t = 2 this means AES-256K (AES-256K (m)).