4 ms·
This looks really useful. It's nice to see libraries that try to do just a few things really well without taking over everything else. I have a couple minor q
by fooaccount 18y ago
This looks really useful. It's nice to see libraries that try to do just a few things really well without taking over everything else.
I have a couple minor quibbles about the crypto though (although, IANAC so take this with a grain of salt):
In your symmetric encryption routine, you include an HMAC of the encrypted IV and the ciphertext by computing HMAC_k($encrypted_iv . $ciphertext). This is problematic because an attacker can shift data from the end of the IV to the beginning of ciphertext without being caught immediately. Presumably it will garble the message in a way that will be noticed, but that's not a great assumption to make. At the very least it lets the attacker cause the script to spew warnings by passing an empty IV.
Using Triple-DES to encrypt an IV for AES also strikes me as a little weird. If you include the IV in an HMAC, you don't gain anything by encrypting it (since the entire point of encrypting the IV is to prevent someone from modifying it in transit).
- wbond 18y agoThanks for taking the time to check it out, it is encouraging to see positive and constructive feedback. I'll be sure to change the hmac to use a separator for the iv and ciphertext, that's a subtle vulnerability that you articulated well. I think you are also correct about encrypting the iv being worthless. Thinking back to when I wrote this, I believe that I originally added the encryption for that purpose exactly, to prevent modification during transmission. I later added the hmac to prevent modification of the ciphertex, but I ended up adding the iv in there too. Thanks!