Skip to content
Snippets Groups Projects
Commit d8f38ebd authored by Yuxiao Mao's avatar Yuxiao Mao
Browse files

Attack AES last round: minor comments and code modif

parent 0039f1a9
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ attack_aes_lastround_fr.elf: src/attack_aes_lastround.c cache/cache_util.c cache
victim_aes.elf: src/victim_aes.c libaes.so
$(CC) src/victim_aes.c -Iaes -L. -laes -o $@
# -lrt : for shared memory
victim_aes_shmem.elf: src/victim_aes.c libaes.so
$(CC) -DWITH_PROCESS_VICTIM_SHAREDMEM src/victim_aes.c -Iaes -L. -laes -lrt -o $@
......
......@@ -51,7 +51,7 @@ $ ./cache_profiling_pp8.elf 0
Note:
- For now, we needs `libaes.so/Te0` aligned to 64 byte boundary (begin of a cache line)
### Attacker, Flush+Reload, single process
### Flush+Reload, single process mode
```
$ nm libaes.so | grep Te
......@@ -66,9 +66,9 @@ $ LD_LIBRARY_PATH=. ./attack_aes_lastround_fr.elf 02800 02c00 03000 03400 1000 5
(Usage: <Offset_Te0> <Offset_Te1> <Offset_Te2> <Offset_Te3> <samples> <threshold>)
```
### Victim, command line mode
### Victim
Only allows one single argument.
Command line mode (only allows one single argument):
```
$ LD_LIBRARY_PATH=. ./victim_aes.elf 6bc1bee22e409f96e93d7e117393172a
......@@ -76,14 +76,16 @@ $ LD_LIBRARY_PATH=. ./victim_aes.elf 6bc1bee22e409f96e93d7e117393172a
3ad77bb40d7a3660a89ecaf32466ef97
```
### Victim, shared memory mode
Shared memory mode:
```
$ LD_LIBRARY_PATH=. ./victim_aes_shmem.elf &
$ ./test_victim_aes_shmem.elf
```
### Attacker, Flush+Reload, shared memory mode
### Flush+Reload, shared memory mode
Shared memory is managed by `status` variable (insteed of semaphore).
```
$ LD_LIBRARY_PATH=. ./victim_aes_shmem.elf &
......
......@@ -62,21 +62,24 @@ int prepare_ctx(struct victim_ctx *ctx) {
int send_msg(struct victim_ctx *ctx) {
uint8_t plaintext[AES_BLOCK_SIZE] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a};
// Send plaintext
while(ctx->ptr_msg_to_victim->status != MSG_READY);
uint8_t plaintext[AES_BLOCK_SIZE] = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a};
memcpy(ctx->ptr_msg_to_victim->u8text, plaintext, AES_BLOCK_SIZE);
ctx->ptr_msg_to_victim->status = 1;
ctx->ptr_msg_to_victim->status = MSG_VALID;
printf("[Test Victim] plaintext sent:");
printf("[Test Victim] plaintext sent: ");
printhex_uint8(plaintext, AES_BLOCK_SIZE);
// wait for response
while(ctx->ptr_msg_from_victim->status == 0);
// Receive ciphertext
while(ctx->ptr_msg_from_victim->status == MSG_READY);
uint8_t ciphertext[AES_BLOCK_SIZE] = {0,};
memcpy(ciphertext, ctx->ptr_msg_from_victim->u8text, AES_BLOCK_SIZE);
ctx->ptr_msg_from_victim->status = MSG_READY;
printf("[Test Victim] ciphertext received:");
printf("[Test Victim] ciphertext received: ");
printhex_uint8(ciphertext, AES_BLOCK_SIZE);
}
......
......@@ -140,7 +140,7 @@ int do_encryption(struct victim_ctx *ctx) {
// In shared memory mode, the encryption is performing in a loop
while (1) {
// TODO replace with require shmem semaphor
// Wait until receiving a message
while (ctx->ptr_msg_to_victim->status == MSG_READY) {
sleep(0);
}
......@@ -151,7 +151,6 @@ int do_encryption(struct victim_ctx *ctx) {
}
//printf("[Victim] Received something, status = %d\n", ctx->ptr_msg_to_victim->status); //DEBUG
// TODO when exit victim?
#endif
......@@ -164,7 +163,6 @@ int do_encryption(struct victim_ctx *ctx) {
// Send ciphertext
#if defined(WITH_PROCESS_VICTIM_SHAREDMEM)
// TODO with semaphor
// wait until receiver is available to receive next ciphertest
while (ctx->ptr_msg_from_victim->status != MSG_READY) {
sleep(0);
......@@ -205,7 +203,7 @@ int main(int argc, char **argv) {
struct victim_ctx ctx;
printf("[Victim] Begin AES\n");
printf("[Victim] Begin\n");
// Prepare to receive plaintext and send ciphertext
if (prepare_ctx(argc, argv, &ctx) < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment