Question regarding ICryptoTransform resuability

F

Fredo

Can someone explain the CanResuseTransform property of this interface to me?

I have an app that communicates over the network and I encrypt the
individual UDP packets which are sent and received from multiple clients.
Each has the same key and IV.

I guess my question is, do I need to create new encryptors and decryptors
for every packet?

Part of my concern is that the state of the encryptor/decryptor might change
as packets are encrypted. If that's the case, then if I encrypt a packet and
send it to client A and then encrypt an identical packet for client B, the
two packets will be different and only the first recipient will be able to
decrypt it.

I use the CryptoStream.FlushFinalBlock, so I'm assuming this resets the
states and will allow me to do what I want. I'd like to avoid the cost of
recreating the encryptor and decryptor for every packet.

Thanks.
 
G

Göran Andersson

Fredo said:
Can someone explain the CanResuseTransform property of this interface to me?

I have an app that communicates over the network and I encrypt the
individual UDP packets which are sent and received from multiple clients.
Each has the same key and IV.

I guess my question is, do I need to create new encryptors and decryptors
for every packet?

Part of my concern is that the state of the encryptor/decryptor might change
as packets are encrypted. If that's the case, then if I encrypt a packet and
send it to client A and then encrypt an identical packet for client B, the
two packets will be different and only the first recipient will be able to
decrypt it.

I use the CryptoStream.FlushFinalBlock, so I'm assuming this resets the
states and will allow me to do what I want. I'd like to avoid the cost of
recreating the encryptor and decryptor for every packet.

Thanks.

The CanReuseTransform property tells you exactly that. If it returns
true, you can reuse the transform.
 
F

Fredo

Göran Andersson said:
The CanReuseTransform property tells you exactly that. If it returns true,
you can reuse the transform.


Okay, that's what I suspected. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top