I'm extending a VoIP application that uses UDP to transport data. The idea is to use AES to encrypt each audio packet. For each call, a key will be randomly generated.
The scenario inclues:
- Packet loss, no retransmission;
- Each packet will have noice in it (so it's very unlikely to send two identical packets);
- Each datagram will carry one audio packet;
- Encryption key won't be stored anywhere and will be discarded after the call.
- Encryption will be done using openSSL EVP, following this example.
Questions:
- Which cipher mode should I use, taking into account packet loss? I was thinking about CTR since it does not depend of previous/next packet to encrypt/decrypt each packet.
- Is it safe to NOT use an IV in this case (always use zero or NULL)?
- As far as I got my code done, I had to initialize a new EVP context for each audio packet, so that there wouldn't be any bytes left to be written to the encrypted datagram. If I don't do this, my audio packets may be currupted. Is this the right way to overcome this issue?