Commit 567dd8f
dm crypt: make printing of the key constant-time
The device mapper dm-crypt target is using scnprintf("%02x", cc->key[i]) to
report the current key to userspace. However, this is not a constant-time
operation and it may leak information about the key via timing, via cache
access patterns or via the branch predictor.
Change dm-crypt's key printing to use "%c" instead of "%02x". Also
introduce hex2asc() that carefully avoids any branching or memory
accesses when converting a number in the range 0 ... 15 to an ascii
character.
Cc: [email protected]
Signed-off-by: Mikulas Patocka <[email protected]>
Tested-by: Milan Broz <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>1 parent d3f2a14 commit 567dd8f
1 file changed
+11
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3439 | 3439 | | |
3440 | 3440 | | |
3441 | 3441 | | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
3442 | 3447 | | |
3443 | 3448 | | |
3444 | 3449 | | |
| |||
3457 | 3462 | | |
3458 | 3463 | | |
3459 | 3464 | | |
3460 | | - | |
3461 | | - | |
3462 | | - | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
3463 | 3471 | | |
3464 | 3472 | | |
3465 | 3473 | | |
| |||
0 commit comments