-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
2.16 - to rebase: New password-based authenticated encryption sample program pbcrypt #4216
2.16 - to rebase: New password-based authenticated encryption sample program pbcrypt #4216
Conversation
Sample program for authenticated encryption using a key derived from a password. Signed-off-by: Gilles Peskine <[email protected]>
Test it in all.sh. Signed-off-by: Gilles Peskine <[email protected]>
The sample program aescrypt2 shows bad practice: hand-rolled CBC implementation, CBC+HMAC for AEAD, hand-rolled iterated SHA-2 for key stretching, no algorithm agility. The new sample program pbcrypt does the same thing, but better. So remove aescrypt2. Fix Mbed-TLS#1906 Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
This is a cast to a smaller type on 32-bit platforms. It's ok because the size was checked just above, but Visual Studio wants the cast to be explicit. Signed-off-by: Gilles Peskine <[email protected]>
This cast is needed because mbedtls_cipher_setkey uses int instead of size_t for the key size. It's safe because the key size fits in an int. Visual Studio wants the cast to be explicit. Signed-off-by: Gilles Peskine <[email protected]>
The metadata needs to be checked before it's used. Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
Prefer SHA-512 to SHA-256 and ChaChaPoly to AES-GCM. Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
Signed-off-by: Gilles Peskine <[email protected]>
This needs to be rebased on one of the active branches now that 2.16 is EOL. |
This PR will now be closed. The aescrypt2 program has already been removed from the library and there is a PR currently in progress (#5064) that will add a good selection of example programs. |
The PSA crypto API example programs are not relevant. There's nothing else in the works that's like That being said, we've been putting no effort in example programs for years and I don't see thing changing any time soon. So ok, let's just forget about this one. |
This PR introduces
programs/cipher/pbcrypt
, a new sample program to demonstrate password-based authenticated encryption.This is meant to illustrate good practice (with the limitation of using PBKDF2 rather than something more modern like Argon2), so please review accordingly. A few caveats:
Provide a demo usage script and run it from
all.sh
.Remove the badly designed
aescrypt2
. Fix #1906.This PR is for 2.16. I'll forward-port it to other branches once it's approved.
#ifdef
aboutmain
and tocipher_is_aead
.mbedtls_zeroize
bymbedtls_platform_zeroize
.