In CCA-secure El Gamal encryption that composes El Gamal and AES-GCM, a receiver decrypts messages and checks its authenticity (tag). It is vulnerable if the receiver does not apply rate limiting, and provides feedback on whether the authentication succeeds.
Define parameters p,g
as in context.txt
. The receiver generates its sk
and publishes its pk
(see pk.txt
). The encryption consists of the following steps.
- Sample a random value
y
in range [1,q]
, where q
is the order of subgroup defined by g,p
.
- Compute
v = g^y
and w = pk^y
.
- Compute key
k = H(v, w)
, where H
is SHA-256
.
- Sample a 12-byte
nonce
. Encrypt a message m
by AES-GCM-ENC(k, nonce, m)
.
The decryption proceeds as follows.
- Compute
w = v^sk
.
- Compute key
k = H(v, w)
, where H
is SHA-256
.
- Parse the ciphertext as
nonce || c
. Decrypt a message m
by AES-GCM-DEC(k, nonce, c)
.
In this challenge, you will be given a decryption oracle that takes input a series of decryption queries and provides the feedback. The queries should be stored in a file, in which each line is one query El Gamal ciphertext v nonce || c)
. All fields are in the hex format. There is a space after v
, but nonce
and c
are concatenated.
One example of a line in query file is adfc76e9a7f4e419d03fb6bfa314cfffe191 28826e689e22dffc158f1dac17466a2218e7e4226c6f8ff8a60edd9077c9c355fd11bb187ad5df2baad04204
.
To make the challenge easier, the maximum bit-length of sk
is 20
. The associated data for AES-GCM is fixed as b"cse 539 applied cryptography". When encoding the integers as input strings to SHA-256, they are encoded as 18-byte string assuming big endian.
The oracle is invoked by /challenge/oracle PATH_TO_QUERY_FILE
. It returns the index of the line that is decrypted successfully. The index starts from 1. You can verify your result by /challenge/solve
.