On the conceptual level, SecureString looks like a specialization of ProtectedMemory.
Granted, its primary function is to shorten the lifetime of (immutable) strings inside RAM, swap, and crash dumps. However, it also uses DPAPI to protect the data except on the entry and exit points. DPAPI uses cryptography to do its job. So why SecureString was placed in System.Security rather than in System.Security.Cryptography?
In my view of it, if cryptography wasn't used in the implementation, then SecureString would provide only minimum benefit of convenience above the pre-existing StringBuilder.
There's also the contrast between "Secure" vs. "Protected" in SecureString and ProtectedMemory class names, I'm not sure how that might be motivated either.
I just found out that
SecureString
does not encrypt the internal storage in .NET Core; thatSecureString
should not be used in new development (DE0001); and that unless I get the string out ofSecureString
viaMarshal.SecureStringToGlobalAllocUnicode
, I'll still always have the unecrypted string dancing on generation 0 of the managed heap eventually, even in case of .NET. Therefore it is fair to say thatSecureString
basically was just a decoratedStringBuffer
and the "security" alluded to by its class name had more to do with mutability than with cryptography.Damien_The_Unbeliever in his no longer visible comment showed that this aligns with how the two classes have been documented (all the time since .NET 2 where they were both added):