简体   繁体   中英

Why does TripleDESCryptoServiceProvider automatically generate Key?

When a new instance of TripleDESCryptoServiceProvider is created, a key and IV are generated.

It makes sense that an IV is generated every time.

But what is the point of the key being generated every time?

Isn't the key supposed to be static, so that it can be shared between the parties that are sending each other encrypted messages? Wouldn't I always just override the random key with the shared key?

It what situation is it useful for a new key to be generated every time?

Often keys are generated randomly for each message and then securely transported along with the encrypted message to the recipient using a public-key algorithm.

So, in that case, initializing the cipher with an appropriate key is convenient and probably safer too, if you assume the library developer is less likely to use improper key generation techniques.

However, if you have an existing key that you need to use, and overwrite the cipher's initial key, the only thing you've lost is some bits from the entropy pool.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM