Skip to content
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

KEM PrivateKeyParameters (e.g. FrodoPrivateKeyParameters) not disposable #486

Open
arnomi opened this issue Oct 1, 2023 · 1 comment
Open

Comments

@arnomi
Copy link

arnomi commented Oct 1, 2023

I am trying to dispose a private KEM key after usage so that it does not linger around in managed memory. All PrivateKeyParameters of KEMs (e.g. FrodoPrivateKeyParameters) seem not to be disposable. Since they also make copies of the provided key material in their constructors it seems impossible to wipe the keys from managed memory. I am wondering whether I am overlooking something or whether there is an oversight that these should implement IDisposable.

@nd1012
Copy link

nd1012 commented Oct 15, 2023

I have the same "problem" and solved it (with an emergency solution) using reflection to access the private fields and wipe the byte array contents. I've seen Bouncy Castle code to wipe keys somewhere, but it seems not to be a common task. Also IDisposable is hard to find. If I could only access the key arrays somehow without reflection - or there would be at last a Clear method - it'd really help a lot... Making everything disposable instead would be a huge breaking change in the current API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants