Skip to content
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

PSA crypto: fuzz MAC and symmetric ciphers #71

Merged

Conversation

gilles-peskine-arm
Copy link
Contributor

In the TF-PSA-Crypto module (PSA Crypto API implemented by Mbed TLS), fuzz HMAC, CMAC, SymmetricEncrypt and SymmetricDecrypt (i.e. MAC, cipher and AEAD).

This was a journey of discovery as I struggled through the validation philosophy. Also of learning C++. So I don't think the code is very nice and improvements are welcome.

I ran this overnight on my laptop and it didn't find anything. And it's found things (including one functional bug) so I think it isn't ignoring too much.

Note on timing: I'm putting this out there because it's ready, but I'm going to be offline from Friday until April 8. I'm posting this expecting to do rework when I get back.

The module can be called with invalid operations (inconsistent key
sizes, modes, etc). Do the necessary filtering to skip CMAC operations
when the parameters are inconsistent.
Fuzz unauthenticated ciphers and AEAD.
If an AEAD decryption reports a verification failure, treat that as
any other error, i.e. have the operation return null.
We were reporting an empty tag when doing unauthenticated decryption.
Currently this only affects HMAC: other algorithms require fixed-size
keys anyway.
In cipher_decrypt_oneshot(), don't include the IV in the ciphertext
size when calling check_finish_status(). That caused it to erroneously
think an empty ciphertext is valid for PSA_ALG_CBC_PKCS7 decryption.
@guidovranken
Copy link
Owner

can't find any more issues now and code looks good so will merge this now. thank you for your effort.

@guidovranken guidovranken merged commit f6f56a2 into guidovranken:master Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants