Finalization Versus Explicit Destruction via IDisposable

Normally, when you are finished using an object in the .NET Framework, the memory allocated by the object will be reclaimed by the Framework's garbage collector on an as-needed basis. However, in the case of cryptographic objects, implicit garbage collection is generally not appropriate. By their very nature, cryptographic objects contain sensitive data, such as secret key values, which must be explicitly destroyed after they are no longer needed.

Every cryptographic object within the .NET Framework implements the IDisposable() interface to support proper disposal of sensitive data. Types within the .NET Framework implement the IDisposable interface to provide a programmable way for user ...

Get .NET Framework Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.