Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cache side channel attacks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MATANA
Benchmarks
Cache side channel attacks
Commits
d8f38ebd
Commit
d8f38ebd
authored
3 years ago
by
Yuxiao Mao
Browse files
Options
Downloads
Patches
Plain Diff
Attack AES last round: minor comments and code modif
parent
0039f1a9
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+1
-0
1 addition, 0 deletions
Makefile
README.md
+7
-5
7 additions, 5 deletions
README.md
src/test_victim_aes.c
+9
-6
9 additions, 6 deletions
src/test_victim_aes.c
src/victim_aes.c
+2
-4
2 additions, 4 deletions
src/victim_aes.c
with
19 additions
and
15 deletions
Makefile
+
1
−
0
View file @
d8f38ebd
...
...
@@ -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
$@
...
...
This diff is collapsed.
Click to expand it.
README.md
+
7
−
5
View file @
d8f38ebd
...
...
@@ -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
O
nly allows one single argument
.
Command line mode (o
nly allows one single argument
):
```
$ LD_LIBRARY_PATH=. ./victim_aes.elf 6bc1bee22e409f96e93d7e117393172a
...
...
@@ -76,14 +76,16 @@ $ LD_LIBRARY_PATH=. ./victim_aes.elf 6bc1bee22e409f96e93d7e117393172a
3ad77bb40d7a3660a89ecaf32466ef97
```
### Victim, s
hared memory mode
S
hared 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 &
...
...
This diff is collapsed.
Click to expand it.
src/test_victim_aes.c
+
9
−
6
View file @
d8f38ebd
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
src/victim_aes.c
+
2
−
4
View file @
d8f38ebd
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment