Skip to content

Commit

Permalink
Add leakage
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWichelmann committed May 21, 2022
1 parent 8142683 commit 8484250
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/my_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,40 @@ void init(void)

void lookup_leakage(uint8_t *input, int inputLength, uint8_t *output)
{
// Empty and constant time
for(int i = 0; i < inputLength; ++i)
output[i] = lookup[input[i]];

Check failure

Code scanning / Microwalk

Secret-dependent memory access Error

Found vulnerable memory access instruction, leakage score 100.00% +/- 0%.
}

static int NOINLINE branch_leakage_util(uint8_t data)
{
// Use primes and random calculation to keep the compiler from optimizing this function too much

if(data < 79)

Check warning

Code scanning / Microwalk

Secret-dependent branch Warning

Found vulnerable jump instruction, leakage score 72.50% +/- 11.02%.
return 7;

if(data < 119)

Check failure

Code scanning / Microwalk

Secret-dependent branch Error

Found vulnerable jump instruction, leakage score 92.89% +/- 5.14%.
return data;

return 19 * data + 23;
}

int branch_leakage(uint8_t *input, int inputLength)
{
// Empty and constant time
return lookup[0] + inputLength;
int result = 0;

for(int i = 0; i < inputLength; ++i)
result += branch_leakage_util(input[i]);

return result;
}

int loop_leakage(uint8_t *input, int inputLength)
{
// Empty and constant time
return lookup[0] + inputLength;
for(int i = 0; i < input[0]; ++i)

Check failure

Code scanning / Microwalk

Secret-dependent branch Error

Found vulnerable jump instruction, leakage score 100.00% +/- 0%.

Check failure

Code scanning / Microwalk

Secret-dependent branch Error

Found vulnerable jump instruction, leakage score 100.00% +/- 0%.
{
if(lookup[i] < 5)
return 1;
}

return 2;
}

0 comments on commit 8484250

Please sign in to comment.