-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app/foreshadow: add enclave "simulation" mode PoC without EENTER to d…
…emonstrate FS on CPUs with patched ucode.
- Loading branch information
1 parent
a276655
commit 56ec2ad
Showing
4 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <stdint.h> | ||
// read entire cache line | ||
#define CACHE_LINE_SIZE 64 | ||
#ifndef SECRET_BYTES | ||
#define SECRET_BYTES CACHE_LINE_SIZE | ||
#endif | ||
|
||
// first few cache lines seem not to work stable (?) | ||
#define SECRET_CACHE_LINE 27 | ||
#define SECRET_OFFSET (CACHE_LINE_SIZE*SECRET_CACHE_LINE) | ||
|
||
uint8_t __attribute__ ((aligned(0x1000))) array[1000]; | ||
#define secret array[SECRET_OFFSET] | ||
|
||
void *sim_generate_secret( void ) | ||
{ | ||
for (int i =0; i < SECRET_BYTES; i++) | ||
array[SECRET_OFFSET+i] = rand(); | ||
return &secret; | ||
} | ||
|
||
void sim_destroy_secret( uint8_t cl[64]) | ||
{ | ||
uint8_t rv = secret; | ||
|
||
for (int i=0; i < SECRET_BYTES; i++) | ||
{ | ||
cl[i] = array[SECRET_OFFSET+i]; | ||
array[SECRET_OFFSET+i] = 0xff; | ||
} | ||
} | ||
|
||
void sim_reload( void *adrs ) | ||
{ | ||
asm volatile ( | ||
"movl (%0), %%eax\n\t" | ||
: : "c" (adrs) | ||
: "%rax"); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters