-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Securly overwrite BigInteger #168
Comments
Wouldn't assigning null to the BigInteger after operations be enough? |
I am using BigInteger to store key material and other sensitive data (so is bc-sharp). If I just derefernce the BigIntegers the garbage collector will mark the memory as free, but wont zero/overwrite it until it is allocated again ( if I understand that correctly). This means in theory it could be there indefinitely and since memory leaks exist, I would be a lot happier if I could just zero the underlying byte array |
@schoenbornl you are right. Setting a reference type to If you think about it, the sensitive data must be revealed in memory at some point in time in order to be used. An attacker would have the opportunity to read it anyways. The promise by GC that the data would be overwritten sometime in the future is enough, at least for my purposes. |
@sorashi, bouncycastle big integer implementation (which I feel the issue author is referring to) is a class not a struct. |
ok, my fault |
Interesting quote on the
The purpose of RSA is to secure information during transmit, therefore the key privacy at the end-points is not so strict in most cases (there's usually symmetric encryption, but the key must get revealed when it's being used). |
Just faced the same problem. Generally, .NET apps must store secrets in Secrets should be stored in an unmanaged memory (because GC does not have to zero out the data during mark-sweep phase), and cleared out using SecureZeroMemory or a similar platform-specific function before being deallocated. Also, there should be a way to explicitly deallocate a secret as soon, as it is not needed anymore. |
SecureString doesn't really work and is probably being deprecated (dotnet/runtime#30612) but netcore should be getting support for safely zeroing secrets without pinning/unmanaged memory (dotnet/runtime#10480) |
I wanted to do some crypto with BigIntegers, but the it doesn't seem to be possible to delete them or securely overwrite them. Could you add such a method?
The text was updated successfully, but these errors were encountered: