-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library: file encryption/decryption support #163
base: dev
Are you sure you want to change the base?
Library: file encryption/decryption support #163
Conversation
|
||
const char* enc_filepath = strcat((char*)path, ENCRYPTION_EXT); | ||
|
||
if(file_stream_open(stream_from, path, FSAM_READ, FSOM_OPEN_EXISTING) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test hangs here, I suspect something with Storage*
instance.
3f2892b
to
ea0a922
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
// create new random initialization vector | ||
uint8_t iv[ENCRYPTION_IV_SIZE]; | ||
srand(DWT->CYCCNT); | ||
furi_hal_random_fill_buf(iv, ENCRYPTION_IV_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IV is generated here using srand PRNG + CYCCNT (i.e. cycle counter) as seed,
- Only 32 bits of "entropy" for CYCCNT link
- Predicted (CYCCNT is just incrementing counter), making predicted IV attacks possible (like complete plaintext recovery for low entropy plaintexts) as the resulted encryption is no longer CPA secure
- srand is not a secure PRG (even with better seed as it has only 31 bit inner state)
Original flipper firmware already implemented much better random generation using sts32 hardware random generator. See furi_hal_random.c rand()
function which can be used instead of srand
.
Any updates to this? |
What's new
This PR adds functions to encrypt and decrypt file content using AES algorithm.
Verification
Checklist (For Reviewer)